mirror of
https://github.com/samsonjs/media.git
synced 2026-04-21 13:55:47 +00:00
Treat streams claiming to be AAC Main as AAC LC.
Issue: #1383 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=118021452
This commit is contained in:
parent
8571c81076
commit
b9d2224550
1 changed files with 13 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ import com.google.android.exoplayer.util.MimeTypes;
|
|||
import com.google.android.exoplayer.util.ParsableBitArray;
|
||||
import com.google.android.exoplayer.util.ParsableByteArray;
|
||||
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
@ -33,6 +34,8 @@ import java.util.Collections;
|
|||
*/
|
||||
/* package */ final class AdtsReader extends ElementaryStreamReader {
|
||||
|
||||
private static final String TAG = "AdtsReader";
|
||||
|
||||
private static final int STATE_FINDING_SAMPLE = 0;
|
||||
private static final int STATE_READING_ID3_HEADER = 1;
|
||||
private static final int STATE_READING_ADTS_HEADER = 2;
|
||||
|
|
@ -251,6 +254,16 @@ 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.");
|
||||
audioObjectType = 2;
|
||||
}
|
||||
|
||||
int sampleRateIndex = adtsScratch.readBits(4);
|
||||
adtsScratch.skipBits(1);
|
||||
int channelConfig = adtsScratch.readBits(3);
|
||||
|
|
|
|||
Loading…
Reference in a new issue