Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obs-ffmpeg: Add a stats dock for SRT with graphs #9027

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ if(CMAKE_HOST_SYSTEM_NAME MATCHES "(Darwin)" OR OBS_CMAKE_VERSION VERSION_GREATE
option(ENABLE_UI "Enable building with UI (requires Qt)" ON)
option(ENABLE_SCRIPTING "Enable scripting support" ON)
option(ENABLE_HEVC "Enable HEVC encoders" ON)
option(ENABLE_NEW_MPEGTS_OUTPUT "Use native SRT/RIST mpegts output" ON)
if(ENABLE_NEW_MPEGTS_OUTPUT)
add_compile_definitions(NEW_MPEGTS_OUTPUT)
endif()

add_subdirectory(libobs)
if(OS_WINDOWS)
Expand Down Expand Up @@ -65,6 +69,10 @@ option(ENABLE_HEVC "Enable HEVC encoders" ON)
if(ENABLE_HEVC)
add_compile_definitions(ENABLE_HEVC)
endif()
option(ENABLE_NEW_MPEGTS_OUTPUT "Use native SRT/RIST mpegts output" ON)
if(ENABLE_NEW_MPEGTS_OUTPUT)
add_compile_definitions(NEW_MPEGTS_OUTPUT)
endif()
option(BUILD_FOR_DISTRIBUTION "Build for distribution (enables optimizations)" OFF)
option(ENABLE_UI "Enable building with UI (requires Qt)" ON)
option(ENABLE_SCRIPTING "Enable scripting support" ON)
Expand Down
10 changes: 5 additions & 5 deletions buildspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
}
},
"qt6": {
"version": "2024-01-27",
"baseUrl": "https://github.com/obsproject/obs-deps/releases/download",
"version": "2024-02-19",
"baseUrl": "https://github.com/pkviet/obs-deps/releases/download",
"label": "Pre-Built Qt6",
"hashes": {
"macos-universal": "86f6418c3e454b3979947fdba183aa7303ca9d7729c7056435bd023d466cf93a",
"windows-x64": "7a15c4b494bfe2df51cad16e7cbcfcc2b5b69b55839dd584c622214038c7d44c"
"macos-universal": "77bb4ea468524f1f1e4c3c83fb72251b129716390d1918a49b726cdc306ac1fb",
"windows-x64": "9e5c59f3f26690931808ee1173cae3bc912b6058edbeebc71762ac598f8f901a"
},
"debugSymbols": {
"windows-x64": "ddf356ce20a4946f7522253b5da44ce7fe29398bb55ff74467431fb31e8ec645"
"windows-x64": "62f993967e3858e7e75ef1ef2d42aef2d9d6474b81bbbc062a92a850abd8159b"
}
},
"cef": {
Expand Down
6 changes: 6 additions & 0 deletions cmake/Modules/CopyMSVCBins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ file(
"${QtCore_BIN_DIR}/Qt6Svgd.dll"
"${QtCore_BIN_DIR}/Qt6Xmld.dll"
"${QtCore_BIN_DIR}/Qt6Networkd.dll"
"${QtCore_BIN_DIR}/Qt6Chartsd.dll"
"${QtCore_BIN_DIR}/Qt6OpenGLd.dll"
"${QtCore_BIN_DIR}/Qt6OpenGLWidgetsd.dll"
"${QtCore_BIN_DIR}/libGLESv2d.dll"
"${QtCore_BIN_DIR}/libEGLd.dll")
file(GLOB QT_DEBUG_PLAT_BIN_FILES "${QtCore_PLUGIN_DIR}/platforms/qwindowsd.dll")
Expand All @@ -199,6 +202,9 @@ file(
"${QtCore_BIN_DIR}/Qt6Svg.dll"
"${QtCore_BIN_DIR}/Qt6Xml.dll"
"${QtCore_BIN_DIR}/Qt6Network.dll"
"${QtCore_BIN_DIR}/Qt6Charts.dll"
"${QtCore_BIN_DIR}/Qt6OpenGL.dll"
"${QtCore_BIN_DIR}/Qt6OpenGLWidgets.dll"
"${QtCore_BIN_DIR}/libGLESv2.dll"
"${QtCore_BIN_DIR}/libEGL.dll")
file(GLOB QT_PLAT_BIN_FILES "${QtCore_PLUGIN_DIR}/platforms/qwindows.dll")
Expand Down
6 changes: 6 additions & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ if(OBS_CMAKE_VERSION VERSION_GREATER_EQUAL 3.0.0)
check_obs_browser()
add_subdirectory(obs-ffmpeg)
add_subdirectory(obs-filters)
if(ENABLE_NEW_MPEGTS_OUTPUT)
add_subdirectory(obs-mpegts)
endif()
add_subdirectory(obs-outputs)
if(OS_WINDOWS)
add_subdirectory(obs-qsv11)
Expand Down Expand Up @@ -185,3 +188,6 @@ add_subdirectory(rtmp-services)
add_subdirectory(text-freetype2)
add_subdirectory(aja)
add_subdirectory(obs-webrtc)
if(ENABLE_NEW_MPEGTS_OUTPUT)
add_subdirectory(obs-mpegts)
endif()
9 changes: 1 addition & 8 deletions plugins/obs-ffmpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.22...3.25)
legacy_check()

