gst/mxf/: Add fundamental support for DV-DIF essence streams.

Original commit message from CVS:
* gst/mxf/Makefile.am:
* gst/mxf/mxfdemux.c:
(gst_mxf_demux_handle_header_metadata_update_streams),
(gst_mxf_demux_handle_klv_packet):
* gst/mxf/mxfdv-dif.c: (mxf_is_dv_dif_essence_track),
(mxf_dv_dif_handle_essence_element), (mxf_dv_dif_create_caps):
* gst/mxf/mxfdv-dif.h:
* gst/mxf/mxfparse.c: (mxf_is_descriptive_metadata):
* gst/mxf/mxfparse.h:
Add fundamental support for DV-DIF essence streams.
Handle descriptive metadata packets as metadata packets.
This commit is contained in:
Sebastian Dröge 2008-11-27 10:09:53 +00:00
parent e3337c6868
commit 9e6654352e
7 changed files with 205 additions and 5 deletions

View file

@ -1,3 +1,18 @@
2008-11-27 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* gst/mxf/Makefile.am:
* gst/mxf/mxfdemux.c:
(gst_mxf_demux_handle_header_metadata_update_streams),
(gst_mxf_demux_handle_klv_packet):
* gst/mxf/mxfdv-dif.c: (mxf_is_dv_dif_essence_track),
(mxf_dv_dif_handle_essence_element), (mxf_dv_dif_create_caps):
* gst/mxf/mxfdv-dif.h:
* gst/mxf/mxfparse.c: (mxf_is_descriptive_metadata):
* gst/mxf/mxfparse.h:
Add fundamental support for DV-DIF essence streams.
Handle descriptive metadata packets as metadata packets.
2008-11-27 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* gst/mxf/mxfdemux.c: (gst_mxf_demux_reset),

View file

@ -5,7 +5,8 @@ libgstmxf_la_SOURCES = \
mxfdemux.c \
mxfparse.c \
mxfaes-bwf.c \
mxfmpeg.c
mxfmpeg.c \
mxfdv-dif.c
libgstmxf_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS)
libgstmxf_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS)
@ -16,5 +17,6 @@ noinst_HEADERS = \
mxfparse.h \
mxfaes-bwf.h \
mxfmpeg.h \
mxfdv-dif.h \
mxftypes.h

View file

