代码一次只为一个用户流式传输。任何人都可以帮助我同时在多个系统中播放流(将其转换为多播或广播)。 提前致谢。
库源在这里: 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/26405539/