rtpjitterbuffer: Ensure to not take caps with the wrong pt for getting the clock-rate

Especially the caps on the pad might be out of date, and the new caps would be
provided for the current pt via the request-pt-map signal.

https://bugzilla.gnome.org/show_bug.cgi?id=765689
This commit is contained in:
Sebastian Dröge 2016-04-27 20:33:38 +03:00
parent d24e68719b
commit 608b4ee53c

View file

@ -1258,11 +1258,12 @@ gst_rtp_jitter_buffer_getcaps (GstPad * pad, GstCaps * filter)
static gboolean static gboolean
gst_jitter_buffer_sink_parse_caps (GstRtpJitterBuffer * jitterbuffer, gst_jitter_buffer_sink_parse_caps (GstRtpJitterBuffer * jitterbuffer,
GstCaps * caps) GstCaps * caps, gint pt)
{ {
GstRtpJitterBufferPrivate *priv; GstRtpJitterBufferPrivate *priv;
GstStructure *caps_struct; GstStructure *caps_struct;
guint val; guint val;
gint payload = -1;
GstClockTime tval; GstClockTime tval;
const gchar *ts_refclk, *mediaclk; const gchar *ts_refclk, *mediaclk;
@ -1271,7 +1272,19 @@ gst_jitter_buffer_sink_parse_caps (GstRtpJitterBuffer * jitterbuffer,
/* first parse the caps */ /* first parse the caps */
caps_struct = gst_caps_get_structure (caps, 0); caps_struct = gst_caps_get_structure (caps, 0);
GST_DEBUG_OBJECT (jitterbuffer, "got caps"); GST_DEBUG_OBJECT (jitterbuffer, "got caps %" GST_PTR_FORMAT, caps);
if (gst_structure_get_int (caps_struct, "payload", &payload) && pt != -1
&& payload != pt) {
GST_ERROR_OBJECT (jitterbuffer,
"Got caps with wrong payload type (got %d, expected %d)", payload, pt);
return FALSE;
}
if (payload != -1) {
GST_DEBUG_OBJECT (jitterbuffer, "Got payload type %d", payload);
priv->last_pt = payload;
}
/* we need a clock-rate to convert the rtp timestamps to GStreamer time and to /* we need a clock-rate to convert the rtp timestamps to GStreamer time and to
* measure the amount of data in the buffer */ * measure the amount of data in the buffer */
@ -1643,7 +1656,7 @@ queue_event (GstRtpJitterBuffer * jitterbuffer, GstEvent * event)
GstCaps *caps; GstCaps *caps;
gst_event_parse_caps (event, &caps); gst_event_parse_caps (event, &caps);
gst_jitter_buffer_sink_parse_caps (jitterbuffer, caps); gst_jitter_buffer_sink_parse_caps (jitterbuffer, caps, -1);
break; break;
} }
case GST_EVENT_SEGMENT: case GST_EVENT_SEGMENT:
@ -1815,7 +1828,7 @@ gst_rtp_jitter_buffer_get_clock_rate (GstRtpJitterBuffer * jitterbuffer,
if (!caps) if (!caps)
goto no_caps; goto no_caps;
res = gst_jitter_buffer_sink_parse_caps (jitterbuffer, caps); res = gst_jitter_buffer_sink_parse_caps (jitterbuffer, caps, pt);
gst_caps_unref (caps); gst_caps_unref (caps);
if (G_UNLIKELY (!res)) if (G_UNLIKELY (!res))
@ -2582,7 +2595,7 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstObject * parent,
/* Try to get the clock-rate from the caps first if we can. If there are no /* Try to get the clock-rate from the caps first if we can. If there are no
* caps we must fire the signal to get the clock-rate. */ * caps we must fire the signal to get the clock-rate. */
if ((caps = gst_pad_get_current_caps (pad))) { if ((caps = gst_pad_get_current_caps (pad))) {
gst_jitter_buffer_sink_parse_caps (jitterbuffer, caps); gst_jitter_buffer_sink_parse_caps (jitterbuffer, caps, pt);
gst_caps_unref (caps); gst_caps_unref (caps);
} }
} }