From 075e095cbae80c3ef62f51ef24995db379358ce0 Mon Sep 17 00:00:00 2001 From: olly Date: Mon, 23 May 2016 05:08:37 -0700 Subject: [PATCH] Assume AAC-LC (or HE-AAC) in MPEG-TS. Issue: #774 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=122987179 --- .../exoplayer/extractor/ts/AdtsReader.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java index fb0d7025b3..071cf380d0 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java @@ -255,13 +255,17 @@ import java.util.Collections; if (!hasOutputFormat) { int audioObjectType = adtsScratch.readBits(2) + 1; - if (audioObjectType == 1) { - // The stream indicates AAC Main but it's more likely that the stream contains HE-AAC. - // HE-AAC cannot be represented correctly in the ADTS header because it has an - // audioObjectType value of 5 whereas an ADTS header can only represent values up to 4. - // Since most Android devices don't support AAC Main anyway, we pretend that we're dealing - // with AAC LC and hope for the best. In practice this often works. - Log.w(TAG, "Detected AAC Main audio, but assuming AAC LC."); + if (audioObjectType != 2) { + // The stream indicates AAC-Main (1), AAC-SSR (3) or AAC-LTP (4). When the stream indicates + // AAC-Main it's more likely that the stream contains HE-AAC (5), which cannot be + // represented correctly in the 2 bit audio_object_type field in the ADTS header. In + // practice when the stream indicates AAC-SSR or AAC-LTP it more commonly contains AAC-LC or + // HE-AAC. Since most Android devices don't support AAC-Main, AAC-SSR or AAC-LTP, and since + // indicating AAC-LC works for HE-AAC streams, we pretend that we're dealing with AAC-LC and + // hope for the best. In practice this often works. + // See: https://github.com/google/ExoPlayer/issues/774 + // See: https://github.com/google/ExoPlayer/issues/1383 + Log.w(TAG, "Detected audio object type: " + audioObjectType + ", but assuming AAC LC."); audioObjectType = 2; }