mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 13:06:23 +00:00
Added multiple caps to the pads
Original commit message from CVS: Added multiple caps to the pads Extended the padfactory for the multiple caps GstCaps now have a name so that future manipulations on them can be done by name Updated the plugins for the new caps list
This commit is contained in:
parent
7daccedd65
commit
bc4619a44b
26 changed files with 338 additions and 116 deletions
|
@ -4,7 +4,7 @@
|
||||||
static gboolean playing;
|
static gboolean playing;
|
||||||
|
|
||||||
/* eos will be called when the src element has an end of stream */
|
/* eos will be called when the src element has an end of stream */
|
||||||
void eos(GstSrc *src)
|
void eos(GstElement *src)
|
||||||
{
|
{
|
||||||
g_print("have eos, quitting\n");
|
g_print("have eos, quitting\n");
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,8 @@ static GstPadFactory audiosink_sink_factory = {
|
||||||
"sink",
|
"sink",
|
||||||
GST_PAD_FACTORY_SINK,
|
GST_PAD_FACTORY_SINK,
|
||||||
GST_PAD_FACTORY_ALWAYS,
|
GST_PAD_FACTORY_ALWAYS,
|
||||||
|
GST_PAD_FACTORY_CAPS (
|
||||||
|
"audiosink_sink",
|
||||||
"audio/raw",
|
"audio/raw",
|
||||||
"format", GST_PROPS_INT (AFMT_S16_LE),
|
"format", GST_PROPS_INT (AFMT_S16_LE),
|
||||||
"depth", GST_PROPS_LIST (
|
"depth", GST_PROPS_LIST (
|
||||||
|
@ -81,7 +83,8 @@ static GstPadFactory audiosink_sink_factory = {
|
||||||
GST_PROPS_INT (16)
|
GST_PROPS_INT (16)
|
||||||
),
|
),
|
||||||
"rate", GST_PROPS_INT_RANGE (8000, 48000),
|
"rate", GST_PROPS_INT_RANGE (8000, 48000),
|
||||||
"channels", GST_PROPS_INT_RANGE (1, 2),
|
"channels", GST_PROPS_INT_RANGE (1, 2)
|
||||||
|
),
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <gst/gstpipeline.h>
|
#include <gst/gstpipeline.h>
|
||||||
#include <gst/gstthread.h>
|
#include <gst/gstthread.h>
|
||||||
#include <gst/gsttype.h>
|
#include <gst/gsttype.h>
|
||||||
|
#include <gst/gstautoplug.h>
|
||||||
#include <gst/gstcaps.h>
|
#include <gst/gstcaps.h>
|
||||||
#include <gst/gstprops.h>
|
#include <gst/gstprops.h>
|
||||||
#include <gst/gstplugin.h>
|
#include <gst/gstplugin.h>
|
||||||
|
|
|
@ -88,7 +88,7 @@ gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest)
|
||||||
|
|
||||||
if (srctemp->direction == GST_PAD_SRC &&
|
if (srctemp->direction == GST_PAD_SRC &&
|
||||||
desttemp->direction == GST_PAD_SINK) {
|
desttemp->direction == GST_PAD_SINK) {
|
||||||
if (gst_caps_check_compatibility (srctemp->caps, desttemp->caps)) {
|
if (gst_caps_list_check_compatibility (srctemp->caps, desttemp->caps)) {
|
||||||
INFO(0,"factory \"%s\" can connect with factory \"%s\"", src->name, dest->name);
|
INFO(0,"factory \"%s\" can connect with factory \"%s\"", src->name, dest->name);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -109,8 +109,8 @@ gst_autoplug_elementfactory_get_list (gpointer data)
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GstCaps *src;
|
GList *src;
|
||||||
GstCaps *sink;
|
GList *sink;
|
||||||
} caps_struct;
|
} caps_struct;
|
||||||
|
|
||||||
#define IS_CAPS(cap) (((cap) == caps->src) || (cap) == caps->sink)
|
#define IS_CAPS(cap) (((cap) == caps->src) || (cap) == caps->sink)
|
||||||
|
@ -122,16 +122,16 @@ gst_autoplug_caps_find_cost (gpointer src, gpointer dest, gpointer data)
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
if (IS_CAPS (src) && IS_CAPS (dest)) {
|
if (IS_CAPS (src) && IS_CAPS (dest)) {
|
||||||
res = gst_caps_check_compatibility ((GstCaps *)src, (GstCaps *)dest);
|
res = gst_caps_list_check_compatibility ((GList *)src, (GList *)dest);
|
||||||
INFO (0,"caps %d to caps %d %d", ((GstCaps *)src)->id, ((GstCaps *)dest)->id, res);
|
//INFO (0,"caps %d to caps %d %d", ((GstCaps *)src)->id, ((GstCaps *)dest)->id, res);
|
||||||
}
|
}
|
||||||
else if (IS_CAPS (src)) {
|
else if (IS_CAPS (src)) {
|
||||||
res = gst_elementfactory_can_sink_caps ((GstElementFactory *)dest, src);
|
res = gst_elementfactory_can_sink_caps_list ((GstElementFactory *)dest, (GList *)src);
|
||||||
INFO (0,"factory %s to src caps %d %d", ((GstElementFactory *)dest)->name, ((GstCaps *)src)->id, res);
|
//INFO (0,"factory %s to src caps %d %d", ((GstElementFactory *)dest)->name, ((GstCaps *)src)->id, res);
|
||||||
}
|
}
|
||||||
else if (IS_CAPS (dest)) {
|
else if (IS_CAPS (dest)) {
|
||||||
res = gst_elementfactory_can_src_caps ((GstElementFactory *)src, dest);
|
res = gst_elementfactory_can_src_caps_list ((GstElementFactory *)src, (GList *)dest);
|
||||||
INFO (0,"factory %s to sink caps %d %d", ((GstElementFactory *)src)->name, ((GstCaps *)dest)->id, res);
|
//INFO (0,"factory %s to sink caps %d %d", ((GstElementFactory *)src)->name, ((GstCaps *)dest)->id, res);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res = gst_autoplug_can_match ((GstElementFactory *)src, (GstElementFactory *)dest);
|
res = gst_autoplug_can_match ((GstElementFactory *)src, (GstElementFactory *)dest);
|
||||||
|
@ -148,17 +148,48 @@ gst_autoplug_caps (GstCaps *srccaps, GstCaps *sinkcaps)
|
||||||
{
|
{
|
||||||
caps_struct caps;
|
caps_struct caps;
|
||||||
|
|
||||||
caps.src = srccaps;
|
caps.src = g_list_prepend (NULL,srccaps);
|
||||||
caps.sink = sinkcaps;
|
caps.sink = g_list_prepend (NULL,sinkcaps);
|
||||||
|
|
||||||
INFO (0,"autoplugging two caps structures");
|
INFO (0,"autoplugging two caps structures");
|
||||||
|
|
||||||
return gst_autoplug_func (srccaps, sinkcaps,
|
return gst_autoplug_func (caps.src, caps.sink,
|
||||||
gst_autoplug_elementfactory_get_list,
|
gst_autoplug_elementfactory_get_list,
|
||||||
gst_autoplug_caps_find_cost,
|
gst_autoplug_caps_find_cost,
|
||||||
&caps);
|
&caps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GList*
|
||||||
|
gst_autoplug_caps_list (GList *srccaps, GList *sinkcaps)
|
||||||
|
{
|
||||||
|
caps_struct caps;
|
||||||
|
|
||||||
|
caps.src = srccaps;
|
||||||
|
caps.sink = sinkcaps;
|
||||||
|
|
||||||
|
INFO (0,"autoplugging two caps list structures");
|
||||||
|
|
||||||
|
return gst_autoplug_func (caps.src, caps.sink,
|
||||||
|
gst_autoplug_elementfactory_get_list,
|
||||||
|
gst_autoplug_caps_find_cost,
|
||||||
|
&caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
GList*
|
||||||
|
gst_autoplug_pads (GstPad *srcpad, GstPad *sinkpad)
|
||||||
|
{
|
||||||
|
caps_struct caps;
|
||||||
|
|
||||||
|
caps.src = srcpad->caps;
|
||||||
|
caps.sink = sinkpad->caps;
|
||||||
|
|
||||||
|
INFO (0,"autoplugging two caps structures");
|
||||||
|
|
||||||
|
return gst_autoplug_func (caps.src, caps.sink,
|
||||||
|
gst_autoplug_elementfactory_get_list,
|
||||||
|
gst_autoplug_caps_find_cost,
|
||||||
|
&caps);
|
||||||
|
}
|
||||||
static gint
|
static gint
|
||||||
find_factory (gst_autoplug_node *rgnNodes, gpointer factory)
|
find_factory (gst_autoplug_node *rgnNodes, gpointer factory)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,6 +60,8 @@ struct _GstAutoplugClass {
|
||||||
GtkType gst_autoplug_get_type (void);
|
GtkType gst_autoplug_get_type (void);
|
||||||
|
|
||||||
GList* gst_autoplug_caps (GstCaps *srccaps, GstCaps *sinkcaps);
|
GList* gst_autoplug_caps (GstCaps *srccaps, GstCaps *sinkcaps);
|
||||||
|
GList* gst_autoplug_caps_list (GList *srccaps, GList *sinkcaps);
|
||||||
|
GList* gst_autoplug_pads (GstPad *srcpad, GstPad *sinkpad);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define GST_DEBUG_ENABLED
|
//#define GST_DEBUG_ENABLED
|
||||||
#include "gst_private.h"
|
#include "gst_private.h"
|
||||||
|
|
||||||
#include "gstcaps.h"
|
#include "gstcaps.h"
|
||||||
|
@ -54,6 +54,7 @@ get_type_for_mime (gchar *mime)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_caps_new:
|
* gst_caps_new:
|
||||||
|
* @name: the name of this capability
|
||||||
* @mime: the mime type to attach to the capability
|
* @mime: the mime type to attach to the capability
|
||||||
*
|
*
|
||||||
* create a new capability with the given mime type
|
* create a new capability with the given mime type
|
||||||
|
@ -61,13 +62,14 @@ get_type_for_mime (gchar *mime)
|
||||||
* Returns: a new capability
|
* Returns: a new capability
|
||||||
*/
|
*/
|
||||||
GstCaps*
|
GstCaps*
|
||||||
gst_caps_new (gchar *mime)
|
gst_caps_new (gchar *name, gchar *mime)
|
||||||
{
|
{
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
g_return_val_if_fail (mime != NULL, NULL);
|
g_return_val_if_fail (mime != NULL, NULL);
|
||||||
|
|
||||||
caps = g_new0 (GstCaps, 1);
|
caps = g_new0 (GstCaps, 1);
|
||||||
|
caps->name = g_strdup (name);
|
||||||
caps->id = get_type_for_mime (mime);
|
caps->id = get_type_for_mime (mime);
|
||||||
caps->properties = NULL;
|
caps->properties = NULL;
|
||||||
|
|
||||||
|
@ -76,6 +78,7 @@ gst_caps_new (gchar *mime)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_caps_new_with_props:
|
* gst_caps_new_with_props:
|
||||||
|
* @name: the name of this capability
|
||||||
* @mime: the mime type to attach to the capability
|
* @mime: the mime type to attach to the capability
|
||||||
* @props: the properties for this capability
|
* @props: the properties for this capability
|
||||||
*
|
*
|
||||||
|
@ -85,11 +88,11 @@ gst_caps_new (gchar *mime)
|
||||||
* Returns: a new capability
|
* Returns: a new capability
|
||||||
*/
|
*/
|
||||||
GstCaps*
|
GstCaps*
|
||||||
gst_caps_new_with_props (gchar *mime, GstProps *props)
|
gst_caps_new_with_props (gchar *name, gchar *mime, GstProps *props)
|
||||||
{
|
{
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
caps = gst_caps_new (mime);
|
caps = gst_caps_new (name, mime);
|
||||||
caps->properties = props;
|
caps->properties = props;
|
||||||
|
|
||||||
return caps;
|
return caps;
|
||||||
|
@ -105,16 +108,38 @@ gst_caps_new_with_props (gchar *mime, GstProps *props)
|
||||||
*/
|
*/
|
||||||
GstCaps*
|
GstCaps*
|
||||||
gst_caps_register (GstCapsFactory *factory)
|
gst_caps_register (GstCapsFactory *factory)
|
||||||
|
{
|
||||||
|
guint dummy;
|
||||||
|
|
||||||
|
return gst_caps_register_count (factory, &dummy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_caps_register_count:
|
||||||
|
* @factory: the factory to register
|
||||||
|
* @counter: count how many entries were consumed
|
||||||
|
*
|
||||||
|
* Register the factory.
|
||||||
|
*
|
||||||
|
* Returns: The registered capability
|
||||||
|
*/
|
||||||
|
GstCaps*
|
||||||
|
gst_caps_register_count (GstCapsFactory *factory, guint *counter)
|
||||||
{
|
{
|
||||||
GstCapsFactoryEntry tag;
|
GstCapsFactoryEntry tag;
|
||||||
gint i = 0;
|
gint i = 0;
|
||||||
guint16 typeid;
|
guint16 typeid;
|
||||||
|
gchar *name;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
g_return_val_if_fail (factory != NULL, NULL);
|
g_return_val_if_fail (factory != NULL, NULL);
|
||||||
|
|
||||||
tag = (*factory)[i++];
|
tag = (*factory)[i++];
|
||||||
|
g_return_val_if_fail (tag != NULL, NULL);
|
||||||
|
|
||||||
|
name = tag;
|
||||||
|
|
||||||
|
tag = (*factory)[i++];
|
||||||
g_return_val_if_fail (tag != NULL, NULL);
|
g_return_val_if_fail (tag != NULL, NULL);
|
||||||
|
|
||||||
typeid = get_type_for_mime ((gchar *)tag);
|
typeid = get_type_for_mime ((gchar *)tag);
|
||||||
|
@ -122,8 +147,11 @@ gst_caps_register (GstCapsFactory *factory)
|
||||||
caps = g_new0 (GstCaps, 1);
|
caps = g_new0 (GstCaps, 1);
|
||||||
g_return_val_if_fail (caps != NULL, NULL);
|
g_return_val_if_fail (caps != NULL, NULL);
|
||||||
|
|
||||||
|
caps->name = g_strdup (name);
|
||||||
caps->id = typeid;
|
caps->id = typeid;
|
||||||
caps->properties = gst_props_register (&(*factory)[i]);
|
caps->properties = gst_props_register_count (&(*factory)[i], counter);
|
||||||
|
|
||||||
|
*counter += 2;
|
||||||
|
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +188,7 @@ gst_caps_set_props (GstCaps *caps, GstProps *props)
|
||||||
GstProps*
|
GstProps*
|
||||||
gst_caps_get_props (GstCaps *caps)
|
gst_caps_get_props (GstCaps *caps)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (caps != NULL, caps);
|
g_return_val_if_fail (caps != NULL, NULL);
|
||||||
|
|
||||||
return caps->properties;
|
return caps->properties;
|
||||||
}
|
}
|
||||||
|
@ -201,6 +229,34 @@ gst_caps_check_compatibility (GstCaps *fromcaps, GstCaps *tocaps)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_caps_list_check_compatibility:
|
||||||
|
* @fromcaps: a capabilty
|
||||||
|
* @tocaps: a capabilty
|
||||||
|
*
|
||||||
|
* Checks whether two capability lists are compatible
|
||||||
|
*
|
||||||
|
* Returns: true if compatible, false otherwise
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_caps_list_check_compatibility (GList *fromcaps, GList *tocaps)
|
||||||
|
{
|
||||||
|
while (fromcaps) {
|
||||||
|
GstCaps *fromcap = (GstCaps *)fromcaps->data;
|
||||||
|
GList *destcaps = tocaps;
|
||||||
|
|
||||||
|
while (destcaps) {
|
||||||
|
GstCaps *destcap = (GstCaps *)destcaps->data;
|
||||||
|
|
||||||
|
if (gst_caps_check_compatibility (fromcap, destcap))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
destcaps = g_list_next (destcaps);
|
||||||
|
}
|
||||||
|
fromcaps = g_list_next (fromcaps);
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_caps_save_thyself:
|
* gst_caps_save_thyself:
|
||||||
|
@ -218,6 +274,7 @@ gst_caps_save_thyself (GstCaps *caps, xmlNodePtr parent)
|
||||||
|
|
||||||
g_return_val_if_fail (caps != NULL, NULL);
|
g_return_val_if_fail (caps != NULL, NULL);
|
||||||
|
|
||||||
|
xmlNewChild (parent, NULL, "name", caps->name);
|
||||||
xmlNewChild (parent, NULL, "type", gst_type_find_by_id (caps->id)->mime);
|
xmlNewChild (parent, NULL, "type", gst_type_find_by_id (caps->id)->mime);
|
||||||
if (caps->properties) {
|
if (caps->properties) {
|
||||||
subtree = xmlNewChild (parent, NULL, "properties", NULL);
|
subtree = xmlNewChild (parent, NULL, "properties", NULL);
|
||||||
|
@ -243,6 +300,9 @@ gst_caps_load_thyself (xmlNodePtr parent)
|
||||||
xmlNodePtr field = parent->childs;
|
xmlNodePtr field = parent->childs;
|
||||||
|
|
||||||
while (field) {
|
while (field) {
|
||||||
|
if (!strcmp (field->name, "name")) {
|
||||||
|
caps->name = g_strdup (xmlNodeGetContent (field));
|
||||||
|
}
|
||||||
if (!strcmp (field->name, "type")) {
|
if (!strcmp (field->name, "type")) {
|
||||||
caps->id = get_type_for_mime (xmlNodeGetContent (field));
|
caps->id = get_type_for_mime (xmlNodeGetContent (field));
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@ typedef gpointer GstCapsFactoryEntry;
|
||||||
typedef GstCapsFactoryEntry GstCapsFactory[];
|
typedef GstCapsFactoryEntry GstCapsFactory[];
|
||||||
|
|
||||||
struct _GstCaps {
|
struct _GstCaps {
|
||||||
|
gchar *name; /* the name of this caps */
|
||||||
|
|
||||||
guint16 id; /* type id (major type) */
|
guint16 id; /* type id (major type) */
|
||||||
|
|
||||||
GstProps *properties; /* properties for this capability */
|
GstProps *properties; /* properties for this capability */
|
||||||
|
@ -40,14 +42,16 @@ struct _GstCaps {
|
||||||
/* initialize the subsystem */
|
/* initialize the subsystem */
|
||||||
void _gst_caps_initialize (void);
|
void _gst_caps_initialize (void);
|
||||||
|
|
||||||
GstCaps* gst_caps_new (gchar *mime);
|
GstCaps* gst_caps_new (gchar *name, gchar *mime);
|
||||||
GstCaps* gst_caps_new_with_props (gchar *mime, GstProps *props);
|
GstCaps* gst_caps_new_with_props (gchar *name, gchar *mime, GstProps *props);
|
||||||
GstCaps* gst_caps_register (GstCapsFactory *factory);
|
GstCaps* gst_caps_register (GstCapsFactory *factory);
|
||||||
|
GstCaps* gst_caps_register_count (GstCapsFactory *factory, guint *count);
|
||||||
|
|
||||||
GstCaps* gst_caps_set_props (GstCaps *caps, GstProps *props);
|
GstCaps* gst_caps_set_props (GstCaps *caps, GstProps *props);
|
||||||
GstProps* gst_caps_get_props (GstCaps *caps);
|
GstProps* gst_caps_get_props (GstCaps *caps);
|
||||||
|
|
||||||
gboolean gst_caps_check_compatibility (GstCaps *fromcaps, GstCaps *tocaps);
|
gboolean gst_caps_check_compatibility (GstCaps *fromcaps, GstCaps *tocaps);
|
||||||
|
gboolean gst_caps_list_check_compatibility (GList *fromcaps, GList *tocaps);
|
||||||
|
|
||||||
xmlNodePtr gst_caps_save_thyself (GstCaps *caps, xmlNodePtr parent);
|
xmlNodePtr gst_caps_save_thyself (GstCaps *caps, xmlNodePtr parent);
|
||||||
GstCaps* gst_caps_load_thyself (xmlNodePtr parent);
|
GstCaps* gst_caps_load_thyself (xmlNodePtr parent);
|
||||||
|
|
|
@ -231,6 +231,10 @@ gboolean gst_elementfactory_can_src_caps (GstElementFactory *factory,
|
||||||
GstCaps *caps);
|
GstCaps *caps);
|
||||||
gboolean gst_elementfactory_can_sink_caps (GstElementFactory *factory,
|
gboolean gst_elementfactory_can_sink_caps (GstElementFactory *factory,
|
||||||
GstCaps *caps);
|
GstCaps *caps);
|
||||||
|
gboolean gst_elementfactory_can_src_caps_list (GstElementFactory *factory,
|
||||||
|
GList *caps);
|
||||||
|
gboolean gst_elementfactory_can_sink_caps_list (GstElementFactory *factory,
|
||||||
|
GList *caps);
|
||||||
|
|
||||||
GstElement* gst_elementfactory_create (GstElementFactory *factory,
|
GstElement* gst_elementfactory_create (GstElementFactory *factory,
|
||||||
gchar *name);
|
gchar *name);
|
||||||
|
|
|
@ -218,17 +218,17 @@ gst_elementfactory_add_padtemplate (GstElementFactory *factory,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_elementfactory_can_src_caps :
|
* gst_elementfactory_can_src_caps_list :
|
||||||
* @factory: factory to query
|
* @factory: factory to query
|
||||||
* @caps: the caps to check
|
* @caps: the caps list to check
|
||||||
*
|
*
|
||||||
* Checks if the factory can source the given capability
|
* Checks if the factory can source the given capability list
|
||||||
*
|
*
|
||||||
* Returns: true if it can src the capability
|
* Returns: true if it can src the capabilities
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_elementfactory_can_src_caps (GstElementFactory *factory,
|
gst_elementfactory_can_src_caps_list (GstElementFactory *factory,
|
||||||
GstCaps *caps)
|
GList *caps)
|
||||||
{
|
{
|
||||||
GList *templates;
|
GList *templates;
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ gst_elementfactory_can_src_caps (GstElementFactory *factory,
|
||||||
GstPadTemplate *template = (GstPadTemplate *)templates->data;
|
GstPadTemplate *template = (GstPadTemplate *)templates->data;
|
||||||
|
|
||||||
if (template->direction == GST_PAD_SRC) {
|
if (template->direction == GST_PAD_SRC) {
|
||||||
if (gst_caps_check_compatibility (template->caps, caps))
|
if (gst_caps_list_check_compatibility (template->caps, caps))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
templates = g_list_next (templates);
|
templates = g_list_next (templates);
|
||||||
|
@ -250,6 +250,64 @@ gst_elementfactory_can_src_caps (GstElementFactory *factory,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_elementfactory_can_sink_caps_list :
|
||||||
|
* @factory: factory to query
|
||||||
|
* @caps: the caps list to check
|
||||||
|
*
|
||||||
|
* Checks if the factory can sink the given capability list
|
||||||
|
*
|
||||||
|
* Returns: true if it can sink the capabilities
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_elementfactory_can_sink_caps_list (GstElementFactory *factory,
|
||||||
|
GList *caps)
|
||||||
|
{
|
||||||
|
GList *templates;
|
||||||
|
|
||||||
|
g_return_val_if_fail(factory != NULL, FALSE);
|
||||||
|
g_return_val_if_fail(caps != NULL, FALSE);
|
||||||
|
|
||||||
|
templates = factory->padtemplates;
|
||||||
|
|
||||||
|
while (templates) {
|
||||||
|
GstPadTemplate *template = (GstPadTemplate *)templates->data;
|
||||||
|
|
||||||
|
if (template->direction == GST_PAD_SINK) {
|
||||||
|
if (gst_caps_list_check_compatibility (caps, template->caps))
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
templates = g_list_next (templates);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_elementfactory_can_src_caps :
|
||||||
|
* @factory: factory to query
|
||||||
|
* @caps: the caps to check
|
||||||
|
*
|
||||||
|
* Checks if the factory can src the given capability
|
||||||
|
*
|
||||||
|
* Returns: true if it can sink the capability
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_elementfactory_can_src_caps (GstElementFactory *factory,
|
||||||
|
GstCaps *caps)
|
||||||
|
{
|
||||||
|
GList *dummy;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
dummy = g_list_prepend (NULL, caps);
|
||||||
|
|
||||||
|
ret = gst_elementfactory_can_src_caps_list (factory, dummy);
|
||||||
|
|
||||||
|
g_list_free (dummy);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_elementfactory_can_sink_caps :
|
* gst_elementfactory_can_sink_caps :
|
||||||
* @factory: factory to query
|
* @factory: factory to query
|
||||||
|
@ -263,24 +321,16 @@ gboolean
|
||||||
gst_elementfactory_can_sink_caps (GstElementFactory *factory,
|
gst_elementfactory_can_sink_caps (GstElementFactory *factory,
|
||||||
GstCaps *caps)
|
GstCaps *caps)
|
||||||
{
|
{
|
||||||
GList *templates;
|
GList *dummy;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
g_return_val_if_fail(factory != NULL, FALSE);
|
dummy = g_list_prepend (NULL, caps);
|
||||||
g_return_val_if_fail(caps != NULL, FALSE);
|
|
||||||
|
|
||||||
templates = factory->padtemplates;
|
ret = gst_elementfactory_can_sink_caps_list (factory, dummy);
|
||||||
|
|
||||||
while (templates) {
|
g_list_free (dummy);
|
||||||
GstPadTemplate *template = (GstPadTemplate *)templates->data;
|
|
||||||
|
|
||||||
if (template->direction == GST_PAD_SINK) {
|
return ret;
|
||||||
if (gst_caps_check_compatibility (caps, template->caps))
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
templates = g_list_next (templates);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,7 +33,8 @@ GHashTable *__gst_function_pointers = NULL;
|
||||||
|
|
||||||
/***** INFO system *****/
|
/***** INFO system *****/
|
||||||
GstInfoHandler _gst_info_handler = gst_default_info_handler;
|
GstInfoHandler _gst_info_handler = gst_default_info_handler;
|
||||||
guint32 _gst_info_categories = 0xffffffff;
|
//guint32 _gst_info_categories = 0xffffffff;
|
||||||
|
guint32 _gst_info_categories = 0x00000000;
|
||||||
|
|
||||||
static gchar *_gst_info_category_strings[] = {
|
static gchar *_gst_info_category_strings[] = {
|
||||||
"GST_INIT",
|
"GST_INIT",
|
||||||
|
|
52
gst/gstpad.c
52
gst/gstpad.c
|
@ -471,16 +471,19 @@ gst_pad_connect (GstPad *srcpad,
|
||||||
|
|
||||||
/* chack pad compatibility */
|
/* chack pad compatibility */
|
||||||
if (srcpad->caps && sinkpad->caps) {
|
if (srcpad->caps && sinkpad->caps) {
|
||||||
if (!gst_caps_check_compatibility (srcpad->caps, sinkpad->caps))
|
if (!gst_caps_check_compatibility (srcpad->caps, sinkpad->caps)) {
|
||||||
g_warning ("gstpad: connecting incompatible pads (%s:%s) and (%s:%s)\n",
|
g_warning ("gstpad: connecting incompatible pads (%s:%s) and (%s:%s)\n",
|
||||||
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
|
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
DEBUG ("gstpad: connecting compatible pads (%s:%s) and (%s:%s)\n",
|
DEBUG ("gstpad: connecting compatible pads (%s:%s) and (%s:%s)\n",
|
||||||
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
|
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
DEBUG ("gstpad: could not check capabilities of pads (%s:%s) and (%s:%s)\n",
|
DEBUG ("gstpad: could not check capabilities of pads (%s:%s) and (%s:%s)\n",
|
||||||
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
|
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
|
||||||
|
}
|
||||||
|
|
||||||
/* first set peers */
|
/* first set peers */
|
||||||
srcpad->peer = sinkpad;
|
srcpad->peer = sinkpad;
|
||||||
|
@ -592,15 +595,15 @@ gst_pad_get_ghost_parents (GstPad *pad)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_pad_set_caps:
|
* gst_pad_set_caps_list:
|
||||||
* @pad: the pad to set the caps to
|
* @pad: the pad to set the caps to
|
||||||
* @caps: the caps to attach to this pad
|
* @caps: the capslist to attach to this pad
|
||||||
*
|
*
|
||||||
* set the capabilities of this pad
|
* set the capabilities of this pad
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_pad_set_caps (GstPad *pad,
|
gst_pad_set_caps_list (GstPad *pad,
|
||||||
GstCaps *caps)
|
GList *caps)
|
||||||
{
|
{
|
||||||
g_return_if_fail (pad != NULL);
|
g_return_if_fail (pad != NULL);
|
||||||
g_return_if_fail (GST_IS_PAD (pad));
|
g_return_if_fail (GST_IS_PAD (pad));
|
||||||
|
@ -608,15 +611,15 @@ gst_pad_set_caps (GstPad *pad,
|
||||||
pad->caps = caps;
|
pad->caps = caps;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* gst_pad_get_caps:
|
* gst_pad_get_caps_list:
|
||||||
* @pad: the pad to get the capabilities from
|
* @pad: the pad to get the capabilities from
|
||||||
*
|
*
|
||||||
* get the capabilities of this pad
|
* get the capabilities of this pad
|
||||||
*
|
*
|
||||||
* Returns: the capabilities of this pad
|
* Returns: a list of capabilities of this pad
|
||||||
*/
|
*/
|
||||||
GstCaps *
|
GList *
|
||||||
gst_pad_get_caps (GstPad *pad)
|
gst_pad_get_caps_list (GstPad *pad)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (pad != NULL, NULL);
|
g_return_val_if_fail (pad != NULL, NULL);
|
||||||
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
|
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
|
||||||
|
@ -821,6 +824,7 @@ gst_padtemplate_new (GstPadFactory *factory)
|
||||||
GstPadTemplate *new;
|
GstPadTemplate *new;
|
||||||
GstPadFactoryEntry tag;
|
GstPadFactoryEntry tag;
|
||||||
gint i = 0;
|
gint i = 0;
|
||||||
|
guint counter = 0;
|
||||||
|
|
||||||
g_return_val_if_fail (factory != NULL, NULL);
|
g_return_val_if_fail (factory != NULL, NULL);
|
||||||
|
|
||||||
|
@ -836,7 +840,13 @@ gst_padtemplate_new (GstPadFactory *factory)
|
||||||
tag = (*factory)[i++];
|
tag = (*factory)[i++];
|
||||||
new->presence = GPOINTER_TO_UINT (tag);
|
new->presence = GPOINTER_TO_UINT (tag);
|
||||||
|
|
||||||
new->caps = gst_caps_register ((GstCapsFactory *)&(*factory)[i]);
|
tag = (*factory)[i++];
|
||||||
|
|
||||||
|
while (GPOINTER_TO_INT (tag) == 1) {
|
||||||
|
new->caps = g_list_append (new->caps, gst_caps_register_count ((GstCapsFactory *)&(*factory)[i], &counter));
|
||||||
|
i+=counter;
|
||||||
|
tag = (*factory)[i++];
|
||||||
|
}
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
@ -846,7 +856,7 @@ gst_padtemplate_new (GstPadFactory *factory)
|
||||||
* @name_template: the name template
|
* @name_template: the name template
|
||||||
* @direction: the direction for the template
|
* @direction: the direction for the template
|
||||||
* @presence: the presence of the pad
|
* @presence: the presence of the pad
|
||||||
* @caps: the capabilities for the template
|
* @caps: a list of capabilities for the template
|
||||||
*
|
*
|
||||||
* creates a new padtemplate from the given arguments
|
* creates a new padtemplate from the given arguments
|
||||||
*
|
*
|
||||||
|
@ -855,7 +865,7 @@ gst_padtemplate_new (GstPadFactory *factory)
|
||||||
GstPadTemplate*
|
GstPadTemplate*
|
||||||
gst_padtemplate_create (gchar *name_template,
|
gst_padtemplate_create (gchar *name_template,
|
||||||
GstPadDirection direction, GstPadPresence presence,
|
GstPadDirection direction, GstPadPresence presence,
|
||||||
GstCaps *caps)
|
GList *caps)
|
||||||
{
|
{
|
||||||
GstPadTemplate *new;
|
GstPadTemplate *new;
|
||||||
|
|
||||||
|
@ -883,13 +893,21 @@ xmlNodePtr
|
||||||
gst_padtemplate_save_thyself (GstPadTemplate *pad, xmlNodePtr parent)
|
gst_padtemplate_save_thyself (GstPadTemplate *pad, xmlNodePtr parent)
|
||||||
{
|
{
|
||||||
xmlNodePtr subtree;
|
xmlNodePtr subtree;
|
||||||
|
GList *caps;
|
||||||
|
|
||||||
xmlNewChild(parent,NULL,"nametemplate", pad->name_template);
|
xmlNewChild(parent,NULL,"nametemplate", pad->name_template);
|
||||||
xmlNewChild(parent,NULL,"direction", (pad->direction == GST_PAD_SINK? "sink":"src"));
|
xmlNewChild(parent,NULL,"direction", (pad->direction == GST_PAD_SINK? "sink":"src"));
|
||||||
xmlNewChild(parent,NULL,"presence", (pad->presence == GST_PAD_ALWAYS? "always":"sometimes"));
|
xmlNewChild(parent,NULL,"presence", (pad->presence == GST_PAD_ALWAYS? "always":"sometimes"));
|
||||||
subtree = xmlNewChild(parent,NULL,"caps", NULL);
|
|
||||||
|
|
||||||
gst_caps_save_thyself (pad->caps, subtree);
|
caps = pad->caps;
|
||||||
|
while (caps) {
|
||||||
|
GstCaps *cap = (GstCaps *)caps->data;
|
||||||
|
|
||||||
|
subtree = xmlNewChild(parent,NULL,"caps", NULL);
|
||||||
|
gst_caps_save_thyself (cap, subtree);
|
||||||
|
|
||||||
|
caps = g_list_next (caps);
|
||||||
|
}
|
||||||
|
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
@ -934,7 +952,7 @@ gst_padtemplate_load_thyself (xmlNodePtr parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!strcmp(field->name, "caps")) {
|
else if (!strcmp(field->name, "caps")) {
|
||||||
factory->caps = gst_caps_load_thyself (field);
|
factory->caps = g_list_append(factory->caps, gst_caps_load_thyself (field));
|
||||||
}
|
}
|
||||||
field = field->next;
|
field = field->next;
|
||||||
}
|
}
|
||||||
|
|
15
gst/gstpad.h
15
gst/gstpad.h
|
@ -82,7 +82,7 @@ struct _GstPad {
|
||||||
GstObject object;
|
GstObject object;
|
||||||
|
|
||||||
gchar *name;
|
gchar *name;
|
||||||
GstCaps *caps;
|
GList *caps;
|
||||||
|
|
||||||
cothread_state *threadstate;
|
cothread_state *threadstate;
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ struct _GstPadTemplate {
|
||||||
gchar *name_template;
|
gchar *name_template;
|
||||||
GstPadDirection direction;
|
GstPadDirection direction;
|
||||||
GstPadPresence presence;
|
GstPadPresence presence;
|
||||||
GstCaps *caps;
|
GList *caps;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstPadTemplateClass {
|
struct _GstPadTemplateClass {
|
||||||
|
@ -148,12 +148,15 @@ struct _GstPadTemplateClass {
|
||||||
/* factory */
|
/* factory */
|
||||||
typedef gpointer GstPadFactoryEntry;
|
typedef gpointer GstPadFactoryEntry;
|
||||||
typedef GstPadFactoryEntry GstPadFactory[];
|
typedef GstPadFactoryEntry GstPadFactory[];
|
||||||
|
|
||||||
#define GST_PAD_FACTORY_ALWAYS GINT_TO_POINTER(GST_PAD_ALWAYS)
|
#define GST_PAD_FACTORY_ALWAYS GINT_TO_POINTER(GST_PAD_ALWAYS)
|
||||||
#define GST_PAD_FACTORY_SOMETIMES GINT_TO_POINTER(GST_PAD_SOMETIMES)
|
#define GST_PAD_FACTORY_SOMETIMES GINT_TO_POINTER(GST_PAD_SOMETIMES)
|
||||||
|
|
||||||
#define GST_PAD_FACTORY_SRC GINT_TO_POINTER(GST_PAD_SRC)
|
#define GST_PAD_FACTORY_SRC GINT_TO_POINTER(GST_PAD_SRC)
|
||||||
#define GST_PAD_FACTORY_SINK GINT_TO_POINTER(GST_PAD_SINK)
|
#define GST_PAD_FACTORY_SINK GINT_TO_POINTER(GST_PAD_SINK)
|
||||||
|
|
||||||
|
#define GST_PAD_FACTORY_CAPS(a...) GINT_TO_POINTER(1),##a,NULL
|
||||||
|
|
||||||
GtkType gst_pad_get_type (void);
|
GtkType gst_pad_get_type (void);
|
||||||
|
|
||||||
GstPad* gst_pad_new (gchar *name, GstPadDirection direction);
|
GstPad* gst_pad_new (gchar *name, GstPadDirection direction);
|
||||||
|
@ -167,8 +170,10 @@ void gst_pad_set_get_function (GstPad *pad, GstPadGetFunction get);
|
||||||
void gst_pad_set_getregion_function (GstPad *pad, GstPadGetRegionFunction getregion);
|
void gst_pad_set_getregion_function (GstPad *pad, GstPadGetRegionFunction getregion);
|
||||||
void gst_pad_set_qos_function (GstPad *pad, GstPadQoSFunction qos);
|
void gst_pad_set_qos_function (GstPad *pad, GstPadQoSFunction qos);
|
||||||
|
|
||||||
void gst_pad_set_caps (GstPad *pad, GstCaps *caps);
|
void gst_pad_set_caps_list (GstPad *pad, GList *caps);
|
||||||
GstCaps* gst_pad_get_caps (GstPad *pad);
|
GList* gst_pad_get_caps_list (GstPad *pad);
|
||||||
|
GstCaps* gst_pad_get_caps_by_name (GstPad *pad, gchar *name);
|
||||||
|
gboolean gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad);
|
||||||
|
|
||||||
void gst_pad_set_name (GstPad *pad, const gchar *name);
|
void gst_pad_set_name (GstPad *pad, const gchar *name);
|
||||||
const gchar* gst_pad_get_name (GstPad *pad);
|
const gchar* gst_pad_get_name (GstPad *pad);
|
||||||
|
@ -213,7 +218,7 @@ GtkType gst_padtemplate_get_type (void);
|
||||||
GstPadTemplate* gst_padtemplate_new (GstPadFactory *factory);
|
GstPadTemplate* gst_padtemplate_new (GstPadFactory *factory);
|
||||||
GstPadTemplate* gst_padtemplate_create (gchar *name_template,
|
GstPadTemplate* gst_padtemplate_create (gchar *name_template,
|
||||||
GstPadDirection direction, GstPadPresence presence,
|
GstPadDirection direction, GstPadPresence presence,
|
||||||
GstCaps *caps);
|
GList *caps);
|
||||||
|
|
||||||
xmlNodePtr gst_padtemplate_save_thyself (GstPadTemplate *pad, xmlNodePtr parent);
|
xmlNodePtr gst_padtemplate_save_thyself (GstPadTemplate *pad, xmlNodePtr parent);
|
||||||
GstPadTemplate* gst_padtemplate_load_thyself (xmlNodePtr parent);
|
GstPadTemplate* gst_padtemplate_load_thyself (xmlNodePtr parent);
|
||||||
|
|
|
@ -172,7 +172,7 @@ gst_pipeline_typefind (GstPipeline *pipeline, GstElement *element)
|
||||||
if (found) {
|
if (found) {
|
||||||
caps = gst_util_get_pointer_arg (GTK_OBJECT (typefind), "caps");
|
caps = gst_util_get_pointer_arg (GTK_OBJECT (typefind), "caps");
|
||||||
|
|
||||||
gst_pad_set_caps (gst_element_get_pad (element, "src"), caps);
|
gst_pad_set_caps_list (gst_element_get_pad (element, "src"), g_list_prepend (NULL, caps));
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_pad_disconnect (gst_element_get_pad (element, "src"),
|
gst_pad_disconnect (gst_element_get_pad (element, "src"),
|
||||||
|
@ -200,7 +200,7 @@ gst_pipeline_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink)
|
||||||
if (sinkpad->direction == GST_PAD_SINK &&
|
if (sinkpad->direction == GST_PAD_SINK &&
|
||||||
!GST_PAD_CONNECTED(sinkpad))
|
!GST_PAD_CONNECTED(sinkpad))
|
||||||
{
|
{
|
||||||
if (gst_caps_check_compatibility (pad->caps, sinkpad->caps)) {
|
if (gst_caps_list_check_compatibility (pad->caps, sinkpad->caps)) {
|
||||||
gst_pad_connect(pad, sinkpad);
|
gst_pad_connect(pad, sinkpad);
|
||||||
DEBUG("gstpipeline: autoconnect pad \"%s\" in element %s <-> ", pad->name,
|
DEBUG("gstpipeline: autoconnect pad \"%s\" in element %s <-> ", pad->name,
|
||||||
gst_element_get_name(src));
|
gst_element_get_name(src));
|
||||||
|
@ -308,7 +308,6 @@ gst_pipeline_autoplug (GstPipeline *pipeline)
|
||||||
GList **factories;
|
GList **factories;
|
||||||
GList **base_factories;
|
GList **base_factories;
|
||||||
GstElementFactory *factory;
|
GstElementFactory *factory;
|
||||||
GList *src_pads;
|
|
||||||
GstCaps *src_caps = 0;
|
GstCaps *src_caps = 0;
|
||||||
guint i, numsinks;
|
guint i, numsinks;
|
||||||
gboolean use_thread = FALSE, have_common = FALSE;
|
gboolean use_thread = FALSE, have_common = FALSE;
|
||||||
|
@ -352,14 +351,13 @@ gst_pipeline_autoplug (GstPipeline *pipeline)
|
||||||
i = 0;
|
i = 0;
|
||||||
// fase 2, loop over all the sinks..
|
// fase 2, loop over all the sinks..
|
||||||
while (elements) {
|
while (elements) {
|
||||||
GList *pads;
|
|
||||||
GstPad *pad;
|
GstPad *pad;
|
||||||
|
|
||||||
element = GST_ELEMENT(elements->data);
|
element = GST_ELEMENT(elements->data);
|
||||||
|
|
||||||
pad = (GstPad *)gst_element_get_pad_list (element)->data;
|
pad = (GstPad *)gst_element_get_pad_list (element)->data;
|
||||||
|
|
||||||
base_factories[i] = factories[i] = gst_autoplug_caps (src_caps, pad->caps);
|
base_factories[i] = factories[i] = gst_autoplug_caps_list (g_list_append(NULL,src_caps), pad->caps);
|
||||||
// if we have a succesfull connection, proceed
|
// if we have a succesfull connection, proceed
|
||||||
if (factories[i] != NULL)
|
if (factories[i] != NULL)
|
||||||
i++;
|
i++;
|
||||||
|
@ -451,11 +449,11 @@ differ:
|
||||||
// FIXME connect matching pads, not just the first one...
|
// FIXME connect matching pads, not just the first one...
|
||||||
if (sinkpad->direction == GST_PAD_SINK &&
|
if (sinkpad->direction == GST_PAD_SINK &&
|
||||||
!GST_PAD_CONNECTED(sinkpad)) {
|
!GST_PAD_CONNECTED(sinkpad)) {
|
||||||
GstCaps *caps = gst_pad_get_caps (sinkpad);
|
GList *caps = gst_pad_get_caps_list (sinkpad);
|
||||||
|
|
||||||
// the queue has the type of the elements it connects
|
// the queue has the type of the elements it connects
|
||||||
gst_pad_set_caps (srcpad, caps);
|
gst_pad_set_caps_list (srcpad, caps);
|
||||||
gst_pad_set_caps (gst_element_get_pad(queue, "sink"), caps);
|
gst_pad_set_caps_list (gst_element_get_pad(queue, "sink"), caps);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sinkpads = g_list_next(sinkpads);
|
sinkpads = g_list_next(sinkpads);
|
||||||
|
|
|
@ -459,6 +459,7 @@ gst_plugin_load_typefactory (gchar *mime)
|
||||||
gchar *pluginname = g_strdup (plugin->name);
|
gchar *pluginname = g_strdup (plugin->name);
|
||||||
|
|
||||||
INFO(GST_INFO_PLUGIN_LOADING,"loading type factory for \"%s\" from plugin %s",mime,plugin->name);
|
INFO(GST_INFO_PLUGIN_LOADING,"loading type factory for \"%s\" from plugin %s",mime,plugin->name);
|
||||||
|
plugin->loaded = TRUE;
|
||||||
gst_plugin_remove(plugin);
|
gst_plugin_remove(plugin);
|
||||||
if (!gst_plugin_load_absolute(filename)) {
|
if (!gst_plugin_load_absolute(filename)) {
|
||||||
DEBUG("gstplugin: error loading type factory \"%s\" from plugin %s\n", mime, pluginname);
|
DEBUG("gstplugin: error loading type factory \"%s\" from plugin %s\n", mime, pluginname);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define GST_DEBUG_ENABLED
|
//#define GST_DEBUG_ENABLED
|
||||||
#include "gst_private.h"
|
#include "gst_private.h"
|
||||||
|
|
||||||
#include "gstprops.h"
|
#include "gstprops.h"
|
||||||
|
@ -107,17 +107,34 @@ props_compare_func (gconstpointer a,
|
||||||
*/
|
*/
|
||||||
GstProps *
|
GstProps *
|
||||||
gst_props_register (GstPropsFactory factory)
|
gst_props_register (GstPropsFactory factory)
|
||||||
|
{
|
||||||
|
guint dummy;
|
||||||
|
|
||||||
|
return gst_props_register_count (factory, &dummy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_props_register_count:
|
||||||
|
* @factory: the factory to register
|
||||||
|
* @counter: count how many fields were consumed
|
||||||
|
*
|
||||||
|
* Register the factory.
|
||||||
|
*
|
||||||
|
* Returns: The new property created from the factory
|
||||||
|
*/
|
||||||
|
GstProps *
|
||||||
|
gst_props_register_count (GstPropsFactory factory, guint *counter)
|
||||||
{
|
{
|
||||||
GstPropsFactoryEntry tag;
|
GstPropsFactoryEntry tag;
|
||||||
gint i = 0;
|
gint i = 0;
|
||||||
GstProps *props;
|
GstProps *props = NULL;
|
||||||
gint skipped;
|
gint skipped;
|
||||||
|
|
||||||
g_return_val_if_fail (factory != NULL, NULL);
|
g_return_val_if_fail (factory != NULL, NULL);
|
||||||
|
|
||||||
tag = factory[i++];
|
tag = factory[i++];
|
||||||
|
|
||||||
if (!tag) return NULL;
|
if (!tag) goto end;
|
||||||
|
|
||||||
props = g_new0 (GstProps, 1);
|
props = g_new0 (GstProps, 1);
|
||||||
g_return_val_if_fail (props != NULL, NULL);
|
g_return_val_if_fail (props != NULL, NULL);
|
||||||
|
@ -128,6 +145,11 @@ gst_props_register (GstPropsFactory factory)
|
||||||
GQuark quark;
|
GQuark quark;
|
||||||
GstPropsEntry *entry;
|
GstPropsEntry *entry;
|
||||||
|
|
||||||
|
if (tag < GST_PROPS_LAST_ID) {
|
||||||
|
g_warning ("properties seem to be wrong\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
quark = g_quark_from_string ((gchar *)tag);
|
quark = g_quark_from_string ((gchar *)tag);
|
||||||
|
|
||||||
tag = factory[i];
|
tag = factory[i];
|
||||||
|
@ -167,6 +189,9 @@ gst_props_register (GstPropsFactory factory)
|
||||||
tag = factory[i++];
|
tag = factory[i++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
|
*counter = i;
|
||||||
|
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ typedef enum {
|
||||||
GST_PROPS_INT_RANGE_ID_NUM,
|
GST_PROPS_INT_RANGE_ID_NUM,
|
||||||
GST_PROPS_FOURCC_ID_NUM,
|
GST_PROPS_FOURCC_ID_NUM,
|
||||||
GST_PROPS_BOOL_ID_NUM,
|
GST_PROPS_BOOL_ID_NUM,
|
||||||
|
GST_PROPS_LAST_ID_NUM = GST_PROPS_END_ID_NUM + 16,
|
||||||
} GstPropsId;
|
} GstPropsId;
|
||||||
|
|
||||||
#define GST_PROPS_END_ID GINT_TO_POINTER(GST_PROPS_END_ID_NUM)
|
#define GST_PROPS_END_ID GINT_TO_POINTER(GST_PROPS_END_ID_NUM)
|
||||||
|
@ -48,6 +49,7 @@ typedef enum {
|
||||||
#define GST_PROPS_INT_RANGE_ID GINT_TO_POINTER(GST_PROPS_INT_RANGE_ID_NUM)
|
#define GST_PROPS_INT_RANGE_ID GINT_TO_POINTER(GST_PROPS_INT_RANGE_ID_NUM)
|
||||||
#define GST_PROPS_FOURCC_ID GINT_TO_POINTER(GST_PROPS_FOURCC_ID_NUM)
|
#define GST_PROPS_FOURCC_ID GINT_TO_POINTER(GST_PROPS_FOURCC_ID_NUM)
|
||||||
#define GST_PROPS_BOOL_ID GINT_TO_POINTER(GST_PROPS_BOOL_ID_NUM)
|
#define GST_PROPS_BOOL_ID GINT_TO_POINTER(GST_PROPS_BOOL_ID_NUM)
|
||||||
|
#define GST_PROPS_LAST_ID GINT_TO_POINTER(GST_PROPS_LAST_ID_NUM)
|
||||||
|
|
||||||
#define GST_PROPS_LIST(a...) GST_PROPS_LIST_ID,##a,NULL
|
#define GST_PROPS_LIST(a...) GST_PROPS_LIST_ID,##a,NULL
|
||||||
#define GST_PROPS_INT(a) GST_PROPS_INT_ID,(GINT_TO_POINTER(a))
|
#define GST_PROPS_INT(a) GST_PROPS_INT_ID,(GINT_TO_POINTER(a))
|
||||||
|
@ -65,6 +67,7 @@ struct _GstProps {
|
||||||
void _gst_props_initialize (void);
|
void _gst_props_initialize (void);
|
||||||
|
|
||||||
GstProps* gst_props_register (GstPropsFactory factory);
|
GstProps* gst_props_register (GstPropsFactory factory);
|
||||||
|
GstProps* gst_props_register_count (GstPropsFactory factory, guint *counter);
|
||||||
|
|
||||||
GstProps* gst_props_new (GstPropsFactoryEntry entry, ...);
|
GstProps* gst_props_new (GstPropsFactoryEntry entry, ...);
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,8 @@ static GstPadFactory audiosink_sink_factory = {
|
||||||
"sink",
|
"sink",
|
||||||
GST_PAD_FACTORY_SINK,
|
GST_PAD_FACTORY_SINK,
|
||||||
GST_PAD_FACTORY_ALWAYS,
|
GST_PAD_FACTORY_ALWAYS,
|
||||||
|
GST_PAD_FACTORY_CAPS (
|
||||||
|
"audiosink_sink",
|
||||||
"audio/raw",
|
"audio/raw",
|
||||||
"format", GST_PROPS_INT (AFMT_S16_LE),
|
"format", GST_PROPS_INT (AFMT_S16_LE),
|
||||||
"depth", GST_PROPS_LIST (
|
"depth", GST_PROPS_LIST (
|
||||||
|
@ -81,7 +83,8 @@ static GstPadFactory audiosink_sink_factory = {
|
||||||
GST_PROPS_INT (16)
|
GST_PROPS_INT (16)
|
||||||
),
|
),
|
||||||
"rate", GST_PROPS_INT_RANGE (8000, 48000),
|
"rate", GST_PROPS_INT_RANGE (8000, 48000),
|
||||||
"channels", GST_PROPS_INT_RANGE (1, 2),
|
"channels", GST_PROPS_INT_RANGE (1, 2)
|
||||||
|
),
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
noinst_PROGRAMS = init loadall simplefake states caps queue registry paranoia rip mp3encode autoplug props case4
|
noinst_PROGRAMS = init loadall simplefake states caps queue registry paranoia rip mp3encode autoplug props case4 padfactory
|
||||||
|
|
||||||
LDADD = $(GLIB_LIBS) $(GTK_LIBS) $(top_builddir)/gst/libgst.la
|
LDADD = $(GLIB_LIBS) $(GTK_LIBS) $(top_builddir)/gst/libgst.la
|
||||||
CFLAGS = -Wall
|
CFLAGS = -Wall
|
||||||
|
|
|
@ -5,8 +5,8 @@ autoplug_caps (gchar *mime1, gchar *mime2)
|
||||||
{
|
{
|
||||||
GstCaps *caps1, *caps2;
|
GstCaps *caps1, *caps2;
|
||||||
|
|
||||||
caps1 = gst_caps_new (mime1);
|
caps1 = gst_caps_new ("tescaps1", mime1);
|
||||||
caps2 = gst_caps_new (mime2);
|
caps2 = gst_caps_new ("tescaps2", mime2);
|
||||||
|
|
||||||
return gst_autoplug_caps (caps1, caps2);
|
return gst_autoplug_caps (caps1, caps2);
|
||||||
}
|
}
|
||||||
|
@ -39,21 +39,25 @@ int main(int argc,char *argv[])
|
||||||
|
|
||||||
factories = gst_autoplug_caps (
|
factories = gst_autoplug_caps (
|
||||||
gst_caps_new_with_props(
|
gst_caps_new_with_props(
|
||||||
|
"testcaps3",
|
||||||
"video/mpeg",
|
"video/mpeg",
|
||||||
gst_props_new (
|
gst_props_new (
|
||||||
"mpegversion", GST_PROPS_INT (1),
|
"mpegversion", GST_PROPS_INT (1),
|
||||||
"systemstream", GST_PROPS_BOOLEAN (TRUE),
|
"systemstream", GST_PROPS_BOOLEAN (TRUE),
|
||||||
NULL)),
|
NULL)),
|
||||||
gst_caps_new("audio/raw"));
|
gst_caps_new("testcaps4","audio/raw"));
|
||||||
dump_factories (factories);
|
dump_factories (factories);
|
||||||
|
|
||||||
factories = gst_autoplug_caps (
|
factories = gst_autoplug_caps (
|
||||||
gst_caps_new_with_props(
|
gst_caps_new_with_props(
|
||||||
|
"testcaps5",
|
||||||
"video/mpeg",
|
"video/mpeg",
|
||||||
gst_props_new (
|
gst_props_new (
|
||||||
"mpegversion", GST_PROPS_INT (1),
|
"mpegversion", GST_PROPS_INT (1),
|
||||||
"systemstream", GST_PROPS_BOOLEAN (FALSE),
|
"systemstream", GST_PROPS_BOOLEAN (FALSE),
|
||||||
NULL)),
|
NULL)),
|
||||||
gst_caps_new("video/raw"));
|
gst_caps_new("testcaps6", "video/raw"));
|
||||||
dump_factories (factories);
|
dump_factories (factories);
|
||||||
|
|
||||||
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
12
tests/caps.c
12
tests/caps.c
|
@ -1,12 +1,7 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
static GstTypeFactory mpegfactory = {
|
|
||||||
"video/mpeg", // major type
|
|
||||||
".mpg .mpeg", // extenstions
|
|
||||||
NULL, // typefind function
|
|
||||||
};
|
|
||||||
|
|
||||||
static GstCapsFactory mpeg2dec_sink_caps = {
|
static GstCapsFactory mpeg2dec_sink_caps = {
|
||||||
|
"mpeg2dec_sink",
|
||||||
"video/mpeg",
|
"video/mpeg",
|
||||||
"mpegtype", GST_PROPS_LIST (
|
"mpegtype", GST_PROPS_LIST (
|
||||||
GST_PROPS_INT(1),
|
GST_PROPS_INT(1),
|
||||||
|
@ -16,6 +11,7 @@ static GstCapsFactory mpeg2dec_sink_caps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstCapsFactory mp1parse_src_caps = {
|
static GstCapsFactory mp1parse_src_caps = {
|
||||||
|
"mp1parse_src",
|
||||||
"video/mpeg",
|
"video/mpeg",
|
||||||
"mpegtype", GST_PROPS_LIST (
|
"mpegtype", GST_PROPS_LIST (
|
||||||
GST_PROPS_INT(1)
|
GST_PROPS_INT(1)
|
||||||
|
@ -24,6 +20,7 @@ static GstCapsFactory mp1parse_src_caps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstCapsFactory mpeg2dec_src_caps = {
|
static GstCapsFactory mpeg2dec_src_caps = {
|
||||||
|
"mpeg2dec_src",
|
||||||
"video/raw",
|
"video/raw",
|
||||||
"fourcc", GST_PROPS_LIST (
|
"fourcc", GST_PROPS_LIST (
|
||||||
GST_PROPS_FOURCC ('Y','V','1','2'),
|
GST_PROPS_FOURCC ('Y','V','1','2'),
|
||||||
|
@ -35,6 +32,7 @@ static GstCapsFactory mpeg2dec_src_caps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstCapsFactory raw_sink_caps = {
|
static GstCapsFactory raw_sink_caps = {
|
||||||
|
"raw_sink_caps",
|
||||||
"video/raw",
|
"video/raw",
|
||||||
"fourcc", GST_PROPS_LIST (
|
"fourcc", GST_PROPS_LIST (
|
||||||
GST_PROPS_FOURCC_INT (0x32315659)
|
GST_PROPS_FOURCC_INT (0x32315659)
|
||||||
|
@ -44,6 +42,7 @@ static GstCapsFactory raw_sink_caps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstCapsFactory raw2_sink_caps = {
|
static GstCapsFactory raw2_sink_caps = {
|
||||||
|
"raw2_sink_caps",
|
||||||
"video/raw",
|
"video/raw",
|
||||||
"fourcc", GST_PROPS_LIST (
|
"fourcc", GST_PROPS_LIST (
|
||||||
GST_PROPS_FOURCC_INT (0x32315659),
|
GST_PROPS_FOURCC_INT (0x32315659),
|
||||||
|
@ -58,7 +57,6 @@ static GstCaps *sinkcaps = NULL,
|
||||||
*rawcaps = NULL,
|
*rawcaps = NULL,
|
||||||
*rawcaps2 = NULL,
|
*rawcaps2 = NULL,
|
||||||
*rawcaps3 = NULL,
|
*rawcaps3 = NULL,
|
||||||
*sinkcapslist = NULL,
|
|
||||||
*mp1parsecaps = NULL;
|
*mp1parsecaps = NULL;
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
int main(int argc,char *argv[]) {
|
int main(int argc,char *argv[]) {
|
||||||
GstBin *thread;
|
GstBin *thread;
|
||||||
GstElement *src,*identity,*sink;
|
GstElement *src,*identity,*sink;
|
||||||
int i;
|
|
||||||
|
|
||||||
DEBUG_ENTER("(%d)",argc);
|
DEBUG_ENTER("(%d)",argc);
|
||||||
|
|
||||||
|
@ -31,4 +30,6 @@ int main(int argc,char *argv[]) {
|
||||||
|
|
||||||
gst_bin_iterate(thread);
|
gst_bin_iterate(thread);
|
||||||
gst_bin_iterate(thread);
|
gst_bin_iterate(thread);
|
||||||
|
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,6 @@
|
||||||
|
|
||||||
int main(int argc,char *argv[]) {
|
int main(int argc,char *argv[]) {
|
||||||
gst_init(&argc,&argv);
|
gst_init(&argc,&argv);
|
||||||
|
|
||||||
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
static gboolean playing;
|
static gboolean playing;
|
||||||
|
|
||||||
/* eos will be called when the src element has an end of stream */
|
/* eos will be called when the src element has an end of stream */
|
||||||
void eos(GstSrc *src)
|
void eos(GstElement *src)
|
||||||
{
|
{
|
||||||
g_print("have eos, quitting\n");
|
g_print("have eos, quitting\n");
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ int main(int argc,char *argv[]) {
|
||||||
// thr1 = gst_bin_new("thr1");
|
// thr1 = gst_bin_new("thr1");
|
||||||
g_return_val_if_fail(2,thr1 != NULL);
|
g_return_val_if_fail(2,thr1 != NULL);
|
||||||
// thr2 = GST_BIN(gst_thread_new("thr2"));
|
// thr2 = GST_BIN(gst_thread_new("thr2"));
|
||||||
thr2 = gst_bin_new("thr2");
|
thr2 = GST_BIN(gst_bin_new("thr2"));
|
||||||
g_return_val_if_fail(3,thr2 != NULL);
|
g_return_val_if_fail(3,thr2 != NULL);
|
||||||
fprintf(stderr,"QUEUE: fakesrc\n");
|
fprintf(stderr,"QUEUE: fakesrc\n");
|
||||||
src = gst_elementfactory_make("fakesrc","src");
|
src = gst_elementfactory_make("fakesrc","src");
|
||||||
|
@ -41,8 +41,8 @@ fprintf(stderr,"QUEUE: fakesink\n");
|
||||||
gst_bin_add(pipeline,GST_ELEMENT(queue));
|
gst_bin_add(pipeline,GST_ELEMENT(queue));
|
||||||
gst_bin_add(pipeline,GST_ELEMENT(thr2));
|
gst_bin_add(pipeline,GST_ELEMENT(thr2));
|
||||||
fprintf(stderr,"QUEUE: connecting elements\n");
|
fprintf(stderr,"QUEUE: connecting elements\n");
|
||||||
gst_element_connect(thr1,"src",queue,"sink");
|
gst_element_connect(GST_ELEMENT(thr1),"src",queue,"sink");
|
||||||
gst_element_connect(queue,"src",thr2,"sink");
|
gst_element_connect(queue,"src",GST_ELEMENT(thr2),"sink");
|
||||||
// gst_pad_connect(gst_element_get_pad(src,"src"),gst_element_get_pad(queue,"sink"));
|
// gst_pad_connect(gst_element_get_pad(src,"src"),gst_element_get_pad(queue,"sink"));
|
||||||
// gst_pad_connect(gst_element_get_pad(queue,"src"),gst_element_get_pad(sink,"sink"));
|
// gst_pad_connect(gst_element_get_pad(queue,"src"),gst_element_get_pad(sink,"sink"));
|
||||||
fprintf(stderr,"QUEUE: constructed outer pipeline\n");
|
fprintf(stderr,"QUEUE: constructed outer pipeline\n");
|
||||||
|
@ -59,4 +59,6 @@ fprintf(stderr,"QUEUE: fakesink\n");
|
||||||
// fflush(stdout);
|
// fflush(stdout);
|
||||||
// fflush(stderr);
|
// fflush(stderr);
|
||||||
// gst_bin_iterate(thr2);
|
// gst_bin_iterate(thr2);
|
||||||
|
//
|
||||||
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
int main(int argc,char *argv[]) {
|
int main(int argc,char *argv[]) {
|
||||||
GstPipeline *pipeline;
|
GstElement *pipeline;
|
||||||
GstElement *src,*identity,*sink;
|
GstElement *src,*identity,*sink;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -39,4 +39,6 @@ int main(int argc,char *argv[]) {
|
||||||
fprintf(stderr,"\n");
|
fprintf(stderr,"\n");
|
||||||
gst_bin_iterate(GST_BIN(pipeline));
|
gst_bin_iterate(GST_BIN(pipeline));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ gboolean state_change(GstElement *element,GstElementState state) {
|
||||||
g_print(">STATES: element '%s' state set to %d(%s)\n",
|
g_print(">STATES: element '%s' state set to %d(%s)\n",
|
||||||
gst_element_get_name(element),state,_gst_print_statename(state));
|
gst_element_get_name(element),state,_gst_print_statename(state));
|
||||||
g_print(">STATES: element state is actually %d\n",GST_STATE(element));
|
g_print(">STATES: element state is actually %d\n",GST_STATE(element));
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc,char *argv[]) {
|
int main(int argc,char *argv[]) {
|
||||||
|
@ -61,4 +63,6 @@ int main(int argc,char *argv[]) {
|
||||||
gst_element_set_state (bin, GST_STATE_PLAYING);
|
gst_element_set_state (bin, GST_STATE_PLAYING);
|
||||||
|
|
||||||
gst_bin_iterate (GST_BIN (bin));
|
gst_bin_iterate (GST_BIN (bin));
|
||||||
|
|
||||||
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue