mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 01:08:39 +09:00
Issue #2673 - Part 2: Add ADTS format sniffer.
This commit is contained in:
parent
0c2130e615
commit
e25b285ca7
2 changed files with 25 additions and 0 deletions
|
|
@ -840,4 +840,26 @@ ADTSTrackDemuxer::AverageFrameLength() const
|
|||
return 0.0;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
ADTSDemuxer::ADTSSniffer(const uint8_t* aData, const uint32_t aLength)
|
||||
{
|
||||
if (aLength < 7) {
|
||||
return false;
|
||||
}
|
||||
auto parser = MakeUnique<adts::FrameParser>();
|
||||
|
||||
if (!parser->Parse(0, aData, aData + aLength)) {
|
||||
return false;
|
||||
}
|
||||
const adts::Frame& currentFrame = parser->CurrentFrame();
|
||||
// Check for sync marker after the found frame, since it's
|
||||
// possible to find sync marker in AAC data. If sync marker
|
||||
// exists after the current frame then we've found a frame
|
||||
// header.
|
||||
int64_t nextFrameHeaderOffset = currentFrame.Offset() + currentFrame.Length();
|
||||
return int64_t(aLength) > nextFrameHeaderOffset &&
|
||||
aLength - nextFrameHeaderOffset >= 2 &&
|
||||
adts::FrameHeader::MatchesSync(aData + nextFrameHeaderOffset);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ public:
|
|||
TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
|
||||
bool IsSeekable() const override;
|
||||
|
||||
// Return true if a valid ADTS frame header could be found.
|
||||
static bool ADTSSniffer(const uint8_t* aData, const uint32_t aLength);
|
||||
|
||||
private:
|
||||
bool InitInternal();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue