subparse: check byte seekability
authorruble <just.nam@samsung.com>
Thu, 10 Jun 2021 00:36:25 +0000 (09:36 +0900)
committerruble <just.nam@samsung.com>
Thu, 10 Jun 2021 05:35:41 +0000 (14:35 +0900)
- If seeking in byte format is not possible,
  it'll be handled by default handler.

Change-Id: I186a643a81b084070cea02c64809c2ed1e38f4db

gst/subparse/gstsubparse.c
packaging/gst-plugins-base.spec

index 5a2a7f2..fd83726 100644 (file)
@@ -102,7 +102,9 @@ static GstStateChangeReturn gst_sub_parse_change_state (GstElement * element,
 
 static GstFlowReturn gst_sub_parse_chain (GstPad * sinkpad, GstObject * parent,
     GstBuffer * buf);
-
+#ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION
+static gboolean gst_sub_parse_check_byte_seekability (GstSubParse * subparse);
+#endif
 #define gst_sub_parse_parent_class parent_class
 G_DEFINE_TYPE (GstSubParse, gst_sub_parse, GST_TYPE_ELEMENT);
 
@@ -302,8 +304,13 @@ gst_sub_parse_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
         gst_event_unref (event);
         goto beach;
       }
-
 #ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION
+      if (!gst_sub_parse_check_byte_seekability (self)) {
+        ret = gst_pad_event_default (pad, parent, event);
+        gst_event_unref (event);
+        break;
+      }
+
       SUBPARSE_SEEK_LOCK (self);
 #endif
       /* Convert that seek to a seeking in bytes at position 0,
@@ -343,6 +350,29 @@ beach:
   return ret;
 }
 
+#ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION
+static gboolean
+gst_sub_parse_check_byte_seekability (GstSubParse * subparse)
+{
+  GstQuery *query;
+  gboolean seekable = FALSE;
+
+  query = gst_query_new_seeking (GST_FORMAT_BYTES);
+
+  if (gst_pad_peer_query (subparse->sinkpad, query)) {
+    gst_query_parse_seeking (query, NULL, &seekable, NULL, NULL);
+  } else {
+    GST_DEBUG_OBJECT (subparse, "seeking query failed");
+  }
+
+  gst_query_unref (query);
+
+  GST_INFO_OBJECT (subparse, "byte seekable: %d", seekable);
+
+  return seekable;
+}
+#endif
+
 static void
 gst_sub_parse_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec)
index 9753c78..2a104d7 100644 (file)
@@ -5,7 +5,7 @@
 
 Name:           gst-plugins-base
 Version:        1.16.2
-Release:        12
+Release:        13
 License:        LGPL-2.0+
 Summary:        GStreamer Streaming-Media Framework Plug-Ins
 Url:            http://gstreamer.freedesktop.org/