yjz-web-sdk 1.0.11-beta.2 → 1.0.11-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/WebRTCSdk.d.ts +0 -2
- package/lib/core/rtc/WebRTCClient.d.ts +7 -3
- package/lib/yjz-web-sdk.js +69 -105
- package/package.json +1 -1
package/lib/core/WebRTCSdk.d.ts
CHANGED
|
@@ -12,8 +12,6 @@ export declare class WebRTCSdk extends EventEmitter {
|
|
|
12
12
|
options: WebRTCConfigOptions;
|
|
13
13
|
isConnected: boolean;
|
|
14
14
|
isConnecting: boolean;
|
|
15
|
-
private connectCount;
|
|
16
|
-
private MAX_COUNT;
|
|
17
15
|
private timeout;
|
|
18
16
|
constructor(options: WebRTCConfigOptions);
|
|
19
17
|
initConfig(): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3';
|
|
2
|
-
import type { WebRTCConfig } from "./WebRTCConfig
|
|
3
|
-
import { ChannelDataType } from "../data/WebrtcDataType
|
|
2
|
+
import type { WebRTCConfig } from "./WebRTCConfig";
|
|
3
|
+
import { ChannelDataType } from "../data/WebrtcDataType";
|
|
4
4
|
export declare class WebRTCClient extends EventEmitter {
|
|
5
5
|
private readonly config;
|
|
6
6
|
private peerConnection;
|
|
@@ -9,6 +9,7 @@ export declare class WebRTCClient extends EventEmitter {
|
|
|
9
9
|
private isPushingStream;
|
|
10
10
|
private isPushingLocalStream;
|
|
11
11
|
private dataChannel;
|
|
12
|
+
private videoDataChannel;
|
|
12
13
|
private statsTimer;
|
|
13
14
|
private lastReportTime;
|
|
14
15
|
private lastBytesReceived;
|
|
@@ -18,6 +19,8 @@ export declare class WebRTCClient extends EventEmitter {
|
|
|
18
19
|
private maxLostRate;
|
|
19
20
|
private lastSecondDecodedCount;
|
|
20
21
|
private fileVideo?;
|
|
22
|
+
private videoTransceiver?;
|
|
23
|
+
private audioTransceiver?;
|
|
21
24
|
private canvas?;
|
|
22
25
|
private canvasStream;
|
|
23
26
|
private rafId;
|
|
@@ -37,8 +40,9 @@ export declare class WebRTCClient extends EventEmitter {
|
|
|
37
40
|
switchCamera(useBackCamera: boolean): Promise<void>;
|
|
38
41
|
private getRotatedStream;
|
|
39
42
|
private setVideoParams;
|
|
40
|
-
stopPush(): void
|
|
43
|
+
stopPush(): Promise<void>;
|
|
41
44
|
private resetPeerConnection;
|
|
45
|
+
private onConnected;
|
|
42
46
|
private configDataChannel;
|
|
43
47
|
private handleDataChannelMessage;
|
|
44
48
|
private checkStats;
|
package/lib/yjz-web-sdk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode(".vContainer[data-v-
|
|
1
|
+
!function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode(".vContainer[data-v-ae395fc8]{transition:transform .2s linear;transform-origin:center center;margin:0;overflow:hidden;background:transparent;transform:translateZ(0);will-change:transform}.flex[data-v-ae395fc8]{display:flex}.flex-1[data-v-ae395fc8]{flex:1 1 0}.items-center[data-v-ae395fc8]{align-items:center}.justify-center[data-v-ae395fc8]{justify-content:center}.video-control[data-v-ae395fc8]{width:100%;height:100%;display:block;-webkit-user-select:none;user-select:none;object-fit:cover;background:transparent;clip-path:inset(0 1px);-webkit-user-drag:none;touch-action:none;backface-visibility:hidden;-webkit-backface-visibility:hidden;transform:translateZ(0)}.circle-cursor[data-v-ae395fc8]{cursor:url(\"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20fill='none'%3e%3ccircle%20cx='12'%20cy='12'%20r='12'%20fill='%23fff'%20opacity='.6'/%3e%3ccircle%20cx='12'%20cy='12'%20r='10'%20fill='%23000'%20opacity='.6'/%3e%3c/svg%3e\") 12 12,auto}.triangle-cursor[data-v-ae395fc8]{cursor:url(\"data:image/svg+xml,%3csvg%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='22'%20height='22'%3e%3cpath%20d='M143.832313%205.834982H143.686438A108.676545%20108.676545%200%200%200%205.834982%20143.686438l34.499333-11.815839-34.499333%2011.815839%200.072938%200.218812%200.145874%200.437624%200.583498%201.750494%202.333993%206.71023%208.752474%2025.528047L49.232663%20269.867929a2254749.467572%202254749.467572%200%200%201%20223.917444%20652.351017l9.335972%2027.205605%202.552804%207.585476%200.729373%202.188119a72.572592%2072.572592%200%200%200%20126.181491%2040.844876%2072.134968%2072.134968%200%200%200%2014.076895-18.963693c3.282178-6.41848%205.689108-13.639271%208.023101-20.3495l0.072937-0.291749%2072.572592-209.329989%2047.409231-136.830334%2015.53564-44.710551%200.145874-0.364687%200.510561-0.145874%2045.002301-15.900327%20137.486769-48.649165c99.340573-35.228705%20202.984445-71.989094%20209.913487-74.906584l3.355115-1.312871c8.023101-3.136303%2022.391744-8.606599%2033.915834-20.130689a72.499655%2072.499655%200%200%200%200-102.549813L999.240712%20304.877823c-1.823432-1.969307-7.293728-7.731351-13.274585-11.961714a89.056417%2089.056417%200%200%200-27.205605-12.3264h-0.145874l-2.552805-0.875247L948.184617%20277.161657l-27.86204-9.263034-94.672588-31.800653A405018.007245%20405018.007245%200%200%201%20268.919745%2048.138604L178.039896%2017.504947%20152.657723%208.752473%20145.874556%206.637292%20144.196999%205.90792%20143.832313%205.834982z'%20fill='%23000000'%20opacity='.7'%3e%3c/path%3e%3c/svg%3e\") 1 1,auto}.default-cursor[data-v-ae395fc8]{cursor:default}.no-events[data-v-ae395fc8]{pointer-events:none!important}.ime-input[data-v-ae395fc8]{position:absolute;opacity:0;right:0;bottom:0;width:1px;height:1px;border:none;outline:none;resize:none;z-index:-1}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -3571,7 +3571,6 @@ const formattedTime = (timestamp) => {
|
|
|
3571
3571
|
return `${h}:${m}:${s}.${ms}`;
|
|
3572
3572
|
};
|
|
3573
3573
|
class WebRTCClient extends EventEmitter {
|
|
3574
|
-
// private isFireFox: boolean = false;
|
|
3575
3574
|
constructor(config) {
|
|
3576
3575
|
super();
|
|
3577
3576
|
__publicField(this, "config");
|
|
@@ -3581,6 +3580,7 @@ class WebRTCClient extends EventEmitter {
|
|
|
3581
3580
|
__publicField(this, "isPushingStream", false);
|
|
3582
3581
|
__publicField(this, "isPushingLocalStream", false);
|
|
3583
3582
|
__publicField(this, "dataChannel", null);
|
|
3583
|
+
__publicField(this, "videoDataChannel", null);
|
|
3584
3584
|
__publicField(this, "statsTimer");
|
|
3585
3585
|
__publicField(this, "lastReportTime", 0);
|
|
3586
3586
|
__publicField(this, "lastBytesReceived", 0);
|
|
@@ -3590,27 +3590,19 @@ class WebRTCClient extends EventEmitter {
|
|
|
3590
3590
|
__publicField(this, "maxLostRate", 0);
|
|
3591
3591
|
__publicField(this, "lastSecondDecodedCount", 0);
|
|
3592
3592
|
__publicField(this, "fileVideo");
|
|
3593
|
+
__publicField(this, "videoTransceiver");
|
|
3594
|
+
__publicField(this, "audioTransceiver");
|
|
3593
3595
|
__publicField(this, "canvas");
|
|
3594
3596
|
__publicField(this, "canvasStream", null);
|
|
3595
3597
|
__publicField(this, "rafId", 0);
|
|
3596
3598
|
__publicField(this, "currentMedia", null);
|
|
3597
3599
|
__publicField(this, "fileImage");
|
|
3598
3600
|
__publicField(this, "startPushLocal", async (file) => {
|
|
3599
|
-
var _a;
|
|
3600
3601
|
if (this.isPushingLocalStream || !file) return;
|
|
3601
3602
|
try {
|
|
3602
3603
|
await this.loadMedia(file);
|
|
3603
|
-
this.startCanvasStream();
|
|
3604
|
-
|
|
3605
|
-
(_a = this.canvasStream) == null ? void 0 : _a.getTracks().forEach((track) => {
|
|
3606
|
-
track.contentHint = "detail";
|
|
3607
|
-
const sender = this.peerConnection.addTrack(track, this.canvasStream);
|
|
3608
|
-
senders.push(sender);
|
|
3609
|
-
});
|
|
3610
|
-
senders.forEach((sender) => this.setVideoParams(sender));
|
|
3611
|
-
await createOffer(this.peerConnection, (sdp2) => {
|
|
3612
|
-
this.emit(EmitType.sendOffer, sdp2);
|
|
3613
|
-
});
|
|
3604
|
+
this.rotatedStream = this.startCanvasStream();
|
|
3605
|
+
await this.onConnected();
|
|
3614
3606
|
this.isPushingLocalStream = true;
|
|
3615
3607
|
} catch (err) {
|
|
3616
3608
|
this.isPushingLocalStream = false;
|
|
@@ -3711,6 +3703,7 @@ class WebRTCClient extends EventEmitter {
|
|
|
3711
3703
|
}
|
|
3712
3704
|
}
|
|
3713
3705
|
closeConnection() {
|
|
3706
|
+
var _a, _b;
|
|
3714
3707
|
Logger.info("信息日志:", "关闭webrtc连接=======>");
|
|
3715
3708
|
if (this.statsTimer) {
|
|
3716
3709
|
clearInterval(this.statsTimer);
|
|
@@ -3721,27 +3714,30 @@ class WebRTCClient extends EventEmitter {
|
|
|
3721
3714
|
if (this.peerConnection) {
|
|
3722
3715
|
if (typeof this.peerConnection.getSenders === "function" && this.peerConnection.getSenders) {
|
|
3723
3716
|
this.peerConnection.getSenders().forEach((sender) => {
|
|
3724
|
-
var
|
|
3717
|
+
var _a2, _b2;
|
|
3725
3718
|
if (sender.track) {
|
|
3726
|
-
(
|
|
3719
|
+
(_b2 = (_a2 = sender.track).stop) == null ? void 0 : _b2.call(_a2);
|
|
3727
3720
|
}
|
|
3728
3721
|
});
|
|
3729
3722
|
}
|
|
3730
3723
|
if (typeof this.peerConnection.getReceivers === "function" && this.peerConnection.getReceivers) {
|
|
3731
3724
|
this.peerConnection.getReceivers().forEach((receiver) => {
|
|
3732
|
-
var
|
|
3725
|
+
var _a2, _b2;
|
|
3733
3726
|
if (receiver.track) {
|
|
3734
|
-
(
|
|
3727
|
+
(_b2 = (_a2 = receiver.track).stop) == null ? void 0 : _b2.call(_a2);
|
|
3735
3728
|
}
|
|
3736
3729
|
});
|
|
3737
3730
|
}
|
|
3738
3731
|
if (this.peerConnection.getTransceivers) {
|
|
3739
3732
|
this.peerConnection.getTransceivers().forEach((transceiver) => {
|
|
3740
|
-
var
|
|
3741
|
-
(
|
|
3733
|
+
var _a2;
|
|
3734
|
+
(_a2 = transceiver.stop) == null ? void 0 : _a2.call(transceiver);
|
|
3742
3735
|
});
|
|
3743
3736
|
}
|
|
3744
3737
|
this.removeAllListeners();
|
|
3738
|
+
(_a = this.videoDataChannel) == null ? void 0 : _a.close();
|
|
3739
|
+
this.videoDataChannel = null;
|
|
3740
|
+
(_b = this.dataChannel) == null ? void 0 : _b.close();
|
|
3745
3741
|
this.dataChannel = null;
|
|
3746
3742
|
this.peerConnection.onicecandidate = null;
|
|
3747
3743
|
this.peerConnection.ontrack = null;
|
|
@@ -3756,31 +3752,20 @@ class WebRTCClient extends EventEmitter {
|
|
|
3756
3752
|
}
|
|
3757
3753
|
}
|
|
3758
3754
|
async readyCapture(useBackCamera) {
|
|
3759
|
-
this.resetPeerConnection();
|
|
3760
|
-
this.stopPush();
|
|
3755
|
+
await this.resetPeerConnection();
|
|
3761
3756
|
Logger.info("信息日志:", "启用摄像头推流到云机=======>", useBackCamera);
|
|
3762
3757
|
try {
|
|
3763
3758
|
this.localStream = await navigator.mediaDevices.getUserMedia({
|
|
3764
3759
|
video: {
|
|
3765
3760
|
width: { ideal: 960 },
|
|
3766
|
-
height: { ideal:
|
|
3761
|
+
height: { ideal: 540 },
|
|
3767
3762
|
facingMode: useBackCamera ? { ideal: "environment" } : { ideal: "user" },
|
|
3768
3763
|
frameRate: { ideal: 20, max: 30 }
|
|
3769
3764
|
},
|
|
3770
3765
|
audio: true
|
|
3771
3766
|
});
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
this.rotatedStream = rotatedStream;
|
|
3775
|
-
rotatedStream.getTracks().forEach((track) => {
|
|
3776
|
-
track.contentHint = "motion";
|
|
3777
|
-
const sender = this.peerConnection.addTrack(track, rotatedStream);
|
|
3778
|
-
senders.push(sender);
|
|
3779
|
-
});
|
|
3780
|
-
await createOffer(this.peerConnection, (sdp2) => {
|
|
3781
|
-
this.emit(EmitType.sendOffer, sdp2);
|
|
3782
|
-
});
|
|
3783
|
-
senders.forEach((sender) => this.setVideoParams(sender));
|
|
3767
|
+
this.rotatedStream = await this.getRotatedStream(this.localStream, useBackCamera);
|
|
3768
|
+
await this.onConnected();
|
|
3784
3769
|
} catch (err) {
|
|
3785
3770
|
if (err instanceof DOMException) {
|
|
3786
3771
|
switch (err.name) {
|
|
@@ -3803,27 +3788,22 @@ class WebRTCClient extends EventEmitter {
|
|
|
3803
3788
|
* ✅ 切换前后摄像头(无缝)
|
|
3804
3789
|
*/
|
|
3805
3790
|
async switchCamera(useBackCamera) {
|
|
3806
|
-
var _a;
|
|
3807
3791
|
try {
|
|
3808
3792
|
Logger.info("信息日志:", `切换摄像头 => ${useBackCamera ? "后置" : "前置"}`);
|
|
3809
3793
|
this.isPushingStream = true;
|
|
3810
3794
|
this.localStream = await navigator.mediaDevices.getUserMedia({
|
|
3811
3795
|
video: {
|
|
3812
3796
|
width: { ideal: 960 },
|
|
3813
|
-
height: { ideal:
|
|
3797
|
+
height: { ideal: 540 },
|
|
3814
3798
|
facingMode: useBackCamera ? { ideal: "environment" } : { ideal: "user" },
|
|
3815
3799
|
frameRate: { ideal: 20, max: 30 }
|
|
3816
3800
|
},
|
|
3817
|
-
audio:
|
|
3801
|
+
audio: true
|
|
3818
3802
|
// 音频不需要重新采集
|
|
3819
3803
|
});
|
|
3820
3804
|
const rotatedStream = await this.getRotatedStream(this.localStream, useBackCamera);
|
|
3821
3805
|
this.rotatedStream = rotatedStream;
|
|
3822
|
-
|
|
3823
|
-
const sender = (_a = this.peerConnection) == null ? void 0 : _a.getSenders().find((s) => s.track && s.track.kind === "video");
|
|
3824
|
-
if (sender) {
|
|
3825
|
-
await sender.replaceTrack(newTrack);
|
|
3826
|
-
}
|
|
3806
|
+
await this.onConnected();
|
|
3827
3807
|
} catch (err) {
|
|
3828
3808
|
this.isPushingStream = false;
|
|
3829
3809
|
if (err instanceof DOMException) {
|
|
@@ -3897,18 +3877,6 @@ class WebRTCClient extends EventEmitter {
|
|
|
3897
3877
|
});
|
|
3898
3878
|
return stream;
|
|
3899
3879
|
}
|
|
3900
|
-
// private async setVideoParams(sender: RTCRtpSender) {
|
|
3901
|
-
// Logger.info('信息日志:', '设置推流视频参数=======>')
|
|
3902
|
-
// const params = sender.getParameters();
|
|
3903
|
-
// params.degradationPreference = 'balanced';
|
|
3904
|
-
// const isMobile = /Android|iPhone|iPad/i.test(navigator.userAgent);
|
|
3905
|
-
// params.encodings.forEach(encoding => {
|
|
3906
|
-
// encoding.maxBitrate = isMobile ? 800000 : 1000000;
|
|
3907
|
-
// encoding.priority = 'high';
|
|
3908
|
-
// encoding.scaleResolutionDownBy = 1.0;
|
|
3909
|
-
// });
|
|
3910
|
-
// await sender.setParameters(params);
|
|
3911
|
-
// }
|
|
3912
3880
|
async setVideoParams(sender) {
|
|
3913
3881
|
const params = sender.getParameters();
|
|
3914
3882
|
const isMobile = /Android|iPhone|iPad/i.test(navigator.userAgent);
|
|
@@ -3931,40 +3899,60 @@ class WebRTCClient extends EventEmitter {
|
|
|
3931
3899
|
Logger.error("设置推流参数失败:", e);
|
|
3932
3900
|
}
|
|
3933
3901
|
}
|
|
3934
|
-
stopPush() {
|
|
3935
|
-
var _a, _b, _c;
|
|
3902
|
+
async stopPush() {
|
|
3903
|
+
var _a, _b, _c, _d;
|
|
3904
|
+
Logger.info("信息日志:", `停止推流到云机=======>${this.isPushingStream}`);
|
|
3936
3905
|
if (!this.isPushingStream) return;
|
|
3937
3906
|
this.isPushingStream = false;
|
|
3938
|
-
Logger.info("信息日志:", "停止推流到云机=======>");
|
|
3939
3907
|
(_a = this.localStream) == null ? void 0 : _a.getTracks().forEach((track) => track.stop());
|
|
3940
3908
|
this.localStream = null;
|
|
3941
3909
|
(_b = this.rotatedStream) == null ? void 0 : _b.getTracks().forEach((track) => track.stop());
|
|
3942
3910
|
this.rotatedStream = null;
|
|
3943
|
-
(_c = this.
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
}
|
|
3950
|
-
});
|
|
3911
|
+
if ((_c = this.videoTransceiver) == null ? void 0 : _c.sender) {
|
|
3912
|
+
await this.videoTransceiver.sender.replaceTrack(null);
|
|
3913
|
+
}
|
|
3914
|
+
if ((_d = this.audioTransceiver) == null ? void 0 : _d.sender) {
|
|
3915
|
+
await this.audioTransceiver.sender.replaceTrack(null);
|
|
3916
|
+
}
|
|
3951
3917
|
}
|
|
3952
|
-
resetPeerConnection() {
|
|
3918
|
+
async resetPeerConnection() {
|
|
3953
3919
|
if (!this.peerConnection) {
|
|
3954
3920
|
this.peerConnection = createPeerConnection(this.config);
|
|
3921
|
+
this.videoTransceiver = this.peerConnection.addTransceiver("video", {
|
|
3922
|
+
direction: "sendrecv"
|
|
3923
|
+
});
|
|
3924
|
+
this.audioTransceiver = this.peerConnection.addTransceiver("audio", {
|
|
3925
|
+
direction: "sendrecv"
|
|
3926
|
+
});
|
|
3955
3927
|
configPeerConnection(this.peerConnection, (candidate) => {
|
|
3956
3928
|
this.emit(EmitType.sendICEMessage, candidate);
|
|
3957
3929
|
}, (track) => {
|
|
3958
3930
|
this.emit(EmitType.streamTrack, track);
|
|
3959
|
-
}, (state) => {
|
|
3931
|
+
}, async (state) => {
|
|
3960
3932
|
this.emit(EmitType.iceConnectionState, state);
|
|
3961
3933
|
if (state === "connected") {
|
|
3962
3934
|
this.checkStats();
|
|
3935
|
+
await createOffer(this.peerConnection, (sdp2) => {
|
|
3936
|
+
this.emit(EmitType.sendOffer, sdp2);
|
|
3937
|
+
});
|
|
3963
3938
|
}
|
|
3964
3939
|
}, (err) => this.emit(EmitType.webrtcError, err));
|
|
3965
3940
|
this.configDataChannel();
|
|
3966
3941
|
}
|
|
3967
3942
|
}
|
|
3943
|
+
async onConnected() {
|
|
3944
|
+
var _a, _b;
|
|
3945
|
+
Logger.info("信息日志:", "WebRTC connected,启用轨道");
|
|
3946
|
+
if (this.rotatedStream && ((_a = this.videoTransceiver) == null ? void 0 : _a.sender)) {
|
|
3947
|
+
const videoTrack = this.rotatedStream.getVideoTracks()[0];
|
|
3948
|
+
await this.videoTransceiver.sender.replaceTrack(videoTrack);
|
|
3949
|
+
await this.setVideoParams(this.videoTransceiver.sender);
|
|
3950
|
+
}
|
|
3951
|
+
if (this.localStream && ((_b = this.audioTransceiver) == null ? void 0 : _b.sender)) {
|
|
3952
|
+
const audioTrack = this.localStream.getAudioTracks()[0];
|
|
3953
|
+
await this.audioTransceiver.sender.replaceTrack(audioTrack);
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
3968
3956
|
configDataChannel() {
|
|
3969
3957
|
this.peerConnection.ondatachannel = (event) => {
|
|
3970
3958
|
this.dataChannel = event.channel;
|
|
@@ -3973,19 +3961,19 @@ class WebRTCClient extends EventEmitter {
|
|
|
3973
3961
|
this.sendChannelData(ChannelDataType.ActionRequestCloudDeviceInfo, "");
|
|
3974
3962
|
};
|
|
3975
3963
|
}
|
|
3976
|
-
handleDataChannelMessage(event) {
|
|
3964
|
+
async handleDataChannelMessage(event) {
|
|
3977
3965
|
const data = JSON.parse(event.data);
|
|
3978
3966
|
if (data.type === ChannelDataType.ActionCommandEvent) {
|
|
3979
3967
|
const { action, value, cameraId } = JSON.parse(data.data);
|
|
3980
3968
|
if (action === "ACTION_CONTROL_VIDEO") {
|
|
3981
3969
|
if (value === "ENABLE") {
|
|
3982
3970
|
if (this.isPushingStream) {
|
|
3983
|
-
this.switchCamera(Number(cameraId) === 0);
|
|
3971
|
+
await this.switchCamera(Number(cameraId) === 0);
|
|
3984
3972
|
} else {
|
|
3985
|
-
this.startPush(Number(cameraId) === 0);
|
|
3973
|
+
await this.startPush(Number(cameraId) === 0);
|
|
3986
3974
|
}
|
|
3987
3975
|
} else {
|
|
3988
|
-
this.stopPush();
|
|
3976
|
+
await this.stopPush();
|
|
3989
3977
|
this.stopLocal();
|
|
3990
3978
|
}
|
|
3991
3979
|
}
|
|
@@ -4133,8 +4121,7 @@ class WebRTCClient extends EventEmitter {
|
|
|
4133
4121
|
}
|
|
4134
4122
|
if (kind === "video") {
|
|
4135
4123
|
return new Promise((resolve, reject) => {
|
|
4136
|
-
|
|
4137
|
-
video.src = url;
|
|
4124
|
+
video.src = URL.createObjectURL(file);
|
|
4138
4125
|
video.onloadedmetadata = () => resolve();
|
|
4139
4126
|
video.onerror = () => reject(new Error(`视频文件加载失败: ${file.name}`));
|
|
4140
4127
|
video.play().catch((err) => reject(new Error(`视频播放失败: ${err}`)));
|
|
@@ -4142,8 +4129,7 @@ class WebRTCClient extends EventEmitter {
|
|
|
4142
4129
|
});
|
|
4143
4130
|
} else if (kind === "image") {
|
|
4144
4131
|
return new Promise((resolve, reject) => {
|
|
4145
|
-
|
|
4146
|
-
img.src = url;
|
|
4132
|
+
img.src = URL.createObjectURL(file);
|
|
4147
4133
|
img.onload = () => resolve();
|
|
4148
4134
|
img.onerror = () => reject(new Error(`图片文件加载失败: ${file.name}`));
|
|
4149
4135
|
this.currentMedia = img;
|
|
@@ -4209,20 +4195,12 @@ class WebRTCClient extends EventEmitter {
|
|
|
4209
4195
|
}
|
|
4210
4196
|
/** 停止推流并释放资源 */
|
|
4211
4197
|
stopLocal() {
|
|
4212
|
-
var _a
|
|
4198
|
+
var _a;
|
|
4213
4199
|
if (!this.isPushingLocalStream) return;
|
|
4214
4200
|
this.isPushingLocalStream = false;
|
|
4215
4201
|
cancelAnimationFrame(this.rafId);
|
|
4216
4202
|
(_a = this.canvasStream) == null ? void 0 : _a.getTracks().forEach((track) => track.stop());
|
|
4217
4203
|
this.canvasStream = null;
|
|
4218
|
-
(_b = this.peerConnection) == null ? void 0 : _b.getSenders().forEach((sender) => {
|
|
4219
|
-
var _a2;
|
|
4220
|
-
try {
|
|
4221
|
-
(_a2 = this.peerConnection) == null ? void 0 : _a2.removeTrack(sender);
|
|
4222
|
-
} catch (e) {
|
|
4223
|
-
Logger.error("错误日志:", `移除音视频轨道失败=====>`, e);
|
|
4224
|
-
}
|
|
4225
|
-
});
|
|
4226
4204
|
if (this.fileVideo) {
|
|
4227
4205
|
this.fileVideo.pause();
|
|
4228
4206
|
this.fileVideo.src = "";
|
|
@@ -4320,8 +4298,8 @@ class WebRTCSdk extends EventEmitter {
|
|
|
4320
4298
|
__publicField(this, "options");
|
|
4321
4299
|
__publicField(this, "isConnected", false);
|
|
4322
4300
|
__publicField(this, "isConnecting", false);
|
|
4323
|
-
|
|
4324
|
-
|
|
4301
|
+
// private connectCount: number = 0
|
|
4302
|
+
// private MAX_COUNT: number = 1
|
|
4325
4303
|
__publicField(this, "timeout", null);
|
|
4326
4304
|
/**
|
|
4327
4305
|
* 处理 signal 消息,根据不同消息类型分发到 webRTCClient 或直接触发 SDK 事件
|
|
@@ -4489,9 +4467,6 @@ class WebRTCSdk extends EventEmitter {
|
|
|
4489
4467
|
}
|
|
4490
4468
|
}
|
|
4491
4469
|
}
|
|
4492
|
-
if (this.options.maxRecount) {
|
|
4493
|
-
this.MAX_COUNT = this.options.maxRecount;
|
|
4494
|
-
}
|
|
4495
4470
|
}
|
|
4496
4471
|
async initConfig() {
|
|
4497
4472
|
var _a, _b;
|
|
@@ -4611,14 +4586,8 @@ class WebRTCSdk extends EventEmitter {
|
|
|
4611
4586
|
(clipData) => this.emit(EmitType.cloudClipData, clipData)
|
|
4612
4587
|
);
|
|
4613
4588
|
(_h = this.webRTCClient) == null ? void 0 : _h.on(EmitType.webrtcError, (err) => {
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
this.emit(EmitType.reconnect);
|
|
4617
|
-
this.reconnect();
|
|
4618
|
-
} else {
|
|
4619
|
-
Logger.error("错误信息:", `sdk调试错误日志======>`, err);
|
|
4620
|
-
this.emit(EmitType.webrtcError, err);
|
|
4621
|
-
}
|
|
4589
|
+
Logger.error("错误信息:", `sdk调试错误日志======>`, err);
|
|
4590
|
+
this.emit(EmitType.webrtcError, err);
|
|
4622
4591
|
});
|
|
4623
4592
|
(_i = this.webRTCClient) == null ? void 0 : _i.on(EmitType.cameraError, (err) => {
|
|
4624
4593
|
this.emit(EmitType.cameraError, err);
|
|
@@ -4676,7 +4645,6 @@ class WebRTCSdk extends EventEmitter {
|
|
|
4676
4645
|
this.signalingClient = null;
|
|
4677
4646
|
this.webRTCClient = null;
|
|
4678
4647
|
this.config = null;
|
|
4679
|
-
this.connectCount = 0;
|
|
4680
4648
|
this.isConnected = false;
|
|
4681
4649
|
this.isConnecting = false;
|
|
4682
4650
|
}
|
|
@@ -5393,7 +5361,6 @@ function useKeyboardControl(imeInput, disabled, emit) {
|
|
|
5393
5361
|
const isComposing = ref(false);
|
|
5394
5362
|
const handleKeyDown = (e) => {
|
|
5395
5363
|
const data = getKeyEventData(e);
|
|
5396
|
-
console.log("handleKeyDown===>handleKeyDown");
|
|
5397
5364
|
emit("channelEvent", ChannelDataType.ActionInput, data);
|
|
5398
5365
|
};
|
|
5399
5366
|
function onCompositionStart(_e) {
|
|
@@ -5403,7 +5370,6 @@ function useKeyboardControl(imeInput, disabled, emit) {
|
|
|
5403
5370
|
isComposing.value = false;
|
|
5404
5371
|
const text = e.data;
|
|
5405
5372
|
if (text && text.length > 0) {
|
|
5406
|
-
console.log(`onCompositionEnd===>${text}`);
|
|
5407
5373
|
emit("channelEvent", ChannelDataType.ActionChinese, new InputData(text));
|
|
5408
5374
|
}
|
|
5409
5375
|
clearInput();
|
|
@@ -5433,7 +5399,6 @@ function useKeyboardControl(imeInput, disabled, emit) {
|
|
|
5433
5399
|
const text = e.data;
|
|
5434
5400
|
if (text && text.length > 0) {
|
|
5435
5401
|
emit("channelEvent", ChannelDataType.ActionChinese, new InputData(text));
|
|
5436
|
-
console.log("onInput===>", text);
|
|
5437
5402
|
}
|
|
5438
5403
|
clearInput();
|
|
5439
5404
|
};
|
|
@@ -5571,12 +5536,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
5571
5536
|
(...args) => unref(handleMouseLeave) && unref(handleMouseLeave)(...args)),
|
|
5572
5537
|
onWheel: _cache[5] || (_cache[5] = //@ts-ignore
|
|
5573
5538
|
(...args) => unref(handleWheel) && unref(handleWheel)(...args)),
|
|
5574
|
-
style: normalizeStyle({ backgroundColor: `${unref(bgColor)}` }),
|
|
5575
5539
|
autoplay: "",
|
|
5576
5540
|
playsinline: "",
|
|
5577
5541
|
muted: "",
|
|
5578
5542
|
disablePictureInPicture: true
|
|
5579
|
-
}, null,
|
|
5543
|
+
}, null, 34),
|
|
5580
5544
|
unref(isKeyMapping) ? (openBlock(), createElementBlock("textarea", {
|
|
5581
5545
|
key: 0,
|
|
5582
5546
|
ref_key: "imeInput",
|
|
@@ -5606,7 +5570,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
5606
5570
|
}
|
|
5607
5571
|
return target;
|
|
5608
5572
|
};
|
|
5609
|
-
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
5573
|
+
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ae395fc8"]]);
|
|
5610
5574
|
class SdkController extends EventEmitter {
|
|
5611
5575
|
constructor(config) {
|
|
5612
5576
|
super();
|