mxfdemux: Use arrays instead of lists for the metadata registries

This commit is contained in:
Sebastian Dröge 2009-03-02 17:00:41 +01:00
parent f429818589
commit 62dbf4b9bc
3 changed files with 102 additions and 144 deletions

View file

@ -5613,60 +5613,54 @@ mxf_dms1_cue_words_class_init (MXFDMS1CueWordsClass * klass)
dm_class->type = 0x170800;
}
#define _add_dm_type(type) G_STMT_START { \
GType tmp = type; \
\
g_array_append_val (dms1_sets, tmp); \
} G_STMT_END
void
mxf_dms1_initialize (void)
{
GSList *dms1_sets = NULL;
GArray *dms1_sets = g_array_new (TRUE, TRUE, sizeof (GType));
dms1_sets =
g_slist_prepend (dms1_sets,
(gpointer) MXF_TYPE_DMS1_PRODUCTION_FRAMEWORK);
dms1_sets =
g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_CLIP_FRAMEWORK);
dms1_sets =
g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_SCENE_FRAMEWORK);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_TITLES);
dms1_sets =
g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_IDENTIFICATION);
dms1_sets =
g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_GROUP_RELATIONSHIP);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_BRANDING);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_EVENT);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_PUBLICATION);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_AWARD);
dms1_sets =
g_slist_prepend (dms1_sets,
(gpointer) MXF_TYPE_DMS1_CAPTIONS_DESCRIPTION);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_ANNOTATION);
dms1_sets =
g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_SETTING_PERIOD);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_SCRIPTING);
dms1_sets =
g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_CLASSIFICATION);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_SHOT);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_KEY_POINT);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_PARTICIPANT);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_PERSON);
dms1_sets =
g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_ORGANISATION);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_LOCATION);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_ADDRESS);
dms1_sets =
g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_COMMUNICATIONS);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_CONTRACT);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_RIGHTS);
dms1_sets =
g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_PICTURE_FORMAT);
dms1_sets =
g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_DEVICE_PARAMETERS);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_NAME_VALUE);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_PROCESSING);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_PROJECT);
dms1_sets =
g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_CONTACTS_LIST);
dms1_sets = g_slist_prepend (dms1_sets, (gpointer) MXF_TYPE_DMS1_CUE_WORDS);
_add_dm_type (MXF_TYPE_DMS1_PRODUCTION_FRAMEWORK);
_add_dm_type (MXF_TYPE_DMS1_CLIP_FRAMEWORK);
_add_dm_type (MXF_TYPE_DMS1_SCENE_FRAMEWORK);
_add_dm_type (MXF_TYPE_DMS1_TITLES);
_add_dm_type (MXF_TYPE_DMS1_IDENTIFICATION);
_add_dm_type (MXF_TYPE_DMS1_GROUP_RELATIONSHIP);
_add_dm_type (MXF_TYPE_DMS1_BRANDING);
_add_dm_type (MXF_TYPE_DMS1_EVENT);
_add_dm_type (MXF_TYPE_DMS1_PUBLICATION);
_add_dm_type (MXF_TYPE_DMS1_AWARD);
_add_dm_type (MXF_TYPE_DMS1_CAPTIONS_DESCRIPTION);
_add_dm_type (MXF_TYPE_DMS1_ANNOTATION);
_add_dm_type (MXF_TYPE_DMS1_SETTING_PERIOD);
_add_dm_type (MXF_TYPE_DMS1_SCRIPTING);
_add_dm_type (MXF_TYPE_DMS1_CLASSIFICATION);
_add_dm_type (MXF_TYPE_DMS1_SHOT);
_add_dm_type (MXF_TYPE_DMS1_KEY_POINT);
_add_dm_type (MXF_TYPE_DMS1_PARTICIPANT);
_add_dm_type (MXF_TYPE_DMS1_PERSON);
_add_dm_type (MXF_TYPE_DMS1_ORGANISATION);
_add_dm_type (MXF_TYPE_DMS1_LOCATION);
_add_dm_type (MXF_TYPE_DMS1_ADDRESS);
_add_dm_type (MXF_TYPE_DMS1_COMMUNICATIONS);
_add_dm_type (MXF_TYPE_DMS1_CONTRACT);
_add_dm_type (MXF_TYPE_DMS1_RIGHTS);
_add_dm_type (MXF_TYPE_DMS1_PICTURE_FORMAT);
_add_dm_type (MXF_TYPE_DMS1_DEVICE_PARAMETERS);
_add_dm_type (MXF_TYPE_DMS1_NAME_VALUE);
_add_dm_type (MXF_TYPE_DMS1_PROCESSING);
_add_dm_type (MXF_TYPE_DMS1_PROJECT);
_add_dm_type (MXF_TYPE_DMS1_CONTACTS_LIST);
_add_dm_type (MXF_TYPE_DMS1_CUE_WORDS);
mxf_descriptive_metadata_register (0x01, dms1_sets);
mxf_descriptive_metadata_register (0x01, (GType *) g_array_free (dms1_sets,
FALSE));
}
#undef _add_dm_type
#undef ADD_SET

