зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1573102 - Remove mGraph from HTMLMediaElement::OutputMediaStream and OutputStreamManager. r=karlt
Differential Revision: https://phabricator.services.mozilla.com/D43666 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5b70e980ff
Коммит
04f22f20a5
|
@ -3304,13 +3304,14 @@ already_AddRefed<DOMMediaStream> HTMLMediaElement::CaptureStreamInternal(
|
|||
MarkAsTainted();
|
||||
|
||||
// We don't support routing to a different graph.
|
||||
if (!mOutputStreams.IsEmpty() && aGraph != mOutputStreams[0].mGraph) {
|
||||
if (!mOutputStreams.IsEmpty() &&
|
||||
aGraph !=
|
||||
mOutputStreams[0].mGraphKeepAliveDummyStream->mStream->Graph()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
OutputMediaStream* out = mOutputStreams.AppendElement();
|
||||
nsPIDOMWindowInner* window = OwnerDoc()->GetInnerWindow();
|
||||
out->mGraph = static_cast<MediaStreamGraphImpl*>(aGraph);
|
||||
out->mGraphKeepAliveDummyStream =
|
||||
mOutputStreams.Length() == 1
|
||||
? MakeRefPtr<SharedDummyStream>(aGraph->CreateSourceStream())
|
||||
|
@ -3338,7 +3339,8 @@ already_AddRefed<DOMMediaStream> HTMLMediaElement::CaptureStreamInternal(
|
|||
|
||||
if (mDecoder) {
|
||||
out->mCapturingDecoder = true;
|
||||
mDecoder->AddOutputStream(out->mStream, out->mGraph);
|
||||
mDecoder->AddOutputStream(
|
||||
out->mStream, out->mGraphKeepAliveDummyStream->mStream->Graph());
|
||||
} else if (mSrcStream) {
|
||||
out->mCapturingMediaStream = true;
|
||||
}
|
||||
|
@ -4663,7 +4665,8 @@ nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder) {
|
|||
}
|
||||
|
||||
ms.mCapturingDecoder = true;
|
||||
aDecoder->AddOutputStream(ms.mStream, ms.mGraph);
|
||||
aDecoder->AddOutputStream(ms.mStream,
|
||||
ms.mGraphKeepAliveDummyStream->mStream->Graph());
|
||||
}
|
||||
|
||||
if (mMediaKeys) {
|
||||
|
|
|
@ -758,7 +758,6 @@ class HTMLMediaElement : public nsGenericHTMLElement,
|
|||
~OutputMediaStream();
|
||||
|
||||
RefPtr<DOMMediaStream> mStream;
|
||||
RefPtr<MediaStreamGraphImpl> mGraph;
|
||||
// Dummy stream to keep mGraph from shutting down when MediaDecoder shuts
|
||||
// down. Shared across all OutputMediaStreams as one stream is enough to
|
||||
// keep the graph alive.
|
||||
|
|
|
@ -239,7 +239,7 @@ RefPtr<GenericPromise> MediaDecoder::SetSink(AudioDeviceInfo* aSink) {
|
|||
}
|
||||
|
||||
void MediaDecoder::AddOutputStream(DOMMediaStream* aStream,
|
||||
MediaStreamGraphImpl* aGraph) {
|
||||
MediaStreamGraph* aGraph) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mDecoderStateMachine, "Must be called after Load().");
|
||||
AbstractThread::AutoEnter context(AbstractMainThread());
|
||||
|
|
|
@ -48,7 +48,7 @@ class VideoFrameContainer;
|
|||
class MediaFormatReader;
|
||||
class MediaDecoderStateMachine;
|
||||
struct MediaPlaybackEvent;
|
||||
class MediaStreamGraphImpl;
|
||||
class MediaStreamGraph;
|
||||
|
||||
enum class Visibility : uint8_t;
|
||||
|
||||
|
@ -176,7 +176,7 @@ class MediaDecoder : public DecoderDoctorLifeLogger<MediaDecoder> {
|
|||
// Add an output stream. All decoder output will be sent to the stream.
|
||||
// The stream is initially blocked. The decoder is responsible for unblocking
|
||||
// it while it is playing back.
|
||||
void AddOutputStream(DOMMediaStream* aStream, MediaStreamGraphImpl* aGraph);
|
||||
void AddOutputStream(DOMMediaStream* aStream, MediaStreamGraph* aGraph);
|
||||
// Remove an output stream added with AddOutputStream.
|
||||
void RemoveOutputStream(DOMMediaStream* aStream);
|
||||
|
||||
|
|
|
@ -3776,7 +3776,7 @@ void MediaDecoderStateMachine::RemoveOutputStream(DOMMediaStream* aStream) {
|
|||
}
|
||||
|
||||
void MediaDecoderStateMachine::EnsureOutputStreamManager(
|
||||
MediaStreamGraphImpl* aGraph) {
|
||||
MediaStreamGraph* aGraph) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (mOutputStreamManager) {
|
||||
return;
|
||||
|
|
|
@ -188,7 +188,7 @@ class MediaDecoderStateMachine
|
|||
|
||||
void SetOutputStreamPrincipal(nsIPrincipal* aPrincipal);
|
||||
// If an OutputStreamManager does not exist, one will be created.
|
||||
void EnsureOutputStreamManager(MediaStreamGraphImpl* aGraph);
|
||||
void EnsureOutputStreamManager(MediaStreamGraph* aGraph);
|
||||
// If an OutputStreamManager exists, tracks matching aLoadedInfo will be
|
||||
// created unless they already exist in the manager.
|
||||
void EnsureOutputStreamManagerHasTracks(const MediaInfo& aLoadedInfo);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "OutputStreamManager.h"
|
||||
|
||||
#include "DOMMediaStream.h"
|
||||
#include "../MediaStreamGraphImpl.h"
|
||||
#include "../MediaStreamGraph.h"
|
||||
#include "mozilla/dom/MediaStreamTrack.h"
|
||||
#include "mozilla/dom/AudioStreamTrack.h"
|
||||
#include "mozilla/dom/VideoStreamTrack.h"
|
||||
|
@ -157,16 +157,17 @@ void OutputStreamData::SetPrincipal(nsIPrincipal* aPrincipal) {
|
|||
}
|
||||
}
|
||||
|
||||
OutputStreamManager::OutputStreamManager(MediaStreamGraphImpl* aGraph,
|
||||
OutputStreamManager::OutputStreamManager(MediaStreamGraph* aGraph,
|
||||
nsIPrincipal* aPrincipal,
|
||||
AbstractThread* aAbstractMainThread)
|
||||
: mAbstractMainThread(aAbstractMainThread),
|
||||
mGraph(aGraph),
|
||||
mDummyStream(aGraph->CreateSourceStream()),
|
||||
mPrincipalHandle(
|
||||
aAbstractMainThread,
|
||||
aPrincipal ? MakePrincipalHandle(aPrincipal) : PRINCIPAL_HANDLE_NONE,
|
||||
"OutputStreamManager::mPrincipalHandle (Canonical)") {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mDummyStream->Suspend();
|
||||
}
|
||||
|
||||
void OutputStreamManager::Add(DOMMediaStream* aDOMStream) {
|
||||
|
@ -248,7 +249,8 @@ already_AddRefed<SourceMediaStream> OutputStreamManager::AddTrack(
|
|||
MOZ_ASSERT(!HasTrackType(aType),
|
||||
"Cannot have two tracks of the same type at the same time");
|
||||
|
||||
RefPtr<SourceMediaStream> stream = mGraph->CreateSourceStream();
|
||||
RefPtr<SourceMediaStream> stream =
|
||||
mDummyStream->Graph()->CreateSourceStream();
|
||||
if (!mPlaying) {
|
||||
stream->Suspend();
|
||||
}
|
||||
|
@ -346,7 +348,7 @@ void OutputStreamManager::SetPlaying(bool aPlaying) {
|
|||
}
|
||||
}
|
||||
|
||||
OutputStreamManager::~OutputStreamManager() = default;
|
||||
OutputStreamManager::~OutputStreamManager() { mDummyStream->Destroy(); }
|
||||
|
||||
#undef LOG
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ class OutputStreamManager {
|
|||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(OutputStreamManager);
|
||||
|
||||
public:
|
||||
OutputStreamManager(MediaStreamGraphImpl* aGraph, nsIPrincipal* aPrincipal,
|
||||
OutputStreamManager(MediaStreamGraph* aGraph, nsIPrincipal* aPrincipal,
|
||||
AbstractThread* aAbstractMainThread);
|
||||
// Add the output stream to the collection.
|
||||
void Add(DOMMediaStream* aDOMStream);
|
||||
|
@ -153,7 +153,7 @@ class OutputStreamManager {
|
|||
// Remove tracks sourced from aStream from all output streams.
|
||||
void RemoveTrack(SourceMediaStream* aStream);
|
||||
|
||||
const RefPtr<MediaStreamGraphImpl> mGraph;
|
||||
const RefPtr<SourceMediaStream> mDummyStream;
|
||||
nsTArray<UniquePtr<OutputStreamData>> mStreams;
|
||||
nsTArray<UniquePtr<LiveTrack>> mLiveTracks;
|
||||
Canonical<PrincipalHandle> mPrincipalHandle;
|
||||
|
|
Загрузка…
Ссылка в новой задаче