使用 libstreaming 在 rtsp 中发送多播音频以从 android 设备上行 [英] send a multicast audio in rtsp using libstreaming for upstreaming from an android device

查看:30
本文介绍了使用 libstreaming 在 rtsp 中发送多播音频以从 android 设备上行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

The code is only streaming for one user at a time. Can anyone help me to play the stream in more than one system at the same time(convert it to multicast or broadcast). Thanks in advance.

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

I looked at the code at github and seems that you only need to specify the multicast address to the SessionBuilder class and then the underlying RTSP server and RTP transport should handle everything (at least the RTSP responses seem have code to produce correct transport descriptions). So I guess adding a setDestination call to your SessionBuilder configuration should be ok (replace the 232.0.1.2 with the address you need):

// 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 流应该是单一的并在所有客户端之间共享.

The clients will still connect to the RTSP server through it's address but the actual RTP stream should be single and shared among all the clients.

这篇关于使用 libstreaming 在 rtsp 中发送多播音频以从 android 设备上行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