Added vmethod unprepare to GstRTSPMedia

The default implementation sets the state of the pipeline to GST_STATE_NULL
This commit is contained in:
Sebastian Pölsterl 2009-06-12 18:05:30 +02:00 committed by Wim Taymans
parent 045875ecbe
commit 749765b921
2 changed files with 20 additions and 1 deletions

View file

@ -54,6 +54,7 @@ static void gst_rtsp_media_finalize (GObject * obj);
static gpointer do_loop (GstRTSPMediaClass *klass); static gpointer do_loop (GstRTSPMediaClass *klass);
static gboolean default_handle_message (GstRTSPMedia *media, GstMessage *message); static gboolean default_handle_message (GstRTSPMedia *media, GstMessage *message);
static gboolean default_unprepare (GstRTSPMedia *media);
static void unlock_streams (GstRTSPMedia *media); static void unlock_streams (GstRTSPMedia *media);
static guint gst_rtsp_media_signals[SIGNAL_LAST] = { 0 }; static guint gst_rtsp_media_signals[SIGNAL_LAST] = { 0 };
@ -94,6 +95,7 @@ gst_rtsp_media_class_init (GstRTSPMediaClass * klass)
g_critical ("could not start bus thread: %s", error->message); g_critical ("could not start bus thread: %s", error->message);
} }
klass->handle_message = default_handle_message; klass->handle_message = default_handle_message;
klass->unprepare = default_unprepare;
ssrc_stream_map_key = g_quark_from_static_string ("GstRTSPServer.stream"); ssrc_stream_map_key = g_quark_from_static_string ("GstRTSPServer.stream");
} }
@ -1373,12 +1375,20 @@ is_reused:
gboolean gboolean
gst_rtsp_media_unprepare (GstRTSPMedia *media) gst_rtsp_media_unprepare (GstRTSPMedia *media)
{ {
GstRTSPMediaClass *klass;
gboolean success;
if (!media->prepared) if (!media->prepared)
return TRUE; return TRUE;
g_message ("unprepare media %p", media); g_message ("unprepare media %p", media);
media->target_state = GST_STATE_NULL; media->target_state = GST_STATE_NULL;
gst_element_set_state (media->pipeline, GST_STATE_NULL);
klass = GST_RTSP_MEDIA_GET_CLASS (media);
if (klass->unprepare)
success = klass->unprepare (media);
else
success = TRUE;
media->prepared = FALSE; media->prepared = FALSE;
media->reused = TRUE; media->reused = TRUE;
@ -1387,6 +1397,12 @@ gst_rtsp_media_unprepare (GstRTSPMedia *media)
* recreate it */ * recreate it */
g_signal_emit (media, gst_rtsp_media_signals[SIGNAL_UNPREPARED], 0, NULL); g_signal_emit (media, gst_rtsp_media_signals[SIGNAL_UNPREPARED], 0, NULL);
return success;
}
static gboolean
default_unprepare (GstRTSPMedia *media) {
gst_element_set_state (media->pipeline, GST_STATE_NULL);
return TRUE; return TRUE;
} }

View file

@ -196,6 +196,8 @@ struct _GstRTSPMedia {
* @loop: the mainloop for message. * @loop: the mainloop for message.
* @thread: the thread dispatching messages. * @thread: the thread dispatching messages.
* @handle_message: handle a message * @handle_message: handle a message
* @unprepare: the default implementation sets the pipeline's state
* to GST_STATE_NULL.
* *
* The RTSP media class * The RTSP media class
*/ */
@ -209,6 +211,7 @@ struct _GstRTSPMediaClass {
/* vmethods */ /* vmethods */
gboolean (*handle_message) (GstRTSPMedia *media, GstMessage *message); gboolean (*handle_message) (GstRTSPMedia *media, GstMessage *message);
gboolean (*unprepare) (GstRTSPMedia *media);
/* signals */ /* signals */
gboolean (*unprepared) (GstRTSPMedia *media); gboolean (*unprepared) (GstRTSPMedia *media);