GstElement *fakesink; /* protected by lock */
GSource *source;
guint id;
+ GstRTSPThread *thread;
gboolean time_provider;
GstNetTimeProvider *nettime;
const GValue * value, GParamSpec * pspec);
static void gst_rtsp_media_finalize (GObject * obj);
-static gpointer do_loop (GstRTSPMediaClass * klass);
static gboolean default_handle_message (GstRTSPMedia * media,
GstMessage * message);
static void finish_unprepare (GstRTSPMedia * media);
G_STRUCT_OFFSET (GstRTSPMediaClass, new_state), NULL, NULL,
g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 0, G_TYPE_INT);
- klass->context = g_main_context_new ();
- klass->loop = g_main_loop_new (klass->context, TRUE);
-
GST_DEBUG_CATEGORY_INIT (rtsp_media_debug, "rtspmedia", 0, "GstRTSPMedia");
- klass->thread = g_thread_new ("Bus Thread", (GThreadFunc) do_loop, klass);
-
klass->handle_message = default_handle_message;
klass->unprepare = default_unprepare;
klass->convert_range = default_convert_range;
}
}
-static gpointer
-do_loop (GstRTSPMediaClass * klass)
-{
- GST_INFO ("enter mainloop");
- g_main_loop_run (klass->loop);
- GST_INFO ("exit mainloop");
-
- return NULL;
-}
-
/* must be called with state lock */
static void
collect_media_stats (GstRTSPMedia * media)
/**
* gst_rtsp_media_prepare:
* @media: a #GstRTSPMedia
- * @context: a #GMainContext to run the bus handler or %NULL
+ * @thread: a #GstRTSPThread 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
* Returns: %TRUE on success.
*/
gboolean
-gst_rtsp_media_prepare (GstRTSPMedia * media, GMainContext * context)
+gst_rtsp_media_prepare (GstRTSPMedia * media, GstRTSPThread * thread)
{
GstRTSPMediaPrivate *priv;
GstRTSPMediaStatus status;
- GstRTSPMediaClass *klass;
GstBus *bus;
GSource *source;
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), FALSE);
+ g_return_val_if_fail (GST_IS_RTSP_THREAD (thread), FALSE);
priv = media->priv;
priv->is_live = FALSE;
priv->seekable = FALSE;
priv->buffering = FALSE;
+ priv->thread = thread;
/* we're preparing now */
priv->status = GST_RTSP_MEDIA_STATUS_PREPARING;
- klass = GST_RTSP_MEDIA_GET_CLASS (media);
-
- if (context == NULL)
- context = klass->context;
-
bus = gst_pipeline_get_bus (GST_PIPELINE_CAST (priv->pipeline));
/* add the pipeline bus to our custom mainloop */
g_source_set_callback (priv->source, (GSourceFunc) bus_message,
g_object_ref (media), (GDestroyNotify) watch_destroyed);
- priv->id = g_source_attach (priv->source, context);
+ priv->id = g_source_attach (priv->source, thread->context);
/* add stuff to the bin */
gst_bin_add (GST_BIN (priv->pipeline), priv->rtpbin);
/* do remainder in context */
source = g_idle_source_new ();
g_source_set_callback (source, (GSourceFunc) start_prepare, media, NULL);
- g_source_attach (source, context);
+ g_source_attach (source, thread->context);
g_source_unref (source);
wait_status:
g_source_destroy (priv->source);
g_source_unref (priv->source);
}
+ if (priv->thread) {
+ GST_DEBUG ("stop thread");
+ gst_rtsp_thread_stop (priv->thread);
+ }
}
/* called with state-lock */
typedef struct _GstRTSPMediaPrivate GstRTSPMediaPrivate;
#include "rtsp-stream.h"
+#include "rtsp-thread-pool.h"
#include "rtsp-permissions.h"
#include "rtsp-address-pool.h"
struct _GstRTSPMediaClass {
GObjectClass parent_class;
- /* thread for the mainloop */
- GMainContext *context;
- GMainLoop *loop;
- GThread *thread;
-
/* vmethods */
gboolean (*handle_message) (GstRTSPMedia *media, GstMessage *message);
gboolean (*unprepare) (GstRTSPMedia *media);
const gchar *address, guint16 port);
/* prepare the media for playback */
-gboolean gst_rtsp_media_prepare (GstRTSPMedia *media, GMainContext *context);
+gboolean gst_rtsp_media_prepare (GstRTSPMedia *media, GstRTSPThread *thread);
gboolean gst_rtsp_media_unprepare (GstRTSPMedia *media);
/* creating streams */