gecko-dev/dom/media/CanvasCaptureMediaStream.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

211 строки
6.2 KiB
C++
Исходник Обычный вид История

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "CanvasCaptureMediaStream.h"
#include "DOMMediaStream.h"
#include "ImageContainer.h"
Bug 1454998 - Rename streams to tracks. r=padenot,karlt,smaug This renames the following (in alphabetical order, non-exhaustive): AudioCaptureStream -> AudioCaptureTrack AudioNodeStream -> AudioNodeTrack AudioNodeExternalInputStream -> AudioNodeExternalInputTrack DirectMediaStreamTrackListener -> DirectMediaTrackListener MediaStream -> MediaTrack - Note that there's also dom::MediaTrack. Namespaces differentiate them. MediaStreamGraph -> MediaTrackGraph MediaStreamTrackListener -> MediaTrackListener MSG -> MTG (in comments) ProcessedMediaStream -> ProcessedMediaTrack SharedDummyStream -> SharedDummyTrack SourceMediaStream -> SourceMediaTrack StreamTime -> TrackTime TrackUnionStream -> ForwardedInputTrack - Because this no longer takes a union of anything, but only a single track as input. Other minor classes, members and comments have been updated to reflect these name changes. Differential Revision: https://phabricator.services.mozilla.com/D46146 --HG-- rename : dom/media/AudioCaptureStream.cpp => dom/media/AudioCaptureTrack.cpp rename : dom/media/AudioCaptureStream.h => dom/media/AudioCaptureTrack.h rename : dom/media/TrackUnionStream.cpp => dom/media/ForwardedInputTrack.cpp rename : dom/media/TrackUnionStream.h => dom/media/ForwardedInputTrack.h rename : dom/media/MediaStreamGraph.cpp => dom/media/MediaTrackGraph.cpp rename : dom/media/MediaStreamGraph.h => dom/media/MediaTrackGraph.h rename : dom/media/MediaStreamGraphImpl.h => dom/media/MediaTrackGraphImpl.h rename : dom/media/MediaStreamListener.cpp => dom/media/MediaTrackListener.cpp rename : dom/media/MediaStreamListener.h => dom/media/MediaTrackListener.h rename : dom/media/webaudio/AudioNodeExternalInputStream.cpp => dom/media/webaudio/AudioNodeExternalInputTrack.cpp rename : dom/media/webaudio/AudioNodeExternalInputStream.h => dom/media/webaudio/AudioNodeExternalInputTrack.h rename : dom/media/webaudio/AudioNodeStream.cpp => dom/media/webaudio/AudioNodeTrack.cpp rename : dom/media/webaudio/AudioNodeStream.h => dom/media/webaudio/AudioNodeTrack.h extra : moz-landing-system : lando
2019-10-02 13:23:02 +03:00
#include "MediaTrackGraph.h"
Bug 1454998 - Remove the notion of streams from MediaStreamGraph. r=padenot,karlt This change mainly removes the `mTracks` member from MediaStream and moves all associated members up a level, so that a MediaStream in practice represents a single track. Classes will be renamed in a future patch to reflect this. Other changes include: The new `mEnded` member of MediaStream changes meaning to only become true when all data in the stream has been processed. It stems from StreamTracks::Track::mEnded which used to become true as soon as the last bit of data had been added to a track, and there could still be data in the track that would get processed in future iterations. We are moving towards not having any future data in tracks, which is why this change is ok to make -- keeping the old behavior will soon not make sense. TrackUnionStream is changed to no longer take a list of streams as input and forward the union of their tracks to itself. Instead it's limited to having one track as input at a time. The autofinishing functionality that TrackUnionStream had before has been transformed into an autoending functionality to allow it to defer ending until its been told that it's ok to end through the control API. This lets a single TrackUnionStream span the lifetime of multiple inputs, which will be useful for making DecodedStream spec compliant with HTMLMediaElement::CaptureStream(), and for implementing the currently discussed MediaRecorder::ReplaceTrack(), to name a few potential use cases. AudioNodeStreams used to only have a track (and thus an AudioSegment) if the EXTERNAL_OUTPUT flag was enabled on them. With all MediaStreams now representing a track, AudioNodeStreams inherently have an AudioSegment as a member. It is however only used with data if the EXTERNAL_OUTPUT flag is enabled. Differential Revision: https://phabricator.services.mozilla.com/D45821 --HG-- extra : moz-landing-system : lando
2019-10-02 13:22:53 +03:00
#include "Tracing.h"
#include "VideoSegment.h"
#include "gfxPlatform.h"
#include "mozilla/Atomics.h"
#include "mozilla/dom/CanvasCaptureMediaStreamBinding.h"
#include "mozilla/gfx/2D.h"
#include "nsContentUtils.h"
using namespace mozilla::layers;
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
Bug 1454998 - Rename streams to tracks. r=padenot,karlt,smaug This renames the following (in alphabetical order, non-exhaustive): AudioCaptureStream -> AudioCaptureTrack AudioNodeStream -> AudioNodeTrack AudioNodeExternalInputStream -> AudioNodeExternalInputTrack DirectMediaStreamTrackListener -> DirectMediaTrackListener MediaStream -> MediaTrack - Note that there's also dom::MediaTrack. Namespaces differentiate them. MediaStreamGraph -> MediaTrackGraph MediaStreamTrackListener -> MediaTrackListener MSG -> MTG (in comments) ProcessedMediaStream -> ProcessedMediaTrack SharedDummyStream -> SharedDummyTrack SourceMediaStream -> SourceMediaTrack StreamTime -> TrackTime TrackUnionStream -> ForwardedInputTrack - Because this no longer takes a union of anything, but only a single track as input. Other minor classes, members and comments have been updated to reflect these name changes. Differential Revision: https://phabricator.services.mozilla.com/D46146 --HG-- rename : dom/media/AudioCaptureStream.cpp => dom/media/AudioCaptureTrack.cpp rename : dom/media/AudioCaptureStream.h => dom/media/AudioCaptureTrack.h rename : dom/media/TrackUnionStream.cpp => dom/media/ForwardedInputTrack.cpp rename : dom/media/TrackUnionStream.h => dom/media/ForwardedInputTrack.h rename : dom/media/MediaStreamGraph.cpp => dom/media/MediaTrackGraph.cpp rename : dom/media/MediaStreamGraph.h => dom/media/MediaTrackGraph.h rename : dom/media/MediaStreamGraphImpl.h => dom/media/MediaTrackGraphImpl.h rename : dom/media/MediaStreamListener.cpp => dom/media/MediaTrackListener.cpp rename : dom/media/MediaStreamListener.h => dom/media/MediaTrackListener.h rename : dom/media/webaudio/AudioNodeExternalInputStream.cpp => dom/media/webaudio/AudioNodeExternalInputTrack.cpp rename : dom/media/webaudio/AudioNodeExternalInputStream.h => dom/media/webaudio/AudioNodeExternalInputTrack.h rename : dom/media/webaudio/AudioNodeStream.cpp => dom/media/webaudio/AudioNodeTrack.cpp rename : dom/media/webaudio/AudioNodeStream.h => dom/media/webaudio/AudioNodeTrack.h extra : moz-landing-system : lando
2019-10-02 13:23:02 +03:00
OutputStreamDriver::OutputStreamDriver(SourceMediaTrack* aSourceStream,
const PrincipalHandle& aPrincipalHandle)
: FrameCaptureListener(),
mSourceStream(aSourceStream),
mPrincipalHandle(aPrincipalHandle) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mSourceStream);
// All CanvasCaptureMediaStreams shall at least get one frame.
mFrameCaptureRequested = true;
}
OutputStreamDriver::~OutputStreamDriver() {
MOZ_ASSERT(NS_IsMainThread());
EndTrack();
}
void OutputStreamDriver::EndTrack() {
MOZ_ASSERT(NS_IsMainThread());
if (!mSourceStream->IsDestroyed()) {
mSourceStream->Destroy();
}
}
void OutputStreamDriver::SetImage(RefPtr<layers::Image>&& aImage,
const TimeStamp& aTime) {
MOZ_ASSERT(NS_IsMainThread());
Bug 1454998 - Rename streams to tracks. r=padenot,karlt,smaug This renames the following (in alphabetical order, non-exhaustive): AudioCaptureStream -> AudioCaptureTrack AudioNodeStream -> AudioNodeTrack AudioNodeExternalInputStream -> AudioNodeExternalInputTrack DirectMediaStreamTrackListener -> DirectMediaTrackListener MediaStream -> MediaTrack - Note that there's also dom::MediaTrack. Namespaces differentiate them. MediaStreamGraph -> MediaTrackGraph MediaStreamTrackListener -> MediaTrackListener MSG -> MTG (in comments) ProcessedMediaStream -> ProcessedMediaTrack SharedDummyStream -> SharedDummyTrack SourceMediaStream -> SourceMediaTrack StreamTime -> TrackTime TrackUnionStream -> ForwardedInputTrack - Because this no longer takes a union of anything, but only a single track as input. Other minor classes, members and comments have been updated to reflect these name changes. Differential Revision: https://phabricator.services.mozilla.com/D46146 --HG-- rename : dom/media/AudioCaptureStream.cpp => dom/media/AudioCaptureTrack.cpp rename : dom/media/AudioCaptureStream.h => dom/media/AudioCaptureTrack.h rename : dom/media/TrackUnionStream.cpp => dom/media/ForwardedInputTrack.cpp rename : dom/media/TrackUnionStream.h => dom/media/ForwardedInputTrack.h rename : dom/media/MediaStreamGraph.cpp => dom/media/MediaTrackGraph.cpp rename : dom/media/MediaStreamGraph.h => dom/media/MediaTrackGraph.h rename : dom/media/MediaStreamGraphImpl.h => dom/media/MediaTrackGraphImpl.h rename : dom/media/MediaStreamListener.cpp => dom/media/MediaTrackListener.cpp rename : dom/media/MediaStreamListener.h => dom/media/MediaTrackListener.h rename : dom/media/webaudio/AudioNodeExternalInputStream.cpp => dom/media/webaudio/AudioNodeExternalInputTrack.cpp rename : dom/media/webaudio/AudioNodeExternalInputStream.h => dom/media/webaudio/AudioNodeExternalInputTrack.h rename : dom/media/webaudio/AudioNodeStream.cpp => dom/media/webaudio/AudioNodeTrack.cpp rename : dom/media/webaudio/AudioNodeStream.h => dom/media/webaudio/AudioNodeTrack.h extra : moz-landing-system : lando
2019-10-02 13:23:02 +03:00
TRACE_COMMENT("SourceMediaTrack %p", mSourceStream.get());
VideoSegment segment;
const auto size = aImage->GetSize();
segment.AppendFrame(aImage.forget(), size, mPrincipalHandle, false, aTime);
Bug 1454998 - Remove the notion of streams from MediaStreamGraph. r=padenot,karlt This change mainly removes the `mTracks` member from MediaStream and moves all associated members up a level, so that a MediaStream in practice represents a single track. Classes will be renamed in a future patch to reflect this. Other changes include: The new `mEnded` member of MediaStream changes meaning to only become true when all data in the stream has been processed. It stems from StreamTracks::Track::mEnded which used to become true as soon as the last bit of data had been added to a track, and there could still be data in the track that would get processed in future iterations. We are moving towards not having any future data in tracks, which is why this change is ok to make -- keeping the old behavior will soon not make sense. TrackUnionStream is changed to no longer take a list of streams as input and forward the union of their tracks to itself. Instead it's limited to having one track as input at a time. The autofinishing functionality that TrackUnionStream had before has been transformed into an autoending functionality to allow it to defer ending until its been told that it's ok to end through the control API. This lets a single TrackUnionStream span the lifetime of multiple inputs, which will be useful for making DecodedStream spec compliant with HTMLMediaElement::CaptureStream(), and for implementing the currently discussed MediaRecorder::ReplaceTrack(), to name a few potential use cases. AudioNodeStreams used to only have a track (and thus an AudioSegment) if the EXTERNAL_OUTPUT flag was enabled on them. With all MediaStreams now representing a track, AudioNodeStreams inherently have an AudioSegment as a member. It is however only used with data if the EXTERNAL_OUTPUT flag is enabled. Differential Revision: https://phabricator.services.mozilla.com/D45821 --HG-- extra : moz-landing-system : lando
2019-10-02 13:22:53 +03:00
mSourceStream->AppendData(&segment);
}
// ----------------------------------------------------------------------
class TimerDriver : public OutputStreamDriver {
public:
Bug 1454998 - Rename streams to tracks. r=padenot,karlt,smaug This renames the following (in alphabetical order, non-exhaustive): AudioCaptureStream -> AudioCaptureTrack AudioNodeStream -> AudioNodeTrack AudioNodeExternalInputStream -> AudioNodeExternalInputTrack DirectMediaStreamTrackListener -> DirectMediaTrackListener MediaStream -> MediaTrack - Note that there's also dom::MediaTrack. Namespaces differentiate them. MediaStreamGraph -> MediaTrackGraph MediaStreamTrackListener -> MediaTrackListener MSG -> MTG (in comments) ProcessedMediaStream -> ProcessedMediaTrack SharedDummyStream -> SharedDummyTrack SourceMediaStream -> SourceMediaTrack StreamTime -> TrackTime TrackUnionStream -> ForwardedInputTrack - Because this no longer takes a union of anything, but only a single track as input. Other minor classes, members and comments have been updated to reflect these name changes. Differential Revision: https://phabricator.services.mozilla.com/D46146 --HG-- rename : dom/media/AudioCaptureStream.cpp => dom/media/AudioCaptureTrack.cpp rename : dom/media/AudioCaptureStream.h => dom/media/AudioCaptureTrack.h rename : dom/media/TrackUnionStream.cpp => dom/media/ForwardedInputTrack.cpp rename : dom/media/TrackUnionStream.h => dom/media/ForwardedInputTrack.h rename : dom/media/MediaStreamGraph.cpp => dom/media/MediaTrackGraph.cpp rename : dom/media/MediaStreamGraph.h => dom/media/MediaTrackGraph.h rename : dom/media/MediaStreamGraphImpl.h => dom/media/MediaTrackGraphImpl.h rename : dom/media/MediaStreamListener.cpp => dom/media/MediaTrackListener.cpp rename : dom/media/MediaStreamListener.h => dom/media/MediaTrackListener.h rename : dom/media/webaudio/AudioNodeExternalInputStream.cpp => dom/media/webaudio/AudioNodeExternalInputTrack.cpp rename : dom/media/webaudio/AudioNodeExternalInputStream.h => dom/media/webaudio/AudioNodeExternalInputTrack.h rename : dom/media/webaudio/AudioNodeStream.cpp => dom/media/webaudio/AudioNodeTrack.cpp rename : dom/media/webaudio/AudioNodeStream.h => dom/media/webaudio/AudioNodeTrack.h extra : moz-landing-system : lando
2019-10-02 13:23:02 +03:00
explicit TimerDriver(SourceMediaTrack* aSourceStream, const double& aFPS,
const PrincipalHandle& aPrincipalHandle)
Bug 1454998 - Remove the notion of streams from MediaStreamGraph. r=padenot,karlt This change mainly removes the `mTracks` member from MediaStream and moves all associated members up a level, so that a MediaStream in practice represents a single track. Classes will be renamed in a future patch to reflect this. Other changes include: The new `mEnded` member of MediaStream changes meaning to only become true when all data in the stream has been processed. It stems from StreamTracks::Track::mEnded which used to become true as soon as the last bit of data had been added to a track, and there could still be data in the track that would get processed in future iterations. We are moving towards not having any future data in tracks, which is why this change is ok to make -- keeping the old behavior will soon not make sense. TrackUnionStream is changed to no longer take a list of streams as input and forward the union of their tracks to itself. Instead it's limited to having one track as input at a time. The autofinishing functionality that TrackUnionStream had before has been transformed into an autoending functionality to allow it to defer ending until its been told that it's ok to end through the control API. This lets a single TrackUnionStream span the lifetime of multiple inputs, which will be useful for making DecodedStream spec compliant with HTMLMediaElement::CaptureStream(), and for implementing the currently discussed MediaRecorder::ReplaceTrack(), to name a few potential use cases. AudioNodeStreams used to only have a track (and thus an AudioSegment) if the EXTERNAL_OUTPUT flag was enabled on them. With all MediaStreams now representing a track, AudioNodeStreams inherently have an AudioSegment as a member. It is however only used with data if the EXTERNAL_OUTPUT flag is enabled. Differential Revision: https://phabricator.services.mozilla.com/D45821 --HG-- extra : moz-landing-system : lando
2019-10-02 13:22:53 +03:00
: OutputStreamDriver(aSourceStream, aPrincipalHandle),
mFPS(aFPS),
mTimer(nullptr) {
if (mFPS == 0.0) {
return;
}
NS_NewTimerWithFuncCallback(
getter_AddRefs(mTimer), &TimerTick, this, int(1000 / mFPS),
nsITimer::TYPE_REPEATING_SLACK, "dom::TimerDriver::TimerDriver");
}
static void TimerTick(nsITimer* aTimer, void* aClosure) {
MOZ_ASSERT(aClosure);
TimerDriver* driver = static_cast<TimerDriver*>(aClosure);
driver->RequestFrameCapture();
}
void NewFrame(already_AddRefed<Image> aImage,
const TimeStamp& aTime) override {
Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat The bulk of this commit was generated with a script, executed at the top level of a typical source code checkout. The only non-machine-generated part was modifying MFBT's moz.build to reflect the new naming. CLOSED TREE makes big refactorings like this a piece of cake. # The main substitution. find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ xargs perl -p -i -e ' s/nsRefPtr\.h/RefPtr\.h/g; # handle includes s/nsRefPtr ?</RefPtr</g; # handle declarations and variables ' # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h. perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h # Handle nsRefPtr.h itself, a couple places that define constructors # from nsRefPtr, and code generators specially. We do this here, rather # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename # things like nsRefPtrHashtable. perl -p -i -e 's/nsRefPtr/RefPtr/g' \ mfbt/nsRefPtr.h \ xpcom/glue/nsCOMPtr.h \ xpcom/base/OwningNonNull.h \ ipc/ipdl/ipdl/lower.py \ ipc/ipdl/ipdl/builtin.py \ dom/bindings/Codegen.py \ python/lldbutils/lldbutils/utils.py # In our indiscriminate substitution above, we renamed # nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up. find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \ xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g' if [ -d .git ]; then git mv mfbt/nsRefPtr.h mfbt/RefPtr.h else hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h fi --HG-- rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 08:24:48 +03:00
RefPtr<Image> image = aImage;
if (!mFrameCaptureRequested) {
return;
}
mFrameCaptureRequested = false;
SetImage(std::move(image), aTime);
}
void Forget() override {
if (mTimer) {
mTimer->Cancel();
mTimer = nullptr;
}
}
protected:
virtual ~TimerDriver() = default;
private:
const double mFPS;
nsCOMPtr<nsITimer> mTimer;
};
// ----------------------------------------------------------------------
class AutoDriver : public OutputStreamDriver {
public:
Bug 1454998 - Rename streams to tracks. r=padenot,karlt,smaug This renames the following (in alphabetical order, non-exhaustive): AudioCaptureStream -> AudioCaptureTrack AudioNodeStream -> AudioNodeTrack AudioNodeExternalInputStream -> AudioNodeExternalInputTrack DirectMediaStreamTrackListener -> DirectMediaTrackListener MediaStream -> MediaTrack - Note that there's also dom::MediaTrack. Namespaces differentiate them. MediaStreamGraph -> MediaTrackGraph MediaStreamTrackListener -> MediaTrackListener MSG -> MTG (in comments) ProcessedMediaStream -> ProcessedMediaTrack SharedDummyStream -> SharedDummyTrack SourceMediaStream -> SourceMediaTrack StreamTime -> TrackTime TrackUnionStream -> ForwardedInputTrack - Because this no longer takes a union of anything, but only a single track as input. Other minor classes, members and comments have been updated to reflect these name changes. Differential Revision: https://phabricator.services.mozilla.com/D46146 --HG-- rename : dom/media/AudioCaptureStream.cpp => dom/media/AudioCaptureTrack.cpp rename : dom/media/AudioCaptureStream.h => dom/media/AudioCaptureTrack.h rename : dom/media/TrackUnionStream.cpp => dom/media/ForwardedInputTrack.cpp rename : dom/media/TrackUnionStream.h => dom/media/ForwardedInputTrack.h rename : dom/media/MediaStreamGraph.cpp => dom/media/MediaTrackGraph.cpp rename : dom/media/MediaStreamGraph.h => dom/media/MediaTrackGraph.h rename : dom/media/MediaStreamGraphImpl.h => dom/media/MediaTrackGraphImpl.h rename : dom/media/MediaStreamListener.cpp => dom/media/MediaTrackListener.cpp rename : dom/media/MediaStreamListener.h => dom/media/MediaTrackListener.h rename : dom/media/webaudio/AudioNodeExternalInputStream.cpp => dom/media/webaudio/AudioNodeExternalInputTrack.cpp rename : dom/media/webaudio/AudioNodeExternalInputStream.h => dom/media/webaudio/AudioNodeExternalInputTrack.h rename : dom/media/webaudio/AudioNodeStream.cpp => dom/media/webaudio/AudioNodeTrack.cpp rename : dom/media/webaudio/AudioNodeStream.h => dom/media/webaudio/AudioNodeTrack.h extra : moz-landing-system : lando
2019-10-02 13:23:02 +03:00
explicit AutoDriver(SourceMediaTrack* aSourceStream,
const PrincipalHandle& aPrincipalHandle)
Bug 1454998 - Remove the notion of streams from MediaStreamGraph. r=padenot,karlt This change mainly removes the `mTracks` member from MediaStream and moves all associated members up a level, so that a MediaStream in practice represents a single track. Classes will be renamed in a future patch to reflect this. Other changes include: The new `mEnded` member of MediaStream changes meaning to only become true when all data in the stream has been processed. It stems from StreamTracks::Track::mEnded which used to become true as soon as the last bit of data had been added to a track, and there could still be data in the track that would get processed in future iterations. We are moving towards not having any future data in tracks, which is why this change is ok to make -- keeping the old behavior will soon not make sense. TrackUnionStream is changed to no longer take a list of streams as input and forward the union of their tracks to itself. Instead it's limited to having one track as input at a time. The autofinishing functionality that TrackUnionStream had before has been transformed into an autoending functionality to allow it to defer ending until its been told that it's ok to end through the control API. This lets a single TrackUnionStream span the lifetime of multiple inputs, which will be useful for making DecodedStream spec compliant with HTMLMediaElement::CaptureStream(), and for implementing the currently discussed MediaRecorder::ReplaceTrack(), to name a few potential use cases. AudioNodeStreams used to only have a track (and thus an AudioSegment) if the EXTERNAL_OUTPUT flag was enabled on them. With all MediaStreams now representing a track, AudioNodeStreams inherently have an AudioSegment as a member. It is however only used with data if the EXTERNAL_OUTPUT flag is enabled. Differential Revision: https://phabricator.services.mozilla.com/D45821 --HG-- extra : moz-landing-system : lando
2019-10-02 13:22:53 +03:00
: OutputStreamDriver(aSourceStream, aPrincipalHandle) {}
void NewFrame(already_AddRefed<Image> aImage,
const TimeStamp& aTime) override {
// Don't reset `mFrameCaptureRequested` since AutoDriver shall always have
// `mFrameCaptureRequested` set to true.
// This also means we should accept every frame as NewFrame is called only
// after something changed.
Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat The bulk of this commit was generated with a script, executed at the top level of a typical source code checkout. The only non-machine-generated part was modifying MFBT's moz.build to reflect the new naming. CLOSED TREE makes big refactorings like this a piece of cake. # The main substitution. find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ xargs perl -p -i -e ' s/nsRefPtr\.h/RefPtr\.h/g; # handle includes s/nsRefPtr ?</RefPtr</g; # handle declarations and variables ' # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h. perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h # Handle nsRefPtr.h itself, a couple places that define constructors # from nsRefPtr, and code generators specially. We do this here, rather # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename # things like nsRefPtrHashtable. perl -p -i -e 's/nsRefPtr/RefPtr/g' \ mfbt/nsRefPtr.h \ xpcom/glue/nsCOMPtr.h \ xpcom/base/OwningNonNull.h \ ipc/ipdl/ipdl/lower.py \ ipc/ipdl/ipdl/builtin.py \ dom/bindings/Codegen.py \ python/lldbutils/lldbutils/utils.py # In our indiscriminate substitution above, we renamed # nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up. find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \ xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g' if [ -d .git ]; then git mv mfbt/nsRefPtr.h mfbt/RefPtr.h else hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h fi --HG-- rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 08:24:48 +03:00
RefPtr<Image> image = aImage;
SetImage(std::move(image), aTime);
}
protected:
virtual ~AutoDriver() = default;
};
// ----------------------------------------------------------------------
NS_IMPL_CYCLE_COLLECTION_INHERITED(CanvasCaptureMediaStream, DOMMediaStream,
mCanvas)
NS_IMPL_ADDREF_INHERITED(CanvasCaptureMediaStream, DOMMediaStream)
NS_IMPL_RELEASE_INHERITED(CanvasCaptureMediaStream, DOMMediaStream)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CanvasCaptureMediaStream)
NS_INTERFACE_MAP_END_INHERITING(DOMMediaStream)
CanvasCaptureMediaStream::CanvasCaptureMediaStream(nsPIDOMWindowInner* aWindow,
HTMLCanvasElement* aCanvas)
: DOMMediaStream(aWindow), mCanvas(aCanvas) {}
CanvasCaptureMediaStream::~CanvasCaptureMediaStream() {
if (mOutputStreamDriver) {
mOutputStreamDriver->Forget();
}
}
JSObject* CanvasCaptureMediaStream::WrapObject(
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
return dom::CanvasCaptureMediaStream_Binding::Wrap(aCx, this, aGivenProto);
}
void CanvasCaptureMediaStream::RequestFrame() {
if (mOutputStreamDriver) {
mOutputStreamDriver->RequestFrameCapture();
}
}
nsresult CanvasCaptureMediaStream::Init(const dom::Optional<double>& aFPS,
nsIPrincipal* aPrincipal) {
Bug 1454998 - Rename streams to tracks. r=padenot,karlt,smaug This renames the following (in alphabetical order, non-exhaustive): AudioCaptureStream -> AudioCaptureTrack AudioNodeStream -> AudioNodeTrack AudioNodeExternalInputStream -> AudioNodeExternalInputTrack DirectMediaStreamTrackListener -> DirectMediaTrackListener MediaStream -> MediaTrack - Note that there's also dom::MediaTrack. Namespaces differentiate them. MediaStreamGraph -> MediaTrackGraph MediaStreamTrackListener -> MediaTrackListener MSG -> MTG (in comments) ProcessedMediaStream -> ProcessedMediaTrack SharedDummyStream -> SharedDummyTrack SourceMediaStream -> SourceMediaTrack StreamTime -> TrackTime TrackUnionStream -> ForwardedInputTrack - Because this no longer takes a union of anything, but only a single track as input. Other minor classes, members and comments have been updated to reflect these name changes. Differential Revision: https://phabricator.services.mozilla.com/D46146 --HG-- rename : dom/media/AudioCaptureStream.cpp => dom/media/AudioCaptureTrack.cpp rename : dom/media/AudioCaptureStream.h => dom/media/AudioCaptureTrack.h rename : dom/media/TrackUnionStream.cpp => dom/media/ForwardedInputTrack.cpp rename : dom/media/TrackUnionStream.h => dom/media/ForwardedInputTrack.h rename : dom/media/MediaStreamGraph.cpp => dom/media/MediaTrackGraph.cpp rename : dom/media/MediaStreamGraph.h => dom/media/MediaTrackGraph.h rename : dom/media/MediaStreamGraphImpl.h => dom/media/MediaTrackGraphImpl.h rename : dom/media/MediaStreamListener.cpp => dom/media/MediaTrackListener.cpp rename : dom/media/MediaStreamListener.h => dom/media/MediaTrackListener.h rename : dom/media/webaudio/AudioNodeExternalInputStream.cpp => dom/media/webaudio/AudioNodeExternalInputTrack.cpp rename : dom/media/webaudio/AudioNodeExternalInputStream.h => dom/media/webaudio/AudioNodeExternalInputTrack.h rename : dom/media/webaudio/AudioNodeStream.cpp => dom/media/webaudio/AudioNodeTrack.cpp rename : dom/media/webaudio/AudioNodeStream.h => dom/media/webaudio/AudioNodeTrack.h extra : moz-landing-system : lando
2019-10-02 13:23:02 +03:00
MediaTrackGraph* graph = MediaTrackGraph::GetInstance(
MediaTrackGraph::SYSTEM_THREAD_DRIVER, mWindow,
MediaTrackGraph::REQUEST_DEFAULT_SAMPLE_RATE,
MediaTrackGraph::DEFAULT_OUTPUT_DEVICE);
Bug 1454998 - Rename streams to tracks. r=padenot,karlt,smaug This renames the following (in alphabetical order, non-exhaustive): AudioCaptureStream -> AudioCaptureTrack AudioNodeStream -> AudioNodeTrack AudioNodeExternalInputStream -> AudioNodeExternalInputTrack DirectMediaStreamTrackListener -> DirectMediaTrackListener MediaStream -> MediaTrack - Note that there's also dom::MediaTrack. Namespaces differentiate them. MediaStreamGraph -> MediaTrackGraph MediaStreamTrackListener -> MediaTrackListener MSG -> MTG (in comments) ProcessedMediaStream -> ProcessedMediaTrack SharedDummyStream -> SharedDummyTrack SourceMediaStream -> SourceMediaTrack StreamTime -> TrackTime TrackUnionStream -> ForwardedInputTrack - Because this no longer takes a union of anything, but only a single track as input. Other minor classes, members and comments have been updated to reflect these name changes. Differential Revision: https://phabricator.services.mozilla.com/D46146 --HG-- rename : dom/media/AudioCaptureStream.cpp => dom/media/AudioCaptureTrack.cpp rename : dom/media/AudioCaptureStream.h => dom/media/AudioCaptureTrack.h rename : dom/media/TrackUnionStream.cpp => dom/media/ForwardedInputTrack.cpp rename : dom/media/TrackUnionStream.h => dom/media/ForwardedInputTrack.h rename : dom/media/MediaStreamGraph.cpp => dom/media/MediaTrackGraph.cpp rename : dom/media/MediaStreamGraph.h => dom/media/MediaTrackGraph.h rename : dom/media/MediaStreamGraphImpl.h => dom/media/MediaTrackGraphImpl.h rename : dom/media/MediaStreamListener.cpp => dom/media/MediaTrackListener.cpp rename : dom/media/MediaStreamListener.h => dom/media/MediaTrackListener.h rename : dom/media/webaudio/AudioNodeExternalInputStream.cpp => dom/media/webaudio/AudioNodeExternalInputTrack.cpp rename : dom/media/webaudio/AudioNodeExternalInputStream.h => dom/media/webaudio/AudioNodeExternalInputTrack.h rename : dom/media/webaudio/AudioNodeStream.cpp => dom/media/webaudio/AudioNodeTrack.cpp rename : dom/media/webaudio/AudioNodeStream.h => dom/media/webaudio/AudioNodeTrack.h extra : moz-landing-system : lando
2019-10-02 13:23:02 +03:00
SourceMediaTrack* source = graph->CreateSourceTrack(MediaSegment::VIDEO);
PrincipalHandle principalHandle = MakePrincipalHandle(aPrincipal);
if (!aFPS.WasPassed()) {
Bug 1454998 - Remove the notion of streams from MediaStreamGraph. r=padenot,karlt This change mainly removes the `mTracks` member from MediaStream and moves all associated members up a level, so that a MediaStream in practice represents a single track. Classes will be renamed in a future patch to reflect this. Other changes include: The new `mEnded` member of MediaStream changes meaning to only become true when all data in the stream has been processed. It stems from StreamTracks::Track::mEnded which used to become true as soon as the last bit of data had been added to a track, and there could still be data in the track that would get processed in future iterations. We are moving towards not having any future data in tracks, which is why this change is ok to make -- keeping the old behavior will soon not make sense. TrackUnionStream is changed to no longer take a list of streams as input and forward the union of their tracks to itself. Instead it's limited to having one track as input at a time. The autofinishing functionality that TrackUnionStream had before has been transformed into an autoending functionality to allow it to defer ending until its been told that it's ok to end through the control API. This lets a single TrackUnionStream span the lifetime of multiple inputs, which will be useful for making DecodedStream spec compliant with HTMLMediaElement::CaptureStream(), and for implementing the currently discussed MediaRecorder::ReplaceTrack(), to name a few potential use cases. AudioNodeStreams used to only have a track (and thus an AudioSegment) if the EXTERNAL_OUTPUT flag was enabled on them. With all MediaStreams now representing a track, AudioNodeStreams inherently have an AudioSegment as a member. It is however only used with data if the EXTERNAL_OUTPUT flag is enabled. Differential Revision: https://phabricator.services.mozilla.com/D45821 --HG-- extra : moz-landing-system : lando
2019-10-02 13:22:53 +03:00
mOutputStreamDriver = new AutoDriver(source, principalHandle);
} else if (aFPS.Value() < 0) {
return NS_ERROR_ILLEGAL_VALUE;
} else {
// Cap frame rate to 60 FPS for sanity
double fps = std::min(60.0, aFPS.Value());
Bug 1454998 - Remove the notion of streams from MediaStreamGraph. r=padenot,karlt This change mainly removes the `mTracks` member from MediaStream and moves all associated members up a level, so that a MediaStream in practice represents a single track. Classes will be renamed in a future patch to reflect this. Other changes include: The new `mEnded` member of MediaStream changes meaning to only become true when all data in the stream has been processed. It stems from StreamTracks::Track::mEnded which used to become true as soon as the last bit of data had been added to a track, and there could still be data in the track that would get processed in future iterations. We are moving towards not having any future data in tracks, which is why this change is ok to make -- keeping the old behavior will soon not make sense. TrackUnionStream is changed to no longer take a list of streams as input and forward the union of their tracks to itself. Instead it's limited to having one track as input at a time. The autofinishing functionality that TrackUnionStream had before has been transformed into an autoending functionality to allow it to defer ending until its been told that it's ok to end through the control API. This lets a single TrackUnionStream span the lifetime of multiple inputs, which will be useful for making DecodedStream spec compliant with HTMLMediaElement::CaptureStream(), and for implementing the currently discussed MediaRecorder::ReplaceTrack(), to name a few potential use cases. AudioNodeStreams used to only have a track (and thus an AudioSegment) if the EXTERNAL_OUTPUT flag was enabled on them. With all MediaStreams now representing a track, AudioNodeStreams inherently have an AudioSegment as a member. It is however only used with data if the EXTERNAL_OUTPUT flag is enabled. Differential Revision: https://phabricator.services.mozilla.com/D45821 --HG-- extra : moz-landing-system : lando
2019-10-02 13:22:53 +03:00
mOutputStreamDriver = new TimerDriver(source, fps, principalHandle);
}
return NS_OK;
}
FrameCaptureListener* CanvasCaptureMediaStream::FrameCaptureListener() {
return mOutputStreamDriver;
}
void CanvasCaptureMediaStream::StopCapture() {
if (!mOutputStreamDriver) {
return;
}
mOutputStreamDriver->EndTrack();
mOutputStreamDriver->Forget();
mOutputStreamDriver = nullptr;
}
Bug 1454998 - Rename streams to tracks. r=padenot,karlt,smaug This renames the following (in alphabetical order, non-exhaustive): AudioCaptureStream -> AudioCaptureTrack AudioNodeStream -> AudioNodeTrack AudioNodeExternalInputStream -> AudioNodeExternalInputTrack DirectMediaStreamTrackListener -> DirectMediaTrackListener MediaStream -> MediaTrack - Note that there's also dom::MediaTrack. Namespaces differentiate them. MediaStreamGraph -> MediaTrackGraph MediaStreamTrackListener -> MediaTrackListener MSG -> MTG (in comments) ProcessedMediaStream -> ProcessedMediaTrack SharedDummyStream -> SharedDummyTrack SourceMediaStream -> SourceMediaTrack StreamTime -> TrackTime TrackUnionStream -> ForwardedInputTrack - Because this no longer takes a union of anything, but only a single track as input. Other minor classes, members and comments have been updated to reflect these name changes. Differential Revision: https://phabricator.services.mozilla.com/D46146 --HG-- rename : dom/media/AudioCaptureStream.cpp => dom/media/AudioCaptureTrack.cpp rename : dom/media/AudioCaptureStream.h => dom/media/AudioCaptureTrack.h rename : dom/media/TrackUnionStream.cpp => dom/media/ForwardedInputTrack.cpp rename : dom/media/TrackUnionStream.h => dom/media/ForwardedInputTrack.h rename : dom/media/MediaStreamGraph.cpp => dom/media/MediaTrackGraph.cpp rename : dom/media/MediaStreamGraph.h => dom/media/MediaTrackGraph.h rename : dom/media/MediaStreamGraphImpl.h => dom/media/MediaTrackGraphImpl.h rename : dom/media/MediaStreamListener.cpp => dom/media/MediaTrackListener.cpp rename : dom/media/MediaStreamListener.h => dom/media/MediaTrackListener.h rename : dom/media/webaudio/AudioNodeExternalInputStream.cpp => dom/media/webaudio/AudioNodeExternalInputTrack.cpp rename : dom/media/webaudio/AudioNodeExternalInputStream.h => dom/media/webaudio/AudioNodeExternalInputTrack.h rename : dom/media/webaudio/AudioNodeStream.cpp => dom/media/webaudio/AudioNodeTrack.cpp rename : dom/media/webaudio/AudioNodeStream.h => dom/media/webaudio/AudioNodeTrack.h extra : moz-landing-system : lando
2019-10-02 13:23:02 +03:00
SourceMediaTrack* CanvasCaptureMediaStream::GetSourceStream() const {
if (!mOutputStreamDriver) {
return nullptr;
}
return mOutputStreamDriver->mSourceStream;
}
} // namespace dom
} // namespace mozilla