diff options
author | Sebastian Dröge <slomo@circular-chaos.org> | 2008-12-15 17:27:00 +0000 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2008-12-15 17:27:00 +0000 |
commit | bc93b81dd56106f11d87f6a8ad9b6134f2817a57 (patch) | |
tree | 7c1d9ab165287ddff168bdde0d16579a1f95487c /gst/mxf/mxfmpeg.c | |
parent | 9cfbca8754cef7961cbfbfb1d7a66ab886efefc9 (diff) | |
download | gstreamer-plugins-bad-bc93b81dd56106f11d87f6a8ad9b6134f2817a57.tar.gz |
gst/mxf/: Convert the structural metadata to GstMiniObjects to make a lot of code easier and to make everything bette...
Original commit message from CVS:
* gst/mxf/Makefile.am:
* gst/mxf/mxf.c: (plugin_init):
* gst/mxf/mxfaes-bwf.c:
(mxf_metadata_wave_audio_essence_descriptor_handle_tag),
(mxf_metadata_wave_audio_essence_descriptor_init),
(mxf_metadata_wave_audio_essence_descriptor_class_init),
(mxf_metadata_aes3_audio_essence_descriptor_finalize),
(mxf_metadata_aes3_audio_essence_descriptor_handle_tag),
(mxf_metadata_aes3_audio_essence_descriptor_init),
(mxf_metadata_aes3_audio_essence_descriptor_class_init),
(mxf_is_aes_bwf_essence_track), (mxf_bwf_create_caps),
(mxf_aes3_create_caps), (mxf_aes_bwf_create_caps),
(mxf_aes_bwf_init):
* gst/mxf/mxfaes-bwf.h:
* gst/mxf/mxfalaw.c: (mxf_is_alaw_essence_track),
(mxf_alaw_create_caps), (mxf_alaw_init):
* gst/mxf/mxfalaw.h:
* gst/mxf/mxfd10.c: (mxf_is_d10_essence_track),
(mxf_d10_create_caps), (mxf_d10_init):
* gst/mxf/mxfd10.h:
* gst/mxf/mxfdemux.c: (gst_mxf_demux_reset_metadata),
(gst_mxf_demux_handle_header_metadata_resolve_references),
(gst_mxf_demux_find_package), (gst_mxf_demux_choose_package),
(gst_mxf_demux_handle_header_metadata_update_streams),
(gst_mxf_demux_handle_metadata),
(gst_mxf_demux_handle_generic_container_essence_element),
(gst_mxf_demux_handle_klv_packet), (gst_mxf_demux_src_query):
* gst/mxf/mxfdemux.h:
* gst/mxf/mxfdv-dif.c: (mxf_is_dv_dif_essence_track),
(mxf_dv_dif_create_caps), (mxf_dv_dif_init):
* gst/mxf/mxfdv-dif.h:
* gst/mxf/mxfjpeg2000.c: (mxf_is_jpeg2000_essence_track),
(mxf_jpeg2000_create_caps), (mxf_jpeg2000_init):
* gst/mxf/mxfjpeg2000.h:
* gst/mxf/mxfmetadata.c: (mxf_metadata_base_finalize),
(mxf_metadata_base_handle_tag), (mxf_metadata_base_resolve),
(mxf_metadata_base_init), (mxf_metadata_base_class_init),
(mxf_metadata_parse), (mxf_metadata_resolve),
(mxf_metadata_handle_tag), (mxf_metadata_class_init),
(mxf_metadata_init), (mxf_metadata_init_types),
(mxf_metadata_register), (mxf_metadata_new),
(mxf_metadata_preface_finalize), (mxf_metadata_preface_handle_tag),
(mxf_metadata_preface_resolve), (mxf_metadata_preface_init),
(mxf_metadata_preface_class_init),
(mxf_metadata_identification_finalize),
(mxf_metadata_identification_handle_tag),
(mxf_metadata_identification_init),
(mxf_metadata_identification_class_init),
(mxf_metadata_content_storage_finalize),
(mxf_metadata_content_storage_handle_tag),
(mxf_metadata_content_storage_resolve),
(mxf_metadata_content_storage_init),
(mxf_metadata_content_storage_class_init),
(mxf_metadata_essence_container_data_handle_tag),
(mxf_metadata_essence_container_data_resolve),
(mxf_metadata_essence_container_data_init),
(mxf_metadata_essence_container_data_class_init),
(mxf_metadata_generic_package_finalize),
(mxf_metadata_generic_package_handle_tag),
(mxf_metadata_generic_package_resolve),
(mxf_metadata_generic_package_init),
(mxf_metadata_generic_package_class_init),
(mxf_metadata_material_package_resolve),
(mxf_metadata_material_package_init),
(mxf_metadata_material_package_class_init),
(mxf_metadata_source_package_finalize),
(mxf_metadata_source_package_handle_tag),
(mxf_metadata_source_package_resolve),
(mxf_metadata_source_package_init),
(mxf_metadata_source_package_class_init),
(mxf_metadata_track_finalize), (mxf_metadata_track_handle_tag),
(mxf_metadata_track_resolve), (mxf_metadata_track_init),
(mxf_metadata_track_class_init),
(mxf_metadata_track_identifier_parse),
(mxf_metadata_timeline_track_handle_tag),
(mxf_metadata_timeline_track_init),
(mxf_metadata_timeline_track_class_init),
(mxf_metadata_event_track_handle_tag),
(mxf_metadata_event_track_init),
(mxf_metadata_event_track_class_init),
(mxf_metadata_static_track_init),
(mxf_metadata_static_track_class_init),
(mxf_metadata_sequence_finalize),
(mxf_metadata_sequence_handle_tag),
(mxf_metadata_sequence_resolve), (mxf_metadata_sequence_init),
(mxf_metadata_sequence_class_init),
(mxf_metadata_structural_component_handle_tag),
(mxf_metadata_structural_component_init),
(mxf_metadata_structural_component_class_init),
(mxf_metadata_timecode_component_handle_tag),
(mxf_metadata_timecode_component_init),
(mxf_metadata_timecode_component_class_init),
(mxf_metadata_source_clip_handle_tag),
(mxf_metadata_source_clip_resolve),
(mxf_metadata_source_clip_init),
(mxf_metadata_source_clip_class_init),
(mxf_metadata_dm_source_clip_finalize),
(mxf_metadata_dm_source_clip_handle_tag),
(mxf_metadata_dm_source_clip_init),
(mxf_metadata_dm_source_clip_class_init),
(mxf_metadata_dm_segment_finalize),
(mxf_metadata_dm_segment_handle_tag),
(mxf_metadata_dm_segment_resolve), (mxf_metadata_dm_segment_init),
(mxf_metadata_dm_segment_class_init),
(mxf_metadata_generic_descriptor_finalize),
(mxf_metadata_generic_descriptor_handle_tag),
(mxf_metadata_generic_descriptor_resolve),
(mxf_metadata_generic_descriptor_init),
(mxf_metadata_generic_descriptor_class_init),
(mxf_metadata_file_descriptor_handle_tag),
(mxf_metadata_file_descriptor_init),
(mxf_metadata_file_descriptor_class_init),
(mxf_metadata_generic_picture_essence_descriptor_handle_tag),
(mxf_metadata_generic_picture_essence_descriptor_init),
(mxf_metadata_generic_picture_essence_descriptor_class_init),
(mxf_metadata_generic_picture_essence_descriptor_set_caps),
(mxf_metadata_generic_sound_essence_descriptor_handle_tag),
(mxf_metadata_generic_sound_essence_descriptor_init),
(mxf_metadata_generic_sound_essence_descriptor_class_init),
(mxf_metadata_cdci_picture_essence_descriptor_handle_tag),
(mxf_metadata_cdci_picture_essence_descriptor_init),
(mxf_metadata_cdci_picture_essence_descriptor_class_init),
(mxf_metadata_rgba_picture_essence_descriptor_finalize),
(mxf_metadata_rgba_picture_essence_descriptor_handle_tag),
(mxf_metadata_rgba_picture_essence_descriptor_init),
(mxf_metadata_rgba_picture_essence_descriptor_class_init),
(mxf_metadata_generic_data_essence_descriptor_handle_tag),
(mxf_metadata_generic_data_essence_descriptor_init),
(mxf_metadata_generic_data_essence_descriptor_class_init),
(mxf_metadata_multiple_descriptor_finalize),
(mxf_metadata_multiple_descriptor_handle_tag),
(mxf_metadata_multiple_descriptor_resolve),
(mxf_metadata_multiple_descriptor_init),
(mxf_metadata_multiple_descriptor_class_init),
(mxf_metadata_locator_init), (mxf_metadata_locator_class_init),
(mxf_metadata_text_locator_finalize),
(mxf_metadata_text_locator_handle_tag),
(mxf_metadata_text_locator_init),
(mxf_metadata_text_locator_class_init),
(mxf_metadata_network_locator_finalize),
(mxf_metadata_network_locator_handle_tag),
(mxf_metadata_network_locator_init),
(mxf_metadata_network_locator_class_init):
* gst/mxf/mxfmetadata.h:
* gst/mxf/mxfmpeg.c:
(mxf_metadata_mpeg_video_descriptor_handle_tag),
(mxf_metadata_mpeg_video_descriptor_init),
(mxf_metadata_mpeg_video_descriptor_class_init),
(mxf_is_mpeg_essence_track), (mxf_mpeg_es_create_caps),
(mxf_mpeg_create_caps), (mxf_mpeg_init):
* gst/mxf/mxfmpeg.h:
* gst/mxf/mxfparse.c: (mxf_index_table_segment_parse),
(mxf_local_tag_add_to_hash_table):
* gst/mxf/mxfparse.h:
* gst/mxf/mxftypes.h:
* gst/mxf/mxfup.c: (mxf_is_up_essence_track), (mxf_up_create_caps),
(mxf_up_init):
* gst/mxf/mxfup.h:
Convert the structural metadata to GstMiniObjects to make a lot of
code easier and to make everything better extensible.
Add a "registry" for metadata handlers to improve extensibility even
more and to remove metadata type specifics from mxfdemux.
Clean up a lot of parts and add some more NULL checks.
Diffstat (limited to 'gst/mxf/mxfmpeg.c')
-rw-r--r-- | gst/mxf/mxfmpeg.c | 127 |
1 files changed, 68 insertions, 59 deletions
diff --git a/gst/mxf/mxfmpeg.c b/gst/mxf/mxfmpeg.c index 608ecc277..7ba129f95 100644 --- a/gst/mxf/mxfmpeg.c +++ b/gst/mxf/mxfmpeg.c @@ -91,14 +91,18 @@ static const guint8 _profile_and_level_ul[] = { 0x0a, 0x00, 0x00 }; -gboolean -mxf_metadata_mpeg_video_descriptor_handle_tag (MXFMetadataGenericDescriptor * d, - const MXFPrimerPack * primer, guint16 tag, const guint8 * tag_data, - guint16 tag_size) +G_DEFINE_TYPE (MXFMetadataMPEGVideoDescriptor, + mxf_metadata_mpeg_video_descriptor, + MXF_TYPE_METADATA_CDCI_PICTURE_ESSENCE_DESCRIPTOR); + +static gboolean +mxf_metadata_mpeg_video_descriptor_handle_tag (MXFMetadataBase * metadata, + MXFPrimerPack * primer, guint16 tag, const guint8 * tag_data, + guint tag_size) { - MXFMetadataMPEGVideoDescriptor *descriptor = - (MXFMetadataMPEGVideoDescriptor *) d; - gboolean ret = FALSE; + MXFMetadataMPEGVideoDescriptor *self = + MXF_METADATA_MPEG_VIDEO_DESCRIPTOR (metadata); + gboolean ret = TRUE; MXFUL *tag_ul = NULL; if (!(tag_ul = @@ -109,91 +113,86 @@ mxf_metadata_mpeg_video_descriptor_handle_tag (MXFMetadataGenericDescriptor * d, if (memcmp (tag_ul, &_single_sequence_ul, 16) == 0) { if (tag_size != 1) goto error; - descriptor->single_sequence = GST_READ_UINT8 (tag_data); + self->single_sequence = GST_READ_UINT8 (tag_data); GST_DEBUG (" single sequence = %s", - (descriptor->single_sequence) ? "yes" : "no"); - ret = TRUE; + (self->single_sequence) ? "yes" : "no"); } else if (memcmp (tag_ul, &_constant_b_frames_ul, 16) == 0) { if (tag_size != 1) goto error; - descriptor->const_b_frames = GST_READ_UINT8 (tag_data); + self->const_b_frames = GST_READ_UINT8 (tag_data); GST_DEBUG (" constant b frames = %s", - (descriptor->single_sequence) ? "yes" : "no"); - ret = TRUE; + (self->single_sequence) ? "yes" : "no"); } else if (memcmp (tag_ul, &_coded_content_type_ul, 16) == 0) { if (tag_size != 1) goto error; - descriptor->coded_content_type = GST_READ_UINT8 (tag_data); - GST_DEBUG (" coded content type = %u", descriptor->coded_content_type); - ret = TRUE; + self->coded_content_type = GST_READ_UINT8 (tag_data); + GST_DEBUG (" coded content type = %u", self->coded_content_type); } else if (memcmp (tag_ul, &_low_delay_ul, 16) == 0) { if (tag_size != 1) goto error; - descriptor->low_delay = GST_READ_UINT8 (tag_data); - GST_DEBUG (" low delay = %s", (descriptor->low_delay) ? "yes" : "no"); - ret = TRUE; + self->low_delay = GST_READ_UINT8 (tag_data); + GST_DEBUG (" low delay = %s", (self->low_delay) ? "yes" : "no"); } else if (memcmp (tag_ul, &_closed_gop_ul, 16) == 0) { if (tag_size != 1) goto error; - descriptor->closed_gop = GST_READ_UINT8 (tag_data); - GST_DEBUG (" closed gop = %s", (descriptor->closed_gop) ? "yes" : "no"); - ret = TRUE; + self->closed_gop = GST_READ_UINT8 (tag_data); + GST_DEBUG (" closed gop = %s", (self->closed_gop) ? "yes" : "no"); } else if (memcmp (tag_ul, &_identical_gop_ul, 16) == 0) { if (tag_size != 1) goto error; - descriptor->identical_gop = GST_READ_UINT8 (tag_data); - GST_DEBUG (" identical gop = %s", - (descriptor->identical_gop) ? "yes" : "no"); - ret = TRUE; + self->identical_gop = GST_READ_UINT8 (tag_data); + GST_DEBUG (" identical gop = %s", (self->identical_gop) ? "yes" : "no"); } else if (memcmp (tag_ul, &_max_gop_ul, 16) == 0) { if (tag_size != 2) goto error; - descriptor->max_gop = GST_READ_UINT16_BE (tag_data); - GST_DEBUG (" max gop = %u", descriptor->max_gop); - ret = TRUE; + self->max_gop = GST_READ_UINT16_BE (tag_data); + GST_DEBUG (" max gop = %u", self->max_gop); } else if (memcmp (tag_ul, &_b_picture_count_ul, 16) == 0) { if (tag_size != 2) goto error; - descriptor->b_picture_count = GST_READ_UINT16_BE (tag_data); - GST_DEBUG (" b picture count = %u", descriptor->b_picture_count); - ret = TRUE; + self->b_picture_count = GST_READ_UINT16_BE (tag_data); + GST_DEBUG (" b picture count = %u", self->b_picture_count); } else if (memcmp (tag_ul, &_bitrate_ul, 16) == 0) { if (tag_size != 4) goto error; - descriptor->bitrate = GST_READ_UINT32_BE (tag_data); - GST_DEBUG (" bitrate = %u", descriptor->bitrate); - ret = TRUE; + self->bitrate = GST_READ_UINT32_BE (tag_data); + GST_DEBUG (" bitrate = %u", self->bitrate); } else if (memcmp (tag_ul, &_profile_and_level_ul, 16) == 0) { if (tag_size != 1) goto error; - descriptor->profile_and_level = GST_READ_UINT8 (tag_data); - GST_DEBUG (" profile & level = %u", descriptor->profile_and_level); - ret = TRUE; + self->profile_and_level = GST_READ_UINT8 (tag_data); + GST_DEBUG (" profile & level = %u", self->profile_and_level); } else { ret = - mxf_metadata_cdci_picture_essence_descriptor_handle_tag (d, primer, tag, - tag_data, tag_size); + MXF_METADATA_BASE_CLASS + (mxf_metadata_mpeg_video_descriptor_parent_class)->handle_tag (metadata, + primer, tag, tag_data, tag_size); } return ret; error: - GST_ERROR ("Invalid mpeg video descriptor tag 0x%04x of size %u", tag, + + GST_ERROR ("Invalid MPEG video descriptor local tag 0x%04x of size %u", tag, tag_size); return FALSE; } -void mxf_metadata_mpeg_video_descriptor_reset - (MXFMetadataMPEGVideoDescriptor * descriptor) +static void +mxf_metadata_mpeg_video_descriptor_init (MXFMetadataMPEGVideoDescriptor * self) { - g_return_if_fail (descriptor != NULL); - mxf_metadata_cdci_picture_essence_descriptor_reset ( - (MXFMetadataCDCIPictureEssenceDescriptor *) descriptor); +} + +static void + mxf_metadata_mpeg_video_descriptor_class_init + (MXFMetadataMPEGVideoDescriptorClass * klass) +{ + MXFMetadataBaseClass *metadata_base_class = (MXFMetadataBaseClass *) klass; - MXF_METADATA_DESCRIPTOR_CLEAR (descriptor, MXFMetadataMPEGVideoDescriptor, - MXFMetadataCDCIPictureEssenceDescriptor); + metadata_base_class->handle_tag = + mxf_metadata_mpeg_video_descriptor_handle_tag; } gboolean @@ -208,7 +207,12 @@ mxf_is_mpeg_essence_track (const MXFMetadataTrack * track) for (i = 0; i < track->n_descriptor; i++) { MXFMetadataFileDescriptor *d = track->descriptor[i]; - MXFUL *key = &d->essence_container; + MXFUL *key; + + if (!d) + continue; + + key = &d->essence_container; /* SMPTE 381M 7 */ if (mxf_is_generic_container_essence_container_label (key) && key->u[12] == 0x02 && @@ -338,8 +342,8 @@ mxf_mpeg_es_create_caps (MXFMetadataGenericPackage * package, codec_name = "MPEG-1 Video"; } else if (p->picture_essence_coding.u[13] == 0x20) { MXFLocalTag *local_tag = - (((MXFMetadataGenericDescriptor *) p)->other_tags) ? - g_hash_table_lookup (((MXFMetadataGenericDescriptor *) + (((MXFMetadataBase *) p)->other_tags) ? + g_hash_table_lookup (((MXFMetadataBase *) p)->other_tags, &sony_mpeg4_extradata) : NULL; caps = gst_caps_new_simple ("video/mpeg", "mpegversion", G_TYPE_INT, 4, @@ -446,17 +450,16 @@ mxf_mpeg_create_caps (MXFMetadataGenericPackage * package, } for (i = 0; i < track->n_descriptor; i++) { - if (((MXFMetadataGenericDescriptor *) track->descriptor[i])->type == - MXF_METADATA_MPEG_VIDEO_DESCRIPTOR || - ((MXFMetadataGenericDescriptor *) track->descriptor[i])->type == - MXF_METADATA_CDCI_PICTURE_ESSENCE_DESCRIPTOR || - ((MXFMetadataGenericDescriptor *) track->descriptor[i])->type == - MXF_METADATA_GENERIC_PICTURE_ESSENCE_DESCRIPTOR) { + if (!track->descriptor[i]) + continue; + + if (MXF_IS_METADATA_GENERIC_PICTURE_ESSENCE_DESCRIPTOR (track-> + descriptor[i])) { f = track->descriptor[i]; p = (MXFMetadataGenericPictureEssenceDescriptor *) track->descriptor[i]; break; - } else if (((MXFMetadataGenericDescriptor *) track->descriptor[i])->type == - MXF_METADATA_GENERIC_SOUND_ESSENCE_DESCRIPTOR) { + } else if (MXF_IS_METADATA_GENERIC_SOUND_ESSENCE_DESCRIPTOR (track-> + descriptor[i])) { f = track->descriptor[i]; s = (MXFMetadataGenericSoundEssenceDescriptor *) track->descriptor[i]; break; @@ -503,3 +506,9 @@ mxf_mpeg_create_caps (MXFMetadataGenericPackage * package, return caps; } + +void +mxf_mpeg_init (void) +{ + mxf_metadata_register (0x0151, MXF_TYPE_METADATA_MPEG_VIDEO_DESCRIPTOR); +} |