* 设置远程 SDP * @param sdp SDP描述
(sdp: RTCSessionDescriptionInit)
| 177 | * @param sdp SDP描述 |
| 178 | */ |
| 179 | public async setRemoteSDP(sdp: RTCSessionDescriptionInit): Promise<void> { |
| 180 | try { |
| 181 | await this.pc.setRemoteDescription(sdp) |
| 182 | if (sdp.type === 'offer') { |
| 183 | const answer = await this.pc.createAnswer() |
| 184 | await this.pc.setLocalDescription(answer) |
| 185 | this.onSDP(answer) |
| 186 | } |
| 187 | } catch (e) { |
| 188 | console.error(e) |
| 189 | this.onError(e instanceof Error ? e : new Error('Error setting remote SDP')) |
| 190 | this.dispose() |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | /** |
| 195 | * 添加一个 ICE candidate |
no test coverage detected