Add talking indicators
This commit is contained in:
		
					parent
					
						
							
								cc7eb26d7c
							
						
					
				
			
			
				commit
				
					
						1d3e7a4e52
					
				
			
		
					 1 changed files with 27 additions and 0 deletions
				
			
		| 
						 | 
					@ -21,6 +21,7 @@ import { randomString } from "./randomstring";
 | 
				
			||||||
const CONF_ROOM = "me.robertlong.conf";
 | 
					const CONF_ROOM = "me.robertlong.conf";
 | 
				
			||||||
const CONF_PARTICIPANT = "me.robertlong.conf.participant";
 | 
					const CONF_PARTICIPANT = "me.robertlong.conf.participant";
 | 
				
			||||||
const PARTICIPANT_TIMEOUT = 1000 * 15;
 | 
					const PARTICIPANT_TIMEOUT = 1000 * 15;
 | 
				
			||||||
 | 
					const SPEAKING_THRESHOLD = -80;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function waitForSync(client) {
 | 
					function waitForSync(client) {
 | 
				
			||||||
  return new Promise((resolve, reject) => {
 | 
					  return new Promise((resolve, reject) => {
 | 
				
			||||||
| 
						 | 
					@ -247,6 +248,7 @@ export class ConferenceCallManager extends EventEmitter {
 | 
				
			||||||
      stream,
 | 
					      stream,
 | 
				
			||||||
      audioMuted: this.audioMuted,
 | 
					      audioMuted: this.audioMuted,
 | 
				
			||||||
      videoMuted: this.videoMuted,
 | 
					      videoMuted: this.videoMuted,
 | 
				
			||||||
 | 
					      speaking: false,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.participants.push(this.localParticipant);
 | 
					    this.participants.push(this.localParticipant);
 | 
				
			||||||
| 
						 | 
					@ -316,6 +318,7 @@ export class ConferenceCallManager extends EventEmitter {
 | 
				
			||||||
    this.localParticipant.call = null;
 | 
					    this.localParticipant.call = null;
 | 
				
			||||||
    this.localParticipant.audioMuted = false;
 | 
					    this.localParticipant.audioMuted = false;
 | 
				
			||||||
    this.localParticipant.videoMuted = false;
 | 
					    this.localParticipant.videoMuted = false;
 | 
				
			||||||
 | 
					    this.localParticipant.speaking = false;
 | 
				
			||||||
    this.audioMuted = false;
 | 
					    this.audioMuted = false;
 | 
				
			||||||
    this.videoMuted = false;
 | 
					    this.videoMuted = false;
 | 
				
			||||||
    clearTimeout(this._memberParticipantStateTimeout);
 | 
					    clearTimeout(this._memberParticipantStateTimeout);
 | 
				
			||||||
| 
						 | 
					@ -498,6 +501,11 @@ export class ConferenceCallManager extends EventEmitter {
 | 
				
			||||||
      remoteFeed.on("mute_state_changed", () =>
 | 
					      remoteFeed.on("mute_state_changed", () =>
 | 
				
			||||||
        this._onCallFeedMuteStateChanged(participant, remoteFeed)
 | 
					        this._onCallFeedMuteStateChanged(participant, remoteFeed)
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					      remoteFeed.setSpeakingThreshold(SPEAKING_THRESHOLD);
 | 
				
			||||||
 | 
					      remoteFeed.measureVolumeActivity(true);
 | 
				
			||||||
 | 
					      remoteFeed.on("speaking", (speaking) => {
 | 
				
			||||||
 | 
					        this._onCallFeedSpeaking(participant, speaking);
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const userId = call.opponentMember.userId;
 | 
					    const userId = call.opponentMember.userId;
 | 
				
			||||||
| 
						 | 
					@ -523,6 +531,7 @@ export class ConferenceCallManager extends EventEmitter {
 | 
				
			||||||
      existingParticipant.stream = stream;
 | 
					      existingParticipant.stream = stream;
 | 
				
			||||||
      existingParticipant.audioMuted = audioMuted;
 | 
					      existingParticipant.audioMuted = audioMuted;
 | 
				
			||||||
      existingParticipant.videoMuted = videoMuted;
 | 
					      existingParticipant.videoMuted = videoMuted;
 | 
				
			||||||
 | 
					      existingParticipant.speaking = false;
 | 
				
			||||||
      existingParticipant.sessionId = sessionId;
 | 
					      existingParticipant.sessionId = sessionId;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      participant = {
 | 
					      participant = {
 | 
				
			||||||
| 
						 | 
					@ -533,6 +542,7 @@ export class ConferenceCallManager extends EventEmitter {
 | 
				
			||||||
        stream,
 | 
					        stream,
 | 
				
			||||||
        audioMuted,
 | 
					        audioMuted,
 | 
				
			||||||
        videoMuted,
 | 
					        videoMuted,
 | 
				
			||||||
 | 
					        speaking: false,
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
      this.participants.push(participant);
 | 
					      this.participants.push(participant);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -623,6 +633,7 @@ export class ConferenceCallManager extends EventEmitter {
 | 
				
			||||||
      participant.stream = null;
 | 
					      participant.stream = null;
 | 
				
			||||||
      participant.audioMuted = false;
 | 
					      participant.audioMuted = false;
 | 
				
			||||||
      participant.videoMuted = false;
 | 
					      participant.videoMuted = false;
 | 
				
			||||||
 | 
					      participant.speaking = false;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      participant = {
 | 
					      participant = {
 | 
				
			||||||
        local: false,
 | 
					        local: false,
 | 
				
			||||||
| 
						 | 
					@ -632,6 +643,7 @@ export class ConferenceCallManager extends EventEmitter {
 | 
				
			||||||
        stream: null,
 | 
					        stream: null,
 | 
				
			||||||
        audioMuted: false,
 | 
					        audioMuted: false,
 | 
				
			||||||
        videoMuted: false,
 | 
					        videoMuted: false,
 | 
				
			||||||
 | 
					        speaking: false,
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
      // TODO: Should we wait until the call has been answered to push the participant?
 | 
					      // TODO: Should we wait until the call has been answered to push the participant?
 | 
				
			||||||
      // Or do we hide the participant until their stream is live?
 | 
					      // Or do we hide the participant until their stream is live?
 | 
				
			||||||
| 
						 | 
					@ -691,6 +703,11 @@ export class ConferenceCallManager extends EventEmitter {
 | 
				
			||||||
      remoteFeed.on("mute_state_changed", () =>
 | 
					      remoteFeed.on("mute_state_changed", () =>
 | 
				
			||||||
        this._onCallFeedMuteStateChanged(participant, remoteFeed)
 | 
					        this._onCallFeedMuteStateChanged(participant, remoteFeed)
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					      remoteFeed.setSpeakingThreshold(SPEAKING_THRESHOLD);
 | 
				
			||||||
 | 
					      remoteFeed.measureVolumeActivity(true);
 | 
				
			||||||
 | 
					      remoteFeed.on("speaking", (speaking) => {
 | 
				
			||||||
 | 
					        this._onCallFeedSpeaking(participant, speaking);
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
      this._onCallFeedMuteStateChanged(participant, remoteFeed);
 | 
					      this._onCallFeedMuteStateChanged(participant, remoteFeed);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
| 
						 | 
					@ -701,6 +718,11 @@ export class ConferenceCallManager extends EventEmitter {
 | 
				
			||||||
    this.emit("participants_changed");
 | 
					    this.emit("participants_changed");
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  _onCallFeedSpeaking = (participant, speaking) => {
 | 
				
			||||||
 | 
					    participant.speaking = speaking;
 | 
				
			||||||
 | 
					    this.emit("participants_changed");
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  _onCallReplaced = (participant, call, newCall) => {
 | 
					  _onCallReplaced = (participant, call, newCall) => {
 | 
				
			||||||
    participant.call = newCall;
 | 
					    participant.call = newCall;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -724,6 +746,11 @@ export class ConferenceCallManager extends EventEmitter {
 | 
				
			||||||
      remoteFeed.on("mute_state_changed", () =>
 | 
					      remoteFeed.on("mute_state_changed", () =>
 | 
				
			||||||
        this._onCallFeedMuteStateChanged(participant, remoteFeed)
 | 
					        this._onCallFeedMuteStateChanged(participant, remoteFeed)
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					      remoteFeed.setSpeakingThreshold(SPEAKING_THRESHOLD);
 | 
				
			||||||
 | 
					      remoteFeed.measureVolumeActivity(true);
 | 
				
			||||||
 | 
					      remoteFeed.on("speaking", (speaking) => {
 | 
				
			||||||
 | 
					        this._onCallFeedSpeaking(participant, speaking);
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.emit("call", newCall);
 | 
					    this.emit("call", newCall);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue