From 196c67d7fff2b99f7454a46c96f41db76386db00 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 13 Dec 2000 19:29:35 +0000 Subject: [PATCH] Changed the GstPadFactory and added the GstPadTemplate. Original commit message from CVS: Changed the GstPadFactory and added the GstPadTemplate. The GstPadFactory is an easy way to define a pad with capabilities. The GstPadFactory is converted into a GstPadTemplate. The template is used to create new pads and to expose the possible pads used in an element to the plugin system. updated mp3parse, mpg123, cdparanoia to the new API. Rerun gstreamer-register because the XML definition has changed. --- docs/gst/gstreamer-decl.txt | 418 +++++++++++++++++++++++----- docs/gst/gstreamer-sections.txt | 6 + docs/gst/tmpl/gstconnection.sgml | 8 - docs/gst/tmpl/gstelement.sgml | 25 +- docs/gst/tmpl/gstpad.sgml | 23 +- docs/gst/tmpl/gstreamer-unused.sgml | 169 +++++++---- docs/gst/tmpl/gstsrc.sgml | 18 -- docs/gst/tmpl/gsttype.sgml | 20 +- gst/elements/gstaudiosink.c | 13 +- gst/elements/gsthttpsrc.c | 2 +- gst/gstcaps.c | 23 +- gst/gstcaps.h | 1 + gst/gstelement.h | 6 +- gst/gstelementfactory.c | 51 ++-- gst/gstpad.c | 99 ++++--- gst/gstpad.h | 31 ++- gst/gsttype.c | 24 +- plugins/elements/gstaudiosink.c | 13 +- plugins/elements/gsthttpsrc.c | 2 +- 19 files changed, 639 insertions(+), 313 deletions(-) diff --git a/docs/gst/gstreamer-decl.txt b/docs/gst/gstreamer-decl.txt index b573634bea..ed9e8a2517 100644 --- a/docs/gst/gstreamer-decl.txt +++ b/docs/gst/gstreamer-decl.txt @@ -71,6 +71,11 @@ cothread_context *ctx cothread_state *thread, cothread_func func,int argc, char **argv +cothread_getcurrent +int +void + + cothread_switch void cothread_state *thread @@ -105,14 +110,6 @@ void void void - -DEBUG -#define DEBUG(format, args...) g_print("DEBUG:(%d) " format, getpid() , ##args) - - -DEBUG -#define DEBUG(format, args...) - gst_bin_details extern GstElementDetails gst_bin_details; @@ -164,6 +161,7 @@ struct GstBin { cothread_context *threadcontext; gboolean use_cothreads; + GList *outside_schedules; }; @@ -506,11 +504,6 @@ void GstElement * gchar *name - -gst_connection_push -void -GstConnection *connection - GstElementState typedef enum { @@ -568,15 +561,22 @@ typedef enum { GST_ELEMENT_MULTI_IN = (1 << 4), GST_ELEMENT_THREAD_SUGGESTED = (1 << 5), GST_ELEMENT_NO_SEEK = (1 << 6), + + GST_ELEMENT_NEW_LOOPFUNC = (1 << 16), + GST_ELEMENT_COTHREAD_STOPPING = (1 << 17), } GstElementFlags; GST_ELEMENT_IS_MULTI_IN -#define GST_ELEMENT_IS_MULTI_IN(obj) (GST_FLAGS(obj) & GST_ELEMENT_MULTI_IN) +#define GST_ELEMENT_IS_MULTI_IN(obj) (GST_FLAG_IS_SET(obj,GST_ELEMENT_MULTI_IN)) GST_ELEMENT_IS_THREAD_SUGGESTED -#define GST_ELEMENT_IS_THREAD_SUGGESTED(obj) (GST_FLAGS(obj) & GST_ELEMENT_THREAD_SUGGESTED) +#define GST_ELEMENT_IS_THREAD_SUGGESTED(obj) (GST_FLAG_IS_SET(obj,GST_ELEMENT_THREAD_SUGGESTED)) + + +GST_ELEMENT_IS_COTHREAD_STOPPING +#define GST_ELEMENT_IS_COTHREAD_STOPPING(obj) (GST_FLAG_IS_SET(obj,GST_ELEMENT_COTHREAD_STOPPING)) GstElement @@ -618,7 +618,7 @@ struct GstElement { GstElementDetails struct GstElementDetails { gchar *longname; /* long, english name */ - gchar *class; /* type of element, kinda */ + gchar *klass; /* type of element, kinda */ gchar *description; /* insights of one form or another */ gchar *version; /* version of the element */ gchar *author; /* who wrote this thing? */ @@ -633,8 +633,7 @@ struct GstElementFactory { GstElementDetails *details; /* pointer to details struct */ - GList *src_types; - GList *sink_types; + GList *padfactories; }; @@ -742,14 +741,14 @@ gchar *name,GtkType type,GstElementDetails *details GstElementFactory *elementfactory -gst_elementfactory_add_src +gst_elementfactory_unregister void -GstElementFactory *elementfactory, guint16 id +GstElementFactory *elementfactory -gst_elementfactory_add_sink +gst_elementfactory_add_pad void -GstElementFactory *elementfactory, guint16 id +GstElementFactory *elementfactory,GstPadFactory *pad gst_elementfactory_find @@ -1053,11 +1052,11 @@ GstObject *object GST_PAD_CONNECTED -#define GST_PAD_CONNECTED(pad) (pad && (pad)->peer != NULL) +#define GST_PAD_CONNECTED(pad) ((pad) && (pad)->peer != NULL) GST_PAD_CAN_PULL -#define GST_PAD_CAN_PULL(pad) (pad && (pad)->pullfunc != NULL) +#define GST_PAD_CAN_PULL(pad) ((pad) && (pad)->pullfunc != NULL) GstPad @@ -1098,13 +1097,21 @@ typedef enum { GST_PAD_SINK, } GstPadDirection; + +GstPadFlags +typedef enum { + GST_PAD_DISABLED = (1 << 4), +} GstPadFlags; + GstPad struct GstPad { GstObject object; gchar *name; - guint16 type; + GstCaps *caps; + + cothread_state *threadstate; GstPadDirection direction; @@ -1113,15 +1120,35 @@ struct GstPad { GstBuffer *bufpen; GstPadChainFunction chainfunc; + GstPadPushFunction pushfunc; GstPadPullFunction pullfunc; GstPadPullRegionFunction pullregionfunc; - GstPadPushFunction pushfunc; GstPadQoSFunction qosfunc; GstObject *parent; GList *ghostparents; }; + +GstPadPresence +typedef enum { + GST_PAD_ALWAYS, + GST_PAD_SOMETIMES, +} GstPadPresence; + + +GstPadFactory + + +GstPadFactory +struct GstPadFactory { + gchar *nametemplate; + GstCapsFactory *caps; + GstPadDirection direction; + GstPadPresence presence; + gpointer priv; +}; + gst_pad_get_type GtkType @@ -1152,19 +1179,24 @@ GstPad *pad, GstPadChainFunction chain GstPad *pad, GstPadPullFunction pull +gst_pad_set_pullregion_function +void +GstPad *pad, GstPadPullRegionFunction pullregion + + gst_pad_set_qos_function void GstPad *pad, GstPadQoSFunction qos -gst_pad_get_type_id -guint16 -GstPad *pad +gst_pad_set_caps +void +GstPad *pad, GstCaps *caps -gst_pad_set_type_id -void -GstPad *pad, guint16 id +gst_pad_get_caps +GstCaps * +GstPad *pad gst_pad_set_name @@ -1246,6 +1278,26 @@ GstPad *pad, xmlNodePtr parent void xmlNodePtr parent, GstObject *element, GHashTable *elements + +gst_padfactory_create +GstPad * +GstPadFactory *factory, gchar *name + + +gst_padfactory_get_caps +GstCaps * +GstPadFactory *factory + + +gst_padfactory_save_thyself +xmlNodePtr +GstPadFactory *pad, xmlNodePtr parent + + +gst_padfactory_load_thyself +GstPadFactory * +xmlNodePtr parent + gst_pipeline_details extern GstElementDetails gst_pipeline_details; @@ -1354,6 +1406,11 @@ GModule *module gchar *name +gst_plugin_set_longname +void +GstPlugin *plugin, gchar *longname + + gst_plugin_load_all void void @@ -1364,19 +1421,14 @@ void gchar *name -gst_library_load -gboolean -gchar *name - - gst_plugin_load_absolute gboolean gchar *name -gst_plugin_set_longname -void -GstPlugin *plugin, gchar *longname +gst_library_load +gboolean +gchar *name gst_plugin_add_factory @@ -1520,8 +1572,8 @@ typedef enum { GstSrc struct GstSrc { - GstElement element; - gint32 flags; + GstElement element; + gint32 flags; }; @@ -1540,16 +1592,6 @@ struct GstSrc { void -gst_src_push -void -GstSrc *src - - -gst_src_push_region -void -GstSrc *src, gulong offset, gulong size - - gst_src_signal_eos void GstSrc *src @@ -1778,7 +1820,7 @@ struct GstType { gchar *mime; /* MIME type */ gchar *exts; /* space-delimited list of extensions */ - GstTypeFindFunc typefindfunc; /* typefind function */ + GSList *typefindfuncs; /* typefind functions */ GList *srcs; /* list of src objects for this type */ GList *sinks; /* list of sink objects for type */ @@ -1812,16 +1854,6 @@ gchar *mime gchar *ext -gst_type_add_src -void -guint16 id, GstElementFactory *src - - -gst_type_add_sink -void -guint16 id, GstElementFactory *sink - - gst_type_get_srcs GList * guint16 id @@ -1970,6 +2002,56 @@ const guchar *fname, const guchar *root GstElement * GstXML *xml, const guchar *name + +GstCaps + + +GstCapsFactoryEntry +typedef gpointer GstCapsFactoryEntry; + + +GstCapsFactory[] +typedef GstCapsFactoryEntry GstCapsFactory[]; + + +GstCapsListFactory[] +typedef GstCapsFactory *GstCapsListFactory[]; + + +GstCapsDefinition +typedef enum { + GST_CAPS_ALWAYS = 1, + GST_CAPS_MAYBE = 2, +} GstCapsDefinition; + + +GstCaps +struct GstCaps { + guint16 id; /* type id (major type) */ + + GstProps *properties; /* properties for this capability */ +}; + + +gst_caps_register +GstCaps * +GstCapsFactory *factory + + +gst_caps_check_compatibility +gboolean +GstCaps *caps1, GstCaps *caps2 + + +gst_caps_save_thyself +xmlNodePtr +GstCaps *caps, xmlNodePtr parent + + +gst_caps_load_thyself +GstCaps * +xmlNodePtr parent + GST_BUFFER_POOL #define GST_BUFFER_POOL(buf) \ @@ -2092,6 +2174,198 @@ void void +GST_DEBUG_ENABLED +#define GST_DEBUG_ENABLED + + +GST_DEBUG_PREFIX +#define GST_DEBUG_PREFIX(format,args...) \ +"DEBUG(%d:%d)" __PRETTY_FUNCTION__ ":%d" format , getpid() , cothread_getcurrent() , __LINE__ , ## args + + +_debug_function_f +void + + + +DEBUG +#define DEBUG(format,args...) \ + (_debug_string != NULL) ? \ + fprintf(stderr,GST_DEBUG_PREFIX("%s: "format , _debug_string , ## args )) : \ + fprintf(stderr,GST_DEBUG_PREFIX(": "format , ## args )) + + +DEBUG_ENTER +#define DEBUG_ENTER(format, args...) \ + fprintf(stderr,GST_DEBUG_PREFIX(format": entering\n" , ## args )) + + +DEBUG_SET_STRING +#define DEBUG_SET_STRING(format, args...) \ + gchar *_debug_string = g_strdup_printf(format , ## args ) + + +DEBUG_ENTER_STRING +#define DEBUG_ENTER_STRING DEBUG_ENTER("%s",_debug_string) + + +DEBUG_LEAVE +#define DEBUG_LEAVE(format, args...) \ + if (_debug_string != NULL) g_free(_debug_string),\ + fprintf(stderr,GST_DEBUG_PREFIX(format": leaving\n" , ## args )) + + +DEBUG_LEAVE_STRING +#define DEBUG_LEAVE_STRING DEBUG_LEAVE("%s",_debug_string) + + +DEBUG +#define DEBUG(format, args...) + + +DEBUG_ENTER +#define DEBUG_ENTER(format, args...) + + +DEBUG_LEAVE +#define DEBUG_LEAVE(format, args...) + + +DEBUG_SET_STRING +#define DEBUG_SET_STRING(format, args...) + + +DEBUG_ENTER_STRING +#define DEBUG_ENTER_STRING + + +GST_DEBUG_PAD_NAME +#define GST_DEBUG_PAD_NAME(pad) \ + ((pad)->parent != NULL) ? gst_element_get_name(GST_ELEMENT((pad)->parent)) : "''", gst_pad_get_name(pad) + + +GstProps + + +GstPropsFactoryEntry +typedef gpointer GstPropsFactoryEntry; + + +GstPropsFactory[] +typedef GstPropsFactoryEntry GstPropsFactory[]; + + +GstPropsListFactory[] +typedef GstPropsFactory *GstPropsListFactory[]; + + +GstPropsId +typedef enum { + GST_PROPS_END_ID_NUM = 0, + GST_PROPS_LIST_ID_NUM, + GST_PROPS_INT_ID_NUM, + GST_PROPS_INT_RANGE_ID_NUM, + GST_PROPS_FOURCC_ID_NUM, + GST_PROPS_BOOL_ID_NUM, +} GstPropsId; + + +GST_PROPS_LIST_ID +#define GST_PROPS_LIST_ID GINT_TO_POINTER(GST_PROPS_LIST_ID_NUM) + + +GST_PROPS_INT_ID +#define GST_PROPS_INT_ID GINT_TO_POINTER(GST_PROPS_INT_ID_NUM) + + +GST_PROPS_INT_RANGE_ID +#define GST_PROPS_INT_RANGE_ID GINT_TO_POINTER(GST_PROPS_INT_RANGE_ID_NUM) + + +GST_PROPS_FOURCC_ID +#define GST_PROPS_FOURCC_ID GINT_TO_POINTER(GST_PROPS_FOURCC_ID_NUM) + + +GST_PROPS_BOOL_ID +#define GST_PROPS_BOOL_ID GINT_TO_POINTER(GST_PROPS_BOOL_ID_NUM) + + +GST_PROPS_LIST +#define GST_PROPS_LIST(a...) GST_PROPS_LIST_ID,##a,NULL + + +GST_PROPS_INT +#define GST_PROPS_INT(a) GST_PROPS_INT_ID,(GINT_TO_POINTER(a)) + + +GST_PROPS_INT_RANGE +#define GST_PROPS_INT_RANGE(a,b) GST_PROPS_INT_RANGE_ID,(GINT_TO_POINTER(a)),(GINT_TO_POINTER(b)) + + +GST_PROPS_FOURCC +#define GST_PROPS_FOURCC(a,b,c,d) GST_PROPS_FOURCC_ID,(GINT_TO_POINTER((a)|(b)<<8|(c)<<16|(d)<<24)) + + +GST_PROPS_FOURCC_INT +#define GST_PROPS_FOURCC_INT(a) GST_PROPS_FOURCC_ID,(GINT_TO_POINTER(a)) + + +GST_PROPS_BOOLEAN +#define GST_PROPS_BOOLEAN(a) GST_PROPS_BOOL_ID,(GINT_TO_POINTER(a)) + + +GstProps +struct GstProps { + GSList *properties; /* properties for this capability */ +}; + + +gst_props_register +GstProps * +GstPropsFactory factory + + +gst_props_check_compatibility +gboolean +GstProps *props1, GstProps *props2 + + +gst_props_save_thyself +xmlNodePtr +GstProps *props, xmlNodePtr parent + + +gst_props_load_thyself +GstProps * +xmlNodePtr parent + + +GstPropsEntry + + +GstPropsEntry +struct GstPropsEntry { + GQuark propid; + GstPropsId propstype; + + union { + /* flat values */ + gboolean bool_data; + guint32 fourcc_data; + gint int_data; + + /* structured values */ + struct { + GList *entries; + } list_data; + struct { + gint min; + gint max; + } int_range_data; + } data; +}; + + GST_TYPE_ASYNCDISKSRC #define GST_TYPE_ASYNCDISKSRC \ (gst_asyncdisksrc_get_type()) @@ -2245,7 +2519,7 @@ GstElementFactory *factory GST_IS_AUDIOSRC_CLASS #define GST_IS_AUDIOSRC_CLASS(obj) \ - (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOSRC))) + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOSRC)) GstAudioSrcFlags @@ -2377,7 +2651,7 @@ void GST_IS_ESDSINK_CLASS #define GST_IS_ESDSINK_CLASS(obj) \ - (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_ESDSINK))) + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_ESDSINK)) GstEsdSink @@ -2428,7 +2702,7 @@ void GST_IS_FAKESINK_CLASS #define GST_IS_FAKESINK_CLASS(obj) \ - (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESINK))) + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESINK)) GstFakeSink @@ -2472,7 +2746,7 @@ void GST_IS_FAKESRC_CLASS #define GST_IS_FAKESRC_CLASS(obj) \ - (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESRC))) + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESRC)) GstFakeSrc @@ -2516,7 +2790,7 @@ void GST_IS_FDSINK_CLASS #define GST_IS_FDSINK_CLASS(obj) \ - (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSINK))) + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSINK)) GstFdSink @@ -2562,7 +2836,7 @@ void GST_IS_FDSRC_CLASS #define GST_IS_FDSRC_CLASS(obj) \ - (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSRC))) + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSRC)) GstFdSrc @@ -2614,7 +2888,7 @@ void GST_IS_HTTPSRC_CLASS #define GST_IS_HTTPSRC_CLASS(obj) \ - (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_HTTPSRC))) + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_HTTPSRC)) GstHttpSrcFlags @@ -2671,7 +2945,7 @@ void GST_IS_IDENTITY_CLASS #define GST_IS_IDENTITY_CLASS(obj) \ - (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_IDENTITY))) + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_IDENTITY)) GstIdentity @@ -2777,7 +3051,7 @@ void GST_IS_SINESRC_CLASS #define GST_IS_SINESRC_CLASS(obj) \ - (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_SINESRC))) + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_SINESRC)) GstSineSrc diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 372597a03c..a174384068 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -30,6 +30,12 @@ gst_init gst_main gst_main_quit DEBUG +GST_DEBUG_ENABLED +DEBUG_SET_STRING +DEBUG_ENTER_STRING +DEBUG_ENTER +DEBUG_LEAVE_STRING +DEBUG_LEAVE SETUP_STACK diff --git a/docs/gst/tmpl/gstconnection.sgml b/docs/gst/tmpl/gstconnection.sgml index 18684738ae..5871a3c1bc 100644 --- a/docs/gst/tmpl/gstconnection.sgml +++ b/docs/gst/tmpl/gstconnection.sgml @@ -31,11 +31,3 @@ elements. A connection is typically a bas class for queues. @Returns: - - - - - -@connection: - - diff --git a/docs/gst/tmpl/gstelement.sgml b/docs/gst/tmpl/gstelement.sgml index 548466dee7..da1aaf22e2 100644 --- a/docs/gst/tmpl/gstelement.sgml +++ b/docs/gst/tmpl/gstelement.sgml @@ -143,6 +143,8 @@ may have. @GST_ELEMENT_MULTI_IN: @GST_ELEMENT_THREAD_SUGGESTED: @GST_ELEMENT_NO_SEEK: +@GST_ELEMENT_NEW_LOOPFUNC: +@GST_ELEMENT_COTHREAD_STOPPING: @@ -174,7 +176,7 @@ describes the element, mostly for the benefit of editors. @longname: -@class: +@klass: @description: @version: @author: @@ -190,8 +192,7 @@ GstElementDetails struct for the element. @name: @type: @details: -@src_types: -@sink_types: +@padfactories: @@ -379,24 +380,6 @@ circumstances. @elementfactory: - - - - - -@elementfactory: -@id: - - - - - - - -@elementfactory: -@id: - - diff --git a/docs/gst/tmpl/gstpad.sgml b/docs/gst/tmpl/gstpad.sgml index 0916e37969..460c988f43 100644 --- a/docs/gst/tmpl/gstpad.sgml +++ b/docs/gst/tmpl/gstpad.sgml @@ -137,24 +137,6 @@ the function that will be called when a QoS message is sent. @pull: - - - - - -@pad: -@Returns: - - - - - - - -@pad: -@id: - - @@ -312,3 +294,8 @@ the function that will be called when a QoS message is sent. @elements: + + + + + diff --git a/docs/gst/tmpl/gstreamer-unused.sgml b/docs/gst/tmpl/gstreamer-unused.sgml index 42162c0d59..5b70a5b7d7 100644 --- a/docs/gst/tmpl/gstreamer-unused.sgml +++ b/docs/gst/tmpl/gstreamer-unused.sgml @@ -17,6 +17,14 @@ + + + + + +@id: +@sink: + @@ -171,13 +179,6 @@ @Returns: - - - - - -@Returns: - @@ -185,19 +186,19 @@ @obj: - - - - - - - + @Returns: + + + + + + @@ -205,6 +206,13 @@ @klass: + + + + + +@Returns: + @@ -329,6 +337,14 @@ @pad: @buf: + + + + + +@id: +@src: + @@ -356,12 +372,6 @@ - - - - - - @@ -369,6 +379,12 @@ @klass: + + + + + + @@ -403,16 +419,16 @@ @obj: - -GstColorSpace - - + +GstColorSpace + + @@ -471,6 +487,13 @@ GstColorSpace @obj: + + + + + +@src: + @@ -502,6 +525,15 @@ GstGetbits @obj: + + + + + +@src: +@offset: +@size: + @@ -703,14 +735,14 @@ This macro unsets the given state on the element. - + @klass: - + @@ -938,6 +970,14 @@ A flag indicating that SSE instructions are supported. + + + + + +@pad: +@id: + @@ -1104,6 +1144,13 @@ This macro checks to see if the given state is set. @Returns: + + + + + +@connection: + @@ -1276,6 +1323,14 @@ Get the size of the current file. @obj: + + + + + +@elementfactory: +@id: + @@ -1283,6 +1338,14 @@ Get the size of the current file. @Returns: + + + + + +@pad: +@Returns: + @@ -1366,13 +1429,6 @@ Get the size of the current file. - - - - - -@meta: - @@ -1380,6 +1436,13 @@ Get the size of the current file. @Returns: + + + + + +@meta: + @@ -1421,6 +1484,12 @@ Get the size of the current file. + + + + + + @@ -1428,12 +1497,6 @@ Get the size of the current file. @obj: - - - - - - @@ -1511,6 +1574,10 @@ GstElement @obj: + + + + @@ -1518,10 +1585,6 @@ GstElement @src: - - - - @@ -1572,6 +1635,14 @@ GstElement @fd: @Returns: + + + + + +@elementfactory: +@id: + @@ -1637,15 +1708,15 @@ GstElement @name: @Returns: - - -A flag indicating that MMX instructions are supported. - - - + + +A flag indicating that MMX instructions are supported. + + + diff --git a/docs/gst/tmpl/gstsrc.sgml b/docs/gst/tmpl/gstsrc.sgml index cf087070ac..83c82fdab6 100644 --- a/docs/gst/tmpl/gstsrc.sgml +++ b/docs/gst/tmpl/gstsrc.sgml @@ -84,24 +84,6 @@ This macro usets the given flags. @src: - - - - - -@src: - - - - - - - -@src: -@offset: -@size: - - An eos signal is triggered whenever the GstSrc has reached the end of diff --git a/docs/gst/tmpl/gsttype.sgml b/docs/gst/tmpl/gsttype.sgml index ba83cc8229..959ca323db 100644 --- a/docs/gst/tmpl/gsttype.sgml +++ b/docs/gst/tmpl/gsttype.sgml @@ -71,7 +71,7 @@ A type @id: @mime: @exts: -@typefindfunc: +@typefindfuncs: @srcs: @sinks: @converters: @@ -112,24 +112,6 @@ The struct with the typefactory information @Returns: - - - - - -@id: -@src: - - - - - - - -@id: -@sink: - - diff --git a/gst/elements/gstaudiosink.c b/gst/elements/gstaudiosink.c index 0a978d1f70..a49b15df46 100644 --- a/gst/elements/gstaudiosink.c +++ b/gst/elements/gstaudiosink.c @@ -67,7 +67,10 @@ enum { /* FILL ME */ }; -static GstCapsFactory audiosink_sink_caps = { +static GstPadFactory audiosink_sink_factory = { + "sink", + GST_PAD_FACTORY_SINK, + GST_PAD_FACTORY_ALWAYS, "audio/raw", "format", GST_PROPS_INT (AFMT_S16_LE), "depth", GST_PROPS_LIST ( @@ -115,7 +118,7 @@ gst_audiosink_channels_get_type(void) { static GstSinkClass *parent_class = NULL; static guint gst_audiosink_signals[LAST_SIGNAL] = { 0 }; -static GstCaps *gst_audiosink_sink_caps = NULL; +static GstPadTemplate *gst_audiosink_sink_template; GtkType gst_audiosink_get_type (void) @@ -176,9 +179,8 @@ gst_audiosink_class_init (GstAudioSinkClass *klass) static void gst_audiosink_init (GstAudioSink *audiosink) { - audiosink->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); + audiosink->sinkpad = gst_pad_new_from_template (gst_audiosink_sink_template, "sink"); gst_element_add_pad (GST_ELEMENT (audiosink), audiosink->sinkpad); - gst_pad_set_caps (audiosink->sinkpad, gst_audiosink_sink_caps); gst_pad_set_chain_function (audiosink->sinkpad, gst_audiosink_chain); @@ -410,7 +412,8 @@ gst_audiosink_change_state (GstElement *element) gboolean gst_audiosink_factory_init (GstElementFactory *factory) { - gst_audiosink_sink_caps = gst_caps_register (audiosink_sink_caps); + gst_audiosink_sink_template = gst_padtemplate_new (&audiosink_sink_factory); + gst_elementfactory_add_padtemplate (factory, gst_audiosink_sink_template); return TRUE; } diff --git a/gst/elements/gsthttpsrc.c b/gst/elements/gsthttpsrc.c index ff27e7f71f..578da6c4fb 100644 --- a/gst/elements/gsthttpsrc.c +++ b/gst/elements/gsthttpsrc.c @@ -122,7 +122,7 @@ static void gst_httpsrc_init(GstHttpSrc *httpsrc) { httpsrc->bytes_per_read = 4096; } -static void gst_httpsrc_push(GstPad *pad) { +static void gst_httpsrc_pull(GstPad *pad) { GstHttpSrc *src; GstBuffer *buf; glong readbytes; diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 80f712f4ca..f51f71b4db 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -45,6 +45,27 @@ get_type_for_mime (gchar *mime) return typeid; } +/** + * gst_caps_new: + * @mime: the mime type to attach to the capability + * + * create a new capability with the given mime type + * + * Returns: a new capability + */ +GstCaps* +gst_caps_new (gchar *mime) +{ + GstCaps *caps; + + g_return_val_if_fail (mime != NULL, NULL); + + caps = g_new0 (GstCaps, 1); + caps->id = get_type_for_mime (mime); + + return caps; +} + /** * gst_caps_register: * @factory: the factory to register @@ -53,7 +74,7 @@ get_type_for_mime (gchar *mime) * * Returns: The registered capability */ -GstCaps * +GstCaps* gst_caps_register (GstCapsFactory *factory) { GstCapsFactoryEntry tag; diff --git a/gst/gstcaps.h b/gst/gstcaps.h index 2bf4c0b38c..43339b79e0 100644 --- a/gst/gstcaps.h +++ b/gst/gstcaps.h @@ -43,6 +43,7 @@ struct _GstCaps { /* initialize the subsystem */ void _gst_caps_initialize (void); +GstCaps* gst_caps_new (gchar *mime); GstCaps* gst_caps_register (GstCapsFactory *factory); gboolean gst_caps_check_compatibility (GstCaps *caps1, GstCaps *caps2); diff --git a/gst/gstelement.h b/gst/gstelement.h index 1362b2e07d..77ace5c54a 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -153,7 +153,7 @@ struct _GstElementFactory { GstElementDetails *details; /* pointer to details struct */ - GList *padfactories; + GList *padtemplates; }; GtkType gst_element_get_type (void); @@ -196,8 +196,8 @@ GstElementFactory* gst_elementfactory_new (gchar *name,GtkType type, void gst_elementfactory_register (GstElementFactory *elementfactory); void gst_elementfactory_unregister (GstElementFactory *elementfactory); -void gst_elementfactory_add_pad (GstElementFactory *elementfactory, - GstPadFactory *pad); +void gst_elementfactory_add_padtemplate (GstElementFactory *elementfactory, + GstPadTemplate *pad); GstElementFactory* gst_elementfactory_find (gchar *name); GList* gst_elementfactory_get_list (void); diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 8725d16f1f..771f590d52 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -58,15 +58,15 @@ gst_elementfactory_register (GstElementFactory *elementfactory) void gst_elementfactory_unregister (GstElementFactory *factory) { - GList *padfactories; + GList *padtemplates; g_return_if_fail (factory != NULL); - padfactories = factory->padfactories; + padtemplates = factory->padtemplates; - while (padfactories) { - GstPadFactory *padfactory = (GstPadFactory *)padfactories->data; - GstCaps *caps = gst_padfactory_get_caps (padfactory); + while (padtemplates) { + GstPadTemplate *padfactory = (GstPadTemplate *)padtemplates->data; + GstCaps *caps = padfactory->caps; if (caps) { switch (padfactory->direction) { @@ -80,7 +80,7 @@ gst_elementfactory_unregister (GstElementFactory *factory) break; } } - padfactories = g_list_next (padfactories); + padtemplates = g_list_next (padtemplates); } _gst_elementfactories = g_list_remove (_gst_elementfactories, factory); @@ -148,7 +148,7 @@ gst_elementfactory_new (gchar *name, GtkType type, factory->name = g_strdup(name); factory->type = type; factory->details = details; - factory->padfactories = NULL; + factory->padtemplates = NULL; return factory; } @@ -224,28 +224,27 @@ gst_elementfactory_make (gchar *factoryname, gchar *name) } /** - * gst_elementfactory_add_pad : + * gst_elementfactory_add_padtemplate : * @elementfactory: factory to add the src id to - * @pad: the padfactory to add + * @template: the padtemplate to add * - * Add the given padfactory to this element. - * + * Add the given padtemplate to this elementfactory. */ void -gst_elementfactory_add_pad (GstElementFactory *factory, - GstPadFactory *padfactory) +gst_elementfactory_add_padtemplate (GstElementFactory *factory, + GstPadTemplate *template) { GstCaps *caps; g_return_if_fail(factory != NULL); - g_return_if_fail(padfactory != NULL); + g_return_if_fail(template != NULL); - factory->padfactories = g_list_append (factory->padfactories, padfactory); + factory->padtemplates = g_list_append (factory->padtemplates, template); - caps = gst_padfactory_get_caps (padfactory); + caps = template->caps; if (caps) { - switch (padfactory->direction) { + switch (template->direction) { case GST_PAD_SRC: _gst_type_add_src (caps->id, factory); break; @@ -282,14 +281,14 @@ gst_elementfactory_save_thyself (GstElementFactory *factory, xmlNewChild(parent,NULL,"author", factory->details->author); xmlNewChild(parent,NULL,"copyright", factory->details->copyright); - pads = factory->padfactories; + pads = factory->padtemplates; if (pads) { while (pads) { xmlNodePtr subtree; - GstPadFactory *padfactory = (GstPadFactory *)pads->data; + GstPadTemplate *padtemplate = (GstPadTemplate *)pads->data; - subtree = xmlNewChild(parent, NULL, "padfactory", NULL); - gst_padfactory_save_thyself(padfactory, subtree); + subtree = xmlNewChild(parent, NULL, "padtemplate", NULL); + gst_padtemplate_save_thyself(padtemplate, subtree); pads = g_list_next (pads); } @@ -311,7 +310,7 @@ gst_elementfactory_load_thyself (xmlNodePtr parent) GstElementFactory *factory = g_new0(GstElementFactory, 1); xmlNodePtr children = parent->childs; factory->details = g_new0(GstElementDetails, 1); - factory->padfactories = NULL; + factory->padtemplates = NULL; while (children) { if (!strcmp(children->name, "name")) { @@ -335,12 +334,12 @@ gst_elementfactory_load_thyself (xmlNodePtr parent) if (!strcmp(children->name, "copyright")) { factory->details->copyright = g_strdup(xmlNodeGetContent(children)); } - if (!strcmp(children->name, "padfactory")) { - GstPadFactory *padfactory; + if (!strcmp(children->name, "padtemplate")) { + GstPadTemplate *template; - padfactory = gst_padfactory_load_thyself (children); + template = gst_padtemplate_load_thyself (children); - gst_elementfactory_add_pad (factory, padfactory); + gst_elementfactory_add_padtemplate (factory, template); } children = children->next; diff --git a/gst/gstpad.c b/gst/gstpad.c index 779a4d6493..d8cf3c62cf 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -175,6 +175,31 @@ gst_pad_new (gchar *name, pad = GST_PAD (gtk_type_new (gst_pad_get_type ())); pad->name = g_strdup (name); pad->direction = direction; + + return pad; +} + +/** + * gst_pad_new_from_template: + * @temp: the pad template to use + * @name: the name of the element + * + * Create a new pad with given name from the given template. + * + * Returns: new pad + */ +GstPad* +gst_pad_new_from_template (GstPadTemplate *temp, + gchar *name) +{ + GstPad *pad; + + g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (temp != NULL, NULL); + + pad = gst_pad_new (name, temp->direction); + pad->caps = temp->caps; + return pad; } @@ -848,73 +873,65 @@ gst_pad_ghost_save_thyself (GstPad *pad, return self; } -/** - * gst_padfactory_create: - * @factory: the pad factory - * @name: the name of the new pad - * - * crrates a new pad form the given factory - * - * Returns: the new pad; - */ -GstPad* -gst_padfactory_create (GstPadFactory *factory, - gchar *name) +GstPadTemplate* +gst_padtemplate_new (GstPadFactory *factory) { - GstPad *newpad; - GstCaps *caps; + GstPadTemplate *new; + GstPadFactoryEntry tag; + gint i = 0; - newpad = gst_pad_new (name, factory->direction); + g_return_val_if_fail (factory != NULL, NULL); - caps = gst_padfactory_get_caps (factory); + new = g_new0 (GstPadTemplate, 1); - gst_pad_set_caps (newpad, caps); + tag = (*factory)[i++]; + g_return_val_if_fail (tag != NULL, new); + new->name_template = g_strdup ((gchar *)tag); - return newpad; + tag = (*factory)[i++]; + new->direction = GPOINTER_TO_UINT (tag); + + tag = (*factory)[i++]; + new->presence = GPOINTER_TO_UINT (tag); + + new->caps = gst_caps_register ((GstCapsFactory *)&(*factory)[i]); + + return new; } -GstCaps* -gst_padfactory_get_caps (GstPadFactory *factory) +GstPadTemplate* +gst_padtemplate_create (gchar *name_template, + GstPadDirection direction, GstPadPresence presence, + GstCaps *caps, ...) { - if (factory->priv) { - return (GstCaps *) factory->priv; - } - else if (factory->caps) { - GstCaps *caps; - - caps = gst_caps_register (factory->caps); - - factory->priv = caps; - - return caps; - } - else return NULL; + return NULL; } + xmlNodePtr -gst_padfactory_save_thyself (GstPadFactory *pad, xmlNodePtr parent) +gst_padtemplate_save_thyself (GstPadTemplate *pad, xmlNodePtr parent) { xmlNodePtr subtree; - xmlNewChild(parent,NULL,"nametemplate", pad->nametemplate); + xmlNewChild(parent,NULL,"nametemplate", pad->name_template); xmlNewChild(parent,NULL,"direction", (pad->direction == GST_PAD_SINK? "sink":"src")); xmlNewChild(parent,NULL,"presence", (pad->presence == GST_PAD_ALWAYS? "always":"sometimes")); subtree = xmlNewChild(parent,NULL,"caps", NULL); - gst_caps_save_thyself (gst_padfactory_get_caps (pad), subtree); + gst_caps_save_thyself (pad->caps, subtree); return parent; } -GstPadFactory* -gst_padfactory_load_thyself (xmlNodePtr parent) +GstPadTemplate* +gst_padtemplate_load_thyself (xmlNodePtr parent) { xmlNodePtr field = parent->childs; - GstPadFactory *factory = g_new0 (GstPadFactory, 1); + GstPadTemplate *factory = g_new0 (GstPadTemplate, 1); while (field) { if (!strcmp(field->name, "nametemplate")) { - factory->nametemplate = g_strdup(xmlNodeGetContent(field)); + factory->name_template = g_strdup(xmlNodeGetContent(field)); } if (!strcmp(field->name, "direction")) { gchar *value = xmlNodeGetContent(field); @@ -938,7 +955,7 @@ gst_padfactory_load_thyself (xmlNodePtr parent) } } else if (!strcmp(field->name, "caps")) { - factory->priv = gst_caps_load_thyself (field); + factory->caps = gst_caps_load_thyself (field); } field = field->next; } diff --git a/gst/gstpad.h b/gst/gstpad.h index 5c6476bd37..f718106eeb 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -103,22 +103,30 @@ typedef enum { GST_PAD_SOMETIMES, } GstPadPresence; -typedef struct _GstPadFactory GstPadFactory; +typedef struct _GstPadTemplate GstPadTemplate; -/* factory */ -struct _GstPadFactory { - gchar *nametemplate; - GstCapsFactory *caps; +/* template */ +struct _GstPadTemplate { + gchar *name_template; GstPadDirection direction; GstPadPresence presence; - gpointer priv; + GstCaps *caps; }; +/* factory */ +typedef gpointer GstPadFactoryEntry; +typedef GstPadFactoryEntry GstPadFactory[]; +#define GST_PAD_FACTORY_ALWAYS GINT_TO_POINTER(GST_PAD_ALWAYS) +#define GST_PAD_FACTORY_SOMETIMES GINT_TO_POINTER(GST_PAD_SOMETIMES) + +#define GST_PAD_FACTORY_SRC GINT_TO_POINTER(GST_PAD_SRC) +#define GST_PAD_FACTORY_SINK GINT_TO_POINTER(GST_PAD_SINK) GtkType gst_pad_get_type (void); GstPad* gst_pad_new (gchar *name, GstPadDirection direction); #define gst_pad_destroy(pad) gst_object_destroy (GST_OBJECT (pad)) +GstPad* gst_pad_new_from_template (GstPadTemplate *temp, gchar *name); GstPadDirection gst_pad_get_direction (GstPad *pad); @@ -154,12 +162,13 @@ void gst_pad_load_and_connect (xmlNodePtr parent, GstObject *element, GHashTa /* factory */ -GstPad* gst_padfactory_create (GstPadFactory *factory, gchar *name); +GstPadTemplate* gst_padtemplate_new (GstPadFactory *factory); +GstPadTemplate* gst_padtemplate_create (gchar *name_template, + GstPadDirection direction, GstPadPresence presence, + GstCaps *caps, ...); -GstCaps* gst_padfactory_get_caps (GstPadFactory *factory); - -xmlNodePtr gst_padfactory_save_thyself (GstPadFactory *pad, xmlNodePtr parent); -GstPadFactory* gst_padfactory_load_thyself (xmlNodePtr parent); +xmlNodePtr gst_padtemplate_save_thyself (GstPadTemplate *pad, xmlNodePtr parent); +GstPadTemplate* gst_padtemplate_load_thyself (xmlNodePtr parent); #ifdef __cplusplus } diff --git a/gst/gsttype.c b/gst/gsttype.c index 7534c8ba92..08d4209235 100644 --- a/gst/gsttype.c +++ b/gst/gsttype.c @@ -266,28 +266,26 @@ gst_type_handle_src (guint16 id, GstElementFactory *src, gboolean remove) g_return_if_fail (type != NULL); g_return_if_fail (src != NULL); - g_print ("gsttype: handle src \"%s\" %d\n", src->name, remove); - if (remove) type->srcs = g_list_remove (type->srcs, src); else type->srcs = g_list_prepend (type->srcs, src); // find out if the element has to be indexed in the matrix - walk = src->padfactories; + walk = src->padtemplates; while (walk) { - GstPadFactory *factory; + GstPadTemplate *template; - factory = (GstPadFactory *) walk->data; + template = (GstPadTemplate *) walk->data; - if (factory->direction == GST_PAD_SINK) { + if (template->direction == GST_PAD_SINK) { GstType *type2; GList *converters; GList *orig; GstCaps *caps; - caps = gst_padfactory_get_caps (factory); + caps = template->caps; if (caps) type2 = gst_type_find_by_id (caps->id); @@ -353,28 +351,26 @@ gst_type_handle_sink (guint16 id, GstElementFactory *sink, gboolean remove) g_return_if_fail (type != NULL); g_return_if_fail (sink != NULL); - g_print ("gsttype: handle sink \"%s\" %d\n", sink->name, remove); - if (remove) type->sinks = g_list_remove (type->sinks, sink); else type->sinks = g_list_prepend (type->sinks, sink); // find out if the element has to be indexed in the matrix - walk = sink->padfactories; + walk = sink->padtemplates; while (walk) { - GstPadFactory *factory; + GstPadTemplate *template; - factory = (GstPadFactory *) walk->data; + template = (GstPadTemplate *) walk->data; - if (factory->direction == GST_PAD_SRC) { + if (template->direction == GST_PAD_SRC) { guint16 id2; GList *converters; GList *orig; GstCaps *caps; - caps = gst_padfactory_get_caps (factory); + caps = template->caps; if (caps) id2 = caps->id; diff --git a/plugins/elements/gstaudiosink.c b/plugins/elements/gstaudiosink.c index 0a978d1f70..a49b15df46 100644 --- a/plugins/elements/gstaudiosink.c +++ b/plugins/elements/gstaudiosink.c @@ -67,7 +67,10 @@ enum { /* FILL ME */ }; -static GstCapsFactory audiosink_sink_caps = { +static GstPadFactory audiosink_sink_factory = { + "sink", + GST_PAD_FACTORY_SINK, + GST_PAD_FACTORY_ALWAYS, "audio/raw", "format", GST_PROPS_INT (AFMT_S16_LE), "depth", GST_PROPS_LIST ( @@ -115,7 +118,7 @@ gst_audiosink_channels_get_type(void) { static GstSinkClass *parent_class = NULL; static guint gst_audiosink_signals[LAST_SIGNAL] = { 0 }; -static GstCaps *gst_audiosink_sink_caps = NULL; +static GstPadTemplate *gst_audiosink_sink_template; GtkType gst_audiosink_get_type (void) @@ -176,9 +179,8 @@ gst_audiosink_class_init (GstAudioSinkClass *klass) static void gst_audiosink_init (GstAudioSink *audiosink) { - audiosink->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); + audiosink->sinkpad = gst_pad_new_from_template (gst_audiosink_sink_template, "sink"); gst_element_add_pad (GST_ELEMENT (audiosink), audiosink->sinkpad); - gst_pad_set_caps (audiosink->sinkpad, gst_audiosink_sink_caps); gst_pad_set_chain_function (audiosink->sinkpad, gst_audiosink_chain); @@ -410,7 +412,8 @@ gst_audiosink_change_state (GstElement *element) gboolean gst_audiosink_factory_init (GstElementFactory *factory) { - gst_audiosink_sink_caps = gst_caps_register (audiosink_sink_caps); + gst_audiosink_sink_template = gst_padtemplate_new (&audiosink_sink_factory); + gst_elementfactory_add_padtemplate (factory, gst_audiosink_sink_template); return TRUE; } diff --git a/plugins/elements/gsthttpsrc.c b/plugins/elements/gsthttpsrc.c index ff27e7f71f..578da6c4fb 100644 --- a/plugins/elements/gsthttpsrc.c +++ b/plugins/elements/gsthttpsrc.c @@ -122,7 +122,7 @@ static void gst_httpsrc_init(GstHttpSrc *httpsrc) { httpsrc->bytes_per_read = 4096; } -static void gst_httpsrc_push(GstPad *pad) { +static void gst_httpsrc_pull(GstPad *pad) { GstHttpSrc *src; GstBuffer *buf; glong readbytes;