New upstream version 26.0.0+dfsg1

This commit is contained in:
Sebastian Ramacher 2020-10-01 22:15:25 +02:00
parent 8e020cdacb
commit 240080891f
837 changed files with 41275 additions and 9196 deletions

View file

@ -64,6 +64,8 @@ struct ffmpeg_muxer {
pthread_t mux_thread;
bool mux_thread_joinable;
volatile bool muxing;
bool is_network;
};
static const char *ffmpeg_mux_getname(void *type)
@ -72,6 +74,12 @@ static const char *ffmpeg_mux_getname(void *type)
return obs_module_text("FFmpegMuxer");
}
static const char *ffmpeg_mpegts_mux_getname(void *type)
{
UNUSED_PARAMETER(type);
return obs_module_text("FFmpegMpegtsMuxer");
}
static inline void replay_buffer_clear(struct ffmpeg_muxer *stream)
{
while (stream->packets.size > 0) {
@ -108,6 +116,9 @@ static void *ffmpeg_mux_create(obs_data_t *settings, obs_output_t *output)
struct ffmpeg_muxer *stream = bzalloc(sizeof(*stream));
stream->output = output;
if (obs_output_get_flags(output) & OBS_OUTPUT_SERVICE)
stream->is_network = true;
UNUSED_PARAMETER(settings);
return stream;
}
@ -145,10 +156,37 @@ static void add_video_encoder_params(struct ffmpeg_muxer *stream,
obs_data_release(settings);
dstr_catf(cmd, "%s %d %d %d %d %d ", obs_encoder_get_codec(vencoder),
bitrate, obs_output_get_width(stream->output),
obs_output_get_height(stream->output), (int)info->fps_num,
(int)info->fps_den);
enum AVColorPrimaries pri = AVCOL_PRI_UNSPECIFIED;
enum AVColorTransferCharacteristic trc = AVCOL_TRC_UNSPECIFIED;
enum AVColorSpace spc = AVCOL_SPC_UNSPECIFIED;
switch (info->colorspace) {
case VIDEO_CS_601:
pri = AVCOL_PRI_SMPTE170M;
trc = AVCOL_TRC_SMPTE170M;
spc = AVCOL_SPC_SMPTE170M;
break;
case VIDEO_CS_DEFAULT:
case VIDEO_CS_709:
pri = AVCOL_PRI_BT709;
trc = AVCOL_TRC_BT709;
spc = AVCOL_SPC_BT709;
break;
case VIDEO_CS_SRGB:
pri = AVCOL_PRI_BT709;
trc = AVCOL_TRC_IEC61966_2_1;
spc = AVCOL_SPC_BT709;
break;
}
const enum AVColorRange range = (info->range == VIDEO_RANGE_FULL)
? AVCOL_RANGE_JPEG
: AVCOL_RANGE_MPEG;
dstr_catf(cmd, "%s %d %d %d %d %d %d %d %d %d ",
obs_encoder_get_codec(vencoder), bitrate,
obs_output_get_width(stream->output),
obs_output_get_height(stream->output), (int)pri, (int)trc,
(int)spc, (int)range, (int)info->fps_num, (int)info->fps_den);
}
static void add_audio_encoder_params(struct dstr *cmd, obs_encoder_t *aencoder)
@ -264,6 +302,27 @@ static inline void start_pipe(struct ffmpeg_muxer *stream, const char *path)
dstr_free(&cmd);
}
static void set_file_not_readable_error(struct ffmpeg_muxer *stream,
obs_data_t *settings, const char *path)
{
struct dstr error_message;
dstr_init_copy(&error_message, obs_module_text("UnableToWritePath"));
#ifdef _WIN32
/* special warning for Windows 10 users about Defender */
struct win_version_info ver;
get_win_ver(&ver);
if (ver.major >= 10) {
dstr_cat(&error_message, "\n\n");
dstr_cat(&error_message,
obs_module_text("WarnWindowsDefender"));
}
#endif
dstr_replace(&error_message, "%1", path);
obs_output_set_last_error(stream->output, error_message.array);
dstr_free(&error_message);
obs_data_release(settings);
}
static bool ffmpeg_mux_start(void *data)
{
struct ffmpeg_muxer *stream = data;
@ -276,34 +335,31 @@ static bool ffmpeg_mux_start(void *data)
return false;
settings = obs_output_get_settings(stream->output);
path = obs_data_get_string(settings, "path");
/* ensure output path is writable to avoid generic error message */
/* TODO: remove once ffmpeg-mux is refactored to pass errors back */
FILE *test_file = os_fopen(path, "wb");
if (!test_file) {
struct dstr error_message;
dstr_init_copy(&error_message,
obs_module_text("UnableToWritePath"));
#ifdef _WIN32
// special warning for Windows 10 users about Defender
struct win_version_info ver;
get_win_ver(&ver);
if (ver.major >= 10) {
dstr_cat(&error_message, "\n\n");
dstr_cat(&error_message,
obs_module_text("WarnWindowsDefender"));
}
#endif
dstr_replace(&error_message, "%1", path);
obs_output_set_last_error(stream->output, error_message.array);
dstr_free(&error_message);
obs_data_release(settings);
return false;
if (stream->is_network) {
obs_service_t *service;
service = obs_output_get_service(stream->output);
if (!service)
return false;
path = obs_service_get_url(service);
} else {
path = obs_data_get_string(settings, "path");
}
fclose(test_file);
os_unlink(path);
if (!stream->is_network) {
/* ensure output path is writable to avoid generic error
* message.
*
* TODO: remove once ffmpeg-mux is refactored to pass
* errors back */
FILE *test_file = os_fopen(path, "wb");
if (!test_file) {
set_file_not_readable_error(stream, settings, path);
return false;
}
fclose(test_file);
os_unlink(path);
}
start_pipe(stream, path);
obs_data_release(settings);
@ -527,6 +583,37 @@ struct obs_output_info ffmpeg_muxer = {
.get_properties = ffmpeg_mux_properties,
};
static int connect_time(struct ffmpeg_muxer *stream)
{
UNUSED_PARAMETER(stream);
/* TODO */
return 0;
}
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",
.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,
};
/* ------------------------------------------------------------------------ */
static const char *replay_buffer_getname(void *type)
@ -803,6 +890,13 @@ static void replay_buffer_save(struct ffmpeg_muxer *stream)
dstr_cat_ch(&stream->path, '/');
dstr_cat(&stream->path, filename);
char *slash = strrchr(stream->path.array, '/');
if (slash) {
*slash = 0;
os_mkdirs(stream->path.array);
*slash = '/';
}
bfree(filename);
obs_data_release(settings);