Skip to content

Commit cc60492

Browse files
authored
Don't allow user to unmute if another user is speaking (#2313)
* Add maximum trasmit time for PTT on sender side by muting mic after the max transmit time has elapsed. * Don't allow user to unmute if another user is speaking Based on #2312 For element-hq/element-call#298
1 parent cdd3913 commit cc60492

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/webrtc/groupCall.ts

+12
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ export class GroupCallError extends Error {
5959
}
6060
}
6161

62+
export class OtherUserSpeakingError extends Error {
63+
constructor() {
64+
super("Cannot unmute: another user is speaking");
65+
}
66+
}
67+
6268
export interface IGroupCallDataChannelOptions {
6369
ordered: boolean;
6470
maxPacketLifeTime: number;
@@ -408,6 +414,12 @@ export class GroupCall extends EventEmitter {
408414

409415
// set a timer for the maximum transmit time on PTT calls
410416
if (this.isPtt) {
417+
// if anoher user is currently unmuted, we can't unmute
418+
if (!muted && this.userMediaFeeds.some(f => !f.isAudioMuted())) {
419+
throw new OtherUserSpeakingError();
420+
}
421+
422+
// Set or clear the max transmit timer
411423
if (!muted && this.isMicrophoneMuted()) {
412424
this.transmitTimer = setTimeout(() => {
413425
this.setMicrophoneMuted(true);

0 commit comments

Comments
 (0)