0

Established: I am currently streaming data packets(.mp3 files) from source(server) to sink(client A) using gstreamer over RTP. This thing is pretty easy and I am successfully able to stream music over a network from server to device.

Requirement: Now, I want to retransmit the data packets in real time(or atleast as close to real time as possible) from the client A to say any other client B . Hence the control would still remain with client A and only the music would now be actually streaming with client B.

What is the most optimum way to do such a thing.

Techie
  • 44,706
  • 42
  • 157
  • 243
user1795516
  • 451
  • 1
  • 8
  • 18

2 Answers2

1

Assuming you want to quickly try this. The ideal way is to setup a rtsp server on client A which can forward client B data. If you want to do it your way here is one way to do it:

If you have a player in client B which can play a rtp stream given a sdp file this is what you can do: Create a copy of the sdp you get in client A. Give it to client B via some path. [Say tcp socket that both agree to communicate upon]

Stream a copy of what you get in client A to client B as well.

You need to change port numbers in sdp to be the one available at client B [This what RTSP negotiation does]. If the client B can tell client A the port number before it gets the SDP, great, you can then set the port number in the sdp correctly, give it to client B and then send a copy of he stream to client B. you are done.

av501
  • 6,645
  • 2
  • 23
  • 34
  • I am trying the same thing. So my server side code is: gst-launch-0.10 filesrc location=/home/kuber/Downloads/brownrang.mp3 ! mad ! audioconvert ! audio/x-raw-int,channels=1,depth=16,width=16,rate=44100 ! rtpL16pay ! udpsink host=localhost port=5000 My client side code, where I am trying to save the stream is: gst-launch rtspsrc location=rtsp://localhost:5000/brownrang.mp3 name=d d. ! rtpmp4adepay ! qtmux name=mux ! filesink location=~/Desktop/sync-rtsp.mp4 sync=true name=f. A .mp4 file is being saved on the location but its empty. It is not being populated by data and I am not sure why? – user1795516 Nov 13 '12 at 05:31
  • That is because your server is a pure rtp/udp sink which not a rtsp sink. While you are trying to read from a rtsp source. Change your source to updsrc and give the correct caps after it. – av501 Nov 13 '12 at 05:57
  • Can you give me the exact command line you are talking about for server? – user1795516 Nov 19 '12 at 16:56
  • Your server is fine. Change your receiver to udpsrc ! capsfilter caps= ! . Your server is sending on a udp port. Your reciever must also recieve from a udp port. Since your sending is not a rtsp server, your recieving cannot be one. If you want rtsp server to send, then take a look at gst-rtsp-server module on gstreamer.net – av501 Nov 24 '12 at 14:54
  • I did the same thing, and I am recieving the mp3 file but the size of the mp3 file is now about 15 mb long(reciever side) whereas the source is sending only 4 mb file. I suspect its the headers and other data that is being sent along with the mp3 which renders the mp3 useless. Any pointers on how to just dl the mp3 and ignore the rest? – user1795516 Nov 29 '12 at 21:04
  • You should remove mad and audio convert and send using rtpmpapay to payload your mp3. You are decoding the mp3 before sending it hence it is bloated. If you want to send mp3 and receive mp3 then don't decode. If you want to send pcm data then you need to receive pcm data and then re-encode it to mp3. – av501 Nov 30 '12 at 03:05
  • Yes, I tried both the techniques and it worked. Thank you! But I had one last question as to : When we are saving the stream then we are not using mad! audioconvert! but while streaming mp3 from client 2 to client 3 we have to use the normal audioconvert to stream data. Why the difference? – user1795516 Dec 03 '12 at 18:00
  • Audio convert is only needed for raw data. Not for mp3 encoded data. So if you are sending raw data you may need to use audio convert to transform to the correct payload for the pcm payloader. – av501 Dec 03 '12 at 19:42
  • I had another question regarding video streaming using gstreamer, I have set up another post for that. Could you please answer that question as well? @av501 The link to that question is : http://stackoverflow.com/q/13871933/1795516 – user1795516 Dec 14 '12 at 18:08
0

you also uset RTP over TCP. So it would be easy for you, as no changes require at RTP level. You need to pass packet to RTSP instead of sending directly over UDP socket. everything will be handle by RTSP. If you are using RTP as a stand alone ,accoeding to rfc 3550 , its not a part of RTP Still you wan't to do so, then you are not following standard way of RTP implementation.

  • I am trying the same thing. So my server side code is: gst-launch-0.10 filesrc location=/home/kuber/Downloads/brownrang.mp3 ! mad ! audioconvert ! audio/x-raw-int,channels=1,depth=16,width=16,rate=44100 ! rtpL16pay ! udpsink host=localhost port=5000 My client side code, where I am trying to save the stream is: gst-launch rtspsrc location=rtsp://localhost:5000/brownrang.mp3 name=d d. ! rtpmp4adepay ! qtmux name=mux ! filesink location=~/Desktop/sync-rtsp.mp4 sync=true name=f. A .mp4 file is being saved on the location but its empty. It is not being populated by data and I am not sure why? – user1795516 Nov 13 '12 at 05:36
  • over here ypu are streaming using UDP protocol and try to receive using TCP, then how can you? It is not possible at all. when you dealing with network client-server must run on same protocol. – Tushar Kanani Nov 13 '12 at 10:15
  • you can also try using UDP src and UDP sink. if you are able to stream , then later try with TCP (using RTSP) – Tushar Kanani Nov 13 '12 at 10:16