From: Aleix Conchillo Flaque Date: Fri, 15 Nov 2013 20:14:32 +0000 (-0800) Subject: rtsp-stream: add getter for payload type X-Git-Tag: 1.19.3~495^2~925 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e5332535a738d90f234710b822cfe9a8bbbb23cf;p=platform%2Fupstream%2Fgstreamer.git rtsp-stream: add getter for payload type * gst/rtsp-server/rtsp-stream.c: add new method gst_rtsp_stream_get_pt. * gst/rtsp-server/rtsp-media.c (pad_added_cb): find real payloader element and create the stream with this one instead of the dynpay%d element. https://bugzilla.gnome.org/show_bug.cgi?id=712396 --- diff --git a/gst/rtsp-server/rtsp-media.c b/gst/rtsp-server/rtsp-media.c index cfa3a25..09628d3 100644 --- a/gst/rtsp-server/rtsp-media.c +++ b/gst/rtsp-server/rtsp-media.c @@ -67,6 +67,8 @@ #include #include +#include + #include "rtsp-media.h" #define GST_RTSP_MEDIA_GET_PRIVATE(obj) \ @@ -1529,15 +1531,41 @@ watch_destroyed (GstRTSPMedia * media) g_object_unref (media); } +static GstElement * +find_payload_element (GstElement * payloader) +{ + GValue item = { 0 }; + GstIterator *iter; + GstElement *element; + GstElement *pay = NULL; + + iter = gst_bin_iterate_recurse (GST_BIN (payloader)); + while (gst_iterator_next (iter, &item) == GST_ITERATOR_OK) { + element = (GstElement *) g_value_get_object (&item); + if (GST_IS_RTP_BASE_PAYLOAD (element)) { + pay = gst_object_ref (element); + g_value_unset (&item); + break; + } + g_value_unset (&item); + } + gst_iterator_free (iter); + + return pay; +} + /* called from streaming threads */ static void pad_added_cb (GstElement * element, GstPad * pad, GstRTSPMedia * media) { GstRTSPMediaPrivate *priv = media->priv; GstRTSPStream *stream; + GstElement *pay; - /* FIXME, element is likely not a payloader, find the payloader here */ - stream = gst_rtsp_media_create_stream (media, element, pad); + /* find the real payload element */ + pay = find_payload_element (element); + stream = gst_rtsp_media_create_stream (media, pay, pad); + gst_object_unref (pay); g_object_set_data (G_OBJECT (pad), "gst-rtsp-dynpad-stream", stream); diff --git a/gst/rtsp-server/rtsp-stream.c b/gst/rtsp-server/rtsp-stream.c index 79471e8..046ca5c 100644 --- a/gst/rtsp-server/rtsp-stream.c +++ b/gst/rtsp-server/rtsp-stream.c @@ -307,6 +307,29 @@ gst_rtsp_stream_get_index (GstRTSPStream * stream) } /** + * gst_rtsp_stream_get_pt: + * @stream: a #GstRTSPStream + * + * Get the stream payload type. + * + * Return: the stream payload type. + */ +guint +gst_rtsp_stream_get_pt (GstRTSPStream * stream) +{ + GstRTSPStreamPrivate *priv; + guint pt; + + g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), -1); + + priv = stream->priv; + + g_object_get (G_OBJECT (priv->payloader), "pt", &pt, NULL); + + return pt; +} + +/** * gst_rtsp_stream_get_srcpad: * @stream: a #GstRTSPStream * diff --git a/gst/rtsp-server/rtsp-stream.h b/gst/rtsp-server/rtsp-stream.h index 7bd4681..2aefdcf 100644 --- a/gst/rtsp-server/rtsp-stream.h +++ b/gst/rtsp-server/rtsp-stream.h @@ -66,6 +66,7 @@ GType gst_rtsp_stream_get_type (void); GstRTSPStream * gst_rtsp_stream_new (guint idx, GstElement *payloader, GstPad *srcpad); guint gst_rtsp_stream_get_index (GstRTSPStream *stream); +guint gst_rtsp_stream_get_pt (GstRTSPStream *stream); GstPad * gst_rtsp_stream_get_srcpad (GstRTSPStream *stream); void gst_rtsp_stream_set_control (GstRTSPStream *stream, const gchar *control);