Merge CAPS branch

Original commit message from CVS:
Merge CAPS branch
This commit is contained in:
David Schleef 2003-12-22 01:39:35 +00:00
parent 54b3850775
commit 8c9cd079d4
110 changed files with 2976 additions and 7684 deletions

View file

@ -604,6 +604,7 @@ testsuite/Makefile
testsuite/bins/Makefile
testsuite/bytestream/Makefile
testsuite/caps/Makefile
testsuite/caps2/Makefile
testsuite/cleanup/Makefile
testsuite/clock/Makefile
testsuite/debug/Makefile

231
docs/random/caps2 Normal file
View file

@ -0,0 +1,231 @@
The new caps code uses the type name GstCaps2 and the function
names gst_caps2_*(). Before the CAPS branch is merged, there
will be a global change from caps2 to caps. Since GstCaps is
no longer defined, it no longer compiles, thus highlighting
exactly what needs to be changed in an element.
Pad Templates:
Old style:
GST_PAD_TEMPLATE_FACTORY (fakesrc_src_factory,
"src%d",
GST_PAD_SRC,
GST_PAD_REQUEST,
GST_CAPS_ANY
);
New style:
GstStaticPadTemplate fakesrc_src_template = GST_STATIC_PAD_TEMPLATE (
"src%d",
GST_PAD_SRC,
GST_PAD_REQUEST,
GST_STATIC_CAPS2_ANY
);
The old style defined a function called fakesrc_src_factory(), which,
when called, returns a pad template. The new style defines a
GstStaticPadTemplate, which can be converted to a GstPadTemplate
by the function gst_static_pad_template_get(). The 4th argument
is also different -- previously it would call the GST_CAPS_NEW()
function. Now it is a GstStaticCaps.
Not every pad template can be converted to a GstStaticPadTemplate,
particularly those which create caps from another source at runtime,
such as videotestsrc.
Caps:
Old style:
GST_CAPS_NEW (
"sinesrc_src",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT_RANGE (8000, 48000),
"channels", GST_PROPS_INT (1)
)
New style:
GST_STATIC_CAPS2 ( "audio/x-raw-int, "
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
"signed = (boolean) true, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) [ 8000, 48000 ], "
"channels = (int) 1"
)
The old style calls a function that creates a GstCaps. The new style
stores a string in a GstStaticCaps2, and this string is converted to
a caps in the function gst_static_caps2_get().
Note that the old caps name is no longer used.
Old style:
caps = GST_CAPS_NEW ("videotestsrc_filter",
"video/x-raw-rgb",
"bpp", GST_PROPS_INT(format->bitspp),
"endianness", GST_PROPS_INT(endianness),
"depth", GST_PROPS_INT(format->depth),
"red_mask", GST_PROPS_INT(format->red_mask),
"green_mask", GST_PROPS_INT(format->green_mask),
"blue_mask", GST_PROPS_INT(format->blue_mask));
New style:
caps = gst_caps2_new_simple("video/x-raw-rgb",
"bpp", G_TYPE_INT, format->bitspp,
"endianness", G_TYPE_INT, endianness,
"depth", G_TYPE_INT, format->depth,
"red_mask", G_TYPE_INT, format->red_mask,
"green_mask", G_TYPE_INT, format->green_mask,
"blue_mask", G_TYPE_INT, format->blue_mask);
Not everything can be converted in this way, especially lists and
ranges.
IMPLEMENTATION
Pad Capabilities (caps) are mathematical sets that represent all the
possible stream types that a pad can use. These general sets are
represented by unions of simpler sets known as caps structures. Each
caps structure has a media type (e.g., "audio/mpeg") and a number of
properties. Each property has a name and a GValue. In normal
circumstances, the GValue will have the types int, boolean, string,
fourcc, and double. Simple sets are constructed by using GValues
that are lists of other GValues, or the special types that represent
int ranges and double ranges.
A "fixed" caps represents exactly one media format. This means that
the caps is a union of exactly one caps structure, and each property
in the caps structure is a simple type, i.e., no ranges or lists.
There are two special caps values, "ANY" which represents the union
of all stream types, and "EMPTY", which represents the set of no
stream types. The ANY caps is often used on generic elements that
handle any type of data (e.g., filesrc and filesink). The EMPTY
caps is the return value of gst_caps_intersect(), when the two
given caps do not intersect. In many cases, using EMPTY is invalid.
CAPS NEGOTIATION
Elements provide information to the core about what stream formats
they understand in four ways: the caps in the pad templates, the
caps returned by a pad's getcaps function, accepting/denying
a given caps in the pad link function, and a new fixate function.
The pad template caps should be the union of caps a pad supports
in any potential situation. Simultaneously, these caps should be
as specific as possible, since it is used to decide which elements
to attempt for autoplugging, without having to load the element.
The pad template caps are generally detemined at compile time, but
might be actually computed at run-time from other information.
The getcaps() function returns the caps supported by a given pad,
in the context of the element's state, its link to other elements,
and the devices or files it has opened. These caps must be a
subset of the pad template caps. In the NULL state with no links,
the getcaps function should ideally return the same caps as the
pad template. In rare circumstances, an object property can affect
the caps returned by getcaps, but this is discouraged. For most
filters, the caps returned by getcaps is directly affected by the
allowed caps on other pads. For demuxers and decoders, the caps
returned by the srcpad's getcaps function is directly related to
the stream data. Again, getcaps should return the most specific
caps it reasonably can, since this helps with autoplugging.
The pad link function is the last step in negotiating caps. The
core calls the pad link function with a fixed caps, meaning that
the stream format is precisely defined, with the caps having one
structure, with no fields that are ranges or lists.
There is also a new pad function "fixate", which is used to help
choose a fixed caps from a non-fixed caps. This is called in
situations where normal negotiation cannot decide on a fixed caps.
You should almost never implement a fixate function, please ask
me if it is appropriate for your case. Fixate functions are called
iteratively on the pads until a fixed caps is found. Fixate functions
are called with a const caps, and should return a caps that is a
strict subset of the given caps. That is, the function should
create a caps that is "more fixed" than previously, but does not
have to return fixed caps. If the fixate function can't provide
more fixed caps, it should return NULL.
Checklist for getcaps:
- The getcaps function prototype no longer has the caps parameter.
Remove it.
- The returned caps is owned by the caller. Make sure you don't
keep a pointer to the caps.
- Make sure that the getcaps function can be called safely in each
element state (NULL, READY, PAUSED, PLAYING), and for any element
configuration (properties, links, devices/files opened or not,
error state, etc.)
- Make sure that the returned caps do not depend on the caps that
indicate the stream type that the pad is currently using.
Checklist for pad_link:
- The pad link function prototypes uses a const GstCaps *.
- Pad link functions are called with fixed caps. There's no need
to check for this. This means that you can assume that the caps
is not ANY or EMPTY, and that there is exactly one structure in
the caps, and that all the properties in the caps
- Pad link functions are called with caps that are a subset of the
most recent return value of the pad's getcaps function. Generally,
the getcaps function was called immediately prior to calling the
src_link function. For 0.8, you can assume that nothing has changed
in your element that would cause a change to the return value of
getcaps.
- the return value GST_PAD_LINK_OK should be used when the caps are
acceptable, and you've extracted all the necessary information from
the caps and set the element's internal state appropriately.
- the return value GST_PAD_LINK_REFUSED should be used when the caps
are unacceptable for whatever reason.
- the return value GST_PAD_LINK_DELAYED should be used when the
element is in a state where it can't determine whether the caps
are acceptable or not. This is often used if the element needs
to open a device or process data before determining acceptable
caps.
- the pad_link function must not call gst_caps_try_set_caps() on
the pad that was specified as a parameter.
- the pad_link function may (and often should) call
gst_caps_try_set_caps() on pads that are not specified as the
pad parameter.
Checklist for fixate:
- Make sure you actually should be using a fixate function. Fixate
functions are reasonable for non-fixed primary sources, such as
videotestsrc, v4lsrc, and osssrc.
- The user_data parameter is mainly used for user-provided fixate
function. It should be ignored in element fixate functions.

54
docs/random/caps_grammar Normal file
View file

@ -0,0 +1,54 @@
Canonical caps/structure strings (those created by gst_caps_to_string()
and gst_structure_to_string()) do not have AUTO_VALUE.
Goals:
- UTF-8 clean
- SIMPLE_STRINGs should cover most simple cases that don't interfere
with other parts of the gst_caps or gst_parse grammar
- forward-parsed grammar
- quoted strings handle backslash escaping as well as XML-style (&ack;)
escaping
CAPS = STRUCTURE [ ';' STRUCTURE ]*
STRUCTURE = STRUCTURE_NAME [ ',' FIELD ]*
STRUCTURE_NAME = STRING
FIELD = FIELD_NAME '=' TYPED_VALUE
FIELD_NAME = SIMPLE_STRING
TYPED_VALUE = CANONICAL_VALUE | AUTO_VALUE
CANONICAL_VALUE = '{' TYPED_VALUE [ ',' TYPED_VALUE ]* '}'
| '[' TYPED_VALUE ',' TYPED_VALUE ']'
| '(' TYPE ')' VALUE
AUTO_VALUE = [-+]?[0-9][0-9]*
| [-+]?[0-9][0-9]*[.][0-9]*[eE][-+][0-9]*
| STRING
VALUE = STRING
STRING = ["][^"]["]
| ['][^'][']
| SIMPLE_STRING
SIMPLE_STRING = [A-Za-z0-9_+-:./]+
TYPE = "int" | "i" | "float" | "f" | "double" | "d" | "fourcc" | "4"
| "boolean" | "bool" | "b"
| GTYPE
Canonical Examples:
"audio/raw"
"audio/raw", rate=(int)44100
"audio/raw", rate=(int)44100, signed=(boolean)true
"audio/raw", rate={ (int)44100, (int)48000 }
"audio/raw", rate=[ (int)8000, (int)48000 ]

View file

@ -330,7 +330,7 @@ create_input_channel (int id, char* location)
#endif
new_element = gst_autoplug_to_caps (autoplug, srccaps,
gst_caps_new ("audio", "audio/raw", NULL), NULL);
gst_caps_new ("audio/raw", NULL), NULL);
if (!new_element) {
g_print ("could not autoplug, no suitable codecs found...\n");

View file

@ -57,31 +57,25 @@ enum {
* can have. They can be quite complex, but for this example plugin
* they are rather simple.
*/
GST_PAD_TEMPLATE_FACTORY (sink_factory,
GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE (
"sink", /* The name of the pad */
GST_PAD_SINK, /* Direction of the pad */
GST_PAD_ALWAYS, /* The pad exists for every instance */
GST_CAPS_NEW (
"example_sink", /* The name of the caps */
"unknown/unknown", /* The overall MIME/type */
"foo", GST_PROPS_INT (1), /* An integer property */
"bar", GST_PROPS_BOOLEAN (TRUE), /* A boolean */
"baz", GST_PROPS_LIST ( /* A list of values for */
GST_PROPS_INT (1),
GST_PROPS_INT (3)
)
GST_STATIC_CAPS (
"unknown/unknown, " /* The MIME media type */
"foo:int=1, " /* an integer property */
"bar:boolean=true, " /* a boolean property */
"baz:int={ 1, 3 }" /* a list of values */
)
);
/* This factory is much simpler, and defines the source pad. */
GST_PAD_TEMPLATE_FACTORY (src_factory,
GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"example_src",
"unknown/unknown",
NULL
GST_STATIC_CAPS (
"unknown/unknown"
)
);
@ -189,8 +183,10 @@ gst_example_class_init (GstExampleClass *klass)
/* The pad templates can be easily generated from the factories above,
* and then added to the list of padtemplates for the class.
*/
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (sink_factory));
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (src_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&sink_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&src_template));
}
/* This function is responsible for initializing a specific instance of
@ -203,7 +199,7 @@ gst_example_init(GstExample *example)
* We will use the template constructed by the factory.
*/
example->sinkpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (sink_factory), "sink");
gst_static_pad_template_get (&sink_template), "sink");
/* Setting the chain function allows us to supply the function that will
* actually be performing the work. Without this, the element would do
* nothing, with undefined results (assertion failures and such).
@ -220,7 +216,7 @@ gst_example_init(GstExample *example)
* they only produce them.
*/
example->srcpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (src_factory), "src");
gst_static_pad_template_get (&src_template), "src");
gst_element_add_pad(GST_ELEMENT(example),example->srcpad);
/* Initialization of element's private variables. */

View file

@ -1,7 +1,7 @@
#include <gst/gst.h>
void
type_found (GstElement *typefind, GstCaps* caps)
type_found (GstElement *typefind, const GstCaps * caps)
{
xmlDocPtr doc;
xmlNodePtr parent;
@ -10,7 +10,8 @@ type_found (GstElement *typefind, GstCaps* caps)
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
parent = xmlNewChild (doc->xmlRootNode, NULL, "Caps1", NULL);
gst_caps_save_thyself (caps, parent);
/* FIXME */
//gst_caps_save_thyself (caps, parent);
xmlDocDump (stdout, doc);
}

View file

@ -80,8 +80,7 @@ libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
gstatomic.c \
gstbin.c \
gstbuffer.c \
gstbufferpool-default.c \
gstcaps.c \
gstcaps2.c \
gstclock.c \
gstcpu.c \
gstdata.c \
@ -98,7 +97,6 @@ libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
gstpipeline.c \
gstplugin.c \
gstpluginfeature.c \
gstprops.c \
gstprobe.c \
gstqueue.c \
gstquery.c \
@ -143,8 +141,7 @@ gst_headers = \
gstobject.h \
gstbin.h \
gstbuffer.h \
gstbufferpool-default.h \
gstcaps.h \
gstcaps2.h \
gstclock.h \
gstcompat.h \
gstcpu.h \
@ -164,7 +161,6 @@ gst_headers = \
gstplugin.h \
gstpluginfeature.h \
gstprobe.h \
gstprops.h \
gstqueue.h \
gstquery.h \
gstscheduler.h \

View file

@ -58,7 +58,7 @@ g_list_free_list_and_elements (GList *list)
* Returns: TRUE, if both caps intersect.
*/
gboolean
gst_autoplug_caps_intersect (GstCaps *src, GstCaps *sink)
gst_autoplug_caps_intersect (const GstCaps *src, const GstCaps *sink)
{
GstCaps *caps;
@ -74,7 +74,7 @@ gst_autoplug_caps_intersect (GstCaps *src, GstCaps *sink)
return FALSE;
/* hurrah, we can link, now remove the intersection */
gst_caps_unref (caps);
gst_caps_free (caps);
return TRUE;
}
@ -88,7 +88,7 @@ gst_autoplug_caps_intersect (GstCaps *src, GstCaps *sink)
* Returns: #GstPadTemplate that can connect to the given caps
*/
GstPadTemplate *
gst_autoplug_can_connect_src (GstElementFactory *fac, GstCaps *src)
gst_autoplug_can_connect_src (GstElementFactory *fac, const GstCaps *src)
{
GList *templs;
@ -117,7 +117,7 @@ gst_autoplug_can_connect_src (GstElementFactory *fac, GstCaps *src)
* Returns: #GstPadTemplate that can connect to the given caps
*/
GstPadTemplate *
gst_autoplug_can_connect_sink (GstElementFactory *fac, GstCaps *sink)
gst_autoplug_can_connect_sink (GstElementFactory *fac, const GstCaps *sink)
{
GList *templs;
@ -331,7 +331,7 @@ gst_autoplug_factories_at_most_templates(GList *factories, GstPadDirection dir,
* to get the shortest path.
*/
GList *
gst_autoplug_sp (GstCaps *srccaps, GstCaps *sinkcaps, GList *factories)
gst_autoplug_sp (const GstCaps *srccaps, const GstCaps *sinkcaps, GList *factories)
{
GList *factory_nodes = NULL;
guint curcost = GST_AUTOPLUG_MAX_COST; /* below this cost, there is no path */
@ -341,10 +341,8 @@ gst_autoplug_sp (GstCaps *srccaps, GstCaps *sinkcaps, GList *factories)
g_return_val_if_fail (sinkcaps != NULL, NULL);
GST_INFO ("attempting to autoplug via shortest path from %s to %s",
gst_caps_get_mime (srccaps), gst_caps_get_mime (sinkcaps));
gst_caps_to_string(srccaps), gst_caps_to_string(sinkcaps));
gst_caps_debug (srccaps, "source caps");
gst_caps_debug (sinkcaps, "sink caps");
/* wrap all factories as GstAutoplugNode
* initialize the cost */
while (factories)

View file

@ -40,9 +40,9 @@ struct _GstAutoplugNode {
};
/* helper functions */
gboolean gst_autoplug_caps_intersect (GstCaps *src, GstCaps *sink);
GstPadTemplate * gst_autoplug_can_connect_src (GstElementFactory *fac, GstCaps *src);
GstPadTemplate * gst_autoplug_can_connect_sink (GstElementFactory *fac, GstCaps *sink);
gboolean gst_autoplug_caps_intersect (const GstCaps *src, const GstCaps *sink);
GstPadTemplate * gst_autoplug_can_connect_src (GstElementFactory *fac, const GstCaps *src);
GstPadTemplate * gst_autoplug_can_connect_sink (GstElementFactory *fac, const GstCaps *sink);
GstPadTemplate * gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest);
gboolean gst_autoplug_factory_has_direction (GstElementFactory *fac, GstPadDirection dir);
#define gst_autoplug_factory_has_sink(fac) gst_autoplug_factory_has_direction((fac), GST_PAD_SINK)
@ -59,6 +59,6 @@ GList * gst_autoplug_factories_filters_with_sink_caps(GList *factories);
GList * gst_autoplug_factories_at_most_templates(GList *factories, GstPadDirection dir, guint maxtemplates);
/* shortest path algorithm */
GList * gst_autoplug_sp (GstCaps *src_caps, GstCaps *sink_caps, GList *factories);
GList * gst_autoplug_sp (const GstCaps *src_caps, const GstCaps *sink_caps, GList *factories);
#endif /* __GST_SEARCHFUNCS_H__ */

View file

@ -65,11 +65,12 @@ enum {
};
/* generic templates */
GST_PAD_TEMPLATE_FACTORY (spider_src_factory,
static GstStaticPadTemplate spider_src_factory =
GST_STATIC_PAD_TEMPLATE (
"src_%d",
GST_PAD_SRC,
GST_PAD_REQUEST,
NULL /* no caps */
GST_STATIC_CAPS_ANY
);
/* standard GObject stuff */
@ -152,7 +153,8 @@ gst_spider_class_init (GstSpiderClass *klass)
gobject_class->get_property = gst_spider_get_property;
gobject_class->dispose = gst_spider_dispose;
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (spider_src_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&spider_src_factory));
gst_element_class_set_details (gstelement_class, &gst_spider_details);
gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_spider_request_new_pad);

View file

@ -41,18 +41,20 @@ static GstElementDetails gst_spider_identity_details = GST_ELEMENT_DETAILS (
/* generic templates
* delete me when meging with spider.c
*/
GST_PAD_TEMPLATE_FACTORY (spider_src_factory,
static GstStaticPadTemplate spider_src_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
NULL /* no caps */
GST_STATIC_CAPS_ANY
);
GST_PAD_TEMPLATE_FACTORY (spider_sink_factory,
static GstStaticPadTemplate spider_sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
NULL /* no caps */
GST_STATIC_CAPS_ANY
);
/* SpiderIdentity signals and args */
@ -73,8 +75,8 @@ static void gst_spider_identity_init (GstSpiderIdentity *spider_identity);
/* functions set in pads, elements and stuff */
static void gst_spider_identity_chain (GstPad *pad, GstBuffer *buf);
static GstElementStateReturn gst_spider_identity_change_state (GstElement *element);
static GstPadLinkReturn gst_spider_identity_link (GstPad *pad, GstCaps *caps);
static GstCaps * gst_spider_identity_getcaps (GstPad *pad, GstCaps *caps);
static GstPadLinkReturn gst_spider_identity_link (GstPad *pad, const GstCaps *caps);
static GstCaps * gst_spider_identity_getcaps (GstPad *pad);
/* loop functions */
static void gst_spider_identity_dumb_loop (GstSpiderIdentity *ident);
static void gst_spider_identity_src_loop (GstSpiderIdentity *ident);
@ -121,35 +123,28 @@ gst_spider_identity_class_init (GstSpiderIdentityClass *klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
/* add our two pad templates */
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (spider_src_factory));
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (spider_sink_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&spider_src_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&spider_sink_factory));
gst_element_class_set_details (gstelement_class, &gst_spider_identity_details);
gstelement_class->change_state = GST_DEBUG_FUNCPTR(gst_spider_identity_change_state);
gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_spider_identity_request_new_pad);
}
static GstBufferPool*
gst_spider_identity_get_bufferpool (GstPad *pad)
{
GstSpiderIdentity *ident;
ident = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad));
return gst_pad_get_bufferpool (ident->src);
}
static void
gst_spider_identity_init (GstSpiderIdentity *ident)
{
/* sink */
ident->sink = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (spider_sink_factory), "sink");
ident->sink = gst_pad_new_from_template (
gst_static_pad_template_get (&spider_sink_factory), "sink");
gst_element_add_pad (GST_ELEMENT (ident), ident->sink);
gst_pad_set_link_function (ident->sink, GST_DEBUG_FUNCPTR (gst_spider_identity_link));
gst_pad_set_getcaps_function (ident->sink, GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps));
gst_pad_set_bufferpool_function (ident->sink, GST_DEBUG_FUNCPTR (gst_spider_identity_get_bufferpool));
/* src */
ident->src = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (spider_src_factory), "src");
ident->src = gst_pad_new_from_template (
gst_static_pad_template_get (&spider_src_factory), "src");
gst_element_add_pad (GST_ELEMENT (ident), ident->src);
gst_pad_set_link_function (ident->src, GST_DEBUG_FUNCPTR (gst_spider_identity_link));
gst_pad_set_getcaps_function (ident->src, GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps));
@ -227,7 +222,7 @@ gst_spider_identity_new_sink (gchar *name)
/* shamelessly stolen from gstqueue.c to get proxy links */
static GstPadLinkReturn
gst_spider_identity_link (GstPad *pad, GstCaps *caps)
gst_spider_identity_link (GstPad *pad, const GstCaps *caps)
{
GstSpiderIdentity *spider_identity = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad));
GstPad *otherpad;
@ -244,20 +239,24 @@ gst_spider_identity_link (GstPad *pad, GstCaps *caps)
}
static GstCaps*
gst_spider_identity_getcaps (GstPad *pad, GstCaps *caps)
gst_spider_identity_getcaps (GstPad *pad)
{
GstSpiderIdentity *spider_identity = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad));
GstPad *otherpad;
GstPad *peer;
if (pad == spider_identity->src)
otherpad = spider_identity->sink;
else
otherpad = spider_identity->src;
if (otherpad != NULL)
return gst_pad_get_allowed_caps (otherpad);
if (otherpad != NULL) {
peer = GST_PAD_PEER (otherpad);
return NULL;
if (peer)
return gst_pad_get_caps (peer);
}
return gst_caps_new_any ();
}
GstPad*
@ -282,7 +281,6 @@ gst_spider_identity_request_new_pad (GstElement *element, GstPadTemplate *templ
gst_element_add_pad (GST_ELEMENT (ident), ident->sink);
gst_pad_set_link_function (ident->sink, GST_DEBUG_FUNCPTR (gst_spider_identity_link));
gst_pad_set_getcaps_function (ident->sink, GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps));
gst_pad_set_bufferpool_function (ident->sink, GST_DEBUG_FUNCPTR (gst_spider_identity_get_bufferpool));
return ident->sink;
case GST_PAD_SRC:
/* src */
@ -431,7 +429,7 @@ spider_find_peek (gpointer data, gint64 offset, guint size)
}
}
static void
spider_find_suggest (gpointer data, guint probability, GstCaps *caps)
spider_find_suggest (gpointer data, guint probability, const GstCaps *caps)
{
SpiderTypeFind *find = (SpiderTypeFind *) data;
G_GNUC_UNUSED gchar *caps_str;
@ -440,7 +438,7 @@ spider_find_suggest (gpointer data, guint probability, GstCaps *caps)
GST_INFO ("suggest %u, %s", probability, caps_str);
g_free (caps_str);
if (probability > find->best_probability) {
gst_caps_replace (&find->caps, caps);
gst_caps_replace (&find->caps, gst_caps_copy (caps));
find->best_probability = probability;
}
}
@ -462,8 +460,8 @@ gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident)
find.buffer = GST_BUFFER (data);
/* maybe there are already valid caps now? */
if ((find.caps = gst_pad_get_caps (ident->sink)) != NULL) {
gst_caps_ref (find.caps); /* it's unrefed later below */
find.caps = gst_pad_get_caps (ident->sink);
if (find.caps != NULL) {
goto plug;
}
@ -503,7 +501,7 @@ plug:
GST_INFO ("typefind function found caps");
g_assert (gst_pad_try_set_caps (ident->src, find.caps) > 0);
gst_caps_debug (find.caps, "spider starting caps");
gst_caps_unref (find.caps);
gst_caps_free (find.caps);
if (type_list)
g_list_free (type_list);

View file

@ -51,11 +51,11 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (aggregator_src_factory,
GstStaticPadTemplate aggregator_src_template = GST_STATIC_PAD_TEMPLATE (
"sink%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
#define GST_TYPE_AGGREGATOR_SCHED (gst_aggregator_sched_get_type())
@ -124,7 +124,8 @@ static void
gst_aggregator_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (aggregator_src_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&aggregator_src_template));
gst_element_class_set_details (gstelement_class, &gst_aggregator_details);
}
static void

View file

@ -56,11 +56,11 @@ enum {
ARG_LAST_MESSAGE,
};
GST_PAD_TEMPLATE_FACTORY (fakesink_sink_factory,
GstStaticPadTemplate fakesink_sink_template = GST_STATIC_PAD_TEMPLATE (
"sink%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
#define GST_TYPE_FAKESINK_STATE_ERROR (gst_fakesink_state_error_get_type())
@ -135,8 +135,10 @@ gst_fakesink_base_init (gpointer g_class)
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (gstelement_class, &gst_fakesink_details);
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (fakesink_sink_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&fakesink_sink_template));
}
static void
gst_fakesink_class_init (GstFakeSinkClass *klass)
{

View file

@ -73,11 +73,11 @@ enum {
ARG_LAST_MESSAGE,
};
GST_PAD_TEMPLATE_FACTORY (fakesrc_src_factory,
GstStaticPadTemplate fakesrc_src_template = GST_STATIC_PAD_TEMPLATE (
"src%d",
GST_PAD_SRC,
GST_PAD_REQUEST,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
#define GST_TYPE_FAKESRC_OUTPUT (gst_fakesrc_output_get_type())
@ -112,7 +112,6 @@ gst_fakesrc_data_get_type (void)
static GEnumValue fakesrc_data[] = {
{ FAKESRC_DATA_ALLOCATE, "1", "Allocate data"},
{ FAKESRC_DATA_SUBBUFFER, "2", "Subbuffer data"},
{ FAKESRC_DATA_BUFFERPOOL, "3", "Use the default buffer pool (forces sizetype=2)"},
{0, NULL, NULL},
};
if (!fakesrc_data_type) {
@ -204,8 +203,10 @@ gst_fakesrc_base_init (gpointer g_class)
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (gstelement_class, &gst_fakesrc_details);
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (fakesrc_src_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&fakesrc_src_template));
}
static void
gst_fakesrc_class_init (GstFakeSrcClass *klass)
{
@ -486,19 +487,6 @@ gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, G
src->parent = NULL;
}
}
if (src->data == FAKESRC_DATA_BUFFERPOOL) {
if (src->sizetype != FAKESRC_SIZETYPE_FIXED)
g_object_set (src, "sizetype", FAKESRC_SIZETYPE_FIXED, NULL);
if (!src->pool)
src->pool = gst_buffer_pool_get_default (src->sizemax, 10);
} else {
if (src->pool) {
gst_buffer_pool_unref (src->pool);
src->pool = NULL;
}
}
break;
case ARG_SIZETYPE:
src->sizetype = g_value_get_enum (value);
@ -726,10 +714,6 @@ gst_fakesrc_create_buffer (GstFakeSrc *src)
}
gst_fakesrc_prepare_buffer (src, buf);
break;
case FAKESRC_DATA_BUFFERPOOL:
buf = gst_buffer_new_from_pool (src->pool, 0, 0);
gst_fakesrc_prepare_buffer (src, buf);
break;
default:
g_warning ("fakesrc: dunno how to allocate buffers !");
buf = gst_buffer_new();
@ -867,10 +851,6 @@ gst_fakesrc_change_state (GstElement *element)
gst_buffer_unref (fakesrc->parent);
fakesrc->parent = NULL;
}
if (fakesrc->pool) {
gst_buffer_pool_unref (fakesrc->pool);
fakesrc->pool = NULL;
}
g_free (fakesrc->last_message);
fakesrc->last_message = NULL;
break;

View file

@ -43,7 +43,6 @@ typedef enum {
typedef enum {
FAKESRC_DATA_ALLOCATE = 1,
FAKESRC_DATA_SUBBUFFER,
FAKESRC_DATA_BUFFERPOOL
} GstFakeSrcDataType;
typedef enum {
@ -103,7 +102,6 @@ struct _GstFakeSrc {
gboolean signal_handoffs;
gboolean dump;
gboolean need_flush;
GstBufferPool *pool;
gchar *last_message;
};

View file

@ -152,21 +152,12 @@ gst_identity_class_init (GstIdentityClass *klass)
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_identity_get_property);
}
static GstBufferPool*
gst_identity_get_bufferpool (GstPad *pad)
{
GstIdentity *identity;
identity = GST_IDENTITY (gst_pad_get_parent (pad));
return gst_pad_get_bufferpool (identity->srcpad);
}
static GstCaps*
gst_identity_getcaps (GstPad *pad, GstCaps *caps)
gst_identity_getcaps (GstPad *pad)
{
GstIdentity *identity;
GstPad *otherpad;
GstPad *peer;
identity = GST_IDENTITY (gst_pad_get_parent (pad));
@ -175,20 +166,25 @@ gst_identity_getcaps (GstPad *pad, GstCaps *caps)
}
otherpad = (pad == identity->srcpad ? identity->sinkpad : identity->srcpad);
peer = GST_PAD_PEER (otherpad);
return gst_pad_get_allowed_caps (otherpad);
if (peer) {
return gst_pad_get_caps (peer);
} else {
return gst_caps_new_any ();
}
}
static GstPadLinkReturn
gst_identity_link (GstPad *pad, GstCaps *caps)
gst_identity_link (GstPad *pad, const GstCaps *caps)
{
GstIdentity *identity;
identity = GST_IDENTITY (gst_pad_get_parent (pad));
if (GST_CAPS_IS_FIXED (caps)) {
if (gst_caps_is_fixed (caps)) {
if (identity->delay_capsnego && GST_PAD_IS_SINK (pad)) {
identity->srccaps = gst_caps_ref (caps);
identity->srccaps = gst_caps_copy (caps);
return GST_PAD_LINK_OK;
}
@ -210,7 +206,6 @@ gst_identity_init (GstIdentity *identity)
identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad);
gst_pad_set_chain_function (identity->sinkpad, GST_DEBUG_FUNCPTR (gst_identity_chain));
gst_pad_set_bufferpool_function (identity->sinkpad, gst_identity_get_bufferpool);
gst_pad_set_link_function (identity->sinkpad, gst_identity_link);
gst_pad_set_getcaps_function (identity->sinkpad, gst_identity_getcaps);

View file

@ -54,11 +54,11 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (md5_sink_factory,
GstStaticPadTemplate md5_sink_template = GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
/* GObject stuff */
@ -412,8 +412,10 @@ gst_md5sink_base_init (gpointer g_class)
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (gstelement_class, &gst_md5sink_details);
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (md5_sink_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&md5_sink_template));
}
static void
gst_md5sink_class_init (GstMD5SinkClass *klass)
{
@ -438,7 +440,8 @@ static void
gst_md5sink_init (GstMD5Sink *md5sink)
{
GstPad *pad;
pad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (md5_sink_factory), "sink");
pad = gst_pad_new_from_template (gst_static_pad_template_get (
&md5_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (md5sink), pad);
gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_md5sink_chain));

View file

@ -60,18 +60,18 @@ typedef struct
GstBuffer *buffer;
} GstShaperConnection;
GST_PAD_TEMPLATE_FACTORY (shaper_src_factory,
GstStaticPadTemplate shaper_src_template = GST_STATIC_PAD_TEMPLATE (
"src%d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
GST_PAD_TEMPLATE_FACTORY (shaper_sink_factory,
GstStaticPadTemplate shaper_sink_template = GST_STATIC_PAD_TEMPLATE (
"sink%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
#define GST_TYPE_SHAPER_POLICY (gst_shaper_policy_get_type())
@ -137,9 +137,12 @@ gst_shaper_base_init (gpointer g_class)
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (gstelement_class, &gst_shaper_details);
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (shaper_src_factory));
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (shaper_sink_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&shaper_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&shaper_sink_template));
}
static void
gst_shaper_class_init (GstShaperClass *klass)
{
@ -167,18 +170,8 @@ gst_shaper_class_init (GstShaperClass *klass)
gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_shaper_request_new_pad);
}
static GstBufferPool*
gst_shaper_get_bufferpool (GstPad *pad)
{
GstShaperConnection *connection;
connection = gst_pad_get_element_private (pad);
return gst_pad_get_bufferpool (connection->srcpad);
}
static GstCaps*
gst_shaper_getcaps (GstPad *pad, GstCaps *caps)
gst_shaper_getcaps (GstPad *pad)
{
GstPad *otherpad;
GstShaperConnection *connection;
@ -187,7 +180,7 @@ gst_shaper_getcaps (GstPad *pad, GstCaps *caps)
otherpad = (pad == connection->srcpad ? connection->sinkpad : connection->srcpad);
return gst_pad_get_allowed_caps (otherpad);
return gst_caps_copy (gst_pad_get_allowed_caps (otherpad));
}
static GList*
@ -207,7 +200,7 @@ gst_shaper_get_internal_link (GstPad *pad)
}
static GstPadLinkReturn
gst_shaper_link (GstPad *pad, GstCaps *caps)
gst_shaper_link (GstPad *pad, const GstCaps *caps)
{
GstPad *otherpad;
GstShaperConnection *connection;
@ -230,9 +223,9 @@ gst_shaper_create_connection (GstShaper *shaper)
connection = g_new0 (GstShaperConnection, 1);
padname = g_strdup_printf ("sink%d", shaper->nconnections);
connection->sinkpad = gst_pad_new_from_template (shaper_sink_factory (), padname);
connection->sinkpad = gst_pad_new_from_template (
gst_static_pad_template_get (&shaper_sink_template), padname);
g_free (padname);
gst_pad_set_bufferpool_function (connection->sinkpad, gst_shaper_get_bufferpool);
gst_pad_set_getcaps_function (connection->sinkpad, gst_shaper_getcaps);
gst_pad_set_internal_link_function (connection->sinkpad, gst_shaper_get_internal_link);
gst_pad_set_link_function (connection->sinkpad, gst_shaper_link);
@ -240,7 +233,8 @@ gst_shaper_create_connection (GstShaper *shaper)
gst_element_add_pad (GST_ELEMENT (shaper), connection->sinkpad);
padname = g_strdup_printf ("src%d", shaper->nconnections);
connection->srcpad = gst_pad_new_from_template (shaper_src_factory (), padname);
connection->srcpad = gst_pad_new_from_template (
gst_static_pad_template_get (&shaper_src_template), padname);
g_free (padname);
gst_pad_set_getcaps_function (connection->srcpad, gst_shaper_getcaps);
gst_pad_set_internal_link_function (connection->srcpad, gst_shaper_get_internal_link);

View file

@ -151,23 +151,12 @@ gst_statistics_class_init (GstStatisticsClass *klass)
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_statistics_get_property);
}
static GstBufferPool*
gst_statistics_get_bufferpool (GstPad *pad)
{
GstStatistics *statistics;
statistics = GST_STATISTICS (gst_pad_get_parent (pad));
return gst_pad_get_bufferpool (statistics->srcpad);
}
static void
gst_statistics_init (GstStatistics *statistics)
{
statistics->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (statistics), statistics->sinkpad);
gst_pad_set_chain_function (statistics->sinkpad, GST_DEBUG_FUNCPTR (gst_statistics_chain));
gst_pad_set_bufferpool_function (statistics->sinkpad, GST_DEBUG_FUNCPTR (gst_statistics_get_bufferpool));
statistics->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (statistics), statistics->srcpad);

View file

@ -53,11 +53,11 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (tee_src_factory,
GstStaticPadTemplate tee_src_template = GST_STATIC_PAD_TEMPLATE (
"src%d",
GST_PAD_SRC,
GST_PAD_REQUEST,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
static void gst_tee_base_init (gpointer g_class);
@ -106,7 +106,8 @@ gst_tee_base_init (gpointer g_class)
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (gstelement_class, &gst_tee_details);
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (tee_src_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&tee_src_template));
}
static void
gst_tee_class_init (GstTeeClass *klass)
@ -137,26 +138,20 @@ gst_tee_class_init (GstTeeClass *klass)
}
static GstPadLinkReturn
gst_tee_sinklink (GstPad *pad, GstCaps *caps)
gst_tee_sinklink (GstPad *pad, const GstCaps *caps)
{
GstTee *tee;
const GList *pads;
GstPadLinkReturn set_retval;
GstCaps *caps1;
GST_DEBUG ( "gst_tee_sinklink caps=%s", gst_caps_to_string(caps));
tee = GST_TEE (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps)) {
if (!gst_caps_is_fixed (caps)) {
return GST_PAD_LINK_DELAYED;
}
if (GST_CAPS_IS_CHAINED (caps)) {
caps1 = gst_caps_copy_1(caps);
caps = caps1;
}
/* go through all the src pads */
pads = gst_element_get_pad_list (GST_ELEMENT (tee));
@ -175,7 +170,7 @@ gst_tee_sinklink (GstPad *pad, GstCaps *caps)
}
static GstPadLinkReturn
gst_tee_srclink (GstPad *pad, GstCaps *caps)
gst_tee_srclink (GstPad *pad, const GstCaps *caps)
{
GstTee *tee;
@ -187,9 +182,9 @@ gst_tee_srclink (GstPad *pad, GstCaps *caps)
}
static GstCaps*
gst_tee_getcaps (GstPad *pad, GstCaps *filter)
gst_tee_getcaps (GstPad *pad)
{
GstCaps *caps = NULL;
GstCaps *caps = GST_CAPS_ANY;
GstTee *tee;
const GList *pads;
@ -202,7 +197,7 @@ gst_tee_getcaps (GstPad *pad, GstCaps *filter)
while (pads) {
GstPad *srcpad = GST_PAD (pads->data);
GstPad *peer;
GstCaps *peercaps;
const GstCaps *peercaps;
GstCaps *newcaps;
pads = g_list_next (pads);
@ -214,8 +209,7 @@ gst_tee_getcaps (GstPad *pad, GstCaps *filter)
peercaps = gst_pad_get_caps (peer);
newcaps = gst_caps_intersect (caps, peercaps);
gst_caps_unref (caps);
gst_caps_sink (peercaps);
gst_caps_free (caps);
caps = newcaps;
}

View file

@ -54,17 +54,18 @@ GstElementDetails gst_type_find_element_details = GST_ELEMENT_DETAILS (
);
/* generic templates */
GST_PAD_TEMPLATE_FACTORY (type_find_element_sink_factory,
GstStaticPadTemplate type_find_element_sink_template = GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
GST_PAD_TEMPLATE_FACTORY (type_find_element_src_factory,
GstStaticPadTemplate type_find_element_src_template = GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
/* TypeFind signals and args */
@ -183,7 +184,7 @@ gst_type_find_element_class_init (gpointer g_class, gpointer class_data)
g_object_class_install_property (gobject_class, ARG_CAPS,
g_param_spec_boxed ("caps", _("caps"), _("detected capabilities in stream"),
GST_TYPE_CAPS, G_PARAM_READABLE));
gst_caps_get_type(), G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_MINIMUM,
g_param_spec_uint ("minimum", _("minimum"), "minimum probability required to accept caps",
GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, G_PARAM_READWRITE));
@ -195,7 +196,7 @@ gst_type_find_element_class_init (gpointer g_class, gpointer class_data)
G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL,
gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2,
G_TYPE_UINT, GST_TYPE_CAPS);
G_TYPE_UINT, gst_caps_get_type());
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_type_find_element_change_state);
}
@ -206,13 +207,13 @@ gst_type_find_element_init (GTypeInstance *instance, gpointer g_class)
/* sinkpad */
typefind->sink = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (type_find_element_sink_factory), "sink");
gst_static_pad_template_get (&type_find_element_sink_template), "sink");
gst_pad_set_chain_function (typefind->sink,
gst_type_find_element_chain);
gst_element_add_pad (GST_ELEMENT (typefind), typefind->sink);
/* srcpad */
typefind->src = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (type_find_element_src_factory), "src");
gst_static_pad_template_get (&type_find_element_src_template), "src");
gst_pad_set_event_function (typefind->src, gst_type_find_element_src_event);
gst_pad_set_event_mask_function (typefind->src, gst_type_find_element_src_event_mask);
gst_element_add_pad (GST_ELEMENT (typefind), typefind->src);
@ -332,7 +333,7 @@ free_entry (TypeFindEntry *entry)
free_entry_buffers (entry);
if (entry->caps)
gst_caps_unref (entry->caps);
gst_caps_free (entry->caps);
g_free (entry);
}
static void
@ -472,7 +473,7 @@ find_peek (gpointer data, gint64 offset, guint size)
}
}
static void
find_suggest (gpointer data, guint probability, GstCaps *caps)
find_suggest (gpointer data, guint probability, const GstCaps *caps)
{
gchar *str;
TypeFindEntry *entry = (TypeFindEntry *) data;
@ -483,7 +484,7 @@ find_suggest (gpointer data, guint probability, GstCaps *caps)
g_free (str);
if (((gint) probability) > entry->probability) {
entry->probability = probability;
gst_caps_replace (&entry->caps, caps);
gst_caps_replace (&entry->caps, gst_caps_copy (caps));
}
}
static gint
@ -565,7 +566,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
GstCaps *found_caps = entry->caps;
guint probability = entry->probability;
gst_caps_ref (found_caps);
found_caps = gst_caps_copy (found_caps);
GST_INFO_OBJECT (typefind, "'%s' returned %u/%u probability, using it NOW",
GST_PLUGIN_FEATURE_NAME (entry->factory), probability, typefind->max_probability);
while (walk) {
@ -580,7 +581,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
typefind->possibilities = NULL;
g_list_free (typefind->possibilities);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, probability, found_caps);
gst_caps_unref (found_caps);
gst_caps_free (found_caps);
} else {
typefind->possibilities = g_list_prepend (typefind->possibilities, entry);
}

View file

@ -54,17 +54,18 @@ GstElementDetails gst_type_find_element_details = GST_ELEMENT_DETAILS (
);
/* generic templates */
GST_PAD_TEMPLATE_FACTORY (type_find_element_sink_factory,
GstStaticPadTemplate type_find_element_sink_template = GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
GST_PAD_TEMPLATE_FACTORY (type_find_element_src_factory,
GstStaticPadTemplate type_find_element_src_template = GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
/* TypeFind signals and args */
@ -183,7 +184,7 @@ gst_type_find_element_class_init (gpointer g_class, gpointer class_data)
g_object_class_install_property (gobject_class, ARG_CAPS,
g_param_spec_boxed ("caps", _("caps"), _("detected capabilities in stream"),
GST_TYPE_CAPS, G_PARAM_READABLE));
gst_caps_get_type(), G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_MINIMUM,
g_param_spec_uint ("minimum", _("minimum"), "minimum probability required to accept caps",
GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, G_PARAM_READWRITE));
@ -195,7 +196,7 @@ gst_type_find_element_class_init (gpointer g_class, gpointer class_data)
G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL,
gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2,
G_TYPE_UINT, GST_TYPE_CAPS);
G_TYPE_UINT, gst_caps_get_type());
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_type_find_element_change_state);
}
@ -206,13 +207,13 @@ gst_type_find_element_init (GTypeInstance *instance, gpointer g_class)
/* sinkpad */
typefind->sink = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (type_find_element_sink_factory), "sink");
gst_static_pad_template_get (&type_find_element_sink_template), "sink");
gst_pad_set_chain_function (typefind->sink,
gst_type_find_element_chain);
gst_element_add_pad (GST_ELEMENT (typefind), typefind->sink);
/* srcpad */
typefind->src = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (type_find_element_src_factory), "src");
gst_static_pad_template_get (&type_find_element_src_template), "src");
gst_pad_set_event_function (typefind->src, gst_type_find_element_src_event);
gst_pad_set_event_mask_function (typefind->src, gst_type_find_element_src_event_mask);
gst_element_add_pad (GST_ELEMENT (typefind), typefind->src);
@ -332,7 +333,7 @@ free_entry (TypeFindEntry *entry)
free_entry_buffers (entry);
if (entry->caps)
gst_caps_unref (entry->caps);
gst_caps_free (entry->caps);
g_free (entry);
}
static void
@ -472,7 +473,7 @@ find_peek (gpointer data, gint64 offset, guint size)
}
}
static void
find_suggest (gpointer data, guint probability, GstCaps *caps)
find_suggest (gpointer data, guint probability, const GstCaps *caps)
{
gchar *str;
TypeFindEntry *entry = (TypeFindEntry *) data;
@ -483,7 +484,7 @@ find_suggest (gpointer data, guint probability, GstCaps *caps)
g_free (str);
if (((gint) probability) > entry->probability) {
entry->probability = probability;
gst_caps_replace (&entry->caps, caps);
gst_caps_replace (&entry->caps, gst_caps_copy (caps));
}
}
static gint
@ -565,7 +566,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
GstCaps *found_caps = entry->caps;
guint probability = entry->probability;
gst_caps_ref (found_caps);
found_caps = gst_caps_copy (found_caps);
GST_INFO_OBJECT (typefind, "'%s' returned %u/%u probability, using it NOW",
GST_PLUGIN_FEATURE_NAME (entry->factory), probability, typefind->max_probability);
while (walk) {
@ -580,7 +581,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
typefind->possibilities = NULL;
g_list_free (typefind->possibilities);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, probability, found_caps);
gst_caps_unref (found_caps);
gst_caps_free (found_caps);
} else {
typefind->possibilities = g_list_prepend (typefind->possibilities, entry);
}

View file

@ -533,7 +533,6 @@ init_post (void)
_gst_cpu_initialize (_gst_enable_cpu_opt);
_gst_structure_initialize ();
_gst_value_initialize ();
_gst_props_initialize ();
_gst_caps_initialize ();
_gst_plugin_initialize ();
_gst_event_initialize ();

View file

@ -33,8 +33,7 @@
#include <gst/gstbin.h>
#include <gst/gstbuffer.h>
#include <gst/gstbufferpool-default.h>
#include <gst/gstcaps.h>
#include <gst/gstcaps2.h>
#include <gst/gstclock.h>
#include <gst/gstcpu.h>
#include <gst/gstelement.h>
@ -46,7 +45,6 @@
#include <gst/gstpad.h>
#include <gst/gstpipeline.h>
#include <gst/gstplugin.h>
#include <gst/gstprops.h>
#include <gst/gstscheduler.h>
#include <gst/gststructure.h>
#include <gst/gstsystemclock.h>

View file

@ -27,7 +27,6 @@
#include "gstbuffer.h"
#include "gstmemchunk.h"
#include "gstinfo.h"
#include "gstbufferpool-default.h"
GType _gst_buffer_type;
GType _gst_buffer_pool_type;
@ -37,7 +36,6 @@ GType _gst_buffer_pool_type;
#include "gsttrace.h"
static GstAllocTrace *_gst_buffer_trace;
static GstAllocTrace *_gst_buffer_pool_trace;
#endif
static GstMemChunk *chunk;
@ -55,7 +53,6 @@ _gst_buffer_initialize (void)
#ifndef GST_DISABLE_TRACE
_gst_buffer_trace = gst_alloc_trace_register (GST_BUFFER_TRACE_NAME);
_gst_buffer_pool_trace = gst_alloc_trace_register (GST_BUFFER_POOL_TRACE_NAME);
#endif
chunk = gst_mem_chunk_new ("GstBufferChunk", sizeof (GstBuffer),
@ -70,16 +67,6 @@ gst_buffer_get_type (void)
return _gst_buffer_type;
}
static void
_gst_buffer_free_to_pool (GstBuffer *buffer)
{
GstBufferPool *pool = buffer->pool;
pool->buffer_free (pool, buffer, pool->user_data);
gst_data_unref (GST_DATA (pool));
}
static void
_gst_buffer_sub_free (GstBuffer *buffer)
{
@ -125,12 +112,25 @@ gst_buffer_default_free (GstBuffer *buffer)
#endif
}
static GstBuffer*
_gst_buffer_copy_from_pool (GstBuffer *buffer)
/**
* gst_buffer_stamp:
* @dest: buffer to stamp
* @src: buffer to stamp from
*
* Copies additional information (timestamps and offsets) from one buffer to
* the other.
*/
void
gst_buffer_stamp (GstBuffer *dest, const GstBuffer *src)
{
return buffer->pool->buffer_copy (buffer->pool, buffer, buffer->pool->user_data);
}
g_return_if_fail (dest != NULL);
g_return_if_fail (src != NULL);
GST_BUFFER_TIMESTAMP (dest) = GST_BUFFER_TIMESTAMP (src);
GST_BUFFER_DURATION (dest) = GST_BUFFER_DURATION (src);
GST_BUFFER_OFFSET (dest) = GST_BUFFER_OFFSET (src);
GST_BUFFER_OFFSET_END (dest) = GST_BUFFER_OFFSET_END (src);
}
/**
* gst_buffer_default_copy:
* @buffer: a #GstBuffer to make a copy of.
@ -164,10 +164,8 @@ gst_buffer_default_copy (GstBuffer *buffer)
GST_BUFFER_SIZE (buffer));
GST_BUFFER_SIZE (copy) = GST_BUFFER_SIZE (buffer);
GST_BUFFER_MAXSIZE (copy) = GST_BUFFER_SIZE (buffer);
GST_BUFFER_TIMESTAMP (copy) = GST_BUFFER_TIMESTAMP (buffer);
GST_BUFFER_DURATION (copy) = GST_BUFFER_DURATION (buffer);
GST_BUFFER_OFFSET (copy) = GST_BUFFER_OFFSET (buffer);
GST_BUFFER_OFFSET_END (copy) = GST_BUFFER_OFFSET_END (buffer);
gst_buffer_stamp (copy, buffer);
GST_BUFFER_BUFFERPOOL (copy) = NULL;
GST_BUFFER_POOL_PRIVATE (copy) = NULL;
@ -234,42 +232,6 @@ gst_buffer_new_and_alloc (guint size)
return newbuf;
}
/**
* gst_buffer_new_from_pool:
* @pool: a #GstBufferPool to use.
* @offset: the offset of the new buffer.
* @size: the size of the new buffer.
*
* Creates a newly allocated buffer using the specified buffer pool,
* offset and size.
*
* Returns: the new #GstBuffer, or NULL if there was an error.
*/
GstBuffer*
gst_buffer_new_from_pool (GstBufferPool *pool,
guint64 offset, guint size)
{
GstBuffer *buffer;
g_return_val_if_fail (pool != NULL, NULL);
gst_data_ref (GST_DATA (pool));
buffer = pool->buffer_new (pool, offset, size, pool->user_data);
if (!buffer)
return NULL;
GST_BUFFER_BUFFERPOOL (buffer) = pool;
/* override the buffer refcount functions with those from the pool (if any) */
if (pool->buffer_free)
GST_DATA (buffer)->free = (GstDataFreeFunction)_gst_buffer_free_to_pool;
if (pool->buffer_copy)
GST_DATA (buffer)->copy = (GstDataCopyFunction)_gst_buffer_copy_from_pool;
return buffer;
}
/**
* gst_buffer_create_sub:
* @parent: a parent #GstBuffer to create a subbuffer from.
@ -478,135 +440,3 @@ gst_buffer_pool_get_type (void)
return _gst_buffer_pool_type;
}
/**
* gst_buffer_pool_default_free:
* @pool: a #GstBufferPool to free.
*
* Frees the memory associated with the bufferpool.
*/
void
gst_buffer_pool_default_free (GstBufferPool *pool)
{
g_return_if_fail (pool != NULL);
_GST_DATA_DISPOSE (GST_DATA (pool));
g_free (pool);
#ifndef GST_DISABLE_TRACE
gst_alloc_trace_free (_gst_buffer_pool_trace, pool);
#endif
}
/**
* gst_buffer_pool_new:
* @free: the #GstDataFreeFunction to free the buffer pool.
* @copy: the #GstDataCopyFunction to copy the buffer pool.
* @buffer_new: the #GstBufferPoolBufferNewFunction to create a new buffer
* from this pool
* @buffer_copy: the #GstBufferPoolBufferCopyFunction to copy a buffer
* from this pool
* @buffer_free: the #GstBufferPoolBufferFreeFunction to free a buffer
* in this pool
* @user_data: the user data gpointer passed to buffer_* functions.
*
* Creates a new buffer pool with the given functions.
*
* Returns: a new #GstBufferPool, or NULL on error.
*/
GstBufferPool*
gst_buffer_pool_new (GstDataFreeFunction free,
GstDataCopyFunction copy,
GstBufferPoolBufferNewFunction buffer_new,
GstBufferPoolBufferCopyFunction buffer_copy,
GstBufferPoolBufferFreeFunction buffer_free,
gpointer user_data)
{
GstBufferPool *pool;
/* we need at least a buffer_new function */
g_return_val_if_fail (buffer_new != NULL, NULL);
pool = g_new0 (GstBufferPool, 1);
#ifndef GST_DISABLE_TRACE
gst_alloc_trace_new (_gst_buffer_pool_trace, pool);
#endif
GST_CAT_DEBUG (GST_CAT_BUFFER, "allocating new buffer pool %p\n", pool);
/* init data struct */
_GST_DATA_INIT (GST_DATA (pool),
_gst_buffer_pool_type,
0,
(free ? free : (GstDataFreeFunction) gst_buffer_pool_default_free),
copy);
/* set functions */
pool->buffer_new = buffer_new;
pool->buffer_copy = buffer_copy;
pool->buffer_free = buffer_free;
pool->user_data = user_data;
return pool;
}
/**
* gst_buffer_pool_is_active:
* @pool: the #GstBufferPool to query.
*
* Queries if the given buffer pool is active.
*
* Returns: TRUE if the pool is active.
*/
gboolean
gst_buffer_pool_is_active (GstBufferPool *pool)
{
g_return_val_if_fail (pool != NULL, FALSE);
return pool->active;
}
/**
* gst_buffer_pool_set_active:
* @pool: a #GstBufferPool to set the activity status on.
* @active: the new status of the pool.
*
* Sets the given pool to the active or inactive state depending on the
* active parameter.
*/
void
gst_buffer_pool_set_active (GstBufferPool *pool, gboolean active)
{
g_return_if_fail (pool != NULL);
pool->active = active;
}
/**
* gst_buffer_pool_set_user_data:
* @pool: the #GstBufferPool to set the user data for.
* @user_data: the user_data to set on the buffer pool.
*
* Sets the given user data on the buffer pool.
*/
void
gst_buffer_pool_set_user_data (GstBufferPool *pool, gpointer user_data)
{
g_return_if_fail (pool != NULL);
pool->user_data = user_data;
}
/**
* gst_buffer_pool_get_user_data:
* @pool: the #GstBufferPool to get the user data for.
*
* Gets the user data of the buffer pool.
*
* Returns: the user data associated with this buffer pool.
*/
gpointer
gst_buffer_pool_get_user_data (GstBufferPool *pool)
{
g_return_val_if_fail (pool != NULL, NULL);
return pool->user_data;
}

View file

@ -30,19 +30,14 @@
G_BEGIN_DECLS
typedef struct _GstBuffer GstBuffer;
typedef struct _GstBufferPool GstBufferPool;
#define GST_BUFFER_TRACE_NAME "GstBuffer"
#define GST_BUFFER_POOL_TRACE_NAME "GstBufferPool"
extern GType _gst_buffer_type;
extern GType _gst_buffer_pool_type;
#define GST_TYPE_BUFFER (_gst_buffer_type)
#define GST_TYPE_BUFFER_POOL (_gst_buffer_pool_type)
#define GST_BUFFER(buf) ((GstBuffer *)(buf))
#define GST_BUFFER_POOL(pool) ((GstBufferPool *)(pool))
#define GST_IS_BUFFER(buf) (GST_DATA_TYPE(buf) == GST_TYPE_BUFFER)
#define GST_IS_BUFFER_POOL(buf) (GST_DATA_TYPE(buf) == GST_TYPE_BUFFER_POOL)
@ -110,47 +105,18 @@ struct _GstBuffer {
guint64 offset_end;
/* this is a pointer to the buffer pool (if any) */
GstBufferPool *pool;
gpointer pool;
/* pointer to pool private data of parent buffer in case of a subbuffer */
gpointer pool_private;
gpointer _gst_reserved[GST_PADDING];
};
/* bufferpools */
typedef GstBuffer* (*GstBufferPoolBufferNewFunction) (GstBufferPool *pool, guint64 offset,
guint size, gpointer user_data);
typedef GstBuffer* (*GstBufferPoolBufferCopyFunction) (GstBufferPool *pool,
const GstBuffer *buffer,
gpointer user_data);
typedef void (*GstBufferPoolBufferFreeFunction) (GstBufferPool *pool,
GstBuffer *buffer,
gpointer user_data);
struct _GstBufferPool {
GstData data;
gboolean active;
GstBufferPoolBufferNewFunction buffer_new;
GstBufferPoolBufferCopyFunction buffer_copy;
GstBufferPoolBufferFreeFunction buffer_free;
gpointer user_data;
gpointer _gst_reserved[GST_PADDING];
};
/* allocation */
GType gst_buffer_get_type (void);
GstBuffer* gst_buffer_new (void);
GstBuffer* gst_buffer_new_and_alloc (guint size);
/* creating a new buffer from a pool */
GstBuffer* gst_buffer_new_from_pool (GstBufferPool *pool,
guint64 offset, guint size);
#define gst_buffer_set_data(buf, data, size) \
G_STMT_START { \
GST_BUFFER_DATA (buf) = data; \
@ -162,6 +128,7 @@ G_STMT_START { \
#define gst_buffer_ref_by_count(buf,c) GST_BUFFER (gst_data_ref_by_count (GST_DATA (buf), c))
#define gst_buffer_unref(buf) gst_data_unref (GST_DATA (buf))
/* copy buffer */
void gst_buffer_stamp (GstBuffer *dest, const GstBuffer *src);
#define gst_buffer_copy(buf) GST_BUFFER (gst_data_copy (GST_DATA (buf)))
#define gst_buffer_is_writable(buf) gst_data_is_writable (GST_DATA (buf))
#define gst_buffer_copy_on_write(buf) GST_BUFFER (gst_data_copy_on_write (GST_DATA (buf)))
@ -182,36 +149,6 @@ void _gst_buffer_initialize (void);
void gst_buffer_default_free (GstBuffer *buffer);
GstBuffer* gst_buffer_default_copy (GstBuffer *buffer);
/* creating a new buffer pools */
GType gst_buffer_pool_get_type (void);
GstBufferPool* gst_buffer_pool_new (GstDataFreeFunction free,
GstDataCopyFunction copy,
GstBufferPoolBufferNewFunction buffer_new,
GstBufferPoolBufferCopyFunction buffer_copy,
GstBufferPoolBufferFreeFunction buffer_free,
gpointer user_data);
/* function used by subclasses and bufferpools */
void gst_buffer_pool_default_free (GstBufferPool *pool);
/* check if pool is usable */
gboolean gst_buffer_pool_is_active (GstBufferPool *pool);
void gst_buffer_pool_set_active (GstBufferPool *pool, gboolean active);
#define gst_buffer_pool_ref(pool) GST_BUFFER_POOL (gst_data_ref (GST_DATA (pool)))
#define gst_buffer_pool_ref_by_count(pool,c) GST_BUFFER_POOL (gst_data_ref_by_count (GST_DATA (pool), c))
#define gst_buffer_pool_unref(pool) gst_data_unref (GST_DATA (pool))
/* bufferpool operations */
#define gst_buffer_pool_copy(pool) GST_BUFFER_POOL (gst_data_copy (GST_DATA (pool)))
#define gst_buffer_pool_is_writable(pool) GST_BUFFER_POOL (gst_data_is_writable (GST_DATA (pool)))
#define gst_buffer_pool_copy_on_write(pool) GST_BUFFER_POOL (gst_data_copy_on_write (GST_DATA (pool)))
#define gst_buffer_pool_free(pool) gst_data_free (GST_DATA (pool))
void gst_buffer_pool_set_user_data (GstBufferPool *pool, gpointer user_data);
gpointer gst_buffer_pool_get_user_data (GstBufferPool *pool);
G_END_DECLS
#endif /* __GST_BUFFER_H__ */

File diff suppressed because it is too large Load diff

View file

@ -1,202 +0,0 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
* gstcaps.h: Header for caps subsystem
*
* 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_CAPS_H__
#define __GST_CAPS_H__
#include <gst/gstprops.h>
G_BEGIN_DECLS
typedef struct _GstCaps GstCaps;
#define GST_CAPS_TRACE_NAME "GstCaps"
extern GType _gst_caps_type;
#define GST_TYPE_CAPS (_gst_caps_type)
typedef enum {
GST_CAPS_UNUSED = (1 << 0), /* unused flag */
GST_CAPS_FLOATING = (1 << 1) /* caps is floating */
} GstCapsFlags;
#define GST_CAPS(caps) ((GstCaps *)(caps))
#define GST_CAPS_FLAGS(caps) ((caps)->flags)
#define GST_CAPS_FLAG_IS_SET(caps,flag) (GST_CAPS_FLAGS (caps) & (flag))
#define GST_CAPS_FLAG_SET(caps,flag) (GST_CAPS_FLAGS (caps) |= (flag))
#define GST_CAPS_FLAG_UNSET(caps,flag) (GST_CAPS_FLAGS (caps) &= ~(flag))
#define GST_CAPS_REFCOUNT(caps) ((caps)->refcount)
#define GST_CAPS_PROPERTIES(caps) ((caps)->properties)
#define GST_CAPS_NEXT(caps) ((caps)->next)
#define GST_CAPS_IS_FIXED(caps) (((caps)->properties == NULL) || \
(GST_PROPS_IS_FIXED ((caps)->properties)))
#define GST_CAPS_IS_FLOATING(caps) (GST_CAPS_FLAG_IS_SET ((caps), GST_CAPS_FLOATING))
#define GST_CAPS_IS_CHAINED(caps) (GST_CAPS_NEXT (caps) != NULL)
#define GST_CAPS_NONE NULL
#define GST_CAPS_ANY (gst_caps_get_any())
struct _GstCaps {
/* --- public --- */
gchar *name; /* the name of this caps */
GQuark id; /* type id (major type) representing
the mime type, it's stored as a GQuark
for speed/space reasons */
guint16 flags; /* flags */
guint refcount;
GstProps *properties; /* properties for this capability */
GstCaps *next; /* not with a GList for efficiency */
};
/* factory macros which make it easier for plugins to instantiate */
#ifdef G_HAVE_ISO_VARARGS
#define GST_CAPS_NEW(name, type, ...) \
gst_caps_new ( \
name, \
type, \
gst_props_new ( \
__VA_ARGS__, \
NULL))
#define GST_CAPS_FACTORY(factoryname, ...) \
static GstCaps* \
factoryname (void) \
{ \
static GstCaps *caps = NULL; \
if (!caps) { \
caps = gst_caps_chain (__VA_ARGS__, NULL); \
} \
return gst_caps_ref(caps); \
}
#elif defined(G_HAVE_GNUC_VARARGS)
#define GST_CAPS_NEW(name, type, a...) \
gst_caps_new ( \
name, \
type, \
gst_props_new ( \
a, \
NULL))
#define GST_CAPS_FACTORY(factoryname, a...) \
static GstCaps* \
factoryname (void) \
{ \
static GstCaps *caps = NULL; \
if (!caps) { \
caps = gst_caps_chain (a, NULL); \
} \
return gst_caps_ref(caps); \
}
#endif
/* get caps from a factory */
#define GST_CAPS_GET(fact) (fact)()
/* initialize the subsystem */
void _gst_caps_initialize (void);
/* creating new caps */
GType gst_caps_get_type (void);
GstCaps* gst_caps_new (const gchar *name, const gchar *mime, GstProps *props);
GstCaps* gst_caps_new_id (const gchar *name, const GQuark id, GstProps *props);
GstCaps* gst_caps_get_any (void);
/* replace pointer to caps, doing proper refcounting */
void gst_caps_replace (GstCaps **oldcaps, GstCaps *newcaps);
void gst_caps_replace_sink (GstCaps **oldcaps, GstCaps *newcaps);
/* caps lifecycle control */
GstCaps* gst_caps_unref (GstCaps *caps);
GstCaps* gst_caps_ref (GstCaps *caps);
void gst_caps_sink (GstCaps *caps);
/* write debug lines to the log */
void gst_caps_debug (GstCaps *caps, const gchar *label);
/* copy caps */
GstCaps* gst_caps_copy (GstCaps *caps);
GstCaps* gst_caps_copy_1 (GstCaps *caps);
GstCaps* gst_caps_copy_on_write (GstCaps *caps);
const gchar* gst_caps_get_name (GstCaps *caps);
void gst_caps_set_name (GstCaps *caps, const gchar *name);
const gchar* gst_caps_get_mime (GstCaps *caps);
void gst_caps_set_mime (GstCaps *caps, const gchar *mime);
GstCaps* gst_caps_set_props (GstCaps *caps, GstProps *props);
GstProps* gst_caps_get_props (GstCaps *caps);
#ifdef G_HAVE_ISO_VARARGS
#define gst_caps_set(caps, ...) gst_props_set ((caps)->properties, __VA_ARGS__)
#define gst_caps_get(caps, ...) gst_props_get ((caps)->properties, __VA_ARGS__)
#elif defined(G_HAVE_GNUC_VARARGS)
#define gst_caps_set(caps, name, args...) gst_props_set ((caps)->properties, name, ##args)
#define gst_caps_get(caps, name, args...) gst_props_get ((caps)->properties, name, ##args)
#endif
#define gst_caps_get_int(caps,name,res) gst_props_entry_get_int(gst_props_get_entry((caps)->properties,name),res)
#define gst_caps_get_float(caps,name,res) gst_props_entry_get_float(gst_props_get_entry((caps)->properties,name),res)
#define gst_caps_get_fourcc_int(caps,name,res) gst_props_entry_get_fourcc_int(gst_props_get_entry((caps)->properties,name),res)
#define gst_caps_get_boolean(caps,name,res) gst_props_entry_get_boolean(gst_props_get_entry((caps)->properties,name),res)
#define gst_caps_get_string(caps,name,res) gst_props_entry_get_string(gst_props_get_entry((caps)->properties,name),res)
gboolean gst_caps_has_property (GstCaps *caps, const gchar *name);
gboolean gst_caps_has_property_typed (GstCaps *caps, const gchar *name, GstPropsType type);
gboolean gst_caps_has_fixed_property (GstCaps *caps, const gchar *name);
GstCaps* gst_caps_get_by_name (GstCaps *caps, const gchar *name);
/* use and construct chained caps */
GstCaps* gst_caps_next (GstCaps *caps);
GstCaps* gst_caps_chain (GstCaps *caps, ...);
GstCaps* gst_caps_append (GstCaps *caps, GstCaps *capstoadd);
GstCaps* gst_caps_prepend (GstCaps *caps, GstCaps *capstoadd);
/* see if fromcaps is a subset of tocaps */
gboolean gst_caps_is_always_compatible (GstCaps *fromcaps, GstCaps *tocaps);
/* operations on caps */
GstCaps* gst_caps_intersect (GstCaps *caps1, GstCaps *caps2);
GstCaps* gst_caps_union (GstCaps *caps1, GstCaps *caps2);
GstCaps* gst_caps_normalize (GstCaps *caps);
#ifndef GST_DISABLE_LOADSAVE
xmlNodePtr gst_caps_save_thyself (GstCaps *caps, xmlNodePtr parent);
GstCaps* gst_caps_load_thyself (xmlNodePtr parent);
#endif
/* for debugging purposes */
gchar * gst_caps_to_string (GstCaps *caps);
GstCaps * gst_caps_from_string (gchar *str);
G_END_DECLS
#endif /* __GST_CAPS_H__ */

View file

@ -24,25 +24,25 @@
#include <gst/gst.h>
static void _gst_caps2_transform_to_string (const GValue *src_value,
static void _gst_caps_transform_to_string (const GValue *src_value,
GValue *dest_value);
static void _gst_caps2_value_init (GValue *value);
static void _gst_caps2_value_free (GValue *value);
static void _gst_caps2_value_copy (const GValue *src, GValue *dest);
static gpointer _gst_caps2_value_peek_pointer (const GValue *value);
static void _gst_caps2_from_string_inplace (GstCaps2 *caps,
static void _gst_caps_value_init (GValue *value);
static void _gst_caps_value_free (GValue *value);
static void _gst_caps_value_copy (const GValue *src, GValue *dest);
static gpointer _gst_caps_value_peek_pointer (const GValue *value);
static gboolean _gst_caps_from_string_inplace (GstCaps *caps,
const gchar *string);
GType _gst_caps2_type;
GType _gst_caps_type;
void _gst_caps2_initialize (void)
void _gst_caps_initialize (void)
{
static const GTypeValueTable type_value_table = {
_gst_caps2_value_init,
_gst_caps2_value_free,
_gst_caps2_value_copy,
_gst_caps2_value_peek_pointer,
_gst_caps_value_init,
_gst_caps_value_free,
_gst_caps_value_copy,
_gst_caps_value_peek_pointer,
NULL,
NULL,
NULL,
@ -61,266 +61,326 @@ void _gst_caps2_initialize (void)
&type_value_table,
};
_gst_caps2_type = g_type_register_static (G_TYPE_BOXED, "GstCaps2",
_gst_caps_type = g_type_register_static (G_TYPE_BOXED, "GstCaps",
&caps2_info, 0);
g_value_register_transform_func (_gst_caps2_type, G_TYPE_STRING,
_gst_caps2_transform_to_string);
g_value_register_transform_func (_gst_caps_type, G_TYPE_STRING,
_gst_caps_transform_to_string);
}
GType gst_caps2_get_type (void)
GType gst_caps_get_type (void)
{
return _gst_caps2_type;
return _gst_caps_type;
}
/* creation/deletion */
GstCaps2 *gst_caps2_new_empty (void)
GstCaps *gst_caps_new_empty (void)
{
GstCaps2 *caps = g_new0(GstCaps2, 1);
GstCaps *caps = g_new0(GstCaps, 1);
caps->type = _gst_caps2_type;
caps->type = _gst_caps_type;
caps->structs = g_ptr_array_new();
return caps;
}
GstCaps2 *gst_caps2_new_any (void)
GstCaps *gst_caps_new_any (void)
{
GstCaps2 *caps = g_new0(GstCaps2, 1);
GstCaps *caps = g_new0(GstCaps, 1);
caps->type = _gst_caps2_type;
caps->type = _gst_caps_type;
caps->structs = g_ptr_array_new();
caps->flags = GST_CAPS2_FLAGS_ANY;
caps->flags = GST_CAPS_FLAGS_ANY;
return caps;
}
GstCaps2 *gst_caps2_new_simple (const char *media_type, const char *fieldname,
GstCaps *gst_caps_new_simple (const char *media_type, const char *fieldname,
...)
{
GstCaps2 *caps;
GstCaps *caps;
GstStructure *structure;
va_list var_args;
caps = g_new0(GstCaps2, 1);
caps->type = _gst_caps2_type;
caps = g_new0(GstCaps, 1);
caps->type = _gst_caps_type;
caps->structs = g_ptr_array_new();
va_start (var_args, fieldname);
structure = gst_structure_new_valist (media_type, fieldname, var_args);
va_end (var_args);
g_ptr_array_add (caps->structs, structure);
gst_caps_append_structure (caps, structure);
return caps;
}
GstCaps2 *gst_caps2_new_full (const GstStructure *struct1, ...)
GstCaps *gst_caps_new_full (GstStructure *struct1, ...)
{
GstCaps2 *caps;
GstCaps *caps;
va_list var_args;
va_start (var_args, struct1);
caps = gst_caps2_new_full_valist (struct1, var_args);
caps = gst_caps_new_full_valist (struct1, var_args);
va_end (var_args);
return caps;
}
GstCaps2 *gst_caps2_new_full_valist (const GstStructure *structure,
GstCaps *gst_caps_new_full_valist (GstStructure *structure,
va_list var_args)
{
GstCaps2 *caps;
GstCaps *caps;
caps = g_new0(GstCaps2, 1);
caps->type = _gst_caps2_type;
caps = g_new0(GstCaps, 1);
caps->type = _gst_caps_type;
caps->structs = g_ptr_array_new();
while(structure){
g_ptr_array_add (caps->structs, (gpointer) structure);
structure = va_arg (var_args, void *);
gst_caps_append_structure (caps, structure);
structure = va_arg (var_args, GstStructure *);
}
return caps;
}
GstCaps2 *gst_caps2_copy (const GstCaps2 *caps)
GstCaps *gst_caps_copy (const GstCaps *caps)
{
GstCaps2 *newcaps;
GstCaps *newcaps;
GstStructure *structure;
int i;
newcaps = g_new0(GstCaps2, 1);
newcaps->type = _gst_caps2_type;
g_return_val_if_fail(caps != NULL, NULL);
newcaps = g_new0(GstCaps, 1);
newcaps->type = _gst_caps_type;
newcaps->flags = caps->flags;
newcaps->structs = g_ptr_array_new();
for(i=0;i<caps->structs->len;i++){
structure = gst_caps2_get_nth_cap (caps, i);
g_ptr_array_add (newcaps->structs, gst_structure_copy(structure));
structure = gst_caps_get_structure (caps, i);
gst_caps_append_structure (newcaps, gst_structure_copy(structure));
}
return newcaps;
}
void gst_caps2_free (GstCaps2 *caps)
void gst_caps_free (GstCaps *caps)
{
GstStructure *structure;
int i;
g_return_if_fail(caps != NULL);
for(i=0;i<caps->structs->len;i++){
structure = gst_caps2_get_nth_cap (caps, i);
structure = gst_caps_get_structure (caps, i);
gst_structure_free (structure);
}
g_ptr_array_free(caps->structs, TRUE);
#ifdef USE_POISONING
memset (caps, 0xff, sizeof(GstCaps));
#endif
g_free(caps);
}
const GstCaps2 *gst_caps2_from_static (GstStaticCaps2 *static_caps)
const GstCaps *gst_static_caps_get (GstStaticCaps *static_caps)
{
GstCaps2 *caps = (GstCaps2 *)static_caps;
GstCaps *caps = (GstCaps *)static_caps;
gboolean ret;
if (caps->type == 0) {
caps->type = _gst_caps2_type;
_gst_caps2_from_string_inplace (caps, static_caps->string);
caps->type = _gst_caps_type;
caps->structs = g_ptr_array_new();
ret = _gst_caps_from_string_inplace (caps, static_caps->string);
if (!ret) {
g_critical ("Could not convert static caps \"%s\"", static_caps->string);
}
}
return caps;
}
/* manipulation */
void gst_caps2_append (GstCaps2 *caps1, GstCaps2 *caps2)
void gst_caps_append (GstCaps *caps1, GstCaps *caps2)
{
GstStructure *structure;
int i;
for(i=0;i<caps2->structs->len;i++){
structure = gst_caps2_get_nth_cap (caps2, i);
g_ptr_array_add (caps1->structs, structure);
structure = gst_caps_get_structure (caps2, i);
gst_caps_append_structure (caps1, structure);
}
g_ptr_array_free(caps2->structs, TRUE);
#ifdef USE_POISONING
memset (caps2, 0xff, sizeof(GstCaps));
#endif
g_free(caps2);
}
void gst_caps2_append_cap (GstCaps2 *caps1, GstStructure *structure)
void gst_caps_append_structure (GstCaps *caps, GstStructure *structure)
{
g_return_if_fail(caps != NULL);
if (structure){
g_ptr_array_add (caps1->structs, structure);
g_ptr_array_add (caps->structs, structure);
}
}
GstCaps2 *gst_caps2_split_one (GstCaps2 *caps)
GstCaps *gst_caps_split_one (GstCaps *caps)
{
/* FIXME */
return NULL;
}
GstStructure *gst_caps2_get_nth_cap (const GstCaps2 *caps, int index)
int gst_caps_get_size (const GstCaps *caps)
{
g_return_val_if_fail (caps != NULL, 0);
return caps->structs->len;
}
GstStructure *gst_caps_get_structure (const GstCaps *caps, int index)
{
g_return_val_if_fail (caps != NULL, NULL);
g_return_val_if_fail (index >= 0, NULL);
g_return_val_if_fail (index < caps->structs->len, NULL);
return g_ptr_array_index(caps->structs, index);
}
GstCaps2 *gst_caps2_copy_1 (const GstCaps2 *caps)
GstCaps *gst_caps_copy_1 (const GstCaps *caps)
{
GstCaps2 *newcaps;
GstCaps *newcaps;
GstStructure *structure;
newcaps = g_new0(GstCaps2, 1);
newcaps->type = _gst_caps2_type;
g_return_val_if_fail(caps != NULL, NULL);
newcaps = g_new0(GstCaps, 1);
newcaps->type = _gst_caps_type;
newcaps->flags = caps->flags;
newcaps->structs = g_ptr_array_new();
if (caps->structs->len > 0){
structure = gst_caps2_get_nth_cap (caps, 0);
g_ptr_array_add (newcaps->structs, gst_structure_copy(structure));
structure = gst_caps_get_structure (caps, 0);
gst_caps_append_structure (newcaps, gst_structure_copy(structure));
}
return newcaps;
}
/* tests */
gboolean gst_caps2_is_any (const GstCaps2 *caps)
void gst_caps_set_simple (GstCaps *caps, char *field, ...)
{
return (caps->flags & GST_CAPS2_FLAGS_ANY);
GstStructure *structure;
va_list var_args;
g_return_if_fail (caps != NULL);
g_return_if_fail (caps->structs->len == 1);
structure = gst_caps_get_structure (caps, 0);
va_start (var_args, field);
gst_structure_set_valist (structure, field, var_args);
va_end(var_args);
}
gboolean gst_caps2_is_empty (const GstCaps2 *caps)
void gst_caps_set_simple_valist (GstCaps *caps, char *field, va_list varargs)
{
if (caps->flags & GST_CAPS2_FLAGS_ANY) return FALSE;
GstStructure *structure;
g_return_if_fail (caps != NULL);
g_return_if_fail (caps->structs->len != 1);
structure = gst_caps_get_structure (caps, 0);
gst_structure_set_valist (structure, field, varargs);
}
/* tests */
gboolean gst_caps_is_any (const GstCaps *caps)
{
g_return_val_if_fail(caps != NULL, FALSE);
return (caps->flags & GST_CAPS_FLAGS_ANY);
}
gboolean gst_caps_is_empty (const GstCaps *caps)
{
g_return_val_if_fail(caps != NULL, FALSE);
if (caps->flags & GST_CAPS_FLAGS_ANY) return FALSE;
return (caps->structs == NULL) || (caps->structs->len == 0);
}
gboolean gst_caps2_is_chained (const GstCaps2 *caps)
gboolean gst_caps_is_chained (const GstCaps *caps)
{
g_return_val_if_fail(caps != NULL, FALSE);
return (caps->structs->len > 1);
}
gboolean gst_caps2_is_fixed (const GstCaps2 *caps)
static gboolean
_gst_caps_is_fixed_foreach (GQuark field_id, GValue *value, gpointer unused)
{
GstStructure *structure;
GstStructureField *field;
GType type;
int i;
if (caps->structs->len > 1) return FALSE;
structure = gst_caps2_get_nth_cap (caps, 0);
for(i=0;i<structure->fields->len;i++) {
field = GST_STRUCTURE_FIELD(structure, i);
type = G_VALUE_TYPE(&field->value);
if(type == GST_TYPE_INT_RANGE || type == GST_TYPE_DOUBLE_RANGE) {
GType type = G_VALUE_TYPE (value);
if (G_TYPE_IS_FUNDAMENTAL (type)) return TRUE;
if (type == GST_TYPE_FOURCC) return TRUE;
return FALSE;
}
}
return TRUE;
}
static gboolean _gst_cap_is_always_compatible (const GstStructure *struct1,
gboolean gst_caps_is_fixed (const GstCaps *caps)
{
GstStructure *structure;
g_return_val_if_fail(caps != NULL, FALSE);
if (caps->structs->len != 1) return FALSE;
structure = gst_caps_get_structure (caps, 0);
return gst_structure_foreach (structure, _gst_caps_is_fixed_foreach, NULL);
}
static gboolean
_gst_structure_field_has_compatible (GQuark field_id,
GValue *val2, gpointer data)
{
GValue dest = { 0 };
GstStructure *struct1 = (GstStructure *) data;
const GValue *val1 = gst_structure_id_get_value (struct1, field_id);
if (val1 == NULL) return FALSE;
if (gst_value_intersect (&dest, val1, val2)) {
g_value_unset (&dest);
return TRUE;
}
return FALSE;
}
static gboolean
_gst_cap_is_always_compatible (const GstStructure *struct1,
const GstStructure *struct2)
{
int i;
const GstStructureField *field1;
const GstStructureField *field2;
if(struct1->name != struct2->name){
return FALSE;
}
for(i=0;i<struct2->fields->len;i++){
GValue dest = { 0 };
/* the reversed order is important */
field2 = GST_STRUCTURE_FIELD (struct2, i);
field1 = gst_structure_id_get_field (struct1, field2->name);
if (field1 == NULL) return FALSE;
if (gst_value_compare (&field1->value, &field2->value) ==
GST_VALUE_EQUAL) {
break;
}
if (gst_value_intersect (&dest, &field1->value, &field2->value)){
g_value_unset (&dest);
break;
}
return FALSE;
}
return TRUE;
return gst_structure_foreach ((GstStructure *) struct2,
_gst_structure_field_has_compatible, (gpointer) struct1);
}
static gboolean _gst_caps_cap_is_always_compatible (const GstStructure
*struct1, const GstCaps2 *caps2)
static gboolean
_gst_caps_cap_is_always_compatible (const GstStructure *struct1,
const GstCaps *caps2)
{
int i;
for(i=0;i<caps2->structs->len;i++){
GstStructure *struct2 = gst_caps2_get_nth_cap (caps2, i);
GstStructure *struct2 = gst_caps_get_structure (caps2, i);
if (_gst_cap_is_always_compatible (struct1, struct2)) {
return TRUE;
@ -330,13 +390,24 @@ static gboolean _gst_caps_cap_is_always_compatible (const GstStructure
return FALSE;
}
gboolean gst_caps2_is_always_compatible (const GstCaps2 *caps1,
const GstCaps2 *caps2)
gboolean
gst_caps_is_always_compatible (const GstCaps *caps1, const GstCaps *caps2)
{
int i;
g_return_val_if_fail (caps1 != NULL, FALSE);
g_return_val_if_fail (caps2 != NULL, FALSE);
/* FIXME: is this right ? */
g_return_val_if_fail (!gst_caps_is_empty (caps1), FALSE);
g_return_val_if_fail (!gst_caps_is_empty (caps2), FALSE);
if (gst_caps_is_any (caps2))
return TRUE;
if (gst_caps_is_any (caps1))
return FALSE;
for(i=0;i<caps1->structs->len;i++) {
GstStructure *struct1 = gst_caps2_get_nth_cap (caps1, i);
GstStructure *struct1 = gst_caps_get_structure (caps1, i);
if (_gst_caps_cap_is_always_compatible(struct1, caps2) == FALSE){
return FALSE;
@ -347,58 +418,65 @@ gboolean gst_caps2_is_always_compatible (const GstCaps2 *caps1,
return FALSE;
}
static GstStructure *gst_caps2_structure_intersect (const GstStructure *struct1,
typedef struct {
GstStructure *dest;
const GstStructure *intersect;
gboolean first_run;
} IntersectData;
static gboolean
gst_caps_structure_intersect_field (GQuark id, GValue *val1, gpointer data)
{
IntersectData *idata = (IntersectData *) data;
GValue dest_value = { 0 };
const GValue *val2 = gst_structure_id_get_value (idata->intersect, id);
if (val2 == NULL) {
gst_structure_id_set_value (idata->dest, id, val1);
} else if (idata->first_run) {
if (gst_value_intersect (&dest_value, val1, val2)) {
gst_structure_id_set_value (idata->dest, id, &dest_value);
g_value_unset (&dest_value);
} else {
return FALSE;
}
}
return TRUE;
}
static GstStructure *gst_caps_structure_intersect (const GstStructure *struct1,
const GstStructure *struct2)
{
int i;
GstStructure *dest;
const GstStructureField *field1;
const GstStructureField *field2;
int ret;
IntersectData data;
g_return_val_if_fail(struct1 != NULL, NULL);
g_return_val_if_fail(struct2 != NULL, NULL);
if (struct1->name != struct2->name) return NULL;
dest = gst_structure_id_empty_new (struct1->name);
data.dest = gst_structure_id_empty_new (struct1->name);
data.intersect = struct2;
data.first_run = TRUE;
if (!gst_structure_foreach ((GstStructure *) struct1,
gst_caps_structure_intersect_field, &data))
goto error;
for(i=0;i<struct1->fields->len;i++){
GValue dest_field = { 0 };
data.intersect = struct1;
data.first_run = FALSE;
if (!gst_structure_foreach ((GstStructure *) struct2,
gst_caps_structure_intersect_field, &data))
goto error;
field1 = GST_STRUCTURE_FIELD (struct1, i);
field2 = gst_structure_id_get_field (struct2, field1->name);
return data.dest;
if (field2 == NULL) {
gst_structure_set_field_copy (dest, field1);
} else {
if (gst_value_intersect (&dest_field, &field1->value, &field2->value)) {
gst_structure_set_value (dest, g_quark_to_string(field1->name),
&dest_field);
} else {
ret = gst_value_compare(&field1->value, &field2->value);
if (ret == GST_VALUE_EQUAL){
gst_structure_set_value (dest, g_quark_to_string(field1->name),
&field1->value);
} else {
gst_structure_free (dest);
error:
gst_structure_free (data.dest);
return NULL;
}
}
}
}
for(i=0;i<struct1->fields->len;i++){
field2 = GST_STRUCTURE_FIELD (struct2, i);
field1 = gst_structure_id_get_field (struct1, field2->name);
if (field1 == NULL) {
gst_structure_set_field_copy (dest, field2);
}
}
return dest;
}
#if 0
static GstStructure *gst_caps2_structure_union (const GstStructure *struct1,
static GstStructure *gst_caps_structure_union (const GstStructure *struct1,
const GstStructure *struct2)
{
int i;
@ -436,21 +514,32 @@ static GstStructure *gst_caps2_structure_union (const GstStructure *struct1,
#endif
/* operations */
GstCaps2 *gst_caps2_intersect (const GstCaps2 *caps1, const GstCaps2 *caps2)
GstCaps *gst_caps_intersect (const GstCaps *caps1, const GstCaps *caps2)
{
int i,j;
GstStructure *struct1;
GstStructure *struct2;
GstCaps2 *dest;
GstCaps *dest;
dest = gst_caps2_new_empty();
g_return_val_if_fail (caps1 != NULL, NULL);
g_return_val_if_fail (caps2 != NULL, NULL);
if (gst_caps_is_empty (caps1) || gst_caps_is_empty (caps2)){
return gst_caps_new_empty ();
}
if (gst_caps_is_any (caps1)) return gst_caps_copy (caps2);
if (gst_caps_is_any (caps2)) return gst_caps_copy (caps1);
dest = gst_caps_new_empty();
for(i=0;i<caps1->structs->len;i++){
struct1 = gst_caps2_get_nth_cap (caps1, i);
for(j=0;j<caps1->structs->len;j++){
struct2 = gst_caps2_get_nth_cap (caps2, j);
struct1 = gst_caps_get_structure (caps1, i);
for(j=0;j<caps2->structs->len;j++){
GstStructure *istruct;
gst_caps2_append_cap(dest, gst_caps2_structure_intersect (
struct1, struct2));
struct2 = gst_caps_get_structure (caps2, j);
istruct = gst_caps_structure_intersect (struct1, struct2);
gst_caps_append_structure(dest, istruct);
}
}
@ -459,14 +548,14 @@ GstCaps2 *gst_caps2_intersect (const GstCaps2 *caps1, const GstCaps2 *caps2)
return dest;
}
GstCaps2 *gst_caps2_union (const GstCaps2 *caps1, const GstCaps2 *caps2)
GstCaps *gst_caps_union (const GstCaps *caps1, const GstCaps *caps2)
{
GstCaps2 *dest1;
GstCaps2 *dest2;
GstCaps *dest1;
GstCaps *dest2;
dest1 = gst_caps2_copy (caps1);
dest2 = gst_caps2_copy (caps2);
gst_caps2_append (dest1, dest2);
dest1 = gst_caps_copy (caps1);
dest2 = gst_caps_copy (caps2);
gst_caps_append (dest1, dest2);
/* FIXME: need a simplify function */
@ -474,20 +563,20 @@ GstCaps2 *gst_caps2_union (const GstCaps2 *caps1, const GstCaps2 *caps2)
return dest1;
}
GstCaps2 *gst_caps2_normalize (const GstCaps2 *caps)
GstCaps *gst_caps_normalize (const GstCaps *caps)
{
return NULL;
}
#ifndef GST_DISABLE_LOADSAVE
xmlNodePtr gst_caps2_save_thyself (const GstCaps2 *caps, xmlNodePtr parent)
xmlNodePtr gst_caps_save_thyself (const GstCaps *caps, xmlNodePtr parent)
{
return 0;
}
GstCaps2 *gst_caps2_load_thyself (xmlNodePtr parent)
GstCaps *gst_caps_load_thyself (xmlNodePtr parent)
{
return NULL;
@ -495,12 +584,15 @@ GstCaps2 *gst_caps2_load_thyself (xmlNodePtr parent)
#endif
/* utility */
void gst_caps2_replace (GstCaps2 **caps, const GstCaps2 *newcaps)
void gst_caps_replace (GstCaps **caps, GstCaps *newcaps)
{
/* FIXME */
if (*caps) gst_caps_free(*caps);
*caps = newcaps;
}
gchar *gst_caps2_to_string (const GstCaps2 *caps)
gchar *gst_caps_to_string (const GstCaps *caps)
{
int i;
GstStructure *structure;
@ -508,18 +600,21 @@ gchar *gst_caps2_to_string (const GstCaps2 *caps)
/* FIXME does this leak? */
if(gst_caps2_is_any(caps)){
if (caps == NULL) {
return g_strdup("NULL");
}
if(gst_caps_is_any(caps)){
return g_strdup("ANY");
}
if(gst_caps2_is_empty(caps)){
if(gst_caps_is_empty(caps)){
return g_strdup("EMPTY");
}
s = g_string_new("");
structure = gst_caps2_get_nth_cap (caps, 0);
structure = gst_caps_get_structure (caps, 0);
g_string_append(s, gst_structure_to_string(structure));
for(i=1;i<caps->structs->len;i++){
structure = gst_caps2_get_nth_cap (caps, i);
structure = gst_caps_get_structure (caps, i);
g_string_append(s, "; ");
g_string_append(s, gst_structure_to_string(structure));
@ -528,60 +623,186 @@ gchar *gst_caps2_to_string (const GstCaps2 *caps)
return g_string_free(s, FALSE);
}
static void _gst_caps2_from_string_inplace (GstCaps2 *caps,
static gboolean _gst_caps_from_string_inplace (GstCaps *caps,
const gchar *string)
{
GstStructure *structure;
gchar *s;
if (strcmp("ANY", string)==0) {
caps->flags = GST_CAPS2_FLAGS_ANY;
return;
caps->flags = GST_CAPS_FLAGS_ANY;
return TRUE;
}
if (strcmp("NONE", string)==0) {
return;
return TRUE;
}
structure = gst_structure_from_string(string);
gst_caps2_append_cap (caps, structure);
structure = gst_structure_from_string(string, &s);
if (structure == NULL) {
return FALSE;
}
gst_caps_append_structure (caps, structure);
while (*s == ';') {
s++;
while (g_ascii_isspace(*s))s++;
structure = gst_structure_from_string(s, &s);
if (structure == NULL) {
return FALSE;
}
gst_caps_append_structure (caps, structure);
while (g_ascii_isspace(*s))s++;
}
if (*s != 0){
return FALSE;
}
return TRUE;
}
GstCaps2 *gst_caps2_from_string (const gchar *string)
GstCaps *gst_caps_from_string (const gchar *string)
{
GstCaps2 *caps;
caps = gst_caps2_new_empty();
_gst_caps2_from_string_inplace (caps, string);
GstCaps *caps;
caps = gst_caps_new_empty();
if (_gst_caps_from_string_inplace (caps, string)) {
return caps;
} else {
gst_caps_free (caps);
return NULL;
}
}
static void _gst_caps2_transform_to_string (const GValue *src_value,
static void _gst_caps_transform_to_string (const GValue *src_value,
GValue *dest_value)
{
g_return_if_fail (src_value != NULL);
g_return_if_fail (dest_value != NULL);
dest_value->data[0].v_pointer =
gst_caps2_to_string (src_value->data[0].v_pointer);
gst_caps_to_string (src_value->data[0].v_pointer);
}
static void _gst_caps2_value_init (GValue *value)
static void _gst_caps_value_init (GValue *value)
{
value->data[0].v_pointer = gst_caps2_new_empty();
value->data[0].v_pointer = gst_caps_new_empty();
}
static void _gst_caps2_value_free (GValue *value)
static void _gst_caps_value_free (GValue *value)
{
gst_caps2_free (value->data[0].v_pointer);
if (value->data[0].v_pointer) gst_caps_free (value->data[0].v_pointer);
}
static void _gst_caps2_value_copy (const GValue *src, GValue *dest)
static void _gst_caps_value_copy (const GValue *src, GValue *dest)
{
dest->data[0].v_pointer = gst_caps2_copy (src->data[0].v_pointer);
if (dest->data[0].v_pointer) {
gst_caps_free (dest->data[0].v_pointer);
dest->data[0].v_pointer = gst_caps_copy (src->data[0].v_pointer);
} else {
dest->data[0].v_pointer = NULL;
}
}
static gpointer _gst_caps2_value_peek_pointer (const GValue *value)
static gpointer _gst_caps_value_peek_pointer (const GValue *value)
{
return value->data[0].v_pointer;
}
/* fixate utility functions */
gboolean gst_caps_structure_fixate_field_nearest_int (GstStructure *structure,
const char *field_name, int target)
{
const GValue *value;
g_return_val_if_fail(gst_structure_has_field (structure, field_name), FALSE);
value = gst_structure_get_value (structure, field_name);
if (G_VALUE_TYPE (value) == G_TYPE_INT) {
/* already fixed */
return FALSE;
} else if (G_VALUE_TYPE (value) == GST_TYPE_INT_RANGE) {
int x;
x = gst_value_get_int_range_min (value);
if (target < x) target = x;
x = gst_value_get_int_range_max (value);
if (target > x) target = x;
gst_structure_set (structure, field_name, G_TYPE_INT, target, NULL);
return TRUE;
} else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
const GValue *list_value;
int i, n;
int best = 0;
int best_index = -1;
n = gst_value_list_get_size (value);
for(i=0;i<n;i++){
list_value = gst_value_list_get_value (value, i);
if (G_VALUE_TYPE (list_value) == G_TYPE_INT) {
int x = g_value_get_int (list_value);
if (best_index == -1 || (ABS(target-x) < ABS(best-x))) {
best_index = i;
best = x;
}
}
}
if(best_index != -1) {
gst_structure_set (structure, field_name, G_TYPE_INT, best, NULL);
return TRUE;
}
return FALSE;
}
return FALSE;
}
gboolean gst_caps_structure_fixate_field_nearest_double (GstStructure
*structure, const char *field_name, double target)
{
const GValue *value;
g_return_val_if_fail(gst_structure_has_field (structure, field_name), FALSE);
value = gst_structure_get_value (structure, field_name);
if (G_VALUE_TYPE (value) == G_TYPE_DOUBLE) {
/* already fixed */
return FALSE;
} else if (G_VALUE_TYPE (value) == GST_TYPE_DOUBLE_RANGE) {
double x;
x = gst_value_get_double_range_min (value);
if (target < x) target = x;
x = gst_value_get_double_range_max (value);
if (target > x) target = x;
gst_structure_set (structure, field_name, G_TYPE_DOUBLE, target, NULL);
return TRUE;
} else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
const GValue *list_value;
int i, n;
double best = 0;
int best_index = -1;
n = gst_value_list_get_size (value);
for(i=0;i<n;i++){
list_value = gst_value_list_get_value (value, i);
if (G_VALUE_TYPE (list_value) == G_TYPE_DOUBLE) {
double x = g_value_get_double (list_value);
if (best_index == -1 || (ABS(target-x) < ABS(best-x))) {
best_index = i;
best = x;
}
}
}
if(best_index != -1) {
gst_structure_set (structure, field_name, G_TYPE_DOUBLE, best, NULL);
return TRUE;
}
return FALSE;
}
return FALSE;
}

View file

@ -17,84 +17,110 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_CAPS2_H__
#define __GST_CAPS2_H__
#ifndef __GST_CAPS_H__
#define __GST_CAPS_H__
#include <gst/gstconfig.h>
#include <gst/gststructure.h>
G_BEGIN_DECLS
#define GST_CAPS2_FLAGS_ANY (1<<0)
#define GST_CAPS_FLAGS_ANY (1<<0)
extern GType _gst_caps2_type;
extern GType _gst_caps_type;
typedef struct _GstCaps2 GstCaps2;
typedef struct _GstStaticCaps2 GstStaticCaps2;
typedef struct _GstCaps GstCaps;
typedef struct _GstStaticCaps GstStaticCaps;
struct _GstCaps2 {
struct _GstCaps {
GType type;
guint16 flags;
GPtrArray *structs;
};
struct _GstStaticCaps2 {
GstCaps2 caps;
struct _GstStaticCaps {
GstCaps caps;
const char *string;
};
#define GST_CAPS2_ANY gst_caps2_new_any()
#define GST_CAPS2_NONE gst_caps2_new_empty()
#define GST_STATIC_CAPS(string) \
{ \
/* caps */ { 0 }, \
/* string */ string, \
}
#define GST_TYPE_CAPS2 gst_caps2_get_type()
#define GST_CAPS_ANY gst_caps_new_any()
#define GST_CAPS_NONE gst_caps_new_empty()
void _gst_caps2_initialize (void);
GType gst_caps2_get_type (void);
#define GST_STATIC_CAPS_ANY GST_STATIC_CAPS("ANY")
#define GST_STATIC_CAPS_NONE GST_STATIC_CAPS("NONE")
#define GST_TYPE_CAPS gst_caps_get_type()
/* FIXME Company should decide the best way to do this */
#define GST_DEBUG_CAPS(string, caps) do { \
char *s = gst_caps_to_string(caps); \
GST_DEBUG ( "%s: %s", (string), s); \
g_free(s); \
}while(0)
void _gst_caps_initialize (void);
GType gst_caps_get_type (void);
/* creation/deletion */
GstCaps2 *gst_caps2_new_empty (void);
GstCaps2 *gst_caps2_new_any (void);
GstCaps2 *gst_caps2_new_simple (const char *media_type, const char *fieldname, ...);
GstCaps2 *gst_caps2_new_full (const GstStructure *struct1, ...);
GstCaps2 *gst_caps2_new_full_valist (const GstStructure *structure, va_list var_args);
GstCaps2 *gst_caps2_copy (const GstCaps2 *caps);
void gst_caps2_free (GstCaps2 *caps);
const GstCaps2 *gst_caps2_from_static (GstStaticCaps2 *caps);
GstCaps *gst_caps_new_empty (void);
GstCaps *gst_caps_new_any (void);
GstCaps *gst_caps_new_simple (const char *media_type, const char *fieldname, ...);
GstCaps *gst_caps_new_full (GstStructure *struct1, ...);
GstCaps *gst_caps_new_full_valist (GstStructure *structure, va_list var_args);
GstCaps *gst_caps_copy (const GstCaps *caps);
void gst_caps_free (GstCaps *caps);
G_CONST_RETURN GstCaps *gst_static_caps_get (GstStaticCaps *caps);
/* manipulation */
void gst_caps2_append (GstCaps2 *caps1, GstCaps2 *caps2);
void gst_caps2_append_cap (GstCaps2 *caps1, GstStructure *structure);
GstCaps2 *gst_caps2_split_one (GstCaps2 *caps);
GstStructure *gst_caps2_get_nth_cap (const GstCaps2 *caps, int index);
GstCaps2 *gst_caps2_copy_1 (const GstCaps2 *caps);
void gst_caps_append (GstCaps *caps1, GstCaps *caps2);
void gst_caps_append_structure (GstCaps *caps1, GstStructure *structure);
GstCaps *gst_caps_split_one (GstCaps *caps);
int gst_caps_get_size (const GstCaps *caps);
GstStructure *gst_caps_get_structure (const GstCaps *caps, int index);
GstCaps *gst_caps_copy_1 (const GstCaps *caps);
void gst_caps_set_simple (GstCaps *caps, char *field, ...);
void gst_caps_set_simple_valist (GstCaps *caps, char *field, va_list varargs);
/* tests */
gboolean gst_caps2_is_any (const GstCaps2 *caps);
gboolean gst_caps2_is_empty (const GstCaps2 *caps);
gboolean gst_caps2_is_chained (const GstCaps2 *caps);
gboolean gst_caps2_is_fixed (const GstCaps2 *caps);
gboolean gst_caps2_is_always_compatible (const GstCaps2 *caps1,
const GstCaps2 *caps2);
gboolean gst_caps_is_any (const GstCaps *caps);
gboolean gst_caps_is_empty (const GstCaps *caps);
gboolean gst_caps_is_chained (const GstCaps *caps);
gboolean gst_caps_is_fixed (const GstCaps *caps);
gboolean gst_caps_is_always_compatible (const GstCaps *caps1,
const GstCaps *caps2);
/* operations */
GstCaps2 *gst_caps2_intersect (const GstCaps2 *caps1, const GstCaps2 *caps2);
GstCaps2 *gst_caps2_union (const GstCaps2 *caps1, const GstCaps2 *caps2);
GstCaps2 *gst_caps2_normalize (const GstCaps2 *caps);
GstCaps *gst_caps_intersect (const GstCaps *caps1, const GstCaps *caps2);
GstCaps *gst_caps_union (const GstCaps *caps1, const GstCaps *caps2);
GstCaps *gst_caps_normalize (const GstCaps *caps);
#ifndef GST_DISABLE_LOADSAVE
xmlNodePtr gst_caps2_save_thyself (const GstCaps2 *caps, xmlNodePtr parent);
GstCaps2 *gst_caps2_load_thyself (xmlNodePtr parent);
xmlNodePtr gst_caps_save_thyself (const GstCaps *caps, xmlNodePtr parent);
GstCaps *gst_caps_load_thyself (xmlNodePtr parent);
#endif
/* utility */
void gst_caps2_replace (GstCaps2 **caps, const GstCaps2 *newcaps);
gchar *gst_caps2_to_string (const GstCaps2 *caps);
GstCaps2 *gst_caps2_from_string (const gchar *string);
void gst_caps_replace (GstCaps **caps, GstCaps *newcaps);
gchar *gst_caps_to_string (const GstCaps *caps);
GstCaps *gst_caps_from_string (const gchar *string);
void gst_caps_debug (const GstCaps *caps, const gchar *string);
gboolean gst_caps_structure_fixate_field_nearest_int (GstStructure *structure,
const char *field_name, int target);
gboolean gst_caps_structure_fixate_field_nearest_double (GstStructure
*structure, const char *field_name, double target);
G_END_DECLS
#endif
#endif /* __GST_CAPS_H__ */

View file

@ -1211,7 +1211,7 @@ gst_element_class_add_pad_template (GstElementClass *klass,
* <note>This function is for use in _base_init functions only.</note>
*/
void
gst_element_class_set_details (GstElementClass *klass, GstElementDetails *details)
gst_element_class_set_details (GstElementClass *klass, const GstElementDetails *details)
{
g_return_if_fail (GST_IS_ELEMENT_CLASS (klass));
g_return_if_fail (GST_IS_ELEMENT_DETAILS (details));
@ -1429,7 +1429,7 @@ gst_element_request_compatible_pad (GstElement *element, GstPadTemplate *templ)
*/
GstPad*
gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad,
GstCaps *filtercaps)
const GstCaps *filtercaps)
{
const GList *pads;
GstPadTemplate *templ;
@ -1462,14 +1462,15 @@ gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad,
/* requesting is a little crazy, we need a template. Let's create one */
if (filtercaps != NULL) {
templcaps = gst_caps_intersect (filtercaps, (GstCaps *) GST_RPAD_CAPS (pad));
/* FIXME */
if (templcaps == NULL)
return NULL;
} else {
templcaps = gst_pad_get_caps (pad);
templcaps = gst_caps_copy (gst_pad_get_caps (pad));
}
templ = gst_pad_template_new ((gchar *) GST_PAD_NAME (pad), GST_RPAD_DIRECTION (pad),
GST_PAD_ALWAYS, templcaps, NULL);
GST_PAD_ALWAYS, templcaps);
foundpad = gst_element_request_compatible_pad (element, templ);
gst_object_unref (GST_OBJECT (templ)); /* this will take care of the caps too */
@ -1477,7 +1478,7 @@ gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad,
have caps on their source padtemplates (spider) can link... */
if (!foundpad && !filtercaps) {
templ = gst_pad_template_new ((gchar *) GST_PAD_NAME (pad), GST_RPAD_DIRECTION (pad),
GST_PAD_ALWAYS, NULL, NULL);
GST_PAD_ALWAYS, gst_caps_new_any());
foundpad = gst_element_request_compatible_pad (element, templ);
gst_object_unref (GST_OBJECT (templ));
}
@ -1521,7 +1522,7 @@ gst_element_get_compatible_pad (GstElement *element, GstPad *pad)
gboolean
gst_element_link_pads_filtered (GstElement *src, const gchar *srcpadname,
GstElement *dest, const gchar *destpadname,
GstCaps *filtercaps)
const GstCaps *filtercaps)
{
const GList *srcpads, *destpads, *srctempls, *desttempls, *l;
GstPad *srcpad, *destpad;
@ -1697,7 +1698,7 @@ gst_element_link_pads_filtered (GstElement *src, const gchar *srcpadname,
*/
gboolean
gst_element_link_filtered (GstElement *src, GstElement *dest,
GstCaps *filtercaps)
const GstCaps *filtercaps)
{
return gst_element_link_pads_filtered (src, NULL, dest, NULL, filtercaps);
}

View file

@ -239,7 +239,7 @@ void gst_element_class_add_pad_template (GstElementClass *klass, GstPadTemplat
void gst_element_class_install_std_props (GstElementClass *klass,
const gchar *first_name, ...);
void gst_element_class_set_details (GstElementClass *klass,
GstElementDetails *details);
const GstElementDetails *details);
#define gst_element_default_deep_notify gst_object_default_deep_notify
@ -305,7 +305,7 @@ G_CONST_RETURN GList*
gst_element_get_pad_list (GstElement *element);
GstPad* gst_element_get_compatible_pad (GstElement *element, GstPad *pad);
GstPad* gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad,
GstCaps *filtercaps);
const GstCaps *filtercaps);
GstPadTemplate* gst_element_class_get_pad_template (GstElementClass *element_class, const gchar *name);
GList* gst_element_class_get_pad_template_list (GstElementClass *element_class);
@ -317,7 +317,7 @@ gboolean gst_element_link (GstElement *src, GstElement *dest);
gboolean gst_element_link_many (GstElement *element_1,
GstElement *element_2, ...);
gboolean gst_element_link_filtered (GstElement *src, GstElement *dest,
GstCaps *filtercaps);
const GstCaps *filtercaps);
void gst_element_unlink (GstElement *src, GstElement *dest);
void gst_element_unlink_many (GstElement *element_1,
GstElement *element_2, ...);
@ -326,7 +326,7 @@ gboolean gst_element_link_pads (GstElement *src, const gchar *srcpadname,
GstElement *dest, const gchar *destpadname);
gboolean gst_element_link_pads_filtered (GstElement *src, const gchar *srcpadname,
GstElement *dest, const gchar *destpadname,
GstCaps *filtercaps);
const GstCaps *filtercaps);
void gst_element_unlink_pads (GstElement *src, const gchar *srcpadname,
GstElement *dest, const gchar *destpadname);
@ -432,9 +432,9 @@ GstElement* gst_element_factory_create (GstElementFactory *factory,
GstElement* gst_element_factory_make (const gchar *factoryname, const gchar *name);
gboolean gst_element_factory_can_src_caps (GstElementFactory *factory,
GstCaps *caps);
const GstCaps *caps);
gboolean gst_element_factory_can_sink_caps (GstElementFactory *factory,
GstCaps *caps);
const GstCaps *caps);
void __gst_element_factory_add_pad_template (GstElementFactory *elementfactory,
GstPadTemplate *templ);

View file

@ -502,7 +502,7 @@ gst_element_factory_get_uri_protocols (GstElementFactory *factory)
*/
gboolean
gst_element_factory_can_src_caps (GstElementFactory *factory,
GstCaps *caps)
const GstCaps *caps)
{
GList *templates;
@ -534,7 +534,7 @@ gst_element_factory_can_src_caps (GstElementFactory *factory,
*/
gboolean
gst_element_factory_can_sink_caps (GstElementFactory *factory,
GstCaps *caps)
const GstCaps *caps)
{
GList *templates;

View file

@ -29,6 +29,11 @@
#include "gstscheduler.h"
#include "gstevent.h"
#include "gstinfo.h"
#include "gstvalue.h"
/* FIXME */
#define gst_caps_debug(a,b) GST_DEBUG_CAPS(b,a)
enum {
TEMPL_PAD_CREATED,
@ -47,8 +52,10 @@ static void gst_pad_init (GstPad *pad);
static void gst_pad_dispose (GObject *object);
static gboolean gst_pad_try_relink_filtered_func (GstRealPad *srcpad, GstRealPad *sinkpad,
GstCaps *caps, gboolean clear);
const GstCaps *caps, gboolean clear);
static void gst_pad_set_pad_template (GstPad *pad, GstPadTemplate *templ);
static GstCaps * _gst_pad_try_fixate_caps (GstRealPad *pad, GstCaps *caps);
static GstCaps * _gst_pad_default_fixate_func (GstPad *pad, GstCaps *caps, gpointer unused);
#ifndef GST_DISABLE_LOADSAVE
static xmlNodePtr gst_pad_save_thyself (GstObject *object, xmlNodePtr parent);
@ -169,17 +176,17 @@ gst_real_pad_class_init (GstRealPadClass *klass)
gst_real_pad_signals[REAL_CAPS_NEGO_FAILED] =
g_signal_new ("caps_nego_failed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstRealPadClass, caps_nego_failed), NULL, NULL,
gst_marshal_VOID__POINTER, G_TYPE_NONE, 1,
gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
GST_TYPE_CAPS);
gst_real_pad_signals[REAL_LINKED] =
g_signal_new ("linked", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstRealPadClass, linked), NULL, NULL,
gst_marshal_VOID__POINTER, G_TYPE_NONE, 1,
gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
GST_TYPE_PAD);
gst_real_pad_signals[REAL_UNLINKED] =
g_signal_new ("unlinked", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstRealPadClass, unlinked), NULL, NULL,
gst_marshal_VOID__POINTER, G_TYPE_NONE, 1,
gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
GST_TYPE_PAD);
/* gtk_object_add_arg_type ("GstRealPad::active", G_TYPE_BOOLEAN, */
@ -209,7 +216,6 @@ gst_real_pad_init (GstRealPad *pad)
pad->chainhandler = NULL;
pad->gethandler = NULL;
pad->bufferpoolfunc = NULL;
pad->ghostpads = NULL;
pad->caps = NULL;
@ -403,7 +409,7 @@ gst_pad_set_active (GstPad *pad, gboolean active)
GST_DEBUG_PAD_NAME (realpad));
GST_FLAG_SET (realpad, GST_PAD_DISABLED);
}
if (old != active)
g_object_notify (G_OBJECT (realpad), "active");
}
@ -781,6 +787,24 @@ gst_pad_set_unlink_function (GstPad *pad,
GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (unlink));
}
/**
* gst_pad_set_fixate_function:
* @pad: a #GstPad to set the fixate function for.
* @getcaps: the #GstPadFixateFunction to set.
*
* Sets the given fixate function for the pad.
*/
void
gst_pad_set_fixate_function (GstPad *pad, GstPadFixateFunction fixate)
{
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_REAL_PAD (pad));
GST_RPAD_FIXATEFUNC (pad) = fixate;
GST_CAT_DEBUG (GST_CAT_PADS, "fixatefunc for %s:%s set to %s",
GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (fixate));
}
/**
* gst_pad_set_getcaps_function:
* @pad: a #GstPad to set the getcaps function for.
@ -799,25 +823,26 @@ gst_pad_set_getcaps_function (GstPad *pad,
GST_CAT_DEBUG (GST_CAT_PADS, "getcapsfunc for %s:%s set to %s",
GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (getcaps));
}
/**
* gst_pad_set_bufferpool_function:
* @pad: a #GstPad to set the bufferpool function for.
* @bufpool: the #GstPadBufferPoolFunction to set.
* gst_pad_set_bufferalloc_function:
* @pad: a #GstPad to set the bufferalloc function for.
* @bufalloc: the #GstPadBufferPoolFunction to set.
*
* Sets the given bufferpool function for the pad. Note that the
* bufferpool function can only be set on sinkpads.
* Sets the given bufferalloc function for the pad. Note that the
* bufferalloc function can only be set on sinkpads.
*/
void
gst_pad_set_bufferpool_function (GstPad *pad,
GstPadBufferPoolFunction bufpool)
gst_pad_set_bufferalloc_function (GstPad *pad,
GstPadBufferAllocFunction bufalloc)
{
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_REAL_PAD (pad));
g_return_if_fail (GST_PAD_IS_SINK (pad));
GST_RPAD_BUFFERPOOLFUNC (pad) = bufpool;
GST_CAT_DEBUG (GST_CAT_PADS, "bufferpoolfunc for %s:%s set to %s",
GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (bufpool));
GST_RPAD_BUFFERALLOCFUNC (pad) = bufalloc;
GST_CAT_DEBUG (GST_CAT_PADS, "bufferallocfunc for %s:%s set to %s",
GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (bufalloc));
}
/**
@ -877,12 +902,6 @@ gst_pad_unlink (GstPad *srcpad,
GST_RPAD_PEER (realsrc) = NULL;
GST_RPAD_PEER (realsink) = NULL;
/* reset the filters, both filters are refcounted once */
if (GST_RPAD_FILTER (realsrc)) {
gst_caps_replace (&GST_RPAD_FILTER (realsink), NULL);
gst_caps_replace (&GST_RPAD_FILTER (realsrc), NULL);
}
/* now tell the scheduler */
if (src_sched && src_sched == sink_sched) {
gst_scheduler_pad_unlink (src_sched,
@ -943,7 +962,7 @@ gst_pad_check_schedulers (GstRealPad *realsrc, GstRealPad *realsink)
*/
gboolean
gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad,
GstCaps *filtercaps)
const GstCaps *filtercaps)
{
GstRealPad *realsrc, *realsink;
@ -1004,7 +1023,8 @@ gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad)
* Returns: TRUE if the pads have been linked, FALSE otherwise.
*/
gboolean
gst_pad_link_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps)
gst_pad_link_filtered (GstPad *srcpad, GstPad *sinkpad,
const GstCaps *filtercaps)
{
GstRealPad *realsrc, *realsink;
GstScheduler *src_sched, *sink_sched;
@ -1322,7 +1342,6 @@ static GstPadLinkReturn
gst_pad_try_set_caps_func (GstRealPad *pad, GstCaps *caps, gboolean notify)
{
GstCaps *allowed = NULL;
GstPadTemplate *template;
GstElement *parent = GST_PAD_PARENT (pad);
g_return_val_if_fail (pad != NULL, GST_PAD_LINK_REFUSED);
@ -1340,14 +1359,7 @@ gst_pad_try_set_caps_func (GstRealPad *pad, GstCaps *caps, gboolean notify)
GST_CAT_INFO (GST_CAT_CAPS, "trying to set caps %p on pad %s:%s",
caps, GST_DEBUG_PAD_NAME (pad));
/* first see if we have to check against a filter, we ref the caps here as we're
* going to unref it later on */
if (!(allowed = gst_caps_ref (GST_RPAD_FILTER (pad)))) {
/* no filter, make sure we check against the padtemplate then */
if ((template = gst_pad_get_pad_template (GST_PAD (pad)))) {
allowed = gst_pad_template_get_caps (template);
}
}
/* FIXME: check against allowed caps */
/* do we have to check the caps against something? */
if (allowed) {
@ -1356,19 +1368,19 @@ gst_pad_try_set_caps_func (GstRealPad *pad, GstCaps *caps, gboolean notify)
/* check against calculated caps */
intersection = gst_caps_intersect (caps, allowed);
/* oops, empty intersection, caps don"t have anything in common */
if (!intersection) {
/* oops, empty intersection, caps don't have anything in common */
if (gst_caps_is_empty (intersection)) {
GST_CAT_INFO (GST_CAT_CAPS, "caps did not intersect with %s:%s's allowed caps",
GST_DEBUG_PAD_NAME (pad));
gst_caps_debug (caps, "caps themselves (attemped to set)");
gst_caps_debug (allowed,
"allowed caps that did not agree with caps");
gst_caps_unref (allowed);
gst_caps_free (allowed);
return GST_PAD_LINK_REFUSED;
}
/* caps checks out fine, we can unref the intersection now */
gst_caps_unref (intersection);
gst_caps_unref (allowed);
gst_caps_free (intersection);
gst_caps_free (allowed);
/* given that the caps are fixed, we know that their intersection with the
* padtemplate caps is the same as caps itself */
}
@ -1378,9 +1390,12 @@ gst_pad_try_set_caps_func (GstRealPad *pad, GstCaps *caps, gboolean notify)
GstPadLinkReturn res;
gchar *debug_string;
gboolean negotiating;
gchar *s;
GST_CAT_INFO (GST_CAT_CAPS, "calling link function on pad %s:%s",
GST_DEBUG_PAD_NAME (pad));
s = gst_caps_to_string (caps);
GST_CAT_INFO (GST_CAT_CAPS, "calling link function on pad %s:%s with caps %s",
GST_DEBUG_PAD_NAME (pad), s);
g_free (s);
negotiating = GST_FLAG_IS_SET (pad, GST_PAD_NEGOTIATING);
@ -1431,12 +1446,12 @@ gst_pad_try_set_caps_func (GstRealPad *pad, GstCaps *caps, gboolean notify)
}
}
/* we can only set caps on the pad if they are fixed */
if (GST_CAPS_IS_FIXED (caps)) {
if (gst_caps_is_fixed (caps)) {
GST_CAT_INFO (GST_CAT_CAPS, "setting caps on pad %s:%s",
GST_DEBUG_PAD_NAME (pad));
/* if we got this far all is ok, remove the old caps, set the new one */
gst_caps_replace_sink (&GST_PAD_CAPS (pad), caps);
gst_caps_replace (&GST_PAD_CAPS (pad), gst_caps_copy (caps));
g_object_notify (G_OBJECT (pad), "caps");
}
@ -1450,6 +1465,113 @@ gst_pad_try_set_caps_func (GstRealPad *pad, GstCaps *caps, gboolean notify)
return GST_PAD_LINK_OK;
}
static GstCaps *
_gst_pad_try_fixate_caps (GstRealPad *pad, GstCaps *caps)
{
GstRealPad *srcpad;
GstRealPad *sinkpad;
GstPadFixateFunction app_fixate = NULL;
GstCaps *newcaps;
g_return_val_if_fail (caps != NULL, NULL);
g_return_val_if_fail (!gst_caps_is_empty(caps), NULL);
if (GST_PAD_IS_SRC (pad)) {
srcpad = pad;
sinkpad = GST_RPAD_PEER (pad);
} else {
sinkpad = pad;
srcpad = GST_RPAD_PEER (pad);
}
while (!gst_caps_is_fixed (caps)) {
if (app_fixate) {
newcaps = (app_fixate) (GST_PAD (srcpad), caps, NULL);
if (newcaps) {
caps = newcaps;
continue;
}
}
if (GST_RPAD_FIXATEFUNC(srcpad)) {
newcaps = GST_RPAD_FIXATEFUNC(srcpad) (GST_PAD (srcpad), caps, NULL);
if (newcaps) {
caps = newcaps;
continue;
}
}
if (GST_RPAD_FIXATEFUNC(sinkpad)) {
newcaps = GST_RPAD_FIXATEFUNC(sinkpad) (GST_PAD (sinkpad), caps, NULL);
if (newcaps) {
caps = newcaps;
continue;
}
}
caps = _gst_pad_default_fixate_func (GST_PAD(srcpad), caps, NULL);
}
GST_DEBUG_CAPS ("fixate decided on", caps);
return caps;
}
static gboolean
_gst_pad_default_fixate_foreach (GQuark field_id, GValue *value,
gpointer s)
{
GstStructure *structure = (GstStructure *)s;
GType type = G_VALUE_TYPE (value);
if (G_TYPE_IS_FUNDAMENTAL (type) || type == GST_TYPE_FOURCC) return TRUE;
if (type == GST_TYPE_INT_RANGE) {
gst_structure_set (structure, g_quark_to_string (field_id),
G_TYPE_INT, gst_value_get_int_range_min (value), NULL);
return FALSE;
}
if (type == GST_TYPE_DOUBLE_RANGE) {
gst_structure_set (structure, g_quark_to_string (field_id),
G_TYPE_DOUBLE, gst_value_get_double_range_min (value), NULL);
return FALSE;
}
if (type == GST_TYPE_LIST) {
gst_structure_set_value (structure, g_quark_to_string (field_id),
gst_value_list_get_value (value, 0));
return FALSE;
}
g_critical ("don't know how to fixate type %s", g_type_name(type));
return TRUE;
}
static GstCaps *
_gst_pad_default_fixate_func (GstPad *pad, GstCaps *caps, gpointer unused)
{
static GstStaticCaps octetcaps = GST_STATIC_CAPS (
"application/octet-stream");
GstStructure *structure;
g_return_val_if_fail (pad != NULL, NULL);
g_return_val_if_fail (caps != NULL, NULL);
g_return_val_if_fail (!gst_caps_is_empty (caps), NULL);
if (gst_caps_is_any (caps)) {
gst_caps_free (caps);
return gst_caps_copy (gst_static_caps_get (&octetcaps));
}
if (caps->structs->len > 1) {
GstCaps *retcaps = gst_caps_copy_1 (caps);
gst_caps_free (caps);
return retcaps;
}
structure = gst_caps_get_structure (caps, 0);
gst_structure_foreach (structure, _gst_pad_default_fixate_foreach,
structure);
return caps;
}
/**
* gst_pad_try_set_caps:
* @pad: a #GstPad to try to set the caps on.
@ -1462,9 +1584,10 @@ gst_pad_try_set_caps_func (GstRealPad *pad, GstCaps *caps, gboolean notify)
* could be set.
*/
GstPadLinkReturn
gst_pad_try_set_caps (GstPad *pad, GstCaps *caps)
gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps)
{
GstRealPad *peer, *realpad;
GstCaps *mycaps;
GstPadLinkReturn set_retval;
realpad = GST_PAD_REALIZE (pad);
@ -1476,25 +1599,24 @@ gst_pad_try_set_caps (GstPad *pad, GstCaps *caps)
gst_caps_debug (caps, "caps that we are trying to set");
/* try to take ownership */
gst_caps_ref (caps);
gst_caps_sink (caps);
mycaps = gst_caps_copy (caps);
/* setting non fixed caps on a pad is not allowed */
if (!GST_CAPS_IS_FIXED (caps)) {
if (!gst_caps_is_fixed (mycaps)) {
GST_CAT_INFO (GST_CAT_CAPS,
"trying to set unfixed caps on pad %s:%s, not allowed",
GST_DEBUG_PAD_NAME (realpad));
g_warning ("trying to set non fixed caps on pad %s:%s, not allowed",
GST_DEBUG_PAD_NAME (realpad));
gst_caps_debug (caps, "unfixed caps");
gst_caps_debug (mycaps, "unfixed caps");
set_retval = GST_PAD_LINK_DELAYED;
goto done;
}
/* if we have a peer try to set the caps, notifying the peerpad
/* if we have a peer, try to set the caps, notifying the peerpad
* if it has a link function */
if (peer && ((set_retval = gst_pad_try_set_caps_func (peer, caps, TRUE)) <= 0))
if (peer && ((set_retval = gst_pad_try_set_caps_func (peer, mycaps, TRUE)) <= 0))
{
GST_CAT_INFO (GST_CAT_CAPS, "tried to set caps on peerpad %s:%s but couldn't, return value %d",
GST_DEBUG_PAD_NAME (peer), set_retval);
@ -1502,19 +1624,19 @@ gst_pad_try_set_caps (GstPad *pad, GstCaps *caps)
}
/* then try to set our own caps, we don't need to be notified */
if ((set_retval = gst_pad_try_set_caps_func (realpad, caps, FALSE)) <= 0)
if ((set_retval = gst_pad_try_set_caps_func (realpad, mycaps, FALSE)) <= 0)
{
GST_CAT_INFO (GST_CAT_CAPS, "tried to set own caps on pad %s:%s but couldn't, return value %d",
GST_DEBUG_PAD_NAME (realpad), set_retval);
goto done;
}
GST_CAT_INFO (GST_CAT_CAPS, "succeeded setting caps %p on pad %s:%s, return value %d",
caps, GST_DEBUG_PAD_NAME (realpad), set_retval);
mycaps, GST_DEBUG_PAD_NAME (realpad), set_retval);
g_assert (GST_PAD_CAPS (pad));
done:
/* if we took ownership, the caps will be freed */
gst_caps_unref (caps);
//gst_caps_free (caps);
return set_retval;
}
@ -1530,7 +1652,7 @@ done:
*/
static gboolean
gst_pad_try_relink_filtered_func (GstRealPad *srcpad, GstRealPad *sinkpad,
GstCaps *filtercaps, gboolean clear)
const GstCaps *filtercaps, gboolean clear)
{
GstCaps *srccaps, *sinkcaps;
GstCaps *intersection = NULL;
@ -1550,19 +1672,17 @@ gst_pad_try_relink_filtered_func (GstRealPad *srcpad, GstRealPad *sinkpad,
gst_caps_replace (&GST_PAD_CAPS (GST_PAD (realsrc)), NULL);
gst_caps_replace (&GST_PAD_CAPS (GST_PAD (realsink)), NULL);
gst_caps_replace (&GST_RPAD_FILTER (realsrc), NULL);
gst_caps_replace (&GST_RPAD_FILTER (realsink), NULL);
}
else {
GST_CAT_INFO (GST_CAT_PADS, "start relink filtered %s:%s and %s:%s",
GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink));
}
srccaps = gst_pad_get_caps (GST_PAD (realsrc));
srccaps = gst_caps_copy(gst_pad_get_caps (GST_PAD (realsrc)));
GST_CAT_DEBUG (GST_CAT_PADS, "dumping caps of pad %s:%s",
GST_DEBUG_PAD_NAME (realsrc));
gst_caps_debug (srccaps, "caps of src pad (pre-relink)");
sinkcaps = gst_pad_get_caps (GST_PAD (realsink));
sinkcaps = gst_caps_copy(gst_pad_get_caps (GST_PAD (realsink)));
GST_CAT_DEBUG (GST_CAT_PADS, "dumping caps of pad %s:%s",
GST_DEBUG_PAD_NAME (realsink));
gst_caps_debug (sinkcaps, "caps of sink pad (pre-relink)");
@ -1572,36 +1692,35 @@ gst_pad_try_relink_filtered_func (GstRealPad *srcpad, GstRealPad *sinkpad,
gst_caps_debug (intersection, "caps of intersection");
/* if we have no intersection but one of the caps was not NULL.. */
if (!intersection && (srccaps || sinkcaps)) {
/* the intersection is NULL but the pad caps were not both NULL,
* this means they have no common format */
if (gst_caps_is_empty(intersection)) {
/* the intersection is EMPTY, they have no common format */
GST_CAT_INFO (GST_CAT_PADS, "pads %s:%s and %s:%s have no common type",
GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink));
/* make sure any floating caps from gst_pad_get_caps are freed here */
gst_caps_sink (srccaps);
gst_caps_sink (sinkcaps);
gst_caps_free (srccaps);
gst_caps_free (sinkcaps);
return FALSE;
} else {
GST_CAT_INFO (GST_CAT_PADS, "pads %s:%s and %s:%s intersected to %s caps",
GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink),
(intersection ?
(GST_CAPS_IS_FIXED (intersection) ? "fixed" : "variable") :
(gst_caps_is_fixed (intersection) ? "fixed" : "variable") :
"NULL"));
/* we don't need those anymore, as the caps can be floating */
gst_caps_sink (srccaps);
gst_caps_sink (sinkcaps);
gst_caps_free (srccaps);
gst_caps_free (sinkcaps);
/* then filter this against the app filter */
if (filtercaps) {
GstCaps *filtered_intersection;
filtered_intersection = gst_caps_intersect (intersection,
filtercaps);
GST_DEBUG_CAPS ("filter caps are ", filtercaps);
filtered_intersection = gst_caps_intersect (intersection, filtercaps);
gst_caps_sink (intersection);
gst_caps_free (intersection);
if (!filtered_intersection) {
if (gst_caps_is_empty(filtered_intersection)) {
GST_CAT_INFO (GST_CAT_PADS,
"filtered link between pads %s:%s and %s:%s is empty",
GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink));
@ -1610,18 +1729,16 @@ gst_pad_try_relink_filtered_func (GstRealPad *srcpad, GstRealPad *sinkpad,
intersection = filtered_intersection;
/* keep a reference to the app caps */
gst_caps_replace_sink (&GST_RPAD_APPFILTER (realsink), filtercaps);
gst_caps_replace_sink (&GST_RPAD_APPFILTER (realsrc), filtercaps);
gst_caps_replace (&GST_RPAD_APPFILTER (realsink),
gst_caps_copy (filtercaps));
gst_caps_replace (&GST_RPAD_APPFILTER (realsrc),
gst_caps_copy (filtercaps));
}
}
GST_CAT_DEBUG (GST_CAT_CAPS, "setting filter for link to:");
gst_caps_debug (intersection, "filter for link");
/* both the app filter and the filter, while stored on both peer pads,
* are equal to the same thing on both */
gst_caps_replace_sink (&GST_RPAD_FILTER (realsrc), intersection);
gst_caps_replace_sink (&GST_RPAD_FILTER (realsink), intersection);
gst_caps_sink (intersection);
gst_caps_free (intersection);
return gst_pad_perform_negotiate (GST_PAD (realsrc), GST_PAD (realsink));
}
@ -1672,6 +1789,7 @@ gst_pad_perform_negotiate (GstPad *srcpad, GstPad *sinkpad)
GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink));
filter = GST_RPAD_APPFILTER (realsrc);
if (filter == NULL) filter = gst_caps_new_any ();
if (filter) {
GST_CAT_INFO (GST_CAT_PADS, "dumping filter for link %s:%s-%s:%s",
GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink));
@ -1683,18 +1801,33 @@ gst_pad_perform_negotiate (GstPad *srcpad, GstPad *sinkpad)
GST_CAT_DEBUG (GST_CAT_PADS, "dumping caps of pad %s:%s",
GST_DEBUG_PAD_NAME (realsrc));
gst_caps_debug (srccaps,
"src caps, awaiting negotiation, after applying filter");
"src caps, awaiting negotiation, before applying filter");
sinkcaps = gst_pad_get_caps (GST_PAD (realsink));
GST_CAT_DEBUG (GST_CAT_PADS, "dumping caps of pad %s:%s",
GST_DEBUG_PAD_NAME (realsink));
gst_caps_debug (sinkcaps,
"sink caps, awaiting negotiation, after applying filter");
"sink caps, awaiting negotiation, before applying filter");
intersection = gst_caps_intersect (srccaps, sinkcaps);
gst_caps_debug (intersection, "intersection of srccaps and sinkcaps");
filtered_intersection = gst_caps_intersect (intersection, filter);
gst_caps_unref (intersection);
gst_caps_free (intersection);
gst_caps_debug (filtered_intersection,
"intersection of srccaps, sinkcaps, and filter");
if (!gst_caps_is_fixed (filtered_intersection)) {
GstCaps *newcaps = _gst_pad_try_fixate_caps (realsrc, filtered_intersection);
if (newcaps == NULL) {
gst_caps_free (filtered_intersection);
g_critical("caps are not fixed, refusing");
GST_CAT_INFO (GST_CAT_CAPS, "caps are not fixed, refusing");
return GST_PAD_LINK_REFUSED;
}
filtered_intersection = newcaps;
}
/* no negotiation is performed if the pads have filtercaps */
if (filtered_intersection) {
if (!gst_caps_is_empty(filtered_intersection)) {
GstPadLinkReturn link_res;
link_res = gst_pad_try_set_caps_func (realsrc, filtered_intersection, TRUE);
@ -1716,9 +1849,9 @@ gst_pad_perform_negotiate (GstPad *srcpad, GstPad *sinkpad)
success:
cleanup:
gst_caps_sink (srccaps);
gst_caps_sink (sinkcaps);
gst_caps_unref (filtered_intersection);
gst_caps_free (srccaps);
gst_caps_free (sinkcaps);
gst_caps_free (filtered_intersection);
return res;
error:
@ -1739,7 +1872,7 @@ error:
*/
gboolean
gst_pad_try_relink_filtered (GstPad *srcpad, GstPad *sinkpad,
GstCaps *filtercaps)
const GstCaps *filtercaps)
{
GstRealPad *realsrc, *realsink;
@ -1770,7 +1903,7 @@ gst_pad_try_relink_filtered (GstPad *srcpad, GstPad *sinkpad,
*/
gboolean
gst_pad_relink_filtered (GstPad *srcpad, GstPad *sinkpad,
GstCaps *filtercaps)
const GstCaps *filtercaps)
{
GstRealPad *realsrc, *realsink;
@ -1802,9 +1935,10 @@ gst_pad_relink_filtered (GstPad *srcpad, GstPad *sinkpad,
* Returns: TRUE if the peer pad accepted the caps, FALSE otherwise.
*/
GstPadLinkReturn
gst_pad_proxy_link (GstPad *pad, GstCaps *caps)
gst_pad_proxy_link (GstPad *pad, const GstCaps *caps)
{
GstRealPad *peer, *realpad;
GstCaps *mycaps;
realpad = GST_PAD_REALIZE (pad);
@ -1813,21 +1947,13 @@ gst_pad_proxy_link (GstPad *pad, GstCaps *caps)
GST_CAT_INFO (GST_CAT_CAPS, "proxy link to pad %s:%s",
GST_DEBUG_PAD_NAME (realpad));
if (peer && gst_pad_try_set_caps_func (peer, caps, TRUE) < 0)
mycaps = gst_caps_copy(caps);
if (peer && gst_pad_try_set_caps_func (peer, mycaps, TRUE) < 0)
return GST_PAD_LINK_REFUSED;
if (gst_pad_try_set_caps_func (realpad, caps, FALSE) < 0)
if (gst_pad_try_set_caps_func (realpad, mycaps, FALSE) < 0)
return GST_PAD_LINK_REFUSED;
if (peer) {
gst_caps_debug (caps, "proxy link filter");
GST_CAT_INFO (GST_CAT_CAPS, "setting filter on %s:%s and %s:%s",
GST_DEBUG_PAD_NAME (peer), GST_DEBUG_PAD_NAME (realpad));
gst_caps_replace_sink (&GST_RPAD_FILTER (peer), caps);
gst_caps_replace_sink (&GST_RPAD_FILTER (realpad), caps);
}
return GST_PAD_LINK_OK;
}
@ -1837,9 +1963,8 @@ gst_pad_proxy_link (GstPad *pad, GstCaps *caps)
*
* Gets the capabilities of this pad.
*
* Returns: the #GstCaps of this pad. This function potentially
* returns a floating caps, so use gst_caps_sink to get rid of
* it.
* Returns: the #GstCaps of this pad. This function returns a new caps, so use
* gst_caps_free to get rid of it.
*/
GstCaps*
gst_pad_get_caps (GstPad *pad)
@ -1854,30 +1979,35 @@ gst_pad_get_caps (GstPad *pad)
GST_CAT_DEBUG (GST_CAT_CAPS, "get pad caps of %s:%s (%p)",
GST_DEBUG_PAD_NAME (realpad), realpad);
/* note that we will not _ref the caps here as this function might be
* called recursively */
if (GST_PAD_CAPS (realpad)) {
GST_CAT_DEBUG (GST_CAT_CAPS, "using pad real caps %p", GST_PAD_CAPS (realpad));
return GST_PAD_CAPS (realpad);
}
else if GST_RPAD_GETCAPSFUNC (realpad) {
if (GST_RPAD_GETCAPSFUNC (realpad)) {
GstCaps *caps;
GST_CAT_DEBUG (GST_CAT_CAPS, "using pad get function");
caps = GST_RPAD_GETCAPSFUNC (realpad) (GST_PAD (realpad), NULL);
if(caps)g_return_val_if_fail(caps->refcount > 0, NULL);
caps = GST_RPAD_GETCAPSFUNC (realpad) (GST_PAD (realpad));
if (caps == NULL) {
g_critical ("pad %s:%s returned NULL caps from getcaps function\n",
GST_ELEMENT_NAME(GST_PAD_PARENT(GST_PAD (realpad))),
GST_PAD_NAME(realpad));
caps = gst_caps_new_any ();
}
return caps;
}
else if (GST_PAD_PAD_TEMPLATE (realpad)) {
} else if (GST_PAD_PAD_TEMPLATE (realpad)) {
GstPadTemplate *templ = GST_PAD_PAD_TEMPLATE (realpad);
GST_CAT_DEBUG (GST_CAT_CAPS, "using pad template %p with caps %p",
templ, GST_PAD_TEMPLATE_CAPS (templ));
return GST_PAD_TEMPLATE_CAPS (templ);
return gst_caps_copy (GST_PAD_TEMPLATE_CAPS (templ));
}
GST_CAT_DEBUG (GST_CAT_CAPS, "pad has no caps");
return NULL;
#if 0
/* FIXME this should be enabled some day */
g_warning("pad %s:%s (%p) has no pad template\n",
GST_DEBUG_PAD_NAME (realpad), realpad);
#endif
return gst_caps_new_any();
}
/**
@ -1889,16 +2019,23 @@ gst_pad_get_caps (GstPad *pad)
* Returns: the template #GstCaps of this pad, unref the caps
* if you no longer need it.
*/
GstCaps*
const GstCaps*
gst_pad_get_pad_template_caps (GstPad *pad)
{
static GstStaticCaps anycaps = GST_STATIC_CAPS ("ANY");
g_return_val_if_fail (pad != NULL, NULL);
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
if (GST_PAD_PAD_TEMPLATE (pad))
return gst_caps_ref (GST_PAD_TEMPLATE_CAPS (GST_PAD_PAD_TEMPLATE (pad)));
return GST_PAD_TEMPLATE_CAPS (GST_PAD_PAD_TEMPLATE (pad));
return NULL;
#if 0
/* FIXME this should be enabled some day */
g_warning("pad %s:%s (%p) has no pad template\n",
GST_DEBUG_PAD_NAME (realpad), realpad);
#endif
return gst_static_caps_get(&anycaps);
}
/**
@ -1911,7 +2048,7 @@ gst_pad_get_pad_template_caps (GstPad *pad)
* Returns: the #GstCaps, or NULL if not found or in case of an error. unref
* the caps if you no longer need it.
*/
GstCaps*
const GstCaps*
gst_pad_template_get_caps_by_name (GstPadTemplate *templ, const gchar *name)
{
GstCaps *caps;
@ -1922,7 +2059,9 @@ gst_pad_template_get_caps_by_name (GstPadTemplate *templ, const gchar *name)
if (!caps)
return NULL;
return gst_caps_ref (gst_caps_get_by_name (caps, name));
/* FIXME */
//return gst_caps_copy (gst_caps_get_by_name (caps, name));
return NULL;
}
/**
@ -1985,14 +2124,17 @@ gst_pad_get_peer (GstPad *pad)
* Gets the capabilities of the allowed media types that can
* flow through this pad. The caller must free the resulting caps.
*
* Returns: the allowed #GstCaps of the pad link. unref the caps if
* Returns: the allowed #GstCaps of the pad link. Free the caps when
* you no longer need it.
*/
GstCaps*
gst_pad_get_allowed_caps (GstPad *pad)
{
GstCaps *caps;
GstRealPad *realpad;
GstCaps *mycaps;
GstCaps *caps;
GstCaps *filtercaps;
GstCaps *peercaps;
g_return_val_if_fail (pad != NULL, NULL);
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
@ -2002,39 +2144,29 @@ gst_pad_get_allowed_caps (GstPad *pad)
GST_CAT_DEBUG (GST_CAT_PROPERTIES, "get allowed caps of %s:%s",
GST_DEBUG_PAD_NAME (pad));
caps = gst_caps_ref (GST_RPAD_FILTER (realpad));
mycaps = gst_pad_get_caps (pad);
if (GST_RPAD_PEER (realpad) == NULL) {
return mycaps;
}
return caps;
peercaps = gst_pad_get_caps (GST_PAD_PEER (realpad));
caps = gst_caps_intersect (mycaps, peercaps);
gst_caps_free (mycaps);
gst_caps_free (peercaps);
filtercaps = GST_RPAD_APPFILTER (realpad);
if (filtercaps) {
return gst_caps_intersect (caps, filtercaps);
} else {
return gst_caps_copy (caps);
}
}
/**
* gst_pad_recalc_allowed_caps:
* @pad: a #GstPad to recalculate the capablities of.
*
* Attempts to relink the pad to its peer through its filter,
* set with gst_pad_[re]link_filtered. This function is useful when a
* plug-in has new capabilities on a pad and wants to notify the peer.
*
* Returns: TRUE on success, FALSE otherwise.
*/
gboolean
gst_pad_recalc_allowed_caps (GstPad *pad)
void
gst_pad_caps_change_notify (GstPad *pad)
{
GstRealPad *peer;
g_return_val_if_fail (pad != NULL, FALSE);
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
GST_CAT_DEBUG (GST_CAT_PROPERTIES, "set allowed caps of %s:%s",
GST_DEBUG_PAD_NAME (pad));
peer = GST_RPAD_PEER (pad);
if (peer)
return gst_pad_try_relink_filtered (pad, GST_PAD (peer),
GST_RPAD_APPFILTER (pad));
return TRUE;
/* call this to indicate that the return value of getcaps may have
* changed, and a renegotiation is suggested */
}
/**
@ -2052,7 +2184,7 @@ gst_pad_recalc_allowed_caps (GstPad *pad)
* on the console and returns FALSE otherwise.
*/
gboolean
gst_pad_recover_caps_error (GstPad *pad, GstCaps *allowed)
gst_pad_recover_caps_error (GstPad *pad, const GstCaps *allowed)
{
GstElement *parent;
@ -2082,16 +2214,16 @@ gst_pad_recover_caps_error (GstPad *pad, GstCaps *allowed)
}
/**
* gst_pad_get_bufferpool:
* @pad: a #GstPad to get the bufferpool from.
* gst_pad_alloc_buffer:
* @pad: a #GstPad to get the buffer from.
*
* Gets the bufferpool of the peer pad of the given pad.Note that
* a bufferpool can only be obtained from a srcpad.
* Allocates a new, empty buffer optimized to push to pad #pad. This
* function only works if #pad is a src pad.
*
* Returns: the #GstBufferPool, or NULL in case of an error.
* Returns: a new, empty #GstBuffer, or NULL if there is an error
*/
GstBufferPool*
gst_pad_get_bufferpool (GstPad *pad)
GstBuffer*
gst_pad_alloc_buffer (GstPad *pad, guint64 offset, gint size)
{
GstRealPad *peer;
@ -2104,18 +2236,17 @@ gst_pad_get_bufferpool (GstPad *pad)
if (!peer)
return NULL;
GST_CAT_DEBUG (GST_CAT_BUFFER, "(%s:%s): getting bufferpool", GST_DEBUG_PAD_NAME (pad));
GST_CAT_DEBUG (GST_CAT_BUFFER, "(%s:%s): getting buffer",
GST_DEBUG_PAD_NAME (pad));
if (peer->bufferpoolfunc) {
if (peer->bufferallocfunc) {
GST_CAT_DEBUG (GST_CAT_PADS,
"calling bufferpoolfunc &%s (@%p) of peer pad %s:%s",
GST_DEBUG_FUNCPTR_NAME (peer->bufferpoolfunc),
&peer->bufferpoolfunc, GST_DEBUG_PAD_NAME (((GstPad*) peer)));
return (peer->bufferpoolfunc) (((GstPad*) peer));
"calling bufferallocfunc &%s (@%p) of peer pad %s:%s",
GST_DEBUG_FUNCPTR_NAME (peer->bufferallocfunc),
&peer->bufferallocfunc, GST_DEBUG_PAD_NAME (((GstPad*) peer)));
return (peer->bufferallocfunc) (GST_PAD (peer), offset, size);
} else {
GST_CAT_DEBUG (GST_CAT_PADS, "no bufferpoolfunc for peer pad %s:%s at %p",
GST_DEBUG_PAD_NAME (((GstPad*) peer)), &peer->bufferpoolfunc);
return NULL;
return gst_buffer_new_and_alloc(size);
}
}
@ -2539,8 +2670,8 @@ gst_pad_template_class_init (GstPadTemplateClass *klass)
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__POINTER, G_TYPE_NONE, 1,
G_TYPE_POINTER);
NULL, NULL, gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
GST_TYPE_PAD);
gobject_class->dispose = gst_pad_template_dispose;
@ -2558,7 +2689,9 @@ gst_pad_template_dispose (GObject *object)
GstPadTemplate *templ = GST_PAD_TEMPLATE (object);
g_free (GST_PAD_TEMPLATE_NAME_TEMPLATE (templ));
gst_caps_unref (GST_PAD_TEMPLATE_CAPS (templ));
if (GST_PAD_TEMPLATE_CAPS (templ)) {
gst_caps_free (GST_PAD_TEMPLATE_CAPS (templ));
}
G_OBJECT_CLASS (padtemplate_parent_class)->dispose (object);
}
@ -2605,25 +2738,55 @@ name_is_valid (const gchar *name, GstPadPresence presence)
}
/**
* gst_pad_template_newv:
* @name_template: the name template.
* @direction: the #GstPadDirection of the template.
* @presence: the #GstPadPresence of the pad.
* @caps: a #GstCaps set for the template.
* @var_args: a NULL-terminated list of #GstCaps.
* gst_static_pad_template_get:
* @pad_template: the static pad template
*
* Creates a new pad template with a name according to the given template
* and with the given arguments.
* Converts a GstStaticPadTemplate into a GstPadTemplate.
*
* Returns: a new #GstPadTemplate.
*/
GstPadTemplate*
gst_pad_template_newv (const gchar *name_template,
GstPadDirection direction, GstPadPresence presence,
GstCaps *caps, va_list var_args)
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;
GstCaps *thecaps = NULL;
g_return_val_if_fail (name_template != NULL, NULL);
@ -2637,50 +2800,7 @@ gst_pad_template_newv (const gchar *name_template,
GST_PAD_TEMPLATE_NAME_TEMPLATE (new) = g_strdup (name_template);
GST_PAD_TEMPLATE_DIRECTION (new) = direction;
GST_PAD_TEMPLATE_PRESENCE (new) = presence;
GST_FLAG_SET (GST_OBJECT (new), GST_PAD_TEMPLATE_FIXED);
while (caps) {
if (!GST_CAPS_IS_FIXED (caps)) {
GST_FLAG_UNSET (GST_OBJECT (new), GST_PAD_TEMPLATE_FIXED);
}
thecaps = gst_caps_append (thecaps, caps);
caps = va_arg (var_args, GstCaps*);
}
GST_PAD_TEMPLATE_CAPS (new) = thecaps;
gst_caps_ref (thecaps);
gst_caps_sink (thecaps);
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.
* @...: a NULL-terminated list of #GstCaps.
*
* Creates a new pad template with a name according to the given template
* and with the given arguments.
*
* Returns: a new #GstPadTemplate.
*/
GstPadTemplate*
gst_pad_template_new (const gchar *name_template,
GstPadDirection direction, GstPadPresence presence,
GstCaps *caps, ...)
{
GstPadTemplate *new;
va_list var_args;
va_start (var_args, caps);
new = gst_pad_template_newv (name_template, direction, presence,
caps, var_args);
va_end (var_args);
GST_PAD_TEMPLATE_CAPS (new) = caps;
return new;
}
@ -2694,12 +2814,12 @@ gst_pad_template_new (const gchar *name_template,
* Returns: the #GstCaps of the pad template. unref the caps
* after use.
*/
GstCaps*
const GstCaps*
gst_pad_template_get_caps (GstPadTemplate *templ)
{
g_return_val_if_fail (templ != NULL, NULL);
return gst_caps_ref (GST_PAD_TEMPLATE_CAPS (templ));
return GST_PAD_TEMPLATE_CAPS (templ);
}
/**

View file

@ -28,7 +28,7 @@
#include <gst/gstobject.h>
#include <gst/gstbuffer.h>
#include <gst/gstcaps.h>
#include <gst/gstcaps2.h>
#include <gst/gstevent.h>
#include <gst/gstprobe.h>
#include <gst/gstquery.h>
@ -80,6 +80,7 @@ typedef struct _GstGhostPad GstGhostPad;
typedef struct _GstGhostPadClass GstGhostPadClass;
/*typedef struct _GstPadTemplate GstPadTemplate;*/
/*typedef struct _GstPadTemplateClass GstPadTemplateClass;*/
typedef struct _GstStaticPadTemplate GstStaticPadTemplate;
typedef enum {
@ -117,10 +118,11 @@ typedef const GstFormat* (*GstPadFormatsFunction) (GstPad *pad);
typedef const GstEventMask* (*GstPadEventMaskFunction) (GstPad *pad);
typedef const GstQueryType* (*GstPadQueryTypeFunction) (GstPad *pad);
typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, GstCaps *caps);
typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, const GstCaps *caps);
typedef void (*GstPadUnlinkFunction) (GstPad *pad);
typedef GstCaps* (*GstPadGetCapsFunction) (GstPad *pad, GstCaps *caps);
typedef GstBufferPool* (*GstPadBufferPoolFunction) (GstPad *pad);
typedef GstCaps* (*GstPadGetCapsFunction) (GstPad *pad);
typedef GstCaps* (*GstPadFixateFunction) (GstPad *pad, const GstCaps *caps, gpointer user_data);
typedef GstBuffer* (*GstPadBufferAllocFunction) (GstPad *pad, guint64 offset, guint size);
typedef gboolean (*GstPadDispatcherFunction) (GstPad *pad, gpointer data);
@ -158,9 +160,10 @@ struct _GstRealPad {
/* the pad capabilities */
GstCaps *caps;
GstCaps *filter;
GstPadFixateFunction appfixatefunc;
GstCaps *appfilter;
GstPadGetCapsFunction getcapsfunc;
GstPadFixateFunction fixatefunc;
GstPadDirection direction;
@ -188,7 +191,7 @@ struct _GstRealPad {
GstPadQueryTypeFunction querytypefunc;
GstPadIntLinkFunction intlinkfunc;
GstPadBufferPoolFunction bufferpoolfunc;
GstPadBufferAllocFunction bufferallocfunc;
GstProbeDispatcher probedisp;
@ -232,7 +235,6 @@ struct _GstGhostPadClass {
/* GstRealPad */
#define GST_RPAD_DIRECTION(pad) (((GstRealPad *)(pad))->direction)
#define GST_RPAD_CAPS(pad) (((GstRealPad *)(pad))->caps)
#define GST_RPAD_FILTER(pad) (((GstRealPad *)(pad))->filter)
#define GST_RPAD_APPFILTER(pad) (((GstRealPad *)(pad))->appfilter)
#define GST_RPAD_PEER(pad) (((GstRealPad *)(pad))->peer)
#define GST_RPAD_CHAINFUNC(pad) (((GstRealPad *)(pad))->chainfunc)
@ -251,7 +253,8 @@ struct _GstGhostPadClass {
#define GST_RPAD_LINKFUNC(pad) (((GstRealPad *)(pad))->linkfunc)
#define GST_RPAD_UNLINKFUNC(pad) (((GstRealPad *)(pad))->unlinkfunc)
#define GST_RPAD_GETCAPSFUNC(pad) (((GstRealPad *)(pad))->getcapsfunc)
#define GST_RPAD_BUFFERPOOLFUNC(pad) (((GstRealPad *)(pad))->bufferpoolfunc)
#define GST_RPAD_FIXATEFUNC(pad) (((GstRealPad *)(pad))->fixatefunc)
#define GST_RPAD_BUFFERALLOCFUNC(pad) (((GstRealPad *)(pad))->bufferallocfunc)
/* GstGhostPad */
#define GST_GPAD_REALPAD(pad) (((GstGhostPad *)(pad))->realpad)
@ -317,56 +320,21 @@ struct _GstPadTemplateClass {
gpointer _gst_reserved[GST_PADDING];
};
#ifdef G_HAVE_ISO_VARARGS
#define GST_PAD_TEMPLATE_NEW(padname, dir, pres, ...) \
gst_pad_template_new ( \
padname, \
dir, \
pres, \
__VA_ARGS__ , \
NULL)
struct _GstStaticPadTemplate {
gchar *name_template;
GstPadDirection direction;
GstPadPresence presence;
GstStaticCaps static_caps;
};
#define GST_PAD_TEMPLATE_FACTORY(name, padname, dir, pres, ...) \
static GstPadTemplate* \
name (void) \
{ \
static GstPadTemplate *templ = NULL; \
if (!templ) { \
templ = GST_PAD_TEMPLATE_NEW ( \
padname, \
dir, \
pres, \
__VA_ARGS__ ); \
} \
return (GstPadTemplate *)g_object_ref((GObject *)templ); \
}
#elif defined(G_HAVE_GNUC_VARARGS)
/* CR1: the space after 'a' is necessary because of preprocessing in gcc */
#define GST_PAD_TEMPLATE_NEW(padname, dir, pres, a...) \
gst_pad_template_new ( \
padname, \
dir, \
pres, \
a , \
NULL)
#define GST_STATIC_PAD_TEMPLATE(padname, dir, pres, caps) \
{ \
/* name_template */ padname, \
/* direction */ dir, \
/* presence */ pres, \
/* caps */ caps \
}
#define GST_PAD_TEMPLATE_FACTORY(name, padname, dir, pres, a...) \
static GstPadTemplate* \
name (void) \
{ \
static GstPadTemplate *templ = NULL; \
if (!templ) { \
templ = GST_PAD_TEMPLATE_NEW ( \
padname, \
dir, \
pres, \
a ); \
} \
return (GstPadTemplate *)g_object_ref((GObject *)templ); \
}
#endif
#define GST_PAD_TEMPLATE_GET(fact) (fact)()
GType gst_pad_get_type (void);
GType gst_real_pad_get_type (void);
@ -401,8 +369,8 @@ GList* gst_pad_get_ghost_pad_list (GstPad *pad);
GstPadTemplate* gst_pad_get_pad_template (GstPad *pad);
void gst_pad_set_bufferpool_function (GstPad *pad, GstPadBufferPoolFunction bufpool);
GstBufferPool* gst_pad_get_bufferpool (GstPad *pad);
void gst_pad_set_bufferalloc_function (GstPad *pad, GstPadBufferAllocFunction bufferalloc);
GstBuffer* gst_pad_alloc_buffer (GstPad *pad, guint64 offset, gint size);
/* data passing setup functions */
void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain);
@ -417,30 +385,31 @@ G_CONST_RETURN GstEventMask*
/* pad links */
void gst_pad_set_link_function (GstPad *pad, GstPadLinkFunction link);
gboolean gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad);
gboolean gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps);
gboolean gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps);
void gst_pad_set_unlink_function (GstPad *pad, GstPadUnlinkFunction unlink);
gboolean gst_pad_link (GstPad *srcpad, GstPad *sinkpad);
gboolean gst_pad_link_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps);
gboolean gst_pad_link_filtered (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps);
void gst_pad_unlink (GstPad *srcpad, GstPad *sinkpad);
GstPad* gst_pad_get_peer (GstPad *pad);
/* capsnego functions */
GstCaps* gst_pad_get_caps (GstPad *pad);
GstCaps* gst_pad_get_pad_template_caps (GstPad *pad);
GstPadLinkReturn gst_pad_try_set_caps (GstPad *pad, GstCaps *caps);
const GstCaps* gst_pad_get_pad_template_caps (GstPad *pad);
GstPadLinkReturn gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps);
gboolean gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad);
void gst_pad_set_getcaps_function (GstPad *pad, GstPadGetCapsFunction getcaps);
GstPadLinkReturn gst_pad_proxy_link (GstPad *pad, GstCaps *caps);
gboolean gst_pad_relink_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps);
void gst_pad_set_fixate_function (GstPad *pad, GstPadFixateFunction fixate);
GstPadLinkReturn gst_pad_proxy_link (GstPad *pad, const GstCaps *caps);
gboolean gst_pad_relink_filtered (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps);
gboolean gst_pad_perform_negotiate (GstPad *srcpad, GstPad *sinkpad);
gboolean gst_pad_try_relink_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps);
gboolean gst_pad_try_relink_filtered (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps);
GstCaps* gst_pad_get_allowed_caps (GstPad *pad);
gboolean gst_pad_recalc_allowed_caps (GstPad *pad);
void gst_pad_caps_change_notify (GstPad *pad);
gboolean gst_pad_recover_caps_error (GstPad *pad, GstCaps *allowed);
gboolean gst_pad_recover_caps_error (GstPad *pad, const GstCaps *allowed);
/* data passing functions */
void gst_pad_push (GstPad *pad, GstData *data);
@ -506,14 +475,11 @@ GType gst_pad_template_get_type (void);
GstPadTemplate* gst_pad_template_new (const gchar *name_template,
GstPadDirection direction, GstPadPresence presence,
GstCaps *caps, ...);
GstCaps *caps);
GstPadTemplate* gst_pad_template_newv (const gchar *name_template,
GstPadDirection direction, GstPadPresence presence,
GstCaps *caps, va_list var_args);
GstCaps* gst_pad_template_get_caps (GstPadTemplate *templ);
GstCaps* gst_pad_template_get_caps_by_name (GstPadTemplate *templ, const gchar *name);
GstPadTemplate * gst_static_pad_template_get (GstStaticPadTemplate *templ);
const GstCaps* gst_pad_template_get_caps (GstPadTemplate *templ);
const GstCaps* gst_pad_template_get_caps_by_name (GstPadTemplate *templ, const gchar *name);
#ifndef GST_DISABLE_LOADSAVE
xmlNodePtr gst_ghost_pad_save_thyself (GstPad *pad,

View file

@ -80,8 +80,7 @@ struct _GstPlugin {
gpointer _gst_reserved[GST_PADDING];
};
#ifndef GST_PLUGIN_STATIC
#define GST_PLUGIN_DEFINE_DYNAMIC(major,minor,name,description,init,version,license,package,origin) \
#define GST_PLUGIN_DEFINE(major,minor,name,description,init,version,license,package,origin) \
GstPluginDesc gst_plugin_desc = { \
major, \
minor, \
@ -95,9 +94,7 @@ GstPluginDesc gst_plugin_desc = { \
origin, \
GST_PADDING_INIT \
};
#define GST_PLUGIN_DEFINE_STATIC(major,minor,name,description,init,version,license,package,origin)
#else
#define GST_PLUGIN_DEFINE_DYNAMIC(major,minor,name,description,init,version,license,package,origin)
#define GST_PLUGIN_DEFINE_STATIC(major,minor,name,description,init,version,license,package,origin) \
static void GST_GNUC_CONSTRUCTOR \
_gst_plugin_static_init__ ##init (void) \
@ -117,11 +114,6 @@ _gst_plugin_static_init__ ##init (void) \
}; \
_gst_plugin_register_static (&plugin_desc_); \
}
#endif
#define GST_PLUGIN_DEFINE(major,minor,name,description,init,version,license,package,origin)\
GST_PLUGIN_DEFINE_STATIC(major,minor,name,description,init,version,license,package,origin)\
GST_PLUGIN_DEFINE_DYNAMIC(major,minor,name,description,init,version,license,package,origin)
#define GST_LICENSE_UNKNOWN "unknown"

File diff suppressed because it is too large Load diff

View file

@ -1,203 +0,0 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
* gstprops.h: Header for properties subsystem
*
* 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_PROPS_H__
#define __GST_PROPS_H__
#include <gst/gstconfig.h>
#include <glib-object.h>
G_BEGIN_DECLS
typedef struct _GstProps GstProps;
extern GType _gst_props_type;
#define GST_PROPS_TRACE_NAME "GstProps"
#define GST_TYPE_PROPS (_gst_props_type)
typedef enum {
GST_PROPS_END_TYPE = 0,
GST_PROPS_INVALID_TYPE,
GST_PROPS_INT_TYPE,
GST_PROPS_FLOAT_TYPE,
GST_PROPS_FOURCC_TYPE,
GST_PROPS_BOOLEAN_TYPE,
GST_PROPS_STRING_TYPE,
GST_PROPS_VAR_TYPE, /* after this marker start the variable properties */
GST_PROPS_LIST_TYPE,
GST_PROPS_GLIST_TYPE,
GST_PROPS_FLOAT_RANGE_TYPE,
GST_PROPS_INT_RANGE_TYPE,
GST_PROPS_LAST_TYPE = GST_PROPS_END_TYPE + 16
} GstPropsType;
#define GST_MAKE_FOURCC(a,b,c,d) (guint32)((a)|(b)<<8|(c)<<16|(d)<<24)
#define GST_STR_FOURCC(f) (guint32)(((f)[0])|((f)[1]<<8)|((f)[2]<<16)|((f)[3]<<24))
#define GST_FOURCC_FORMAT "%c%c%c%c"
#define GST_FOURCC_ARGS(fourcc) \
((gchar) ((fourcc) &0xff)), \
((gchar) (((fourcc)>>8 )&0xff)), \
((gchar) (((fourcc)>>16)&0xff)), \
((gchar) (((fourcc)>>24)&0xff))
#ifdef G_HAVE_ISO_VARARGS
# define GST_PROPS_LIST(...) GST_PROPS_LIST_TYPE,__VA_ARGS__,GST_PROPS_END_TYPE
#elif defined(G_HAVE_GNUC_VARARGS)
# define GST_PROPS_LIST(a...) GST_PROPS_LIST_TYPE,a,GST_PROPS_END_TYPE
#endif
#define GST_PROPS_GLIST(a) GST_PROPS_GLIST_TYPE,(a)
#define GST_PROPS_INT(a) GST_PROPS_INT_TYPE,(a)
#define GST_PROPS_INT_RANGE(a,b) GST_PROPS_INT_RANGE_TYPE,(a),(b)
#define GST_PROPS_FLOAT(a) GST_PROPS_FLOAT_TYPE,((float)(a))
#define GST_PROPS_FLOAT_RANGE(a,b) GST_PROPS_FLOAT_RANGE_TYPE,((float)(a)),((float)(b))
#define GST_PROPS_FOURCC(a) GST_PROPS_FOURCC_TYPE,(a)
#define GST_PROPS_BOOLEAN(a) GST_PROPS_BOOLEAN_TYPE,(a)
#define GST_PROPS_STRING(a) GST_PROPS_STRING_TYPE,(a)
#define GST_PROPS_INT_POSITIVE GST_PROPS_INT_RANGE(0,G_MAXINT)
#define GST_PROPS_INT_NEGATIVE GST_PROPS_INT_RANGE(G_MININT,0)
#define GST_PROPS_INT_ANY GST_PROPS_INT_RANGE(G_MININT,G_MAXINT)
/* propsentries are private */
typedef struct _GstPropsEntry GstPropsEntry;
extern GType _gst_props_entry_type;
#define GST_PROPS_ENTRY_TRACE_NAME "GstPropsEntry"
#define GST_TYPE_PROPS_ENTRY (_gst_props_entry_type)
typedef enum {
GST_PROPS_FIXED = (1 << 0), /* props has no variable entries */
GST_PROPS_FLOATING = (1 << 1) /* props is floating */
} GstPropsFlags;
#define GST_PROPS_FLAGS(props) ((props)->flags)
#define GST_PROPS_FLAG_IS_SET(props,flag) (GST_PROPS_FLAGS (props) & (flag))
#define GST_PROPS_FLAG_SET(props,flag) (GST_PROPS_FLAGS (props) |= (flag))
#define GST_PROPS_FLAG_UNSET(props,flag) (GST_PROPS_FLAGS (props) &= ~(flag))
#define GST_PROPS_REFCOUNT(props) ((props)->refcount)
#define GST_PROPS_PROPERTIES(props) ((props) ? ((props)->properties) : NULL)
#define GST_PROPS_IS_FIXED(props) (GST_PROPS_FLAG_IS_SET ((props), GST_PROPS_FIXED))
#define GST_PROPS_IS_FLOATING(props) (GST_PROPS_FLAG_IS_SET ((props), GST_PROPS_FLOATING))
struct _GstProps {
gint refcount;
gint flags;
GList *properties; /* real property entries for this property */
};
/* initialize the subsystem */
void _gst_props_initialize (void);
/* creating new properties */
GType gst_props_get_type (void);
GstProps* gst_props_new (const gchar *firstname, ...);
GstProps* gst_props_newv (const gchar *firstname, va_list var_args);
GstProps* gst_props_empty_new (void);
/* replace pointer to props, doing proper refcounting */
void gst_props_replace (GstProps **oldprops, GstProps *newprops);
void gst_props_replace_sink (GstProps **oldprops, GstProps *newprops);
/* lifecycle management */
GstProps* gst_props_unref (GstProps *props);
GstProps* gst_props_ref (GstProps *props);
void gst_props_sink (GstProps *props);
/* dump property debug info to the log */
void gst_props_debug (GstProps *props);
/* copy */
GstProps* gst_props_copy (GstProps *props);
GstProps* gst_props_copy_on_write (GstProps *props);
/* check if fromprops is subset of toprops */
gboolean gst_props_check_compatibility (GstProps *fromprops, GstProps *toprops);
/* operation on props */
GstProps* gst_props_merge (GstProps *props, GstProps *tomerge);
GstProps* gst_props_intersect (GstProps *props1, GstProps *props2);
GList* gst_props_normalize (GstProps *props);
/* modify entries */
GstProps* gst_props_set (GstProps *props, const gchar *name, ...);
gboolean gst_props_get (GstProps *props, gchar *first_name, ...);
gboolean gst_props_get_safe (GstProps *props, gchar *first_name, ...);
/* query entries */
gboolean gst_props_has_property (GstProps *props, const gchar *name);
gboolean gst_props_has_property_typed (GstProps *props, const gchar *name, GstPropsType type);
gboolean gst_props_has_fixed_property (GstProps *props, const gchar *name);
/* add/get entries */
const GstPropsEntry* gst_props_get_entry (GstProps *props, const gchar *name);
void gst_props_add_entry (GstProps *props, GstPropsEntry *entry);
void gst_props_remove_entry (GstProps *props, GstPropsEntry *entry);
void gst_props_remove_entry_by_name (GstProps *props, const gchar *name);
/* working with props entries */
GType gst_props_entry_get_type (void);
GstPropsEntry* gst_props_entry_new (const gchar *name, ...);
void gst_props_entry_destroy (GstPropsEntry *entry);
GstPropsEntry* gst_props_entry_copy (const GstPropsEntry *entry);
GstPropsType gst_props_entry_get_props_type (const GstPropsEntry *entry);
const gchar* gst_props_entry_get_name (const GstPropsEntry *entry);
gboolean gst_props_entry_is_fixed (const GstPropsEntry *entry);
gboolean gst_props_entry_get (const GstPropsEntry *entry, ...);
gboolean gst_props_entry_get_int (const GstPropsEntry *entry, gint *val);
gboolean gst_props_entry_get_float (const GstPropsEntry *entry, gfloat *val);
gboolean gst_props_entry_get_fourcc_int (const GstPropsEntry *entry, guint32 *val);
gboolean gst_props_entry_get_boolean (const GstPropsEntry *entry, gboolean *val);
gboolean gst_props_entry_get_string (const GstPropsEntry *entry, const gchar **val);
gboolean gst_props_entry_get_int_range (const GstPropsEntry *entry, gint *min, gint *max);
gboolean gst_props_entry_get_float_range (const GstPropsEntry *entry, gfloat *min, gfloat *max);
gboolean gst_props_entry_get_list (const GstPropsEntry *entry, const GList **val);
/* for debugging purposes */
gchar * gst_props_to_string (GstProps *props);
GstProps * gst_props_from_string (gchar *str);
#ifndef GST_DISABLE_LOADSAVE
xmlNodePtr gst_props_save_thyself (GstProps *props, xmlNodePtr parent);
GstProps* gst_props_load_thyself (xmlNodePtr parent);
#endif
G_END_DECLS
#endif /* __GST_PROPS_H__ */

View file

@ -83,16 +83,13 @@ static void gst_queue_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static GstCaps *gst_queue_getcaps (GstPad *pad,
GstCaps *caps);
static GstCaps *gst_queue_getcaps (GstPad *pad);
static GstPadLinkReturn
gst_queue_link (GstPad *pad,
GstCaps *caps);
const GstCaps *caps);
static void gst_queue_chain (GstPad *pad,
GstData *data);
static GstData *gst_queue_get (GstPad *pad);
static GstBufferPool *
gst_queue_get_bufferpool (GstPad *pad);
static gboolean gst_queue_handle_src_event (GstPad *pad,
GstEvent *event);
@ -254,7 +251,6 @@ gst_queue_init (GstQueue *queue)
queue->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_pad_set_chain_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_chain));
gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
gst_pad_set_bufferpool_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_get_bufferpool));
gst_pad_set_link_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_link));
gst_pad_set_getcaps_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_getcaps));
gst_pad_set_active (queue->sinkpad, TRUE);
@ -334,28 +330,20 @@ gst_queue_otherpad (GstPad *pad)
}
static GstPadLinkReturn
gst_queue_link (GstPad *pad,
GstCaps *caps)
gst_queue_link (GstPad *pad, const GstCaps *caps)
{
return gst_pad_proxy_link (gst_queue_otherpad (pad), caps);
}
static GstCaps *
gst_queue_getcaps (GstPad *pad,
GstCaps *caps)
gst_queue_getcaps (GstPad *pad)
{
GstPad *otherpad = GST_PAD_PEER (gst_queue_otherpad (pad));
if (otherpad)
return gst_pad_get_caps (otherpad);
return NULL;
}
static GstBufferPool *
gst_queue_get_bufferpool (GstPad *pad)
{
return gst_pad_get_bufferpool (gst_queue_otherpad (pad));
return gst_caps_new_any ();
}
static void

View file

@ -28,10 +28,24 @@
#include <gst/gst.h>
#include <gobject/gvaluecollector.h>
//#define G_TYPE_FOURCC G_TYPE_FLOAT
static GType _gst_structure_type;
typedef struct _GstStructureField GstStructureField;
struct _GstStructureField {
GQuark name;
GValue value;
};
#define GST_STRUCTURE_FIELD(structure, index) \
&g_array_index((structure)->fields, GstStructureField, (index))
static void gst_structure_set_field (GstStructure *structure,
GstStructureField *field);
static GstStructureField *gst_structure_get_field(const GstStructure *structure,
const gchar *fieldname);
static GstStructureField *gst_structure_id_get_field(const GstStructure *structure,
GQuark fieldname);
static void _gst_structure_transform_to_string(const GValue *src_value,
GValue *dest_value);
@ -238,6 +252,9 @@ void gst_structure_free(GstStructure *structure)
g_value_unset(&field->value);
}
}
#ifdef USE_POISONING
memset (structure, 0xff, sizeof(GstStructure));
#endif
g_free(structure);
}
@ -249,7 +266,7 @@ void gst_structure_free(GstStructure *structure)
*
* Returns: the name of the structure.
*/
const gchar *gst_structure_get_name(GstStructure *structure)
const gchar *gst_structure_get_name(const GstStructure *structure)
{
g_return_val_if_fail(structure != NULL, NULL);
@ -341,7 +358,7 @@ void gst_structure_set(GstStructure *structure, const gchar *field, ...)
}
/**
* gst_structure_set:
* gst_structure_set_valist:
* @structure: a #GstStructure
* @field: the name of the field to set
* @varargs: variable arguments
@ -391,9 +408,21 @@ void gst_structure_set_valist(GstStructure *structure, const gchar *fieldname,
i = va_arg(varargs, int);
g_value_init(&field.value, GST_TYPE_FOURCC);
gst_value_set_fourcc(&field.value, i);
break;
}else{
} else if (type == GST_TYPE_INT_RANGE){
int min, max;
min = va_arg(varargs, int);
max = va_arg(varargs, int);
g_value_init(&field.value, GST_TYPE_INT_RANGE);
gst_value_set_int_range(&field.value, min, max);
} else if (type == GST_TYPE_DOUBLE_RANGE){
double min, max;
min = va_arg(varargs, double);
max = va_arg(varargs, double);
g_value_init(&field.value, GST_TYPE_DOUBLE_RANGE);
gst_value_set_double_range(&field.value, min, max);
} else {
g_critical("unimplemented vararg field type %d\n", (int)type);
return;
}
break;
}
@ -404,32 +433,6 @@ void gst_structure_set_valist(GstStructure *structure, const gchar *fieldname,
}
}
/**
* gst_structure_set_field_copy:
* @structure: a #GstStructure
* @field: the #GstStructureField to set
*
* Sets a field in the structure. If the structure currently contains
* a field with the same name, it is replaced with the provided field.
* Otherwise, the field is added to the structure. The field's value
* is deeply copied.
*
* This function is intended mainly for internal use. The function
* #gst_structure_set() is recommended instead of this one.
*/
void gst_structure_set_field_copy (GstStructure *structure,
const GstStructureField *field)
{
GstStructureField f = { 0 };
GType type = G_VALUE_TYPE (&field->value);
f.name = field->name;
g_value_init (&f.value, type);
g_value_copy (&field->value, &f.value);
gst_structure_set_field (structure, &f);
}
/**
* gst_structure_set_field:
* @structure: a #GstStructure
@ -443,7 +446,7 @@ void gst_structure_set_field_copy (GstStructure *structure,
* This function is intended mainly for internal use. The function
* #gst_structure_set() is recommended instead of this one.
*/
void gst_structure_set_field(GstStructure *structure, GstStructureField *field)
static void gst_structure_set_field(GstStructure *structure, GstStructureField *field)
{
GstStructureField *f;
int i;
@ -471,7 +474,7 @@ void gst_structure_set_field(GstStructure *structure, GstStructureField *field)
*
* Returns: the #GstStructureField with the given ID
*/
GstStructureField *gst_structure_id_get_field(const GstStructure *structure,
static GstStructureField *gst_structure_id_get_field(const GstStructure *structure,
GQuark field_id)
{
GstStructureField *field;
@ -498,7 +501,7 @@ GstStructureField *gst_structure_id_get_field(const GstStructure *structure,
*
* Returns: the #GstStructureField with the given name
*/
GstStructureField *
static GstStructureField *
gst_structure_get_field(const GstStructure *structure, const gchar *fieldname)
{
g_return_val_if_fail(structure != NULL, NULL);
@ -531,6 +534,29 @@ gst_structure_get_value(const GstStructure *structure, const gchar *fieldname)
return &field->value;
}
/**
* gst_structure_id_get_value:
* @structure: a #GstStructure
* @id: the #GQuark of the field to get
*
* Accessor function.
*
* Returns: the #GValue corresponding to the field with the given name
* identifier.
*/
const GValue *
gst_structure_id_get_value(const GstStructure *structure, GQuark id)
{
GstStructureField *field;
g_return_val_if_fail(structure != NULL, NULL);
field = gst_structure_id_get_field(structure, id);
if(field == NULL) return NULL;
return &field->value;
}
#if 0
void gst_structure_get(GstStructure *structure, const gchar *fieldname, ...)
{
@ -637,25 +663,29 @@ gst_structure_n_fields(const GstStructure *structure)
}
/**
* gst_structure_field_foreach:
* gst_structure_foreach:
* @structure: a #GstStructure
* @func: a function to call for each field
* @user_data: private data
*
* Calls the provided function once for each field in the #GstStructure.
*/
void
gst_structure_field_foreach (GstStructure *structure,
gboolean
gst_structure_foreach (GstStructure *structure,
GstStructureForeachFunc func, gpointer user_data)
{
int i;
GstStructureField *field;
gboolean ret;
for(i=0;i<structure->fields->len;i++){
field = GST_STRUCTURE_FIELD(structure, i);
func (structure, field->name, &field->value, user_data);
ret = func (field->name, &field->value, user_data);
if (!ret) return FALSE;
}
return TRUE;
}
/**
@ -796,9 +826,9 @@ gst_structure_get_fourcc(const GstStructure *structure, const gchar *fieldname,
field = gst_structure_get_field(structure, fieldname);
if(field == NULL) return FALSE;
if(!G_VALUE_HOLDS_UINT(&field->value))return FALSE;
if(!GST_VALUE_HOLDS_FOURCC(&field->value))return FALSE;
*value = g_value_get_uint(&field->value);
*value = gst_value_get_fourcc (&field->value);
return TRUE;
}
@ -926,6 +956,59 @@ static const char *_gst_structure_to_abbr(GType type)
return g_type_name(type);
}
#define GST_ASCII_IS_STRING(c) (g_ascii_isalnum((c)) || ((c) == '_') || \
((c) == '-') || ((c) == '+') || ((c) == '/') || ((c) == ':') || \
((c) == '.'))
static gchar *
_gst_structure_wrap_string(gchar *s)
{
gchar *t;
int len;
gchar *d, *e;
gboolean wrap = FALSE;
len = 0;
t = s;
while (*t) {
if(GST_ASCII_IS_STRING(*t)) {
len++;
} else if(*t < 0x20 || *t >= 0x7f) {
wrap = TRUE;
len += 4;
} else {
wrap = TRUE;
len += 2;
}
t++;
}
if (!wrap) return s;
e = d = g_malloc(len + 3);
*e++ = '\"';
t = s;
while (*t) {
if(GST_ASCII_IS_STRING(*t)) {
*e++ = *t++;
} else if(*t < 0x20 || *t >= 0x7f) {
*e++ = '\\';
*e++ = '0' + ((*t)>>6);
*e++ = '0' + (((*t)>>3)&0x7);
*e++ = '0' + ((*t++)&0x7);
} else {
*e++ = '\\';
*e++ = *t++;
}
}
*e++ = '\"';
*e = 0;
g_free(s);
return d;
}
/**
* gst_structure_to_string:
* @structure: a #GstStructure
@ -939,13 +1022,15 @@ gst_structure_to_string(const GstStructure *structure)
{
GstStructureField *field;
GString *s;
char *t;
int i;
g_return_val_if_fail(structure != NULL, NULL);
s = g_string_new("");
g_string_append_printf(s, "\"%s\"", g_quark_to_string(structure->name));
for(i=0;i<structure->fields->len;i++){
/* FIXME this string may need to be escaped */
g_string_append_printf(s, "%s", g_quark_to_string(structure->name));
for(i=0;i<structure->fields->len;i++) {
GValue s_val = { 0 };
GType type;
@ -957,21 +1042,28 @@ gst_structure_to_string(const GstStructure *structure)
type = G_VALUE_TYPE (&field->value);
if (type == GST_TYPE_LIST) {
GPtrArray *ptr_array = g_value_peek_pointer (&field->value);
if (ptr_array->len > 0){
GValue *value = g_ptr_array_index (ptr_array, 0);
GArray *array = g_value_peek_pointer (&field->value);
if (array->len > 0){
GValue *value = &g_array_index (array, GValue, 0);
type = G_VALUE_TYPE (value);
} else {
type = G_TYPE_INT;
}
t = g_strdup(g_value_get_string(&s_val));
} else if (G_VALUE_TYPE(&field->value) == GST_TYPE_INT_RANGE) {
type = G_TYPE_INT;
t = g_strdup(g_value_get_string(&s_val));
} else if (G_VALUE_TYPE(&field->value) == GST_TYPE_DOUBLE_RANGE) {
type = G_TYPE_DOUBLE;
t = g_strdup(g_value_get_string(&s_val));
} else {
t = _gst_structure_wrap_string(g_strdup(g_value_get_string(&s_val)));
}
g_string_append_printf(s, ", %s:%s=%s", g_quark_to_string(field->name),
_gst_structure_to_abbr(type), g_value_get_string(&s_val));
g_string_append_printf(s, ", %s=(%s)%s", g_quark_to_string(field->name),
_gst_structure_to_abbr(type), t);
g_free(t);
g_value_unset (&s_val);
}
return g_string_free(s, FALSE);
@ -984,96 +1076,88 @@ gst_structure_to_string(const GstStructure *structure)
* unread data.
* THIS FUNCTION MODIFIES THE STRING AND DETECTS INSIDE A NONTERMINATED STRING
*/
static gboolean _gst_structure_parse_simple_string (gchar *s, gchar **end);
static gboolean
_gst_structure_parse_string (gchar *r, gchar **end, gchar **next)
_gst_structure_parse_string (gchar *s, gchar **end, gchar **next)
{
gchar *w;
gchar c = '\0';
w = r;
if (*r == '\'' || *r == '\"') {
c = *r;
r++;
if (*s == 0) return FALSE;
if (*s != '"') {
int ret;
ret = _gst_structure_parse_simple_string (s, end);
*next = *end;
return ret;
}
for (;;r++) {
if (*r == '\0') {
if (c) {
goto error;
} else {
goto found;
}
w = s;
s++;
while (*s != '"') {
if (*s == 0) return FALSE;
if (*s == '\\') {
s++;
}
if (*r == '\\') {
r++;
if (*r == '\0')
goto error;
*w++ = *r;
continue;
*w = *s;
w++;
s++;
}
s++;
if (*r == c) {
r++;
if (*r == '\0')
goto found;
break;
}
if (!c) {
if (g_ascii_isspace (*r))
break;
/* this needs to be escaped */
if (*r == ',' || *r == ')' || *r == ']' || *r == ':' ||
*r == ';' || *r == '(' || *r == '[')
break;
}
*w++ = *r;
}
found:
while (g_ascii_isspace (*r)) r++;
if (w != r)
*w++ = '\0';
*end = w;
*next = r;
return TRUE;
*next = s;
error:
return FALSE;
return TRUE;
}
static gboolean
_gst_structure_parse_value (gchar *s, gchar **after, GType type,
GValue *value)
gst_value_from_string (GValue *value, const char *s)
{
gboolean ret = FALSE;
gchar *val;
gchar *end;
GType type = G_VALUE_TYPE (value);
if (type == G_TYPE_INVALID) return FALSE;
while (g_ascii_isspace (*s)) s++;
g_value_init(value, type);
val = s;
switch (type) {
case G_TYPE_INT:
{
int x;
x = strtol (val, &s, 0);
if (val != s) {
g_value_set_int (value, x);
x = strtol (s, &end, 0);
if (*end == 0) {
ret = TRUE;
} else {
if (g_ascii_strcasecmp (s, "little_endian") == 0) {
x = G_LITTLE_ENDIAN;
ret = TRUE;
} else if (g_ascii_strcasecmp (s, "big_endian") == 0) {
x = G_BIG_ENDIAN;
ret = TRUE;
} else if (g_ascii_strcasecmp (s, "byte_order") == 0) {
x = G_BYTE_ORDER;
ret = TRUE;
} else if (g_ascii_strcasecmp (s, "min") == 0) {
x = G_MININT;
ret = TRUE;
} else if (g_ascii_strcasecmp (s, "max") == 0) {
x = G_MAXINT;
ret = TRUE;
}
}
if (ret) {
g_value_set_int (value, x);
}
}
break;
case G_TYPE_FLOAT:
{
double x;
x = g_ascii_strtod (val, &s);
if (val != s) {
x = g_ascii_strtod (s, &end);
if (*end == 0) {
g_value_set_float (value, x);
ret = TRUE;
}
@ -1082,60 +1166,56 @@ _gst_structure_parse_value (gchar *s, gchar **after, GType type,
case G_TYPE_DOUBLE:
{
double x;
x = g_ascii_strtod (val, &s);
if (val != s) {
g_value_set_double (value, x);
x = g_ascii_strtod (s, &end);
if (*end == 0) {
ret = TRUE;
} else {
if (g_ascii_strcasecmp (s, "min") == 0) {
x = -G_MAXDOUBLE;
ret = TRUE;
} else if (g_ascii_strcasecmp (s, "max") == 0) {
x = G_MAXDOUBLE;
ret = TRUE;
}
}
if (ret) {
g_value_set_double (value, x);
}
}
break;
case G_TYPE_BOOLEAN:
{
int len;
ret = _gst_structure_parse_string (val, &end, &s);
len = end - val;
if (ret && len > 0) {
if (g_ascii_strncasecmp (val, "true", len) == 0 ||
g_ascii_strncasecmp (val, "yes", len) == 0 ||
g_ascii_strncasecmp (val, "t", len) == 0 ||
strncmp (val, "1", len)) {
if (g_ascii_strcasecmp (s, "true") == 0 ||
g_ascii_strcasecmp (s, "yes") == 0 ||
g_ascii_strcasecmp (s, "t") == 0 ||
strcmp (s, "1") == 0) {
g_value_set_boolean (value, TRUE);
} else if (g_ascii_strncasecmp (val, "false", len) == 0 ||
g_ascii_strncasecmp (val, "no", len) == 0 ||
g_ascii_strncasecmp (val, "f", len) == 0 ||
strncmp (val, "0", len)) {
ret = TRUE;
} else if (g_ascii_strcasecmp (s, "false") == 0 ||
g_ascii_strcasecmp (s, "no") == 0 ||
g_ascii_strcasecmp (s, "f") == 0 ||
strcmp (s, "0") == 0) {
g_value_set_boolean (value, FALSE);
} else {
ret = FALSE;
}
ret = TRUE;
}
}
break;
case G_TYPE_STRING:
{
ret = _gst_structure_parse_string (val, &end, &s);
if (ret) {
g_value_set_string_take_ownership (value,
g_strndup(val, end - val));
g_value_set_string (value, s);
ret = TRUE;
}
}
break;
default:
/* FIXME: make more general */
if (type == GST_TYPE_FOURCC) {
guint32 fourcc = 0;
if (g_ascii_isdigit (*s)) {
fourcc = strtoul (val, &s, 0);
if (val != s) {
if (strlen(s) == 4) {
fourcc = GST_MAKE_FOURCC(s[0], s[1], s[2], s[3]);
ret = TRUE;
}
} else {
ret = _gst_structure_parse_string (val, &end, &s);
g_print("end - val = %d\n", end - val);
if (end - val >= 4) {
fourcc = GST_MAKE_FOURCC(val[0], val[1], val[2], val[3]);
} else if (g_ascii_isdigit (*s)) {
fourcc = strtoul (s, &end, 0);
if (*end == 0) {
ret = TRUE;
}
}
@ -1146,54 +1226,52 @@ g_print("end - val = %d\n", end - val);
break;
}
*after = s;
return ret;
}
static gboolean _gst_structure_parse_value (gchar *str, gchar **after,
GValue *value, GType default_type);
static gboolean
_gst_structure_parse_range (gchar *s, gchar **after, GType type,
GValue *value)
_gst_structure_parse_range (gchar *s, gchar **after, GValue *value, GType type)
{
GValue value1 = { 0 };
GValue value2 = { 0 };
GType range_type;
gboolean ret;
if (type == G_TYPE_DOUBLE) {
range_type = GST_TYPE_DOUBLE_RANGE;
} else if (type == G_TYPE_INT) {
range_type = GST_TYPE_INT_RANGE;
} else {
return FALSE;
}
g_print("%d \"%s\"\n", __LINE__, s);
if (*s != '[') return FALSE;
s++;
g_print("%d \"%s\"\n", __LINE__, s);
ret = _gst_structure_parse_value(s, &s, type, &value1);
ret = _gst_structure_parse_value(s, &s, &value1, type);
if (ret == FALSE) return FALSE;
while (g_ascii_isspace (*s)) s++;
g_print("%d \"%s\"\n", __LINE__, s);
if (*s != ',') return FALSE;
s++;
while (g_ascii_isspace (*s)) s++;
g_print("%d \"%s\"\n", __LINE__, s);
ret = _gst_structure_parse_value(s, &s, type, &value2);
ret = _gst_structure_parse_value(s, &s, &value2, type);
if (ret == FALSE) return FALSE;
while (g_ascii_isspace (*s)) s++;
g_print("%d \"%s\"\n", __LINE__, s);
if (*s != ']') return FALSE;
s++;
if (G_VALUE_TYPE (&value1) != G_VALUE_TYPE (&value2)) return FALSE;
if (G_VALUE_TYPE (&value1) == G_TYPE_DOUBLE) {
range_type = GST_TYPE_DOUBLE_RANGE;
} else if (G_VALUE_TYPE (&value1) == G_TYPE_INT) {
range_type = GST_TYPE_INT_RANGE;
} else {
return FALSE;
}
g_value_init(value, range_type);
if (range_type == GST_TYPE_DOUBLE_RANGE) {
gst_value_set_double_range(value, g_value_get_double(&value1),
@ -1208,38 +1286,43 @@ g_print("%d \"%s\"\n", __LINE__, s);
}
static gboolean
_gst_structure_parse_list (gchar *s, gchar **after, GType type, GValue *value)
_gst_structure_parse_list (gchar *s, gchar **after, GValue *value, GType type)
{
GValue list_value = { 0 };
gboolean ret;
GArray *array;
g_value_init(value, GST_TYPE_LIST);
array = g_value_peek_pointer (value);
if (*s != '(') return FALSE;
if (*s != '{') return FALSE;
s++;
while (g_ascii_isspace (*s)) s++;
if (*s == ')') {
if (*s == '}') {
s++;
*after = s;
return TRUE;
}
ret = _gst_structure_parse_value(s, &s, type, &list_value);
ret = _gst_structure_parse_value(s, &s, &list_value, type);
if (ret == FALSE) return FALSE;
g_array_append_val (array, list_value);
while (g_ascii_isspace (*s)) s++;
while (*s != ')') {
while (*s != '}') {
if (*s != ',') return FALSE;
s++;
while (g_ascii_isspace (*s)) s++;
memset (&list_value, 0, sizeof (list_value));
ret = _gst_structure_parse_value(s, &s, type, &list_value);
ret = _gst_structure_parse_value(s, &s, &list_value, type);
if (ret == FALSE) return FALSE;
g_array_append_val (array, list_value);
while (g_ascii_isspace (*s)) s++;
}
@ -1249,68 +1332,118 @@ _gst_structure_parse_list (gchar *s, gchar **after, GType type, GValue *value)
return TRUE;
}
static gboolean
_gst_structure_parse_simple_string (gchar *str, gchar **end)
{
char *s = str;
while(GST_ASCII_IS_STRING(*s)){
s++;
}
*end = s;
return (s != str);
}
static gboolean
_gst_structure_parse_field (gchar *str, gchar **after, GstStructureField *field)
{
/* NAME[:TYPE]=VALUE */
gchar *name;
gchar *type_name;
gchar *s, *del;
gboolean have_type = FALSE;
GType type = G_TYPE_INVALID;
int ret;
gchar *name_end;
gchar *s;
gchar c;
g_print("parsing: \"%s\"\n", str);
name = s = str;
while (g_ascii_isalnum (*s) || *s == '_' || *s == '-') s++;
del = s;
while (g_ascii_isspace (*s)) s++;
if (!(*s == '=' || *s == ':')) return FALSE;
if (*s == ':') have_type = TRUE;
s++;
while (g_ascii_isspace (*s)) s++;
*del = '\0';
s = str;
field->name = g_quark_from_string (name);
while(g_ascii_isspace (*s)) s++;
name = s;
if (!_gst_structure_parse_simple_string (s, &name_end)) return FALSE;
s = name_end;
while(g_ascii_isspace (*s)) s++;
if (have_type) {
while (g_ascii_isspace (*s)) s++;
type_name = s;
while (g_ascii_isalnum (*s) || *s == '_' || *s == '-') s++;
del = s;
while (g_ascii_isspace (*s)) s++;
if (*s != '=') return FALSE;
s++;
while (g_ascii_isspace (*s)) s++;
*del = '\0';
g_print("type name is \"%s\"\n",type_name);
c = *name_end;
*name_end = 0;
field->name = g_quark_from_string (name);
*name_end = c;
if (!_gst_structure_parse_value (s, &s, &field->value, G_TYPE_INVALID))
return FALSE;
*after = s;
return TRUE;
}
static gboolean
_gst_structure_parse_value (gchar *str, gchar **after, GValue *value,
GType default_type)
{
gchar *type_name;
gchar *type_end;
gchar *value_s;
gchar *value_end;
gchar *s;
gchar c;
int ret;
GType type = default_type;
s = str;
while(g_ascii_isspace (*s)) s++;
type_name = NULL;
if (*s == '(') {
type = G_TYPE_INVALID;
s++;
while(g_ascii_isspace (*s)) s++;
type_name = s;
if (!_gst_structure_parse_simple_string (s, &type_end)) return FALSE;
s = type_end;
while(g_ascii_isspace (*s)) s++;
if (*s != ')') return FALSE;
s++;
while(g_ascii_isspace (*s)) s++;
c = *type_end;
*type_end = 0;
type = _gst_structure_from_abbr(type_name);
g_print("type n is \"%s\"\n",g_type_name(type));
*type_end = c;
if (type == G_TYPE_INVALID) return FALSE;
} else {
if (g_ascii_isdigit (*s) ||
((*s == '-' || *s == '+') && g_ascii_isdigit (s[1]))) {
char *t = s;
while (g_ascii_isdigit (*t)) t++;
if (*t == '.'){
type = G_TYPE_DOUBLE;
} else {
type = G_TYPE_INT;
}
} else if (g_ascii_isalpha (*s) || *s == '"' || *s == '\'') {
type = G_TYPE_STRING;
}
}
while(g_ascii_isspace (*s)) s++;
if (*s == '[') {
ret = _gst_structure_parse_range (s, &s, type, &field->value);
} else if (*s == '(') {
ret = _gst_structure_parse_list (s, &s, type, &field->value);
ret = _gst_structure_parse_range (s, &s, value, type);
} else if (*s == '{') {
ret = _gst_structure_parse_list (s, &s, value, type);
} else {
ret = _gst_structure_parse_value(s, &s, type, &field->value);
value_s = s;
if (!_gst_structure_parse_string (s, &value_end, &s)) return FALSE;
c = *value_end;
*value_end = 0;
if (type == G_TYPE_INVALID) {
GType try_types[] = { G_TYPE_INT, G_TYPE_DOUBLE, G_TYPE_STRING };
int i;
for(i=0;i<3;i++) {
g_value_init(value, try_types[i]);
ret = gst_value_from_string (value, value_s);
if (ret) break;
g_value_unset(value);
}
} else {
g_value_init(value, type);
ret = gst_value_from_string (value, value_s);
}
*value_end = c;
}
*after = s;
@ -1364,7 +1497,6 @@ gst_structure_from_string (const gchar *string, gchar **end)
memset(&field,0,sizeof(field));
res = _gst_structure_parse_field (r, &r, &field);
g_print("returned %d \"%s\"\n", res, r);
if (!res) {
gst_structure_free (structure);
return NULL;

View file

@ -26,26 +26,19 @@
G_BEGIN_DECLS
typedef struct _GstStructure GstStructure;
typedef struct _GstStructureField GstStructureField;
typedef void (*GstStructureForeachFunc) (GstStructure *structure,
GQuark field_id, GValue *value, gpointer user_data);
typedef gboolean (*GstStructureForeachFunc) (GQuark field_id, GValue *value,
gpointer user_data);
struct _GstStructure {
int len;
GType type;
GQuark name;
GArray *fields;
};
struct _GstStructureField {
GQuark name;
GValue value;
};
#define GST_STRUCTURE_FIELD(structure, index) \
&g_array_index((structure)->fields, GstStructureField, (index))
#define GST_TYPE_STRUCTURE (gst_structure_get_type())
GType gst_structure_get_type(void);
void _gst_structure_initialize(void);
@ -59,12 +52,8 @@ GstStructure *gst_structure_new_valist(const gchar *name,
GstStructure *gst_structure_copy(GstStructure *structure);
void gst_structure_free(GstStructure *structure);
G_CONST_RETURN gchar *gst_structure_get_name(GstStructure *structure);
G_CONST_RETURN gchar *gst_structure_get_name(const GstStructure *structure);
void gst_structure_set_name(GstStructure *structure, const gchar *name);
void gst_structure_set_field_copy (GstStructure *structure,
const GstStructureField *field);
void gst_structure_set_field (GstStructure *structure,
GstStructureField *field);
void gst_structure_id_set_value(GstStructure *structure, GQuark field,
const GValue *value);
@ -73,18 +62,16 @@ void gst_structure_set_value(GstStructure *structure, const gchar *field,
void gst_structure_set(GstStructure *structure, const gchar *field, ...);
void gst_structure_set_valist(GstStructure *structure, const gchar *field,
va_list varargs);
G_CONST_RETURN GValue *gst_structure_id_get_value(const GstStructure *structure,
GQuark field);
G_CONST_RETURN GValue *gst_structure_get_value(const GstStructure *structure,
const gchar *field);
GstStructureField *gst_structure_get_field(const GstStructure *structure,
const gchar *fieldname);
GstStructureField *gst_structure_id_get_field(const GstStructure *structure,
GQuark fieldname);
void gst_structure_remove_field(GstStructure *structure, const gchar *field);
void gst_structure_remove_all_fields(GstStructure *structure);
GType gst_structure_get_field_type(const GstStructure *structure,
const gchar *field);
void gst_structure_field_foreach (GstStructure *structure,
gboolean gst_structure_foreach (GstStructure *structure,
GstStructureForeachFunc func, gpointer user_data);
gint gst_structure_n_fields(const GstStructure *structure);
gboolean gst_structure_has_field(const GstStructure *structure, const gchar *field);

View file

@ -390,26 +390,26 @@ static void
gst_tag_list_add_value_internal (GstStructure *list, GstTagMergeMode mode, GQuark tag, GValue *value)
{
GstTagInfo *info = gst_tag_lookup (tag);
GstStructureField *field;
const GValue *value2;
g_assert (info != NULL);
if (info->merge_func && (field = gst_structure_id_get_field (list, tag)) != NULL) {
GValue value2 = { 0, };
if (info->merge_func && (value2 = gst_structure_id_get_value (list, tag)) != NULL) {
GValue dest = { 0, };
switch (mode) {
case GST_TAG_MERGE_REPLACE_ALL:
case GST_TAG_MERGE_REPLACE:
gst_structure_id_set_value (list, tag, value);
break;
case GST_TAG_MERGE_PREPEND:
gst_value_list_concat (&value2, value, &field->value);
gst_structure_id_set_value (list, tag, &value2);
g_value_unset (&value2);
gst_value_list_concat (&dest, value, value2);
gst_structure_id_set_value (list, tag, &dest);
g_value_unset (&dest);
break;
case GST_TAG_MERGE_APPEND:
gst_value_list_concat (&value2, &field->value, value);
gst_structure_id_set_value (list, tag, &value2);
g_value_unset (&value2);
gst_value_list_concat (&dest, value2, value);
gst_structure_id_set_value (list, tag, &dest);
g_value_unset (&dest);
break;
case GST_TAG_MERGE_KEEP:
case GST_TAG_MERGE_KEEP_ALL:
@ -422,7 +422,7 @@ gst_tag_list_add_value_internal (GstStructure *list, GstTagMergeMode mode, GQuar
switch (mode) {
case GST_TAG_MERGE_APPEND:
case GST_TAG_MERGE_KEEP:
if (gst_structure_id_get_field (list, tag) != NULL)
if (gst_structure_id_get_value (list, tag) != NULL)
break;
/* fall through */
case GST_TAG_MERGE_REPLACE_ALL:
@ -438,12 +438,14 @@ gst_tag_list_add_value_internal (GstStructure *list, GstTagMergeMode mode, GQuar
}
}
}
static void
gst_tag_list_copy_foreach (GstStructure *structure, GQuark tag, GValue *value, gpointer user_data)
static gboolean
gst_tag_list_copy_foreach (GQuark tag, GValue *value, gpointer user_data)
{
GstTagCopyData *copy = (GstTagCopyData *) user_data;
gst_tag_list_add_value_internal (copy->list, copy->mode, tag, value);
return TRUE;
}
/**
* gst_tag_list_insert:
@ -467,7 +469,7 @@ gst_tag_list_insert (GstTagList *into, const GstTagList *from, GstTagMergeMode m
if (mode == GST_TAG_MERGE_REPLACE_ALL) {
gst_structure_remove_all_fields (data.list);
}
gst_structure_field_foreach ((GstStructure *) from, gst_tag_list_copy_foreach, &data);
gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach, &data);
}
/**
* gst_tag_list_copy:
@ -631,14 +633,16 @@ gst_tag_list_remove_tag (GstTagList *list, const gchar *tag)
}
typedef struct {
GstTagForeachFunc func;
GstTagList * tag_list;
gpointer data;
} TagForeachData;
static void
structure_foreach_wrapper (GstStructure *structure, GQuark field_id,
static int
structure_foreach_wrapper (GQuark field_id,
GValue *value, gpointer user_data)
{
TagForeachData *data = (TagForeachData *) user_data;
data->func (GST_TAG_LIST (structure), g_quark_to_string (field_id), data->data);
data->func (data->tag_list, g_quark_to_string (field_id), data->data);
return TRUE;
}
/**
* gst_tag_list_foreach:
@ -658,8 +662,9 @@ gst_tag_list_foreach (GstTagList *list, GstTagForeachFunc func, gpointer user_da
g_return_if_fail (func != NULL);
data.func = func;
data.tag_list = list;
data.data = user_data;
gst_structure_field_foreach ((GstStructure *) list, structure_foreach_wrapper, &data);
gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper, &data);
}
/***** tag events *****/

View file

@ -390,26 +390,26 @@ static void
gst_tag_list_add_value_internal (GstStructure *list, GstTagMergeMode mode, GQuark tag, GValue *value)
{
GstTagInfo *info = gst_tag_lookup (tag);
GstStructureField *field;
const GValue *value2;
g_assert (info != NULL);
if (info->merge_func && (field = gst_structure_id_get_field (list, tag)) != NULL) {
GValue value2 = { 0, };
if (info->merge_func && (value2 = gst_structure_id_get_value (list, tag)) != NULL) {
GValue dest = { 0, };
switch (mode) {
case GST_TAG_MERGE_REPLACE_ALL:
case GST_TAG_MERGE_REPLACE:
gst_structure_id_set_value (list, tag, value);
break;
case GST_TAG_MERGE_PREPEND:
gst_value_list_concat (&value2, value, &field->value);
gst_structure_id_set_value (list, tag, &value2);
g_value_unset (&value2);
gst_value_list_concat (&dest, value, value2);
gst_structure_id_set_value (list, tag, &dest);
g_value_unset (&dest);
break;
case GST_TAG_MERGE_APPEND:
gst_value_list_concat (&value2, &field->value, value);
gst_structure_id_set_value (list, tag, &value2);
g_value_unset (&value2);
gst_value_list_concat (&dest, value2, value);
gst_structure_id_set_value (list, tag, &dest);
g_value_unset (&dest);
break;
case GST_TAG_MERGE_KEEP:
case GST_TAG_MERGE_KEEP_ALL:
@ -422,7 +422,7 @@ gst_tag_list_add_value_internal (GstStructure *list, GstTagMergeMode mode, GQuar
switch (mode) {
case GST_TAG_MERGE_APPEND:
case GST_TAG_MERGE_KEEP:
if (gst_structure_id_get_field (list, tag) != NULL)
if (gst_structure_id_get_value (list, tag) != NULL)
break;
/* fall through */
case GST_TAG_MERGE_REPLACE_ALL:
@ -438,12 +438,14 @@ gst_tag_list_add_value_internal (GstStructure *list, GstTagMergeMode mode, GQuar
}
}
}
static void
gst_tag_list_copy_foreach (GstStructure *structure, GQuark tag, GValue *value, gpointer user_data)
static gboolean
gst_tag_list_copy_foreach (GQuark tag, GValue *value, gpointer user_data)
{
GstTagCopyData *copy = (GstTagCopyData *) user_data;
gst_tag_list_add_value_internal (copy->list, copy->mode, tag, value);
return TRUE;
}
/**
* gst_tag_list_insert:
@ -467,7 +469,7 @@ gst_tag_list_insert (GstTagList *into, const GstTagList *from, GstTagMergeMode m
if (mode == GST_TAG_MERGE_REPLACE_ALL) {
gst_structure_remove_all_fields (data.list);
}
gst_structure_field_foreach ((GstStructure *) from, gst_tag_list_copy_foreach, &data);
gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach, &data);
}
/**
* gst_tag_list_copy:
@ -631,14 +633,16 @@ gst_tag_list_remove_tag (GstTagList *list, const gchar *tag)
}
typedef struct {
GstTagForeachFunc func;
GstTagList * tag_list;
gpointer data;
} TagForeachData;
static void
structure_foreach_wrapper (GstStructure *structure, GQuark field_id,
static int
structure_foreach_wrapper (GQuark field_id,
GValue *value, gpointer user_data)
{
TagForeachData *data = (TagForeachData *) user_data;
data->func (GST_TAG_LIST (structure), g_quark_to_string (field_id), data->data);
data->func (data->tag_list, g_quark_to_string (field_id), data->data);
return TRUE;
}
/**
* gst_tag_list_foreach:
@ -658,8 +662,9 @@ gst_tag_list_foreach (GstTagList *list, GstTagForeachFunc func, gpointer user_da
g_return_if_fail (func != NULL);
data.func = func;
data.tag_list = list;
data.data = user_data;
gst_structure_field_foreach ((GstStructure *) list, structure_foreach_wrapper, &data);
gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper, &data);
}
/***** tag events *****/

View file

@ -92,7 +92,7 @@ gst_type_find_factory_dispose (GObject *object)
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (object);
if (factory->caps) {
gst_caps_unref (factory->caps);
gst_caps_free (factory->caps);
factory->caps = NULL;
}
if (factory->extensions) {
@ -146,7 +146,7 @@ gst_type_find_factory_get_list (void)
*
* Returns: the #GstCaps associated with this factory
*/
GstCaps *
const GstCaps *
gst_type_find_factory_get_caps (const GstTypeFindFactory *factory)
{
g_return_val_if_fail (GST_IS_TYPE_FIND_FACTORY (factory), NULL);
@ -211,8 +211,8 @@ gst_type_find_factory_call_function (const GstTypeFindFactory *factory, GstTypeF
*/
gboolean
gst_type_find_register (GstPlugin *plugin, const gchar *name, guint rank,
GstTypeFindFunction func, gchar **extensions, GstCaps *possible_caps,
gpointer data)
GstTypeFindFunction func, gchar **extensions,
const GstCaps *possible_caps, gpointer data)
{
GstTypeFindFactory *factory;
@ -236,7 +236,7 @@ gst_type_find_register (GstPlugin *plugin, const gchar *name, guint rank,
g_strfreev (factory->extensions);
factory->extensions = g_strdupv (extensions);
gst_caps_replace (&factory->caps, possible_caps);
gst_caps_replace (&factory->caps, gst_caps_copy(possible_caps));
factory->function = func;
factory->user_data = data;
@ -281,17 +281,14 @@ gst_type_find_peek (GstTypeFind *find, gint64 offset, guint size)
* It is up to the caller of the typefind function to interpret these values.
*/
void
gst_type_find_suggest (GstTypeFind *find, guint probability, GstCaps *caps)
gst_type_find_suggest (GstTypeFind *find, guint probability, const GstCaps *caps)
{
g_return_if_fail (find->suggest != NULL);
g_return_if_fail (probability <= 100);
g_return_if_fail (caps != NULL);
g_return_if_fail (GST_CAPS_IS_FIXED (caps));
g_return_if_fail (gst_caps_is_fixed (caps));
gst_caps_ref (caps);
gst_caps_sink (caps);
find->suggest (find->data, probability, caps);
gst_caps_unref (caps);
}
/**
* gst_type_find_get_length:

View file

@ -24,7 +24,7 @@
#define __GST_TYPE_FIND_H__
#include <gst/gstbuffer.h>
#include <gst/gstcaps.h>
#include <gst/gstcaps2.h>
#include <gst/gstplugin.h>
#include <gst/gstpluginfeature.h>
#include <gst/gsttypes.h>
@ -59,7 +59,7 @@ struct _GstTypeFind {
guint size);
void (* suggest) (gpointer data,
guint probability,
GstCaps * caps);
const GstCaps * caps);
gpointer data;
@ -96,7 +96,7 @@ guint8 * gst_type_find_peek (GstTypeFind * find,
guint size);
void gst_type_find_suggest (GstTypeFind * find,
guint probability,
GstCaps * caps);
const GstCaps * caps);
guint64 gst_type_find_get_length (GstTypeFind * find);
/* registration interface */
@ -105,7 +105,7 @@ gboolean gst_type_find_register (GstPlugin * plugin,
guint rank,
GstTypeFindFunction func,
gchar ** extensions,
GstCaps * possible_caps,
const GstCaps * possible_caps,
gpointer data);
/* typefinding interface */
@ -115,7 +115,7 @@ GType gst_type_find_factory_get_type (void);
GList * gst_type_find_factory_get_list (void);
gchar ** gst_type_find_factory_get_extensions (const GstTypeFindFactory *factory);
GstCaps * gst_type_find_factory_get_caps (const GstTypeFindFactory *factory);
const GstCaps * gst_type_find_factory_get_caps (const GstTypeFindFactory *factory);
void gst_type_find_factory_call_function (const GstTypeFindFactory *factory,
GstTypeFind *find);

View file

@ -265,7 +265,6 @@ gst_util_set_object_arg (GObject * object, const gchar * name, const gchar * val
*/
#include "gstpad.h"
#include "gstprops.h"
static void
string_append_indent (GString * str, gint count)
@ -276,6 +275,7 @@ string_append_indent (GString * str, gint count)
g_string_append_c (str, ' ');
}
#if 0
static void
gst_print_props (GString *buf, gint indent, GList *props, gboolean showname)
{
@ -371,6 +371,7 @@ gst_print_props (GString *buf, gint indent, GList *props, gboolean showname)
}
}
}
#endif
/**
* gst_print_pad_caps:
@ -395,20 +396,11 @@ gst_print_pad_caps (GString * buf, gint indent, GstPad * pad)
g_string_printf (buf, "%s:%s has no capabilities", GST_DEBUG_PAD_NAME (pad));
}
else {
gint capx = 0;
char *s;
while (caps) {
string_append_indent (buf, indent);
g_string_append_printf (buf, "Cap[%d]: %s\n", capx++, caps->name);
string_append_indent (buf, indent + 2);
g_string_append_printf (buf, "MIME type: %s\n", gst_caps_get_mime (caps));
if (caps->properties)
gst_print_props (buf, indent + 4, caps->properties->properties, TRUE);
caps = caps->next;
}
s = gst_caps_to_string(caps);
g_string_append(buf, s);
g_free(s);
}
}

View file

@ -169,42 +169,6 @@ gst_value_list_get_value (const GValue *value, guint index)
return (const GValue *) &g_array_index ((GArray *) value->data[0].v_pointer, GValue, index);
}
/* special case function for any union */
static gboolean
gst_value_union_lists (GValue *dest, const GValue *value1, const GValue *value2)
{
guint i, value1_length, value2_length;
GArray *array;
value1_length = (GST_VALUE_HOLDS_LIST (value1) ? gst_value_list_get_size (value1) : 1);
value2_length = (GST_VALUE_HOLDS_LIST (value2) ? gst_value_list_get_size (value2) : 1);
g_value_init (dest, GST_TYPE_LIST);
array = (GArray *) dest->data[0].v_pointer;
g_array_set_size (array, value1_length + value2_length);
if (GST_VALUE_HOLDS_LIST (value1)) {
for (i = 0; i < value1_length; i++) {
g_value_init (&g_array_index(array, GValue, i), G_VALUE_TYPE (gst_value_list_get_value (value1, i)));
g_value_copy (gst_value_list_get_value (value1, i), &g_array_index(array, GValue, i));
}
} else {
g_value_init (&g_array_index(array, GValue, 0), G_VALUE_TYPE (value1));
g_value_copy (value1, &g_array_index(array, GValue, 0));
}
if (GST_VALUE_HOLDS_LIST (value2)) {
for (i = 0; i < value2_length; i++) {
g_value_init (&g_array_index(array, GValue, i + value1_length), G_VALUE_TYPE (gst_value_list_get_value (value2, i)));
g_value_copy (gst_value_list_get_value (value2, i), &g_array_index(array, GValue, i + value1_length));
}
} else {
g_value_init (&g_array_index(array, GValue, value1_length), G_VALUE_TYPE (value2));
g_value_copy (value2, &g_array_index(array, GValue, value1_length));
}
return TRUE;
}
/**
* gst_value_list_concat:
* @dest: an uninitialized #GValue to take the result
@ -257,20 +221,20 @@ gst_value_list_concat (GValue *dest, const GValue *value1, const GValue *value2)
static void
gst_value_init_fourcc (GValue *value)
{
value->data[0].v_long = 0;
value->data[0].v_int = 0;
}
static void
gst_value_copy_fourcc (const GValue *src_value, GValue *dest_value)
{
dest_value->data[0].v_long = src_value->data[0].v_long;
dest_value->data[0].v_int = src_value->data[0].v_int;
}
static gchar *
gst_value_collect_fourcc (GValue *value, guint n_collect_values,
GTypeCValue *collect_values, guint collect_flags)
{
value->data[0].v_long = collect_values[0].v_long;
value->data[0].v_int = collect_values[0].v_int;
return NULL;
}
@ -285,7 +249,7 @@ gst_value_lcopy_fourcc (const GValue *value, guint n_collect_values,
return g_strdup_printf ("value location for `%s' passed as NULL",
G_VALUE_TYPE_NAME (value));
*fourcc_p = value->data[0].v_long;
*fourcc_p = value->data[0].v_int;
return NULL;
}
@ -295,7 +259,7 @@ gst_value_set_fourcc (GValue *value, guint32 fourcc)
{
g_return_if_fail (GST_VALUE_HOLDS_FOURCC (value));
value->data[0].v_long = fourcc;
value->data[0].v_int = fourcc;
}
guint32
@ -303,7 +267,7 @@ gst_value_get_fourcc (const GValue *value)
{
g_return_val_if_fail (GST_VALUE_HOLDS_FOURCC (value), 0);
return value->data[0].v_long;
return value->data[0].v_int;
}
/* int range */
@ -311,20 +275,24 @@ gst_value_get_fourcc (const GValue *value)
static void
gst_value_init_int_range (GValue *value)
{
value->data[0].v_long = 0;
value->data[0].v_int = 0;
value->data[1].v_int = 0;
}
static void
gst_value_copy_int_range (const GValue *src_value, GValue *dest_value)
{
dest_value->data[0].v_long = src_value->data[0].v_long;
dest_value->data[0].v_int = src_value->data[0].v_int;
dest_value->data[1].v_int = src_value->data[1].v_int;
}
static gchar *
gst_value_collect_int_range (GValue *value, guint n_collect_values,
GTypeCValue *collect_values, guint collect_flags)
{
value->data[0].v_long = collect_values[0].v_long;
/* FIXME */
value->data[0].v_int = collect_values[0].v_int;
value->data[1].v_int = collect_values[1].v_int;
return NULL;
}
@ -333,13 +301,18 @@ static gchar *
gst_value_lcopy_int_range (const GValue *value, guint n_collect_values,
GTypeCValue *collect_values, guint collect_flags)
{
guint32 *int_range_p = collect_values[0].v_pointer;
guint32 *int_range_start = collect_values[0].v_pointer;
guint32 *int_range_end = collect_values[1].v_pointer;
if (!int_range_p)
return g_strdup_printf ("value location for `%s' passed as NULL",
if (!int_range_start)
return g_strdup_printf ("start value location for `%s' passed as NULL",
G_VALUE_TYPE_NAME (value));
if (!int_range_end)
return g_strdup_printf ("end value location for `%s' passed as NULL",
G_VALUE_TYPE_NAME (value));
*int_range_p = value->data[0].v_long;
*int_range_start = value->data[0].v_int;
*int_range_end = value->data[1].v_int;
return NULL;
}
@ -349,8 +322,8 @@ gst_value_set_int_range (GValue *value, int start, int end)
{
g_return_if_fail (GST_VALUE_HOLDS_INT_RANGE (value));
value->data[0].v_long = start;
value->data[1].v_long = end;
value->data[0].v_int = start;
value->data[1].v_int = end;
}
int
@ -358,7 +331,7 @@ gst_value_get_int_range_min (const GValue *value)
{
g_return_val_if_fail (GST_VALUE_HOLDS_INT_RANGE (value), 0);
return value->data[0].v_long;
return value->data[0].v_int;
}
int
@ -366,7 +339,7 @@ gst_value_get_int_range_max (const GValue *value)
{
g_return_val_if_fail (GST_VALUE_HOLDS_INT_RANGE (value), 0);
return value->data[1].v_long;
return value->data[1].v_int;
}
/* double range */
@ -389,7 +362,6 @@ static gchar *
gst_value_collect_double_range (GValue *value, guint n_collect_values,
GTypeCValue *collect_values, guint collect_flags)
{
/* FIXME */
value->data[0].v_double = collect_values[0].v_double;
value->data[1].v_double = collect_values[1].v_double;
@ -400,15 +372,18 @@ static gchar *
gst_value_lcopy_double_range (const GValue *value, guint n_collect_values,
GTypeCValue *collect_values, guint collect_flags)
{
guint32 *double_range_p = collect_values[0].v_pointer;
gdouble *double_range_start = collect_values[0].v_pointer;
gdouble *double_range_end = collect_values[1].v_pointer;
/* FIXME */
if (!double_range_p)
return g_strdup_printf ("value location for `%s' passed as NULL",
if (!double_range_start)
return g_strdup_printf ("start value location for `%s' passed as NULL",
G_VALUE_TYPE_NAME (value));
if (!double_range_end)
return g_strdup_printf ("end value location for `%s' passed as NULL",
G_VALUE_TYPE_NAME (value));
*double_range_p = value->data[0].v_double;
*double_range_start = value->data[0].v_double;
*double_range_end = value->data[1].v_double;
return NULL;
}
@ -440,23 +415,21 @@ gst_value_get_double_range_max (const GValue *value)
/* GstCaps */
#if 0
void
gst_value_set_caps (GValue *value, const GstCaps2 *caps)
gst_value_set_caps (GValue *value, const GstCaps *caps)
{
g_return_if_fail (GST_VALUE_HOLDS_CAPS (value));
value->data[0].v_pointer = gst_caps2_copy (caps);
value->data[0].v_pointer = gst_caps_copy (caps);
}
const GstCaps2 *
const GstCaps *
gst_value_get_caps (const GValue *value)
{
g_return_val_if_fail (GST_VALUE_HOLDS_CAPS (value), 0);
return value->data[0].v_pointer;
}
#endif
/* fourcc */
@ -464,14 +437,14 @@ static void
gst_value_transform_fourcc_string (const GValue *src_value,
GValue *dest_value)
{
guint32 fourcc = src_value->data[0].v_long;
guint32 fourcc = src_value->data[0].v_int;
if (g_ascii_isprint ((fourcc>>0) & 0xff) &&
g_ascii_isprint ((fourcc>>8) & 0xff) &&
g_ascii_isprint ((fourcc>>16) & 0xff) &&
g_ascii_isprint ((fourcc>>24) & 0xff)){
dest_value->data[0].v_pointer = g_strdup_printf(
"\"" GST_FOURCC_FORMAT "\"", GST_FOURCC_ARGS(fourcc));
GST_FOURCC_FORMAT, GST_FOURCC_ARGS(fourcc));
} else {
dest_value->data[0].v_pointer = g_strdup_printf("0x%08x", fourcc);
}
@ -482,7 +455,7 @@ gst_value_transform_int_range_string (const GValue *src_value,
GValue *dest_value)
{
dest_value->data[0].v_pointer = g_strdup_printf("[%d,%d]",
(int)src_value->data[0].v_long, (int)src_value->data[1].v_long);
(int)src_value->data[0].v_int, (int)src_value->data[1].v_int);
}
static void
@ -505,7 +478,7 @@ gst_value_transform_list_string (const GValue *src_value,
array = src_value->data[0].v_pointer;
s = g_string_new("(");
s = g_string_new("{ ");
for(i=0;i<array->len;i++){
list_value = &g_array_index(array, GValue, i);
@ -516,13 +489,22 @@ gst_value_transform_list_string (const GValue *src_value,
g_string_append (s, list_s);
g_free (list_s);
}
g_string_append (s, ")");
g_string_append (s, " }");
dest_value->data[0].v_pointer = g_string_free (s, FALSE);
}
/* comparison functions */
static int
gst_value_compare_boolean (const GValue *value1, const GValue *value2)
{
/* FIXME: ds, can we assume that those values are only TRUE and FALSE? */
if (value1->data[0].v_int == value2->data[0].v_int)
return GST_VALUE_EQUAL;
return GST_VALUE_UNORDERED;
}
static int
gst_value_compare_int (const GValue *value1, const GValue *value2)
{
@ -569,7 +551,6 @@ gst_value_compare_string (const GValue *value1, const GValue *value2)
static int
gst_value_compare_fourcc (const GValue *value1, const GValue *value2)
{
g_print("comparing fourccs\n");
if (value2->data[0].v_int == value1->data[0].v_int) return GST_VALUE_EQUAL;
return GST_VALUE_UNORDERED;
}
@ -694,7 +675,9 @@ gst_value_union (GValue *dest, const GValue *value1, const GValue *value2)
return union_info->func(dest, value1, value2);
}
}
return gst_value_union_lists (dest, value1, value2);
gst_value_list_concat (dest, value1, value2);
return TRUE;
}
void
@ -718,8 +701,9 @@ gst_value_intersect_int_int_range (GValue *dest, const GValue *src1,
g_return_val_if_fail(G_VALUE_TYPE(src1) == G_TYPE_INT, FALSE);
g_return_val_if_fail(G_VALUE_TYPE(src2) == GST_TYPE_INT_RANGE, FALSE);
if (src2->data[0].v_long <= src1->data[0].v_int &&
src2->data[1].v_long >= src1->data[0].v_int){
if (src2->data[0].v_int <= src1->data[0].v_int &&
src2->data[1].v_int >= src1->data[0].v_int){
g_value_init(dest, G_TYPE_INT);
g_value_copy(src1, dest);
return TRUE;
}
@ -737,8 +721,8 @@ gst_value_intersect_int_range_int_range (GValue *dest, const GValue *src1,
g_return_val_if_fail(G_VALUE_TYPE(src1) == GST_TYPE_INT_RANGE, FALSE);
g_return_val_if_fail(G_VALUE_TYPE(src2) == GST_TYPE_INT_RANGE, FALSE);
min = MAX(src1->data[0].v_long, src2->data[0].v_long);
max = MIN(src1->data[1].v_long, src2->data[1].v_long);
min = MAX(src1->data[0].v_int, src2->data[0].v_int);
max = MIN(src1->data[1].v_int, src2->data[1].v_int);
if(min < max){
g_value_init(dest, GST_TYPE_INT_RANGE);
@ -754,12 +738,97 @@ gst_value_intersect_int_range_int_range (GValue *dest, const GValue *src1,
return FALSE;
}
static gboolean
gst_value_intersect_double_double_range (GValue *dest, const GValue *src1,
const GValue *src2)
{
g_return_val_if_fail(G_VALUE_TYPE(src1) == G_TYPE_DOUBLE, FALSE);
g_return_val_if_fail(G_VALUE_TYPE(src2) == GST_TYPE_DOUBLE_RANGE, FALSE);
if (src2->data[0].v_double <= src1->data[0].v_double &&
src2->data[1].v_double >= src1->data[0].v_double){
g_value_init(dest, G_TYPE_DOUBLE);
g_value_copy(src1, dest);
return TRUE;
}
return FALSE;
}
static gboolean
gst_value_intersect_double_range_double_range (GValue *dest, const GValue *src1,
const GValue *src2)
{
double min;
double max;
g_return_val_if_fail(G_VALUE_TYPE(src1) == GST_TYPE_DOUBLE_RANGE, FALSE);
g_return_val_if_fail(G_VALUE_TYPE(src2) == GST_TYPE_DOUBLE_RANGE, FALSE);
min = MAX(src1->data[0].v_double, src2->data[0].v_double);
max = MIN(src1->data[1].v_double, src2->data[1].v_double);
if(min < max){
g_value_init(dest, GST_TYPE_DOUBLE_RANGE);
gst_value_set_double_range(dest, min, max);
return TRUE;
}
if(min == max){
g_value_init(dest, G_TYPE_DOUBLE);
g_value_set_int(dest, min);
return TRUE;
}
return FALSE;
}
static gboolean
gst_value_intersect_list (GValue *dest, const GValue *value1, const GValue *value2)
{
guint i, size;
GValue intersection = { 0, };
gboolean ret = FALSE;
g_return_val_if_fail (GST_VALUE_HOLDS_LIST (value1), FALSE);
size = gst_value_list_get_size (value1);
for (i = 0; i < size; i++) {
const GValue *cur = gst_value_list_get_value (value1, i);
if (gst_value_intersect (&intersection, cur, value2)) {
/* append value */
if (!ret) {
g_value_init (dest, G_VALUE_TYPE(&intersection));
g_value_copy (dest, &intersection);
ret = TRUE;
} else if (GST_VALUE_HOLDS_LIST (dest)) {
gst_value_list_append_value (dest, &intersection);
} else {
GValue temp = {0, };
g_value_init (&temp, G_VALUE_TYPE(dest));
g_value_copy (dest, &temp);
g_value_unset (dest);
gst_value_list_concat (dest, &temp, &intersection);
}
g_value_unset (&intersection);
}
}
return ret;
}
gboolean
gst_value_can_intersect (const GValue *value1, const GValue *value2)
{
GstValueIntersectInfo *intersect_info;
int i;
/* special cases */
if (GST_VALUE_HOLDS_LIST (value1) ||
GST_VALUE_HOLDS_LIST (value2))
return TRUE;
for(i=0;i<gst_value_intersect_funcs->len;i++){
intersect_info = &g_array_index(gst_value_intersect_funcs,
GstValueIntersectInfo, i);
@ -767,7 +836,7 @@ gst_value_can_intersect (const GValue *value1, const GValue *value2)
intersect_info->type2 == G_VALUE_TYPE(value2)) return TRUE;
}
return FALSE;
return gst_value_can_compare (value1, value2);
}
gboolean
@ -777,16 +846,23 @@ gst_value_intersect (GValue *dest, const GValue *value1, const GValue *value2)
int i;
int ret = FALSE;
g_print("intersecting %s=%s and %s=%s\n",
g_type_name(G_VALUE_TYPE(value1)), g_strdup_value_contents(value1),
g_type_name(G_VALUE_TYPE(value2)), g_strdup_value_contents(value2));
/* special cases first */
if (GST_VALUE_HOLDS_LIST (value1))
return gst_value_intersect_list (dest, value1, value2);
if (GST_VALUE_HOLDS_LIST (value2))
return gst_value_intersect_list (dest, value2, value1);
for(i=0;i<gst_value_intersect_funcs->len;i++){
intersect_info = &g_array_index(gst_value_intersect_funcs,
GstValueIntersectInfo, i);
if(intersect_info->type1 == G_VALUE_TYPE(value1) &&
intersect_info->type2 == G_VALUE_TYPE(value2)) {
ret = intersect_info->func(dest, value1, value2);
g_print("result is %d %s\n", ret, ret?g_strdup_value_contents(dest):"none1");
return ret;
}
if(intersect_info->type1 == G_VALUE_TYPE(value2) &&
intersect_info->type2 == G_VALUE_TYPE(value1)) {
ret = intersect_info->func(dest, value2, value1);
return ret;
}
}
@ -795,10 +871,8 @@ g_print("result is %d %s\n", ret, ret?g_strdup_value_contents(dest):"none1");
g_value_init(dest, G_VALUE_TYPE(value1));
g_value_copy(value1, dest);
ret = TRUE;
g_print("result is %d %s\n", ret, ret?g_strdup_value_contents(dest):"none2");
}
g_print("result is %d %s\n", ret, ret?g_strdup_value_contents(dest):"none3");
return ret;
}
@ -853,9 +927,9 @@ _gst_value_initialize (void)
NULL,
gst_value_copy_int_range,
NULL,
"i",
"ii",
gst_value_collect_int_range,
"p",
"pp",
gst_value_lcopy_int_range
};
info.value_table = &value_table;
@ -868,9 +942,9 @@ _gst_value_initialize (void)
NULL,
gst_value_copy_double_range,
NULL,
"i",
"dd",
gst_value_collect_double_range,
"p",
"pp",
gst_value_lcopy_double_range
};
info.value_table = &value_table;
@ -904,6 +978,7 @@ _gst_value_initialize (void)
gst_value_compare_funcs = g_array_new(FALSE, FALSE,
sizeof(GstValueCompareInfo));
gst_value_register_compare_func (G_TYPE_BOOLEAN, gst_value_compare_boolean);
gst_value_register_compare_func (G_TYPE_INT, gst_value_compare_int);
gst_value_register_compare_func (G_TYPE_FLOAT, gst_value_compare_float);
gst_value_register_compare_func (G_TYPE_DOUBLE, gst_value_compare_double);
@ -923,6 +998,10 @@ _gst_value_initialize (void)
gst_value_intersect_int_int_range);
gst_value_register_intersect_func (GST_TYPE_INT_RANGE, GST_TYPE_INT_RANGE,
gst_value_intersect_int_range_int_range);
gst_value_register_intersect_func (G_TYPE_DOUBLE, GST_TYPE_DOUBLE_RANGE,
gst_value_intersect_double_double_range);
gst_value_register_intersect_func (GST_TYPE_DOUBLE_RANGE, GST_TYPE_DOUBLE_RANGE,
gst_value_intersect_double_range_double_range);
}

View file

@ -21,9 +21,7 @@
#define __GST_VALUE_H__
#include <gst/gstconfig.h>
#if 0
#include <gst/gstcaps2.h>
#endif
G_BEGIN_DECLS
@ -76,13 +74,11 @@ void gst_value_set_double_range (GValue *value, double start, double end);
double gst_value_get_double_range_min (const GValue *value);
double gst_value_get_double_range_max (const GValue *value);
#if 0
G_CONST_RETURN GstCaps2 *gst_value_get_caps (const GValue *value);
void gst_value_set_caps (GValue *calue, const GstCaps2 *caps);
#endif
G_CONST_RETURN GstCaps *gst_value_get_caps (const GValue *value);
void gst_value_set_caps (GValue *calue, const GstCaps *caps);
void gst_value_list_prepend_value (GValue *value, const GValue *prepend_value);
void gst_value_list_append_value (GValue *value, const GValue *prepend_value);
void gst_value_list_append_value (GValue *value, const GValue *append_value);
guint gst_value_list_get_size (const GValue *value);
G_CONST_RETURN GValue *gst_value_list_get_value (const GValue *value, guint index);
void gst_value_list_concat (GValue *dest, const GValue *value1, const GValue *value2);

View file

@ -336,7 +336,7 @@ gst_parse_free_link (link_t *link)
g_slist_foreach (link->sink_pads, (GFunc) gst_parse_strfree, NULL);
g_slist_free (link->src_pads);
g_slist_free (link->sink_pads);
gst_caps_unref (link->caps);
if (link->caps) gst_caps_free (link->caps);
gst_parse_link_free (link);
}
static void
@ -396,7 +396,7 @@ gst_parse_found_pad (GstElement *src, GstPad *pad, gpointer data)
g_signal_handler_disconnect (src, link->signal_id);
g_free (link->src_pad);
g_free (link->sink_pad);
gst_caps_unref (link->caps);
if (link->caps) gst_caps_free (link->caps);
if (!gst_element_is_locked_state (src))
gst_parse_element_lock (link->sink, FALSE);
g_free (link);
@ -423,7 +423,7 @@ gst_parse_perform_delayed_link (GstElement *src, const gchar *src_pad,
data->src_pad = g_strdup (src_pad);
data->sink = sink;
data->sink_pad = g_strdup (sink_pad);
data->caps = gst_caps_ref (caps);
data->caps = gst_caps_copy (caps);
data->signal_id = g_signal_connect (G_OBJECT (src), "new_pad",
G_CALLBACK (gst_parse_found_pad), data);
return TRUE;
@ -596,8 +596,6 @@ link: linkpart LINK linkpart { $$ = $1;
if (!$$->caps)
ERROR (GST_PARSE_ERROR_LINK, "could not parse caps \"%s\"", $2);
gst_parse_strfree ($2);
gst_caps_ref($$->caps);
gst_caps_sink($$->caps);
}
$$->sink_name = $3->src_name;
$$->sink_pads = $3->src_pads;

View file

@ -833,35 +833,20 @@ gst_xml_registry_parse_padtemplate (GMarkupParseContext *context, const gchar *t
registry->presence = GST_PAD_REQUEST;
}
}
return TRUE;
}
else if (!strncmp (tag, "caps", 4)) {
char *s;
static gboolean
gst_xml_registry_parse_capscomp (GMarkupParseContext *context, const gchar *tag, const gchar *text,
gsize text_len, GstXMLRegistry *registry, GError **error)
{
if (!strcmp (tag, "name")) {
registry->caps_name = g_strndup (text, text_len);
s = g_strndup (text, text_len);
registry->caps = gst_caps_from_string (s);
if (registry->caps == NULL) {
g_critical ("Could not parse caps: %d %*s\n", text_len, text_len, text);
}
else if (!strcmp (tag, "type")) {
registry->caps_mime = g_strndup (text, text_len);
g_free(s);
return TRUE;
}
return TRUE;
}
static gint
find_index_for (const gchar *name, const gchar **attribute_names)
{
gint i=0;
while (attribute_names[i]) {
if (!strcmp (attribute_names[i], name))
return i;
i++;
}
return -1;
}
static void
gst_xml_registry_start_element (GMarkupParseContext *context,
const gchar *element_name,
@ -937,125 +922,6 @@ gst_xml_registry_start_element (GMarkupParseContext *context,
xmlregistry->caps = NULL;
}
break;
case GST_XML_REGISTRY_PADTEMPLATE:
if (!strncmp (element_name, "caps", 4)) {
xmlregistry->state = GST_XML_REGISTRY_CAPS;
xmlregistry->parser = NULL;
}
break;
case GST_XML_REGISTRY_CAPS:
if (!strncmp (element_name, "capscomp", 8)) {
xmlregistry->state = GST_XML_REGISTRY_CAPSCOMP;
xmlregistry->parser = gst_xml_registry_parse_capscomp;
}
break;
case GST_XML_REGISTRY_CAPSCOMP:
if (!strncmp (element_name, "properties", 10)) {
xmlregistry->state = GST_XML_REGISTRY_PROPERTIES;
xmlregistry->parser = NULL;
xmlregistry->props = gst_props_empty_new ();
}
break;
case GST_XML_REGISTRY_PROPERTIES:
{
gint name_index;
GstPropsEntry *entry = NULL;
name_index = find_index_for ("name", attribute_names);
if (name_index < 0)
break;
if (!strncmp (element_name, "list", 4)) {
xmlregistry->in_list = TRUE;
xmlregistry->list_name = g_strdup (attribute_values[name_index]);
}
if (!strncmp (element_name, "int", 3)) {
gint value;
gint index;
if ((index = find_index_for ("value", attribute_names)) < 0)
break;
sscanf (attribute_values[index], "%d", &value);
entry = gst_props_entry_new (attribute_values[name_index],
GST_PROPS_INT (value));
}
else if (!strncmp (element_name, "range", 5)) {
gint min, max;
gint min_idx, max_idx;
if ((min_idx = find_index_for ("min", attribute_names)) < 0)
break;
if ((max_idx = find_index_for ("max", attribute_names)) < 0)
break;
sscanf (attribute_values[min_idx], "%d", &min);
sscanf (attribute_values[max_idx], "%d", &max);
entry = gst_props_entry_new (attribute_values[name_index], GST_PROPS_INT_RANGE (min, max));
}
else if (!strncmp (element_name, "float", 5)) {
gfloat value;
gint index;
if ((index = find_index_for ("value", attribute_names)) < 0)
break;
sscanf (attribute_values[index], "%f", &value);
entry = gst_props_entry_new (attribute_values[name_index], GST_PROPS_FLOAT (value));
}
else if (!strncmp (element_name, "floatrange", 10)) {
gfloat min, max;
gint min_idx, max_idx;
if ((min_idx = find_index_for ("min", attribute_names)) < 0)
break;
if ((max_idx = find_index_for ("max", attribute_names)) < 0)
break;
sscanf (attribute_values[min_idx], "%f", &min);
sscanf (attribute_values[max_idx], "%f", &max);
entry = gst_props_entry_new (attribute_values[name_index], GST_PROPS_FLOAT_RANGE (min, max));
}
else if (!strncmp (element_name, "boolean", 7)) {
gboolean value = TRUE;
gint index;
if ((index = find_index_for ("value", attribute_names)) < 0)
break;
if (!strcmp (attribute_values[index], "false"))
value = FALSE;
entry = gst_props_entry_new (attribute_values[name_index], GST_PROPS_BOOLEAN (value));
}
else if (!strncmp (element_name, "fourcc", 6)) {
guint32 value;
gint index;
if ((index = find_index_for ("hexvalue", attribute_names)) < 0)
break;
sscanf (attribute_values[index], "%08x", &value);
entry = gst_props_entry_new (attribute_values[name_index], GST_PROPS_FOURCC (value));
}
else if (!strncmp (element_name, "string", 6)) {
gint index;
if ((index = find_index_for ("value", attribute_names)) < 0)
break;
entry = gst_props_entry_new (attribute_values[name_index],
GST_PROPS_STRING (attribute_values[index]));
}
/* add property to list or parent */
if (entry) {
if (xmlregistry->in_list)
xmlregistry->entry_list = g_list_prepend (xmlregistry->entry_list, entry);
else
gst_props_add_entry (xmlregistry->props, entry);
}
break;
}
default:
break;
}
@ -1100,7 +966,7 @@ gst_xml_registry_end_element (GMarkupParseContext *context,
template = gst_pad_template_new (xmlregistry->name_template,
xmlregistry->direction,
xmlregistry->presence,
xmlregistry->caps, NULL);
xmlregistry->caps);
g_free (xmlregistry->name_template);
xmlregistry->name_template = NULL;
@ -1112,49 +978,6 @@ gst_xml_registry_end_element (GMarkupParseContext *context,
xmlregistry->parser = gst_xml_registry_parse_element_factory;
}
break;
case GST_XML_REGISTRY_CAPS:
if (!strcmp (element_name, "caps")) {
xmlregistry->state = GST_XML_REGISTRY_PADTEMPLATE;
xmlregistry->parser = gst_xml_registry_parse_padtemplate;
}
break;
case GST_XML_REGISTRY_CAPSCOMP:
if (!strcmp (element_name, "capscomp")) {
GstCaps *caps;
xmlregistry->state = GST_XML_REGISTRY_CAPS;
xmlregistry->parser = gst_xml_registry_parse_padtemplate;
caps = gst_caps_new (xmlregistry->caps_name, xmlregistry->caps_mime, xmlregistry->props);
g_free (xmlregistry->caps_mime);
g_free (xmlregistry->caps_name);
xmlregistry->caps = gst_caps_append (xmlregistry->caps, caps);
xmlregistry->props = NULL;
}
break;
case GST_XML_REGISTRY_PROPERTIES:
if (!strncmp (element_name, "list", 4)) {
GstPropsEntry *entry;
xmlregistry->entry_list = g_list_reverse (xmlregistry->entry_list);
entry = gst_props_entry_new (xmlregistry->list_name,
GST_PROPS_GLIST (xmlregistry->entry_list));
gst_props_add_entry (xmlregistry->props, entry);
g_list_free (xmlregistry->entry_list);
g_free (xmlregistry->list_name);
xmlregistry->entry_list = NULL;
xmlregistry->list_name = NULL;
xmlregistry->in_list = FALSE;
}
else if (!strcmp (element_name, "properties")) {
xmlregistry->state = GST_XML_REGISTRY_CAPSCOMP;
xmlregistry->parser = NULL;
}
break;
default:
break;
}
@ -1276,119 +1099,10 @@ G_STMT_START{ \
static gboolean
gst_xml_registry_save_props_func (GstPropsEntry *entry,
GstXMLRegistry *xmlregistry)
gst_xml_registry_save_caps (GstXMLRegistry *xmlregistry, const GstCaps *caps)
{
const gchar *name;
name = gst_props_entry_get_name (entry);
switch (gst_props_entry_get_props_type (entry)) {
case GST_PROPS_INT_TYPE:
{
gint value;
gst_props_entry_get_int (entry, &value);
CLASS (xmlregistry)->save_func (xmlregistry, "<int name=\"%s\" value=\"%d\"/>\n", name, value);
break;
}
case GST_PROPS_INT_RANGE_TYPE:
{
gint min, max;
gst_props_entry_get_int_range (entry, &min, &max);
CLASS (xmlregistry)->save_func (xmlregistry, "<range name=\"%s\" min=\"%d\" max=\"%d\"/>\n", name, min, max);
break;
}
case GST_PROPS_FLOAT_TYPE:
{
gfloat value;
gst_props_entry_get_float (entry, &value);
CLASS (xmlregistry)->save_func (xmlregistry, "<float name=\"%s\" value=\"%f\"/>\n", name, value);
break;
}
case GST_PROPS_FLOAT_RANGE_TYPE:
{
gfloat min, max;
gst_props_entry_get_float_range (entry, &min, &max);
CLASS (xmlregistry)->save_func (xmlregistry, "<floatrange name=\"%s\" min=\"%f\" max=\"%f\"/>\n", name, min, max);
break;
}
case GST_PROPS_FOURCC_TYPE:
{
guint32 fourcc;
gst_props_entry_get_fourcc_int (entry, &fourcc);
CLASS (xmlregistry)->save_func (xmlregistry, "<!-- "GST_FOURCC_FORMAT" -->\n",
GST_FOURCC_ARGS (fourcc));
CLASS (xmlregistry)->save_func (xmlregistry, "<fourcc name=\"%s\" hexvalue=\"%08x\"/>\n", name, fourcc);
break;
}
case GST_PROPS_BOOLEAN_TYPE:
{
gboolean value;
gst_props_entry_get_boolean (entry, &value);
CLASS (xmlregistry)->save_func (xmlregistry, "<boolean name=\"%s\" value=\"%s\"/>\n", name, (value ? "true" : "false"));
break;
}
case GST_PROPS_STRING_TYPE:
{
const gchar *value;
gst_props_entry_get_string (entry, &value);
CLASS (xmlregistry)->save_func (xmlregistry, "<string name=\"%s\" value=\"%s\"/>\n", name, value);
break;
}
default:
g_warning ("trying to save unknown property type %d", gst_props_entry_get_props_type (entry));
return FALSE;
}
return TRUE;
}
static gboolean
gst_xml_registry_save_props (GstXMLRegistry *xmlregistry, GstProps *props)
{
GList *proplist;
proplist = props->properties;
while (proplist) {
GstPropsEntry *entry = (GstPropsEntry *) proplist->data;
switch (gst_props_entry_get_props_type (entry)) {
case GST_PROPS_LIST_TYPE:
{
const GList *list;
gst_props_entry_get_list (entry, &list);
CLASS (xmlregistry)->save_func (xmlregistry, "<list name=\"%s\">\n", gst_props_entry_get_name (entry));
g_list_foreach ((GList *)list, (GFunc) gst_xml_registry_save_props_func, xmlregistry);
CLASS (xmlregistry)->save_func (xmlregistry, "</list>\n");
break;
}
default:
gst_xml_registry_save_props_func (entry, xmlregistry);
break;
}
proplist = g_list_next (proplist);
}
return TRUE;
}
static gboolean
gst_xml_registry_save_caps (GstXMLRegistry *xmlregistry, GstCaps *caps)
{
while (caps) {
CLASS (xmlregistry)->save_func (xmlregistry, "<capscomp>\n");
PUT_ESCAPED ("name", caps->name);
PUT_ESCAPED ("type", gst_caps_get_mime (caps));
if (caps->properties) {
CLASS (xmlregistry)->save_func (xmlregistry, "<properties>\n");
gst_xml_registry_save_props (xmlregistry, caps->properties);
CLASS (xmlregistry)->save_func (xmlregistry, "</properties>\n");
}
CLASS (xmlregistry)->save_func (xmlregistry, "</capscomp>\n");
caps = caps->next;
}
char *s = gst_caps_to_string (caps);
PUT_ESCAPED ("caps", s);
return TRUE;
}
@ -1417,9 +1131,7 @@ gst_xml_registry_save_pad_template (GstXMLRegistry *xmlregistry, GstPadTemplate
CLASS (xmlregistry)->save_func (xmlregistry, "<presence>%s</presence>\n", presence);
if (GST_PAD_TEMPLATE_CAPS (template)) {
CLASS (xmlregistry)->save_func (xmlregistry, "<caps>\n");
gst_xml_registry_save_caps (xmlregistry, GST_PAD_TEMPLATE_CAPS (template));
CLASS (xmlregistry)->save_func (xmlregistry, "</caps>\n");
}
return TRUE;
}
@ -1476,12 +1188,9 @@ gst_xml_registry_save_feature (GstXMLRegistry *xmlregistry, GstPluginFeature *fe
else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
gint i = 0;
/* FIXME
if (factory->caps) {
CLASS (xmlregistry)->save_func (xmlregistry, "<caps>\n");
gst_xml_registry_save_caps (xmlregistry, factory->caps);
CLASS (xmlregistry)->save_func (xmlregistry, "</caps>\n");
} */
}
if (factory->extensions) {
while (factory->extensions[i]) {
PUT_ESCAPED ("extension", factory->extensions[i]);

View file

@ -52,7 +52,7 @@ typedef enum {
GST_XML_REGISTRY_FEATURE,
GST_XML_REGISTRY_PADTEMPLATE,
GST_XML_REGISTRY_CAPS,
GST_XML_REGISTRY_CAPSCOMP,
GST_XML_REGISTRY_STRUCTURE,
GST_XML_REGISTRY_PROPERTIES
} GstXMLRegistryState;
@ -103,8 +103,9 @@ struct _GstXMLRegistry {
GstCaps *caps;
gchar *caps_name;
gchar *caps_mime;
GstProps *props;
gchar *structure_name;
//gchar *caps_mime;
//GstProps *props;
gboolean in_list;
GList *entry_list;

View file

@ -23,7 +23,6 @@
#define __GST_DPARAM_H__
#include <gst/gstobject.h>
#include <gst/gstprops.h>
#include "dparamcommon.h"
G_BEGIN_DECLS

View file

@ -23,7 +23,6 @@
#define __GST_DPMAN_H__
#include <gst/gstobject.h>
#include <gst/gstprops.h>
#include <gst/control/dparamcommon.h>
#include <gst/control/dparam.h>
#include <gst/control/unitconvert.h>

View file

@ -51,11 +51,11 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (aggregator_src_factory,
GstStaticPadTemplate aggregator_src_template = GST_STATIC_PAD_TEMPLATE (
"sink%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
#define GST_TYPE_AGGREGATOR_SCHED (gst_aggregator_sched_get_type())
@ -124,7 +124,8 @@ static void
gst_aggregator_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (aggregator_src_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&aggregator_src_template));
gst_element_class_set_details (gstelement_class, &gst_aggregator_details);
}
static void

View file

@ -56,11 +56,11 @@ enum {
ARG_LAST_MESSAGE,
};
GST_PAD_TEMPLATE_FACTORY (fakesink_sink_factory,
GstStaticPadTemplate fakesink_sink_template = GST_STATIC_PAD_TEMPLATE (
"sink%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
#define GST_TYPE_FAKESINK_STATE_ERROR (gst_fakesink_state_error_get_type())
@ -135,8 +135,10 @@ gst_fakesink_base_init (gpointer g_class)
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (gstelement_class, &gst_fakesink_details);
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (fakesink_sink_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&fakesink_sink_template));
}
static void
gst_fakesink_class_init (GstFakeSinkClass *klass)
{

View file

@ -73,11 +73,11 @@ enum {
ARG_LAST_MESSAGE,
};
GST_PAD_TEMPLATE_FACTORY (fakesrc_src_factory,
GstStaticPadTemplate fakesrc_src_template = GST_STATIC_PAD_TEMPLATE (
"src%d",
GST_PAD_SRC,
GST_PAD_REQUEST,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
#define GST_TYPE_FAKESRC_OUTPUT (gst_fakesrc_output_get_type())
@ -112,7 +112,6 @@ gst_fakesrc_data_get_type (void)
static GEnumValue fakesrc_data[] = {
{ FAKESRC_DATA_ALLOCATE, "1", "Allocate data"},
{ FAKESRC_DATA_SUBBUFFER, "2", "Subbuffer data"},
{ FAKESRC_DATA_BUFFERPOOL, "3", "Use the default buffer pool (forces sizetype=2)"},
{0, NULL, NULL},
};
if (!fakesrc_data_type) {
@ -204,8 +203,10 @@ gst_fakesrc_base_init (gpointer g_class)
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (gstelement_class, &gst_fakesrc_details);
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (fakesrc_src_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&fakesrc_src_template));
}
static void
gst_fakesrc_class_init (GstFakeSrcClass *klass)
{
@ -486,19 +487,6 @@ gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, G
src->parent = NULL;
}
}
if (src->data == FAKESRC_DATA_BUFFERPOOL) {
if (src->sizetype != FAKESRC_SIZETYPE_FIXED)
g_object_set (src, "sizetype", FAKESRC_SIZETYPE_FIXED, NULL);
if (!src->pool)
src->pool = gst_buffer_pool_get_default (src->sizemax, 10);
} else {
if (src->pool) {
gst_buffer_pool_unref (src->pool);
src->pool = NULL;
}
}
break;
case ARG_SIZETYPE:
src->sizetype = g_value_get_enum (value);
@ -726,10 +714,6 @@ gst_fakesrc_create_buffer (GstFakeSrc *src)
}
gst_fakesrc_prepare_buffer (src, buf);
break;
case FAKESRC_DATA_BUFFERPOOL:
buf = gst_buffer_new_from_pool (src->pool, 0, 0);
gst_fakesrc_prepare_buffer (src, buf);
break;
default:
g_warning ("fakesrc: dunno how to allocate buffers !");
buf = gst_buffer_new();
@ -867,10 +851,6 @@ gst_fakesrc_change_state (GstElement *element)
gst_buffer_unref (fakesrc->parent);
fakesrc->parent = NULL;
}
if (fakesrc->pool) {
gst_buffer_pool_unref (fakesrc->pool);
fakesrc->pool = NULL;
}
g_free (fakesrc->last_message);
fakesrc->last_message = NULL;
break;

View file

@ -43,7 +43,6 @@ typedef enum {
typedef enum {
FAKESRC_DATA_ALLOCATE = 1,
FAKESRC_DATA_SUBBUFFER,
FAKESRC_DATA_BUFFERPOOL
} GstFakeSrcDataType;
typedef enum {
@ -103,7 +102,6 @@ struct _GstFakeSrc {
gboolean signal_handoffs;
gboolean dump;
gboolean need_flush;
GstBufferPool *pool;
gchar *last_message;
};

View file

@ -152,21 +152,12 @@ gst_identity_class_init (GstIdentityClass *klass)
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_identity_get_property);
}
static GstBufferPool*
gst_identity_get_bufferpool (GstPad *pad)
{
GstIdentity *identity;
identity = GST_IDENTITY (gst_pad_get_parent (pad));
return gst_pad_get_bufferpool (identity->srcpad);
}
static GstCaps*
gst_identity_getcaps (GstPad *pad, GstCaps *caps)
gst_identity_getcaps (GstPad *pad)
{
GstIdentity *identity;
GstPad *otherpad;
GstPad *peer;
identity = GST_IDENTITY (gst_pad_get_parent (pad));
@ -175,20 +166,25 @@ gst_identity_getcaps (GstPad *pad, GstCaps *caps)
}
otherpad = (pad == identity->srcpad ? identity->sinkpad : identity->srcpad);
peer = GST_PAD_PEER (otherpad);
return gst_pad_get_allowed_caps (otherpad);
if (peer) {
return gst_pad_get_caps (peer);
} else {
return gst_caps_new_any ();
}
}
static GstPadLinkReturn
gst_identity_link (GstPad *pad, GstCaps *caps)
gst_identity_link (GstPad *pad, const GstCaps *caps)
{
GstIdentity *identity;
identity = GST_IDENTITY (gst_pad_get_parent (pad));
if (GST_CAPS_IS_FIXED (caps)) {
if (gst_caps_is_fixed (caps)) {
if (identity->delay_capsnego && GST_PAD_IS_SINK (pad)) {
identity->srccaps = gst_caps_ref (caps);
identity->srccaps = gst_caps_copy (caps);
return GST_PAD_LINK_OK;
}
@ -210,7 +206,6 @@ gst_identity_init (GstIdentity *identity)
identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad);
gst_pad_set_chain_function (identity->sinkpad, GST_DEBUG_FUNCPTR (gst_identity_chain));
gst_pad_set_bufferpool_function (identity->sinkpad, gst_identity_get_bufferpool);
gst_pad_set_link_function (identity->sinkpad, gst_identity_link);
gst_pad_set_getcaps_function (identity->sinkpad, gst_identity_getcaps);

View file

@ -54,11 +54,11 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (md5_sink_factory,
GstStaticPadTemplate md5_sink_template = GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
/* GObject stuff */
@ -412,8 +412,10 @@ gst_md5sink_base_init (gpointer g_class)
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (gstelement_class, &gst_md5sink_details);
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (md5_sink_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&md5_sink_template));
}
static void
gst_md5sink_class_init (GstMD5SinkClass *klass)
{
@ -438,7 +440,8 @@ static void
gst_md5sink_init (GstMD5Sink *md5sink)
{
GstPad *pad;
pad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (md5_sink_factory), "sink");
pad = gst_pad_new_from_template (gst_static_pad_template_get (
&md5_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (md5sink), pad);
gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_md5sink_chain));

View file

@ -83,16 +83,13 @@ static void gst_queue_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static GstCaps *gst_queue_getcaps (GstPad *pad,
GstCaps *caps);
static GstCaps *gst_queue_getcaps (GstPad *pad);
static GstPadLinkReturn
gst_queue_link (GstPad *pad,
GstCaps *caps);
const GstCaps *caps);
static void gst_queue_chain (GstPad *pad,
GstData *data);
static GstData *gst_queue_get (GstPad *pad);
static GstBufferPool *
gst_queue_get_bufferpool (GstPad *pad);
static gboolean gst_queue_handle_src_event (GstPad *pad,
GstEvent *event);
@ -254,7 +251,6 @@ gst_queue_init (GstQueue *queue)
queue->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_pad_set_chain_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_chain));
gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
gst_pad_set_bufferpool_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_get_bufferpool));
gst_pad_set_link_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_link));
gst_pad_set_getcaps_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_getcaps));
gst_pad_set_active (queue->sinkpad, TRUE);
@ -334,28 +330,20 @@ gst_queue_otherpad (GstPad *pad)
}
static GstPadLinkReturn
gst_queue_link (GstPad *pad,
GstCaps *caps)
gst_queue_link (GstPad *pad, const GstCaps *caps)
{
return gst_pad_proxy_link (gst_queue_otherpad (pad), caps);
}
static GstCaps *
gst_queue_getcaps (GstPad *pad,
GstCaps *caps)
gst_queue_getcaps (GstPad *pad)
{
GstPad *otherpad = GST_PAD_PEER (gst_queue_otherpad (pad));
if (otherpad)
return gst_pad_get_caps (otherpad);
return NULL;
}
static GstBufferPool *
gst_queue_get_bufferpool (GstPad *pad)
{
return gst_pad_get_bufferpool (gst_queue_otherpad (pad));
return gst_caps_new_any ();
}
static void

View file

@ -60,18 +60,18 @@ typedef struct
GstBuffer *buffer;
} GstShaperConnection;
GST_PAD_TEMPLATE_FACTORY (shaper_src_factory,
GstStaticPadTemplate shaper_src_template = GST_STATIC_PAD_TEMPLATE (
"src%d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
GST_PAD_TEMPLATE_FACTORY (shaper_sink_factory,
GstStaticPadTemplate shaper_sink_template = GST_STATIC_PAD_TEMPLATE (
"sink%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
#define GST_TYPE_SHAPER_POLICY (gst_shaper_policy_get_type())
@ -137,9 +137,12 @@ gst_shaper_base_init (gpointer g_class)
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (gstelement_class, &gst_shaper_details);
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (shaper_src_factory));
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (shaper_sink_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&shaper_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&shaper_sink_template));
}
static void
gst_shaper_class_init (GstShaperClass *klass)
{
@ -167,18 +170,8 @@ gst_shaper_class_init (GstShaperClass *klass)
gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_shaper_request_new_pad);
}
static GstBufferPool*
gst_shaper_get_bufferpool (GstPad *pad)
{
GstShaperConnection *connection;
connection = gst_pad_get_element_private (pad);
return gst_pad_get_bufferpool (connection->srcpad);
}
static GstCaps*
gst_shaper_getcaps (GstPad *pad, GstCaps *caps)
gst_shaper_getcaps (GstPad *pad)
{
GstPad *otherpad;
GstShaperConnection *connection;
@ -187,7 +180,7 @@ gst_shaper_getcaps (GstPad *pad, GstCaps *caps)
otherpad = (pad == connection->srcpad ? connection->sinkpad : connection->srcpad);
return gst_pad_get_allowed_caps (otherpad);
return gst_caps_copy (gst_pad_get_allowed_caps (otherpad));
}
static GList*
@ -207,7 +200,7 @@ gst_shaper_get_internal_link (GstPad *pad)
}
static GstPadLinkReturn
gst_shaper_link (GstPad *pad, GstCaps *caps)
gst_shaper_link (GstPad *pad, const GstCaps *caps)
{
GstPad *otherpad;
GstShaperConnection *connection;
@ -230,9 +223,9 @@ gst_shaper_create_connection (GstShaper *shaper)
connection = g_new0 (GstShaperConnection, 1);
padname = g_strdup_printf ("sink%d", shaper->nconnections);
connection->sinkpad = gst_pad_new_from_template (shaper_sink_factory (), padname);
connection->sinkpad = gst_pad_new_from_template (
gst_static_pad_template_get (&shaper_sink_template), padname);
g_free (padname);
gst_pad_set_bufferpool_function (connection->sinkpad, gst_shaper_get_bufferpool);
gst_pad_set_getcaps_function (connection->sinkpad, gst_shaper_getcaps);
gst_pad_set_internal_link_function (connection->sinkpad, gst_shaper_get_internal_link);
gst_pad_set_link_function (connection->sinkpad, gst_shaper_link);
@ -240,7 +233,8 @@ gst_shaper_create_connection (GstShaper *shaper)
gst_element_add_pad (GST_ELEMENT (shaper), connection->sinkpad);
padname = g_strdup_printf ("src%d", shaper->nconnections);
connection->srcpad = gst_pad_new_from_template (shaper_src_factory (), padname);
connection->srcpad = gst_pad_new_from_template (
gst_static_pad_template_get (&shaper_src_template), padname);
g_free (padname);
gst_pad_set_getcaps_function (connection->srcpad, gst_shaper_getcaps);
gst_pad_set_internal_link_function (connection->srcpad, gst_shaper_get_internal_link);

View file

@ -151,23 +151,12 @@ gst_statistics_class_init (GstStatisticsClass *klass)
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_statistics_get_property);
}
static GstBufferPool*
gst_statistics_get_bufferpool (GstPad *pad)
{
GstStatistics *statistics;
statistics = GST_STATISTICS (gst_pad_get_parent (pad));
return gst_pad_get_bufferpool (statistics->srcpad);
}
static void
gst_statistics_init (GstStatistics *statistics)
{
statistics->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (statistics), statistics->sinkpad);
gst_pad_set_chain_function (statistics->sinkpad, GST_DEBUG_FUNCPTR (gst_statistics_chain));
gst_pad_set_bufferpool_function (statistics->sinkpad, GST_DEBUG_FUNCPTR (gst_statistics_get_bufferpool));
statistics->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (statistics), statistics->srcpad);

View file

@ -53,11 +53,11 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (tee_src_factory,
GstStaticPadTemplate tee_src_template = GST_STATIC_PAD_TEMPLATE (
"src%d",
GST_PAD_SRC,
GST_PAD_REQUEST,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
static void gst_tee_base_init (gpointer g_class);
@ -106,7 +106,8 @@ gst_tee_base_init (gpointer g_class)
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (gstelement_class, &gst_tee_details);
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (tee_src_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&tee_src_template));
}
static void
gst_tee_class_init (GstTeeClass *klass)
@ -137,26 +138,20 @@ gst_tee_class_init (GstTeeClass *klass)
}
static GstPadLinkReturn
gst_tee_sinklink (GstPad *pad, GstCaps *caps)
gst_tee_sinklink (GstPad *pad, const GstCaps *caps)
{
GstTee *tee;
const GList *pads;
GstPadLinkReturn set_retval;
GstCaps *caps1;
GST_DEBUG ( "gst_tee_sinklink caps=%s", gst_caps_to_string(caps));
tee = GST_TEE (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps)) {
if (!gst_caps_is_fixed (caps)) {
return GST_PAD_LINK_DELAYED;
}
if (GST_CAPS_IS_CHAINED (caps)) {
caps1 = gst_caps_copy_1(caps);
caps = caps1;
}
/* go through all the src pads */
pads = gst_element_get_pad_list (GST_ELEMENT (tee));
@ -175,7 +170,7 @@ gst_tee_sinklink (GstPad *pad, GstCaps *caps)
}
static GstPadLinkReturn
gst_tee_srclink (GstPad *pad, GstCaps *caps)
gst_tee_srclink (GstPad *pad, const GstCaps *caps)
{
GstTee *tee;
@ -187,9 +182,9 @@ gst_tee_srclink (GstPad *pad, GstCaps *caps)
}
static GstCaps*
gst_tee_getcaps (GstPad *pad, GstCaps *filter)
gst_tee_getcaps (GstPad *pad)
{
GstCaps *caps = NULL;
GstCaps *caps = GST_CAPS_ANY;
GstTee *tee;
const GList *pads;
@ -202,7 +197,7 @@ gst_tee_getcaps (GstPad *pad, GstCaps *filter)
while (pads) {
GstPad *srcpad = GST_PAD (pads->data);
GstPad *peer;
GstCaps *peercaps;
const GstCaps *peercaps;
GstCaps *newcaps;
pads = g_list_next (pads);
@ -214,8 +209,7 @@ gst_tee_getcaps (GstPad *pad, GstCaps *filter)
peercaps = gst_pad_get_caps (peer);
newcaps = gst_caps_intersect (caps, peercaps);
gst_caps_unref (caps);
gst_caps_sink (peercaps);
gst_caps_free (caps);
caps = newcaps;
}

View file

@ -54,17 +54,18 @@ GstElementDetails gst_type_find_element_details = GST_ELEMENT_DETAILS (
);
/* generic templates */
GST_PAD_TEMPLATE_FACTORY (type_find_element_sink_factory,
GstStaticPadTemplate type_find_element_sink_template = GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
GST_PAD_TEMPLATE_FACTORY (type_find_element_src_factory,
GstStaticPadTemplate type_find_element_src_template = GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
/* TypeFind signals and args */
@ -183,7 +184,7 @@ gst_type_find_element_class_init (gpointer g_class, gpointer class_data)
g_object_class_install_property (gobject_class, ARG_CAPS,
g_param_spec_boxed ("caps", _("caps"), _("detected capabilities in stream"),
GST_TYPE_CAPS, G_PARAM_READABLE));
gst_caps_get_type(), G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_MINIMUM,
g_param_spec_uint ("minimum", _("minimum"), "minimum probability required to accept caps",
GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, G_PARAM_READWRITE));
@ -195,7 +196,7 @@ gst_type_find_element_class_init (gpointer g_class, gpointer class_data)
G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL,
gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2,
G_TYPE_UINT, GST_TYPE_CAPS);
G_TYPE_UINT, gst_caps_get_type());
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_type_find_element_change_state);
}
@ -206,13 +207,13 @@ gst_type_find_element_init (GTypeInstance *instance, gpointer g_class)
/* sinkpad */
typefind->sink = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (type_find_element_sink_factory), "sink");
gst_static_pad_template_get (&type_find_element_sink_template), "sink");
gst_pad_set_chain_function (typefind->sink,
gst_type_find_element_chain);
gst_element_add_pad (GST_ELEMENT (typefind), typefind->sink);
/* srcpad */
typefind->src = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (type_find_element_src_factory), "src");
gst_static_pad_template_get (&type_find_element_src_template), "src");
gst_pad_set_event_function (typefind->src, gst_type_find_element_src_event);
gst_pad_set_event_mask_function (typefind->src, gst_type_find_element_src_event_mask);
gst_element_add_pad (GST_ELEMENT (typefind), typefind->src);
@ -332,7 +333,7 @@ free_entry (TypeFindEntry *entry)
free_entry_buffers (entry);
if (entry->caps)
gst_caps_unref (entry->caps);
gst_caps_free (entry->caps);
g_free (entry);
}
static void
@ -472,7 +473,7 @@ find_peek (gpointer data, gint64 offset, guint size)
}
}
static void
find_suggest (gpointer data, guint probability, GstCaps *caps)
find_suggest (gpointer data, guint probability, const GstCaps *caps)
{
gchar *str;
TypeFindEntry *entry = (TypeFindEntry *) data;
@ -483,7 +484,7 @@ find_suggest (gpointer data, guint probability, GstCaps *caps)
g_free (str);
if (((gint) probability) > entry->probability) {
entry->probability = probability;
gst_caps_replace (&entry->caps, caps);
gst_caps_replace (&entry->caps, gst_caps_copy (caps));
}
}
static gint
@ -565,7 +566,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
GstCaps *found_caps = entry->caps;
guint probability = entry->probability;
gst_caps_ref (found_caps);
found_caps = gst_caps_copy (found_caps);
GST_INFO_OBJECT (typefind, "'%s' returned %u/%u probability, using it NOW",
GST_PLUGIN_FEATURE_NAME (entry->factory), probability, typefind->max_probability);
while (walk) {
@ -580,7 +581,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
typefind->possibilities = NULL;
g_list_free (typefind->possibilities);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, probability, found_caps);
gst_caps_unref (found_caps);
gst_caps_free (found_caps);
} else {
typefind->possibilities = g_list_prepend (typefind->possibilities, entry);
}

View file

@ -54,17 +54,18 @@ GstElementDetails gst_type_find_element_details = GST_ELEMENT_DETAILS (
);
/* generic templates */
GST_PAD_TEMPLATE_FACTORY (type_find_element_sink_factory,
GstStaticPadTemplate type_find_element_sink_template = GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
GST_PAD_TEMPLATE_FACTORY (type_find_element_src_factory,
GstStaticPadTemplate type_find_element_src_template = GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_ANY
GST_STATIC_CAPS_ANY
);
/* TypeFind signals and args */
@ -183,7 +184,7 @@ gst_type_find_element_class_init (gpointer g_class, gpointer class_data)
g_object_class_install_property (gobject_class, ARG_CAPS,
g_param_spec_boxed ("caps", _("caps"), _("detected capabilities in stream"),
GST_TYPE_CAPS, G_PARAM_READABLE));
gst_caps_get_type(), G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_MINIMUM,
g_param_spec_uint ("minimum", _("minimum"), "minimum probability required to accept caps",
GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, G_PARAM_READWRITE));
@ -195,7 +196,7 @@ gst_type_find_element_class_init (gpointer g_class, gpointer class_data)
G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL,
gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2,
G_TYPE_UINT, GST_TYPE_CAPS);
G_TYPE_UINT, gst_caps_get_type());
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_type_find_element_change_state);
}
@ -206,13 +207,13 @@ gst_type_find_element_init (GTypeInstance *instance, gpointer g_class)
/* sinkpad */
typefind->sink = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (type_find_element_sink_factory), "sink");
gst_static_pad_template_get (&type_find_element_sink_template), "sink");
gst_pad_set_chain_function (typefind->sink,
gst_type_find_element_chain);
gst_element_add_pad (GST_ELEMENT (typefind), typefind->sink);
/* srcpad */
typefind->src = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (type_find_element_src_factory), "src");
gst_static_pad_template_get (&type_find_element_src_template), "src");
gst_pad_set_event_function (typefind->src, gst_type_find_element_src_event);
gst_pad_set_event_mask_function (typefind->src, gst_type_find_element_src_event_mask);
gst_element_add_pad (GST_ELEMENT (typefind), typefind->src);
@ -332,7 +333,7 @@ free_entry (TypeFindEntry *entry)
free_entry_buffers (entry);
if (entry->caps)
gst_caps_unref (entry->caps);
gst_caps_free (entry->caps);
g_free (entry);
}
static void
@ -472,7 +473,7 @@ find_peek (gpointer data, gint64 offset, guint size)
}
}
static void
find_suggest (gpointer data, guint probability, GstCaps *caps)
find_suggest (gpointer data, guint probability, const GstCaps *caps)
{
gchar *str;
TypeFindEntry *entry = (TypeFindEntry *) data;
@ -483,7 +484,7 @@ find_suggest (gpointer data, guint probability, GstCaps *caps)
g_free (str);
if (((gint) probability) > entry->probability) {
entry->probability = probability;
gst_caps_replace (&entry->caps, caps);
gst_caps_replace (&entry->caps, gst_caps_copy (caps));
}
}
static gint
@ -565,7 +566,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
GstCaps *found_caps = entry->caps;
guint probability = entry->probability;
gst_caps_ref (found_caps);
found_caps = gst_caps_copy (found_caps);
GST_INFO_OBJECT (typefind, "'%s' returned %u/%u probability, using it NOW",
GST_PLUGIN_FEATURE_NAME (entry->factory), probability, typefind->max_probability);
while (walk) {
@ -580,7 +581,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
typefind->possibilities = NULL;
g_list_free (typefind->possibilities);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, probability, found_caps);
gst_caps_unref (found_caps);
gst_caps_free (found_caps);
} else {
typefind->possibilities = g_list_prepend (typefind->possibilities, entry);
}

View file

@ -1,87 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR GStreamer core team
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2003-12-20 17:28+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: gst/gst.c:116
msgid "Print the GStreamer version"
msgstr ""
#: gst/gst.c:117
msgid "Make all warnings fatal"
msgstr ""
#: gst/gst.c:119
msgid ""
"default debug level from 1 (only error) to 5 (anything) or 0 for no output"
msgstr ""
#: gst/gst.c:120
msgid ""
"colon-seperated list of category_name=level pairs to set specific levels for "
"the individual categories.\n"
"Example:GST_AUTOPLUG=5:GST_ELEMENT_*=3"
msgstr ""
#: gst/gst.c:121
msgid "disable color debugging output"
msgstr ""
#: gst/gst.c:122
msgid "disable debugging"
msgstr ""
#: gst/gst.c:123
msgid "print available debug categories and exit"
msgstr ""
#: gst/gst.c:125
msgid "Disable accelerated CPU instructions"
msgstr ""
#: gst/gst.c:126
msgid "enable verbose plugin loading diagnostics"
msgstr ""
#: gst/gst.c:127
msgid "'"
msgstr ""
#: gst/gst.c:127
msgid "'--separated path list for loading plugins"
msgstr ""
#: gst/gst.c:128
msgid ""
"comma-separated list of plugins to preload in addition to the list stored in "
"env variable GST_PLUGIN_PATH"
msgstr ""
#: gst/gst.c:129
msgid "disable trapping of segmentation faults during plugin loading"
msgstr ""
#: gst/gst.c:130
msgid "scheduler to use ('"
msgstr ""
#: gst/gst.c:130
msgid "' is the default)"
msgstr ""
#: gst/gst.c:131
msgid "registry to use"
msgstr ""

View file

@ -330,7 +330,7 @@ create_input_channel (int id, char* location)
#endif
new_element = gst_autoplug_to_caps (autoplug, srccaps,
gst_caps_new ("audio", "audio/raw", NULL), NULL);
gst_caps_new ("audio/raw", NULL), NULL);
if (!new_element) {
g_print ("could not autoplug, no suitable codecs found...\n");

View file

@ -57,31 +57,25 @@ enum {
* can have. They can be quite complex, but for this example plugin
* they are rather simple.
*/
GST_PAD_TEMPLATE_FACTORY (sink_factory,
GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE (
"sink", /* The name of the pad */
GST_PAD_SINK, /* Direction of the pad */
GST_PAD_ALWAYS, /* The pad exists for every instance */
GST_CAPS_NEW (
"example_sink", /* The name of the caps */
"unknown/unknown", /* The overall MIME/type */
"foo", GST_PROPS_INT (1), /* An integer property */
"bar", GST_PROPS_BOOLEAN (TRUE), /* A boolean */
"baz", GST_PROPS_LIST ( /* A list of values for */
GST_PROPS_INT (1),
GST_PROPS_INT (3)
)
GST_STATIC_CAPS (
"unknown/unknown, " /* The MIME media type */
"foo:int=1, " /* an integer property */
"bar:boolean=true, " /* a boolean property */
"baz:int={ 1, 3 }" /* a list of values */
)
);
/* This factory is much simpler, and defines the source pad. */
GST_PAD_TEMPLATE_FACTORY (src_factory,
GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"example_src",
"unknown/unknown",
NULL
GST_STATIC_CAPS (
"unknown/unknown"
)
);
@ -189,8 +183,10 @@ gst_example_class_init (GstExampleClass *klass)
/* The pad templates can be easily generated from the factories above,
* and then added to the list of padtemplates for the class.
*/
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (sink_factory));
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (src_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&sink_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&src_template));
}
/* This function is responsible for initializing a specific instance of
@ -203,7 +199,7 @@ gst_example_init(GstExample *example)
* We will use the template constructed by the factory.
*/
example->sinkpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (sink_factory), "sink");
gst_static_pad_template_get (&sink_template), "sink");
/* Setting the chain function allows us to supply the function that will
* actually be performing the work. Without this, the element would do
* nothing, with undefined results (assertion failures and such).
@ -220,7 +216,7 @@ gst_example_init(GstExample *example)
* they only produce them.
*/
example->srcpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (src_factory), "src");
gst_static_pad_template_get (&src_template), "src");
gst_element_add_pad(GST_ELEMENT(example),example->srcpad);
/* Initialization of element's private variables. */

View file

@ -1,7 +1,7 @@
#include <gst/gst.h>
void
type_found (GstElement *typefind, GstCaps* caps)
type_found (GstElement *typefind, const GstCaps * caps)
{
xmlDocPtr doc;
xmlNodePtr parent;
@ -10,7 +10,8 @@ type_found (GstElement *typefind, GstCaps* caps)
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
parent = xmlNewChild (doc->xmlRootNode, NULL, "Caps1", NULL);
gst_caps_save_thyself (caps, parent);
/* FIXME */
//gst_caps_save_thyself (caps, parent);
xmlDocDump (stdout, doc);
}

View file

@ -14,10 +14,10 @@ GST_DEBUG_DIRS = debug
endif
SUBDIRS = bins bytestream cleanup dynparams \
caps plugin elements clock refcounting tags threads \
caps caps2 plugin elements clock refcounting tags threads \
indexers debug $(GST_PARSE_DIRS) $(GST_DEBUG_DIRS)
DIST_SUBDIRS = bins bytestream caps cleanup clock dynparams elements indexers \
DIST_SUBDIRS = bins bytestream caps caps2 cleanup clock dynparams elements indexers \
plugin refcounting tags threads parse debug
tests_pass = test_gst_init

View file

@ -172,7 +172,7 @@ gst_bstest_class_init (GstBsTestClass * klass)
}
static GstCaps *
gst_bstest_getcaps (GstPad *pad, GstCaps *caps)
gst_bstest_getcaps (GstPad *pad)
{
GstBsTest *bstest = GST_BSTEST (gst_pad_get_parent (pad));
GstPad *otherpad;

View file

@ -1,116 +1,63 @@
#include <gst/gst.h>
/* these caps all have a non empty intersection */
GST_CAPS_FACTORY (sinkcaps,
GST_CAPS_NEW (
"mpeg2dec_sink",
"video/mpeg",
"mpegtype", GST_PROPS_LIST (
GST_PROPS_INT (1),
GST_PROPS_INT (2)
)
)
GstStaticCaps sinkcaps = GST_STATIC_CAPS(
"video/mpeg, "
"mpegtype=(int)[1,2]"
);
GST_CAPS_FACTORY (mp1parsecaps,
GST_CAPS_NEW (
"mp1parse_src",
"video/mpeg",
"mpegtype", GST_PROPS_LIST (
GST_PROPS_INT (1)
)
)
GstStaticCaps mp1parsecaps = GST_STATIC_CAPS(
"video/mpeg, "
"mpegtype=(int)1"
);
GST_CAPS_FACTORY (rawcaps,
GST_CAPS_NEW (
"mpeg2dec_src",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps = GST_STATIC_CAPS(
"video/raw, "
"fourcc=(fourcc){YV12,YUY2}, "
"width=(int)[16,4096], "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (rawcaps2,
GST_CAPS_NEW (
"raw_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12"))
),
"height", GST_PROPS_INT_RANGE (16, 256)
)
GstStaticCaps rawcaps2 = GST_STATIC_CAPS(
"video/raw, "
"fourcc=(fourcc)YUY2, "
"height=(int)[16,256]"
);
GST_CAPS_FACTORY (rawcaps3,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps3 = GST_STATIC_CAPS(
"video/raw, "
"fourcc=(fourcc){YV12,YUY2}, "
"height=(int)[16,4096]"
);
/* these caps aren't used yet
GST_CAPS_FACTORY (rawcaps4,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
#if 0
/* these caps aren't used yet */
GstStaticCaps rawcaps4 = GST_STATIC_CAPS(
"video/raw, "
"fourcc=(fourcc){\"YV12\", \"YUYV\"}, "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (rawcaps5,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps4 = GST_STATIC_CAPS(
"video/raw, "
"fourcc=(fourcc){\"YUYV\", \"YUY2\"}, "
"height=(int)[16,4096]"
);
*/
#endif
GST_CAPS_FACTORY(rawcaps6,
GST_CAPS_NEW (
"videotestsrc_src",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0'))
),
GST_CAPS_NEW (
"videotestsrc_src",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','V'))
)
)
GstStaticCaps rawcaps6 = GST_STATIC_CAPS(
"video/raw, "
"format=(fourcc)\"I420\"; "
"video/raw, "
"format=(fourcc)\"YUYV\""
);
GST_CAPS_FACTORY(rawcaps7,
GST_CAPS_NEW (
"xvideosink_sink",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0'))
),
GST_CAPS_NEW (
"xvideosink_sink",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2'))
)
)
GstStaticCaps rawcaps7 = GST_STATIC_CAPS(
"video/raw, "
"format=(fourcc)\"I420\"; "
"video/raw, "
"format=(fourcc)\"YV12\""
);
int
@ -121,43 +68,53 @@ main (int argc, char *argv[])
gst_init (&argc, &argv);
testret = gst_caps_is_always_compatible (GST_CAPS_GET (mp1parsecaps), GST_CAPS_GET (rawcaps));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&mp1parsecaps),
gst_static_caps_get (&rawcaps));
g_print ("4 <-> 2 == %d (invalid, wrong major type)\n", testret);
ret = ret + (testret == FALSE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (mp1parsecaps), GST_CAPS_GET (sinkcaps));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&mp1parsecaps),
gst_static_caps_get (&sinkcaps));
g_print ("4 <-> 1 == %d (valid, subset)\n", testret);
ret = ret + (testret == TRUE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (sinkcaps), GST_CAPS_GET (mp1parsecaps));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&sinkcaps),
gst_static_caps_get (&mp1parsecaps));
g_print ("1 <-> 4 == %d (invalid, superset)\n", testret);
ret = ret + (testret == FALSE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (rawcaps), GST_CAPS_GET (rawcaps2));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps),
gst_static_caps_get (&rawcaps2));
g_print ("2 <-> 3 == %d (invalid, ranges)\n", testret);
ret = ret + (testret == FALSE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (rawcaps), GST_CAPS_GET (rawcaps3));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps),
gst_static_caps_get (&rawcaps3));
g_print ("2 <-> 5 == %d (valid)\n", testret);
ret = ret + (testret == TRUE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (rawcaps3), GST_CAPS_GET (rawcaps));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps3),
gst_static_caps_get (&rawcaps));
g_print ("5 <-> 2 == %d (invalid)\n", testret);
ret = ret + (testret == FALSE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (rawcaps2), GST_CAPS_GET (rawcaps3));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps2),
gst_static_caps_get (&rawcaps3));
g_print ("3 <-> 5 == %d (valid)\n", testret);
ret = ret + (testret == TRUE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (rawcaps2), GST_CAPS_GET (rawcaps));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps2),
gst_static_caps_get (&rawcaps));
g_print ("3 <-> 2 == %d (invalid, property missing in source)\n", testret);
ret = ret + (testret == FALSE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (rawcaps), GST_CAPS_GET (rawcaps));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps),
gst_static_caps_get (&rawcaps));
g_print ("2 <-> 2 == %d (valid, same caps)\n", testret);
ret = ret + (testret == TRUE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (rawcaps6), GST_CAPS_GET (rawcaps7));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps6),
gst_static_caps_get (&rawcaps7));
g_print ("6 <-> 7 == %d (invalid, second caps doesn't fit)\n", testret);
ret = ret + (testret == FALSE) ? 0 : 1;

View file

@ -22,9 +22,8 @@
gint
main (gint argc, gchar *argv[])
{
#if 0
GstCaps *caps;
GstProps *props;
GstPropsEntry *entry;
gst_init (&argc, &argv);
@ -80,6 +79,7 @@ main (gint argc, gchar *argv[])
/* caps too */
g_assert (GST_CAPS_IS_FIXED (caps));
#endif
return 0;
}

View file

@ -1,44 +1,100 @@
#include <gst/gst.h>
GST_CAPS_FACTORY (rawcaps1,
GST_CAPS_NEW (
"raw1_sink_caps",
"video/raw",
"fourcc", GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV")),
"height", GST_PROPS_INT (640),
"width", GST_PROPS_INT (480),
"framerate",GST_PROPS_FLOAT (30.0)
),
GST_CAPS_NEW (
"raw1_sink_caps",
"video/raw",
"fourcc", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")),
"height", GST_PROPS_INT (640),
"width", GST_PROPS_INT (480),
"framerate",GST_PROPS_FLOAT (30.0)
)
GstStaticCaps rawcaps1 = GST_STATIC_CAPS(
"video/x-raw-yuv, "
"fourcc:fourcc=\"YUYV\", "
"height:int=640, "
"width:int=480, "
"framerate:float=30.0; "
"video/x-raw-yuv, "
"fourcc:fourcc=\"I420\", "
"height:int=640, "
"width:int=480, "
"framerate:float=30.0"
);
GstStaticCaps rawcaps2 = GST_STATIC_CAPS(
"video/x-raw-yuv"
);
GstStaticCaps rawcaps3 = GST_STATIC_CAPS(
"video/x-raw-yuv, height=(int) [ 0, MAX ]"
);
GstStaticCaps rawcaps4 = GST_STATIC_CAPS(
"video/x-raw-yuv, format=(fourcc)YUY2; video/x-raw-yuv, format=(fourcc)UYVY"
);
GstStaticCaps rawcaps5 = GST_STATIC_CAPS(
"video/x-raw-yuv, format=(fourcc)YUY2, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]; video/x-raw-yuv, format=(fourcc)UYVY, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]"
);
GstStaticCaps rawcaps6 = GST_STATIC_CAPS(
"video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240"
);
GstStaticCaps rawcaps7 = GST_STATIC_CAPS(
"video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[0,2147483647], height=(int)[0,2147483647], framerate=(double)[0,1.79769e+308]"
);
GstStaticCaps rawcaps8 = GST_STATIC_CAPS(
"video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240"
);
int
main (int argc, char *argv[])
{
GstCaps *caps1;
GstCaps *caps2;
GstCaps *caps3;
GstCaps *caps4;
GstCaps *caps;
gst_init (&argc, &argv);
caps1 = GST_CAPS_GET (rawcaps1);
caps2 = gst_caps_copy_1 (GST_CAPS_GET (rawcaps1));
caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps1));
caps2 = gst_caps_copy_1 (gst_static_caps_get (&rawcaps1));
#if 0
gst_caps_set(caps1, "height", GST_PROPS_INT(640));
gst_caps_set(caps1, "width", GST_PROPS_INT(480));
gst_caps_set(caps1, "framerate", GST_PROPS_FLOAT(30.0));
#endif
caps = gst_caps_intersect(caps1, caps2);
g_print("caps %s\n", gst_caps_to_string(caps));
if (gst_caps_is_empty (caps)) return 1;
gst_caps_free(caps1);
gst_caps_free(caps2);
caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps2));
caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps3));
caps = gst_caps_intersect(caps1, caps2);
g_print("caps %s\n", gst_caps_to_string(caps));
if (gst_caps_is_empty (caps)) return 1;
gst_caps_free(caps1);
gst_caps_free(caps2);
caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps4));
caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps5));
caps3 = gst_caps_copy( gst_static_caps_get (&rawcaps6));
caps4 = gst_caps_intersect(caps1, caps2);
caps = gst_caps_intersect(caps3, caps4);
g_print("caps4 %s\n", gst_caps_to_string(caps4));
g_print("caps %s\n", gst_caps_to_string(caps));
gst_caps_free(caps1);
gst_caps_free(caps2);
gst_caps_free(caps3);
gst_caps_free(caps4);
caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps7));
caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps8));
caps = gst_caps_intersect(caps1, caps2);
g_print("caps %s\n", gst_caps_to_string(caps));
if (gst_caps_is_empty (caps)) return 1;
gst_caps_free(caps1);
gst_caps_free(caps2);
if(caps == NULL)return 1;
return 0;
}

View file

@ -1,103 +1,65 @@
#include <gst/gst.h>
/* these caps all have a non empty intersection */
GST_CAPS_FACTORY (sinkcaps,
GST_CAPS_NEW (
"mpeg2dec_sink",
"video/mpeg",
"mpegtype", GST_PROPS_INT (1),
"foo1", GST_PROPS_INT_RANGE (20,40),
"foo2", GST_PROPS_INT_RANGE (20,40),
"foo3", GST_PROPS_INT_RANGE (10,20)
)
GstStaticCaps sinkcaps = GST_STATIC_CAPS (
"video/mpeg, "
"mpegtype=(int)1, "
"foo1=(int)[20,40], "
"foo2=(int)[20,40], "
"foo3=(int)[10,20]"
);
GST_CAPS_FACTORY (mp1parsecaps,
GST_CAPS_NEW (
"mp1parse_src",
"video/mpeg",
"mpegtype", GST_PROPS_INT (1),
"foo1", GST_PROPS_INT (30),
"foo2", GST_PROPS_INT_RANGE (20,30),
"foo3", GST_PROPS_INT_RANGE (20,30)
)
GstStaticCaps mp1parsecaps = GST_STATIC_CAPS (
"video/mpeg, "
"mpegtype=(int)1, "
"foo1=(int)30, "
"foo2=(int)[20,30], "
"foo3=(int)[20,30]"
);
GST_CAPS_FACTORY (rawcaps,
GST_CAPS_NEW (
"mpeg2dec_src",
"video/raw",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps = GST_STATIC_CAPS (
"video/raw, "
"width=(int)[16,4096], "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (rawcaps2,
GST_CAPS_NEW (
"raw_sink_caps",
"video/raw",
"height", GST_PROPS_INT_RANGE (16, 256),
"depth", GST_PROPS_INT (16)
)
GstStaticCaps rawcaps2 = GST_STATIC_CAPS (
"video/raw, "
"height=(int)[16,256], "
"depth=(int)16"
);
GST_CAPS_FACTORY (rawcaps3,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps3 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc){\"YUY2\", \"YV12\" }, "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (rawcaps4,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps4 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc){\"YUY2\",\"YV12\",\"YUYV\" }, "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (rawcaps5,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps5 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc){\"YUYV\",\"YUY2\"}, "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (rawcaps6,
GST_CAPS_NEW (
"raw6_sink_caps",
"video/raw",
"fourcc", GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV")),
"height", GST_PROPS_INT (640),
"width", GST_PROPS_INT (480),
"framerate",GST_PROPS_FLOAT (30.0)
),
GST_CAPS_NEW (
"raw6_sink_caps",
"video/raw",
"fourcc", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")),
"height", GST_PROPS_INT (640),
"width", GST_PROPS_INT (480),
"framerate",GST_PROPS_FLOAT (30.0)
)
GstStaticCaps rawcaps6 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc)\"YUYV\", "
"height=(int)640, "
"width=(int)480, "
"framerate=(double)30.0; "
"video/raw, "
"fourcc=(fourcc)\"I420\", "
"height=(int)640, "
"width=(int)480, "
"framerate=(double)30.0"
);
int
@ -115,30 +77,34 @@ main (int argc, char *argv[])
/*
g_mem_chunk_info ();
for (i = 0; i<100000; i++) {
caps = gst_caps_intersect (GST_CAPS_GET (rawcaps3), GST_CAPS_GET (rawcaps4));
caps = gst_caps_intersect (gst_static_caps_get (rawcaps3), GST_CAPS_GET (rawcaps4));
gst_caps_unref (caps);
}
g_mem_chunk_info ();
*/
caps = gst_caps_intersect (GST_CAPS_GET (sinkcaps), GST_CAPS_GET (mp1parsecaps));
caps = gst_caps_intersect (gst_static_caps_get (&sinkcaps),
gst_static_caps_get (&mp1parsecaps));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_intersect (GST_CAPS_GET (rawcaps), GST_CAPS_GET (rawcaps2));
caps = gst_caps_intersect (gst_static_caps_get (&rawcaps),
gst_static_caps_get (&rawcaps2));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities2", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_intersect (GST_CAPS_GET (rawcaps3), GST_CAPS_GET (rawcaps4));
caps = gst_caps_intersect (gst_static_caps_get (&rawcaps3),
gst_static_caps_get (&rawcaps4));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities3", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_intersect (GST_CAPS_GET (rawcaps3), GST_CAPS_GET (rawcaps5));
caps = gst_caps_intersect (gst_static_caps_get (&rawcaps3),
gst_static_caps_get (&rawcaps5));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities4", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_intersect (GST_CAPS_GET (rawcaps6),
gst_caps_copy_1(GST_CAPS_GET (rawcaps6)));
caps = gst_caps_intersect (gst_static_caps_get (&rawcaps6),
gst_caps_copy_1(gst_static_caps_get (&rawcaps6)));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities5", NULL);
gst_caps_save_thyself (caps, parent);

View file

@ -1,87 +1,46 @@
#include <gst/gst.h>
/* these caps all have a non empty intersection */
GST_CAPS_FACTORY (sinkcaps,
GST_CAPS_NEW (
"mpeg2dec_sink",
"video/mpeg",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"foo1", GST_PROPS_INT_RANGE (20,40),
"foo2", GST_PROPS_INT_RANGE (20,40),
"foo3", GST_PROPS_INT_RANGE (10,20)
)
GstStaticCaps sinkcaps = GST_STATIC_CAPS (
"video/mpeg, "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
"foo1=(int)[20,40], "
"foo2=(int)[20,40], "
"foo3=(int)[10,20]"
);
GST_CAPS_FACTORY (mp1parsecaps,
GST_CAPS_NEW (
"mp1parse_src",
"video/mpeg",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"foo4", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
)
)
GstStaticCaps mp1parsecaps = GST_STATIC_CAPS (
"video/mpeg, "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
"foo4=(fourcc){\"YV12\",\"YUY2\"}"
);
GST_CAPS_FACTORY (rawcaps,
GST_CAPS_NEW (
"mpeg2dec_src",
"video/raw",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096),
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
)
)
GstStaticCaps rawcaps = GST_STATIC_CAPS (
"video/raw, "
"width=(int)[16,4096], "
"height=(int)[16,4096], "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}"
);
GST_CAPS_FACTORY (rawcaps2,
GST_CAPS_NEW (
"raw_sink_caps",
"video/raw",
"height", GST_PROPS_INT_RANGE (16, 256),
"depth", GST_PROPS_INT (16)
),
GST_CAPS_NEW (
"raw_sink_caps",
"video/raw",
"height", GST_PROPS_INT_RANGE (16, 256),
"depth", GST_PROPS_INT (16)
)
GstStaticCaps rawcaps2 = GST_STATIC_CAPS (
"video/raw, "
"width=(int)[16,256], "
"height=(int)16; "
"video/raw, "
"width=(int)[16,256], "
"height=(int)16"
);
GST_CAPS_FACTORY (rawcaps3,
GST_CAPS_NEW (
"raw_sink_caps",
"video/raw",
"height", GST_PROPS_INT_RANGE (16, 256),
"depth", GST_PROPS_INT (16)
),
GST_CAPS_NEW (
"raw_sink_caps",
"video/raw",
"height", GST_PROPS_INT_RANGE (16, 256),
"depth", GST_PROPS_INT (16)
),
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps3 = GST_STATIC_CAPS (
"video/raw, "
"width=(int)[16,256], "
"height=(int)16; "
"video/raw, "
"width=(int)[16,256], "
"height=(int)16; "
"video/raw, "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
"height=(int)[16,4096]"
);
/* defined, not used
@ -123,23 +82,23 @@ main (int argc, char *argv[])
doc = xmlNewDoc ("1.0");
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
caps = gst_caps_normalize (GST_CAPS_GET (sinkcaps));
caps = gst_caps_normalize (gst_static_caps_get (&sinkcaps));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_normalize (GST_CAPS_GET (mp1parsecaps));
caps = gst_caps_normalize (gst_static_caps_get (&mp1parsecaps));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_normalize (GST_CAPS_GET (rawcaps));
caps = gst_caps_normalize (gst_static_caps_get (&rawcaps));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_normalize (GST_CAPS_GET (rawcaps2));
caps = gst_caps_normalize (gst_static_caps_get (&rawcaps2));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_normalize (GST_CAPS_GET (rawcaps3));
caps = gst_caps_normalize (gst_static_caps_get (&rawcaps3));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);

View file

@ -1,111 +1,60 @@
#include <gst/gst.h>
#include <string.h>
GST_CAPS_FACTORY (caps1,
GST_CAPS_NEW (
"mpeg2dec_sink",
"video/mpeg",
"mpegtype", GST_PROPS_LIST (
GST_PROPS_INT (1),
GST_PROPS_INT (2)
)
)
GstStaticCaps caps1 = GST_STATIC_CAPS (
"video/mpeg, "
"mpegtype=(int){1,2}"
);
GST_CAPS_FACTORY (caps2,
GST_CAPS_NEW (
"mp1parse_src",
"video/mpeg",
"mpegtype", GST_PROPS_LIST (
GST_PROPS_INT (1)
)
)
GstStaticCaps caps2 = GST_STATIC_CAPS (
"video/mpeg, "
"mpegtype=(int){1}"
);
GST_CAPS_FACTORY (caps3,
GST_CAPS_NEW (
"mpeg2dec_src",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps caps3 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
"width=(int)[16,4096], "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (caps4,
GST_CAPS_NEW (
"raw_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12"))
),
"height", GST_PROPS_INT_RANGE (16, 256)
)
GstStaticCaps caps4 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc)\"YV12\", "
"height=(int)[16,256]"
);
GST_CAPS_FACTORY (caps5,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps caps5 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (caps6,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps caps6 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc){\"YV12\",\"YUYV\"}, "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (caps7,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps caps7 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc){\"YVYV\",\"YUY2\"}, "
"height=(int)[16,4096]"
);
GstStaticCaps caps8 = GST_STATIC_CAPS (
"video/raw, "
"format=(fourcc)\"I420\"; "
"video/raw, "
"format=(fourcc)\"YUYV\""
);
GstStaticCaps caps9 = GST_STATIC_CAPS (
"video/raw, "
"format=(fourcc)\"I420\"; "
"video/raw, "
"format=(fourcc)\"YV12\""
);
GST_CAPS_FACTORY(caps8,
GST_CAPS_NEW (
"videotestsrc_src",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0'))
),
GST_CAPS_NEW (
"videotestsrc_src",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','V'))
)
)
GST_CAPS_FACTORY(caps9,
GST_CAPS_NEW (
"xvideosink_sink",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0'))
),
GST_CAPS_NEW (
"xvideosink_sink",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2'))
)
)
GST_CAPS_FACTORY(caps10,
GST_CAPS_NEW (
"my_caps",
"video/x-jpeg",
NULL
)
)
static gint test = 0;
static gint failures = 0;
@ -121,13 +70,12 @@ static gint failures = 0;
} \
}G_STMT_END
static void
test_caps_func (GstCaps *caps)
test_caps_func (const GstCaps *caps)
{
gchar *str1, *str2;
gboolean ret = FALSE;
str1 = gst_caps_to_string (caps);
gst_caps_unref (caps);
caps = gst_caps_from_string (str1);
if (!caps) {
g_print ("%3d, INFO : no caps from %s\n", test, str1);
@ -135,7 +83,6 @@ test_caps_func (GstCaps *caps)
return;
}
str2 = gst_caps_to_string (caps);
gst_caps_unref (caps);
g_print ("%3d, INFO : %s <==> %s\n", test, str1, str2);
ret = strcmp (str1, str2) == 0;
g_free (str1);
@ -143,7 +90,7 @@ test_caps_func (GstCaps *caps)
TEST_END (ret);
}
static void
test_caps (GstCaps *caps)
test_caps (const GstCaps *caps)
{
TEST_START;
test_caps_func (caps);
@ -171,6 +118,7 @@ test_string_fail (gchar *str)
TEST_START;
g_print ("%3d, INFO : checking %s for failure\n", test, str);
caps = gst_caps_from_string (str);
g_print("got %p\n", caps);
TEST_END (caps == NULL);
}
int
@ -180,76 +128,71 @@ main (int argc, char *argv[])
goto bla;
bla:
/* stupidity tests */
test_caps (gst_caps_new ("no_props", "audio/raw", NULL));
test_caps (gst_caps_new_simple ("audio/raw", NULL));
/* all sorts of caps */
test_caps (GST_PAD_TEMPLATE_GET (caps1));
test_caps (GST_PAD_TEMPLATE_GET (caps2));
test_caps (GST_PAD_TEMPLATE_GET (caps3));
test_caps (GST_PAD_TEMPLATE_GET (caps4));
test_caps (GST_PAD_TEMPLATE_GET (caps5));
test_caps (GST_PAD_TEMPLATE_GET (caps6));
test_caps (GST_PAD_TEMPLATE_GET (caps7));
test_caps (GST_PAD_TEMPLATE_GET (caps8));
test_caps (GST_PAD_TEMPLATE_GET (caps9));
test_caps (GST_PAD_TEMPLATE_GET (caps10));
test_caps (gst_static_caps_get (&caps1));
test_caps (gst_static_caps_get (&caps2));
test_caps (gst_static_caps_get (&caps3));
test_caps (gst_static_caps_get (&caps4));
test_caps (gst_static_caps_get (&caps5));
test_caps (gst_static_caps_get (&caps6));
test_caps (gst_static_caps_get (&caps7));
test_caps (gst_static_caps_get (&caps8));
test_caps (gst_static_caps_get (&caps9));
/* mime types */
test_string ("audio/raw");
test_string ("\"audio/raw\"");
test_string ("'audio/raw'");
test_string ("\\a\\u\\d\\i\\o/\\r\\a\\w");
/* fixed props entries */
test_string ("audio/raw ,test:int=1");
test_string ("audio/raw ,test:float= 1");
test_string ("audio/raw, test:fourcc =1");
test_string ("audio/raw ,test:i=1");
test_string ("audio/raw ,test:f= 1");
test_string ("audio/raw, test:4 =1");
test_string ("audio/raw,test: fourcc = 0x0000001");
test_string ("audio/raw , test:fourcc= RGB");
test_string ("audio/raw,test :fourcc= \"RGB \"");
test_string ("audio/raw , test: string=1");
test_string ("audio/raw ,test=(int)1");
test_string ("audio/raw ,test=(float) 1");
test_string ("audio/raw, test=(fourcc )1");
test_string ("audio/raw ,test=(i)1");
test_string ("audio/raw ,test=(f) 1");
test_string ("audio/raw, test=(4 )1");
test_string ("audio/raw,test=( fourcc ) 0x0000001");
test_string ("audio/raw,test =(fourcc) \"RGB \"");
test_string ("audio/raw , test=( string)1");
test_string ("audio/raw,test= 1");
test_string ("audio/raw,test = 1.0");
test_string ("audio/raw ,test= '1.0'");
test_string ("audio/raw,test: str= \"1\"");
test_string ("audio/raw ,test:b=False");
test_string ("audio/raw ,test :bool= trUE");
test_string ("audio/raw ,test:b = yes");
test_string ("audio/raw ,test : boolean=no");
test_string ("audio/raw ,test= \"1.0\"");
test_string ("audio/raw,test=( str) \"1\"");
test_string ("audio/raw ,test=(b)False");
test_string ("audio/raw ,test =(bool) trUE");
test_string ("audio/raw ,test=(b ) yes");
test_string ("audio/raw ,test =( boolean)no");
/* unfixed props entries */
test_string ("audio/raw, test= [ 1, 2 ]");
test_string ("audio/raw, test= [ 1.0 , 2]");
test_string ("audio/raw, test = [1, 2.5 ]");
test_string_fail ("audio/raw, test= [ 1.0 , 2]");
test_string_fail ("audio/raw, test = [1, 2.5 ]");
test_string ("audio/raw, test= [1.3, 2.1 ]");
test_string ("audio/raw, test :int = [1,2]");
test_string ("audio/raw, test :float = [1,2]");
test_string ("audio/raw, test= [int = 1, 2 ]");
test_string ("audio/raw, test:f= [ float=1.0 , 2]");
test_string ("audio/raw, test = [int =1, float = 2.5 ]");
test_string ("audio/raw, test:float= [1.3, float=2.1 ]");
test_string ("audio/raw, test :i= [int=1,2]");
test_string ("audio/raw, test:l= (int=1,2)");
test_string ("audio/raw, test:list= (int=1 ,2,3 ,int= 4 , 5 ,6 , int =7 ,8 , int = 9, 10)");
test_string ("audio/raw, test= (1.0)");
test_string ("audio/raw, test:list= (\"hi\", 'i dig ya', dude)");
test_string ("audio/raw, test:l= (int=1,2)");
test_string ("audio/raw, test:list= (int=1,2)");
test_string ("audio/raw, test =(int ) [1,2]");
test_string ("audio/raw, test =(double ) [1,2]");
test_string ("audio/raw, test= [(int) 1, 2 ]");
test_string ("audio/raw, test=(d) [ (double)1.0 , 2]");
test_string ("audio/raw, test=(double) [1.3, (double)2.1 ]");
test_string ("audio/raw, test =(i) [(int)1,2]");
test_string ("audio/raw, test={(int)1,2}");
test_string ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}");
test_string ("audio/raw, test= {1.0}");
test_string ("audio/raw, test= {\"hi\", \"i dig ya\", dude}");
test_string ("audio/raw, test= {(int)1,2}");
test_string ("audio/raw, test= {(int)1,2}");
/* prop concatenations */
test_string ("audio/raw, test:float= [1.3, float=2.1 ], test2= [ 1, 2 ]");
test_string ("audio/raw , test:fourcc= RGB,test2:int=1");
test_string ("audio/raw, test= [int = 1, 2 ] ,test2 :fourcc= \"RGB \"");
test_string ("audio/raw, test= [1.3, 2.1 ] , test2= (1.0)");
test_string ("audio/raw, test:list= (int=1 ,2,3 ,int= 4 , 5 ,6 , int =7 ,8 , int = 9, 10), test2 = [1, 2.5 ] , test3: string=1 ,test4:i=1");
test_string ("audio/raw, test=(double) [1.3, (double)2.1 ], test2= [ 1, 2 ]");
test_string ("audio/raw , test=(fourcc) \"RGB \",test2=(int)1");
test_string ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \"");
test_string ("audio/raw, test= [1.3, 2.1 ] , test2= {1.0}");
test_string ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}, test2 = [1.0, 2.5 ] , test3= (string)1 ,test4=(i)1");
/* caps concatenations */
test_string ("audio/raw, test= [int = 1, 2 ] ,test2 :fourcc= \"RGB \";\"audio/raw\"");
test_string ("audio/raw, test :float = [1,2] ; audio/raw, test:fourcc =1 ;'audio/raw', test:list= (\"hi\", 'i dig ya', dude)");
test_string ("audio/raw, test:float= [1.3, float=2.1 ];audio/raw, test :i= [int=1,2]");
test_string ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \";\"audio/raw\"");
test_string ("audio/raw, test =(double ) [1,2] ; audio/raw, test=(fourcc )1 ;audio/raw, test= {\"hi\", \"i dig ya\", dude}");
test_string ("audio/raw, test=(double) [1.3, (double)2.1 ];audio/raw, test =(i) [(int)1,2]");
/* mimes */
@ -257,12 +200,12 @@ bla:
test_string_fail ("'audio/raw");
test_string_fail ("'audio/raw\"");
/* wrong type */
test_string_fail ("audio/raw, test:int = [1.0,2]");
test_string_fail ("audio/raw, test:int = [1 ,0.2]");
test_string_fail ("audio/raw, test:int = [1.0, 2.000]");
test_string_fail ("audio/raw, test=(int) [1.0,2]");
test_string_fail ("audio/raw, test=(int) [1 ,0.2]");
test_string_fail ("audio/raw, test=(int) [1.0, 2.000]");
/* unmatched */
test_string_fail ("audio/raw, test:int = [");
test_string_fail ("audio/raw, test:l = (");
test_string_fail ("audio/raw, test=(int = [");
test_string_fail ("audio/raw, test= {");
test_string_fail ("audio/raw, test = \"dood'");
test_string_fail ("audio/raw, test= '");

View file

@ -1,26 +1,20 @@
#include <gst/gst.h>
/* these caps all have a non empty intersection */
GST_CAPS_FACTORY (sinkcaps,
GST_CAPS_NEW (
"mpeg2dec_sink",
"video/mpeg",
"mpegtype", GST_PROPS_INT (1),
"foo1", GST_PROPS_INT_RANGE (20,40),
"foo2", GST_PROPS_INT_RANGE (20,40),
"foo3", GST_PROPS_INT_RANGE (10,20)
)
GstStaticCaps sinkcaps = GST_STATIC_CAPS (
"video/mpeg, "
"mpegtype:int=1, "
"foo1:int=[20,40], "
"foo2:int=[20,40], "
"foo3:int=[10,20]"
);
GST_CAPS_FACTORY (mp1parsecaps,
GST_CAPS_NEW (
"mp1parse_src",
"video/mpeg",
"mpegtype", GST_PROPS_INT (1),
"foo1", GST_PROPS_INT (30),
"foo2", GST_PROPS_INT_RANGE (20,30),
"foo3", GST_PROPS_INT_RANGE (20,30)
)
GstStaticCaps mp1parsecaps = GST_STATIC_CAPS (
"video/mpeg, "
"mpegtype:int=1, "
"foo1:int=30, "
"foo2:int=[20,30], "
"foo3:int=[20,30]"
);
int
@ -35,7 +29,8 @@ main (int argc, char *argv[])
doc = xmlNewDoc ("1.0");
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
caps = gst_caps_union (GST_CAPS_GET (sinkcaps), GST_CAPS_GET (mp1parsecaps));
caps = gst_caps_union (gst_static_caps_get (&sinkcaps),
gst_static_caps_get (&mp1parsecaps));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);

View file

@ -25,7 +25,7 @@ gint
main (gint argc, gchar *argv[])
{
GstElement *pipeline;
gint i = 10000;
gint i = 1000;
gint step = 100;
free (malloc(8)); /* -lefence */

View file

@ -28,7 +28,7 @@ gint
main (gint argc, gchar *argv[])
{
GstElement *pipeline;
gint i = 10000;
gint i = 1000;
gint step = 100;
free (malloc(8)); /* -lefence */

View file

@ -11,7 +11,7 @@ main (gint argc, gchar *argv[])
gst_init (&argc, &argv);
i = 10000;
i = 1000;
pipeline = gst_pipeline_new ("main_pipeline");

View file

@ -3,7 +3,7 @@
int main(int argc,char *argv[])
{
GstElement *bin, *element;
gint i = 100000;
gint i = 1000;
gint step = 100;

View file

@ -13,7 +13,6 @@
*/
#include <gst/gst.h>
#include <gst/gstprops.h>
#include <property.h>
GstElement *
@ -45,7 +44,7 @@ main (int argc, char *argv[])
GstPad *tee_src1, *tee_src2;
GstCaps *src_caps = NULL;
GstCaps *sink_caps = NULL;
GstProps *props = NULL;
GstStructure *structure = NULL;
GstPad *pad = NULL;
/* init */
@ -100,46 +99,41 @@ main (int argc, char *argv[])
/* now we try setting caps on the src pad */
/* FIXME: should we set to pause here ? */
src_caps = GST_CAPS_NEW (
"input audio",
"audio/raw",
"format", GST_PROPS_STRING ("int"),
"rate", GST_PROPS_INT (44100)
);
src_caps = gst_caps_from_string ("audio/raw, format=(s)\"int\", "
"rate=(i)44100");
g_assert (src_caps != NULL);
g_print ("Setting caps on fakesrc's src pad\n");
pad = gst_element_get_pad (src, "src");
if ((gst_pad_try_set_caps (pad, src_caps)) <= 0)
{
if ((gst_pad_try_set_caps (pad, src_caps)) <= 0) {
g_print ("Could not set caps !\n");
}
/* now iterate and see if it proxies caps ok */
gst_bin_iterate (GST_BIN (pipeline));
sink_caps = gst_pad_get_caps (gst_element_get_pad (sink1, "sink"));
props = gst_caps_get_props (sink_caps);
if (! (gst_props_has_property (props, "rate")))
{
if (sink_caps && gst_caps_is_fixed (sink_caps)) {
structure = gst_caps_get_structure (sink_caps, 0);
}else {
structure = NULL;
g_print ("sink_caps is not fixed\n");
}
if (structure == NULL || !(gst_structure_has_field (structure, "rate"))) {
g_print ("Hm, rate has not been propagated to sink1.\n");
return 1;
}
else
{
} else {
int rate;
gst_props_get (props, "rate", &rate, NULL);
gst_structure_get_int (structure, "rate", &rate);
g_print ("Rate of pad on sink1 : %d\n", rate);
}
sink_caps = gst_pad_get_caps (gst_element_get_pad (sink2, "sink"));
props = gst_caps_get_props (sink_caps);
if (! (gst_props_has_property (props, "rate")))
{
structure = gst_caps_get_structure (sink_caps, 0);
if (structure != NULL && ! (gst_structure_has_field (structure, "rate"))) {
g_print ("Hm, rate has not been propagated to sink2.\n");
return 1;
}
else
{
} else {
int rate;
gst_props_get (props, "rate", &rate, NULL);
gst_structure_get_int (structure, "rate", &rate);
g_print ("Rate of pad on sink2 : %d\n", rate);
}

View file

@ -1,3 +1,4 @@
include ../Rules
plugin_LTLIBRARIES = libtestplugin.la libtestplugin2.la
@ -15,5 +16,5 @@ libtestplugin2_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
linked_LIBS = libtestplugin.la libtestplugin2.la
static_SOURCES = static.c testplugin_s.c testplugin2_s.c
static_SOURCES = static.c

View file

@ -1,6 +1,4 @@
#define GST_PLUGIN_STATIC
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -12,7 +10,7 @@ plugin_init (GstPlugin *plugin)
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_PLUGIN_DEFINE_STATIC (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"testplugin",
@ -30,7 +28,7 @@ plugin2_init (GstPlugin *plugin)
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_PLUGIN_DEFINE_STATIC (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"testplugin2",

View file

@ -22,3 +22,4 @@ GST_PLUGIN_DEFINE (
GST_PACKAGE,
GST_ORIGIN
);

View file

@ -1,3 +1,26 @@
#define GST_PLUGIN_STATIC
#include "testplugin2.c"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gst/gst.h>
static gboolean
plugin_init (GstPlugin *plugin)
{
return TRUE;
}
GST_PLUGIN_DEFINE_STATIC (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"testplugin2",
"another testplugin for testing",
plugin_init,
VERSION,
GST_LICENSE,
GST_COPYRIGHT,
GST_PACKAGE,
GST_ORIGIN
);

View file

@ -1,3 +1,25 @@
#define GST_PLUGIN_STATIC
#include "testplugin.c"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gst/gst.h>
static gboolean
plugin_init (GstPlugin *plugin)
{
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"testplugin",
"a plugin for testing",
plugin_init,
VERSION,
GST_LICENSE,
GST_COPYRIGHT,
GST_PACKAGE,
GST_ORIGIN
);

View file

@ -14,10 +14,10 @@ GST_DEBUG_DIRS = debug
endif
SUBDIRS = bins bytestream cleanup dynparams \
caps plugin elements clock refcounting tags threads \
caps caps2 plugin elements clock refcounting tags threads \
indexers debug $(GST_PARSE_DIRS) $(GST_DEBUG_DIRS)
DIST_SUBDIRS = bins bytestream caps cleanup clock dynparams elements indexers \
DIST_SUBDIRS = bins bytestream caps caps2 cleanup clock dynparams elements indexers \
plugin refcounting tags threads parse debug
tests_pass = test_gst_init

View file

@ -172,7 +172,7 @@ gst_bstest_class_init (GstBsTestClass * klass)
}
static GstCaps *
gst_bstest_getcaps (GstPad *pad, GstCaps *caps)
gst_bstest_getcaps (GstPad *pad)
{
GstBsTest *bstest = GST_BSTEST (gst_pad_get_parent (pad));
GstPad *otherpad;

View file

@ -1,116 +1,63 @@
#include <gst/gst.h>
/* these caps all have a non empty intersection */
GST_CAPS_FACTORY (sinkcaps,
GST_CAPS_NEW (
"mpeg2dec_sink",
"video/mpeg",
"mpegtype", GST_PROPS_LIST (
GST_PROPS_INT (1),
GST_PROPS_INT (2)
)
)
GstStaticCaps sinkcaps = GST_STATIC_CAPS(
"video/mpeg, "
"mpegtype=(int)[1,2]"
);
GST_CAPS_FACTORY (mp1parsecaps,
GST_CAPS_NEW (
"mp1parse_src",
"video/mpeg",
"mpegtype", GST_PROPS_LIST (
GST_PROPS_INT (1)
)
)
GstStaticCaps mp1parsecaps = GST_STATIC_CAPS(
"video/mpeg, "
"mpegtype=(int)1"
);
GST_CAPS_FACTORY (rawcaps,
GST_CAPS_NEW (
"mpeg2dec_src",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps = GST_STATIC_CAPS(
"video/raw, "
"fourcc=(fourcc){YV12,YUY2}, "
"width=(int)[16,4096], "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (rawcaps2,
GST_CAPS_NEW (
"raw_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12"))
),
"height", GST_PROPS_INT_RANGE (16, 256)
)
GstStaticCaps rawcaps2 = GST_STATIC_CAPS(
"video/raw, "
"fourcc=(fourcc)YUY2, "
"height=(int)[16,256]"
);
GST_CAPS_FACTORY (rawcaps3,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps3 = GST_STATIC_CAPS(
"video/raw, "
"fourcc=(fourcc){YV12,YUY2}, "
"height=(int)[16,4096]"
);
/* these caps aren't used yet
GST_CAPS_FACTORY (rawcaps4,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
#if 0
/* these caps aren't used yet */
GstStaticCaps rawcaps4 = GST_STATIC_CAPS(
"video/raw, "
"fourcc=(fourcc){\"YV12\", \"YUYV\"}, "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (rawcaps5,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps4 = GST_STATIC_CAPS(
"video/raw, "
"fourcc=(fourcc){\"YUYV\", \"YUY2\"}, "
"height=(int)[16,4096]"
);
*/
#endif
GST_CAPS_FACTORY(rawcaps6,
GST_CAPS_NEW (
"videotestsrc_src",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0'))
),
GST_CAPS_NEW (
"videotestsrc_src",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','V'))
)
)
GstStaticCaps rawcaps6 = GST_STATIC_CAPS(
"video/raw, "
"format=(fourcc)\"I420\"; "
"video/raw, "
"format=(fourcc)\"YUYV\""
);
GST_CAPS_FACTORY(rawcaps7,
GST_CAPS_NEW (
"xvideosink_sink",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0'))
),
GST_CAPS_NEW (
"xvideosink_sink",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2'))
)
)
GstStaticCaps rawcaps7 = GST_STATIC_CAPS(
"video/raw, "
"format=(fourcc)\"I420\"; "
"video/raw, "
"format=(fourcc)\"YV12\""
);
int
@ -121,43 +68,53 @@ main (int argc, char *argv[])
gst_init (&argc, &argv);
testret = gst_caps_is_always_compatible (GST_CAPS_GET (mp1parsecaps), GST_CAPS_GET (rawcaps));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&mp1parsecaps),
gst_static_caps_get (&rawcaps));
g_print ("4 <-> 2 == %d (invalid, wrong major type)\n", testret);
ret = ret + (testret == FALSE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (mp1parsecaps), GST_CAPS_GET (sinkcaps));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&mp1parsecaps),
gst_static_caps_get (&sinkcaps));
g_print ("4 <-> 1 == %d (valid, subset)\n", testret);
ret = ret + (testret == TRUE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (sinkcaps), GST_CAPS_GET (mp1parsecaps));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&sinkcaps),
gst_static_caps_get (&mp1parsecaps));
g_print ("1 <-> 4 == %d (invalid, superset)\n", testret);
ret = ret + (testret == FALSE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (rawcaps), GST_CAPS_GET (rawcaps2));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps),
gst_static_caps_get (&rawcaps2));
g_print ("2 <-> 3 == %d (invalid, ranges)\n", testret);
ret = ret + (testret == FALSE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (rawcaps), GST_CAPS_GET (rawcaps3));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps),
gst_static_caps_get (&rawcaps3));
g_print ("2 <-> 5 == %d (valid)\n", testret);
ret = ret + (testret == TRUE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (rawcaps3), GST_CAPS_GET (rawcaps));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps3),
gst_static_caps_get (&rawcaps));
g_print ("5 <-> 2 == %d (invalid)\n", testret);
ret = ret + (testret == FALSE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (rawcaps2), GST_CAPS_GET (rawcaps3));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps2),
gst_static_caps_get (&rawcaps3));
g_print ("3 <-> 5 == %d (valid)\n", testret);
ret = ret + (testret == TRUE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (rawcaps2), GST_CAPS_GET (rawcaps));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps2),
gst_static_caps_get (&rawcaps));
g_print ("3 <-> 2 == %d (invalid, property missing in source)\n", testret);
ret = ret + (testret == FALSE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (rawcaps), GST_CAPS_GET (rawcaps));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps),
gst_static_caps_get (&rawcaps));
g_print ("2 <-> 2 == %d (valid, same caps)\n", testret);
ret = ret + (testret == TRUE) ? 0 : 1;
testret = gst_caps_is_always_compatible (GST_CAPS_GET (rawcaps6), GST_CAPS_GET (rawcaps7));
testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps6),
gst_static_caps_get (&rawcaps7));
g_print ("6 <-> 7 == %d (invalid, second caps doesn't fit)\n", testret);
ret = ret + (testret == FALSE) ? 0 : 1;

View file

@ -22,9 +22,8 @@
gint
main (gint argc, gchar *argv[])
{
#if 0
GstCaps *caps;
GstProps *props;
GstPropsEntry *entry;
gst_init (&argc, &argv);
@ -80,6 +79,7 @@ main (gint argc, gchar *argv[])
/* caps too */
g_assert (GST_CAPS_IS_FIXED (caps));
#endif
return 0;
}

View file

@ -1,44 +1,100 @@
#include <gst/gst.h>
GST_CAPS_FACTORY (rawcaps1,
GST_CAPS_NEW (
"raw1_sink_caps",
"video/raw",
"fourcc", GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV")),
"height", GST_PROPS_INT (640),
"width", GST_PROPS_INT (480),
"framerate",GST_PROPS_FLOAT (30.0)
),
GST_CAPS_NEW (
"raw1_sink_caps",
"video/raw",
"fourcc", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")),
"height", GST_PROPS_INT (640),
"width", GST_PROPS_INT (480),
"framerate",GST_PROPS_FLOAT (30.0)
)
GstStaticCaps rawcaps1 = GST_STATIC_CAPS(
"video/x-raw-yuv, "
"fourcc:fourcc=\"YUYV\", "
"height:int=640, "
"width:int=480, "
"framerate:float=30.0; "
"video/x-raw-yuv, "
"fourcc:fourcc=\"I420\", "
"height:int=640, "
"width:int=480, "
"framerate:float=30.0"
);
GstStaticCaps rawcaps2 = GST_STATIC_CAPS(
"video/x-raw-yuv"
);
GstStaticCaps rawcaps3 = GST_STATIC_CAPS(
"video/x-raw-yuv, height=(int) [ 0, MAX ]"
);
GstStaticCaps rawcaps4 = GST_STATIC_CAPS(
"video/x-raw-yuv, format=(fourcc)YUY2; video/x-raw-yuv, format=(fourcc)UYVY"
);
GstStaticCaps rawcaps5 = GST_STATIC_CAPS(
"video/x-raw-yuv, format=(fourcc)YUY2, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]; video/x-raw-yuv, format=(fourcc)UYVY, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]"
);
GstStaticCaps rawcaps6 = GST_STATIC_CAPS(
"video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240"
);
GstStaticCaps rawcaps7 = GST_STATIC_CAPS(
"video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[0,2147483647], height=(int)[0,2147483647], framerate=(double)[0,1.79769e+308]"
);
GstStaticCaps rawcaps8 = GST_STATIC_CAPS(
"video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240"
);
int
main (int argc, char *argv[])
{
GstCaps *caps1;
GstCaps *caps2;
GstCaps *caps3;
GstCaps *caps4;
GstCaps *caps;
gst_init (&argc, &argv);
caps1 = GST_CAPS_GET (rawcaps1);
caps2 = gst_caps_copy_1 (GST_CAPS_GET (rawcaps1));
caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps1));
caps2 = gst_caps_copy_1 (gst_static_caps_get (&rawcaps1));
#if 0
gst_caps_set(caps1, "height", GST_PROPS_INT(640));
gst_caps_set(caps1, "width", GST_PROPS_INT(480));
gst_caps_set(caps1, "framerate", GST_PROPS_FLOAT(30.0));
#endif
caps = gst_caps_intersect(caps1, caps2);
g_print("caps %s\n", gst_caps_to_string(caps));
if (gst_caps_is_empty (caps)) return 1;
gst_caps_free(caps1);
gst_caps_free(caps2);
caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps2));
caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps3));
caps = gst_caps_intersect(caps1, caps2);
g_print("caps %s\n", gst_caps_to_string(caps));
if (gst_caps_is_empty (caps)) return 1;
gst_caps_free(caps1);
gst_caps_free(caps2);
caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps4));
caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps5));
caps3 = gst_caps_copy( gst_static_caps_get (&rawcaps6));
caps4 = gst_caps_intersect(caps1, caps2);
caps = gst_caps_intersect(caps3, caps4);
g_print("caps4 %s\n", gst_caps_to_string(caps4));
g_print("caps %s\n", gst_caps_to_string(caps));
gst_caps_free(caps1);
gst_caps_free(caps2);
gst_caps_free(caps3);
gst_caps_free(caps4);
caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps7));
caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps8));
caps = gst_caps_intersect(caps1, caps2);
g_print("caps %s\n", gst_caps_to_string(caps));
if (gst_caps_is_empty (caps)) return 1;
gst_caps_free(caps1);
gst_caps_free(caps2);
if(caps == NULL)return 1;
return 0;
}

View file

@ -1,103 +1,65 @@
#include <gst/gst.h>
/* these caps all have a non empty intersection */
GST_CAPS_FACTORY (sinkcaps,
GST_CAPS_NEW (
"mpeg2dec_sink",
"video/mpeg",
"mpegtype", GST_PROPS_INT (1),
"foo1", GST_PROPS_INT_RANGE (20,40),
"foo2", GST_PROPS_INT_RANGE (20,40),
"foo3", GST_PROPS_INT_RANGE (10,20)
)
GstStaticCaps sinkcaps = GST_STATIC_CAPS (
"video/mpeg, "
"mpegtype=(int)1, "
"foo1=(int)[20,40], "
"foo2=(int)[20,40], "
"foo3=(int)[10,20]"
);
GST_CAPS_FACTORY (mp1parsecaps,
GST_CAPS_NEW (
"mp1parse_src",
"video/mpeg",
"mpegtype", GST_PROPS_INT (1),
"foo1", GST_PROPS_INT (30),
"foo2", GST_PROPS_INT_RANGE (20,30),
"foo3", GST_PROPS_INT_RANGE (20,30)
)
GstStaticCaps mp1parsecaps = GST_STATIC_CAPS (
"video/mpeg, "
"mpegtype=(int)1, "
"foo1=(int)30, "
"foo2=(int)[20,30], "
"foo3=(int)[20,30]"
);
GST_CAPS_FACTORY (rawcaps,
GST_CAPS_NEW (
"mpeg2dec_src",
"video/raw",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps = GST_STATIC_CAPS (
"video/raw, "
"width=(int)[16,4096], "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (rawcaps2,
GST_CAPS_NEW (
"raw_sink_caps",
"video/raw",
"height", GST_PROPS_INT_RANGE (16, 256),
"depth", GST_PROPS_INT (16)
)
GstStaticCaps rawcaps2 = GST_STATIC_CAPS (
"video/raw, "
"height=(int)[16,256], "
"depth=(int)16"
);
GST_CAPS_FACTORY (rawcaps3,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps3 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc){\"YUY2\", \"YV12\" }, "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (rawcaps4,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps4 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc){\"YUY2\",\"YV12\",\"YUYV\" }, "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (rawcaps5,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps5 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc){\"YUYV\",\"YUY2\"}, "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (rawcaps6,
GST_CAPS_NEW (
"raw6_sink_caps",
"video/raw",
"fourcc", GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV")),
"height", GST_PROPS_INT (640),
"width", GST_PROPS_INT (480),
"framerate",GST_PROPS_FLOAT (30.0)
),
GST_CAPS_NEW (
"raw6_sink_caps",
"video/raw",
"fourcc", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")),
"height", GST_PROPS_INT (640),
"width", GST_PROPS_INT (480),
"framerate",GST_PROPS_FLOAT (30.0)
)
GstStaticCaps rawcaps6 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc)\"YUYV\", "
"height=(int)640, "
"width=(int)480, "
"framerate=(double)30.0; "
"video/raw, "
"fourcc=(fourcc)\"I420\", "
"height=(int)640, "
"width=(int)480, "
"framerate=(double)30.0"
);
int
@ -115,30 +77,34 @@ main (int argc, char *argv[])
/*
g_mem_chunk_info ();
for (i = 0; i<100000; i++) {
caps = gst_caps_intersect (GST_CAPS_GET (rawcaps3), GST_CAPS_GET (rawcaps4));
caps = gst_caps_intersect (gst_static_caps_get (rawcaps3), GST_CAPS_GET (rawcaps4));
gst_caps_unref (caps);
}
g_mem_chunk_info ();
*/
caps = gst_caps_intersect (GST_CAPS_GET (sinkcaps), GST_CAPS_GET (mp1parsecaps));
caps = gst_caps_intersect (gst_static_caps_get (&sinkcaps),
gst_static_caps_get (&mp1parsecaps));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_intersect (GST_CAPS_GET (rawcaps), GST_CAPS_GET (rawcaps2));
caps = gst_caps_intersect (gst_static_caps_get (&rawcaps),
gst_static_caps_get (&rawcaps2));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities2", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_intersect (GST_CAPS_GET (rawcaps3), GST_CAPS_GET (rawcaps4));
caps = gst_caps_intersect (gst_static_caps_get (&rawcaps3),
gst_static_caps_get (&rawcaps4));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities3", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_intersect (GST_CAPS_GET (rawcaps3), GST_CAPS_GET (rawcaps5));
caps = gst_caps_intersect (gst_static_caps_get (&rawcaps3),
gst_static_caps_get (&rawcaps5));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities4", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_intersect (GST_CAPS_GET (rawcaps6),
gst_caps_copy_1(GST_CAPS_GET (rawcaps6)));
caps = gst_caps_intersect (gst_static_caps_get (&rawcaps6),
gst_caps_copy_1(gst_static_caps_get (&rawcaps6)));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities5", NULL);
gst_caps_save_thyself (caps, parent);

View file

@ -1,87 +1,46 @@
#include <gst/gst.h>
/* these caps all have a non empty intersection */
GST_CAPS_FACTORY (sinkcaps,
GST_CAPS_NEW (
"mpeg2dec_sink",
"video/mpeg",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"foo1", GST_PROPS_INT_RANGE (20,40),
"foo2", GST_PROPS_INT_RANGE (20,40),
"foo3", GST_PROPS_INT_RANGE (10,20)
)
GstStaticCaps sinkcaps = GST_STATIC_CAPS (
"video/mpeg, "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
"foo1=(int)[20,40], "
"foo2=(int)[20,40], "
"foo3=(int)[10,20]"
);
GST_CAPS_FACTORY (mp1parsecaps,
GST_CAPS_NEW (
"mp1parse_src",
"video/mpeg",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"foo4", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
)
)
GstStaticCaps mp1parsecaps = GST_STATIC_CAPS (
"video/mpeg, "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
"foo4=(fourcc){\"YV12\",\"YUY2\"}"
);
GST_CAPS_FACTORY (rawcaps,
GST_CAPS_NEW (
"mpeg2dec_src",
"video/raw",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096),
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
)
)
GstStaticCaps rawcaps = GST_STATIC_CAPS (
"video/raw, "
"width=(int)[16,4096], "
"height=(int)[16,4096], "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}"
);
GST_CAPS_FACTORY (rawcaps2,
GST_CAPS_NEW (
"raw_sink_caps",
"video/raw",
"height", GST_PROPS_INT_RANGE (16, 256),
"depth", GST_PROPS_INT (16)
),
GST_CAPS_NEW (
"raw_sink_caps",
"video/raw",
"height", GST_PROPS_INT_RANGE (16, 256),
"depth", GST_PROPS_INT (16)
)
GstStaticCaps rawcaps2 = GST_STATIC_CAPS (
"video/raw, "
"width=(int)[16,256], "
"height=(int)16; "
"video/raw, "
"width=(int)[16,256], "
"height=(int)16"
);
GST_CAPS_FACTORY (rawcaps3,
GST_CAPS_NEW (
"raw_sink_caps",
"video/raw",
"height", GST_PROPS_INT_RANGE (16, 256),
"depth", GST_PROPS_INT (16)
),
GST_CAPS_NEW (
"raw_sink_caps",
"video/raw",
"height", GST_PROPS_INT_RANGE (16, 256),
"depth", GST_PROPS_INT (16)
),
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps rawcaps3 = GST_STATIC_CAPS (
"video/raw, "
"width=(int)[16,256], "
"height=(int)16; "
"video/raw, "
"width=(int)[16,256], "
"height=(int)16; "
"video/raw, "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
"height=(int)[16,4096]"
);
/* defined, not used
@ -123,23 +82,23 @@ main (int argc, char *argv[])
doc = xmlNewDoc ("1.0");
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
caps = gst_caps_normalize (GST_CAPS_GET (sinkcaps));
caps = gst_caps_normalize (gst_static_caps_get (&sinkcaps));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_normalize (GST_CAPS_GET (mp1parsecaps));
caps = gst_caps_normalize (gst_static_caps_get (&mp1parsecaps));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_normalize (GST_CAPS_GET (rawcaps));
caps = gst_caps_normalize (gst_static_caps_get (&rawcaps));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_normalize (GST_CAPS_GET (rawcaps2));
caps = gst_caps_normalize (gst_static_caps_get (&rawcaps2));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_normalize (GST_CAPS_GET (rawcaps3));
caps = gst_caps_normalize (gst_static_caps_get (&rawcaps3));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);

View file

@ -1,111 +1,60 @@
#include <gst/gst.h>
#include <string.h>
GST_CAPS_FACTORY (caps1,
GST_CAPS_NEW (
"mpeg2dec_sink",
"video/mpeg",
"mpegtype", GST_PROPS_LIST (
GST_PROPS_INT (1),
GST_PROPS_INT (2)
)
)
GstStaticCaps caps1 = GST_STATIC_CAPS (
"video/mpeg, "
"mpegtype=(int){1,2}"
);
GST_CAPS_FACTORY (caps2,
GST_CAPS_NEW (
"mp1parse_src",
"video/mpeg",
"mpegtype", GST_PROPS_LIST (
GST_PROPS_INT (1)
)
)
GstStaticCaps caps2 = GST_STATIC_CAPS (
"video/mpeg, "
"mpegtype=(int){1}"
);
GST_CAPS_FACTORY (caps3,
GST_CAPS_NEW (
"mpeg2dec_src",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps caps3 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
"width=(int)[16,4096], "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (caps4,
GST_CAPS_NEW (
"raw_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12"))
),
"height", GST_PROPS_INT_RANGE (16, 256)
)
GstStaticCaps caps4 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc)\"YV12\", "
"height=(int)[16,256]"
);
GST_CAPS_FACTORY (caps5,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps caps5 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (caps6,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps caps6 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc){\"YV12\",\"YUYV\"}, "
"height=(int)[16,4096]"
);
GST_CAPS_FACTORY (caps7,
GST_CAPS_NEW (
"raw2_sink_caps",
"video/raw",
"fourcc", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUYV")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))
),
"height", GST_PROPS_INT_RANGE (16, 4096)
)
GstStaticCaps caps7 = GST_STATIC_CAPS (
"video/raw, "
"fourcc=(fourcc){\"YVYV\",\"YUY2\"}, "
"height=(int)[16,4096]"
);
GstStaticCaps caps8 = GST_STATIC_CAPS (
"video/raw, "
"format=(fourcc)\"I420\"; "
"video/raw, "
"format=(fourcc)\"YUYV\""
);
GstStaticCaps caps9 = GST_STATIC_CAPS (
"video/raw, "
"format=(fourcc)\"I420\"; "
"video/raw, "
"format=(fourcc)\"YV12\""
);
GST_CAPS_FACTORY(caps8,
GST_CAPS_NEW (
"videotestsrc_src",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0'))
),
GST_CAPS_NEW (
"videotestsrc_src",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','V'))
)
)
GST_CAPS_FACTORY(caps9,
GST_CAPS_NEW (
"xvideosink_sink",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0'))
),
GST_CAPS_NEW (
"xvideosink_sink",
"video/raw",
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2'))
)
)
GST_CAPS_FACTORY(caps10,
GST_CAPS_NEW (
"my_caps",
"video/x-jpeg",
NULL
)
)
static gint test = 0;
static gint failures = 0;
@ -121,13 +70,12 @@ static gint failures = 0;
} \
}G_STMT_END
static void
test_caps_func (GstCaps *caps)
test_caps_func (const GstCaps *caps)
{
gchar *str1, *str2;
gboolean ret = FALSE;
str1 = gst_caps_to_string (caps);
gst_caps_unref (caps);
caps = gst_caps_from_string (str1);
if (!caps) {
g_print ("%3d, INFO : no caps from %s\n", test, str1);
@ -135,7 +83,6 @@ test_caps_func (GstCaps *caps)
return;
}
str2 = gst_caps_to_string (caps);
gst_caps_unref (caps);
g_print ("%3d, INFO : %s <==> %s\n", test, str1, str2);
ret = strcmp (str1, str2) == 0;
g_free (str1);
@ -143,7 +90,7 @@ test_caps_func (GstCaps *caps)
TEST_END (ret);
}
static void
test_caps (GstCaps *caps)
test_caps (const GstCaps *caps)
{
TEST_START;
test_caps_func (caps);
@ -171,6 +118,7 @@ test_string_fail (gchar *str)
TEST_START;
g_print ("%3d, INFO : checking %s for failure\n", test, str);
caps = gst_caps_from_string (str);
g_print("got %p\n", caps);
TEST_END (caps == NULL);
}
int
@ -180,76 +128,71 @@ main (int argc, char *argv[])
goto bla;
bla:
/* stupidity tests */
test_caps (gst_caps_new ("no_props", "audio/raw", NULL));
test_caps (gst_caps_new_simple ("audio/raw", NULL));
/* all sorts of caps */
test_caps (GST_PAD_TEMPLATE_GET (caps1));
test_caps (GST_PAD_TEMPLATE_GET (caps2));
test_caps (GST_PAD_TEMPLATE_GET (caps3));
test_caps (GST_PAD_TEMPLATE_GET (caps4));
test_caps (GST_PAD_TEMPLATE_GET (caps5));
test_caps (GST_PAD_TEMPLATE_GET (caps6));
test_caps (GST_PAD_TEMPLATE_GET (caps7));
test_caps (GST_PAD_TEMPLATE_GET (caps8));
test_caps (GST_PAD_TEMPLATE_GET (caps9));
test_caps (GST_PAD_TEMPLATE_GET (caps10));
test_caps (gst_static_caps_get (&caps1));
test_caps (gst_static_caps_get (&caps2));
test_caps (gst_static_caps_get (&caps3));
test_caps (gst_static_caps_get (&caps4));
test_caps (gst_static_caps_get (&caps5));
test_caps (gst_static_caps_get (&caps6));
test_caps (gst_static_caps_get (&caps7));
test_caps (gst_static_caps_get (&caps8));
test_caps (gst_static_caps_get (&caps9));
/* mime types */
test_string ("audio/raw");
test_string ("\"audio/raw\"");
test_string ("'audio/raw'");
test_string ("\\a\\u\\d\\i\\o/\\r\\a\\w");
/* fixed props entries */
test_string ("audio/raw ,test:int=1");
test_string ("audio/raw ,test:float= 1");
test_string ("audio/raw, test:fourcc =1");
test_string ("audio/raw ,test:i=1");
test_string ("audio/raw ,test:f= 1");
test_string ("audio/raw, test:4 =1");
test_string ("audio/raw,test: fourcc = 0x0000001");
test_string ("audio/raw , test:fourcc= RGB");
test_string ("audio/raw,test :fourcc= \"RGB \"");
test_string ("audio/raw , test: string=1");
test_string ("audio/raw ,test=(int)1");
test_string ("audio/raw ,test=(float) 1");
test_string ("audio/raw, test=(fourcc )1");
test_string ("audio/raw ,test=(i)1");
test_string ("audio/raw ,test=(f) 1");
test_string ("audio/raw, test=(4 )1");
test_string ("audio/raw,test=( fourcc ) 0x0000001");
test_string ("audio/raw,test =(fourcc) \"RGB \"");
test_string ("audio/raw , test=( string)1");
test_string ("audio/raw,test= 1");
test_string ("audio/raw,test = 1.0");
test_string ("audio/raw ,test= '1.0'");
test_string ("audio/raw,test: str= \"1\"");
test_string ("audio/raw ,test:b=False");
test_string ("audio/raw ,test :bool= trUE");
test_string ("audio/raw ,test:b = yes");
test_string ("audio/raw ,test : boolean=no");
test_string ("audio/raw ,test= \"1.0\"");
test_string ("audio/raw,test=( str) \"1\"");
test_string ("audio/raw ,test=(b)False");
test_string ("audio/raw ,test =(bool) trUE");
test_string ("audio/raw ,test=(b ) yes");
test_string ("audio/raw ,test =( boolean)no");
/* unfixed props entries */
test_string ("audio/raw, test= [ 1, 2 ]");
test_string ("audio/raw, test= [ 1.0 , 2]");
test_string ("audio/raw, test = [1, 2.5 ]");
test_string_fail ("audio/raw, test= [ 1.0 , 2]");
test_string_fail ("audio/raw, test = [1, 2.5 ]");
test_string ("audio/raw, test= [1.3, 2.1 ]");
test_string ("audio/raw, test :int = [1,2]");
test_string ("audio/raw, test :float = [1,2]");
test_string ("audio/raw, test= [int = 1, 2 ]");
test_string ("audio/raw, test:f= [ float=1.0 , 2]");
test_string ("audio/raw, test = [int =1, float = 2.5 ]");
test_string ("audio/raw, test:float= [1.3, float=2.1 ]");
test_string ("audio/raw, test :i= [int=1,2]");
test_string ("audio/raw, test:l= (int=1,2)");
test_string ("audio/raw, test:list= (int=1 ,2,3 ,int= 4 , 5 ,6 , int =7 ,8 , int = 9, 10)");
test_string ("audio/raw, test= (1.0)");
test_string ("audio/raw, test:list= (\"hi\", 'i dig ya', dude)");
test_string ("audio/raw, test:l= (int=1,2)");
test_string ("audio/raw, test:list= (int=1,2)");
test_string ("audio/raw, test =(int ) [1,2]");
test_string ("audio/raw, test =(double ) [1,2]");
test_string ("audio/raw, test= [(int) 1, 2 ]");
test_string ("audio/raw, test=(d) [ (double)1.0 , 2]");
test_string ("audio/raw, test=(double) [1.3, (double)2.1 ]");
test_string ("audio/raw, test =(i) [(int)1,2]");
test_string ("audio/raw, test={(int)1,2}");
test_string ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}");
test_string ("audio/raw, test= {1.0}");
test_string ("audio/raw, test= {\"hi\", \"i dig ya\", dude}");
test_string ("audio/raw, test= {(int)1,2}");
test_string ("audio/raw, test= {(int)1,2}");
/* prop concatenations */
test_string ("audio/raw, test:float= [1.3, float=2.1 ], test2= [ 1, 2 ]");
test_string ("audio/raw , test:fourcc= RGB,test2:int=1");
test_string ("audio/raw, test= [int = 1, 2 ] ,test2 :fourcc= \"RGB \"");
test_string ("audio/raw, test= [1.3, 2.1 ] , test2= (1.0)");
test_string ("audio/raw, test:list= (int=1 ,2,3 ,int= 4 , 5 ,6 , int =7 ,8 , int = 9, 10), test2 = [1, 2.5 ] , test3: string=1 ,test4:i=1");
test_string ("audio/raw, test=(double) [1.3, (double)2.1 ], test2= [ 1, 2 ]");
test_string ("audio/raw , test=(fourcc) \"RGB \",test2=(int)1");
test_string ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \"");
test_string ("audio/raw, test= [1.3, 2.1 ] , test2= {1.0}");
test_string ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}, test2 = [1.0, 2.5 ] , test3= (string)1 ,test4=(i)1");
/* caps concatenations */
test_string ("audio/raw, test= [int = 1, 2 ] ,test2 :fourcc= \"RGB \";\"audio/raw\"");
test_string ("audio/raw, test :float = [1,2] ; audio/raw, test:fourcc =1 ;'audio/raw', test:list= (\"hi\", 'i dig ya', dude)");
test_string ("audio/raw, test:float= [1.3, float=2.1 ];audio/raw, test :i= [int=1,2]");
test_string ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \";\"audio/raw\"");
test_string ("audio/raw, test =(double ) [1,2] ; audio/raw, test=(fourcc )1 ;audio/raw, test= {\"hi\", \"i dig ya\", dude}");
test_string ("audio/raw, test=(double) [1.3, (double)2.1 ];audio/raw, test =(i) [(int)1,2]");
/* mimes */
@ -257,12 +200,12 @@ bla:
test_string_fail ("'audio/raw");
test_string_fail ("'audio/raw\"");
/* wrong type */
test_string_fail ("audio/raw, test:int = [1.0,2]");
test_string_fail ("audio/raw, test:int = [1 ,0.2]");
test_string_fail ("audio/raw, test:int = [1.0, 2.000]");
test_string_fail ("audio/raw, test=(int) [1.0,2]");
test_string_fail ("audio/raw, test=(int) [1 ,0.2]");
test_string_fail ("audio/raw, test=(int) [1.0, 2.000]");
/* unmatched */
test_string_fail ("audio/raw, test:int = [");
test_string_fail ("audio/raw, test:l = (");
test_string_fail ("audio/raw, test=(int = [");
test_string_fail ("audio/raw, test= {");
test_string_fail ("audio/raw, test = \"dood'");
test_string_fail ("audio/raw, test= '");

View file

@ -1,26 +1,20 @@
#include <gst/gst.h>
/* these caps all have a non empty intersection */
GST_CAPS_FACTORY (sinkcaps,
GST_CAPS_NEW (
"mpeg2dec_sink",
"video/mpeg",
"mpegtype", GST_PROPS_INT (1),
"foo1", GST_PROPS_INT_RANGE (20,40),
"foo2", GST_PROPS_INT_RANGE (20,40),
"foo3", GST_PROPS_INT_RANGE (10,20)
)
GstStaticCaps sinkcaps = GST_STATIC_CAPS (
"video/mpeg, "
"mpegtype:int=1, "
"foo1:int=[20,40], "
"foo2:int=[20,40], "
"foo3:int=[10,20]"
);
GST_CAPS_FACTORY (mp1parsecaps,
GST_CAPS_NEW (
"mp1parse_src",
"video/mpeg",
"mpegtype", GST_PROPS_INT (1),
"foo1", GST_PROPS_INT (30),
"foo2", GST_PROPS_INT_RANGE (20,30),
"foo3", GST_PROPS_INT_RANGE (20,30)
)
GstStaticCaps mp1parsecaps = GST_STATIC_CAPS (
"video/mpeg, "
"mpegtype:int=1, "
"foo1:int=30, "
"foo2:int=[20,30], "
"foo3:int=[20,30]"
);
int
@ -35,7 +29,8 @@ main (int argc, char *argv[])
doc = xmlNewDoc ("1.0");
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
caps = gst_caps_union (GST_CAPS_GET (sinkcaps), GST_CAPS_GET (mp1parsecaps));
caps = gst_caps_union (gst_static_caps_get (&sinkcaps),
gst_static_caps_get (&mp1parsecaps));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);

View file

@ -25,7 +25,7 @@ gint
main (gint argc, gchar *argv[])
{
GstElement *pipeline;
gint i = 10000;
gint i = 1000;
gint step = 100;
free (malloc(8)); /* -lefence */

View file

@ -28,7 +28,7 @@ gint
main (gint argc, gchar *argv[])
{
GstElement *pipeline;
gint i = 10000;
gint i = 1000;
gint step = 100;
free (malloc(8)); /* -lefence */

View file

@ -11,7 +11,7 @@ main (gint argc, gchar *argv[])
gst_init (&argc, &argv);
i = 10000;
i = 1000;
pipeline = gst_pipeline_new ("main_pipeline");

Some files were not shown because too many files have changed in this diff Show more