godka / kurento-rtmp

demo: webrtc to rtmp via kurento
Apache License 2.0
201 stars 60 forks source link

How to have two simultaneous sessions ? #4

Closed nishachar closed 6 years ago

nishachar commented 6 years ago

first of all awesome work !!! Thanks ffor making it public.

My issue is that when i am trying to have two simultaneous sessions, ffmpeg throws error -

From ffmpeg:
'[udp @ 0x14fa9a0] bind failed: Address already in use
/opt/conference/kurento-rtmp/127.0.0.1_55001.sdp: Invalid data found when processing input

Requesting help in resolving this. I already tried changing the audio port in sdp file dynamically like video. It did not help.

godka commented 6 years ago

thx for your interest,please fine the reply inline :) Q:how to have two simultaneous sessions? A: what is simultaneous sessions?you mean mix two rtp sessions into one session? the correct process for establishing rtp-rtmp bridge is:

create rtp protocol -> save sdp file -> ffmpeg read sdp file -> transcode to rtmp

in server.js,you will find this code

                        console.log('my session id:', sessionId);
                        var streamPort = 55000 + session_index;
                        session_index++;    //change to next port
                        var streamIp = '127.0.0.1';//Test ip

According to the process,the session-index should be cumulative while another session requests. if you wanna mix two rtp in one session,try to fix this code.

nishachar commented 6 years ago

This approach of incrementing the session index by one and assigning it to port is not working. You can test this bug on the test link that u have given. I have however figured out the problem. FFMPEG blocks two ports and not one when you run a sdp file. One is the port mentioned in the sdp and the port immidiately after it. Thats why the next incremented port used un second SDP gave "Address already in use" error. I have fixed the error and attaching the updated server.js with this comment. If you find it ok, please commit it. ( please remove the .txt from the file extention ) Once again, awesome work

server.js.txt

nishachar commented 6 years ago

And also if i may very humbly suggest you to put up a licence file in your code base.

godka commented 6 years ago

good job bro,I've commit your code and add apache license. thx for your interest again!