membuffer_write(buf, temp, 4);
}
-static void membuffer_write_std_tag(struct membuffer *buf, const char *name,
- const char *value)
-{
- uint32_t len = strlen(value);
- membuffer_write_int32(buf, 8 /* atom header */
- + 8 /* data atom header */
- + 8 /* flags + reserved */
- + len);
- membuffer_write_atom_name(buf, name);
- membuffer_write_int32(buf, 8 /* data atom header */
- + 8 /* flags + reserved */
- + len);
- membuffer_write_atom_name(buf, "data");
- membuffer_write_int32(buf, 1); /* flags */
- membuffer_write_int32(buf, 0); /* reserved */
- membuffer_write(buf, value, len);
-}
-
static unsigned membuffer_get_size(const struct membuffer *buf)
{
return buf->written;
for (n = 0; n < meta->count; n++) {
struct mp4_tag *tag = meta->tags + n;
+ unsigned len = strlen(tag->value);
const char *atom_name;
+
if (!strcasecmp(tag->item, "title"))
atom_name = "\xA9" "nam";
else if (!strcasecmp(tag->item, "artist"))
atom_name = "\xA9" "cmt";
else
assert(false);
- membuffer_write_std_tag(buf, atom_name, tag->value);
+ membuffer_write_int32(buf, 8 /* atom header */
+ + 8 /* data atom header */
+ + 8 /* flags + reserved */
+ + len);
+ membuffer_write_atom_name(buf, atom_name);
+ membuffer_write_int32(buf, 8 /* data atom header */
+ + 8 /* flags + reserved */
+ + len);
+ membuffer_write_atom_name(buf, "data");
+ membuffer_write_int32(buf, 1); /* flags */
+ membuffer_write_int32(buf, 0); /* reserved */
+ membuffer_write(buf, tag->value, len);
}
*out_size = membuffer_get_size(buf);
return membuffer_detach(buf);