Skip to content

Commit b41eb38

Browse files
committed
Make avdevice library optional again
It is not used by avformat when performing playback via SDL2, the only thing it does is initializing avdevice and not using it later.
1 parent e2e8162 commit b41eb38

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ if(MOD_AVFORMAT)
229229
AVUTIL
230230
AVCODEC
231231
AVFILTER
232-
AVDEVICE
233232
SWRESAMPLE
233+
OPTIONAL_COMPONENTS AVDEVICE
234234
)
235235

236236
list(APPEND MLT_SUPPORTED_COMPONENTS avformat)

cmake/FindFFmpeg.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ foreach (_component ${FFmpeg_FIND_COMPONENTS})
194194
endif ()
195195
list(APPEND _FFmpeg_FOUND_LIBRARIES ${${_component}_LIBRARIES})
196196
endif ()
197-
list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS ${_component}_FOUND)
197+
if (${FFMPEG_FIND_REQUIRED_${_component}})
198+
list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS ${_component}_FOUND)
199+
endif()
198200
endforeach ()
199201
list(INSERT _FFmpeg_REQUIRED_VARS 0 _FFmpeg_FOUND_LIBRARIES)
200202

src/modules/avformat/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ if(WIN32)
5151
endif()
5252
endif()
5353

54+
if(AVDEVICE_FOUND)
55+
target_compile_definitions(mltavformat PRIVATE AVDEVICE)
56+
endif()
57+
5458
if(CPU_MMX)
5559
target_compile_definitions(mltavformat PRIVATE USE_MMX)
5660
endif()

src/modules/avformat/factory.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ extern mlt_link link_swresample_init(mlt_profile profile, mlt_service_type, cons
4545
// ffmpeg Header files
4646
#include "mltavformat_export.h"
4747
#include <libavcodec/avcodec.h>
48+
#ifdef AVDEVICE
4849
#include <libavdevice/avdevice.h>
50+
#endif
4951
#include <libavfilter/avfilter.h>
5052
#include <libavformat/avformat.h>
5153
#include <libavutil/opt.h>
@@ -58,7 +60,9 @@ static void avformat_init()
5860
// Initialise avformat if necessary
5961
if (avformat_initialised == 0) {
6062
avformat_initialised = 1;
63+
#ifdef AVDEVICE
6164
avdevice_register_all();
65+
#endif
6266
avformat_network_init();
6367
av_log_set_level(mlt_log_get_level());
6468
if (getenv("MLT_AVFORMAT_PRODUCER_CACHE")) {

0 commit comments

Comments
 (0)