From 086cf1c279ba10a0cc67be8c2c99622faafb7b6e Mon Sep 17 00:00:00 2001 From: Mike Jerris Date: Tue, 24 Feb 2015 13:51:07 -0600 Subject: [PATCH] FS-7500: expand libpng detection to try to find a good png >= 1.6.16, fall back to older verison in weezy, and add support for building without libpng --- Makefile.am | 12 ++++++++++-- configure.ac | 9 ++++++++- src/switch_core_video.c | 23 +++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 6513aa055e..00b74f714b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -145,6 +145,10 @@ if HAVE_ODBC CORE_CFLAGS += -DSWITCH_HAVE_ODBC $(ODBC_INC_FLAGS) endif +if HAVE_PNG +CORE_CFLAGS += -DSWITCH_HAVE_PNG $(LIBPNG_CFLAGS) +endif + ## ## libfreeswitch ## @@ -153,11 +157,15 @@ libfreeswitch_spandsp_la_SOURCES = libs/spandsp/src/plc.c libs/spandsp/src/alloc libfreeswitch_spandsp_la_CFLAGS = -Ilibs/spandsp/src $(CORE_CFLAGS) $(AM_CFLAGS) CORE_LIBS+=libfreeswitch_spandsp.la lib_LTLIBRARIES = libfreeswitch.la -libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(SQLITE_CFLAGS) $(LIBPNG_CFLAGS) $(FREETYPE_CFLAGS) $(CURL_CFLAGS) $(PCRE_CFLAGS) $(SPEEX_CFLAGS) $(LIBEDIT_CFLAGS) $(openssl_CFLAGS) $(AM_CFLAGS) +libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(SQLITE_CFLAGS) $(FREETYPE_CFLAGS) $(CURL_CFLAGS) $(PCRE_CFLAGS) $(SPEEX_CFLAGS) $(LIBEDIT_CFLAGS) $(openssl_CFLAGS) $(AM_CFLAGS) libfreeswitch_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS) $(PLATFORM_CORE_LDFLAGS) -no-undefined -libfreeswitch_la_LIBADD = $(CORE_LIBS) $(APR_LIBS) $(SQLITE_LIBS) $(LIBPNG_LIBS) $(FREETYPE_LIBS) $(CURL_LIBS) $(PCRE_LIBS) $(SPEEX_LIBS) $(LIBEDIT_LIBS) $(openssl_LIBS) $(VPX_LIBS) $(PLATFORM_CORE_LIBS) +libfreeswitch_la_LIBADD = $(CORE_LIBS) $(APR_LIBS) $(SQLITE_LIBS) $(FREETYPE_LIBS) $(CURL_LIBS) $(PCRE_LIBS) $(SPEEX_LIBS) $(LIBEDIT_LIBS) $(openssl_LIBS) $(VPX_LIBS) $(PLATFORM_CORE_LIBS) libfreeswitch_la_DEPENDENCIES = $(BUILT_SOURCES) +if HAVE_PNG +libfreeswitch_la_LIBADD += $(LIBPNG_LIBS) +endif + if HAVE_ODBC libfreeswitch_la_LDFLAGS += $(ODBC_LIB_FLAGS) endif diff --git a/configure.ac b/configure.ac index 6121b51ea2..9f01f9eed6 100644 --- a/configure.ac +++ b/configure.ac @@ -1197,7 +1197,14 @@ module_enabled() { grep -v -e "\#" -e "^\$" modules.conf | sed -e "s|^.*/||" | grep "^${1}\$" >/dev/null } -PKG_CHECK_MODULES([LIBPNG], [libpng >= 1.2.49]) + +PKG_CHECK_MODULES([LIBPNG], [libpng >= 1.6.16],[ + AM_CONDITIONAL([HAVE_PNG],[true])],[ + PKG_CHECK_MODULES([LIBPNG], [libpng16 >= 1.6.16],[ + AM_CONDITIONAL([HAVE_PNG],[true])],[ + PKG_CHECK_MODULES([LIBPNG], [libpng >= 1.2.49],[ + AM_CONDITIONAL([HAVE_PNG],[true])],[ + AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_PNG],[false])])])]) PKG_CHECK_MODULES([FREETYPE], [freetype2 >= 2.4.9]) PKG_CHECK_MODULES([SQLITE], [sqlite3 >= 3.6.20]) PKG_CHECK_MODULES([CURL], [libcurl >= 7.19]) diff --git a/src/switch_core_video.c b/src/switch_core_video.c index 424afe0f68..68953d45d1 100644 --- a/src/switch_core_video.c +++ b/src/switch_core_video.c @@ -717,6 +717,7 @@ SWITCH_DECLARE(void) switch_img_patch_hole(switch_image_t *IMG, switch_image_t * #define SWITCH_IMG_MAX_WIDTH 1920 * 2 #define SWITCH_IMG_MAX_HEIGHT 1080 * 2 +#ifdef SWITCH_HAVE_PNG // WIP png functions, need furthur tweak/check to make sure it works on all png files and errors are properly detected and reported // #define PNG_DEBUG 3 #define PNG_SKIP_SETJMP_CHECK @@ -1204,6 +1205,28 @@ end: #endif +#else + +SWITCH_DECLARE(switch_status_t) switch_img_patch_png(switch_image_t *img, int x, int y, const char *file_name) +{ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This function is not available, libpng not installed\n"); + return SWITCH_STATUS_FALSE; +} + +SWITCH_DECLARE(switch_image_t *) switch_img_read_png(const char* file_name) +{ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This function is not available, libpng not installed\n"); + return NULL; +} + +SWITCH_DECLARE(switch_status_t) switch_img_write_png(switch_image_t *img, char* file_name) +{ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This function is not available, libpng not installed\n"); + return SWITCH_STATUS_FALSE; +} + +#endif + SWITCH_DECLARE(switch_status_t) switch_img_fit(switch_image_t **srcP, int width, int height) { switch_image_t *src, *tmp = NULL;