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); }
throw new Error('associated MID not found'); this._remoteSdp.closeMediaSection(mid);