From: Jaroslav Kysela Date: Thu, 6 Oct 2016 14:11:06 +0000 (+0200) Subject: audioes: add stream type / index filtering X-Git-Tag: v4.2.1~279 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b848597d0b3b86fc4eaae71264f01a6338597567;p=thirdparty%2Ftvheadend.git audioes: add stream type / index filtering --- diff --git a/src/muxer.h b/src/muxer.h index 8b79f77ec..b2e442c68 100644 --- a/src/muxer.h +++ b/src/muxer.h @@ -60,6 +60,9 @@ typedef struct muxer_config { int m_rewrite_eit; int m_cache; + int m_force_type; + int m_index; + /* * directory_permissions should really be in dvr.h as it's not really needed for the muxer * but it's kept with file_permissions for neatness diff --git a/src/muxer/muxer_audioes.c b/src/muxer/muxer_audioes.c index f6f2b357c..857e4254a 100644 --- a/src/muxer/muxer_audioes.c +++ b/src/muxer/muxer_audioes.c @@ -47,29 +47,44 @@ typedef struct audioes_muxer { } audioes_muxer_t; +/** + * + */ +static int +audioes_muxer_type(streaming_component_type_t type) +{ + muxer_container_type_t mc = MC_UNKNOWN; + switch (type) { + case SCT_MPEG2AUDIO: mc = MC_MPEG2AUDIO; break; + case SCT_AC3: mc = MC_AC3; break; + case SCT_EAC3: mc = MC_AC3; break; + case SCT_AAC: mc = MC_AAC; break; + case SCT_MP4A: mc = MC_MP4A; break; + case SCT_VORBIS: mc = MC_VORBIS; break; + default: break; + } + return mc; +} + + /** * Figure out the mimetype */ static const char * -audioes_muxer_mime(muxer_t* m, const struct streaming_start *ss) +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; - switch (ssc->ssc_type) { - case SCT_MPEG2AUDIO: mc = MC_MPEG2AUDIO; break; - case SCT_AC3: mc = MC_AC3; break; - case SCT_EAC3: mc = MC_AC3; break; - case SCT_AAC: mc = MC_AAC; break; - case SCT_MP4A: mc = MC_MP4A; break; - case SCT_VORBIS: mc = MC_VORBIS; break; - default: break; - } + mc = audioes_muxer_type(ssc->ssc_type); break; } @@ -81,11 +96,12 @@ audioes_muxer_mime(muxer_t* m, const struct streaming_start *ss) * Reconfigure the muxer */ static int -audioes_muxer_reconfigure(muxer_t* m, const struct streaming_start *ss) +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; - int i; + muxer_container_type_t mc; + int i, count = 0; am->am_index = -1; @@ -93,8 +109,16 @@ audioes_muxer_reconfigure(muxer_t* m, const struct streaming_start *ss) ssc = &ss->ss_components[i]; if ((!ssc->ssc_disabled) && (SCT_ISAUDIO(ssc->ssc_type))) { - am->am_index = ssc->ssc_index; - break; + 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++; } } diff --git a/src/profile.c b/src/profile.c index 75af0af82..0cb2872c5 100644 --- a/src/profile.c +++ b/src/profile.c @@ -1300,14 +1300,47 @@ profile_matroska_builder(void) */ typedef struct profile_audio { profile_t; + int pro_mc; + int pro_index; } profile_audio_t; +static htsmsg_t * +profile_class_mc_audio_list ( void *o, const char *lang ) +{ + static const struct strtab tab[] = { + { N_("Any"), MC_UNKNOWN }, + { N_("MPEG-2 audio"), MC_MPEG2AUDIO, }, + { N_("AC3 audio"), MC_AC3, }, + { N_("AAC audio"), MC_AAC }, + { N_("MP4 audio"), MC_MP4A }, + { N_("Vorbis audio"), MC_VORBIS }, + }; + return strtab2htsmsg(tab, 1, lang); +} + const idclass_t profile_audio_class = { .ic_super = &profile_class, .ic_class = "profile-audio", .ic_caption = N_("Audio stream"), .ic_properties = (const property_t[]){ + { + .type = PT_INT, + .id = "type", + .name = N_("Audio type"), + .desc = N_("Pick the stream with given audio type only."), + .off = offsetof(profile_audio_t, pro_mc), + .list = profile_class_mc_audio_list, + .group = 1 + }, + { + .type = PT_INT, + .id = "index", + .name = N_("Stream index"), + .desc = N_("Stream index (starts with zero)."), + .off = offsetof(profile_audio_t, pro_index), + .group = 1 + }, { } } }; @@ -1318,12 +1351,15 @@ profile_audio_reopen(profile_chain_t *prch, muxer_config_t *m_cfg, int flags) { muxer_config_t c; + profile_audio_t *pro = (profile_audio_t *)prch->prch_pro; if (m_cfg) c = *m_cfg; /* do not alter the original parameter */ else memset(&c, 0, sizeof(c)); - c.m_type = MC_MPEG2AUDIO; + c.m_type = pro->pro_mc != MC_UNKNOWN ? pro->pro_mc : MC_MPEG2AUDIO; + c.m_force_type = pro->pro_mc; + c.m_index = pro->pro_index; assert(!prch->prch_muxer); prch->prch_muxer = muxer_create(&c); @@ -1352,7 +1388,10 @@ profile_audio_open(profile_chain_t *prch, static muxer_container_type_t profile_audio_get_mc(profile_t *_pro) { - return MC_MPEG2AUDIO; /* may be incorrect */ + profile_audio_t *pro = (profile_audio_t *)_pro; + if (pro->pro_mc == MC_UNKNOWN) + return MC_MPEG2AUDIO; + return pro->pro_mc; } static profile_t * @@ -1367,10 +1406,6 @@ profile_audio_builder(void) } - - - - #if ENABLE_LIBAV /*