struct mp4_track *track[MAX_TRACKS];
/* metadata */
- struct mp4_metadata tags;
+ struct mp4_metadata meta;
};
int32_t mp4_total_tracks(const struct mp4 *f)
return 0;
}
-static int32_t tag_add_field(struct mp4_metadata *tags, const char *item,
+static int32_t tag_add_field(struct mp4_metadata *meta, const char *item,
const char *value, int32_t len)
{
- tags->tags = para_realloc(tags->tags,
- (tags->count + 1) * sizeof(struct mp4_tag));
- tags->tags[tags->count].item = para_strdup(item);
- tags->tags[tags->count].len = len;
+ meta->tags = para_realloc(meta->tags,
+ (meta->count + 1) * sizeof(struct mp4_tag));
+ meta->tags[meta->count].item = para_strdup(item);
+ meta->tags[meta->count].len = len;
if (len >= 0) {
- tags->tags[tags->count].value = para_malloc(len + 1);
- memcpy(tags->tags[tags->count].value, value, len);
- tags->tags[tags->count].value[len] = 0;
+ meta->tags[meta->count].value = para_malloc(len + 1);
+ memcpy(meta->tags[meta->count].value, value, len);
+ meta->tags[meta->count].value[len] = 0;
} else {
- tags->tags[tags->count].value = para_strdup(value);
+ meta->tags[meta->count].value = para_strdup(value);
}
- tags->count++;
+ meta->count++;
return 1;
}
}
if (!data)
return;
- tag_add_field(&f->tags, get_metadata_name(parent), data, len);
+ tag_add_field(&f->meta, get_metadata_name(parent), data, len);
free(data);
}
return f;
}
-static int32_t tag_delete(struct mp4_metadata *tags)
+static int32_t tag_delete(struct mp4_metadata *meta)
{
uint32_t i;
- for (i = 0; i < tags->count; i++) {
- free(tags->tags[i].item);
- free(tags->tags[i].value);
+ for (i = 0; i < meta->count; i++) {
+ free(meta->tags[i].item);
+ free(meta->tags[i].value);
}
- free(tags->tags);
- tags->tags = NULL;
- tags->count = 0;
+ free(meta->tags);
+ meta->tags = NULL;
+ meta->count = 0;
return 0;
}
}
}
- tag_delete(&(f->tags));
+ tag_delete(&(f->meta));
free(f);
}
*/
struct mp4_metadata *mp4_get_meta(struct mp4 *f)
{
- return &f->tags;
+ return &f->meta;
}
static uint32_t find_atom(struct mp4 *f, uint64_t base, uint32_t size,
return ret;
}
-static uint32_t create_ilst(const struct mp4_metadata *data, void **out_buffer,
+static uint32_t create_ilst(const struct mp4_metadata *meta, void **out_buffer,
uint32_t * out_size)
{
struct membuffer *buf = membuffer_create();
unsigned metaptr;
- char *mask = para_calloc(data->count);
+ char *mask = para_calloc(meta->count);
const char *tracknumber_ptr = 0, *totaltracks_ptr = 0;
const char *discnumber_ptr = 0, *totaldiscs_ptr = 0;
const char *genre_ptr = 0, *tempo_ptr = 0;
- for (metaptr = 0; metaptr < data->count; metaptr++) {
- struct mp4_tag *tag = &data->tags[metaptr];
+ for (metaptr = 0; metaptr < meta->count; metaptr++) {
+ struct mp4_tag *tag = &meta->tags[metaptr];
if (!strcasecmp(tag->item, "tracknumber")
|| !strcasecmp(tag->item, "track")) {
if (tracknumber_ptr == 0)
else
membuffer_write_int16_tag(buf, "gnre", index);
}
- for (metaptr = 0; metaptr < data->count; metaptr++) {
+ for (metaptr = 0; metaptr < meta->count; metaptr++) {
struct mp4_tag *tag;
const char *std_meta_atom;
if (mask[metaptr])
continue;
- tag = &data->tags[metaptr];
+ tag = &meta->tags[metaptr];
std_meta_atom = find_standard_meta(tag->item);
if (std_meta_atom)
membuffer_write_std_tag(buf, std_meta_atom, tag->value);
return bytes;
}
-static uint32_t create_meta(const struct mp4_metadata *data, void **out_buffer,
+static uint32_t create_meta(const struct mp4_metadata *meta, void **out_buffer,
uint32_t * out_size)
{
struct membuffer *buf;
uint32_t ilst_size;
void *ilst_buffer;
- if (!create_ilst(data, &ilst_buffer, &ilst_size))
+ if (!create_ilst(meta, &ilst_buffer, &ilst_size))
return 0;
buf = membuffer_create();
return 1;
}
-static uint32_t create_udta(const struct mp4_metadata *data, void **out_buffer,
+static uint32_t create_udta(const struct mp4_metadata *meta, void **out_buffer,
uint32_t * out_size)
{
struct membuffer *buf;
uint32_t meta_size;
void *meta_buffer;
- if (!create_meta(data, &meta_buffer, &meta_size))
+ if (!create_meta(meta, &meta_buffer, &meta_size))
return 0;
buf = membuffer_create();
struct membuffer *buf;
void *new_udta_buffer;
uint32_t new_udta_size;
- if (!create_udta(&f->tags, &new_udta_buffer, &new_udta_size))
+ if (!create_udta(&f->meta, &new_udta_buffer, &new_udta_size))
return 0;
buf = membuffer_create();
void *new_meta_buffer;
uint32_t new_meta_size;
- if (!create_meta(&f->tags, &new_meta_buffer, &new_meta_size))
+ if (!create_meta(&f->meta, &new_meta_buffer, &new_meta_size))
return 0;
buf = membuffer_create();
ilst_offset = get_position(f);
ilst_size = read_int32(f);
- if (!create_ilst(&f->tags, &new_ilst_buffer, &new_ilst_size))
+ if (!create_ilst(&f->meta, &new_ilst_buffer, &new_ilst_size))
return 0;
size_delta = new_ilst_size - (ilst_size - 8);
{
uint32_t i;
- for (i = 0; i < f->tags.count; i++)
- if (!strcasecmp(f->tags.tags[i].item, item))
- return para_strdup(f->tags.tags[i].value);
+ for (i = 0; i < f->meta.count; i++)
+ if (!strcasecmp(f->meta.tags[i].item, item))
+ return para_strdup(f->meta.tags[i].value);
return NULL;
}