From: Ognyan Tonchev Date: Tue, 21 Jan 2014 11:01:25 +0000 (+0100) Subject: media: add signal to notify of pending state changes X-Git-Tag: 1.6.0~281 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5eca958d5ea090949091e593a83d4a24abf5c5df;p=platform%2Fupstream%2Fgst-rtsp-server.git media: add signal to notify of pending state changes --- diff --git a/gst/rtsp-server/rtsp-media.c b/gst/rtsp-server/rtsp-media.c index f5ed9ab..06e361b 100644 --- a/gst/rtsp-server/rtsp-media.c +++ b/gst/rtsp-server/rtsp-media.c @@ -157,6 +157,7 @@ enum SIGNAL_REMOVED_STREAM, SIGNAL_PREPARED, SIGNAL_UNPREPARED, + SIGNAL_TARGET_STATE, SIGNAL_NEW_STATE, SIGNAL_LAST }; @@ -293,6 +294,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_TARGET_STATE] = + g_signal_new ("target-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, 1, G_TYPE_INT); + 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, @@ -1939,8 +1945,10 @@ start_preroll (GstRTSPMedia * media) GST_INFO ("setting pipeline to PAUSED for media %p", media); /* first go to PAUSED */ - ret = gst_element_set_state (priv->pipeline, GST_STATE_PAUSED); priv->target_state = GST_STATE_PAUSED; + g_signal_emit (media, gst_rtsp_media_signals[SIGNAL_TARGET_STATE], 0, + priv->target_state, NULL); + ret = gst_element_set_state (priv->pipeline, GST_STATE_PAUSED); switch (ret) { case GST_STATE_CHANGE_SUCCESS: @@ -2320,6 +2328,8 @@ gst_rtsp_media_unprepare (GstRTSPMedia * media) GST_INFO ("unprepare media %p", media); priv->target_state = GST_STATE_NULL; + g_signal_emit (media, gst_rtsp_media_signals[SIGNAL_TARGET_STATE], 0, + priv->target_state, NULL); success = TRUE; if (priv->status == GST_RTSP_MEDIA_STATUS_PREPARED) { @@ -2559,6 +2569,8 @@ gst_rtsp_media_suspend (GstRTSPMedia * media) case GST_RTSP_SUSPEND_MODE_PAUSE: GST_DEBUG ("media %p suspend to PAUSED", media); priv->target_state = GST_STATE_PAUSED; + g_signal_emit (media, gst_rtsp_media_signals[SIGNAL_TARGET_STATE], 0, + priv->target_state, NULL); ret = gst_element_set_state (priv->pipeline, GST_STATE_PAUSED); if (ret == GST_STATE_CHANGE_FAILURE) goto state_failed; @@ -2566,6 +2578,8 @@ gst_rtsp_media_suspend (GstRTSPMedia * media) case GST_RTSP_SUSPEND_MODE_RESET: GST_DEBUG ("media %p suspend to NULL", media); priv->target_state = GST_STATE_NULL; + g_signal_emit (media, gst_rtsp_media_signals[SIGNAL_TARGET_STATE], 0, + priv->target_state, NULL); ret = gst_element_set_state (priv->pipeline, GST_STATE_NULL); if (ret == GST_STATE_CHANGE_FAILURE) goto state_failed; @@ -2670,6 +2684,8 @@ media_set_pipeline_state_locked (GstRTSPMedia * media, GstState state) } else { GST_INFO ("state %s media %p", gst_element_state_get_name (state), media); priv->target_state = state; + g_signal_emit (media, gst_rtsp_media_signals[SIGNAL_TARGET_STATE], 0, + priv->target_state, NULL); /* when we are buffering, don't update the state yet, this will be done * when buffering finishes */ if (priv->buffering) { diff --git a/gst/rtsp-server/rtsp-media.h b/gst/rtsp-server/rtsp-media.h index cd38a49..1ef5079 100644 --- a/gst/rtsp-server/rtsp-media.h +++ b/gst/rtsp-server/rtsp-media.h @@ -134,6 +134,7 @@ struct _GstRTSPMediaClass { void (*prepared) (GstRTSPMedia *media); void (*unprepared) (GstRTSPMedia *media); + void (*target_state) (GstRTSPMedia *media, GstState state); void (*new_state) (GstRTSPMedia *media, GstState state); /*< private >*/