gst/mxf/: Implement an essence element handling registry and use this instead of an hardcoded, large if-then-else block.

Original commit message from CVS:
* gst/mxf/mxfaes-bwf.c: (mxf_is_aes_bwf_essence_track),
(mxf_bwf_handle_essence_element),
(mxf_aes3_handle_essence_element), (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_handle_essence_element), (mxf_alaw_create_caps),
(mxf_alaw_init):
* gst/mxf/mxfalaw.h:
* gst/mxf/mxfd10.c: (mxf_is_d10_essence_track),
(mxf_d10_picture_handle_essence_element),
(mxf_d10_sound_handle_essence_element), (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_update_streams),
(gst_mxf_demux_handle_generic_container_essence_element):
* gst/mxf/mxfdv-dif.c: (mxf_is_dv_dif_essence_track),
(mxf_dv_dif_handle_essence_element), (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_handle_essence_element), (mxf_jpeg2000_create_caps),
(mxf_jpeg2000_init):
* gst/mxf/mxfjpeg2000.h:
* gst/mxf/mxfmpeg.c: (mxf_is_mpeg_essence_track),
(mxf_mpeg_video_handle_essence_element),
(mxf_mpeg_audio_handle_essence_element), (mxf_mpeg_es_create_caps),
(mxf_mpeg_create_caps), (mxf_mpeg_init):
* gst/mxf/mxfmpeg.h:
* gst/mxf/mxfparse.c: (mxf_essence_element_handler_register),
(mxf_essence_element_handler_find):
* gst/mxf/mxfparse.h:
* gst/mxf/mxfup.c: (mxf_is_up_essence_track),
(mxf_up_handle_essence_element), (mxf_up_rgba_create_caps),
(mxf_up_create_caps), (mxf_up_init):
* gst/mxf/mxfup.h:
Implement an essence element handling registry and use this instead
of an hardcoded, large if-then-else block.
This commit is contained in:
Sebastian Dröge 2008-12-16 12:30:34 +00:00
parent 2bdd84b48d
commit 5587f91210
18 changed files with 429 additions and 414 deletions

View file

@ -1,3 +1,46 @@
2008-12-16 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* gst/mxf/mxfaes-bwf.c: (mxf_is_aes_bwf_essence_track),
(mxf_bwf_handle_essence_element),
(mxf_aes3_handle_essence_element), (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_handle_essence_element), (mxf_alaw_create_caps),
(mxf_alaw_init):
* gst/mxf/mxfalaw.h:
* gst/mxf/mxfd10.c: (mxf_is_d10_essence_track),
(mxf_d10_picture_handle_essence_element),
(mxf_d10_sound_handle_essence_element), (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_update_streams),
(gst_mxf_demux_handle_generic_container_essence_element):
* gst/mxf/mxfdv-dif.c: (mxf_is_dv_dif_essence_track),
(mxf_dv_dif_handle_essence_element), (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_handle_essence_element), (mxf_jpeg2000_create_caps),
(mxf_jpeg2000_init):
* gst/mxf/mxfjpeg2000.h:
* gst/mxf/mxfmpeg.c: (mxf_is_mpeg_essence_track),
(mxf_mpeg_video_handle_essence_element),
(mxf_mpeg_audio_handle_essence_element), (mxf_mpeg_es_create_caps),
(mxf_mpeg_create_caps), (mxf_mpeg_init):
* gst/mxf/mxfmpeg.h:
* gst/mxf/mxfparse.c: (mxf_essence_element_handler_register),
(mxf_essence_element_handler_find):
* gst/mxf/mxfparse.h:
* gst/mxf/mxfup.c: (mxf_is_up_essence_track),
(mxf_up_handle_essence_element), (mxf_up_rgba_create_caps),
(mxf_up_create_caps), (mxf_up_init):
* gst/mxf/mxfup.h:
Implement an essence element handling registry and use this instead
of an hardcoded, large if-then-else block.
2008-12-16 Edward Hervey <edward.hervey@collabora.co.uk>
* tests/check/Makefile.am:

View file

