The typefind function now returns a GstCaps structure instead of a gboolean. modified some plugins to this new behaviour
Original commit message from CVS: The typefind function now returns a GstCaps structure instead of a gboolean. modified some plugins to this new behaviour Fixed autoplugging for the mpg123 case. When an element is selected in autoplugging and the caps do not match, another element is selected until the caps match. only examples/autoplug works because gstmediaplay uses a threaded setup that does not seem to work with the current scheduling.
This commit is contained in:
parent
e40c284572
commit
510430d10f
@ -17,7 +17,7 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define GST_DEBUG_ENABLED
|
//#define GST_DEBUG_ENABLED
|
||||||
|
|
||||||
#include "gstbin.h"
|
#include "gstbin.h"
|
||||||
#include "gstdebug.h"
|
#include "gstdebug.h"
|
||||||
@ -592,7 +592,6 @@ gst_bin_src_wrapper (int argc,char *argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
static void
|
static void
|
||||||
gst_bin_pullregionfunc_proxy (GstPad *pad,
|
gst_bin_pullregionfunc_proxy (GstPad *pad,
|
||||||
gulong offset,
|
gulong offset,
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "gstcaps.h"
|
#include "gstcaps.h"
|
||||||
#include "gsttype.h"
|
#include "gsttype.h"
|
||||||
|
|
||||||
|
#include "gstpropsprivate.h"
|
||||||
void
|
void
|
||||||
_gst_caps_initialize (void)
|
_gst_caps_initialize (void)
|
||||||
{
|
{
|
||||||
@ -62,6 +63,7 @@ gst_caps_new (gchar *mime)
|
|||||||
|
|
||||||
caps = g_new0 (GstCaps, 1);
|
caps = g_new0 (GstCaps, 1);
|
||||||
caps->id = get_type_for_mime (mime);
|
caps->id = get_type_for_mime (mime);
|
||||||
|
caps->properties = NULL;
|
||||||
|
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
@ -118,10 +120,22 @@ gst_caps_check_compatibility (GstCaps *fromcaps, GstCaps *tocaps)
|
|||||||
if (fromcaps->id != tocaps->id)
|
if (fromcaps->id != tocaps->id)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (fromcaps->properties && tocaps->properties) {
|
if (tocaps->properties) {
|
||||||
return gst_props_check_compatibility (fromcaps->properties, tocaps->properties);
|
GstPropsEntry *entry = (GstPropsEntry *)tocaps->properties;
|
||||||
|
|
||||||
|
if (fromcaps->properties) {
|
||||||
|
return gst_props_check_compatibility (fromcaps->properties, tocaps->properties);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
g_print ("gstcaps: no source caps\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// assume it accepts everything
|
||||||
|
g_print ("gstcaps: no caps\n");
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
else return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -626,6 +626,8 @@ gst_pad_connect (GstPad *srcpad,
|
|||||||
else
|
else
|
||||||
g_print ("gstpad: connecting compatible pads\n");
|
g_print ("gstpad: connecting compatible pads\n");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
g_print ("gstpad: could not check capabilities of pads\n");
|
||||||
|
|
||||||
/* first set peers */
|
/* first set peers */
|
||||||
srcpad->peer = sinkpad;
|
srcpad->peer = sinkpad;
|
||||||
|
@ -138,7 +138,8 @@ gst_pipeline_typefind (GstPipeline *pipeline, GstElement *element)
|
|||||||
{
|
{
|
||||||
gboolean found = FALSE;
|
gboolean found = FALSE;
|
||||||
GstElement *typefind;
|
GstElement *typefind;
|
||||||
guint16 type_id = 0;
|
GstCaps *caps = NULL;
|
||||||
|
guint type_id = 0;
|
||||||
|
|
||||||
g_print("GstPipeline: typefind for element \"%s\" %p\n",
|
g_print("GstPipeline: typefind for element \"%s\" %p\n",
|
||||||
gst_element_get_name(element), &found);
|
gst_element_get_name(element), &found);
|
||||||
@ -155,7 +156,6 @@ gst_pipeline_typefind (GstPipeline *pipeline, GstElement *element)
|
|||||||
gst_bin_add (GST_BIN (pipeline), typefind);
|
gst_bin_add (GST_BIN (pipeline), typefind);
|
||||||
|
|
||||||
gst_bin_create_plan (GST_BIN (pipeline));
|
gst_bin_create_plan (GST_BIN (pipeline));
|
||||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY);
|
|
||||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
||||||
|
|
||||||
// keep pushing buffers... the have_type signal handler will set the found flag
|
// keep pushing buffers... the have_type signal handler will set the found flag
|
||||||
@ -166,11 +166,11 @@ gst_pipeline_typefind (GstPipeline *pipeline, GstElement *element)
|
|||||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
GstType *type;
|
caps = gst_util_get_pointer_arg (GTK_OBJECT (typefind), "caps");
|
||||||
type_id = gst_util_get_int_arg (GTK_OBJECT (typefind), "type");
|
|
||||||
type = gst_type_find_by_id (type_id);
|
|
||||||
|
|
||||||
gst_pad_set_caps (gst_element_get_pad (element, "src"), gst_caps_new (type->mime));
|
gst_pad_set_caps (gst_element_get_pad (element, "src"), caps);
|
||||||
|
|
||||||
|
type_id = caps->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_pad_disconnect (gst_element_get_pad (element, "src"),
|
gst_pad_disconnect (gst_element_get_pad (element, "src"),
|
||||||
@ -196,16 +196,38 @@ gst_pipeline_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink)
|
|||||||
|
|
||||||
// if we have a match, connect the pads
|
// if we have a match, connect the pads
|
||||||
if (sinkpad->direction == GST_PAD_SINK &&
|
if (sinkpad->direction == GST_PAD_SINK &&
|
||||||
!GST_PAD_CONNECTED(sinkpad) &&
|
!GST_PAD_CONNECTED(sinkpad))
|
||||||
gst_caps_check_compatibility (pad->caps, sinkpad->caps))
|
|
||||||
{
|
{
|
||||||
gst_pad_connect(pad, sinkpad);
|
if (gst_caps_check_compatibility (pad->caps, sinkpad->caps)) {
|
||||||
g_print("gstpipeline: autoconnect pad \"%s\" in element %s <-> ", pad->name,
|
gst_pad_connect(pad, sinkpad);
|
||||||
|
g_print("gstpipeline: autoconnect pad \"%s\" in element %s <-> ", pad->name,
|
||||||
gst_element_get_name(src));
|
gst_element_get_name(src));
|
||||||
g_print("pad \"%s\" in element %s\n", sinkpad->name,
|
g_print("pad \"%s\" in element %s\n", sinkpad->name,
|
||||||
gst_element_get_name(sink));
|
gst_element_get_name(sink));
|
||||||
connected = TRUE;
|
connected = TRUE;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
GList *factories;
|
||||||
|
g_print("gstpipeline: not compatible, find intermediate element\n");
|
||||||
|
|
||||||
|
factories = gst_type_get_sink_to_src (pad->caps->id, sinkpad->caps->id);
|
||||||
|
|
||||||
|
while (factories) {
|
||||||
|
GstElementFactory *factory = (GstElementFactory *)factories->data;
|
||||||
|
GstElement *element = gst_elementfactory_create (factory, factory->name);
|
||||||
|
|
||||||
|
g_print ("gstpipeline: trying element \"%s\"\n", element->name);
|
||||||
|
|
||||||
|
if (gst_pipeline_pads_autoplug_func (src, pad, element)) {
|
||||||
|
if (gst_pipeline_pads_autoplug_func (element, gst_element_get_pad (element, "src"), sink)) {
|
||||||
|
gst_bin_add (gst_object_get_parent (GST_OBJECT(sink)), element);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
factories = g_list_next (factories);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sinkpads = g_list_next(sinkpads);
|
sinkpads = g_list_next(sinkpads);
|
||||||
}
|
}
|
||||||
|
@ -103,12 +103,14 @@ gst_props_register (GstPropsFactory factory)
|
|||||||
|
|
||||||
g_return_val_if_fail (factory != NULL, NULL);
|
g_return_val_if_fail (factory != NULL, NULL);
|
||||||
|
|
||||||
|
tag = factory[i++];
|
||||||
|
|
||||||
|
if (!tag) return NULL;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
props->properties = NULL;
|
props->properties = NULL;
|
||||||
|
|
||||||
tag = factory[i++];
|
|
||||||
|
|
||||||
while (tag) {
|
while (tag) {
|
||||||
GQuark quark;
|
GQuark quark;
|
||||||
|
@ -50,7 +50,7 @@ struct _gst_type_node
|
|||||||
|
|
||||||
typedef struct _gst_type_node gst_type_node;
|
typedef struct _gst_type_node gst_type_node;
|
||||||
|
|
||||||
static gboolean gst_type_typefind_dummy (GstBuffer *buffer, gpointer priv);
|
static GstCaps* gst_type_typefind_dummy (GstBuffer *buffer, gpointer priv);
|
||||||
|
|
||||||
/* we keep a (spase) matrix in the hashtable like:
|
/* we keep a (spase) matrix in the hashtable like:
|
||||||
*
|
*
|
||||||
@ -538,6 +538,14 @@ gst_type_find_cost (gint src, gint dest)
|
|||||||
return MAX_COST;
|
return MAX_COST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GList*
|
||||||
|
gst_type_find_identity (gint typeid)
|
||||||
|
{
|
||||||
|
GstType *type = gst_type_find_by_id (typeid);
|
||||||
|
|
||||||
|
return (GList *)g_hash_table_lookup (type->converters, GUINT_TO_POINTER (typeid));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_type_get_sink_to_src:
|
* gst_type_get_sink_to_src:
|
||||||
* @sinkid: the id of the sink
|
* @sinkid: the id of the sink
|
||||||
@ -558,7 +566,7 @@ gst_type_get_sink_to_src (guint16 sinkid, guint16 srcid)
|
|||||||
g_print ("gsttype: find %d to %d\n", srcid, sinkid);
|
g_print ("gsttype: find %d to %d\n", srcid, sinkid);
|
||||||
if (sinkid == srcid) {
|
if (sinkid == srcid) {
|
||||||
//FIXME return an identity element
|
//FIXME return an identity element
|
||||||
return NULL;
|
return gst_type_find_identity (sinkid);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rgnNodes = g_malloc (sizeof (gst_type_node) * _gst_maxtype);
|
rgnNodes = g_malloc (sizeof (gst_type_node) * _gst_maxtype);
|
||||||
@ -680,7 +688,7 @@ gst_typefactory_save_thyself (GstTypeFactory *factory, xmlNodePtr parent)
|
|||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static GstCaps *
|
||||||
gst_type_typefind_dummy (GstBuffer *buffer, gpointer priv)
|
gst_type_typefind_dummy (GstBuffer *buffer, gpointer priv)
|
||||||
{
|
{
|
||||||
GstType *type = (GstType *)priv;
|
GstType *type = (GstType *)priv;
|
||||||
@ -700,7 +708,8 @@ gst_type_typefind_dummy (GstBuffer *buffer, gpointer priv)
|
|||||||
GstTypeFindFunc func = (GstTypeFindFunc) funcs->data;
|
GstTypeFindFunc func = (GstTypeFindFunc) funcs->data;
|
||||||
|
|
||||||
if (func) {
|
if (func) {
|
||||||
if (func (buffer, type)) return TRUE;
|
GstCaps *res = func (buffer, type);
|
||||||
|
if (res) return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
funcs = g_slist_next (funcs);
|
funcs = g_slist_next (funcs);
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/* type of function used to check a stream for equality with type */
|
/* type of function used to check a stream for equality with type */
|
||||||
typedef gboolean (*GstTypeFindFunc) (GstBuffer *buf,gpointer priv);
|
typedef GstCaps *(*GstTypeFindFunc) (GstBuffer *buf,gpointer priv);
|
||||||
|
|
||||||
typedef struct _GstType GstType;
|
typedef struct _GstType GstType;
|
||||||
typedef struct _GstTypeFactory GstTypeFactory;
|
typedef struct _GstTypeFactory GstTypeFactory;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user