mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1195073: [webm] P2. Add WebMBufferedState::GetLastBlockOffset method. r=kinetik
MSE may input partial media segment, which could cause the WebMDemuxer and libnestegg to error upon encountering an incomplete block which can't be recovered from. this will allow to limit read to known complete blocks.
This commit is contained in:
parent
b430a15240
commit
bc02eee4d2
@ -344,6 +344,22 @@ void WebMBufferedState::NotifyDataArrived(const unsigned char* aBuffer, uint32_t
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
mLastEndOffset = std::max<int64_t>(aOffset + aLength, mLastEndOffset);
|
||||
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
if (mTimeMapping.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
int32_t endIdx = mTimeMapping.Length() - 1;
|
||||
while (endIdx >= 0 && mLastEndOffset < mTimeMapping[endIdx].mEndOffset) {
|
||||
endIdx -= 1;
|
||||
}
|
||||
if (endIdx < 0) {
|
||||
return;
|
||||
}
|
||||
mLastBlockOffset = mTimeMapping[endIdx].mEndOffset;
|
||||
}
|
||||
|
||||
void WebMBufferedState::Reset() {
|
||||
@ -398,6 +414,13 @@ int64_t WebMBufferedState::GetInitEndOffset()
|
||||
return mRangeParsers[0].mInitEndOffset;
|
||||
}
|
||||
|
||||
int64_t WebMBufferedState::GetLastBlockOffset()
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
return mLastBlockOffset;
|
||||
}
|
||||
|
||||
bool WebMBufferedState::GetStartTime(uint64_t *aTime)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
@ -225,7 +225,11 @@ class WebMBufferedState final
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebMBufferedState)
|
||||
|
||||
public:
|
||||
WebMBufferedState() : mReentrantMonitor("WebMBufferedState") {
|
||||
WebMBufferedState()
|
||||
: mReentrantMonitor("WebMBufferedState")
|
||||
, mLastBlockOffset(-1)
|
||||
, mLastEndOffset(-1)
|
||||
{
|
||||
MOZ_COUNT_CTOR(WebMBufferedState);
|
||||
}
|
||||
|
||||
@ -242,6 +246,8 @@ public:
|
||||
|
||||
// Returns end offset of init segment or -1 if none found.
|
||||
int64_t GetInitEndOffset();
|
||||
// Returns the end offset of the last complete block or -1 if none found.
|
||||
int64_t GetLastBlockOffset();
|
||||
|
||||
// Returns start time
|
||||
bool GetStartTime(uint64_t *aTime);
|
||||
@ -255,12 +261,16 @@ private:
|
||||
MOZ_COUNT_DTOR(WebMBufferedState);
|
||||
}
|
||||
|
||||
// Synchronizes access to the mTimeMapping array.
|
||||
// Synchronizes access to the mTimeMapping array and mLastBlockOffset.
|
||||
ReentrantMonitor mReentrantMonitor;
|
||||
|
||||
// Sorted (by offset) map of data offsets to timecodes. Populated
|
||||
// on the main thread as data is received and parsed by WebMBufferedParsers.
|
||||
nsTArray<WebMTimeDataOffset> mTimeMapping;
|
||||
// The last complete block parsed. -1 if not set.
|
||||
int64_t mLastBlockOffset;
|
||||
// The last seen data end offset. -1 if not set.
|
||||
int64_t mLastEndOffset;
|
||||
|
||||
// Sorted (by offset) live parser instances. Main thread only.
|
||||
nsTArray<WebMBufferedParser> mRangeParsers;
|
||||
|
Loading…
Reference in New Issue
Block a user