(target, args)
| 249 | // 获取webRTC流 |
| 250 | window.RTCPeerConnection = new Proxy(window.RTCPeerConnection, { |
| 251 | construct(target, args) { |
| 252 | const pc = new target(...args); |
| 253 | pc.addEventListener('track', (event) => { |
| 254 | const track = event.track; |
| 255 | if (track.kind === 'video' || track.kind === 'audio') { |
| 256 | tips(`${track.kind} ${i18n("streamAdded", "流已添加")}`); |
| 257 | $tracks[track.kind].appendChild(new Option(track.label, tracks[track.kind].length)); |
| 258 | $tracks[track.kind].value = tracks[track.kind].length; |
| 259 | tracks[track.kind].push(track); |
| 260 | if (tracks.video.length && tracks.audio.length) { |
| 261 | tips(i18n("videoAndAudio", "已包含音频和视频流")); |
| 262 | } |
| 263 | } |
| 264 | }); |
| 265 | pc.addEventListener('iceconnectionstatechange', (event) => { |
| 266 | if (pc.iceConnectionState === 'disconnected' && recorder?.state === 'recording') { |
| 267 | recorder.stop(); |
| 268 | tips(i18n("stopRecording", "连接已断开,录制已停止")); |
| 269 | } |
| 270 | }); |
| 271 | return pc; |
| 272 | } |
| 273 | }); |
| 274 | |
| 275 | // #region 移动逻辑 |
nothing calls this directly
no test coverage detected