mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
Add CRC check for PMT
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=131394778
This commit is contained in:
parent
6528aef2bb
commit
d72e26ff35
1 changed files with 8 additions and 1 deletions
|
|
@ -278,7 +278,7 @@ public final class TsExtractor implements Extractor {
|
|||
|
||||
int crcStart = data.getPosition() - 3;
|
||||
int crcEnd = data.getPosition() + sectionLength;
|
||||
if (Util.crc(data.data, crcStart, crcEnd, 0xffffffff) != 0) {
|
||||
if (Util.crc(data.data, crcStart, crcEnd, 0xFFFFFFFF) != 0) {
|
||||
// CRC Invalid. The section gets discarded.
|
||||
return;
|
||||
}
|
||||
|
|
@ -313,6 +313,7 @@ public final class TsExtractor implements Extractor {
|
|||
|
||||
private int sectionLength;
|
||||
private int sectionBytesRead;
|
||||
private int crc;
|
||||
|
||||
public PmtReader() {
|
||||
pmtScratch = new ParsableBitArray(new byte[5]);
|
||||
|
|
@ -337,6 +338,7 @@ public final class TsExtractor implements Extractor {
|
|||
data.readBytes(pmtScratch, 3);
|
||||
pmtScratch.skipBits(12); // table_id (8), section_syntax_indicator (1), 0 (1), reserved (2)
|
||||
sectionLength = pmtScratch.readBits(12);
|
||||
crc = Util.crc(pmtScratch.data, 0, 3, 0xFFFFFFFF);
|
||||
|
||||
if (sectionData.capacity() < sectionLength) {
|
||||
sectionData.reset(new byte[sectionLength], sectionLength);
|
||||
|
|
@ -354,6 +356,11 @@ public final class TsExtractor implements Extractor {
|
|||
return;
|
||||
}
|
||||
|
||||
if (Util.crc(sectionData.data, 0, sectionLength, crc) != 0) {
|
||||
// CRC Invalid. The section gets discarded.
|
||||
return;
|
||||
}
|
||||
|
||||
// program_number (16), reserved (2), version_number (5), current_next_indicator (1),
|
||||
// section_number (8), last_section_number (8), reserved (3), PCR_PID (13)
|
||||
// Skip the rest of the PMT header.
|
||||
|
|
|
|||
Loading…
Reference in a new issue