[vlc-devel] [PATCH] Zip Module - Use the system minizip when available

Nicolas Chauvet (kwizart) kwizart at gmail.com
Wed Jan 28 19:19:08 CET 2009


- Avoid namespace issue when zip.h from minizip is present
 (renaming zip module zip.h -> to zip_accessdemux.h)
- Detect minizip presence with pkgconfig
- Move the zlib.h detection in one place (after pkgconfig macro)
  minizip in bundled within zlib in some distro
- Prevent the compilation of libs/unzip if minizip is available
 (it shound't prevent this directory to be bundled with the sources)
- Fix the zip_accessdemux.h (old zip.h) presence in the related Modules.am
---
 Makefile.am                          |    3 +
 configure.ac                         |   29 ++++++++++---
 modules/access/zip/Modules.am        |    1 +
 modules/access/zip/zip.h             |   73 ----------------------------------
 modules/access/zip/zip_accessdemux.h |   73 ++++++++++++++++++++++++++++++++++
 modules/access/zip/zipaccess.c       |    2 +-
 modules/access/zip/zipstream.c       |    2 +-
 7 files changed, 101 insertions(+), 82 deletions(-)
 delete mode 100644 modules/access/zip/zip.h
 create mode 100644 modules/access/zip/zip_accessdemux.h

diff --git a/Makefile.am b/Makefile.am
index 33dc7ef..fc212bd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -21,8 +21,11 @@ if HAVE_LIBGCRYPT
 SUBDIRS += libs/srtp
 endif
 if HAVE_ZLIB
+if HAVE_MINIZIP
+else
 SUBDIRS += libs/unzip
 endif
+endif
 if BUILD_VLC
 SUBDIRS += bin
 endif
diff --git a/configure.ac b/configure.ac
index 279442e..8f30e0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -550,9 +550,6 @@ AC_CHECK_FUNCS(send,,[
   ])
 ])
 
