0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00
obs-studio/plugins/obs-ffmpeg/CMakeLists.txt
pkv e7d097cab8
obs-ffmpeg: Native SRT/RIST for mpegts output
Currently the ffmpeg_mpegts_muxer output is integrated with ffmpeg-mux.
Both use obs native encoders in contrast with obs-ffmpeg-output which
relies on avcodec library.
This allowed easy implementation of SRT, RIST & HLS protocols through
avformat library.
The main drawback is that obs-ffmpeg-mux exe doesn't allow for easy
debugging nor logging of the protocols.
It was written initially as a separate binary designed for recording so
that if obs fails for some reason, the recording can still terminate
gracefully.

In this commit the ffmpeg_mpegts_muxer is rewritten so that a pipe to
the ffmpeg-mux binary is not used any more.
The muxing to mpegts is still delegated to avformat.
But it can be traced more easily in all its steps.
Also the protocol part for SRT & RIST is implemented natively.
Custom avio_contexts for SRT & RIST are used to that end.
This allows to pass our own implementation of librist and libsrt
libraries instead of relying on avformat. This is very advantageous :
- this allows better logging.
- this allows better bug fixing and maintainance without having to rely
on hypothetical upstream fixes.

One immediate bonus of native implementation is that fixes bugs which
were not previously fixable.

Fixes: SRT & RIST auto-reconnect partly broken  #6749
Fixes: SRT: OBS unusable and uncloseable after starting stream to
invalid srt server #5791

Signed-off-by: pkv <pkv@obsproject.com>
2022-07-30 17:03:10 +02:00

97 lines
2.6 KiB
CMake

project(obs-ffmpeg)
option(ENABLE_FFMPEG_LOGGING "Enables obs-ffmpeg logging" OFF)
find_package(
FFmpeg REQUIRED
COMPONENTS avcodec
avfilter
avdevice
avutil
swscale
avformat
swresample)
add_library(obs-ffmpeg MODULE)
add_library(OBS::ffmpeg ALIAS obs-ffmpeg)
find_package(Librist QUIET)
find_package(Libsrt QUIET)
add_subdirectory(ffmpeg-mux)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/obs-ffmpeg-config.h.in
${CMAKE_BINARY_DIR}/config/obs-ffmpeg-config.h)
target_sources(
obs-ffmpeg
PRIVATE obs-ffmpeg.c
obs-ffmpeg-video-encoders.c
obs-ffmpeg-audio-encoders.c
obs-ffmpeg-av1.c
obs-ffmpeg-nvenc.c
obs-ffmpeg-output.c
obs-ffmpeg-mpegts.c
obs-ffmpeg-mux.c
obs-ffmpeg-mux.h
obs-ffmpeg-hls-mux.c
obs-ffmpeg-source.c
obs-ffmpeg-compat.h
obs-ffmpeg-formats.h
${CMAKE_BINARY_DIR}/config/obs-ffmpeg-config.h
obs-ffmpeg-srt.h
obs-ffmpeg-rist.h
obs-ffmpeg-url.h)
target_include_directories(obs-ffmpeg PRIVATE ${CMAKE_BINARY_DIR}/config)
target_link_libraries(
obs-ffmpeg
PRIVATE OBS::libobs
OBS::media-playback
OBS::opts-parser
FFmpeg::avcodec
FFmpeg::avfilter
FFmpeg::avformat
FFmpeg::avdevice
FFmpeg::avutil
FFmpeg::swscale
FFmpeg::swresample
Librist::Librist
Libsrt::Libsrt)
if(ENABLE_FFMPEG_LOGGING)
target_sources(obs-ffmpeg PRIVATE obs-ffmpeg-logging.c)
endif()
set_target_properties(obs-ffmpeg PROPERTIES FOLDER "plugins/obs-ffmpeg" PREFIX
"")
target_compile_options(
obs-ffmpeg
PRIVATE
$<$<OR:$<C_COMPILER_ID:Clang>,$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:GNU>>:-Wno-switch>
)
if(OS_WINDOWS)
add_subdirectory(obs-amf-test)
if(MSVC)
target_link_libraries(obs-ffmpeg PRIVATE OBS::w32-pthreads)
endif()
target_link_libraries(obs-ffmpeg PRIVATE ws2_32.lib)
set(MODULE_DESCRIPTION "OBS FFmpeg module")
configure_file(${CMAKE_SOURCE_DIR}/cmake/bundle/windows/obs-module.rc.in
obs-ffmpeg.rc)
target_sources(
obs-ffmpeg PRIVATE texture-amf.cpp texture-amf-opts.hpp jim-nvenc.c
jim-nvenc.h jim-nvenc-helpers.c obs-ffmpeg.rc)
elseif(OS_POSIX AND NOT OS_MACOS)
find_package(Libpci REQUIRED)
target_sources(obs-ffmpeg PRIVATE obs-ffmpeg-vaapi.c)
target_link_libraries(obs-ffmpeg PRIVATE LIBPCI::LIBPCI)
endif()
setup_plugin_target(obs-ffmpeg)