diff --git a/.github/workflows/ci-bullseye.yml b/.github/workflows/ci-bullseye.yml index 4de6a0fd2..7d1882844 100644 --- a/.github/workflows/ci-bullseye.yml +++ b/.github/workflows/ci-bullseye.yml @@ -38,7 +38,15 @@ jobs: with: submodules: recursive - name: Install dependencies - run: apt-get -qq install make cmake g++ default-libmysqlclient-dev libavdevice-dev libcurl4-gnutls-dev libvlc-dev libvncserver-dev libdate-manip-perl libdbd-mysql-perl libsys-mmap-perl libwww-perl libpolkit-gobject-1-dev catch2 ${{ matrix.crypto_package }} ${{ matrix.jwt_package }} + run: > + apt-get -qq install make cmake g++ + default-libmysqlclient-dev + libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev + libcurl4-gnutls-dev libvlc-dev libvncserver-dev + libdate-manip-perl libdbd-mysql-perl libsys-mmap-perl libwww-perl + libpolkit-gobject-1-dev + catch2 + ${{ matrix.crypto_package }} ${{ matrix.jwt_package }} - name: Prepare run: mkdir build - name: Configure diff --git a/.github/workflows/ci-buster.yml b/.github/workflows/ci-buster.yml index 5dd0e6d10..7411366dd 100644 --- a/.github/workflows/ci-buster.yml +++ b/.github/workflows/ci-buster.yml @@ -38,7 +38,14 @@ jobs: with: submodules: recursive - name: Install dependencies - run: apt-get -qq install make cmake g++ default-libmysqlclient-dev libavdevice-dev libcurl4-gnutls-dev libvlc-dev libvncserver-dev libdate-manip-perl libdbd-mysql-perl libsys-mmap-perl libwww-perl libpolkit-gobject-1-dev ${{ matrix.crypto_package }} ${{ matrix.jwt_package }} + run: > + apt-get -qq install make cmake g++ + default-libmysqlclient-dev + libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev + libcurl4-gnutls-dev libvlc-dev libvncserver-dev + libdate-manip-perl libdbd-mysql-perl libsys-mmap-perl libwww-perl + libpolkit-gobject-1-dev + ${{ matrix.crypto_package }} ${{ matrix.jwt_package }} - name: Prepare run: mkdir build - name: Configure diff --git a/.github/workflows/ci-stretch.yml b/.github/workflows/ci-stretch.yml index 95da4a10e..e42d4db3d 100644 --- a/.github/workflows/ci-stretch.yml +++ b/.github/workflows/ci-stretch.yml @@ -24,7 +24,14 @@ jobs: with: submodules: recursive - name: Install dependencies - run: apt-get -qq install make cmake g++ default-libmysqlclient-dev libavdevice-dev libcurl4-gnutls-dev libvlc-dev libvncserver-dev libdate-manip-perl libdbd-mysql-perl libsys-mmap-perl libwww-perl libpolkit-gobject-1-dev libssl-dev + run: > + apt-get -qq install make cmake g++ + default-libmysqlclient-dev + libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev + libcurl4-gnutls-dev libvlc-dev libvncserver-dev + libdate-manip-perl libdbd-mysql-perl libsys-mmap-perl libwww-perl + libpolkit-gobject-1-dev + libssl-dev - name: Prepare run: mkdir build - name: Configure diff --git a/.github/workflows/ci-xenial.yml b/.github/workflows/ci-xenial.yml index df7d9bb49..35ecb7fcc 100644 --- a/.github/workflows/ci-xenial.yml +++ b/.github/workflows/ci-xenial.yml @@ -18,7 +18,11 @@ jobs: with: submodules: recursive - name: Install dependencies - run: sudo apt-get -qq install libavdevice-dev libcurl4-gnutls-dev libvlc-dev libvncserver-dev libdate-manip-perl libdbd-mysql-perl libsys-mmap-perl libpolkit-gobject-1-dev + run: > + sudo apt-get -qq install libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev + libcurl4-gnutls-dev libvlc-dev libvncserver-dev + libdate-manip-perl libdbd-mysql-perl libsys-mmap-perl + libpolkit-gobject-1-dev - name: Prepare run: mkdir build - name: Configure diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f63ef62e8..d25aa3710 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -52,7 +52,7 @@ jobs: git submodule init git submodule update --init --recursive sudo apt-get update - sudo apt-get install libavdevice-dev libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev libjwt-gnutls-dev + sudo apt-get install libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev libjwt-gnutls-dev sudo apt-get install libbz2-dev libcurl4-gnutls-dev libjpeg-turbo8-dev libturbojpeg0-dev sudo apt-get install default-libmysqlclient-dev libpcre3-dev libpolkit-gobject-1-dev libv4l-dev libvlc-dev sudo apt-get install libdate-manip-perl libdbd-mysql-perl libphp-serialization-perl libsys-mmap-perl diff --git a/CMakeLists.txt b/CMakeLists.txt index f9879b2af..a92e0e6d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -438,69 +438,16 @@ else() message(FATAL_ERROR "ZoneMinder requires mysqlclient but it was not found on your system") endif() -find_package(FFMPEG COMPONENTS avformat) -if(FFMPEG_avformat_FOUND) - set(HAVE_LIBAVFORMAT 1) - set(HAVE_LIBAVFORMAT_AVFORMAT_H 1) - list(APPEND ZM_BIN_LIBS "FFMPEG::avformat") - set(optlibsfound "${optlibsfound} AVFormat") -else() - set(optlibsnotfound "${optlibsnotfound} AVFormat") -endif() +find_package(FFMPEG REQUIRED + COMPONENTS + avcodec + avformat + avutil + swresample + swscale) -find_package(FFMPEG COMPONENTS avcodec) -if(FFMPEG_avcodec_FOUND) - set(HAVE_LIBAVCODEC 1) - set(HAVE_LIBAVCODEC_AVCODEC_H 1) - list(APPEND ZM_BIN_LIBS "${FFMPEG_avcodec_LIBRARIES}") - set(optlibsfound "${optlibsfound} AVCodec") -else() - message(WARNING "\nWhile it should be possible to build ZM without AVCODEC the result will pretty useless.") - set(optlibsnotfound "${optlibsnotfound} AVCodec") -endif() - -find_package(FFMPEG COMPONENTS avdevice) -if(FFMPEG_avdevice_FOUND) - set(HAVE_LIBAVDEVICE 1) - set(HAVE_LIBAVDEVICE_AVDEVICE_H 1) - list(APPEND ZM_BIN_LIBS "${FFMPEG_avdevice_LIBRARIES}") - set(optlibsfound "${optlibsfound} AVDevice") -else() - set(optlibsnotfound "${optlibsnotfound} AVDevice") -endif() - -find_package(FFMPEG COMPONENTS avutil) -if(FFMPEG_avutil_FOUND) - set(HAVE_LIBAVUTIL 1) - set(HAVE_LIBAVUTIL_AVUTIL_H 1) - set(CMAKE_REQUIRED_INCLUDES ${FFMPEG_avutil_INCLUDE_DIRS}) - check_include_file("libavutil/mathematics.h" HAVE_LIBAVUTIL_MATHEMATICS_H) - check_include_file("libavutil/hwcontext.h" HAVE_LIBAVUTIL_HWCONTEXT_H) - list(APPEND ZM_BIN_LIBS "${FFMPEG_avutil_LIBRARIES}") - set(optlibsfound "${optlibsfound} AVUtil") -else() - set(optlibsnotfound "${optlibsnotfound} AVUtil") -endif() - -find_package(FFMPEG COMPONENTS swscale) -if(FFMPEG_swscale_FOUND) - set(HAVE_LIBSWSCALE 1) - set(HAVE_LIBSWSCALE_SWSCALE_H 1) - list(APPEND ZM_BIN_LIBS "${FFMPEG_swscale_LIBRARIES}") - set(optlibsfound "${optlibsfound} SWScale") -else() - set(optlibsnotfound "${optlibsnotfound} SWScale") -endif() - -find_package(FFMPEG COMPONENTS swresample) -if(FFMPEG_swresample_FOUND) - set(HAVE_LIBSWRESAMPLE 1) - set(HAVE_LIBSWRESAMPLE_SWRESAMPLE_H 1) - list(APPEND ZM_BIN_LIBS "${FFMPEG_swresample_LIBRARIES}") - set(optlibsfound "${optlibsfound} SWResample") -else() - set(optlibsnotfound "${optlibsnotfound} SWResample") -endif() +set(CMAKE_REQUIRED_INCLUDES ${FFMPEG_avutil_INCLUDE_DIRS}) +check_include_file("libavutil/hwcontext.h" HAVE_LIBAVUTIL_HWCONTEXT_H) set(PATH_FFMPEG "") set(OPT_FFMPEG "no") diff --git a/distros/beowulf/control b/distros/beowulf/control index ae93080f9..50d25a0c4 100644 --- a/distros/beowulf/control +++ b/distros/beowulf/control @@ -5,7 +5,6 @@ Maintainer: Isaac Connor Uploaders: Isaac Connor Build-Depends: debhelper, sphinx-doc, dh-linktree, dh-apache2 ,cmake - ,libavdevice-dev ,libavcodec-dev ,libavformat-dev ,libavutil-dev diff --git a/distros/debian/control b/distros/debian/control index 3ae5c7922..221a1dda5 100644 --- a/distros/debian/control +++ b/distros/debian/control @@ -9,7 +9,6 @@ Build-Depends: debhelper (>= 9), cmake , libjpeg8-dev | libjpeg-dev , libpcre3-dev , libavcodec-dev, libavformat-dev (>= 3:0.svn20090204), libswscale-dev (>= 3:0.svn20090204), libavutil-dev - , libavdevice-dev , libv4l-dev (>= 0.8.3) , libbz2-dev , ffmpeg | libav-tools @@ -47,7 +46,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends} ,libnumber-bytes-human-perl ,libfile-slurp-perl , libpcre3 - , ffmpeg | libav-tools, libavdevice53 | libavdevice55 | libavdevice57 + , ffmpeg | libav-tools , rsyslog | system-log-daemon , netpbm , zip diff --git a/distros/ubuntu1504_cmake_split_packages/control b/distros/ubuntu1504_cmake_split_packages/control index 45b7a3e50..1345c39ee 100644 --- a/distros/ubuntu1504_cmake_split_packages/control +++ b/distros/ubuntu1504_cmake_split_packages/control @@ -8,7 +8,7 @@ Build-Depends: debhelper (>= 9), po-debconf (>= 1.0), autoconf, automake, libtoo , libdate-manip-perl, libwww-perl , libjpeg8-dev | libjpeg9-dev | libjpeg62-turbo-dev , libpcre3-dev -, libavcodec-ffmpeg-dev, libavformat-ffmpeg-dev, libswscale-ffmpeg-dev, libavutil-ffmpeg-dev, libavdevice-ffmpeg-dev +, libavcodec-ffmpeg-dev, libavformat-ffmpeg-dev, libswscale-ffmpeg-dev, libavutil-ffmpeg-dev , libv4l-dev (>= 0.8.3) , libbz2-dev , libsys-mmap-perl diff --git a/distros/ubuntu1604/control b/distros/ubuntu1604/control index 2133fcc5b..5f6e1e7a2 100644 --- a/distros/ubuntu1604/control +++ b/distros/ubuntu1604/control @@ -5,7 +5,6 @@ Maintainer: Isaac Connor Uploaders: Isaac Connor Build-Depends: debhelper (>= 9), dh-systemd, python3-sphinx, apache2-dev, dh-linktree, dh-systemd, dh-apache2 ,cmake - ,libavdevice-dev (>= 6:10~) ,libavcodec-dev (>= 6:10~) ,libavformat-dev (>= 6:10~) ,libavutil-dev (>= 6:10~) diff --git a/distros/ubuntu2004/control b/distros/ubuntu2004/control index c853b7d63..f689ade62 100644 --- a/distros/ubuntu2004/control +++ b/distros/ubuntu2004/control @@ -4,7 +4,6 @@ Priority: optional Maintainer: Isaac Connor Build-Depends: debhelper (>= 12), sphinx-doc, python3-sphinx, dh-linktree, dh-apache2 ,cmake - ,libavdevice-dev ,libavcodec-dev ,libavformat-dev ,libavutil-dev diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b6d3ce1fb..82f6cefe0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -77,6 +77,11 @@ target_include_directories(zm target_link_libraries(zm PUBLIC + FFMPEG::avcodec + FFMPEG::avformat + FFMPEG::avutil + FFMPEG::swresample + FFMPEG::swscale libbcrypt::bcrypt RtspServer::RtspServer martinmoene::span-lite diff --git a/src/zm_config.h b/src/zm_config.h index daea8e14c..a6d0420b4 100644 --- a/src/zm_config.h +++ b/src/zm_config.h @@ -29,10 +29,6 @@ #define PATH_MAX 1024 #endif -#ifdef HAVE_LIBAVFORMAT -#define ZM_HAS_FFMPEG 1 -#endif // HAVE_LIBAVFORMAT - #define ZM_MAX_IMAGE_WIDTH 2048 // The largest image we imagine ever handling #define ZM_MAX_IMAGE_HEIGHT 1536 // The largest image we imagine ever handling #define ZM_MAX_IMAGE_COLOURS 4 // The largest image we imagine ever handling diff --git a/src/zm_eventstream.cpp b/src/zm_eventstream.cpp index 9b4f106e9..25949624d 100644 --- a/src/zm_eventstream.cpp +++ b/src/zm_eventstream.cpp @@ -699,7 +699,6 @@ bool EventStream::sendFrame(int delta_us) { return false; } -#if HAVE_LIBAVCODEC if ( type == STREAM_MPEG ) { Image image(filepath); @@ -712,9 +711,7 @@ bool EventStream::sendFrame(int delta_us) { vid_stream->OpenStream(); } /* double pts = */ vid_stream->EncodeFrame(send_image->Buffer(), send_image->Size(), config.mpeg_timed_frames, delta_us*1000); - } else -#endif // HAVE_LIBAVCODEC - { + } else { bool send_raw = (type == STREAM_JPEG) && ((scale>=ZM_SCALE_BASE)&&(zoom==ZM_SCALE_BASE)) && filepath[0]; fprintf(stdout, "--" BOUNDARY "\r\n"); @@ -1026,10 +1023,9 @@ void EventStream::runStream() { } // end if forward or reverse } // end if checkEventLoaded } // end while ! zm_terminate -#if HAVE_LIBAVCODEC - if ( type == STREAM_MPEG ) + if (type == STREAM_MPEG) { delete vid_stream; -#endif // HAVE_LIBAVCODEC + } closeComms(); } // end void EventStream::runStream() diff --git a/src/zm_eventstream.h b/src/zm_eventstream.h index 54b7687ab..4592e97e7 100644 --- a/src/zm_eventstream.h +++ b/src/zm_eventstream.h @@ -26,15 +26,11 @@ #include "zm_storage.h" #include "zm_stream.h" -#ifdef __cplusplus extern "C" { -#endif -#include "libavformat/avformat.h" -#include "libavformat/avio.h" -#include "libavcodec/avcodec.h" -#ifdef __cplusplus +#include +#include +#include } -#endif class EventStream : public StreamBase { public: diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index 53cc907f8..955d7f91d 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -24,11 +24,9 @@ #include "zm_utils.h" extern "C" { -#include "libavutil/pixdesc.h" +#include } -#if HAVE_LIBAVCODEC || HAVE_LIBAVUTIL || HAVE_LIBSWSCALE - void log_libav_callback(void *ptr, int level, const char *fmt, va_list vargs) { Logger *log = Logger::fetch(); int log_level = 0; @@ -100,7 +98,6 @@ void FFMPEGDeInit() { bInit = false; } -#if HAVE_LIBAVUTIL enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subpixelorder) { enum _AVPIXELFORMAT pf; @@ -190,11 +187,8 @@ int av_dict_parse_string(AVDictionary **pm, const char *str, return 0; } #endif -#endif // HAVE_LIBAVUTIL -#endif // HAVE_LIBAVCODEC || HAVE_LIBAVUTIL || HAVE_LIBSWSCALE -#if HAVE_LIBAVUTIL #if LIBAVUTIL_VERSION_CHECK(56, 0, 0, 17, 100) int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int duration, int64_t *last, AVRational out_tb){ int64_t a, b, this_thing; @@ -219,7 +213,6 @@ simple_round: return av_rescale_q(this_thing, fs_tb, out_tb); } #endif -#endif static void zm_log_fps(double d, const char *postfix) { uint64_t v = lrintf(d * 100); @@ -642,7 +635,6 @@ void zm_packet_copy_rescale_ts(const AVPacket *ipkt, AVPacket *opkt, const AVRat av_packet_rescale_ts(opkt, src_tb, dst_tb); } -#if defined(HAVE_LIBSWRESAMPLE) int zm_resample_audio(SwrContext *resample_ctx, AVFrame *in_frame, AVFrame *out_frame) { if (in_frame) { // Resample the in_frame into the audioSampleBuffer until we process the whole @@ -666,7 +658,6 @@ int zm_resample_audio(SwrContext *resample_ctx, AVFrame *in_frame, AVFrame *out_ int zm_resample_get_delay(SwrContext *resample_ctx, int time_base) { return swr_get_delay(resample_ctx, time_base); } -#endif int zm_add_samples_to_fifo(AVAudioFifo *fifo, AVFrame *frame) { int ret = av_audio_fifo_realloc(fifo, av_audio_fifo_size(fifo) + frame->nb_samples); diff --git a/src/zm_ffmpeg.h b/src/zm_ffmpeg.h index 704c46d25..84cfa342d 100644 --- a/src/zm_ffmpeg.h +++ b/src/zm_ffmpeg.h @@ -24,22 +24,18 @@ #include "zm_define.h" extern "C" { - -#ifdef HAVE_LIBSWRESAMPLE -#include "libswresample/swresample.h" -#endif +#include // AVUTIL -#if HAVE_LIBAVUTIL_AVUTIL_H -#include "libavutil/avassert.h" +#include #include #include #include #include -#include "libavutil/audio_fifo.h" -#include "libavutil/imgutils.h" +#include +#include #if HAVE_LIBAVUTIL_HWCONTEXT_H - #include "libavutil/hwcontext.h" + #include #endif /* LIBAVUTIL_VERSION_CHECK checks for the right version of libav and FFmpeg @@ -109,10 +105,8 @@ extern "C" { //#define AV_PIX_FMT_VDPAU_MPEG1 PIX_FMT_VDPAU_MPEG1 //#define AV_PIX_FMT_VDPAU_MPEG2 PIX_FMT_VDPAU_MPEG2 #endif -#endif /* HAVE_LIBAVUTIL_AVUTIL_H */ // AVCODEC -#if HAVE_LIBAVCODEC_AVCODEC_H #include /* @@ -130,10 +124,8 @@ extern "C" { #else #define _AVCODECID CodecID #endif -#endif /* HAVE_LIBAVCODEC_AVCODEC_H */ // AVFORMAT -#if HAVE_LIBAVFORMAT_AVFORMAT_H #include /* LIBAVFORMAT_VERSION_CHECK checks for the right version of libav and FFmpeg @@ -145,24 +137,7 @@ extern "C" { ( (LIBAVFORMAT_VERSION_MICRO < 100 && LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(a, b, c) ) || \ (LIBAVFORMAT_VERSION_MICRO >= 100 && LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(a, d, e) ) ) -#endif /* HAVE_LIBAVFORMAT_AVFORMAT_H */ - -// AVDEVICE -#if HAVE_LIBAVDEVICE_AVDEVICE_H -#include - -/* LIBAVDEVICE_VERSION_CHECK checks for the right version of libav and FFmpeg - * a is the major version - * b and c the minor and micro versions of libav - * d and e the minor and micro versions of FFmpeg */ -#define LIBAVDEVICE_VERSION_CHECK(a, b, c, d, e) \ - ( (LIBAVDEVICE_VERSION_MICRO < 100 && LIBAVDEVICE_VERSION_INT >= AV_VERSION_INT(a, b, c) ) || \ - (LIBAVDEVICE_VERSION_MICRO >= 100 && LIBAVDEVICE_VERSION_INT >= AV_VERSION_INT(a, d, e) ) ) - -#endif /* HAVE_LIBAVDEVICE_AVDEVICE_H */ - // SWSCALE -#if HAVE_LIBSWSCALE_SWSCALE_H #include /* LIBSWSCALE_VERSION_CHECK checks for the right version of libav and FFmpeg @@ -173,13 +148,7 @@ extern "C" { ( (LIBSWSCALE_VERSION_MICRO < 100 && LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(a, b, c) ) || \ (LIBSWSCALE_VERSION_MICRO >= 100 && LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(a, d, e) ) ) -#endif /* HAVE_LIBSWSCALE_SWSCALE_H */ - -#ifdef __cplusplus } -#endif - -#if ( HAVE_LIBAVUTIL_AVUTIL_H || HAVE_LIBAVCODEC_AVCODEC_H || HAVE_LIBAVFORMAT_AVFORMAT_H || HAVE_LIBAVDEVICE_AVDEVICE_H ) #if !LIBAVFORMAT_VERSION_CHECK(52, 107, 0, 107, 0) #if defined(AVIO_WRONLY) @@ -193,9 +162,7 @@ extern "C" { void FFMPEGInit(); void FFMPEGDeInit(); -#if HAVE_LIBAVUTIL enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subpixelorder); -#endif // HAVE_LIBAVUTIL #if !LIBAVCODEC_VERSION_CHECK(54, 25, 0, 51, 100) #define AV_CODEC_ID_NONE CODEC_ID_NONE @@ -228,8 +195,6 @@ enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subp * C++ friendly version of av_err2str taken from http://libav-users.943685.n4.nabble.com/Libav-user-g-4-7-2-fails-to-compile-av-err2str-td4656417.html. * Newer g++ versions fail with "error: taking address of temporary array" when using native libav version. */ -#ifdef __cplusplus - inline static const std::string av_make_error_string(int errnum) { static char errbuf[AV_ERROR_MAX_STRING_SIZE]; #if LIBAVUTIL_VERSION_CHECK(50, 13, 0, 13, 0) @@ -251,11 +216,6 @@ enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subp int flags); #endif -#endif // __cplusplus - - -#endif // ( HAVE_LIBAVUTIL_AVUTIL_H || HAVE_LIBAVCODEC_AVCODEC_H || HAVE_LIBAVFORMAT_AVFORMAT_H || HAVE_LIBAVDEVICE_AVDEVICE_H ) - #ifndef av_rescale_delta /** * Rescale a timestamp while preserving known durations. @@ -428,10 +388,8 @@ int zm_send_frame_receive_packet(AVCodecContext *context, AVFrame *frame, AVPack void zm_packet_copy_rescale_ts(const AVPacket *ipkt, AVPacket *opkt, const AVRational src_tb, const AVRational dst_tb); -#if defined(HAVE_LIBSWRESAMPLE) int zm_resample_audio(SwrContext *resample_ctx, AVFrame *in_frame, AVFrame *out_frame); int zm_resample_get_delay(SwrContext *resample_ctx, int time_base); -#endif int zm_add_samples_to_fifo(AVAudioFifo *fifo, AVFrame *frame); int zm_get_samples_from_fifo(AVAudioFifo *fifo, AVFrame *frame); diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 17917d696..f98d3e090 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -25,15 +25,13 @@ #include "zm_signal.h" #include "zm_utils.h" -#if HAVE_LIBAVFORMAT - extern "C" { -#include "libavutil/time.h" +#include #if HAVE_LIBAVUTIL_HWCONTEXT_H - #include "libavutil/hwcontext.h" + #include #endif -#include "libavutil/pixdesc.h" +#include } #include @@ -146,9 +144,7 @@ FfmpegCamera::FfmpegCamera( #endif #endif -#if HAVE_LIBSWSCALE mConvertContext = nullptr; -#endif /* Has to be located inside the constructor so other components such as zma * will receive correct colours and subpixel order */ if ( colours == ZM_COLOUR_RGB32 ) { @@ -630,5 +626,3 @@ int FfmpegCamera::FfmpegInterruptCallback(void *ctx) { } return 0; } - -#endif // HAVE_LIBAVFORMAT diff --git a/src/zm_ffmpeg_camera.h b/src/zm_ffmpeg_camera.h index df1cb3936..e320d3b31 100644 --- a/src/zm_ffmpeg_camera.h +++ b/src/zm_ffmpeg_camera.h @@ -62,9 +62,7 @@ class FfmpegCamera : public Camera { int Close() override; bool mCanCapture; -#if HAVE_LIBSWSCALE struct SwsContext *mConvertContext; -#endif int error_count; diff --git a/src/zm_ffmpeg_input.h b/src/zm_ffmpeg_input.h index 5ca5f07dc..6ccc87682 100644 --- a/src/zm_ffmpeg_input.h +++ b/src/zm_ffmpeg_input.h @@ -3,17 +3,11 @@ #include "zm_define.h" -#ifdef __cplusplus extern "C" { -#endif - -#include "libavformat/avformat.h" -#include "libavformat/avio.h" -#include "libavcodec/avcodec.h" - -#ifdef __cplusplus +#include +#include +#include } -#endif class FFmpeg_Input { diff --git a/src/zm_ffmpeg_output.h b/src/zm_ffmpeg_output.h index 76afad0d7..9ab4ea403 100644 --- a/src/zm_ffmpeg_output.h +++ b/src/zm_ffmpeg_output.h @@ -1,17 +1,11 @@ #ifndef ZM_FFMPEG_INPUT_H #define ZM_FFMPEG_INPUT_H -#ifdef __cplusplus extern "C" { -#endif - -#include "libavformat/avformat.h" -#include "libavformat/avio.h" -#include "libavcodec/avcodec.h" - -#ifdef __cplusplus +#include +#include +#include } -#endif class FFmpeg_Output { diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 262ece1e9..4c6bcd97f 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -45,7 +45,6 @@ static int vidioctl(int fd, int request, void *arg) { return result; } -#if HAVE_LIBSWSCALE static _AVPIXELFORMAT getFfPixFormatFromV4lPalette(int v4l_version, int palette) { _AVPIXELFORMAT pixFormat = AV_PIX_FMT_NONE; @@ -176,7 +175,6 @@ static _AVPIXELFORMAT getFfPixFormatFromV4lPalette(int v4l_version, int palette) return pixFormat; } // end getFfPixFormatFromV4lPalette -#endif // HAVE_LIBSWSCALE static char palette_desc[32]; /* Automatic format selection preferred formats */ @@ -222,9 +220,7 @@ int LocalCamera::vid_fd = -1; int LocalCamera::v4l_version = 0; LocalCamera::V4L2Data LocalCamera::v4l2_data; -#if HAVE_LIBSWSCALE AVFrame **LocalCamera::capturePictures = nullptr; -#endif // HAVE_LIBSWSCALE LocalCamera *LocalCamera::last_camera = nullptr; @@ -326,11 +322,9 @@ LocalCamera::LocalCamera( Warning("Different capture sizes defined for monitors sharing same device, results may be unpredictable or completely wrong"); } -#if HAVE_LIBSWSCALE /* Get ffmpeg pixel format based on capture palette and endianness */ capturePixFormat = getFfPixFormatFromV4lPalette( v4l_version, palette ); imagePixFormat = AV_PIX_FMT_NONE; -#endif // HAVE_LIBSWSCALE } /* V4L2 format matching */ @@ -360,16 +354,11 @@ LocalCamera::LocalCamera( /* Unable to find a solution for the selected palette and target colourspace. Conversion required. Notify the user of performance penalty */ } else { if ( capture ) { -#if HAVE_LIBSWSCALE Info( "No direct match for the selected palette (%d) and target colorspace (%02u). Format conversion is required, performance penalty expected", capturePixFormat, colours); -#else - Info("No direct match for the selected palette and target colorspace. Format conversion is required, performance penalty expected"); -#endif } -#if HAVE_LIBSWSCALE /* Try using swscale for the conversion */ conversion_type = 1; Debug(2, "Using swscale for image conversion"); @@ -397,10 +386,6 @@ LocalCamera::LocalCamera( } #endif } -#else - /* Don't have swscale, see what we can do */ - conversion_type = 2; -#endif /* Our YUYV->Grayscale conversion is a lot faster than swscale's */ if ( colours == ZM_COLOUR_GRAY8 && palette == V4L2_PIX_FMT_YUYV ) { conversion_type = 2; @@ -458,7 +443,6 @@ LocalCamera::LocalCamera( last_camera = this; Debug(3, "Selected subpixelorder: %u", subpixelorder); -#if HAVE_LIBSWSCALE /* Initialize swscale stuff */ if ( capture and (conversion_type == 1) ) { #if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101) @@ -490,7 +474,6 @@ LocalCamera::LocalCamera( tmpPicture = nullptr; imgConversionContext = nullptr; } // end if capture and conversion_tye == swscale -#endif if ( capture and device_prime ) Initialise(); } // end LocalCamera::LocalCamera @@ -499,7 +482,6 @@ LocalCamera::~LocalCamera() { if ( device_prime && capture ) Terminate(); -#if HAVE_LIBSWSCALE /* Clean up swscale stuff */ if ( capture && (conversion_type == 1) ) { sws_freeContext(imgConversionContext); @@ -507,8 +489,6 @@ LocalCamera::~LocalCamera() { av_frame_free(&tmpPicture); } -#endif - } // end LocalCamera::~LocalCamera int LocalCamera::Close() { @@ -696,9 +676,8 @@ void LocalCamera::Initialise() { channel_count, v4l_multi_buffer, v4l2_data.reqbufs.count); v4l2_data.buffers = new V4L2MappedBuffer[v4l2_data.reqbufs.count]; -#if HAVE_LIBSWSCALE capturePictures = new AVFrame *[v4l2_data.reqbufs.count]; -#endif // HAVE_LIBSWSCALE + for ( unsigned int i = 0; i < v4l2_data.reqbufs.count; i++ ) { struct v4l2_buffer vid_buf; @@ -720,7 +699,6 @@ void LocalCamera::Initialise() { Fatal("Can't map video buffer %u (%u bytes) to memory: %s(%d)", i, vid_buf.length, strerror(errno), errno); -#if HAVE_LIBSWSCALE #if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101) capturePictures[i] = av_frame_alloc(); #else @@ -746,7 +724,6 @@ void LocalCamera::Initialise() { v4l2_data.fmt.fmt.pix.height ); #endif -#endif // HAVE_LIBSWSCALE } // end foreach request buf Debug(3, "Configuring video source"); @@ -792,13 +769,11 @@ void LocalCamera::Terminate() { Debug(3, "Unmapping video buffers"); for ( unsigned int i = 0; i < v4l2_data.reqbufs.count; i++ ) { -#if HAVE_LIBSWSCALE /* Free capture pictures */ #if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101) av_frame_free(&capturePictures[i]); #else av_freep(&capturePictures[i]); -#endif #endif if ( munmap(v4l2_data.buffers[i].start, v4l2_data.buffers[i].length) < 0 ) Error("Failed to munmap buffer %d: %s", i, strerror(errno)); @@ -1484,7 +1459,6 @@ int LocalCamera::Capture(std::shared_ptr &zm_packet) { Error("Failed requesting writeable buffer for the captured image."); return -1; } -#if HAVE_LIBSWSCALE if (conversion_type == 1) { Debug(9, "Calling sws_scale to perform the conversion"); /* Use swscale to convert the image directly into the shared memory */ @@ -1505,9 +1479,7 @@ int LocalCamera::Capture(std::shared_ptr &zm_packet) { tmpPicture->data, tmpPicture->linesize ); - } else -#endif - if ( conversion_type == 2 ) { + } else if (conversion_type == 2) { Debug(9, "Calling the conversion function"); /* Call the image conversion function and convert directly into the shared memory */ (*conversion_fptr)(buffer, directbuffer, pixels); @@ -1517,7 +1489,6 @@ int LocalCamera::Capture(std::shared_ptr &zm_packet) { /* JPEG decoding */ zm_packet->image->DecodeJpeg(buffer, buffer_bytesused, colours, subpixelorder); } - } else { Debug(3, "No format conversion performed. Assigning the image"); diff --git a/src/zm_local_camera.h b/src/zm_local_camera.h index 455cd8bc8..f331929d5 100644 --- a/src/zm_local_camera.h +++ b/src/zm_local_camera.h @@ -73,13 +73,11 @@ protected: static V4L2Data v4l2_data; -#if HAVE_LIBSWSCALE static AVFrame **capturePictures; _AVPIXELFORMAT imagePixFormat; _AVPIXELFORMAT capturePixFormat; struct SwsContext *imgConversionContext; AVFrame *tmpPicture; -#endif // HAVE_LIBSWSCALE static LocalCamera *last_camera; diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 0b00f41a5..d9eccb6d6 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -21,11 +21,13 @@ #include "zm_group.h" #include "zm_eventstream.h" +#include "zm_ffmpeg_camera.h" #include "zm_fifo.h" #include "zm_file_camera.h" #include "zm_remote_camera.h" #include "zm_remote_camera_http.h" #include "zm_remote_camera_nvsocket.h" +#include "zm_remote_camera_rtsp.h" #include "zm_signal.h" #include "zm_time.h" #include "zm_utils.h" @@ -35,14 +37,6 @@ #include "zm_local_camera.h" #endif // ZM_HAS_V4L -#if HAVE_LIBAVFORMAT -#include "zm_remote_camera_rtsp.h" -#endif // HAVE_LIBAVFORMAT - -#if HAVE_LIBAVFORMAT -#include "zm_ffmpeg_camera.h" -#endif // HAVE_LIBAVFORMAT - #if HAVE_LIBVLC #include "zm_libvlc_camera.h" #endif // HAVE_LIBVLC @@ -733,7 +727,6 @@ void Monitor::LoadCamera() { record_audio ); } -#if HAVE_LIBAVFORMAT else if (protocol == "rtsp") { camera = ZM::make_unique(this, method, @@ -752,7 +745,6 @@ void Monitor::LoadCamera() { record_audio ); } -#endif // HAVE_LIBAVFORMAT else { Error("Unexpected remote camera protocol '%s'", protocol.c_str()); } @@ -773,7 +765,6 @@ void Monitor::LoadCamera() { ); break; } -#if HAVE_LIBAVFORMAT case FFMPEG: { camera = ZM::make_unique(this, path, @@ -794,7 +785,6 @@ void Monitor::LoadCamera() { ); break; } -#endif // HAVE_LIBAVFORMAT case NVSOCKET: { camera = ZM::make_unique(this, host.c_str(), @@ -2468,7 +2458,6 @@ std::vector> Monitor::LoadFileMonitors(const char *file return LoadMonitors(where, purpose); } -#if HAVE_LIBAVFORMAT std::vector> Monitor::LoadFfmpegMonitors(const char *file, Purpose purpose) { std::string where = "`Function` != 'None' AND `Type` = 'Ffmpeg'"; if (file[0]) @@ -2477,7 +2466,6 @@ std::vector> Monitor::LoadFfmpegMonitors(const char *fi where += stringtf(" AND `ServerId`=%d", staticConfig.SERVER_ID); return LoadMonitors(where, purpose); } -#endif // HAVE_LIBAVFORMAT /* Returns 0 on success, even if no new images are available (transient error) * Returns -1 on failure. @@ -2950,12 +2938,10 @@ bool Monitor::DumpSettings(char *output, bool verbose) { FileCamera* cam = static_cast(camera.get()); sprintf( output+strlen(output), "Path : %s\n", cam->Path() ); } -#if HAVE_LIBAVFORMAT else if ( camera->IsFfmpeg() ) { FfmpegCamera* cam = static_cast(camera.get()); sprintf( output+strlen(output), "Path : %s\n", cam->Path().c_str() ); } -#endif // HAVE_LIBAVFORMAT sprintf( output+strlen(output), "Width : %u\n", camera->Width() ); sprintf( output+strlen(output), "Height : %u\n", camera->Height() ); #if ZM_HAS_V4L diff --git a/src/zm_monitor.h b/src/zm_monitor.h index 69fff8c59..c72b8d326 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -600,18 +600,14 @@ public: #endif // ZM_HAS_V4L static std::vector> LoadRemoteMonitors(const char *protocol, const char *host, const char*port, const char*path, Purpose purpose); static std::vector> LoadFileMonitors(const char *file, Purpose purpose); -#if HAVE_LIBAVFORMAT static std::vector> LoadFfmpegMonitors(const char *file, Purpose purpose); -#endif // HAVE_LIBAVFORMAT static std::shared_ptr Load(unsigned int id, bool load_zones, Purpose purpose); void Load(MYSQL_ROW dbrow, bool load_zones, Purpose purpose); //void writeStreamImage( Image *image, struct timeval *timestamp, int scale, int mag, int x, int y ); //void StreamImages( int scale=100, int maxfps=10, time_t ttl=0, int msq_id=0 ); //void StreamImagesRaw( int scale=100, int maxfps=10, time_t ttl=0 ); //void StreamImagesZip( int scale=100, int maxfps=10, time_t ttl=0 ); -#if HAVE_LIBAVCODEC //void StreamMpeg( const char *format, int scale=100, int maxfps=10, int bitrate=100000 ); -#endif // HAVE_LIBAVCODEC double get_capture_fps( ) const { return shared_data ? shared_data->capture_fps : 0.0; } diff --git a/src/zm_monitorstream.cpp b/src/zm_monitorstream.cpp index 0df93f963..f7ff0fea5 100644 --- a/src/zm_monitorstream.cpp +++ b/src/zm_monitorstream.cpp @@ -385,7 +385,6 @@ bool MonitorStream::sendFrame(Image *image, const timeval ×tamp) { monitor->TimestampImage(send_image, timestamp); fputs("--" BOUNDARY "\r\n", stdout); -#if HAVE_LIBAVCODEC if ( type == STREAM_MPEG ) { if ( !vid_stream ) { vid_stream = new VideoStream("pipe:", format, bitrate, effective_fps, send_image->Colours(), send_image->SubpixelOrder(), send_image->Width(), send_image->Height()); @@ -398,9 +397,7 @@ bool MonitorStream::sendFrame(Image *image, const timeval ×tamp) { base_time = timestamp; DELTA_TIMEVAL(delta_time, timestamp, base_time, DT_PREC_3); /* double pts = */ vid_stream->EncodeFrame(send_image->Buffer(), send_image->Size(), config.mpeg_timed_frames, delta_time.delta); - } else -#endif // HAVE_LIBAVCODEC - { + } else { static unsigned char temp_img_buffer[ZM_MAX_IMAGE_SIZE]; int img_buffer_size = 0; diff --git a/src/zm_mpeg.cpp b/src/zm_mpeg.cpp index 5ab1ad5dc..d55d39b1d 100644 --- a/src/zm_mpeg.cpp +++ b/src/zm_mpeg.cpp @@ -24,7 +24,6 @@ #include #include -#if HAVE_LIBAVCODEC extern "C" { #include #include @@ -595,20 +594,14 @@ double VideoStream::EncodeFrame( const uint8_t *buffer, int buffer_size, bool _a double VideoStream::ActuallyEncodeFrame( const uint8_t *buffer, int buffer_size, bool add_timestamp, unsigned int timestamp ) { if ( codec_context->pix_fmt != pf ) { -#ifdef HAVE_LIBSWSCALE static struct SwsContext *img_convert_ctx = nullptr; -#endif // HAVE_LIBSWSCALE memcpy( tmp_opicture->data[0], buffer, buffer_size ); -#ifdef HAVE_LIBSWSCALE if ( !img_convert_ctx ) { img_convert_ctx = sws_getCachedContext( nullptr, codec_context->width, codec_context->height, pf, codec_context->width, codec_context->height, codec_context->pix_fmt, SWS_BICUBIC, nullptr, nullptr, nullptr ); if ( !img_convert_ctx ) Panic( "Unable to initialise image scaling context" ); } sws_scale( img_convert_ctx, tmp_opicture->data, tmp_opicture->linesize, 0, codec_context->height, opicture->data, opicture->linesize ); -#else // HAVE_LIBSWSCALE - Fatal( "swscale is required for MPEG mode" ); -#endif // HAVE_LIBSWSCALE } else { memcpy( opicture->data[0], buffer, buffer_size ); } @@ -766,5 +759,3 @@ void *VideoStream::StreamingThreadCallback(void *ctx){ return nullptr; } - -#endif // HAVE_LIBAVCODEC diff --git a/src/zm_mpeg.h b/src/zm_mpeg.h index 4999f1328..b6a6f49be 100644 --- a/src/zm_mpeg.h +++ b/src/zm_mpeg.h @@ -23,8 +23,6 @@ #include "zm_ffmpeg.h" #include -#if HAVE_LIBAVCODEC - class VideoStream { protected: struct MimeData { @@ -83,6 +81,4 @@ public: double EncodeFrame( const uint8_t *buffer, int buffer_size, bool add_timestamp=false, unsigned int timestamp=0 ); }; -#endif // HAVE_LIBAVCODEC - #endif // ZM_MPEG_H diff --git a/src/zm_remote_camera_rtsp.cpp b/src/zm_remote_camera_rtsp.cpp index e35217cc8..cede4fa4e 100644 --- a/src/zm_remote_camera_rtsp.cpp +++ b/src/zm_remote_camera_rtsp.cpp @@ -23,8 +23,6 @@ #include "zm_monitor.h" #include "zm_packet.h" -#if HAVE_LIBAVFORMAT - RemoteCameraRtsp::RemoteCameraRtsp( const Monitor *monitor, const std::string &p_method, @@ -320,4 +318,3 @@ int RemoteCameraRtsp::Capture(std::shared_ptr &zm_packet) { int RemoteCameraRtsp::PostCapture() { return 1; } -#endif // HAVE_LIBAVFORMAT diff --git a/src/zm_remote_camera_rtsp.h b/src/zm_remote_camera_rtsp.h index a815b96b1..4880f6f35 100644 --- a/src/zm_remote_camera_rtsp.h +++ b/src/zm_remote_camera_rtsp.h @@ -48,10 +48,8 @@ protected: int frameCount; -#if HAVE_LIBAVFORMAT AVFormatContext *mFormatContext; _AVPIXELFORMAT imagePixFormat; -#endif // HAVE_LIBAVFORMAT public: RemoteCameraRtsp( diff --git a/src/zm_rtp_ctrl.cpp b/src/zm_rtp_ctrl.cpp index 9d74359fc..954ea2fd4 100644 --- a/src/zm_rtp_ctrl.cpp +++ b/src/zm_rtp_ctrl.cpp @@ -23,8 +23,6 @@ #include "zm_rtp.h" #include "zm_rtsp.h" -#if HAVE_LIBAVFORMAT - RtpCtrlThread::RtpCtrlThread(RtspThread &rtspThread, RtpSource &rtpSource) : mRtspThread(rtspThread), mRtpSource(rtpSource), mTerminate(false) { @@ -334,5 +332,3 @@ void RtpCtrlThread::Run() { rtpCtrlServer.close(); mRtspThread.Stop(); } - -#endif // HAVE_LIBAVFORMAT diff --git a/src/zm_rtp_data.cpp b/src/zm_rtp_data.cpp index aed02aea6..744abd21f 100644 --- a/src/zm_rtp_data.cpp +++ b/src/zm_rtp_data.cpp @@ -23,8 +23,6 @@ #include "zm_rtsp.h" #include "zm_signal.h" -#if HAVE_LIBAVFORMAT - RtpDataThread::RtpDataThread(RtspThread &rtspThread, RtpSource &rtpSource) : mRtspThread(rtspThread), mRtpSource(rtpSource), mTerminate(false) { @@ -107,5 +105,3 @@ void RtpDataThread::Run() { rtpDataSocket.close(); mRtspThread.Stop(); } - -#endif // HAVE_LIBAVFORMAT diff --git a/src/zm_rtp_source.cpp b/src/zm_rtp_source.cpp index ff69a6069..2fd5bc41b 100644 --- a/src/zm_rtp_source.cpp +++ b/src/zm_rtp_source.cpp @@ -25,8 +25,6 @@ #include #include -#if HAVE_LIBAVCODEC - RtpSource::RtpSource( int id, const std::string &localHost, @@ -371,5 +369,3 @@ bool RtpSource::getFrame(Buffer &buffer) { Debug(4, "Copied %d bytes", buffer.size()); return true; } - -#endif // HAVE_LIBAVCODEC diff --git a/src/zm_rtp_source.h b/src/zm_rtp_source.h index 0d1bdee83..3736f71cb 100644 --- a/src/zm_rtp_source.h +++ b/src/zm_rtp_source.h @@ -29,8 +29,6 @@ #include #include -#if HAVE_LIBAVCODEC - struct RtpDataHeader; class RtpSource @@ -193,6 +191,4 @@ public: } }; -#endif // HAVE_LIBAVCODEC - #endif // ZM_RTP_SOURCE_H diff --git a/src/zm_rtsp.cpp b/src/zm_rtsp.cpp index 4efe0a43b..09dd3b5b6 100644 --- a/src/zm_rtsp.cpp +++ b/src/zm_rtsp.cpp @@ -26,8 +26,6 @@ #include -#if HAVE_LIBAVFORMAT - int RtspThread::smMinDataPort = 0; int RtspThread::smMaxDataPort = 0; RtspThread::PortSet RtspThread::smAssignedPorts; @@ -790,5 +788,3 @@ void RtspThread::Run() { return; } - -#endif // HAVE_LIBAVFORMAT diff --git a/src/zm_sdp.cpp b/src/zm_sdp.cpp index 63bb8d9bd..9e771ec2c 100644 --- a/src/zm_sdp.cpp +++ b/src/zm_sdp.cpp @@ -23,8 +23,6 @@ #include "zm_exception.h" #include "zm_logger.h" -#if HAVE_LIBAVFORMAT - #if (LIBAVCODEC_VERSION_CHECK(52, 64, 0, 64, 0) || LIBAVUTIL_VERSION_CHECK(50, 14, 0, 14, 0)) SessionDescriptor::StaticPayloadDesc SessionDescriptor::smStaticPayloads[] = { { 0, "PCMU", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_PCM_MULAW, 8000, 1 }, @@ -497,5 +495,3 @@ AVFormatContext *SessionDescriptor::generateFormatContext() const { return formatContext; } - -#endif // HAVE_LIBAVFORMAT diff --git a/src/zm_sendfile.h b/src/zm_sendfile.h index 593a94833..fd72e2e61 100644 --- a/src/zm_sendfile.h +++ b/src/zm_sendfile.h @@ -1,10 +1,6 @@ #ifndef ZM_SENDFILE_H #define ZM_SENDFILE_H -#ifdef __cplusplus -extern "C" { -#endif - #ifdef HAVE_SENDFILE4_SUPPORT #include int zm_sendfile(int out_fd, int in_fd, off_t *offset, size_t size) { @@ -37,8 +33,4 @@ int zm_sendfile(int out_fd, int in_fd, off_t *offset, off_t size) { #error "Your platform does not support sendfile. Sorry." #endif -#ifdef __cplusplus -} -#endif - -#endif +#endif // ZM_SENDFILE_H diff --git a/src/zm_stream.cpp b/src/zm_stream.cpp index ce7a4460b..c8f1166bd 100644 --- a/src/zm_stream.cpp +++ b/src/zm_stream.cpp @@ -28,12 +28,10 @@ #include StreamBase::~StreamBase() { -#if HAVE_LIBAVCODEC - if ( vid_stream ) { + if (vid_stream) { delete vid_stream; vid_stream = nullptr; } -#endif closeComms(); } @@ -263,7 +261,6 @@ bool StreamBase::sendTextFrame(const char *frame_text) { if ( scale != 100 ) { image.Scale(scale); } -#if HAVE_LIBAVCODEC if ( type == STREAM_MPEG ) { if ( !vid_stream ) { vid_stream = new VideoStream("pipe:", format, bitrate, effective_fps, image.Colours(), image.SubpixelOrder(), image.Width(), image.Height()); @@ -271,9 +268,7 @@ bool StreamBase::sendTextFrame(const char *frame_text) { vid_stream->OpenStream(); } /* double pts = */ vid_stream->EncodeFrame(image.Buffer(), image.Size()); - } else -#endif // HAVE_LIBAVCODEC - { + } else { static unsigned char buffer[ZM_MAX_IMAGE_SIZE]; int n_bytes = 0; diff --git a/src/zm_stream.h b/src/zm_stream.h index 6d752689d..9182d6dd4 100644 --- a/src/zm_stream.h +++ b/src/zm_stream.h @@ -129,9 +129,7 @@ protected: double last_frame_sent; struct timeval last_frame_timestamp; -#if HAVE_LIBAVCODEC VideoStream *vid_stream; -#endif // HAVE_LIBAVCODEC CmdMsg msg; @@ -178,9 +176,7 @@ public: effective_fps = 0.0; frame_mod = 1; -#if HAVE_LIBAVCODEC vid_stream = 0; -#endif // HAVE_LIBAVCODEC last_frame_sent = 0.0; last_frame_timestamp = {}; msg = { 0, { 0 } }; diff --git a/src/zm_swscale.cpp b/src/zm_swscale.cpp index c4aa6b738..6929151d3 100644 --- a/src/zm_swscale.cpp +++ b/src/zm_swscale.cpp @@ -22,7 +22,6 @@ #include "zm_image.h" #include "zm_logger.h" -#if HAVE_LIBSWSCALE && HAVE_LIBAVUTIL SWScale::SWScale() : gotdefaults(false), swscale_ctx(nullptr), input_avframe(nullptr), output_avframe(nullptr) { Debug(4, "SWScale object created"); } @@ -291,4 +290,3 @@ size_t SWScale::GetBufferSize(enum _AVPIXELFORMAT pf, unsigned int width, unsign return outsize = avpicture_get_size(pf, width,height); #endif } -#endif // HAVE_LIBSWSCALE && HAVE_LIBAVUTIL diff --git a/src/zm_swscale.h b/src/zm_swscale.h index 8e7e1fa19..c0d1e7120 100644 --- a/src/zm_swscale.h +++ b/src/zm_swscale.h @@ -7,7 +7,6 @@ class Image; /* SWScale wrapper class to make our life easier and reduce code reuse */ -#if HAVE_LIBSWSCALE && HAVE_LIBAVUTIL class SWScale { public: SWScale(); @@ -32,6 +31,5 @@ class SWScale { unsigned int default_width; unsigned int default_height; }; -#endif // HAVE_LIBSWSCALE && HAVE_LIBAVUTIL -#endif +#endif // ZM_SWSCALE_H diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index b72ff4968..c7f7aa3ef 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -24,7 +24,7 @@ #include "zm_monitor.h" extern "C" { -#include "libavutil/time.h" +#include } /* @@ -87,10 +87,8 @@ VideoStore::VideoStore( packets_written(0), frame_count(0), hw_device_ctx(nullptr), -#if defined(HAVE_LIBSWRESAMPLE) resample_ctx(nullptr), fifo(nullptr), -#endif converted_in_samples(nullptr), filename(filename_in), format(format_in), @@ -722,7 +720,6 @@ VideoStore::~VideoStore() { #endif } -#if defined(HAVE_LIBSWRESAMPLE) if (resample_ctx) { if (fifo) { av_audio_fifo_free(fifo); @@ -742,7 +739,6 @@ VideoStore::~VideoStore() { av_free(converted_in_samples); converted_in_samples = nullptr; } -#endif } // end if audio_out_stream Debug(4, "free context"); @@ -753,10 +749,6 @@ VideoStore::~VideoStore() { } // VideoStore::~VideoStore() bool VideoStore::setup_resampler() { -#if !defined(HAVE_LIBSWRESAMPLE) - Error("Not built with resample library. Cannot do audio conversion to AAC"); - return false; -#else int ret; #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) @@ -925,7 +917,6 @@ bool VideoStore::setup_resampler() { Error("Could not allocate FIFO"); return false; } -#if defined(HAVE_LIBSWRESAMPLE) resample_ctx = swr_alloc_set_opts(nullptr, audio_out_ctx->channel_layout, audio_out_ctx->sample_fmt, @@ -948,7 +939,6 @@ bool VideoStore::setup_resampler() { return false; } Debug(1,"Success setting up SWRESAMPLE"); -#endif out_frame->nb_samples = audio_out_ctx->frame_size; out_frame->format = audio_out_ctx->sample_fmt; @@ -984,7 +974,6 @@ bool VideoStore::setup_resampler() { } return true; -#endif } // end bool VideoStore::setup_resampler() int VideoStore::writePacket(const std::shared_ptr &ipkt) { diff --git a/src/zm_videostore.h b/src/zm_videostore.h index 0a3f69ecf..580607959 100644 --- a/src/zm_videostore.h +++ b/src/zm_videostore.h @@ -9,17 +9,13 @@ #include extern "C" { -#ifdef HAVE_LIBSWRESAMPLE -#include "libswresample/swresample.h" -#endif -#include "libavutil/audio_fifo.h" +#include +#include #if HAVE_LIBAVUTIL_HWCONTEXT_H -#include "libavutil/hwcontext.h" +#include #endif } -#if HAVE_LIBAVCODEC - class Monitor; class ZMPacket; class PacketQueue; @@ -72,10 +68,8 @@ class VideoStore { AVBufferRef *hw_device_ctx; -#ifdef HAVE_LIBSWRESAMPLE SwrContext *resample_ctx; AVAudioFifo *fifo; -#endif uint8_t *converted_in_samples; const char *filename; @@ -119,6 +113,5 @@ class VideoStore { void flush_codecs(); }; -#endif //havelibav -#endif //zm_videostore_h +#endif // ZM_VIDEOSTORE_H diff --git a/src/zms.cpp b/src/zms.cpp index d98f24418..70b0b1b80 100644 --- a/src/zms.cpp +++ b/src/zms.cpp @@ -281,19 +281,9 @@ int main(int argc, const char *argv[], char **envp) { } else if ( mode == ZMS_SINGLE ) { stream.setStreamType(MonitorStream::STREAM_SINGLE); } else { -#if HAVE_LIBAVCODEC stream.setStreamFormat(format); stream.setStreamBitrate(bitrate); stream.setStreamType(MonitorStream::STREAM_MPEG); -#else // HAVE_LIBAVCODEC - Error("MPEG streaming of '%s' attempted while disabled", query); - fprintf(stderr, "MPEG streaming is disabled.\n" - "You should configure with the --with-ffmpeg" - " option and rebuild to use this functionality.\n"); - logTerm(); - zmDbClose(); - return -1; -#endif // HAVE_LIBAVCODEC } stream.runStream(); } else if ( source == ZMS_FIFO ) { @@ -320,19 +310,9 @@ int main(int argc, const char *argv[], char **envp) { if ( mode == ZMS_JPEG ) { stream.setStreamType(EventStream::STREAM_JPEG); } else { -#if HAVE_LIBAVCODEC stream.setStreamFormat(format); stream.setStreamBitrate(bitrate); stream.setStreamType(EventStream::STREAM_MPEG); -#else // HAVE_LIBAVCODEC - Error("MPEG streaming of '%s' attempted while disabled", query); - fprintf(stderr, "MPEG streaming is disabled.\n" - "You should ensure the ffmpeg libraries are installed and detected" - " and rebuild to use this functionality.\n"); - logTerm(); - zmDbClose(); - return -1; -#endif // HAVE_LIBAVCODEC } // end if jpeg or mpeg stream.runStream(); } else { diff --git a/zoneminder-config.cmake b/zoneminder-config.cmake index 7d5fd2323..c535de4de 100644 --- a/zoneminder-config.cmake +++ b/zoneminder-config.cmake @@ -34,20 +34,7 @@ #cmakedefine HAVE_LIBGNUTLS 1 #cmakedefine HAVE_LIBMYSQLCLIENT 1 #cmakedefine HAVE_MYSQL_H 1 -#cmakedefine HAVE_LIBAVFORMAT 1 -#cmakedefine HAVE_LIBAVFORMAT_AVFORMAT_H 1 -#cmakedefine HAVE_LIBAVCODEC 1 -#cmakedefine HAVE_LIBAVCODEC_AVCODEC_H 1 -#cmakedefine HAVE_LIBAVDEVICE 1 -#cmakedefine HAVE_LIBAVDEVICE_AVDEVICE_H 1 -#cmakedefine HAVE_LIBAVUTIL 1 -#cmakedefine HAVE_LIBAVUTIL_AVUTIL_H 1 -#cmakedefine HAVE_LIBAVUTIL_MATHEMATICS_H 1 #cmakedefine HAVE_LIBAVUTIL_HWCONTEXT_H 1 -#cmakedefine HAVE_LIBSWSCALE 1 -#cmakedefine HAVE_LIBSWSCALE_SWSCALE_H 1 -#cmakedefine HAVE_LIBSWRESAMPLE 1 -#cmakedefine HAVE_LIBSWRESAMPLE_SWRESAMPLE_H 1 #cmakedefine HAVE_LIBVLC 1 #cmakedefine HAVE_VLC_VLC_H 1 #cmakedefine HAVE_LIBVNC 1