From: Wim Taymans Date: Tue, 28 Dec 2010 17:34:10 +0000 (+0100) Subject: media: add signal to notify of state changes X-Git-Tag: 1.19.3~495^2~1387^2~111 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=915cd708ea8e974c730fe7c679105be1fd89b6c5;p=platform%2Fupstream%2Fgstreamer.git media: add signal to notify of state changes --- diff --git a/gst/rtsp-server/rtsp-media.c b/gst/rtsp-server/rtsp-media.c index 8f3b643..45843b4 100644 --- a/gst/rtsp-server/rtsp-media.c +++ b/gst/rtsp-server/rtsp-media.c @@ -48,6 +48,7 @@ enum { SIGNAL_PREPARED, SIGNAL_UNPREPARED, + SIGNAL_NEW_STATE, SIGNAL_LAST }; @@ -114,6 +115,11 @@ gst_rtsp_media_class_init (GstRTSPMediaClass * klass) G_STRUCT_OFFSET (GstRTSPMediaClass, unprepared), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, G_TYPE_NONE); + gst_rtsp_media_signals[SIGNAL_NEW_STATE] = + g_signal_new ("new-state", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + 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); @@ -1888,16 +1894,22 @@ gst_rtsp_media_set_state (GstRTSPMedia * media, GstState state, else do_state = FALSE; - GST_INFO ("active %d media %p", media->active, media); + GST_INFO ("state %d active %d media %p do_state %d", state, media->active, + media, do_state); - if (do_state && media->target_state != state) { - if (state == GST_STATE_NULL) { - gst_rtsp_media_unprepare (media); - } else { - GST_INFO ("state %s media %p", gst_element_state_get_name (state), media); - media->target_state = state; - ret = gst_element_set_state (media->pipeline, state); + if (media->target_state != state) { + if (do_state) { + if (state == GST_STATE_NULL) { + gst_rtsp_media_unprepare (media); + } else { + GST_INFO ("state %s media %p", gst_element_state_get_name (state), + media); + media->target_state = state; + ret = gst_element_set_state (media->pipeline, state); + } } + g_signal_emit (media, gst_rtsp_media_signals[SIGNAL_NEW_STATE], 0, state, + NULL); } /* remember where we are */ diff --git a/gst/rtsp-server/rtsp-media.h b/gst/rtsp-server/rtsp-media.h index 6e35b20..fc4b159 100644 --- a/gst/rtsp-server/rtsp-media.h +++ b/gst/rtsp-server/rtsp-media.h @@ -252,6 +252,8 @@ struct _GstRTSPMediaClass { /* signals */ gboolean (*prepared) (GstRTSPMedia *media); gboolean (*unprepared) (GstRTSPMedia *media); + + gboolean (*new_state) (GstRTSPMedia *media, GstState state); }; GType gst_rtsp_media_get_type (void);