mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-23 17:14:23 +00:00
- further productizing the fixed flag on GstCaps by using the flag on
Original commit message from CVS: - further productizing the fixed flag on GstCaps by using the flag on GstProps instead of keeping the two in sync. - implemented proper flag updates in _props_set and _props_remove.
This commit is contained in:
parent
20ada53580
commit
024c51c559
4 changed files with 102 additions and 48 deletions
|
@ -253,7 +253,7 @@ gst_caps_new_id (const gchar *name, const guint16 id, GstProps *props)
|
||||||
gst_alloc_trace_new (_gst_caps_trace, caps);
|
gst_alloc_trace_new (_gst_caps_trace, caps);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GST_DEBUG (GST_CAT_CAPS, "new %p", caps);
|
GST_DEBUG (GST_CAT_CAPS, "new %p, props %p", caps, props);
|
||||||
|
|
||||||
gst_props_ref (props);
|
gst_props_ref (props);
|
||||||
gst_props_sink (props);
|
gst_props_sink (props);
|
||||||
|
@ -265,11 +265,6 @@ gst_caps_new_id (const gchar *name, const guint16 id, GstProps *props)
|
||||||
caps->refcount = 1;
|
caps->refcount = 1;
|
||||||
GST_CAPS_FLAG_SET (caps, GST_CAPS_FLOATING);
|
GST_CAPS_FLAG_SET (caps, GST_CAPS_FLOATING);
|
||||||
|
|
||||||
if (props && !GST_PROPS_IS_FIXED (props))
|
|
||||||
GST_CAPS_FLAG_UNSET (caps, GST_CAPS_FIXED);
|
|
||||||
else
|
|
||||||
GST_CAPS_FLAG_SET (caps, GST_CAPS_FIXED);
|
|
||||||
|
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,10 +343,7 @@ void
|
||||||
gst_caps_debug (GstCaps *caps, const gchar *label)
|
gst_caps_debug (GstCaps *caps, const gchar *label)
|
||||||
{
|
{
|
||||||
GST_DEBUG_ENTER ("caps debug: %s", label);
|
GST_DEBUG_ENTER ("caps debug: %s", label);
|
||||||
if (caps && caps->refcount == 0) {
|
|
||||||
g_warning ("Warning: refcount of caps %s is 0", label);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (caps) {
|
while (caps) {
|
||||||
GST_DEBUG (GST_CAT_CAPS, "caps: %p %s %s (%sfixed) (refcount %d) %s",
|
GST_DEBUG (GST_CAT_CAPS, "caps: %p %s %s (%sfixed) (refcount %d) %s",
|
||||||
caps, caps->name, gst_caps_get_mime (caps),
|
caps, caps->name, gst_caps_get_mime (caps),
|
||||||
|
@ -645,11 +637,6 @@ gst_caps_set_props (GstCaps *caps, GstProps *props)
|
||||||
|
|
||||||
gst_props_replace_sink (&caps->properties, props);
|
gst_props_replace_sink (&caps->properties, props);
|
||||||
|
|
||||||
if (props && !GST_PROPS_IS_FIXED (props))
|
|
||||||
GST_CAPS_FLAG_UNSET (caps, GST_CAPS_FIXED);
|
|
||||||
else
|
|
||||||
GST_CAPS_FLAG_SET (caps, GST_CAPS_FIXED);
|
|
||||||
|
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1078,7 +1065,6 @@ gst_caps_load_thyself (xmlNodePtr parent)
|
||||||
xmlNodePtr subfield = field->xmlChildrenNode;
|
xmlNodePtr subfield = field->xmlChildrenNode;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
gchar *content;
|
gchar *content;
|
||||||
GstCapsFlags fixed = GST_CAPS_FIXED;
|
|
||||||
|
|
||||||
caps = gst_mem_chunk_alloc0 (_gst_caps_chunk);
|
caps = gst_mem_chunk_alloc0 (_gst_caps_chunk);
|
||||||
#ifndef GST_DISABLE_TRACE
|
#ifndef GST_DISABLE_TRACE
|
||||||
|
@ -1104,13 +1090,10 @@ gst_caps_load_thyself (xmlNodePtr parent)
|
||||||
gst_props_ref (props);
|
gst_props_ref (props);
|
||||||
gst_props_sink (props);
|
gst_props_sink (props);
|
||||||
caps->properties = props;
|
caps->properties = props;
|
||||||
|
|
||||||
fixed &= (GST_PROPS_IS_FIXED (caps->properties) ? GST_CAPS_FIXED : 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
subfield = subfield->next;
|
subfield = subfield->next;
|
||||||
}
|
}
|
||||||
GST_CAPS_FLAG_SET (caps, fixed);
|
|
||||||
|
|
||||||
result = gst_caps_append (result, caps);
|
result = gst_caps_append (result, caps);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,23 +37,24 @@ extern GType _gst_caps_type;
|
||||||
#define GST_TYPE_CAPS (_gst_caps_type)
|
#define GST_TYPE_CAPS (_gst_caps_type)
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GST_CAPS_FIXED = (1 << 0), /* caps has no variable properties */
|
GST_CAPS_UNUSED = (1 << 0), /* unused flag */
|
||||||
GST_CAPS_FLOATING = (1 << 1) /* caps is floating */
|
GST_CAPS_FLOATING = (1 << 1) /* caps is floating */
|
||||||
} GstCapsFlags;
|
} GstCapsFlags;
|
||||||
|
|
||||||
#define GST_CAPS(caps) ((GstCaps *)(caps))
|
#define GST_CAPS(caps) ((GstCaps *)(caps))
|
||||||
|
|
||||||
#define GST_CAPS_FLAGS(caps) ((caps)->flags)
|
#define GST_CAPS_FLAGS(caps) ((caps)->flags)
|
||||||
#define GST_CAPS_FLAG_IS_SET(caps,flag) (GST_CAPS_FLAGS (caps) & flag)
|
#define GST_CAPS_FLAG_IS_SET(caps,flag) (GST_CAPS_FLAGS (caps) & (flag))
|
||||||
#define GST_CAPS_FLAG_SET(caps,flag) (GST_CAPS_FLAGS (caps) |= (flag))
|
#define GST_CAPS_FLAG_SET(caps,flag) (GST_CAPS_FLAGS (caps) |= (flag))
|
||||||
#define GST_CAPS_FLAG_UNSET(caps,flag) (GST_CAPS_FLAGS (caps) &= ~(flag))
|
#define GST_CAPS_FLAG_UNSET(caps,flag) (GST_CAPS_FLAGS (caps) &= ~(flag))
|
||||||
|
|
||||||
#define GST_CAPS_REFCOUNT(caps) ((caps)->refcount)
|
#define GST_CAPS_REFCOUNT(caps) ((caps)->refcount)
|
||||||
#define GST_CAPS_PROPERTIES(caps) ((caps)->properties)
|
#define GST_CAPS_PROPERTIES(caps) ((caps)->properties)
|
||||||
#define GST_CAPS_NEXT(caps) ((caps)->next)
|
#define GST_CAPS_NEXT(caps) ((caps)->next)
|
||||||
|
|
||||||
#define GST_CAPS_IS_FIXED(caps) (GST_CAPS_FLAGS (caps) & GST_CAPS_FIXED)
|
#define GST_CAPS_IS_FIXED(caps) (((caps)->properties == NULL) || \
|
||||||
#define GST_CAPS_IS_FLOATING(caps) (GST_CAPS_FLAGS (caps) & GST_CAPS_FLOATING)
|
(GST_PROPS_IS_FIXED ((caps)->properties)))
|
||||||
|
#define GST_CAPS_IS_FLOATING(caps) (GST_CAPS_FLAG_IS_SET ((caps), GST_CAPS_FLOATING))
|
||||||
#define GST_CAPS_IS_CHAINED(caps) (GST_CAPS_NEXT (caps) != NULL)
|
#define GST_CAPS_IS_CHAINED(caps) (GST_CAPS_NEXT (caps) != NULL)
|
||||||
|
|
||||||
struct _GstCaps {
|
struct _GstCaps {
|
||||||
|
|
110
gst/gstprops.c
110
gst/gstprops.c
|
@ -865,12 +865,44 @@ gst_props_add_entry (GstProps *props, GstPropsEntry *entry)
|
||||||
g_return_if_fail (props);
|
g_return_if_fail (props);
|
||||||
g_return_if_fail (entry);
|
g_return_if_fail (entry);
|
||||||
|
|
||||||
|
/* only variable properties can change the fixed flag */
|
||||||
if (GST_PROPS_IS_FIXED (props) && GST_PROPS_ENTRY_IS_VARIABLE (entry)) {
|
if (GST_PROPS_IS_FIXED (props) && GST_PROPS_ENTRY_IS_VARIABLE (entry)) {
|
||||||
GST_PROPS_FLAG_UNSET (props, GST_PROPS_FIXED);
|
GST_PROPS_FLAG_UNSET (props, GST_PROPS_FIXED);
|
||||||
}
|
}
|
||||||
props->properties = g_list_insert_sorted (props->properties, entry, props_compare_func);
|
props->properties = g_list_insert_sorted (props->properties, entry, props_compare_func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_props_remove_entry_by_id (GstProps *props, GQuark propid)
|
||||||
|
{
|
||||||
|
GList *properties;
|
||||||
|
gboolean found;
|
||||||
|
|
||||||
|
/* assume fixed */
|
||||||
|
GST_PROPS_FLAG_SET (props, GST_PROPS_FIXED);
|
||||||
|
|
||||||
|
found = FALSE;
|
||||||
|
|
||||||
|
properties = props->properties;
|
||||||
|
while (properties) {
|
||||||
|
GList *current = properties;
|
||||||
|
GstPropsEntry *lentry = (GstPropsEntry *) current->data;
|
||||||
|
|
||||||
|
properties = g_list_next (properties);
|
||||||
|
|
||||||
|
if (lentry->propid == propid) {
|
||||||
|
found = TRUE;
|
||||||
|
g_list_delete_link (props->properties, current);
|
||||||
|
}
|
||||||
|
else if (GST_PROPS_ENTRY_IS_VARIABLE (lentry)) {
|
||||||
|
GST_PROPS_FLAG_UNSET (props, GST_PROPS_FIXED);
|
||||||
|
/* no need to check for further variable entries
|
||||||
|
* if we already removed the entry */
|
||||||
|
if (found)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* gst_props_remove_entry:
|
* gst_props_remove_entry:
|
||||||
* @props: the property to remove the entry from
|
* @props: the property to remove the entry from
|
||||||
|
@ -884,7 +916,7 @@ gst_props_remove_entry (GstProps *props, GstPropsEntry *entry)
|
||||||
g_return_if_fail (props != NULL);
|
g_return_if_fail (props != NULL);
|
||||||
g_return_if_fail (entry != NULL);
|
g_return_if_fail (entry != NULL);
|
||||||
|
|
||||||
props->properties = g_list_remove (props->properties, entry);
|
gst_props_remove_entry_by_id (props, entry->propid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -897,18 +929,13 @@ gst_props_remove_entry (GstProps *props, GstPropsEntry *entry)
|
||||||
void
|
void
|
||||||
gst_props_remove_entry_by_name (GstProps *props, const gchar *name)
|
gst_props_remove_entry_by_name (GstProps *props, const gchar *name)
|
||||||
{
|
{
|
||||||
GList *lentry;
|
|
||||||
GQuark quark;
|
GQuark quark;
|
||||||
|
|
||||||
g_return_if_fail (props != NULL);
|
g_return_if_fail (props != NULL);
|
||||||
g_return_if_fail (name != NULL);
|
g_return_if_fail (name != NULL);
|
||||||
|
|
||||||
quark = g_quark_from_string (name);
|
quark = g_quark_from_string (name);
|
||||||
|
gst_props_remove_entry_by_id (props, quark);
|
||||||
lentry = g_list_find_custom (props->properties, GINT_TO_POINTER (quark), props_find_func);
|
|
||||||
if (lentry) {
|
|
||||||
gst_props_remove_entry (props, (GstPropsEntry *)lentry->data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -949,7 +976,8 @@ gst_props_debug (GstProps *props)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG (GST_CAT_PROPERTIES, "props %p, refcount %d, flags %d", props, props->refcount, props->flags);
|
GST_DEBUG (GST_CAT_PROPERTIES, "props %p, refcount %d, flags %d",
|
||||||
|
props, props->refcount, props->flags);
|
||||||
|
|
||||||
g_list_foreach (props->properties, (GFunc) gst_props_debug_entry, NULL);
|
g_list_foreach (props->properties, (GFunc) gst_props_debug_entry, NULL);
|
||||||
}
|
}
|
||||||
|
@ -1237,26 +1265,66 @@ GstProps*
|
||||||
gst_props_set (GstProps *props, const gchar *name, ...)
|
gst_props_set (GstProps *props, const gchar *name, ...)
|
||||||
{
|
{
|
||||||
GQuark quark;
|
GQuark quark;
|
||||||
GList *lentry;
|
GList *properties;
|
||||||
va_list var_args;
|
va_list var_args;
|
||||||
|
gboolean found;
|
||||||
|
gboolean was_fixed;
|
||||||
|
|
||||||
g_return_val_if_fail (props != NULL, NULL);
|
g_return_val_if_fail (props != NULL, NULL);
|
||||||
|
|
||||||
|
found = FALSE;
|
||||||
|
was_fixed = GST_PROPS_IS_FIXED (props);
|
||||||
|
GST_PROPS_FLAG_SET (props, GST_PROPS_FIXED);
|
||||||
|
|
||||||
quark = g_quark_from_string (name);
|
quark = g_quark_from_string (name);
|
||||||
|
/* this looks a little complicated but the idea is to get
|
||||||
lentry = g_list_find_custom (props->properties, GINT_TO_POINTER (quark), props_find_func);
|
* out of the loop ASAP. Changing the entry to a variable
|
||||||
|
* property immediatly marks the props as non-fixed.
|
||||||
if (lentry) {
|
* changing the entry to fixed when the props was fixed
|
||||||
|
* does not change the props and we can get out of the loop
|
||||||
|
* as well.
|
||||||
|
* When changing the entry to a fixed entry, we need to
|
||||||
|
* see if all entries are fixed before we can decide the props
|
||||||
|
*/
|
||||||
|
properties = props->properties;
|
||||||
|
while (properties) {
|
||||||
GstPropsEntry *entry;
|
GstPropsEntry *entry;
|
||||||
|
|
||||||
entry = (GstPropsEntry *)lentry->data;
|
entry = (GstPropsEntry *) properties->data;
|
||||||
|
|
||||||
va_start (var_args, name);
|
if (entry->propid == quark) {
|
||||||
gst_props_entry_clean (entry);
|
found = TRUE;
|
||||||
GST_PROPS_ENTRY_FILL (entry, var_args);
|
|
||||||
va_end (var_args);
|
va_start (var_args, name);
|
||||||
|
gst_props_entry_clean (entry);
|
||||||
|
GST_PROPS_ENTRY_FILL (entry, var_args);
|
||||||
|
va_end (var_args);
|
||||||
|
|
||||||
|
/* if the props was fixed and we changed this entry
|
||||||
|
* with a fixed entry, we can stop now as the global
|
||||||
|
* props flag cannot change */
|
||||||
|
if (was_fixed && !GST_PROPS_ENTRY_IS_VARIABLE (entry))
|
||||||
|
break;
|
||||||
|
/* if we already found a non fixed entry we can exit */
|
||||||
|
if (!GST_PROPS_IS_FIXED (props))
|
||||||
|
break;
|
||||||
|
/* if the entry is variable, we'll get out of the loop
|
||||||
|
* in the next statement */
|
||||||
|
/* if the entry is fixed we have to check all other
|
||||||
|
* entries before we can decide if the props are fixed */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GST_PROPS_ENTRY_IS_VARIABLE (entry)) {
|
||||||
|
/* mark the props as variable */
|
||||||
|
GST_PROPS_FLAG_UNSET (props, GST_PROPS_FIXED);
|
||||||
|
/* if we already changed the entry, we can stop now */
|
||||||
|
if (found)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
properties = g_list_next (properties);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
if (!found) {
|
||||||
g_warning ("gstprops: no property '%s' to change\n", name);
|
g_warning ("gstprops: no property '%s' to change\n", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2424,7 +2492,9 @@ gst_props_normalize (GstProps *props)
|
||||||
GList *lentry;
|
GList *lentry;
|
||||||
|
|
||||||
newprops = gst_props_copy (props);
|
newprops = gst_props_copy (props);
|
||||||
lentry = g_list_find_custom (newprops->properties, GINT_TO_POINTER (list_entry->propid), props_find_func);
|
lentry = g_list_find_custom (newprops->properties,
|
||||||
|
GINT_TO_POINTER (list_entry->propid),
|
||||||
|
props_find_func);
|
||||||
if (lentry) {
|
if (lentry) {
|
||||||
GList *new_list;
|
GList *new_list;
|
||||||
|
|
||||||
|
|
|
@ -101,15 +101,15 @@ typedef enum {
|
||||||
} GstPropsFlags;
|
} GstPropsFlags;
|
||||||
|
|
||||||
#define GST_PROPS_FLAGS(props) ((props)->flags)
|
#define GST_PROPS_FLAGS(props) ((props)->flags)
|
||||||
#define GST_PROPS_FLAG_IS_SET(props,flag) (GST_PROPS_FLAGS (props) & flag)
|
#define GST_PROPS_FLAG_IS_SET(props,flag) (GST_PROPS_FLAGS (props) & (flag))
|
||||||
#define GST_PROPS_FLAG_SET(props,flag) (GST_PROPS_FLAGS (props) |= (flag))
|
#define GST_PROPS_FLAG_SET(props,flag) (GST_PROPS_FLAGS (props) |= (flag))
|
||||||
#define GST_PROPS_FLAG_UNSET(props,flag) (GST_PROPS_FLAGS (props) &= ~(flag))
|
#define GST_PROPS_FLAG_UNSET(props,flag) (GST_PROPS_FLAGS (props) &= ~(flag))
|
||||||
|
|
||||||
#define GST_PROPS_REFCOUNT(props) ((props)->refcount)
|
#define GST_PROPS_REFCOUNT(props) ((props)->refcount)
|
||||||
#define GST_PROPS_PROPERTIES(props) ((props)->properties)
|
#define GST_PROPS_PROPERTIES(props) ((props)->properties)
|
||||||
|
|
||||||
#define GST_PROPS_IS_FIXED(props) (GST_PROPS_FLAGS (props) & GST_PROPS_FIXED)
|
#define GST_PROPS_IS_FIXED(props) (GST_PROPS_FLAG_IS_SET ((props), GST_PROPS_FIXED))
|
||||||
#define GST_PROPS_IS_FLOATING(props) (GST_PROPS_FLAGS (props) & GST_PROPS_FLOATING)
|
#define GST_PROPS_IS_FLOATING(props) (GST_PROPS_FLAG_IS_SET ((props), GST_PROPS_FLOATING))
|
||||||
|
|
||||||
struct _GstProps {
|
struct _GstProps {
|
||||||
gint refcount;
|
gint refcount;
|
||||||
|
|
Loading…
Reference in a new issue