testsuite/bins/Makefile
testsuite/bytestream/Makefile
testsuite/caps/Makefile
+testsuite/caps2/Makefile
testsuite/cleanup/Makefile
testsuite/clock/Makefile
testsuite/debug/Makefile
--- /dev/null
+
+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.
+
+
+
+
--- /dev/null
+
+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 ]
+
+
#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");
* can have. They can be quite complex, but for this example plugin
* they are rather simple.
*/
-GST_PAD_TEMPLATE_FACTORY (sink_factory,
- "sink", /* The name of the pad */
+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"
)
);
/* 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
* 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).
* 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. */
#include <gst/gst.h>
void
-type_found (GstElement *typefind, GstCaps* caps)
+type_found (GstElement *typefind, const GstCaps * caps)
{
xmlDocPtr doc;
xmlNodePtr parent;
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);
}
gstatomic.c \
gstbin.c \
gstbuffer.c \
- gstbufferpool-default.c \
- gstcaps.c \
+ gstcaps2.c \
gstclock.c \
gstcpu.c \
gstdata.c \
gstpipeline.c \
gstplugin.c \
gstpluginfeature.c \
- gstprops.c \
gstprobe.c \
gstqueue.c \
gstquery.c \
gstobject.h \
gstbin.h \
gstbuffer.h \
- gstbufferpool-default.h \
- gstcaps.h \
+ gstcaps2.h \
gstclock.h \
gstcompat.h \
gstcpu.h \
gstplugin.h \
gstpluginfeature.h \
gstprobe.h \
- gstprops.h \
gstqueue.h \
gstquery.h \
gstscheduler.h \
* 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;
return FALSE;
/* hurrah, we can link, now remove the intersection */
- gst_caps_unref (caps);
+ gst_caps_free (caps);
return TRUE;
}
* 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;
* 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;
* 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 */
g_return_val_if_fail (srccaps != NULL, NULL);
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_INFO ("attempting to autoplug via shortest path from %s to %s",
+ 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)
};
/* 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)
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__ */
};
/* 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 */
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);
/* 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 */
/* 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);
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));
/* 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;
}
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);
-
- return NULL;
+ if (otherpad != NULL) {
+ peer = GST_PAD_PEER (otherpad);
+
+ if (peer)
+ return gst_pad_get_caps (peer);
+ }
+ return gst_caps_new_any ();
}
GstPad*
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 */
}
}
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;
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;
}
}
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;
}
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);
/* 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())
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
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())
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)
{
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())
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) {
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)
{
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);
}
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();
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;
typedef enum {
FAKESRC_DATA_ALLOCATE = 1,
FAKESRC_DATA_SUBBUFFER,
- FAKESRC_DATA_BUFFERPOOL
} GstFakeSrcDataType;
typedef enum {
gboolean signal_handoffs;
gboolean dump;
gboolean need_flush;
- GstBufferPool *pool;
gchar *last_message;
};
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));
}
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;
}
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);
/* 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 */
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)
{
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));
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())
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)
{
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;
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*
}
static GstPadLinkReturn
-gst_shaper_link (GstPad *pad, GstCaps *caps)
+gst_shaper_link (GstPad *pad, const GstCaps *caps)
{
GstPad *otherpad;
GstShaperConnection *connection;
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);
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);
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);
/* 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);
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)
}
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));
}
static GstPadLinkReturn
-gst_tee_srclink (GstPad *pad, GstCaps *caps)
+gst_tee_srclink (GstPad *pad, const GstCaps *caps)
{
GstTee *tee;
}
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;
while (pads) {
GstPad *srcpad = GST_PAD (pads->data);
GstPad *peer;
- GstCaps *peercaps;
+ const GstCaps *peercaps;
GstCaps *newcaps;
pads = g_list_next (pads);
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;
}
);
/* 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 */
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));
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);
}
/* 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);
free_entry_buffers (entry);
if (entry->caps)
- gst_caps_unref (entry->caps);
+ gst_caps_free (entry->caps);
g_free (entry);
}
static void
}
}
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;
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
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) {
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);
}
);
/* 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 */
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));
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);
}
/* 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);
free_entry_buffers (entry);
if (entry->caps)
- gst_caps_unref (entry->caps);
+ gst_caps_free (entry->caps);
g_free (entry);
}
static void
}
}
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;
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
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) {
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);
}
_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 ();
#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>
#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>
#include "gstbuffer.h"
#include "gstmemchunk.h"
#include "gstinfo.h"
-#include "gstbufferpool-default.h"
GType _gst_buffer_type;
GType _gst_buffer_pool_type;
#include "gsttrace.h"
static GstAllocTrace *_gst_buffer_trace;
-static GstAllocTrace *_gst_buffer_pool_trace;
#endif
static GstMemChunk *chunk;
#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),
}
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)
{
gst_data_unref (GST_DATA (buffer->pool_private));
#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.
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;
}
/**
- * 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.
* @offset: the offset into parent #GstBuffer.
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;
-}
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)
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; \
#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)))
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__ */
+++ /dev/null
-/* GStreamer
- * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
- * 2000 Wim Taymans <wtay@chello.be>
- *
- * gstcaps.c: Element capabilities 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.
- */
-
-#include "gst_private.h"
-
-#include "gstcaps.h"
-#include "gstmemchunk.h"
-#include "gstinfo.h"
-
-#ifndef GST_DISABLE_TRACE
-/* #define GST_WITH_ALLOC_TRACE */
-#include "gsttrace.h"
-
-static GstAllocTrace *_gst_caps_trace;
-#endif
-
-static GstMemChunk *_gst_caps_chunk;
-
-GType _gst_caps_type;
-
-extern GstProps * __gst_props_from_string_func (gchar *s, gchar **end, gboolean caps);
-extern gboolean __gst_props_parse_string (gchar *r, gchar **end, gchar **next);
-
-/* transform functions */
-static void gst_caps_transform_to_string (const GValue *src_value, GValue *dest_value);
-
-static void gst_caps_destroy (GstCaps *caps);
-
-
-static void
-gst_caps_transform_to_string (const GValue *src_value, GValue *dest_value)
-{
- GstCaps *caps = g_value_peek_pointer (src_value);
- dest_value->data[0].v_pointer = gst_caps_to_string (caps);
-}
-/**
- * gst_caps_to_string:
- * caps: the caps to convert to a string
- *
- * Converts a #GstCaps into a readable format. This is mainly intended for
- * debugging purposes. You have to free the string using g_free.
- * A string converted with #gst_caps_to_string can always be converted back to
- * its caps representation using #gst_caps_from_string.
- *
- * Returns: A newly allocated string
- */
-gchar *
-gst_caps_to_string (GstCaps *caps)
-{
- gchar *ret;
- GString *result;
-
- result = g_string_new ("");
-
- if(caps==NULL){
- g_string_append(result, "NULL");
- }
-
- while (caps) {
- gchar *props;
- GValue value = { 0, }; /* the important thing is that value.type = 0 */
-
- g_string_append_printf (result, "\"%s\"", gst_caps_get_mime (caps));
-
- if (caps->properties) {
- g_value_init (&value, GST_TYPE_PROPS);
- g_value_set_boxed (&value, caps->properties);
- props = g_strdup_value_contents (&value);
-
- /* this happens with empty (but existing) caps->properties */
- if (props[0] != '\0') {
- g_value_unset (&value);
- g_string_append (result, ", ");
- g_string_append (result, props);
- g_free (props);
- }
- }
-
- caps = caps->next;
- if (caps)
- g_string_append (result, "; ");
- }
- ret = result->str;
- g_string_free (result, FALSE);
- return ret;
-}
-
-static GstCaps *
-gst_caps_from_string_func (gchar *r)
-{
- gchar *mime, *w;
- GstCaps *caps, *append;
- GstProps *props = NULL;
-
- mime = r;
- if (!__gst_props_parse_string (r, &w, &r)) goto error;
-
- if (*r == '\0') goto found;
- if (*r++ != ',') goto error;
- while (g_ascii_isspace (*r)) r++;
-
- props = __gst_props_from_string_func (r, &r, TRUE);
- if (!props) goto error;
-
-found:
- *w = '\0';
- if (*mime == '\0') {
- gst_props_unref (props);
- goto error;
- }
- caps = gst_caps_new ("parsed caps", mime, props);
- if (*r == '\0')
- return caps;
-
- while (g_ascii_isspace (*r)) r++;
- if (*r == ';') {
- r++;
- while (g_ascii_isspace (*r)) r++;
- append = gst_caps_from_string_func (r);
- if (!append) {
- gst_caps_unref (caps);
- goto error;
- }
- gst_caps_append (caps, append);
- }
-
- return caps;
-
-error:
- return NULL;
-}
-/**
- * gst_caps_from_string:
- * str: the str to convert into caps
- *
- * Tries to convert a string into a #GstCaps. This is mainly intended for
- * debugging purposes. The returned caps are floating.
- *
- * Returns: A floating caps or NULL if the string couldn't be converted
- */
-GstCaps *
-gst_caps_from_string (gchar *str)
-{
- gchar *s;
- GstCaps *caps;
- g_return_val_if_fail (str != NULL, NULL);
-
- s = g_strdup (str);
- caps = gst_caps_from_string_func (s);
- g_free (s);
-
- return caps;
-}
-void
-_gst_caps_initialize (void)
-{
- _gst_caps_chunk = gst_mem_chunk_new ("GstCaps",
- sizeof (GstCaps), sizeof (GstCaps) * 256,
- G_ALLOC_AND_FREE);
-
- _gst_caps_type = g_boxed_type_register_static ("GstCaps",
- (GBoxedCopyFunc) gst_caps_ref,
- (GBoxedFreeFunc) gst_caps_unref);
-
- g_value_register_transform_func (_gst_caps_type, G_TYPE_STRING,
- gst_caps_transform_to_string);
-
-#ifndef GST_DISABLE_TRACE
- _gst_caps_trace = gst_alloc_trace_register (GST_CAPS_TRACE_NAME);
-#endif
-}
-
-GType
-gst_caps_get_type (void)
-{
- return _gst_caps_type;
-}
-/**
- * gst_caps_new:
- * @name: the name of this capability
- * @mime: the mime type to attach to the capability
- * @props: the properties to add to this capability
- *
- * Create a new capability with the given mime type and properties.
- *
- * Returns: a new capability
- */
-GstCaps*
-gst_caps_new (const gchar *name, const gchar *mime, GstProps *props)
-{
- g_return_val_if_fail (mime != NULL, NULL);
-
- return gst_caps_new_id (name, g_quark_from_string (mime), props);
-}
-/**
- * gst_caps_new_id:
- * @name: the name of this capability
- * @id: the id of the mime type
- * @props: the properties to add to this capability
- *
- * Create a new capability with the given mime typeid and properties.
- *
- * Returns: a new capability
- */
-GstCaps*
-gst_caps_new_id (const gchar *name, const GQuark id, GstProps *props)
-{
- GstCaps *caps;
-
- caps = gst_mem_chunk_alloc (_gst_caps_chunk);
-#ifndef GST_DISABLE_TRACE
- gst_alloc_trace_new (_gst_caps_trace, caps);
-#endif
-
- GST_CAT_LOG (GST_CAT_CAPS, "new %p, props %p", caps, props);
-
- gst_props_ref (props);
- gst_props_sink (props);
-
- caps->name = g_strdup (name);
- caps->id = id;
- caps->properties = props;
- caps->next = NULL;
- caps->refcount = 1;
- GST_CAPS_FLAG_SET (caps, GST_CAPS_FLOATING);
-
- return caps;
-}
-
-/**
- * gst_caps_get_any:
- *
- * Return a copy of the caps that represents any capability.
- *
- * Returns: the ANY capability
- */
-GstCaps*
-gst_caps_get_any (void)
-{
-#if 0
- static GstCaps *caps;
-
- if (!caps){
- caps = GST_CAPS_NEW ("gst_caps_any", "*", NULL);
- gst_caps_ref(caps);
- gst_caps_sink(caps);
- }
-
- return gst_caps_ref(caps);
-#else
- return NULL;
-#endif
-}
-
-/**
- * gst_caps_replace:
- * @oldcaps: the caps to take replace
- * @newcaps: the caps to take replace
- *
- * Replace the pointer to the caps, doing proper
- * refcounting.
- */
-void
-gst_caps_replace (GstCaps **oldcaps, GstCaps *newcaps)
-{
- if (*oldcaps != newcaps) {
- if (newcaps) gst_caps_ref (newcaps);
- if (*oldcaps) gst_caps_unref (*oldcaps);
-
- *oldcaps = newcaps;
- }
-}
-
-/**
- * gst_caps_replace_sink:
- * @oldcaps: the caps to take replace
- * @newcaps: the caps to take replace
- *
- * Replace the pointer to the caps and take ownership.
- */
-void
-gst_caps_replace_sink (GstCaps **oldcaps, GstCaps *newcaps)
-{
- gst_caps_replace (oldcaps, newcaps);
- gst_caps_sink (newcaps);
-}
-
-/**
- * gst_caps_destroy:
- * @caps: the caps to destroy
- *
- * Frees the memory used by this caps structure and all
- * the chained caps and properties.
- */
-static void
-gst_caps_destroy (GstCaps *caps)
-{
- GstCaps *next;
-
- if (caps == NULL)
- return;
-
- next = caps->next;
-
- GST_CAT_LOG (GST_CAT_CAPS, "destroy %p", caps);
-
- gst_props_unref (caps->properties);
- g_free (caps->name);
-
-#ifdef USE_POISONING
- memset(caps, 0xff, sizeof(*caps));
-#endif
-
-#ifndef GST_DISABLE_TRACE
- gst_alloc_trace_free (_gst_caps_trace, caps);
-#endif
- gst_mem_chunk_free (_gst_caps_chunk, caps);
-
- if (next)
- gst_caps_unref (next);
-}
-
-/**
- * gst_caps_debug:
- * @caps: the caps to print out
- * @label: a label to put on the printout, or NULL
- *
- * Print out the contents of the caps structure. Useful for debugging.
- */
-void
-gst_caps_debug (GstCaps *caps, const gchar *label)
-{
- GST_CAT_DEBUG (GST_CAT_CAPS, "starting caps debug: %s", label);
- if (caps && caps->refcount == 0) {
- g_warning ("Warning: refcount of caps %s is 0", label);
- return;
- }
-
- while (caps) {
- GST_CAT_DEBUG (GST_CAT_CAPS, "caps: %p %s %s (%sfixed) (refcount %d) %s",
- caps, caps->name, gst_caps_get_mime (caps),
- GST_CAPS_IS_FIXED (caps) ? "" : "NOT ", caps->refcount,
- GST_CAPS_IS_FLOATING (caps) ? "FLOATING" : "");
-
- if (caps->properties) {
- gst_props_debug (caps->properties);
- }
- else {
- GST_CAT_DEBUG (GST_CAT_CAPS, "no properties");
- }
-
- caps = caps->next;
- }
- GST_CAT_DEBUG (GST_CAT_CAPS, "finished caps debug");
-}
-
-/**
- * gst_caps_unref:
- * @caps: the caps to unref
- *
- * Decrease the refcount of this caps structure,
- * destroying it when the refcount is 0
- *
- * Returns: caps or NULL if the refcount reached 0
- */
-GstCaps*
-gst_caps_unref (GstCaps *caps)
-{
- gboolean zero;
-
- if (caps == NULL)
- return NULL;
-
- g_return_val_if_fail (caps->refcount > 0, NULL);
-
- GST_CAT_LOG (GST_CAT_CAPS, "unref %p (%d->%d) %d",
- caps, caps->refcount, caps->refcount-1, GST_CAPS_FLAGS (caps));
-
- caps->refcount--;
- zero = (caps->refcount == 0);
-
- if (zero) {
- gst_caps_destroy (caps);
- caps = NULL;
- }
- return caps;
-}
-
-/**
- * gst_caps_ref:
- * @caps: the caps to ref
- *
- * Increase the refcount of this caps structure
- *
- * Returns: the caps with the refcount incremented
- */
-GstCaps*
-gst_caps_ref (GstCaps *caps)
-{
- if (caps == NULL)
- return NULL;
-
- g_return_val_if_fail (caps->refcount > 0, NULL);
-
- GST_CAT_LOG (GST_CAT_CAPS, "ref %p (%d->%d) %d",
- caps, caps->refcount, caps->refcount+1, GST_CAPS_FLAGS (caps));
-
- caps->refcount++;
-
- return caps;
-}
-
-/**
- * gst_caps_sink:
- * @caps: the caps to take ownership of
- *
- * Take ownership of a GstCaps
- */
-void
-gst_caps_sink (GstCaps *caps)
-{
- if (caps == NULL)
- return;
-
- if (GST_CAPS_IS_FLOATING (caps)) {
- GST_CAT_LOG (GST_CAT_CAPS, "sink %p", caps);
-
- GST_CAPS_FLAG_UNSET (caps, GST_CAPS_FLOATING);
- gst_caps_unref (caps);
- }
-}
-
-/**
- * gst_caps_copy_1:
- * @caps: the caps to copy
- *
- * Copies the caps, not copying any chained caps.
- *
- * Returns: a floating copy of the GstCaps structure.
- */
-GstCaps*
-gst_caps_copy_1 (GstCaps *caps)
-{
- GstCaps *newcaps;
-
- if (!caps)
- return NULL;
-
- newcaps = gst_caps_new_id (
- caps->name,
- caps->id,
- gst_props_copy (caps->properties));
-
- return newcaps;
-}
-
-/**
- * gst_caps_copy:
- * @caps: the caps to copy
- *
- * Copies the caps.
- *
- * Returns: a floating copy of the GstCaps structure.
- */
-GstCaps*
-gst_caps_copy (GstCaps *caps)
-{
- GstCaps *new = NULL, *walk = NULL;
-
- while (caps) {
- GstCaps *newcaps;
-
- newcaps = gst_caps_copy_1 (caps);
-
- if (new == NULL) {
- new = walk = newcaps;
- }
- else {
- walk = walk->next = newcaps;
- }
- caps = caps->next;
- }
-
- return new;
-}
-
-/**
- * gst_caps_copy_on_write:
- * @caps: the caps to copy
- *
- * Copies the caps if the refcount is greater than 1
- *
- * Returns: a pointer to a GstCaps strcuture that can
- * be safely written to.
- */
-GstCaps*
-gst_caps_copy_on_write (GstCaps *caps)
-{
- GstCaps *new = caps;
- gboolean needcopy;
-
- g_return_val_if_fail (caps != NULL, NULL);
-
- needcopy = (caps->refcount > 1);
-
- if (needcopy) {
- new = gst_caps_copy (caps);
- gst_caps_unref (caps);
- }
-
- return new;
-}
-
-/**
- * gst_caps_get_name:
- * @caps: the caps to get the name from
- *
- * Get the name of a GstCaps structure.
- *
- * Returns: the name of the caps
- */
-const gchar*
-gst_caps_get_name (GstCaps *caps)
-{
- g_return_val_if_fail (caps != NULL, NULL);
-
- return (const gchar *)caps->name;
-}
-
-/**
- * gst_caps_set_name:
- * @caps: the caps to set the name to
- * @name: the name to set
- *
- * Set the name of a caps.
- */
-void
-gst_caps_set_name (GstCaps *caps, const gchar *name)
-{
- g_return_if_fail (caps != NULL);
-
- g_free (caps->name);
- caps->name = g_strdup (name);
-}
-/**
- * gst_caps_get_mime:
- * @caps: the caps to get the mime type from
- *
- * Get the mime type of the caps as a string.
- *
- * Returns: the mime type of the caps
- */
-const gchar*
-gst_caps_get_mime (GstCaps *caps)
-{
- g_return_val_if_fail (caps != NULL, NULL);
-
- return g_quark_to_string (caps->id);
-}
-/**
- * gst_caps_set_mime:
- * @caps: the caps to set the mime type to
- * @mime: the mime type to attach to the caps
- *
- * Set the mime type of the caps as a string.
- */
-void
-gst_caps_set_mime (GstCaps *caps, const gchar *mime)
-{
- g_return_if_fail (caps != NULL);
- g_return_if_fail (mime != NULL);
-
- caps->id = g_quark_from_string (mime);
-}
-/**
- * gst_caps_set_props:
- * @caps: the caps to attach the properties to
- * @props: the properties to attach
- *
- * Set the properties to the given caps.
- *
- * Returns: the new caps structure
- */
-GstCaps*
-gst_caps_set_props (GstCaps *caps, GstProps *props)
-{
- g_return_val_if_fail (caps != NULL, caps);
-
- gst_props_replace_sink (&caps->properties, props);
-
- return caps;
-}
-
-/**
- * gst_caps_get_props:
- * @caps: the caps to get the properties from
- *
- * Get the properties of the given caps.
- *
- * Returns: the properties of the caps
- */
-GstProps*
-gst_caps_get_props (GstCaps *caps)
-{
- g_return_val_if_fail (caps != NULL, NULL);
-
- return caps->properties;
-}
-
-/**
- * gst_caps_has_property:
- * @caps: the caps to query
- * @name: the name of the property to search for
- *
- * Figure out whether this caps contains the requested property.
- *
- * Returns: true if the caps contains the property.
- */
-
-gboolean
-gst_caps_has_property (GstCaps *caps, const gchar *name)
-{
- GstProps *props = gst_caps_get_props (caps);
-
- return (props != NULL &&
- gst_props_has_property (props, name));
-}
-
-/**
- * gst_caps_has_property_typed:
- * @caps: the caps to query
- * @name: the name of the property to search for
- * @type: the type of the property to search for
- *
- * Figure out whether this caps contains the requested property,
- * and whether this property is of the requested type.
- *
- * Returns: true if the caps contains the typed property.
- */
-
-gboolean
-gst_caps_has_property_typed (GstCaps *caps, const gchar *name, GstPropsType type)
-{
- GstProps *props = gst_caps_get_props (caps);
-
- return (props != NULL &&
- gst_props_has_property_typed (props, name, type));
-}
-
-/**
- * gst_caps_has_fixed_property
- * @caps: the caps to query
- * @name: the name of the property to search for
- *
- * Figure out whether this caps contains the requested property,
- * and whether this property is fixed.
- *
- * Returns: true if the caps contains the fixed property.
- */
-
-gboolean
-gst_caps_has_fixed_property (GstCaps *caps, const gchar *name)
-{
- GstProps *props = gst_caps_get_props (caps);
-
- return (props != NULL &&
- gst_props_has_fixed_property (props, name));
-}
-
-/**
- * gst_caps_next:
- * @caps: the caps to query
- *
- * Get the next caps of this chained caps.
- *
- * Returns: the next caps or NULL if the chain ended.
- */
-GstCaps*
-gst_caps_next (GstCaps *caps)
-{
- if (caps == NULL)
- return NULL;
-
- return caps->next;
-}
-
-/**
- * gst_caps_chain:
- * @caps: a capabilty
- * @...: more capabilities
- *
- * chains the given capabilities
- *
- * Returns: the new capability
- */
-GstCaps*
-gst_caps_chain (GstCaps *caps, ...)
-{
- GstCaps *orig = caps;
- va_list var_args;
-
- va_start (var_args, caps);
-
- while (caps) {
- GstCaps *toadd;
-
- toadd = va_arg (var_args, GstCaps*);
- gst_caps_append (caps, toadd);
-
- caps = toadd;
- }
- va_end (var_args);
-
- return orig;
-}
-
-/**
- * gst_caps_append:
- * @caps: a capabilty
- * @capstoadd: the capability to append
- *
- * Appends a capability to the existing capability.
- *
- * Returns: the new capability
- */
-GstCaps*
-gst_caps_append (GstCaps *caps, GstCaps *capstoadd)
-{
- GstCaps *orig = caps;
-
- if (caps == NULL || caps == capstoadd)
- return capstoadd;
-
- while (caps->next) {
- caps = caps->next;
- }
- gst_caps_replace_sink (&caps->next, capstoadd);
-
- return orig;
-}
-
-/**
- * gst_caps_prepend:
- * @caps: a capabilty
- * @capstoadd: a capabilty to prepend
- *
- * prepend the capability to the list of capabilities
- *
- * Returns: the new capability
- */
-GstCaps*
-gst_caps_prepend (GstCaps *caps, GstCaps *capstoadd)
-{
- GstCaps *orig = capstoadd;
-
- if (capstoadd == NULL)
- return caps;
-
- g_return_val_if_fail (caps != capstoadd, caps);
-
- while (capstoadd->next) {
- capstoadd = capstoadd->next;
- }
- gst_caps_replace_sink (&capstoadd->next, caps);
-
- return orig;
-}
-
-/**
- * gst_caps_get_by_name:
- * @caps: a capabilty
- * @name: the name of the capability to get
- *
- * Get the capability with the given name from this
- * chain of capabilities.
- *
- * Returns: the first capability in the chain with the
- * given name
- */
-GstCaps*
-gst_caps_get_by_name (GstCaps *caps, const gchar *name)
-{
- g_return_val_if_fail (caps != NULL, NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- while (caps) {
- if (!strcmp (caps->name, name))
- return caps;
- caps = caps->next;
- }
-
- return NULL;
-}
-
-static gboolean
-gst_caps_check_compatibility_func (GstCaps *fromcaps, GstCaps *tocaps)
-{
- if (fromcaps->id != tocaps->id) {
- GST_CAT_DEBUG (GST_CAT_CAPS,"mime types differ (%s to %s)",
- gst_caps_get_mime (fromcaps),
- gst_caps_get_mime (tocaps));
- return FALSE;
- }
-
- if (tocaps->properties) {
- if (fromcaps->properties) {
- return gst_props_check_compatibility (fromcaps->properties, tocaps->properties);
- }
- else {
- GST_CAT_DEBUG (GST_CAT_CAPS,"no source caps");
- return FALSE;
- }
- }
- else {
- /* assume it accepts everything */
- GST_CAT_DEBUG (GST_CAT_CAPS,"no caps");
- return TRUE;
- }
-}
-
-/**
- * gst_caps_is_always_compatible:
- * @fromcaps: a #GstCaps capability to check compatibility of.
- * @tocaps: the #GstCaps capability to check compatibility with.
- *
- * Checks if a link is always possible from fromcaps to tocaps, for all
- * possible capabilities.
- *
- * Returns: TRUE if compatible under all circumstances, FALSE otherwise.
- */
-gboolean
-gst_caps_is_always_compatible (GstCaps *fromcaps, GstCaps *tocaps)
-{
- if (fromcaps == NULL) {
- if (tocaps == NULL) {
- /* if both are NULL, they can always link. Think filesrc ! filesink */
- GST_CAT_DEBUG (GST_CAT_CAPS, "both caps NULL, compatible");
- return TRUE;
- }
- else {
- /* if source caps are NULL, it could be sending anything, so the
- * destination can't know if it can accept this. Think filesrc ! mad */
- GST_CAT_DEBUG (GST_CAT_CAPS, "source caps NULL, not guaranteed compatible");
- return FALSE;
- }
- }
- else {
- if (tocaps == NULL) {
- /* if the dest caps are NULL, the element can accept anything, always,
- * so they're compatible by definition. Think mad ! filesink */
- GST_CAT_DEBUG (GST_CAT_CAPS,"destination caps NULL");
- return TRUE;
- }
- }
-
- while (fromcaps) {
- GstCaps *destcaps = tocaps;
- /* assume caps is incompatible */
- gboolean compat = FALSE;
-
- while (destcaps && !compat) {
- if (gst_caps_check_compatibility_func (fromcaps, destcaps)) {
- compat = TRUE;
- }
- destcaps = destcaps->next;
- }
- if (!compat)
- return FALSE;
-
- fromcaps = fromcaps->next;
- }
- return TRUE;
-}
-
-static GstCaps*
-gst_caps_intersect_func (GstCaps *caps1, GstCaps *caps2)
-{
- GstCaps *result = NULL;
- GstProps *props;
-
- if (caps1->id != caps2->id) {
- GST_CAT_DEBUG (GST_CAT_CAPS, "mime types differ (%s to %s)",
- gst_caps_get_mime (caps1),
- gst_caps_get_mime (caps2));
- return NULL;
- }
-
- if (caps1->properties == NULL) {
- return gst_caps_ref (caps2);
- }
- if (caps2->properties == NULL) {
- return gst_caps_ref (caps1);
- }
-
- props = gst_props_intersect (caps1->properties, caps2->properties);
- if (props) {
- result = gst_caps_new_id ("intersect", caps1->id, props);
- gst_caps_ref (result);
- gst_caps_sink (result);
- }
-
- return result;
-}
-
-/**
- * gst_caps_intersect:
- * @caps1: a capability
- * @caps2: a capability
- *
- * Make the intersection between two caps.
- *
- * Returns: The intersection of the two caps or NULL if the intersection
- * is empty. unref the caps after use.
- */
-GstCaps*
-gst_caps_intersect (GstCaps *caps1, GstCaps *caps2)
-{
- GstCaps *result = NULL, *walk = NULL;
-
- /* printing the name is not useful here since caps can be chained */
- GST_CAT_DEBUG (GST_CAT_CAPS, "intersecting caps %p and %p", caps1, caps2);
-
- if (caps1 == NULL) {
- GST_CAT_DEBUG (GST_CAT_CAPS, "first caps is NULL, return other caps");
- return gst_caps_ref (caps2);
- }
- if (caps2 == NULL) {
- GST_CAT_DEBUG (GST_CAT_CAPS, "second caps is NULL, return other caps");
- return gst_caps_ref (caps1);
- }
-
- /* same caps */
- if (caps1 == caps2) {
- return gst_caps_ref (caps1);
- }
-
- while (caps1) {
- GstCaps *othercaps = caps2;
-
- while (othercaps) {
- GstCaps *intersection;
-
- intersection = gst_caps_intersect_func (caps1, othercaps);
-
- if (intersection) {
- if (!result) {
- walk = result = intersection;
- }
- else {
- walk = walk->next = intersection;
- }
- }
- othercaps = othercaps->next;
- }
- caps1 = caps1->next;
- }
-
- return result;
-}
-
-GstCaps*
-gst_caps_union (GstCaps *caps1, GstCaps *caps2)
-{
- GstCaps *result = NULL;
-
- /* printing the name is not useful here since caps can be chained */
- GST_CAT_DEBUG (GST_CAT_CAPS, "making union of caps %p and %p", caps1, caps2);
-
- if (caps1 == NULL) {
- GST_CAT_DEBUG (GST_CAT_CAPS, "first caps is NULL, return other caps");
- return gst_caps_ref (caps2);
- }
- if (caps2 == NULL) {
- GST_CAT_DEBUG (GST_CAT_CAPS, "second caps is NULL, return other caps");
- return gst_caps_ref (caps1);
- }
-
- return result;
-}
-
-/**
- * gst_caps_normalize:
- * @caps: a capabilty
- *
- * Make the normalisation of the caps. This will return a new caps
- * that is equivalent to the input caps with the exception that all
- * lists are unrolled. This function is useful when you want to iterate
- * the caps. unref the caps after use.
- *
- * Returns: The normalisation of the caps. Unref after usage.
- */
-GstCaps*
-gst_caps_normalize (GstCaps *caps)
-{
- GstCaps *result = NULL, *walk;
-
- if (caps == NULL)
- return caps;
-
- GST_CAT_DEBUG (GST_CAT_CAPS, "normalizing caps %p ", caps);
-
- walk = caps;
-
- while (caps) {
- GList *proplist;
-
- proplist = gst_props_normalize (caps->properties);
- while (proplist) {
- GstProps *props = (GstProps *) proplist->data;
- GstCaps *newcaps = gst_caps_new_id (caps->name, caps->id, props);
-
- gst_caps_ref (newcaps);
- gst_caps_sink (newcaps);
-
- if (result == NULL)
- walk = result = newcaps;
- else {
- walk = walk->next = newcaps;
- }
- proplist = g_list_next (proplist);
- }
- caps = caps->next;
- }
- return result;
-}
-
-#ifndef GST_DISABLE_LOADSAVE_REGISTRY
-/**
- * gst_caps_save_thyself:
- * @caps: a capabilty to save
- * @parent: the parent XML node pointer
- *
- * Save the capability into an XML representation.
- *
- * Returns: a new XML node pointer
- */
-xmlNodePtr
-gst_caps_save_thyself (GstCaps *caps, xmlNodePtr parent)
-{
- xmlNodePtr subtree;
- xmlNodePtr subsubtree;
-
- while (caps) {
- subtree = xmlNewChild (parent, NULL, "capscomp", NULL);
-
- xmlNewChild (subtree, NULL, "name", caps->name);
- xmlNewChild (subtree, NULL, "type", gst_caps_get_mime (caps));
- if (caps->properties) {
- subsubtree = xmlNewChild (subtree, NULL, "properties", NULL);
-
- gst_props_save_thyself (caps->properties, subsubtree);
- }
-
- caps = caps->next;
- }
-
- return parent;
-}
-
-/**
- * gst_caps_load_thyself:
- * @parent: the parent XML node pointer
- *
- * Load a new caps from the XML representation.
- *
- * Returns: a new capability
- */
-GstCaps*
-gst_caps_load_thyself (xmlNodePtr parent)
-{
- GstCaps *result = NULL;
- xmlNodePtr field = parent->xmlChildrenNode;
-
- while (field) {
- if (!strcmp (field->name, "capscomp")) {
- xmlNodePtr subfield = field->xmlChildrenNode;
- GstCaps *caps;
- gchar *content;
-
- caps = gst_mem_chunk_alloc0 (_gst_caps_chunk);
-#ifndef GST_DISABLE_TRACE
- gst_alloc_trace_new (_gst_caps_trace, caps);
-#endif
-
- caps->refcount = 1;
- GST_CAPS_FLAG_SET (caps, GST_CAPS_FLOATING);
- caps->next = NULL;
-
- while (subfield) {
- if (!strcmp (subfield->name, "name")) {
- caps->name = xmlNodeGetContent (subfield);
- }
- if (!strcmp (subfield->name, "type")) {
- content = xmlNodeGetContent (subfield);
- caps->id = g_quark_from_string (content);
- g_free (content);
- }
- else if (!strcmp (subfield->name, "properties")) {
- GstProps *props = gst_props_load_thyself (subfield);
-
- gst_props_ref (props);
- gst_props_sink (props);
- caps->properties = props;
- }
-
- subfield = subfield->next;
- }
-
- result = gst_caps_append (result, caps);
- }
- field = field->next;
- }
-
- return result;
-}
-
-#endif /* GST_DISABLE_LOADSAVE_REGISTRY */
+++ /dev/null
-/* 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__ */
#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,
&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;
}
+void gst_caps_set_simple (GstCaps *caps, char *field, ...)
+{
+ 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);
+}
+
+void gst_caps_set_simple_valist (GstCaps *caps, char *field, va_list varargs)
+{
+ 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_caps2_is_any (const GstCaps2 *caps)
+gboolean gst_caps_is_any (const GstCaps *caps)
{
- return (caps->flags & GST_CAPS2_FLAGS_ANY);
+ g_return_val_if_fail(caps != NULL, FALSE);
+
+ return (caps->flags & GST_CAPS_FLAGS_ANY);
}
-gboolean gst_caps2_is_empty (const GstCaps2 *caps)
+gboolean gst_caps_is_empty (const GstCaps *caps)
{
- if (caps->flags & GST_CAPS2_FLAGS_ANY) return FALSE;
+ 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;
+ GType type = G_VALUE_TYPE (value);
+ if (G_TYPE_IS_FUNDAMENTAL (type)) return TRUE;
+ if (type == GST_TYPE_FOURCC) return TRUE;
+ return FALSE;
+}
- if (caps->structs->len > 1) return FALSE;
+gboolean gst_caps_is_fixed (const GstCaps *caps)
+{
+ GstStructure *structure;
- structure = gst_caps2_get_nth_cap (caps, 0);
+ g_return_val_if_fail(caps != NULL, FALSE);
- for(i=0;i<structure->fields->len;i++) {
- field = GST_STRUCTURE_FIELD(structure, i);
- type = G_VALUE_TYPE(&field->value);
+ if (caps->structs->len != 1) return FALSE;
- if(type == GST_TYPE_INT_RANGE || type == GST_TYPE_DOUBLE_RANGE) {
- return FALSE;
- }
- }
+ structure = gst_caps_get_structure (caps, 0);
- return TRUE;
+ return gst_structure_foreach (structure, _gst_caps_is_fixed_foreach, NULL);
}
-static gboolean _gst_cap_is_always_compatible (const GstStructure *struct1,
- const GstStructure *struct2)
+static gboolean
+_gst_structure_field_has_compatible (GQuark field_id,
+ GValue *val2, gpointer data)
{
- int i;
- const GstStructureField *field1;
- const GstStructureField *field2;
+ GValue dest = { 0 };
+ GstStructure *struct1 = (GstStructure *) data;
+ const GValue *val1 = gst_structure_id_get_value (struct1, field_id);
- if(struct1->name != struct2->name){
- return FALSE;
+ if (val1 == NULL) return FALSE;
+ if (gst_value_intersect (&dest, val1, val2)) {
+ g_value_unset (&dest);
+ return TRUE;
}
- 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;
+}
+static gboolean
+_gst_cap_is_always_compatible (const GstStructure *struct1,
+ const GstStructure *struct2)
+{
+ if(struct1->name != struct2->name){
return FALSE;
}
- return TRUE;
+ /* the reversed order is important */
+ 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;
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;
return FALSE;
}
-static GstStructure *gst_caps2_structure_intersect (const GstStructure *struct1,
- const GstStructure *struct2)
-{
- int i;
+typedef struct {
GstStructure *dest;
- const GstStructureField *field1;
- const GstStructureField *field2;
- int ret;
-
- if (struct1->name != struct2->name) return NULL;
-
- dest = gst_structure_id_empty_new (struct1->name);
-
- for(i=0;i<struct1->fields->len;i++){
- GValue dest_field = { 0 };
-
- field1 = GST_STRUCTURE_FIELD (struct1, i);
- field2 = gst_structure_id_get_field (struct2, field1->name);
-
- if (field2 == NULL) {
- gst_structure_set_field_copy (dest, field1);
+ 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 {
- 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);
- return NULL;
- }
- }
+ return FALSE;
}
}
+
+ return TRUE;
+}
- for(i=0;i<struct1->fields->len;i++){
- field2 = GST_STRUCTURE_FIELD (struct2, i);
- field1 = gst_structure_id_get_field (struct1, field2->name);
+static GstStructure *gst_caps_structure_intersect (const GstStructure *struct1,
+ const GstStructure *struct2)
+{
+ IntersectData data;
- if (field1 == NULL) {
- gst_structure_set_field_copy (dest, field2);
- }
- }
+ g_return_val_if_fail(struct1 != NULL, NULL);
+ g_return_val_if_fail(struct2 != NULL, NULL);
- return dest;
+ if (struct1->name != struct2->name) return NULL;
+
+ 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;
+
+ data.intersect = struct1;
+ data.first_run = FALSE;
+ if (!gst_structure_foreach ((GstStructure *) struct2,
+ gst_caps_structure_intersect_field, &data))
+ goto error;
+
+ return data.dest;
+
+error:
+ gst_structure_free (data.dest);
+ return NULL;
}
#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;
#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;
+
+ 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_caps2_new_empty();
+ 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);
}
}
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 */
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;
#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;
/* 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));
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;
+ GstCaps *caps;
- caps = gst_caps2_new_empty();
- _gst_caps2_from_string_inplace (caps, string);
-
- return 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;
+
+}
+
* 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__ */
* <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));
*/
GstPad*
gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad,
- GstCaps *filtercaps)
+ const GstCaps *filtercaps)
{
const GList *pads;
GstPadTemplate *templ;
/* 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 */
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));
}
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;
*/
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);
}
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
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);
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, ...);
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);
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);
*/
gboolean
gst_element_factory_can_src_caps (GstElementFactory *factory,
- GstCaps *caps)
+ const GstCaps *caps)
{
GList *templates;
*/
gboolean
gst_element_factory_can_sink_caps (GstElementFactory *factory,
- GstCaps *caps)
+ const GstCaps *caps)
{
GList *templates;
#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,
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);
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, */
pad->chainhandler = NULL;
pad->gethandler = NULL;
- pad->bufferpoolfunc = NULL;
pad->ghostpads = NULL;
pad->caps = NULL;
GST_DEBUG_PAD_NAME (realpad));
GST_FLAG_SET (realpad, GST_PAD_DISABLED);
}
- if (old != active)
- g_object_notify (G_OBJECT (realpad), "active");
+
+ g_object_notify (G_OBJECT (realpad), "active");
}
/**
}
/**
+ * 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.
* @getcaps: the #GstPadGetCapsFunction to set.
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));
}
/**
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,
*/
gboolean
gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad,
- GstCaps *filtercaps)
+ const GstCaps *filtercaps)
{
GstRealPad *realsrc, *realsink;
* 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;
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);
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) {
GstCaps *intersection;
/* 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 */
}
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);
}
}
/* 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");
}
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.
* 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);
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);
}
/* 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;
}
*/
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;
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)");
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));
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));
}
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));
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);
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:
*/
gboolean
gst_pad_try_relink_filtered (GstPad *srcpad, GstPad *sinkpad,
- GstCaps *filtercaps)
+ const GstCaps *filtercaps)
{
GstRealPad *realsrc, *realsink;
*/
gboolean
gst_pad_relink_filtered (GstPad *srcpad, GstPad *sinkpad,
- GstCaps *filtercaps)
+ const GstCaps *filtercaps)
{
GstRealPad *realsrc, *realsink;
* 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);
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;
}
*
* 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)
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();
}
/**
* 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);
}
/**
* 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;
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;
}
/**
* 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);
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 */
}
/**
* 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;
}
/**
- * 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;
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);
}
}
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;
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);
}
}
/**
- * 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;
- GstCaps *thecaps = NULL;
-
- g_return_val_if_fail (name_template != NULL, NULL);
- if (!name_is_valid (name_template, presence))
+ if (!name_is_valid (pad_template->name_template, pad_template->presence))
return NULL;
new = g_object_new (gst_pad_template_get_type (),
- "name", name_template,
+ "name", pad_template->name_template,
NULL);
- GST_PAD_TEMPLATE_NAME_TEMPLATE (new) = g_strdup (name_template);
- GST_PAD_TEMPLATE_DIRECTION (new) = direction;
- GST_PAD_TEMPLATE_PRESENCE (new) = presence;
+ GST_PAD_TEMPLATE_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_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);
+ GST_PAD_TEMPLATE_CAPS (new) = gst_caps_copy (
+ gst_static_caps_get (&pad_template->static_caps));
return 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.
+ * @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.
+ * 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, ...)
+ GstCaps *caps)
{
GstPadTemplate *new;
- va_list var_args;
- va_start (var_args, caps);
+ g_return_val_if_fail (name_template != NULL, NULL);
- new = gst_pad_template_newv (name_template, direction, presence,
- caps, var_args);
+ if (!name_is_valid (name_template, presence))
+ return NULL;
- va_end (var_args);
+ new = g_object_new (gst_pad_template_get_type (),
+ "name", name_template,
+ NULL);
+
+ GST_PAD_TEMPLATE_NAME_TEMPLATE (new) = g_strdup (name_template);
+ GST_PAD_TEMPLATE_DIRECTION (new) = direction;
+ GST_PAD_TEMPLATE_PRESENCE (new) = presence;
+ GST_PAD_TEMPLATE_CAPS (new) = caps;
return new;
}
* 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);
}
/**
#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>
typedef struct _GstGhostPadClass GstGhostPadClass;
/*typedef struct _GstPadTemplate GstPadTemplate;*/
/*typedef struct _GstPadTemplateClass GstPadTemplateClass;*/
+typedef struct _GstStaticPadTemplate GstStaticPadTemplate;
typedef enum {
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);
/* the pad capabilities */
GstCaps *caps;
- GstCaps *filter;
+ GstPadFixateFunction appfixatefunc;
GstCaps *appfilter;
GstPadGetCapsFunction getcapsfunc;
+ GstPadFixateFunction fixatefunc;
GstPadDirection direction;
GstPadQueryTypeFunction querytypefunc;
GstPadIntLinkFunction intlinkfunc;
- GstPadBufferPoolFunction bufferpoolfunc;
+ GstPadBufferAllocFunction bufferallocfunc;
GstProbeDispatcher probedisp;
/* 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)
#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)
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)
-
-#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_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
+struct _GstStaticPadTemplate {
+ gchar *name_template;
+ GstPadDirection direction;
+ GstPadPresence presence;
+ GstStaticCaps static_caps;
+};
+
+#define GST_STATIC_PAD_TEMPLATE(padname, dir, pres, caps) \
+ { \
+ /* name_template */ padname, \
+ /* direction */ dir, \
+ /* presence */ pres, \
+ /* caps */ caps \
+ }
-#define GST_PAD_TEMPLATE_GET(fact) (fact)()
GType gst_pad_get_type (void);
GType gst_real_pad_get_type (void);
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);
/* 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);
GstPadTemplate* gst_pad_template_new (const gchar *name_template,
GstPadDirection direction, GstPadPresence presence,
- GstCaps *caps, ...);
-
-GstPadTemplate* gst_pad_template_newv (const gchar *name_template,
- GstPadDirection direction, GstPadPresence presence,
- GstCaps *caps, va_list var_args);
+ GstCaps *caps);
-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,
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, \
license, \
package, \
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)
+ GST_PADDING_INIT \
+};
+
#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) \
}; \
_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"
+++ /dev/null
-/* GStreamer
- * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
- * 2000 Wim Taymans <wim.taymans@chello.be>
- *
- * gstprops.c: Properties subsystem for generic usage
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "gst_private.h"
-
-#include "gstinfo.h"
-#include "gstprops.h"
-#include "gstmemchunk.h"
-
-#ifndef GST_DISABLE_TRACE
-/* #define GST_WITH_ALLOC_TRACE */
-#include "gsttrace.h"
-static GstAllocTrace *_props_trace;
-static GstAllocTrace *_entries_trace;
-#endif
-
-GType _gst_props_type;
-GType _gst_props_entry_type;
-
-#define GST_PROPS_ENTRY_IS_VARIABLE(a) (((GstPropsEntry*)(a))->propstype > GST_PROPS_VAR_TYPE)
-
-struct _GstPropsEntry {
- GQuark propid;
- GstPropsType propstype;
-
- union {
- /* flat values */
- gboolean bool_data;
- guint32 fourcc_data;
- gint int_data;
- gfloat float_data;
-
- /* structured values */
- struct {
- GList *entries;
- } list_data;
- struct {
- gchar *string;
- } string_data;
- struct {
- gint min;
- gint max;
- } int_range_data;
- struct {
- gfloat min;
- gfloat max;
- } float_range_data;
- } data;
-};
-
-static GstMemChunk *_gst_props_entries_chunk;
-static GstMemChunk *_gst_props_chunk;
-
-/* transform functions */
-static void gst_props_transform_to_string (const GValue *src_value, GValue *dest_value);
-static gchar * gst_props_entry_to_string (GstPropsEntry *entry);
-gboolean __gst_props_parse_string (gchar *r, gchar **end, gchar **next);
-
-static gboolean gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry2);
-static GList* gst_props_list_copy (GList *propslist);
-
-static GstPropsEntry* gst_props_alloc_entry (void);
-static inline void gst_props_entry_free (GstPropsEntry *entry);
-
-static void gst_props_destroy (GstProps *props);
-
-static gchar *
-gst_props_entry_to_string (GstPropsEntry *entry)
-{
- switch (entry->propstype) {
- case GST_PROPS_INT_TYPE:
- return g_strdup_printf ("int = %d", entry->data.int_data);
- case GST_PROPS_FLOAT_TYPE:
- return g_strdup_printf ("float = %g", entry->data.float_data);
- break;
- case GST_PROPS_FOURCC_TYPE: {
- gchar fourcc[5] = { GST_FOURCC_ARGS (entry->data.fourcc_data), '\0' }; /* Do all compilers understand that? */
- if (g_ascii_isalnum(fourcc[1]) && g_ascii_isalnum(fourcc[2]) &&
- g_ascii_isalnum(fourcc[3]) && g_ascii_isalnum(fourcc[4])) {
- return g_strdup_printf ("fourcc = %s", fourcc);
- } else {
- return g_strdup_printf ("fourcc = %d", entry->data.fourcc_data);
- }
- }
- case GST_PROPS_BOOLEAN_TYPE:
- return g_strdup_printf ("bool = %s", (entry->data.bool_data ? "TRUE" : "FALSE"));
- case GST_PROPS_STRING_TYPE:
- /* FIXME: Need to escape stuff here */
- return g_strdup_printf ("string = '%s'", entry->data.string_data.string);
- case GST_PROPS_INT_RANGE_TYPE:
- return g_strdup_printf ("int = [%d, %d]", entry->data.int_range_data.min, entry->data.int_range_data.max);
- case GST_PROPS_FLOAT_RANGE_TYPE:
- return g_strdup_printf ("float = [%g, %g]", entry->data.float_range_data.min, entry->data.float_range_data.max);
- case GST_PROPS_LIST_TYPE: {
- GList *walk;
- GString *s;
- gchar *temp;
-
- s = g_string_new ("list = (");
- walk = entry->data.list_data.entries;
- while (walk) {
- temp = gst_props_entry_to_string ((GstPropsEntry *) walk->data);
- g_string_append (s, temp);
- walk = walk->next;
- if (walk) {
- g_string_append (s, ", ");
- } else {
- g_string_append (s, ")");
- }
- g_free (temp);
- }
- temp = s->str;
- g_string_free (s, FALSE);
- return temp;
- }
- default:
- /* transforms always succeed */
- g_warning("corrupt property list, type==%d\n",entry->propstype);
- g_assert_not_reached();
- return NULL;
- }
-}
-/**
- * gst_props_to_string:
- * props: the props to convert to a string
- *
- * Converts a #GstProps into a readable format. This is mainly intended for
- * debugging purposes. You have to free the string using g_free.
- * A string converted with #gst_props_to_string can always be converted back to
- * its props representation using #gst_props_from_string.
- *
- * Returns: A newly allocated string
- */
-gchar *
-gst_props_to_string (GstProps *props)
-{
- GString *s;
- gchar *temp;
- GList *propslist;
-
- s = g_string_new ("");
- propslist = props->properties;
- while (propslist) {
- GstPropsEntry *entry = (GstPropsEntry *)propslist->data;
- const gchar *name = g_quark_to_string (entry->propid);
-
- temp = gst_props_entry_to_string (entry);
- propslist = g_list_next (propslist);
- if (temp) {
- if (propslist) {
- g_string_append_printf (s, "%s:%s, ", name, temp);
- } else {
- g_string_append_printf (s, "%s:%s", name, temp);
- }
- g_free (temp);
- }
- }
- temp = s->str;
- g_string_free (s, FALSE);
-
- return temp;
-}
-static void
-gst_props_transform_to_string (const GValue *src_value, GValue *dest_value)
-{
- GstProps *props = g_value_peek_pointer (src_value);
-
- if (props)
- dest_value->data[0].v_pointer = gst_props_to_string (props);
-}
-/*
- * r will still point to the string. if end == next, the string will not be
- * null-terminated. In all other cases it will be.
- * end = pointer to char behind end of string, next = pointer to start of
- * unread data.
- * THIS FUNCTION MODIFIES THE STRING AND DETECTS INSIDE A NONTERMINATED STRING
- */
-gboolean
-__gst_props_parse_string (gchar *r, gchar **end, gchar **next)
-{
- gchar *w;
- gchar c = '\0';
-
- w = r;
- if (*r == '\'' || *r == '\"') {
- c = *r;
- r++;
- }
-
- for (;;r++) {
- if (*r == '\0') {
- if (c) {
- goto error;
- } else {
- goto found;
- }
- }
-
- if (*r == '\\') {
- r++;
- if (*r == '\0')
- goto error;
- *w++ = *r;
- continue;
- }
-
- 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;
-
-error:
- return FALSE;
-}
-static GstPropsEntry *
-gst_props_entry_from_string_no_name (gchar *s, gchar **after, gboolean has_type)
-{
- GstPropsEntry *entry;
- gchar org = '\0';
- gchar *end, *next, *check = s;
- GstPropsType type = GST_PROPS_INVALID_TYPE;
- /* [TYPE=]VALUE */
- /*
- * valid type identifiers case insensitive:
- * INT: "i", "int"
- * FLOAT: "f", "float"
- * FOURCC: "4", "fourcc"
- * BOOLEAN: "b", "bool", "boolean"
- * STRING: "s", "str", "string"
- * lists/ranges are identified by the value
- */
- if (g_ascii_tolower (s[0]) == 'i') {
- type = GST_PROPS_INT_TYPE;
- if (g_ascii_tolower (s[1]) == 'n' && g_ascii_tolower (s[2]) == 't') {
- check = s + 3;
- } else {
- check = s + 1;
- }
- } else if (g_ascii_tolower (s[0]) == 'f') {
- type = GST_PROPS_FLOAT_TYPE;
- if (g_ascii_tolower (s[1]) == 'l' && g_ascii_tolower (s[2]) == 'o' &&
- g_ascii_tolower (s[3]) == 'a' && g_ascii_tolower (s[4]) == 't') {
- check = s + 5;
- } else if (g_ascii_tolower (s[1]) == 'o' && g_ascii_tolower (s[2]) == 'u' &&
- g_ascii_tolower (s[3]) == 'r' && g_ascii_tolower (s[4]) == 'c' &&
- g_ascii_tolower (s[5]) == 'c') {
- check = s + 6;
- type = GST_PROPS_FOURCC_TYPE;
- } else {
- check = s + 1;
- }
- } else if (g_ascii_tolower (s[0]) == '4') {
- type = GST_PROPS_FOURCC_TYPE;
- check = s + 1;
- } else if (g_ascii_tolower (s[0]) == 'b') {
- type = GST_PROPS_BOOLEAN_TYPE;
- if (g_ascii_tolower (s[1]) == 'o' && g_ascii_tolower (s[2]) == 'o' &&
- g_ascii_tolower (s[3]) == 'l') {
- if (g_ascii_tolower (s[4]) == 'e' && g_ascii_tolower (s[5]) == 'a' &&
- g_ascii_tolower (s[6]) == 'n') {
- check = s + 7;
- } else {
- check = s + 4;
- }
- } else {
- check = s + 1;
- }
- } else if (g_ascii_tolower (s[0]) == 's') {
- type = GST_PROPS_STRING_TYPE;
- if (g_ascii_tolower (s[1]) == 't' && g_ascii_tolower (s[2]) == 'r') {
- if (g_ascii_tolower (s[3]) == 'i' && g_ascii_tolower (s[4]) == 'n' &&
- g_ascii_tolower (s[5]) == 'g') {
- check = s + 6;
- } else {
- check = s + 3;
- }
- } else {
- check = s + 1;
- }
- } else if (g_ascii_tolower (s[0]) == 'l') {
- type = GST_PROPS_LIST_TYPE;
- if (g_ascii_tolower (s[1]) == 'i' && g_ascii_tolower (s[2]) == 's' &&
- g_ascii_tolower (s[3]) == 't') {
- check = s + 4;
- } else {
- check = s + 1;
- }
- }
- while (g_ascii_isspace(*check)) check++;
- if (*check != '=') {
- if (has_type) goto error;
- type = GST_PROPS_INVALID_TYPE;
- check = s;
- } else {
- check++;
- while (g_ascii_isspace(*check)) check++;
- }
- /* ok. Now type is GST_PROPS_INVALID_TYPE for guessing or the selected type.
- check points to the string containing the contents. s still is the beginning
- of the string */
- if (type == GST_PROPS_INVALID_TYPE || type == GST_PROPS_INT_TYPE || type == GST_PROPS_FOURCC_TYPE) {
- glong l;
- l = strtol (check, &end, 0);
- while (g_ascii_isspace (*end)) end++;
- if (*end == '\0' || *end == ',' || *end == ';' || *end == ')' || *end == ']') {
- *after = end;
- entry = gst_props_alloc_entry ();
- if (type == GST_PROPS_FOURCC_TYPE) {
- entry->propstype = GST_PROPS_FOURCC_TYPE;
- entry->data.fourcc_data = l;
- } else {
- entry->propstype = GST_PROPS_INT_TYPE;
- entry->data.int_data = l;
- }
- return entry;
- }
- }
- if (type == GST_PROPS_INVALID_TYPE || type == GST_PROPS_FLOAT_TYPE) {
- gdouble d;
- d = g_ascii_strtod (check, &end);
- while (g_ascii_isspace (*end)) end++;
- if (*end == '\0' || *end == ',' || *end == ';' || *end == ')' || *end == ']') {
- *after = end;
- entry = gst_props_alloc_entry ();
- entry->propstype = GST_PROPS_FLOAT_TYPE;
- entry->data.float_data = d;
- return entry;
- }
- }
- if ((type == GST_PROPS_INVALID_TYPE || type == GST_PROPS_FLOAT_TYPE ||
- type == GST_PROPS_INT_TYPE) && *check == '[') {
- GstPropsEntry *min, *max;
- check++;
- if (g_ascii_isspace (*check)) check++;
- min = gst_props_entry_from_string_no_name (check, &check, FALSE);
- if (!min) goto error;
- if (*check++ != ',') goto error;
- if (g_ascii_isspace (*check)) check++;
- max = gst_props_entry_from_string_no_name (check, &check, FALSE);
- if (!max || *check++ != ']') {
- gst_props_entry_destroy (min);
- goto error;
- }
- if (g_ascii_isspace (*check)) check++;
- entry = gst_props_alloc_entry ();
- entry->propstype = GST_PROPS_FLOAT_RANGE_TYPE;
- if (min->propstype == GST_PROPS_INT_TYPE && max->propstype == GST_PROPS_INT_TYPE && type != GST_PROPS_FLOAT_TYPE) {
- entry->propstype = GST_PROPS_INT_RANGE_TYPE;
- entry->data.int_range_data.min = min->data.int_data;
- entry->data.int_range_data.max = max->data.int_data;
- } else if (min->propstype == GST_PROPS_INT_TYPE && max->propstype == GST_PROPS_INT_TYPE && type == GST_PROPS_FLOAT_TYPE) {
- entry->data.float_range_data.min = min->data.int_data;
- entry->data.float_range_data.max = max->data.int_data;
- } else if (min->propstype == GST_PROPS_INT_TYPE && max->propstype == GST_PROPS_FLOAT_TYPE && type != GST_PROPS_INT_TYPE) {
- entry->data.float_range_data.min = min->data.int_data;
- entry->data.float_range_data.max = max->data.float_data;
- } else if (min->propstype == GST_PROPS_FLOAT_TYPE && max->propstype == GST_PROPS_INT_TYPE && type != GST_PROPS_INT_TYPE) {
- entry->data.float_range_data.min = min->data.float_data;
- entry->data.float_range_data.max = max->data.int_data;
- } else if (min->propstype == GST_PROPS_FLOAT_TYPE && max->propstype == GST_PROPS_FLOAT_TYPE && type != GST_PROPS_INT_TYPE) {
- entry->data.float_range_data.min = min->data.float_data;
- entry->data.float_range_data.max = max->data.float_data;
- } else {
- gst_props_entry_destroy (min);
- gst_props_entry_destroy (max);
- gst_props_entry_destroy (entry);
- goto error;
- }
- gst_props_entry_destroy (min);
- gst_props_entry_destroy (max);
- *after = check;
- return entry;
- }
- if ((type == GST_PROPS_INVALID_TYPE || type == GST_PROPS_LIST_TYPE) && *check == '(') {
- GstPropsEntry *next;
- check++;
- entry = gst_props_alloc_entry ();
- entry->propstype = GST_PROPS_LIST_TYPE;
- entry->data.list_data.entries = NULL;
- do {
- while (g_ascii_isspace (*check)) check++;
- next = gst_props_entry_from_string_no_name (check, &check, FALSE);
- /* use g_list_append to keep original order */
- entry->data.list_data.entries = g_list_append (entry->data.list_data.entries, next);
- if (*check == ')') break;
- if (*check++ != ',') goto error;
- } while (TRUE);
- check++;
- while (g_ascii_isspace (*check)) check++;
- *after = check;
- return entry;
- }
- if (!__gst_props_parse_string (check, &next, &end))
- goto error;
- if (next == end) {
- org = *end;
- *end = '\0';
- }
- if (type == GST_PROPS_INVALID_TYPE || type == GST_PROPS_BOOLEAN_TYPE) {
- if (!(g_ascii_strcasecmp (check, "true") &&
- g_ascii_strcasecmp (check, "yes"))) {
- entry = gst_props_alloc_entry ();
- entry->propstype = GST_PROPS_BOOLEAN_TYPE;
- entry->data.bool_data = TRUE;
- goto string_out;
- }
- if (!(g_ascii_strcasecmp (check, "false") &&
- g_ascii_strcasecmp (check, "no"))) {
- entry = gst_props_alloc_entry ();
- entry->propstype = GST_PROPS_BOOLEAN_TYPE;
- entry->data.bool_data = FALSE;
- goto string_out;
- }
- }
- if (type == GST_PROPS_FOURCC_TYPE) {
- gint l = strlen (check);
- entry = gst_props_alloc_entry ();
- entry->propstype = GST_PROPS_FOURCC_TYPE;
- entry->data.fourcc_data = GST_MAKE_FOURCC(l > 0 ? check[0] : ' ',
- l > 1 ? check[1] : ' ',
- l > 2 ? check[2] : ' ',
- l > 3 ? check[3] : ' ');
- goto string_out;
- }
- if (type == GST_PROPS_INVALID_TYPE || type == GST_PROPS_STRING_TYPE) {
- entry = gst_props_alloc_entry ();
- entry->propstype = GST_PROPS_STRING_TYPE;
- entry->data.string_data.string = g_strdup (check);
- goto string_out;
- }
-error:
- return NULL;
-
-string_out:
- *next = org;
- *after = end;
- return entry;
-}
-static GstPropsEntry *
-gst_props_entry_from_string (gchar *str, gchar **after)
-{
- /* NAME[:TYPE]=VALUE */
- gchar *name;
- gchar *s, *del;
- gboolean has_type = FALSE;
- GstPropsEntry *entry;
-
- name = s = str;
- while (g_ascii_isalnum (*s) || *s == '_' || *s == '-') s++;
- del = s;
- while (g_ascii_isspace (*s)) s++;
- if (!(*s == '=' || *s == ':')) return NULL;
- if (*s == ':') has_type = TRUE;
- s++;
- while (g_ascii_isspace (*s)) s++;
- *del = '\0';
-
- entry = gst_props_entry_from_string_no_name (s, &s, has_type);
- if (entry) {
- entry->propid = g_quark_from_string (name);
- *after = s;
- }
-
- return entry;
-}
-GstProps *
-__gst_props_from_string_func (gchar *s, gchar **end, gboolean caps)
-{
- GstProps *props;
- GstPropsEntry *entry;
-
- props = gst_props_empty_new ();
- for (;;) {
- entry = gst_props_entry_from_string (s, &s);
- if (!entry) goto error;
- gst_props_add_entry (props, entry);
- while (g_ascii_isspace (*s)) s++;
- if ((*s == '\0') || /* end */
- (caps && (*s == ';'))) /* another caps */
- break;
- if (!(*s == ',')) goto error;
- s++;
- while (g_ascii_isspace (*s)) s++;
- }
-
- *end = s;
- return props;
-error:
- gst_props_unref (props);
- return NULL;
-}
-/**
- * gst_props_from_string:
- * str: the str to convert into props
- *
- * Tries to convert a string into a #GstProps. This is mainly intended for
- * debugging purposes. The returned props are floating.
- *
- * Returns: A floating props or NULL if the string couldn't be converted
- */
-GstProps *
-gst_props_from_string (gchar *str)
-{
- /*
- * format to parse is ENTRY[,ENTRY ...]
- * ENTRY is NAME[:TYPE]=VALUE
- * NAME is alphanumeric
- * TYPE is a list of values
- * VALUE is evil, see gst_props_entry_to_string
- */
- GstProps *props;
- gchar *temp, *org;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- org = g_strdup (str);
- props = __gst_props_from_string_func (org, &temp, FALSE);
- g_free (org);
-
- return props;
-}
-
-void
-_gst_props_initialize (void)
-{
- _gst_props_entries_chunk = gst_mem_chunk_new ("GstPropsEntries",
- sizeof (GstPropsEntry), sizeof (GstPropsEntry) * 1024,
- G_ALLOC_AND_FREE);
-
- _gst_props_chunk = gst_mem_chunk_new ("GstProps",
- sizeof (GstProps), sizeof (GstProps) * 256,
- G_ALLOC_AND_FREE);
-
- _gst_props_type = g_boxed_type_register_static ("GstProps",
- (GBoxedCopyFunc) gst_props_ref,
- (GBoxedFreeFunc) gst_props_unref);
-
- g_value_register_transform_func (_gst_props_type, G_TYPE_STRING,
- gst_props_transform_to_string);
-
- _gst_props_entry_type = g_boxed_type_register_static ("GstPropsEntry",
- (GBoxedCopyFunc) gst_props_entry_copy,
- (GBoxedFreeFunc) gst_props_entry_destroy);
-
-#ifndef GST_DISABLE_TRACE
- _props_trace = gst_alloc_trace_register (GST_PROPS_TRACE_NAME);
- _entries_trace = gst_alloc_trace_register (GST_PROPS_ENTRY_TRACE_NAME);
-#endif
-}
-
-static void
-gst_props_debug_entry (GstPropsEntry *entry)
-{
- /* unused when debugging is disabled */
- G_GNUC_UNUSED const gchar *name = g_quark_to_string (entry->propid);
-
- switch (entry->propstype) {
- case GST_PROPS_INT_TYPE:
- GST_CAT_DEBUG (GST_CAT_PROPERTIES, "%p: %s: int %d", entry, name, entry->data.int_data);
- break;
- case GST_PROPS_FLOAT_TYPE:
- GST_CAT_DEBUG (GST_CAT_PROPERTIES, "%p: %s: float %g", entry, name, entry->data.float_data);
- break;
- case GST_PROPS_FOURCC_TYPE:
- GST_CAT_DEBUG (GST_CAT_PROPERTIES, "%p: %s: fourcc %c%c%c%c", entry, name,
- (entry->data.fourcc_data>>0)&0xff,
- (entry->data.fourcc_data>>8)&0xff,
- (entry->data.fourcc_data>>16)&0xff,
- (entry->data.fourcc_data>>24)&0xff);
- break;
- case GST_PROPS_BOOLEAN_TYPE:
- GST_CAT_DEBUG (GST_CAT_PROPERTIES, "%p: %s: bool %d", entry, name, entry->data.bool_data);
- break;
- case GST_PROPS_STRING_TYPE:
- GST_CAT_DEBUG (GST_CAT_PROPERTIES, "%p: %s: string \"%s\"", entry, name, entry->data.string_data.string);
- break;
- case GST_PROPS_INT_RANGE_TYPE:
- GST_CAT_DEBUG (GST_CAT_PROPERTIES, "%p: %s: int range %d-%d", entry, name, entry->data.int_range_data.min,
- entry->data.int_range_data.max);
- break;
- case GST_PROPS_FLOAT_RANGE_TYPE:
- GST_CAT_DEBUG (GST_CAT_PROPERTIES, "%p: %s: float range %g-%g", entry, name, entry->data.float_range_data.min,
- entry->data.float_range_data.max);
- break;
- case GST_PROPS_LIST_TYPE:
- GST_CAT_DEBUG (GST_CAT_PROPERTIES, "%p: [list]", entry);
- g_list_foreach (entry->data.list_data.entries, (GFunc) gst_props_debug_entry, NULL);
- break;
- default:
- g_warning ("unknown property type %d at %p", entry->propstype, entry);
- break;
- }
-}
-
-static gint
-props_compare_func (gconstpointer a,
- gconstpointer b)
-{
- GstPropsEntry *entry1 = (GstPropsEntry *)a;
- GstPropsEntry *entry2 = (GstPropsEntry *)b;
-
- return (entry1->propid - entry2->propid);
-}
-
-static gint
-props_find_func (gconstpointer a,
- gconstpointer b)
-{
- GstPropsEntry *entry2 = (GstPropsEntry *)a;
- GQuark quark = (GQuark) GPOINTER_TO_INT (b);
-
- return (quark - entry2->propid);
-}
-
-/* This is implemented as a huge macro because we cannot pass
- * va_list variables by reference on some architectures.
- */
-static inline GstPropsType
-gst_props_type_sanitize (GstPropsType type)
-{
- switch (type) {
- case GST_PROPS_INT_TYPE:
- case GST_PROPS_INT_RANGE_TYPE:
- return GST_PROPS_INT_TYPE;
- case GST_PROPS_FLOAT_TYPE:
- case GST_PROPS_FLOAT_RANGE_TYPE:
- return GST_PROPS_FLOAT_TYPE;
- case GST_PROPS_FOURCC_TYPE:
- case GST_PROPS_BOOLEAN_TYPE:
- case GST_PROPS_STRING_TYPE:
- return type;
- case GST_PROPS_LIST_TYPE:
- case GST_PROPS_GLIST_TYPE:
- return GST_PROPS_LIST_TYPE;
- case GST_PROPS_END_TYPE:
- case GST_PROPS_INVALID_TYPE:
- case GST_PROPS_VAR_TYPE:
- case GST_PROPS_LAST_TYPE:
- break;
- }
- g_assert_not_reached ();
- return GST_PROPS_END_TYPE;
-}
-#define GST_PROPS_ENTRY_FILL(entry, var_args) \
-G_STMT_START { \
- entry->propstype = va_arg (var_args, GstPropsType); \
- if (entry->propstype == GST_PROPS_LIST_TYPE) { \
- GList *_list = NULL; \
- GstPropsEntry *_cur = NULL; /* initialize so gcc doesn't complain */ \
- GstPropsType _cur_type; \
- GstPropsType _type = va_arg (var_args, GstPropsType); \
- _cur_type = _type; \
- _type = gst_props_type_sanitize (_type); \
- while (_cur_type != GST_PROPS_END_TYPE) { \
- _cur = gst_props_alloc_entry (); \
- _cur->propid = entry->propid; \
- _cur->propstype = _cur_type; \
- _cur_type = gst_props_type_sanitize (_cur_type); \
- g_assert (_cur_type == _type); \
- GST_PROPS_ENTRY_FILL_DATA(_cur, var_args); \
- if (_cur_type == GST_PROPS_INT_TYPE) { \
- _list = gst_props_add_to_int_list (_list, _cur); \
- } else { \
- _list = g_list_prepend (_list, _cur); \
- } \
- _cur_type = va_arg (var_args, GstPropsType); \
- } \
- if (_list && g_list_next (_list)) { \
- entry->data.list_data.entries = _list; \
- } else { \
- entry->propstype = _cur->propstype; \
- entry->data = _cur->data; \
- gst_props_entry_free (_cur); \
- } \
- } else { \
- GST_PROPS_ENTRY_FILL_DATA(entry, var_args); \
- } \
-} G_STMT_END
-
-#define GST_PROPS_ENTRY_FILL_DATA(entry, var_args) \
-G_STMT_START { \
- switch (entry->propstype) { \
- case GST_PROPS_INT_TYPE: \
- entry->data.int_data = va_arg (var_args, gint); \
- break; \
- case GST_PROPS_INT_RANGE_TYPE: \
- entry->data.int_range_data.min = va_arg (var_args, gint); \
- entry->data.int_range_data.max = va_arg (var_args, gint); \
- break; \
- case GST_PROPS_FLOAT_TYPE: \
- entry->data.float_data = va_arg (var_args, gdouble); \
- break; \
- case GST_PROPS_FLOAT_RANGE_TYPE: \
- entry->data.float_range_data.min = va_arg (var_args, gdouble); \
- entry->data.float_range_data.max = va_arg (var_args, gdouble); \
- break; \
- case GST_PROPS_FOURCC_TYPE: \
- entry->data.fourcc_data = va_arg (var_args, gulong); \
- break; \
- case GST_PROPS_BOOLEAN_TYPE: \
- entry->data.bool_data = va_arg (var_args, gboolean); \
- break; \
- case GST_PROPS_STRING_TYPE: \
- entry->data.string_data.string = g_strdup (va_arg (var_args, gchar*)); \
- break; \
- case GST_PROPS_GLIST_TYPE: \
- entry->propstype = GST_PROPS_LIST_TYPE; \
- entry->data.list_data.entries = g_list_copy (va_arg (var_args, GList*)); \
- break; \
- case GST_PROPS_END_TYPE: \
- break; \
- default: \
- g_warning("attempt to set invalid props type\n"); \
- break; \
- } \
-} G_STMT_END
-
-
-#define GST_PROPS_ENTRY_READ(entry, var_args, safe, result) \
-G_STMT_START { \
- \
- *result = TRUE; \
- \
- if (safe) { \
- GstPropsType propstype = va_arg (var_args, GstPropsType); \
- if (propstype != entry->propstype) { \
- *result = FALSE; \
- } \
- } \
- if (*result) { \
- switch (entry->propstype) { \
- case GST_PROPS_INT_TYPE: \
- *(va_arg (var_args, gint*)) = entry->data.int_data; \
- break; \
- case GST_PROPS_INT_RANGE_TYPE: \
- *(va_arg (var_args, gint*)) = entry->data.int_range_data.min; \
- *(va_arg (var_args, gint*)) = entry->data.int_range_data.max; \
- break; \
- case GST_PROPS_FLOAT_TYPE: \
- *(va_arg (var_args, gfloat*)) = entry->data.float_data; \
- break; \
- case GST_PROPS_FLOAT_RANGE_TYPE: \
- *(va_arg (var_args, gfloat*)) = entry->data.float_range_data.min; \
- *(va_arg (var_args, gfloat*)) = entry->data.float_range_data.max; \
- break; \
- case GST_PROPS_FOURCC_TYPE: \
- *(va_arg (var_args, guint32*)) = entry->data.fourcc_data; \
- break; \
- case GST_PROPS_BOOLEAN_TYPE: \
- *(va_arg (var_args, gboolean*)) = entry->data.bool_data; \
- break; \
- case GST_PROPS_STRING_TYPE: \
- *(va_arg (var_args, gchar**)) = entry->data.string_data.string; \
- break; \
- case GST_PROPS_LIST_TYPE: \
- *(va_arg (var_args, GList**)) = entry->data.list_data.entries; \
- break; \
- case GST_PROPS_END_TYPE: \
- break; \
- default: \
- *result = FALSE; \
- break; \
- } \
- } \
-} G_STMT_END
-
-static GstPropsEntry*
-gst_props_alloc_entry (void)
-{
- GstPropsEntry *entry;
-
- entry = gst_mem_chunk_alloc (_gst_props_entries_chunk);
-#ifndef GST_DISABLE_TRACE
- gst_alloc_trace_new (_entries_trace, entry);
-#endif
-
- GST_CAT_LOG (GST_CAT_PROPERTIES, "new entry %p", entry);
-
- return entry;
-}
-
-static void
-gst_props_entry_clean (GstPropsEntry *entry)
-{
- switch (entry->propstype) {
- case GST_PROPS_STRING_TYPE:
- g_free (entry->data.string_data.string);
- break;
- case GST_PROPS_LIST_TYPE:
- g_list_foreach (entry->data.list_data.entries, (GFunc) gst_props_entry_destroy, NULL);
- g_list_free (entry->data.list_data.entries);
- break;
- default:
- break;
- }
-}
-static inline void
-gst_props_entry_free (GstPropsEntry *entry)
-{
-#ifdef USE_POISONING
- memset (entry, 0xff, sizeof(*entry));
-#endif
- gst_mem_chunk_free (_gst_props_entries_chunk, entry);
-#ifndef GST_DISABLE_TRACE
- gst_alloc_trace_free (_entries_trace, entry);
-#endif
-}
-/**
- * gst_props_entry_destroy:
- * @entry: the entry to destroy
- *
- * Free the given propsentry
- */
-void
-gst_props_entry_destroy (GstPropsEntry *entry)
-{
- if (!entry) return;
-
- GST_CAT_LOG (GST_CAT_PROPERTIES, "destroy entry %p", entry);
-
- gst_props_entry_clean (entry);
-
- gst_props_entry_free (entry);
-}
-
-GType
-gst_props_get_type (void)
-{
- return _gst_props_type;
-}
-
-/**
- * gst_props_empty_new:
- *
- * Create a new empty property.
- *
- * Returns: the new property
- */
-GstProps*
-gst_props_empty_new (void)
-{
- GstProps *props;
-
- props = gst_mem_chunk_alloc (_gst_props_chunk);
-#ifndef GST_DISABLE_TRACE
- gst_alloc_trace_new (_props_trace, props);
-#endif
-
- GST_CAT_LOG (GST_CAT_PROPERTIES, "new %p", props);
-
- props->properties = NULL;
- props->refcount = 1;
- GST_PROPS_FLAG_SET (props, GST_PROPS_FLOATING);
- GST_PROPS_FLAG_SET (props, GST_PROPS_FIXED);
-
- return props;
-}
-
-/**
- * gst_props_replace:
- * @oldprops: the props to take replace
- * @newprops: the props to take replace
- *
- * Replace the pointer to the props, doing proper
- * refcounting.
- */
-void
-gst_props_replace (GstProps **oldprops, GstProps *newprops)
-{
- if (*oldprops != newprops) {
- if (newprops) gst_props_ref (newprops);
- if (*oldprops) gst_props_unref (*oldprops);
-
- *oldprops = newprops;
- }
-}
-
-/**
- * gst_props_replace_sink:
- * @oldprops: the props to take replace
- * @newprops: the props to take replace
- *
- * Replace the pointer to the props and take ownership.
- */
-void
-gst_props_replace_sink (GstProps **oldprops, GstProps *newprops)
-{
- gst_props_replace (oldprops, newprops);
- gst_props_sink (newprops);
-}
-
-/**
- * gst_props_add_entry:
- * @props: the property to add the entry to
- * @entry: the entry to add
- *
- * Addes the given propsentry to the props
- */
-void
-gst_props_add_entry (GstProps *props, GstPropsEntry *entry)
-{
- g_return_if_fail (props);
- g_return_if_fail (entry);
-
- /* only variable properties can change the fixed flag */
- if (GST_PROPS_IS_FIXED (props) && GST_PROPS_ENTRY_IS_VARIABLE (entry)) {
- GST_PROPS_FLAG_UNSET (props, GST_PROPS_FIXED);
- }
- props->properties = g_list_insert_sorted (props->properties, entry, props_compare_func);
-}
-
-static void
-gst_props_remove_entry_by_id (GstProps *props, GQuark propid)
-{
- GList *properties;
- gboolean found;
-
- /* assume fixed */
- GST_PROPS_FLAG_SET (props, GST_PROPS_FIXED);
-
- found = FALSE;
-
- properties = props->properties;
- while (properties) {
- GList *current = properties;
- GstPropsEntry *lentry = (GstPropsEntry *) current->data;
-
- properties = g_list_next (properties);
-
- if (lentry->propid == propid) {
- found = TRUE;
- props->properties = g_list_delete_link (props->properties, current);
- gst_props_entry_destroy (lentry);
- }
- else if (GST_PROPS_ENTRY_IS_VARIABLE (lentry)) {
- GST_PROPS_FLAG_UNSET (props, GST_PROPS_FIXED);
- /* no need to check for further variable entries
- * if we already removed the entry */
- if (found)
- break;
- }
- }
-}
-/**
- * gst_props_remove_entry:
- * @props: the property to remove the entry from
- * @entry: the entry to remove
- *
- * Removes the given propsentry from the props.
- */
-void
-gst_props_remove_entry (GstProps *props, GstPropsEntry *entry)
-{
- g_return_if_fail (props != NULL);
- g_return_if_fail (entry != NULL);
-
- gst_props_remove_entry_by_id (props, entry->propid);
-}
-
-/**
- * gst_props_remove_entry_by_name:
- * @props: the property to remove the entry from
- * @name: the name of the entry to remove
- *
- * Removes the propsentry with the given name from the props.
- */
-void
-gst_props_remove_entry_by_name (GstProps *props, const gchar *name)
-{
- GQuark quark;
-
- g_return_if_fail (props != NULL);
- g_return_if_fail (name != NULL);
-
- quark = g_quark_from_string (name);
- gst_props_remove_entry_by_id (props, quark);
-}
-
-/**
- * gst_props_new:
- * @firstname: the first property name
- * @...: the property values
- *
- * Create a new property from the given key/value pairs
- *
- * Returns: the new property
- */
-GstProps*
-gst_props_new (const gchar *firstname, ...)
-{
- GstProps *props;
- va_list var_args;
-
- va_start (var_args, firstname);
-
- props = gst_props_newv (firstname, var_args);
-
- va_end (var_args);
-
- return props;
-}
-
-/**
- * gst_props_debug:
- * @props: the props to debug
- *
- * Dump the contents of the given properties into the DEBUG log.
- */
-void
-gst_props_debug (GstProps *props)
-{
- if (!props) {
- GST_CAT_DEBUG (GST_CAT_PROPERTIES, "props (null)");
- return;
- }
-
- GST_CAT_DEBUG (GST_CAT_PROPERTIES, "props %p, refcount %d, flags %d",
- props, props->refcount, props->flags);
-
- g_list_foreach (props->properties, (GFunc) gst_props_debug_entry, NULL);
-}
-
-/**
- * gst_props_merge_int_entries:
- * @newentry: the new entry
- * @oldentry: an old entry
- *
- * Tries to merge oldentry into newentry, if there is a simpler single entry which represents
- *
- * Assumes that the entries are either ints or int ranges.
- *
- * Returns: TRUE if the entries were merged, FALSE otherwise.
- */
-static gboolean
-gst_props_merge_int_entries(GstPropsEntry *newentry, GstPropsEntry *oldentry)
-{
- gint new_min, new_max, old_min, old_max;
- gboolean can_merge = FALSE;
-
- if (newentry->propstype == GST_PROPS_INT_TYPE) {
- new_min = newentry->data.int_data;
- new_max = newentry->data.int_data;
- } else {
- new_min = newentry->data.int_range_data.min;
- new_max = newentry->data.int_range_data.max;
- }
-
- if (oldentry->propstype == GST_PROPS_INT_TYPE) {
- old_min = oldentry->data.int_data;
- old_max = oldentry->data.int_data;
- } else {
- old_min = oldentry->data.int_range_data.min;
- old_max = oldentry->data.int_range_data.max;
- }
-
- /* Put range which starts lower into (new_min, new_max) */
- if (old_min < new_min) {
- gint tmp;
- tmp = old_min;
- old_min = new_min;
- new_min = tmp;
- tmp = old_max;
- old_max = new_max;
- new_max = tmp;
- }
-
- /* new_min is min of either entry - second half of the following conditional */
- /* is to avoid overflow problems. */
- if (new_max >= old_min - 1 && old_min - 1 < old_min) {
- /* ranges overlap, or are adjacent. Pick biggest maximum. */
- can_merge = TRUE;
- if (old_max > new_max) new_max = old_max;
- }
-
- if (can_merge) {
- if (new_min == new_max) {
- newentry->propstype = GST_PROPS_INT_TYPE;
- newentry->data.int_data = new_min;
- } else {
- newentry->propstype = GST_PROPS_INT_RANGE_TYPE;
- newentry->data.int_range_data.min = new_min;
- newentry->data.int_range_data.max = new_max;
- }
- }
- return can_merge;
-}
-
-/**
- * gst_props_add_to_int_list:
- * @entries: the existing list of entries
- * @entry: the new entry to add to the list
- *
- * Add an integer property to a list of properties, removing duplicates
- * and merging ranges.
- *
- * Assumes that the existing list is in simplest form, contains
- * only ints and int ranges, and that the new entry is an int or
- * an int range.
- *
- * Returns: a pointer to a list with the new entry added.
- */
-static GList*
-gst_props_add_to_int_list (GList *entries, GstPropsEntry *newentry)
-{
- GList *i;
-
- i = entries;
- while (i) {
- GstPropsEntry *oldentry = (GstPropsEntry *)(i->data);
- gboolean merged = gst_props_merge_int_entries(newentry, oldentry);
-
- if (merged) {
- /* replace the existing one with the merged one */
- gst_props_entry_destroy (oldentry);
-
- entries = g_list_remove_link (entries, i);
- g_list_free_1 (i);
-
- /* start again: it's possible that this change made an earlier entry */
- /* mergeable, and the pointer is now invalid anyway. */
- i = entries;
- }
-
- i = g_list_next (i);
- }
-
- return g_list_prepend (entries, newentry);
-}
-
-GType
-gst_props_entry_get_type (void)
-{
- return _gst_props_entry_type;
-}
-
-#define GST_PROPS_ENTRY_NEW(entry, name,var_args) \
-G_STMT_START { \
- entry = gst_props_alloc_entry (); \
- entry->propid = g_quark_from_string (name); \
- GST_PROPS_ENTRY_FILL (entry, var_args); \
-} G_STMT_END
-static GstPropsEntry*
-gst_props_entry_newv (const gchar *name, va_list var_args)
-{
- GstPropsEntry *entry;
-
- GST_PROPS_ENTRY_NEW (entry, name, var_args);
-
- return entry;
-}
-
-/**
- * gst_props_entry_new:
- * @name: the name of the props entry
- * @...: the value of the entry
- *
- * Create a new property entry with the given key/value.
- *
- * Returns: the new entry.
- */
-GstPropsEntry*
-gst_props_entry_new (const gchar *name, ...)
-{
- va_list var_args;
- GstPropsEntry *entry;
-
- va_start (var_args, name);
- entry = gst_props_entry_newv (name, var_args);
- va_end (var_args);
-
- return entry;
-}
-
-/**
- * gst_props_newv:
- * @firstname: the first property name
- * @var_args: the property values
- *
- * Create a new property from the list of entries.
- *
- * Returns: the new property created from the list of entries
- */
-GstProps*
-gst_props_newv (const gchar *firstname, va_list var_args)
-{
- GstProps *props;
- const gchar *prop_name;
-
- if (firstname == NULL)
- return NULL;
-
- props = gst_props_empty_new ();
-
- prop_name = firstname;
-
- /* properties */
- while (prop_name) {
- GstPropsEntry *entry;
-
- GST_PROPS_ENTRY_NEW (entry, prop_name, var_args);
- gst_props_add_entry (props, entry);
-
- prop_name = va_arg (var_args, gchar*);
- }
-
- return props;
-}
-
-/**
- * gst_props_set:
- * @props: the props to modify
- * @name: the name of the entry to modify
- * @...: The prop entry.
- *
- * Modifies the value of the given entry in the props struct.
- * For the optional args, use GST_PROPS_FOO, where FOO is INT,
- * STRING, etc. This macro expands to a variable number of arguments,
- * hence the lack of precision in the function prototype. No
- * terminating NULL is necessary as only one property can be changed.
- *
- * Returns: the new modified property structure.
- */
-GstProps*
-gst_props_set (GstProps *props, const gchar *name, ...)
-{
- GQuark quark;
- GList *properties;
- va_list var_args;
- gboolean found;
- gboolean was_fixed;
-
- g_return_val_if_fail (props != NULL, NULL);
-
- found = FALSE;
- was_fixed = GST_PROPS_IS_FIXED (props);
- GST_PROPS_FLAG_SET (props, GST_PROPS_FIXED);
-
- quark = g_quark_from_string (name);
- /* this looks a little complicated but the idea is to get
- * out of the loop ASAP. Changing the entry to a variable
- * property immediatly marks the props as non-fixed.
- * changing the entry to fixed when the props was fixed
- * does not change the props and we can get out of the loop
- * as well.
- * When changing the entry to a fixed entry, we need to
- * see if all entries are fixed before we can decide the props
- */
- properties = props->properties;
- while (properties) {
- GstPropsEntry *entry;
-
- entry = (GstPropsEntry *) properties->data;
-
- if (entry->propid == quark) {
- found = TRUE;
-
- va_start (var_args, name);
- gst_props_entry_clean (entry);
- GST_PROPS_ENTRY_FILL (entry, var_args);
- va_end (var_args);
-
- /* if the props was fixed and we changed this entry
- * with a fixed entry, we can stop now as the global
- * props flag cannot change */
- if (was_fixed && !GST_PROPS_ENTRY_IS_VARIABLE (entry))
- break;
- /* if we already found a non fixed entry we can exit */
- if (!GST_PROPS_IS_FIXED (props))
- break;
- /* if the entry is variable, we'll get out of the loop
- * in the next statement */
- /* if the entry is fixed we have to check all other
- * entries before we can decide if the props are fixed */
- }
-
- if (GST_PROPS_ENTRY_IS_VARIABLE (entry)) {
- /* mark the props as variable */
- GST_PROPS_FLAG_UNSET (props, GST_PROPS_FIXED);
- /* if we already changed the entry, we can stop now */
- if (found)
- break;
- }
- properties = g_list_next (properties);
- }
-
- if (!found) {
- g_warning ("gstprops: no property '%s' to change\n", name);
- }
-
- return props;
-}
-
-
-/**
- * gst_props_unref:
- * @props: the props to unref
- *
- * Decrease the refcount of the property structure, destroying
- * the property if the refcount is 0.
- *
- * Returns: handle to unrefed props or NULL when it was
- * destroyed.
- */
-GstProps*
-gst_props_unref (GstProps *props)
-{
- if (props == NULL)
- return NULL;
-
- g_return_val_if_fail (props->refcount > 0, NULL);
-
- GST_CAT_LOG (GST_CAT_PROPERTIES, "unref %p (%d->%d)", props, props->refcount, props->refcount-1);
- props->refcount--;
-
- if (props->refcount == 0) {
- gst_props_destroy (props);
- return NULL;
- }
-
- return props;
-}
-
-/**
- * gst_props_ref:
- * @props: the props to ref
- *
- * Increase the refcount of the property structure.
- *
- * Returns: handle to refed props.
- */
-GstProps*
-gst_props_ref (GstProps *props)
-{
- if (props == NULL)
- return NULL;
-
- g_return_val_if_fail (props->refcount > 0, NULL);
-
- GST_CAT_LOG (GST_CAT_PROPERTIES, "ref %p (%d->%d)", props, props->refcount, props->refcount+1);
-
- props->refcount++;
-
- return props;
-}
-
-/**
- * gst_props_sink:
- * @props: the props to sink
- *
- * If the props if floating, decrease its refcount. Usually used
- * with gst_props_ref() to take ownership of the props.
- */
-void
-gst_props_sink (GstProps *props)
-{
- if (props == NULL)
- return;
-
- GST_CAT_LOG (GST_CAT_PROPERTIES, "sink %p", props);
-
- if (GST_PROPS_IS_FLOATING (props)) {
- GST_PROPS_FLAG_UNSET (props, GST_PROPS_FLOATING);
- gst_props_unref (props);
- }
-}
-
-/**
- * gst_props_destroy:
- * @props: the props to destroy
- *
- * Destroy the property, freeing all the memory that
- * was allocated.
- */
-static void
-gst_props_destroy (GstProps *props)
-{
- if (props == NULL)
- return;
-
- g_list_foreach (props->properties, (GFunc) gst_props_entry_destroy, NULL);
- g_list_free (props->properties);
-
-#ifdef USE_POISONING
- memset(props, 0xff, sizeof(*props));
-#endif
- gst_mem_chunk_free (_gst_props_chunk, props);
-#ifndef GST_DISABLE_TRACE
- gst_alloc_trace_free (_props_trace, props);
-#endif
-}
-
-/**
- * gst_props_entry_copy:
- * @entry: the entry to copy
- *
- * Copy the propsentry.
- *
- * Returns: a new #GstPropsEntry that is a copy of the original
- * given entry.
- */
-GstPropsEntry*
-gst_props_entry_copy (const GstPropsEntry *entry)
-{
- GstPropsEntry *newentry;
-
- newentry = gst_props_alloc_entry ();
- memcpy (newentry, entry, sizeof (GstPropsEntry));
-
- switch (entry->propstype) {
- case GST_PROPS_LIST_TYPE:
- newentry->data.list_data.entries = gst_props_list_copy (entry->data.list_data.entries);
- break;
- case GST_PROPS_STRING_TYPE:
- newentry->data.string_data.string = g_strdup (entry->data.string_data.string);
- break;
- default:
- /* FIXME more? */
- break;
- }
-
- return newentry;
-}
-
-static GList*
-gst_props_list_copy (GList *propslist)
-{
- GList *new = NULL;
-
- while (propslist) {
- GstPropsEntry *entry = (GstPropsEntry *)propslist->data;
-
- new = g_list_prepend (new, gst_props_entry_copy (entry));
-
- propslist = g_list_next (propslist);
- }
- new = g_list_reverse (new);
-
- return new;
-}
-
-/**
- * gst_props_copy:
- * @props: the props to copy
- *
- * Copy the property structure.
- *
- * Returns: the new property that is a copy of the original
- * one.
- */
-GstProps*
-gst_props_copy (GstProps *props)
-{
- GstProps *new;
-
- if (props == NULL)
- return NULL;
-
- new = gst_props_empty_new ();
- new->properties = gst_props_list_copy (props->properties);
- GST_PROPS_FLAGS (new) = GST_PROPS_FLAGS (props) | GST_PROPS_FLOATING;
-
- return new;
-}
-
-/**
- * gst_props_copy_on_write:
- * @props: the props to copy on write
- *
- * Copy the property structure if the refcount is >1.
- *
- * Returns: A new props that can be safely written to.
- */
-GstProps*
-gst_props_copy_on_write (GstProps *props)
-{
- GstProps *new = props;;
-
- g_return_val_if_fail (props != NULL, NULL);
-
- if (props->refcount > 1) {
- new = gst_props_copy (props);
- gst_props_unref (props);
- }
-
- return new;
-}
-
-/**
- * gst_props_get_entry:
- * @props: the props to query
- * @name: the name of the entry to get
- *
- * Get the props entry with the given name
- *
- * Returns: The props entry with the given name or NULL if
- * the entry does not exist.
- */
-const GstPropsEntry*
-gst_props_get_entry (GstProps *props, const gchar *name)
-{
- GList *lentry;
- GQuark quark;
-
- g_return_val_if_fail (name != NULL, NULL);
-
- if (props == NULL) return FALSE;
-
- quark = g_quark_from_string (name);
-
- lentry = g_list_find_custom (props->properties, GINT_TO_POINTER (quark), props_find_func);
-
- if (lentry) {
- GstPropsEntry *thisentry;
- thisentry = (GstPropsEntry *)lentry->data;
- return thisentry;
- }
- return NULL;
-}
-
-/**
- * gst_props_has_property:
- * @props: the props to check
- * @name: the name of the key to find
- *
- * Checks if a given props has a property with the given name.
- *
- * Returns: TRUE if the property was found, FALSE otherwise.
- */
-gboolean
-gst_props_has_property (GstProps *props, const gchar *name)
-{
- return (gst_props_get_entry (props, name) != NULL);
-}
-
-/**
- * gst_props_has_property_typed:
- * @props: the props to check
- * @name: the name of the key to find
- * @type: the type of the required property
- *
- * Checks if a given props has a property with the given name and the given type.
- *
- * Returns: TRUE if the property was found, FALSE otherwise.
- */
-gboolean
-gst_props_has_property_typed (GstProps *props, const gchar *name, GstPropsType type)
-{
- const GstPropsEntry *entry;
-
- entry = gst_props_get_entry (props, name);
- if (!entry)
- return FALSE;
-
- return (entry->propstype == type);
-}
-
-/**
- * gst_props_has_fixed_property:
- * @props: the props to check
- * @name: the name of the key to find
- *
- * Checks if a given props has a property with the given name that
- * is also fixed, ie. is not a list or a range.
- *
- * Returns: TRUE if the property was found, FALSE otherwise.
- */
-gboolean
-gst_props_has_fixed_property (GstProps *props, const gchar *name)
-{
- const GstPropsEntry *entry;
-
- entry = gst_props_get_entry (props, name);
- if (!entry)
- return FALSE;
-
- return !GST_PROPS_ENTRY_IS_VARIABLE (entry);
-}
-
-/**
- * gst_props_entry_get_props_type:
- * @entry: the props entry to query
- *
- * Get the type of the given props entry.
- *
- * Returns: The type of the props entry.
- */
-GstPropsType
-gst_props_entry_get_props_type (const GstPropsEntry *entry)
-{
- g_return_val_if_fail (entry != NULL, GST_PROPS_INVALID_TYPE);
-
- return entry->propstype;
-}
-
-/**
- * gst_props_entry_get_name:
- * @entry: the props entry to query
- *
- * Get the name of the given props entry.
- *
- * Returns: The name of the props entry.
- */
-const gchar*
-gst_props_entry_get_name (const GstPropsEntry *entry)
-{
- g_return_val_if_fail (entry != NULL, NULL);
-
- return g_quark_to_string (entry->propid);
-}
-
-/**
- * gst_props_entry_is_fixed:
- * @entry: the props entry to query
- *
- * Checks if the props entry is fixe, ie. is not a list
- * or a range.
- *
- * Returns: TRUE is the props entry is fixed.
- */
-gboolean
-gst_props_entry_is_fixed (const GstPropsEntry *entry)
-{
- g_return_val_if_fail (entry != NULL, FALSE);
-
- return !GST_PROPS_ENTRY_IS_VARIABLE (entry);
-}
-
-static gboolean
-gst_props_entry_getv (const GstPropsEntry *entry, gboolean safe, va_list var_args)
-{
- gboolean result;
-
- GST_PROPS_ENTRY_READ (entry, var_args, safe, &result);
-
- return result;
-}
-
-/**
- * gst_props_entry_get:
- * @entry: the props entry to query
- * @...: a pointer to a type that can hold the value.
- *
- * Gets the contents of the entry.
- *
- * Returns: TRUE is the props entry could be fetched.
- */
-gboolean
-gst_props_entry_get (const GstPropsEntry *entry, ...)
-{
- gboolean result;
- va_list var_args;
-
- g_return_val_if_fail (entry != NULL, FALSE);
-
- va_start (var_args, entry);
- result = gst_props_entry_getv (entry, FALSE, var_args);
- va_end (var_args);
-
- return result;
-}
-
-static gboolean
-gst_props_entry_get_safe (const GstPropsEntry *entry, ...)
-{
- gboolean result;
- va_list var_args;
-
- if(entry == NULL) return FALSE;
-
- va_start (var_args, entry);
- result = gst_props_entry_getv (entry, TRUE, var_args);
- va_end (var_args);
-
- return result;
-}
-
-static gboolean
-gst_props_getv (GstProps *props, gboolean safe, gchar *first_name, va_list var_args)
-{
- while (first_name) {
- const GstPropsEntry *entry = gst_props_get_entry (props, first_name);
- gboolean result;
-
- if (!entry) return FALSE;
- GST_PROPS_ENTRY_READ (entry, var_args, safe, &result);
- if (!result) return FALSE;
-
- first_name = va_arg (var_args, gchar *);
- }
- return TRUE;
-}
-
-/**
- * gst_props_get:
- * @props: the props to query
- * @first_name: the first key
- * @...: a pointer to a datastructure that can hold the value.
- *
- * Gets the contents of the props into given key/value pairs.
- * Make sure you pass a NULL terminated list.
- *
- * Returns: TRUE if all of the props entries could be fetched.
- */
-gboolean
-gst_props_get (GstProps *props, gchar *first_name, ...)
-{
- va_list var_args;
- gboolean ret;
-
- va_start (var_args, first_name);
- ret = gst_props_getv (props, FALSE, first_name, var_args);
- va_end (var_args);
-
- return ret;
-}
-
-/**
- * gst_props_get_safe:
- * @props: the props to query
- * @first_name: the first key
- * @...: a pointer to a datastructure that can hold the value.
- *
- * Gets the contents of the props into given key/value pairs.
- *
- * Returns: TRUE if all of the props entries could be fetched.
- */
-gboolean
-gst_props_get_safe (GstProps *props, gchar *first_name, ...)
-{
- va_list var_args;
- gboolean ret;
-
- va_start (var_args, first_name);
- ret = gst_props_getv (props, TRUE, first_name, var_args);
- va_end (var_args);
-
- return ret;
-}
-
-/**
- * gst_props_entry_get_int:
- * @entry: the props entry to query
- * @val: a pointer to a gint to hold the value.
- *
- * Get the contents of the entry into the given gint.
- *
- * Returns: TRUE is the value could be fetched. FALSE if the
- * entry is not of given type or did not exist.
- */
-gboolean
-gst_props_entry_get_int (const GstPropsEntry *entry, gint *val)
-{
- return gst_props_entry_get_safe (entry, GST_PROPS_INT_TYPE, val);
-}
-
-/**
- * gst_props_entry_get_float:
- * @entry: the props entry to query
- * @val: a pointer to a gfloat to hold the value.
- *
- * Get the contents of the entry into the given gfloat.
- *
- * Returns: TRUE is the value could be fetched. FALSE if the
- * entry is not of given type or did not exist.
- */
-gboolean
-gst_props_entry_get_float (const GstPropsEntry *entry, gfloat *val)
-{
- return gst_props_entry_get_safe (entry, GST_PROPS_FLOAT_TYPE, val);
-}
-
-/**
- * gst_props_entry_get_fourcc_int:
- * @entry: the props entry to query
- * @val: a pointer to a guint32 to hold the value.
- *
- * Get the contents of the entry into the given guint32.
- *
- * Returns: TRUE is the value could be fetched. FALSE if the
- * entry is not of given type or did not exist.
- */
-gboolean
-gst_props_entry_get_fourcc_int (const GstPropsEntry *entry, guint32 *val)
-{
- return gst_props_entry_get_safe (entry, GST_PROPS_FOURCC_TYPE, val);
-}
-
-/**
- * gst_props_entry_get_boolean:
- * @entry: the props entry to query
- * @val: a pointer to a gboolean to hold the value.
- *
- * Get the contents of the entry into the given gboolean.
- *
- * Returns: TRUE is the value could be fetched. FALSE if the
- * entry is not of given type or did not exist.
- */
-gboolean
-gst_props_entry_get_boolean (const GstPropsEntry *entry, gboolean *val)
-{
- return gst_props_entry_get_safe (entry, GST_PROPS_BOOLEAN_TYPE, val);
-}
-
-/**
- * gst_props_entry_get_string:
- * @entry: the props entry to query
- * @val: a pointer to a gchar* to hold the value.
- *
- * Get the contents of the entry into the given gchar*.
- *
- * Returns: TRUE is the value could be fetched. FALSE if the
- * entry is not of given type or did not exist.
- */
-gboolean
-gst_props_entry_get_string (const GstPropsEntry *entry, const gchar **val)
-{
- return gst_props_entry_get_safe (entry, GST_PROPS_STRING_TYPE, val);
-}
-
-/**
- * gst_props_entry_get_int_range:
- * @entry: the props entry to query
- * @min: a pointer to a gint to hold the minimun value.
- * @max: a pointer to a gint to hold the maximum value.
- *
- * Get the contents of the entry into the given gints.
- *
- * Returns: TRUE is the value could be fetched. FALSE if the
- * entry is not of given type or did not exist.
- */
-gboolean
-gst_props_entry_get_int_range (const GstPropsEntry *entry, gint *min, gint *max)
-{
- return gst_props_entry_get_safe (entry, GST_PROPS_INT_RANGE_TYPE, min, max);
-}
-
-/**
- * gst_props_entry_get_float_range:
- * @entry: the props entry to query
- * @min: a pointer to a gfloat to hold the minimun value.
- * @max: a pointer to a gfloat to hold the maximum value.
- *
- * Get the contents of the entry into the given gfloats.
- *
- * Returns: TRUE is the value could be fetched. FALSE if the
- * entry is not of given type or did not exist.
- */
-gboolean
-gst_props_entry_get_float_range (const GstPropsEntry *entry, gfloat *min, gfloat *max)
-{
- return gst_props_entry_get_safe (entry, GST_PROPS_FLOAT_RANGE_TYPE, min, max);
-}
-
-/**
- * gst_props_entry_get_list:
- * @entry: the props entry to query
- * @val: a pointer to a GList to hold the value.
- *
- * Get the contents of the entry into the given GList.
- *
- * Returns: TRUE is the value could be fetched. FALSE if the
- * entry is not of given type or did not exist.
- */
-gboolean
-gst_props_entry_get_list (const GstPropsEntry *entry, const GList **val)
-{
- return gst_props_entry_get_safe (entry, GST_PROPS_LIST_TYPE, val);
-}
-
-/**
- * gst_props_merge:
- * @props: the property to merge into
- * @tomerge: the property to merge
- *
- * Merge the properties of tomerge into props.
- *
- * Returns: the new merged property
- */
-GstProps*
-gst_props_merge (GstProps *props, GstProps *tomerge)
-{
- GList *merge_props;
-
- g_return_val_if_fail (props != NULL, NULL);
- g_return_val_if_fail (tomerge != NULL, NULL);
-
- merge_props = tomerge->properties;
-
- /* FIXME do proper merging here... */
- while (merge_props) {
- GstPropsEntry *entry = (GstPropsEntry *)merge_props->data;
-
- gst_props_add_entry (props, entry);
-
- merge_props = g_list_next (merge_props);
- }
-
- return props;
-}
-
-
-/* entry2 is always a list, entry1 never is */
-static gboolean
-gst_props_entry_check_list_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry2)
-{
- GList *entrylist = entry2->data.list_data.entries;
- gboolean found = FALSE;
-
- while (entrylist && !found) {
- GstPropsEntry *entry = (GstPropsEntry *) entrylist->data;
-
- found |= gst_props_entry_check_compatibility (entry1, entry);
-
- entrylist = g_list_next (entrylist);
- }
-
- return found;
-}
-
-static gboolean
-gst_props_entry_check_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry2)
-{
- GST_CAT_DEBUG (GST_CAT_PROPERTIES,"compare: %s %s", g_quark_to_string (entry1->propid), g_quark_to_string (entry2->propid));
-
- if (entry2->propstype == GST_PROPS_LIST_TYPE && entry1->propstype != GST_PROPS_LIST_TYPE) {
- return gst_props_entry_check_list_compatibility (entry1, entry2);
- }
-
- switch (entry1->propstype) {
- case GST_PROPS_LIST_TYPE:
- {
- GList *entrylist = entry1->data.list_data.entries;
- gboolean valid = TRUE; /* innocent until proven guilty */
-
- while (entrylist && valid) {
- GstPropsEntry *entry = (GstPropsEntry *) entrylist->data;
-
- valid &= gst_props_entry_check_compatibility (entry, entry2);
-
- entrylist = g_list_next (entrylist);
- }
-
- return valid;
- }
- case GST_PROPS_INT_RANGE_TYPE:
- switch (entry2->propstype) {
- /* a - b <---> a - c */
- case GST_PROPS_INT_RANGE_TYPE:
- return (entry2->data.int_range_data.min <= entry1->data.int_range_data.min &&
- entry2->data.int_range_data.max >= entry1->data.int_range_data.max);
- default:
- break;
- }
- break;
- case GST_PROPS_FLOAT_RANGE_TYPE:
- switch (entry2->propstype) {
- /* a - b <---> a - c */
- case GST_PROPS_FLOAT_RANGE_TYPE:
- return (entry2->data.float_range_data.min <= entry1->data.float_range_data.min &&
- entry2->data.float_range_data.max >= entry1->data.float_range_data.max);
- default:
- break;
- }
- break;
- case GST_PROPS_FOURCC_TYPE:
- switch (entry2->propstype) {
- /* b <---> a */
- case GST_PROPS_FOURCC_TYPE:
- GST_CAT_DEBUG (GST_CAT_PROPERTIES,"\"%c%c%c%c\" <--> \"%c%c%c%c\" ?",
- (entry2->data.fourcc_data>>0)&0xff,
- (entry2->data.fourcc_data>>8)&0xff,
- (entry2->data.fourcc_data>>16)&0xff,
- (entry2->data.fourcc_data>>24)&0xff,
- (entry1->data.fourcc_data>>0)&0xff,
- (entry1->data.fourcc_data>>8)&0xff,
- (entry1->data.fourcc_data>>16)&0xff,
- (entry1->data.fourcc_data>>24)&0xff);
- return (entry2->data.fourcc_data == entry1->data.fourcc_data);
- default:
- break;
- }
- break;
- case GST_PROPS_INT_TYPE:
- switch (entry2->propstype) {
- /* b <---> a - d */
- case GST_PROPS_INT_RANGE_TYPE:
- GST_CAT_DEBUG (GST_CAT_PROPERTIES,"%d <= %d <= %d ?",entry2->data.int_range_data.min,
- entry1->data.int_data,entry2->data.int_range_data.max);
- return (entry2->data.int_range_data.min <= entry1->data.int_data &&
- entry2->data.int_range_data.max >= entry1->data.int_data);
- /* b <---> a */
- case GST_PROPS_INT_TYPE:
- GST_CAT_DEBUG (GST_CAT_PROPERTIES,"%d == %d ?",entry1->data.int_data,entry2->data.int_data);
- return (entry2->data.int_data == entry1->data.int_data);
- default:
- break;
- }
- break;
- case GST_PROPS_FLOAT_TYPE:
- switch (entry2->propstype) {
- /* b <---> a - d */
- case GST_PROPS_FLOAT_RANGE_TYPE:
- return (entry2->data.float_range_data.min <= entry1->data.float_data &&
- entry2->data.float_range_data.max >= entry1->data.float_data);
- /* b <---> a */
- case GST_PROPS_FLOAT_TYPE:
- return (entry2->data.float_data == entry1->data.float_data);
- default:
- break;
- }
- break;
- case GST_PROPS_BOOLEAN_TYPE:
- switch (entry2->propstype) {
- /* t <---> t */
- case GST_PROPS_BOOLEAN_TYPE:
- return (entry2->data.bool_data == entry1->data.bool_data);
- default:
- break;
- }
- case GST_PROPS_STRING_TYPE:
- switch (entry2->propstype) {
- /* t <---> t */
- case GST_PROPS_STRING_TYPE:
- GST_CAT_DEBUG (GST_CAT_PROPERTIES,"\"%s\" <--> \"%s\" ?",
- entry2->data.string_data.string, entry1->data.string_data.string);
- return (!strcmp (entry2->data.string_data.string, entry1->data.string_data.string));
- default:
- break;
- }
- default:
- break;
- }
-
- return FALSE;
-}
-
-/**
- * gst_props_check_compatibility:
- * @fromprops: a property
- * @toprops: a property
- *
- * Checks whether two capabilities are compatible.
- *
- * Returns: TRUE if compatible, FALSE otherwise
- */
-gboolean
-gst_props_check_compatibility (GstProps *fromprops, GstProps *toprops)
-{
- GList *sourcelist;
- GList *sinklist;
- gint missing = 0;
- gint more = 0;
- gboolean compatible = TRUE;
-
- g_return_val_if_fail (fromprops != NULL, FALSE);
- g_return_val_if_fail (toprops != NULL, FALSE);
-
- sourcelist = fromprops->properties;
- sinklist = toprops->properties;
-
- while (sourcelist && sinklist && compatible) {
- GstPropsEntry *entry1;
- GstPropsEntry *entry2;
-
- entry1 = (GstPropsEntry *)sourcelist->data;
- entry2 = (GstPropsEntry *)sinklist->data;
-
- while (entry1->propid < entry2->propid) {
- more++;
- sourcelist = g_list_next (sourcelist);
- if (sourcelist) entry1 = (GstPropsEntry *)sourcelist->data;
- else goto end;
- }
- while (entry1->propid > entry2->propid) {
- missing++;
- sinklist = g_list_next (sinklist);
- if (sinklist) entry2 = (GstPropsEntry *)sinklist->data;
- else goto end;
- }
-
- if (!gst_props_entry_check_compatibility (entry1, entry2)) {
- compatible = FALSE;
- GST_CAT_DEBUG (GST_CAT_PROPERTIES, "%s are not compatible: ",
- g_quark_to_string (entry1->propid));
- }
-
- sourcelist = g_list_next (sourcelist);
- sinklist = g_list_next (sinklist);
- }
- if (sinklist && compatible) {
- GstPropsEntry *entry2;
- entry2 = (GstPropsEntry *)sinklist->data;
- missing++;
- }
-end:
-
- if (missing)
- return FALSE;
-
- return compatible;
-}
-
-static gint
-_props_entry_flexibility (GstPropsEntry *entry)
-{
- gint rank;
- switch (entry->propstype) {
- default:
- rank = 0;
- break;
- case GST_PROPS_INT_RANGE_TYPE:
- rank = 1;
- break;
- case GST_PROPS_FLOAT_RANGE_TYPE:
- rank = 2;
- break;
- case GST_PROPS_LIST_TYPE:
- rank = 3;
- break;
- }
- return rank;
-}
-
-static GstPropsEntry*
-gst_props_entry_intersect (GstPropsEntry *entry1, GstPropsEntry *entry2)
-{
- GstPropsEntry *result = NULL;
-
- /* Swap more flexible types into entry1 */
- if (_props_entry_flexibility (entry1) < _props_entry_flexibility (entry2)) {
- GstPropsEntry *temp;
- temp = entry1;
- entry1 = entry2;
- entry2 = temp;
- }
-
- switch (entry1->propstype) {
- case GST_PROPS_LIST_TYPE:
- {
- GList *entrylist = entry1->data.list_data.entries;
- GList *intersection = NULL;
-
- while (entrylist) {
- GstPropsEntry *entry = (GstPropsEntry *) entrylist->data;
- GstPropsEntry *intersectentry;
-
- intersectentry = gst_props_entry_intersect (entry2, entry);
-
- if (intersectentry) {
- if (intersectentry->propstype == GST_PROPS_LIST_TYPE) {
- intersection = g_list_concat (intersection,
- intersectentry->data.list_data.entries);
- /* set the list to NULL because the entries are concatenated to the above
- * list and we don't want to free them */
- intersectentry->data.list_data.entries = NULL;
- gst_props_entry_destroy (intersectentry);
- }
- else {
- intersection = g_list_prepend (intersection, intersectentry);
- }
- }
- entrylist = g_list_next (entrylist);
- }
- if (intersection) {
- /* check if the list only contains 1 element, if so, we can just copy it */
- if (g_list_next (intersection) == NULL) {
- result = (GstPropsEntry *) (intersection->data);
- g_list_free (intersection);
- }
- /* else we need to create a new entry to hold the list */
- else {
- result = gst_props_alloc_entry ();
- result->propid = entry1->propid;
- result->propstype = GST_PROPS_LIST_TYPE;
- result->data.list_data.entries = g_list_reverse (intersection);
- }
- }
- return result;
- }
- case GST_PROPS_INT_RANGE_TYPE:
- switch (entry2->propstype) {
- /* a - b <---> a - c */
- case GST_PROPS_INT_RANGE_TYPE:
- {
- gint lower = MAX (entry1->data.int_range_data.min, entry2->data.int_range_data.min);
- gint upper = MIN (entry1->data.int_range_data.max, entry2->data.int_range_data.max);
-
- if (lower <= upper) {
- result = gst_props_alloc_entry ();
- result->propid = entry1->propid;
-
- if (lower == upper) {
- result->propstype = GST_PROPS_INT_TYPE;
- result->data.int_data = lower;
- }
- else {
- result->propstype = GST_PROPS_INT_RANGE_TYPE;
- result->data.int_range_data.min = lower;
- result->data.int_range_data.max = upper;
- }
- }
- break;
- }
- case GST_PROPS_LIST_TYPE:
- {
- GList *entries = entry2->data.list_data.entries;
- result = gst_props_alloc_entry ();
- result->propid = entry1->propid;
- result->propstype = GST_PROPS_LIST_TYPE;
- result->data.list_data.entries = NULL;
- while (entries) {
- GstPropsEntry *this = (GstPropsEntry *)entries->data;
- if (this->propstype != GST_PROPS_INT_TYPE) {
- /* no hope, this list doesn't even contain ints! */
- gst_props_entry_destroy (result);
- result = NULL;
- break;
- }
- if (this->data.int_data >= entry1->data.int_range_data.min &&
- this->data.int_data <= entry1->data.int_range_data.max)
- {
- /* prepend and reverse at the end */
- result->data.list_data.entries = g_list_prepend (result->data.list_data.entries,
- gst_props_entry_copy (this));
- }
- entries = g_list_next (entries);
- }
- if (result) {
- result->data.list_data.entries = g_list_reverse (result->data.list_data.entries);
- }
- break;
- }
- case GST_PROPS_INT_TYPE:
- {
- if (entry1->data.int_range_data.min <= entry2->data.int_data &&
- entry1->data.int_range_data.max >= entry2->data.int_data)
- {
- result = gst_props_entry_copy (entry2);
- }
- break;
- }
- default:
- break;
- }
- break;
- case GST_PROPS_FLOAT_RANGE_TYPE:
- switch (entry2->propstype) {
- /* a - b <---> a - c */
- case GST_PROPS_FLOAT_RANGE_TYPE:
- {
- gfloat lower = MAX (entry1->data.float_range_data.min, entry2->data.float_range_data.min);
- gfloat upper = MIN (entry1->data.float_range_data.max, entry2->data.float_range_data.max);
-
- if (lower <= upper) {
- result = gst_props_alloc_entry ();
- result->propid = entry1->propid;
-
- if (lower == upper) {
- result->propstype = GST_PROPS_FLOAT_TYPE;
- result->data.float_data = lower;
- }
- else {
- result->propstype = GST_PROPS_FLOAT_RANGE_TYPE;
- result->data.float_range_data.min = lower;
- result->data.float_range_data.max = upper;
- }
- }
- break;
- }
- case GST_PROPS_FLOAT_TYPE:
- if (entry1->data.float_range_data.min <= entry2->data.float_data &&
- entry1->data.float_range_data.max >= entry2->data.float_data)
- {
- result = gst_props_entry_copy (entry2);
- }
- default:
- break;
- }
- break;
- case GST_PROPS_FOURCC_TYPE:
- switch (entry2->propstype) {
- /* b <---> a */
- case GST_PROPS_FOURCC_TYPE:
- if (entry1->data.fourcc_data == entry2->data.fourcc_data)
- result = gst_props_entry_copy (entry1);
- default:
- break;
- }
- break;
- case GST_PROPS_INT_TYPE:
- switch (entry2->propstype) {
- /* b <---> a */
- case GST_PROPS_INT_TYPE:
- if (entry1->data.int_data == entry2->data.int_data)
- result = gst_props_entry_copy (entry1);
- default:
- break;
- }
- break;
- case GST_PROPS_FLOAT_TYPE:
- switch (entry2->propstype) {
- /* b <---> a */
- case GST_PROPS_FLOAT_TYPE:
- if (entry1->data.float_data == entry2->data.float_data)
- result = gst_props_entry_copy (entry1);
- default:
- break;
- }
- break;
- case GST_PROPS_BOOLEAN_TYPE:
- switch (entry2->propstype) {
- /* t <---> t */
- case GST_PROPS_BOOLEAN_TYPE:
- if (entry1->data.bool_data == entry2->data.bool_data)
- result = gst_props_entry_copy (entry1);
- default:
- break;
- }
- case GST_PROPS_STRING_TYPE:
- switch (entry2->propstype) {
- /* t <---> t */
- case GST_PROPS_STRING_TYPE:
- if (!strcmp (entry1->data.string_data.string, entry2->data.string_data.string))
- result = gst_props_entry_copy (entry1);
- default:
- break;
- }
- default:
- break;
- }
-
- /* make caps debugging extremely verbose
-
- GST_CAT_DEBUG (GST_CAT_CAPS, "intersecting %s: %s x %s => %s",
- g_quark_to_string (entry1->propid),
- gst_props_entry_to_string (entry1),
- gst_props_entry_to_string (entry2),
- result? gst_props_entry_to_string (result) : "fail");
- */
-
- return result;
-}
-
-/* when running over the entries in sorted order we can
- * optimize addition with _prepend and a reverse at the end */
-#define gst_props_entry_add_sorted_prepend(props, entry) \
-G_STMT_START { \
- /* avoid double evaluation of input */ \
- GstPropsEntry *toadd = (entry); \
- if (GST_PROPS_ENTRY_IS_VARIABLE (toadd)) \
- GST_PROPS_FLAG_UNSET ((props), GST_PROPS_FIXED); \
- props->properties = g_list_prepend ((props)->properties, toadd); \
-} G_STMT_END
-static gint
-compare_props_entry (gconstpointer one, gconstpointer two)
-{
- GstPropsEntry *a = (GstPropsEntry *) one;
- GstPropsEntry *b = (GstPropsEntry *) two;
-
- if (a->propid > b->propid) return 1;
- if (a->propid < b->propid) return -1;
- return 0;
-}
-/**
- * gst_props_intersect:
- * @props1: a property
- * @props2: another property
- *
- * Calculates the intersection bewteen two GstProps.
- *
- * Returns: a GstProps with the intersection or NULL if the
- * intersection is empty. The new GstProps is floating and must
- * be unreffed afetr use.
- */
-GstProps*
-gst_props_intersect (GstProps *props1, GstProps *props2)
-{
- GList *props1list;
- GList *props2list;
- GstProps *intersection;
- GList *leftovers;
- GstPropsEntry *iprops = NULL;
-
- g_return_val_if_fail (props1 != NULL, NULL);
- g_return_val_if_fail (props2 != NULL, NULL);
-
- intersection = gst_props_empty_new ();
-
- props1->properties = g_list_sort (props1->properties, compare_props_entry);
- props2->properties = g_list_sort (props2->properties, compare_props_entry);
-
- props1list = props1->properties;
- props2list = props2->properties;
-
- while (props1list && props2list) {
- GstPropsEntry *entry1;
- GstPropsEntry *entry2;
-
- entry1 = (GstPropsEntry *)props1list->data;
- entry2 = (GstPropsEntry *)props2list->data;
-
- while (entry1->propid < entry2->propid) {
- gst_props_entry_add_sorted_prepend (intersection, gst_props_entry_copy (entry1));
-
- props1list = g_list_next (props1list);
- if (!props1list)
- goto end;
-
- entry1 = (GstPropsEntry *)props1list->data;
- }
- while (entry1->propid > entry2->propid) {
- gst_props_entry_add_sorted_prepend (intersection, gst_props_entry_copy (entry2));
-
- props2list = g_list_next (props2list);
- if (!props2list)
- goto end;
-
- entry2 = (GstPropsEntry *)props2list->data;
- }
- if (entry1->propid < entry2->propid)
- continue;
- /* at this point we are talking about the same property */
- iprops = gst_props_entry_intersect (entry1, entry2);
- if (!iprops) {
- /* common properties did not intersect, intersection is empty */
- gst_props_unref (intersection);
- return NULL;
- }
-
- gst_props_entry_add_sorted_prepend (intersection, iprops);
-
- props1list = g_list_next (props1list);
- props2list = g_list_next (props2list);
- }
-
-end:
- /* at this point one of the lists could contain leftover properties, while
- * the other one is NULL */
- leftovers = props1list;
- if (!leftovers)
- leftovers = props2list;
-
- while (leftovers) {
- gst_props_entry_add_sorted_prepend (intersection,
- gst_props_entry_copy ((GstPropsEntry *) leftovers->data));
- leftovers = g_list_next (leftovers);
- }
-
- intersection->properties = g_list_reverse (intersection->properties);
-
- return intersection;
-}
-
-/**
- * gst_props_normalize:
- * @props: a property
- *
- * Unrolls all lists in the given GstProps. This is usefull if you
- * want to loop over the props.
- *
- * Returns: A GList with the unrolled props entries. g_list_free
- * after usage.
- */
-GList*
-gst_props_normalize (GstProps *props)
-{
- GList *entries;
- GList *result = NULL;
- gboolean fixed = TRUE;
-
- if (!props)
- return NULL;
-
- /* warning: the property here could have a wrong FIXED flag
- * but it'll be fixed at the end of the loop */
- entries = props->properties;
-
- while (entries) {
- GstPropsEntry *entry = (GstPropsEntry *) entries->data;
-
- /* be carefull with the bitmasks */
- fixed &= (GST_PROPS_ENTRY_IS_VARIABLE (entry) ? FALSE : TRUE);
-
- if (entry->propstype == GST_PROPS_LIST_TYPE) {
- GList *list_entries = entry->data.list_data.entries;
-
- while (list_entries) {
- GstPropsEntry *list_entry = (GstPropsEntry *) list_entries->data;
- GstPropsEntry *new_entry;
- GstProps *newprops;
- GList *lentry;
-
- newprops = gst_props_copy (props);
- lentry = g_list_find_custom (newprops->properties,
- GINT_TO_POINTER (list_entry->propid),
- props_find_func);
- if (lentry) {
- GList *new_list;
-
- new_entry = (GstPropsEntry *) lentry->data;
- memcpy (new_entry, list_entry, sizeof (GstPropsEntry));
- /* it's possible that this property now became fixed, since we
- * removed the list, we'll update the flag when everything is
- * unreolled at the end of this function */
- new_list = gst_props_normalize (newprops);
- result = g_list_concat (new_list, result);
- }
- else {
- /* FIXME append or prepend */
- result = g_list_append (result, newprops);
- }
-
- list_entries = g_list_next (list_entries);
- }
- /* we break out of the loop because the other lists are
- * unrolled in the recursive call */
- break;
- }
- entries = g_list_next (entries);
- }
- if (!result) {
- /* at this point, the props did not need any unrolling, we have scanned
- * all entries and the fixed flag will hold the correct value */
- if (fixed)
- GST_PROPS_FLAG_SET (props, GST_PROPS_FIXED);
- else
- GST_PROPS_FLAG_UNSET (props, GST_PROPS_FIXED);
-
- /* no result, create list with input props */
- result = g_list_prepend (result, props);
- }
- else {
- result = g_list_reverse (result);
- }
- return result;
-}
-
-#ifndef GST_DISABLE_LOADSAVE_REGISTRY
-static xmlNodePtr
-gst_props_save_thyself_func (GstPropsEntry *entry, xmlNodePtr parent)
-{
- xmlNodePtr subtree;
- gchar *str;
-
- switch (entry->propstype) {
- case GST_PROPS_INT_TYPE:
- subtree = xmlNewChild (parent, NULL, "int", NULL);
- xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
- str = g_strdup_printf ("%d", entry->data.int_data);
- xmlNewProp (subtree, "value", str);
- g_free(str);
- break;
- case GST_PROPS_INT_RANGE_TYPE:
- subtree = xmlNewChild (parent, NULL, "range", NULL);
- xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
- str = g_strdup_printf ("%d", entry->data.int_range_data.min);
- xmlNewProp (subtree, "min", str);
- g_free(str);
- str = g_strdup_printf ("%d", entry->data.int_range_data.max);
- xmlNewProp (subtree, "max", str);
- g_free(str);
- break;
- case GST_PROPS_FLOAT_TYPE:
- subtree = xmlNewChild (parent, NULL, "float", NULL);
- xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
- str = g_strdup_printf ("%g", entry->data.float_data);
- xmlNewProp (subtree, "value", str);
- g_free(str);
- break;
- case GST_PROPS_FLOAT_RANGE_TYPE:
- subtree = xmlNewChild (parent, NULL, "floatrange", NULL);
- xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
- str = g_strdup_printf ("%g", entry->data.float_range_data.min);
- xmlNewProp (subtree, "min", str);
- g_free(str);
- str = g_strdup_printf ("%g", entry->data.float_range_data.max);
- xmlNewProp (subtree, "max", str);
- g_free(str);
- break;
- case GST_PROPS_FOURCC_TYPE:
- str = g_strdup_printf ("%c%c%c%c",
- (entry->data.fourcc_data>>0)&0xff,
- (entry->data.fourcc_data>>8)&0xff,
- (entry->data.fourcc_data>>16)&0xff,
- (entry->data.fourcc_data>>24)&0xff);
- xmlAddChild (parent, xmlNewComment (str));
- g_free(str);
- subtree = xmlNewChild (parent, NULL, "fourcc", NULL);
- xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
- str = g_strdup_printf ("%08x", entry->data.fourcc_data);
- xmlNewProp (subtree, "hexvalue", str);
- g_free(str);
- break;
- case GST_PROPS_BOOLEAN_TYPE:
- subtree = xmlNewChild (parent, NULL, "boolean", NULL);
- xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
- xmlNewProp (subtree, "value", (entry->data.bool_data ? "true" : "false"));
- break;
- case GST_PROPS_STRING_TYPE:
- subtree = xmlNewChild (parent, NULL, "string", NULL);
- xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
- xmlNewProp (subtree, "value", entry->data.string_data.string);
- break;
- default:
- g_warning ("trying to save unknown property type %d", entry->propstype);
- break;
- }
-
- return parent;
-}
-
-/**
- * gst_props_save_thyself:
- * @props: a property to save
- * @parent: the parent XML tree
- *
- * Saves the property into an XML representation.
- *
- * Returns: the new XML tree
- */
-xmlNodePtr
-gst_props_save_thyself (GstProps *props, xmlNodePtr parent)
-{
- GList *proplist;
- xmlNodePtr subtree;
-
- g_return_val_if_fail (props != NULL, NULL);
-
- proplist = props->properties;
-
- while (proplist) {
- GstPropsEntry *entry = (GstPropsEntry *) proplist->data;
-
- switch (entry->propstype) {
- case GST_PROPS_LIST_TYPE:
- subtree = xmlNewChild (parent, NULL, "list", NULL);
- xmlNewProp (subtree, "name", g_quark_to_string (entry->propid));
- g_list_foreach (entry->data.list_data.entries, (GFunc) gst_props_save_thyself_func, subtree);
- break;
- default:
- gst_props_save_thyself_func (entry, parent);
- }
-
- proplist = g_list_next (proplist);
- }
-
- return parent;
-}
-
-static GstPropsEntry*
-gst_props_load_thyself_func (xmlNodePtr field)
-{
- GstPropsEntry *entry;
- gchar *prop;
-
- entry = gst_props_alloc_entry ();
-
- if (!strcmp(field->name, "int")) {
- entry->propstype = GST_PROPS_INT_TYPE;
- prop = xmlGetProp(field, "name");
- entry->propid = g_quark_from_string (prop);
- g_free (prop);
- prop = xmlGetProp(field, "value");
- sscanf (prop, "%d", &entry->data.int_data);
- g_free (prop);
- }
- else if (!strcmp(field->name, "range")) {
- entry->propstype = GST_PROPS_INT_RANGE_TYPE;
- prop = xmlGetProp(field, "name");
- entry->propid = g_quark_from_string (prop);
- g_free (prop);
- prop = xmlGetProp (field, "min");
- sscanf (prop, "%d", &entry->data.int_range_data.min);
- g_free (prop);
- prop = xmlGetProp (field, "max");
- sscanf (prop, "%d", &entry->data.int_range_data.max);
- g_free (prop);
- }
- else if (!strcmp(field->name, "float")) {
- entry->propstype = GST_PROPS_FLOAT_TYPE;
- prop = xmlGetProp(field, "name");
- entry->propid = g_quark_from_string (prop);
- g_free (prop);
- prop = xmlGetProp(field, "value");
- sscanf (prop, "%f", &entry->data.float_data);
- g_free (prop);
- }
- else if (!strcmp(field->name, "floatrange")) {
- entry->propstype = GST_PROPS_FLOAT_RANGE_TYPE;
- prop = xmlGetProp(field, "name");
- entry->propid = g_quark_from_string (prop);
- g_free (prop);
- prop = xmlGetProp (field, "min");
- sscanf (prop, "%f", &entry->data.float_range_data.min);
- g_free (prop);
- prop = xmlGetProp (field, "max");
- sscanf (prop, "%f", &entry->data.float_range_data.max);
- g_free (prop);
- }
- else if (!strcmp(field->name, "boolean")) {
- entry->propstype = GST_PROPS_BOOLEAN_TYPE;
- prop = xmlGetProp(field, "name");
- entry->propid = g_quark_from_string (prop);
- g_free (prop);
- prop = xmlGetProp (field, "value");
- if (!strcmp (prop, "false")) entry->data.bool_data = 0;
- else entry->data.bool_data = 1;
- g_free (prop);
- }
- else if (!strcmp(field->name, "fourcc")) {
- entry->propstype = GST_PROPS_FOURCC_TYPE;
- prop = xmlGetProp(field, "name");
- entry->propid = g_quark_from_string (prop);
- g_free (prop);
- prop = xmlGetProp (field, "hexvalue");
- sscanf (prop, "%08x", &entry->data.fourcc_data);
- g_free (prop);
- }
- else if (!strcmp(field->name, "string")) {
- entry->propstype = GST_PROPS_STRING_TYPE;
- prop = xmlGetProp(field, "name");
- entry->propid = g_quark_from_string (prop);
- g_free (prop);
- entry->data.string_data.string = xmlGetProp (field, "value");
- }
- else {
- gst_props_entry_destroy (entry);
- entry = NULL;
- }
-
- return entry;
-}
-
-/**
- * gst_props_load_thyself:
- * @parent: the XML tree to load from
- *
- * Creates a new property out of an XML tree.
- *
- * Returns: the new property
- */
-GstProps*
-gst_props_load_thyself (xmlNodePtr parent)
-{
- GstProps *props;
- xmlNodePtr field = parent->xmlChildrenNode;
- gchar *prop;
-
- props = gst_props_empty_new ();
-
- while (field) {
- if (!strcmp (field->name, "list")) {
- GstPropsEntry *entry;
- xmlNodePtr subfield = field->xmlChildrenNode;
-
- entry = gst_props_alloc_entry ();
- prop = xmlGetProp (field, "name");
- entry->propid = g_quark_from_string (prop);
- g_free (prop);
- entry->propstype = GST_PROPS_LIST_TYPE;
- entry->data.list_data.entries = NULL;
-
- while (subfield) {
- GstPropsEntry *subentry = gst_props_load_thyself_func (subfield);
-
- if (subentry)
- entry->data.list_data.entries = g_list_prepend (entry->data.list_data.entries, subentry);
-
- subfield = subfield->next;
- }
- entry->data.list_data.entries = g_list_reverse (entry->data.list_data.entries);
- gst_props_add_entry (props, entry);
- }
- else {
- GstPropsEntry *entry;
-
- entry = gst_props_load_thyself_func (field);
-
- if (entry)
- gst_props_add_entry (props, entry);
- }
- field = field->next;
- }
-
- return props;
-}
-#endif /* GST_DISABLE_LOADSAVE_REGISTRY */
+++ /dev/null
-/* 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__ */
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);
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);
}
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
#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);
g_value_unset(&field->value);
}
}
+#ifdef USE_POISONING
+ memset (structure, 0xff, sizeof(GstStructure));
+#endif
g_free(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);
}
/**
- * gst_structure_set:
+ * gst_structure_set_valist:
* @structure: a #GstStructure
* @field: the name of the field to set
* @varargs: variable arguments
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;
}
}
/**
- * 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
* @field: the #GstStructureField to set
* 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;
*
* 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;
*
* 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);
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, ...)
{
}
/**
- * 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;
}
/**
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;
}
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
{
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;
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);
* 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;
- for (;;r++) {
- if (*r == '\0') {
- if (c) {
- goto error;
- } else {
- goto found;
- }
- }
+ if (*s != '"') {
+ int ret;
- if (*r == '\\') {
- r++;
- if (*r == '\0')
- goto error;
- *w++ = *r;
- continue;
- }
+ ret = _gst_structure_parse_simple_string (s, end);
+ *next = *end;
- if (*r == c) {
- r++;
- if (*r == '\0')
- goto found;
- break;
- }
+ return ret;
+ }
- if (!c) {
- if (g_ascii_isspace (*r))
- break;
- /* this needs to be escaped */
- if (*r == ',' || *r == ')' || *r == ']' || *r == ':' ||
- *r == ';' || *r == '(' || *r == '[')
- break;
+ w = s;
+ s++;
+ while (*s != '"') {
+ if (*s == 0) return FALSE;
+
+ if (*s == '\\') {
+ s++;
}
- *w++ = *r;
+
+ *w = *s;
+ w++;
+ s++;
}
+ s++;
-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;
}
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)) {
- 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)) {
- g_value_set_boolean (value, FALSE);
- } else {
- ret = FALSE;
- }
+ 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);
+ 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);
+ 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));
- ret = TRUE;
- }
+ 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) {
- 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]);
+ if (strlen(s) == 4) {
+ fourcc = GST_MAKE_FOURCC(s[0], s[1], s[2], s[3]);
+ ret = TRUE;
+ } else if (g_ascii_isdigit (*s)) {
+ fourcc = strtoul (s, &end, 0);
+ if (*end == 0) {
ret = TRUE;
}
}
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),
}
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++;
}
}
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 = str;
+
+ 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 (*s != '=') return FALSE;
s++;
- while (g_ascii_isspace (*s)) s++;
- *del = '\0';
+ c = *name_end;
+ *name_end = 0;
field->name = g_quark_from_string (name);
+ *name_end = c;
- if (have_type) {
- while (g_ascii_isspace (*s)) s++;
+ 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;
- while (g_ascii_isalnum (*s) || *s == '_' || *s == '-') s++;
- del = s;
- while (g_ascii_isspace (*s)) s++;
- if (*s != '=') return FALSE;
+ 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++;
- *del = '\0';
-
-g_print("type name is \"%s\"\n",type_name);
+ 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;
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;
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);
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);
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);
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:
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:
}
}
}
-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:
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:
}
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:
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 *****/
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:
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:
}
}
}
-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:
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:
}
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:
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 *****/
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) {
*
* 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);
*/
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;
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;
* 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:
#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>
guint size);
void (* suggest) (gpointer data,
guint probability,
- GstCaps * caps);
+ const GstCaps * caps);
gpointer data;
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 */
guint rank,
GstTypeFindFunction func,
gchar ** extensions,
- GstCaps * possible_caps,
+ const GstCaps * possible_caps,
gpointer data);
/* typefinding interface */
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);
*/
#include "gstpad.h"
-#include "gstprops.h"
static void
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)
{
}
}
}
+#endif
/**
* gst_print_pad_caps:
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);
}
}
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
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;
}
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;
}
{
g_return_if_fail (GST_VALUE_HOLDS_FOURCC (value));
- value->data[0].v_long = fourcc;
+ value->data[0].v_int = fourcc;
}
guint32
{
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 */
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;
}
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;
}
{
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
{
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
{
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 */
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;
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;
-
- /* FIXME */
+ gdouble *double_range_start = collect_values[0].v_pointer;
+ gdouble *double_range_end = collect_values[1].v_pointer;
- 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;
}
/* 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 */
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);
}
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
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);
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)
{
if (value1->data[0].v_int > value2->data[0].v_int)
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;
}
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
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;
}
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);
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);
intersect_info->type2 == G_VALUE_TYPE(value2)) return TRUE;
}
- return FALSE;
+ return gst_value_can_compare (value1, value2);
}
gboolean
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;
}
}
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;
}
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;
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;
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);
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);
}
#define __GST_VALUE_H__
#include <gst/gstconfig.h>
-#if 0
#include <gst/gstcaps2.h>
-#endif
G_BEGIN_DECLS
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);
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
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);
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;
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;
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);
- }
- else if (!strcmp (tag, "type")) {
- registry->caps_mime = 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);
+ }
+ 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,
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;
}
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;
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;
}
static gboolean
-gst_xml_registry_save_props_func (GstPropsEntry *entry,
- GstXMLRegistry *xmlregistry)
-{
- 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)
+gst_xml_registry_save_caps (GstXMLRegistry *xmlregistry, const 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;
}
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;
}
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]);
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;
GstCaps *caps;
gchar *caps_name;
- gchar *caps_mime;
- GstProps *props;
+ gchar *structure_name;
+ //gchar *caps_mime;
+ //GstProps *props;
gboolean in_list;
GList *entry_list;
#define __GST_DPARAM_H__
#include <gst/gstobject.h>
-#include <gst/gstprops.h>
#include "dparamcommon.h"
G_BEGIN_DECLS
#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>
/* 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())
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
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())
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)
{
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())
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) {
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)
{
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);
}
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();
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;
typedef enum {
FAKESRC_DATA_ALLOCATE = 1,
FAKESRC_DATA_SUBBUFFER,
- FAKESRC_DATA_BUFFERPOOL
} GstFakeSrcDataType;
typedef enum {
gboolean signal_handoffs;
gboolean dump;
gboolean need_flush;
- GstBufferPool *pool;
gchar *last_message;
};
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));
}
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;
}
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);
/* 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 */
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)
{
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));
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);
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);
}
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
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())
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)
{
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;
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*
}
static GstPadLinkReturn
-gst_shaper_link (GstPad *pad, GstCaps *caps)
+gst_shaper_link (GstPad *pad, const GstCaps *caps)
{
GstPad *otherpad;
GstShaperConnection *connection;
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);
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);
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);
/* 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);
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)
}
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));
}
static GstPadLinkReturn
-gst_tee_srclink (GstPad *pad, GstCaps *caps)
+gst_tee_srclink (GstPad *pad, const GstCaps *caps)
{
GstTee *tee;
}
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;
while (pads) {
GstPad *srcpad = GST_PAD (pads->data);
GstPad *peer;
- GstCaps *peercaps;
+ const GstCaps *peercaps;
GstCaps *newcaps;
pads = g_list_next (pads);
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;
}
);
/* 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 */
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));
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);
}
/* 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);
free_entry_buffers (entry);
if (entry->caps)
- gst_caps_unref (entry->caps);
+ gst_caps_free (entry->caps);
g_free (entry);
}
static void
}
}
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;
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
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) {
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);
}
);
/* 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 */
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));
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);
}
/* 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);
free_entry_buffers (entry);
if (entry->caps)
- gst_caps_unref (entry->caps);
+ gst_caps_free (entry->caps);
g_free (entry);
}
static void
}
}
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;
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
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) {
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);
}
+++ /dev/null
-# 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 ""
#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");
* can have. They can be quite complex, but for this example plugin
* they are rather simple.
*/
-GST_PAD_TEMPLATE_FACTORY (sink_factory,
- "sink", /* The name of the pad */
+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"
)
);
/* 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
* 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).
* 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. */
#include <gst/gst.h>
void
-type_found (GstElement *typefind, GstCaps* caps)
+type_found (GstElement *typefind, const GstCaps * caps)
{
xmlDocPtr doc;
xmlNodePtr parent;
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);
}
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
}
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;
#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"
);
+GstStaticCaps rawcaps = GST_STATIC_CAPS(
+ "video/raw, "
+ "fourcc=(fourcc){YV12,YUY2}, "
+ "width=(int)[16,4096], "
+ "height=(int)[16,4096]"
+);
+GstStaticCaps rawcaps2 = GST_STATIC_CAPS(
+ "video/raw, "
+ "fourcc=(fourcc)YUY2, "
+ "height=(int)[16,256]"
+);
-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 rawcaps3 = GST_STATIC_CAPS(
+ "video/raw, "
+ "fourcc=(fourcc){YV12,YUY2}, "
+ "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)
- )
+#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 (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 rawcaps4 = GST_STATIC_CAPS(
+ "video/raw, "
+ "fourcc=(fourcc){\"YUYV\", \"YUY2\"}, "
+ "height=(int)[16,4096]"
);
+#endif
-/* 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)
- )
+GstStaticCaps rawcaps6 = GST_STATIC_CAPS(
+ "video/raw, "
+ "format=(fourcc)\"I420\"; "
+ "video/raw, "
+ "format=(fourcc)\"YUYV\""
);
-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 rawcaps7 = GST_STATIC_CAPS(
+ "video/raw, "
+ "format=(fourcc)\"I420\"; "
+ "video/raw, "
+ "format=(fourcc)\"YV12\""
);
-*/
-
-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'))
- )
-)
-
-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'))
- )
-)
int
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;
gint
main (gint argc, gchar *argv[])
{
+#if 0
GstCaps *caps;
- GstProps *props;
- GstPropsEntry *entry;
gst_init (&argc, &argv);
/* caps too */
g_assert (GST_CAPS_IS_FIXED (caps));
+#endif
return 0;
}
#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;
}
#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
/*
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);
#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
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);
#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}"
+);
+
+GstStaticCaps caps3 = GST_STATIC_CAPS (
+ "video/raw, "
+ "fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
+ "width=(int)[16,4096], "
+ "height=(int)[16,4096]"
+);
+
+GstStaticCaps caps4 = GST_STATIC_CAPS (
+ "video/raw, "
+ "fourcc=(fourcc)\"YV12\", "
+ "height=(int)[16,256]"
);
-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 caps5 = GST_STATIC_CAPS (
+ "video/raw, "
+ "fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
+ "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 caps6 = GST_STATIC_CAPS (
+ "video/raw, "
+ "fourcc=(fourcc){\"YV12\",\"YUYV\"}, "
+ "height=(int)[16,4096]"
);
-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 caps7 = GST_STATIC_CAPS (
+ "video/raw, "
+ "fourcc=(fourcc){\"YVYV\",\"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 caps8 = GST_STATIC_CAPS (
+ "video/raw, "
+ "format=(fourcc)\"I420\"; "
+ "video/raw, "
+ "format=(fourcc)\"YUYV\""
);
-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 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;
} \
}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);
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);
TEST_END (ret);
}
static void
-test_caps (GstCaps *caps)
+test_caps (const GstCaps *caps)
{
TEST_START;
test_caps_func (caps);
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
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 */
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= '");
#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
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);
main (gint argc, gchar *argv[])
{
GstElement *pipeline;
- gint i = 10000;
+ gint i = 1000;
gint step = 100;
free (malloc(8)); /* -lefence */
main (gint argc, gchar *argv[])
{
GstElement *pipeline;
- gint i = 10000;
+ gint i = 1000;
gint step = 100;
free (malloc(8)); /* -lefence */
gst_init (&argc, &argv);
- i = 10000;
+ i = 1000;
pipeline = gst_pipeline_new ("main_pipeline");
int main(int argc,char *argv[])
{
GstElement *bin, *element;
- gint i = 100000;
+ gint i = 1000;
gint step = 100;
*/
#include <gst/gst.h>
-#include <gst/gstprops.h>
#include <property.h>
GstElement *
GstPad *tee_src1, *tee_src2;
GstCaps *src_caps = NULL;
GstCaps *sink_caps = NULL;
- GstProps *props = NULL;
+ GstStructure *structure = NULL;
GstPad *pad = NULL;
/* init */
/* 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);
}
+
include ../Rules
plugin_LTLIBRARIES = libtestplugin.la libtestplugin2.la
linked_LIBS = libtestplugin.la libtestplugin2.la
-static_SOURCES = static.c testplugin_s.c testplugin2_s.c
+static_SOURCES = static.c
-#define GST_PLUGIN_STATIC
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
return TRUE;
}
-GST_PLUGIN_DEFINE (
+GST_PLUGIN_DEFINE_STATIC (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"testplugin",
return TRUE;
}
-GST_PLUGIN_DEFINE (
+GST_PLUGIN_DEFINE_STATIC (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"testplugin2",
GST_PACKAGE,
GST_ORIGIN
);
+
-#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
+);
+
-#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
+);
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
}
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;
#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"
);
+GstStaticCaps rawcaps = GST_STATIC_CAPS(
+ "video/raw, "
+ "fourcc=(fourcc){YV12,YUY2}, "
+ "width=(int)[16,4096], "
+ "height=(int)[16,4096]"
+);
+GstStaticCaps rawcaps2 = GST_STATIC_CAPS(
+ "video/raw, "
+ "fourcc=(fourcc)YUY2, "
+ "height=(int)[16,256]"
+);
-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 rawcaps3 = GST_STATIC_CAPS(
+ "video/raw, "
+ "fourcc=(fourcc){YV12,YUY2}, "
+ "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)
- )
+#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 (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 rawcaps4 = GST_STATIC_CAPS(
+ "video/raw, "
+ "fourcc=(fourcc){\"YUYV\", \"YUY2\"}, "
+ "height=(int)[16,4096]"
);
+#endif
-/* 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)
- )
+GstStaticCaps rawcaps6 = GST_STATIC_CAPS(
+ "video/raw, "
+ "format=(fourcc)\"I420\"; "
+ "video/raw, "
+ "format=(fourcc)\"YUYV\""
);
-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 rawcaps7 = GST_STATIC_CAPS(
+ "video/raw, "
+ "format=(fourcc)\"I420\"; "
+ "video/raw, "
+ "format=(fourcc)\"YV12\""
);
-*/
-
-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'))
- )
-)
-
-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'))
- )
-)
int
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;
gint
main (gint argc, gchar *argv[])
{
+#if 0
GstCaps *caps;
- GstProps *props;
- GstPropsEntry *entry;
gst_init (&argc, &argv);
/* caps too */
g_assert (GST_CAPS_IS_FIXED (caps));
+#endif
return 0;
}
#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;
}
#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
/*
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);
#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
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);
#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}"
+);
+
+GstStaticCaps caps3 = GST_STATIC_CAPS (
+ "video/raw, "
+ "fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
+ "width=(int)[16,4096], "
+ "height=(int)[16,4096]"
+);
+
+GstStaticCaps caps4 = GST_STATIC_CAPS (
+ "video/raw, "
+ "fourcc=(fourcc)\"YV12\", "
+ "height=(int)[16,256]"
);
-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 caps5 = GST_STATIC_CAPS (
+ "video/raw, "
+ "fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
+ "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 caps6 = GST_STATIC_CAPS (
+ "video/raw, "
+ "fourcc=(fourcc){\"YV12\",\"YUYV\"}, "
+ "height=(int)[16,4096]"
);
-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 caps7 = GST_STATIC_CAPS (
+ "video/raw, "
+ "fourcc=(fourcc){\"YVYV\",\"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 caps8 = GST_STATIC_CAPS (
+ "video/raw, "
+ "format=(fourcc)\"I420\"; "
+ "video/raw, "
+ "format=(fourcc)\"YUYV\""
);
-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 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;
} \
}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);
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);
TEST_END (ret);
}
static void
-test_caps (GstCaps *caps)
+test_caps (const GstCaps *caps)
{
TEST_START;
test_caps_func (caps);
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
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 */
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= '");
#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
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);
main (gint argc, gchar *argv[])
{
GstElement *pipeline;
- gint i = 10000;
+ gint i = 1000;
gint step = 100;
free (malloc(8)); /* -lefence */
main (gint argc, gchar *argv[])
{
GstElement *pipeline;
- gint i = 10000;
+ gint i = 1000;
gint step = 100;
free (malloc(8)); /* -lefence */
gst_init (&argc, &argv);
- i = 10000;
+ i = 1000;
pipeline = gst_pipeline_new ("main_pipeline");
int main(int argc,char *argv[])
{
GstElement *bin, *element;
- gint i = 100000;
+ gint i = 1000;
gint step = 100;
*/
#include <gst/gst.h>
-#include <gst/gstprops.h>
#include <property.h>
GstElement *
GstPad *tee_src1, *tee_src2;
GstCaps *src_caps = NULL;
GstCaps *sink_caps = NULL;
- GstProps *props = NULL;
+ GstStructure *structure = NULL;
GstPad *pad = NULL;
/* init */
/* 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);
}
+
include ../Rules
plugin_LTLIBRARIES = libtestplugin.la libtestplugin2.la
linked_LIBS = libtestplugin.la libtestplugin2.la
-static_SOURCES = static.c testplugin_s.c testplugin2_s.c
+static_SOURCES = static.c
-#define GST_PLUGIN_STATIC
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
return TRUE;
}
-GST_PLUGIN_DEFINE (
+GST_PLUGIN_DEFINE_STATIC (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"testplugin",
return TRUE;
}
-GST_PLUGIN_DEFINE (
+GST_PLUGIN_DEFINE_STATIC (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"testplugin2",
GST_PACKAGE,
GST_ORIGIN
);
+
-#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
+);
+
-#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
+);
#include <string.h>
static void
-print_prop (GstPropsEntry *prop, gboolean showname, const gchar *pfx)
+print_caps (const GstCaps *caps, const gchar *pfx)
{
- GstPropsType type;
+ char *s;
- if (showname)
- g_print("%s%-20.20s: ", pfx, gst_props_entry_get_name (prop));
- else
- g_print(pfx);
-
- type = gst_props_entry_get_props_type (prop);
-
- switch (type) {
- case GST_PROPS_INT_TYPE:
- {
- gint val;
- gst_props_entry_get_int (prop, &val);
- g_print("Integer: %d\n", val);
- break;
- }
- case GST_PROPS_INT_RANGE_TYPE:
- {
- gint min, max;
- gst_props_entry_get_int_range (prop, &min, &max);
- g_print("Integer range: %d - %d\n", min, max);
- break;
- }
- case GST_PROPS_FLOAT_TYPE:
- {
- gfloat val;
- gst_props_entry_get_float (prop, &val);
- g_print("Float: %g\n", val);
- break;
- }
- case GST_PROPS_FLOAT_RANGE_TYPE:
- {
- gfloat min, max;
- gst_props_entry_get_float_range (prop, &min, &max);
- g_print("Float range: %g - %g\n", min, max);
- break;
- }
- case GST_PROPS_BOOLEAN_TYPE:
- {
- gboolean val;
- gst_props_entry_get_boolean (prop, &val);
- g_print("Boolean: %s\n", val ? "TRUE" : "FALSE");
- break;
- }
- case GST_PROPS_STRING_TYPE:
- {
- const gchar *val;
- gst_props_entry_get_string (prop, &val);
- g_print("String: \"%s\"\n", val);
- break;
- }
- case GST_PROPS_FOURCC_TYPE:
- {
- guint32 val;
- gst_props_entry_get_fourcc_int (prop, &val);
- g_print("FourCC: '%c%c%c%c'\n",
- (gchar)( val & 0xff),
- (gchar)((val >> 8) & 0xff),
- (gchar)((val >> 16) & 0xff),
- (gchar)((val >> 24) & 0xff));
- break;
- }
- case GST_PROPS_LIST_TYPE:
- {
- const GList *list;
- gchar *longprefix;
-
- gst_props_entry_get_list (prop, &list);
- g_print ("List:\n");
- longprefix = g_strdup_printf ("%s ", pfx);
- while (list) {
- GstPropsEntry *listentry;
-
- listentry = (GstPropsEntry*) (list->data);
- print_prop (listentry, FALSE, longprefix);
-
- list = g_list_next (list);
- }
- g_free (longprefix);
- break;
- }
- default:
- g_print("unknown props %d\n", type);
- }
-}
-
-static void
-print_props (GstProps *properties, const gchar *pfx)
-{
- GList *props;
- GstPropsEntry *prop;
-
- props = properties->properties;
- while (props) {
- prop = (GstPropsEntry*)(props->data);
- props = g_list_next(props);
-
- print_prop(prop,TRUE,pfx);
- }
-}
-
-static void
-print_caps (GstCaps *caps, const gchar *pfx)
-{
- while (caps) {
- g_print ("%s'%s': (%sfixed)\n", pfx, caps->name, (GST_CAPS_IS_FIXED (caps) ? "" : "NOT "));
- g_print ("%s MIME type: '%s':\n", pfx, gst_caps_get_mime (caps));
-
- if (caps->properties) {
- gchar *prefix = g_strdup_printf ("%s ", pfx);
-
- print_props(caps->properties, prefix);
-
- g_free (prefix);
- }
-
- caps = caps->next;
- }
+ s = gst_caps_to_string (caps);
+ g_print ("%s%s\n", pfx, s);
+ g_free(s);
}
static void
g_print("%-23.23s URI", "");
}
if (param->value_type == GST_TYPE_CAPS) {
- GstCaps *caps = g_value_peek_pointer (&value);
+ const GstCaps *caps = gst_value_get_caps (&value);
if (!caps)
g_print("%-23.23s Caps (NULL)", "");
g_print (" Has custom intconnfunc(): %s\n",
GST_DEBUG_FUNCPTR_NAME(realpad->intlinkfunc));
- if (realpad->bufferpoolfunc)
- g_print (" Has bufferpoolfunc(): %s\n",
- GST_DEBUG_FUNCPTR_NAME(realpad->bufferpoolfunc));
+ if (realpad->bufferallocfunc)
+ g_print (" Has bufferallocfunc(): %s\n",
+ GST_DEBUG_FUNCPTR_NAME(realpad->bufferallocfunc));
if (pad->padtemplate)
g_print (" Pad Template: '%s'\n",
gchar *filename = NULL;
void
-gst_caps_print (const char *filename, GstCaps *caps)
+gst_caps_print (const char *filename, const GstCaps *caps)
{
gchar *caps_str = gst_caps_to_string (caps);
g_print ("%s - %s\n", filename, caps_str);
}
void
-have_type_handler (GstElement *typefind, guint probability, GstCaps *caps, gpointer unused)
+have_type_handler (GstElement *typefind, guint probability, const GstCaps *caps, gpointer unused)
{
gst_caps_print (filename, caps);
FOUND = TRUE;
#endif
static void
-print_prop (GstPropsEntry *prop, gint pfx)
+print_caps (const GstCaps *caps, gint pfx)
{
- GstPropsType type;
-
- type = gst_props_entry_get_props_type (prop);
-
- switch (type) {
- case GST_PROPS_INT_TYPE:
- {
- gint val;
- gst_props_entry_get_int (prop, &val);
- PUT_STRING (pfx, "<int name=\"%s\" value=\"%d\"/>",
- gst_props_entry_get_name (prop), val);
- break;
- }
- case GST_PROPS_INT_RANGE_TYPE:
- {
- gint min, max;
- gst_props_entry_get_int_range (prop, &min, &max);
- PUT_STRING (pfx, "<range name=\"%s\" min=\"%d\" max=\"%d\"/>",
- gst_props_entry_get_name (prop), min, max);
- break;
- }
- case GST_PROPS_FLOAT_TYPE:
- {
- gfloat val;
- gst_props_entry_get_float (prop, &val);
- PUT_STRING (pfx, "<float name=\"%s\" value=\"%f\"/>",
- gst_props_entry_get_name (prop), val);
- break;
- }
- case GST_PROPS_FLOAT_RANGE_TYPE:
- {
- gfloat min, max;
- gst_props_entry_get_float_range (prop, &min, &max);
- PUT_STRING (pfx, "<floatrange name=\"%s\" min=\"%f\" max=\"%f\"/>",
- gst_props_entry_get_name (prop), min, max);
- break;
- }
- case GST_PROPS_BOOLEAN_TYPE:
- {
- gboolean val;
- gst_props_entry_get_boolean (prop, &val);
- PUT_STRING (pfx, "<boolean name=\"%s\" value=\"%s\"/>",
- gst_props_entry_get_name (prop), val ? "true" : "false");
- break;
- }
- case GST_PROPS_STRING_TYPE:
- {
- const gchar *val;
- gst_props_entry_get_string (prop, &val);
- PUT_STRING (pfx, "<string name=\"%s\" value=\"%s\"/>",
- gst_props_entry_get_name (prop), val);
- break;
- }
- case GST_PROPS_FOURCC_TYPE:
- {
- guint32 val;
- gst_props_entry_get_fourcc_int (prop, &val);
- PUT_STRING (pfx, "<!--%c%c%c%c-->",
- (gchar)( val & 0xff),
- (gchar)((val >> 8) & 0xff),
- (gchar)((val >> 16) & 0xff),
- (gchar)((val >> 24) & 0xff));
- PUT_STRING (pfx, "<fourcc name=\"%s\" hexvalue=\"%08x\"/>",
- gst_props_entry_get_name (prop), val);
- break;
- }
- case GST_PROPS_LIST_TYPE:
- {
- const GList *list;
-
- gst_props_entry_get_list (prop, &list);
- PUT_STRING (pfx, "<list name=\"%s\">", gst_props_entry_get_name (prop));
- while (list) {
- GstPropsEntry *listentry;
-
- listentry = (GstPropsEntry*) (list->data);
- print_prop (listentry, pfx + 1);
-
- list = g_list_next (list);
- }
- PUT_END_TAG (pfx, "list");
- break;
- }
- default:
- break;
- }
-}
-
-static void
-print_props (GstProps *properties, gint pfx)
-{
- GList *props;
- GstPropsEntry *prop;
+ char *s;
- props = properties->properties;
-
- if (!props)
- return;
-
- PUT_START_TAG (pfx, "properties");
-
- while (props) {
- prop = (GstPropsEntry*) (props->data);
- props = g_list_next (props);
-
- print_prop (prop, pfx + 1);
- }
- PUT_END_TAG (pfx, "properties");
-}
-
-static void
-print_caps (GstCaps *caps, gint pfx)
-{
if (!caps)
return;
- PUT_START_TAG (pfx, "capscomp");
-
- while (caps) {
- PUT_START_TAG (pfx + 1, "caps");
- PUT_ESCAPED (pfx + 2, "name", caps->name);
-
- PUT_ESCAPED (pfx + 2, "type", gst_caps_get_mime (caps));
-
- if (caps->properties) {
- print_props(caps->properties, pfx + 2);
- }
- PUT_END_TAG (pfx + 1, "caps");
-
- caps = caps->next;
- }
- PUT_END_TAG (pfx, "capscomp");
+ s = gst_caps_to_string (caps);
+ PUT_ESCAPED (pfx, "caps", s);
+ g_free(s);
}
static void
PUT_STRING (4, "<intlink-function function=\"%s\"/>",
GST_DEBUG_FUNCPTR_NAME(realpad->intlinkfunc));
- if (realpad->bufferpoolfunc)
- PUT_STRING (4, "<bufferpool-function function=\"%s\"/>",
- GST_DEBUG_FUNCPTR_NAME(realpad->bufferpoolfunc));
+ if (realpad->bufferallocfunc)
+ PUT_STRING (4, "<bufferalloc-function function=\"%s\"/>",
+ GST_DEBUG_FUNCPTR_NAME(realpad->bufferallocfunc));
PUT_END_TAG (3, "implementation");
if (realpad->caps) {