rtpbin: Add use-rtsp-buffering property 28/234028/8
authorHyunil <hyunil46.park@samsung.com>
Thu, 21 May 2020 07:04:34 +0000 (16:04 +0900)
committerHyunil <hyunil46.park@samsung.com>
Fri, 22 May 2020 05:16:08 +0000 (14:16 +0900)
Change-Id: Ia250c1ca60bc66c12b30b6cab064185f3c457016
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
gst/rtpmanager/gstrtpbin.c
gst/rtpmanager/gstrtpbin.h
packaging/gst-plugins-good.spec

index fbed414..0583481 100644 (file)
@@ -311,6 +311,9 @@ enum
 #define DEFAULT_MAX_STREAMS          G_MAXUINT
 #define DEFAULT_MAX_TS_OFFSET_ADJUSTMENT G_GUINT64_CONSTANT(0)
 #define DEFAULT_MAX_TS_OFFSET        G_GINT64_CONSTANT(3000000000)
+#ifdef TIZEN_FEATURE_RTSP_MODIFICATION
+#define DEFAULT_RTSP_USE_BUFFERING  FALSE
+#endif
 
 enum
 {
@@ -338,6 +341,9 @@ enum
   PROP_MAX_STREAMS,
   PROP_MAX_TS_OFFSET_ADJUSTMENT,
   PROP_MAX_TS_OFFSET,
+#ifdef TIZEN_FEATURE_RTSP_MODIFICATION
+  PROP_USE_RTSP_BUFFERING       /* use for player RTSP buffering */
+#endif
 };
 
 #define GST_RTP_BIN_RTCP_SYNC_TYPE (gst_rtp_bin_rtcp_sync_get_type())
@@ -1712,9 +1718,11 @@ create_stream (GstRtpBinSession * session, guint32 ssrc)
       goto no_demux;
   }
 #ifdef TIZEN_FEATURE_RTSP_MODIFICATION
-  if (session->bin->buffer_mode == RTP_JITTER_BUFFER_MODE_SLAVE)
+  if (rtpbin->use_rtsp_buffering &&
+      rtpbin->buffer_mode == RTP_JITTER_BUFFER_MODE_SLAVE) {
     if (!(queue2 = gst_element_factory_make ("queue2", NULL)))
       goto no_queue2;
+  }
 #endif
   stream = g_new0 (GstRtpBinStream, 1);
   stream->ssrc = ssrc;
@@ -2632,6 +2640,14 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
           "changed to 0 (no limit)", 0, G_MAXINT64, DEFAULT_MAX_TS_OFFSET,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+#ifdef TIZEN_FEATURE_RTSP_MODIFICATION
