Bug 756372 - Change |seeking| to prevent seeking in WebM livestream. r=kinetik

This commit is contained in:
Paul Adenot 2012-05-18 13:35:43 -04:00
parent c9e49b6ecd
commit 0da5e3bca2
9 changed files with 44 additions and 1 deletions

View File

@ -34,6 +34,10 @@ public:
PRInt64 aCurrentTime);
virtual nsresult GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime);
virtual bool IsSeekableInBufferedRanges() {
return true;
}
virtual bool HasAudio() {
return mInfo.mHasAudio;
}

View File

@ -985,7 +985,13 @@ nsresult nsBuiltinDecoder::GetSeekable(nsTimeRanges* aSeekable)
return NS_OK;
}
return GetBuffered(aSeekable);
if (mDecoderStateMachine->IsSeekableInBufferedRanges()) {
return GetBuffered(aSeekable);
} else {
// The stream is not seekable using only buffered ranges, and is not
// seekable. Don't allow seeking (return no ranges in |seekable|).
return NS_OK;
}
}
void nsBuiltinDecoder::SetEndTime(double aTime)

View File

@ -331,6 +331,9 @@ public:
virtual nsresult GetBuffered(nsTimeRanges* aBuffered) = 0;
// Return true if the media is seekable using only buffered ranges.
virtual bool IsSeekableInBufferedRanges() = 0;
virtual PRInt64 VideoQueueMemoryInUse() = 0;
virtual PRInt64 AudioQueueMemoryInUse() = 0;

View File

@ -480,6 +480,9 @@ public:
virtual nsresult GetBuffered(nsTimeRanges* aBuffered,
PRInt64 aStartTime) = 0;
// True if we can seek using only buffered ranges. This is backend dependant.
virtual bool IsSeekableInBufferedRanges() = 0;
class VideoQueueMemoryFunctor : public nsDequeFunctor {
public:
VideoQueueMemoryFunctor() : mResult(0) {}

View File

@ -243,6 +243,13 @@ public:
return mSeekable;
}
bool IsSeekableInBufferedRanges() {
if (mReader) {
return mReader->IsSeekableInBufferedRanges();
}
return false;
}
// Sets the current frame buffer length for the MozAudioAvailable event.
// Accessed on the main and state machine threads.
virtual void SetFrameBufferLength(PRUint32 aLength);

View File

@ -84,6 +84,11 @@ public:
virtual nsresult Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime);
virtual nsresult GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime);
// We use bisection to seek in buffered range.
virtual bool IsSeekableInBufferedRanges() {
return true;
}
private:
bool HasSkeleton() {

View File

@ -70,6 +70,11 @@ public:
virtual nsresult Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime);
virtual nsresult GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime);
// By seeking in the media resource, it is possible to seek.
bool IsSeekableInBufferedRanges() {
return true;
}
private:
bool ReadFromResource(MediaResource *aResource, PRUint8 *aBuf, PRUint32 aLength);

View File

@ -68,6 +68,11 @@ public:
virtual nsresult Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime);
virtual nsresult GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime);
// To seek in a buffered range, we just have to seek the stream.
virtual bool IsSeekableInBufferedRanges() {
return true;
}
private:
bool ReadAll(char* aBuf, PRInt64 aSize, PRInt64* aBytesRead = nsnull);
bool LoadRIFFChunk();

View File

@ -156,6 +156,11 @@ public:
return mHasVideo;
}
// Bug 575140, cannot seek in webm if no cue is present.
bool IsSeekableInBufferedRanges() {
return false;
}
virtual nsresult ReadMetadata(nsVideoInfo* aInfo);
virtual nsresult Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime);
virtual nsresult GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime);