]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7655: attempt to make libvpx and libyuv optional (none of the video features will...
authorMichael Jerris <mike@jerris.com>
Tue, 16 Jun 2015 23:24:26 +0000 (18:24 -0500)
committerMichael Jerris <mike@jerris.com>
Tue, 16 Jun 2015 23:24:35 +0000 (18:24 -0500)
16 files changed:
Makefile.am
configure.ac
src/include/switch_core_video.h
src/include/switch_image.h [new file with mode: 0644]
src/include/switch_vpx.h
src/mod/applications/mod_av/Makefile.am
src/mod/applications/mod_conference/mod_conference.c
src/mod/applications/mod_cv/Makefile.am
src/mod/applications/mod_fsv/Makefile.am
src/mod/applications/mod_mp4v2/Makefile.am
src/mod/codecs/mod_openh264/Makefile.am
src/mod/formats/mod_imagick/Makefile.am
src/mod/formats/mod_local_stream/Makefile.am
src/mod/formats/mod_local_stream/mod_local_stream.c
src/mod/formats/mod_vlc/Makefile.am
src/switch_core_video.c

index b3bd493c4cc87a3c23050a69dec037390a935408..ff91efe1de2aa4cb2a107668d2fd3dc4a696b7d3 100644 (file)
@@ -149,6 +149,14 @@ if HAVE_PNG
 CORE_CFLAGS += -DSWITCH_HAVE_PNG $(LIBPNG_CFLAGS)
 endif
 
+if HAVE_VPX
+CORE_CFLAGS += -DSWITCH_HAVE_VPX $(VPX_CFLAGS)
+endif
+
+if HAVE_YUV
+CORE_CFLAGS += -DSWITCH_HAVE_YUV $(YUV_CFLAGS)
+endif
+
 if HAVE_FREETYPE
 CORE_CFLAGS += -DSWITCH_HAVE_FREETYPE $(LIBFREETYPE_CFLAGS)
 endif
index 6d063622909e40cc588b8278ca01984b37307c4d..e6cecc5fd38d620a1fecf355aa150deaaef06dc9 100644 (file)
@@ -783,12 +783,15 @@ if test "x$have_libz" = "xyes"  ; then
 APR_ADDTO([PLATFORM_CORE_LIBS], [-lz])
 fi
 
-PKG_CHECK_MODULES([YUV], [libyuv >= 0.0.1280],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([You need to install libyuv-dev. Required library])])
+PKG_CHECK_MODULES([YUV], [libyuv >= 0.0.1280],
+                        [AC_MSG_RESULT([yes]);AM_CONDITIONAL([HAVE_YUV],[true])],
+                        [AC_MSG_RESULT([no]);AM_CONDITIONAL([HAVE_YUV],[false])])
 
-AC_CHECK_LIB(yuv, I420Scale, have_libyuv=yes, AC_MSG_ERROR([no usable libyuv; please install libyuv devel package or equivalent]))
-if test "x$have_libyuv" = "xyes"  ; then
 APR_ADDTO([PLATFORM_CORE_LIBS], [${YUV_LIBS}])
-fi
+
+PKG_CHECK_MODULES([MPG123], [libmpg123 >= 1.20.1],[
+  AM_CONDITIONAL([HAVE_MPG123],[true])],[
+  AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_MPG123],[false])])
 
 AC_CHECK_LIB(apr-1, apr_pool_mutex_set, use_system_apr=yes, use_system_apr=no)
 AM_CONDITIONAL([SYSTEM_APR],[test "${use_system_apr}" = "yes"])
