RTP & RTCP restream using rtpbin.

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

RTP & RTCP restream using rtpbin.

stproj
Greetings,

I'm trying to built a streaming application that involves streaming and restreaming to different machines the same source and daisy chain them.

What i want to do for starters, is to make rtpbin both a receiver and a transmitter of an rtp stream, and its respective rtcp streams. Below, im providing the part where I'm trying to link rtpsrc to rtpbin and rtpbin to rtpsink, but it doesn't work (can't link rtpbin to rtpsink). If u have any suggestion on how should i move pls share the knowledge!!

Thank you in advance,
S.



  /* the rtpbin element */
  rtpbin = gst_element_factory_make ("rtpbin", "rtpbin");
  g_assert (rtpbin);
 
  gst_bin_add (GST_BIN (pipeline), rtpbin);
 
  /* now link all to the rtpbin, start by getting an RTP sinkpad for session 0 */
  srcpad = gst_element_get_static_pad (rtpsrc, "src");
  sinkpad = gst_element_get_request_pad (rtpbin, "recv_rtp_sink_0");
  lres = gst_pad_link (srcpad, sinkpad);
  g_assert (lres == GST_PAD_LINK_OK);
  gst_object_unref (srcpad);

  /* get the RTP srcpad that was created when we requested the sinkpad above and
   * link it to the rtpsink sinkpad*/
  srcpad = gst_element_get_request_pad (rtpbin, "send_rtp_src_0");
  sinkpad = gst_element_get_static_pad (rtpsink, "sink");
  if (gst_pad_link (srcpad,sinkpad) != GST_PAD_LINK_OK)
    g_error ("Failed to link rtpbin to rtpsink");
  gst_object_unref (srcpad);
  gst_object_unref (sinkpad);

Reply | Threaded
Open this post in threaded view
|

Re: RTP & RTCP restream using rtpbin.

Sebastian Dröge-3
On Wed, 2016-10-19 at 05:15 -0700, stproj wrote:

> Greetings,
>
> I'm trying to built a streaming application that involves streaming and
> restreaming to different machines the same source and daisy chain them.
>
> What i want to do for starters, is to make rtpbin both a receiver and a
> transmitter of an rtp stream, and its respective rtcp streams. Below, im
> providing the part where I'm trying to link rtpsrc to rtpbin and rtpbin to
> rtpsink, but it doesn't work (can't link rtpbin to rtpsink). If u have any
> suggestion on how should i move pls share the knowledge!! 
>
> Thank you in advance,
> S.
>
>
>
>   /* the rtpbin element */
>   rtpbin = gst_element_factory_make ("rtpbin", "rtpbin");
>   g_assert (rtpbin);
>   
>   gst_bin_add (GST_BIN (pipeline), rtpbin);
>   
>   /* now link all to the rtpbin, start by getting an RTP sinkpad for session
> 0 */
>   srcpad = gst_element_get_static_pad (rtpsrc, "src");
>   sinkpad = gst_element_get_request_pad (rtpbin, "recv_rtp_sink_0");
>   lres = gst_pad_link (srcpad, sinkpad);
>   g_assert (lres == GST_PAD_LINK_OK);
>   gst_object_unref (srcpad);
>
>   /* get the RTP srcpad that was created when we requested the sinkpad above
> and
>    * link it to the rtpsink sinkpad*/
>   srcpad = gst_element_get_request_pad (rtpbin, "send_rtp_src_0");
>   sinkpad = gst_element_get_static_pad (rtpsink, "sink");
>   if (gst_pad_link (srcpad,sinkpad) != GST_PAD_LINK_OK)
>     g_error ("Failed to link rtpbin to rtpsink");
"send_rtp_src_%u" is a sometimes pad on rtpbin, not a request pad. It
will appear (check the pad-added signal) at some point and then you can
link it.

