Build: Promote libswresample 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
762476ec76
commit
3d34e6f177
|
@ -443,6 +443,7 @@ find_package(FFMPEG REQUIRED
|
|||
avcodec
|
||||
avformat
|
||||
avutil
|
||||
swresample
|
||||
swscale)
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES ${FFMPEG_avutil_INCLUDE_DIRS})
|
||||
|
@ -458,16 +459,6 @@ else()
|
|||
set(optlibsnotfound "${optlibsnotfound} AVDevice")
|
||||
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")
|
||||
set(optlibsfound "${optlibsfound} SWResample")
|
||||
else()
|
||||
set(optlibsnotfound "${optlibsnotfound} SWResample")
|
||||
endif()
|
||||
|
||||
set(PATH_FFMPEG "")
|
||||
set(OPT_FFMPEG "no")
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ target_link_libraries(zm
|
|||
FFMPEG::avcodec
|
||||
FFMPEG::avformat
|
||||
FFMPEG::avutil
|
||||
FFMPEG::swresample
|
||||
FFMPEG::swscale
|
||||
libbcrypt::bcrypt
|
||||
RtspServer::RtspServer
|
||||
|
|
|
@ -635,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
|
||||
|
@ -659,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,21 +24,18 @@
|
|||
#include "zm_define.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
#ifdef HAVE_LIBSWRESAMPLE
|
||||
#include "libswresample/swresample.h"
|
||||
#endif
|
||||
#include <libswresample/swresample.h>
|
||||
|
||||
// AVUTIL
|
||||
#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
|
||||
|
@ -411,10 +408,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);
|
||||
|
|
|
@ -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,12 +9,10 @@
|
|||
#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
|
||||
}
|
||||
|
||||
|
@ -70,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;
|
||||
|
|
|
@ -37,8 +37,6 @@
|
|||
#cmakedefine HAVE_LIBAVDEVICE 1
|
||||
#cmakedefine HAVE_LIBAVDEVICE_AVDEVICE_H 1
|
||||
#cmakedefine HAVE_LIBAVUTIL_HWCONTEXT_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