From 1681e808eda24af7865fdc3a1b3d8e74ba9a9534 Mon Sep 17 00:00:00 2001 From: "jiyong.min" Date: Fri, 10 Mar 2023 15:06:08 +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.22.0-19 [Issue Type] Bug fix Change-Id: I258b070156f5d485014fc2e692edffa5919383be --- packaging/gstreamer.spec | 2 +- subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c | 94 +++++++++++++--------- subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.h | 1 + 3 files changed, 60 insertions(+), 37 deletions(-) diff --git a/packaging/gstreamer.spec b/packaging/gstreamer.spec index c9c83f3..1a9f4e0 100644 --- a/packaging/gstreamer.spec +++ b/packaging/gstreamer.spec @@ -62,7 +62,7 @@ Name: %{_name} Version: 1.22.0 -Release: 18 +Release: 19 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 8e0f1d9..fecc506 100644 --- a/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c +++ b/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c @@ -315,6 +315,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 @@ -328,6 +329,7 @@ enum #ifdef TIZEN_FEATURE_RTSP_MODIFICATION PROP_START_POSITION, PROP_RESUME_POSITION, + PROP_POST_STREAM_INFO_MESSAGE, #endif PROP_TCP_TIMEOUT, PROP_LATENCY, @@ -665,6 +667,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", @@ -1796,6 +1803,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)); @@ -1988,6 +1999,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); @@ -6380,36 +6394,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: @@ -6470,12 +6488,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: @@ -9964,16 +9984,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 d64071e..64f98e8 100644 --- a/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.h +++ b/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.h @@ -392,6 +392,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.7.4