]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
transcode: audio - add track limiter
authorJaroslav Kysela <perex@perex.cz>
Tue, 29 Aug 2017 16:18:38 +0000 (18:18 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 29 Aug 2017 16:18:38 +0000 (18:18 +0200)
src/transcoding/codec/internals.h
src/transcoding/codec/profile.c
src/transcoding/codec/profile_audio_class.c
src/transcoding/transcode/transcoder.c

index 0f3faad31ec17c5f3c1a93f84e136f273402ae8a..dcee72468e446d1de3752f334c58dac95cea61b3 100644 (file)
@@ -224,6 +224,7 @@ extern const codec_profile_class_t codec_profile_audio_class;
 
 typedef struct tvh_codec_profile_audio_t {
     TVHCodecProfile;
+    int tracks;
     const char *language1;
     const char *language2;
     const char *language3;
index 424f422286e4744fb215482bbcaee395188b7d25..1ffc5aafd626e5a47d13099a10555064879bcfde 100644 (file)
@@ -289,6 +289,7 @@ tvh_codec_profile_audio_init(TVHCodecProfile *_self, htsmsg_t *conf)
 {
     TVHAudioCodecProfile *self = (TVHAudioCodecProfile *)_self;
     self->sample_fmt = AV_SAMPLE_FMT_NONE;
+    self->tracks = 1;
     return 0;
 }
 
index 01aa57367d823fac689b42d8fcc62f195d5b8793..6287949e494477f8b7ff59cd0c48541b527d762d 100644 (file)
@@ -254,6 +254,15 @@ const codec_profile_class_t codec_profile_audio_class = {
         .ic_class      = "codec_profile_audio",
         .ic_caption    = N_("audio"),
         .ic_properties = (const property_t[]) {
+            {
+                .type     = PT_INT,
+                .id       = "tracks",
+                .name     = N_("Limit audio tracks"),
+                .desc     = N_("Use only defined number of audio tracks at maximum."),
+                .group    = 2,
+                .off      = offsetof(TVHAudioCodecProfile, tracks),
+                .def.i    = 1,
+            },
             {
                 .type     = PT_STR,
                 .id       = "language1",
index a739497da77791f03ea7714b8bcf1a0eabe1d23a..134c7b8704f46bcb8c7516709fd9f651b1df0890 100644 (file)
@@ -144,16 +144,31 @@ tvh_transcoder_start(TVHTranscoder *self, tvh_ss_t *ss_src)
         indexes[count++] = video_index;
     }
     if (audio_index >= 0) {
-        indexes[count++] = audio_index;
+        for (i = j = 0; i < ARRAY_SIZE(audio_pindex); i++) {
+            if (audio_pindex[i] >= 0) {
+                indexes[count++] = audio_pindex[i];
+                if ((ssc = &ss_src->ss_components[audio_pindex[i]]) == NULL)
+                    continue;
+                media_type = ssc_get_media_type(ssc);
+                if (media_type != AVMEDIA_TYPE_AUDIO)
+                    continue;
+                aprofile = (TVHAudioCodecProfile *)self->profiles[media_type];
+                if (++j >= aprofile->tracks)
+                    break;
+            }
+        }
     } else {
         /* nothing is preferred, use all audio tracks */
-        for (i = 0; i < ss_src->ss_num_components; i++) {
+        for (i = j = 0; i < ss_src->ss_num_components; i++) {
             if ((ssc = &ss_src->ss_components[i]) == NULL)
                 continue;
             media_type = ssc_get_media_type(ssc);
             if (media_type != AVMEDIA_TYPE_AUDIO)
                 continue;
             indexes[count++] = i;
+            aprofile = (TVHAudioCodecProfile *)self->profiles[media_type];
+            if (++j >= aprofile->tracks)
+                break;
         }
     }
     if (subtitle_index >= 0) {