mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
gst/gstcaps.*: Add simplify function
Original commit message from CVS: * 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.
This commit is contained in:
parent
abe422b141
commit
cd1d72deb2
6 changed files with 100 additions and 5 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
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>
|
2003-12-27 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||||
|
|
||||||
* gst/gstcaps.c: (gst_caps_append):
|
* gst/gstcaps.c: (gst_caps_append):
|
||||||
|
|
|
@ -568,10 +568,66 @@ GstCaps *gst_caps_union (const GstCaps *caps1, const GstCaps *caps2)
|
||||||
|
|
||||||
GstCaps *gst_caps_normalize (const GstCaps *caps)
|
GstCaps *gst_caps_normalize (const GstCaps *caps)
|
||||||
{
|
{
|
||||||
|
g_critical ("unimplemented");
|
||||||
|
|
||||||
return NULL;
|
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
|
#ifndef GST_DISABLE_LOADSAVE
|
||||||
xmlNodePtr gst_caps_save_thyself (const GstCaps *caps, xmlNodePtr parent)
|
xmlNodePtr gst_caps_save_thyself (const GstCaps *caps, xmlNodePtr parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -101,6 +101,7 @@ gboolean gst_caps_is_always_compatible (const GstCaps *caps1,
|
||||||
GstCaps *gst_caps_intersect (const GstCaps *caps1, const GstCaps *caps2);
|
GstCaps *gst_caps_intersect (const GstCaps *caps1, const GstCaps *caps2);
|
||||||
GstCaps *gst_caps_union (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_normalize (const GstCaps *caps);
|
||||||
|
GstCaps *gst_caps_simplify (const GstCaps *caps);
|
||||||
|
|
||||||
#ifndef GST_DISABLE_LOADSAVE
|
#ifndef GST_DISABLE_LOADSAVE
|
||||||
xmlNodePtr gst_caps_save_thyself (const GstCaps *caps, xmlNodePtr parent);
|
xmlNodePtr gst_caps_save_thyself (const GstCaps *caps, xmlNodePtr parent);
|
||||||
|
|
28
gst/gstpad.c
28
gst/gstpad.c
|
@ -1205,6 +1205,8 @@ gst_pad_link_try (GstPadLink *link)
|
||||||
|
|
||||||
ret = gst_pad_link_negotiate (link);
|
ret = gst_pad_link_negotiate (link);
|
||||||
if (ret == GST_PAD_LINK_REFUSED) {
|
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))
|
if (oldlink && oldlink->caps && !gst_pad_link_call_link_functions (oldlink))
|
||||||
g_warning ("pads don't accept old caps. We assume they did though");
|
g_warning ("pads don't accept old caps. We assume they did though");
|
||||||
gst_pad_link_free (link);
|
gst_pad_link_free (link);
|
||||||
|
@ -1257,6 +1259,7 @@ GstPadLinkReturn
|
||||||
gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps)
|
gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps)
|
||||||
{
|
{
|
||||||
GstPadLink *link;
|
GstPadLink *link;
|
||||||
|
GstPadLinkReturn ret;
|
||||||
|
|
||||||
g_return_val_if_fail (pad != NULL, GST_PAD_LINK_REFUSED);
|
g_return_val_if_fail (pad != NULL, GST_PAD_LINK_REFUSED);
|
||||||
g_return_val_if_fail (GST_IS_PAD (pad), GST_PAD_LINK_REFUSED);
|
g_return_val_if_fail (GST_IS_PAD (pad), GST_PAD_LINK_REFUSED);
|
||||||
|
@ -1306,7 +1309,9 @@ gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps)
|
||||||
link->sinknotify = FALSE;
|
link->sinknotify = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return gst_pad_link_try (link);
|
ret = gst_pad_link_try (link);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1829,7 +1834,7 @@ _gst_pad_default_fixate_func (GstPad *pad, GstCaps *caps, gpointer unused)
|
||||||
gboolean
|
gboolean
|
||||||
gst_pad_perform_negotiate (GstPad *srcpad, GstPad *sinkpad)
|
gst_pad_perform_negotiate (GstPad *srcpad, GstPad *sinkpad)
|
||||||
{
|
{
|
||||||
return gst_pad_renegotiate (srcpad) >= 0;
|
return GST_PAD_LINK_SUCCESSFUL (gst_pad_renegotiate (srcpad));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2020,6 +2025,25 @@ gst_pad_proxy_link (GstPad *pad, const GstCaps *caps)
|
||||||
return gst_pad_try_set_caps (pad, caps);
|
return gst_pad_try_set_caps (pad, caps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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:
|
* gst_pad_get_negotiated_caps:
|
||||||
* @pad: a #GstPad to get the negotiated capabilites of
|
* @pad: a #GstPad to get the negotiated capabilites of
|
||||||
|
|
|
@ -402,6 +402,7 @@ GstPad* gst_pad_get_peer (GstPad *pad);
|
||||||
|
|
||||||
/* capsnego functions */
|
/* capsnego functions */
|
||||||
G_CONST_RETURN GstCaps* gst_pad_get_negotiated_caps (GstPad *pad);
|
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);
|
GstCaps* gst_pad_get_caps (GstPad *pad);
|
||||||
G_CONST_RETURN GstCaps* gst_pad_get_pad_template_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);
|
GstPadLinkReturn gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps);
|
||||||
|
|
|
@ -211,8 +211,6 @@ GstStructure *gst_structure_copy(GstStructure *structure)
|
||||||
g_return_val_if_fail(structure != NULL, NULL);
|
g_return_val_if_fail(structure != NULL, NULL);
|
||||||
|
|
||||||
new_structure = gst_structure_empty_new(g_quark_to_string(structure->name));
|
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;
|
new_structure->name = structure->name;
|
||||||
|
|
||||||
for(i=0;i<structure->fields->len;i++){
|
for(i=0;i<structure->fields->len;i++){
|
||||||
|
@ -225,7 +223,7 @@ GstStructure *gst_structure_copy(GstStructure *structure)
|
||||||
g_array_append_val(new_structure->fields, new_field);
|
g_array_append_val(new_structure->fields, new_field);
|
||||||
}
|
}
|
||||||
|
|
||||||
return structure;
|
return new_structure;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue