mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1000608 - Implement cue-less seeking on WebM Reader - r=kinetik
This commit is contained in:
parent
af943fb408
commit
ff8b2f2881
@ -219,6 +219,22 @@ bool WebMBufferedState::CalculateBufferedForRange(int64_t aStartOffset, int64_t
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebMBufferedState::GetOffsetForTime(uint64_t aTime, int64_t* aOffset)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
WebMTimeDataOffset result(0,0);
|
||||
|
||||
for (uint32_t i = 0; i < mTimeMapping.Length(); ++i) {
|
||||
WebMTimeDataOffset o = mTimeMapping[i];
|
||||
if (o.mTimecode < aTime && o.mTimecode > result.mTimecode) {
|
||||
result = o;
|
||||
}
|
||||
}
|
||||
|
||||
*aOffset = result.mOffset;
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebMBufferedState::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||
|
@ -194,6 +194,7 @@ public:
|
||||
void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset);
|
||||
bool CalculateBufferedForRange(int64_t aStartOffset, int64_t aEndOffset,
|
||||
uint64_t* aStartTime, uint64_t* aEndTime);
|
||||
bool GetOffsetForTime(uint64_t aTime, int64_t* aOffset);
|
||||
|
||||
private:
|
||||
// Private destructor, to discourage deletion outside of Release():
|
||||
|
@ -1004,7 +1004,17 @@ nsresult WebMReader::Seek(int64_t aTarget, int64_t aStartTime, int64_t aEndTime,
|
||||
}
|
||||
int r = nestegg_track_seek(mContext, trackToSeek, target);
|
||||
if (r != 0) {
|
||||
return NS_ERROR_FAILURE;
|
||||
// Try seeking directly based on cluster information in memory.
|
||||
int64_t offset = 0;
|
||||
bool rv = mBufferedState->GetOffsetForTime((aTarget - aStartTime)/NS_PER_USEC, &offset);
|
||||
if (!rv) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
r = nestegg_offset_seek(mContext, offset);
|
||||
if (r != 0) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user