From: Jaroslav Kysela Date: Sat, 15 Oct 2016 18:06:48 +0000 (+0200) Subject: audioes: fix the mime type / suffix audio-detection X-Git-Tag: v4.2.1~266 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=37ef4b8afadc35d3d650220f8cbe90b26b57d35a;p=thirdparty%2Ftvheadend.git audioes: fix the mime type / suffix audio-detection --- diff --git a/src/muxer/muxer_audioes.c b/src/muxer/muxer_audioes.c index 857e4254a..79e3810d9 100644 --- a/src/muxer/muxer_audioes.c +++ b/src/muxer/muxer_audioes.c @@ -67,26 +67,49 @@ audioes_muxer_type(streaming_component_type_t type) } +/** + * + */ +static const streaming_start_component_t * +audioes_get_component(muxer_t *m, const struct streaming_start *ss) +{ + const streaming_start_component_t *ssc; + muxer_container_type_t mc = MC_UNKNOWN; + int i, count; + + for (i = count = 0; i < ss->ss_num_components;i++) { + ssc = &ss->ss_components[i]; + + if ((!ssc->ssc_disabled) && (SCT_ISAUDIO(ssc->ssc_type))) { + if (m->m_config.m_force_type != MC_UNKNOWN) { + mc = audioes_muxer_type(ssc->ssc_type); + if (m->m_config.m_force_type != mc) + continue; + } + if (m->m_config.m_index == count) + return ssc; + count++; + } + } + return NULL; +} + + /** * Figure out the mimetype */ static const char * audioes_muxer_mime(muxer_t *m, const struct streaming_start *ss) { - int i; muxer_container_type_t mc = MC_UNKNOWN; const streaming_start_component_t *ssc; if (m->m_config.m_force_type != MC_UNKNOWN) return muxer_container_type2mime(m->m_config.m_force_type, 0); - for (i = 0; i < ss->ss_num_components; i++) { - ssc = &ss->ss_components[i]; - if (ssc->ssc_disabled) - continue; + ssc = audioes_get_component(m, ss); + if (ssc) mc = audioes_muxer_type(ssc->ssc_type); - break; - } return muxer_container_type2mime(mc, 0); } @@ -100,27 +123,12 @@ audioes_muxer_reconfigure(muxer_t *m, const struct streaming_start *ss) { audioes_muxer_t *am = (audioes_muxer_t*)m; const streaming_start_component_t *ssc; - muxer_container_type_t mc; - int i, count = 0; am->am_index = -1; - for (i = 0; i < ss->ss_num_components;i++) { - ssc = &ss->ss_components[i]; - - if ((!ssc->ssc_disabled) && (SCT_ISAUDIO(ssc->ssc_type))) { - if (m->m_config.m_force_type != MC_UNKNOWN) { - mc = audioes_muxer_type(ssc->ssc_type); - if (m->m_config.m_force_type != mc) - continue; - } - if (m->m_config.m_index == count) { - am->am_index = ssc->ssc_index; - break; - } - count++; - } - } + ssc = audioes_get_component(m, ss); + if (ssc) + am->am_index = ssc->ssc_index; return 0; }