diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp
index 4e83bbc5eca1..a159bc1c7abd 100644
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -3304,13 +3304,14 @@ already_AddRefed 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(aGraph);
out->mGraphKeepAliveDummyStream =
mOutputStreams.Length() == 1
? MakeRefPtr(aGraph->CreateSourceStream())
@@ -3338,7 +3339,8 @@ already_AddRefed 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) {
diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h
index e75b653c1205..685c61664973 100644
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -758,7 +758,6 @@ class HTMLMediaElement : public nsGenericHTMLElement,
~OutputMediaStream();
RefPtr mStream;
- RefPtr 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.
diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp
index 8e3b52c05b80..6954180b3912 100644
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -239,7 +239,7 @@ RefPtr 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());
diff --git a/dom/media/MediaDecoder.h b/dom/media/MediaDecoder.h
index d5f2c2fa4753..95e024bc75ee 100644
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -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 {
// 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);
diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp
index 4213bd98bb5c..5ddef2d5d830 100644
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -3776,7 +3776,7 @@ void MediaDecoderStateMachine::RemoveOutputStream(DOMMediaStream* aStream) {
}
void MediaDecoderStateMachine::EnsureOutputStreamManager(
- MediaStreamGraphImpl* aGraph) {
+ MediaStreamGraph* aGraph) {
MOZ_ASSERT(NS_IsMainThread());
if (mOutputStreamManager) {
return;
diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h
index 4c03e3e82705..22707742cebe 100644
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -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);
diff --git a/dom/media/mediasink/OutputStreamManager.cpp b/dom/media/mediasink/OutputStreamManager.cpp
index c765b220c7a0..86dbbeaabef7 100644
--- a/dom/media/mediasink/OutputStreamManager.cpp
+++ b/dom/media/mediasink/OutputStreamManager.cpp
@@ -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 OutputStreamManager::AddTrack(
MOZ_ASSERT(!HasTrackType(aType),
"Cannot have two tracks of the same type at the same time");
- RefPtr stream = mGraph->CreateSourceStream();
+ RefPtr 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
diff --git a/dom/media/mediasink/OutputStreamManager.h b/dom/media/mediasink/OutputStreamManager.h
index eb93af5ddd46..d5fed9962a36 100644
--- a/dom/media/mediasink/OutputStreamManager.h
+++ b/dom/media/mediasink/OutputStreamManager.h
@@ -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 mGraph;
+ const RefPtr mDummyStream;
nsTArray> mStreams;
nsTArray> mLiveTracks;
Canonical mPrincipalHandle;