1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-11-03 04:17:18 -05:00

Remove half-baked support for "passthrough encoders"

The correct way is to just not configure an encoder for a stream, which
is what the documentation already states. Encoder sections now require
a program name to be set or the configuration will not load.

Fixes a segfault in ezstream.c, as reported by Tom McCallum via Github.
This commit is contained in:
Moritz Grimm 2020-01-15 22:56:05 +01:00
parent 7989928690
commit 83d1d17be1
4 changed files with 31 additions and 47 deletions

View File

@ -17,7 +17,7 @@
<stream>
<mountpoint>/video.ogg</mountpoint>
<format>Theora</format>
<encoder>PassThrough</encoder>
<!-- No encoder configured (see below). -->
</stream>
</streams>
@ -30,19 +30,14 @@
<decoders>
<decoder>
<name>Theora-192x128</name>
<!-- Reencode into Ogg Theora directly -->
<!--
Reencodes into Ogg Theora directly. The stream should be configured
without an encoder, so that the decoder output is passed through as-is.
-->
<program>ffmpeg2theora -x 192 -y 128 -a 0 -v 4 --title @M@ -o - @T@</program>
<file_ext>.avi</file_ext>
<file_ext>.mpg</file_ext>
</decoder>
</decoders>
<encoders>
<encoder>
<name>PassThrough</name>
<format>Theora</format>
<!-- Do not set an encoder program to pass through data as-is -->
</encoder>
</encoders>
</ezstream>

View File

@ -210,17 +210,18 @@ cfg_encoder_set_format_str(struct cfg_encoder *e,
int
cfg_encoder_set_program(struct cfg_encoder *e,
struct cfg_encoder_list *not_used, const char *program,
const char **not_used2)
const char **errstrp)
{
(void)not_used;
(void)not_used2;
if (!program || !program[0]) {
if (errstrp)
*errstrp = "empty";
return (-1);
}
xfree(e->program);
if (!program || !program[0])
e->program = NULL;
else
e->program = xstrdup(program);
e->program = xstrdup(program);
return (0);
}
@ -234,8 +235,11 @@ cfg_encoder_validate(struct cfg_encoder *e, const char **errstrp)
return (-1);
}
if (!e->program)
return (0);
if (!e->program) {
if (errstrp)
*errstrp = "program not set";
return (-1);
}
CHECKPH_PROHIBITED(e->program, PLACEHOLDER_TRACK);
CHECKPH_PROHIBITED(e->program, PLACEHOLDER_STRING);

View File

@ -309,27 +309,6 @@ _parse_ezconfig0(EZCONFIG *ez)
cfg_encoder_list_remove(enc_list, &enc);
warnings++;
}
} else {
if (ed->format &&
0 == strcasecmp(ed->format, "THEORA")) {
cfg_encoder_t enc;
enc = cfg_encoder_list_find(enc_list,
ed->format);
if (NULL == enc)
enc = cfg_encoder_list_get(enc_list,
CFG_DEFAULT);
ENTITY_SET(enc, enc_list, cfg_encoder_set_name,
"<format> (encoder)", ed->format);
ENTITY_SET(enc, enc_list, cfg_encoder_set_format_str,
"<format> (encoder)", ed->format);
if (0 > cfg_encoder_validate(enc, &err_str)) {
log_warning("%s: %s: %s", v0_cfgfile,
"<encdec> (encoder)", err_str);
cfg_encoder_list_remove(enc_list, &enc);
warnings++;
}
}
}
if (ed->decoder) {
cfg_decoder_t dec = NULL;

View File

@ -52,13 +52,8 @@ END_TEST
START_TEST(test_encoder_set_program)
{
cfg_encoder_t enc = cfg_encoder_list_get(encoders, "test_encoder_set_program");
ck_assert_int_eq(cfg_encoder_set_program(enc, encoders, NULL, NULL), 0);
ck_assert_ptr_eq(cfg_encoder_get_program(enc), NULL);
ck_assert_int_eq(cfg_encoder_set_program(enc, encoders, "test", NULL), 0);
ck_assert_str_eq(cfg_encoder_get_program(enc), "test");
TEST_XSTRDUP_T(cfg_encoder_t, cfg_encoder_list_get, encoders,
cfg_encoder_set_program, cfg_encoder_get_program);
}
END_TEST
@ -94,14 +89,25 @@ END_TEST
START_TEST(test_encoder_validate)
{
cfg_encoder_t enc = cfg_encoder_list_get(encoders, "test_encoder_validate");
cfg_encoder_t enc2 = cfg_encoder_list_get(encoders, "test_encoder_validate_2");;
const char *errstr;
errstr = NULL;
ck_assert_int_ne(cfg_encoder_set_name(enc2, encoders,
"test_encoder_validate", &errstr), 0);
ck_assert_str_eq(errstr, "already exists");
ck_assert_int_ne(cfg_encoder_validate(enc, NULL), 0);
ck_assert_int_ne(cfg_encoder_validate(enc, &errstr), 0);
ck_assert_str_eq(errstr, "format not set");
ck_assert_int_eq(cfg_encoder_set_format(enc, CFG_STREAM_VORBIS), 0);
ck_assert_int_ne(cfg_encoder_validate(enc, &errstr), 0);
ck_assert_str_eq(errstr, "program not set");
ck_assert_int_eq(cfg_encoder_set_program(enc, encoders, "test", NULL),
0);
ck_assert_int_eq(cfg_encoder_validate(enc, NULL), 0);
ck_assert_int_eq(cfg_encoder_set_program(enc, encoders,