rtpbasepayload: change SSRC on GstRTPCollision event

Change our SSRC and update the caps when we receive a GstRTPCollision
event from downstream.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=711560
This commit is contained in:
Julien Isorce 2013-12-12 13:42:59 +01:00 committed by Wim Taymans
parent 6f614e1225
commit 71788c1432

View file

@ -430,13 +430,52 @@ gst_rtp_base_payload_src_event_default (GstRTPBasePayload * rtpbasepayload,
GstEvent * event) GstEvent * event)
{ {
GstObject *parent = GST_OBJECT_CAST (rtpbasepayload); GstObject *parent = GST_OBJECT_CAST (rtpbasepayload);
gboolean res = FALSE; gboolean res = TRUE, forward = TRUE;
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CUSTOM_UPSTREAM:
{
const GstStructure *s = gst_event_get_structure (event);
if (gst_structure_has_name (s, "GstRTPCollision")) {
guint ssrc = 0;
if (!gst_structure_get_uint (s, "ssrc", &ssrc))
ssrc = -1;
GST_DEBUG_OBJECT (rtpbasepayload, "collided ssrc: %" G_GUINT32_FORMAT,
ssrc);
/* choose another ssrc for our stream */
if (ssrc == rtpbasepayload->current_ssrc) {
GstCaps *caps;
do {
rtpbasepayload->current_ssrc = g_random_int ();
} while (ssrc == rtpbasepayload->current_ssrc);
caps = gst_pad_get_current_caps (rtpbasepayload->srcpad);
caps = gst_caps_make_writable (caps);
gst_caps_set_simple (caps,
"ssrc", G_TYPE_UINT, rtpbasepayload->current_ssrc, NULL);
res = gst_pad_set_caps (rtpbasepayload->srcpad, caps);
gst_caps_unref (caps);
/* the event was for us */
forward = FALSE;
}
}
break;
}
default: default:
res = gst_pad_event_default (rtpbasepayload->srcpad, parent, event);
break; break;
} }
if (forward)
res = gst_pad_event_default (rtpbasepayload->srcpad, parent, event);
else
gst_event_unref (event);
return res; return res;
} }