@ -40,6 +40,78 @@
GST_DEBUG_CATEGORY_EXTERN (mxf_debug);
#define GST_CAT_DEFAULT mxf_debug
/* SMPTE 382M Annex 1 */
#define MXF_TYPE_METADATA_WAVE_AUDIO_ESSENCE_DESCRIPTOR \
(mxf_metadata_wave_audio_essence_descriptor_get_type())
#define MXF_METADATA_WAVE_AUDIO_ESSENCE_DESCRIPTOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),MXF_TYPE_METADATA_WAVE_AUDIO_ESSENCE_DESCRIPTOR, MXFMetadataWaveAudioEssenceDescriptor))
#define MXF_IS_METADATA_WAVE_AUDIO_ESSENCE_DESCRIPTOR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),MXF_TYPE_METADATA_WAVE_AUDIO_ESSENCE_DESCRIPTOR))
typedef struct _MXFMetadataWaveAudioEssenceDescriptor
MXFMetadataWaveAudioEssenceDescriptor;
typedef MXFMetadataBaseClass MXFMetadataWaveAudioEssenceDescriptorClass;
GType mxf_metadata_wave_audio_essence_descriptor_get_type (void);
struct _MXFMetadataWaveAudioEssenceDescriptor
{
MXFMetadataGenericSoundEssenceDescriptor parent;
guint16 block_align;
guint8 sequence_offset;
guint32 avg_bps;
MXFUL channel_assignment;
guint32 peak_envelope_version;
guint32 peak_envelope_format;
guint32 points_per_peak_value;
guint32 peak_envelope_block_size;
guint32 peak_channels;
guint32 peak_frames;
gint64 peak_of_peaks_position;
MXFTimestamp peak_envelope_timestamp;
guint8 *peak_envelope_data;
guint16 peak_envelope_data_length;
};
/* SMPTE 382M Annex 2 */
#define MXF_TYPE_METADATA_AES3_AUDIO_ESSENCE_DESCRIPTOR \
(mxf_metadata_aes3_audio_essence_descriptor_get_type())
#define MXF_METADATA_AES3_AUDIO_ESSENCE_DESCRIPTOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),MXF_TYPE_METADATA_AES3_AUDIO_ESSENCE_DESCRIPTOR, MXFMetadataAES3AudioEssenceDescriptor))
#define MXF_IS_METADATA_AES3_AUDIO_ESSENCE_DESCRIPTOR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),MXF_TYPE_METADATA_AES3_AUDIO_ESSENCE_DESCRIPTOR))
typedef struct _MXFMetadataAES3AudioEssenceDescriptor
MXFMetadataAES3AudioEssenceDescriptor;
typedef MXFMetadataBaseClass MXFMetadataAES3AudioEssenceDescriptorClass;
GType mxf_metadata_aes3_audio_essence_descriptor_get_type (void);
struct _MXFMetadataAES3AudioEssenceDescriptor
{
MXFMetadataWaveAudioEssenceDescriptor parent;
guint8 emphasis;
guint16 block_start_offset;
guint8 auxiliary_bits_mode;
guint32 n_channel_status_mode;
guint8 *channel_status_mode;
guint32 n_fixed_channel_status_data;
guint8 **fixed_channel_status_data;
guint32 n_user_data_mode;
guint8 *user_data_mode;
guint32 n_fixed_user_data;
guint8 **fixed_user_data;
guint32 linked_timecode_track_id;
guint8 stream_number;
};
/* SMPTE 382M Annex 1 */
G_DEFINE_TYPE (MXFMetadataWaveAudioEssenceDescriptor,
mxf_metadata_wave_audio_essence_descriptor,
@ -463,20 +535,20 @@ static void
mxf_metadata_aes3_audio_essence_descriptor_handle_tag;
}
gboolean
mxf_is_aes_bwf_essence_track (const MXFMetadataTrack * track)
static gboolean
mxf_is_aes_bwf_essence_track (const MXFMetadataTimelineTrack * track)
{
guint i;
g_return_val_if_fail (track != NULL, FALSE);
if (track->descriptor == NULL) {
if (track->parent.descriptor == NULL) {
GST_ERROR ("No descriptor for this track");
return FALSE;
}
for (i = 0; i < track->n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->descriptor[i];
for (i = 0; i < track->parent.n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->parent.descriptor[i];
MXFUL *key;
if (!d)
@ -500,9 +572,10 @@ mxf_is_aes_bwf_essence_track (const MXFMetadataTrack * track)
static GstFlowReturn
mxf_bwf_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
GstCaps * caps, MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, MXFMetadataStructuralComponent * component,
gpointer mapping_data, GstBuffer ** outbuf)
GstCaps * caps,
MXFMetadataTimelineTrack * track,
MXFMetadataStructuralComponent * component, gpointer mapping_data,
GstBuffer ** outbuf)
{
*outbuf = buffer;
@ -519,9 +592,9 @@ mxf_bwf_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
static GstFlowReturn
mxf_aes3_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
GstCaps * caps, MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, MXFMetadataStructuralComponent * component,
gpointer mapping_data, GstBuffer ** outbuf)
GstCaps * caps, MXFMetadataTimelineTrack * track,
MXFMetadataStructuralComponent * component, gpointer mapping_data,
GstBuffer ** outbuf)
{
*outbuf = buffer;
@ -555,10 +628,9 @@ static const MXFUL mxf_sound_essence_compression_alaw =
};
static GstCaps *
mxf_bwf_create_caps (MXFMetadataGenericPackage * package,
MXFMetadataTrack * track,
mxf_bwf_create_caps (MXFMetadataTimelineTrack * track,
MXFMetadataGenericSoundEssenceDescriptor * descriptor, GstTagList ** tags,
MXFEssenceElementHandler * handler, gpointer * mapping_data)
MXFEssenceElementHandleFunc * handler, gpointer * mapping_data)
{
GstCaps *ret = NULL;
MXFMetadataWaveAudioEssenceDescriptor *wa_descriptor = NULL;
@ -653,6 +725,8 @@ mxf_bwf_create_caps (MXFMetadataGenericPackage * package,
mxf_ul_to_string (&descriptor->sound_essence_compression, str));
}
*handler = mxf_bwf_handle_essence_element;
if (!*tags)
*tags = gst_tag_list_new ();
@ -666,16 +740,13 @@ mxf_bwf_create_caps (MXFMetadataGenericPackage * package,
gst_tag_list_add (*tags, GST_TAG_MERGE_APPEND, GST_TAG_BITRATE,
wa_descriptor->avg_bps * 8, NULL);
*handler = mxf_bwf_handle_essence_element;
return ret;
}
static GstCaps *
mxf_aes3_create_caps (MXFMetadataGenericPackage * package,
MXFMetadataTrack * track,
mxf_aes3_create_caps (MXFMetadataTimelineTrack * track,
MXFMetadataGenericSoundEssenceDescriptor * descriptor, GstTagList ** tags,
MXFEssenceElementHandler * handler, gpointer * mapping_data)
MXFEssenceElementHandleFunc * handler, gpointer * mapping_data)
{
GstCaps *ret = NULL;
MXFMetadataWaveAudioEssenceDescriptor *wa_descriptor = NULL;
@ -726,42 +797,43 @@ mxf_aes3_create_caps (MXFMetadataGenericPackage * package,
return ret;
}
GstCaps *
mxf_aes_bwf_create_caps (MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, GstTagList ** tags,
MXFEssenceElementHandler * handler, gpointer * mapping_data)
static GstCaps *
mxf_aes_bwf_create_caps (MXFMetadataTimelineTrack * track, GstTagList ** tags,
MXFEssenceElementHandleFunc * handler, gpointer * mapping_data)
{
MXFMetadataGenericSoundEssenceDescriptor *s = NULL;
gboolean bwf = FALSE;
guint i;
g_return_val_if_fail (package != NULL, NULL);
g_return_val_if_fail (track != NULL, NULL);
if (track->descriptor == NULL) {
if (track->parent.descriptor == NULL) {
GST_ERROR ("No descriptor found for this track");
return NULL;
}
for (i = 0; i < track->n_descriptor; i++) {
if (!track->descriptor[i])
for (i = 0; i < track->parent.n_descriptor; i++) {
if (!track->parent.descriptor[i])
continue;
if (MXF_IS_METADATA_GENERIC_SOUND_ESSENCE_DESCRIPTOR (track->descriptor[i])
&& (track->descriptor[i]->essence_container.u[14] == 0x01
|| track->descriptor[i]->essence_container.u[14] == 0x02
|| track->descriptor[i]->essence_container.u[14] == 0x08)) {
s = (MXFMetadataGenericSoundEssenceDescriptor *) track->descriptor[i];
if (MXF_IS_METADATA_GENERIC_SOUND_ESSENCE_DESCRIPTOR (track->parent.
descriptor[i])
&& (track->parent.descriptor[i]->essence_container.u[14] == 0x01
|| track->parent.descriptor[i]->essence_container.u[14] == 0x02
|| track->parent.descriptor[i]->essence_container.u[14] == 0x08)) {
s = (MXFMetadataGenericSoundEssenceDescriptor *) track->parent.
descriptor[i];
bwf = TRUE;
break;
} else
if (MXF_IS_METADATA_GENERIC_SOUND_ESSENCE_DESCRIPTOR (track->descriptor
[i])
&& (track->descriptor[i]->essence_container.u[14] == 0x03
|| track->descriptor[i]->essence_container.u[14] == 0x04
|| track->descriptor[i]->essence_container.u[14] == 0x09)) {
if (MXF_IS_METADATA_GENERIC_SOUND_ESSENCE_DESCRIPTOR (track->parent.
descriptor[i])
&& (track->parent.descriptor[i]->essence_container.u[14] == 0x03
|| track->parent.descriptor[i]->essence_container.u[14] == 0x04
|| track->parent.descriptor[i]->essence_container.u[14] == 0x09)) {
s = (MXFMetadataGenericSoundEssenceDescriptor *) track->descriptor[i];
s = (MXFMetadataGenericSoundEssenceDescriptor *) track->parent.
descriptor[i];
bwf = FALSE;
break;
}
@ -771,15 +843,19 @@ mxf_aes_bwf_create_caps (MXFMetadataGenericPackage * package,
GST_ERROR ("No descriptor found for this track");
return NULL;
} else if (bwf) {
return mxf_bwf_create_caps (package, track, s, tags, handler, mapping_data);
return mxf_bwf_create_caps (track, s, tags, handler, mapping_data);
} else {
return mxf_aes3_create_caps (package, track, s, tags, handler,
mapping_data);
return mxf_aes3_create_caps (track, s, tags, handler, mapping_data);
}
return NULL;
}
static const MXFEssenceElementHandler mxf_aes_bwf_essence_handler = {
mxf_is_aes_bwf_essence_track,
mxf_aes_bwf_create_caps
};
void
mxf_aes_bwf_init (void)
{
@ -787,4 +863,6 @@ mxf_aes_bwf_init (void)
MXF_TYPE_METADATA_WAVE_AUDIO_ESSENCE_DESCRIPTOR);
mxf_metadata_register (0x0147,
MXF_TYPE_METADATA_AES3_AUDIO_ESSENCE_DESCRIPTOR);
mxf_essence_element_handler_register (&mxf_aes_bwf_essence_handler);
}

View file

@ -29,79 +29,6 @@
#include "mxfparse.h"
#include "mxfmetadata.h"
/* SMPTE 382M Annex 1 */
#define MXF_TYPE_METADATA_WAVE_AUDIO_ESSENCE_DESCRIPTOR \
(mxf_metadata_wave_audio_essence_descriptor_get_type())
#define MXF_METADATA_WAVE_AUDIO_ESSENCE_DESCRIPTOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),MXF_TYPE_METADATA_WAVE_AUDIO_ESSENCE_DESCRIPTOR, MXFMetadataWaveAudioEssenceDescriptor))
#define MXF_IS_METADATA_WAVE_AUDIO_ESSENCE_DESCRIPTOR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),MXF_TYPE_METADATA_WAVE_AUDIO_ESSENCE_DESCRIPTOR))
typedef struct _MXFMetadataWaveAudioEssenceDescriptor MXFMetadataWaveAudioEssenceDescriptor;
typedef MXFMetadataBaseClass MXFMetadataWaveAudioEssenceDescriptorClass;
GType mxf_metadata_wave_audio_essence_descriptor_get_type (void);
struct _MXFMetadataWaveAudioEssenceDescriptor {
MXFMetadataGenericSoundEssenceDescriptor parent;
guint16 block_align;
guint8 sequence_offset;
guint32 avg_bps;
MXFUL channel_assignment;
guint32 peak_envelope_version;
guint32 peak_envelope_format;
guint32 points_per_peak_value;
guint32 peak_envelope_block_size;
guint32 peak_channels;
guint32 peak_frames;
gint64 peak_of_peaks_position;
MXFTimestamp peak_envelope_timestamp;
guint8 *peak_envelope_data;
guint16 peak_envelope_data_length;
};
/* SMPTE 382M Annex 2 */
#define MXF_TYPE_METADATA_AES3_AUDIO_ESSENCE_DESCRIPTOR \
(mxf_metadata_aes3_audio_essence_descriptor_get_type())
#define MXF_METADATA_AES3_AUDIO_ESSENCE_DESCRIPTOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),MXF_TYPE_METADATA_AES3_AUDIO_ESSENCE_DESCRIPTOR, MXFMetadataAES3AudioEssenceDescriptor))
#define MXF_IS_METADATA_AES3_AUDIO_ESSENCE_DESCRIPTOR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),MXF_TYPE_METADATA_AES3_AUDIO_ESSENCE_DESCRIPTOR))
typedef struct _MXFMetadataAES3AudioEssenceDescriptor MXFMetadataAES3AudioEssenceDescriptor;
typedef MXFMetadataBaseClass MXFMetadataAES3AudioEssenceDescriptorClass;
GType mxf_metadata_aes3_audio_essence_descriptor_get_type (void);
struct _MXFMetadataAES3AudioEssenceDescriptor {
MXFMetadataWaveAudioEssenceDescriptor parent;
guint8 emphasis;
guint16 block_start_offset;
guint8 auxiliary_bits_mode;
guint32 n_channel_status_mode;
guint8 *channel_status_mode;
guint32 n_fixed_channel_status_data;
guint8 **fixed_channel_status_data;
guint32 n_user_data_mode;
guint8 *user_data_mode;
guint32 n_fixed_user_data;
guint8 **fixed_user_data;
guint32 linked_timecode_track_id;
guint8 stream_number;
};
gboolean mxf_is_aes_bwf_essence_track (const MXFMetadataTrack *track);
GstCaps *
mxf_aes_bwf_create_caps (MXFMetadataGenericPackage *package, MXFMetadataTrack *track, GstTagList **tags, MXFEssenceElementHandler *handler, gpointer *mapping_data);
void mxf_aes_bwf_init (void);
#endif /* __MXF_AES_BWF_H__ */

View file

@ -33,18 +33,18 @@
GST_DEBUG_CATEGORY_EXTERN (mxf_debug);
#define GST_CAT_DEFAULT mxf_debug
gboolean
mxf_is_alaw_essence_track (const MXFMetadataTrack * track)
static gboolean
mxf_is_alaw_essence_track (const MXFMetadataTimelineTrack * track)
{
guint i;
g_return_val_if_fail (track != NULL, FALSE);
if (track->descriptor == NULL)
if (track->parent.descriptor == NULL)
return FALSE;
for (i = 0; i < track->n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->descriptor[i];
for (i = 0; i < track->parent.n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->parent.descriptor[i];
MXFUL *key;
if (!d)
@ -63,9 +63,10 @@ mxf_is_alaw_essence_track (const MXFMetadataTrack * track)
static GstFlowReturn
mxf_alaw_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
GstCaps * caps, MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, MXFMetadataStructuralComponent * component,
gpointer mapping_data, GstBuffer ** outbuf)
GstCaps * caps,
MXFMetadataTimelineTrack * track,
MXFMetadataStructuralComponent * component, gpointer mapping_data,
GstBuffer ** outbuf)
{
*outbuf = buffer;
@ -80,29 +81,29 @@ mxf_alaw_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
}
GstCaps *
mxf_alaw_create_caps (MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, GstTagList ** tags,
MXFEssenceElementHandler * handler, gpointer * mapping_data)
static GstCaps *
mxf_alaw_create_caps (MXFMetadataTimelineTrack * track, GstTagList ** tags,
MXFEssenceElementHandleFunc * handler, gpointer * mapping_data)
{
MXFMetadataGenericSoundEssenceDescriptor *s = NULL;
guint i;
GstCaps *caps = NULL;
g_return_val_if_fail (package != NULL, NULL);
g_return_val_if_fail (track != NULL, NULL);
if (track->descriptor == NULL) {
if (track->parent.descriptor == NULL) {
GST_ERROR ("No descriptor found for this track");
return NULL;
}
for (i = 0; i < track->n_descriptor; i++) {
if (!track->descriptor[i])
for (i = 0; i < track->parent.n_descriptor; i++) {
if (!track->parent.descriptor[i])
continue;
if (MXF_IS_METADATA_GENERIC_SOUND_ESSENCE_DESCRIPTOR (track->descriptor[i])) {
s = (MXFMetadataGenericSoundEssenceDescriptor *) track->descriptor[i];
if (MXF_IS_METADATA_GENERIC_SOUND_ESSENCE_DESCRIPTOR (track->parent.
descriptor[i])) {
s = (MXFMetadataGenericSoundEssenceDescriptor *) track->parent.
descriptor[i];
break;
}
}
@ -135,7 +136,13 @@ mxf_alaw_create_caps (MXFMetadataGenericPackage * package,
return caps;
}
static const MXFEssenceElementHandler mxf_alaw_essence_element_handler = {
mxf_is_alaw_essence_track,
mxf_alaw_create_caps
};
void
mxf_alaw_init (void)
{
mxf_essence_element_handler_register (&mxf_alaw_essence_element_handler);
}

View file

@ -28,11 +28,6 @@
#include "mxfparse.h"
gboolean mxf_is_alaw_essence_track (const MXFMetadataTrack *track);
GstCaps *
mxf_alaw_create_caps (MXFMetadataGenericPackage *package, MXFMetadataTrack *track, GstTagList **tags, MXFEssenceElementHandler *handler, gpointer *mapping_data);
void mxf_alaw_init (void);
#endif /* __MXF_ALAW_H__ */

View file

@ -40,18 +40,18 @@ typedef struct
guint width, channels;
} MXFD10AudioMappingData;
gboolean
mxf_is_d10_essence_track (const MXFMetadataTrack * track)
static gboolean
mxf_is_d10_essence_track (const MXFMetadataTimelineTrack * track)
{
guint i;
g_return_val_if_fail (track != NULL, FALSE);
if (track->descriptor == NULL)
if (track->parent.descriptor == NULL)
return FALSE;
for (i = 0; i < track->n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->descriptor[i];
for (i = 0; i < track->parent.n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->parent.descriptor[i];
MXFUL *key;
if (!d)
@ -71,9 +71,10 @@ mxf_is_d10_essence_track (const MXFMetadataTrack * track)
static GstFlowReturn
mxf_d10_picture_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
GstCaps * caps, MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, MXFMetadataStructuralComponent * component,
gpointer mapping_data, GstBuffer ** outbuf)
GstCaps * caps,
MXFMetadataTimelineTrack * track,
MXFMetadataStructuralComponent * component, gpointer mapping_data,
GstBuffer ** outbuf)
{
*outbuf = buffer;
@ -88,9 +89,10 @@ mxf_d10_picture_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
static GstFlowReturn
mxf_d10_sound_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
GstCaps * caps, MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, MXFMetadataStructuralComponent * component,
gpointer mapping_data, GstBuffer ** outbuf)
GstCaps * caps,
MXFMetadataTimelineTrack * track,
MXFMetadataStructuralComponent * component, gpointer mapping_data,
GstBuffer ** outbuf)
{
guint i, j, nsamples;
const guint8 *indata;
@ -153,35 +155,35 @@ mxf_d10_sound_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
return GST_FLOW_OK;
}
GstCaps *
mxf_d10_create_caps (MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, GstTagList ** tags,
MXFEssenceElementHandler * handler, gpointer * mapping_data)
static GstCaps *
mxf_d10_create_caps (MXFMetadataTimelineTrack * track, GstTagList ** tags,
MXFEssenceElementHandleFunc * handler, gpointer * mapping_data)
{
MXFMetadataGenericPictureEssenceDescriptor *p = NULL;
MXFMetadataGenericSoundEssenceDescriptor *s = NULL;
guint i;
GstCaps *caps = NULL;
g_return_val_if_fail (package != NULL, NULL);
g_return_val_if_fail (track != NULL, NULL);
if (track->descriptor == NULL) {
if (track->parent.descriptor == NULL) {
GST_ERROR ("No descriptor found for this track");
return NULL;
}
for (i = 0; i < track->n_descriptor; i++) {
if (!track->descriptor[i])
for (i = 0; i < track->parent.n_descriptor; i++) {
if (!track->parent.descriptor[i])
continue;
if (MXF_IS_METADATA_GENERIC_PICTURE_ESSENCE_DESCRIPTOR (track->
descriptor[i])) {
p = (MXFMetadataGenericPictureEssenceDescriptor *) track->descriptor[i];
parent.descriptor[i])) {
p = (MXFMetadataGenericPictureEssenceDescriptor *) track->parent.
descriptor[i];
break;
} else if (MXF_IS_METADATA_GENERIC_SOUND_ESSENCE_DESCRIPTOR (track->
descriptor[i])) {
s = (MXFMetadataGenericSoundEssenceDescriptor *) track->descriptor[i];
parent.descriptor[i])) {
s = (MXFMetadataGenericSoundEssenceDescriptor *) track->parent.
descriptor[i];
break;
}
}
@ -243,7 +245,13 @@ mxf_d10_create_caps (MXFMetadataGenericPackage * package,
return caps;
}
static const MXFEssenceElementHandler mxf_d10_essence_element_handler = {
mxf_is_d10_essence_track,
mxf_d10_create_caps
};
void
mxf_d10_init (void)
{
mxf_essence_element_handler_register (&mxf_d10_essence_element_handler);
}

View file

@ -28,11 +28,6 @@
#include "mxfparse.h"
gboolean mxf_is_d10_essence_track (const MXFMetadataTrack *track);
GstCaps *
mxf_d10_create_caps (MXFMetadataGenericPackage *package, MXFMetadataTrack *track, GstTagList **tags, MXFEssenceElementHandler *handler, gpointer *mapping_data);
void mxf_d10_init (void);
#endif /* __MXF_D10_H__ */

View file

@ -43,8 +43,6 @@
* timestamp calculation, etc.
* - Handle timecode tracks correctly (where is this documented?)
* - Handle Generic container system items
* - Use an "essence element/track handling" registry instead of the large if-then-else
* block when detecting the codec
* - Force synchronization of tracks. Packets that have the timestamp are not required
* to be stored at the same position in the essence stream, especially if tracks
* with different source packages (body sid) are used.
@ -69,13 +67,6 @@
#include "mxfdemux.h"
#include "mxfparse.h"
#include "mxfmetadata.h"
#include "mxfaes-bwf.h"
#include "mxfmpeg.h"
#include "mxfdv-dif.h"
#include "mxfalaw.h"
#include "mxfjpeg2000.h"
#include "mxfd10.h"
#include "mxfup.h"
#include <string.h>
@ -109,8 +100,9 @@ typedef struct
GstFlowReturn last_flow;
guint64 essence_element_count;
MXFEssenceElementHandler handle_essence_element;
gpointer mapping_data;
const MXFEssenceElementHandler *handler;
MXFEssenceElementHandleFunc handle_func;
GstTagList *tags;
@ -235,6 +227,9 @@ gst_mxf_demux_reset_metadata (GstMXFDemux * demux)
for (i = 0; i < demux->src->len; i++) {
GstMXFDemuxPad *pad = g_ptr_array_index (demux->src, i);
pad->handler = NULL;
pad->handle_func = NULL;
pad->material_track = NULL;
pad->material_package = NULL;
pad->component = NULL;
@ -559,11 +554,11 @@ gst_mxf_demux_choose_package (GstMXFDemux * demux)
for (i = 0; i < demux->preface->content_storage->n_packages; i++) {
if (demux->preface->content_storage->packages[i] &&
MXF_IS_METADATA_MATERIAL_PACKAGE (demux->preface->content_storage->
packages[i])) {
MXF_IS_METADATA_MATERIAL_PACKAGE (demux->preface->
content_storage->packages[i])) {
ret =
MXF_METADATA_GENERIC_PACKAGE (demux->preface->content_storage->
packages[i]);
MXF_METADATA_GENERIC_PACKAGE (demux->preface->
content_storage->packages[i]);
break;
}
}
@ -736,90 +731,23 @@ gst_mxf_demux_handle_header_metadata_update_streams (GstMXFDemux * demux)
pad->source_package = source_package;
pad->source_track = source_track;
pad->handle_essence_element = NULL;
pad->handler = NULL;
g_free (pad->mapping_data);
pad->handle_func = NULL;
pad->mapping_data = NULL;
switch (track->parent.type) {
case MXF_METADATA_TRACK_PICTURE_ESSENCE:
if (mxf_is_mpeg_essence_track ((MXFMetadataTrack *) source_track))
caps =
mxf_mpeg_create_caps (MXF_METADATA_GENERIC_PACKAGE
(source_package), (MXFMetadataTrack *) source_track, &pad->tags,
&pad->handle_essence_element, &pad->mapping_data);
else if (mxf_is_dv_dif_essence_track ((MXFMetadataTrack *)
source_track))
caps =
mxf_dv_dif_create_caps (MXF_METADATA_GENERIC_PACKAGE
(source_package), (MXFMetadataTrack *) source_track, &pad->tags,
&pad->handle_essence_element, &pad->mapping_data);
else if (mxf_is_jpeg2000_essence_track ((MXFMetadataTrack *)
source_track))
caps =
mxf_jpeg2000_create_caps (MXF_METADATA_GENERIC_PACKAGE
(source_package), (MXFMetadataTrack *) source_track, &pad->tags,
&pad->handle_essence_element, &pad->mapping_data);
else if (mxf_is_d10_essence_track ((MXFMetadataTrack *) source_track))
caps =
mxf_d10_create_caps (MXF_METADATA_GENERIC_PACKAGE
(source_package), (MXFMetadataTrack *) source_track, &pad->tags,
&pad->handle_essence_element, &pad->mapping_data);
else if (mxf_is_up_essence_track ((MXFMetadataTrack *) source_track))
caps =
mxf_up_create_caps (MXF_METADATA_GENERIC_PACKAGE (source_package),
(MXFMetadataTrack *) source_track, &pad->tags,
&pad->handle_essence_element, &pad->mapping_data);
break;
case MXF_METADATA_TRACK_SOUND_ESSENCE:
if (mxf_is_aes_bwf_essence_track ((MXFMetadataTrack *) source_track))
caps =
mxf_aes_bwf_create_caps (MXF_METADATA_GENERIC_PACKAGE
(source_package), (MXFMetadataTrack *) source_track, &pad->tags,
&pad->handle_essence_element, &pad->mapping_data);
else if (mxf_is_dv_dif_essence_track ((MXFMetadataTrack *)
source_track))
caps =
mxf_dv_dif_create_caps (MXF_METADATA_GENERIC_PACKAGE
(source_package), (MXFMetadataTrack *) source_track, &pad->tags,
&pad->handle_essence_element, &pad->mapping_data);
else if (mxf_is_alaw_essence_track ((MXFMetadataTrack *) source_track))
caps =
mxf_alaw_create_caps (MXF_METADATA_GENERIC_PACKAGE
(source_package), (MXFMetadataTrack *) source_track, &pad->tags,
&pad->handle_essence_element, &pad->mapping_data);
else if (mxf_is_mpeg_essence_track ((MXFMetadataTrack *) source_track))
caps =
mxf_mpeg_create_caps (MXF_METADATA_GENERIC_PACKAGE
(source_package), (MXFMetadataTrack *) source_track, &pad->tags,
&pad->handle_essence_element, &pad->mapping_data);
else if (mxf_is_d10_essence_track ((MXFMetadataTrack *) source_track))
caps =
mxf_d10_create_caps (MXF_METADATA_GENERIC_PACKAGE
(source_package), (MXFMetadataTrack *) source_track, &pad->tags,
&pad->handle_essence_element, &pad->mapping_data);
break;
case MXF_METADATA_TRACK_DATA_ESSENCE:
if (mxf_is_dv_dif_essence_track ((MXFMetadataTrack *) source_track))
caps =
mxf_dv_dif_create_caps (MXF_METADATA_GENERIC_PACKAGE
(source_package), (MXFMetadataTrack *) source_track, &pad->tags,
&pad->handle_essence_element, &pad->mapping_data);
else if (mxf_is_mpeg_essence_track ((MXFMetadataTrack *) source_track))
caps =
mxf_mpeg_create_caps (MXF_METADATA_GENERIC_PACKAGE
(source_package), (MXFMetadataTrack *) source_track, &pad->tags,
&pad->handle_essence_element, &pad->mapping_data);
else if (mxf_is_d10_essence_track ((MXFMetadataTrack *) source_track))
caps =
mxf_d10_create_caps (MXF_METADATA_GENERIC_PACKAGE
(source_package), (MXFMetadataTrack *) source_track, &pad->tags,
&pad->handle_essence_element, &pad->mapping_data);
break;
default:
g_assert_not_reached ();
break;
pad->handler = mxf_essence_element_handler_find (source_track);
if (!pad->handler) {
GST_WARNING_OBJECT (demux, "No essence element handler for track found");
gst_object_unref (pad);
continue;
}
caps =
pad->handler->create_caps (source_track, &pad->tags, &pad->handle_func,
&pad->mapping_data);
if (!caps) {
GST_WARNING_OBJECT (demux, "No caps created, ignoring stream");
gst_object_unref (pad);
@ -1081,13 +1009,11 @@ gst_mxf_demux_handle_generic_container_essence_element (GstMXFDemux * demux,
GST_BUFFER_OFFSET_END (inbuf) = GST_BUFFER_OFFSET_NONE;
gst_buffer_set_caps (inbuf, pad->caps);
if (pad->handle_essence_element) {
if (pad->handle_func) {
/* Takes ownership of inbuf */
ret =
pad->handle_essence_element (key, inbuf, pad->caps,
(MXFMetadataGenericPackage *) pad->source_package,
(MXFMetadataTrack *) pad->source_track, pad->component,
pad->mapping_data, &outbuf);
pad->handle_func (key, inbuf, pad->caps,
pad->source_track, pad->component, pad->mapping_data, &outbuf);
inbuf = NULL;
} else {
outbuf = inbuf;

View file

@ -39,18 +39,18 @@
GST_DEBUG_CATEGORY_EXTERN (mxf_debug);
#define GST_CAT_DEFAULT mxf_debug
gboolean
mxf_is_dv_dif_essence_track (const MXFMetadataTrack * track)
static gboolean
mxf_is_dv_dif_essence_track (const MXFMetadataTimelineTrack * track)
{
guint i;
g_return_val_if_fail (track != NULL, FALSE);
if (track->descriptor == NULL)
if (track->parent.descriptor == NULL)
return FALSE;
for (i = 0; i < track->n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->descriptor[i];
for (i = 0; i < track->parent.n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->parent.descriptor[i];
MXFUL *key;
if (!d)
@ -68,9 +68,10 @@ mxf_is_dv_dif_essence_track (const MXFMetadataTrack * track)
static GstFlowReturn
mxf_dv_dif_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
GstCaps * caps, MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, MXFMetadataStructuralComponent * component,
gpointer mapping_data, GstBuffer ** outbuf)
GstCaps * caps,
MXFMetadataTimelineTrack * track,
MXFMetadataStructuralComponent * component, gpointer mapping_data,
GstBuffer ** outbuf)
{
*outbuf = buffer;
@ -84,30 +85,28 @@ mxf_dv_dif_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
}
GstCaps *
mxf_dv_dif_create_caps (MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, GstTagList ** tags,
MXFEssenceElementHandler * handler, gpointer * mapping_data)
static GstCaps *
mxf_dv_dif_create_caps (MXFMetadataTimelineTrack * track, GstTagList ** tags,
MXFEssenceElementHandleFunc * handler, gpointer * mapping_data)
{
MXFMetadataFileDescriptor *f = NULL;
guint i;
GstCaps *caps = NULL;
g_return_val_if_fail (package != NULL, NULL);
g_return_val_if_fail (track != NULL, NULL);
if (track->descriptor == NULL) {
if (track->parent.descriptor == NULL) {
GST_ERROR ("No descriptor found for this track");
return NULL;
}
for (i = 0; i < track->n_descriptor; i++) {
if (!track->descriptor[i])
for (i = 0; i < track->parent.n_descriptor; i++) {
if (!track->parent.descriptor[i])
continue;
if (MXF_IS_METADATA_FILE_DESCRIPTOR (track->descriptor[i]) &&
!MXF_IS_METADATA_MULTIPLE_DESCRIPTOR (track->descriptor[i])) {
f = track->descriptor[i];
if (MXF_IS_METADATA_FILE_DESCRIPTOR (track->parent.descriptor[i]) &&
!MXF_IS_METADATA_MULTIPLE_DESCRIPTOR (track->parent.descriptor[i])) {
f = track->parent.descriptor[i];
}
}
@ -138,8 +137,13 @@ mxf_dv_dif_create_caps (MXFMetadataGenericPackage * package,
return caps;
}
static const MXFEssenceElementHandler mxf_dv_dif_essence_element_handler = {
mxf_is_dv_dif_essence_track,
mxf_dv_dif_create_caps
};
void
mxf_dv_dif_init (void)
{
mxf_essence_element_handler_register (&mxf_dv_dif_essence_element_handler);
}

View file

@ -28,11 +28,6 @@
#include "mxfparse.h"
gboolean mxf_is_dv_dif_essence_track (const MXFMetadataTrack *track);
GstCaps *
mxf_dv_dif_create_caps (MXFMetadataGenericPackage *package, MXFMetadataTrack *track, GstTagList **tags, MXFEssenceElementHandler *handler, gpointer *mapping_data);
void mxf_dv_dif_init (void);
#endif /* __MXF_DV_DIF_H__ */

View file

@ -38,18 +38,18 @@
GST_DEBUG_CATEGORY_EXTERN (mxf_debug);
#define GST_CAT_DEFAULT mxf_debug
gboolean
mxf_is_jpeg2000_essence_track (const MXFMetadataTrack * track)
static gboolean
mxf_is_jpeg2000_essence_track (const MXFMetadataTimelineTrack * track)
{
guint i;
g_return_val_if_fail (track != NULL, FALSE);
if (track->descriptor == NULL)
if (track->parent.descriptor == NULL)
return FALSE;
for (i = 0; i < track->n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->descriptor[i];
for (i = 0; i < track->parent.n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->parent.descriptor[i];
MXFUL *key;
if (!d)
@ -68,9 +68,10 @@ mxf_is_jpeg2000_essence_track (const MXFMetadataTrack * track)
static GstFlowReturn
mxf_jpeg2000_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
GstCaps * caps, MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, MXFMetadataStructuralComponent * component,
gpointer mapping_data, GstBuffer ** outbuf)
GstCaps * caps,
MXFMetadataTimelineTrack * track,
MXFMetadataStructuralComponent * component, gpointer mapping_data,
GstBuffer ** outbuf)
{
*outbuf = buffer;
@ -84,10 +85,9 @@ mxf_jpeg2000_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
}
GstCaps *
mxf_jpeg2000_create_caps (MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, GstTagList ** tags,
MXFEssenceElementHandler * handler, gpointer * mapping_data)
static GstCaps *
mxf_jpeg2000_create_caps (MXFMetadataTimelineTrack * track, GstTagList ** tags,
MXFEssenceElementHandleFunc * handler, gpointer * mapping_data)
{
MXFMetadataFileDescriptor *f = NULL;
MXFMetadataGenericPictureEssenceDescriptor *p = NULL;
@ -95,26 +95,26 @@ mxf_jpeg2000_create_caps (MXFMetadataGenericPackage * package,
GstCaps *caps = NULL;
guint32 fourcc;
g_return_val_if_fail (package != NULL, NULL);
g_return_val_if_fail (track != NULL, NULL);
if (track->descriptor == NULL) {
if (track->parent.descriptor == NULL) {
GST_ERROR ("No descriptor found for this track");
return NULL;
}
for (i = 0; i < track->n_descriptor; i++) {
if (!track->descriptor[i])
for (i = 0; i < track->parent.n_descriptor; i++) {
if (!track->parent.descriptor[i])
continue;
if (MXF_IS_METADATA_GENERIC_PICTURE_ESSENCE_DESCRIPTOR (track->
descriptor[i])) {
p = (MXFMetadataGenericPictureEssenceDescriptor *) track->descriptor[i];
f = track->descriptor[i];
parent.descriptor[i])) {
p = (MXFMetadataGenericPictureEssenceDescriptor *) track->parent.
descriptor[i];
f = track->parent.descriptor[i];
break;
} else if (MXF_IS_METADATA_FILE_DESCRIPTOR (track->descriptor[i]) &&
!MXF_IS_METADATA_MULTIPLE_DESCRIPTOR (track->descriptor[i])) {
f = track->descriptor[i];
} else if (MXF_IS_METADATA_FILE_DESCRIPTOR (track->parent.descriptor[i]) &&
!MXF_IS_METADATA_MULTIPLE_DESCRIPTOR (track->parent.descriptor[i])) {
f = track->parent.descriptor[i];
}
}
@ -198,7 +198,13 @@ mxf_jpeg2000_create_caps (MXFMetadataGenericPackage * package,
return caps;
}
static const MXFEssenceElementHandler mxf_jpeg2000_essence_element_handler = {
mxf_is_jpeg2000_essence_track,
mxf_jpeg2000_create_caps
};
void
mxf_jpeg2000_init (void)
{
mxf_essence_element_handler_register (&mxf_jpeg2000_essence_element_handler);
}

View file

@ -28,11 +28,6 @@
#include "mxfparse.h"
gboolean mxf_is_jpeg2000_essence_track (const MXFMetadataTrack *track);
GstCaps *
mxf_jpeg2000_create_caps (MXFMetadataGenericPackage *package, MXFMetadataTrack *track, GstTagList **tags, MXFEssenceElementHandler *handler, gpointer *mapping_data);
void mxf_jpeg2000_init (void);
#endif /* __MXF_JPEG2000_H__ */

View file

@ -91,6 +91,35 @@ static const guint8 _profile_and_level_ul[] = {
0x0a, 0x00, 0x00
};
/* SMPTE 381M 8.1 */
#define MXF_TYPE_METADATA_MPEG_VIDEO_DESCRIPTOR \
(mxf_metadata_mpeg_video_descriptor_get_type())
#define MXF_METADATA_MPEG_VIDEO_DESCRIPTOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),MXF_TYPE_METADATA_MPEG_VIDEO_DESCRIPTOR, MXFMetadataMPEGVideoDescriptor))
#define MXF_IS_METADATA_MPEG_VIDEO_DESCRIPTOR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),MXF_TYPE_METADATA_MPEG_VIDEO_DESCRIPTOR))
typedef struct _MXFMetadataMPEGVideoDescriptor MXFMetadataMPEGVideoDescriptor;
typedef MXFMetadataBaseClass MXFMetadataMPEGVideoDescriptorClass;
GType mxf_metadata_mpeg_video_descriptor_get_type (void);
struct _MXFMetadataMPEGVideoDescriptor
{
MXFMetadataCDCIPictureEssenceDescriptor parent;
gboolean single_sequence;
gboolean const_b_frames;
guint8 coded_content_type;
gboolean low_delay;
gboolean closed_gop;
gboolean identical_gop;
guint16 max_gop;
guint16 b_picture_count;
guint32 bitrate;
guint8 profile_and_level;
};
G_DEFINE_TYPE (MXFMetadataMPEGVideoDescriptor,
mxf_metadata_mpeg_video_descriptor,
MXF_TYPE_METADATA_CDCI_PICTURE_ESSENCE_DESCRIPTOR);
@ -195,18 +224,18 @@ static void
mxf_metadata_mpeg_video_descriptor_handle_tag;
}
gboolean
mxf_is_mpeg_essence_track (const MXFMetadataTrack * track)
static gboolean
mxf_is_mpeg_essence_track (const MXFMetadataTimelineTrack * track)
{
guint i;
g_return_val_if_fail (track != NULL, FALSE);
if (track->descriptor == NULL)
if (track->parent.descriptor == NULL)
return FALSE;
for (i = 0; i < track->n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->descriptor[i];
for (i = 0; i < track->parent.n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->parent.descriptor[i];
MXFUL *key;
if (!d)
@ -226,9 +255,9 @@ mxf_is_mpeg_essence_track (const MXFMetadataTrack * track)
static GstFlowReturn
mxf_mpeg_video_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
GstCaps * caps, MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, MXFMetadataStructuralComponent * component,
gpointer mapping_data, GstBuffer ** outbuf)
GstCaps * caps, MXFMetadataTimelineTrack * track,
MXFMetadataStructuralComponent * component, gpointer mapping_data,
GstBuffer ** outbuf)
{
*outbuf = buffer;
@ -244,9 +273,9 @@ mxf_mpeg_video_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
static GstFlowReturn
mxf_mpeg_audio_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
GstCaps * caps, MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, MXFMetadataStructuralComponent * component,
gpointer mapping_data, GstBuffer ** outbuf)
GstCaps * caps, MXFMetadataTimelineTrack * track,
MXFMetadataStructuralComponent * component, gpointer mapping_data,
GstBuffer ** outbuf)
{
*outbuf = buffer;
@ -300,9 +329,8 @@ static const MXFUL sound_essence_compression_dts = { {
};
static GstCaps *
mxf_mpeg_es_create_caps (MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, GstTagList ** tags,
MXFEssenceElementHandler * handler, gpointer * mapping_data,
mxf_mpeg_es_create_caps (MXFMetadataTimelineTrack * track, GstTagList ** tags,
MXFEssenceElementHandleFunc * handler, gpointer * mapping_data,
MXFMetadataGenericPictureEssenceDescriptor * p,
MXFMetadataGenericSoundEssenceDescriptor * s)
{
@ -430,10 +458,9 @@ mxf_mpeg_es_create_caps (MXFMetadataGenericPackage * package,
return caps;
}
GstCaps *
mxf_mpeg_create_caps (MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, GstTagList ** tags,
MXFEssenceElementHandler * handler, gpointer * mapping_data)
static GstCaps *
mxf_mpeg_create_caps (MXFMetadataTimelineTrack * track, GstTagList ** tags,
MXFEssenceElementHandleFunc * handler, gpointer * mapping_data)
{
MXFMetadataFileDescriptor *f = NULL;
MXFMetadataGenericPictureEssenceDescriptor *p = NULL;
@ -441,27 +468,28 @@ mxf_mpeg_create_caps (MXFMetadataGenericPackage * package,
guint i;
GstCaps *caps = NULL;
g_return_val_if_fail (package != NULL, NULL);
g_return_val_if_fail (track != NULL, NULL);
if (track->descriptor == NULL) {
if (track->parent.descriptor == NULL) {
GST_ERROR ("No descriptor found for this track");
return NULL;
}
for (i = 0; i < track->n_descriptor; i++) {
if (!track->descriptor[i])
for (i = 0; i < track->parent.n_descriptor; i++) {
if (!track->parent.descriptor[i])
continue;
if (MXF_IS_METADATA_GENERIC_PICTURE_ESSENCE_DESCRIPTOR (track->
descriptor[i])) {
f = track->descriptor[i];
p = (MXFMetadataGenericPictureEssenceDescriptor *) track->descriptor[i];
parent.descriptor[i])) {
f = track->parent.descriptor[i];
p = (MXFMetadataGenericPictureEssenceDescriptor *) track->parent.
descriptor[i];
break;
} else if (MXF_IS_METADATA_GENERIC_SOUND_ESSENCE_DESCRIPTOR (track->
descriptor[i])) {
f = track->descriptor[i];
s = (MXFMetadataGenericSoundEssenceDescriptor *) track->descriptor[i];
parent.descriptor[i])) {
f = track->parent.descriptor[i];
s = (MXFMetadataGenericSoundEssenceDescriptor *) track->parent.
descriptor[i];
break;
}
}
@ -475,9 +503,7 @@ mxf_mpeg_create_caps (MXFMetadataGenericPackage * package,
if (f->essence_container.u[13] == 0x04) {
GST_DEBUG ("Found MPEG ES stream");
caps =
mxf_mpeg_es_create_caps (package, track, tags, handler, mapping_data, p,
s);
caps = mxf_mpeg_es_create_caps (track, tags, handler, mapping_data, p, s);
} else if (f->essence_container.u[13] == 0x07) {
GST_ERROR ("MPEG PES streams not supported yet");
return NULL;
@ -507,8 +533,14 @@ mxf_mpeg_create_caps (MXFMetadataGenericPackage * package,
return caps;
}
static const MXFEssenceElementHandler mxf_mpeg_essence_element_handler = {
mxf_is_mpeg_essence_track,
mxf_mpeg_create_caps
};
void
mxf_mpeg_init (void)
{
mxf_metadata_register (0x0151, MXF_TYPE_METADATA_MPEG_VIDEO_DESCRIPTOR);
mxf_essence_element_handler_register (&mxf_mpeg_essence_element_handler);
}

View file

@ -29,39 +29,6 @@
#include "mxfparse.h"
#include "mxfmetadata.h"
/* SMPTE 381M 8.1 */
#define MXF_TYPE_METADATA_MPEG_VIDEO_DESCRIPTOR \
(mxf_metadata_mpeg_video_descriptor_get_type())
#define MXF_METADATA_MPEG_VIDEO_DESCRIPTOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),MXF_TYPE_METADATA_MPEG_VIDEO_DESCRIPTOR, MXFMetadataMPEGVideoDescriptor))
#define MXF_IS_METADATA_MPEG_VIDEO_DESCRIPTOR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),MXF_TYPE_METADATA_MPEG_VIDEO_DESCRIPTOR))
typedef struct _MXFMetadataMPEGVideoDescriptor MXFMetadataMPEGVideoDescriptor;
typedef MXFMetadataBaseClass MXFMetadataMPEGVideoDescriptorClass;
GType mxf_metadata_mpeg_video_descriptor_get_type (void);
struct _MXFMetadataMPEGVideoDescriptor {
MXFMetadataCDCIPictureEssenceDescriptor parent;
gboolean single_sequence;
gboolean const_b_frames;
guint8 coded_content_type;
gboolean low_delay;
gboolean closed_gop;
gboolean identical_gop;
guint16 max_gop;
guint16 b_picture_count;
guint32 bitrate;
guint8 profile_and_level;
};
gboolean mxf_is_mpeg_essence_track (const MXFMetadataTrack *track);
GstCaps *
mxf_mpeg_create_caps (MXFMetadataGenericPackage *package, MXFMetadataTrack *track, GstTagList **tags, MXFEssenceElementHandler *handler, gpointer *mapping_data);
void mxf_mpeg_init (void);
#endif /* __MXF_MPEG_H__ */

View file

@ -1015,3 +1015,30 @@ mxf_local_tag_add_to_hash_table (const MXFPrimerPack * primer,
return TRUE;
}
static GSList *_mxf_essence_element_handler_registry = NULL;
void
mxf_essence_element_handler_register (const MXFEssenceElementHandler * handler)
{
_mxf_essence_element_handler_registry =
g_slist_prepend (_mxf_essence_element_handler_registry,
(gpointer) handler);
}
const MXFEssenceElementHandler *
mxf_essence_element_handler_find (const MXFMetadataTimelineTrack * track)
{
GSList *l;
const MXFEssenceElementHandler *ret = NULL;
for (l = _mxf_essence_element_handler_registry; l; l = l->next) {
MXFEssenceElementHandler *current = l->data;
if (current->handles_track (track)) {
ret = current;
}
}
return ret;
}

View file

@ -27,7 +27,12 @@
#include "mxftypes.h"
#include "mxfmetadata.h"
typedef GstFlowReturn (*MXFEssenceElementHandler) (const MXFUL *key, GstBuffer *buffer, GstCaps *caps, MXFMetadataGenericPackage *package, MXFMetadataTrack *track, MXFMetadataStructuralComponent *component, gpointer mapping_data, GstBuffer **outbuf);
typedef GstFlowReturn (*MXFEssenceElementHandleFunc) (const MXFUL *key, GstBuffer *buffer, GstCaps *caps, MXFMetadataTimelineTrack *track, MXFMetadataStructuralComponent *component, gpointer mapping_data, GstBuffer **outbuf);
typedef struct {
gboolean (*handles_track) (const MXFMetadataTimelineTrack *track);
GstCaps * (*create_caps) (MXFMetadataTimelineTrack *track, GstTagList **tags, MXFEssenceElementHandleFunc *handler, gpointer *mapping_data);
} MXFEssenceElementHandler;
gchar * mxf_ul_to_string (const MXFUL *ul, gchar str[48]);
gboolean mxf_ul_is_equal (const MXFUL *a, const MXFUL *b);
@ -90,5 +95,8 @@ gboolean mxf_local_tag_add_to_hash_table (const MXFPrimerPack *primer,
guint16 tag, const guint8 *tag_data, guint16 tag_size,
GHashTable **hash_table);
void mxf_essence_element_handler_register (const MXFEssenceElementHandler *handler);
const MXFEssenceElementHandler * mxf_essence_element_handler_find (const MXFMetadataTimelineTrack *track);
#endif /* __MXF_PARSE_H__ */

View file

@ -49,18 +49,18 @@ typedef struct
guint32 image_end_offset;
} MXFUPMappingData;
gboolean
mxf_is_up_essence_track (const MXFMetadataTrack * track)
static gboolean
mxf_is_up_essence_track (const MXFMetadataTimelineTrack * track)
{
guint i;
g_return_val_if_fail (track != NULL, FALSE);
if (track->descriptor == NULL)
if (track->parent.descriptor == NULL)
return FALSE;
for (i = 0; i < track->n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->descriptor[i];
for (i = 0; i < track->parent.n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->parent.descriptor[i];
MXFUL *key;
if (!d)
@ -78,9 +78,10 @@ mxf_is_up_essence_track (const MXFMetadataTrack * track)
static GstFlowReturn
mxf_up_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
GstCaps * caps, MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, MXFMetadataStructuralComponent * component,
gpointer mapping_data, GstBuffer ** outbuf)
GstCaps * caps,
MXFMetadataTimelineTrack * track,
MXFMetadataStructuralComponent * component, gpointer mapping_data,
GstBuffer ** outbuf)
{
MXFUPMappingData *data = mapping_data;
@ -111,10 +112,9 @@ mxf_up_handle_essence_element (const MXFUL * key, GstBuffer * buffer,
}
static GstCaps *
mxf_up_rgba_create_caps (MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, MXFMetadataRGBAPictureEssenceDescriptor * d,
GstTagList ** tags,
MXFEssenceElementHandler * handler, gpointer * mapping_data)
mxf_up_rgba_create_caps (MXFMetadataTimelineTrack * track,
MXFMetadataRGBAPictureEssenceDescriptor * d, GstTagList ** tags,
MXFEssenceElementHandleFunc * handler, gpointer * mapping_data)
{
GstCaps *caps = NULL;
@ -201,10 +201,9 @@ mxf_up_rgba_create_caps (MXFMetadataGenericPackage * package,
return caps;
}
GstCaps *
mxf_up_create_caps (MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, GstTagList ** tags,
MXFEssenceElementHandler * handler, gpointer * mapping_data)
static GstCaps *
mxf_up_create_caps (MXFMetadataTimelineTrack * track, GstTagList ** tags,
MXFEssenceElementHandleFunc * handler, gpointer * mapping_data)
{
MXFMetadataGenericPictureEssenceDescriptor *p = NULL;
MXFMetadataCDCIPictureEssenceDescriptor *c = NULL;
@ -212,26 +211,30 @@ mxf_up_create_caps (MXFMetadataGenericPackage * package,
guint i;
GstCaps *caps = NULL;
g_return_val_if_fail (package != NULL, NULL);
g_return_val_if_fail (track != NULL, NULL);
if (track->descriptor == NULL) {
if (track->parent.descriptor == NULL) {
GST_ERROR ("No descriptor found for this track");
return NULL;
}
for (i = 0; i < track->n_descriptor; i++) {
if (!track->descriptor[i])
for (i = 0; i < track->parent.n_descriptor; i++) {
if (!track->parent.descriptor[i])
continue;
if (MXF_IS_METADATA_RGBA_PICTURE_ESSENCE_DESCRIPTOR (track->descriptor[i])) {
p = (MXFMetadataGenericPictureEssenceDescriptor *) track->descriptor[i];
r = (MXFMetadataRGBAPictureEssenceDescriptor *) track->descriptor[i];
if (MXF_IS_METADATA_RGBA_PICTURE_ESSENCE_DESCRIPTOR (track->parent.
descriptor[i])) {
p = (MXFMetadataGenericPictureEssenceDescriptor *) track->parent.
descriptor[i];
r = (MXFMetadataRGBAPictureEssenceDescriptor *) track->parent.
descriptor[i];
break;
} else if (MXF_IS_METADATA_CDCI_PICTURE_ESSENCE_DESCRIPTOR (track->
descriptor[i])) {
p = (MXFMetadataGenericPictureEssenceDescriptor *) track->descriptor[i];
c = (MXFMetadataCDCIPictureEssenceDescriptor *) track->descriptor[i];
parent.descriptor[i])) {
p = (MXFMetadataGenericPictureEssenceDescriptor *) track->parent.
descriptor[i];
c = (MXFMetadataCDCIPictureEssenceDescriptor *) track->parent.
descriptor[i];
}
}
@ -243,9 +246,7 @@ mxf_up_create_caps (MXFMetadataGenericPackage * package,
*handler = mxf_up_handle_essence_element;
if (r) {
caps =
mxf_up_rgba_create_caps (package, track, r, tags, handler,
mapping_data);
caps = mxf_up_rgba_create_caps (track, r, tags, handler, mapping_data);
} else {
GST_ERROR ("CDCI uncompressed picture essence not supported yet");
return NULL;
@ -258,7 +259,13 @@ mxf_up_create_caps (MXFMetadataGenericPackage * package,
return caps;
}
static const MXFEssenceElementHandler mxf_up_essence_element_handler = {
mxf_is_up_essence_track,
mxf_up_create_caps
};
void
mxf_up_init (void)
{
mxf_essence_element_handler_register (&mxf_up_essence_element_handler);
}

View file

@ -28,11 +28,6 @@
#include "mxfparse.h"
gboolean mxf_is_up_essence_track (const MXFMetadataTrack *track);
GstCaps *
mxf_up_create_caps (MXFMetadataGenericPackage *package, MXFMetadataTrack *track, GstTagList **tags, MXFEssenceElementHandler *handler, gpointer *mapping_data);
void mxf_up_init (void);
#endif /* __MXF_UP_H__ */