0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00
obs-studio/cmake/Modules/FindLibsrt.cmake
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

75 lines
2.0 KiB
CMake

# Once done these will be defined:
#
# LIBSRT_FOUND LIBSRT_INCLUDE_DIRS LIBSRT_LIBRARIES
#
# For use in OBS:
#
# LIBSRT_INCLUDE_DIR
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(_LIBSRT QUIET libsrt)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_lib_suffix 64)
else()
set(_lib_suffix 32)
endif()
find_path(
LIBSRT_INCLUDE_DIR
NAMES srt.h srt/srt.h
HINTS ENV LIBSRT_PATH ${LIBSRT_PATH} ${CMAKE_SOURCE_DIR}/${LIBSRT_PATH}
${_LIBSRT_INCLUDE_DIRS} ${DepsPath}
PATHS /usr/include /usr/local/include /opt/local/include /sw/include
PATH_SUFFIXES include)
find_library(
LIBSRT_LIB
NAMES ${_LIBSRT_LIBRARIES} srt libsrt
HINTS ENV LIBSRT_PATH ${LIBSRT_PATH} ${CMAKE_SOURCE_DIR}/${LIBSRT_PATH}
${_LIBSRT_LIBRARY_DIRS} ${DepsPath}
PATHS /usr/lib /usr/local/lib /opt/local/lib /sw/lib
PATH_SUFFIXES
lib${_lib_suffix}
lib
libs${_lib_suffix}
libs
bin${_lib_suffix}
bin
../lib${_lib_suffix}
../lib
../libs${_lib_suffix}
../libs
../bin${_lib_suffix}
../bin)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libsrt DEFAULT_MSG LIBSRT_LIB
LIBSRT_INCLUDE_DIR)
mark_as_advanced(LIBSRT_INCLUDE_DIR LIBSRT_LIB)
if(LIBSRT_FOUND)
set(LIBSRT_INCLUDE_DIRS ${LIBSRT_INCLUDE_DIR})
set(LIBSRT_LIBRARIES ${LIBSRT_LIB})
if(NOT TARGET Libsrt::Libsrt)
if(IS_ABSOLUTE "${LIBSRT_LIBRARIES}")
add_library(Libsrt::Libsrt UNKNOWN IMPORTED)
set_target_properties(Libsrt::Libsrt PROPERTIES IMPORTED_LOCATION
"${LIBSRT_LIBRARIES}")
else()
add_library(Libsrt::Libsrt INTERFACE IMPORTED)
set_target_properties(Libsrt::Libsrt PROPERTIES IMPORTED_LIBNAME
"${LIBSRT_LIBRARIES}")
endif()
set_target_properties(
Libsrt::Libsrt PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${LIBSRT_INCLUDE_DIRS}")
endif()
else()
message(STATUS "libsrt library not found")
endif()