mp4: support 2.0 mp4v2 API changes.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Thu, 5 Jul 2012 16:37:47 +0000 (13:37 -0300)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Thu, 5 Jul 2012 16:37:47 +0000 (13:37 -0300)
The function signature changed:
 * MP4Read(path, flag) -> MP4Read(path)
 * MP4Close(handle) -> MP4Close(handle, flags)

Then detect this and add a new define to choose how to use functions.

configure.ac
src/plugins/mp4/mp4.c

index 649ba93..f85f344 100644 (file)
@@ -75,6 +75,20 @@ define([CHECK_MODULE_MP4],
             if test "x$HAVE_MP4_HEADERS" = "xyes"; then
                AC_DEFINE(HAVE_MP4, 1, Define if mp4.h is present)
             fi
+
+            # test for new 2.0 api
+            if test "x$HAVE_MP4V2_HEADERS" = "xyes"; then
+               AC_MSG_CHECKING([mp4v2 2.0 API (MP4Read and MP4Close)])
+               AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+                  [[#include <mp4v2/mp4v2.h>]],
+                  [[MP4FileHandle fh = MP4Read("/tmp");
+                    MP4Close(fh, 0);
+                  ]])],
+                  [
+                     AC_MSG_RESULT([yes])
+                     AC_DEFINE(HAVE_MP4V2_2_0_API, 1, Define to 1 if you have mp4v2 2.0 api)
+                  ], [AC_MSG_RESULT([no])])
+            fi
         else
             MP4=false
         fi
index c0c4dd6..0ea8f65 100644 (file)
@@ -102,7 +102,11 @@ _parse(struct plugin *plugin, struct lms_context *ctxt, const struct lms_file_in
     MP4FileHandle mp4_fh;
     u_int32_t num_tracks;
 
+#ifdef HAVE_MP4V2_2_0_API
+    mp4_fh = MP4Read(finfo->path);
+#else
     mp4_fh = MP4Read(finfo->path, 0);
+#endif
     if (mp4_fh == MP4_INVALID_FILE_HANDLE) {
         fprintf(stderr, "ERROR: cannot read mp4 file %s\n", finfo->path);
         return -1;
@@ -179,7 +183,11 @@ _parse(struct plugin *plugin, struct lms_context *ctxt, const struct lms_file_in
         r = lms_db_video_add(plugin->video_db, &video_info);
     }
 
+#ifdef HAVE_MP4V2_2_0_API
+    MP4Close(mp4_fh, 0);
+#else
     MP4Close(mp4_fh);
+#endif
 
     if (info.title.str)
         free(info.title.str);