From 3fe87f7eab5982f2326e95d868d01fb1bc7a00f5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 29 Dec 2008 14:21:47 +0000 Subject: [PATCH] gst/rtpmanager/rtpsource.*: When no payload was specified on the caps but there was a clock-rate, assume the clock-ra... Original commit message from CVS: * gst/rtpmanager/rtpsource.c: (rtp_source_init), (rtp_source_update_caps), (get_clock_rate): * gst/rtpmanager/rtpsource.h: When no payload was specified on the caps but there was a clock-rate, assume the clock-rate corresponds to the first payload type found in the RTP packets. Fixes #565509. --- gst/rtpmanager/rtpsource.c | 20 +++++++++++++++++--- gst/rtpmanager/rtpsource.h | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/gst/rtpmanager/rtpsource.c b/gst/rtpmanager/rtpsource.c index 5aff005..4fae901 100644 --- a/gst/rtpmanager/rtpsource.c +++ b/gst/rtpmanager/rtpsource.c @@ -156,7 +156,7 @@ rtp_source_init (RTPSource * src) src->internal = FALSE; src->probation = RTP_DEFAULT_PROBATION; - src->payload = 0; + src->payload = -1; src->clock_rate = -1; src->packets = g_queue_new (); src->seqnum_base = -1; @@ -575,13 +575,22 @@ rtp_source_update_caps (RTPSource * src, GstCaps * caps) if (gst_structure_get_int (s, "payload", &ival)) src->payload = ival; + else + src->payload = -1; GST_DEBUG ("got payload %d", src->payload); - gst_structure_get_int (s, "clock-rate", &src->clock_rate); + if (gst_structure_get_int (s, "clock-rate", &ival)) + src->clock_rate = ival; + else + src->clock_rate = -1; + GST_DEBUG ("got clock-rate %d", src->clock_rate); if (gst_structure_get_uint (s, "seqnum-base", &val)) src->seqnum_base = val; + else + src->seqnum_base = -1; + GST_DEBUG ("got seqnum-base %" G_GINT32_FORMAT, src->seqnum_base); gst_caps_replace (&src->caps, caps); @@ -776,7 +785,12 @@ push_packet (RTPSource * src, GstBuffer * buffer) static gint get_clock_rate (RTPSource * src, guint8 payload) { - if (payload != src->payload) { + if (src->payload == -1) { + /* first payload received, nothing was in the caps, lock on to this payload */ + src->payload = payload; + GST_DEBUG ("first payload %d", payload); + } else if (payload != src->payload) { + /* we have a different payload than before, reset the clock-rate */ GST_DEBUG ("new payload %d", payload); src->payload = payload; src->clock_rate = -1; diff --git a/gst/rtpmanager/rtpsource.h b/gst/rtpmanager/rtpsource.h index 0353a58..a44ac1c 100644 --- a/gst/rtpmanager/rtpsource.h +++ b/gst/rtpmanager/rtpsource.h @@ -128,7 +128,7 @@ struct _RTPSource { gboolean have_rtcp_from; GstNetAddress rtcp_from; - guint8 payload; + gint payload; GstCaps *caps; gint clock_rate; gint32 seqnum_base; -- 2.7.4