# broadcasting a vp8 rtp stream from gstreamer

**URL:** <https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93>\
**Category:** Integration\
**Created:** [June 16, 2019, 8:54am UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93 "2019-06-16T08:54:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![koyaya](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/koyaya/32/46_2.png) [@koyaya](https://mediasoup.discourse.group/u/koyaya)\
**Post date:** [June 16, 2019, 8:54am UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/1 "2019-06-16T08:54:47Z")

</div>

Hi community guys,

i failed to find a way to stream a vp8 encoded raw rtp stream from gst-launch to media soup to have it display the video (with the demo application)

i am looking for something equivalent to the following ffmpeg command

ffmpeg  
-re   
-v info   
-stream\_loop -1   
-rtsp\_transport tcp   
-i {MEDIA\_FILE} \ -map 0:v:0 \ -pix\_fmt yuv420p -c:v libvpx -b:v 1000k -deadline realtime -cpu-used 4 \ -f tee \ "select=v:f=rtp:ssrc={VIDEO\_SSRC}:payload\_type={VIDEO\_PT}]rtp://{transportIp}:${transportPort"

the transport is defined as rtpParameters:="{ “codecs”: [{ “mimeType”:“video/vp8”, “payloadType”:{VIDEO\_PT}, \"clockRate\":90000 }], \"encodings\": [{ \"ssrc\":{VIDEO\_SSRC} }] }" \

the trivial pipeline below doesnt work

! decodebin   
! vp8enc ! rtpvp8pay pt={VIDEO\_PT} ssrc={VIDEO\_SSRC}   
! udpsink host={transportIp} port={transportPort}

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [June 16, 2019, 7:26pm UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/2 "2019-06-16T19:26:23Z")

</div>

Definitely we are not experts in FFmpeg or GStreamer, so we refer to the documentation and forums of those projects:

- [FFmpeg documentation](https://ffmpeg.org/documentation.html)
- [GStreamer documentation](https://gstreamer.freedesktop.org/documentation/)

---

<div class="post-metadata">

**Author:** ![vpalmisano](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/vpalmisano/32/43_2.png) [@vpalmisano](https://mediasoup.discourse.group/u/vpalmisano)\
**Post date:** [June 17, 2019, 7:13am UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/3 "2019-06-17T07:13:30Z")

</div>

When using vp8/vp9, you should set the rtpvp{8,9}pay picture-id-mode={1,2} parameter. Moreover, you should use the rtpbin element ([https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good/html/gst-plugins-good-plugins-rtpbin.html](https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good/html/gst-plugins-good-plugins-rtpbin.html)) in order to handle retransmissions and keyframe requests.

---

<div class="post-metadata">

**Author:** ![vpalmisano](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/vpalmisano/32/43_2.png) [@vpalmisano](https://mediasoup.discourse.group/u/vpalmisano)\
**Post date:** [June 17, 2019, 8:30am UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/4 "2019-06-17T08:30:18Z")

</div>

@ibc investigating the rtcp feedbacks received by gstreamer, a found that when mediasoup sends a PLI request, gstreamer gets a RTCP packet with “sender\_ssrc” equals to “0”, and so it fails to reply to the request.

In particular, the received RTCP packet has:

- type = GST\_RTCP\_TYPE\_PSFB (Payload-specific feedback)
- fbtype = GST\_RTCP\_PSFB\_TYPE\_PLI
- source\_ssrc = 0

Full received RTCP buffer: ‘\x81\xce\x00\x02\x00\x00\x00\x00\x00\x98\x96\x80’

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [June 17, 2019, 8:59am UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/5 "2019-06-17T08:59:04Z")

</div>

Can you put a packet.Dump() after the PLI packet is created here?

> <https://github.com/versatica/mediasoup/blob/v3/worker/src/RTC/RtpStreamRecv.cpp>

We pass the media SSRC to it.

---

<div class="post-metadata">

**Author:** ![jmillan](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/jmillan/32/9_2.png) [@jmillan](https://mediasoup.discourse.group/u/jmillan)\
**Post date:** [June 17, 2019, 9:11am UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/6 "2019-06-17T09:11:42Z")

</div>

@vpalmisano refers to the `source ssrc`, which is **0** because the sender of the RTCP is not RTP source by any means. It must be set to **0** since mediasoup is only receiving RTP from that stream, it is not the typical bidirectional **sendrecv** SDP formed stream.

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [June 17, 2019, 9:12am UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/7 "2019-06-17T09:12:19Z")

</div>

This is what I see doing it:

```auto
mediasoup:worker[pid:82416] RTC::RtpStreamRecv::RequestKeyFrame() | sending PLI [ssrc:4067265976]
RTC::RTCP::FeedbackPsPli::Dump() | <FeedbackPsPliPacket>
RTC::RTCP::Feedback::Dump() | sender ssrc : 0
RTC::RTCP::Feedback::Dump() | media ssrc : 4067265976
RTC::RTCP::Feedback::Dump() | size : 12
RTC::RTCP::FeedbackPsPli::Dump() | </FeedbackPsPliPacket>

```

Clearly the PLI has a `media ssrc` field with the SSRC of the RTP stream. If GStreamer is expecting something different from 0 in the `sender ssrc` then it must be a bug in GStreamer as obviously we cannot put any other value on it.

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [June 17, 2019, 9:14am UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/8 "2019-06-17T09:14:52Z")

</div>

Just to confirm, @vpalmisano can you modify [this line](https://github.com/versatica/mediasoup/blob/v3/worker/src/RTC/RtpStreamRecv.cpp#L507) in mediasoup as follows?

```auto
- RTC::RTCP::FeedbackPsPliPacket packet(0, GetSsrc());
+ RTC::RTCP::FeedbackPsPliPacket packet(GetSsrc(), GetSsrc());

```

and see what happens? Even if it works, GStreamer is wrong about it.

---

<div class="post-metadata">

**Author:** ![vpalmisano](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/vpalmisano/32/43_2.png) [@vpalmisano](https://mediasoup.discourse.group/u/vpalmisano)\
**Post date:** [June 17, 2019, 9:18am UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/9 "2019-06-17T09:18:26Z")

</div>

I have modified the received RTCP buffer received on UDP by GStreamer setting the SSRC sent in the “encodings” dict, now GStreamer is able to handle the PLI request.  
If this is a GStremer bug, I can use this approach without modifications of mediasoup.

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [June 17, 2019, 9:22am UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/10 "2019-06-17T09:22:39Z")

</div>

This seems an important issue and we are pretty sure we are doing it good in mediasoup. [This](https://github.com/GStreamer/gst-plugins-good/blob/master/gst/rtpmanager/rtpsession.c#L2698) may be related code in GStreamer. May you please report it in the GStreamer project?

---

<div class="post-metadata">

**Author:** ![vpalmisano](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/vpalmisano/32/43_2.png) [@vpalmisano](https://mediasoup.discourse.group/u/vpalmisano)\
**Post date:** [June 17, 2019, 9:25am UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/11 "2019-06-17T09:25:36Z")

</div>

I’m looking exactly at the same code. Maybe because it can handle different ssrc RTCP reports on the same UDP connection?

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [June 17, 2019, 9:36am UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/12 "2019-06-17T09:36:03Z")

</div>

I don’t know if GStreamer can send different RTP streams on the same UDP connection (BUNDLE), probably it should be able to do it. And if so it must check the `media ssrc` in received PLIs.

I insist that mediasoup is correctly setting the `media ssrc` field in PLI packets. `sender ssrc` is another story and it’s 0 because there is no bidirectional RTP sending.

> I have modified the received RTCP buffer received on UDP by GStreamer setting the SSRC sent in the “encodings” dict

So you are basically mangling the received PLI packet before GStreamer processes it. What are you exactly overriding in the PLI packet? the `sender ssrc`?

---

<div class="post-metadata">

**Author:** ![vpalmisano](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/vpalmisano/32/43_2.png) [@vpalmisano](https://mediasoup.discourse.group/u/vpalmisano)\
**Post date:** [June 17, 2019, 9:38am UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/13 "2019-06-17T09:38:23Z")

</div>

> [@ibc](#):
>
> So you are basically mangling the received PLI packet before GStreamer processes it. What are you exactly overriding in the PLI packet? the `sender ssrc` ?

Yes, settings the same ssrc sent at the producer creation.

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [June 17, 2019, 10:07am UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/14 "2019-06-17T10:07:19Z")

</div>

Will you report an issue in Gstreamer? I’d like to have that as a workaround ☹

BTW Gstreamer seems to [look first](https://github.com/GStreamer/gst-plugins-good/blob/master/gst/rtpmanager/rtpsession.c#L2698) for “sender ssrc” and, if no session is found then it looks for “media ssrc”. May be there is an issue in Gstreamer when reading those ssrcs (network order, etc)? Why is it finding a session by looking to “sender ssrc = 0”?

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [June 17, 2019, 12:48pm UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/15 "2019-06-17T12:48:53Z")

</div>

In order to find the exact bug in Gstreamer, @vpalmisano may you please try [this](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/8)?

---

<div class="post-metadata">

**Author:** ![vpalmisano](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/vpalmisano/32/43_2.png) [@vpalmisano](https://mediasoup.discourse.group/u/vpalmisano)\
**Post date:** [June 17, 2019, 3:56pm UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/16 "2019-06-17T15:56:49Z")

</div>

I will try tomorrow. If the effect is the same of mangling the packet content, I think the result will be the same.

---

<div class="post-metadata">

**Author:** ![vpalmisano](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/vpalmisano/32/43_2.png) [@vpalmisano](https://mediasoup.discourse.group/u/vpalmisano)\
**Post date:** [June 17, 2019, 3:58pm UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/17 "2019-06-17T15:58:09Z")

</div>

Question: when using PipeTransports, the PLI requests are sent to the pipe origin producer?

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [June 17, 2019, 4:09pm UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/18 "2019-06-17T16:09:29Z")

</div>

> [@vpalmisano](#):
>
> If the effect is the same of mangling the packet content, I think the result will be the same.

GStreamer first looks at the `sender ssrc`. If it gets NULL then it tries with `media ssrc`. So, if my proposal makes it work it means that, somehow, GStreamer is getting “something” when looking for `sender ssrc = 0`, which is crazy.

BTW: when you did the UDP packet mangling to set `sender ssrc`, did you properly write the ssrc in network order?

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [June 17, 2019, 4:12pm UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/19 "2019-06-17T16:12:19Z")

</div>

Yes. The flow is:

- Consumer2 (in a WebRtcTransport in router2) requests a key frame to its Producer in router2.
- Producer in router2 generates a PLI or FIR and sends it over its PipeTransport which communicates with router1.
- The PLI/FIR reaches router1’s PipeTransport which delivers the PLI/FIR to the PipeConsumer in router1.
- The PipeConsumer in router1 requests a keyframe to its associated Producer in router1.
- The Producer in router1 sends a PLI or FIR to the producing endpoint.

---

<div class="post-metadata">

**Author:** ![vpalmisano](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/vpalmisano/32/43_2.png) [@vpalmisano](https://mediasoup.discourse.group/u/vpalmisano)\
**Post date:** [June 17, 2019, 4:15pm UTC](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93/20 "2019-06-17T16:15:57Z")

</div>

I need to update my GStreamer to the latest version. The stable version on Ubuntu is 1.14.1 and there is no media src reference in the rtp\_session\_process\_pli function ([https://github.com/GStreamer/gst-plugins-good/blob/1.14.1/gst/rtpmanager/rtpsession.c#L2606](https://github.com/GStreamer/gst-plugins-good/blob/1.14.1/gst/rtpmanager/rtpsession.c#L2606)).

Yes, I write the ssrc in network order.

[Next page](https://mediasoup.discourse.group/t/broadcasting-a-vp8-rtp-stream-from-gstreamer/93.md?page=2)