You probably also want "recv_rtp_src_%u_%u_%u", which is the pad that
is created (also later, see pad-added) from "recv_rtp_sink_%u".

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (949 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: RTP & RTCP restream using rtpbin.

stproj
Sebastian Dröge-3 wrote
On Wed, 2016-10-19 at 05:15 -0700, stproj wrote:
> Greetings,
>
> I'm trying to built a streaming application that involves streaming and
> restreaming to different machines the same source and daisy chain them.
>
> What i want to do for starters, is to make rtpbin both a receiver and a
> transmitter of an rtp stream, and its respective rtcp streams. Below, im
> providing the part where I'm trying to link rtpsrc to rtpbin and rtpbin to
> rtpsink, but it doesn't work (can't link rtpbin to rtpsink). If u have any
> suggestion on how should i move pls share the knowledge!! 
>
> Thank you in advance,
> S.
>
>
>
>   /* the rtpbin element */
>   rtpbin = gst_element_factory_make ("rtpbin", "rtpbin");
>   g_assert (rtpbin);
>   
>   gst_bin_add (GST_BIN (pipeline), rtpbin);
>   
>   /* now link all to the rtpbin, start by getting an RTP sinkpad for session
> 0 */
>   srcpad = gst_element_get_static_pad (rtpsrc, "src");
>   sinkpad = gst_element_get_request_pad (rtpbin, "recv_rtp_sink_0");
>   lres = gst_pad_link (srcpad, sinkpad);
>   g_assert (lres == GST_PAD_LINK_OK);
>   gst_object_unref (srcpad);
>
>   /* get the RTP srcpad that was created when we requested the sinkpad above
> and
>    * link it to the rtpsink sinkpad*/
>   srcpad = gst_element_get_request_pad (rtpbin, "send_rtp_src_0");
>   sinkpad = gst_element_get_static_pad (rtpsink, "sink");
>   if (gst_pad_link (srcpad,sinkpad) != GST_PAD_LINK_OK)
>     g_error ("Failed to link rtpbin to rtpsink");

"send_rtp_src_%u" is a sometimes pad on rtpbin, not a request pad. It
will appear (check the pad-added signal) at some point and then you can
link it.

You probably also want "recv_rtp_src_%u_%u_%u", which is the pad that
is created (also later, see pad-added) from "recv_rtp_sink_%u".

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


signature.asc (949 bytes) <http://gstreamer-devel.966125.n4.nabble.com/attachment/4680135/0/signature.asc>
Hello Sebastian,

 Thank you for your reply. You are right, with on_pad_added_cb i can link rtpbin to rtpsink and relay the rtpstream.

 I now have the same problem with building the rtcp src/sink for this particular session. Do you think that i can rename the new_pad  or should i extract the %u_%u_%u  part from the string in order to make it the same for the rtcpsrcpad & rtcpsinkpads.

Im providing the on_pad_added_cb.

static void
pad_added_cb (GstElement * rtpbin, GstPad * new_pad, GstElement * sink)
{
  GstPad *sinkpad, *srcpad;
  GstPadLinkReturn lres;

  g_print ("new payload on pad: %s\n", GST_PAD_NAME (new_pad));
 
  sinkpad = gst_element_get_static_pad (sink, "sink");
  g_assert (sinkpad);

  lres = gst_pad_link (new_pad, sinkpad);
  g_assert (lres == GST_PAD_LINK_OK);
  gst_object_unref (sinkpad);

}



 

Reply | Threaded
Open this post in threaded view
|

Re: RTP & RTCP restream using rtpbin.

Sebastian Dröge-3
On Thu, 2016-10-20 at 03:14 -0700, stproj wrote:

