mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1058452 - Use FakeMediaStreamGraph r=mikeh
This commit is contained in:
parent
cb658776f3
commit
33dd24cf72
@ -1188,7 +1188,7 @@ public:
|
||||
* Should only be called during MediaStreamListener callbacks or during
|
||||
* ProcessedMediaStream::ProcessInput().
|
||||
*/
|
||||
void DispatchToMainThreadAfterStreamStateUpdate(already_AddRefed<nsIRunnable> aRunnable)
|
||||
virtual void DispatchToMainThreadAfterStreamStateUpdate(already_AddRefed<nsIRunnable> aRunnable)
|
||||
{
|
||||
*mPendingUpdateRunnables.AppendElement() = aRunnable;
|
||||
}
|
||||
|
@ -19,6 +19,13 @@ using namespace mozilla::dom;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
void
|
||||
FakeMediaStreamGraph::DispatchToMainThreadAfterStreamStateUpdate(already_AddRefed<nsIRunnable> aRunnable)
|
||||
{
|
||||
nsRefPtr<nsIRunnable> task = aRunnable;
|
||||
NS_DispatchToMainThread(task);
|
||||
}
|
||||
|
||||
CameraPreviewMediaStream::CameraPreviewMediaStream(DOMMediaStream* aWrapper)
|
||||
: MediaStream(aWrapper)
|
||||
, mMutex("mozilla::camera::CameraPreviewMediaStream")
|
||||
@ -26,7 +33,7 @@ CameraPreviewMediaStream::CameraPreviewMediaStream(DOMMediaStream* aWrapper)
|
||||
, mDiscardedFrames(0)
|
||||
, mRateLimit(false)
|
||||
{
|
||||
SetGraphImpl(MediaStreamGraph::GetInstance());
|
||||
mFakeMediaStreamGraph = new FakeMediaStreamGraph();
|
||||
mIsConsumed = false;
|
||||
}
|
||||
|
||||
@ -55,11 +62,10 @@ CameraPreviewMediaStream::AddVideoOutput(VideoFrameContainer* aContainer)
|
||||
if (mVideoOutputs.Length() > 1) {
|
||||
return;
|
||||
}
|
||||
MediaStreamGraph* gm = MediaStreamGraph::GetInstance();
|
||||
mIsConsumed = true;
|
||||
for (uint32_t j = 0; j < mListeners.Length(); ++j) {
|
||||
MediaStreamListener* l = mListeners[j];
|
||||
l->NotifyConsumptionChanged(gm, MediaStreamListener::CONSUMED);
|
||||
l->NotifyConsumptionChanged(mFakeMediaStreamGraph, MediaStreamListener::CONSUMED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,11 +78,10 @@ CameraPreviewMediaStream::RemoveVideoOutput(VideoFrameContainer* aContainer)
|
||||
if (!mVideoOutputs.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
MediaStreamGraph* gm = MediaStreamGraph::GetInstance();
|
||||
mIsConsumed = false;
|
||||
for (uint32_t j = 0; j < mListeners.Length(); ++j) {
|
||||
MediaStreamListener* l = mListeners[j];
|
||||
l->NotifyConsumptionChanged(gm, MediaStreamListener::NOT_CONSUMED);
|
||||
l->NotifyConsumptionChanged(mFakeMediaStreamGraph, MediaStreamListener::NOT_CONSUMED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,9 +95,9 @@ CameraPreviewMediaStream::AddListener(MediaStreamListener* aListener)
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
MediaStreamGraph* gm = MediaStreamGraph::GetInstance();
|
||||
MediaStreamListener* listener = *mListeners.AppendElement() = aListener;
|
||||
listener->NotifyBlockingChanged(gm, MediaStreamListener::UNBLOCKED);
|
||||
listener->NotifyBlockingChanged(mFakeMediaStreamGraph, MediaStreamListener::UNBLOCKED);
|
||||
listener->NotifyHasCurrentData(mFakeMediaStreamGraph);
|
||||
}
|
||||
|
||||
void
|
||||
@ -100,10 +105,9 @@ CameraPreviewMediaStream::RemoveListener(MediaStreamListener* aListener)
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
MediaStreamGraph* gm = MediaStreamGraph::GetInstance();
|
||||
nsRefPtr<MediaStreamListener> listener(aListener);
|
||||
mListeners.RemoveElement(aListener);
|
||||
listener->NotifyEvent(gm, MediaStreamListener::EVENT_REMOVED);
|
||||
listener->NotifyEvent(mFakeMediaStreamGraph, MediaStreamListener::EVENT_REMOVED);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -11,6 +11,23 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class FakeMediaStreamGraph : public MediaStreamGraph
|
||||
{
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FakeMediaStreamGraph)
|
||||
public:
|
||||
FakeMediaStreamGraph()
|
||||
: MediaStreamGraph()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void
|
||||
DispatchToMainThreadAfterStreamStateUpdate(already_AddRefed<nsIRunnable> aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
~FakeMediaStreamGraph()
|
||||
{}
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a stream for camera preview.
|
||||
*
|
||||
@ -50,6 +67,7 @@ protected:
|
||||
int32_t mInvalidatePending;
|
||||
uint32_t mDiscardedFrames;
|
||||
bool mRateLimit;
|
||||
nsRefPtr<FakeMediaStreamGraph> mFakeMediaStreamGraph;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user