MCPcopy
hub / github.com/xifangczy/cat-catch / construct

Function construct

catch-script/webrtc.js:251–272  ·  view source on GitHub ↗
(target, args)

Source from the content-addressed store, hash-verified

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 移动逻辑

Callers

nothing calls this directly

Calls 5

tipsFunction · 0.85
addEventListenerMethod · 0.80
stopMethod · 0.80
i18nFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected