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
Родитель 5a2f54ca85
Коммит 1cd2b803c6
6 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

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

Просмотреть файл

@ -74,6 +74,11 @@ private:
// mMediaSource. // mMediaSource.
dom::MediaSource* mMediaSource; dom::MediaSource* mMediaSource;
nsRefPtr<MediaSourceReader> mReader; 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 } // namespace mozilla

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -43,7 +43,7 @@ public:
// Returns the highest end time of all of the buffered ranges in the // 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 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); double Buffered(dom::TimeRanges* aRanges);
// Mark the current decoder's resource as ended, clear mCurrentDecoder and // Mark the current decoder's resource as ended, clear mCurrentDecoder and