mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-22 16:37:31 +09:00
Merge remote-tracking branch 'origin/tracking' into custom
This commit is contained in:
commit
44f397bea2
7 changed files with 93 additions and 36 deletions
|
|
@ -5,12 +5,10 @@
|
|||
|
||||
#include "ADTSDemuxer.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "TimeUnits.h"
|
||||
#include "prenv.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
extern mozilla::LazyLogModule gMediaDemuxerLog;
|
||||
|
|
@ -160,11 +158,11 @@ public:
|
|||
}
|
||||
|
||||
// Returns whether the valid
|
||||
bool Parse(int64_t aOffset, uint8_t* aStart, uint8_t* aEnd) {
|
||||
bool Parse(int64_t aOffset, const uint8_t* aStart, const uint8_t* aEnd) {
|
||||
MOZ_ASSERT(aStart && aEnd);
|
||||
|
||||
bool found = false;
|
||||
uint8_t* ptr = aStart;
|
||||
const uint8_t* ptr = aStart;
|
||||
// Require at least 7 bytes of data at the end of the buffer for the minimum
|
||||
// ADTS frame header.
|
||||
while (ptr < aEnd - 7 && !found) {
|
||||
|
|
@ -214,7 +212,7 @@ public:
|
|||
// if one was found. After returning, the variable passed to 'aBytesToSkip' holds
|
||||
// the amount of bytes to be skipped (if any) in order to jump across a large
|
||||
// ID3v2 tag spanning multiple buffers.
|
||||
bool Parse(int64_t aOffset, uint8_t* aStart, uint8_t* aEnd) {
|
||||
bool Parse(int64_t aOffset, const uint8_t* aStart, const uint8_t* aEnd) {
|
||||
const bool found = mFrame.Parse(aOffset, aStart, aEnd);
|
||||
|
||||
if (mFrame.Length() && !mFirstFrame.Length()) {
|
||||
|
|
@ -728,7 +726,7 @@ ADTSTrackDemuxer::GetNextFrame(const adts::Frame& aFrame)
|
|||
RefPtr<MediaRawData> frame = new MediaRawData();
|
||||
frame->mOffset = offset;
|
||||
|
||||
nsAutoPtr<MediaRawDataWriter> frameWriter(frame->CreateWriter());
|
||||
UniquePtr<MediaRawDataWriter> frameWriter(frame->CreateWriter());
|
||||
if (!frameWriter->SetSize(length)) {
|
||||
ADTSLOG("GetNext() Exit failed to allocated media buffer");
|
||||
return nullptr;
|
||||
|
|
@ -842,4 +840,30 @@ ADTSTrackDemuxer::AverageFrameLength() const
|
|||
return 0.0;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
ADTSDemuxer::ADTSSniffer(const uint8_t* aData, const uint32_t aLength)
|
||||
{
|
||||
if (aLength < 7) {
|
||||
return false;
|
||||
}
|
||||
// Avoid seeking if blob doesn't start with an ADTS marker.
|
||||
if (!adts::FrameHeader::MatchesSync(aData)) {
|
||||
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