mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-08 14:03:49 +00:00
Bug 1493613 - Update muted state through MediaStreamTrackSource. r=bwc,smaug
This ensures all clones of the original track also receives the new muted state. Differential Revision: https://phabricator.services.mozilla.com/D37933 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
dc0cfa8bb6
commit
719dfe4ede
@ -450,7 +450,6 @@ void MediaStreamTrack::MutedChanged(bool aNewState) {
|
||||
*/
|
||||
|
||||
if (mMuted == aNewState) {
|
||||
MOZ_ASSERT_UNREACHABLE("Muted state didn't actually change");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1576,23 +1576,21 @@ class RTCPeerConnection {
|
||||
_processTrackAdditionsAndRemovals() {
|
||||
const removeList = [];
|
||||
const addList = [];
|
||||
const muteTracks = [];
|
||||
const muteTransceiverReceiveTracks = [];
|
||||
const trackEventInits = [];
|
||||
|
||||
for (const transceiver of this._transceivers) {
|
||||
transceiver.receiver.processTrackAdditionsAndRemovals(transceiver, {
|
||||
removeList,
|
||||
addList,
|
||||
muteTracks,
|
||||
muteTransceiverReceiveTracks,
|
||||
trackEventInits,
|
||||
});
|
||||
}
|
||||
|
||||
muteTracks.forEach(track => {
|
||||
muteTransceiverReceiveTracks.forEach(transceiver => {
|
||||
// Check this as late as possible, in case JS has messed with this state.
|
||||
if (!track.muted) {
|
||||
track.mutedChanged(true);
|
||||
}
|
||||
transceiver.setReceiveTrackMuted(true);
|
||||
});
|
||||
|
||||
for (const { stream, track } of removeList) {
|
||||
@ -2552,7 +2550,7 @@ class RTCRtpReceiver {
|
||||
|
||||
processTrackAdditionsAndRemovals(
|
||||
transceiver,
|
||||
{ removeList, addList, muteTracks, trackEventInits }
|
||||
{ removeList, addList, muteTransceiverReceiveTracks, trackEventInits }
|
||||
) {
|
||||
const receiver = this.__DOM_IMPL__;
|
||||
const track = this.track;
|
||||
@ -2572,7 +2570,7 @@ class RTCRtpReceiver {
|
||||
// New track, set in case streamsAdded is empty
|
||||
needsTrackEvent = true;
|
||||
} else {
|
||||
muteTracks.push(track);
|
||||
muteTransceiverReceiveTracks.push(this._transceiverImpl);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,4 @@ interface MediaStreamTrack : EventTarget {
|
||||
[Throws, NeedsCallerType]
|
||||
Promise<void> applyConstraints (optional MediaTrackConstraints constraints = {});
|
||||
// attribute EventHandler onoverconstrained;
|
||||
|
||||
[ChromeOnly]
|
||||
void mutedChanged(boolean muted);
|
||||
};
|
||||
|
@ -17,6 +17,7 @@
|
||||
[ChromeOnly]
|
||||
interface TransceiverImpl {
|
||||
MediaStreamTrack getReceiveTrack();
|
||||
void setReceiveTrackMuted(boolean muted);
|
||||
[Throws]
|
||||
void syncWithJS(RTCRtpTransceiver transceiver);
|
||||
};
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "MediaStreamGraphImpl.h"
|
||||
#include "MediaStreamListener.h"
|
||||
#include "MediaStreamTrack.h"
|
||||
#include "RemoteTrackSource.h"
|
||||
#include "RtpLogger.h"
|
||||
#include "VideoFrameConverter.h"
|
||||
#include "VideoSegment.h"
|
||||
@ -1164,7 +1165,8 @@ void MediaPipelineTransmit::PipelineListener::NewData(
|
||||
class GenericReceiveListener : public MediaStreamTrackListener {
|
||||
public:
|
||||
explicit GenericReceiveListener(dom::MediaStreamTrack* aTrack)
|
||||
: mTrack(aTrack),
|
||||
: mTrack(new nsMainThreadPtrHolder<dom::MediaStreamTrack>(
|
||||
"GenericReceiveListener::mTrack", aTrack)),
|
||||
mTrackId(aTrack->GetInputTrackId()),
|
||||
mSource(mTrack->GetInputStream()->AsSourceStream()),
|
||||
mPrincipalHandle(PRINCIPAL_HANDLE_NONE),
|
||||
@ -1173,10 +1175,7 @@ class GenericReceiveListener : public MediaStreamTrackListener {
|
||||
MOZ_RELEASE_ASSERT(mSource, "Must be used with a SourceMediaStream");
|
||||
}
|
||||
|
||||
virtual ~GenericReceiveListener() {
|
||||
NS_ReleaseOnMainThreadSystemGroup("GenericReceiveListener::track_",
|
||||
mTrack.forget());
|
||||
}
|
||||
virtual ~GenericReceiveListener() = default;
|
||||
|
||||
void AddTrackToSource(uint32_t aRate = 0) {
|
||||
MOZ_ASSERT((aRate != 0 && mTrack->AsAudioStreamTrack()) ||
|
||||
@ -1226,8 +1225,8 @@ class GenericReceiveListener : public MediaStreamTrackListener {
|
||||
}
|
||||
|
||||
void OnRtpReceived_m() {
|
||||
if (mListening && mTrack->Muted()) {
|
||||
mTrack->MutedChanged(false);
|
||||
if (mListening) {
|
||||
static_cast<RemoteTrackSource&>(mTrack->GetSource()).SetMuted(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1268,7 +1267,7 @@ class GenericReceiveListener : public MediaStreamTrackListener {
|
||||
}
|
||||
|
||||
protected:
|
||||
RefPtr<dom::MediaStreamTrack> mTrack;
|
||||
const nsMainThreadPtrHandle<dom::MediaStreamTrack> mTrack;
|
||||
const TrackID mTrackId;
|
||||
const RefPtr<SourceMediaStream> mSource;
|
||||
PrincipalHandle mPrincipalHandle;
|
||||
|
@ -13,6 +13,7 @@ LOCAL_INCLUDES += [
|
||||
'/media/mtransport',
|
||||
'/media/webrtc',
|
||||
'/media/webrtc/signaling/src/media-conduit',
|
||||
'/media/webrtc/signaling/src/peerconnection',
|
||||
'/media/webrtc/trunk',
|
||||
'/media/webrtc/trunk/webrtc',
|
||||
'/netwerk/srtp/src/crypto/include',
|
||||
|
@ -1824,25 +1824,24 @@ OwningNonNull<dom::MediaStreamTrack> PeerConnectionImpl::CreateReceiveTrack(
|
||||
}
|
||||
|
||||
RefPtr<MediaStreamTrack> track;
|
||||
RefPtr<RemoteTrackSource> trackSource;
|
||||
if (audio) {
|
||||
track = stream->CreateDOMTrack(
|
||||
333, // Use a constant TrackID. Dependents read this from the DOM
|
||||
// track.
|
||||
MediaSegment::AUDIO,
|
||||
new RemoteTrackSource(principal,
|
||||
NS_ConvertASCIItoUTF16("remote audio")));
|
||||
trackSource = new RemoteTrackSource(principal,
|
||||
NS_ConvertASCIItoUTF16("remote audio"));
|
||||
track = stream->CreateDOMTrack(333, // Use a constant TrackID. Dependents
|
||||
// read this from the DOM track.
|
||||
MediaSegment::AUDIO, trackSource);
|
||||
} else {
|
||||
track = stream->CreateDOMTrack(
|
||||
666, // Use a constant TrackID. Dependents read this from the DOM
|
||||
// track.
|
||||
MediaSegment::VIDEO,
|
||||
new RemoteTrackSource(principal,
|
||||
NS_ConvertASCIItoUTF16("remote video")));
|
||||
trackSource = new RemoteTrackSource(principal,
|
||||
NS_ConvertASCIItoUTF16("remote video"));
|
||||
track = stream->CreateDOMTrack(666, // Use a constant TrackID. Dependents
|
||||
// read this from the DOM track.
|
||||
MediaSegment::VIDEO, trackSource);
|
||||
}
|
||||
|
||||
stream->AddTrackInternal(track);
|
||||
// Spec says remote tracks start out muted.
|
||||
track->MutedChanged(true);
|
||||
trackSource->SetMuted(true);
|
||||
|
||||
return OwningNonNull<dom::MediaStreamTrack>(*track);
|
||||
}
|
||||
|
@ -23,8 +23,9 @@ class RemoteTrackSource : public dom::MediaStreamTrackSource {
|
||||
const dom::MediaTrackConstraints& aConstraints,
|
||||
dom::CallerType aCallerType) override {
|
||||
return ApplyConstraintsPromise::CreateAndReject(
|
||||
MakeRefPtr<MediaMgrError>(MediaStreamError::Name::OverconstrainedError,
|
||||
NS_LITERAL_STRING("")),
|
||||
MakeRefPtr<MediaMgrError>(
|
||||
dom::MediaStreamError::Name::OverconstrainedError,
|
||||
NS_LITERAL_STRING("")),
|
||||
__func__);
|
||||
}
|
||||
|
||||
@ -41,6 +42,7 @@ class RemoteTrackSource : public dom::MediaStreamTrackSource {
|
||||
mPrincipal = aPrincipal;
|
||||
PrincipalChanged();
|
||||
}
|
||||
void SetMuted(bool aMuted) { MutedChanged(aMuted); }
|
||||
|
||||
protected:
|
||||
virtual ~RemoteTrackSource() {}
|
||||
|
@ -242,6 +242,15 @@ nsresult TransceiverImpl::UpdateConduit() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void TransceiverImpl::SetReceiveTrackMuted(bool aMuted) {
|
||||
if (!mReceiveTrack) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This sets the muted state for mReceiveTrack and all its clones.
|
||||
static_cast<RemoteTrackSource&>(mReceiveTrack->GetSource()).SetMuted(aMuted);
|
||||
}
|
||||
|
||||
nsresult TransceiverImpl::UpdatePrincipal(nsIPrincipal* aPrincipal) {
|
||||
if (mJsepTransceiver->IsStopped()) {
|
||||
return NS_OK;
|
||||
|
@ -92,6 +92,7 @@ class TransceiverImpl : public nsISupports {
|
||||
bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto,
|
||||
JS::MutableHandle<JSObject*> aReflector);
|
||||
already_AddRefed<dom::MediaStreamTrack> GetReceiveTrack();
|
||||
void SetReceiveTrackMuted(bool aMuted);
|
||||
void SyncWithJS(dom::RTCRtpTransceiver& aJsTransceiver, ErrorResult& aRv);
|
||||
|
||||
void InsertDTMFTone(int tone, uint32_t duration);
|
||||
|
Loading…
Reference in New Issue
Block a user