souphttpsrc: get seekable info from dlna op code
[platform/upstream/gst-plugins-good.git] / ext / soup / gstsouphttpsrc.c
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;
   }