mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 13:11:06 +00:00
Added API to dynamically create GstCaps and GstProps
Original commit message from CVS: Added API to dynamically create GstCaps and GstProps Changed typefind of mpeg1 to set the GstProps. autoplugging now works again for mpeg1, whoohoo!
This commit is contained in:
parent
0b1967b440
commit
efda5ffd9a
5 changed files with 101 additions and 7 deletions
|
@ -19,6 +19,7 @@
|
|||
|
||||
//#define DEBUG_ENABLED
|
||||
|
||||
#include "gstdebug.h"
|
||||
#include "gstcaps.h"
|
||||
#include "gsttype.h"
|
||||
|
||||
|
@ -68,6 +69,17 @@ gst_caps_new (gchar *mime)
|
|||
return caps;
|
||||
}
|
||||
|
||||
GstCaps*
|
||||
gst_caps_new_with_props (gchar *mime, GstProps *props)
|
||||
{
|
||||
GstCaps *caps;
|
||||
|
||||
caps = gst_caps_new (mime);
|
||||
caps->properties = props;
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_caps_register:
|
||||
* @factory: the factory to register
|
||||
|
@ -101,6 +113,25 @@ gst_caps_register (GstCapsFactory *factory)
|
|||
return caps;
|
||||
}
|
||||
|
||||
GstCaps*
|
||||
gst_caps_set_props (GstCaps *caps, GstProps *props)
|
||||
{
|
||||
g_return_val_if_fail (caps != NULL, caps);
|
||||
g_return_val_if_fail (props != NULL, caps);
|
||||
g_return_val_if_fail (caps->properties == NULL, caps);
|
||||
|
||||
caps->properties = props;
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
GstProps*
|
||||
gst_caps_get_props (GstCaps *caps)
|
||||
{
|
||||
g_return_val_if_fail (caps != NULL, caps);
|
||||
|
||||
return caps->properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_caps_check_compatibility:
|
||||
|
@ -118,24 +149,22 @@ gst_caps_check_compatibility (GstCaps *fromcaps, GstCaps *tocaps)
|
|||
g_return_val_if_fail (tocaps != NULL, FALSE);
|
||||
|
||||
if (fromcaps->id != tocaps->id) {
|
||||
//g_print ("gstcaps: mime types wrong\n");
|
||||
DEBUG ("gstcaps: mime types wrong\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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");
|
||||
DEBUG ("gstcaps: no source caps\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// assume it accepts everything
|
||||
//g_print ("gstcaps: no caps\n");
|
||||
DEBUG ("gstcaps: no caps\n");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,8 +44,12 @@ struct _GstCaps {
|
|||
void _gst_caps_initialize (void);
|
||||
|
||||
GstCaps* gst_caps_new (gchar *mime);
|
||||
GstCaps* gst_caps_new_with_props (gchar *mime, GstProps *props);
|
||||
GstCaps* gst_caps_register (GstCapsFactory *factory);
|
||||
|
||||
GstCaps* gst_caps_set_props (GstCaps *caps, GstProps *props);
|
||||
GstProps* gst_caps_get_props (GstCaps *caps);
|
||||
|
||||
gboolean gst_caps_check_compatibility (GstCaps *caps1, GstCaps *caps2);
|
||||
|
||||
xmlNodePtr gst_caps_save_thyself (GstCaps *caps, xmlNodePtr parent);
|
||||
|
|
|
@ -158,6 +158,63 @@ gst_props_register (GstPropsFactory factory)
|
|||
return props;
|
||||
}
|
||||
|
||||
GstProps *
|
||||
gst_props_new (GstPropsFactoryEntry entry, ...)
|
||||
{
|
||||
va_list var_args;
|
||||
GstPropsFactoryEntry value;
|
||||
gint i = 0;
|
||||
gint size;
|
||||
GstPropsFactoryEntry *factory;
|
||||
|
||||
|
||||
size = 16;
|
||||
factory = (GstPropsFactoryEntry *) g_malloc (size*sizeof(GstPropsFactoryEntry));
|
||||
|
||||
va_start (var_args, entry);
|
||||
|
||||
value = (GstPropsFactoryEntry) entry;
|
||||
|
||||
while (value) {
|
||||
DEBUG ("%p\n", value);
|
||||
|
||||
factory[i++] = value;
|
||||
|
||||
if (i >= size) {
|
||||
size += 16;
|
||||
factory = (GstPropsFactoryEntry *) g_realloc (factory, size*sizeof(GstPropsFactoryEntry));
|
||||
}
|
||||
|
||||
value = va_arg (var_args, GstPropsFactoryEntry);
|
||||
}
|
||||
factory[i++] = NULL;
|
||||
|
||||
return gst_props_register (factory);
|
||||
}
|
||||
|
||||
GstProps*
|
||||
gst_props_merge (GstProps *props, GstProps *tomerge)
|
||||
{
|
||||
GSList *merge_props;
|
||||
|
||||
g_return_val_if_fail (props != NULL, NULL);
|
||||
g_return_val_if_fail (tomerge != NULL, NULL);
|
||||
|
||||
merge_props = tomerge->properties;
|
||||
|
||||
// FIXME do proper merging here...
|
||||
while (merge_props) {
|
||||
GstPropsEntry *entry = (GstPropsEntry *)merge_props->data;
|
||||
|
||||
props->properties = g_slist_insert_sorted (props->properties, entry, props_compare_func);
|
||||
|
||||
merge_props = g_slist_next (merge_props);
|
||||
}
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
|
||||
/* entry2 is always a list, entry1 never is */
|
||||
static gboolean
|
||||
gst_props_entry_check_list_compatibility (GstPropsEntry *entry1, GstPropsEntry *entry2)
|
||||
|
|
|
@ -53,7 +53,7 @@ typedef enum {
|
|||
|
||||
|
||||
struct _GstProps {
|
||||
GSList *properties; /* properties for this capability */
|
||||
GSList *properties; /* real properties for this property */
|
||||
};
|
||||
|
||||
/* initialize the subsystem */
|
||||
|
@ -61,6 +61,10 @@ void _gst_props_initialize (void);
|
|||
|
||||
GstProps* gst_props_register (GstPropsFactory factory);
|
||||
|
||||
GstProps* gst_props_new (GstPropsFactoryEntry entry, ...);
|
||||
|
||||
GstProps* gst_props_merge (GstProps *props, GstProps *tomerge);
|
||||
|
||||
gboolean gst_props_check_compatibility (GstProps *props1, GstProps *props2);
|
||||
|
||||
xmlNodePtr gst_props_save_thyself (GstProps *props, xmlNodePtr parent);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
noinst_PROGRAMS = init loadall simplefake states caps queue registry paranoia rip mp3encode autoplug
|
||||
noinst_PROGRAMS = init loadall simplefake states caps queue registry paranoia rip mp3encode autoplug props
|
||||
|
||||
LDADD = $(GLIB_LIBS) $(GTK_LIBS) $(top_builddir)/gst/libgst.la
|
||||
CFLAGS = -Wall
|
||||
|
|
Loading…
Reference in a new issue