Build: Promote libavformat to a required dependency
FFmpeg is an integral component of ZM. Promote the appropriate libraries to required dependencies. This reduces the possible build configurations greatly and thus maintenance burden.
This commit is contained in:
parent
1a6904a297
commit
7d15396833
|
@ -438,15 +438,13 @@ 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
|
||||
avformat
|
||||
avutil)
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES ${FFMPEG_avutil_INCLUDE_DIRS})
|
||||
check_include_file("libavutil/hwcontext.h" HAVE_LIBAVUTIL_HWCONTEXT_H)
|
||||
|
||||
find_package(FFMPEG COMPONENTS avcodec)
|
||||
if(FFMPEG_avcodec_FOUND)
|
||||
|
@ -469,10 +467,6 @@ else()
|
|||
set(optlibsnotfound "${optlibsnotfound} AVDevice")
|
||||
endif()
|
||||
|
||||
find_package(FFMPEG REQUIRED COMPONENTS avutil)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${FFMPEG_avutil_INCLUDE_DIRS})
|
||||
check_include_file("libavutil/hwcontext.h" HAVE_LIBAVUTIL_HWCONTEXT_H)
|
||||
|
||||
find_package(FFMPEG COMPONENTS swscale)
|
||||
if(FFMPEG_swscale_FOUND)
|
||||
set(HAVE_LIBSWSCALE 1)
|
||||
|
@ -487,7 +481,7 @@ 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}")
|
||||
list(APPEND ZM_BIN_LIBS "FFMPEG::swresample")
|
||||
set(optlibsfound "${optlibsfound} SWResample")
|
||||
else()
|
||||
set(optlibsnotfound "${optlibsnotfound} SWResample")
|
||||
|
|
|
@ -77,6 +77,7 @@ target_include_directories(zm
|
|||
|
||||
target_link_libraries(zm
|
||||
PUBLIC
|
||||
FFMPEG::avformat
|
||||
FFMPEG::avutil
|
||||
libbcrypt::bcrypt
|
||||
RtspServer::RtspServer
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -131,7 +131,6 @@ extern "C" {
|
|||
#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
|
||||
|
@ -143,8 +142,6 @@ 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>
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
#include "zm_signal.h"
|
||||
#include "zm_utils.h"
|
||||
|
||||
#if HAVE_LIBAVFORMAT
|
||||
|
||||
extern "C" {
|
||||
#include "libavutil/time.h"
|
||||
#if HAVE_LIBAVUTIL_HWCONTEXT_H
|
||||
|
@ -630,5 +628,3 @@ int FfmpegCamera::FfmpegInterruptCallback(void *ctx) {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // HAVE_LIBAVFORMAT
|
||||
|
|
|
@ -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,9 +600,7 @@ 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 );
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
#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
|
||||
|
|
Loading…
Reference in New Issue