Merge pull request #3278 from Carbenium/ffmpeg-required
Promote FFmpeg libs to a required dependencies
This commit is contained in:
commit
bbdf01880a
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(PATH_FFMPEG "")
|
||||
set(OPT_FFMPEG "no")
|
||||
|
|
|
@ -5,7 +5,6 @@ Maintainer: Isaac Connor <isaac@zoneminder.com>
|
|||
Uploaders: Isaac Connor <isaac@zoneminder.com>
|
||||
Build-Depends: debhelper, sphinx-doc, dh-linktree, dh-apache2
|
||||
,cmake
|
||||
,libavdevice-dev
|
||||
,libavcodec-dev
|
||||
,libavformat-dev
|
||||
,libavutil-dev
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -5,7 +5,6 @@ Maintainer: Isaac Connor <isaac@zoneminder.com>
|
|||
Uploaders: Isaac Connor <isaac@zoneminder.com>
|
||||
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~)
|
||||
|
|
|
@ -4,7 +4,6 @@ Priority: optional
|
|||
Maintainer: Isaac Connor <isaac@zoneminder.com>
|
||||
Build-Depends: debhelper (>= 12), sphinx-doc, python3-sphinx, dh-linktree, dh-apache2
|
||||
,cmake
|
||||
,libavdevice-dev
|
||||
,libavcodec-dev
|
||||
,libavformat-dev
|
||||
,libavutil-dev
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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 <libavformat/avformat.h>
|
||||
#include <libavformat/avio.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
class EventStream : public StreamBase {
|
||||
public:
|
||||
|
|
|
@ -24,11 +24,9 @@
|
|||
#include "zm_utils.h"
|
||||
|
||||
extern "C" {
|
||||
#include "libavutil/pixdesc.h"
|
||||
#include <libavutil/pixdesc.h>
|
||||
}
|
||||
|
||||
#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);
|
||||
|
|
|
@ -24,22 +24,18 @@
|
|||
#include "zm_define.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
#ifdef HAVE_LIBSWRESAMPLE
|
||||
#include "libswresample/swresample.h"
|
||||
#endif
|
||||
#include <libswresample/swresample.h>
|
||||
|
||||
// AVUTIL
|
||||
#if HAVE_LIBAVUTIL_AVUTIL_H
|
||||
#include "libavutil/avassert.h"
|
||||
#include <libavutil/avassert.h>
|
||||
#include <libavutil/avutil.h>
|
||||
#include <libavutil/base64.h>
|
||||
#include <libavutil/mathematics.h>
|
||||
#include <libavutil/avstring.h>
|
||||
#include "libavutil/audio_fifo.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include <libavutil/audio_fifo.h>
|
||||
#include <libavutil/imgutils.h>
|
||||
#if HAVE_LIBAVUTIL_HWCONTEXT_H
|
||||
#include "libavutil/hwcontext.h"
|
||||
#include <libavutil/hwcontext.h>
|
||||
#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 <libavcodec/avcodec.h>
|
||||
|
||||
/*
|
||||
|
@ -130,10 +124,8 @@ extern "C" {
|
|||
#else
|
||||
#define _AVCODECID CodecID
|
||||
#endif
|
||||
#endif /* HAVE_LIBAVCODEC_AVCODEC_H */
|
||||
|
||||
// AVFORMAT
|
||||
#if HAVE_LIBAVFORMAT_AVFORMAT_H
|
||||
#include <libavformat/avformat.h>
|
||||
|
||||
/* 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/avdevice.h>
|
||||
|
||||
/* 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/swscale.h>
|
||||
|
||||
/* 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);
|
||||
|
|
|
@ -25,15 +25,13 @@
|
|||
#include "zm_signal.h"
|
||||
#include "zm_utils.h"
|
||||
|
||||
#if HAVE_LIBAVFORMAT
|
||||
|
||||
extern "C" {
|
||||
#include "libavutil/time.h"
|
||||
#include <libavutil/time.h>
|
||||
#if HAVE_LIBAVUTIL_HWCONTEXT_H
|
||||
#include "libavutil/hwcontext.h"
|
||||
#include <libavutil/hwcontext.h>
|
||||
#endif
|
||||
|
||||
#include "libavutil/pixdesc.h"
|
||||
#include <libavutil/pixdesc.h>
|
||||
}
|
||||
|
||||
#include <string>
|
||||
|
@ -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
|
||||
|
|
|
@ -62,9 +62,7 @@ class FfmpegCamera : public Camera {
|
|||
int Close() override;
|
||||
bool mCanCapture;
|
||||
|
||||
#if HAVE_LIBSWSCALE
|
||||
struct SwsContext *mConvertContext;
|
||||
#endif
|
||||
|
||||
int error_count;
|
||||
|
||||
|
|
|
@ -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 <libavformat/avformat.h>
|
||||
#include <libavformat/avio.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
class FFmpeg_Input {
|
||||
|
||||
|
|
|
@ -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 <libavformat/avformat.h>
|
||||
#include <libavformat/avio.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
class FFmpeg_Output {
|
||||
|
||||
|
|
|
@ -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<ZMPacket> &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<ZMPacket> &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<ZMPacket> &zm_packet) {
|
|||
/* JPEG decoding */
|
||||
zm_packet->image->DecodeJpeg(buffer, buffer_bytesused, colours, subpixelorder);
|
||||
}
|
||||
|
||||
} else {
|
||||
Debug(3, "No format conversion performed. Assigning the image");
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<RemoteCameraRtsp>(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<FfmpegCamera>(this,
|
||||
path,
|
||||
|
@ -794,7 +785,6 @@ void Monitor::LoadCamera() {
|
|||
);
|
||||
break;
|
||||
}
|
||||
#endif // HAVE_LIBAVFORMAT
|
||||
case NVSOCKET: {
|
||||
camera = ZM::make_unique<RemoteCameraNVSocket>(this,
|
||||
host.c_str(),
|
||||
|
@ -2468,7 +2458,6 @@ std::vector<std::shared_ptr<Monitor>> Monitor::LoadFileMonitors(const char *file
|
|||
return LoadMonitors(where, purpose);
|
||||
}
|
||||
|
||||
#if HAVE_LIBAVFORMAT
|
||||
std::vector<std::shared_ptr<Monitor>> Monitor::LoadFfmpegMonitors(const char *file, Purpose purpose) {
|
||||
std::string where = "`Function` != 'None' AND `Type` = 'Ffmpeg'";
|
||||
if (file[0])
|
||||
|
@ -2477,7 +2466,6 @@ std::vector<std::shared_ptr<Monitor>> 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<FileCamera*>(camera.get());
|
||||
sprintf( output+strlen(output), "Path : %s\n", cam->Path() );
|
||||
}
|
||||
#if HAVE_LIBAVFORMAT
|
||||
else if ( camera->IsFfmpeg() ) {
|
||||
FfmpegCamera* cam = static_cast<FfmpegCamera*>(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
|
||||
|
|
|
@ -600,18 +600,14 @@ public:
|
|||
#endif // ZM_HAS_V4L
|
||||
static std::vector<std::shared_ptr<Monitor>> LoadRemoteMonitors(const char *protocol, const char *host, const char*port, const char*path, Purpose purpose);
|
||||
static std::vector<std::shared_ptr<Monitor>> LoadFileMonitors(const char *file, Purpose purpose);
|
||||
#if HAVE_LIBAVFORMAT
|
||||
static std::vector<std::shared_ptr<Monitor>> LoadFfmpegMonitors(const char *file, Purpose purpose);
|
||||
#endif // HAVE_LIBAVFORMAT
|
||||
static std::shared_ptr<Monitor> 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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
|
||||
#if HAVE_LIBAVCODEC
|
||||
extern "C" {
|
||||
#include <libavutil/mathematics.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
@ -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
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
#include "zm_ffmpeg.h"
|
||||
#include <pthread.h>
|
||||
|
||||
#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
|
||||
|
|
|
@ -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<ZMPacket> &zm_packet) {
|
|||
int RemoteCameraRtsp::PostCapture() {
|
||||
return 1;
|
||||
}
|
||||
#endif // HAVE_LIBAVFORMAT
|
||||
|
|
|
@ -48,10 +48,8 @@ protected:
|
|||
|
||||
int frameCount;
|
||||
|
||||
#if HAVE_LIBAVFORMAT
|
||||
AVFormatContext *mFormatContext;
|
||||
_AVPIXELFORMAT imagePixFormat;
|
||||
#endif // HAVE_LIBAVFORMAT
|
||||
|
||||
public:
|
||||
RemoteCameraRtsp(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
#include <string>
|
||||
#include <sys/time.h>
|
||||
|
||||
#if HAVE_LIBAVCODEC
|
||||
|
||||
struct RtpDataHeader;
|
||||
|
||||
class RtpSource
|
||||
|
@ -193,6 +191,4 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#endif // HAVE_LIBAVCODEC
|
||||
|
||||
#endif // ZM_RTP_SOURCE_H
|
||||
|
|
|
@ -26,8 +26,6 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
#ifndef ZM_SENDFILE_H
|
||||
#define ZM_SENDFILE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SENDFILE4_SUPPORT
|
||||
#include <sys/sendfile.h>
|
||||
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
|
||||
|
|
|
@ -28,12 +28,10 @@
|
|||
#include <unistd.h>
|
||||
|
||||
StreamBase::~StreamBase() {
|
||||
#if HAVE_LIBAVCODEC
|
||||
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;
|
||||
|
||||
|
|
|
@ -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 } };
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "zm_monitor.h"
|
||||
|
||||
extern "C" {
|
||||
#include "libavutil/time.h"
|
||||
#include <libavutil/time.h>
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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<ZMPacket> &ipkt) {
|
||||
|
|
|
@ -9,17 +9,13 @@
|
|||
#include <memory>
|
||||
|
||||
extern "C" {
|
||||
#ifdef HAVE_LIBSWRESAMPLE
|
||||
#include "libswresample/swresample.h"
|
||||
#endif
|
||||
#include "libavutil/audio_fifo.h"
|
||||
#include <libswresample/swresample.h>
|
||||
#include <libavutil/audio_fifo.h>
|
||||
#if HAVE_LIBAVUTIL_HWCONTEXT_H
|
||||
#include "libavutil/hwcontext.h"
|
||||
#include <libavutil/hwcontext.h>
|
||||
#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
|
||||
|
||||
|
|
20
src/zms.cpp
20
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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue