From 1c822639453438a827bf2f8bd8a1df1dc365e29b Mon Sep 17 00:00:00 2001 From: "jiyong.min" Date: Wed, 8 Mar 2023 11:19:43 +0900 Subject: [PATCH] Add "stream-info-message" property for GSTRTSPSRC - The rtspsrc sent stream info message when stream open is completed. But rtspsrc wait until stream open is completed in READY_TO_PAUSE case. As a result, READY_TO_PAUSE state is changed lately. - The added "stream-info-message" property allow the user to select the above action. - The default is TRUE. [Version] 1.20.0-44 [Issue Type] Bug fix Change-Id: Ib05d694d224ed486b8da2f0e5c84633a0f405246 --- packaging/gstreamer.spec | 2 +- .../gst-plugins-good/gst/rtsp/gstrtspsrc.c | 95 ++++++++++++------- .../gst-plugins-good/gst/rtsp/gstrtspsrc.h | 1 + 3 files changed, 61 insertions(+), 37 deletions(-) diff --git a/packaging/gstreamer.spec b/packaging/gstreamer.spec index 779ae97dba..aac5a584f9 100644 --- a/packaging/gstreamer.spec +++ b/packaging/gstreamer.spec @@ -62,7 +62,7 @@ Name: %{_name} Version: 1.20.0 -Release: 43 +Release: 44 Summary: Streaming-Media Framework Runtime License: LGPL-2.0+ Group: Multimedia/Framework diff --git a/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c b/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c index 5f745e4adf..a462f5efe6 100644 --- a/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c +++ b/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c @@ -313,6 +313,7 @@ gst_rtsp_backchannel_get_type (void) #ifdef TIZEN_FEATURE_RTSP_MODIFICATION #define DEFAULT_START_POSITION 0 +#define DEFAULT_STREAM_INFO_MESSAGE TRUE #endif enum @@ -326,6 +327,7 @@ enum #ifdef TIZEN_FEATURE_RTSP_MODIFICATION PROP_START_POSITION, PROP_RESUME_POSITION, + PROP_POST_STREAM_INFO_MESSAGE, #endif PROP_TCP_TIMEOUT, PROP_LATENCY, @@ -663,6 +665,11 @@ gst_rtspsrc_class_init (GstRTSPSrcClass * klass) "Set resume position before PLAYING request after pause.", 0, G_MAXUINT64, DEFAULT_START_POSITION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_POST_STREAM_INFO_MESSAGE, + g_param_spec_uint64 ("stream-info-message", "set stream info message", + "Send stream info message when stream is opened.", + 0, G_MAXUINT64, DEFAULT_STREAM_INFO_MESSAGE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); #endif g_object_class_install_property (gobject_class, PROP_TCP_TIMEOUT, g_param_spec_uint64 ("tcp-timeout", "TCP Timeout", @@ -1523,6 +1530,7 @@ gst_rtspsrc_init (GstRTSPSrc * src) src->group_id = GST_GROUP_ID_INVALID; #ifdef TIZEN_FEATURE_RTSP_MODIFICATION + src->post_stream_info_message = DEFAULT_STREAM_INFO_MESSAGE; g_mutex_init (&(src)->pause_lock); g_cond_init (&(src)->open_end); #endif @@ -1743,6 +1751,10 @@ gst_rtspsrc_set_property (GObject * object, guint prop_id, const GValue * value, GST_DEBUG_OBJECT (rtspsrc, "src->last_pos value set to %" GST_TIME_FORMAT, GST_TIME_ARGS (rtspsrc->last_pos)); break; + case PROP_POST_STREAM_INFO_MESSAGE: + rtspsrc->post_stream_info_message = g_value_get_boolean (value); + GST_INFO_OBJECT (rtspsrc, "src->post_stream_info_message value set to %d", rtspsrc->post_stream_info_message); + break; #endif case PROP_TCP_TIMEOUT: gst_rtspsrc_set_tcp_timeout (rtspsrc, g_value_get_uint64 (value)); @@ -1932,6 +1944,9 @@ gst_rtspsrc_get_property (GObject * object, guint prop_id, GValue * value, case PROP_RESUME_POSITION: g_value_set_uint64 (value, rtspsrc->last_pos); break; + case PROP_POST_STREAM_INFO_MESSAGE: + g_value_set_boolean (value, rtspsrc->post_stream_info_message); + break; #endif case PROP_TCP_TIMEOUT: g_value_set_uint64 (value, rtspsrc->tcp_timeout); @@ -6218,36 +6233,40 @@ static void gst_rtspsrc_loop_complete_cmd (GstRTSPSrc * src, gint cmd) { #ifdef TIZEN_FEATURE_RTSP_MODIFICATION - GstMessage *s; + GstMessage *s = NULL; GST_WARNING_OBJECT (src, "Got cmd %s", cmd_to_string (cmd)); #endif switch (cmd) { case CMD_OPEN: #ifdef TIZEN_FEATURE_RTSP_MODIFICATION - GST_DEBUG_OBJECT (src, - "rtsp_duration %" GST_TIME_FORMAT - ", rtsp_audio_codec %s , rtsp_video_codec %s , rtsp_video_frame_size %s", - GST_TIME_ARGS (src->segment.duration), src->audio_codec, - src->video_codec, src->video_frame_size); - - /* post message */ - s = gst_message_new_element (GST_OBJECT_CAST (src), - gst_structure_new ("rtspsrc_properties", - "rtsp_duration", G_TYPE_UINT64, src->segment.duration, - "rtsp_audio_codec", G_TYPE_STRING, src->audio_codec, - "rtsp_video_codec", G_TYPE_STRING, src->video_codec, - "rtsp_video_frame_size", G_TYPE_STRING, src->video_frame_size, - NULL)); - - gst_element_post_message (GST_ELEMENT_CAST (src), s); + if (src->post_stream_info_message) { + GST_DEBUG_OBJECT (src, + "rtsp_duration %" GST_TIME_FORMAT + ", rtsp_audio_codec %s , rtsp_video_codec %s , rtsp_video_frame_size %s", + GST_TIME_ARGS (src->segment.duration), src->audio_codec, + src->video_codec, src->video_frame_size); + + /* post message */ + s = gst_message_new_element (GST_OBJECT_CAST (src), + gst_structure_new ("rtspsrc_properties", + "rtsp_duration", G_TYPE_UINT64, src->segment.duration, + "rtsp_audio_codec", G_TYPE_STRING, src->audio_codec, + "rtsp_video_codec", G_TYPE_STRING, src->video_codec, + "rtsp_video_frame_size", G_TYPE_STRING, src->video_frame_size, + NULL)); + + gst_element_post_message (GST_ELEMENT_CAST (src), s); + } #endif GST_ELEMENT_PROGRESS (src, COMPLETE, "open", ("Opened Stream")); #ifdef TIZEN_FEATURE_RTSP_MODIFICATION - /* rtspsrc PAUSE state should be here for parsing sdp before PAUSE state changed. */ - g_mutex_lock (&(src)->pause_lock); - g_cond_signal (&(src)->open_end); - g_mutex_unlock (&(src)->pause_lock); + if (s) { + /* rtspsrc PAUSE state should be here for parsing sdp before PAUSE state changed. */ + g_mutex_lock (&(src)->pause_lock); + g_cond_signal (&(src)->open_end); + g_mutex_unlock (&(src)->pause_lock); + } #endif break; case CMD_PLAY: @@ -6308,12 +6327,14 @@ gst_rtspsrc_loop_error_cmd (GstRTSPSrc * src, gint cmd) case CMD_OPEN: GST_ELEMENT_PROGRESS (src, ERROR, "open", ("Open failed")); #ifdef TIZEN_FEATURE_RTSP_MODIFICATION - /* Ending conditional wait for pause when open fails.*/ - g_mutex_lock (&(src)->pause_lock); - g_cond_signal (&(src)->open_end); - g_mutex_unlock (&(src)->pause_lock); - GST_WARNING_OBJECT (src, - "ending conditional wait for pause as open is failed."); + if (src->post_stream_info_message) { + /* Ending conditional wait for pause when open fails.*/ + g_mutex_lock (&(src)->pause_lock); + g_cond_signal (&(src)->open_end); + g_mutex_unlock (&(src)->pause_lock); + GST_WARNING_OBJECT (src, + "ending conditional wait for pause as open is failed."); + } #endif break; case CMD_PLAY: @@ -9751,16 +9772,18 @@ gst_rtspsrc_change_state (GstElement * element, GstStateChange transition) break; case GST_STATE_CHANGE_READY_TO_PAUSED: #ifdef TIZEN_FEATURE_RTSP_MODIFICATION - /* don't change to PAUSE state before complete stream opend. - see gst_rtspsrc_loop_complete_cmd() */ - g_mutex_lock (&(rtspsrc)->pause_lock); - end_time = g_get_monotonic_time () + 10 * G_TIME_SPAN_SECOND; - if (!g_cond_wait_until (&(rtspsrc)->open_end, &(rtspsrc)->pause_lock, - end_time)) { - GST_WARNING_OBJECT (rtspsrc, - "time out: stream opend is not completed yet.."); + if (rtspsrc->post_stream_info_message) { + /* don't change to PAUSE state before complete stream opend. + see gst_rtspsrc_loop_complete_cmd() */ + g_mutex_lock (&(rtspsrc)->pause_lock); + end_time = g_get_monotonic_time () + 10 * G_TIME_SPAN_SECOND; + if (!g_cond_wait_until (&(rtspsrc)->open_end, &(rtspsrc)->pause_lock, + end_time)) { + GST_WARNING_OBJECT (rtspsrc, + "time out: stream opend is not completed yet.."); + } + g_mutex_unlock (&(rtspsrc)->pause_lock); } - g_mutex_unlock (&(rtspsrc)->pause_lock); #endif if (rtspsrc->is_live) ret = GST_STATE_CHANGE_NO_PREROLL; diff --git a/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.h b/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.h index bb42826122..f8079c4c44 100644 --- a/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.h +++ b/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.h @@ -391,6 +391,7 @@ struct _GstRTSPSrc { GMutex group_lock; #ifdef TIZEN_FEATURE_RTSP_MODIFICATION + gboolean post_stream_info_message; GCond open_end; GMutex pause_lock; guint64 start_position; -- 2.34.1