diff options
Diffstat (limited to 'dom/html/HTMLMediaElement.cpp')
-rw-r--r-- | dom/html/HTMLMediaElement.cpp | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 4ea52ccdf6..877f3ec3ba 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -454,7 +454,7 @@ class HTMLMediaElement::MediaControlKeyListener final void HandleMediaKey(MediaControlKey aKey) override { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(IsStarted()); - MEDIACONTROL_LOG("HandleEvent '%s'", ToMediaControlKeyStr(aKey)); + MEDIACONTROL_LOG("HandleEvent '%s'", GetEnumString(aKey).get()); if (aKey == MediaControlKey::Play) { Owner()->Play(); } else if (aKey == MediaControlKey::Pause) { @@ -565,6 +565,10 @@ class HTMLMediaElement::MediaStreamTrackListener explicit MediaStreamTrackListener(HTMLMediaElement* aElement) : mElement(aElement) {} + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaStreamTrackListener, + DOMMediaStream::TrackListener) + void NotifyTrackAdded(const RefPtr<MediaStreamTrack>& aTrack) override { if (!mElement) { return; @@ -678,16 +682,26 @@ class HTMLMediaElement::MediaStreamTrackListener } protected: - const WeakPtr<HTMLMediaElement> mElement; + virtual ~MediaStreamTrackListener() = default; + RefPtr<HTMLMediaElement> mElement; }; +NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLMediaElement::MediaStreamTrackListener, + DOMMediaStream::TrackListener, mElement) +NS_IMPL_ADDREF_INHERITED(HTMLMediaElement::MediaStreamTrackListener, + DOMMediaStream::TrackListener) +NS_IMPL_RELEASE_INHERITED(HTMLMediaElement::MediaStreamTrackListener, + DOMMediaStream::TrackListener) +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION( + HTMLMediaElement::MediaStreamTrackListener) +NS_INTERFACE_MAP_END_INHERITING(DOMMediaStream::TrackListener) + /** * Helper class that manages audio and video outputs for all enabled tracks in a * media element. It also manages calculating the current time when playing a * MediaStream. */ -class HTMLMediaElement::MediaStreamRenderer - : public DOMMediaStream::TrackListener { +class HTMLMediaElement::MediaStreamRenderer { public: NS_INLINE_DECL_REFCOUNTING(MediaStreamRenderer) @@ -1973,6 +1987,7 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLMediaElement) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLMediaElement, nsGenericHTMLElement) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStreamWindowCapturer) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaSource) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSrcMediaSource) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSrcStream) @@ -1988,6 +2003,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLMediaElement, NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTextTrackManager) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAudioTrackList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVideoTrackList) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaStreamTrackListener) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaKeys) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIncomingMediaKeys) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSelectedVideoStreamTrack) @@ -2022,6 +2038,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLMediaElement, tmp->mMediaStreamTrackListener.get()); } } + NS_IMPL_CYCLE_COLLECTION_UNLINK(mStreamWindowCapturer) NS_IMPL_CYCLE_COLLECTION_UNLINK(mSrcStream) NS_IMPL_CYCLE_COLLECTION_UNLINK(mSrcAttrStream) NS_IMPL_CYCLE_COLLECTION_UNLINK(mMediaSource) @@ -2040,6 +2057,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLMediaElement, NS_IMPL_CYCLE_COLLECTION_UNLINK(mTextTrackManager) NS_IMPL_CYCLE_COLLECTION_UNLINK(mAudioTrackList) NS_IMPL_CYCLE_COLLECTION_UNLINK(mVideoTrackList) + NS_IMPL_CYCLE_COLLECTION_UNLINK(mMediaStreamTrackListener) NS_IMPL_CYCLE_COLLECTION_UNLINK(mMediaKeys) NS_IMPL_CYCLE_COLLECTION_UNLINK(mIncomingMediaKeys) NS_IMPL_CYCLE_COLLECTION_UNLINK(mSelectedVideoStreamTrack) @@ -5270,7 +5288,7 @@ void HTMLMediaElement::SetupSrcMediaStreamPlayback(DOMMediaStream* aStream) { NotifyMediaStreamTrackAdded(track); } - mMediaStreamTrackListener = MakeUnique<MediaStreamTrackListener>(this); + mMediaStreamTrackListener = new MediaStreamTrackListener(this); mSrcStream->RegisterTrackListener(mMediaStreamTrackListener.get()); ChangeNetworkState(NETWORK_IDLE); @@ -7347,7 +7365,9 @@ void HTMLMediaElement::AudioCaptureTrackChange(bool aCapture) { CaptureStreamInternal(StreamCaptureBehavior::CONTINUE_WHEN_ENDED, StreamCaptureType::CAPTURE_AUDIO, mtg); mStreamWindowCapturer = - MakeUnique<MediaStreamWindowCapturer>(stream, window->WindowID()); + new MediaStreamWindowCapturer(stream, window->WindowID()); + mStreamWindowCapturer->mStream->RegisterTrackListener( + mStreamWindowCapturer); } else if (!aCapture && mStreamWindowCapturer) { for (size_t i = 0; i < mOutputStreams.Length(); i++) { if (mOutputStreams[i].mStream == mStreamWindowCapturer->mStream) { @@ -7361,6 +7381,9 @@ void HTMLMediaElement::AudioCaptureTrackChange(bool aCapture) { break; } } + + mStreamWindowCapturer->mStream->UnregisterTrackListener( + mStreamWindowCapturer); mStreamWindowCapturer = nullptr; if (mOutputStreams.IsEmpty()) { mTracksCaptured = nullptr; |