Skip to content

Commit

Permalink
Add the option to mute audio/video before publishing/subscribing (lyn…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcague authored Sep 18, 2017
1 parent 716cd8e commit 6b792c3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
12 changes: 12 additions & 0 deletions erizo_controller/erizoClient/src/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ const Room = (altIo, altConnection, specInput) => {
attributes: stream.getAttributes(),
metadata: options.metadata,
createOffer: options.createOffer,
muteStream: options.muteStream,
});

const populateStreamFunctions = (id, streamInput, error, callback = () => {}) => {
Expand Down Expand Up @@ -445,6 +446,7 @@ const Room = (altIo, altConnection, specInput) => {
browser: that.Connection.getBrowser(),
createOffer: options.createOffer,
metadata: options.metadata,
muteStream: options.muteStream,
slideShowMode: options.slideShowMode };
socket.sendSDP('subscribe', constraint, undefined, (result, error) => {
if (result === null) {
Expand Down Expand Up @@ -594,6 +596,11 @@ const Room = (altIo, altConnection, specInput) => {

options.simulcast = options.simulcast || false;

options.muteStream = {
audio: stream.audioMuted,
video: stream.videoMuted,
};

// 1- If the stream is not local or it is a failed stream we do nothing.
if (stream && stream.local && !stream.failed && !localStreams.has(stream.getID())) {
// 2- Publish Media Stream to Erizo-Controller
Expand Down Expand Up @@ -703,6 +710,11 @@ const Room = (altIo, altConnection, specInput) => {
options.audio = false;
}

options.muteStream = {
audio: stream.audioMuted,
video: stream.videoMuted,
};

if (that.p2p) {
socket.sendSDP('subscribe', { streamId: stream.getID(), metadata: options.metadata });
callback(true);
Expand Down
4 changes: 3 additions & 1 deletion erizo_controller/erizoClient/src/Stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@ const Stream = (altConnection, specInput) => {
}
const config = { muteStream: { audio: that.audioMuted, video: that.videoMuted } };
that.checkOptions(config, true);
that.pc.updateSpec(config, callback);
if (that.pc) {
that.pc.updateSpec(config, callback);
}
};

that.muteAudio = (isMuted, callback = () => {}) => {
Expand Down
7 changes: 6 additions & 1 deletion erizo_controller/erizoJS/models/Publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ class Source {
'id: ' + wrtcId + ', scheme: ' + this.scheme+
', ' + logger.objectToLog(options.metadata));
wrtc.scheme = this.scheme;
this.muteSubscriberStream(id, false, false);
const muteVideo = (options.muteStream && options.muteStream.video) || false;
const muteAudio = (options.muteStream && options.muteStream.audio) || false;
this.muteSubscriberStream(id, muteVideo, muteAudio);
}

removeSubscriber(id) {
Expand Down Expand Up @@ -160,6 +162,9 @@ class Publisher extends Source {
this.wrtc.setAudioReceiver(this.muxer);
this.wrtc.setVideoReceiver(this.muxer);
this.muxer.setPublisher(this.wrtc);
const muteVideo = (options.muteStream && options.muteStream.video) || false;
const muteAudio = (options.muteStream && options.muteStream.audio) || false;
this.muteStream(muteVideo, muteAudio);
}

resetWrtc() {
Expand Down

0 comments on commit 6b792c3

Please sign in to comment.