【问题标题】:send a multicast audio in rtsp using libstreaming for upstreaming from an android device使用 libstreaming 在 rtsp 中发送多播音频以从 android 设备上行
【发布时间】:2023-03-29 11:03:01
【问题描述】:

代码一次只为一位用户流式传输。谁能帮助我同时在多个系统中播放流(将其转换为多播或广播)。 提前致谢。

库源在这里: https://github.com/fyhertz/libstreaming

我当前的代码是:

    mSurfaceView = (net.majorkernelpanic.streaming.gl.SurfaceView) findViewById(R.id.surface);

    // Sets the port of the RTSP server to 1234
    Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
    editor.putString(RtspServer.KEY_PORT, String.valueOf(5060));                                                            // audio port num               
    editor.commit();

    // Configures the SessionBuilde
    SessionBuilder.getInstance()
    .setSurfaceView(mSurfaceView)
    .setPreviewOrientation(90)
    .setContext(getApplicationContext())
    .setAudioEncoder(SessionBuilder.AUDIO_AAC)
    .setVideoEncoder(SessionBuilder.VIDEO_NONE);


    MainActivity.this.startService(new Intent(MainActivity.this,RtspServer.class));

【问题讨论】:

    标签: android audio-streaming rtsp


    【解决方案1】:

    我查看了 github 上的代码,似乎您只需要为 SessionBuilder 类指定多播地址,然后底层 RTSP 服务器和 RTP 传输应该处理所有事情(至少 RTSP 响应似乎有代码可以生成正确的运输说明)。所以我想在你的SessionBuilder 配置中添加一个setDestination 调用应该没问题(用你需要的地址替换232.0.1.2):

    // Configures the SessionBuilde
    SessionBuilder.getInstance()
    .setSurfaceView(mSurfaceView)
    .setPreviewOrientation(90)
    .setContext(getApplicationContext())
    .setAudioEncoder(SessionBuilder.AUDIO_AAC)
    .setVideoEncoder(SessionBuilder.VIDEO_NONE)
    .setDestination("232.0.1.2");
    

    客户端仍然会通过它的地址连接到 RTSP 服务器,但实际的 RTP 流应该是单一的并且在所有客户端之间共享。

    【讨论】:

    • 你好。我不明白目标地址对应什么。它似乎不是 Android 服务器的地址,也不是客户端 IP 的列表。那么你能解释一下它是什么,如何定义它,以及是否必须有一个软件在这个地址监听?谢谢!
    • 嗯,这是一个服务器使用的普通多播地址。由于多播是 UDP,所以你不需要监听,只需调用 C 中的 recfrom 等无连接接收函数,而服务器只调用 sendto
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多