Commit e5003989 authored by Sebastian Dröge's avatar Sebastian Dröge

mxf: Add MXF muxer

This muxer currently only supports OP1a and is
probably not yet 100% complying to the standards.
parent 86719f19
......@@ -160,6 +160,10 @@ fi
AM_CONDITIONAL(HAVE_GCC_ASM, test "x$HAVE_GCC_ASM" = "xyes")
dnl *** checks for library functions ***
AC_CHECK_FUNCS([gmtime_r])
dnl *** checks for headers ***
AC_CHECK_HEADERS([sys/utsname.h])
dnl *** checks for dependency libraries ***
......
......@@ -14,7 +14,9 @@ libgstmxf_la_SOURCES = \
mxfup.c \
mxfvc3.c \
mxfmetadata.c \
mxfdms1.c
mxfdms1.c \
mxfwrite.c \
mxfmux.c
libgstmxf_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
libgstmxf_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) \
......@@ -35,5 +37,7 @@ noinst_HEADERS = \
mxfvc3.h \
mxftypes.h \
mxfmetadata.h \
mxfdms1.h
mxfdms1.h \
mxfwrite.h \
mxfmux.h
......@@ -24,6 +24,7 @@
#include "mxfquark.h"
#include "mxfdemux.h"
#include "mxfmux.h"
#include "mxfaes-bwf.h"
#include "mxfmpeg.h"
#include "mxfdv-dif.h"
......@@ -53,6 +54,8 @@ mxf_init (void)
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (mxf_debug, "mxf", 0, "MXF");
mxf_init ();
mxf_quark_initialize ();
mxf_metadata_init_types ();
......@@ -67,11 +70,10 @@ plugin_init (GstPlugin * plugin)
mxf_dms1_initialize ();
if (!gst_element_register (plugin, "mxfdemux", GST_RANK_PRIMARY,
GST_TYPE_MXF_DEMUX))
GST_TYPE_MXF_DEMUX) ||
!gst_element_register (plugin, "mxfmux", GST_RANK_NONE, GST_TYPE_MXF_MUX))
return FALSE;
GST_DEBUG_CATEGORY_INIT (mxf_debug, "mxf", 0, "MXF");
return TRUE;
}
......
This diff is collapsed.
......@@ -386,6 +386,7 @@ struct _MXFMetadataBaseClass {
gboolean (*handle_tag) (MXFMetadataBase *self, MXFPrimerPack *primer, guint16 tag, const guint8 *tag_data, guint tag_size);
gboolean (*resolve) (MXFMetadataBase *self, GHashTable *metadata);
GstStructure * (*to_structure) (MXFMetadataBase *self);
GList * (*write_tags) (MXFMetadataBase *self, MXFPrimerPack *primer);
GQuark name_quark;
};
......@@ -751,15 +752,20 @@ struct _MXFDescriptiveMetadataFrameworkInterface {
gboolean mxf_metadata_base_parse (MXFMetadataBase *self, MXFPrimerPack *primer, const guint8 *data, guint size);
gboolean mxf_metadata_base_resolve (MXFMetadataBase *self, GHashTable *metadata);
GstStructure * mxf_metadata_base_to_structure (MXFMetadataBase *self);
GstBuffer * mxf_metadata_base_to_buffer (MXFMetadataBase *self, MXFPrimerPack *primer);
MXFMetadata *mxf_metadata_new (guint16 type, MXFPrimerPack *primer, guint64 offset, const guint8 *data, guint size);
void mxf_metadata_register (GType type);
void mxf_metadata_init_types (void);
MXFMetadataTrackType mxf_metadata_track_identifier_parse (const MXFUL * track_identifier);
const MXFUL * mxf_metadata_track_identifier_get (MXFMetadataTrackType type);
void mxf_metadata_generic_picture_essence_descriptor_set_caps (MXFMetadataGenericPictureEssenceDescriptor * self, GstCaps * caps);
void mxf_metadata_generic_picture_essence_descriptor_from_caps (MXFMetadataGenericPictureEssenceDescriptor * self, GstCaps * caps);
void mxf_metadata_generic_sound_essence_descriptor_set_caps (MXFMetadataGenericSoundEssenceDescriptor * self, GstCaps * caps);
void mxf_metadata_generic_sound_essence_descriptor_from_caps (MXFMetadataGenericSoundEssenceDescriptor * self, GstCaps * caps);
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);
......
This diff is collapsed.
/* GStreamer
* Copyright (C) 2009 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.
*/
#ifndef __MXF_MUX_H__
#define __MXF_MUX_H__
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
#include <gst/base/gstcollectpads.h>
#include "mxfwrite.h"
G_BEGIN_DECLS
#define GST_TYPE_MXF_MUX \
(gst_mxf_mux_get_type ())
#define GST_MXF_MUX(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MXF_MUX, GstMXFMux))
#define GST_MXF_MUX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MXF_MUX, GstMXFMuxClass))
#define GST_IS_MXF_MUX(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MXF_MUX))
#define GST_IS_MXF_MUX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MXF_MUX))
typedef struct
{
GstCollectData collect;
guint64 pos;
GstClockTime last_timestamp;
MXFMetadataFileDescriptor *descriptor;
GstAdapter *adapter;
gpointer mapping_data;
const MXFEssenceElementWriter *writer;
MXFEssenceElementWriteFunc write_func;
MXFMetadataSourcePackage *source_package;
MXFMetadataTimelineTrack *source_track;
} GstMXFMuxPad;
typedef enum
{
GST_MXF_MUX_STATE_HEADER,
GST_MXF_MUX_STATE_DATA
} GstMXFMuxState;
typedef struct _GstMXFMux {
GstElement element;
GstPad *srcpad;
GstCollectPads *collect;
GstPadEventFunction collect_event;
GstMXFMuxState state;
guint n_pads;
guint64 offset;
MXFPartitionPack partition;
MXFPrimerPack primer;
GHashTable *metadata;
MXFMetadataPreface *preface;
MXFFraction min_edit_rate;
guint64 last_gc_position;
GstClockTime last_gc_timestamp;
gchar *application;
} GstMXFMux;
typedef struct _GstMXFMuxClass {
GstElementClass parent;
} GstMXFMuxClass;
GType gst_mxf_mux_get_type (void);
G_END_DECLS
#endif /* __MXF_MUX_H__ */
......@@ -468,6 +468,14 @@ mxf_product_version_parse (MXFProductVersion * product_version,
return TRUE;
}
gboolean
mxf_product_version_is_valid (const MXFProductVersion * version)
{
static const guint8 null[sizeof (MXFProductVersion)] = { 0, };
return (memcmp (version, &null, sizeof (MXFProductVersion)) == 0);
}
gboolean
mxf_ul_array_parse (MXFUL ** array, guint32 * count, const guint8 * data,
guint size)
......@@ -1023,7 +1031,12 @@ mxf_primer_pack_reset (MXFPrimerPack * pack)
if (pack->mappings)
g_hash_table_destroy (pack->mappings);
if (pack->reverse_mappings)
g_hash_table_destroy (pack->reverse_mappings);
memset (pack, 0, sizeof (MXFPrimerPack));
pack->next_free_tag = 0x8000;
}
/* structural metadata parsing */
......@@ -1051,7 +1064,10 @@ mxf_local_tag_parse (const guint8 * data, guint size, guint16 * tag,
void
mxf_local_tag_free (MXFLocalTag * tag)
{
g_free (tag->data);
if (tag->g_slice)
g_slice_free1 (tag->size, tag->data);
else
g_free (tag->data);
g_slice_free (MXFLocalTag, tag);
}
......@@ -1100,6 +1116,32 @@ mxf_local_tag_add_to_hash_table (const MXFPrimerPack * primer,
return TRUE;
}
gboolean
mxf_local_tag_insert (MXFLocalTag * tag, GHashTable ** hash_table)
{
#ifndef GST_DISABLE_GST_DEBUG
gchar str[48];
#endif
g_return_val_if_fail (tag != NULL, FALSE);
g_return_val_if_fail (hash_table != NULL, FALSE);
if (*hash_table == NULL)
*hash_table =
g_hash_table_new_full ((GHashFunc) mxf_ul_hash,
(GEqualFunc) mxf_ul_is_equal, (GDestroyNotify) NULL,
(GDestroyNotify) mxf_local_tag_free);
g_return_val_if_fail (*hash_table != NULL, FALSE);
GST_DEBUG ("Adding local tag 0x%04x with UL %s and size %u", tag,
mxf_ul_to_string (&tag->key, str), tag->size);
g_hash_table_insert (*hash_table, &tag->key, tag);
return TRUE;
}
static GSList *_mxf_essence_element_handler_registry = NULL;
void
......
......@@ -72,6 +72,7 @@ gchar * mxf_utf16_to_utf8 (const guint8 * data, guint size);
gboolean mxf_product_version_parse (MXFProductVersion * product_version,
const guint8 * data, guint size);
gboolean mxf_product_version_is_valid (const MXFProductVersion *version);
gboolean mxf_fraction_parse (MXFFraction *fraction, const guint8 *data, guint size);
gdouble mxf_fraction_to_double (const MXFFraction *fraction);
......@@ -96,11 +97,12 @@ void mxf_index_table_segment_reset (MXFIndexTableSegment *segment);
gboolean mxf_local_tag_parse (const guint8 * data, guint size, guint16 * tag,
guint16 * tag_size, const guint8 ** tag_data);
void gst_mxf_local_tag_free (MXFLocalTag *tag);
void mxf_local_tag_free (MXFLocalTag *tag);
gboolean mxf_local_tag_add_to_hash_table (const MXFPrimerPack *primer,
guint16 tag, const guint8 *tag_data, guint16 tag_size,
GHashTable **hash_table);
gboolean mxf_local_tag_insert (MXFLocalTag *tag, GHashTable **hash_table);
void mxf_essence_element_handler_register (const MXFEssenceElementHandler *handler);
const MXFEssenceElementHandler * mxf_essence_element_handler_find (const MXFMetadataTimelineTrack *track);
......
......@@ -65,6 +65,8 @@ typedef struct {
MXFUL key;
guint16 size;
guint8 *data;
gboolean g_slice; /* TRUE if data was allocated by GSlice */
} MXFLocalTag;
/* SMPTE 377M 11.1 */
......@@ -114,6 +116,8 @@ typedef struct {
typedef struct {
guint64 offset;
GHashTable *mappings;
GHashTable *reverse_mappings;
guint16 next_free_tag;
} MXFPrimerPack;
/* SMPTE 377M 10.2.3 */
......
This diff is collapsed.
/* GStreamer
* Copyright (C) 2009 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.
*/
/* Handling of the basic MXF types */
#ifndef __MXF_WRITE_H__
#define __MXF_WRITE_H__
#include <string.h>
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
#include "mxfmetadata.h"
#include "mxftypes.h"
#include "mxfparse.h"
typedef GstFlowReturn (*MXFEssenceElementWriteFunc) (GstBuffer *buffer, GstCaps *caps, gpointer mapping_data, GstAdapter *adapter, GstBuffer **outbuf, gboolean flush);
typedef struct {
MXFMetadataFileDescriptor * (*get_descriptor) (GstPadTemplate *tmpl, GstCaps *caps, MXFEssenceElementWriteFunc *handler, gpointer *mapping_data);
void (*update_descriptor) (MXFMetadataFileDescriptor *d, GstCaps *caps, gpointer mapping_data, GstBuffer *buf);
void (*get_edit_rate) (MXFMetadataFileDescriptor *a, GstCaps *caps, gpointer mapping_data, GstBuffer *buf, MXFMetadataSourcePackage *package, MXFMetadataTimelineTrack *track, MXFFraction *edit_rate);
guint32 (*get_track_number_template) (MXFMetadataFileDescriptor *a, GstCaps *caps, gpointer mapping_data);
const GstPadTemplate *pad_template;
MXFUL data_definition;
} MXFEssenceElementWriter;
typedef enum {
MXF_OP_UNKNOWN = 0,
MXF_OP_ATOM,
MXF_OP_1a,
MXF_OP_1b,
MXF_OP_1c,
MXF_OP_2a,
MXF_OP_2b,
MXF_OP_2c,
MXF_OP_3a,
MXF_OP_3b,
MXF_OP_3c,
} MXFOperationalPattern;
void mxf_essence_element_writer_register (const MXFEssenceElementWriter *writer);
const GstPadTemplate ** mxf_essence_element_writer_get_pad_templates (void);
const MXFEssenceElementWriter *mxf_essence_element_writer_find (const GstPadTemplate *templ);
void mxf_ul_set (MXFUL *ul, GHashTable *hashtable);
void mxf_umid_set (MXFUMID *umid);
void mxf_timestamp_set_now (MXFTimestamp *timestamp);
void mxf_timestamp_write (const MXFTimestamp *timestamp, guint8 *data);
void mxf_op_set_atom (MXFUL *ul, gboolean single_sourceclip, gboolean single_essence_track);
void mxf_op_set_generalized (MXFUL *ul, MXFOperationalPattern pattern, gboolean internal_essence, gboolean streamable, gboolean single_track);
guint16 mxf_primer_pack_add_mapping (MXFPrimerPack *primer, guint16 local_tag, const MXFUL *ul);
guint mxf_ber_encode_size (guint size, guint8 ber[9]);
guint8 * mxf_utf8_to_utf16 (const gchar *str, guint16 *size);
void mxf_product_version_write (const MXFProductVersion *version, guint8 *data);
GstBuffer * mxf_partition_pack_to_buffer (const MXFPartitionPack *pack);
GstBuffer * mxf_primer_pack_to_buffer (const MXFPrimerPack *pack);
GstBuffer * mxf_fill_new (guint size);
GstBuffer * mxf_random_index_pack_to_buffer (const GArray *array);
#endif /* __MXF_WRITE_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment