Assume AAC-LC (or HE-AAC) in MPEG-TS.

Issue: #774
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=122987179
This commit is contained in:
olly 2016-05-23 05:08:37 -07:00 committed by Oliver Woodman
parent c539db68ca
commit 075e095cba

View file

@ -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;
}