#include "gstcaps.h"
#include "gsttype.h"
+#include "gstpropsprivate.h"
void
_gst_caps_initialize (void)
{
caps = g_new0 (GstCaps, 1);
caps->id = get_type_for_mime (mime);
+ caps->properties = NULL;
return caps;
}
if (fromcaps->id != tocaps->id)
return FALSE;
- if (fromcaps->properties && tocaps->properties) {
- return gst_props_check_compatibility (fromcaps->properties, tocaps->properties);
+ if (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;
}
{
gboolean found = FALSE;
GstElement *typefind;
- guint16 type_id = 0;
+ GstCaps *caps = NULL;
+ guint type_id = 0;
g_print("GstPipeline: typefind for element \"%s\" %p\n",
gst_element_get_name(element), &found);
gst_bin_add (GST_BIN (pipeline), typefind);
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);
// keep pushing buffers... the have_type signal handler will set the found flag
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
if (found) {
- GstType *type;
- type_id = gst_util_get_int_arg (GTK_OBJECT (typefind), "type");
- type = gst_type_find_by_id (type_id);
+ caps = gst_util_get_pointer_arg (GTK_OBJECT (typefind), "caps");
- 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"),
// if we have a match, connect the pads
if (sinkpad->direction == GST_PAD_SINK &&
- !GST_PAD_CONNECTED(sinkpad) &&
- gst_caps_check_compatibility (pad->caps, sinkpad->caps))
+ !GST_PAD_CONNECTED(sinkpad))
{
- gst_pad_connect(pad, sinkpad);
- g_print("gstpipeline: autoconnect pad \"%s\" in element %s <-> ", pad->name,
+ if (gst_caps_check_compatibility (pad->caps, sinkpad->caps)) {
+ gst_pad_connect(pad, sinkpad);
+ g_print("gstpipeline: autoconnect pad \"%s\" in element %s <-> ", pad->name,
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));
- connected = TRUE;
- break;
+ connected = TRUE;
+ 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);
}
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:
*
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:
* @sinkid: the id of the sink
g_print ("gsttype: find %d to %d\n", srcid, sinkid);
if (sinkid == srcid) {
//FIXME return an identity element
- return NULL;
+ return gst_type_find_identity (sinkid);
}
else {
rgnNodes = g_malloc (sizeof (gst_type_node) * _gst_maxtype);
return parent;
}
-static gboolean
+static GstCaps *
gst_type_typefind_dummy (GstBuffer *buffer, gpointer priv)
{
GstType *type = (GstType *)priv;
GstTypeFindFunc func = (GstTypeFindFunc) funcs->data;
if (func) {
- if (func (buffer, type)) return TRUE;
+ GstCaps *res = func (buffer, type);
+ if (res) return res;
}
funcs = g_slist_next (funcs);