>
>
> Hello Sebastian,
>
>  Thank you for your reply. You are right, with on_pad_added_cb i can link
> rtpbin to rtpsink and relay the rtpstream. 
>
>  I now have the same problem with building the rtcp src/sink for this
> particular session. Do you think that i can rename the new_pad  or should i
> extract the %u_%u_%u  part from the string in order to make it the same for
> the rtcpsrcpad & rtcpsinkpads. 
It's send_rtcp_src_%u / recv_rtcp_sink_%u. You only provide it with the
same session id that you used when requesting the RTP pad, and then use
that.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (949 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: RTP & RTCP restream using rtpbin.

stproj
Sebastian Dröge-3 wrote
On Thu, 2016-10-20 at 03:14 -0700, stproj wrote:
>
>
> Hello Sebastian,
>
>  Thank you for your reply. You are right, with on_pad_added_cb i can link
> rtpbin to rtpsink and relay the rtpstream. 
>
>  I now have the same problem with building the rtcp src/sink for this
> particular session. Do you think that i can rename the new_pad  or should i
> extract the %u_%u_%u  part from the string in order to make it the same for
> the rtcpsrcpad & rtcpsinkpads. 

It's send_rtcp_src_%u / recv_rtcp_sink_%u. You only provide it with the
same session id that you used when requesting the RTP pad, and then use
that.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


signature.asc (949 bytes) <http://gstreamer-devel.966125.n4.nabble.com/attachment/4680178/0/signature.asc>
Yes this is correct. This is what i'd like to do:

Relay the rtp_stream from recv_rtp_sink_%u pad to send_rtp_src_%u pad but i want to treat it like an entirely new stream.
When i link with the pad added, the newly pad is recv_rtp_src_0 which i find it impossible to attach also the rtcp stream for this particular session,perhaps maybe because it has the same session_id (0). How do you propose i should continue? Any tips would be very helpful.
Reply | Threaded
Open this post in threaded view
|

Re: RTP & RTCP restream using rtpbin.

Sebastian Dröge-3
On Mon, 2016-10-24 at 12:30 -0700, stproj wrote:
>
> Yes this is correct. This is what i'd like to do:
>
> Relay the rtp_stream from recv_rtp_sink_%u pad to send_rtp_src_%u pad but i
> want to treat it like an entirely new stream.
> When i link with the pad added, the newly pad is recv_rtp_src_0 which i find
> it impossible to attach also the rtcp stream for this particular
> session,perhaps maybe because it has the same session_id (0). How do you
> propose i should continue? Any tips would be very helpful. 

You need to use a different session then. Everything in the same
session has the same RTCP, but here you would like to relay and have
separate RTCP.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (949 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: RTP & RTCP restream using rtpbin.

stproj
Yes, this is what i want. As soon as pad-added on recv_rtp_src_0 callback is called, i need to request a send_rtp_sink_1 pad and link the two pads in order to have a proper rtp & rtcp relay. The problem is that i cannot find any info regarding this issue.

Ive keep reading about GstRtpSession but i cannot find any way to configure it through rtpbin. Do you have any suggestion about linking two pads of the same element and accessing rtpsession through rtpbin?

https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-rtpbin.html

Reply | Threaded
Open this post in threaded view
|

Re: RTP & RTCP restream using rtpbin.

Sebastian Dröge-3
On Wed, 2016-11-02 at 15:11 -0700, stproj wrote:
> Yes, this is what i want. As soon as pad-added on recv_rtp_src_0 callback is
> called, i need to request a send_rtp_sink_1 pad and link the two pads in
> order to have a proper rtp & rtcp relay. The problem is that i cannot find
> any info regarding this issue. 

What's missing?

> Ive keep reading about GstRtpSession but i cannot find any way to configure
> it through rtpbin. Do you have any suggestion about linking two pads of the
> same element and accessing rtpsession through rtpbin?

The "get-internal-session" action signal on rtpbin gives you access to
the rtpsession.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (949 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: RTP & RTCP restream using rtpbin.

stproj
I solved the issue i had.

What i was doing wrong is that i was trying to
gst_pad_link (recv_rtp_src_0, send_rtp_sink_1) directly, which felt like a bad idea from the beginning, like 'short-circuiting' the rtpbin. After some thought i decided to change the topology and instead of linking directly i am now linking recv_rtp_src_0 to the 'relay branch' and then i drive the 'relay branch' to send_rtp_sink_1.

The result is that i have a proper rtp-rtcp connection on both end of rtp-bin with a little warning of loop on pipeline, which is obvious and normal. :)