]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mp4.c
mp4: Introduce mp4_get_meta().
[paraslash.git] / mp4.c
diff --git a/mp4.c b/mp4.c
index 37a700bacb9c005d97750de969661b17dba1b825..49fb22b97a640101c5e20ebf472610e6a28b802d 100644 (file)
--- a/mp4.c
+++ b/mp4.c
@@ -1105,23 +1105,17 @@ struct mp4 *mp4_open_meta(const struct mp4_callback *cb)
        return f;
 }
 
-int32_t mp4_meta_get_num_items(const struct mp4 *f)
+/**
+ * Return the metadata of an mp4 file.
+ *
+ * \param f As returned by either \ref mp4_open_read() or \ref mp4_open_meta().
+ *
+ * The caller is allowed to add, delete or modify the entries of the returned
+ * structure in order to pass the modified version to \ref mp4_meta_update().
+ */
+struct mp4_metadata *mp4_get_meta(struct mp4 *f)
 {
-       return f->tags.count;
-}
-
-int32_t mp4_meta_get_by_index(const struct mp4 *f, uint32_t index,
-                               char **item, char **value)
-{
-       if (index >= f->tags.count) {
-               *item = NULL;
-               *value = NULL;
-               return 0;
-       } else {
-               *item = para_strdup(f->tags.tags[index].item);
-               *value = para_strdup(f->tags.tags[index].value);
-               return 1;
-       }
+       return &f->tags;
 }
 
 static uint32_t find_atom(struct mp4 *f, uint64_t base, uint32_t size,
@@ -1619,6 +1613,7 @@ static uint32_t modify_moov(struct mp4 *f, const struct mp4_metadata *data,
                        struct membuffer *buf;
                        void *new_meta_buffer;
                        uint32_t new_meta_size;
+
                        if (!create_meta(data, &new_meta_buffer, &new_meta_size))
                                return 0;
 
@@ -1714,14 +1709,11 @@ int32_t mp4_meta_update(struct mp4 *f, struct mp4_metadata *meta)
        void *new_moov_data;
        uint32_t new_moov_size;
 
-       tag_delete(&f->tags);
-       f->tags = *meta;
        set_position(f, 0);
        if (!modify_moov(f, meta, &new_moov_data, &new_moov_size)) {
                mp4_close(f);
                return 0;
        }
-
        /* copy moov atom to end of the file */
        if (f->last_atom != ATOM_MOOV) {
                char *free_data = "free";