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

Fix calling the applyConstraints(noiseSuppresion) for audio mutes the audio in player #356

Merged
merged 1 commit into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/main/webapp/js/media_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,16 +915,19 @@ export class MediaManager {
}

if (typeof deviceId != "undefined") {
//Update the media constraints
if (this.mediaConstraints.audio !== true)
this.mediaConstraints.audio.deviceId = deviceId;
else
this.mediaConstraints.audio = {"deviceId": deviceId};

//to change only audio track set video false otherwise issue #3826 occurs on Android
let tempMediaConstraints = {"video": false, "audio": {"deviceId": deviceId}};
this.setAudioInputSource(streamId, tempMediaConstraints, null, true, deviceId);
return this.setAudioInputSource(streamId, tempMediaConstraints, null, deviceId);
} else {
this.setAudioInputSource(streamId, this.mediaConstraints, null, true, deviceId);
return new Promise((resolve, reject) => {
reject("There is no device id for audio input source");
});
}
}

Expand Down Expand Up @@ -1337,7 +1340,10 @@ export class MediaManager {

if (constraints.audio !== undefined) {
//just give the audio constraints not to get video stream
promise = this.setAudioInputSource(streamId, {audio: this.mediaConstraints.audio}, null);
//we dont call applyContrains for audio because it does not work. I think this is due to gainStream things. This is why we call getUserMedia again

//use the publishStreamId because we don't have streamId in the parameter anymore
promise = this.setAudioInputSource(this.publishStreamId, {audio: this.mediaConstraints.audio}, null);
}
return promise;
}
Expand Down
9 changes: 2 additions & 7 deletions src/main/webapp/js/webrtc_adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ export class WebRTCAdaptor {
}

switchAudioInputSource(streamId, deviceId) {
this.mediaManager.switchAudioInputSource(streamId, deviceId);
return this.mediaManager.switchAudioInputSource(streamId, deviceId);
}

setVolumeLevel(volumeLevel) {
Expand All @@ -1638,7 +1638,7 @@ export class WebRTCAdaptor {
}

applyConstraints(constraints) {
this.mediaManager.applyConstraints(constraints)
return this.mediaManager.applyConstraints(constraints)
};

changeBandwidth(bandwidth, streamId) {
Expand All @@ -1664,11 +1664,6 @@ export class WebRTCAdaptor {
closeStream() {
return this.mediaManager.closeStream();
};


applyConstraints(newConstaints) {
this.mediaManager.applyConstraints(newConstaints);
}
}


Expand Down
8 changes: 7 additions & 1 deletion src/main/webapp/samples/publish_webrtc.html
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,13 @@
break;
}
}
webRTCAdaptor.applyConstraints(constraint);
webRTCAdaptor.applyConstraints(constraint).then((value) => {
console.log("Applied audio constraints: " + JSON.stringify(constraint));
})
.catch((error) => {
console.error("Audio Constraints could not be applied" + JSON.stringify(constraint));
console.error(error);
});
}

var websocketURL = getWebSocketURL(location, rtmpForward);
Expand Down