Commit 09b615db authored by Moritz Grimm's avatar Moritz Grimm
Browse files

Support v0 ffmpeg/Ogg Theora configuration migration

parent b61b78e1
......@@ -291,6 +291,14 @@ cfg_stream_set_encoder(struct cfg_stream *s, struct cfg_stream_list *not_used,
const char *encoder, const char **errstrp)
{
(void)not_used;
if (NULL == encoder) {
if (s->encoder)
xfree(s->encoder);
s->encoder = NULL;
return (0);
}
SET_XSTRDUP(s->encoder, encoder, errstrp);
return (0);
}
......
......@@ -387,9 +387,9 @@ _parse_ezconfig0(EZCONFIG *ez)
if (cfg_stream_get_encoder(str) &&
NULL == cfg_encoder_list_find(enc_list,
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));
return (-1);
cfg_stream_set_encoder(str, NULL, NULL, NULL);
}
if (0 > cfg_server_validate(srv, &err_str) ||
......
......@@ -28,6 +28,16 @@
ck_assert_str_eq(errstr, "empty"); \
} 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 { \
TEST_EMPTYSTR(setter); \
\
......@@ -44,6 +54,15 @@
ck_assert_str_eq(getter(obj2), "check_cfg"); \
} 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 { \
char buf[length + 1]; \
const char *errstr2; \
......
......@@ -130,7 +130,15 @@ END_TEST
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);
}
END_TEST
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment