mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
inlined two more docs factored gstpadtemplate out of gstpad
Original commit message from CVS: * docs/gst/gstreamer-sections.txt: * docs/gst/tmpl/.cvsignore: * docs/gst/tmpl/gstpad.sgml: * docs/gst/tmpl/gstpadtemplate.sgml: * gst/Makefile.am: * gst/gstpad.c: (gst_pad_class_init), (gst_pad_dispose), (gst_pad_finalize), (gst_pad_set_pad_template): * gst/gstpad.h: * gst/gstpadtemplate.c: (gst_pad_template_get_type), (gst_pad_template_class_init), (gst_pad_template_init), (gst_pad_template_dispose), (name_is_valid), (gst_static_pad_template_get), (gst_pad_template_new), (gst_static_pad_template_get_caps), (gst_pad_template_get_caps), (gst_pad_template_pad_created): * gst/gstpadtemplate.h: inlined two more docs factored gstpadtemplate out of gstpad
This commit is contained in:
parent
4ed6212a26
commit
41aca72772
10 changed files with 701 additions and 1855 deletions
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,23 @@
|
|||
2005-09-25 Stefan Kost <ensonic@users.sf.net>
|
||||
|
||||
* docs/gst/gstreamer-sections.txt:
|
||||
* docs/gst/tmpl/.cvsignore:
|
||||
* docs/gst/tmpl/gstpad.sgml:
|
||||
* docs/gst/tmpl/gstpadtemplate.sgml:
|
||||
* gst/Makefile.am:
|
||||
* gst/gstpad.c: (gst_pad_class_init), (gst_pad_dispose),
|
||||
(gst_pad_finalize), (gst_pad_set_pad_template):
|
||||
* gst/gstpad.h:
|
||||
* gst/gstpadtemplate.c: (gst_pad_template_get_type),
|
||||
(gst_pad_template_class_init), (gst_pad_template_init),
|
||||
(gst_pad_template_dispose), (name_is_valid),
|
||||
(gst_static_pad_template_get), (gst_pad_template_new),
|
||||
(gst_static_pad_template_get_caps), (gst_pad_template_get_caps),
|
||||
(gst_pad_template_pad_created):
|
||||
* gst/gstpadtemplate.h:
|
||||
inlined two more docs
|
||||
factored gstpadtemplate out of gstpad
|
||||
|
||||
2005-09-24 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* check/gst/gstbin.c: (test_children_state_change_order_flagged_sink),
|
||||
|
|
|
@ -1137,7 +1137,6 @@ GstPadDispatcherFunction
|
|||
GstPadDirection
|
||||
GstPadFlags
|
||||
GstPadLinkReturn
|
||||
GstPadPresence
|
||||
GstFlowReturn
|
||||
GstActivateMode
|
||||
|
||||
|
@ -1297,7 +1296,6 @@ GST_PAD_SET_FLUSHING
|
|||
GST_PAD_TASK
|
||||
GST_PAD_UNSET_FLUSHING
|
||||
|
||||
|
||||
GST_PAD_ACCEPTCAPSFUNC
|
||||
GST_PAD_ACTIVATEFUNC
|
||||
GST_PAD_ACTIVATEPULLFUNC
|
||||
|
@ -1331,10 +1329,12 @@ GST_PAD_TEMPLATE_PRESENCE
|
|||
GST_PAD_TEMPLATE_CAPS
|
||||
GST_PAD_TEMPLATE_IS_FIXED
|
||||
GstPadTemplateFlags
|
||||
GstPadPresence
|
||||
gst_pad_template_new
|
||||
gst_static_pad_template_get
|
||||
gst_static_pad_template_get_caps
|
||||
gst_pad_template_get_caps
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GstPadTemplateClass
|
||||
GST_PAD_TEMPLATE
|
||||
|
@ -1344,9 +1344,11 @@ GST_IS_PAD_TEMPLATE_CLASS
|
|||
GST_STATIC_PAD_TEMPLATE
|
||||
GST_TYPE_PAD_TEMPLATE
|
||||
GST_TYPE_PAD_TEMPLATE_FLAGS
|
||||
|
||||
<SUBSECTION Private>
|
||||
gst_pad_template_get_type
|
||||
gst_pad_template_flags_get_type
|
||||
gst_pad_template_pad_created
|
||||
</SECTION>
|
||||
|
||||
|
||||
|
|
2
docs/gst/tmpl/.gitignore
vendored
2
docs/gst/tmpl/.gitignore
vendored
|
@ -38,6 +38,8 @@ gstmemchunk.sgml
|
|||
gstmessage.sgml
|
||||
gstminiobject.sgml
|
||||
gstobject.sgml
|
||||
gstpad.sgml
|
||||
gstpadtemplate.sgml
|
||||
gstparse.sgml
|
||||
gstpluginfeature.sgml
|
||||
gstpushsrc.sgml
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,202 +0,0 @@
|
|||
<!-- ##### SECTION Title ##### -->
|
||||
GstPadTemplate
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
Describe the media type of a pad.
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
Padtemplates describe the possible media types a pad or an elementfactory can
|
||||
handle.
|
||||
</para>
|
||||
<para>
|
||||
Pad and PadTemplates have #GstCaps attached to it to describe the media type they
|
||||
are capable of dealing with. gst_pad_template_get_caps() is used to get the
|
||||
caps of a padtemplate. It's not possible to modify the caps of a padtemplate after
|
||||
creation.
|
||||
</para>
|
||||
<para>
|
||||
Padtemplates can be created with gst_pad_template_new() or with the convenient
|
||||
GST_PAD_TEMPLATE_FACTORY() macro. A padtemplate can be used to create a pad or
|
||||
to add to an elementfactory.
|
||||
</para>
|
||||
<para>
|
||||
The following code example shows the code to create a pad from a padtemplate.
|
||||
<example>
|
||||
<title>Create a pad from a padtemplate</title>
|
||||
<programlisting>
|
||||
GstStaticPadTemplate my_template =
|
||||
GST_STATIC_PAD_TEMPLATE (
|
||||
"sink", /* the name of the pad */
|
||||
GST_PAD_SINK, /* the direction of the pad */
|
||||
GST_PAD_ALWAYS, /* when this pad will be present */
|
||||
GST_STATIC_CAPS ( /* the capabilities of the padtemplate */
|
||||
"audio/x-raw-int, "
|
||||
"channels = (int) [ 1, 6 ]"
|
||||
)
|
||||
)
|
||||
|
||||
void
|
||||
my_method (void)
|
||||
{
|
||||
GstPad *pad;
|
||||
|
||||
pad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (my_template_factory), "sink");
|
||||
...
|
||||
}
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
The following example shows you how to add the padtemplate to an elementfactory:
|
||||
<programlisting>
|
||||
gboolean
|
||||
my_factory_init (GstPlugin *plugin)
|
||||
{
|
||||
GstElementFactory *factory;
|
||||
|
||||
factory = gst_element_factory_new ("my_factory", GST_TYPE_MYFACTORY, &gst_myfactory_details);
|
||||
g_return_val_if_fail (factory != NULL, FALSE);
|
||||
|
||||
gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (my_template_factory));
|
||||
|
||||
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
#GstPad, #GstElementFactory
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION Stability_Level ##### -->
|
||||
|
||||
|
||||
<!-- ##### STRUCT GstPadTemplate ##### -->
|
||||
<para>
|
||||
The padtemplate object.
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### SIGNAL GstPadTemplate::pad-created ##### -->
|
||||
<para>
|
||||
This signal is fired when an element creates a pad from this
|
||||
template.
|
||||
</para>
|
||||
|
||||
@gstpadtemplate: the object which received the signal.
|
||||
@arg1: The pad that was created.
|
||||
|
||||
<!-- ##### STRUCT GstStaticPadTemplate ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@name_template:
|
||||
@direction:
|
||||
@presence:
|
||||
@static_caps:
|
||||
|
||||
<!-- ##### MACRO GST_IS_PAD_FAST ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@obj:
|
||||
|
||||
|
||||
<!-- ##### MACRO GST_PAD_TEMPLATE_NAME_TEMPLATE ##### -->
|
||||
<para>
|
||||
Get the nametemplate of the padtemplate.
|
||||
</para>
|
||||
|
||||
@templ: the template to query
|
||||
|
||||
|
||||
<!-- ##### MACRO GST_PAD_TEMPLATE_DIRECTION ##### -->
|
||||
<para>
|
||||
Get the direction of the padtemplate.
|
||||
</para>
|
||||
|
||||
@templ: the template to query
|
||||
|
||||
|
||||
<!-- ##### MACRO GST_PAD_TEMPLATE_PRESENCE ##### -->
|
||||
<para>
|
||||
Get the presence of the padtemplate.
|
||||
</para>
|
||||
|
||||
@templ: the template to query
|
||||
|
||||
|
||||
<!-- ##### MACRO GST_PAD_TEMPLATE_CAPS ##### -->
|
||||
<para>
|
||||
Get a handle to the padtemplate #GstCaps
|
||||
</para>
|
||||
|
||||
@templ: the template to query
|
||||
|
||||
|
||||
<!-- ##### MACRO GST_PAD_TEMPLATE_IS_FIXED ##### -->
|
||||
<para>
|
||||
Check if the properties of the padtemplate are fixed
|
||||
</para>
|
||||
|
||||
@templ: the template to query
|
||||
|
||||
|
||||
<!-- ##### ENUM GstPadTemplateFlags ##### -->
|
||||
<para>
|
||||
Flags for the padtemplate
|
||||
</para>
|
||||
|
||||
@GST_PAD_TEMPLATE_FIXED: the padtemplate has no variable properties
|
||||
@GST_PAD_TEMPLATE_FLAG_LAST: first flag that can be used by subclasses.
|
||||
|
||||
<!-- ##### FUNCTION gst_pad_template_new ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@name_template:
|
||||
@direction:
|
||||
@presence:
|
||||
@caps:
|
||||
@Returns:
|
||||
<!-- # Unused Parameters # -->
|
||||
@Varargs:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gst_static_pad_template_get ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@pad_template:
|
||||
@Returns:
|
||||
<!-- # Unused Parameters # -->
|
||||
@templ:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gst_static_pad_template_get_caps ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@templ:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gst_pad_template_get_caps ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@templ:
|
||||
@Returns:
|
||||
|
||||
|
|
@ -91,6 +91,7 @@ libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
|
|||
gstmessage.c \
|
||||
gstminiobject.c \
|
||||
gstpad.c \
|
||||
gstpadtemplate.c \
|
||||
gstpipeline.c \
|
||||
gstplugin.c \
|
||||
gstpluginfeature.c \
|
||||
|
@ -168,6 +169,7 @@ gst_headers = \
|
|||
gstmessage.h \
|
||||
gstminiobject.h \
|
||||
gstpad.h \
|
||||
gstpadtemplate.h \
|
||||
gstpipeline.h \
|
||||
gstplugin.h \
|
||||
gstpluginfeature.h \
|
||||
|
|
285
gst/gstpad.c
285
gst/gstpad.c
|
@ -19,10 +19,52 @@
|
|||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/**
|
||||
* SECTION:gstpad
|
||||
* @short_description: Object contained by elements that allows links to other elements
|
||||
* @see_also: #GstPadTemplate, #GstElement, #GstEvent
|
||||
*
|
||||
* A #GstElement is linked to other elements via "pads", which are extremely
|
||||
* light-weight generic link points.
|
||||
* After two pads are retrieved from an element with gst_element_get_pad(),
|
||||
* the pads can be link with gst_pad_link(). (For quick links,
|
||||
* you can also use gst_element_link(), which will make the obvious
|
||||
* link for you if it's straightforward.)
|
||||
*
|
||||
* Pads are typically created from a #GstPadTemplate with
|
||||
* gst_pad_new_from_template().
|
||||
*
|
||||
* Pads have #GstCaps attached to it to describe the media type they are capable
|
||||
* of dealing with.
|
||||
* gst_pad_get_caps() and gst_pad_try_set_caps() are used to manipulate the caps
|
||||
* of the pads.
|
||||
* Pads created from a pad template cannot set capabilities that are
|
||||
* incompatible with the pad template capabilities.
|
||||
*
|
||||
* Pads without pad templates can be created with gst_pad_new(),
|
||||
* which takes a direction and a name as an argument. If the name is NULL,
|
||||
* then a guaranteed unique name will be assigned to it.
|
||||
*
|
||||
* gst_pad_get_parent() will retrieve the #GstElement that owns the pad.
|
||||
*
|
||||
* A #GstElement creating a pad will typically use the various
|
||||
* gst_pad_set_*_function() calls to register callbacks for various events
|
||||
* on the pads.
|
||||
*
|
||||
* GstElements will use gst_pad_push() and gst_pad_pull() to push out
|
||||
* or pull in a buffer.
|
||||
* gst_pad_select() and gst_pad_selectv() are used by plugins to wait for the
|
||||
* first incoming buffer or event on any of the given set of pads.
|
||||
*
|
||||
* To send a #GstEvent on a pad, use gst_pad_send_event().
|
||||
*
|
||||
* Last reviewed on December 13th, 2002 (0.5.0.1)
|
||||
*/
|
||||
|
||||
#include "gst_private.h"
|
||||
|
||||
#include "gstpad.h"
|
||||
#include "gstpadtemplate.h"
|
||||
#include "gstenumtypes.h"
|
||||
#include "gstmarshal.h"
|
||||
#include "gstutils.h"
|
||||
|
@ -44,16 +86,6 @@ GST_DEBUG_CATEGORY_STATIC (debug_dataflow);
|
|||
}G_STMT_END
|
||||
#define GST_CAT_DEFAULT GST_CAT_PADS
|
||||
|
||||
enum
|
||||
{
|
||||
TEMPL_PAD_CREATED,
|
||||
/* FILL ME */
|
||||
TEMPL_LAST_SIGNAL
|
||||
};
|
||||
|
||||
static GstObject *padtemplate_parent_class = NULL;
|
||||
static guint gst_pad_template_signals[TEMPL_LAST_SIGNAL] = { 0 };
|
||||
|
||||
/* Pad signals and args */
|
||||
enum
|
||||
{
|
||||
|
@ -62,7 +94,7 @@ enum
|
|||
PAD_REQUEST_LINK,
|
||||
PAD_HAVE_DATA,
|
||||
/* FILL ME */
|
||||
PAD_LAST_SIGNAL
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -93,8 +125,8 @@ static gboolean gst_pad_activate_default (GstPad * pad);
|
|||
static xmlNodePtr gst_pad_save_thyself (GstObject * object, xmlNodePtr parent);
|
||||
#endif
|
||||
|
||||
static GstObjectClass *pad_parent_class = NULL;
|
||||
static guint gst_pad_signals[PAD_LAST_SIGNAL] = { 0 };
|
||||
static GstObjectClass *parent_class = NULL;
|
||||
static guint gst_pad_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GQuark buffer_quark;
|
||||
static GQuark event_quark;
|
||||
|
@ -152,7 +184,7 @@ gst_pad_class_init (GstPadClass * klass)
|
|||
gobject_class = (GObjectClass *) klass;
|
||||
gstobject_class = (GstObjectClass *) klass;
|
||||
|
||||
pad_parent_class = g_type_class_ref (GST_TYPE_OBJECT);
|
||||
parent_class = g_type_class_ref (GST_TYPE_OBJECT);
|
||||
|
||||
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_pad_dispose);
|
||||
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_pad_finalize);
|
||||
|
@ -295,7 +327,7 @@ gst_pad_dispose (GObject * object)
|
|||
gst_element_remove_pad (GST_ELEMENT (GST_OBJECT_PARENT (pad)), pad);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (pad_parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -327,7 +359,7 @@ gst_pad_finalize (GObject * object)
|
|||
pad->block_cond = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (pad_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1628,11 +1660,8 @@ gst_pad_set_pad_template (GstPad * pad, GstPadTemplate * templ)
|
|||
gst_object_replace ((GstObject **) & pad->padtemplate, (GstObject *) templ);
|
||||
GST_UNLOCK (pad);
|
||||
|
||||
if (templ) {
|
||||
gst_object_sink (GST_OBJECT (templ));
|
||||
g_signal_emit (G_OBJECT (templ),
|
||||
gst_pad_template_signals[TEMPL_PAD_CREATED], 0, pad);
|
||||
}
|
||||
if (templ)
|
||||
gst_pad_template_pad_created (templ, pad);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3487,220 +3516,6 @@ dropping:
|
|||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* templates
|
||||
*
|
||||
*/
|
||||
static void gst_pad_template_class_init (GstPadTemplateClass * klass);
|
||||
static void gst_pad_template_init (GstPadTemplate * templ);
|
||||
static void gst_pad_template_dispose (GObject * object);
|
||||
|
||||
GType
|
||||
gst_pad_template_get_type (void)
|
||||
{
|
||||
static GType padtemplate_type = 0;
|
||||
|
||||
if (!padtemplate_type) {
|
||||
static const GTypeInfo padtemplate_info = {
|
||||
sizeof (GstPadTemplateClass), NULL, NULL,
|
||||
(GClassInitFunc) gst_pad_template_class_init, NULL, NULL,
|
||||
sizeof (GstPadTemplate),
|
||||
0,
|
||||
(GInstanceInitFunc) gst_pad_template_init, NULL
|
||||
};
|
||||
|
||||
padtemplate_type =
|
||||
g_type_register_static (GST_TYPE_OBJECT, "GstPadTemplate",
|
||||
&padtemplate_info, 0);
|
||||
}
|
||||
return padtemplate_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pad_template_class_init (GstPadTemplateClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstObjectClass *gstobject_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
gstobject_class = (GstObjectClass *) klass;
|
||||
|
||||
padtemplate_parent_class = g_type_class_ref (GST_TYPE_OBJECT);
|
||||
|
||||
gst_pad_template_signals[TEMPL_PAD_CREATED] =
|
||||
g_signal_new ("pad-created", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GstPadTemplateClass, pad_created),
|
||||
NULL, NULL, gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_PAD);
|
||||
|
||||
gobject_class->dispose = gst_pad_template_dispose;
|
||||
|
||||
gstobject_class->path_string_separator = "*";
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pad_template_init (GstPadTemplate * templ)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pad_template_dispose (GObject * object)
|
||||
{
|
||||
GstPadTemplate *templ = GST_PAD_TEMPLATE (object);
|
||||
|
||||
g_free (GST_PAD_TEMPLATE_NAME_TEMPLATE (templ));
|
||||
if (GST_PAD_TEMPLATE_CAPS (templ)) {
|
||||
gst_caps_unref (GST_PAD_TEMPLATE_CAPS (templ));
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (padtemplate_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
/* ALWAYS padtemplates cannot have conversion specifications (like src_%d),
|
||||
* since it doesn't make sense.
|
||||
* SOMETIMES padtemplates can do whatever they want, they are provided by the
|
||||
* element.
|
||||
* REQUEST padtemplates can be reverse-parsed (the user asks for 'sink1', the
|
||||
* 'sink%d' template is automatically selected), so we need to restrict their
|
||||
* naming.
|
||||
*/
|
||||
static gboolean
|
||||
name_is_valid (const gchar * name, GstPadPresence presence)
|
||||
{
|
||||
const gchar *str;
|
||||
|
||||
if (presence == GST_PAD_ALWAYS) {
|
||||
if (strchr (name, '%')) {
|
||||
g_warning ("invalid name template %s: conversion specifications are not"
|
||||
" allowed for GST_PAD_ALWAYS padtemplates", name);
|
||||
return FALSE;
|
||||
}
|
||||
} else if (presence == GST_PAD_REQUEST) {
|
||||
if ((str = strchr (name, '%')) && strchr (str + 1, '%')) {
|
||||
g_warning ("invalid name template %s: only one conversion specification"
|
||||
" allowed in GST_PAD_REQUEST padtemplate", name);
|
||||
return FALSE;
|
||||
}
|
||||
if (str && (*(str + 1) != 's' && *(str + 1) != 'd')) {
|
||||
g_warning ("invalid name template %s: conversion specification must be of"
|
||||
" type '%%d' or '%%s' for GST_PAD_REQUEST padtemplate", name);
|
||||
return FALSE;
|
||||
}
|
||||
if (str && (*(str + 2) != '\0')) {
|
||||
g_warning ("invalid name template %s: conversion specification must"
|
||||
" appear at the end of the GST_PAD_REQUEST padtemplate name", name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_static_pad_template_get:
|
||||
* @pad_template: the static pad template
|
||||
*
|
||||
* Converts a #GstStaticPadTemplate into a #GstPadTemplate.
|
||||
*
|
||||
* Returns: a new #GstPadTemplate.
|
||||
*/
|
||||
GstPadTemplate *
|
||||
gst_static_pad_template_get (GstStaticPadTemplate * pad_template)
|
||||
{
|
||||
GstPadTemplate *new;
|
||||
|
||||
if (!name_is_valid (pad_template->name_template, pad_template->presence))
|
||||
return NULL;
|
||||
|
||||
new = g_object_new (gst_pad_template_get_type (),
|
||||
"name", pad_template->name_template, NULL);
|
||||
|
||||
GST_PAD_TEMPLATE_NAME_TEMPLATE (new) = g_strdup (pad_template->name_template);
|
||||
GST_PAD_TEMPLATE_DIRECTION (new) = pad_template->direction;
|
||||
GST_PAD_TEMPLATE_PRESENCE (new) = pad_template->presence;
|
||||
|
||||
GST_PAD_TEMPLATE_CAPS (new) =
|
||||
gst_caps_copy (gst_static_caps_get (&pad_template->static_caps));
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_template_new:
|
||||
* @name_template: the name template.
|
||||
* @direction: the #GstPadDirection of the template.
|
||||
* @presence: the #GstPadPresence of the pad.
|
||||
* @caps: a #GstCaps set for the template. The caps are taken ownership of.
|
||||
*
|
||||
* Creates a new pad template with a name according to the given template
|
||||
* and with the given arguments. This functions takes ownership of the provided
|
||||
* caps, so be sure to not use them afterwards.
|
||||
*
|
||||
* Returns: a new #GstPadTemplate.
|
||||
*/
|
||||
GstPadTemplate *
|
||||
gst_pad_template_new (const gchar * name_template,
|
||||
GstPadDirection direction, GstPadPresence presence, GstCaps * caps)
|
||||
{
|
||||
GstPadTemplate *new;
|
||||
|
||||
g_return_val_if_fail (name_template != NULL, NULL);
|
||||
g_return_val_if_fail (caps != NULL, NULL);
|
||||
g_return_val_if_fail (direction == GST_PAD_SRC
|
||||
|| direction == GST_PAD_SINK, NULL);
|
||||
g_return_val_if_fail (presence == GST_PAD_ALWAYS
|
||||
|| presence == GST_PAD_SOMETIMES || presence == GST_PAD_REQUEST, NULL);
|
||||
|
||||
if (!name_is_valid (name_template, presence)) {
|
||||
gst_caps_unref (caps);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new = g_object_new (gst_pad_template_get_type (),
|
||||
"name", name_template, NULL);
|
||||
|
||||
GST_PAD_TEMPLATE_NAME_TEMPLATE (new) = g_strdup (name_template);
|
||||
GST_PAD_TEMPLATE_DIRECTION (new) = direction;
|
||||
GST_PAD_TEMPLATE_PRESENCE (new) = presence;
|
||||
GST_PAD_TEMPLATE_CAPS (new) = caps;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_static_pad_template_get_caps:
|
||||
* @templ: a #GstStaticPadTemplate to get capabilities of.
|
||||
*
|
||||
* Gets the capabilities of the static pad template.
|
||||
*
|
||||
* Returns: the #GstCaps of the static pad template. If you need to keep a
|
||||
* reference to the caps, take a ref (see gst_caps_ref ()).
|
||||
*/
|
||||
GstCaps *
|
||||
gst_static_pad_template_get_caps (GstStaticPadTemplate * templ)
|
||||
{
|
||||
g_return_val_if_fail (templ, NULL);
|
||||
|
||||
return (GstCaps *) gst_static_caps_get (&templ->static_caps);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_template_get_caps:
|
||||
* @templ: a #GstPadTemplate to get capabilities of.
|
||||
*
|
||||
* Gets the capabilities of the pad template.
|
||||
*
|
||||
* Returns: the #GstCaps of the pad template. If you need to keep a reference to
|
||||
* the caps, take a ref (see gst_caps_ref ()).
|
||||
*/
|
||||
GstCaps *
|
||||
gst_pad_template_get_caps (GstPadTemplate * templ)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_PAD_TEMPLATE (templ), NULL);
|
||||
|
||||
return GST_PAD_TEMPLATE_CAPS (templ);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_set_element_private:
|
||||
* @pad: the #GstPad to set the private data of.
|
||||
|
|
196
gst/gstpad.h
196
gst/gstpad.h
|
@ -52,10 +52,6 @@ GST_EXPORT GType _gst_pad_type;
|
|||
typedef struct _GstPad GstPad;
|
||||
typedef struct _GstPadClass GstPadClass;
|
||||
|
||||
typedef struct _GstPadTemplate GstPadTemplate;
|
||||
typedef struct _GstPadTemplateClass GstPadTemplateClass;
|
||||
typedef struct _GstStaticPadTemplate GstStaticPadTemplate;
|
||||
|
||||
/**
|
||||
* GstPadLinkReturn:
|
||||
* @GST_PAD_LINK_OK : link succeeded
|
||||
|
@ -76,7 +72,22 @@ typedef enum {
|
|||
GST_PAD_LINK_REFUSED = -6,
|
||||
} GstPadLinkReturn;
|
||||
|
||||
/**
|
||||
* GST_PAD_LINK_FAILED:
|
||||
* @ret: the #GstPadLinkReturn value
|
||||
*
|
||||
* Macro to test if the given #GstPadLinkReturn value indicates a failed
|
||||
* negotiation step (REFUSED/DELAYED).
|
||||
*/
|
||||
#define GST_PAD_LINK_FAILED(ret) ((ret) < GST_PAD_LINK_OK)
|
||||
|
||||
/**
|
||||
* GST_PAD_LINK_SUCCESSFUL:
|
||||
* @ret: the #GstPadLinkReturn value
|
||||
*
|
||||
* Macro to test if the given #GstPadLinkReturn value indicates a successfull
|
||||
* negotiation step (OK/DONE).
|
||||
*/
|
||||
#define GST_PAD_LINK_SUCCESSFUL(ret) ((ret) >= GST_PAD_LINK_OK)
|
||||
|
||||
typedef enum {
|
||||
|
@ -106,38 +117,136 @@ typedef enum {
|
|||
typedef gboolean (*GstPadActivateFunction) (GstPad *pad);
|
||||
typedef gboolean (*GstPadActivateModeFunction) (GstPad *pad, gboolean active);
|
||||
|
||||
|
||||
/* data passing */
|
||||
/**
|
||||
* GstPadChainFunction:
|
||||
* @pad: the #GstPad that performed the chain.
|
||||
* @buffer: the #GstBuffer that is chained.
|
||||
*
|
||||
* A function that will be called when chaining buffers.
|
||||
*
|
||||
*
|
||||
*/
|
||||
typedef GstFlowReturn (*GstPadChainFunction) (GstPad *pad, GstBuffer *buffer);
|
||||
typedef GstFlowReturn (*GstPadGetRangeFunction) (GstPad *pad, guint64 offset,
|
||||
guint length, GstBuffer **buffer);
|
||||
|
||||
/**
|
||||
* GstPadEventFunction:
|
||||
* @pad: the #GstPad to handle the event.
|
||||
* @event: the #GstEvent to handle.
|
||||
*
|
||||
* Function signature to handle an event for the pad.
|
||||
*
|
||||
* Returns: TRUE if the pad could handle the event.
|
||||
*/
|
||||
typedef gboolean (*GstPadEventFunction) (GstPad *pad, GstEvent *event);
|
||||
|
||||
|
||||
/* deprecate me, check range should use seeking query */
|
||||
typedef gboolean (*GstPadCheckGetRangeFunction) (GstPad *pad);
|
||||
|
||||
|
||||
/* internal links */
|
||||
/**
|
||||
* GstPadIntLinkFunction:
|
||||
* @pad: The #GstPad to query.
|
||||
*
|
||||
* The signature of the internal pad link function.
|
||||
*
|
||||
* Returns: a newly allocated #GList of pads that are linked to the given pad on
|
||||
* the inside of the parent element.
|
||||
* The caller must call g_list_free() on it after use.
|
||||
*
|
||||
*/
|
||||
typedef GList* (*GstPadIntLinkFunction) (GstPad *pad);
|
||||
|
||||
|
||||
/* generic query function */
|
||||
/**
|
||||
* GstPadQueryTypeFunction:
|
||||
* @pad: a #GstPad to query
|
||||
*
|
||||
* The signature of the query types function.
|
||||
*
|
||||
* Returns: an array of query types
|
||||
*/
|
||||
typedef const GstQueryType* (*GstPadQueryTypeFunction) (GstPad *pad);
|
||||
|
||||
/**
|
||||
* GstPadQueryFunction:
|
||||
* @pad: the #GstPad to query.
|
||||
* @query: the #GstQuery object to execute
|
||||
*
|
||||
* The signature of the query function.
|
||||
*
|
||||
* Returns: TRUE if the query could be performed.
|
||||
*/
|
||||
typedef gboolean (*GstPadQueryFunction) (GstPad *pad, GstQuery *query);
|
||||
|
||||
|
||||
/* linking */
|
||||
/**
|
||||
* GstPadLinkFunction
|
||||
* @pad: the #GstPad that is linked.
|
||||
* @peer: the peer #GstPad of the link
|
||||
*
|
||||
* Function signature to handle a new link on the pad.
|
||||
*
|
||||
* Returns: the result of the link with the specified peer.
|
||||
*/
|
||||
typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, GstPad *peer);
|
||||
/**
|
||||
* GstPadUnlinkFunction
|
||||
* @pad: the #GstPad that is linked.
|
||||
*
|
||||
* Function signature to handle a unlinking the pad prom its peer.
|
||||
*/
|
||||
typedef void (*GstPadUnlinkFunction) (GstPad *pad);
|
||||
|
||||
|
||||
/* caps nego */
|
||||
/**
|
||||
* GstPadGetCapsFunction:
|
||||
* @pad: the #GstPad to get the capabilities of.
|
||||
*
|
||||
* Returns a copy of the capabilities of the specified pad. By default this
|
||||
* function will return the pad template capabilities, but can optionally
|
||||
* be overridden.
|
||||
*
|
||||
* Returns: a newly allocated copy #GstCaps of the pad.
|
||||
*/
|
||||
typedef GstCaps* (*GstPadGetCapsFunction) (GstPad *pad);
|
||||
typedef gboolean (*GstPadSetCapsFunction) (GstPad *pad, GstCaps *caps);
|
||||
typedef gboolean (*GstPadAcceptCapsFunction) (GstPad *pad, GstCaps *caps);
|
||||
typedef void (*GstPadFixateCapsFunction) (GstPad *pad, GstCaps *caps);
|
||||
typedef GstFlowReturn (*GstPadBufferAllocFunction) (GstPad *pad, guint64 offset, guint size,
|
||||
GstCaps *caps, GstBuffer **buf);
|
||||
|
||||
/* misc */
|
||||
/**
|
||||
* GstPadDispatcherFunction:
|
||||
* @pad: the #GstPad that is dispatched.
|
||||
* @data: the gpointer to optional user data.
|
||||
*
|
||||
* A dispatcher function is called for all internally linked pads, see
|
||||
* gst_pad_dispatcher().
|
||||
*
|
||||
* Returns: TRUE if the dispatching procedure has to be stopped.
|
||||
*/
|
||||
typedef gboolean (*GstPadDispatcherFunction) (GstPad *pad, gpointer data);
|
||||
|
||||
typedef void (*GstPadBlockCallback) (GstPad *pad, gboolean blocked, gpointer user_data);
|
||||
|
||||
/**
|
||||
* GstPadDirection:
|
||||
* @GST_PAD_UNKNOWN: direction is unknown.
|
||||
* @GST_PAD_SRC: the pad is a source pad.
|
||||
* @GST_PAD_SINK: the pad is a sink pad.
|
||||
*
|
||||
* The direction of a pad.
|
||||
*/
|
||||
typedef enum {
|
||||
GST_PAD_UNKNOWN,
|
||||
GST_PAD_SRC,
|
||||
|
@ -153,6 +262,9 @@ typedef enum {
|
|||
GST_PAD_FLAG_LAST = GST_OBJECT_FLAG_LAST + 8
|
||||
} GstPadFlags;
|
||||
|
||||
/* FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h) */
|
||||
typedef struct _GstPadTemplate GstPadTemplate;
|
||||
|
||||
struct _GstPad {
|
||||
GstObject object;
|
||||
|
||||
|
@ -306,67 +418,8 @@ struct _GstPadClass {
|
|||
#define GST_PAD_BLOCK_WAIT(pad) (g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_GET_LOCK (pad)))
|
||||
#define GST_PAD_BLOCK_SIGNAL(pad) (g_cond_signal(GST_PAD_BLOCK_GET_COND (pad)))
|
||||
|
||||
/***** PadTemplate *****/
|
||||
#define GST_TYPE_PAD_TEMPLATE (gst_pad_template_get_type ())
|
||||
#define GST_PAD_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD_TEMPLATE,GstPadTemplate))
|
||||
#define GST_PAD_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD_TEMPLATE,GstPadTemplateClass))
|
||||
#define GST_IS_PAD_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD_TEMPLATE))
|
||||
#define GST_IS_PAD_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD_TEMPLATE))
|
||||
|
||||
typedef enum {
|
||||
GST_PAD_ALWAYS,
|
||||
GST_PAD_SOMETIMES,
|
||||
GST_PAD_REQUEST
|
||||
} GstPadPresence;
|
||||
|
||||
#define GST_PAD_TEMPLATE_NAME_TEMPLATE(templ) (((GstPadTemplate *)(templ))->name_template)
|
||||
#define GST_PAD_TEMPLATE_DIRECTION(templ) (((GstPadTemplate *)(templ))->direction)
|
||||
#define GST_PAD_TEMPLATE_PRESENCE(templ) (((GstPadTemplate *)(templ))->presence)
|
||||
#define GST_PAD_TEMPLATE_CAPS(templ) (((GstPadTemplate *)(templ))->caps)
|
||||
|
||||
typedef enum {
|
||||
GST_PAD_TEMPLATE_FIXED = GST_OBJECT_FLAG_LAST,
|
||||
|
||||
GST_PAD_TEMPLATE_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4
|
||||
} GstPadTemplateFlags;
|
||||
|
||||
#define GST_PAD_TEMPLATE_IS_FIXED(templ) (GST_FLAG_IS_SET(templ, GST_PAD_TEMPLATE_FIXED))
|
||||
|
||||
struct _GstPadTemplate {
|
||||
GstObject object;
|
||||
|
||||
gchar *name_template;
|
||||
GstPadDirection direction;
|
||||
GstPadPresence presence;
|
||||
GstCaps *caps;
|
||||
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
struct _GstPadTemplateClass {
|
||||
GstObjectClass parent_class;
|
||||
|
||||
/* signal callbacks */
|
||||
void (*pad_created) (GstPadTemplate *templ, GstPad *pad);
|
||||
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
struct _GstStaticPadTemplate {
|
||||
gchar *name_template;
|
||||
GstPadDirection direction;
|
||||
GstPadPresence presence;
|
||||
GstStaticCaps static_caps;
|
||||
};
|
||||
|
||||
#define GST_STATIC_PAD_TEMPLATE(padname, dir, pres, caps) \
|
||||
{ \
|
||||
/* name_template */ padname, \
|
||||
/* direction */ dir, \
|
||||
/* presence */ pres, \
|
||||
/* caps */ caps \
|
||||
}
|
||||
|
||||
/* FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h) */
|
||||
#include <gst/gstpadtemplate.h>
|
||||
|
||||
GType gst_pad_get_type (void);
|
||||
|
||||
|
@ -482,19 +535,6 @@ gboolean gst_pad_dispatcher (GstPad *pad, GstPadDispatcherFunction dispatch,
|
|||
void gst_pad_load_and_link (xmlNodePtr self, GstObject *parent);
|
||||
#endif
|
||||
|
||||
|
||||
/* templates and factories */
|
||||
GType gst_pad_template_get_type (void);
|
||||
|
||||
GstPadTemplate* gst_pad_template_new (const gchar *name_template,
|
||||
GstPadDirection direction, GstPadPresence presence,
|
||||
GstCaps *caps);
|
||||
|
||||
GstPadTemplate * gst_static_pad_template_get (GstStaticPadTemplate *pad_template);
|
||||
GstCaps* gst_static_pad_template_get_caps (GstStaticPadTemplate *templ);
|
||||
GstCaps* gst_pad_template_get_caps (GstPadTemplate *templ);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_PAD_H__ */
|
||||
|
|
331
gst/gstpadtemplate.c
Normal file
331
gst/gstpadtemplate.c
Normal file
|
@ -0,0 +1,331 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
||||
* 2000 Wim Taymans <wtay@chello.be>
|
||||
*
|
||||
* gstpadtemplate.c: Templates for pad creation
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
/**
|
||||
* SECTION:gstpadtemplate
|
||||
* @short_description: Describe the media type of a pad.
|
||||
* @see_also: #GstPad, #GstElementFactory
|
||||
*
|
||||
* Padtemplates describe the possible media types a pad or an elementfactory can
|
||||
* handle.
|
||||
*
|
||||
* Pad and PadTemplates have #GstCaps attached to it to describe the media type they
|
||||
* are capable of dealing with. gst_pad_template_get_caps() is used to get the
|
||||
* caps of a padtemplate. It's not possible to modify the caps of a padtemplate after
|
||||
* creation.
|
||||
*
|
||||
* Padtemplates can be created with gst_pad_template_new() or with the convenient
|
||||
* GST_PAD_TEMPLATE_FACTORY() macro. A padtemplate can be used to create a pad or
|
||||
* to add to an elementfactory.
|
||||
*
|
||||
* The following code example shows the code to create a pad from a padtemplate.
|
||||
* <example>
|
||||
* <title>Create a pad from a padtemplate</title>
|
||||
* <programlisting>
|
||||
* GstStaticPadTemplate my_template =
|
||||
* GST_STATIC_PAD_TEMPLATE (
|
||||
* "sink", // the name of the pad
|
||||
* GST_PAD_SINK, // the direction of the pad
|
||||
* GST_PAD_ALWAYS, // when this pad will be present
|
||||
* GST_STATIC_CAPS ( // the capabilities of the padtemplate
|
||||
* "audio/x-raw-int, "
|
||||
* "channels = (int) [ 1, 6 ]"
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* void
|
||||
* my_method (void)
|
||||
* {
|
||||
* GstPad *pad;
|
||||
*
|
||||
* pad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (my_template_factory), "sink");
|
||||
* ...
|
||||
* }
|
||||
* </programlisting>
|
||||
* </example>
|
||||
*
|
||||
* The following example shows you how to add the padtemplate to an elementfactory:
|
||||
* <informalexample>
|
||||
* <programlisting>
|
||||
* gboolean
|
||||
* my_factory_init (GstPlugin *plugin)
|
||||
* {
|
||||
* GstElementFactory *factory;
|
||||
*
|
||||
* factory = gst_element_factory_new ("my_factory", GST_TYPE_MYFACTORY, &gst_myfactory_details);
|
||||
* g_return_val_if_fail (factory != NULL, FALSE);
|
||||
*
|
||||
* gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (my_template_factory));
|
||||
*
|
||||
* gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
|
||||
*
|
||||
* return TRUE;
|
||||
* }
|
||||
* </programlisting>
|
||||
* </informalexample>
|
||||
*/
|
||||
|
||||
#include "gst_private.h"
|
||||
|
||||
#include "gstpad.h"
|
||||
#include "gstpadtemplate.h"
|
||||
#include "gstenumtypes.h"
|
||||
#include "gstmarshal.h"
|
||||
#include "gstutils.h"
|
||||
#include "gstinfo.h"
|
||||
#include "gsterror.h"
|
||||
#include "gstvalue.h"
|
||||
|
||||
#define GST_CAT_DEFAULT GST_CAT_PADS
|
||||
|
||||
enum
|
||||
{
|
||||
TEMPL_PAD_CREATED,
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static GstObject *parent_class = NULL;
|
||||
static guint gst_pad_template_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static void gst_pad_template_class_init (GstPadTemplateClass * klass);
|
||||
static void gst_pad_template_init (GstPadTemplate * templ);
|
||||
static void gst_pad_template_dispose (GObject * object);
|
||||
|
||||
GType
|
||||
gst_pad_template_get_type (void)
|
||||
{
|
||||
static GType padtemplate_type = 0;
|
||||
|
||||
if (!padtemplate_type) {
|
||||
static const GTypeInfo padtemplate_info = {
|
||||
sizeof (GstPadTemplateClass), NULL, NULL,
|
||||
(GClassInitFunc) gst_pad_template_class_init, NULL, NULL,
|
||||
sizeof (GstPadTemplate),
|
||||
0,
|
||||
(GInstanceInitFunc) gst_pad_template_init, NULL
|
||||
};
|
||||
|
||||
padtemplate_type =
|
||||
g_type_register_static (GST_TYPE_OBJECT, "GstPadTemplate",
|
||||
&padtemplate_info, 0);
|
||||
}
|
||||
return padtemplate_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pad_template_class_init (GstPadTemplateClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstObjectClass *gstobject_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
gstobject_class = (GstObjectClass *) klass;
|
||||
|
||||
parent_class = g_type_class_ref (GST_TYPE_OBJECT);
|
||||
|
||||
/**
|
||||
* GstPadTemplate::pad-created:
|
||||
* @pad_template: the object which received the signal.
|
||||
* @pad: the pad that was created.
|
||||
*
|
||||
* This signal is fired when an element creates a pad from this template.
|
||||
*/
|
||||
gst_pad_template_signals[TEMPL_PAD_CREATED] =
|
||||
g_signal_new ("pad-created", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GstPadTemplateClass, pad_created),
|
||||
NULL, NULL, gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_PAD);
|
||||
|
||||
gobject_class->dispose = gst_pad_template_dispose;
|
||||
|
||||
gstobject_class->path_string_separator = "*";
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pad_template_init (GstPadTemplate * templ)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pad_template_dispose (GObject * object)
|
||||
{
|
||||
GstPadTemplate *templ = GST_PAD_TEMPLATE (object);
|
||||
|
||||
g_free (GST_PAD_TEMPLATE_NAME_TEMPLATE (templ));
|
||||
if (GST_PAD_TEMPLATE_CAPS (templ)) {
|
||||
gst_caps_unref (GST_PAD_TEMPLATE_CAPS (templ));
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
/* ALWAYS padtemplates cannot have conversion specifications (like src_%d),
|
||||
* since it doesn't make sense.
|
||||
* SOMETIMES padtemplates can do whatever they want, they are provided by the
|
||||
* element.
|
||||
* REQUEST padtemplates can be reverse-parsed (the user asks for 'sink1', the
|
||||
* 'sink%d' template is automatically selected), so we need to restrict their
|
||||
* naming.
|
||||
*/
|
||||
static gboolean
|
||||
name_is_valid (const gchar * name, GstPadPresence presence)
|
||||
{
|
||||
const gchar *str;
|
||||
|
||||
if (presence == GST_PAD_ALWAYS) {
|
||||
if (strchr (name, '%')) {
|
||||
g_warning ("invalid name template %s: conversion specifications are not"
|
||||
" allowed for GST_PAD_ALWAYS padtemplates", name);
|
||||
return FALSE;
|
||||
}
|
||||
} else if (presence == GST_PAD_REQUEST) {
|
||||
if ((str = strchr (name, '%')) && strchr (str + 1, '%')) {
|
||||
g_warning ("invalid name template %s: only one conversion specification"
|
||||
" allowed in GST_PAD_REQUEST padtemplate", name);
|
||||
return FALSE;
|
||||
}
|
||||
if (str && (*(str + 1) != 's' && *(str + 1) != 'd')) {
|
||||
g_warning ("invalid name template %s: conversion specification must be of"
|
||||
" type '%%d' or '%%s' for GST_PAD_REQUEST padtemplate", name);
|
||||
return FALSE;
|
||||
}
|
||||
if (str && (*(str + 2) != '\0')) {
|
||||
g_warning ("invalid name template %s: conversion specification must"
|
||||
" appear at the end of the GST_PAD_REQUEST padtemplate name", name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_static_pad_template_get:
|
||||
* @pad_template: the static pad template
|
||||
*
|
||||
* Converts a #GstStaticPadTemplate into a #GstPadTemplate.
|
||||
*
|
||||
* Returns: a new #GstPadTemplate.
|
||||
*/
|
||||
GstPadTemplate *
|
||||
gst_static_pad_template_get (GstStaticPadTemplate * pad_template)
|
||||
{
|
||||
GstPadTemplate *new;
|
||||
|
||||
if (!name_is_valid (pad_template->name_template, pad_template->presence))
|
||||
return NULL;
|
||||
|
||||
new = g_object_new (gst_pad_template_get_type (),
|
||||
"name", pad_template->name_template, NULL);
|
||||
|
||||
GST_PAD_TEMPLATE_NAME_TEMPLATE (new) = g_strdup (pad_template->name_template);
|
||||
GST_PAD_TEMPLATE_DIRECTION (new) = pad_template->direction;
|
||||
GST_PAD_TEMPLATE_PRESENCE (new) = pad_template->presence;
|
||||
|
||||
GST_PAD_TEMPLATE_CAPS (new) =
|
||||
gst_caps_copy (gst_static_caps_get (&pad_template->static_caps));
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_template_new:
|
||||
* @name_template: the name template.
|
||||
* @direction: the #GstPadDirection of the template.
|
||||
* @presence: the #GstPadPresence of the pad.
|
||||
* @caps: a #GstCaps set for the template. The caps are taken ownership of.
|
||||
*
|
||||
* Creates a new pad template with a name according to the given template
|
||||
* and with the given arguments. This functions takes ownership of the provided
|
||||
* caps, so be sure to not use them afterwards.
|
||||
*
|
||||
* Returns: a new #GstPadTemplate.
|
||||
*/
|
||||
GstPadTemplate *
|
||||
gst_pad_template_new (const gchar * name_template,
|
||||
GstPadDirection direction, GstPadPresence presence, GstCaps * caps)
|
||||
{
|
||||
GstPadTemplate *new;
|
||||
|
||||
g_return_val_if_fail (name_template != NULL, NULL);
|
||||
g_return_val_if_fail (caps != NULL, NULL);
|
||||
g_return_val_if_fail (direction == GST_PAD_SRC
|
||||
|| direction == GST_PAD_SINK, NULL);
|
||||
g_return_val_if_fail (presence == GST_PAD_ALWAYS
|
||||
|| presence == GST_PAD_SOMETIMES || presence == GST_PAD_REQUEST, NULL);
|
||||
|
||||
if (!name_is_valid (name_template, presence)) {
|
||||
gst_caps_unref (caps);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new = g_object_new (gst_pad_template_get_type (),
|
||||
"name", name_template, NULL);
|
||||
|
||||
GST_PAD_TEMPLATE_NAME_TEMPLATE (new) = g_strdup (name_template);
|
||||
GST_PAD_TEMPLATE_DIRECTION (new) = direction;
|
||||
GST_PAD_TEMPLATE_PRESENCE (new) = presence;
|
||||
GST_PAD_TEMPLATE_CAPS (new) = caps;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_static_pad_template_get_caps:
|
||||
* @templ: a #GstStaticPadTemplate to get capabilities of.
|
||||
*
|
||||
* Gets the capabilities of the static pad template.
|
||||
*
|
||||
* Returns: the #GstCaps of the static pad template. If you need to keep a
|
||||
* reference to the caps, take a ref (see gst_caps_ref ()).
|
||||
*/
|
||||
GstCaps *
|
||||
gst_static_pad_template_get_caps (GstStaticPadTemplate * templ)
|
||||
{
|
||||
g_return_val_if_fail (templ, NULL);
|
||||
|
||||
return (GstCaps *) gst_static_caps_get (&templ->static_caps);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_template_get_caps:
|
||||
* @templ: a #GstPadTemplate to get capabilities of.
|
||||
*
|
||||
* Gets the capabilities of the pad template.
|
||||
*
|
||||
* Returns: the #GstCaps of the pad template. If you need to keep a reference to
|
||||
* the caps, take a ref (see gst_caps_ref ()).
|
||||
*/
|
||||
GstCaps *
|
||||
gst_pad_template_get_caps (GstPadTemplate * templ)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_PAD_TEMPLATE (templ), NULL);
|
||||
|
||||
return GST_PAD_TEMPLATE_CAPS (templ);
|
||||
}
|
||||
|
||||
void
|
||||
gst_pad_template_pad_created (GstPadTemplate * templ, GstPad * pad)
|
||||
{
|
||||
gst_object_sink (GST_OBJECT (templ));
|
||||
g_signal_emit (G_OBJECT (templ),
|
||||
gst_pad_template_signals[TEMPL_PAD_CREATED], 0, pad);
|
||||
}
|
174
gst/gstpadtemplate.h
Normal file
174
gst/gstpadtemplate.h
Normal file
|
@ -0,0 +1,174 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
||||
* 2000 Wim Taymans <wim.taymans@chello.be>
|
||||
*
|
||||
* gstpadtemplate.h: Header for GstPadTemplate object
|
||||
*
|
||||
* 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_PAD_TEMPLATE_H__
|
||||
#define __GST_PAD_TEMPLATE_H__
|
||||
|
||||
#include <gst/gstconfig.h>
|
||||
|
||||
#include <gst/gstobject.h>
|
||||
#include <gst/gstbuffer.h>
|
||||
#include <gst/gstcaps.h>
|
||||
#include <gst/gstevent.h>
|
||||
#include <gst/gstquery.h>
|
||||
#include <gst/gstqueryutils.h>
|
||||
#include <gst/gsttask.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* FIXME: this awful circular dependency need to be resolved properly (see pad.h) */
|
||||
//typedef struct _GstPadTemplate GstPadTemplate;
|
||||
typedef struct _GstPadTemplateClass GstPadTemplateClass;
|
||||
typedef struct _GstStaticPadTemplate GstStaticPadTemplate;
|
||||
|
||||
#define GST_TYPE_PAD_TEMPLATE (gst_pad_template_get_type ())
|
||||
#define GST_PAD_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD_TEMPLATE,GstPadTemplate))
|
||||
#define GST_PAD_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD_TEMPLATE,GstPadTemplateClass))
|
||||
#define GST_IS_PAD_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD_TEMPLATE))
|
||||
#define GST_IS_PAD_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD_TEMPLATE))
|
||||
|
||||
/**
|
||||
* GstPadPresence:
|
||||
* @GST_PAD_ALWAYS: the pad is always available
|
||||
* @GST_PAD_SOMETIMES: the pad will become available depending on the media stream
|
||||
* @GST_PAD_REQUEST: the pad is only available on request with
|
||||
* gst_element_request_pad_by_name() or gst_element_request_compatible_pad().
|
||||
*
|
||||
* Indicates when this pad will become available.
|
||||
*/
|
||||
typedef enum {
|
||||
GST_PAD_ALWAYS,
|
||||
GST_PAD_SOMETIMES,
|
||||
GST_PAD_REQUEST
|
||||
} GstPadPresence;
|
||||
|
||||
/**
|
||||
* GST_PAD_TEMPLATE_NAME_TEMPLATE:
|
||||
* @templ: the template to query
|
||||
*
|
||||
* Get the nametemplate of the padtemplate.
|
||||
*/
|
||||
#define GST_PAD_TEMPLATE_NAME_TEMPLATE(templ) (((GstPadTemplate *)(templ))->name_template)
|
||||
|
||||
/**
|
||||
* GST_PAD_TEMPLATE_DIRECTION:
|
||||
* @templ: the template to query
|
||||
*
|
||||
* Get the direction of the padtemplate.
|
||||
*/
|
||||
#define GST_PAD_TEMPLATE_DIRECTION(templ) (((GstPadTemplate *)(templ))->direction)
|
||||
|
||||
/**
|
||||
* GST_PAD_TEMPLATE_PRESENCE:
|
||||
* @templ: the template to query
|
||||
*
|
||||
* Get the presence of the padtemplate.
|
||||
*/
|
||||
#define GST_PAD_TEMPLATE_PRESENCE(templ) (((GstPadTemplate *)(templ))->presence)
|
||||
|
||||
/**
|
||||
* GST_PAD_TEMPLATE_CAPS:
|
||||
* @templ: the template to query
|
||||
*
|
||||
* Get a handle to the padtemplate #GstCaps
|
||||
*/
|
||||
#define GST_PAD_TEMPLATE_CAPS(templ) (((GstPadTemplate *)(templ))->caps)
|
||||
|
||||
/**
|
||||
* GstPadTemplateFlags:
|
||||
* @GST_PAD_TEMPLATE_FIXED: the padtemplate has no variable properties
|
||||
* @GST_PAD_TEMPLATE_FLAG_LAST: first flag that can be used by subclasses.
|
||||
*
|
||||
* Flags for the padtemplate
|
||||
*/
|
||||
typedef enum {
|
||||
GST_PAD_TEMPLATE_FIXED = GST_OBJECT_FLAG_LAST,
|
||||
|
||||
GST_PAD_TEMPLATE_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4
|
||||
} GstPadTemplateFlags;
|
||||
|
||||
/**
|
||||
* GST_PAD_TEMPLATE_IS_FIXED:
|
||||
* @templ: the template to query
|
||||
*
|
||||
* Check if the properties of the padtemplate are fixed
|
||||
*/
|
||||
#define GST_PAD_TEMPLATE_IS_FIXED(templ) (GST_FLAG_IS_SET(templ, GST_PAD_TEMPLATE_FIXED))
|
||||
|
||||
/**
|
||||
* GstPadTemplate:
|
||||
*
|
||||
* The padtemplate object.
|
||||
*/
|
||||
struct _GstPadTemplate {
|
||||
GstObject object;
|
||||
|
||||
gchar *name_template;
|
||||
GstPadDirection direction;
|
||||
GstPadPresence presence;
|
||||
GstCaps *caps;
|
||||
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
struct _GstPadTemplateClass {
|
||||
GstObjectClass parent_class;
|
||||
|
||||
/* signal callbacks */
|
||||
void (*pad_created) (GstPadTemplate *templ, GstPad *pad);
|
||||
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
struct _GstStaticPadTemplate {
|
||||
gchar *name_template;
|
||||
GstPadDirection direction;
|
||||
GstPadPresence presence;
|
||||
GstStaticCaps static_caps;
|
||||
};
|
||||
|
||||
#define GST_STATIC_PAD_TEMPLATE(padname, dir, pres, caps) \
|
||||
{ \
|
||||
/* name_template */ padname, \
|
||||
/* direction */ dir, \
|
||||
/* presence */ pres, \
|
||||
/* caps */ caps \
|
||||
}
|
||||
|
||||
/* templates and factories */
|
||||
GType gst_pad_template_get_type (void);
|
||||
|
||||
GstPadTemplate* gst_pad_template_new (const gchar *name_template,
|
||||
GstPadDirection direction, GstPadPresence presence,
|
||||
GstCaps *caps);
|
||||
|
||||
GstPadTemplate * gst_static_pad_template_get (GstStaticPadTemplate *pad_template);
|
||||
GstCaps* gst_static_pad_template_get_caps (GstStaticPadTemplate *templ);
|
||||
GstCaps* gst_pad_template_get_caps (GstPadTemplate *templ);
|
||||
|
||||
void gst_pad_template_pad_created (GstPadTemplate * templ, GstPad * pad);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_PAD_TEMPLATE_H__ */
|
||||
|
Loading…
Reference in a new issue