index ac4b40c1cdfd55520d0592a8994e3648ece8465b..e69ebbb0ed60b8e0ffc0f394b425ca66819763d3 100644 (file)
@@ -364,7 +364,7 @@ SWITCH_DECLARE(switch_image_t *) switch_img_write_text_img(int w, int h, switch_
 
 SWITCH_DECLARE(switch_image_t *) switch_img_read_file(const char* file_name);
 SWITCH_DECLARE(switch_status_t) switch_img_letterbox(switch_image_t *img, switch_image_t **imgP, int width, int height, const char *color);
-
+SWITCH_DECLARE(switch_bool_t) switch_core_has_video();
 /** @} */
 
 SWITCH_END_EXTERN_C
diff --git a/src/include/switch_image.h b/src/include/switch_image.h
new file mode 100644 (file)
index 0000000..c06d351
--- /dev/null
@@ -0,0 +1,224 @@
+/*
+ *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+/*!\file
+ * \brief Describes the vpx image descriptor and associated operations
+ *
+ */
+#ifndef VPX_VPX_IMAGE_H_
+#define VPX_VPX_IMAGE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+  /*!\brief Current ABI version number
+   *
+   * \internal
+   * If this file is altered in any way that changes the ABI, this value
+   * must be bumped.  Examples include, but are not limited to, changing
+   * types, removing or reassigning enums, adding/removing/rearranging
+   * fields to structures
+   */
+#define VPX_IMAGE_ABI_VERSION (3) /**<\hideinitializer*/
+
+
+#define VPX_IMG_FMT_PLANAR     0x100  /**< Image is a planar format. */
+#define VPX_IMG_FMT_UV_FLIP    0x200  /**< V plane precedes U in memory. */
+#define VPX_IMG_FMT_HAS_ALPHA  0x400  /**< Image has an alpha channel. */
+#define VPX_IMG_FMT_HIGHBITDEPTH 0x800  /**< Image uses 16bit framebuffer. */
+
+  /*!\brief List of supported image formats */
+  typedef enum vpx_img_fmt {
+    VPX_IMG_FMT_NONE,
+    VPX_IMG_FMT_RGB24,   /**< 24 bit per pixel packed RGB */
+    VPX_IMG_FMT_RGB32,   /**< 32 bit per pixel packed 0RGB */
+    VPX_IMG_FMT_RGB565,  /**< 16 bit per pixel, 565 */
+    VPX_IMG_FMT_RGB555,  /**< 16 bit per pixel, 555 */
+    VPX_IMG_FMT_UYVY,    /**< UYVY packed YUV */
+    VPX_IMG_FMT_YUY2,    /**< YUYV packed YUV */
+    VPX_IMG_FMT_YVYU,    /**< YVYU packed YUV */
+    VPX_IMG_FMT_BGR24,   /**< 24 bit per pixel packed BGR */
+    VPX_IMG_FMT_RGB32_LE, /**< 32 bit packed BGR0 */
+    VPX_IMG_FMT_ARGB,     /**< 32 bit packed ARGB, alpha=255 */
+    VPX_IMG_FMT_ARGB_LE,  /**< 32 bit packed BGRA, alpha=255 */
+    VPX_IMG_FMT_RGB565_LE,  /**< 16 bit per pixel, gggbbbbb rrrrrggg */
+    VPX_IMG_FMT_RGB555_LE,  /**< 16 bit per pixel, gggbbbbb 0rrrrrgg */
+    VPX_IMG_FMT_YV12    = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
+    VPX_IMG_FMT_I420    = VPX_IMG_FMT_PLANAR | 2,
+    VPX_IMG_FMT_VPXYV12 = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 3, /** < planar 4:2:0 format with vpx color space */
+    VPX_IMG_FMT_VPXI420 = VPX_IMG_FMT_PLANAR | 4,
+    VPX_IMG_FMT_I422    = VPX_IMG_FMT_PLANAR | 5,
+    VPX_IMG_FMT_I444    = VPX_IMG_FMT_PLANAR | 6,
+    VPX_IMG_FMT_I440    = VPX_IMG_FMT_PLANAR | 7,
+    VPX_IMG_FMT_444A    = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_HAS_ALPHA | 6,
+    VPX_IMG_FMT_I42016    = VPX_IMG_FMT_I420 | VPX_IMG_FMT_HIGHBITDEPTH,
+    VPX_IMG_FMT_I42216    = VPX_IMG_FMT_I422 | VPX_IMG_FMT_HIGHBITDEPTH,
+    VPX_IMG_FMT_I44416    = VPX_IMG_FMT_I444 | VPX_IMG_FMT_HIGHBITDEPTH,
+    VPX_IMG_FMT_I44016    = VPX_IMG_FMT_I440 | VPX_IMG_FMT_HIGHBITDEPTH
+  } vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
+
+  /*!\brief List of supported color spaces */
+  typedef enum vpx_color_space {
+    VPX_CS_UNKNOWN    = 0,  /**< Unknown */
+    VPX_CS_BT_601     = 1,  /**< BT.601 */
+    VPX_CS_BT_709     = 2,  /**< BT.709 */
+    VPX_CS_SMPTE_170  = 3,  /**< SMPTE.170 */
+    VPX_CS_SMPTE_240  = 4,  /**< SMPTE.240 */
+    VPX_CS_BT_2020    = 5,  /**< BT.2020 */
+    VPX_CS_RESERVED   = 6,  /**< Reserved */
+    VPX_CS_SRGB       = 7   /**< sRGB */
+  } vpx_color_space_t; /**< alias for enum vpx_color_space */
+
+  /**\brief Image Descriptor */
+  typedef struct vpx_image {
+    vpx_img_fmt_t fmt; /**< Image Format */
+    vpx_color_space_t cs; /**< Color Space */
+
+    /* Image storage dimensions */
+    unsigned int  w;           /**< Stored image width */
+    unsigned int  h;           /**< Stored image height */
+    unsigned int  bit_depth;   /**< Stored image bit-depth */
+
+    /* Image display dimensions */
+    unsigned int  d_w;   /**< Displayed image width */
+    unsigned int  d_h;   /**< Displayed image height */
+
+    /* Chroma subsampling info */
+    unsigned int  x_chroma_shift;   /**< subsampling order, X */
+    unsigned int  y_chroma_shift;   /**< subsampling order, Y */
+
+    /* Image data pointers. */
+#define VPX_PLANE_PACKED 0   /**< To be used for all packed formats */
+#define VPX_PLANE_Y      0   /**< Y (Luminance) plane */
+#define VPX_PLANE_U      1   /**< U (Chroma) plane */
+#define VPX_PLANE_V      2   /**< V (Chroma) plane */
+#define VPX_PLANE_ALPHA  3   /**< A (Transparency) plane */
+    unsigned char *planes[4];  /**< pointer to the top left pixel for each plane */
+    int      stride[4];  /**< stride between rows for each plane */
+
+    int     bps; /**< bits per sample (for packed formats) */
+
+    /* The following member may be set by the application to associate data
+     * with this image.
+     */
+    void    *user_priv; /**< may be set by the application to associate data
+                         *   with this image. */
+
+    /* The following members should be treated as private. */
+    unsigned char *img_data;       /**< private */
+    int      img_data_owner; /**< private */
+    int      self_allocd;    /**< private */
+
+    void    *fb_priv; /**< Frame buffer data associated with the image. */
+  } vpx_image_t; /**< alias for struct vpx_image */
+
+  /**\brief Representation of a rectangle on a surface */
+  typedef struct vpx_image_rect {
+    unsigned int x; /**< leftmost column */
+    unsigned int y; /**< topmost row */
+    unsigned int w; /**< width */
+    unsigned int h; /**< height */
+  } vpx_image_rect_t; /**< alias for struct vpx_image_rect */
+
+  /*!\brief Open a descriptor, allocating storage for the underlying image
+   *
+   * Returns a descriptor for storing an image of the given format. The
+   * storage for the descriptor is allocated on the heap.
+   *
+   * \param[in]    img       Pointer to storage for descriptor. If this parameter
+   *                         is NULL, the storage for the descriptor will be
+   *                         allocated on the heap.
+   * \param[in]    fmt       Format for the image
+   * \param[in]    d_w       Width of the image
+   * \param[in]    d_h       Height of the image
+   * \param[in]    align     Alignment, in bytes, of the image buffer and
+   *                         each row in the image(stride).
+   *
+   * \return Returns a pointer to the initialized image descriptor. If the img
+   *         parameter is non-null, the value of the img parameter will be
+   *         returned.
+   */
+  vpx_image_t *vpx_img_alloc(vpx_image_t  *img,
+                             vpx_img_fmt_t fmt,
+                             unsigned int d_w,
+                             unsigned int d_h,
+                             unsigned int align);
+
+  /*!\brief Open a descriptor, using existing storage for the underlying image
+   *
+   * Returns a descriptor for storing an image of the given format. The
+   * storage for descriptor has been allocated elsewhere, and a descriptor is
+   * desired to "wrap" that storage.
+   *
+   * \param[in]    img       Pointer to storage for descriptor. If this parameter
+   *                         is NULL, the storage for the descriptor will be
+   *                         allocated on the heap.
+   * \param[in]    fmt       Format for the image
+   * \param[in]    d_w       Width of the image
+   * \param[in]    d_h       Height of the image
+   * \param[in]    align     Alignment, in bytes, of each row in the image.
+   * \param[in]    img_data  Storage to use for the image
+   *
+   * \return Returns a pointer to the initialized image descriptor. If the img
+   *         parameter is non-null, the value of the img parameter will be
+   *         returned.
+   */
+  vpx_image_t *vpx_img_wrap(vpx_image_t  *img,
+                            vpx_img_fmt_t fmt,
+                            unsigned int d_w,
+                            unsigned int d_h,
+                            unsigned int align,
+                            unsigned char      *img_data);
+
+
+  /*!\brief Set the rectangle identifying the displayed portion of the image
+   *
+   * Updates the displayed rectangle (aka viewport) on the image surface to
+   * match the specified coordinates and size.
+   *
+   * \param[in]    img       Image descriptor
+   * \param[in]    x         leftmost column
+   * \param[in]    y         topmost row
+   * \param[in]    w         width
+   * \param[in]    h         height
+   *
+   * \return 0 if the requested rectangle is valid, nonzero otherwise.
+   */
+  int vpx_img_set_rect(vpx_image_t  *img,
+                       unsigned int  x,
+                       unsigned int  y,
+                       unsigned int  w,
+                       unsigned int  h);
+
+
+  /*!\brief Flip the image vertically (top for bottom)
+   *
+   * Adjusts the image descriptor's pointers and strides to make the image
+   * be referenced upside-down.
+   *
+   * \param[in]    img       Image descriptor
+   */
+  void vpx_img_flip(vpx_image_t *img);
+
+  /*!\brief Close an image descriptor
+   *
+   * Frees all allocated storage associated with an image descriptor.
+   *
+   * \param[in]    img       Image descriptor
+   */
+  void vpx_img_free(vpx_image_t *img);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+#endif  // VPX_VPX_IMAGE_H_
index 4dd1dd488aadf4cbd67049db5a35439d14f4b208..a975775a7a0f9b9cdb458b21ff55a7075e505e4b 100644 (file)
@@ -40,9 +40,7 @@
 #define SWITCH_VPX_H
 
 #include <switch.h>
-
-#include "vpx/vpx_image.h"
-#include "vpx/vpx_integer.h"
+#include <switch_image.h>
 
 SWITCH_BEGIN_EXTERN_C
 
index 1354526fbf38285956f810836dc93e293d3c296e..cd5ffdb10751a26ba190e75a4ff931dc1a32e331 100644 (file)
@@ -1,6 +1,8 @@
 include $(top_srcdir)/build/modmake.rulesam
 MODNAME=mod_av
 
+if HAVE_YUV
+if HAVE_VPX
 if HAVE_AVFORMAT
 
 mod_LTLIBRARIES = mod_av.la
@@ -16,3 +18,18 @@ error:
        $(error You must install libavformat-dev to build mod_av)
 endif
 
+else
+install: error
+all: error
+error:
+       $(error You must install libvpx2-dev to build mod_av)
+endif
+
+
+else
+install: error
+all: error
+error:
+       $(error You must install libyuv-dev to build mod_av)
+endif
+
index 8caa354679e838753716230ada29001d957d2d64..7d264cd5a05f82786715395590023503ab2da247 100644 (file)
@@ -12982,6 +12982,11 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c
 
        conference->conf_video_mode = conf_video_mode;
 
+       if (!switch_core_has_video() && (conference->conf_video_mode == CONF_VIDEO_MODE_MUX || conference->conf_video_mode == CONF_VIDEO_MODE_TRANSCODE)) {
+               conference->conf_video_mode = CONF_VIDEO_MODE_PASSTHROUGH;
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "video-mode invalid, only valid setting is 'passthrough' due to no video capabilities\n");
+       }
+       
        if (conference->conf_video_mode == CONF_VIDEO_MODE_MUX) {
                int canvas_w = 0, canvas_h = 0;
                if (video_canvas_size) {
index 9afcff9c39da03f65cb464f08138342df431f567..6386d459713ba25821cc585532a1e0af196675b4 100644 (file)
@@ -1,6 +1,8 @@
 include $(top_srcdir)/build/modmake.rulesam
 MODNAME=mod_cv
 
+if HAVE_YUV
+if HAVE_VPX
 if HAVE_OPENCV
 
 mod_LTLIBRARIES = mod_cv.la
@@ -16,3 +18,18 @@ error:
        $(error You must install libopencv-dev to build mod_cv)
 endif
 
+else
+install: error
+all: error
+error:
+       $(error You must install libvpx2-dev to build mod_cv)
+endif
+
+
+else
+install: error
+all: error
+error:
+       $(error You must install libyuv-dev to build mod_cv)
+endif
+
index dd75a2f0816f5f1587033148c57e9cf03c65295d..3b21b98405d34f413af25d10894da1c1501a6c2e 100644 (file)
@@ -1,8 +1,28 @@
 include $(top_srcdir)/build/modmake.rulesam
 MODNAME=mod_fsv
 
+if HAVE_YUV
+if HAVE_VPX
+
 mod_LTLIBRARIES = mod_fsv.la
 mod_fsv_la_SOURCES  = mod_fsv.c
 mod_fsv_la_CFLAGS   = $(AM_CFLAGS)
 mod_fsv_la_LIBADD   = $(switch_builddir)/libfreeswitch.la
 mod_fsv_la_LDFLAGS  = -avoid-version -module -no-undefined -shared
+
+else
+install: error
+all: error
+error:
+       $(error You must install libvpx2-dev to build mod_fsv)
+endif
+
+
+else
+install: error
+all: error
+error:
+       $(error You must install libyuv-dev to build mod_fsv)
+endif
+
+
index f8b8bec05a7156c94dfdbe52b1f3500fc29052b9..877dd45e12997359f68bc68090486cc241154f7c 100644 (file)
@@ -1,8 +1,27 @@
 include $(top_srcdir)/build/modmake.rulesam
 MODNAME=mod_mp4v2
 
+if HAVE_YUV
+if HAVE_VPX
+
 mod_LTLIBRARIES = mod_mp4v2.la
 mod_mp4v2_la_SOURCES  = mod_mp4v2.c
 mod_mp4v2_la_CFLAGS   = $(AM_CFLAGS)
 mod_mp4v2_la_LIBADD   = $(switch_builddir)/libfreeswitch.la
 mod_mp4v2_la_LDFLAGS  = -avoid-version -module -no-undefined -shared -lmp4v2
+
+else
+install: error
+all: error
+error:
+       $(error You must install libvpx2-dev to build mod_mp4v2)
+endif
+
+
+else
+install: error
+all: error
+error:
+       $(error You must install libyuv-dev to build mod_mp4v2)
+endif
+
index 058f5bebb7d12bba3c4357b2f4fdce8806e986e4..f7939ea3682e66eda240b86bacbd1740645f7494 100644 (file)
@@ -1,6 +1,9 @@
 include $(top_srcdir)/build/modmake.rulesam
 MODNAME=mod_openh264
 
+if HAVE_YUV
+if HAVE_VPX
+
 OPENH264_DIR=/usr/local/
 
 mod_LTLIBRARIES = mod_openh264.la
@@ -9,3 +12,18 @@ mod_openh264_la_CXXFLAGS   = $(AM_CXXFLAGS) -I$(OPENH264_DIR)/include/wels
 mod_openh264_la_LIBADD   = $(switch_builddir)/libfreeswitch.la
 mod_openh264_la_LDFLAGS  = -L$(OPENH264_DIR)/lib/ -lopenh264 -avoid-version -module -no-undefined -shared
 
+else
+install: error
+all: error
+error:
+       $(error You must install libvpx2-dev to build mod_openh264)
+endif
+
+
+else
+install: error
+all: error
+error:
+       $(error You must install libyuv-dev to build mod_openh264)
+endif
+
index 0181c6d3cdfa73ddbd6b3833193c24a1b0f1c5d7..c960d33d78a924ad360f1a341f779344ff0c2e2a 100644 (file)
@@ -1,6 +1,8 @@
 include $(top_srcdir)/build/modmake.rulesam
 MODNAME=mod_imagick
 
+if HAVE_YUV
+if HAVE_VPX
 if HAVE_MAGICK
 
 mod_LTLIBRARIES = mod_imagick.la
@@ -16,3 +18,18 @@ error:
        $(error You must install libmagickcore-dev to build mod_imagick)
 endif
 
+else
+install: error
+all: error
+error:
+       $(error You must install libvpx2-dev to build mod_imagick)
+endif
+
+
+else
+install: error
+all: error
+error:
+       $(error You must install libyuv-dev to build mod_imagick)
+endif
+
index c34977df9f39840744a7e908a85351bf017617f3..3853f19fb3c86ddd43ce145ac969c47521e296c5 100644 (file)
@@ -6,3 +6,4 @@ mod_local_stream_la_SOURCES  = mod_local_stream.c
 mod_local_stream_la_CFLAGS   = $(AM_CFLAGS)
 mod_local_stream_la_LIBADD   = $(switch_builddir)/libfreeswitch.la
 mod_local_stream_la_LDFLAGS  = -avoid-version -module -no-undefined -shared
+
index caba6b00738ecc730b67b0fa622d6f183e4a44bd..3aa6d63f20acafb13d96abbad186aedc12c99421 100644 (file)
@@ -284,7 +284,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
 
 
                                if (is_open) {
-                                       if (switch_core_file_has_video(use_fh)) {
+                                       if (switch_core_has_video() && switch_core_file_has_video(use_fh)) {
                                                switch_frame_t vid_frame = { 0 };
 
                                                if (switch_core_file_read_video(use_fh, &vid_frame, SVR_FLUSH) == SWITCH_STATUS_SUCCESS) {
@@ -1124,7 +1124,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_local_stream_load)
        file_interface->file_open = local_stream_file_open;
        file_interface->file_close = local_stream_file_close;
        file_interface->file_read = local_stream_file_read;
-       file_interface->file_read_video = local_stream_file_read_video;
+
+       if (switch_core_has_video()) {
+               file_interface->file_read_video = local_stream_file_read_video;
+       }
 
        if (switch_event_bind(modname, SWITCH_EVENT_SHUTDOWN, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind event handler!\n");
index 90c9dfb1609acf962d526987ac4e69ca916534bd..16bda68ad5ad74ca79c71edfae232586097c037d 100644 (file)
@@ -1,6 +1,8 @@
 include $(top_srcdir)/build/modmake.rulesam
 MODNAME=mod_vlc
 
+if HAVE_YUV
+if HAVE_VPX
 if HAVE_VLC
 
 mod_LTLIBRARIES = mod_vlc.la
@@ -16,3 +18,17 @@ error:
        $(error You must install libvlc-dev to build mod_vlc)
 endif
 
+else
+install: error
+all: error
+error:
+       $(error You must install libvpx2-dev to build mod_vlc)
+endif
+
+else
+install: error
+all: error
+error:
+       $(error You must install libyuv-dev to build mod_vlc)
+endif
+
index 2d401ce54b616f6d94f1a72ac372431b52fe581c..0831d473913be3f5dd7d79d5ad7398de0b2f9a56 100644 (file)
  *
  */
 
+#ifdef SWITCH_HAVE_VPX
+#include "vpx/vpx_image.h"
+#if VPX_IMAGE_ABI_VERSION != (3)
+#error VPX_IMAGE_ABI_VERSION is not (3)
+#endif
+#endif
+
 #include <switch.h>
 #include <switch_utf8.h>
+
+#ifdef SWITCH_HAVE_YUV
 #include <libyuv.h>
+#endif
 
 // #define HAVE_LIBGD
 #ifdef HAVE_LIBGD
 #include <gd.h>
 #endif
 
-
 struct pos_el {
        switch_img_position_t pos;
        const char *name;
@@ -77,12 +86,26 @@ SWITCH_DECLARE(switch_img_position_t) parse_img_position(const char *name)
        return r;
 }
 
+SWITCH_DECLARE(switch_bool_t) switch_core_has_video()
+{
+#ifdef SWITCH_HAVE_VPX
+#ifdef SWITCH_HAVE_YUV
+       return SWITCH_TRUE;
+#else
+       return SWITCH_FALSE;
+#endif
+#else
+       return SWITCH_FALSE;
+#endif
+}
+                                                         
 SWITCH_DECLARE(switch_image_t *)switch_img_alloc(switch_image_t  *img,
                                                 switch_img_fmt_t fmt,
                                                 unsigned int d_w,
                                                 unsigned int d_h,
                                                 unsigned int align)
 {
+#ifdef SWITCH_HAVE_VPX
 #ifdef HAVE_LIBGD
        if (fmt == SWITCH_IMG_FMT_GD) {
                gdImagePtr gd = gdImageCreateTrueColor(d_w, d_h);
@@ -106,6 +129,9 @@ SWITCH_DECLARE(switch_image_t *)switch_img_alloc(switch_image_t  *img,
 #endif
 
        return (switch_image_t *)vpx_img_alloc((vpx_image_t *)img, (vpx_img_fmt_t)fmt, d_w, d_h, align);
+#else
+       return NULL;
+#endif
 }
 
 SWITCH_DECLARE(switch_image_t *)switch_img_wrap(switch_image_t  *img,
@@ -115,7 +141,11 @@ SWITCH_DECLARE(switch_image_t *)switch_img_wrap(switch_image_t  *img,
                                                unsigned int align,
                                                unsigned char      *img_data)
 {
+#ifdef SWITCH_HAVE_VPX
        return (switch_image_t *)vpx_img_wrap((vpx_image_t *)img, (vpx_img_fmt_t)fmt, d_w, d_h, align, img_data);
+#else
+       return NULL;
+#endif
 }
 
 SWITCH_DECLARE(int) switch_img_set_rect(switch_image_t  *img,
@@ -124,16 +154,23 @@ SWITCH_DECLARE(int) switch_img_set_rect(switch_image_t  *img,
                                   unsigned int  w,
                                   unsigned int  h)
 {
+#ifdef SWITCH_HAVE_VPX
        return vpx_img_set_rect((vpx_image_t *)img, x, y, w, h);
+#else
+       return 0;
+#endif
 }
 
 SWITCH_DECLARE(void) switch_img_flip(switch_image_t *img)
 {
+#ifdef SWITCH_HAVE_VPX
        vpx_img_flip((vpx_image_t *)img);
+#endif
 }
 
 SWITCH_DECLARE(void) switch_img_free(switch_image_t **img)
 {
+#ifdef SWITCH_HAVE_VPX
        if (img && *img) {
                if ((*img)->fmt == SWITCH_IMG_FMT_GD) {
 #ifdef HAVE_LIBGD
@@ -145,6 +182,7 @@ SWITCH_DECLARE(void) switch_img_free(switch_image_t **img)
                vpx_img_free((vpx_image_t *)*img);
                *img = NULL;
        }
+#endif
 }
 
 #ifndef MIN
@@ -248,6 +286,7 @@ SWITCH_DECLARE(void) switch_img_patch(switch_image_t *IMG, switch_image_t *img,
 
 SWITCH_DECLARE(void) switch_img_patch_rect(switch_image_t *IMG, int X, int Y, switch_image_t *img, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
 {
+#ifdef SWITCH_HAVE_VPX
        switch_image_t *tmp;
        uint8_t *data;
 
@@ -270,6 +309,7 @@ SWITCH_DECLARE(void) switch_img_patch_rect(switch_image_t *IMG, int X, int Y, sw
        }
 
        switch_img_free(&tmp);
+#endif
 }
 
 SWITCH_DECLARE(void) switch_img_copy(switch_image_t *img, switch_image_t **new_img)
@@ -325,6 +365,7 @@ SWITCH_DECLARE(void) switch_img_copy(switch_image_t *img, switch_image_t **new_i
 
 SWITCH_DECLARE(switch_image_t *) switch_img_copy_rect(switch_image_t *img, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
 {
+#ifdef SWITCH_HAVE_VPX
        switch_image_t *new_img = NULL, *tmp;
        uint8_t *data;
 
@@ -351,10 +392,14 @@ SWITCH_DECLARE(switch_image_t *) switch_img_copy_rect(switch_image_t *img, uint3
        switch_img_free(&tmp);
 
        return new_img;
+#else
+       return NULL;
+#endif
 }
 
 SWITCH_DECLARE(void) switch_img_draw_pixel(switch_image_t *img, int x, int y, switch_rgb_color_t *color)
 {
+#ifdef SWITCH_HAVE_YUV 
        switch_yuv_color_t yuv;
 
        if (x < 0 || y < 0 || x >= img->d_w || y >= img->d_h) return;
@@ -375,10 +420,12 @@ SWITCH_DECLARE(void) switch_img_draw_pixel(switch_image_t *img, int x, int y, sw
                *(alpha + 2) = color->g;
                *(alpha + 3) = color->b;
        }
+#endif
 }
 
 SWITCH_DECLARE(void) switch_img_fill(switch_image_t *img, int x, int y, int w, int h, switch_rgb_color_t *color)
 {
+#ifdef SWITCH_HAVE_YUV 
        int len, i, max_h;
        switch_yuv_color_t yuv_color;
 
@@ -419,10 +466,12 @@ SWITCH_DECLARE(void) switch_img_fill(switch_image_t *img, int x, int y, int w, i
                                        img->planes[SWITCH_PLANE_PACKED], img->d_w * 4);
                }
        }
+#endif
 }
 
 SWITCH_DECLARE(void) switch_img_get_yuv_pixel(switch_image_t *img, switch_yuv_color_t *yuv, int x, int y)
 {
+#ifdef SWITCH_HAVE_YUV         
        // switch_assert(img->fmt == SWITCH_IMG_FMT_I420);
 
        if (x < 0 || y < 0 || x >= img->d_w || y >= img->d_h) return;
@@ -430,10 +479,12 @@ SWITCH_DECLARE(void) switch_img_get_yuv_pixel(switch_image_t *img, switch_yuv_co
        yuv->y = *(img->planes[SWITCH_PLANE_Y] + img->stride[SWITCH_PLANE_Y] * y + x);
        yuv->u = *(img->planes[SWITCH_PLANE_U] + img->stride[SWITCH_PLANE_U] * y / 2 + x / 2);
        yuv->v = *(img->planes[SWITCH_PLANE_V] + img->stride[SWITCH_PLANE_V] * y / 2 + x / 2);
+#endif 
 }
 
 SWITCH_DECLARE(void) switch_img_get_rgb_pixel(switch_image_t *img, switch_rgb_color_t *rgb, int x, int y)
 {
+#ifdef SWITCH_HAVE_YUV         
        if (x < 0 || y < 0 || x >= img->d_w || y >= img->d_h) return;
 
        if (img->fmt == SWITCH_IMG_FMT_I420) {
@@ -448,6 +499,7 @@ SWITCH_DECLARE(void) switch_img_get_rgb_pixel(switch_image_t *img, switch_rgb_co
                rgb->g = *(++a);
                rgb->b = *(++a);
        }
+#endif 
 }
 
 SWITCH_DECLARE(void) switch_img_overlay(switch_image_t *IMG, switch_image_t *img, int x, int y, uint8_t alpha)
@@ -577,15 +629,18 @@ SWITCH_DECLARE(void) switch_color_set_rgb(switch_rgb_color_t *color, const char
 
 SWITCH_DECLARE(void) switch_color_rgb2yuv(switch_rgb_color_t *rgb, switch_yuv_color_t *yuv)
 {
+#ifdef SWITCH_HAVE_YUV         
        yuv->y = (uint8_t)(((rgb->r * 4897) >> 14) + ((rgb->g * 9611) >> 14) + ((rgb->b * 1876) >> 14));
        yuv->u = (uint8_t)(- ((rgb->r * 2766) >> 14)  - ((5426 * rgb->g) >> 14) + rgb->b / 2 + 128);
        yuv->v = (uint8_t)(rgb->r / 2 -((6855 * rgb->g) >> 14) - ((rgb->b * 1337) >> 14) + 128);
+#endif 
 }
 
 #define CLAMP(val) MAX(0, MIN(val, 255))
 
 SWITCH_DECLARE(void) switch_color_yuv2rgb(switch_yuv_color_t *yuv, switch_rgb_color_t *rgb)
 {
+#ifdef SWITCH_HAVE_YUV 
 #if 0
        int C = yuv->y - 16;
        int D = yuv->u - 128;
@@ -600,14 +655,17 @@ SWITCH_DECLARE(void) switch_color_yuv2rgb(switch_yuv_color_t *yuv, switch_rgb_co
        rgb->r = CLAMP( yuv->y + ((22457 * (yuv->v-128)) >> 14));
        rgb->g = CLAMP((yuv->y - ((715   * (yuv->v-128)) >> 10) - ((5532 * (yuv->u-128)) >> 14)));
        rgb->b = CLAMP((yuv->y + ((28384 * (yuv->u-128)) >> 14)));
-}
+#endif
+ }
 
 SWITCH_DECLARE(void) switch_color_set_yuv(switch_yuv_color_t *color, const char *str)
 {
+#ifdef SWITCH_HAVE_YUV 
        switch_rgb_color_t rgb = { 0 };
 
        switch_color_set_rgb(&rgb, str);
        switch_color_rgb2yuv(&rgb, color);
+#endif 
 }
 
 #if SWITCH_HAVE_FREETYPE