Read AC-3 and HEVC signaled by private registration_descriptor.

Issue: #898
This commit is contained in:
Oliver Woodman 2015-10-27 18:20:53 +00:00
parent 6fb5052d2f
commit f91ea9039d

View File

@ -22,6 +22,7 @@ import com.google.android.exoplayer.extractor.PositionHolder;
import com.google.android.exoplayer.extractor.SeekMap; import com.google.android.exoplayer.extractor.SeekMap;
import com.google.android.exoplayer.util.ParsableBitArray; import com.google.android.exoplayer.util.ParsableBitArray;
import com.google.android.exoplayer.util.ParsableByteArray; import com.google.android.exoplayer.util.ParsableByteArray;
import com.google.android.exoplayer.util.Util;
import android.util.Log; import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
@ -50,6 +51,9 @@ public final class TsExtractor implements Extractor {
private static final int TS_STREAM_TYPE_ID3 = 0x15; private static final int TS_STREAM_TYPE_ID3 = 0x15;
private static final int TS_STREAM_TYPE_EIA608 = 0x100; // 0xFF + 1 private static final int TS_STREAM_TYPE_EIA608 = 0x100; // 0xFF + 1
private static final long AC3_FORMAT_IDENTIFIER = Util.getIntegerCodeForString("AC-3");
private static final long HEVC_FORMAT_IDENTIFIER = Util.getIntegerCodeForString("HEVC");
private final PtsTimestampAdjuster ptsTimestampAdjuster; private final PtsTimestampAdjuster ptsTimestampAdjuster;
private final ParsableByteArray tsPacketBuffer; private final ParsableByteArray tsPacketBuffer;
private final ParsableBitArray tsScratch; private final ParsableBitArray tsScratch;
@ -283,8 +287,21 @@ public final class TsExtractor implements Extractor {
pmtScratch.skipBits(4); // reserved pmtScratch.skipBits(4); // reserved
int esInfoLength = pmtScratch.readBits(12); int esInfoLength = pmtScratch.readBits(12);
// Skip the descriptors. int descriptorPosition = data.getPosition();
data.skipBytes(esInfoLength); if (streamType == 0x06) {
int descriptorTag = data.readUnsignedByte();
if (descriptorTag == 0x05) { // registration_descriptor
data.skipBytes(1); // descriptor_length
long formatIdentifier = data.readUnsignedInt();
if (formatIdentifier == AC3_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_ATSC_AC3;
} else if (formatIdentifier == HEVC_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_H265;
}
// Ignore additional_identification_info.
}
}
data.setPosition(descriptorPosition + esInfoLength);
entriesSize -= esInfoLength + 5; entriesSize -= esInfoLength + 5;
if (streamTypes.get(streamType)) { if (streamTypes.get(streamType)) {