mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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 crcStart = data.getPosition() - 3;
|
||||||
int crcEnd = data.getPosition() + sectionLength;
|
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.
|
// CRC Invalid. The section gets discarded.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -313,6 +313,7 @@ public final class TsExtractor implements Extractor {
|
||||||
|
|
||||||
private int sectionLength;
|
private int sectionLength;
|
||||||
private int sectionBytesRead;
|
private int sectionBytesRead;
|
||||||
|
private int crc;
|
||||||
|
|
||||||
public PmtReader() {
|
public PmtReader() {
|
||||||
pmtScratch = new ParsableBitArray(new byte[5]);
|
pmtScratch = new ParsableBitArray(new byte[5]);
|
||||||
|
|
@ -337,6 +338,7 @@ public final class TsExtractor implements Extractor {
|
||||||
data.readBytes(pmtScratch, 3);
|
data.readBytes(pmtScratch, 3);
|
||||||
pmtScratch.skipBits(12); // table_id (8), section_syntax_indicator (1), 0 (1), reserved (2)
|
pmtScratch.skipBits(12); // table_id (8), section_syntax_indicator (1), 0 (1), reserved (2)
|
||||||
sectionLength = pmtScratch.readBits(12);
|
sectionLength = pmtScratch.readBits(12);
|
||||||
|
crc = Util.crc(pmtScratch.data, 0, 3, 0xFFFFFFFF);
|
||||||
|
|
||||||
if (sectionData.capacity() < sectionLength) {
|
if (sectionData.capacity() < sectionLength) {
|
||||||
sectionData.reset(new byte[sectionLength], sectionLength);
|
sectionData.reset(new byte[sectionLength], sectionLength);
|
||||||
|
|
@ -354,6 +356,11 @@ public final class TsExtractor implements Extractor {
|
||||||
return;
|
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),
|
// program_number (16), reserved (2), version_number (5), current_next_indicator (1),
|
||||||
// section_number (8), last_section_number (8), reserved (3), PCR_PID (13)
|
// section_number (8), last_section_number (8), reserved (3), PCR_PID (13)
|
||||||
// Skip the rest of the PMT header.
|
// Skip the rest of the PMT header.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue