From bb0873fa89f3b44036e08076885027f5cd033c7e Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Tue, 13 Jan 2015 08:48:01 +0100 Subject: [PATCH] Backed out changeset d9db938747d2 (bug 879717) for M-3 Test failures/timeouts on a CLOSED TREE --- dom/html/HTMLMediaElement.cpp | 118 ++++----------------- dom/html/HTMLMediaElement.h | 9 -- dom/media/test/test_streams_srcObject.html | 2 - 3 files changed, 20 insertions(+), 109 deletions(-) diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 9c9e9cba4a6..d8e012120a3 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -71,8 +71,6 @@ #include "mozilla/dom/MediaSource.h" #include "MediaMetadataManager.h" #include "MediaSourceDecoder.h" -#include "AudioStreamTrack.h" -#include "VideoStreamTrack.h" #include "AudioChannelService.h" @@ -673,10 +671,7 @@ void HTMLMediaElement::AbortExistingLoads() mHaveQueuedSelectResource = false; mSuspendedForPreloadNone = false; mDownloadSuspendedByCache = false; - mHasAudio = false; - mHasVideo = false; mSourcePointer = nullptr; - mLastNextFrameStatus = NEXT_FRAME_UNINITIALIZED; mTags = nullptr; @@ -907,30 +902,6 @@ void HTMLMediaElement::NotifyMediaTrackEnabled(MediaTrack* aTrack) } } -void HTMLMediaElement::NotifyMediaStreamTracksAvailable(DOMMediaStream* aStream) -{ - if (!mSrcStream || mSrcStream != aStream) { - return; - } - - bool oldHasVideo = mHasVideo; - - nsAutoTArray,1> audioTracks; - mSrcStream->GetAudioTracks(audioTracks); - nsAutoTArray,1> videoTracks; - mSrcStream->GetVideoTracks(videoTracks); - - mHasAudio = !audioTracks.IsEmpty(); - mHasVideo = !videoTracks.IsEmpty(); - - if (IsVideo() && oldHasVideo != mHasVideo) { - // We are a video element and mHasVideo changed so update the screen wakelock - NotifyOwnerDocumentActivityChanged(); - } - - UpdateReadyStateForData(mLastNextFrameStatus); -} - void HTMLMediaElement::LoadFromSourceChildren() { NS_ASSERTION(mDelayingLoadEvent, @@ -2016,7 +1987,6 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed& aNo mCurrentLoadID(0), mNetworkState(nsIDOMHTMLMediaElement::NETWORK_EMPTY), mReadyState(nsIDOMHTMLMediaElement::HAVE_NOTHING), - mLastNextFrameStatus(NEXT_FRAME_UNINITIALIZED), mLoadWaitStatus(NOT_WAITING), mVolume(1.0), mPreloadAction(PRELOAD_UNDEFINED), @@ -2853,25 +2823,6 @@ private: bool mPendingNotifyOutput; }; -class HTMLMediaElement::MediaStreamTracksAvailableCallback: - public DOMMediaStream::OnTracksAvailableCallback -{ -public: - explicit MediaStreamTracksAvailableCallback(HTMLMediaElement* aElement, - DOMMediaStream::TrackTypeHints aExpectedTracks = 0): - DOMMediaStream::OnTracksAvailableCallback(aExpectedTracks), - mElement(aElement) - {} - virtual void NotifyTracksAvailable(DOMMediaStream* aStream) - { - NS_ASSERTION(NS_IsMainThread(), "Should be on main thread."); - - mElement->NotifyMediaStreamTracksAvailable(aStream); - } -private: - HTMLMediaElement* mElement; -}; - void HTMLMediaElement::SetupSrcMediaStreamPlayback(DOMMediaStream* aStream) { NS_ASSERTION(!mSrcStream && !mSrcStreamListener, "Should have been ended already"); @@ -2893,26 +2844,22 @@ void HTMLMediaElement::SetupSrcMediaStreamPlayback(DOMMediaStream* aStream) if (mPausedForInactiveDocumentOrChannel) { GetSrcMediaStream()->ChangeExplicitBlockerCount(1); } - - mSrcStream->OnTracksAvailable(new MediaStreamTracksAvailableCallback(this, DOMMediaStream::HINT_CONTENTS_AUDIO)); - mSrcStream->OnTracksAvailable(new MediaStreamTracksAvailableCallback(this, DOMMediaStream::HINT_CONTENTS_VIDEO)); - - ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_IDLE); - ChangeDelayLoadStatus(false); GetSrcMediaStream()->AddAudioOutput(this); - SetVolumeInternal(); + GetSrcMediaStream()->SetAudioOutputVolume(this, float(mMuted ? 0.0 : mVolume)); VideoFrameContainer* container = GetVideoFrameContainer(); if (container) { GetSrcMediaStream()->AddVideoOutput(container); } - CheckAutoplayDataReady(); - // Note: we must call DisconnectTrackListListeners(...) before dropping // mSrcStream mSrcStream->ConstructMediaTracks(AudioTracks(), VideoTracks()); + ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA); + DispatchAsyncEvent(NS_LITERAL_STRING("durationchange")); + DispatchAsyncEvent(NS_LITERAL_STRING("loadedmetadata")); + ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_IDLE); // FirstFrameLoaded() will be called when the stream has current data. } @@ -2992,11 +2939,6 @@ void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo, } else { UpdateMediaSize(aInfo->mVideo.mDisplay); } - - if (IsVideo() && aInfo->HasVideo()) { - // We are a video element playing video so update the screen wakelock - NotifyOwnerDocumentActivityChanged(); - } } void HTMLMediaElement::FirstFrameLoaded() @@ -3261,47 +3203,18 @@ bool HTMLMediaElement::ShouldCheckAllowOrigin() void HTMLMediaElement::UpdateReadyStateForData(MediaDecoderOwner::NextFrameStatus aNextFrame) { - mLastNextFrameStatus = aNextFrame; - - if (mDecoder && mReadyState < nsIDOMHTMLMediaElement::HAVE_METADATA) { + if (mReadyState < nsIDOMHTMLMediaElement::HAVE_METADATA) { // aNextFrame might have a next frame because the decoder can advance // on its own thread before MetadataLoaded gets a chance to run. // The arrival of more data can't change us out of this readyState. return; } - if (mSrcStream && mReadyState < nsIDOMHTMLMediaElement::HAVE_METADATA) { - if ((!mHasAudio && !mHasVideo) || - (IsVideo() && mHasVideo && mMediaSize == nsIntSize(-1, -1))) { - return; - } - - // We are playing a stream that has video and a video frame is now set. - // This means we have all metadata needed to change ready state. - MediaInfo mediaInfo; - mediaInfo.mAudio.mHasAudio = mHasAudio; - mediaInfo.mVideo.mHasVideo = mHasVideo; - if (mHasVideo) { - mediaInfo.mVideo.mDisplay = mMediaSize; - } - MetadataLoaded(&mediaInfo, nsAutoPtr(nullptr)); - } - if (aNextFrame == MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_SEEKING) { ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA); return; } - if (IsVideo() && mHasVideo && !IsPlaybackEnded() && - GetImageContainer() && !GetImageContainer()->HasCurrentImage()) { - // Don't advance if we are playing video, but don't have a video frame. - // Also, if video became available after advancing to HAVE_CURRENT_DATA - // while we are still playing, we need to revert to HAVE_METADATA until - // a video frame is available. - ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA); - return; - } - if (mDownloadSuspendedByCache && mDecoder && !mDecoder->IsEnded()) { // The decoder has signaled that the download has been suspended by the // media cache. So move readyState into HAVE_ENOUGH_DATA, in case there's @@ -3452,14 +3365,14 @@ void HTMLMediaElement::ChangeNetworkState(nsMediaNetworkState aState) bool HTMLMediaElement::CanActivateAutoplay() { - // For stream inputs, we activate autoplay on HAVE_NOTHING because + // For stream inputs, we activate autoplay on HAVE_CURRENT_DATA because // this element itself might be blocking the stream from making progress by // being paused. return !mPausedForInactiveDocumentOrChannel && mAutoplaying && mPaused && ((mDecoder && mReadyState >= nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA) || - mSrcStream) && + (mSrcStream && mReadyState >= nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA)) && HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay) && mAutoplayEnabled && !IsEditable(); @@ -3488,14 +3401,24 @@ void HTMLMediaElement::CheckAutoplayDataReady() VideoFrameContainer* HTMLMediaElement::GetVideoFrameContainer() { - if (mVideoFrameContainer) - return mVideoFrameContainer; + // If we have loaded the metadata, and the size of the video is still + // (-1, -1), the media has no video. Don't go a create a video frame + // container. + if (mReadyState >= nsIDOMHTMLMediaElement::HAVE_METADATA && + mMediaSize == nsIntSize(-1, -1)) { + return nullptr; + } // Only video frames need an image container. if (!IsVideo()) { return nullptr; } + mHasVideo = true; + + if (mVideoFrameContainer) + return mVideoFrameContainer; + mVideoFrameContainer = new VideoFrameContainer(this, LayerManager::CreateAsynchronousImageContainer()); @@ -3610,7 +3533,6 @@ void HTMLMediaElement::NotifyDecoderPrincipalChanged() void HTMLMediaElement::UpdateMediaSize(nsIntSize size) { mMediaSize = size; - UpdateReadyStateForData(mLastNextFrameStatus); } void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendEvents) diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h index 61864b31202..4f5d6e08fbb 100644 --- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -281,11 +281,6 @@ public: void NotifyMediaTrackEnabled(MediaTrack* aTrack); - /** - * Called when tracks become available to the source media stream. - */ - void NotifyMediaStreamTracksAvailable(DOMMediaStream* aStream); - virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE; /** @@ -617,7 +612,6 @@ protected: virtual ~HTMLMediaElement(); class MediaLoadListener; - class MediaStreamTracksAvailableCallback; class StreamListener; virtual void GetItemValueText(nsAString& text) MOZ_OVERRIDE; @@ -1042,9 +1036,6 @@ protected: nsMediaNetworkState mNetworkState; nsMediaReadyState mReadyState; - // Last value passed from codec or stream source to UpdateReadyStateForData. - NextFrameStatus mLastNextFrameStatus; - enum LoadAlgorithmState { // No load algorithm instance is waiting for a source to be added to the // media in order to continue loading. diff --git a/dom/media/test/test_streams_srcObject.html b/dom/media/test/test_streams_srcObject.html index ed9c5866783..446c5466b41 100644 --- a/dom/media/test/test_streams_srcObject.html +++ b/dom/media/test/test_streams_srcObject.html @@ -45,8 +45,6 @@ function doTest() { } ++step; }); - a.play(); - b.play(); }