зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 34f6eb1300f1 due to test failure
This commit is contained in:
Родитель
c53f161056
Коммит
830de8db59
|
@ -821,10 +821,8 @@ nsresult nsHTMLMediaElement::DispatchProgressEvent(const nsAString& aName)
|
|||
|
||||
nsCOMPtr<nsIDOMProgressEvent> progressEvent(do_QueryInterface(event));
|
||||
NS_ENSURE_TRUE(progressEvent, NS_ERROR_FAILURE);
|
||||
|
||||
PRInt64 length = mDecoder->GetTotalBytes();
|
||||
rv = progressEvent->InitProgressEvent(aName, PR_TRUE, PR_TRUE,
|
||||
length >= 0, mDecoder->GetBytesLoaded(), length);
|
||||
|
||||
rv = progressEvent->InitProgressEvent(aName, PR_TRUE, PR_TRUE, PR_FALSE, mDecoder->GetBytesLoaded(), mDecoder->GetTotalBytes());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool dummy;
|
||||
|
|
|
@ -68,11 +68,8 @@ class nsChannelToPipeListener : public nsIStreamListener
|
|||
|
||||
public:
|
||||
// If aSeeking is PR_TRUE then this listener was created as part of a
|
||||
// seek request and is expecting a byte range partial result. aOffset
|
||||
// is the offset in bytes that this listener started reading from.
|
||||
nsChannelToPipeListener(nsMediaDecoder* aDecoder,
|
||||
PRBool aSeeking = PR_FALSE,
|
||||
PRInt64 aOffset = 0);
|
||||
// seek request and is expecting a byte range partial result.
|
||||
nsChannelToPipeListener(nsMediaDecoder* aDecoder, PRBool aSeeking = PR_FALSE);
|
||||
nsresult Init();
|
||||
nsresult GetInputStream(nsIInputStream** aStream);
|
||||
void Stop();
|
||||
|
@ -98,12 +95,7 @@ private:
|
|||
// bytes per second download rate.
|
||||
PRIntervalTime mIntervalEnd;
|
||||
|
||||
// Offset from the beginning of the resource where the listener
|
||||
// started reading. This is used for computing the current file
|
||||
// position for progress events.
|
||||
PRInt64 mOffset;
|
||||
|
||||
// Total bytes transferred so far. Used for computing download rates.
|
||||
// Total bytes transferred so far
|
||||
PRInt64 mTotalBytes;
|
||||
|
||||
// PR_TRUE if this listener is expecting a byte range request result
|
||||
|
|
|
@ -160,11 +160,8 @@ class nsMediaDecoder : public nsIObserver
|
|||
// Invalidate the frame.
|
||||
virtual void Invalidate();
|
||||
|
||||
// Fire progress events if needed according to the time and byte
|
||||
// constraints outlined in the specification. aTimer is PR_TRUE
|
||||
// if the method is called as a result of the progress timer rather
|
||||
// than the result of downloaded data.
|
||||
virtual void Progress(PRBool aTimer);
|
||||
// Update progress information.
|
||||
virtual void Progress();
|
||||
|
||||
// Keep track of the number of bytes downloaded
|
||||
virtual void UpdateBytesDownloaded(PRUint64 aBytes) = 0;
|
||||
|
@ -209,16 +206,6 @@ protected:
|
|||
PRInt32 mRGBWidth;
|
||||
PRInt32 mRGBHeight;
|
||||
|
||||
// Time that the last progress event was fired. Read/Write from the
|
||||
// main thread only.
|
||||
PRIntervalTime mProgressTime;
|
||||
|
||||
// Time that data was last read from the media resource. Used for
|
||||
// computing if the download has stalled. A value of 0 indicates that
|
||||
// a stall event has already fired and not to fire another one until
|
||||
// more data is received. Read/Write from the main thread only.
|
||||
PRIntervalTime mDataTime;
|
||||
|
||||
// Has our size changed since the last repaint?
|
||||
PRPackedBool mSizeChanged;
|
||||
|
||||
|
|
|
@ -47,12 +47,10 @@
|
|||
|
||||
nsChannelToPipeListener::nsChannelToPipeListener(
|
||||
nsMediaDecoder* aDecoder,
|
||||
PRBool aSeeking,
|
||||
PRInt64 aOffset) :
|
||||
PRBool aSeeking) :
|
||||
mDecoder(aDecoder),
|
||||
mIntervalStart(0),
|
||||
mIntervalEnd(0),
|
||||
mOffset(aOffset),
|
||||
mTotalBytes(0),
|
||||
mSeeking(aSeeking)
|
||||
{
|
||||
|
@ -101,7 +99,7 @@ nsresult nsChannelToPipeListener::OnStartRequest(nsIRequest* aRequest, nsISuppor
|
|||
mIntervalStart = PR_IntervalNow();
|
||||
mIntervalEnd = mIntervalStart;
|
||||
mTotalBytes = 0;
|
||||
mDecoder->UpdateBytesDownloaded(mOffset);
|
||||
mDecoder->UpdateBytesDownloaded(mTotalBytes);
|
||||
nsCOMPtr<nsIHttpChannel> hc = do_QueryInterface(aRequest);
|
||||
if (hc) {
|
||||
PRUint32 responseStatus = 0;
|
||||
|
@ -152,10 +150,6 @@ nsresult nsChannelToPipeListener::OnStartRequest(nsIRequest* aRequest, nsISuppor
|
|||
}
|
||||
}
|
||||
|
||||
// Fires an initial progress event and sets up the stall counter so stall events
|
||||
// fire if no download occurs within the required time frame.
|
||||
mDecoder->Progress(PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -189,16 +183,11 @@ nsresult nsChannelToPipeListener::OnDataAvailable(nsIRequest* aRequest,
|
|||
|
||||
aCount -= bytes;
|
||||
mTotalBytes += bytes;
|
||||
mDecoder->UpdateBytesDownloaded(mOffset + aOffset + bytes);
|
||||
mDecoder->UpdateBytesDownloaded(mTotalBytes);
|
||||
} while (aCount) ;
|
||||
|
||||
nsresult rv = mOutput->Flush();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Fire a progress events according to the time and byte constraints outlined
|
||||
// in the spec.
|
||||
mDecoder->Progress(PR_FALSE);
|
||||
|
||||
mIntervalEnd = PR_IntervalNow();
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -52,12 +52,6 @@
|
|||
#include "nsPresContext.h"
|
||||
#include "nsMediaDecoder.h"
|
||||
|
||||
// Number of milliseconds between progress events as defined by spec
|
||||
#define PROGRESS_MS 350
|
||||
|
||||
// Number of milliseconds of no data before a stall event is fired as defined by spec
|
||||
#define STALL_MS 3000
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
// Logging object for decoder
|
||||
PRLogModuleInfo* gVideoDecoderLog = nsnull;
|
||||
|
@ -67,8 +61,6 @@ nsMediaDecoder::nsMediaDecoder() :
|
|||
mElement(0),
|
||||
mRGBWidth(-1),
|
||||
mRGBHeight(-1),
|
||||
mProgressTime(0),
|
||||
mDataTime(0),
|
||||
mSizeChanged(PR_FALSE),
|
||||
mVideoUpdateLock(nsnull),
|
||||
mFramerate(0.0)
|
||||
|
@ -135,46 +127,26 @@ void nsMediaDecoder::Invalidate()
|
|||
static void ProgressCallback(nsITimer* aTimer, void* aClosure)
|
||||
{
|
||||
nsMediaDecoder* decoder = static_cast<nsMediaDecoder*>(aClosure);
|
||||
decoder->Progress(PR_TRUE);
|
||||
decoder->Progress();
|
||||
}
|
||||
|
||||
void nsMediaDecoder::Progress(PRBool aTimer)
|
||||
void nsMediaDecoder::Progress()
|
||||
{
|
||||
// The check for mProgressTimer is to ensure that progress events
|
||||
// are only sent when we've asked for them to start via StartProgress.
|
||||
if (!mElement || !mProgressTimer)
|
||||
if (!mElement)
|
||||
return;
|
||||
|
||||
PRIntervalTime now = PR_IntervalNow();
|
||||
|
||||
if (mProgressTime == 0 ||
|
||||
PR_IntervalToMilliseconds(PR_IntervalNow() - mProgressTime) >= PROGRESS_MS) {
|
||||
mElement->DispatchProgressEvent(NS_LITERAL_STRING("progress"));
|
||||
mProgressTime = now;
|
||||
}
|
||||
|
||||
// The test for aTimer is to ensure that we dispatch 'stalled'
|
||||
// only when we are not receiving data.
|
||||
if (aTimer &&
|
||||
mDataTime != 0 &&
|
||||
PR_IntervalToMilliseconds(now - mDataTime) >= STALL_MS) {
|
||||
mElement->DispatchProgressEvent(NS_LITERAL_STRING("stalled"));
|
||||
mDataTime = 0;
|
||||
}
|
||||
|
||||
if (!aTimer) {
|
||||
mDataTime = now;
|
||||
}
|
||||
mElement->DispatchProgressEvent(NS_LITERAL_STRING("progress"));
|
||||
}
|
||||
|
||||
nsresult nsMediaDecoder::StartProgress()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mProgressTimer) {
|
||||
mProgressTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
rv = mProgressTimer->InitWithFuncCallback(ProgressCallback,
|
||||
this,
|
||||
PROGRESS_MS,
|
||||
350, // Number of milliseconds defined in spec
|
||||
nsITimer::TYPE_REPEATING_PRECISE);
|
||||
}
|
||||
return rv;
|
||||
|
@ -187,7 +159,6 @@ nsresult nsMediaDecoder::StopProgress()
|
|||
rv = mProgressTimer->Cancel();
|
||||
mProgressTimer = nsnull;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -270,7 +270,6 @@ nsresult nsFileStreamStrategy::Open(nsIStreamListener** aStreamListener)
|
|||
rv = mInput->Available(&size);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mDecoder->SetTotalBytes(size);
|
||||
mDecoder->UpdateBytesDownloaded(size);
|
||||
}
|
||||
|
||||
/* Get our principal */
|
||||
|
@ -547,7 +546,7 @@ public:
|
|||
hc->SetRequestHeader(NS_LITERAL_CSTRING("Range"), rangeString, PR_FALSE);
|
||||
}
|
||||
|
||||
mListener = new nsChannelToPipeListener(mDecoder, PR_TRUE, mOffset);
|
||||
mListener = new nsChannelToPipeListener(mDecoder, PR_TRUE);
|
||||
NS_ENSURE_TRUE(mListener, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
mResult = mListener->Init();
|
||||
|
|
|
@ -1254,6 +1254,8 @@ nsresult nsOggDecoder::Load(nsIURI* aURI, nsIChannel* aChannel,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
StartProgress();
|
||||
|
||||
RegisterShutdownObserver();
|
||||
|
||||
mReader = new nsChannelReader();
|
||||
|
@ -1387,13 +1389,6 @@ void nsOggDecoder::MetadataLoaded()
|
|||
if (mElement) {
|
||||
mElement->MetadataLoaded();
|
||||
}
|
||||
|
||||
// Start progress events if we have bytes left to download.
|
||||
// Need to check this as it's possible the entire file has been
|
||||
// downloaded before the metadata is decoded.
|
||||
if (mBytesDownloaded != mContentLength) {
|
||||
StartProgress();
|
||||
}
|
||||
}
|
||||
|
||||
void nsOggDecoder::FirstFrameLoaded()
|
||||
|
@ -1419,25 +1414,10 @@ void nsOggDecoder::FirstFrameLoaded()
|
|||
|
||||
void nsOggDecoder::ResourceLoaded()
|
||||
{
|
||||
{
|
||||
// If we are seeking or loading then the resource loaded notification we get
|
||||
// should be ignored, since it represents the end of the seek request.
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
if (mPlayState == PLAY_STATE_SEEKING || mPlayState == PLAY_STATE_LOADING)
|
||||
return;
|
||||
}
|
||||
|
||||
mBytesDownloaded = mContentLength;
|
||||
StopProgress();
|
||||
|
||||
// Ensure the final progress event gets fired
|
||||
if (mElement) {
|
||||
mElement->DispatchProgressEvent(NS_LITERAL_STRING("progress"));
|
||||
}
|
||||
|
||||
if (mElement) {
|
||||
mElement->ResourceLoaded();
|
||||
}
|
||||
StopProgress();
|
||||
}
|
||||
|
||||
void nsOggDecoder::NetworkError()
|
||||
|
@ -1492,16 +1472,7 @@ void nsOggDecoder::SetTotalBytes(PRInt64 aBytes)
|
|||
|
||||
void nsOggDecoder::UpdateBytesDownloaded(PRUint64 aBytes)
|
||||
{
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
|
||||
// Don't update bytes downloaded if we are in the LOADING
|
||||
// play state. The value of aBytes is unreliable at this
|
||||
// stage due to seeking to get the duration done during
|
||||
// metadata loading. This prevents the progress bar from
|
||||
// jumping around from 0 to 100% back to 0.
|
||||
if (mPlayState != PLAY_STATE_LOADING) {
|
||||
mBytesDownloaded = aBytes;
|
||||
}
|
||||
mBytesDownloaded = aBytes;
|
||||
}
|
||||
|
||||
void nsOggDecoder::BufferingStopped()
|
||||
|
@ -1536,8 +1507,6 @@ void nsOggDecoder::SeekingStopped()
|
|||
if (mElement) {
|
||||
mElement->SeekCompleted();
|
||||
}
|
||||
|
||||
StartProgress();
|
||||
}
|
||||
|
||||
void nsOggDecoder::SeekingStarted()
|
||||
|
@ -1548,11 +1517,6 @@ void nsOggDecoder::SeekingStarted()
|
|||
return;
|
||||
}
|
||||
|
||||
// Don't do progress events while seeking
|
||||
// due to the rapid change in loaded position
|
||||
// that occurs.
|
||||
StopProgress();
|
||||
|
||||
if (mElement) {
|
||||
mElement->SeekStarted();
|
||||
}
|
||||
|
|
|
@ -1111,11 +1111,6 @@ nsWaveDecoder::ResourceLoaded()
|
|||
mPlaybackStateMachine->StreamEnded();
|
||||
}
|
||||
StopProgress();
|
||||
|
||||
// Ensure the final progress event gets fired
|
||||
if (mElement) {
|
||||
mElement->DispatchProgressEvent(NS_LITERAL_STRING("progress"));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -53,8 +53,6 @@ _TEST_FILES = test_autoplay.html \
|
|||
test_ended2.html \
|
||||
test_networkState.html \
|
||||
test_paused.html \
|
||||
test_progress1.html \
|
||||
test_progress2.html \
|
||||
test_readyState.html \
|
||||
test_seek1.html \
|
||||
test_seek2.html \
|
||||
|
@ -76,8 +74,7 @@ _TEST_FILES = test_autoplay.html \
|
|||
320x240.ogg \
|
||||
bug461281.ogg \
|
||||
seek.ogg \
|
||||
big.wav \
|
||||
r11025_s16_c1.wav \
|
||||
r11025_s16_c1.wav \
|
||||
r11025_u8_c1.wav \
|
||||
# test_bug448534.html \
|
||||
$(NULL)
|
||||
|
|
Загрузка…
Ссылка в новой задаче