View file

@ -284,104 +284,61 @@ mxf_metadata_init (MXFMetadata * self)
{
}
static GSList *_mxf_metadata_registry = NULL;
static GArray *_mxf_metadata_registry = NULL;
typedef struct
{
guint16 type_id;
GType type;
} _MXFMetadataType;
#define _add_metadata_type(type) G_STMT_START { \
GType t = type; \
\
g_array_append_val (_mxf_metadata_registry, t); \
} G_STMT_END
void
mxf_metadata_init_types (void)
{
g_return_if_fail (_mxf_metadata_registry == NULL);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_PREFACE);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_IDENTIFICATION);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_CONTENT_STORAGE);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_ESSENCE_CONTAINER_DATA);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_MATERIAL_PACKAGE);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_SOURCE_PACKAGE);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_TIMELINE_TRACK);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_EVENT_TRACK);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_STATIC_TRACK);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_SEQUENCE);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_SOURCE_CLIP);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_TIMECODE_COMPONENT);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_DM_SEGMENT);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_DM_SOURCE_CLIP);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_FILE_DESCRIPTOR);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_GENERIC_PICTURE_ESSENCE_DESCRIPTOR);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_CDCI_PICTURE_ESSENCE_DESCRIPTOR);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_RGBA_PICTURE_ESSENCE_DESCRIPTOR);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_GENERIC_SOUND_ESSENCE_DESCRIPTOR);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_GENERIC_DATA_ESSENCE_DESCRIPTOR);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_MULTIPLE_DESCRIPTOR);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_NETWORK_LOCATOR);
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry,
(gpointer) MXF_TYPE_METADATA_TEXT_LOCATOR);
_mxf_metadata_registry = g_array_new (FALSE, TRUE, sizeof (GType));
_add_metadata_type (MXF_TYPE_METADATA_PREFACE);
_add_metadata_type (MXF_TYPE_METADATA_IDENTIFICATION);
_add_metadata_type (MXF_TYPE_METADATA_CONTENT_STORAGE);
_add_metadata_type (MXF_TYPE_METADATA_ESSENCE_CONTAINER_DATA);
_add_metadata_type (MXF_TYPE_METADATA_MATERIAL_PACKAGE);
_add_metadata_type (MXF_TYPE_METADATA_SOURCE_PACKAGE);
_add_metadata_type (MXF_TYPE_METADATA_TIMELINE_TRACK);
_add_metadata_type (MXF_TYPE_METADATA_EVENT_TRACK);
_add_metadata_type (MXF_TYPE_METADATA_STATIC_TRACK);
_add_metadata_type (MXF_TYPE_METADATA_SEQUENCE);
_add_metadata_type (MXF_TYPE_METADATA_SOURCE_CLIP);
_add_metadata_type (MXF_TYPE_METADATA_TIMECODE_COMPONENT);
_add_metadata_type (MXF_TYPE_METADATA_DM_SEGMENT);
_add_metadata_type (MXF_TYPE_METADATA_DM_SOURCE_CLIP);
_add_metadata_type (MXF_TYPE_METADATA_FILE_DESCRIPTOR);
_add_metadata_type (MXF_TYPE_METADATA_GENERIC_PICTURE_ESSENCE_DESCRIPTOR);
_add_metadata_type (MXF_TYPE_METADATA_CDCI_PICTURE_ESSENCE_DESCRIPTOR);
_add_metadata_type (MXF_TYPE_METADATA_RGBA_PICTURE_ESSENCE_DESCRIPTOR);
_add_metadata_type (MXF_TYPE_METADATA_GENERIC_SOUND_ESSENCE_DESCRIPTOR);
_add_metadata_type (MXF_TYPE_METADATA_GENERIC_DATA_ESSENCE_DESCRIPTOR);
_add_metadata_type (MXF_TYPE_METADATA_MULTIPLE_DESCRIPTOR);
_add_metadata_type (MXF_TYPE_METADATA_NETWORK_LOCATOR);
_add_metadata_type (MXF_TYPE_METADATA_TEXT_LOCATOR);
}
#undef _add_metadata_type
void
mxf_metadata_register (GType type)
{
g_return_if_fail (g_type_is_a (type, MXF_TYPE_METADATA));
_mxf_metadata_registry =
g_slist_prepend (_mxf_metadata_registry, (gpointer) type);
g_array_append_val (_mxf_metadata_registry, type);
}
MXFMetadata *
mxf_metadata_new (guint16 type, MXFPrimerPack * primer, guint64 offset,
const guint8 * data, guint size)
{
GSList *l;
guint i;
GType t = G_TYPE_INVALID;
MXFMetadata *ret = NULL;
@ -389,8 +346,8 @@ mxf_metadata_new (guint16 type, MXFPrimerPack * primer, guint64 offset,
g_return_val_if_fail (primer != NULL, NULL);
g_return_val_if_fail (_mxf_metadata_registry != NULL, NULL);
for (l = _mxf_metadata_registry; l; l = l->next) {
GType tmp = (GType) l->data;
for (i = 0; i < _mxf_metadata_registry->len; i++) {
GType tmp = g_array_index (_mxf_metadata_registry, GType, i);
MXFMetadataClass *klass = MXF_METADATA_CLASS (g_type_class_ref (tmp));
if (klass->type == type) {
@ -4619,36 +4576,41 @@ mxf_descriptive_metadata_class_init (MXFDescriptiveMetadataClass * klass)
typedef struct
{
guint8 scheme;
GSList *sets;
GType *types;
} _MXFDescriptiveMetadataScheme;
static GSList *_dm_schemes = NULL;
static GArray *_dm_schemes = NULL;
void
mxf_descriptive_metadata_register (guint8 scheme, GSList * sets)
mxf_descriptive_metadata_register (guint8 scheme, GType * types)
{
_MXFDescriptiveMetadataScheme *s =
g_slice_new (_MXFDescriptiveMetadataScheme);
_MXFDescriptiveMetadataScheme s;
s->scheme = scheme;
s->sets = sets;
_dm_schemes = g_slist_prepend (_dm_schemes, s);
if (!_dm_schemes)
_dm_schemes =
g_array_new (FALSE, TRUE, sizeof (_MXFDescriptiveMetadataScheme));
s.scheme = scheme;
s.types = types;
g_array_append_val (_dm_schemes, s);
}
MXFDescriptiveMetadata *
mxf_descriptive_metadata_new (guint8 scheme, guint32 type,
MXFPrimerPack * primer, guint64 offset, const guint8 * data, guint size)
{
GSList *l;
GType t = G_TYPE_INVALID;
guint i;
GType t = G_TYPE_INVALID, *p;
_MXFDescriptiveMetadataScheme *s = NULL;
MXFDescriptiveMetadata *ret = NULL;
g_return_val_if_fail (type != 0, NULL);
g_return_val_if_fail (primer != NULL, NULL);
for (l = _dm_schemes; l; l = l->next) {
_MXFDescriptiveMetadataScheme *data = l->data;
for (i = 0; i < _dm_schemes->len; i++) {
_MXFDescriptiveMetadataScheme *data =
&g_array_index (_dm_schemes, _MXFDescriptiveMetadataScheme, i);
if (data->scheme == scheme) {
s = data;
@ -4661,8 +4623,9 @@ mxf_descriptive_metadata_new (guint8 scheme, guint32 type,
return NULL;
}
for (l = s->sets; l; l = l->next) {
GType tmp = (GType) l->data;
p = s->types;
while (*p) {
GType tmp = *p;
MXFDescriptiveMetadataClass *klass =
MXF_DESCRIPTIVE_METADATA_CLASS (g_type_class_ref (tmp));
@ -4672,6 +4635,7 @@ mxf_descriptive_metadata_new (guint8 scheme, guint32 type,
break;
}
g_type_class_unref (klass);
p++;
}
if (t == G_TYPE_INVALID) {

View file

@ -761,7 +761,7 @@ MXFMetadataTrackType mxf_metadata_track_identifier_parse (const MXFUL * track_id
void mxf_metadata_generic_picture_essence_descriptor_set_caps (MXFMetadataGenericPictureEssenceDescriptor * self, GstCaps * caps);
void mxf_metadata_generic_sound_essence_descriptor_set_caps (MXFMetadataGenericSoundEssenceDescriptor * self, GstCaps * caps);
void mxf_descriptive_metadata_register (guint8 scheme, GSList *sets);
void mxf_descriptive_metadata_register (guint8 scheme, GType *types);
MXFDescriptiveMetadata * mxf_descriptive_metadata_new (guint8 scheme, guint32 type, MXFPrimerPack * primer, guint64 offset, const guint8 * data, guint size);
GHashTable *mxf_metadata_hash_table_new (void);