qtmux: refactor tags functions to accomodata UDTA at trak level

Refactor the functions that were bound to the 'moov' atom to
directly pass the desired 'udta' that should receive the tags.
This allows the tags to be written to 'udta' at the 'moov' or
the 'trak' level, creating tags that are for the container or
for a stream only.

https://bugzilla.gnome.org/show_bug.cgi?id=692473
This commit is contained in:
Thiago Santos 2015-01-31 13:14:44 -03:00
parent f0fde8be88
commit 6321cdedb3
3 changed files with 165 additions and 167 deletions

View file

@ -1040,42 +1040,6 @@ atom_tkhd_clear (AtomTKHD * tkhd)
atom_full_clear (&tkhd->header); atom_full_clear (&tkhd->header);
} }
static void
atom_trak_init (AtomTRAK * trak, AtomsContext * context)
{
atom_header_set (&trak->header, FOURCC_trak, 0, 0);
atom_tkhd_init (&trak->tkhd, context);
trak->edts = NULL;
atom_mdia_init (&trak->mdia, context);
}
AtomTRAK *
atom_trak_new (AtomsContext * context)
{
AtomTRAK *trak = g_new0 (AtomTRAK, 1);
atom_trak_init (trak, context);
return trak;
}
static void
atom_trak_clear (AtomTRAK * trak)
{
atom_clear (&trak->header);
atom_tkhd_clear (&trak->tkhd);
if (trak->edts)
atom_edts_free (trak->edts);
atom_mdia_clear (&trak->mdia);
}
static void
atom_trak_free (AtomTRAK * trak)
{
atom_trak_clear (trak);
g_free (trak);
}
static void static void
atom_ilst_init (AtomILST * ilst) atom_ilst_init (AtomILST * ilst)
{ {
@ -1135,23 +1099,30 @@ atom_meta_free (AtomMETA * meta)
} }
static void static void
atom_udta_init (AtomUDTA * udta) atom_udta_init_metatags (AtomUDTA * udta, AtomsContext * context)
{ {
atom_header_set (&udta->header, FOURCC_udta, 0, 0); if (context->flavor != ATOMS_TREE_FLAVOR_3GP) {
udta->meta = NULL; if (!udta->meta) {
} udta->meta = atom_meta_new (context);
}
static AtomUDTA * if (!udta->meta->ilst) {
atom_udta_new (void) udta->meta->ilst = atom_ilst_new ();
{ }
AtomUDTA *udta = g_new0 (AtomUDTA, 1); }
atom_udta_init (udta);
return udta;
} }
static void static void
atom_udta_free (AtomUDTA * udta) atom_udta_init (AtomUDTA * udta, AtomsContext * context)
{
atom_header_set (&udta->header, FOURCC_udta, 0, 0);
udta->meta = NULL;
udta->context = context;
atom_udta_init_metatags (udta, context);
}
static void
atom_udta_clear (AtomUDTA * udta)
{ {
atom_clear (&udta->header); atom_clear (&udta->header);
if (udta->meta) if (udta->meta)
@ -1159,7 +1130,6 @@ atom_udta_free (AtomUDTA * udta)
udta->meta = NULL; udta->meta = NULL;
if (udta->entries) if (udta->entries)
atom_info_list_free (udta->entries); atom_info_list_free (udta->entries);
g_free (udta);
} }
static void static void
@ -1253,13 +1223,53 @@ atom_mvex_init (AtomMVEX * mvex)
mvex->trexs = NULL; mvex->trexs = NULL;
} }
static void
atom_trak_init (AtomTRAK * trak, AtomsContext * context)
{
atom_header_set (&trak->header, FOURCC_trak, 0, 0);
atom_tkhd_init (&trak->tkhd, context);
trak->context = context;
atom_udta_init (&trak->udta, context);
trak->edts = NULL;
atom_mdia_init (&trak->mdia, context);
}
AtomTRAK *
atom_trak_new (AtomsContext * context)
{
AtomTRAK *trak = g_new0 (AtomTRAK, 1);
atom_trak_init (trak, context);
return trak;
}
static void
atom_trak_clear (AtomTRAK * trak)
{
atom_clear (&trak->header);
atom_tkhd_clear (&trak->tkhd);
if (trak->edts)
atom_edts_free (trak->edts);
atom_udta_clear (&trak->udta);
atom_mdia_clear (&trak->mdia);
}
static void
atom_trak_free (AtomTRAK * trak)
{
atom_trak_clear (trak);
g_free (trak);
}
static void static void
atom_moov_init (AtomMOOV * moov, AtomsContext * context) atom_moov_init (AtomMOOV * moov, AtomsContext * context)
{ {
atom_header_set (&(moov->header), FOURCC_moov, 0, 0); atom_header_set (&(moov->header), FOURCC_moov, 0, 0);
atom_mvhd_init (&(moov->mvhd)); atom_mvhd_init (&(moov->mvhd));
atom_mvex_init (&(moov->mvex)); atom_mvex_init (&(moov->mvex));
moov->udta = NULL; atom_udta_init (&moov->udta, context);
moov->traks = NULL; moov->traks = NULL;
moov->context = *context; moov->context = *context;
} }
@ -1311,11 +1321,7 @@ atom_moov_free (AtomMOOV * moov)
g_list_free (moov->traks); g_list_free (moov->traks);
moov->traks = NULL; moov->traks = NULL;
if (moov->udta) { atom_udta_clear (&moov->udta);
atom_udta_free (moov->udta);
moov->udta = NULL;
}
atom_mvex_clear (&moov->mvex); atom_mvex_clear (&moov->mvex);
g_free (moov); g_free (moov);
@ -2303,32 +2309,6 @@ atom_edts_copy_data (AtomEDTS * edts, guint8 ** buffer, guint64 * size,
return *offset - original_offset; return *offset - original_offset;
} }
guint64
atom_trak_copy_data (AtomTRAK * trak, guint8 ** buffer, guint64 * size,
guint64 * offset)
{
guint64 original_offset = *offset;
if (!atom_copy_data (&trak->header, buffer, size, offset)) {
return 0;
}
if (!atom_tkhd_copy_data (&trak->tkhd, buffer, size, offset)) {
return 0;
}
if (trak->edts) {
if (!atom_edts_copy_data (trak->edts, buffer, size, offset)) {
return 0;
}
}
if (!atom_mdia_copy_data (&trak->mdia, buffer, size, offset)) {
return 0;
}
atom_write_size (buffer, size, offset, original_offset);
return *offset - original_offset;
}
static guint64 static guint64
atom_tag_data_copy_data (AtomTagData * data, guint8 ** buffer, guint64 * size, atom_tag_data_copy_data (AtomTagData * data, guint8 ** buffer, guint64 * size,
guint64 * offset) guint64 * offset)
@ -2492,6 +2472,37 @@ atom_mvex_copy_data (AtomMVEX * mvex, guint8 ** buffer, guint64 * size,
return *offset - original_offset; return *offset - original_offset;
} }
guint64
atom_trak_copy_data (AtomTRAK * trak, guint8 ** buffer, guint64 * size,
guint64 * offset)
{
guint64 original_offset = *offset;
if (!atom_copy_data (&trak->header, buffer, size, offset)) {
return 0;
}
if (!atom_tkhd_copy_data (&trak->tkhd, buffer, size, offset)) {
return 0;
}
if (trak->edts) {
if (!atom_edts_copy_data (trak->edts, buffer, size, offset)) {
return 0;
}
}
if (!atom_mdia_copy_data (&trak->mdia, buffer, size, offset)) {
return 0;
}
if (!atom_udta_copy_data (&trak->udta, buffer, size, offset)) {
return 0;
}
atom_write_size (buffer, size, offset, original_offset);
return *offset - original_offset;
}
guint64 guint64
atom_moov_copy_data (AtomMOOV * atom, guint8 ** buffer, guint64 * size, atom_moov_copy_data (AtomMOOV * atom, guint8 ** buffer, guint64 * size,
guint64 * offset) guint64 * offset)
@ -2513,10 +2524,8 @@ atom_moov_copy_data (AtomMOOV * atom, guint8 ** buffer, guint64 * size,
walker = g_list_next (walker); walker = g_list_next (walker);
} }
if (atom->udta) { if (!atom_udta_copy_data (&atom->udta, buffer, size, offset)) {
if (!atom_udta_copy_data (atom->udta, buffer, size, offset)) { return 0;
return 0;
}
} }
if (atom->fragmented) { if (atom->fragmented) {
@ -2948,22 +2957,6 @@ atom_trak_tx3g_update_dimension (AtomTRAK * trak, guint32 width, guint32 height)
/* /*
* Meta tags functions * Meta tags functions
*/ */
static void
atom_moov_init_metatags (AtomMOOV * moov, AtomsContext * context)
{
if (!moov->udta) {
moov->udta = atom_udta_new ();
}
if (context->flavor != ATOMS_TREE_FLAVOR_3GP) {
if (!moov->udta->meta) {
moov->udta->meta = atom_meta_new (context);
}
if (!moov->udta->meta->ilst) {
moov->udta->meta->ilst = atom_ilst_new ();
}
}
}
static void static void
atom_tag_data_alloc_data (AtomTagData * data, guint size) atom_tag_data_alloc_data (AtomTagData * data, guint size)
{ {
@ -2975,20 +2968,19 @@ atom_tag_data_alloc_data (AtomTagData * data, guint size)
} }
static void static void
atom_moov_append_tag (AtomMOOV * moov, AtomInfo * tag) atom_udta_append_tag (AtomUDTA * udta, AtomInfo * tag)
{ {
GList **entries; GList **entries;
atom_moov_init_metatags (moov, &moov->context); if (udta->meta)
if (moov->udta->meta) entries = &udta->meta->ilst->entries;
entries = &moov->udta->meta->ilst->entries;
else else
entries = &moov->udta->entries; entries = &udta->entries;
*entries = g_list_append (*entries, tag); *entries = g_list_append (*entries, tag);
} }
void void
atom_moov_add_tag (AtomMOOV * moov, guint32 fourcc, guint32 flags, atom_udta_add_tag (AtomUDTA * udta, guint32 fourcc, guint32 flags,
const guint8 * data, guint size) const guint8 * data, guint size)
{ {
AtomTag *tag; AtomTag *tag;
@ -2999,32 +2991,32 @@ atom_moov_add_tag (AtomMOOV * moov, guint32 fourcc, guint32 flags,
atom_tag_data_alloc_data (tdata, size); atom_tag_data_alloc_data (tdata, size);
memmove (tdata->data, data, size); memmove (tdata->data, data, size);
atom_moov_append_tag (moov, atom_udta_append_tag (udta,
build_atom_info_wrapper ((Atom *) tag, atom_tag_copy_data, build_atom_info_wrapper ((Atom *) tag, atom_tag_copy_data,
atom_tag_free)); atom_tag_free));
} }
void void
atom_moov_add_str_tag (AtomMOOV * moov, guint32 fourcc, const gchar * value) atom_udta_add_str_tag (AtomUDTA * udta, guint32 fourcc, const gchar * value)
{ {
gint len = strlen (value); gint len = strlen (value);
if (len > 0) if (len > 0)
atom_moov_add_tag (moov, fourcc, METADATA_TEXT_FLAG, (guint8 *) value, len); atom_udta_add_tag (udta, fourcc, METADATA_TEXT_FLAG, (guint8 *) value, len);
} }
void void
atom_moov_add_uint_tag (AtomMOOV * moov, guint32 fourcc, guint32 flags, atom_udta_add_uint_tag (AtomUDTA * udta, guint32 fourcc, guint32 flags,
guint32 value) guint32 value)
{ {
guint8 data[8] = { 0, }; guint8 data[8] = { 0, };
if (flags) { if (flags) {
GST_WRITE_UINT16_BE (data, value); GST_WRITE_UINT16_BE (data, value);
atom_moov_add_tag (moov, fourcc, flags, data, 2); atom_udta_add_tag (udta, fourcc, flags, data, 2);
} else { } else {
GST_WRITE_UINT32_BE (data + 2, value); GST_WRITE_UINT32_BE (data + 2, value);
atom_moov_add_tag (moov, fourcc, flags, data, 8); atom_udta_add_tag (udta, fourcc, flags, data, 8);
} }
} }
@ -3042,7 +3034,7 @@ _gst_buffer_new_wrapped (gpointer mem, gsize size, GFreeFunc free_func)
} }
void void
atom_moov_add_blob_tag (AtomMOOV * moov, guint8 * data, guint size) atom_udta_add_blob_tag (AtomUDTA * udta, guint8 * data, guint size)
{ {
AtomData *data_atom; AtomData *data_atom;
GstBuffer *buf; GstBuffer *buf;
@ -3063,13 +3055,13 @@ atom_moov_add_blob_tag (AtomMOOV * moov, guint8 * data, guint size)
data_atom = atom_data_new_from_gst_buffer (fourcc, buf); data_atom = atom_data_new_from_gst_buffer (fourcc, buf);
gst_buffer_unref (buf); gst_buffer_unref (buf);
atom_moov_append_tag (moov, atom_udta_append_tag (udta,
build_atom_info_wrapper ((Atom *) data_atom, atom_data_copy_data, build_atom_info_wrapper ((Atom *) data_atom, atom_data_copy_data,
atom_data_free)); atom_data_free));
} }
void void
atom_moov_add_3gp_tag (AtomMOOV * moov, guint32 fourcc, guint8 * data, atom_udta_add_3gp_tag (AtomUDTA * udta, guint32 fourcc, guint8 * data,
guint size) guint size)
{ {
AtomData *data_atom; AtomData *data_atom;
@ -3086,7 +3078,7 @@ atom_moov_add_3gp_tag (AtomMOOV * moov, guint32 fourcc, guint8 * data,
data_atom = atom_data_new_from_gst_buffer (fourcc, buf); data_atom = atom_data_new_from_gst_buffer (fourcc, buf);
gst_buffer_unref (buf); gst_buffer_unref (buf);
atom_moov_append_tag (moov, atom_udta_append_tag (udta,
build_atom_info_wrapper ((Atom *) data_atom, atom_data_copy_data, build_atom_info_wrapper ((Atom *) data_atom, atom_data_copy_data,
atom_data_free)); atom_data_free));
} }
@ -3102,7 +3094,7 @@ language_code (const char *lang)
} }
void void
atom_moov_add_3gp_str_int_tag (AtomMOOV * moov, guint32 fourcc, atom_udta_add_3gp_str_int_tag (AtomUDTA * udta, guint32 fourcc,
const gchar * value, gint16 ivalue) const gchar * value, gint16 ivalue)
{ {
gint len = 0, size = 0; gint len = 0, size = 0;
@ -3133,39 +3125,37 @@ atom_moov_add_3gp_str_int_tag (AtomMOOV * moov, guint32 fourcc,
} }
} }
atom_moov_add_3gp_tag (moov, fourcc, data, size); atom_udta_add_3gp_tag (udta, fourcc, data, size);
g_free (data); g_free (data);
} }
void void
atom_moov_add_3gp_str_tag (AtomMOOV * moov, guint32 fourcc, const gchar * value) atom_udta_add_3gp_str_tag (AtomUDTA * udta, guint32 fourcc, const gchar * value)
{ {
atom_moov_add_3gp_str_int_tag (moov, fourcc, value, -1); atom_udta_add_3gp_str_int_tag (udta, fourcc, value, -1);
} }
void void
atom_moov_add_3gp_uint_tag (AtomMOOV * moov, guint32 fourcc, guint16 value) atom_udta_add_3gp_uint_tag (AtomUDTA * udta, guint32 fourcc, guint16 value)
{ {
atom_moov_add_3gp_str_int_tag (moov, fourcc, NULL, value); atom_udta_add_3gp_str_int_tag (udta, fourcc, NULL, value);
} }
void void
atom_moov_add_xmp_tags (AtomMOOV * moov, GstBuffer * xmpbuffer) atom_udta_add_xmp_tags (AtomUDTA * udta, GstBuffer * xmpbuffer)
{ {
AtomData *data_atom = NULL; AtomData *data_atom = NULL;
if (moov->context.flavor == ATOMS_TREE_FLAVOR_MOV) { if (udta->context->flavor == ATOMS_TREE_FLAVOR_MOV) {
if (xmpbuffer) { if (xmpbuffer) {
data_atom = atom_data_new_from_gst_buffer (FOURCC_XMP_, xmpbuffer); data_atom = atom_data_new_from_gst_buffer (FOURCC_XMP_, xmpbuffer);
atom_moov_init_metatags (moov, &moov->context); udta->entries = g_list_append (udta->entries,
moov->udta->entries = g_list_append (moov->udta->entries,
build_atom_info_wrapper ((Atom *) data_atom, atom_data_copy_data, build_atom_info_wrapper ((Atom *) data_atom, atom_data_copy_data,
atom_data_free)); atom_data_free));
} }
} else { } else {
GST_DEBUG ("Not adding xmp to moov atom, it is only used in 'mov' format"); GST_DEBUG ("Not adding xmp to moov atom, it is only used in 'mov' format");
} }
} }
/* /*

View file

@ -597,6 +597,8 @@ typedef struct _AtomUDTA
GList* entries; GList* entries;
/* or list is further down */ /* or list is further down */
AtomMETA *meta; AtomMETA *meta;
AtomsContext *context;
} AtomUDTA; } AtomUDTA;
enum TrFlags enum TrFlags
@ -626,10 +628,13 @@ typedef struct _AtomTRAK
AtomTKHD tkhd; AtomTKHD tkhd;
AtomEDTS *edts; AtomEDTS *edts;
AtomMDIA mdia; AtomMDIA mdia;
AtomUDTA udta;
/* some helper info for structural conformity checks */ /* some helper info for structural conformity checks */
gboolean is_video; gboolean is_video;
gboolean is_h264; gboolean is_h264;
AtomsContext *context;
} AtomTRAK; } AtomTRAK;
typedef struct _AtomTREX typedef struct _AtomTREX
@ -746,7 +751,7 @@ typedef struct _AtomMOOV
/* list of AtomTRAK */ /* list of AtomTRAK */
GList *traks; GList *traks;
AtomUDTA *udta; AtomUDTA udta;
gboolean fragmented; gboolean fragmented;
} AtomMOOV; } AtomMOOV;
@ -969,21 +974,21 @@ AtomInfo * build_uuid_xmp_atom (GstBuffer * xmp);
/* /*
* Meta tags functions * Meta tags functions
*/ */
void atom_moov_add_str_tag (AtomMOOV *moov, guint32 fourcc, const gchar *value); void atom_udta_add_str_tag (AtomUDTA *udta, guint32 fourcc, const gchar *value);
void atom_moov_add_uint_tag (AtomMOOV *moov, guint32 fourcc, guint32 flags, void atom_udta_add_uint_tag (AtomUDTA *udta, guint32 fourcc, guint32 flags,
guint32 value); guint32 value);
void atom_moov_add_tag (AtomMOOV *moov, guint32 fourcc, guint32 flags, void atom_udta_add_tag (AtomUDTA *udta, guint32 fourcc, guint32 flags,
const guint8 * data, guint size); const guint8 * data, guint size);
void atom_moov_add_blob_tag (AtomMOOV *moov, guint8 *data, guint size); void atom_udta_add_blob_tag (AtomUDTA *udta, guint8 *data, guint size);
void atom_moov_add_3gp_str_tag (AtomMOOV * moov, guint32 fourcc, const gchar * value); void atom_udta_add_3gp_str_tag (AtomUDTA *udta, guint32 fourcc, const gchar * value);
void atom_moov_add_3gp_uint_tag (AtomMOOV * moov, guint32 fourcc, guint16 value); void atom_udta_add_3gp_uint_tag (AtomUDTA *udta, guint32 fourcc, guint16 value);
void atom_moov_add_3gp_str_int_tag (AtomMOOV * moov, guint32 fourcc, const gchar * value, void atom_udta_add_3gp_str_int_tag (AtomUDTA *udta, guint32 fourcc, const gchar * value,
gint16 ivalue); gint16 ivalue);
void atom_moov_add_3gp_tag (AtomMOOV * moov, guint32 fourcc, guint8 * data, void atom_udta_add_3gp_tag (AtomUDTA *udta, guint32 fourcc, guint8 * data,
guint size); guint size);
void atom_moov_add_xmp_tags (AtomMOOV * moov, GstBuffer * xmp); void atom_udta_add_xmp_tags (AtomUDTA *udta, GstBuffer * xmp);
#define GST_QT_MUX_DEFAULT_TAG_LANGUAGE "und" /* undefined/unknown */ #define GST_QT_MUX_DEFAULT_TAG_LANGUAGE "und" /* undefined/unknown */
guint16 language_code (const char * lang); guint16 language_code (const char * lang);