option(ENABLE_FFMPEG_LOGGING "Enables obs-ffmpeg logging" OFF)
option(ENABLE_NEW_MPEGTS_OUTPUT "Use native SRT/RIST mpegts output" ON)

include(cmake/dependencies.cmake)

Expand All @@ -16,10 +15,6 @@ target_sources(
obs-ffmpeg
PRIVATE # cmake-format: sortable
$<$<BOOL:${ENABLE_FFMPEG_LOGGING}>:obs-ffmpeg-logging.c>
$<$<BOOL:${ENABLE_NEW_MPEGTS_OUTPUT}>:obs-ffmpeg-mpegts.c>
$<$<BOOL:${ENABLE_NEW_MPEGTS_OUTPUT}>:obs-ffmpeg-rist.h>
$<$<BOOL:${ENABLE_NEW_MPEGTS_OUTPUT}>:obs-ffmpeg-srt.h>
$<$<BOOL:${ENABLE_NEW_MPEGTS_OUTPUT}>:obs-ffmpeg-url.h>
$<$<PLATFORM_ID:Linux,FreeBSD,OpenBSD>:obs-ffmpeg-vaapi.c>
$<$<PLATFORM_ID:Linux,FreeBSD,OpenBSD>:vaapi-utils.c>
$<$<PLATFORM_ID:Linux,FreeBSD,OpenBSD>:vaapi-utils.h>
Expand Down Expand Up @@ -65,9 +60,7 @@ target_link_libraries(
$<$<PLATFORM_ID:Windows>:ws2_32>
$<$<PLATFORM_ID:Linux,FreeBSD,OpenBSD>:Libva::va>
$<$<PLATFORM_ID:Linux,FreeBSD,OpenBSD>:Libva::drm>
$<$<PLATFORM_ID:Linux,FreeBSD,OpenBSD>:Libpci::pci>
$<$<BOOL:${ENABLE_NEW_MPEGTS_OUTPUT}>:Librist::Librist>
$<$<BOOL:${ENABLE_NEW_MPEGTS_OUTPUT}>:Libsrt::Libsrt>)
$<$<PLATFORM_ID:Linux,FreeBSD,OpenBSD>:Libpci::pci>)

