+2003-12-29 David Schleef <ds@schleef.org>
+
+ * gst/gstcaps.c: (gst_caps_normalize), (simplify_foreach),
+ (gst_caps_structure_simplify), (gst_caps_simplify):
+ * gst/gstcaps.h:
+ Add simplify function
+ * gst/gstpad.c: (gst_pad_link_try), (gst_pad_try_set_caps),
+ (gst_pad_perform_negotiate), (gst_pad_is_negotiated):
+ * gst/gstpad.h:
+ Copy over srcnotify, sinknotify when calling old pad_link
+ functions. Add new is_negotiated() function.
+ * gst/gststructure.c: (gst_structure_copy):
+ Fix an incredibly stupid bug that should have been noticed
+ weeks ago. _copy() returned the argument, not the new copy.
+
2003-12-27 Benjamin Otte <in7y118@public.uni-hamburg.de>
* gst/gstcaps.c: (gst_caps_append):
GstCaps *gst_caps_normalize (const GstCaps *caps)
{
+ g_critical ("unimplemented");
return NULL;
}
+static gboolean
+simplify_foreach (GQuark field_id, GValue *value, gpointer user_data)
+{
+ GstStructure *s2 = (GstStructure *) user_data;
+ const GValue *v2;
+
+ v2 = gst_structure_id_get_value (s2, field_id);
+ if (v2 == NULL) return FALSE;
+
+ if (gst_value_compare (value, v2) == GST_VALUE_EQUAL) return TRUE;
+ return FALSE;
+}
+
+static gboolean
+gst_caps_structure_simplify (GstStructure *struct1, const GstStructure *struct2)
+{
+ /* FIXME this is just a simple compare. Better would be to merge
+ * the two structures */
+ if (struct1->name != struct2->name) return FALSE;
+ if (struct1->fields->len != struct2->fields->len) return FALSE;
+
+ return gst_structure_foreach (struct1, simplify_foreach, (void *)struct2);
+}
+
+GstCaps *gst_caps_simplify (const GstCaps *caps)
+{
+ int i;
+ int j;
+ GstCaps *newcaps;
+ GstStructure *structure;
+ GstStructure *struct2;
+
+ if (gst_caps_get_size (caps) < 2) {
+ return gst_caps_copy (caps);
+ }
+
+ newcaps = gst_caps_new_empty ();
+
+ for(i=0;i<gst_caps_get_size (caps);i++){
+ structure = gst_caps_get_structure (caps, i);
+
+ for(j=0;j<gst_caps_get_size (newcaps);j++){
+ struct2 = gst_caps_get_structure (caps, i);
+ if (gst_caps_structure_simplify (struct2, structure)) {
+ break;
+ }
+ }
+ if (j==gst_caps_get_size (newcaps)) {
+ gst_caps_append_structure (newcaps, gst_structure_copy(structure));
+ }
+ }
+
+ return newcaps;
+}
+
#ifndef GST_DISABLE_LOADSAVE
xmlNodePtr gst_caps_save_thyself (const GstCaps *caps, xmlNodePtr parent)
{
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);
+GstCaps *gst_caps_simplify (const GstCaps *caps);
#ifndef GST_DISABLE_LOADSAVE
xmlNodePtr gst_caps_save_thyself (const GstCaps *caps, xmlNodePtr parent);
ret = gst_pad_link_negotiate (link);
if (ret == GST_PAD_LINK_REFUSED) {
+ oldlink->srcnotify = link->srcnotify;
+ oldlink->sinknotify = link->sinknotify;
if (oldlink && oldlink->caps && !gst_pad_link_call_link_functions (oldlink))
g_warning ("pads don't accept old caps. We assume they did though");
gst_pad_link_free (link);
gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps)
{
GstPadLink *link;
+ GstPadLinkReturn ret;
g_return_val_if_fail (pad != NULL, GST_PAD_LINK_REFUSED);
g_return_val_if_fail (GST_IS_PAD (pad), GST_PAD_LINK_REFUSED);
link->sinknotify = FALSE;
}
- return gst_pad_link_try (link);
+ ret = gst_pad_link_try (link);
+
+ return ret;
}
gboolean
gst_pad_perform_negotiate (GstPad *srcpad, GstPad *sinkpad)
{
- return gst_pad_renegotiate (srcpad) >= 0;
+ return GST_PAD_LINK_SUCCESSFUL (gst_pad_renegotiate (srcpad));
}
void
}
/**
+ * gst_pad_is_negotiated:
+ * @pad: a #GstPad to get the negotiation status of
+ *
+ * Returns: TRUE if the pad has successfully negotiated caps.
+ */
+gboolean
+gst_pad_is_negotiated (GstPad *pad)
+{
+ g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
+
+ if (!GST_PAD_REALIZE (pad))
+ return FALSE;
+ if (!GST_RPAD_LINK (pad))
+ return FALSE;
+
+ return (GST_RPAD_LINK (pad)->caps != NULL);
+}
+
+/**
* gst_pad_get_negotiated_caps:
* @pad: a #GstPad to get the negotiated capabilites of
*
/* capsnego functions */
G_CONST_RETURN GstCaps* gst_pad_get_negotiated_caps (GstPad *pad);
+gboolean gst_pad_is_negotiated (GstPad *pad);
GstCaps* gst_pad_get_caps (GstPad *pad);
G_CONST_RETURN GstCaps* gst_pad_get_pad_template_caps (GstPad *pad);
GstPadLinkReturn gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps);
g_return_val_if_fail(structure != NULL, NULL);
new_structure = gst_structure_empty_new(g_quark_to_string(structure->name));
- new_structure->fields = g_array_set_size(new_structure->fields,
- structure->fields->len);
new_structure->name = structure->name;
for(i=0;i<structure->fields->len;i++){
g_array_append_val(new_structure->fields, new_field);
}
- return structure;
+ return new_structure;
}
/**