зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 5454dcaa31ff (bug 1208373)
This commit is contained in:
Родитель
2c32e5b3ad
Коммит
79d88f89e8
|
@ -98,10 +98,10 @@ DOMMediaStream::TrackPort::GetSourceTrackId() const
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<Pledge<bool>>
|
already_AddRefed<Pledge<bool>>
|
||||||
DOMMediaStream::TrackPort::BlockSourceTrackId(TrackID aTrackId, BlockingMode aBlockingMode)
|
DOMMediaStream::TrackPort::BlockSourceTrackId(TrackID aTrackId)
|
||||||
{
|
{
|
||||||
if (mInputPort) {
|
if (mInputPort) {
|
||||||
return mInputPort->BlockSourceTrackId(aTrackId, aBlockingMode);
|
return mInputPort->BlockSourceTrackId(aTrackId);
|
||||||
}
|
}
|
||||||
RefPtr<Pledge<bool>> rejected = new Pledge<bool>();
|
RefPtr<Pledge<bool>> rejected = new Pledge<bool>();
|
||||||
rejected->Reject(NS_ERROR_FAILURE);
|
rejected->Reject(NS_ERROR_FAILURE);
|
||||||
|
@ -1040,10 +1040,8 @@ DOMMediaStream::CloneDOMTrack(MediaStreamTrack& aTrack,
|
||||||
if (aTrack.Ended()) {
|
if (aTrack.Ended()) {
|
||||||
// For extra suspenders, make sure that we don't forward data by mistake
|
// For extra suspenders, make sure that we don't forward data by mistake
|
||||||
// to the clone when the original has already ended.
|
// to the clone when the original has already ended.
|
||||||
// We only block END_EXISTING to allow any pending clones to end.
|
|
||||||
RefPtr<Pledge<bool, nsresult>> blockingPledge =
|
RefPtr<Pledge<bool, nsresult>> blockingPledge =
|
||||||
inputPort->BlockSourceTrackId(inputTrackID,
|
inputPort->BlockSourceTrackId(inputTrackID);
|
||||||
BlockingMode::END_EXISTING);
|
|
||||||
Unused << blockingPledge;
|
Unused << blockingPledge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1251,9 +1249,7 @@ DOMMediaStream::BlockPlaybackTrack(TrackPort* aTrack)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aTrack);
|
MOZ_ASSERT(aTrack);
|
||||||
++mTracksPendingRemoval;
|
++mTracksPendingRemoval;
|
||||||
RefPtr<Pledge<bool>> p =
|
RefPtr<Pledge<bool>> p = aTrack->BlockSourceTrackId(aTrack->GetTrack()->mTrackID);
|
||||||
aTrack->BlockSourceTrackId(aTrack->GetTrack()->mTrackID,
|
|
||||||
BlockingMode::CREATION);
|
|
||||||
RefPtr<DOMMediaStream> self = this;
|
RefPtr<DOMMediaStream> self = this;
|
||||||
p->Then([self] (const bool& aIgnore) { self->NotifyPlaybackTrackBlocked(); },
|
p->Then([self] (const bool& aIgnore) { self->NotifyPlaybackTrackBlocked(); },
|
||||||
[] (const nsresult& aIgnore) { NS_ERROR("Could not remove track from MSG"); }
|
[] (const nsresult& aIgnore) { NS_ERROR("Could not remove track from MSG"); }
|
||||||
|
|
|
@ -33,8 +33,6 @@ class MediaStreamDirectListener;
|
||||||
class MediaStreamGraph;
|
class MediaStreamGraph;
|
||||||
class ProcessedMediaStream;
|
class ProcessedMediaStream;
|
||||||
|
|
||||||
enum class BlockingMode;
|
|
||||||
|
|
||||||
namespace dom {
|
namespace dom {
|
||||||
class AudioNode;
|
class AudioNode;
|
||||||
class HTMLCanvasElement;
|
class HTMLCanvasElement;
|
||||||
|
@ -305,8 +303,7 @@ public:
|
||||||
* destroyed. Returns a pledge that gets resolved when the MediaStreamGraph
|
* destroyed. Returns a pledge that gets resolved when the MediaStreamGraph
|
||||||
* has applied the block in the playback stream.
|
* has applied the block in the playback stream.
|
||||||
*/
|
*/
|
||||||
already_AddRefed<media::Pledge<bool, nsresult>>
|
already_AddRefed<media::Pledge<bool, nsresult>> BlockSourceTrackId(TrackID aTrackId);
|
||||||
BlockSourceTrackId(TrackID aTrackId, BlockingMode aBlockingMode);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<MediaInputPort> mInputPort;
|
RefPtr<MediaInputPort> mInputPort;
|
||||||
|
|
|
@ -3136,26 +3136,24 @@ MediaInputPort::SetGraphImpl(MediaStreamGraphImpl* aGraph)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaInputPort::BlockSourceTrackIdImpl(TrackID aTrackId, BlockingMode aBlockingMode)
|
MediaInputPort::BlockSourceTrackIdImpl(TrackID aTrackId)
|
||||||
{
|
{
|
||||||
mBlockedTracks.AppendElement(Pair<TrackID, BlockingMode>(aTrackId, aBlockingMode));
|
mBlockedTracks.AppendElement(aTrackId);
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<Pledge<bool>>
|
already_AddRefed<Pledge<bool>>
|
||||||
MediaInputPort::BlockSourceTrackId(TrackID aTrackId, BlockingMode aBlockingMode)
|
MediaInputPort::BlockSourceTrackId(TrackID aTrackId)
|
||||||
{
|
{
|
||||||
class Message : public ControlMessage {
|
class Message : public ControlMessage {
|
||||||
public:
|
public:
|
||||||
explicit Message(MediaInputPort* aPort,
|
explicit Message(MediaInputPort* aPort,
|
||||||
TrackID aTrackId,
|
TrackID aTrackId,
|
||||||
BlockingMode aBlockingMode,
|
|
||||||
already_AddRefed<nsIRunnable> aRunnable)
|
already_AddRefed<nsIRunnable> aRunnable)
|
||||||
: ControlMessage(aPort->GetDestination()),
|
: ControlMessage(aPort->GetDestination()),
|
||||||
mPort(aPort), mTrackId(aTrackId), mBlockingMode(aBlockingMode),
|
mPort(aPort), mTrackId(aTrackId), mRunnable(aRunnable) {}
|
||||||
mRunnable(aRunnable) {}
|
|
||||||
void Run() override
|
void Run() override
|
||||||
{
|
{
|
||||||
mPort->BlockSourceTrackIdImpl(mTrackId, mBlockingMode);
|
mPort->BlockSourceTrackIdImpl(mTrackId);
|
||||||
if (mRunnable) {
|
if (mRunnable) {
|
||||||
mStream->Graph()->DispatchToMainThreadAfterStreamStateUpdate(mRunnable.forget());
|
mStream->Graph()->DispatchToMainThreadAfterStreamStateUpdate(mRunnable.forget());
|
||||||
}
|
}
|
||||||
|
@ -3166,7 +3164,6 @@ MediaInputPort::BlockSourceTrackId(TrackID aTrackId, BlockingMode aBlockingMode)
|
||||||
}
|
}
|
||||||
RefPtr<MediaInputPort> mPort;
|
RefPtr<MediaInputPort> mPort;
|
||||||
TrackID mTrackId;
|
TrackID mTrackId;
|
||||||
BlockingMode mBlockingMode;
|
|
||||||
nsCOMPtr<nsIRunnable> mRunnable;
|
nsCOMPtr<nsIRunnable> mRunnable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3179,7 +3176,7 @@ MediaInputPort::BlockSourceTrackId(TrackID aTrackId, BlockingMode aBlockingMode)
|
||||||
pledge->Resolve(true);
|
pledge->Resolve(true);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
});
|
});
|
||||||
GraphImpl()->AppendMessage(MakeUnique<Message>(this, aTrackId, aBlockingMode, runnable.forget()));
|
GraphImpl()->AppendMessage(MakeUnique<Message>(this, aTrackId, runnable.forget()));
|
||||||
return pledge.forget();
|
return pledge.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3222,7 +3219,7 @@ ProcessedMediaStream::AllocateInputPort(MediaStream* aStream, TrackID aTrackID,
|
||||||
aInputNumber, aOutputNumber);
|
aInputNumber, aOutputNumber);
|
||||||
if (aBlockedTracks) {
|
if (aBlockedTracks) {
|
||||||
for (TrackID trackID : *aBlockedTracks) {
|
for (TrackID trackID : *aBlockedTracks) {
|
||||||
port->BlockSourceTrackIdImpl(trackID, BlockingMode::CREATION);
|
port->BlockSourceTrackIdImpl(trackID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
port->SetGraphImpl(GraphImpl());
|
port->SetGraphImpl(GraphImpl());
|
||||||
|
|
|
@ -1176,23 +1176,6 @@ protected:
|
||||||
bool mNeedsMixing;
|
bool mNeedsMixing;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* The blocking mode decides how a track should be blocked in a MediaInputPort.
|
|
||||||
*/
|
|
||||||
enum class BlockingMode
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* BlockingMode CREATION blocks the source track from being created
|
|
||||||
* in the destination. It'll end if it already exists.
|
|
||||||
*/
|
|
||||||
CREATION,
|
|
||||||
/**
|
|
||||||
* BlockingMode END_EXISTING allows a track to be created in the destination
|
|
||||||
* but will end it before any data has been passed through.
|
|
||||||
*/
|
|
||||||
END_EXISTING,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a connection between a ProcessedMediaStream and one of its
|
* Represents a connection between a ProcessedMediaStream and one of its
|
||||||
* input streams.
|
* input streams.
|
||||||
|
@ -1274,39 +1257,16 @@ public:
|
||||||
* Returns a pledge that resolves on the main thread after the track block has
|
* Returns a pledge that resolves on the main thread after the track block has
|
||||||
* been applied by the MSG.
|
* been applied by the MSG.
|
||||||
*/
|
*/
|
||||||
already_AddRefed<media::Pledge<bool, nsresult>> BlockSourceTrackId(TrackID aTrackId,
|
already_AddRefed<media::Pledge<bool, nsresult>> BlockSourceTrackId(TrackID aTrackId);
|
||||||
BlockingMode aBlockingMode);
|
|
||||||
private:
|
private:
|
||||||
void BlockSourceTrackIdImpl(TrackID aTrackId, BlockingMode aBlockingMode);
|
void BlockSourceTrackIdImpl(TrackID aTrackId);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Returns true if aTrackId has not been blocked for any reason and this port
|
// Returns true if aTrackId has not been blocked and this port has not
|
||||||
// has not been locked to another track.
|
// been locked to another track.
|
||||||
bool PassTrackThrough(TrackID aTrackId) {
|
bool PassTrackThrough(TrackID aTrackId) {
|
||||||
bool blocked = false;
|
return !mBlockedTracks.Contains(aTrackId) &&
|
||||||
for (auto pair : mBlockedTracks) {
|
(mSourceTrack == TRACK_ANY || mSourceTrack == aTrackId);
|
||||||
if (pair.first() == aTrackId &&
|
|
||||||
(pair.second() == BlockingMode::CREATION ||
|
|
||||||
pair.second() == BlockingMode::END_EXISTING)) {
|
|
||||||
blocked = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return !blocked && (mSourceTrack == TRACK_ANY || mSourceTrack == aTrackId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if aTrackId has not been blocked for track creation and this
|
|
||||||
// port has not been locked to another track.
|
|
||||||
bool AllowCreationOf(TrackID aTrackId) {
|
|
||||||
bool blocked = false;
|
|
||||||
for (auto pair : mBlockedTracks) {
|
|
||||||
if (pair.first() == aTrackId &&
|
|
||||||
pair.second() == BlockingMode::CREATION) {
|
|
||||||
blocked = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return !blocked && (mSourceTrack == TRACK_ANY || mSourceTrack == aTrackId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t InputNumber() const { return mInputNumber; }
|
uint16_t InputNumber() const { return mInputNumber; }
|
||||||
|
@ -1361,9 +1321,7 @@ private:
|
||||||
// Web Audio.
|
// Web Audio.
|
||||||
const uint16_t mInputNumber;
|
const uint16_t mInputNumber;
|
||||||
const uint16_t mOutputNumber;
|
const uint16_t mOutputNumber;
|
||||||
|
nsTArray<TrackID> mBlockedTracks;
|
||||||
typedef Pair<TrackID, BlockingMode> BlockedTrack;
|
|
||||||
nsTArray<BlockedTrack> mBlockedTracks;
|
|
||||||
|
|
||||||
// Our media stream graph
|
// Our media stream graph
|
||||||
MediaStreamGraphImpl* mGraph;
|
MediaStreamGraphImpl* mGraph;
|
||||||
|
|
|
@ -237,7 +237,7 @@ MediaStreamTrack::Stop()
|
||||||
MOZ_ASSERT(mOwningStream, "Every MediaStreamTrack needs an owning DOMMediaStream");
|
MOZ_ASSERT(mOwningStream, "Every MediaStreamTrack needs an owning DOMMediaStream");
|
||||||
DOMMediaStream::TrackPort* port = mOwningStream->FindOwnedTrackPort(*this);
|
DOMMediaStream::TrackPort* port = mOwningStream->FindOwnedTrackPort(*this);
|
||||||
MOZ_ASSERT(port, "A MediaStreamTrack must exist in its owning DOMMediaStream");
|
MOZ_ASSERT(port, "A MediaStreamTrack must exist in its owning DOMMediaStream");
|
||||||
RefPtr<Pledge<bool>> p = port->BlockSourceTrackId(mInputTrackID, BlockingMode::CREATION);
|
RefPtr<Pledge<bool>> p = port->BlockSourceTrackId(mInputTrackID);
|
||||||
Unused << p;
|
Unused << p;
|
||||||
|
|
||||||
mReadyState = MediaStreamTrackState::Ended;
|
mReadyState = MediaStreamTrackState::Ended;
|
||||||
|
|
|
@ -107,7 +107,7 @@ TrackUnionStream::TrackUnionStream(DOMMediaStream* aWrapper) :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found && mInputs[i]->AllowCreationOf(tracks->GetID())) {
|
if (!found && mInputs[i]->PassTrackThrough(tracks->GetID())) {
|
||||||
bool trackFinished = false;
|
bool trackFinished = false;
|
||||||
trackAdded = true;
|
trackAdded = true;
|
||||||
uint32_t mapIndex = AddTrack(mInputs[i], tracks.get(), aFrom);
|
uint32_t mapIndex = AddTrack(mInputs[i], tracks.get(), aFrom);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче