From: Wim Taymans Date: Wed, 3 Jul 2013 13:13:45 +0000 (+0200) Subject: stream: add method to check control url of stream X-Git-Tag: 1.19.3~495^2~1080 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4e8d800c932400f859beeb1c5d5f4dcd0e90085;p=platform%2Fupstream%2Fgstreamer.git stream: add method to check control url of stream --- diff --git a/gst/rtsp-server/rtsp-stream.c b/gst/rtsp-server/rtsp-stream.c index 8e5e141..2a91126 100644 --- a/gst/rtsp-server/rtsp-stream.c +++ b/gst/rtsp-server/rtsp-stream.c @@ -17,8 +17,9 @@ * Boston, MA 02110-1301, USA. */ -#include #include +#include +#include #include @@ -297,7 +298,7 @@ gst_rtsp_stream_get_control (GstRTSPStream * stream) g_mutex_lock (&priv->lock); if ((result = g_strdup (priv->control)) == NULL) - result = g_strdup_printf ("stream=%d", priv->idx); + result = g_strdup_printf ("stream=%u", priv->idx); g_mutex_unlock (&priv->lock); return result; @@ -326,6 +327,38 @@ gst_rtsp_stream_set_control (GstRTSPStream * stream, const gchar * control) } /** + * gst_rtsp_stream_has_control: + * @stream: a #GstRTSPStream + * @control: a control string + * + * Check if @stream has the control string @control. + * + * Returns: %TRUE is @stream has @control as the control string + */ +gboolean +gst_rtsp_stream_has_control (GstRTSPStream * stream, const gchar * control) +{ + GstRTSPStreamPrivate *priv; + gboolean res; + + g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), FALSE); + + priv = stream->priv; + + g_mutex_lock (&priv->lock); + if (priv->control) + res = g_strcmp0 (priv->control, control); + else { + guint streamid; + sscanf (control, "stream=%u", &streamid); + res = (streamid == priv->idx); + } + g_mutex_unlock (&priv->lock); + + return res; +} + +/** * gst_rtsp_stream_set_mtu: * @stream: a #GstRTSPStream * @mtu: a new MTU @@ -1233,7 +1266,8 @@ gst_rtsp_stream_join_bin (GstRTSPStream * stream, GstBin * bin, GstElement * rtpbin, GstState state) { GstRTSPStreamPrivate *priv; - gint i, idx; + gint i; + guint idx; gchar *name; GstPad *pad, *teepad, *queuepad, *selpad; GstPadLinkReturn ret; @@ -1251,7 +1285,7 @@ gst_rtsp_stream_join_bin (GstRTSPStream * stream, GstBin * bin, /* create a session with the same index as the stream */ idx = priv->idx; - GST_INFO ("stream %p joining bin as session %d", stream, idx); + GST_INFO ("stream %p joining bin as session %u", stream, idx); if (!alloc_ports (stream)) goto no_ports; @@ -1448,12 +1482,12 @@ was_joined: no_ports: { g_mutex_unlock (&priv->lock); - GST_WARNING ("failed to allocate ports %d", idx); + GST_WARNING ("failed to allocate ports %u", idx); return FALSE; } link_failed: { - GST_WARNING ("failed to link stream %d", idx); + GST_WARNING ("failed to link stream %u", idx); gst_object_unref (priv->send_rtp_sink); priv->send_rtp_sink = NULL; g_mutex_unlock (&priv->lock); diff --git a/gst/rtsp-server/rtsp-stream.h b/gst/rtsp-server/rtsp-stream.h index a4c893a..8e5cbc5 100644 --- a/gst/rtsp-server/rtsp-stream.h +++ b/gst/rtsp-server/rtsp-stream.h @@ -69,6 +69,7 @@ GstPad * gst_rtsp_stream_get_srcpad (GstRTSPStream *stream); void gst_rtsp_stream_set_control (GstRTSPStream *stream, const gchar *control); gchar * gst_rtsp_stream_get_control (GstRTSPStream *stream); +gboolean gst_rtsp_stream_has_control (GstRTSPStream *stream, const gchar *control); void gst_rtsp_stream_set_mtu (GstRTSPStream *stream, guint mtu); guint gst_rtsp_stream_get_mtu (GstRTSPStream *stream);