Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync_audioMuted and _videoMuted with local mediaStream if provided #798

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/RTCSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ module.exports = class RTCSession extends EventEmitter
// A local MediaStream is given, use it.
if (mediaStream)
{
this._checkLocalMediaStream(mediaStream);
return mediaStream;
}

Expand Down Expand Up @@ -2621,6 +2622,7 @@ module.exports = class RTCSession extends EventEmitter
// A stream is given, let the app set events such as 'peerconnection' and 'connecting'.
if (mediaStream)
{
this._checkLocalMediaStream(mediaStream);
return mediaStream;
}
// Request for user media access.
Expand Down Expand Up @@ -3444,6 +3446,26 @@ module.exports = class RTCSession extends EventEmitter
}
}

/**
* Syncs muted status of audio to mediaStream option passed to answer and connect functions.
*/
_checkLocalMediaStream(mediaStream) {

if (!mediaStream || typeof mediaStream.getTracks !== "function")
return;

mediaStream.getTracks().forEach((track) => {

if (track.kind === "audio") {
this._audioMuted = track.enabled ? false : true;
}
else {
this._videoMuted = track.enabled ? false : true;
}

});
}

_toggleMuteAudio(mute)
{
const senders = this._connection.getSenders().filter((sender) =>
Expand Down