Permalink
Browse files

Add pad query

Signed-off-by: Felipe Contreras <felipe.contreras@nokia.com>
  • Loading branch information...
1 parent a7ebf3a commit 37709656203a708c0e3348d9110aaa4b45ba7692 Felipe Contreras committed with Sep 4, 2009
Showing with 33 additions and 0 deletions.
  1. +33 −0 gstavdec.c
View
@@ -210,6 +210,38 @@ pad_chain(GstPad *pad,
return ret;
}
+static gboolean
+pad_query(GstPad *pad,
+ GstQuery *query)
+{
+ GstAVDec *self;
+ gboolean res = FALSE;
+
+ self = GST_AVDEC(GST_PAD_PARENT(pad));
+
+ switch (GST_QUERY_TYPE(query)) {
+ case GST_QUERY_CONVERT:
+ {
+ GstFormat src_fmt, dest_fmt;
+ gint64 src_val, dest_val;
+
+ gst_query_parse_convert(query, &src_fmt, &src_val, &dest_fmt, &dest_val);
+ if (src_fmt != GST_FORMAT_DEFAULT || dest_fmt != GST_FORMAT_TIME)
+ break;
+
+ dest_val = gst_util_uint64_scale_int(src_val, GST_SECOND, self->av_ctx->sample_rate);
+
+ gst_query_set_convert(query, src_fmt, src_val, dest_fmt, dest_val);
+ return TRUE;
+ }
+ default:
+ res = gst_pad_query_default(pad, query);
+ break;
+ }
+
+ return res;
+}
+
static GstStateChangeReturn
change_state(GstElement *element,
GstStateChange transition)
@@ -303,6 +335,7 @@ instance_init(GTypeInstance *instance,
gst_pad_new_from_template(gst_element_class_get_pad_template(element_class, "src"), "src");
gst_pad_use_fixed_caps(self->srcpad);
+ gst_pad_set_query_function(self->sinkpad, pad_query);
gst_element_add_pad(GST_ELEMENT(self), self->sinkpad);
gst_element_add_pad(GST_ELEMENT(self), self->srcpad);

0 comments on commit 3770965

Please sign in to comment.