mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 909187: Part 2 - Allow DOM MediaStreams to intercept SetTrackEnabled calls r=roc (reland)
This commit is contained in:
parent
31b3d54567
commit
e95c682ba0
@ -240,6 +240,14 @@ DOMMediaStream::CreateTrackUnionStream(nsIDOMWindow* aWindow, TrackTypeHints aHi
|
||||
return stream.forget();
|
||||
}
|
||||
|
||||
void
|
||||
DOMMediaStream::SetTrackEnabled(TrackID aTrackID, bool aEnabled)
|
||||
{
|
||||
if (mStream) {
|
||||
mStream->SetTrackEnabled(aTrackID, aEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
DOMMediaStream::CombineWithPrincipal(nsIPrincipal* aPrincipal)
|
||||
{
|
||||
|
@ -84,6 +84,12 @@ public:
|
||||
virtual bool AddDirectListener(MediaStreamDirectListener *aListener) { return false; }
|
||||
virtual void RemoveDirectListener(MediaStreamDirectListener *aListener) {}
|
||||
|
||||
/**
|
||||
* Overridden in DOMLocalMediaStreams to allow getUserMedia to disable
|
||||
* media at the SourceMediaStream.
|
||||
*/
|
||||
virtual void SetTrackEnabled(TrackID aTrackID, bool aEnabled);
|
||||
|
||||
bool IsFinished();
|
||||
/**
|
||||
* Returns a principal indicating who may access this stream. The stream contents
|
||||
|
@ -942,6 +942,11 @@ public:
|
||||
virtual void ProduceOutput(GraphTime aFrom, GraphTime aTo) = 0;
|
||||
void SetAutofinishImpl(bool aAutofinish) { mAutofinish = aAutofinish; }
|
||||
|
||||
/**
|
||||
* Forward SetTrackEnabled() to the input MediaStream(s) and translate the ID
|
||||
*/
|
||||
virtual void ForwardTrackEnabled(TrackID aOutputID, bool aEnabled) {};
|
||||
|
||||
protected:
|
||||
// This state is all accessed only on the media graph thread.
|
||||
|
||||
|
@ -52,10 +52,7 @@ void
|
||||
MediaStreamTrack::SetEnabled(bool aEnabled)
|
||||
{
|
||||
mEnabled = aEnabled;
|
||||
MediaStream* stream = mStream->GetStream();
|
||||
if (stream) {
|
||||
stream->SetTrackEnabled(mTrackID, aEnabled);
|
||||
}
|
||||
mStream->SetTrackEnabled(mTrackID, aEnabled);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -115,6 +115,17 @@ public:
|
||||
mFilterCallback = aCallback;
|
||||
}
|
||||
|
||||
// Forward SetTrackEnabled(output_track_id, enabled) to the Source MediaStream,
|
||||
// translating the output track ID into the correct ID in the source.
|
||||
virtual void ForwardTrackEnabled(TrackID aOutputID, bool aEnabled) {
|
||||
for (int32_t i = mTrackMap.Length() - 1; i >= 0; --i) {
|
||||
if (mTrackMap[i].mOutputTrackID == aOutputID) {
|
||||
mTrackMap[i].mInputPort->GetSource()->
|
||||
SetTrackEnabled(mTrackMap[i].mInputTrackID, aEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
TrackIDFilterCallback mFilterCallback;
|
||||
|
||||
|
@ -312,6 +312,17 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// let us intervene for direct listeners when someone does track.enabled = false
|
||||
virtual void SetTrackEnabled(TrackID aID, bool aEnabled) MOZ_OVERRIDE
|
||||
{
|
||||
// We encapsulate the SourceMediaStream and TrackUnion into one entity, so
|
||||
// we can handle the disabling at the SourceMediaStream
|
||||
|
||||
// We need to find the input track ID for output ID aID, so we let the TrackUnion
|
||||
// forward the request to the source and translate the ID
|
||||
GetStream()->AsProcessedStream()->ForwardTrackEnabled(aID, aEnabled);
|
||||
}
|
||||
|
||||
// The actual MediaStream is a TrackUnionStream. But these resources need to be
|
||||
// explicitly destroyed too.
|
||||
nsRefPtr<SourceMediaStream> mSourceStream;
|
||||
|
Loading…
Reference in New Issue
Block a user