Bug 1091008 - Implement a sensible GetBuffered override for MediaSourceReader using the existing GetBuffered on MediaSource. r=cajbir

This commit is contained in:
Bobby Holley 2014-11-05 10:08:59 +01:00
parent 2c76301bbe
commit e1fdd341c3
6 changed files with 16 additions and 2 deletions

View File

@ -353,6 +353,7 @@ MediaSource::Detach()
void
MediaSource::GetBuffered(TimeRanges* aBuffered)
{
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
MOZ_ASSERT(aBuffered->Length() == 0);
if (mActiveSourceBuffers->IsEmpty()) {
return;

View File

@ -74,6 +74,11 @@ private:
// mMediaSource.
dom::MediaSource* mMediaSource;
nsRefPtr<MediaSourceReader> mReader;
// XXXbholley - This is to allow the reader to invoke GetBuffered on
// mMediaSource. It goes away in a subsequent patch when that function gets
// hoisted into MediaSourceReader.
friend class MediaSourceReader;
};
} // namespace mozilla

View File

@ -446,6 +446,13 @@ MediaSourceReader::Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime,
return NS_OK;
}
nsresult
MediaSourceReader::GetBuffered(dom::TimeRanges* aBuffered)
{
static_cast<MediaSourceDecoder*>(mDecoder)->mMediaSource->GetBuffered(aBuffered);
return NS_OK;
}
nsresult
MediaSourceReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
{

View File

@ -77,6 +77,8 @@ public:
nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime,
int64_t aCurrentTime) MOZ_OVERRIDE;
nsresult GetBuffered(dom::TimeRanges* aBuffered) MOZ_OVERRIDE;
already_AddRefed<SourceBufferDecoder> CreateSubDecoder(const nsACString& aType);
void AddTrackBuffer(TrackBuffer* aTrackBuffer);

View File

@ -191,7 +191,6 @@ double
TrackBuffer::Buffered(dom::TimeRanges* aRanges)
{
ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
MOZ_ASSERT(NS_IsMainThread());
double highestEndTime = 0;

View File

@ -43,7 +43,7 @@ public:
// Returns the highest end time of all of the buffered ranges in the
// decoders managed by this TrackBuffer, and returns the union of the
// decoders buffered ranges in aRanges.
// decoders buffered ranges in aRanges. This may be called on any thread.
double Buffered(dom::TimeRanges* aRanges);
// Mark the current decoder's resource as ended, clear mCurrentDecoder and