mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 17:51:16 +00:00
revert preferred caps
Original commit message from CVS: revert preferred caps
This commit is contained in:
parent
d2f7218664
commit
3cd8266b12
6 changed files with 16 additions and 301 deletions
|
@ -1,3 +1,11 @@
|
|||
2004-09-26 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* docs/gst/gstreamer-sections.txt:
|
||||
* gst/gstcaps.c:
|
||||
* gst/gstcaps.h:
|
||||
* gst/gstpad.c:
|
||||
Revert preferred caps: (#147789)
|
||||
|
||||
2004-09-19 Steve Lhomme <steve.lhomme@free.fr>
|
||||
|
||||
* win32/dirent.c:
|
||||
|
|
|
@ -142,7 +142,6 @@ GST_CAPS_IS_SIMPLE
|
|||
gst_caps_is_simple
|
||||
GST_DEBUG_CAPS
|
||||
GST_STATIC_CAPS
|
||||
GST_STATIC_CAPS_PREFERRED
|
||||
GstCaps
|
||||
GstStaticCaps
|
||||
gst_caps_new_empty
|
||||
|
@ -182,9 +181,6 @@ gst_caps_from_string
|
|||
gst_caps_structure_fixate_field_nearest_int
|
||||
gst_caps_structure_fixate_field_nearest_double
|
||||
gst_caps_subtract
|
||||
gst_caps_get_preferred
|
||||
gst_caps_set_preferred
|
||||
gst_caps_use_preferred
|
||||
<SUBSECTION Standard>
|
||||
GST_CAPS
|
||||
GST_IS_CAPS
|
||||
|
|
|
@ -90,15 +90,6 @@ templates.
|
|||
@Returns: a new #GstCaps instance
|
||||
|
||||
|
||||
<!-- ##### MACRO GST_STATIC_CAPS_PREFERRED ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@string:
|
||||
@preferred:
|
||||
|
||||
|
||||
<!-- ##### STRUCT GstCaps ##### -->
|
||||
<para>
|
||||
|
||||
|
@ -107,7 +98,6 @@ templates.
|
|||
@type:
|
||||
@flags:
|
||||
@structs:
|
||||
@preferred:
|
||||
@_gst_reserved:
|
||||
|
||||
<!-- ##### STRUCT GstStaticCaps ##### -->
|
||||
|
@ -117,7 +107,6 @@ templates.
|
|||
|
||||
@caps:
|
||||
@string:
|
||||
@preferred:
|
||||
@_gst_reserved:
|
||||
|
||||
<!-- ##### FUNCTION gst_caps_new_empty ##### -->
|
||||
|
@ -473,30 +462,3 @@ templates.
|
|||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gst_caps_get_preferred ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@caps:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gst_caps_set_preferred ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@caps:
|
||||
@structure:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gst_caps_use_preferred ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@caps:
|
||||
@Returns:
|
||||
|
||||
|
||||
|
|
136
gst/gstcaps.c
136
gst/gstcaps.c
|
@ -210,10 +210,6 @@ gst_caps_copy (const GstCaps * caps)
|
|||
gst_caps_append_structure (newcaps, gst_structure_copy (structure));
|
||||
}
|
||||
|
||||
if (caps->preferred) {
|
||||
newcaps->preferred = gst_structure_copy (caps->preferred);
|
||||
}
|
||||
|
||||
return newcaps;
|
||||
}
|
||||
|
||||
|
@ -232,9 +228,6 @@ gst_caps_free (GstCaps * caps)
|
|||
|
||||
g_return_if_fail (GST_IS_CAPS (caps));
|
||||
|
||||
if (caps->preferred) {
|
||||
gst_structure_free (caps->preferred);
|
||||
}
|
||||
for (i = 0; i < caps->structs->len; i++) {
|
||||
structure = gst_caps_get_structure (caps, i);
|
||||
gst_structure_free (structure);
|
||||
|
@ -309,15 +302,6 @@ gst_caps_append (GstCaps * caps1, GstCaps * caps2)
|
|||
gst_caps_append_structure (caps1, structure);
|
||||
}
|
||||
}
|
||||
|
||||
if (caps2->preferred) {
|
||||
if (caps1->preferred) {
|
||||
gst_structure_free (caps2->preferred);
|
||||
} else {
|
||||
caps1->preferred = caps2->preferred;
|
||||
}
|
||||
}
|
||||
|
||||
g_ptr_array_free (caps2->structs, TRUE);
|
||||
#ifdef USE_POISONING
|
||||
memset (caps2, 0xff, sizeof (GstCaps));
|
||||
|
@ -458,10 +442,6 @@ gst_caps_copy_1 (const GstCaps * caps)
|
|||
gst_caps_append_structure (newcaps, gst_structure_copy (structure));
|
||||
}
|
||||
|
||||
if (caps->preferred) {
|
||||
newcaps->preferred = gst_structure_copy (caps->preferred);
|
||||
}
|
||||
|
||||
return newcaps;
|
||||
}
|
||||
|
||||
|
@ -869,12 +849,6 @@ gst_caps_intersect (const GstCaps * caps1, const GstCaps * caps2)
|
|||
}
|
||||
}
|
||||
|
||||
if (caps1->preferred) {
|
||||
dest->preferred = gst_structure_copy (caps1->preferred);
|
||||
} else if (caps2->preferred) {
|
||||
dest->preferred = gst_structure_copy (caps2->preferred);
|
||||
}
|
||||
|
||||
gst_caps_do_simplify (dest);
|
||||
return dest;
|
||||
}
|
||||
|
@ -1036,12 +1010,6 @@ gst_caps_union (const GstCaps * caps1, const GstCaps * caps2)
|
|||
dest2 = gst_caps_copy (caps2);
|
||||
gst_caps_append (dest1, dest2);
|
||||
|
||||
if (caps1->preferred) {
|
||||
dest1->preferred = gst_structure_copy (caps1->preferred);
|
||||
} else if (caps2->preferred) {
|
||||
dest1->preferred = gst_structure_copy (caps2->preferred);
|
||||
}
|
||||
|
||||
gst_caps_do_simplify (dest1);
|
||||
return dest1;
|
||||
}
|
||||
|
@ -1644,107 +1612,3 @@ gst_caps_structure_fixate_field_nearest_double (GstStructure * structure,
|
|||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
const GstStructure *
|
||||
gst_caps_get_preferred (const GstCaps * caps)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
|
||||
|
||||
return caps->preferred;
|
||||
}
|
||||
|
||||
void
|
||||
gst_caps_set_preferred (GstCaps * caps, const GstStructure * structure)
|
||||
{
|
||||
g_return_if_fail (GST_IS_CAPS (caps));
|
||||
g_return_if_fail (GST_IS_STRUCTURE (structure));
|
||||
|
||||
if (caps->preferred)
|
||||
gst_structure_free (caps->preferred);
|
||||
caps->preferred = gst_structure_copy (structure);
|
||||
}
|
||||
|
||||
GstStructure *
|
||||
gst_caps_get_structure_by_id (const GstCaps * caps, GQuark id)
|
||||
{
|
||||
int i;
|
||||
GstStructure *structure;
|
||||
|
||||
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
|
||||
|
||||
for (i = 0; i < gst_caps_get_size (caps); i++) {
|
||||
structure = gst_caps_get_structure (caps, i);
|
||||
if (structure->name == id) {
|
||||
return structure;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_caps_prefer_foreach (GQuark name, GValue * value, gpointer user_data)
|
||||
{
|
||||
GstStructure *structure = (GstStructure *) user_data;
|
||||
const GValue *svalue;
|
||||
GValue ivalue = { 0 };
|
||||
gboolean ret;
|
||||
|
||||
svalue = gst_structure_id_get_value (structure, name);
|
||||
if (svalue == NULL)
|
||||
return TRUE;
|
||||
|
||||
if (G_VALUE_TYPE (value) == G_TYPE_INT) {
|
||||
int target = g_value_get_int (value);
|
||||
|
||||
gst_caps_structure_fixate_field_nearest_int (structure,
|
||||
g_quark_to_string (name), target);
|
||||
} else if (G_VALUE_TYPE (value) == G_TYPE_DOUBLE) {
|
||||
double target = g_value_get_double (value);
|
||||
|
||||
gst_caps_structure_fixate_field_nearest_double (structure,
|
||||
g_quark_to_string (name), target);
|
||||
} else {
|
||||
ret = gst_value_intersect (&ivalue, value, svalue);
|
||||
if (ret) {
|
||||
gst_structure_id_set_value (structure, name, &ivalue);
|
||||
g_value_unset (&ivalue);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GstCaps *
|
||||
gst_caps_use_preferred (const GstCaps * caps)
|
||||
{
|
||||
GstCaps *pcaps;
|
||||
GstStructure *structure;
|
||||
|
||||
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
|
||||
|
||||
if (!caps->preferred || gst_caps_is_any (caps) || gst_caps_is_empty (caps)
|
||||
|| gst_caps_is_fixed (caps)) {
|
||||
return gst_caps_copy (caps);
|
||||
}
|
||||
|
||||
if (gst_caps_is_simple (caps)) {
|
||||
structure = gst_caps_get_structure (caps, 0);
|
||||
} else {
|
||||
structure = gst_caps_get_structure_by_id (caps, caps->preferred->name);
|
||||
}
|
||||
|
||||
if (structure) {
|
||||
structure = gst_structure_copy (structure);
|
||||
|
||||
gst_structure_foreach (caps->preferred, gst_caps_prefer_foreach, structure);
|
||||
|
||||
pcaps = gst_caps_new_full (structure, NULL);
|
||||
|
||||
return pcaps;
|
||||
}
|
||||
|
||||
/* FIXME */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_CAPS (gst_caps_get_type())
|
||||
#define GST_CAPS(object) ((GstCaps*)(object))
|
||||
#define GST_CAPS(object) ((GstCaps*)object)
|
||||
#define GST_IS_CAPS(object) ((object) && (GST_CAPS(object)->type == GST_TYPE_CAPS))
|
||||
|
||||
#define GST_CAPS_FLAGS_ANY (1 << 0)
|
||||
|
@ -51,13 +51,6 @@ G_BEGIN_DECLS
|
|||
/* string */ string, \
|
||||
}
|
||||
|
||||
#define GST_STATIC_CAPS_PREFERRED(string, preferred) \
|
||||
{ \
|
||||
/* caps */ { 0 }, \
|
||||
/* string */ string, \
|
||||
/* preferred */ preferred, \
|
||||
}
|
||||
|
||||
typedef struct _GstCaps GstCaps;
|
||||
typedef struct _GstStaticCaps GstStaticCaps;
|
||||
|
||||
|
@ -66,17 +59,14 @@ struct _GstCaps {
|
|||
|
||||
guint16 flags;
|
||||
GPtrArray *structs;
|
||||
GstStructure *preferred;
|
||||
|
||||
gpointer _gst_reserved[GST_PADDING - 1];
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
struct _GstStaticCaps {
|
||||
GstCaps caps;
|
||||
const char *string;
|
||||
const char *preferred;
|
||||
|
||||
gpointer _gst_reserved[GST_PADDING - 1];
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
GType gst_caps_get_type (void) G_GNUC_CONST;
|
||||
|
@ -159,12 +149,6 @@ gboolean gst_caps_structure_fixate_field_nearest_double (GstStru
|
|||
const char *field_name,
|
||||
double target);
|
||||
|
||||
const GstStructure * gst_caps_get_preferred (const GstCaps *caps);
|
||||
void gst_caps_set_preferred (GstCaps *caps,
|
||||
const GstStructure *structure);
|
||||
GstCaps * gst_caps_use_preferred (const GstCaps *caps);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_CAPS_H__ */
|
||||
|
|
109
gst/gstpad.c
109
gst/gstpad.c
|
@ -1149,61 +1149,20 @@ gst_pad_link_ready_for_negotiation (GstPadLink * link)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static const GstStructure *
|
||||
gst_pad_link_get_preferred (GstPadLink * link)
|
||||
{
|
||||
const GstStructure *pref;
|
||||
|
||||
if (link->filtercaps) {
|
||||
pref = gst_caps_get_preferred (link->filtercaps);
|
||||
if (pref)
|
||||
return pref;
|
||||
}
|
||||
|
||||
if (link->srccaps) {
|
||||
pref = gst_caps_get_preferred (link->srccaps);
|
||||
if (pref)
|
||||
return pref;
|
||||
}
|
||||
|
||||
if (link->sinkcaps) {
|
||||
pref = gst_caps_get_preferred (link->sinkcaps);
|
||||
if (pref)
|
||||
return pref;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pad_link_fixate (GstPadLink * link)
|
||||
{
|
||||
GstCaps *caps;
|
||||
GstCaps *newcaps;
|
||||
const GstStructure *pref;
|
||||
|
||||
caps = link->caps;
|
||||
|
||||
g_return_if_fail (caps != NULL);
|
||||
g_return_if_fail (!gst_caps_is_empty (caps));
|
||||
|
||||
gst_caps_do_simplify (caps);
|
||||
|
||||
pref = gst_pad_link_get_preferred (link);
|
||||
GST_DEBUG ("link had preferred format %" GST_PTR_FORMAT, pref);
|
||||
if (pref) {
|
||||
GstCaps *caps2;
|
||||
|
||||
gst_caps_set_preferred (caps, pref);
|
||||
caps2 = gst_caps_use_preferred (caps);
|
||||
GST_DEBUG ("using preferred format %" GST_PTR_FORMAT, caps2);
|
||||
if (caps2) {
|
||||
gst_caps_free (caps);
|
||||
caps = caps2;
|
||||
}
|
||||
}
|
||||
|
||||
GST_DEBUG ("trying to fixate caps %" GST_PTR_FORMAT, caps);
|
||||
|
||||
gst_caps_do_simplify (caps);
|
||||
while (!gst_caps_is_fixed (caps)) {
|
||||
int i;
|
||||
|
||||
|
@ -1346,8 +1305,6 @@ gst_pad_link_call_link_functions (GstPadLink * link)
|
|||
}
|
||||
}
|
||||
|
||||
g_assert (GST_IS_PAD (link->srcpad));
|
||||
g_assert (GST_IS_PAD (link->sinkpad));
|
||||
GST_FLAG_UNSET (link->srcpad, GST_PAD_NEGOTIATING);
|
||||
GST_FLAG_UNSET (link->sinkpad, GST_PAD_NEGOTIATING);
|
||||
return res;
|
||||
|
@ -1478,8 +1435,8 @@ gst_pad_renegotiate (GstPad * pad)
|
|||
|
||||
link = gst_pad_link_new ();
|
||||
|
||||
link->srcpad = GST_PAD (GST_PAD_REALIZE (GST_PAD_LINK_SRC (pad)));
|
||||
link->sinkpad = GST_PAD (GST_PAD_REALIZE (GST_PAD_LINK_SINK (pad)));
|
||||
link->srcpad = GST_PAD_LINK_SRC (pad);
|
||||
link->sinkpad = GST_PAD_LINK_SINK (pad);
|
||||
|
||||
if (!gst_pad_link_ready_for_negotiation (link)) {
|
||||
gst_pad_link_free (link);
|
||||
|
@ -2643,52 +2600,6 @@ gst_pad_get_negotiated_caps (GstPad * pad)
|
|||
return GST_RPAD_LINK (pad)->caps;
|
||||
}
|
||||
|
||||
static GstStructure *
|
||||
gst_pad_guess_preferred (GstPad * pad, const GstCaps * caps)
|
||||
{
|
||||
GstCaps *prefcaps;
|
||||
GstStructure *pref = NULL;
|
||||
|
||||
if (caps->preferred != NULL)
|
||||
return NULL;
|
||||
if (GST_RPAD_FIXATEFUNC (pad) == NULL)
|
||||
return NULL;
|
||||
|
||||
GST_DEBUG ("guessing preferred format of %" GST_PTR_FORMAT, caps);
|
||||
prefcaps = gst_caps_copy (caps);
|
||||
|
||||
/* help things along a bit */
|
||||
if (!gst_caps_is_simple (prefcaps)) {
|
||||
GstCaps *newpref;
|
||||
|
||||
newpref =
|
||||
gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (caps,
|
||||
0)), NULL);
|
||||
gst_caps_free (prefcaps);
|
||||
prefcaps = newpref;
|
||||
}
|
||||
|
||||
while (!gst_caps_is_fixed (prefcaps)) {
|
||||
GstCaps *newpref;
|
||||
|
||||
newpref = GST_RPAD_FIXATEFUNC (pad) (pad, prefcaps);
|
||||
GST_DEBUG ("fixated to %" GST_PTR_FORMAT, newpref);
|
||||
if (newpref) {
|
||||
gst_caps_free (prefcaps);
|
||||
prefcaps = newpref;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (gst_caps_is_fixed (prefcaps)) {
|
||||
pref = gst_structure_copy (gst_caps_get_structure (prefcaps, 0));
|
||||
}
|
||||
|
||||
gst_caps_free (prefcaps);
|
||||
return pref;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_get_caps:
|
||||
* @pad: a #GstPad to get the capabilities of.
|
||||
|
@ -2749,16 +2660,6 @@ gst_pad_get_caps (GstPad * pad)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (caps->preferred == NULL && GST_RPAD_FIXATEFUNC (pad)) {
|
||||
GstStructure *pref;
|
||||
|
||||
pref = gst_pad_guess_preferred (pad, caps);
|
||||
if (pref) {
|
||||
gst_caps_set_preferred (caps, pref);
|
||||
}
|
||||
}
|
||||
|
||||
return caps;
|
||||
}
|
||||
}
|
||||
|
@ -3298,7 +3199,7 @@ gst_pad_push (GstPad * pad, GstData * data)
|
|||
if (!GST_IS_EVENT (data) && !GST_PAD_IS_ACTIVE (peer)) {
|
||||
g_warning ("push on peer of pad %s:%s but peer is not active",
|
||||
GST_DEBUG_PAD_NAME (pad));
|
||||
//return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (peer->chainhandler) {
|
||||
|
|
Loading…
Reference in a new issue