+  g_object_class_install_property (gobject_class, PROP_USE_RTSP_BUFFERING,
+      g_param_spec_boolean ("use-rtsp-buffering", "Use RTSP buffering",
+          "Use RTSP buffering in RTP_JITTER_BUFFER_MODE_SLAVE buffer mode",
+          DEFAULT_RTSP_USE_BUFFERING,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+#endif
+
   gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_bin_change_state);
   gstelement_class->request_new_pad =
       GST_DEBUG_FUNCPTR (gst_rtp_bin_request_new_pad);
@@ -2709,6 +2725,9 @@ gst_rtp_bin_init (GstRtpBin * rtpbin)
   rtpbin->max_ts_offset_adjustment = DEFAULT_MAX_TS_OFFSET_ADJUSTMENT;
   rtpbin->max_ts_offset = DEFAULT_MAX_TS_OFFSET;
   rtpbin->max_ts_offset_is_set = FALSE;
+#ifdef TIZEN_FEATURE_RTSP_MODIFICATION
+  rtpbin->use_rtsp_buffering = FALSE;
+#endif
 
   /* some default SDES entries */
   cname = g_strdup_printf ("user%u@host-%x", g_random_int (), g_random_int ());
@@ -2797,6 +2816,13 @@ gst_rtp_bin_set_property (GObject * object, guint prop_id,
   rtpbin = GST_RTP_BIN (object);
 
   switch (prop_id) {
+#ifdef TIZEN_FEATURE_RTSP_MODIFICATION
+    case PROP_USE_RTSP_BUFFERING:
+      GST_RTP_BIN_LOCK (rtpbin);
+      rtpbin->use_rtsp_buffering = g_value_get_boolean (value);
+      GST_RTP_BIN_UNLOCK (rtpbin);
+      break;
+#endif
     case PROP_LATENCY:
       GST_RTP_BIN_LOCK (rtpbin);
       rtpbin->latency_ms = g_value_get_uint (value);
@@ -2966,6 +2992,13 @@ gst_rtp_bin_get_property (GObject * object, guint prop_id,
   rtpbin = GST_RTP_BIN (object);
 
   switch (prop_id) {
+#ifdef TIZEN_FEATURE_RTSP_MODIFICATION
+    case PROP_USE_RTSP_BUFFERING:
+      GST_RTP_BIN_LOCK (rtpbin);
+      g_value_set_boolean (value, rtpbin->use_rtsp_buffering);
+      GST_RTP_BIN_UNLOCK (rtpbin);
+      break;
+#endif
     case PROP_LATENCY:
       GST_RTP_BIN_LOCK (rtpbin);
       g_value_set_uint (value, rtpbin->latency_ms);
@@ -3123,40 +3156,48 @@ gst_rtp_bin_handle_message (GstBin * bin, GstMessage * message)
                 streams = g_slist_next (streams)) {
               GstRtpBinStream *stream = (GstRtpBinStream *) streams->data;
 #ifdef TIZEN_FEATURE_RTSP_MODIFICATION
-              GstPad *temp_pad_src = NULL;
-              GstCaps *temp_caps_src = NULL;
-              GstStructure *caps_structure;
-              const gchar *caps_str_media = NULL;
-              temp_pad_src = gst_element_get_static_pad (stream->buffer, "src");
-              temp_caps_src = gst_pad_get_current_caps (temp_pad_src);
-              GST_DEBUG_OBJECT (bin,
-                  "stream %p percent %d : temp_caps_src=%" GST_PTR_FORMAT,
-                  stream, stream->percent, temp_caps_src);
-              if (temp_caps_src) {
-                caps_structure = gst_caps_get_structure (temp_caps_src, 0);
-                caps_str_media =
-                    gst_structure_get_string (caps_structure, "media");
-                if (caps_str_media != NULL) {
-                  if ((strcmp (caps_str_media, "video") != 0)
-                      && (strcmp (caps_str_media, "audio") != 0)) {
-                    GST_DEBUG_OBJECT (bin,
-                        "Non Audio/Video Stream.. ignoring the same !!");
-                    gst_caps_unref (temp_caps_src);
-                    gst_object_unref (temp_pad_src);
-                    continue;
-                  } else if (stream->percent >= 100) {
-                    /* Most of the time buffering icon displays in rtsp playback.
-                       Optimizing the buffering updation code. Whenever any stream percentage
-                       reaches 100 do not post buffering messages. */
-                    if (stream->prev_percent < 100)
-                      buffering_flag = TRUE;
-                    else
-                      update_buffering_status = FALSE;
+              if (rtpbin->use_rtsp_buffering &&
+                  rtpbin->buffer_mode == RTP_JITTER_BUFFER_MODE_SLAVE) {
+                GstPad *temp_pad_src = NULL;
+                GstCaps *temp_caps_src = NULL;
+                GstStructure *caps_structure;
+                const gchar *caps_str_media = NULL;
+                temp_pad_src = gst_element_get_static_pad (stream->buffer, "src");
+                temp_caps_src = gst_pad_get_current_caps (temp_pad_src);
+                GST_DEBUG_OBJECT (bin,
+                    "stream %p percent %d : temp_caps_src=%" GST_PTR_FORMAT,
+                    stream, stream->percent, temp_caps_src);
+                if (temp_caps_src) {
+                  caps_structure = gst_caps_get_structure (temp_caps_src, 0);
+                  caps_str_media =
+                      gst_structure_get_string (caps_structure, "media");
+                  if (caps_str_media != NULL) {
+                    if ((strcmp (caps_str_media, "video") != 0)
+                        && (strcmp (caps_str_media, "audio") != 0)) {
+                      GST_DEBUG_OBJECT (bin,
+                          "Non Audio/Video Stream.. ignoring the same !!");
+                      gst_caps_unref (temp_caps_src);
+                      gst_object_unref (temp_pad_src);
+                      continue;
+                    } else if (stream->percent >= 100) {
+                      /* Most of the time buffering icon displays in rtsp playback.
+                         Optimizing the buffering updation code. Whenever any stream percentage
+                         reaches 100 do not post buffering messages. */
+                      if (stream->prev_percent < 100)
+                        buffering_flag = TRUE;
+                      else
+                        update_buffering_status = FALSE;
+                    }
                   }
+                  gst_caps_unref (temp_caps_src);
                 }
-                gst_caps_unref (temp_caps_src);
+                gst_object_unref (temp_pad_src);
+                /* Updating prev stream percentage */
+                stream->prev_percent = stream->percent;
+              } else {
+                GST_DEBUG_OBJECT (bin, "stream %p percent %d", stream,
+                    stream->percent);
               }
-              gst_object_unref (temp_pad_src);
 #else
               GST_DEBUG_OBJECT (bin, "stream %p percent %d", stream,
                   stream->percent);
@@ -3164,10 +3205,6 @@ gst_rtp_bin_handle_message (GstBin * bin, GstMessage * message)
               /* find min percent */
               if (min_percent > stream->percent)
                 min_percent = stream->percent;
-#ifdef TIZEN_FEATURE_RTSP_MODIFICATION
-              /* Updating prev stream percentage */
-              stream->prev_percent = stream->percent;
-#endif
             }
           } else {
             GST_INFO_OBJECT (bin,
@@ -3178,23 +3215,9 @@ gst_rtp_bin_handle_message (GstBin * bin, GstMessage * message)
         }
         GST_DEBUG_OBJECT (bin, "min percent %d", min_percent);
 #ifdef TIZEN_FEATURE_RTSP_MODIFICATION
-        if (rtpbin->buffer_mode != RTP_JITTER_BUFFER_MODE_SLAVE) {
-          if (rtpbin->buffering) {
-            if (min_percent == 100) {
-              rtpbin->buffering = FALSE;
-              active = TRUE;
-              change = TRUE;
-            }
-          } else {
-            if (min_percent < 100) {
-              /* pause the streams */
-              rtpbin->buffering = TRUE;
-              active = FALSE;
-              change = TRUE;
-            }
-          }
-        }
-#else
+        if (!(rtpbin->use_rtsp_buffering &&
+            rtpbin->buffer_mode == RTP_JITTER_BUFFER_MODE_SLAVE)) {
+#endif
         if (rtpbin->buffering) {
           if (min_percent == 100) {
             rtpbin->buffering = FALSE;
@@ -3209,13 +3232,16 @@ gst_rtp_bin_handle_message (GstBin * bin, GstMessage * message)
             change = TRUE;
           }
         }
+#ifdef TIZEN_FEATURE_RTSP_MODIFICATION
+        }
 #endif
         GST_RTP_BIN_UNLOCK (rtpbin);
 
         gst_message_unref (message);
 
 #ifdef TIZEN_FEATURE_RTSP_MODIFICATION
-        if (rtpbin->buffer_mode == RTP_JITTER_BUFFER_MODE_SLAVE) {
+          if (rtpbin->use_rtsp_buffering &&
+              rtpbin->buffer_mode == RTP_JITTER_BUFFER_MODE_SLAVE) {
           if (update_buffering_status == FALSE)
             break;
           if (buffering_flag) {
@@ -3231,7 +3257,8 @@ gst_rtp_bin_handle_message (GstBin * bin, GstMessage * message)
             buffering_left);
 
 #ifdef TIZEN_FEATURE_RTSP_MODIFICATION
-        if (rtpbin->buffer_mode == RTP_JITTER_BUFFER_MODE_SLAVE)
+        if (rtpbin->use_rtsp_buffering &&
+            rtpbin->buffer_mode == RTP_JITTER_BUFFER_MODE_SLAVE)
           goto slave_buffering;
 #endif
         if (G_UNLIKELY (change)) {
index c3c1fb5..0151b94 100644 (file)
@@ -78,7 +78,9 @@ struct _GstRtpBin {
   guint64         max_ts_offset_adjustment;
   gint64          max_ts_offset;
   gboolean        max_ts_offset_is_set;
-
+#ifdef TIZEN_FEATURE_RTSP_MODIFICATION
+  gboolean        use_rtsp_buffering;
+#endif
   /* a list of session */
   GSList         *sessions;
 
index ef03d66..9d0bb06 100644 (file)
@@ -3,7 +3,7 @@
 
 Name:           gst-plugins-good
 Version:        1.16.2
-Release:        2
+Release:        3
 License:        LGPL-2.1+
 Summary:        GStreamer Streaming-Media Framework Plug-Ins
 Url:            http://gstreamer.freedesktop.org/