From 93f541efef52384cf7811c03d1de0ed19e8f2ad9 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Mon, 8 Nov 2004 15:45:31 +0000 Subject: [PATCH] gst/elements/: Subtract size of internally stored data from position queries. Original commit message from CVS: * gst/elements/gstfakesink.c: (gst_fakesink_class_init): * gst/elements/gstidentity.c: (gst_identity_class_init): Use G_SIGNAL_TYPE_STATIC_SCOPE, patch by Christophe Fergeau (#157263). * gst/elements/gsttypefindelement.c: (gst_type_find_element_init), (gst_type_find_handle_src_query): Subtract size of internally stored data from position queries. --- ChangeLog | 10 +++++++++ gst/elements/gstfakesink.c | 2 +- gst/elements/gstidentity.c | 3 ++- gst/elements/gsttypefindelement.c | 32 +++++++++++++++++++++++++++ plugins/elements/gstfakesink.c | 2 +- plugins/elements/gstidentity.c | 3 ++- plugins/elements/gsttypefindelement.c | 32 +++++++++++++++++++++++++++ 7 files changed, 80 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2acceb4515..1d57a9b8bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-11-08 Ronald S. Bultje + + * gst/elements/gstfakesink.c: (gst_fakesink_class_init): + * gst/elements/gstidentity.c: (gst_identity_class_init): + Use G_SIGNAL_TYPE_STATIC_SCOPE, patch by Christophe Fergeau + (#157263). + * gst/elements/gsttypefindelement.c: (gst_type_find_element_init), + (gst_type_find_handle_src_query): + Subtract size of internally stored data from position queries. + 2004-11-07 Martin Soto * gst/schedulers/fairscheduler.c: diff --git a/gst/elements/gstfakesink.c b/gst/elements/gstfakesink.c index 2327db80b0..851b6f9375 100644 --- a/gst/elements/gstfakesink.c +++ b/gst/elements/gstfakesink.c @@ -167,7 +167,7 @@ gst_fakesink_class_init (GstFakeSinkClass * klass) g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstFakeSinkClass, handoff), NULL, NULL, gst_marshal_VOID__BOXED_OBJECT, G_TYPE_NONE, 2, - GST_TYPE_BUFFER, GST_TYPE_PAD); + GST_TYPE_BUFFER | G_SIGNAL_TYPE_STATIC_SCOPE, GST_TYPE_PAD); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesink_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesink_get_property); diff --git a/gst/elements/gstidentity.c b/gst/elements/gstidentity.c index af8817ee51..835697c209 100644 --- a/gst/elements/gstidentity.c +++ b/gst/elements/gstidentity.c @@ -181,7 +181,8 @@ gst_identity_class_init (GstIdentityClass * klass) gst_identity_signals[SIGNAL_HANDOFF] = g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL, - gst_marshal_VOID__BOXED, G_TYPE_NONE, 1, GST_TYPE_BUFFER); + gst_marshal_VOID__BOXED, G_TYPE_NONE, 1, + GST_TYPE_BUFFER | G_SIGNAL_TYPE_STATIC_SCOPE); gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_identity_finalize); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property); diff --git a/gst/elements/gsttypefindelement.c b/gst/elements/gsttypefindelement.c index daf33bac61..8bc760eb3e 100644 --- a/gst/elements/gsttypefindelement.c +++ b/gst/elements/gsttypefindelement.c @@ -106,6 +106,8 @@ static void gst_type_find_element_get_property (GObject * object, static const GstEventMask *gst_type_find_element_src_event_mask (GstPad * pad); static gboolean gst_type_find_element_src_event (GstPad * pad, GstEvent * event); +static gboolean gst_type_find_handle_src_query (GstPad * pad, + GstQueryType type, GstFormat * fmt, gint64 * value); static void push_buffer_store (GstTypeFindElement * typefind); static void gst_type_find_element_chain (GstPad * sinkpad, GstData * data); @@ -189,6 +191,8 @@ gst_type_find_element_init (GstTypeFindElement * typefind) gst_pad_set_event_function (typefind->src, gst_type_find_element_src_event); gst_pad_set_event_mask_function (typefind->src, gst_type_find_element_src_event_mask); + gst_pad_set_query_function (typefind->src, + GST_DEBUG_FUNCPTR (gst_type_find_handle_src_query)); gst_pad_use_explicit_caps (typefind->src); gst_element_add_pad (GST_ELEMENT (typefind), typefind->src); @@ -261,6 +265,34 @@ gst_type_find_element_get_property (GObject * object, guint prop_id, break; } } + +static gboolean +gst_type_find_handle_src_query (GstPad * pad, + GstQueryType type, GstFormat * fmt, gint64 * value) +{ + GstTypeFindElement *typefind = + GST_TYPE_FIND_ELEMENT (gst_pad_get_parent (pad)); + gboolean res; + + res = gst_pad_query (GST_PAD_PEER (typefind->sink), type, fmt, value); + if (!res) + return FALSE; + + if (type == GST_QUERY_POSITION && typefind->store != NULL) { + /* FIXME: this code assumes that there's no discont in the queue */ + switch (*fmt) { + case GST_FORMAT_BYTES: + *value -= gst_buffer_store_get_size (typefind->store, 0); + break; + default: + /* FIXME */ + break; + } + } + + return TRUE; +} + static const GstEventMask * gst_type_find_element_src_event_mask (GstPad * pad) { diff --git a/plugins/elements/gstfakesink.c b/plugins/elements/gstfakesink.c index 2327db80b0..851b6f9375 100644 --- a/plugins/elements/gstfakesink.c +++ b/plugins/elements/gstfakesink.c @@ -167,7 +167,7 @@ gst_fakesink_class_init (GstFakeSinkClass * klass) g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstFakeSinkClass, handoff), NULL, NULL, gst_marshal_VOID__BOXED_OBJECT, G_TYPE_NONE, 2, - GST_TYPE_BUFFER, GST_TYPE_PAD); + GST_TYPE_BUFFER | G_SIGNAL_TYPE_STATIC_SCOPE, GST_TYPE_PAD); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesink_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesink_get_property); diff --git a/plugins/elements/gstidentity.c b/plugins/elements/gstidentity.c index af8817ee51..835697c209 100644 --- a/plugins/elements/gstidentity.c +++ b/plugins/elements/gstidentity.c @@ -181,7 +181,8 @@ gst_identity_class_init (GstIdentityClass * klass) gst_identity_signals[SIGNAL_HANDOFF] = g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL, - gst_marshal_VOID__BOXED, G_TYPE_NONE, 1, GST_TYPE_BUFFER); + gst_marshal_VOID__BOXED, G_TYPE_NONE, 1, + GST_TYPE_BUFFER | G_SIGNAL_TYPE_STATIC_SCOPE); gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_identity_finalize); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property); diff --git a/plugins/elements/gsttypefindelement.c b/plugins/elements/gsttypefindelement.c index daf33bac61..8bc760eb3e 100644 --- a/plugins/elements/gsttypefindelement.c +++ b/plugins/elements/gsttypefindelement.c @@ -106,6 +106,8 @@ static void gst_type_find_element_get_property (GObject * object, static const GstEventMask *gst_type_find_element_src_event_mask (GstPad * pad); static gboolean gst_type_find_element_src_event (GstPad * pad, GstEvent * event); +static gboolean gst_type_find_handle_src_query (GstPad * pad, + GstQueryType type, GstFormat * fmt, gint64 * value); static void push_buffer_store (GstTypeFindElement * typefind); static void gst_type_find_element_chain (GstPad * sinkpad, GstData * data); @@ -189,6 +191,8 @@ gst_type_find_element_init (GstTypeFindElement * typefind) gst_pad_set_event_function (typefind->src, gst_type_find_element_src_event); gst_pad_set_event_mask_function (typefind->src, gst_type_find_element_src_event_mask); + gst_pad_set_query_function (typefind->src, + GST_DEBUG_FUNCPTR (gst_type_find_handle_src_query)); gst_pad_use_explicit_caps (typefind->src); gst_element_add_pad (GST_ELEMENT (typefind), typefind->src); @@ -261,6 +265,34 @@ gst_type_find_element_get_property (GObject * object, guint prop_id, break; } } + +static gboolean +gst_type_find_handle_src_query (GstPad * pad, + GstQueryType type, GstFormat * fmt, gint64 * value) +{ + GstTypeFindElement *typefind = + GST_TYPE_FIND_ELEMENT (gst_pad_get_parent (pad)); + gboolean res; + + res = gst_pad_query (GST_PAD_PEER (typefind->sink), type, fmt, value); + if (!res) + return FALSE; + + if (type == GST_QUERY_POSITION && typefind->store != NULL) { + /* FIXME: this code assumes that there's no discont in the queue */ + switch (*fmt) { + case GST_FORMAT_BYTES: + *value -= gst_buffer_store_get_size (typefind->store, 0); + break; + default: + /* FIXME */ + break; + } + } + + return TRUE; +} + static const GstEventMask * gst_type_find_element_src_event_mask (GstPad * pad) {