obs-ffmpeg: Allow use of old mpegts output
By default, new mpegts output is used; but to allow CI on linux not to be broken, we allow use of old mpegts output. Up to ubuntu 22.04 there is no librist package available. A manual compile is then required but the CI scripts would need to be updated. This also allows easy fallback in case of fatal bugs in new output. Signed-off-by: pkv <pkv@obsproject.com>master
parent
e7d097cab8
commit
039d7347a3
|
@ -1,6 +1,7 @@
|
|||
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
|
||||
|
@ -15,9 +16,11 @@ find_package(
|
|||
add_library(obs-ffmpeg MODULE)
|
||||
add_library(OBS::ffmpeg ALIAS obs-ffmpeg)
|
||||
|
||||
find_package(Librist QUIET)
|
||||
find_package(Libsrt QUIET)
|
||||
add_subdirectory(ffmpeg-mux)
|
||||
if(ENABLE_NEW_MPEGTS_OUTPUT)
|
||||
find_package(Librist)
|
||||
find_package(Libsrt)
|
||||
endif()
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/obs-ffmpeg-config.h.in
|
||||
${CMAKE_BINARY_DIR}/config/obs-ffmpeg-config.h)
|
||||
|
@ -30,17 +33,13 @@ target_sources(
|
|||
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)
|
||||
${CMAKE_BINARY_DIR}/config/obs-ffmpeg-config.h)
|
||||
|
||||
target_include_directories(obs-ffmpeg PRIVATE ${CMAKE_BINARY_DIR}/config)
|
||||
|
||||
|
@ -55,9 +54,18 @@ target_link_libraries(
|
|||
FFmpeg::avdevice
|
||||
FFmpeg::avutil
|
||||
FFmpeg::swscale
|
||||
FFmpeg::swresample
|
||||
Librist::Librist
|
||||
Libsrt::Libsrt)
|
||||
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)
|
||||
|
@ -77,7 +85,6 @@ if(OS_WINDOWS)
|
|||
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
|
||||
|
|
|
@ -36,6 +36,14 @@ static const char *ffmpeg_mux_getname(void *type)
|
|||
return obs_module_text("FFmpegMuxer");
|
||||
}
|
||||
|
||||
#ifndef NEW_MPEGTS_OUTPUT
|
||||
static const char *ffmpeg_mpegts_mux_getname(void *type)
|
||||
{
|
||||
UNUSED_PARAMETER(type);
|
||||
return obs_module_text("FFmpegMpegtsMuxer");
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void replay_buffer_clear(struct ffmpeg_muxer *stream)
|
||||
{
|
||||
while (stream->packets.size > 0) {
|
||||
|
@ -892,6 +900,31 @@ static int connect_time(struct ffmpeg_muxer *stream)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifndef NEW_MPEGTS_OUTPUT
|
||||
static int ffmpeg_mpegts_mux_connect_time(void *data)
|
||||
{
|
||||
struct ffmpeg_muxer *stream = data;
|
||||
/* TODO */
|
||||
return connect_time(stream);
|
||||
}
|
||||
|
||||
struct obs_output_info ffmpeg_mpegts_muxer = {
|
||||
.id = "ffmpeg_mpegts_muxer",
|
||||
.flags = OBS_OUTPUT_AV | OBS_OUTPUT_ENCODED | OBS_OUTPUT_MULTI_TRACK |
|
||||
OBS_OUTPUT_SERVICE,
|
||||
.encoded_video_codecs = "h264;av1",
|
||||
.encoded_audio_codecs = "aac",
|
||||
.get_name = ffmpeg_mpegts_mux_getname,
|
||||
.create = ffmpeg_mux_create,
|
||||
.destroy = ffmpeg_mux_destroy,
|
||||
.start = ffmpeg_mux_start,
|
||||
.stop = ffmpeg_mux_stop,
|
||||
.encoded_packet = ffmpeg_mux_data,
|
||||
.get_total_bytes = ffmpeg_mux_total_bytes,
|
||||
.get_properties = ffmpeg_mux_properties,
|
||||
.get_connect_time_ms = ffmpeg_mpegts_mux_connect_time,
|
||||
};
|
||||
#endif
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
static const char *replay_buffer_getname(void *type)
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
#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;
|
||||
|
@ -99,16 +101,12 @@ 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);
|
||||
|
||||
#define SRT_PROTO "srt"
|
||||
#define UDP_PROTO "udp"
|
||||
#define TCP_PROTO "tcp"
|
||||
#define HTTP_PROTO "http"
|
||||
#define RIST_PROTO "rist"
|
||||
|
|
Loading…
Reference in New Issue