X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=mp4.c;h=f576529c0a954967e327834ae2b4e0bd204f24e2;hb=3fecc9a4654398b856f5722af298aa61f9407d9f;hp=d8aea78379aeabc80987481229c2e537cef8a93f;hpb=06dd900e86fee406c52f18b7dcf81f7487cb7cb6;p=paraslash.git diff --git a/mp4.c b/mp4.c index d8aea783..f576529c 100644 --- a/mp4.c +++ b/mp4.c @@ -1747,47 +1747,70 @@ int32_t mp4_meta_update(const struct mp4_callback *cb, 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"); }