diff --git a/src/webrtc/groupCall.ts b/src/webrtc/groupCall.ts index 031422fd97e..32f6fa29554 100644 --- a/src/webrtc/groupCall.ts +++ b/src/webrtc/groupCall.ts @@ -59,6 +59,12 @@ export class GroupCallError extends Error { } } +export class OtherUserSpeakingError extends Error { + constructor() { + super("Cannot unmute: another user is speaking"); + } +} + export interface IGroupCallDataChannelOptions { ordered: boolean; maxPacketLifeTime: number; @@ -408,6 +414,12 @@ export class GroupCall extends EventEmitter { // set a timer for the maximum transmit time on PTT calls if (this.isPtt) { + // if anoher user is currently unmuted, we can't unmute + if (!muted && this.userMediaFeeds.some(f => !f.isAudioMuted())) { + throw new OtherUserSpeakingError(); + } + + // Set or clear the max transmit timer if (!muted && this.isMicrophoneMuted()) { this.transmitTimer = setTimeout(() => { this.setMicrophoneMuted(true);