From 9e6654352e1e92664efad60f9a951cc2dd3c2a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 27 Nov 2008 10:09:53 +0000 Subject: 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. --- ChangeLog | 15 +++++++ gst/mxf/Makefile.am | 4 +- gst/mxf/mxfdemux.c | 20 +++++++-- gst/mxf/mxfdv-dif.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++ gst/mxf/mxfdv-dif.h | 36 ++++++++++++++++ gst/mxf/mxfparse.c | 12 ++++++ gst/mxf/mxfparse.h | 1 + 7 files changed, 205 insertions(+), 5 deletions(-) create mode 100644 gst/mxf/mxfdv-dif.c create mode 100644 gst/mxf/mxfdv-dif.h diff --git a/ChangeLog b/ChangeLog index f28fdf2b..3bd1573c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-11-27 Sebastian Dröge + + * 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 * gst/mxf/mxfdemux.c: (gst_mxf_demux_reset), diff --git a/gst/mxf/Makefile.am b/gst/mxf/Makefile.am index 0113d9d1..6b1529f5 100644 --- a/gst/mxf/Makefile.am +++ b/gst/mxf/Makefile.am @@ -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 diff --git a/gst/mxf/mxfdemux.c b/gst/mxf/mxfdemux.c index 11bd6dec..0098951e 100644 --- a/gst/mxf/mxfdemux.c +++ b/gst/mxf/mxfdemux.c @@ -33,6 +33,7 @@ #include "mxfparse.h" #include "mxfaes-bwf.h" #include "mxfmpeg.h" +#include "mxfdv-dif.h" #include @@ -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)) != diff --git a/gst/mxf/mxfdv-dif.c b/gst/mxf/mxfdv-dif.c new file mode 100644 index 00000000..71268ff1 --- /dev/null +++ b/gst/mxf/mxfdv-dif.c @@ -0,0 +1,122 @@ +/* GStreamer + * Copyright (C) 2008 Sebastian Dröge + * + * 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 +#include + +#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; +} diff --git a/gst/mxf/mxfdv-dif.h b/gst/mxf/mxfdv-dif.h new file mode 100644 index 00000000..a4d39f08 --- /dev/null +++ b/gst/mxf/mxfdv-dif.h @@ -0,0 +1,36 @@ +/* GStreamer + * Copyright (C) 2008 Sebastian Dröge + * + * 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 + +#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__ */ diff --git a/gst/mxf/mxfparse.c b/gst/mxf/mxfparse.c index 3d6587ff..90fa6348 100644 --- a/gst/mxf/mxfparse.c +++ b/gst/mxf/mxfparse.c @@ -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) { diff --git a/gst/mxf/mxfparse.h b/gst/mxf/mxfparse.h index 730829fe..99295762 100644 --- a/gst/mxf/mxfparse.h +++ b/gst/mxf/mxfparse.h @@ -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); -- cgit v1.2.1