static int32_t tag_add_field(struct mp4_metadata *tags, const char *item,
const char *value, int32_t len)
{
- if (!item || (item && !*item) || !value)
- return 0;
tags->tags = para_realloc(tags->tags,
(tags->count + 1) * sizeof(struct mp4_tag));
tags->tags[tags->count].item = para_strdup(item);
static void parse_tag(struct mp4 *f, uint8_t parent, int32_t size)
{
uint64_t subsize, sumsize;
- char *name = NULL;
char *data = NULL;
uint32_t len = 0;
uint64_t destpos;
uint8_t header_size = 0;
subsize = atom_read_header(f, &atom_type, &header_size);
destpos = get_position(f) + subsize - header_size;
- if (atom_type == ATOM_NAME) {
- read_char(f); /* version */
- read_int24(f); /* flags */
- free(name);
- name = read_string(f, subsize - (header_size + 4));
- continue;
- }
if (atom_type != ATOM_DATA)
continue;
read_char(f); /* version */
data = read_string(f, subsize - (header_size + 8));
len = subsize - (header_size + 8);
}
- if (data) {
- if (!name)
- name = para_strdup(get_metadata_name(parent));
- tag_add_field(&(f->tags), name, data, len);
- free(data);
- }
- free(name);
+ if (!data)
+ return;
+ tag_add_field(&f->tags, get_metadata_name(parent), data, len);
+ free(data);
}
static int32_t read_mdhd(struct mp4 *f)