@ -33,6 +33,7 @@
#include "mxfparse.h"
#include "mxfaes-bwf.h"
#include "mxfmpeg.h"
#include "mxfdv-dif.h"
#include <string.h>
@ -1274,9 +1275,8 @@ gst_mxf_demux_handle_header_metadata_resolve_references (GstMXFDemux * demux)
MXFMetadataEssenceContainerData, i);
for (j = 0; j < demux->content_storage.n_essence_container_data; j++) {
if (mxf_ul_is_equal (&demux->
content_storage.essence_container_data_uids[j],
&data->instance_uid)) {
if (mxf_ul_is_equal (&demux->content_storage.
essence_container_data_uids[j], &data->instance_uid)) {
demux->content_storage.essence_container_data[j] = data;
break;
}
@ -1812,14 +1812,26 @@ choose_package:
caps =
mxf_mpeg_video_create_caps (source_package, source_track,
&pad->tags, &pad->handle_essence_element, &pad->mapping_data);
else if (mxf_is_dv_dif_essence_track (source_track))
caps =
mxf_dv_dif_create_caps (source_package, 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 (source_track))
caps =
mxf_aes_bwf_create_caps (source_package, source_track, &pad->tags,
&pad->handle_essence_element, &pad->mapping_data);
else if (mxf_is_dv_dif_essence_track (source_track))
caps =
mxf_dv_dif_create_caps (source_package, 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 (source_track))
caps =
mxf_dv_dif_create_caps (source_package, source_track,
&pad->tags, &pad->handle_essence_element, &pad->mapping_data);
break;
default:
g_assert_not_reached ();
@ -2391,7 +2403,7 @@ gst_mxf_demux_handle_klv_packet (GstMXFDemux * demux, const MXFUL * key,
if (demux->update_metadata
&& !mxf_timestamp_is_unknown (&demux->preface.last_modified_date)
&& !mxf_is_metadata (key)
&& !mxf_is_metadata (key) && !mxf_is_descriptive_metadata (key)
&& !mxf_is_fill (key)) {
if ((ret =
gst_mxf_demux_handle_header_metadata_resolve_references (demux)) !=

122
gst/mxf/mxfdv-dif.c Normal file
View file

@ -0,0 +1,122 @@
/* GStreamer
* Copyright (C) 2008 Sebastian Dröge <sebastian.droege@collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* Implementation of SMPTE 383M - Mapping DV-DIF data into the MXF
* Generic Container
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <string.h>
#include "mxfdv-dif.h"
GST_DEBUG_CATEGORY_EXTERN (mxf_debug);
#define GST_CAT_DEFAULT mxf_debug
gboolean
mxf_is_dv_dif_essence_track (const MXFMetadataTrack * track)
{
guint i;
g_return_val_if_fail (track != NULL, FALSE);
if (track->descriptor == NULL)
return FALSE;
for (i = 0; i < track->n_descriptor; i++) {
MXFMetadataFileDescriptor *d = track->descriptor[i];
MXFUL *key = &d->essence_container;
/* SMPTE 383M 8 */
if (mxf_is_generic_container_essence_container_label (key) &&
key->u[12] == 0x02 && key->u[13] == 0x02)
return TRUE;
}
return FALSE;
}
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)
{
*outbuf = buffer;
/* SMPTE 383 6.1.1 */
if (key->u[12] != 0x18 || (key->u[14] != 0x01 && key->u[14] != 0x02)) {
GST_ERROR ("Invalid DV-DIF essence element");
return GST_FLOW_ERROR;
}
return GST_FLOW_OK;
}
GstCaps *
mxf_dv_dif_create_caps (MXFMetadataGenericPackage * package,
MXFMetadataTrack * track, GstTagList ** tags,
MXFEssenceElementHandler * 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) {
GST_ERROR ("No descriptor found for this track");
return NULL;
}
for (i = 0; i < track->n_descriptor; i++) {
if (((MXFMetadataGenericDescriptor *) track->descriptor[i])->
is_file_descriptor
&& ((MXFMetadataGenericDescriptor *) track->descriptor[i])->type !=
MXF_METADATA_MULTIPLE_DESCRIPTOR) {
f = track->descriptor[i];
}
}
if (!f) {
GST_ERROR ("No descriptor found for this track");
return NULL;
}
*handler = mxf_dv_dif_handle_essence_element;
/* SMPTE 383M 8 */
/* TODO: might be video or audio only, use values of the generic sound/picture
* descriptor in the caps in that case
* Also dvdemux might not forward timestamps
*/
if (f->essence_container.u[13] == 0x02) {
GST_DEBUG ("Found DV-DIF stream");
caps =
gst_caps_new_simple ("video/x-dv", "systemstream", G_TYPE_BOOLEAN, TRUE,
NULL);
}
return caps;
}

36
gst/mxf/mxfdv-dif.h Normal file
View file

@ -0,0 +1,36 @@
/* GStreamer
* Copyright (C) 2008 Sebastian Dröge <sebastian.droege@collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* Implementation of SMPTE 383M - Mapping DV-DIF data into the MXF
* Generic Container
*/
#ifndef __MXF_DV_DIF_H__
#define __MXF_DV_DIF_H__
#include <gst/gst.h>
#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);
#endif /* __MXF_DV_DIF_H__ */

View file

@ -141,6 +141,18 @@ mxf_is_metadata (const MXFUL * key)
return (memcmp (key, metadata_key, 13) == 0 && key->u[15] == 0x00);
}
/* SMPTE 377M 8.7.3 */
gboolean
mxf_is_descriptive_metadata (const MXFUL * key)
{
return (memcmp (key, mxf_key, 4) == 0 &&
key->u[4] == 0x02 &&
key->u[6] == 0x01 &&
key->u[7] == 0x01 &&
key->u[8] == 0x0d &&
key->u[9] == 0x01 && key->u[10] == 0x04 && key->u[11] == 0x01);
}
gboolean
mxf_is_random_index_pack (const MXFUL * key)
{

View file

@ -48,6 +48,7 @@ gboolean mxf_is_footer_partition_pack (const MXFUL *key);
gboolean mxf_is_primer_pack (const MXFUL *key);
gboolean mxf_is_metadata (const MXFUL *key);
gboolean mxf_is_descriptive_metadata (const MXFUL *key);
gboolean mxf_is_random_index_pack (const MXFUL *key);
gboolean mxf_is_index_table_segment (const MXFUL *key);