send a multicast audio in rtsp using libstreaming

2020-04-08 06:16发布

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.

The library source is over here: https://github.com/fyhertz/libstreaming

my current code is:

    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));

1条回答
The star\"
2楼-- · 2020-04-08 06:17

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");

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.

查看更多
登录 后发表回答