-AC_CHECK_HEADERS(zlib.h, [
-  VLC_ADD_LIBS([access_http],[-lz])
-])
 
 dnl Check for socklen_t
 AH_TEMPLATE(socklen_t, [Define to `int' if <sys/socket.h> does not define.])
@@ -877,6 +874,24 @@ AC_ARG_VAR(PKG_CONFIG_PATH,
 	   [Paths where to find .pc not at the default location])
 PKG_PROG_PKG_CONFIG()
 
+dnl
+dnl Check for zlib.h and -lz along with system -lminizip if available
+dnl 
+AC_CHECK_HEADERS(zlib.h, [ have_zlib=yes ], [ have_zlib=no ])
+AM_CONDITIONAL(HAVE_ZLIB, [ test "${have_zlib}" = "yes" ])
+if test "${have_zlib}" = "yes"
+then
+  VLC_ADD_LIBS([access_http],[-lz])
+  PKG_CHECK_MODULES([MINIZIP], [minizip] , [ have_minizip=yes ], [
+     have_minizip=no
+     MINIZIP_CFLAGS="-I../../../@top_srcdir@/libs/unzip"
+     MINIZIP_LIBS="../../../libs/unzip/libunzip.la"
+     AC_SUBST(MINIZIP_CFLAGS)
+     AC_SUBST(MINIZIP_LIBS)
+  ])
+  AM_CONDITIONAL(HAVE_MINIZIP, [ test "${have_minizip}" = "yes" ])
+fi
+
 dnl Check for hal
 AC_ARG_ENABLE(hal,
   [  --enable-hal            Linux HAL services discovery (default enabled)])
@@ -3239,8 +3254,8 @@ dnl MP4 module
 dnl
 AC_CHECK_HEADERS(zlib.h, [
   VLC_ADD_LIBS([mp4 skins2 sap mkv gme],[-lz])
-  VLC_ADD_CPPFLAGS([skins2],[-I../../../@top_srcdir@/libs/unzip])
-  VLC_ADD_LIBS([skins2],[../../../libs/unzip/libunzip.la])
+  VLC_ADD_CPPFLAGS([skins2],[$MINIZIP_CFLAGS])
+  VLC_ADD_LIBS([skins2],[$MINIZIP_LIBS])
 ] )
 
 AC_ARG_ENABLE(libsysfs,
@@ -5392,8 +5407,8 @@ then
   VLC_ADD_PLUGIN([unzip])
   VLC_ADD_LIBS([zip],[-lz])
   VLC_ADD_PLUGIN([zip])
-  VLC_ADD_CFLAGS([zip],[-I../../../@top_srcdir@/libs/unzip])
-  VLC_ADD_LIBS([zip],[../../../libs/unzip/libunzip.la])
+  VLC_ADD_CFLAGS([zip],[$MINIZIP_CFLAGS])
+  VLC_ADD_LIBS([zip],[$MINIZIP_LIBS])
 fi
 
 
diff --git a/modules/access/zip/Modules.am b/modules/access/zip/Modules.am
index 303c29f..1cf1d9b 100644
--- a/modules/access/zip/Modules.am
+++ b/modules/access/zip/Modules.am
@@ -1,5 +1,6 @@
 if HAVE_ZLIB
 SOURCES_zip = \
+	zip_accessdemux.h \
 	zipstream.c \
 	zipaccess.c \
 	$(NULL)
diff --git a/modules/access/zip/zip.h b/modules/access/zip/zip.h
deleted file mode 100644
index c78a6ca..0000000
--- a/modules/access/zip/zip.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*****************************************************************************
- * zip.h: Module (access+filter) to extract different archives, based on zlib
- *****************************************************************************
- * Copyright (C) 2009 the VideoLAN team
- * $Id$
- *
- * Authors: Jean-Philippe André <jpeg at videolan.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-/** **************************************************************************
- * Common includes and shared headers
- *****************************************************************************/
-
-#ifndef ZIP_ACCESSDEMUX_H
-#define ZIP_ACCESSDEMUX_H
-
-#include <vlc/vlc.h>
-#include <vlc_common.h>
-#include <vlc_url.h>
-#include <vlc_strings.h>
-#include <vlc_arrays.h>
-#include <vlc_plugin.h>
-#include <vlc_stream.h>
-#include "unzip.h"
-#include "ioapi.h"
-
-#include <assert.h>
-
-#define ZIP_FILENAME_LEN 512
-#define ZIP_BUFFER_LEN 32768
-#define ZIP_SEP      "|"
-#define ZIP_SEP_CHAR '|'
-
-
-/** **************************************************************************
- * Module access points: stream_filter
- *****************************************************************************/
-int StreamOpen( vlc_object_t* );
-void StreamClose( vlc_object_t* );
-
-/** **************************************************************************
- * Module access points: access
- *****************************************************************************/
-int AccessOpen( vlc_object_t *p_this );
-void AccessClose( vlc_object_t *p_this );
-
-/** **************************************************************************
- * zipIO function headers : how to use vlc_stream to read the zip
- * Note: static because the implementations differ
- *****************************************************************************/
-static void* ZCALLBACK ZipIO_Open( void* opaque, const char* filename, int m );
-static uLong ZCALLBACK ZipIO_Read( void*, void* stream, void* buf, uLong sz );
-static uLong ZCALLBACK ZipIO_Write( void*, void* stream, const void*, uLong );
-static long ZCALLBACK ZipIO_Tell( void*, void* stream );
-static long ZCALLBACK ZipIO_Seek( void*, void* stream, uLong offset, int ori );
-static int ZCALLBACK ZipIO_Close( void*, void* stream );
-static int ZCALLBACK ZipIO_Error( void*, void* stream );
-
-#endif /* ZIP_ACCESSDEMUX_H */
diff --git a/modules/access/zip/zip_accessdemux.h b/modules/access/zip/zip_accessdemux.h
new file mode 100644
index 0000000..c78a6ca
--- /dev/null
+++ b/modules/access/zip/zip_accessdemux.h
@@ -0,0 +1,73 @@
+/*****************************************************************************
+ * zip.h: Module (access+filter) to extract different archives, based on zlib
+ *****************************************************************************
+ * Copyright (C) 2009 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Jean-Philippe André <jpeg at videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/** **************************************************************************
+ * Common includes and shared headers
+ *****************************************************************************/
+
+#ifndef ZIP_ACCESSDEMUX_H
+#define ZIP_ACCESSDEMUX_H
+
+#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_url.h>
+#include <vlc_strings.h>
+#include <vlc_arrays.h>
+#include <vlc_plugin.h>
+#include <vlc_stream.h>
+#include "unzip.h"
+#include "ioapi.h"
+
+#include <assert.h>
+
+#define ZIP_FILENAME_LEN 512
+#define ZIP_BUFFER_LEN 32768
+#define ZIP_SEP      "|"
+#define ZIP_SEP_CHAR '|'
+
+
+/** **************************************************************************
+ * Module access points: stream_filter
+ *****************************************************************************/
+int StreamOpen( vlc_object_t* );
+void StreamClose( vlc_object_t* );
+
+/** **************************************************************************
+ * Module access points: access
+ *****************************************************************************/
+int AccessOpen( vlc_object_t *p_this );
+void AccessClose( vlc_object_t *p_this );
+
+/** **************************************************************************
+ * zipIO function headers : how to use vlc_stream to read the zip
+ * Note: static because the implementations differ
+ *****************************************************************************/
+static void* ZCALLBACK ZipIO_Open( void* opaque, const char* filename, int m );
+static uLong ZCALLBACK ZipIO_Read( void*, void* stream, void* buf, uLong sz );
+static uLong ZCALLBACK ZipIO_Write( void*, void* stream, const void*, uLong );
+static long ZCALLBACK ZipIO_Tell( void*, void* stream );
+static long ZCALLBACK ZipIO_Seek( void*, void* stream, uLong offset, int ori );
+static int ZCALLBACK ZipIO_Close( void*, void* stream );
+static int ZCALLBACK ZipIO_Error( void*, void* stream );
+
+#endif /* ZIP_ACCESSDEMUX_H */
diff --git a/modules/access/zip/zipaccess.c b/modules/access/zip/zipaccess.c
index d60f3dc..8800202 100644
--- a/modules/access/zip/zipaccess.c
+++ b/modules/access/zip/zipaccess.c
@@ -33,7 +33,7 @@
 
 #ifdef HAVE_ZLIB_H
 
-#include "zip.h"
+#include "zip_accessdemux.h"
 #include <vlc_access.h>
 
 /** **************************************************************************
diff --git a/modules/access/zip/zipstream.c b/modules/access/zip/zipstream.c
index 6596cd6..4753cc3 100644
--- a/modules/access/zip/zipstream.c
+++ b/modules/access/zip/zipstream.c
@@ -29,7 +29,7 @@
 # include "config.h"
 #endif
 
-#include "zip.h"
+#include "zip_accessdemux.h"
 #include <stddef.h>
 
 /* FIXME remove */
-- 
1.6.0.6




More information about the vlc-devel mailing list