gpt4 book ai didi

android - 使用 libstreaming 在 rtsp 中发送多播音频以从 android 设备上传

转载 作者:太空宇宙 更新时间:2023-11-03 11:10:18 32 4
gpt4 key购买 nike

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

库源在这里: 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));

最佳答案

我查看了 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 - 使用 libstreaming 在 rtsp 中发送多播音频以从 android 设备上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26421465/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com