Skip to content

Commit

Permalink
wip webrtc
Browse files Browse the repository at this point in the history
Signed-off-by: DorraJaouad <[email protected]>
  • Loading branch information
DorraJaouad committed Oct 27, 2024
1 parent 442a743 commit 26b1d62
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/utils/webrtc/models/LocalCallParticipantModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ export default function LocalCallParticipantModel() {
guestName: null,
peerNeeded: false,
connectionState: null,
forcedCallViewMode: null,
})

this._handleForcedMuteBound = this._handleForcedMute.bind(this)
this._handleForcedCallViewModeBound = this._handleForcedCallViewMode.bind(this)
this._handleExtendedIceConnectionStateChangeBound = this._handleExtendedIceConnectionStateChange.bind(this)

}
Expand All @@ -49,15 +51,18 @@ LocalCallParticipantModel.prototype = {
setWebRtc(webRtc) {
if (this._webRtc) {
this._webRtc.off('forcedMute', this._handleForcedMuteBound)
this._webRtc.off('forcedCallViewMode', this._handleForcedCallViewModeBound)
this._unwatchDisplayNameChange()
}

this._webRtc = webRtc

this.set('peerId', this._webRtc.connection.getSessionId())
this.set('guestName', null)
this.set('forcedCallViewMode', null)

this._webRtc.on('forcedMute', this._handleForcedMuteBound)
this._webRtc.on('forcedCallViewMode', this._handleForcedCallViewModeBound)
this._unwatchDisplayNameChange = store.watch(state => state.actorStore.displayName, this.setGuestName.bind(this))
},

Expand Down Expand Up @@ -120,6 +125,10 @@ LocalCallParticipantModel.prototype = {
this._trigger('forcedMute')
},

_handleForcedCallViewMode(forcedCallViewMode) {
this.set('forcedCallViewMode', forcedCallViewMode)
},

_handleExtendedIceConnectionStateChange(extendedIceConnectionState) {
switch (extendedIceConnectionState) {
case 'new':
Expand Down Expand Up @@ -162,6 +171,16 @@ LocalCallParticipantModel.prototype = {
})
},

forceCallViewMode(callViewMode) {
if (!this._webRtc) {
throw new Error('WebRtc not initialized yet')
}

this._webRtc.sendToAll('control', {
action: 'forceCallViewMode',
callViewMode,
})
},
}

EmitterMixin.apply(LocalCallParticipantModel.prototype)
2 changes: 2 additions & 0 deletions src/utils/webrtc/simplewebrtc/simplewebrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ export default function SimpleWebRTC(opts) {
} else {
self.emit('mute', { id: message.payload.peerId })
}
} else if (message.payload.action === 'forceCallViewMode') {
self.emit('forcedCallViewMode', message.payload.callViewMode)
}
} else if (message.type === 'nickChanged') {
// "nickChanged" can be received from a participant without a Peer
Expand Down

0 comments on commit 26b1d62

Please sign in to comment.