media: add method to find a stream by control url

This commit is contained in:
Wim Taymans 2013-07-03 15:14:39 +02:00
parent d4e8d800c9
commit 3999bd4e4e
2 changed files with 40 additions and 0 deletions

View file

@ -1094,6 +1094,45 @@ gst_rtsp_media_get_stream (GstRTSPMedia * media, guint idx)
return res;
}
/**
* gst_rtsp_media_find_stream:
* @media: a #GstRTSPMedia
* @control: the control of the stream
*
* Find a stream in @media with @control as the control uri.
*
* Returns: (transfer none): the #GstRTSPStream with control uri @control
* or %NULL when a stream with that control did not exist.
*/
GstRTSPStream *
gst_rtsp_media_find_stream (GstRTSPMedia * media, const gchar * control)
{
GstRTSPMediaPrivate *priv;
GstRTSPStream *res;
gint i;
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), NULL);
g_return_val_if_fail (control != NULL, NULL);
priv = media->priv;
res = NULL;
g_mutex_lock (&priv->lock);
for (i = 0; i < priv->streams->len; i++) {
GstRTSPStream *test;
test = g_ptr_array_index (priv->streams, i);
if (gst_rtsp_stream_has_control (test, control)) {
res = test;
break;
}
}
g_mutex_unlock (&priv->lock);
return res;
}
/**
* gst_rtsp_media_get_range_string:
* @media: a #GstRTSPMedia

View file

@ -167,6 +167,7 @@ GstClockTime gst_rtsp_media_get_base_time (GstRTSPMedia *media);
guint gst_rtsp_media_n_streams (GstRTSPMedia *media);
GstRTSPStream * gst_rtsp_media_get_stream (GstRTSPMedia *media, guint idx);
GstRTSPStream * gst_rtsp_media_find_stream (GstRTSPMedia *media, const gchar * control);
gboolean gst_rtsp_media_seek (GstRTSPMedia *media, GstRTSPTimeRange *range);
gchar * gst_rtsp_media_get_range_string (GstRTSPMedia *media,