souphttpsrc: add dash segment handling 18/107518/1
authorEunhae Choi <eunhae1.choi@samsung.com>
Wed, 28 Dec 2016 08:11:07 +0000 (17:11 +0900)
committereunhae choi <eunhae1.choi@samsung.com>
Wed, 28 Dec 2016 10:11:36 +0000 (02:11 -0800)
Change-Id: I91f95265fa925188789a1aa11b86331e80a99aaa

ext/soup/gstsouphttpsrc.c
ext/soup/gstsouphttpsrc.h
gst/rtpmanager/gstrtpbin.c
gst/rtsp/gstrtspsrc.c

index 7a8fee5..adea645 100644 (file)
@@ -447,6 +447,16 @@ gst_soup_http_src_reset (GstSoupHTTPSrc * src)
   src->content_size = 0;
   src->have_body = FALSE;
 
+#ifdef TIZEN_FEATURE_SOUP_MODIFICATION
+  if (src->dash_oldest_segment) {
+    g_free (src->dash_oldest_segment);
+    src->dash_oldest_segment = NULL;
+  }
+  if (src->dash_newest_segment) {
+    g_free (src->dash_newest_segment);
+    src->dash_newest_segment = NULL;
+  }
+#endif
   src->ret = GST_FLOW_OK;
 
   gst_caps_replace (&src->src_caps, NULL);
@@ -486,6 +496,10 @@ gst_soup_http_src_init (GstSoupHTTPSrc * src)
   src->tls_database = DEFAULT_TLS_DATABASE;
   src->max_retries = DEFAULT_RETRIES;
   src->method = DEFAULT_SOUP_METHOD;