if(OS_WINDOWS)
configure_file(cmake/windows/obs-module.rc.in obs-ffmpeg.rc)
Expand Down
19 changes: 0 additions & 19 deletions plugins/obs-ffmpeg/cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,3 @@ elseif(
find_package(Libva REQUIRED)
find_package(Libpci REQUIRED)
endif()

if(ENABLE_NEW_MPEGTS_OUTPUT)
find_package(Librist QUIET)
find_package(Libsrt QUIET)

foreach(_output_lib IN ITEMS Librist Libsrt)
if(NOT TARGET ${_output_lib}::${_output_lib})
list(APPEND _error_messages "MPEGTS output library ${_output_lib} not found.")
endif()
endforeach()

if(_error_messages)
list(JOIN _error_messages "\n" _error_string)
message(
FATAL_ERROR
"${_error_string}\n Disable this error by setting ENABLE_NEW_MPEGTS_OUTPUT to OFF or providing the build system with required SRT and Rist libraries."
)
endif()
endif()
25 changes: 0 additions & 25 deletions plugins/obs-ffmpeg/cmake/legacy.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
project(obs-ffmpeg)

option(ENABLE_FFMPEG_LOGGING "Enables obs-ffmpeg logging" OFF)
option(ENABLE_NEW_MPEGTS_OUTPUT "Use native SRT/RIST mpegts output" ON)

find_package(
FFmpeg REQUIRED
Expand All @@ -17,20 +16,6 @@ add_library(obs-ffmpeg MODULE)
add_library(OBS::ffmpeg ALIAS obs-ffmpeg)

add_subdirectory(ffmpeg-mux)
if(ENABLE_NEW_MPEGTS_OUTPUT)
find_package(Librist QUIET)
find_package(Libsrt QUIET)

if(NOT TARGET Librist::Librist AND NOT TARGET Libsrt::Libsrt)
obs_status(
FATAL_ERROR
"SRT and RIST libraries not found! Please install SRT and RIST libraries or set ENABLE_NEW_MPEGTS_OUTPUT=OFF.")
elseif(NOT TARGET Libsrt::Libsrt)
obs_status(FATAL_ERROR "SRT library not found! Please install SRT library or set ENABLE_NEW_MPEGTS_OUTPUT=OFF.")
elseif(NOT TARGET Librist::Librist)
obs_status(FATAL_ERROR "RIST library not found! Please install RIST library or set ENABLE_NEW_MPEGTS_OUTPUT=OFF.")
endif()
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/obs-ffmpeg-config.h.in ${CMAKE_BINARY_DIR}/config/obs-ffmpeg-config.h)

Expand Down Expand Up @@ -66,16 +51,6 @@ target_link_libraries(
FFmpeg::swscale
FFmpeg::swresample)

if(ENABLE_NEW_MPEGTS_OUTPUT)
target_sources(obs-ffmpeg PRIVATE obs-ffmpeg-mpegts.c obs-ffmpeg-srt.h obs-ffmpeg-rist.h obs-ffmpeg-url.h)

target_link_libraries(obs-ffmpeg PRIVATE Librist::Librist Libsrt::Libsrt)
if(OS_WINDOWS)
target_link_libraries(obs-ffmpeg PRIVATE ws2_32.lib)
endif()
target_compile_definitions(obs-ffmpeg PRIVATE NEW_MPEGTS_OUTPUT)
endif()

if(ENABLE_FFMPEG_LOGGING)
target_sources(obs-ffmpeg PRIVATE obs-ffmpeg-logging.c)
endif()
Expand Down
9 changes: 0 additions & 9 deletions plugins/obs-ffmpeg/obs-ffmpeg-output.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#ifdef NEW_MPEGTS_OUTPUT
#include "obs-ffmpeg-url.h"
#endif

struct ffmpeg_cfg {
const char *url;
Expand Down Expand Up @@ -107,12 +104,6 @@ struct ffmpeg_output {
os_event_t *stop_event;

DARRAY(AVPacket *) packets;
#ifdef NEW_MPEGTS_OUTPUT
/* used for SRT & RIST */
URLContext *h;
AVIOContext *s;
bool got_headers;
#endif
};
bool ffmpeg_data_init(struct ffmpeg_data *data, struct ffmpeg_cfg *config);
void ffmpeg_data_free(struct ffmpeg_data *data);
4 changes: 4 additions & 0 deletions plugins/obs-ffmpeg/obs-ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ MODULE_EXPORT const char *obs_module_description(void)
extern struct obs_source_info ffmpeg_source;
extern struct obs_output_info ffmpeg_output;
extern struct obs_output_info ffmpeg_muxer;
#ifndef NEW_MPEGTS_OUTPUT
extern struct obs_output_info ffmpeg_mpegts_muxer;
#endif
extern struct obs_output_info replay_buffer;
extern struct obs_output_info ffmpeg_hls_muxer;
extern struct obs_encoder_info aac_encoder_info;
Expand Down Expand Up @@ -362,7 +364,9 @@ bool obs_module_load(void)
obs_register_source(&ffmpeg_source);
obs_register_output(&ffmpeg_output);
obs_register_output(&ffmpeg_muxer);
#ifndef NEW_MPEGTS_OUTPUT
obs_register_output(&ffmpeg_mpegts_muxer);
#endif
obs_register_output(&ffmpeg_hls_muxer);
obs_register_output(&replay_buffer);
obs_register_encoder(&aac_encoder_info);
Expand Down
39 changes: 39 additions & 0 deletions plugins/obs-mpegts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
cmake_minimum_required(VERSION 3.22...3.25)

legacy_check()

include(cmake/dependencies.cmake)

add_library(obs-mpegts MODULE)
add_library(OBS::mpegts ALIAS obs-mpegts)

find_package(Librist REQUIRED)
find_package(Libsrt REQUIRED)

target_sources(obs-mpegts PRIVATE obs-mpegts.c obs-mpegts-common.h obs-mpegts-rist.h obs-mpegts-srt.h
obs-mpegts-srt-stats.cpp obs-mpegts-srt-stats.hpp)

target_compile_options(obs-ffmpeg PRIVATE $<$<COMPILE_LANG_AND_ID:C,AppleClang,Clang>:-Wno-shorten-64-to-32>)
target_link_libraries(
obs-mpegts
PRIVATE OBS::libobs
OBS::frontend-api
FFmpeg::avcodec
FFmpeg::avformat
FFmpeg::avutil
$<$<PLATFORM_ID:Windows>:OBS::w32-pthreads>
$<$<PLATFORM_ID:Windows>:ws2_32>
Librist::Librist
Libsrt::Libsrt
Qt::Core
Qt::Widgets
Qt::Charts)

if(OS_WINDOWS)
configure_file(cmake/windows/obs-module.rc.in obs-mpegts.rc)
target_sources(obs-mpegts PRIVATE obs-mpegts.rc)
endif()

# cmake-format: off
set_target_properties_obs(obs-mpegts PROPERTIES FOLDER plugins/obs-mpegts PREFIX "" AUTOMOC ON AUTOUIC ON AUTORCC ON)
# cmake-format: on
31 changes: 31 additions & 0 deletions plugins/obs-mpegts/cmake/dependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# cmake-format: off
if(OS_WINDOWS OR OS_MACOS)
set(ffmpeg_version 6)
else()
set(ffmpeg_version 4.4)
endif()

find_package(
FFmpeg ${ffmpeg_version}
REQUIRED avcodec
avutil
avformat)
# cmake-format: on

find_qt(COMPONENTS Core Widgets Charts)
find_package(Librist QUIET)
find_package(Libsrt QUIET)

foreach(_output_lib IN ITEMS Librist Libsrt)
if(NOT TARGET ${_output_lib}::${_output_lib})
list(APPEND _error_messages "MPEGTS output library ${_output_lib} not found.")
endif()
endforeach()

if(_error_messages)
list(JOIN "\n" _error_string _error_string)
message(
FATAL_ERROR
"${_error_string}\n Disable this error by setting ENABLE_NEW_MPEGTS_OUTPUT to OFF or providing the build system with required SRT and Rist libraries."
)
endif()
59 changes: 59 additions & 0 deletions plugins/obs-mpegts/cmake/legacy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
project(obs-mpegts)

find_package(FFmpeg REQUIRED COMPONENTS avcodec avutil avformat)

add_library(obs-mpegts MODULE)
add_library(OBS::mpegts ALIAS obs-mpegts)

find_package(Librist REQUIRED)
find_package(Libsrt REQUIRED)
find_qt(COMPONENTS Core Widgets Charts)

foreach(_output_lib IN ITEMS Librist Libsrt)
if(NOT TARGET ${_output_lib}::${_output_lib})
list(APPEND _error_messages "MPEGTS output library ${_output_lib} not found.")
endif()
endforeach()

if(_error_messages)
list(JOIN "\n" _error_string _error_string)
message(
FATAL_ERROR
"${_error_string}\n Disable this error by setting ENABLE_NEW_MPEGTS_OUTPUT to OFF or providing the build system with required SRT and Rist libraries."
)
endif()

target_sources(obs-mpegts PRIVATE obs-mpegts.c obs-mpegts-common.h obs-mpegts-rist.h obs-mpegts-srt.h
obs-mpegts-srt-stats.cpp obs-mpegts-srt-stats.hpp)

target_link_libraries(
obs-mpegts
PRIVATE OBS::libobs
OBS::frontend-api
FFmpeg::avcodec
FFmpeg::avformat
FFmpeg::avutil
Librist::Librist
Libsrt::Libsrt
Qt::Core
Qt::Widgets
Qt::Charts)

set_target_properties(obs-mpegts PROPERTIES FOLDER "plugins/obs-mpegts" PREFIX "")
set_target_properties(
obs-mpegts
PROPERTIES AUTOMOC ON
AUTOUIC ON
AUTORCC ON)

if(OS_WINDOWS)
target_link_libraries(obs-mpegts PRIVATE ws2_32.lib)
if(MSVC)
target_link_libraries(obs-mpegts PRIVATE OBS::w32-pthreads)
endif()

set(MODULE_DESCRIPTION "OBS MPEG-TS muxer module")
configure_file(${CMAKE_SOURCE_DIR}/cmake/bundle/windows/obs-module.rc.in obs-mpegts.rc)
endif()

setup_plugin_target(obs-mpegts)
24 changes: 24 additions & 0 deletions plugins/obs-mpegts/cmake/windows/obs-module.rc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
1 VERSIONINFO
FILEVERSION ${OBS_VERSION_MAJOR},${OBS_VERSION_MINOR},${OBS_VERSION_PATCH},0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "${OBS_COMPANY_NAME}"
VALUE "FileDescription", "OBS MPEG-TS muxer module"
VALUE "FileVersion", "${OBS_VERSION_CANONICAL}"
VALUE "ProductName", "${OBS_PRODUCT_NAME}"
VALUE "ProductVersion", "${OBS_VERSION_CANONICAL}"
VALUE "Comments", "${OBS_COMMENTS}"
VALUE "LegalCopyright", "${OBS_LEGAL_COPYRIGHT}"
VALUE "InternalName", "obs-mpegts"
VALUE "OriginalFilename", "obs-mpegts"
END
END

BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 0x04B0
END
END
Loading
Loading