mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
media: add optional context for bus messages
Add an optional mainloop to _prepare that will handle the bus messages instead of always using the shared mainloop.
This commit is contained in:
parent
48ff096a25
commit
12583e819c
4 changed files with 12 additions and 11 deletions
|
@ -522,7 +522,7 @@ find_media (GstRTSPClient * client, GstRTSPClientState * state, gint * matched)
|
|||
goto no_media;
|
||||
|
||||
/* prepare the media */
|
||||
if (!(gst_rtsp_media_prepare (media)))
|
||||
if (!(gst_rtsp_media_prepare (media, NULL)))
|
||||
goto no_prepare;
|
||||
|
||||
/* now keep track of the uri and the media */
|
||||
|
|
|
@ -1507,6 +1507,7 @@ struct _DynPaySignalHandlers
|
|||
/**
|
||||
* gst_rtsp_media_prepare:
|
||||
* @media: a #GstRTSPMedia
|
||||
* @context: a #GMainContext to run the bus handler or %NULL
|
||||
*
|
||||
* Prepare @media for streaming. This function will create the objects
|
||||
* to manage the streaming. A pipeline must have been set on @media with
|
||||
|
@ -1518,7 +1519,7 @@ struct _DynPaySignalHandlers
|
|||
* Returns: %TRUE on success.
|
||||
*/
|
||||
gboolean
|
||||
gst_rtsp_media_prepare (GstRTSPMedia * media)
|
||||
gst_rtsp_media_prepare (GstRTSPMedia * media, GMainContext * context)
|
||||
{
|
||||
GstRTSPMediaPrivate *priv;
|
||||
GstStateChangeReturn ret;
|
||||
|
@ -1570,7 +1571,7 @@ gst_rtsp_media_prepare (GstRTSPMedia * media)
|
|||
g_object_ref (media), (GDestroyNotify) watch_destroyed);
|
||||
|
||||
klass = GST_RTSP_MEDIA_GET_CLASS (media);
|
||||
priv->id = g_source_attach (priv->source, klass->context);
|
||||
priv->id = g_source_attach (priv->source, context ? context : klass->context);
|
||||
|
||||
/* add stuff to the bin */
|
||||
gst_bin_add (GST_BIN (priv->pipeline), priv->rtpbin);
|
||||
|
|
|
@ -149,7 +149,7 @@ GstNetTimeProvider * gst_rtsp_media_get_time_provider (GstRTSPMedia *media,
|
|||
const gchar *address, guint16 port);
|
||||
|
||||
/* prepare the media for playback */
|
||||
gboolean gst_rtsp_media_prepare (GstRTSPMedia *media);
|
||||
gboolean gst_rtsp_media_prepare (GstRTSPMedia *media, GMainContext *context);
|
||||
gboolean gst_rtsp_media_unprepare (GstRTSPMedia *media);
|
||||
|
||||
/* creating streams */
|
||||
|
|
|
@ -53,7 +53,7 @@ GST_START_TEST (test_launch)
|
|||
/* fails, need to be prepared */
|
||||
fail_if (gst_rtsp_media_seek (media, range));
|
||||
|
||||
fail_unless (gst_rtsp_media_prepare (media));
|
||||
fail_unless (gst_rtsp_media_prepare (media, NULL));
|
||||
|
||||
str = gst_rtsp_media_get_range_string (media, FALSE, GST_RTSP_RANGE_NPT);
|
||||
fail_unless (g_str_equal (str, "npt=0-"));
|
||||
|
@ -132,10 +132,10 @@ GST_START_TEST (test_media_prepare)
|
|||
fail_unless (GST_IS_RTSP_MEDIA (media));
|
||||
fail_unless (gst_rtsp_media_n_streams (media) == 1);
|
||||
|
||||
fail_unless (gst_rtsp_media_prepare (media));
|
||||
fail_unless (gst_rtsp_media_prepare (media, NULL));
|
||||
fail_unless (gst_rtsp_media_unprepare (media));
|
||||
fail_unless (gst_rtsp_media_n_streams (media) == 1);
|
||||
fail_if (gst_rtsp_media_prepare (media));
|
||||
fail_if (gst_rtsp_media_prepare (media, NULL));
|
||||
|
||||
g_object_unref (media);
|
||||
gst_rtsp_url_free (url);
|
||||
|
@ -155,10 +155,10 @@ GST_START_TEST (test_media_prepare)
|
|||
|
||||
g_object_set (G_OBJECT (media), "reusable", TRUE, NULL);
|
||||
|
||||
fail_unless (gst_rtsp_media_prepare (media));
|
||||
fail_unless (gst_rtsp_media_prepare (media, NULL));
|
||||
fail_unless (gst_rtsp_media_unprepare (media));
|
||||
fail_unless (gst_rtsp_media_n_streams (media) == 1);
|
||||
fail_unless (gst_rtsp_media_prepare (media));
|
||||
fail_unless (gst_rtsp_media_prepare (media, NULL));
|
||||
fail_unless (gst_rtsp_media_unprepare (media));
|
||||
|
||||
g_object_unref (media);
|
||||
|
@ -220,13 +220,13 @@ GST_START_TEST (test_media_dyn_prepare)
|
|||
g_signal_connect (srcpad, "notify::caps", (GCallback) on_notify_caps, pay);
|
||||
|
||||
fail_unless (gst_rtsp_media_n_streams (media) == 0);
|
||||
fail_unless (gst_rtsp_media_prepare (media));
|
||||
fail_unless (gst_rtsp_media_prepare (media, NULL));
|
||||
fail_unless (gst_rtsp_media_n_streams (media) == 1);
|
||||
fail_unless (gst_rtsp_media_unprepare (media));
|
||||
fail_unless (gst_rtsp_media_n_streams (media) == 0);
|
||||
|
||||
fail_unless (gst_rtsp_media_n_streams (media) == 0);
|
||||
fail_unless (gst_rtsp_media_prepare (media));
|
||||
fail_unless (gst_rtsp_media_prepare (media, NULL));
|
||||
fail_unless (gst_rtsp_media_n_streams (media) == 1);
|
||||
fail_unless (gst_rtsp_media_unprepare (media));
|
||||
fail_unless (gst_rtsp_media_n_streams (media) == 0);
|
||||
|
|
Loading…
Reference in a new issue