From e40880a90e6eebcee0ce1c4868d31b76d11c2bf0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 19 Jan 2001 00:02:53 +0000 Subject: [PATCH] And here they are.... Original commit message from CVS: And here they are.... --- gst/{elements => }/gstqueue.c | 7 +- gst/{elements => }/gstqueue.h | 3 +- gst/gsttypefind.c | 195 ++++++++++++++++++++++++++++++++++++++++++ gst/gsttypefind.h | 74 ++++++++++++++++ plugins/elements/gstqueue.c | 7 +- plugins/elements/gstqueue.h | 3 +- 6 files changed, 281 insertions(+), 8 deletions(-) rename gst/{elements => }/gstqueue.c (99%) rename gst/{elements => }/gstqueue.h (98%) create mode 100644 gst/gsttypefind.c create mode 100644 gst/gsttypefind.h diff --git a/gst/elements/gstqueue.c b/gst/gstqueue.c similarity index 99% rename from gst/elements/gstqueue.c rename to gst/gstqueue.c index b3512e2..f5f1b86 100644 --- a/gst/elements/gstqueue.c +++ b/gst/gstqueue.c @@ -28,9 +28,12 @@ #define STATUS(A) #endif -#include "gstqueue.h" +#include + +#include "config.h" +#include "gst_private.h" -#include +#include "gstqueue.h" GstElementDetails gst_queue_details = { "Queue", diff --git a/gst/elements/gstqueue.h b/gst/gstqueue.h similarity index 98% rename from gst/elements/gstqueue.h rename to gst/gstqueue.h index 9b03979..6063467 100644 --- a/gst/elements/gstqueue.h +++ b/gst/gstqueue.h @@ -25,8 +25,7 @@ #define __GST_QUEUE_H__ -#include -#include +#include #ifdef __cplusplus diff --git a/gst/gsttypefind.c b/gst/gsttypefind.c new file mode 100644 index 0000000..6d8fe21 --- /dev/null +++ b/gst/gsttypefind.c @@ -0,0 +1,195 @@ +/* GStreamer + * Copyright (C) 1999,2000 Erik Walthinsen + * 2000 Wim Taymans + * + * gsttypefind.c: + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#include "gst_private.h" + +#include "gsttype.h" + +#include "gsttypefind.h" + +//#define GST_DEBUG_ENABLED + +GstElementDetails gst_typefind_details = { + "TypeFind", + "TypeFind", + "Finds the media type", + VERSION, + "Erik Walthinsen " + "Wim Taymans ", + "(C) 1999", +}; + + +/* TypeFind signals and args */ +enum { + HAVE_TYPE, + LAST_SIGNAL +}; + +enum { + ARG_0, + ARG_CAPS, +}; + + +static void gst_typefind_class_init (GstTypeFindClass *klass); +static void gst_typefind_init (GstTypeFind *typefind); + +static void gst_typefind_set_arg (GtkObject *object, GtkArg *arg, guint id); +static void gst_typefind_get_arg (GtkObject *object, GtkArg *arg, guint id); + +static void gst_typefind_chain (GstPad *pad, GstBuffer *buf); + +static GstElementClass *parent_class = NULL; +static guint gst_typefind_signals[LAST_SIGNAL] = { 0 }; + +GtkType +gst_typefind_get_type(void) { + static GtkType typefind_type = 0; + + if (!typefind_type) { + static const GtkTypeInfo typefind_info = { + "GstTypeFind", + sizeof(GstTypeFind), + sizeof(GstTypeFindClass), + (GtkClassInitFunc)gst_typefind_class_init, + (GtkObjectInitFunc)gst_typefind_init, + (GtkArgSetFunc)gst_typefind_set_arg, + (GtkArgGetFunc)gst_typefind_get_arg, + (GtkClassInitFunc)NULL, + }; + typefind_type = gtk_type_unique(GST_TYPE_ELEMENT,&typefind_info); + } + return typefind_type; +} + +static void +gst_typefind_class_init (GstTypeFindClass *klass) +{ + GtkObjectClass *gtkobject_class; + + gtkobject_class = (GtkObjectClass*)klass; + + parent_class = gtk_type_class (GST_TYPE_ELEMENT); + + gtk_object_add_arg_type("GstTypeFind::caps", GTK_TYPE_POINTER, + GTK_ARG_READABLE, ARG_CAPS); + + gst_typefind_signals[HAVE_TYPE] = + gtk_signal_new ("have_type", GTK_RUN_LAST, gtkobject_class->type, + GTK_SIGNAL_OFFSET (GstTypeFindClass, have_type), + gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); + + gtk_object_class_add_signals (gtkobject_class, gst_typefind_signals, + LAST_SIGNAL); + + gtkobject_class->set_arg = gst_typefind_set_arg; + gtkobject_class->get_arg = gst_typefind_get_arg; +} + +static void +gst_typefind_init (GstTypeFind *typefind) +{ + typefind->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); + gst_element_add_pad (GST_ELEMENT (typefind), typefind->sinkpad); + gst_pad_set_chain_function (typefind->sinkpad, gst_typefind_chain); +} + +static void +gst_typefind_set_arg (GtkObject *object, GtkArg *arg, guint id) +{ + GstTypeFind *typefind; + + /* it's not null if we got it, but it might not be ours */ + g_return_if_fail (GST_IS_TYPEFIND (object)); + + typefind = GST_TYPEFIND (object); + + switch(id) { + default: + break; + } +} + +static void +gst_typefind_get_arg (GtkObject *object, GtkArg *arg, guint id) +{ + GstTypeFind *typefind; + + /* it's not null if we got it, but it might not be ours */ + g_return_if_fail (GST_IS_TYPEFIND (object)); + + typefind = GST_TYPEFIND (object); + + switch(id) { + case ARG_CAPS: + GTK_VALUE_POINTER (*arg) = typefind->caps; + break; + default: + break; + } +} + +static void +gst_typefind_chain (GstPad *pad, GstBuffer *buf) +{ + GstTypeFind *typefind; + GList *type_list; + GstType *type; + + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); + g_return_if_fail (buf != NULL); + + typefind = GST_TYPEFIND (pad->parent); + GST_DEBUG (0,"got buffer of %d bytes in '%s'\n", + GST_BUFFER_SIZE (buf), gst_element_get_name (GST_ELEMENT (typefind))); + + type_list = gst_type_get_list (); + + while (type_list) { + GSList *funcs; + type = (GstType *)type_list->data; + + funcs = type->typefindfuncs; + + while (funcs) { + GstTypeFindFunc typefindfunc = (GstTypeFindFunc)funcs->data; + GstCaps *caps; + + GST_DEBUG (0,"try type :%d \"%s\"\n", type->id, type->mime); + if (typefindfunc && (caps = typefindfunc (buf, type))) { + GST_DEBUG (0,"found type :%d \"%s\"\n", caps->id, type->mime); + typefind->caps = caps; + gtk_signal_emit (GTK_OBJECT (typefind), gst_typefind_signals[HAVE_TYPE], + typefind->caps); + goto end; + } + funcs = g_slist_next (funcs); + } + + type_list = g_list_next (type_list); + } +end: + gst_buffer_unref (buf); +} diff --git a/gst/gsttypefind.h b/gst/gsttypefind.h new file mode 100644 index 0000000..6b42015 --- /dev/null +++ b/gst/gsttypefind.h @@ -0,0 +1,74 @@ +/* GStreamer + * Copyright (C) 1999,2000 Erik Walthinsen + * 2000 Wim Taymans + * + * gsttypefind.h: + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#ifndef __GST_TYPEFIND_H__ +#define __GST_TYPEFIND_H__ + + +#include + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +GstElementDetails gst_typefind_details; + +#define GST_TYPE_TYPEFIND \ + (gst_typefind_get_type()) +#define GST_TYPEFIND(obj) \ + (GTK_CHECK_CAST((obj),GST_TYPE_TYPEFIND,GstTypeFind)) +#define GST_TYPEFIND_CLASS(klass) \ + (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_TYPEFIND,GstTypeFindClass)) +#define GST_IS_TYPEFIND(obj) \ + (GTK_CHECK_TYPE((obj),GST_TYPE_TYPEFIND)) +#define GST_IS_TYPEFIND_CLASS(obj) \ + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_TYPEFIND)) + +typedef struct _GstTypeFind GstTypeFind; +typedef struct _GstTypeFindClass GstTypeFindClass; + +struct _GstTypeFind { + GstElement element; + + GstPad *sinkpad; + + GstCaps *caps; +}; + +struct _GstTypeFindClass { + GstElementClass parent_class; + + /* signals */ + void (*have_type) (GstElement *element); +}; + +GtkType gst_typefind_get_type (void); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __GST_TYPEFIND_H__ */ diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index b3512e2..f5f1b86 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -28,9 +28,12 @@ #define STATUS(A) #endif -#include "gstqueue.h" +#include + +#include "config.h" +#include "gst_private.h" -#include +#include "gstqueue.h" GstElementDetails gst_queue_details = { "Queue", diff --git a/plugins/elements/gstqueue.h b/plugins/elements/gstqueue.h index 9b03979..6063467 100644 --- a/plugins/elements/gstqueue.h +++ b/plugins/elements/gstqueue.h @@ -25,8 +25,7 @@ #define __GST_QUEUE_H__ -#include -#include +#include #ifdef __cplusplus -- 2.7.4