+#ifdef TIZEN_FEATURE_SOUP_MODIFICATION
+  src->dash_oldest_segment = NULL;
+  src->dash_newest_segment = NULL;
+#endif
   proxy = g_getenv ("http_proxy");
   if (!gst_soup_http_src_set_proxy (src, proxy)) {
     GST_WARNING_OBJECT (src,
@@ -838,10 +852,9 @@ gst_soup_http_src_add_range_header (GstSoupHTTPSrc * src, guint64 offset,
 
   soup_message_headers_remove (src->msg->request_headers, "Range");
 
-/*[prasenjit.c]This changes are needed to enable Seekable Contents from server.
-We have observed that , for few specific networks ( VODAFONE ) , without theabove headers ,
-Youtube is sending non-seekable contents to the Client.
-*/
+/* This changes are needed to enable Seekable Contents from server.
+   We have observed that , for few specific networks ( VODAFONE ) , without theabove headers ,
+   Youtube is sending non-seekable contents to the Client. */
 #ifndef TIZEN_FEATURE_SOUP_MODIFICATION
   if (offset || stop_offset != -1)
 #endif
@@ -1096,9 +1109,9 @@ gst_soup_http_src_session_close (GstSoupHTTPSrc * src)
   g_mutex_lock (&src->mutex);
   if (src->session) {
 #ifdef TIZEN_FEATURE_SOUP_MODIFICATION
-//[prasenjit.c] When Playback is ongoing and Browser is moved to background ( Pressing Menu or Home Key ), The Session gets destroyed.
-// But the cookie_jar property remains unfreed. This results in garbage pointer and causes crash.
-// Removing the cookie_jar feature during close session of browser to handle the issue.
+/* When Playback is ongoing and Browser is moved to background ( Pressing Menu or Home Key ), The Session gets destroyed.
+   But the cookie_jar property remains unfreed. This results in garbage pointer and causes crash.
+   Removing the cookie_jar feature during close session of browser to handle the issue. */
     GST_DEBUG_OBJECT (src, "Removing Cookie Jar instance");
     soup_session_remove_feature_by_type(src->session, SOUP_TYPE_COOKIE_JAR);
     src->cookie_jar = NULL;
@@ -1217,6 +1230,24 @@ gst_soup_http_src_headers_foreach (const gchar * name, const gchar * val,
       GST_INFO_OBJECT (src, "request url [%s], posted cookies [%s] msg and returned = %d", tmp->location, val, bret);
     }
   }
+  else if (g_ascii_strcasecmp (name, "Dash-Oldest-Segment") == 0)
+  {
+    if (val)
+    {
+      GstSoupHTTPSrc * tmp = src;
+      tmp->dash_oldest_segment = g_strdup (val);
+      GST_INFO_OBJECT (src, "Dash-Oldest-Segment set as %s ", tmp->dash_oldest_segment);
+    }
+  }
+  else if (g_ascii_strcasecmp (name, "Dash-Newest-Segment") == 0)
+  {
+    if (val)
+    {
+      GstSoupHTTPSrc * tmp = src;
+      tmp->dash_newest_segment = g_strdup (val);
+      GST_INFO_OBJECT (src, "Dash-Newest-Segment set as %s ", tmp->dash_newest_segment);
+    }
+  }
 }
 #endif
 
@@ -1815,10 +1846,9 @@ gst_soup_http_src_build_message (GstSoupHTTPSrc * src, const gchar * method)
   }
 
 #ifdef TIZEN_FEATURE_SOUP_MODIFICATION
-/*[prasenjit.c]This changes are needed to enable Seekable Contents from server.
-We have observed that , for few specific networks ( VODAFONE ) , without theabove headers ,
-Youtube is sending non-seekable contents to the Client.
-*/
+/* This changes are needed to enable Seekable Contents from server.
+   We have observed that , for few specific networks ( VODAFONE ) , without theabove headers ,
+   Youtube is sending non-seekable contents to the Client. */
   soup_message_headers_append (src->msg->request_headers, "Accept-Ranges","bytes");
 
   if (src->cookie_jar) {
@@ -2018,6 +2048,16 @@ gst_soup_http_src_start (GstBaseSrc * bsrc)
 
   GST_DEBUG_OBJECT (src, "start(\"%s\")", src->location);
 
+#ifdef TIZEN_FEATURE_SOUP_MODIFICATION
+  if (src->dash_oldest_segment) {
+    g_free (src->dash_oldest_segment);
+    src->dash_oldest_segment = NULL;
+  }
+  if (src->dash_newest_segment) {
+    g_free (src->dash_newest_segment);
+    src->dash_newest_segment = NULL;
+  }
+#endif
   return gst_soup_http_src_session_open (src);
 }
 
index bfb32e0..fdc8318 100644 (file)
@@ -114,6 +114,10 @@ struct _GstSoupHTTPSrc {
   GCond request_finished_cond;
 
   GstEvent *http_headers_event;
+#ifdef TIZEN_FEATURE_SOUP_MODIFICATION
+  gchar *dash_oldest_segment;
+  gchar *dash_newest_segment;
+#endif
 };
 
 struct _GstSoupHTTPSrcClass {
index 9098eed..d921235 100644 (file)
@@ -2613,44 +2613,44 @@ 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)
-                               {
-                                       /*[shweta.agg] 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_object_unref( temp_pad_src );
+              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_object_unref( temp_pad_src );
 #else
               GST_DEBUG_OBJECT (bin, "stream %p percent %d", stream,
                   stream->percent);
@@ -2659,8 +2659,8 @@ gst_rtp_bin_handle_message (GstBin * bin, GstMessage * message)
               if (min_percent > stream->percent)
                 min_percent = stream->percent;
 #ifdef TIZEN_FEATURE_RTSP_MODIFICATION
-             /* Updating prev stream percentage */
-             stream->prev_percent = stream->percent;
+              /* Updating prev stream percentage */
+              stream->prev_percent = stream->percent;
 #endif
             }
           } else {
index a8e6209..01a8535 100644 (file)
@@ -5571,7 +5571,7 @@ 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
-/*[shweta.agg] Ending conditional wait for pause when open fails.*/
+/* 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);
@@ -7248,7 +7248,7 @@ gst_rtspsrc_parse_range (GstRTSPSrc * src, const gchar * range,
   segment->start = seconds;
 #ifndef TIZEN_FEATURE_RTSP_MODIFICATION
 /*
-[prasenjit.c] The range-min points to the start of the segment , not the current position.
+The range-min points to the start of the segment , not the current position.
 After getting the current position from MSL during normal pause/resume or during seek , we should not
 update the segment->position again with the rtp header npt timestamp.
 */
@@ -7449,7 +7449,7 @@ gst_rtspsrc_open_from_sdp (GstRTSPSrc * src, GstSDPMessage * sdp,
 
   src->state = GST_RTSP_STATE_INIT;
 #ifdef TIZEN_FEATURE_RTSP_MODIFICATION
-  //[prasenjit.c] Check for the support for the Media codecs
+  /* Check for the support for the Media codecs */
   if ((!src->is_audio_codec_supported)&&(!src->is_video_codec_supported))
   {
        GST_ERROR_OBJECT (src, "UnSupported Media Type !!!! \n");
@@ -8132,7 +8132,7 @@ gst_rtspsrc_play (GstRTSPSrc * src, GstSegment * segment, gboolean async)
     else
     {
 /*
-[prasenjit.c] Updating position with the MSL current position as gst_rtspsrc_get_position() does not return correct position.
+ Updating position with the MSL current position as gst_rtspsrc_get_position() does not return correct position.
 */
       GST_DEBUG_OBJECT (src, " During normal pause-resume , segment->position=%" GST_TIME_FORMAT",src->start_position=%"GST_TIME_FORMAT,
       GST_TIME_ARGS (segment->position),GST_TIME_ARGS (src->start_position));
@@ -8140,7 +8140,7 @@ gst_rtspsrc_play (GstRTSPSrc * src, GstSegment * segment, gboolean async)
     }
 
 /*
-[prasenjit.c] Sending the npt range request for each play request for updating the segment position properly.
+ Sending the npt range request for each play request for updating the segment position properly.
 */
     hval = gen_range_header (src, segment);
     gst_rtsp_message_take_header (&request, GST_RTSP_HDR_RANGE, hval);