зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1077274: Clean up tracklists r=jib
This commit is contained in:
Родитель
c0f03905c5
Коммит
8046f925d7
|
@ -2843,6 +2843,8 @@ void HTMLMediaElement::SetupSrcMediaStreamPlayback(DOMMediaStream* aStream)
|
|||
GetSrcMediaStream()->AddVideoOutput(container);
|
||||
}
|
||||
|
||||
// Note: we must call DisconnectTrackListListeners(...) before dropping
|
||||
// mSrcStream
|
||||
mSrcStream->ConstructMediaTracks(AudioTracks(), VideoTracks());
|
||||
|
||||
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA);
|
||||
|
@ -2859,6 +2861,8 @@ void HTMLMediaElement::EndSrcMediaStreamPlayback()
|
|||
if (stream) {
|
||||
stream->RemoveListener(mSrcStreamListener);
|
||||
}
|
||||
mSrcStream->DisconnectTrackListListeners(AudioTracks(), VideoTracks());
|
||||
|
||||
// Kill its reference to this element
|
||||
mSrcStreamListener->Forget();
|
||||
mSrcStreamListener = nullptr;
|
||||
|
|
|
@ -452,6 +452,19 @@ DOMMediaStream::ConstructMediaTracks(AudioTrackList* aAudioTrackList,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
DOMMediaStream::DisconnectTrackListListeners(const AudioTrackList* aAudioTrackList,
|
||||
const VideoTrackList* aVideoTrackList)
|
||||
{
|
||||
for (auto i = mMediaTrackListListeners.Length(); i > 0; ) { // unsigned!
|
||||
--i; // 0 ... Length()-1 range
|
||||
if (mMediaTrackListListeners[i].mMediaTrackList == aAudioTrackList ||
|
||||
mMediaTrackListListeners[i].mMediaTrackList == aVideoTrackList) {
|
||||
mMediaTrackListListeners.RemoveElementAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DOMMediaStream::NotifyMediaStreamTrackCreated(MediaStreamTrack* aTrack)
|
||||
{
|
||||
|
|
|
@ -242,6 +242,12 @@ public:
|
|||
void ConstructMediaTracks(AudioTrackList* aAudioTrackList,
|
||||
VideoTrackList* aVideoTrackList);
|
||||
|
||||
/**
|
||||
* MUST call this before the AudioTrackList or VideoTrackList go away
|
||||
*/
|
||||
void DisconnectTrackListListeners(const AudioTrackList* aAudioTrackList,
|
||||
const VideoTrackList* aVideoTrackList);
|
||||
|
||||
virtual void NotifyMediaStreamTrackCreated(MediaStreamTrack* aTrack);
|
||||
|
||||
virtual void NotifyMediaStreamTrackEnded(MediaStreamTrack* aTrack);
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
|
||||
namespace mozilla {
|
||||
class DOMMediaStream;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class HTMLMediaElement;
|
||||
|
@ -28,6 +30,8 @@ class MediaTrackList;
|
|||
class MediaTrackListListener
|
||||
{
|
||||
public:
|
||||
friend class mozilla::DOMMediaStream;
|
||||
|
||||
explicit MediaTrackListListener(MediaTrackList* aMediaTrackList)
|
||||
: mMediaTrackList(aMediaTrackList) {};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче