]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mp4.c
mp4: Replace the five tag value functions by a single one.
[paraslash.git] / mp4.c
diff --git a/mp4.c b/mp4.c
index 757c42958da37c7eeac1c70dc379752da2076fae..e4082549113c5bb89a6c765b9ff50f76d765a60f 100644 (file)
--- a/mp4.c
+++ b/mp4.c
@@ -896,70 +896,23 @@ free_moov:
        return ret;
 }
 
-static char *meta_find_by_name(const struct mp4 *f, const char *item)
-{
-       uint32_t i;
-
-       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;
-}
-
 /**
- * Return the value of the artist meta tag of an mp4 file.
+ * Return the value of the given tag item.
  *
  * \param f Must not be NULL.
+ * \param item "artist", "title", "album", "comment", or "date".
  *
- * \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.
+ * \return The function always returns NULL if the given item is not in the
+ * above list. Otherwise, if the file does not contain a tag for the given
+ * item, the function also returns NULL. Otherwise a copy of the tag value is
+ * returned and the caller should free this memory when it is no longer needed.
  */
-char *mp4_meta_get_artist(const struct mp4 *f)
+char *mp4_get_tag_value(const struct mp4 *f, const char *item)
 {
-       return meta_find_by_name(f, "artist");
-}
-
-/**
- * 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");
-}
-
-/**
- * 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");
-}
-
-/**
- * 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");
-}
+       uint32_t i;
 
-/**
- * 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");
+       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;
 }