}
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
atom_ilst_init (AtomILST * ilst)
{
atom_header_set (&ilst->header, FOURCC_ilst, 0, 0);
}
static void
-atom_udta_init (AtomUDTA * udta)
+atom_udta_init_metatags (AtomUDTA * udta, AtomsContext * context)
{
- atom_header_set (&udta->header, FOURCC_udta, 0, 0);
- udta->meta = NULL;
+ if (context->flavor != ATOMS_TREE_FLAVOR_3GP) {
+ if (!udta->meta) {
+ udta->meta = atom_meta_new (context);
+ }
+ if (!udta->meta->ilst) {
+ udta->meta->ilst = atom_ilst_new ();
+ }
+ }
}
-static AtomUDTA *
-atom_udta_new (void)
+static void
+atom_udta_init (AtomUDTA * udta, AtomsContext * context)
{
- AtomUDTA *udta = g_new0 (AtomUDTA, 1);
+ atom_header_set (&udta->header, FOURCC_udta, 0, 0);
+ udta->meta = NULL;
+ udta->context = context;
- atom_udta_init (udta);
- return udta;
+ atom_udta_init_metatags (udta, context);
}
static void
-atom_udta_free (AtomUDTA * udta)
+atom_udta_clear (AtomUDTA * udta)
{
atom_clear (&udta->header);
if (udta->meta)
udta->meta = NULL;
if (udta->entries)
atom_info_list_free (udta->entries);
- g_free (udta);
}
static void
}
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
atom_moov_init (AtomMOOV * moov, AtomsContext * context)
{
atom_header_set (&(moov->header), FOURCC_moov, 0, 0);
atom_mvhd_init (&(moov->mvhd));
atom_mvex_init (&(moov->mvex));
- moov->udta = NULL;
+ atom_udta_init (&moov->udta, context);
moov->traks = NULL;
moov->context = *context;
}
g_list_free (moov->traks);
moov->traks = NULL;
- if (moov->udta) {
- atom_udta_free (moov->udta);
- moov->udta = NULL;
- }
-
+ atom_udta_clear (&moov->udta);
atom_mvex_clear (&moov->mvex);
g_free (moov);
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
atom_tag_data_copy_data (AtomTagData * data, guint8 ** buffer, guint64 * size,
guint64 * 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
atom_moov_copy_data (AtomMOOV * atom, guint8 ** buffer, guint64 * size,
guint64 * offset)
{
walker = g_list_next (walker);
}
- if (atom->udta) {
- if (!atom_udta_copy_data (atom->udta, buffer, size, offset)) {
- return 0;
- }
+ if (!atom_udta_copy_data (&atom->udta, buffer, size, offset)) {
+ return 0;
}
if (atom->fragmented) {
* 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
atom_tag_data_alloc_data (AtomTagData * data, guint size)
{
if (data->data != NULL) {
}
static void
-atom_moov_append_tag (AtomMOOV * moov, AtomInfo * tag)
+atom_udta_append_tag (AtomUDTA * udta, AtomInfo * tag)
{
GList **entries;
- atom_moov_init_metatags (moov, &moov->context);
- if (moov->udta->meta)
- entries = &moov->udta->meta->ilst->entries;
+ if (udta->meta)
+ entries = &udta->meta->ilst->entries;
else
- entries = &moov->udta->entries;
+ entries = &udta->entries;
*entries = g_list_append (*entries, tag);
}
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)
{
AtomTag *tag;
atom_tag_data_alloc_data (tdata, 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,
atom_tag_free));
}
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);
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
-atom_moov_add_uint_tag (AtomMOOV * moov, guint32 fourcc, guint32 flags,
+atom_udta_add_uint_tag (AtomUDTA * udta, guint32 fourcc, guint32 flags,
guint32 value)
{
guint8 data[8] = { 0, };
if (flags) {
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 {
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);
}
}
}
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;
GstBuffer *buf;
data_atom = atom_data_new_from_gst_buffer (fourcc, 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,
atom_data_free));
}
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)
{
AtomData *data_atom;
data_atom = atom_data_new_from_gst_buffer (fourcc, 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,
atom_data_free));
}
}
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)
{
gint len = 0, size = 0;
}
}
- atom_moov_add_3gp_tag (moov, fourcc, data, size);
+ atom_udta_add_3gp_tag (udta, fourcc, data, size);
g_free (data);
}
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
-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
-atom_moov_add_xmp_tags (AtomMOOV * moov, GstBuffer * xmpbuffer)
+atom_udta_add_xmp_tags (AtomUDTA * udta, GstBuffer * xmpbuffer)
{
AtomData *data_atom = NULL;
- if (moov->context.flavor == ATOMS_TREE_FLAVOR_MOV) {
+ if (udta->context->flavor == ATOMS_TREE_FLAVOR_MOV) {
if (xmpbuffer) {
data_atom = atom_data_new_from_gst_buffer (FOURCC_XMP_, xmpbuffer);
- atom_moov_init_metatags (moov, &moov->context);
- moov->udta->entries = g_list_append (moov->udta->entries,
+ udta->entries = g_list_append (udta->entries,
build_atom_info_wrapper ((Atom *) data_atom, atom_data_copy_data,
atom_data_free));
}
} else {
GST_DEBUG ("Not adding xmp to moov atom, it is only used in 'mov' format");
}
-
}
/*
static void
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)) {
/* strings */
break;
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s",
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);
break;
}
break;
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %u",
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;
}
case G_TYPE_UINT:
break;
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %u/%u",
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));
} else {
/* unpaired unsigned integers */
break;
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %u",
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;
}
static void
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;
GDateYear year;
str = g_strdup_printf ("%u-%u-%u", year, month, day);
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s",
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);
}
static void
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, };
GstBuffer *buf;
gst_buffer_map (buf, &map, GST_MAP_READ);
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT
" -> 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);
done:
g_value_unset (&value);
static void
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;
guint number;
if (!tag2) {
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s",
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 {
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s/%d",
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);
static void
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;
GDateYear year;
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %d",
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
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;
gchar *location = NULL;
GST_WRITE_UINT16_BE (data + 13, 0);
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);
}
static void
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;
guint8 *data, *ddata;
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);
}
static void
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;
gint size = 0;
memcpy (data + 8, content, size);
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);
}
-typedef void (*GstQTMuxAddTagFunc) (GstQTMux * mux, const GstTagList * list,
- const char *tag, const char *tag2, guint32 fourcc);
+typedef void (*GstQTMuxAddUdtaTagFunc) (GstQTMux * mux,
+ const GstTagList * list, AtomUDTA * udta, const char *tag,
+ const char *tag2, guint32 fourcc);
/*
* Struct to record mappings from gstreamer tags to fourcc codes
guint32 fourcc;
const gchar *gsttag;
const gchar *gsttag2;
- const GstQTMuxAddTagFunc func;
+ const GstQTMuxAddUdtaTagFunc func;
} GstTagToFourcc;
/* tag list tags to fourcc matching */
xmp = gst_tag_xmp_writer_tag_list_to_xmp_buffer (GST_TAG_XMP_WRITER (qtmux),
list, TRUE);
if (xmp)
- atom_moov_add_xmp_tags (qtmux->moov, xmp);
+ atom_udta_add_xmp_tags (&qtmux->moov->udta, xmp);
} else {
AtomInfo *ainfo;
/* for isom/mp4, it is a top level uuid atom */
}
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));
guint32 fourcc;
tag2 = tag_matches[i].gsttag2;
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 */
(strcmp (style, "iso") == 0 &&
qtmux_klass->format == GST_QT_MUX_FORMAT_3GP)) {
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_tag_list_remove_tag (copy, GST_TAG_CONTAINER_FORMAT);
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_tag_list_unref (copy);
} else {
GST_DEBUG_OBJECT (qtmux, "No tags received");
}
+
}
static inline GstBuffer *