Bug 810177 - Part 1: Move NextFrameStatus to nsMediaDecoder; r=cpearce

This patch simply moves the NextFrameStatus enum to nsMediaDecoder and
reorganizes things so that they compile again.
This commit is contained in:
Ehsan Akhgari 2012-11-08 18:22:32 -05:00
parent 1f30634052
commit 4920cf0e6a
6 changed files with 29 additions and 26 deletions

View File

@ -216,16 +216,7 @@ public:
// the data for the next frame is available. This method will
// decide whether to set the ready state to HAVE_CURRENT_DATA,
// HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA.
enum NextFrameStatus {
// The next frame of audio/video is available
NEXT_FRAME_AVAILABLE,
// The next frame of audio/video is unavailable because the decoder
// is paused while it buffers up data
NEXT_FRAME_UNAVAILABLE_BUFFERING,
// The next frame of audio/video is unavailable for some other reasons
NEXT_FRAME_UNAVAILABLE
};
void UpdateReadyStateForData(NextFrameStatus aNextFrame);
void UpdateReadyStateForData(nsMediaDecoder::NextFrameStatus aNextFrame);
// Use this method to change the mReadyState member, so required
// events can be fired.

View File

@ -2692,7 +2692,8 @@ public:
{
if (mElement && mHaveCurrentData) {
mElement->UpdateReadyStateForData(
mBlocked ? NEXT_FRAME_UNAVAILABLE_BUFFERING : NEXT_FRAME_AVAILABLE);
mBlocked ? nsMediaDecoder::NEXT_FRAME_UNAVAILABLE_BUFFERING :
nsMediaDecoder::NEXT_FRAME_AVAILABLE);
}
}
void DoNotifyBlocked()
@ -3095,7 +3096,7 @@ bool nsHTMLMediaElement::ShouldCheckAllowOrigin()
return mCORSMode != CORS_NONE;
}
void nsHTMLMediaElement::UpdateReadyStateForData(NextFrameStatus aNextFrame)
void nsHTMLMediaElement::UpdateReadyStateForData(nsMediaDecoder::NextFrameStatus aNextFrame)
{
if (mReadyState < nsIDOMHTMLMediaElement::HAVE_METADATA) {
// aNextFrame might have a next frame because the decoder can advance
@ -3120,9 +3121,9 @@ void nsHTMLMediaElement::UpdateReadyStateForData(NextFrameStatus aNextFrame)
return;
}
if (aNextFrame != NEXT_FRAME_AVAILABLE) {
if (aNextFrame != nsMediaDecoder::NEXT_FRAME_AVAILABLE) {
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA);
if (!mWaitingFired && aNextFrame == NEXT_FRAME_UNAVAILABLE_BUFFERING) {
if (!mWaitingFired && aNextFrame == nsMediaDecoder::NEXT_FRAME_UNAVAILABLE_BUFFERING) {
FireTimeUpdate(false);
DispatchAsyncEvent(NS_LITERAL_STRING("waiting"));
mWaitingFired = true;

View File

@ -878,7 +878,7 @@ void nsBuiltinDecoder::NextFrameUnavailableBuffering()
if (!mElement || mShuttingDown || !mDecoderStateMachine)
return;
mElement->UpdateReadyStateForData(nsHTMLMediaElement::NEXT_FRAME_UNAVAILABLE_BUFFERING);
mElement->UpdateReadyStateForData(nsMediaDecoder::NEXT_FRAME_UNAVAILABLE_BUFFERING);
}
void nsBuiltinDecoder::NextFrameAvailable()
@ -887,7 +887,7 @@ void nsBuiltinDecoder::NextFrameAvailable()
if (!mElement || mShuttingDown || !mDecoderStateMachine)
return;
mElement->UpdateReadyStateForData(nsHTMLMediaElement::NEXT_FRAME_AVAILABLE);
mElement->UpdateReadyStateForData(nsMediaDecoder::NEXT_FRAME_AVAILABLE);
}
void nsBuiltinDecoder::NextFrameUnavailable()
@ -895,7 +895,7 @@ void nsBuiltinDecoder::NextFrameUnavailable()
NS_ASSERTION(NS_IsMainThread(), "Should be called on main thread");
if (!mElement || mShuttingDown || !mDecoderStateMachine)
return;
mElement->UpdateReadyStateForData(nsHTMLMediaElement::NEXT_FRAME_UNAVAILABLE);
mElement->UpdateReadyStateForData(nsMediaDecoder::NEXT_FRAME_UNAVAILABLE);
}
void nsBuiltinDecoder::UpdateReadyStateForData()
@ -903,7 +903,7 @@ void nsBuiltinDecoder::UpdateReadyStateForData()
NS_ASSERTION(NS_IsMainThread(), "Should be called on main thread");
if (!mElement || mShuttingDown || !mDecoderStateMachine)
return;
nsHTMLMediaElement::NextFrameStatus frameStatus =
NextFrameStatus frameStatus =
mDecoderStateMachine->GetNextFrameStatus();
mElement->UpdateReadyStateForData(frameStatus);
}

