From 6fab55192f5d436282549fa72d706288418eef2e Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 27 Jun 2014 17:33:06 +0200 Subject: [PATCH] muxer: tidy muxer_container_list() function --- src/muxer.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/src/muxer.c b/src/muxer.c index 03150d39..33399c7d 100644 --- a/src/muxer.c +++ b/src/muxer.c @@ -160,36 +160,30 @@ muxer_container_type2txt(muxer_container_type_t mc) /** * Get a list of supported containers */ +static int +muxer_container_add(htsmsg_t *array, int type, const char *text) +{ + htsmsg_t *mc; + + mc = htsmsg_create_map(); + htsmsg_add_str(mc, "name", muxer_container_type2txt(type)); + htsmsg_add_str(mc, "description", text); + htsmsg_add_msg(array, NULL, mc); + return 1; +} + int muxer_container_list(htsmsg_t *array) { - htsmsg_t *mc; - int c = 0; + int c; - mc = htsmsg_create_map(); - htsmsg_add_str(mc, "name", muxer_container_type2txt(MC_MATROSKA)); - htsmsg_add_str(mc, "description", "Matroska"); - htsmsg_add_msg(array, NULL, mc); - c++; - - mc = htsmsg_create_map(); - htsmsg_add_str(mc, "name", muxer_container_type2txt(MC_PASS)); - htsmsg_add_str(mc, "description", "Same as source (pass through)"); - htsmsg_add_msg(array, NULL, mc); - c++; + c = muxer_container_add(array, MC_MATROSKA, "Matroska (mkv)"); + c += muxer_container_add(array, MC_PASS, "Same as source (pass through)"); #if ENABLE_LIBAV - mc = htsmsg_create_map(); - htsmsg_add_str(mc, "name", muxer_container_type2txt(MC_MPEGTS)); - htsmsg_add_str(mc, "description", "MPEG-TS"); - htsmsg_add_msg(array, NULL, mc); - c++; + c += muxer_container_add(array, MC_MPEGTS, "MPEG-TS"); - mc = htsmsg_create_map(); - htsmsg_add_str(mc, "name", muxer_container_type2txt(MC_MPEGPS)); - htsmsg_add_str(mc, "description", "MPEG-PS (DVD)"); - htsmsg_add_msg(array, NULL, mc); - c++; + c += muxer_container_add(array, MC_MPEGPS, "MPEG-PS (DVD)"); #endif return c;