async _setupTransport({ localDtlsRole, localSdpObject }) { if (!localSdpObject) { const offer = await this._channel.request('handler.getLocalDescription', this._internal); localSdpObject = sdpTransform.parse(offer.sdp); } // Get our local DTLS parameters. const dtlsParameters = sdpCommonUtils.extractDtlsParameters({ sdpObject: localSdpObject }); // Set our DTLS role. dtlsParameters.role = localDtlsRole; // Update the remote DTLS role in the SDP. this._remoteSdp.updateDtlsRole(localDtlsRole === 'client' ? 'server' : 'client'); // Need to tell the remote transport about our parameters. await this.safeEmitAsPromise('@connect', { dtlsParameters }); this._transportReady = true; }
async stopSending(localId) { this._assertSendDirection(); logger.debug('stopSending() [localId:%s]', localId); // Remove the original track from our map and its events. const track = this._mapLocalIdTracks.get(localId); if (!track) throw new Error('associated track not found'); this._mapLocalIdTracks.delete(localId); // Remove the MID from the map. const mid = this._mapLocalIdMid.get(localId); if (!mid) throw new Error('associated MID not found'); this._mapLocalIdMid.delete(localId); await this._channel.request('handler.removeTrack', this._internal, { localId }); this._remoteSdp.disableMediaSection(mid); const offer = await this._channel.request('handler.createOffer', this._internal); logger.debug('stopSending() | calling handler.setLocalDescription() [offer:%o]', offer); await this._channel.request('handler.setLocalDescription', this._internal, offer); const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() }; logger.debug('stopSending() | calling handler.setRemoteDescription() [answer:%o]', answer); await this._channel.request('handler.setRemoteDescription', this._internal, answer); }
async stopReceiving(localId) { this._assertRecvDirection(); logger.debug('stopReceiving() [localId:%s]', localId); // Remove the remote track from the map and make it emit 'ended'. const track = this._mapLocalIdTracks.get(localId); if (!track) throw new Error('associated track not found'); this._mapLocalIdTracks.delete(localId); track.remoteStop(); const mid = this._mapLocalIdMid.get(localId); if (!mid) throw new Error('associated MID not found'); this._remoteSdp.closeMediaSection(mid); const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() }; logger.debug('stopReceiving() | calling handler.setRemoteDescription() [offer:%o]', offer); await this._channel.request('handler.setRemoteDescription', this._internal, offer); const answer = await this._channel.request('handler.createAnswer', this._internal); logger.debug('stopReceiving() | calling handler.setLocalDescription() [answer:%o]', answer); await this._channel.request('handler.setLocalDescription', this._internal, answer); }
logger.debug('sendDataChannel() | calling handler.setLocalDescription() [offer:%o]', offer); await this._channel.request('handler.setLocalDescription', this._internal, offer); this._remoteSdp.sendSctpAssociation({ offerMediaObject }); const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() }; logger.debug('sendDataChannel() | calling handler.setRemoteDescription() [answer:%o]', answer); await this._channel.request('handler.setRemoteDescription', this._internal, answer);
const localId = rtpParameters.mid || String(this._mapLocalIdMid.size); const mid = localId; this._remoteSdp.receive({ mid, kind, trackId }); const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() }; logger.debug('receive() | calling handler.setRemoteDescription() [offer:%o]', offer); await this._channel.request('handler.setRemoteDescription', this._internal, offer);
this._remoteSdp.receiveSctpAssociation(); const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() }; logger.debug('receiveDataChannel() | calling handler.setRemoteDescription() [offer:%o]', offer); await this._channel.request('handler.setRemoteDescription', this._internal, offer);
this._remoteSdp.receiveSctpAssociation(); const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
offer as RTCSessionDescription); this._remoteSdp.sendSctpAssociation({ offerMediaObject }); const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
this._remoteSdp.updateDtlsRole( localDtlsRole === 'client' ? 'server' : 'client');
'handler.removeTrack', this._internal, { localId }); this._remoteSdp.disableMediaSection(mid); offer as RTCSessionDescription); const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
throw new Error('associated MID not found'); this._remoteSdp.closeMediaSection(mid); const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
this._remoteSdp.send({ offerMediaObject, reuseMid: '', extmapAllowMixed: false }); const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() }; logger.debug('send() | calling handler.setRemoteDescription() [answer:%o]', answer); await this._channel.request('handler.setRemoteDescription', this._internal, answer);