View File

@ -1308,15 +1308,15 @@ void nsBuiltinDecoderStateMachine::ClearPositionChangeFlag()
mPositionChangeQueued = false;
}
nsHTMLMediaElement::NextFrameStatus nsBuiltinDecoderStateMachine::GetNextFrameStatus()
nsMediaDecoder::NextFrameStatus nsBuiltinDecoderStateMachine::GetNextFrameStatus()
{
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
if (IsBuffering() || IsSeeking()) {
return nsHTMLMediaElement::NEXT_FRAME_UNAVAILABLE_BUFFERING;
return nsMediaDecoder::NEXT_FRAME_UNAVAILABLE_BUFFERING;
} else if (HaveNextFrameData()) {
return nsHTMLMediaElement::NEXT_FRAME_AVAILABLE;
return nsMediaDecoder::NEXT_FRAME_AVAILABLE;
}
return nsHTMLMediaElement::NEXT_FRAME_UNAVAILABLE;
return nsMediaDecoder::NEXT_FRAME_UNAVAILABLE;
}
void nsBuiltinDecoderStateMachine::SetVolume(double volume)
@ -2389,13 +2389,13 @@ void nsBuiltinDecoderStateMachine::UpdateReadyState() {
nsCOMPtr<nsIRunnable> event;
switch (GetNextFrameStatus()) {
case nsHTMLMediaElement::NEXT_FRAME_UNAVAILABLE_BUFFERING:
case nsMediaDecoder::NEXT_FRAME_UNAVAILABLE_BUFFERING:
event = NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::NextFrameUnavailableBuffering);
break;
case nsHTMLMediaElement::NEXT_FRAME_AVAILABLE:
case nsMediaDecoder::NEXT_FRAME_AVAILABLE:
event = NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::NextFrameAvailable);
break;
case nsHTMLMediaElement::NEXT_FRAME_UNAVAILABLE:
case nsMediaDecoder::NEXT_FRAME_UNAVAILABLE:
event = NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::NextFrameUnavailable);
break;
default:

View File

@ -165,7 +165,7 @@ public:
return IsCurrentThread(mAudioThread);
}
nsHTMLMediaElement::NextFrameStatus GetNextFrameStatus();
nsMediaDecoder::NextFrameStatus GetNextFrameStatus();
// Cause state transitions. These methods obtain the decoder monitor
// to synchronise the change of state, and to notify other threads

View File

@ -387,6 +387,17 @@ public:
return mVideoFrameContainer ? mVideoFrameContainer->GetImageContainer() : nullptr;
}
// The status of the next frame which might be available from the decoder
enum NextFrameStatus {
// The next frame of audio/video is available
NEXT_FRAME_AVAILABLE,
// The next frame of audio/video is unavailable because the decoder
// is paused while it buffers up data
NEXT_FRAME_UNAVAILABLE_BUFFERING,
// The next frame of audio/video is unavailable for some other reasons
NEXT_FRAME_UNAVAILABLE
};
protected:
// Start timer to update download progress information.