audiodecoder: Add sink and src query virtual method
authorWonchul Lee <chul0812@gmail.com>
Thu, 2 Apr 2015 15:44:12 +0000 (00:44 +0900)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 23 Apr 2015 18:29:20 +0000 (19:29 +0100)
API: GstAudioDecoderClass::src_query()
API: GstAudioDecoderClass::sink_query()

https://bugzilla.gnome.org/show_bug.cgi?id=747293

gst-libs/gst/audio/gstaudiodecoder.c
gst-libs/gst/audio/gstaudiodecoder.h

index 1473f51..db70837 100644 (file)
@@ -383,6 +383,10 @@ static gboolean gst_audio_decoder_negotiate_default (GstAudioDecoder * dec);
 static gboolean gst_audio_decoder_negotiate_unlocked (GstAudioDecoder * dec);
 static gboolean gst_audio_decoder_handle_gap (GstAudioDecoder * dec,
     GstEvent * event);
+static gboolean gst_audio_decoder_sink_query_default (GstAudioDecoder * dec,
+    GstQuery * query);
+static gboolean gst_audio_decoder_src_query_default (GstAudioDecoder * dec,
+    GstQuery * query);
 
 static GstElementClass *parent_class = NULL;
 
@@ -470,6 +474,10 @@ gst_audio_decoder_class_init (GstAudioDecoderClass * klass)
       GST_DEBUG_FUNCPTR (gst_audio_decoder_decide_allocation_default);
   audiodecoder_class->negotiate =
       GST_DEBUG_FUNCPTR (gst_audio_decoder_negotiate_default);
+  audiodecoder_class->sink_query =
+      GST_DEBUG_FUNCPTR (gst_audio_decoder_sink_query_default);
+  audiodecoder_class->src_query =
+      GST_DEBUG_FUNCPTR (gst_audio_decoder_src_query_default);
 }
 
 static void
@@ -2541,15 +2549,11 @@ gst_audio_decoder_sink_getcaps (GstAudioDecoder * decoder, GstCaps * filter)
   return caps;
 }
 
-
 static gboolean
-gst_audio_decoder_sink_query (GstPad * pad, GstObject * parent,
-    GstQuery * query)
+gst_audio_decoder_sink_query_default (GstAudioDecoder * dec, GstQuery * query)
 {
+  GstPad *pad = GST_AUDIO_DECODER_SINK_PAD (dec);
   gboolean res = FALSE;
-  GstAudioDecoder *dec;
-
-  dec = GST_AUDIO_DECODER (parent);
 
   GST_LOG_OBJECT (dec, "handling query: %" GST_PTR_FORMAT, query);
 
@@ -2630,7 +2634,7 @@ gst_audio_decoder_sink_query (GstPad * pad, GstObject * parent,
       /* fall-through */
     }
     default:
-      res = gst_pad_query_default (pad, parent, query);
+      res = gst_pad_query_default (pad, GST_OBJECT_CAST (dec), query);
       break;
   }
 
@@ -2638,18 +2642,35 @@ error:
   return res;
 }
 
+static gboolean
+gst_audio_decoder_sink_query (GstPad * pad, GstObject * parent,
+    GstQuery * query)
+{
+  GstAudioDecoderClass *dec_class;
+  GstAudioDecoder *dec;
+  gboolean ret = FALSE;
+
+  dec = GST_AUDIO_DECODER (parent);
+  dec_class = GST_AUDIO_DECODER_GET_CLASS (dec);
+
+  GST_DEBUG_OBJECT (pad, "received query %" GST_PTR_FORMAT, query);
+
+  if (dec_class->sink_query)
+    ret = dec_class->sink_query (dec, query);
+
+  return ret;
+}
+
 /* FIXME ? are any of these queries (other than latency) a decoder's business ??
  * also, the conversion stuff might seem to make sense, but seems to not mind
  * segment stuff etc at all
  * Supposedly that's backward compatibility ... */
 static gboolean
-gst_audio_decoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
+gst_audio_decoder_src_query_default (GstAudioDecoder * dec, GstQuery * query)
 {
-  GstAudioDecoder *dec;
+  GstPad *pad = GST_AUDIO_DECODER_SRC_PAD (dec);
   gboolean res = FALSE;
 
-  dec = GST_AUDIO_DECODER (parent);
-
   GST_LOG_OBJECT (dec, "handling query: %" GST_PTR_FORMAT, query);
 
   switch (GST_QUERY_TYPE (query)) {
@@ -2658,7 +2679,7 @@ gst_audio_decoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
       GstFormat format;
 
       /* upstream in any case */
-      if ((res = gst_pad_query_default (pad, parent, query)))
+      if ((res = gst_pad_query_default (pad, GST_OBJECT_CAST (dec), query)))
         break;
 
       gst_query_parse_duration (query, &format, NULL);
@@ -2755,7 +2776,7 @@ gst_audio_decoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
       break;
     }
     default:
-      res = gst_pad_query_default (pad, parent, query);
+      res = gst_pad_query_default (pad, GST_OBJECT_CAST (dec), query);
       break;
   }
 
@@ -2763,6 +2784,24 @@ gst_audio_decoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
 }
 
 static gboolean
+gst_audio_decoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
+{
+  GstAudioDecoder *dec;
+  GstAudioDecoderClass *dec_class;
+  gboolean ret = FALSE;
+
+  dec = GST_AUDIO_DECODER (parent);
+  dec_class = GST_AUDIO_DECODER_GET_CLASS (dec);
+
+  GST_DEBUG_OBJECT (pad, "received query %" GST_PTR_FORMAT, query);
+
+  if (dec_class->src_query)
+    ret = dec_class->src_query (dec, query);
+
+  return ret;
+}
+
+static gboolean
 gst_audio_decoder_stop (GstAudioDecoder * dec)
 {
   GstAudioDecoderClass *klass;
index 56cfa46..10317fc 100644 (file)
@@ -231,6 +231,16 @@ struct _GstAudioDecoder
  *                      Propose buffer allocation parameters for upstream elements.
  *                      Subclasses should chain up to the parent implementation to
  *                      invoke the default handler.
+ * @sink_query:     Optional.
+ *                  Query handler on the sink pad. This function should
+ *                  return TRUE if the query could be performed. Subclasses
+ *                  should chain up to the parent implementation to invoke the
+ *                  default handler. Since 1.6
+ * @src_query:      Optional.
+ *                  Query handler on the source pad. This function should
+ *                  return TRUE if the query could be performed. Subclasses
+ *                  should chain up to the parent implementation to invoke the
+ *                  default handler. Since 1.6
  * @getcaps:        Optional.
  *                  Allows for a custom sink getcaps implementation.
  *                  If not implemented,
@@ -283,11 +293,15 @@ struct _GstAudioDecoderClass
   gboolean      (*propose_allocation) (GstAudioDecoder *dec,
                                        GstQuery * query);
 
+  gboolean      (*sink_query)         (GstAudioDecoder *dec, GstQuery *query);
+
+  gboolean      (*src_query)          (GstAudioDecoder *dec, GstQuery *query);
+
   GstCaps *     (*getcaps)            (GstAudioDecoder * dec,
                                        GstCaps * filter);
 
   /*< private >*/
-  gpointer       _gst_reserved[GST_PADDING_LARGE - 1];
+  gpointer       _gst_reserved[GST_PADDING_LARGE - 3];
 };
 
 GType             gst_audio_decoder_get_type (void);