aacparse: Check aacparse seekable to byte, in the push mode
[platform/upstream/gst-plugins-good.git] / gst / audioparsers / gstaacparse.c
index 93a5e0b..6ec3a75 100644 (file)
@@ -122,6 +122,7 @@ static gboolean gst_aac_parse_adts_src_eventfunc (GstBaseParse * parse,
 int get_aac_parse_get_adts_frame_length (const unsigned char *data,
     gint64 offset);
 static gboolean gst_aac_parse_estimate_duration (GstBaseParse * parse);
+static void gst_aac_parse_check_byte_seekability (GstBaseParse * parse);
 #endif
 
 #define gst_aac_parse_parent_class parent_class
@@ -1422,6 +1423,7 @@ gst_aac_parse_handle_frame (GstBaseParse * parse,
         GST_WARNING_OBJECT (aacparse, "can not estimate total duration");
         ret = GST_FLOW_NOT_SUPPORTED;
       }
+      gst_aac_parse_check_byte_seekability (parse);
     }
 #endif
   } else if (aacparse->header_type == DSPAAC_HEADER_LOAS) {
@@ -2137,10 +2139,13 @@ gst_aac_parse_adts_src_eventfunc (GstBaseParse * parse, GstEvent * event)
         GstPad *srcpad = parse->srcpad;
         GST_INFO_OBJECT (aacparse, "aac parser is PUSH MODE.");
         /* check NULL */
-        ret = gst_aac_audio_parse_do_push_seek (parse, srcpad, event);
-        gst_object_unref (srcpad);
-        return ret;
+        if (aacparse->byte_seekable)
+          return gst_aac_audio_parse_do_push_seek (parse, srcpad, event);
+
+        GST_INFO_OBJECT (aacparse, "not support byte seek");
+        goto aac_seek_null_exit;
       }
+
       gst_base_parse_get_upstream_size (parse, &total_file_size);
       gst_base_parse_get_index_last_offset (parse, &start_offset);
       gst_base_parse_get_index_last_ts (parse, &current_ts);
@@ -2327,4 +2332,25 @@ aac_seek_null_exit:
   handled = GST_BASE_PARSE_CLASS (parent_class)->src_event (parse, event);
   return handled;
 }
+
+static void
+gst_aac_parse_check_byte_seekability (GstBaseParse * parse)
+{
+  GstQuery *query;
+  gboolean seekable = FALSE;
+  GstAacParse *aacparse = GST_AAC_PARSE (parse);
+  GST_LOG_OBJECT (aacparse, "gst_aac_parse_check_byte_seekability enter");
+
+  query = gst_query_new_seeking (GST_FORMAT_BYTES);
+  if (gst_pad_peer_query (parse->sinkpad, query))
+    gst_query_parse_seeking (query, NULL, &seekable, NULL, NULL);
+  else
+    GST_DEBUG_OBJECT (aacparse, "seeking query failed");
+
+  gst_query_unref (query);
+
+  GST_INFO_OBJECT (aacparse, "byte seekable: %d", seekable);
+
+  aacparse->byte_seekable = seekable;
+}
 #endif /* TIZEN_FEATURE_AACPARSE_MODIFICATION */