mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out due to test failures
This commit is contained in:
commit
3bf6c00baa
@ -1064,10 +1064,8 @@ nsresult nsHTMLMediaElement::DispatchProgressEvent(const nsAString& aName)
|
|||||||
|
|
||||||
nsCOMPtr<nsIDOMProgressEvent> progressEvent(do_QueryInterface(event));
|
nsCOMPtr<nsIDOMProgressEvent> progressEvent(do_QueryInterface(event));
|
||||||
NS_ENSURE_TRUE(progressEvent, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(progressEvent, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
PRInt64 length = mDecoder->GetTotalBytes();
|
rv = progressEvent->InitProgressEvent(aName, PR_TRUE, PR_TRUE, PR_FALSE, mDecoder->GetBytesLoaded(), mDecoder->GetTotalBytes());
|
||||||
rv = progressEvent->InitProgressEvent(aName, PR_TRUE, PR_TRUE,
|
|
||||||
length >= 0, mDecoder->GetBytesLoaded(), length);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
PRBool dummy;
|
PRBool dummy;
|
||||||
|
@ -68,11 +68,8 @@ class nsChannelToPipeListener : public nsIStreamListener
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// If aSeeking is PR_TRUE then this listener was created as part of a
|
// 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
|
// seek request and is expecting a byte range partial result.
|
||||||
// is the offset in bytes that this listener started reading from.
|
nsChannelToPipeListener(nsMediaDecoder* aDecoder, PRBool aSeeking = PR_FALSE);
|
||||||
nsChannelToPipeListener(nsMediaDecoder* aDecoder,
|
|
||||||
PRBool aSeeking = PR_FALSE,
|
|
||||||
PRInt64 aOffset = 0);
|
|
||||||
nsresult Init();
|
nsresult Init();
|
||||||
nsresult GetInputStream(nsIInputStream** aStream);
|
nsresult GetInputStream(nsIInputStream** aStream);
|
||||||
void Stop();
|
void Stop();
|
||||||
@ -98,12 +95,7 @@ private:
|
|||||||
// bytes per second download rate.
|
// bytes per second download rate.
|
||||||
PRIntervalTime mIntervalEnd;
|
PRIntervalTime mIntervalEnd;
|
||||||
|
|
||||||
// Offset from the beginning of the resource where the listener
|
// Total bytes transferred so far
|
||||||
// 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.
|
|
||||||
PRInt64 mTotalBytes;
|
PRInt64 mTotalBytes;
|
||||||
|
|
||||||
// PR_TRUE if this listener is expecting a byte range request result
|
// PR_TRUE if this listener is expecting a byte range request result
|
||||||
|
@ -164,11 +164,8 @@ class nsMediaDecoder : public nsIObserver
|
|||||||
// Invalidate the frame.
|
// Invalidate the frame.
|
||||||
virtual void Invalidate();
|
virtual void Invalidate();
|
||||||
|
|
||||||
// Fire progress events if needed according to the time and byte
|
// Update progress information.
|
||||||
// constraints outlined in the specification. aTimer is PR_TRUE
|
virtual void Progress();
|
||||||
// if the method is called as a result of the progress timer rather
|
|
||||||
// than the result of downloaded data.
|
|
||||||
virtual void Progress(PRBool aTimer);
|
|
||||||
|
|
||||||
// Keep track of the number of bytes downloaded
|
// Keep track of the number of bytes downloaded
|
||||||
virtual void UpdateBytesDownloaded(PRUint64 aBytes) = 0;
|
virtual void UpdateBytesDownloaded(PRUint64 aBytes) = 0;
|
||||||
@ -213,16 +210,6 @@ protected:
|
|||||||
PRInt32 mRGBWidth;
|
PRInt32 mRGBWidth;
|
||||||
PRInt32 mRGBHeight;
|
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?
|
// Has our size changed since the last repaint?
|
||||||
PRPackedBool mSizeChanged;
|
PRPackedBool mSizeChanged;
|
||||||
|
|
||||||
@ -252,12 +239,6 @@ protected:
|
|||||||
// waiting for the playback event loop to shutdown. Read/Write from the
|
// waiting for the playback event loop to shutdown. Read/Write from the
|
||||||
// main thread only.
|
// main thread only.
|
||||||
PRPackedBool mStopping;
|
PRPackedBool mStopping;
|
||||||
|
|
||||||
// True when seeking or otherwise moving the play position around in
|
|
||||||
// such a manner that progress event data is inaccurate. This is set
|
|
||||||
// before a seek or during loading of metadata to prevent the progress indicator
|
|
||||||
// from jumping around. Accessed on the main thread only.
|
|
||||||
PRPackedBool mIgnoreProgressData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -512,10 +512,6 @@ private:
|
|||||||
// when writing to the state, or when reading from a non-main thread.
|
// when writing to the state, or when reading from a non-main thread.
|
||||||
// Any change to the state must call NotifyAll on the monitor.
|
// Any change to the state must call NotifyAll on the monitor.
|
||||||
PlayState mNextState;
|
PlayState mNextState;
|
||||||
|
|
||||||
// True when the media resource has completely loaded. Accessed on
|
|
||||||
// the main thread only.
|
|
||||||
PRPackedBool mResourceLoaded;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -274,10 +274,6 @@ private:
|
|||||||
|
|
||||||
// True if the media resource is seekable.
|
// True if the media resource is seekable.
|
||||||
PRPackedBool mSeekable;
|
PRPackedBool mSeekable;
|
||||||
|
|
||||||
// True when the media resource has completely loaded. Accessed on
|
|
||||||
// the main thread only.
|
|
||||||
PRPackedBool mResourceLoaded;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -47,12 +47,10 @@
|
|||||||
|
|
||||||
nsChannelToPipeListener::nsChannelToPipeListener(
|
nsChannelToPipeListener::nsChannelToPipeListener(
|
||||||
nsMediaDecoder* aDecoder,
|
nsMediaDecoder* aDecoder,
|
||||||
PRBool aSeeking,
|
PRBool aSeeking) :
|
||||||
PRInt64 aOffset) :
|
|
||||||
mDecoder(aDecoder),
|
mDecoder(aDecoder),
|
||||||
mIntervalStart(0),
|
mIntervalStart(0),
|
||||||
mIntervalEnd(0),
|
mIntervalEnd(0),
|
||||||
mOffset(aOffset),
|
|
||||||
mTotalBytes(0),
|
mTotalBytes(0),
|
||||||
mSeeking(aSeeking)
|
mSeeking(aSeeking)
|
||||||
{
|
{
|
||||||
@ -101,7 +99,7 @@ nsresult nsChannelToPipeListener::OnStartRequest(nsIRequest* aRequest, nsISuppor
|
|||||||
mIntervalStart = PR_IntervalNow();
|
mIntervalStart = PR_IntervalNow();
|
||||||
mIntervalEnd = mIntervalStart;
|
mIntervalEnd = mIntervalStart;
|
||||||
mTotalBytes = 0;
|
mTotalBytes = 0;
|
||||||
mDecoder->UpdateBytesDownloaded(mOffset);
|
mDecoder->UpdateBytesDownloaded(mTotalBytes);
|
||||||
nsCOMPtr<nsIHttpChannel> hc = do_QueryInterface(aRequest);
|
nsCOMPtr<nsIHttpChannel> hc = do_QueryInterface(aRequest);
|
||||||
if (hc) {
|
if (hc) {
|
||||||
PRUint32 responseStatus = 0;
|
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;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,16 +183,11 @@ nsresult nsChannelToPipeListener::OnDataAvailable(nsIRequest* aRequest,
|
|||||||
|
|
||||||
aCount -= bytes;
|
aCount -= bytes;
|
||||||
mTotalBytes += bytes;
|
mTotalBytes += bytes;
|
||||||
mDecoder->UpdateBytesDownloaded(mOffset + aOffset + bytes);
|
mDecoder->UpdateBytesDownloaded(mTotalBytes);
|
||||||
} while (aCount) ;
|
} while (aCount) ;
|
||||||
|
|
||||||
nsresult rv = mOutput->Flush();
|
nsresult rv = mOutput->Flush();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
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();
|
mIntervalEnd = PR_IntervalNow();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -52,12 +52,6 @@
|
|||||||
#include "nsPresContext.h"
|
#include "nsPresContext.h"
|
||||||
#include "nsMediaDecoder.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
|
#ifdef PR_LOGGING
|
||||||
// Logging object for decoder
|
// Logging object for decoder
|
||||||
PRLogModuleInfo* gVideoDecoderLog = nsnull;
|
PRLogModuleInfo* gVideoDecoderLog = nsnull;
|
||||||
@ -67,14 +61,11 @@ nsMediaDecoder::nsMediaDecoder() :
|
|||||||
mElement(0),
|
mElement(0),
|
||||||
mRGBWidth(-1),
|
mRGBWidth(-1),
|
||||||
mRGBHeight(-1),
|
mRGBHeight(-1),
|
||||||
mProgressTime(0),
|
|
||||||
mDataTime(0),
|
|
||||||
mSizeChanged(PR_FALSE),
|
mSizeChanged(PR_FALSE),
|
||||||
mVideoUpdateLock(nsnull),
|
mVideoUpdateLock(nsnull),
|
||||||
mFramerate(0.0),
|
mFramerate(0.0),
|
||||||
mShuttingDown(PR_FALSE),
|
mShuttingDown(PR_FALSE),
|
||||||
mStopping(PR_FALSE),
|
mStopping(PR_FALSE)
|
||||||
mIgnoreProgressData(PR_TRUE)
|
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsMediaDecoder);
|
MOZ_COUNT_CTOR(nsMediaDecoder);
|
||||||
}
|
}
|
||||||
@ -138,55 +129,38 @@ void nsMediaDecoder::Invalidate()
|
|||||||
static void ProgressCallback(nsITimer* aTimer, void* aClosure)
|
static void ProgressCallback(nsITimer* aTimer, void* aClosure)
|
||||||
{
|
{
|
||||||
nsMediaDecoder* decoder = static_cast<nsMediaDecoder*>(aClosure);
|
nsMediaDecoder* decoder = static_cast<nsMediaDecoder*>(aClosure);
|
||||||
decoder->Progress(PR_TRUE);
|
decoder->Progress();
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsMediaDecoder::Progress(PRBool aTimer)
|
void nsMediaDecoder::Progress()
|
||||||
{
|
{
|
||||||
if (!mElement || mIgnoreProgressData)
|
if (!mElement)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PRIntervalTime now = PR_IntervalNow();
|
mElement->DispatchProgressEvent(NS_LITERAL_STRING("progress"));
|
||||||
if (mProgressTime == 0 ||
|
|
||||||
PR_IntervalToMilliseconds(PR_IntervalNow() - mProgressTime) >= PROGRESS_MS) {
|
|
||||||
mElement->DispatchAsyncProgressEvent(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->DispatchAsyncProgressEvent(NS_LITERAL_STRING("stalled"));
|
|
||||||
mDataTime = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!aTimer) {
|
|
||||||
mDataTime = now;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsMediaDecoder::StartProgress()
|
nsresult nsMediaDecoder::StartProgress()
|
||||||
{
|
{
|
||||||
if (mProgressTimer)
|
nsresult rv = NS_OK;
|
||||||
return NS_OK;
|
|
||||||
|
|
||||||
mProgressTimer = do_CreateInstance("@mozilla.org/timer;1");
|
if (!mProgressTimer) {
|
||||||
return mProgressTimer->InitWithFuncCallback(ProgressCallback,
|
mProgressTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||||
|
rv = mProgressTimer->InitWithFuncCallback(ProgressCallback,
|
||||||
this,
|
this,
|
||||||
PROGRESS_MS,
|
350, // Number of milliseconds defined in spec
|
||||||
nsITimer::TYPE_REPEATING_SLACK);
|
nsITimer::TYPE_REPEATING_PRECISE);
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsMediaDecoder::StopProgress()
|
nsresult nsMediaDecoder::StopProgress()
|
||||||
{
|
{
|
||||||
if (!mProgressTimer)
|
nsresult rv = NS_OK;
|
||||||
return NS_OK;
|
if (mProgressTimer) {
|
||||||
|
rv = mProgressTimer->Cancel();
|
||||||
nsresult rv = mProgressTimer->Cancel();
|
mProgressTimer = nsnull;
|
||||||
mProgressTimer = nsnull;
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +270,6 @@ nsresult nsFileStreamStrategy::Open(nsIStreamListener** aStreamListener)
|
|||||||
rv = mInput->Available(&size);
|
rv = mInput->Available(&size);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
mDecoder->SetTotalBytes(size);
|
mDecoder->SetTotalBytes(size);
|
||||||
mDecoder->UpdateBytesDownloaded(size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get our principal */
|
/* Get our principal */
|
||||||
@ -547,7 +546,7 @@ public:
|
|||||||
hc->SetRequestHeader(NS_LITERAL_CSTRING("Range"), rangeString, PR_FALSE);
|
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);
|
NS_ENSURE_TRUE(mListener, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
mResult = mListener->Init();
|
mResult = mListener->Init();
|
||||||
|
@ -1198,8 +1198,7 @@ nsOggDecoder::nsOggDecoder() :
|
|||||||
mReader(0),
|
mReader(0),
|
||||||
mMonitor(0),
|
mMonitor(0),
|
||||||
mPlayState(PLAY_STATE_PAUSED),
|
mPlayState(PLAY_STATE_PAUSED),
|
||||||
mNextState(PLAY_STATE_PAUSED),
|
mNextState(PLAY_STATE_PAUSED)
|
||||||
mResourceLoaded(PR_FALSE)
|
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsOggDecoder);
|
MOZ_COUNT_CTOR(nsOggDecoder);
|
||||||
}
|
}
|
||||||
@ -1233,11 +1232,6 @@ nsresult nsOggDecoder::Load(nsIURI* aURI, nsIChannel* aChannel,
|
|||||||
// reusing decoder.
|
// reusing decoder.
|
||||||
mStopping = PR_FALSE;
|
mStopping = PR_FALSE;
|
||||||
|
|
||||||
// Reset progress member variables
|
|
||||||
mIgnoreProgressData = PR_TRUE;
|
|
||||||
mBytesDownloaded = 0;
|
|
||||||
mResourceLoaded = PR_FALSE;
|
|
||||||
|
|
||||||
NS_ASSERTION(!mReader, "Didn't shutdown properly!");
|
NS_ASSERTION(!mReader, "Didn't shutdown properly!");
|
||||||
NS_ASSERTION(!mDecodeStateMachine, "Didn't shutdown properly!");
|
NS_ASSERTION(!mDecodeStateMachine, "Didn't shutdown properly!");
|
||||||
NS_ASSERTION(!mDecodeThread, "Didn't shutdown properly!");
|
NS_ASSERTION(!mDecodeThread, "Didn't shutdown properly!");
|
||||||
@ -1260,6 +1254,8 @@ nsresult nsOggDecoder::Load(nsIURI* aURI, nsIChannel* aChannel,
|
|||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StartProgress();
|
||||||
|
|
||||||
RegisterShutdownObserver();
|
RegisterShutdownObserver();
|
||||||
|
|
||||||
mReader = new nsChannelReader();
|
mReader = new nsChannelReader();
|
||||||
@ -1369,7 +1365,6 @@ void nsOggDecoder::Stop()
|
|||||||
|
|
||||||
ChangeState(PLAY_STATE_ENDED);
|
ChangeState(PLAY_STATE_ENDED);
|
||||||
|
|
||||||
mIgnoreProgressData = PR_TRUE;
|
|
||||||
StopProgress();
|
StopProgress();
|
||||||
|
|
||||||
// Force any outstanding seek and byterange requests to complete
|
// Force any outstanding seek and byterange requests to complete
|
||||||
@ -1446,18 +1441,6 @@ void nsOggDecoder::MetadataLoaded()
|
|||||||
if (mElement && notifyElement) {
|
if (mElement && notifyElement) {
|
||||||
mElement->MetadataLoaded();
|
mElement->MetadataLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mResourceLoaded) {
|
|
||||||
StartProgress();
|
|
||||||
}
|
|
||||||
else if (mElement)
|
|
||||||
{
|
|
||||||
// Resource was loaded during metadata loading, when progress
|
|
||||||
// events are being ignored. Fire the final progress event.
|
|
||||||
mElement->DispatchAsyncProgressEvent(NS_LITERAL_STRING("progress"));
|
|
||||||
}
|
|
||||||
|
|
||||||
mIgnoreProgressData = PR_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsOggDecoder::FirstFrameLoaded()
|
void nsOggDecoder::FirstFrameLoaded()
|
||||||
@ -1494,39 +1477,13 @@ void nsOggDecoder::FirstFrameLoaded()
|
|||||||
|
|
||||||
void nsOggDecoder::ResourceLoaded()
|
void nsOggDecoder::ResourceLoaded()
|
||||||
{
|
{
|
||||||
// Don't handle ResourceLoaded if we are shutting down, or if
|
if (mShuttingDown)
|
||||||
// we need to ignore progress data due to seeking (in the case
|
|
||||||
// that the seek results in reaching end of file, we get a bogus call
|
|
||||||
// to ResourceLoaded).
|
|
||||||
if (mShuttingDown || mIgnoreProgressData)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Progress(PR_FALSE);
|
|
||||||
{
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we know the content length, set the bytes downloaded to this
|
|
||||||
// so the final progress event gets the correct final value.
|
|
||||||
if (mContentLength >= 0) {
|
|
||||||
mBytesDownloaded = mContentLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
mResourceLoaded = PR_TRUE;
|
|
||||||
StopProgress();
|
|
||||||
|
|
||||||
// Ensure the final progress event gets fired
|
|
||||||
if (mElement && !mIgnoreProgressData) {
|
|
||||||
mElement->DispatchAsyncProgressEvent(NS_LITERAL_STRING("progress"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mElement) {
|
if (mElement) {
|
||||||
mElement->ResourceLoaded();
|
mElement->ResourceLoaded();
|
||||||
}
|
}
|
||||||
|
StopProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsOggDecoder::NetworkError()
|
void nsOggDecoder::NetworkError()
|
||||||
@ -1592,11 +1549,7 @@ void nsOggDecoder::SetTotalBytes(PRInt64 aBytes)
|
|||||||
|
|
||||||
void nsOggDecoder::UpdateBytesDownloaded(PRUint64 aBytes)
|
void nsOggDecoder::UpdateBytesDownloaded(PRUint64 aBytes)
|
||||||
{
|
{
|
||||||
nsAutoMonitor mon(mMonitor);
|
mBytesDownloaded = aBytes;
|
||||||
|
|
||||||
if (!mIgnoreProgressData) {
|
|
||||||
mBytesDownloaded = aBytes;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsOggDecoder::BufferingStopped()
|
void nsOggDecoder::BufferingStopped()
|
||||||
@ -1624,8 +1577,6 @@ void nsOggDecoder::SeekingStopped()
|
|||||||
if (mShuttingDown)
|
if (mShuttingDown)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mIgnoreProgressData = PR_FALSE;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
nsAutoMonitor mon(mMonitor);
|
nsAutoMonitor mon(mMonitor);
|
||||||
|
|
||||||
@ -1647,8 +1598,6 @@ void nsOggDecoder::SeekingStarted()
|
|||||||
if (mShuttingDown)
|
if (mShuttingDown)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mIgnoreProgressData = PR_TRUE;
|
|
||||||
|
|
||||||
if (mElement) {
|
if (mElement) {
|
||||||
mElement->SeekStarted();
|
mElement->SeekStarted();
|
||||||
}
|
}
|
||||||
@ -1782,3 +1731,4 @@ PRBool nsOggDecoder::GetSeekable()
|
|||||||
{
|
{
|
||||||
return mSeekable;
|
return mSeekable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -982,8 +982,7 @@ nsWaveDecoder::nsWaveDecoder()
|
|||||||
mEndedDuration(std::numeric_limits<float>::quiet_NaN()),
|
mEndedDuration(std::numeric_limits<float>::quiet_NaN()),
|
||||||
mEnded(PR_FALSE),
|
mEnded(PR_FALSE),
|
||||||
mNotifyOnShutdown(PR_FALSE),
|
mNotifyOnShutdown(PR_FALSE),
|
||||||
mSeekable(PR_TRUE),
|
mSeekable(PR_TRUE)
|
||||||
mResourceLoaded(PR_FALSE)
|
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsWaveDecoder);
|
MOZ_COUNT_CTOR(nsWaveDecoder);
|
||||||
}
|
}
|
||||||
@ -1099,7 +1098,6 @@ nsWaveDecoder::Stop()
|
|||||||
|
|
||||||
mStopping = PR_TRUE;
|
mStopping = PR_TRUE;
|
||||||
|
|
||||||
mIgnoreProgressData = PR_TRUE;
|
|
||||||
StopProgress();
|
StopProgress();
|
||||||
|
|
||||||
if (mPlaybackStateMachine) {
|
if (mPlaybackStateMachine) {
|
||||||
@ -1132,11 +1130,6 @@ nsWaveDecoder::Load(nsIURI* aURI, nsIChannel* aChannel, nsIStreamListener** aStr
|
|||||||
{
|
{
|
||||||
mStopping = PR_FALSE;
|
mStopping = PR_FALSE;
|
||||||
|
|
||||||
// Reset progress member variables
|
|
||||||
mIgnoreProgressData = PR_TRUE;
|
|
||||||
mBytesDownloaded = 0;
|
|
||||||
mResourceLoaded = PR_FALSE;
|
|
||||||
|
|
||||||
if (aStreamListener) {
|
if (aStreamListener) {
|
||||||
*aStreamListener = nsnull;
|
*aStreamListener = nsnull;
|
||||||
}
|
}
|
||||||
@ -1152,6 +1145,7 @@ nsWaveDecoder::Load(nsIURI* aURI, nsIChannel* aChannel, nsIStreamListener** aStr
|
|||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StartProgress();
|
||||||
RegisterShutdownObserver();
|
RegisterShutdownObserver();
|
||||||
|
|
||||||
mStream = new nsMediaStream();
|
mStream = new nsMediaStream();
|
||||||
@ -1183,18 +1177,6 @@ nsWaveDecoder::MetadataLoaded()
|
|||||||
mElement->MetadataLoaded();
|
mElement->MetadataLoaded();
|
||||||
mElement->FirstFrameLoaded();
|
mElement->FirstFrameLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mResourceLoaded) {
|
|
||||||
StartProgress();
|
|
||||||
}
|
|
||||||
else if (mElement)
|
|
||||||
{
|
|
||||||
// Resource was loaded during metadata loading, when progress
|
|
||||||
// events are being ignored. Fire the final progress event.
|
|
||||||
mElement->DispatchAsyncProgressEvent(NS_LITERAL_STRING("progress"));
|
|
||||||
}
|
|
||||||
|
|
||||||
mIgnoreProgressData = PR_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1216,28 +1198,13 @@ nsWaveDecoder::ResourceLoaded()
|
|||||||
if (mShuttingDown) {
|
if (mShuttingDown) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we know the content length, set the bytes downloaded to this
|
|
||||||
// so the final progress event gets the correct final value.
|
|
||||||
if (mContentLength >= 0) {
|
|
||||||
mBytesDownloaded = mContentLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
mResourceLoaded = PR_TRUE;
|
|
||||||
|
|
||||||
if (mElement) {
|
if (mElement) {
|
||||||
mElement->ResourceLoaded();
|
mElement->ResourceLoaded();
|
||||||
}
|
}
|
||||||
if (mPlaybackStateMachine) {
|
if (mPlaybackStateMachine) {
|
||||||
mPlaybackStateMachine->StreamEnded();
|
mPlaybackStateMachine->StreamEnded();
|
||||||
}
|
}
|
||||||
|
|
||||||
StopProgress();
|
StopProgress();
|
||||||
|
|
||||||
// Ensure the final progress event gets fired
|
|
||||||
if (mElement && !mIgnoreProgressData) {
|
|
||||||
mElement->DispatchAsyncProgressEvent(NS_LITERAL_STRING("progress"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1294,9 +1261,7 @@ nsWaveDecoder::SetTotalBytes(PRInt64 aBytes)
|
|||||||
void
|
void
|
||||||
nsWaveDecoder::UpdateBytesDownloaded(PRUint64 aBytes)
|
nsWaveDecoder::UpdateBytesDownloaded(PRUint64 aBytes)
|
||||||
{
|
{
|
||||||
if (!mIgnoreProgressData) {
|
mBytesDownloaded = aBytes;
|
||||||
mBytesDownloaded = aBytes;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// An event that gets posted to the main thread, when the media element is
|
// An event that gets posted to the main thread, when the media element is
|
||||||
|
@ -67,8 +67,7 @@ _TEST_FILES += \
|
|||||||
test_ended1.html \
|
test_ended1.html \
|
||||||
test_ended2.html \
|
test_ended2.html \
|
||||||
test_onloadedmetadata.html \
|
test_onloadedmetadata.html \
|
||||||
test_progress1.html \
|
test_seek1.html \
|
||||||
test_seek1.html \
|
|
||||||
test_seek3.html \
|
test_seek3.html \
|
||||||
test_seek4.html \
|
test_seek4.html \
|
||||||
test_seek5.html \
|
test_seek5.html \
|
||||||
@ -91,12 +90,10 @@ endif
|
|||||||
|
|
||||||
ifdef MOZ_WAVE
|
ifdef MOZ_WAVE
|
||||||
_TEST_FILES += \
|
_TEST_FILES += \
|
||||||
big.wav \
|
|
||||||
test_bug463162.xhtml \
|
test_bug463162.xhtml \
|
||||||
test_can_play_type_wave.html \
|
test_can_play_type_wave.html \
|
||||||
test_wav_8bit.html \
|
test_wav_8bit.html \
|
||||||
test_wav_ended1.html \
|
test_wav_ended1.html \
|
||||||
test_progress2.html \
|
|
||||||
test_wav_seek3.html \
|
test_wav_seek3.html \
|
||||||
test_wav_seek4.html \
|
test_wav_seek4.html \
|
||||||
test_wav_seek5.html \
|
test_wav_seek5.html \
|
||||||
|
Binary file not shown.
@ -1,68 +0,0 @@
|
|||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Media test: progress events</title>
|
|
||||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<pre id="test">
|
|
||||||
<script class="testbody" type="text/javascript">
|
|
||||||
var completed = false;
|
|
||||||
var load_count = 0;
|
|
||||||
var last_progress = false;
|
|
||||||
|
|
||||||
function on_loadedmetadata() {
|
|
||||||
var v = document.getElementById('v');
|
|
||||||
ok(v, "Found video element after metadata loaded: " + v);
|
|
||||||
v.play();
|
|
||||||
dump('test_progress1: on_loadedmetadata exiting\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_progress(e) {
|
|
||||||
dump('test_progress1: do_progress ' + e.loaded + '\n');
|
|
||||||
ok(!completed, "Check for progress event after completed: " + completed);
|
|
||||||
ok(e.lengthComputable, "Check progress lengthComputable");
|
|
||||||
ok(e.loaded >= 0 && e.loaded <= e.total, "Check progress loaded: " + e.loaded);
|
|
||||||
ok(e.total == 285310, "Check progress total: " + e.total);
|
|
||||||
last_progress = e.loaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_ended() {
|
|
||||||
dump('test_progress1: do_ended\n');
|
|
||||||
ok(!completed, "Check for duplicate ended event");
|
|
||||||
completed = true;
|
|
||||||
ok(last_progress == 285310, "Last progress event size: " + last_progress);
|
|
||||||
SimpleTest.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_load(e) {
|
|
||||||
load_count++;
|
|
||||||
dump('test_progress1: do_loaded ' + e.loaded + "\n");
|
|
||||||
ok(load_count == 1, "load event raised: " + load_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_timeupdate() {
|
|
||||||
var v = document.getElementById('v');
|
|
||||||
dump('test_progress1: timeupdate: ' + v.currentTime + "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_play() {
|
|
||||||
dump('test_progress1: do_play\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
|
||||||
</script>
|
|
||||||
</pre>
|
|
||||||
<video id='v'
|
|
||||||
src='seek.ogg'
|
|
||||||
onloadedmetadata='on_loadedmetadata()'
|
|
||||||
onended='do_ended()'
|
|
||||||
ontimeupdate='do_timeupdate()'
|
|
||||||
onload='do_load(event)'
|
|
||||||
onplay='do_play()'
|
|
||||||
onprogress='do_progress(event)'>
|
|
||||||
</video>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,46 +0,0 @@
|
|||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Media test: progress events</title>
|
|
||||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<pre id="test">
|
|
||||||
<script class="testbody" type="text/javascript">
|
|
||||||
// Test progress events with wav backend
|
|
||||||
var completed = false;
|
|
||||||
var last_progress = false;
|
|
||||||
|
|
||||||
function on_loadedmetadata() {
|
|
||||||
var v = document.getElementById('v');
|
|
||||||
v.play();
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_progress(e) {
|
|
||||||
ok(!completed, "Check for progress event after completed: " + completed);
|
|
||||||
ok(e.lengthComputable, "Check progress lengthComputable");
|
|
||||||
ok(e.loaded >= 0 && e.loaded <= e.total, "Check progress loaded: " + e.loaded);
|
|
||||||
ok(e.total == 102444, "Check progress total: " + e.total);
|
|
||||||
last_progress = e.loaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_ended() {
|
|
||||||
ok(!completed, "Check for duplicate ended event");
|
|
||||||
completed = true;
|
|
||||||
ok(last_progress == 102444, "Last progress event size: " + last_progress);
|
|
||||||
SimpleTest.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
|
||||||
</script>
|
|
||||||
</pre>
|
|
||||||
<audio id='v'
|
|
||||||
src='big.wav'
|
|
||||||
onloadedmetadata='on_loadedmetadata()'
|
|
||||||
onended='do_ended()'
|
|
||||||
onprogress='do_progress(event)'>
|
|
||||||
</audio>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Loading…
Reference in New Issue
Block a user