View file

@ -600,7 +600,7 @@ gst_qt_mux_create_empty_tx3g_buffer (GstQTPad * qtpad, gint64 duration)
static void static void
gst_qt_mux_add_mp4_tag (GstQTMux * qtmux, const GstTagList * list, gst_qt_mux_add_mp4_tag (GstQTMux * qtmux, const GstTagList * list,
const char *tag, const char *tag2, guint32 fourcc) AtomUDTA * udta, const char *tag, const char *tag2, guint32 fourcc)
{ {
switch (gst_tag_get_type (tag)) { switch (gst_tag_get_type (tag)) {
/* strings */ /* strings */
@ -612,7 +612,7 @@ gst_qt_mux_add_mp4_tag (GstQTMux * qtmux, const GstTagList * list,
break; break;
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s", GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s",
GST_FOURCC_ARGS (fourcc), str); GST_FOURCC_ARGS (fourcc), str);
atom_moov_add_str_tag (qtmux->moov, fourcc, str); atom_udta_add_str_tag (udta, fourcc, str);
g_free (str); g_free (str);
break; break;
} }
@ -625,7 +625,7 @@ gst_qt_mux_add_mp4_tag (GstQTMux * qtmux, const GstTagList * list,
break; break;
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %u", GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %u",
GST_FOURCC_ARGS (fourcc), (gint) value); GST_FOURCC_ARGS (fourcc), (gint) value);
atom_moov_add_uint_tag (qtmux->moov, fourcc, 21, (gint) value); atom_udta_add_uint_tag (udta, fourcc, 21, (gint) value);
break; break;
} }
case G_TYPE_UINT: case G_TYPE_UINT:
@ -642,7 +642,7 @@ gst_qt_mux_add_mp4_tag (GstQTMux * qtmux, const GstTagList * list,
break; break;
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %u/%u", GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %u/%u",
GST_FOURCC_ARGS (fourcc), value, count); GST_FOURCC_ARGS (fourcc), value, count);
atom_moov_add_uint_tag (qtmux->moov, fourcc, 0, atom_udta_add_uint_tag (udta, fourcc, 0,
value << 16 | (count & 0xFFFF)); value << 16 | (count & 0xFFFF));
} else { } else {
/* unpaired unsigned integers */ /* unpaired unsigned integers */
@ -650,7 +650,7 @@ gst_qt_mux_add_mp4_tag (GstQTMux * qtmux, const GstTagList * list,
break; break;
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %u", GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %u",
GST_FOURCC_ARGS (fourcc), value); GST_FOURCC_ARGS (fourcc), value);
atom_moov_add_uint_tag (qtmux->moov, fourcc, 1, value); atom_udta_add_uint_tag (udta, fourcc, 1, value);
} }
break; break;
} }
@ -662,7 +662,7 @@ gst_qt_mux_add_mp4_tag (GstQTMux * qtmux, const GstTagList * list,
static void static void
gst_qt_mux_add_mp4_date (GstQTMux * qtmux, const GstTagList * list, gst_qt_mux_add_mp4_date (GstQTMux * qtmux, const GstTagList * list,
const char *tag, const char *tag2, guint32 fourcc) AtomUDTA * udta, const char *tag, const char *tag2, guint32 fourcc)
{ {
GDate *date = NULL; GDate *date = NULL;
GDateYear year; GDateYear year;
@ -690,13 +690,13 @@ gst_qt_mux_add_mp4_date (GstQTMux * qtmux, const GstTagList * list,
str = g_strdup_printf ("%u-%u-%u", year, month, day); str = g_strdup_printf ("%u-%u-%u", year, month, day);
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s", GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s",
GST_FOURCC_ARGS (fourcc), str); GST_FOURCC_ARGS (fourcc), str);
atom_moov_add_str_tag (qtmux->moov, fourcc, str); atom_udta_add_str_tag (udta, fourcc, str);
g_free (str); g_free (str);
} }
static void static void
gst_qt_mux_add_mp4_cover (GstQTMux * qtmux, const GstTagList * list, gst_qt_mux_add_mp4_cover (GstQTMux * qtmux, const GstTagList * list,
const char *tag, const char *tag2, guint32 fourcc) AtomUDTA * udta, const char *tag, const char *tag2, guint32 fourcc)
{ {
GValue value = { 0, }; GValue value = { 0, };
GstBuffer *buf; GstBuffer *buf;
@ -742,7 +742,7 @@ gst_qt_mux_add_mp4_cover (GstQTMux * qtmux, const GstTagList * list,
gst_buffer_map (buf, &map, GST_MAP_READ); gst_buffer_map (buf, &map, GST_MAP_READ);
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT
" -> image size %" G_GSIZE_FORMAT "", GST_FOURCC_ARGS (fourcc), map.size); " -> image size %" G_GSIZE_FORMAT "", GST_FOURCC_ARGS (fourcc), map.size);
atom_moov_add_tag (qtmux->moov, fourcc, flags, map.data, map.size); atom_udta_add_tag (udta, fourcc, flags, map.data, map.size);
gst_buffer_unmap (buf, &map); gst_buffer_unmap (buf, &map);
done: done:
g_value_unset (&value); g_value_unset (&value);
@ -750,7 +750,7 @@ done:
static void static void
gst_qt_mux_add_3gp_str (GstQTMux * qtmux, const GstTagList * list, gst_qt_mux_add_3gp_str (GstQTMux * qtmux, const GstTagList * list,
const char *tag, const char *tag2, guint32 fourcc) AtomUDTA * udta, const char *tag, const char *tag2, guint32 fourcc)
{ {
gchar *str = NULL; gchar *str = NULL;
guint number; guint number;
@ -768,11 +768,11 @@ gst_qt_mux_add_3gp_str (GstQTMux * qtmux, const GstTagList * list,
if (!tag2) { if (!tag2) {
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s", GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s",
GST_FOURCC_ARGS (fourcc), str); GST_FOURCC_ARGS (fourcc), str);
atom_moov_add_3gp_str_tag (qtmux->moov, fourcc, str); atom_udta_add_3gp_str_tag (udta, fourcc, str);
} else { } else {
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s/%d", GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s/%d",
GST_FOURCC_ARGS (fourcc), str, number); GST_FOURCC_ARGS (fourcc), str, number);
atom_moov_add_3gp_str_int_tag (qtmux->moov, fourcc, str, number); atom_udta_add_3gp_str_int_tag (udta, fourcc, str, number);
} }
g_free (str); g_free (str);
@ -780,7 +780,7 @@ gst_qt_mux_add_3gp_str (GstQTMux * qtmux, const GstTagList * list,
static void static void
gst_qt_mux_add_3gp_date (GstQTMux * qtmux, const GstTagList * list, gst_qt_mux_add_3gp_date (GstQTMux * qtmux, const GstTagList * list,
const char *tag, const char *tag2, guint32 fourcc) AtomUDTA * udta, const char *tag, const char *tag2, guint32 fourcc)
{ {
GDate *date = NULL; GDate *date = NULL;
GDateYear year; GDateYear year;
@ -799,12 +799,12 @@ gst_qt_mux_add_3gp_date (GstQTMux * qtmux, const GstTagList * list,
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %d", GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %d",
GST_FOURCC_ARGS (fourcc), year); GST_FOURCC_ARGS (fourcc), year);
atom_moov_add_3gp_uint_tag (qtmux->moov, fourcc, year); atom_udta_add_3gp_uint_tag (udta, fourcc, year);
} }
static void static void
gst_qt_mux_add_3gp_location (GstQTMux * qtmux, const GstTagList * list, gst_qt_mux_add_3gp_location (GstQTMux * qtmux, const GstTagList * list,
const char *tag, const char *tag2, guint32 fourcc) AtomUDTA * udta, const char *tag, const char *tag2, guint32 fourcc)
{ {
gdouble latitude = -360, longitude = -360, altitude = 0; gdouble latitude = -360, longitude = -360, altitude = 0;
gchar *location = NULL; gchar *location = NULL;
@ -852,13 +852,13 @@ gst_qt_mux_add_3gp_location (GstQTMux * qtmux, const GstTagList * list,
GST_WRITE_UINT16_BE (data + 13, 0); GST_WRITE_UINT16_BE (data + 13, 0);
GST_DEBUG_OBJECT (qtmux, "Adding tag 'loci'"); GST_DEBUG_OBJECT (qtmux, "Adding tag 'loci'");
atom_moov_add_3gp_tag (qtmux->moov, fourcc, ddata, size); atom_udta_add_3gp_tag (udta, fourcc, ddata, size);
g_free (ddata); g_free (ddata);
} }
static void static void
gst_qt_mux_add_3gp_keywords (GstQTMux * qtmux, const GstTagList * list, gst_qt_mux_add_3gp_keywords (GstQTMux * qtmux, const GstTagList * list,
const char *tag, const char *tag2, guint32 fourcc) AtomUDTA * udta, const char *tag, const char *tag2, guint32 fourcc)
{ {
gchar *keywords = NULL; gchar *keywords = NULL;
guint8 *data, *ddata; guint8 *data, *ddata;
@ -903,7 +903,7 @@ gst_qt_mux_add_3gp_keywords (GstQTMux * qtmux, const GstTagList * list,
g_strfreev (kwds); g_strfreev (kwds);
atom_moov_add_3gp_tag (qtmux->moov, fourcc, ddata, size); atom_udta_add_3gp_tag (udta, fourcc, ddata, size);
g_free (ddata); g_free (ddata);
} }
@ -981,7 +981,7 @@ mismatch:
static void static void
gst_qt_mux_add_3gp_classification (GstQTMux * qtmux, const GstTagList * list, gst_qt_mux_add_3gp_classification (GstQTMux * qtmux, const GstTagList * list,
const char *tag, const char *tag2, guint32 fourcc) AtomUDTA * udta, const char *tag, const char *tag2, guint32 fourcc)
{ {
gchar *clsf_data = NULL; gchar *clsf_data = NULL;
gint size = 0; gint size = 0;
@ -1016,12 +1016,13 @@ gst_qt_mux_add_3gp_classification (GstQTMux * qtmux, const GstTagList * list,
memcpy (data + 8, content, size); memcpy (data + 8, content, size);
g_free (content); g_free (content);
atom_moov_add_3gp_tag (qtmux->moov, fourcc, data, 4 + 2 + 2 + size); atom_udta_add_3gp_tag (udta, fourcc, data, 4 + 2 + 2 + size);
g_free (data); g_free (data);
} }
typedef void (*GstQTMuxAddTagFunc) (GstQTMux * mux, const GstTagList * list, typedef void (*GstQTMuxAddUdtaTagFunc) (GstQTMux * mux,
const char *tag, const char *tag2, guint32 fourcc); const GstTagList * list, AtomUDTA * udta, const char *tag,
const char *tag2, guint32 fourcc);
/* /*
* Struct to record mappings from gstreamer tags to fourcc codes * Struct to record mappings from gstreamer tags to fourcc codes
@ -1031,7 +1032,7 @@ typedef struct _GstTagToFourcc
guint32 fourcc; guint32 fourcc;
const gchar *gsttag; const gchar *gsttag;
const gchar *gsttag2; const gchar *gsttag2;
const GstQTMuxAddTagFunc func; const GstQTMuxAddUdtaTagFunc func;
} GstTagToFourcc; } GstTagToFourcc;
/* tag list tags to fourcc matching */ /* tag list tags to fourcc matching */
@ -1109,7 +1110,7 @@ gst_qt_mux_add_xmp_tags (GstQTMux * qtmux, const GstTagList * list)
xmp = gst_tag_xmp_writer_tag_list_to_xmp_buffer (GST_TAG_XMP_WRITER (qtmux), xmp = gst_tag_xmp_writer_tag_list_to_xmp_buffer (GST_TAG_XMP_WRITER (qtmux),
list, TRUE); list, TRUE);
if (xmp) if (xmp)
atom_moov_add_xmp_tags (qtmux->moov, xmp); atom_udta_add_xmp_tags (&qtmux->moov->udta, xmp);
} else { } else {
AtomInfo *ainfo; AtomInfo *ainfo;
/* for isom/mp4, it is a top level uuid atom */ /* for isom/mp4, it is a top level uuid atom */
@ -1127,7 +1128,8 @@ gst_qt_mux_add_xmp_tags (GstQTMux * qtmux, const GstTagList * list)
} }
static void static void
gst_qt_mux_add_metadata_tags (GstQTMux * qtmux, const GstTagList * list) gst_qt_mux_add_metadata_tags (GstQTMux * qtmux, const GstTagList * list,
AtomUDTA * udta)
{ {
GstQTMuxClass *qtmux_klass = (GstQTMuxClass *) (G_OBJECT_GET_CLASS (qtmux)); GstQTMuxClass *qtmux_klass = (GstQTMuxClass *) (G_OBJECT_GET_CLASS (qtmux));
guint32 fourcc; guint32 fourcc;
@ -1157,7 +1159,7 @@ gst_qt_mux_add_metadata_tags (GstQTMux * qtmux, const GstTagList * list)
tag2 = tag_matches[i].gsttag2; tag2 = tag_matches[i].gsttag2;
g_assert (tag_matches[i].func); g_assert (tag_matches[i].func);
tag_matches[i].func (qtmux, list, tag, tag2, fourcc); tag_matches[i].func (qtmux, list, udta, tag, tag2, fourcc);
} }
/* add unparsed blobs if present */ /* add unparsed blobs if present */
@ -1191,7 +1193,7 @@ gst_qt_mux_add_metadata_tags (GstQTMux * qtmux, const GstTagList * list)
(strcmp (style, "iso") == 0 && (strcmp (style, "iso") == 0 &&
qtmux_klass->format == GST_QT_MUX_FORMAT_3GP)) { qtmux_klass->format == GST_QT_MUX_FORMAT_3GP)) {
GST_DEBUG_OBJECT (qtmux, "Adding private tag"); GST_DEBUG_OBJECT (qtmux, "Adding private tag");
atom_moov_add_blob_tag (qtmux->moov, map.data, map.size); atom_udta_add_blob_tag (udta, map.data, map.size);
} }
} }
gst_buffer_unmap (buf, &map); gst_buffer_unmap (buf, &map);
@ -1226,12 +1228,13 @@ gst_qt_mux_setup_metadata (GstQTMux * qtmux)
gst_tag_list_remove_tag (copy, GST_TAG_CONTAINER_FORMAT); gst_tag_list_remove_tag (copy, GST_TAG_CONTAINER_FORMAT);
GST_DEBUG_OBJECT (qtmux, "Formatting tags"); GST_DEBUG_OBJECT (qtmux, "Formatting tags");
gst_qt_mux_add_metadata_tags (qtmux, copy); gst_qt_mux_add_metadata_tags (qtmux, copy, &qtmux->moov->udta);
gst_qt_mux_add_xmp_tags (qtmux, copy); gst_qt_mux_add_xmp_tags (qtmux, copy);
gst_tag_list_unref (copy); gst_tag_list_unref (copy);
} else { } else {
GST_DEBUG_OBJECT (qtmux, "No tags received"); GST_DEBUG_OBJECT (qtmux, "No tags received");
} }
} }
static inline GstBuffer * static inline GstBuffer *