1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-12-04 14:46:31 -05:00

Support v0 ffmpeg/Ogg Theora configuration migration

This commit is contained in:
Moritz Grimm 2020-01-25 01:05:18 +01:00
parent b61b78e161
commit 09b615db0a
4 changed files with 38 additions and 3 deletions

View File

@ -291,6 +291,14 @@ cfg_stream_set_encoder(struct cfg_stream *s, struct cfg_stream_list *not_used,
const char *encoder, const char **errstrp) const char *encoder, const char **errstrp)
{ {
(void)not_used; (void)not_used;
if (NULL == encoder) {
if (s->encoder)
xfree(s->encoder);
s->encoder = NULL;
return (0);
}
SET_XSTRDUP(s->encoder, encoder, errstrp); SET_XSTRDUP(s->encoder, encoder, errstrp);
return (0); return (0);
} }

View File

@ -387,9 +387,9 @@ _parse_ezconfig0(EZCONFIG *ez)
if (cfg_stream_get_encoder(str) && if (cfg_stream_get_encoder(str) &&
NULL == cfg_encoder_list_find(enc_list, NULL == cfg_encoder_list_find(enc_list,
cfg_stream_get_encoder(str))) { cfg_stream_get_encoder(str))) {
log_error("%s: %s encoder not found due to errors", log_warning("%s: %s encoder not found; disabling reencoding",
v0_cfgfile, cfg_stream_get_encoder(str)); v0_cfgfile, cfg_stream_get_encoder(str));
return (-1); cfg_stream_set_encoder(str, NULL, NULL, NULL);
} }
if (0 > cfg_server_validate(srv, &err_str) || if (0 > cfg_server_validate(srv, &err_str) ||

View File

@ -28,6 +28,16 @@
ck_assert_str_eq(errstr, "empty"); \ ck_assert_str_eq(errstr, "empty"); \
} while (0) } while (0)
#define TEST_EMPTYSTR_T_NULL(type, objget, list, setter) do { \
type obj3 = objget(list, #setter); \
const char *errstr; \
\
errstr = NULL; \
ck_assert_int_eq(setter(obj3, list, NULL, NULL), 0); \
ck_assert_int_eq(setter(obj3, list, "", &errstr), -1); \
ck_assert_str_eq(errstr, "empty"); \
} while (0)
#define TEST_XSTRDUP(setter, getter) do { \ #define TEST_XSTRDUP(setter, getter) do { \
TEST_EMPTYSTR(setter); \ TEST_EMPTYSTR(setter); \
\ \
@ -44,6 +54,15 @@
ck_assert_str_eq(getter(obj2), "check_cfg"); \ ck_assert_str_eq(getter(obj2), "check_cfg"); \
} while (0) } while (0)
#define TEST_XSTRDUP_T_NULL(type, objget, list, setter, getter) do { \
type obj2 = objget(list, #setter); \
\
TEST_EMPTYSTR_T_NULL(type, objget, list, setter); \
\
ck_assert_int_eq(setter(obj2, list, "check_cfg", NULL), 0); \
ck_assert_str_eq(getter(obj2), "check_cfg"); \
} while (0)
#define TEST_STRLCPY(setter, getter, length) do { \ #define TEST_STRLCPY(setter, getter, length) do { \
char buf[length + 1]; \ char buf[length + 1]; \
const char *errstr2; \ const char *errstr2; \

View File

@ -130,7 +130,15 @@ END_TEST
START_TEST(test_stream_encoder) START_TEST(test_stream_encoder)
{ {
TEST_XSTRDUP_T(cfg_stream_t, cfg_stream_list_get, streams, cfg_stream_t str = cfg_stream_list_get(streams, "test_stream_encoder");
ck_assert_ptr_eq(cfg_stream_get_encoder(str), NULL);
ck_assert_int_eq(cfg_stream_set_encoder(str, NULL, "test", NULL), 0);
ck_assert_str_eq(cfg_stream_get_encoder(str), "test");
ck_assert_int_eq(cfg_stream_set_encoder(str, NULL, NULL, NULL), 0);
ck_assert_ptr_eq(cfg_stream_get_encoder(str), NULL);
TEST_XSTRDUP_T_NULL(cfg_stream_t, cfg_stream_list_get, streams,
cfg_stream_set_encoder, cfg_stream_get_encoder); cfg_stream_set_encoder, cfg_stream_get_encoder);
} }
END_TEST END_TEST