From 31427072e3fa5da886abbfea03d6f2c6009248e8 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 20 Apr 2001 19:21:51 +0000 Subject: [PATCH] Added caps proxying and bufferpool passing to identity so that Original commit message from CVS: Added caps proxying and bufferpool passing to identity so that -launch disksrc ! mad ! identity ! osssink works. --- gst/elements/gstidentity.c | 55 +++++++++++++++++++++++++++++++++++++++--- gst/elements/gstidentity.h | 1 + plugins/elements/gstidentity.c | 55 +++++++++++++++++++++++++++++++++++++++--- plugins/elements/gstidentity.h | 1 + 4 files changed, 104 insertions(+), 8 deletions(-) diff --git a/gst/elements/gstidentity.c b/gst/elements/gstidentity.c index 4e209a1..1e92dc5 100644 --- a/gst/elements/gstidentity.c +++ b/gst/elements/gstidentity.c @@ -44,6 +44,7 @@ enum { ARG_0, ARG_LOOP_BASED, ARG_SLEEP_TIME, + ARG_SILENT, }; @@ -92,23 +93,59 @@ gst_identity_class_init (GstIdentityClass *klass) GTK_ARG_READWRITE, ARG_LOOP_BASED); gtk_object_add_arg_type ("GstIdentity::sleep_time", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_SLEEP_TIME); + gtk_object_add_arg_type ("GstIdentity::silent", GTK_TYPE_BOOL, + GTK_ARG_READWRITE, ARG_SILENT); gtkobject_class->set_arg = gst_identity_set_arg; gtkobject_class->get_arg = gst_identity_get_arg; } +static GstBufferPool* +gst_identity_get_bufferpool (GstPad *pad) +{ + GstIdentity *identity; + + identity = GST_IDENTITY (gst_pad_get_parent (pad)); + + return gst_pad_get_bufferpool (identity->srcpad); +} + +static GstPadNegotiateReturn +gst_identity_negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data) +{ + GstIdentity *identity; + + identity = GST_IDENTITY (gst_pad_get_parent (pad)); + + return gst_pad_negotiate_proxy (pad, identity->sinkpad, caps); +} + +static GstPadNegotiateReturn +gst_identity_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data) +{ + GstIdentity *identity; + + identity = GST_IDENTITY (gst_pad_get_parent (pad)); + + return gst_pad_negotiate_proxy (pad, identity->srcpad, caps); +} + static void gst_identity_init (GstIdentity *identity) { identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad); gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain); + gst_pad_set_bufferpool_function (identity->sinkpad, gst_identity_get_bufferpool); + gst_pad_set_negotiate_function (identity->sinkpad, gst_identity_negotiate_sink); identity->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad); + gst_pad_set_negotiate_function (identity->srcpad, gst_identity_negotiate_src); identity->loop_based = FALSE; - identity->sleep_time = 10000; + identity->sleep_time = 0; + identity->silent = FALSE; } static void @@ -121,11 +158,14 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf) g_return_if_fail (buf != NULL); identity = GST_IDENTITY (gst_pad_get_parent (pad)); - g_print("identity: ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(pad)); + + if (!identity->silent) + g_print("identity: ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(pad)); gst_pad_push (identity->srcpad, buf); - usleep (identity->sleep_time); + if (identity->sleep_time) + usleep (identity->sleep_time); } static void @@ -145,7 +185,8 @@ gst_identity_loop (GstElement *element) gst_pad_push (identity->srcpad, buf); - usleep (identity->sleep_time); + if (identity->sleep_time) + usleep (identity->sleep_time); } while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element)); } @@ -175,6 +216,9 @@ gst_identity_set_arg (GtkObject *object, GtkArg *arg, guint id) case ARG_SLEEP_TIME: identity->sleep_time = GTK_VALUE_UINT (*arg); break; + case ARG_SILENT: + identity->silent = GTK_VALUE_BOOL (*arg); + break; default: break; } @@ -195,6 +239,9 @@ static void gst_identity_get_arg(GtkObject *object,GtkArg *arg,guint id) { case ARG_SLEEP_TIME: GTK_VALUE_UINT (*arg) = identity->sleep_time; break; + case ARG_SILENT: + GTK_VALUE_BOOL (*arg) = identity->silent; + break; default: arg->type = GTK_TYPE_INVALID; break; diff --git a/gst/elements/gstidentity.h b/gst/elements/gstidentity.h index 3c53648..129c492 100644 --- a/gst/elements/gstidentity.h +++ b/gst/elements/gstidentity.h @@ -60,6 +60,7 @@ struct _GstIdentity { gboolean loop_based; guint sleep_time; + gboolean silent; }; struct _GstIdentityClass { diff --git a/plugins/elements/gstidentity.c b/plugins/elements/gstidentity.c index 4e209a1..1e92dc5 100644 --- a/plugins/elements/gstidentity.c +++ b/plugins/elements/gstidentity.c @@ -44,6 +44,7 @@ enum { ARG_0, ARG_LOOP_BASED, ARG_SLEEP_TIME, + ARG_SILENT, }; @@ -92,23 +93,59 @@ gst_identity_class_init (GstIdentityClass *klass) GTK_ARG_READWRITE, ARG_LOOP_BASED); gtk_object_add_arg_type ("GstIdentity::sleep_time", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_SLEEP_TIME); + gtk_object_add_arg_type ("GstIdentity::silent", GTK_TYPE_BOOL, + GTK_ARG_READWRITE, ARG_SILENT); gtkobject_class->set_arg = gst_identity_set_arg; gtkobject_class->get_arg = gst_identity_get_arg; } +static GstBufferPool* +gst_identity_get_bufferpool (GstPad *pad) +{ + GstIdentity *identity; + + identity = GST_IDENTITY (gst_pad_get_parent (pad)); + + return gst_pad_get_bufferpool (identity->srcpad); +} + +static GstPadNegotiateReturn +gst_identity_negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data) +{ + GstIdentity *identity; + + identity = GST_IDENTITY (gst_pad_get_parent (pad)); + + return gst_pad_negotiate_proxy (pad, identity->sinkpad, caps); +} + +static GstPadNegotiateReturn +gst_identity_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data) +{ + GstIdentity *identity; + + identity = GST_IDENTITY (gst_pad_get_parent (pad)); + + return gst_pad_negotiate_proxy (pad, identity->srcpad, caps); +} + static void gst_identity_init (GstIdentity *identity) { identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad); gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain); + gst_pad_set_bufferpool_function (identity->sinkpad, gst_identity_get_bufferpool); + gst_pad_set_negotiate_function (identity->sinkpad, gst_identity_negotiate_sink); identity->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad); + gst_pad_set_negotiate_function (identity->srcpad, gst_identity_negotiate_src); identity->loop_based = FALSE; - identity->sleep_time = 10000; + identity->sleep_time = 0; + identity->silent = FALSE; } static void @@ -121,11 +158,14 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf) g_return_if_fail (buf != NULL); identity = GST_IDENTITY (gst_pad_get_parent (pad)); - g_print("identity: ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(pad)); + + if (!identity->silent) + g_print("identity: ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(pad)); gst_pad_push (identity->srcpad, buf); - usleep (identity->sleep_time); + if (identity->sleep_time) + usleep (identity->sleep_time); } static void @@ -145,7 +185,8 @@ gst_identity_loop (GstElement *element) gst_pad_push (identity->srcpad, buf); - usleep (identity->sleep_time); + if (identity->sleep_time) + usleep (identity->sleep_time); } while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element)); } @@ -175,6 +216,9 @@ gst_identity_set_arg (GtkObject *object, GtkArg *arg, guint id) case ARG_SLEEP_TIME: identity->sleep_time = GTK_VALUE_UINT (*arg); break; + case ARG_SILENT: + identity->silent = GTK_VALUE_BOOL (*arg); + break; default: break; } @@ -195,6 +239,9 @@ static void gst_identity_get_arg(GtkObject *object,GtkArg *arg,guint id) { case ARG_SLEEP_TIME: GTK_VALUE_UINT (*arg) = identity->sleep_time; break; + case ARG_SILENT: + GTK_VALUE_BOOL (*arg) = identity->silent; + break; default: arg->type = GTK_TYPE_INVALID; break; diff --git a/plugins/elements/gstidentity.h b/plugins/elements/gstidentity.h index 3c53648..129c492 100644 --- a/plugins/elements/gstidentity.h +++ b/plugins/elements/gstidentity.h @@ -60,6 +60,7 @@ struct _GstIdentity { gboolean loop_based; guint sleep_time; + gboolean silent; }; struct _GstIdentityClass { -- 2.7.4