souphttpsrc: get seekable info from dlna op code 50/210250/3 accepted/tizen_5.5_unified_mobile_hotfix tizen_5.5_mobile_hotfix tizen_5.5_tv accepted/tizen/5.5/unified/20191031.005754 accepted/tizen/5.5/unified/mobile/hotfix/20201027.062832 accepted/tizen/unified/20190729.081000 submit/tizen/20190723.041031 submit/tizen/20190725.100239 submit/tizen_5.5/20191031.000006 submit/tizen_5.5_mobile_hotfix/20201026.185106 tizen_5.5.m2_release
authorEunhye Choi <eunhae1.choi@samsung.com>
Wed, 17 Jul 2019 07:34:28 +0000 (16:34 +0900)
committerEunhye Choi <eunhae1.choi@samsung.com>
Wed, 17 Jul 2019 08:45:13 +0000 (17:45 +0900)
- get seekable info from dlna op code to support
  seek operation regardless of the server response code.

Change-Id: Ica14f9bed5d3121ca8cca3179ea97a7314d2d8c6

ext/soup/gstsouphttpsrc.c
ext/soup/gstsouphttpsrc.h

index 64d05fe..40abf46 100644 (file)
@@ -140,6 +140,11 @@ enum
 #define REDUCE_BLOCKSIZE_COUNT 2
 #define REDUCE_BLOCKSIZE_FACTOR 0.5
 
+#ifdef TIZEN_FEATURE_SOUP_MODIFICATION
+#define DLNA_OP_TIMED_SEEK  0x02
+#define DLNA_OP_BYTE_SEEK   0x01
+#endif
+
 static void gst_soup_http_src_uri_handler_init (gpointer g_iface,
     gpointer iface_data);
 static void gst_soup_http_src_finalize (GObject * gobject);
@@ -456,6 +461,7 @@ gst_soup_http_src_reset (GstSoupHTTPSrc * src)
     g_free (src->dash_newest_segment);
     src->dash_newest_segment = NULL;
   }
+  src->dlna_opt = 0;
 #endif
 
   g_cancellable_reset (src->cancellable);
@@ -506,6 +512,7 @@ gst_soup_http_src_init (GstSoupHTTPSrc * src)
   src->dash_oldest_segment = NULL;
   src->dash_newest_segment = NULL;
   src->received_total = 0;
+  src->dlna_opt = 0;
 #endif
   proxy = g_getenv ("http_proxy");
   if (!gst_soup_http_src_set_proxy (src, proxy)) {
@@ -1250,6 +1257,44 @@ gst_soup_http_src_got_headers (GstSoupHTTPSrc * src, SoupMessage * msg)
   gst_event_replace (&src->http_headers_event, http_headers_event);
   gst_event_unref (http_headers_event);
 
+#ifdef TIZEN_FEATURE_SOUP_MODIFICATION
+  /* Parse DLNA OP CODE */
+  if ((value = soup_message_headers_get_one
+        (msg->response_headers, "contentFeatures.dlna.org")) != NULL) {
+    gchar **token = NULL;
+    gchar **ptr = NULL;
+
+    GST_DEBUG_OBJECT (src, "DLNA server response");
+
+    token = g_strsplit (value, ";", 0);
+    for (ptr = token ; *ptr ; ptr++) {
+      gchar *tmp = NULL;
+      gchar *op_code = NULL;
+
+      if (!strlen (*ptr))
+        continue;
+
+      tmp = g_ascii_strup (*ptr, strlen (*ptr));
+      if (!strstr (tmp, "DLNA.ORG_OP")) {
+        g_free (tmp);
+        continue;
+      }
+
+      g_free (tmp);
+
+      op_code = strchr (*ptr, '=');
+      if (op_code) {
+        op_code++;
+
+        src->dlna_opt = (atoi (op_code) / 10 << 1) | (atoi (op_code) % 10);
+        GST_DEBUG_OBJECT (src, "dlna op code: %s (0x%X)", op_code, src->dlna_opt);
+        break;
+      }
+    }
+    g_strfreev (token);
+  }
+#endif
+
   /* Parse Content-Length. */
   if (soup_message_headers_get_encoding (msg->response_headers) ==
       SOUP_ENCODING_CONTENT_LENGTH) {
@@ -1297,10 +1342,16 @@ gst_soup_http_src_got_headers (GstSoupHTTPSrc * src, SoupMessage * msg)
       src->seekable = FALSE;
   }
 #ifdef TIZEN_FEATURE_SOUP_MODIFICATION
+  else if (src->dlna_opt & DLNA_OP_BYTE_SEEK) {
+    if (src->have_size) {
+      GST_DEBUG_OBJECT (src, "DLNA server is seekable");
+      src->seekable = TRUE;
+    }
+  }
   /* The Range request header is always included.
    * @ref gst_soup_http_src_add_range_header() */
   else if ((msg->status_code == SOUP_STATUS_OK) &&
-    (soup_message_headers_get_content_range(msg->response_headers, &start, &stop, &total) == FALSE)) {
+    (soup_message_headers_get_content_range (msg->response_headers, &start, &stop, &total) == FALSE)) {
     GST_DEBUG_OBJECT (src, "there is no accept range header");
     src->seekable = FALSE;
   }
index b6f0065..3b37fe0 100644 (file)
@@ -118,6 +118,7 @@ struct _GstSoupHTTPSrc {
   gchar *dash_oldest_segment;
   gchar *dash_newest_segment;
   guint64 received_total;    /* temp: for debugging */
+  guint dlna_opt;            /* DLNA server option */
 #endif
 };