Bug 1289334 - HTMLMediaElement::ResetConnectionState() should shut down the decoder. r?cpearce
MozReview-Commit-ID: 7IZ2Y4Da7xZ
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -2603,16 +2603,19 @@ void
HTMLMediaElement::ResetConnectionState()
{
SetCurrentTime(0);
FireTimeUpdate(false);
DispatchAsyncEvent(NS_LITERAL_STRING("ended"));
ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_EMPTY);
ChangeDelayLoadStatus(false);
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_NOTHING);
+ if (mDecoder) {
+ ShutdownDecoder();
+ }
}
void
HTMLMediaElement::Play(ErrorResult& aRv)
{
nsresult rv = PlayInternal(nsContentUtils::IsCallerChrome());
if (NS_FAILED(rv)) {
aRv.Throw(rv);
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1020,24 +1020,18 @@ MediaDecoder::FinishDecoderSetup(MediaRe
return NS_OK;
}
void
MediaDecoder::ResetConnectionState()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!IsShutdown());
-
- // Notify the media element that connection gets lost.
mOwner->ResetConnectionState();
-
- // Since we have notified the media element the connection
- // lost event, the decoder will be reloaded when user tries
- // to play the Rtsp streaming next time.
- Shutdown();
+ MOZ_ASSERT(IsShutdown());
}
void
MediaDecoder::NetworkError()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!IsShutdown());
mOwner->NetworkError();
--- a/dom/media/MediaDecoderOwner.h
+++ b/dom/media/MediaDecoderOwner.h
@@ -129,18 +129,20 @@ public:
// Check if the decoder owner is hidden.
virtual bool IsHidden() const = 0;
// Called by the media decoder and the video frame to get the
// ImageContainer containing the video data.
virtual VideoFrameContainer* GetVideoFrameContainer() = 0;
- // Called by the media decoder object, on the main thread,
+ // Called by the decoder object, on the main thread,
// when the connection between Rtsp server and client gets lost.
+ // The decoder owner should call Shutdown() on the decoder and drop the
+ // reference to the decoder to prevent further calls into the decoder.
virtual void ResetConnectionState() = 0;
// Called by media decoder when the audible state changed
virtual void SetAudibleState(bool aAudible) = 0;
#ifdef MOZ_EME
// Dispatches a "encrypted" event to the HTMLMediaElement, with the
// provided init data. Actual dispatch may be delayed until HAVE_METADATA.