static void _aac_afh_get_taginfo(const struct mp4 *mp4, struct taginfo *tags)
{
- mp4_meta_get_artist(mp4, &tags->artist);
- mp4_meta_get_title(mp4, &tags->title);
- mp4_meta_get_date(mp4, &tags->year);
- mp4_meta_get_album(mp4, &tags->album);
- mp4_meta_get_comment(mp4, &tags->comment);
+ tags->artist = mp4_meta_get_artist(mp4);
+ tags->title = mp4_meta_get_title(mp4);
+ tags->year = mp4_meta_get_date(mp4);
+ tags->album = mp4_meta_get_album(mp4);
+ tags->comment = mp4_meta_get_comment(mp4);
}
/*
return 1;
}
-/* find a metadata item by name */
-/* returns 0 if item found, 1 if no such item */
-static int32_t meta_find_by_name(const struct mp4 *f, const char *item,
- char **value)
+static char *meta_find_by_name(const struct mp4 *f, const char *item)
{
uint32_t i;
- for (i = 0; i < f->tags.count; i++) {
- if (!strcasecmp(f->tags.tags[i].item, item)) {
- *value = para_strdup(f->tags.tags[i].value);
- return 1;
- }
- }
-
- *value = NULL;
-
- /* not found */
- return 0;
+ for (i = 0; i < f->tags.count; i++)
+ if (!strcasecmp(f->tags.tags[i].item, item))
+ return para_strdup(f->tags.tags[i].value);
+ return NULL;
}
-int32_t mp4_meta_get_artist(const struct mp4 *f, char **value)
+/**
+ * Return the value of the artist meta tag of an mp4 file.
+ *
+ * \param f Must not be NULL.
+ *
+ * \return If the file does not contain this metadata tag, the function returns
+ * NULL. Otherwise, a copy of the tag value is returned. The caller should free
+ * this memory when it is no longer needed.
+ */
+char *mp4_meta_get_artist(const struct mp4 *f)
{
- return meta_find_by_name(f, "artist", value);
+ return meta_find_by_name(f, "artist");
}
-int32_t mp4_meta_get_title(const struct mp4 *f, char **value)
+/**
+ * Return the value of the title meta tag of an mp4 file.
+ *
+ * \param f See \ref mp4_meta_get_artist().
+ * \return See \ref mp4_meta_get_artist().
+ */
+char *mp4_meta_get_title(const struct mp4 *f)
{
- return meta_find_by_name(f, "title", value);
+ return meta_find_by_name(f, "title");
}
-int32_t mp4_meta_get_date(const struct mp4 *f, char **value)
+/**
+ * Return the value of the date meta tag of an mp4 file.
+ *
+ * \param f See \ref mp4_meta_get_artist().
+ * \return See \ref mp4_meta_get_artist().
+ */
+char *mp4_meta_get_date(const struct mp4 *f)
{
- return meta_find_by_name(f, "date", value);
+ return meta_find_by_name(f, "date");
}
-int32_t mp4_meta_get_album(const struct mp4 *f, char **value)
+/**
+ * Return the value of the album meta tag of an mp4 file.
+ *
+ * \param f See \ref mp4_meta_get_artist().
+ * \return See \ref mp4_meta_get_artist().
+ */
+char *mp4_meta_get_album(const struct mp4 *f)
{
- return meta_find_by_name(f, "album", value);
+ return meta_find_by_name(f, "album");
}
-int32_t mp4_meta_get_comment(const struct mp4 *f, char **value)
+/**
+ * Return the value of the comment meta tag of an mp4 file.
+ *
+ * \param f See \ref mp4_meta_get_artist().
+ * \return See \ref mp4_meta_get_artist().
+ */
+char *mp4_meta_get_comment(const struct mp4 *f)
{
- return meta_find_by_name(f, "comment", value);
+ return meta_find_by_name(f, "comment");
}
const struct mp4_metadata *data);
int mp4_meta_get_num_items(const struct mp4 *f);
-int mp4_meta_get_artist(const struct mp4 *f, char **value);
-int mp4_meta_get_title(const struct mp4 *f, char **value);
-int mp4_meta_get_date(const struct mp4 *f, char **value);
-int mp4_meta_get_album(const struct mp4 *f, char **value);
-int mp4_meta_get_comment(const struct mp4 *f, char **value);
+char *mp4_meta_get_artist(const struct mp4 *f);
+char *mp4_meta_get_title(const struct mp4 *f);
+char *mp4_meta_get_date(const struct mp4 *f);
+char *mp4_meta_get_album(const struct mp4 *f);
+char *mp4_meta_get_comment(const struct mp4 *f);