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

标签 android audio-streaming rtsp

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

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

相关文章:

android - 每 x 分钟通过 android 设备将更新的 GPS 坐标自动发送到 Web 服务器

android - 请解释一下 Android 中的 Context 类

android - SHOUTcast广播流媒体不适用于Kitkat

python - 使用Python进行实时流传输

windows - 将 rtsp-stream 转换为 http 流

android - java.util.zip.ZipException : duplicate entry: android/support/annotation/ColorRes. 类

android - 让 Android 像 Android Spinner 一样对待 HTML Select?

python - 如何使用 pydub 库从 mp3 文件生成带有 G.711alaw 的 wav?

c++ - Wav文件噪声去除

android - 在 Android VideoView 上绘制叠加层(HUD)?