Build: Promote libavutil 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:
Peter Keresztes Schmidt 2021-06-05 11:58:44 +02:00
parent 70c626a30e
commit 1a6904a297
7 changed files with 8 additions and 35 deletions

View File

@ -469,18 +469,9 @@ 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)
find_package(FFMPEG REQUIRED COMPONENTS avutil)
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)

View File

@ -77,6 +77,7 @@ target_include_directories(zm
target_link_libraries(zm
PUBLIC
FFMPEG::avutil
libbcrypt::bcrypt
RtspServer::RtspServer
martinmoene::span-lite

View File

@ -27,8 +27,6 @@ extern "C" {
#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);

View File

@ -30,7 +30,6 @@ extern "C" {
#endif
// AVUTIL
#if HAVE_LIBAVUTIL_AVUTIL_H
#include "libavutil/avassert.h"
#include <libavutil/avutil.h>
#include <libavutil/base64.h>
@ -109,7 +108,6 @@ 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
@ -179,8 +177,6 @@ extern "C" {
}
#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)
#define AVIO_FLAG_WRITE AVIO_WRONLY
@ -193,9 +189,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
@ -253,9 +247,6 @@ enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subp
#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.

View File

@ -22,7 +22,7 @@
#include "zm_image.h"
#include "zm_logger.h"
#if HAVE_LIBSWSCALE && HAVE_LIBAVUTIL
#if HAVE_LIBSWSCALE
SWScale::SWScale() : gotdefaults(false), swscale_ctx(nullptr), input_avframe(nullptr), output_avframe(nullptr) {
Debug(4, "SWScale object created");
}
@ -291,4 +291,4 @@ 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
#endif // HAVE_LIBSWSCALE

View File

@ -7,7 +7,7 @@
class Image;
/* SWScale wrapper class to make our life easier and reduce code reuse */
#if HAVE_LIBSWSCALE && HAVE_LIBAVUTIL
#if HAVE_LIBSWSCALE
class SWScale {
public:
SWScale();
@ -32,6 +32,6 @@ class SWScale {
unsigned int default_width;
unsigned int default_height;
};
#endif // HAVE_LIBSWSCALE && HAVE_LIBAVUTIL
#endif // HAVE_LIBSWSCALE
#endif

View File

@ -40,9 +40,6 @@
#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