Bug 1000608 - Allow querying source buffers to see if they contain data for a given time - r=kinetik

This commit is contained in:
cajbir 2014-04-23 19:45:00 +12:00
parent 9ed0d59e8d
commit f18b46a7c3
4 changed files with 26 additions and 0 deletions

View File

@ -490,6 +490,15 @@ SourceBuffer::Evict(double aStart, double aEnd)
}
}
bool
SourceBuffer::ContainsTime(double aTime)
{
double start = 0.0;
double end = 0.0;
GetBufferedStartEndTime(&start, &end);
return aTime >= start && aTime <= end;
}
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(SourceBuffer, DOMEventTargetHelper,
mMediaSource)

View File

@ -109,6 +109,9 @@ public:
// Evict data in the source buffer in the given time range.
void Evict(double aStart, double aEnd);
// Returns true if the data in the source buffer contains the given time.
bool ContainsTime(double aTime);
private:
SourceBuffer(MediaSource* aMediaSource, const nsACString& aType);

View File

@ -111,6 +111,17 @@ SourceBufferList::Evict(double aStart, double aEnd)
}
}
bool
SourceBufferList::ContainsTime(double aTime)
{
for (uint32_t i = 0; i < mSourceBuffers.Length(); ++i) {
if (!mSourceBuffers[i]->ContainsTime(aTime)) {
return false;
}
}
return true;
}
void
SourceBufferList::Ended()
{

View File

@ -77,6 +77,9 @@ public:
// Evicts data for the given time range from each SourceBuffer in the list.
void Evict(double aStart, double aEnd);
// Returns true if all SourceBuffers in the list contain data for the given time.
bool ContainsTime(double aTime);
private:
friend class AsyncEventRunner<SourceBufferList>;
void DispatchSimpleEvent(const char* aName);