yjz-web-sdk 1.0.2 → 1.0.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/composables/useKeyboardControl.d.ts +3 -3
- package/lib/core/WebRTCSdk.d.ts +1 -0
- package/lib/core/data/MessageType.d.ts +4 -2
- package/lib/core/data/WebRtcError.d.ts +3 -1
- package/lib/core/data/WebrtcDataType.d.ts +54 -1
- package/lib/core/groupctrl/GroupControllerManager.d.ts +22 -0
- package/lib/core/rtc/WebRTCConfig.d.ts +8 -0
- package/lib/core/signal/SignalingClient.d.ts +5 -0
- package/lib/core/util/KeyCodeUtil.d.ts +2 -2
- package/lib/index.d.ts +4 -2
- package/lib/yjz-web-sdk.css +1 -1
- package/lib/yjz-web-sdk.js +208 -36
- package/lib/yjz-web-sdk.umd.cjs +51 -36
- package/package.json +1 -2
package/lib/yjz-web-sdk.js
CHANGED
|
@@ -198,6 +198,7 @@ var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
|
|
198
198
|
MessageType2["NotAvailable"] = "NotAvailable";
|
|
199
199
|
MessageType2["Ping"] = "Ping";
|
|
200
200
|
MessageType2["Pong"] = "Pong";
|
|
201
|
+
MessageType2["SendScreenshot"] = "SendScreenshot";
|
|
201
202
|
return MessageType2;
|
|
202
203
|
})(MessageType || {});
|
|
203
204
|
var SendType = /* @__PURE__ */ ((SendType2) => {
|
|
@@ -208,6 +209,7 @@ var SendType = /* @__PURE__ */ ((SendType2) => {
|
|
|
208
209
|
SendType2["IceCandidates"] = "IceCandidates";
|
|
209
210
|
SendType2["Pong"] = "Pong";
|
|
210
211
|
SendType2["Identity"] = "Web";
|
|
212
|
+
SendType2["RequestScreenshot"] = "RequestScreenshot";
|
|
211
213
|
return SendType2;
|
|
212
214
|
})(SendType || {});
|
|
213
215
|
var FailCode = /* @__PURE__ */ ((FailCode2) => {
|
|
@@ -304,6 +306,8 @@ var EmitType = /* @__PURE__ */ ((EmitType2) => {
|
|
|
304
306
|
EmitType2["iceConnectionState"] = "iceConnectionState";
|
|
305
307
|
EmitType2["cloudStatusChanged"] = "cloudStatusChanged";
|
|
306
308
|
EmitType2["statisticInfo"] = "statisticInfo";
|
|
309
|
+
EmitType2["cloudClipData"] = "cloudClipData";
|
|
310
|
+
EmitType2["screenshot"] = "screenshot";
|
|
307
311
|
return EmitType2;
|
|
308
312
|
})(EmitType || {});
|
|
309
313
|
class SignalingClient extends EventEmitter {
|
|
@@ -323,7 +327,6 @@ class SignalingClient extends EventEmitter {
|
|
|
323
327
|
start() {
|
|
324
328
|
this.webSocket = new WebSocket(this.config.signalServerUrl);
|
|
325
329
|
this.webSocket.onopen = () => {
|
|
326
|
-
console.log("sendSignInMessagesendSignInMessagesendSignInMessage");
|
|
327
330
|
this.sendSignInMessage();
|
|
328
331
|
if (this.timeout === null) {
|
|
329
332
|
this.timeout = setTimeout(() => {
|
|
@@ -379,6 +382,23 @@ class SignalingClient extends EventEmitter {
|
|
|
379
382
|
type: SendType.SignIn,
|
|
380
383
|
identity: SendType.Identity,
|
|
381
384
|
turnServerUri: this.config.turnServerUri,
|
|
385
|
+
roomId: this.config.roomId,
|
|
386
|
+
isControl: this.config.isControl ? "true" : "false",
|
|
387
|
+
screenshotWidth: this.config.screenshotWidth,
|
|
388
|
+
screenshotHeight: this.config.screenshotHeight,
|
|
389
|
+
screenshotQuality: this.config.screenshotQuality
|
|
390
|
+
};
|
|
391
|
+
const jsonMessage = JSON.stringify(message);
|
|
392
|
+
this.sendMessage(jsonMessage);
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* 用于从控请求当前截屏
|
|
396
|
+
* @param visible 当前从控page控件是否可见
|
|
397
|
+
*/
|
|
398
|
+
sendRequestScreenshot(visible) {
|
|
399
|
+
const message = {
|
|
400
|
+
type: SendType.RequestScreenshot,
|
|
401
|
+
visible,
|
|
382
402
|
roomId: this.config.roomId
|
|
383
403
|
};
|
|
384
404
|
const jsonMessage = JSON.stringify(message);
|
|
@@ -2982,6 +3002,10 @@ class WebRTCConfig {
|
|
|
2982
3002
|
__publicField(this, "turnServerUri");
|
|
2983
3003
|
__publicField(this, "turnServerUserName");
|
|
2984
3004
|
__publicField(this, "turnServerPassword");
|
|
3005
|
+
__publicField(this, "isControl");
|
|
3006
|
+
__publicField(this, "screenshotWidth");
|
|
3007
|
+
__publicField(this, "screenshotHeight");
|
|
3008
|
+
__publicField(this, "screenshotQuality");
|
|
2985
3009
|
this.signalServerUrl = options.signalServerUrl || "";
|
|
2986
3010
|
this.myId = options.myId || "";
|
|
2987
3011
|
this.roomId = options.roomId || "";
|
|
@@ -2992,6 +3016,10 @@ class WebRTCConfig {
|
|
|
2992
3016
|
this.turnServerUri = options.turnServerUri || "turn:btweb.yajuzhen.com:3478";
|
|
2993
3017
|
this.turnServerUserName = options.turnServerUserName || "yangyj";
|
|
2994
3018
|
this.turnServerPassword = options.turnServerPassword || "hb@2025@168";
|
|
3019
|
+
this.isControl = options.isControl ?? true;
|
|
3020
|
+
this.screenshotWidth = options.screenshotWidth || 144;
|
|
3021
|
+
this.screenshotHeight = options.screenshotHeight || 256;
|
|
3022
|
+
this.screenshotQuality = options.screenshotQuality || 20;
|
|
2995
3023
|
}
|
|
2996
3024
|
}
|
|
2997
3025
|
const setRemoteDescriptionWithHandleOffer = (peerConnection, sdp2, sendAnswer, onError) => {
|
|
@@ -3006,7 +3034,6 @@ const setLocalDescriptionWithCreateAnswer = (peerConnection, answer, sendAnswer,
|
|
|
3006
3034
|
sendAnswer == null ? void 0 : sendAnswer(answer.sdp ?? "");
|
|
3007
3035
|
}).catch((error) => {
|
|
3008
3036
|
onError == null ? void 0 : onError(createWebRtcError(FailCode.LOCAL_DES, error));
|
|
3009
|
-
console.log("21321322212213");
|
|
3010
3037
|
});
|
|
3011
3038
|
};
|
|
3012
3039
|
const createPeerConnection = (config) => {
|
|
@@ -3045,14 +3072,14 @@ const configPeerConnection = (peerConnection, onICEMessage, onTrack, onConnectSt
|
|
|
3045
3072
|
if (!state) {
|
|
3046
3073
|
return;
|
|
3047
3074
|
}
|
|
3048
|
-
if (state === "failed") {
|
|
3075
|
+
if (state === "failed" || state === "disconnected") {
|
|
3049
3076
|
onError == null ? void 0 : onError(createWebRtcError(FailCode.ICE_STATE, "failed"));
|
|
3050
3077
|
}
|
|
3051
3078
|
onConnectState == null ? void 0 : onConnectState(state);
|
|
3052
3079
|
};
|
|
3053
3080
|
peerConnection.ontrack = (event) => {
|
|
3054
3081
|
const track = event.track;
|
|
3055
|
-
track.contentHint = "
|
|
3082
|
+
track.contentHint = "motion";
|
|
3056
3083
|
onTrack == null ? void 0 : onTrack(track);
|
|
3057
3084
|
};
|
|
3058
3085
|
};
|
|
@@ -3078,8 +3105,20 @@ var ChannelDataType = /* @__PURE__ */ ((ChannelDataType2) => {
|
|
|
3078
3105
|
ChannelDataType2["ActionRequestCloudDeviceInfo"] = "ActionRequestCloudDeviceInfo";
|
|
3079
3106
|
ChannelDataType2["ActionClarity"] = "ActionClarity";
|
|
3080
3107
|
ChannelDataType2["ActionWheel"] = "ActionWheel";
|
|
3108
|
+
ChannelDataType2["CloudClipData"] = "CloudClipData";
|
|
3109
|
+
ChannelDataType2["ActionCommandEvent"] = "ActionCommandEvent";
|
|
3110
|
+
ChannelDataType2["ActionUpdateCloudStatus"] = "ActionUpdateCloudStatus";
|
|
3111
|
+
ChannelDataType2["ActionGesture"] = "ActionGesture";
|
|
3081
3112
|
return ChannelDataType2;
|
|
3082
3113
|
})(ChannelDataType || {});
|
|
3114
|
+
var ActionCommandType = /* @__PURE__ */ ((ActionCommandType2) => {
|
|
3115
|
+
ActionCommandType2["ActionBack"] = "ActionBack";
|
|
3116
|
+
ActionCommandType2["ActionHome"] = "ActionHome";
|
|
3117
|
+
ActionCommandType2["ActionRecent"] = "ActionRecent";
|
|
3118
|
+
ActionCommandType2["ActionSwitchNavButtons"] = "ActionSwitchNavButtons";
|
|
3119
|
+
ActionCommandType2["ActionSwitchNavGestural"] = "ActionSwitchNavGestural";
|
|
3120
|
+
return ActionCommandType2;
|
|
3121
|
+
})(ActionCommandType || {});
|
|
3083
3122
|
const ActionType = {
|
|
3084
3123
|
ACTION_DOWN: 0,
|
|
3085
3124
|
ACTION_MOVE: 2,
|
|
@@ -3129,6 +3168,12 @@ class KeyEventData {
|
|
|
3129
3168
|
this.meta = meta;
|
|
3130
3169
|
}
|
|
3131
3170
|
}
|
|
3171
|
+
class GestureData {
|
|
3172
|
+
constructor(mode) {
|
|
3173
|
+
__publicField(this, "mode");
|
|
3174
|
+
this.mode = mode;
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3132
3177
|
class ChannelData {
|
|
3133
3178
|
constructor(type, data = null) {
|
|
3134
3179
|
__publicField(this, "type");
|
|
@@ -3155,6 +3200,9 @@ class ChannelData {
|
|
|
3155
3200
|
static click(touchData) {
|
|
3156
3201
|
return new ChannelData("ClickData", this.formatData(touchData));
|
|
3157
3202
|
}
|
|
3203
|
+
static action(actionData) {
|
|
3204
|
+
return new ChannelData("ActionCommand", this.formatData(actionData));
|
|
3205
|
+
}
|
|
3158
3206
|
/**
|
|
3159
3207
|
* 生成剪贴板数据
|
|
3160
3208
|
* @param data 剪贴板数据,可以是字符串或其他类型
|
|
@@ -3176,6 +3224,13 @@ class ChannelData {
|
|
|
3176
3224
|
static wheel(data) {
|
|
3177
3225
|
return new ChannelData("ActionWheel", this.formatData(data));
|
|
3178
3226
|
}
|
|
3227
|
+
/**
|
|
3228
|
+
* 切换手势模式数据
|
|
3229
|
+
* @param data 输入数据对象
|
|
3230
|
+
*/
|
|
3231
|
+
static gesture(data) {
|
|
3232
|
+
return new ChannelData("ActionGesture", this.formatData(data));
|
|
3233
|
+
}
|
|
3179
3234
|
/**
|
|
3180
3235
|
* 生成中文输入数据
|
|
3181
3236
|
* @param data 中文输入数据
|
|
@@ -3262,6 +3317,12 @@ class WebRTCClient extends EventEmitter {
|
|
|
3262
3317
|
case ChannelDataType.ActionWheel:
|
|
3263
3318
|
channelData = ChannelData.wheel(data);
|
|
3264
3319
|
break;
|
|
3320
|
+
case ChannelDataType.ActionGesture:
|
|
3321
|
+
channelData = ChannelData.gesture(data);
|
|
3322
|
+
break;
|
|
3323
|
+
case ChannelDataType.ActionCommand:
|
|
3324
|
+
channelData = ChannelData.action(data);
|
|
3325
|
+
break;
|
|
3265
3326
|
}
|
|
3266
3327
|
if (channelData) {
|
|
3267
3328
|
const jsonString = JSON.stringify(channelData);
|
|
@@ -3409,20 +3470,23 @@ class WebRTCClient extends EventEmitter {
|
|
|
3409
3470
|
}
|
|
3410
3471
|
handleDataChannelMessage(event) {
|
|
3411
3472
|
const data = JSON.parse(event.data);
|
|
3412
|
-
if (data.type ===
|
|
3473
|
+
if (data.type === ChannelDataType.ActionCommandEvent) {
|
|
3413
3474
|
const { action, value } = JSON.parse(data.data);
|
|
3414
3475
|
if (action === "ACTION_CONTROL_VIDEO") {
|
|
3415
3476
|
value === "ENABLE" ? this.startPush() : this.stopPush();
|
|
3416
3477
|
}
|
|
3417
|
-
} else if (data.type ===
|
|
3418
|
-
const { rotation, screenWidth, screenHeight } = JSON.parse(data.data);
|
|
3478
|
+
} else if (data.type === ChannelDataType.ActionUpdateCloudStatus) {
|
|
3479
|
+
const { rotation, screenWidth, screenHeight, gestureMode } = JSON.parse(data.data);
|
|
3419
3480
|
const direction = [StreamRotation.ROTATION_0, StreamRotation.ROTATION_180].includes(rotation) ? ContainerDirection.Vertical : ContainerDirection.Horizontal;
|
|
3420
3481
|
const cloudStatus = {
|
|
3421
3482
|
direction,
|
|
3422
3483
|
screenWidth,
|
|
3423
|
-
screenHeight
|
|
3484
|
+
screenHeight,
|
|
3485
|
+
gestureMode
|
|
3424
3486
|
};
|
|
3425
3487
|
this.emit(EmitType.cloudStatusChanged, cloudStatus);
|
|
3488
|
+
} else if (data.type === ChannelDataType.CloudClipData) {
|
|
3489
|
+
this.emit(EmitType.cloudClipData, data.data);
|
|
3426
3490
|
}
|
|
3427
3491
|
}
|
|
3428
3492
|
checkStats() {
|
|
@@ -3441,6 +3505,7 @@ class WebRTCClient extends EventEmitter {
|
|
|
3441
3505
|
let bytesReceived = 0;
|
|
3442
3506
|
let framesDecoded = 0;
|
|
3443
3507
|
let pliCount = 0;
|
|
3508
|
+
let framesReceived = 0;
|
|
3444
3509
|
let connectionType = "";
|
|
3445
3510
|
const currentTime = Date.now();
|
|
3446
3511
|
statsReport.forEach((report) => {
|
|
@@ -3452,6 +3517,7 @@ class WebRTCClient extends EventEmitter {
|
|
|
3452
3517
|
videoFps = report.framesPerSecond || 0;
|
|
3453
3518
|
totalDecodeTime = report.totalDecodeTime || 0;
|
|
3454
3519
|
framesDecoded = report.framesDecoded || 0;
|
|
3520
|
+
framesReceived = report.framesReceived || 0;
|
|
3455
3521
|
pliCount = (report.pliCount || 0) + (report.firCount || 0);
|
|
3456
3522
|
}
|
|
3457
3523
|
}
|
|
@@ -3494,7 +3560,9 @@ class WebRTCClient extends EventEmitter {
|
|
|
3494
3560
|
// percent
|
|
3495
3561
|
bitrate,
|
|
3496
3562
|
pliCount,
|
|
3497
|
-
averageDecodeTime
|
|
3563
|
+
averageDecodeTime,
|
|
3564
|
+
framesDecoded,
|
|
3565
|
+
framesReceived
|
|
3498
3566
|
};
|
|
3499
3567
|
this.emit(EmitType.statisticInfo, screenInfo);
|
|
3500
3568
|
}).catch((error) => {
|
|
@@ -3523,7 +3591,6 @@ class WebRTCSdk extends EventEmitter {
|
|
|
3523
3591
|
this.config.myId = message.myId;
|
|
3524
3592
|
break;
|
|
3525
3593
|
case MessageType.Offer:
|
|
3526
|
-
console.log("handleSignaling===>", message);
|
|
3527
3594
|
if (message.senderId && message.sdp) {
|
|
3528
3595
|
this.config.targetId = message.senderId;
|
|
3529
3596
|
this.webRTCClient.handleOffer(message.sdp);
|
|
@@ -3558,6 +3625,10 @@ class WebRTCSdk extends EventEmitter {
|
|
|
3558
3625
|
case MessageType.Ping:
|
|
3559
3626
|
this.sendPong();
|
|
3560
3627
|
break;
|
|
3628
|
+
case MessageType.SendScreenshot:
|
|
3629
|
+
const base64Str = `data:image/png;base64,${message.screenshot}`;
|
|
3630
|
+
this.emit(EmitType.screenshot, { "room_id": this.config.roomId, "base64": base64Str });
|
|
3631
|
+
break;
|
|
3561
3632
|
}
|
|
3562
3633
|
});
|
|
3563
3634
|
/** 发送 Offer 信令 */
|
|
@@ -3621,6 +3692,10 @@ class WebRTCSdk extends EventEmitter {
|
|
|
3621
3692
|
EmitType.cloudStatusChanged,
|
|
3622
3693
|
(info) => this.emit(EmitType.cloudStatusChanged, info)
|
|
3623
3694
|
);
|
|
3695
|
+
this.webRTCClient.on(
|
|
3696
|
+
EmitType.cloudClipData,
|
|
3697
|
+
(clipData) => this.emit(EmitType.cloudClipData, clipData)
|
|
3698
|
+
);
|
|
3624
3699
|
this.webRTCClient.on(EmitType.webrtcError, (err) => {
|
|
3625
3700
|
this.emit(EmitType.webrtcError, err);
|
|
3626
3701
|
});
|
|
@@ -3640,16 +3715,14 @@ class WebRTCSdk extends EventEmitter {
|
|
|
3640
3715
|
}
|
|
3641
3716
|
/** 开始推流:触发媒体采集与轨道添加 */
|
|
3642
3717
|
async startPush() {
|
|
3643
|
-
try {
|
|
3644
|
-
await this.webRTCClient.readyCapture();
|
|
3645
|
-
} catch (error) {
|
|
3646
|
-
this.emit("error", { type: "camera", error });
|
|
3647
|
-
}
|
|
3648
3718
|
}
|
|
3649
3719
|
/** 发送信道数据 */
|
|
3650
3720
|
sendChannelData(type, data) {
|
|
3651
3721
|
this.webRTCClient.sendChannelData(type, data);
|
|
3652
3722
|
}
|
|
3723
|
+
sendRequestScreenshot(visible) {
|
|
3724
|
+
this.signalingClient.sendRequestScreenshot(visible);
|
|
3725
|
+
}
|
|
3653
3726
|
sendPong() {
|
|
3654
3727
|
const message = {
|
|
3655
3728
|
type: SendType.Pong
|
|
@@ -3794,10 +3867,10 @@ const KeyCodeMap = {
|
|
|
3794
3867
|
};
|
|
3795
3868
|
const getKeyEventData = (event) => {
|
|
3796
3869
|
const keyCode = KeyCodeMap[event.code] ?? -1;
|
|
3797
|
-
const
|
|
3870
|
+
const meta = computeAndroidMetaState(event);
|
|
3798
3871
|
return {
|
|
3799
|
-
|
|
3800
|
-
|
|
3872
|
+
keyCode,
|
|
3873
|
+
meta
|
|
3801
3874
|
};
|
|
3802
3875
|
};
|
|
3803
3876
|
function transformCoordinate(viewWidth, viewHeight, cloudWidth, cloudHeight, viewAngle, streamAngle, inputX, inputY) {
|
|
@@ -3870,6 +3943,85 @@ function rotatePoint90(width, height, inputX, inputY) {
|
|
|
3870
3943
|
const yRotated = -x0 + offsetShortSide;
|
|
3871
3944
|
return [xRotated, yRotated];
|
|
3872
3945
|
}
|
|
3946
|
+
class GroupControllerManager extends EventEmitter {
|
|
3947
|
+
constructor() {
|
|
3948
|
+
super(...arguments);
|
|
3949
|
+
__publicField(this, "webRTCConfigList", []);
|
|
3950
|
+
__publicField(this, "sdkList", []);
|
|
3951
|
+
__publicField(this, "loopTimer", null);
|
|
3952
|
+
__publicField(this, "visibilityMap", /* @__PURE__ */ new Map());
|
|
3953
|
+
__publicField(this, "previousVisibilityMap", /* @__PURE__ */ new Map());
|
|
3954
|
+
}
|
|
3955
|
+
startGroupControl(configList) {
|
|
3956
|
+
if (!Array.isArray(configList) || configList.length === 0) {
|
|
3957
|
+
throw new Error("群控列表为空");
|
|
3958
|
+
}
|
|
3959
|
+
const controlCount = configList.filter((config) => config.isControl).length;
|
|
3960
|
+
if (controlCount !== 1) {
|
|
3961
|
+
throw new Error(`一次群控发起,有且只有一个主控,当前主控个数为 ${controlCount}。`);
|
|
3962
|
+
}
|
|
3963
|
+
this.webRTCConfigList = configList;
|
|
3964
|
+
configList.forEach((config) => {
|
|
3965
|
+
const sdk = new WebRTCSdk(config);
|
|
3966
|
+
sdk.startConnection();
|
|
3967
|
+
sdk.on(EmitType.screenshot, (screenshot) => {
|
|
3968
|
+
this.emit(EmitType.screenshot, screenshot);
|
|
3969
|
+
});
|
|
3970
|
+
this.sdkList.push(sdk);
|
|
3971
|
+
});
|
|
3972
|
+
this.startLoop();
|
|
3973
|
+
}
|
|
3974
|
+
stopGroupControl() {
|
|
3975
|
+
this.sdkList.forEach((sdk) => sdk.stop());
|
|
3976
|
+
this.sdkList = [];
|
|
3977
|
+
this.visibilityMap.clear();
|
|
3978
|
+
this.previousVisibilityMap.clear();
|
|
3979
|
+
this.removeAllListeners();
|
|
3980
|
+
this.stopLoop();
|
|
3981
|
+
}
|
|
3982
|
+
getConnectionList() {
|
|
3983
|
+
return this.webRTCConfigList;
|
|
3984
|
+
}
|
|
3985
|
+
/**
|
|
3986
|
+
* 设置某个视图的可见状态
|
|
3987
|
+
* @param viewId 视图 ID
|
|
3988
|
+
* @param visible 是否可见
|
|
3989
|
+
*/
|
|
3990
|
+
setViewVisibility(viewId, visible) {
|
|
3991
|
+
this.visibilityMap.set(viewId, visible);
|
|
3992
|
+
}
|
|
3993
|
+
sendChannelData(type, data) {
|
|
3994
|
+
this.sdkList.forEach((sdk) => {
|
|
3995
|
+
sdk.sendChannelData(type, data);
|
|
3996
|
+
});
|
|
3997
|
+
}
|
|
3998
|
+
startLoop() {
|
|
3999
|
+
if (this.loopTimer !== null) return;
|
|
4000
|
+
this.loopTimer = setInterval(() => {
|
|
4001
|
+
try {
|
|
4002
|
+
this.sdkList.forEach((sdk) => {
|
|
4003
|
+
const viewId = sdk.config.roomId;
|
|
4004
|
+
const isVisibleNow = this.visibilityMap.get(viewId) ?? false;
|
|
4005
|
+
const wasVisible = this.previousVisibilityMap.get(viewId) ?? false;
|
|
4006
|
+
if (isVisibleNow) {
|
|
4007
|
+
sdk.sendRequestScreenshot(true);
|
|
4008
|
+
} else if (wasVisible && !isVisibleNow) {
|
|
4009
|
+
sdk.sendRequestScreenshot(false);
|
|
4010
|
+
}
|
|
4011
|
+
this.previousVisibilityMap.set(viewId, isVisibleNow);
|
|
4012
|
+
});
|
|
4013
|
+
} catch (err) {
|
|
4014
|
+
console.error("Error during loop execution:", err);
|
|
4015
|
+
}
|
|
4016
|
+
}, 1e3);
|
|
4017
|
+
}
|
|
4018
|
+
stopLoop() {
|
|
4019
|
+
if (this.loopTimer !== null) {
|
|
4020
|
+
clearInterval(this.loopTimer);
|
|
4021
|
+
this.loopTimer = null;
|
|
4022
|
+
}
|
|
4023
|
+
}
|
|
4024
|
+
}
|
|
3873
4025
|
function useDeviceMode() {
|
|
3874
4026
|
const isMobile = ref(false);
|
|
3875
4027
|
const checkDeviceMode = () => {
|
|
@@ -3926,6 +4078,7 @@ function useRemoteVideo(videoContainer, remoteVideoElement, videoAngle) {
|
|
|
3926
4078
|
const widthRadio = ref(0);
|
|
3927
4079
|
const heightRadio = ref(0);
|
|
3928
4080
|
const resizeObserver = ref(null);
|
|
4081
|
+
const id = ref(0);
|
|
3929
4082
|
const videoSize = computed(() => {
|
|
3930
4083
|
let width = 0;
|
|
3931
4084
|
let height = 0;
|
|
@@ -3982,6 +4135,7 @@ function useRemoteVideo(videoContainer, remoteVideoElement, videoAngle) {
|
|
|
3982
4135
|
if (remoteVideoElement.value && remoteVideoElement.value.srcObject) {
|
|
3983
4136
|
remoteVideoElement.value.srcObject.getTracks().forEach((track) => track.stop());
|
|
3984
4137
|
remoteVideoElement.value.srcObject = null;
|
|
4138
|
+
remoteVideoElement.value.cancelVideoFrameCallback(id.value);
|
|
3985
4139
|
}
|
|
3986
4140
|
};
|
|
3987
4141
|
return {
|
|
@@ -4014,7 +4168,7 @@ function useMouseTouchControl(options) {
|
|
|
4014
4168
|
const endY = ref(0);
|
|
4015
4169
|
const handlePointerEvent = (event, action) => {
|
|
4016
4170
|
if (!remoteVideoElement.value) return;
|
|
4017
|
-
const offsetTime = Math.trunc(
|
|
4171
|
+
const offsetTime = Math.trunc(event.timeStamp - pointerDownTime.value[0]);
|
|
4018
4172
|
const rect = remoteVideoElement.value.getBoundingClientRect();
|
|
4019
4173
|
let x = event.clientX - rect.left;
|
|
4020
4174
|
let y = event.clientY - rect.top;
|
|
@@ -4153,19 +4307,27 @@ function useMouseTouchControl(options) {
|
|
|
4153
4307
|
handleWheel
|
|
4154
4308
|
};
|
|
4155
4309
|
}
|
|
4156
|
-
function useKeyboardControl(emit) {
|
|
4310
|
+
function useKeyboardControl(disabled, emit) {
|
|
4311
|
+
const listening = ref(false);
|
|
4157
4312
|
const handleKeyDown = (e) => {
|
|
4158
4313
|
const data = getKeyEventData(e);
|
|
4159
4314
|
emit("channelEvent", ChannelDataType.ActionInput, data);
|
|
4160
4315
|
};
|
|
4161
|
-
const startListening = (
|
|
4162
|
-
|
|
4163
|
-
|
|
4316
|
+
const startListening = () => {
|
|
4317
|
+
if (!disabled) {
|
|
4318
|
+
return;
|
|
4319
|
+
}
|
|
4320
|
+
listening.value = true;
|
|
4321
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
4164
4322
|
};
|
|
4165
4323
|
const stopListening = () => {
|
|
4324
|
+
if (!disabled) {
|
|
4325
|
+
return;
|
|
4326
|
+
}
|
|
4327
|
+
listening.value = false;
|
|
4328
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
4166
4329
|
};
|
|
4167
4330
|
return {
|
|
4168
|
-
handleKeyDown,
|
|
4169
4331
|
startListening,
|
|
4170
4332
|
stopListening
|
|
4171
4333
|
};
|
|
@@ -4173,10 +4335,10 @@ function useKeyboardControl(emit) {
|
|
|
4173
4335
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4174
4336
|
__name: "index",
|
|
4175
4337
|
props: {
|
|
4176
|
-
streamAngle: {
|
|
4177
|
-
videoAngle: {
|
|
4178
|
-
cursorType: {
|
|
4179
|
-
cloudDeviceSize: {
|
|
4338
|
+
streamAngle: { default: 0 },
|
|
4339
|
+
videoAngle: { default: 0 },
|
|
4340
|
+
cursorType: { default: 0 },
|
|
4341
|
+
cloudDeviceSize: { default: () => ({ width: 0, height: 0 }) },
|
|
4180
4342
|
disabled: { type: Boolean, default: true }
|
|
4181
4343
|
},
|
|
4182
4344
|
emits: ["channelEvent"],
|
|
@@ -4221,22 +4383,29 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
4221
4383
|
emit
|
|
4222
4384
|
});
|
|
4223
4385
|
const {
|
|
4224
|
-
handleKeyDown,
|
|
4225
4386
|
startListening,
|
|
4226
4387
|
stopListening
|
|
4227
|
-
} = useKeyboardControl(emit);
|
|
4388
|
+
} = useKeyboardControl(disabled, emit);
|
|
4228
4389
|
useResizeObserver(videoContainer, dimensions);
|
|
4390
|
+
const handleClick = () => {
|
|
4391
|
+
var _a;
|
|
4392
|
+
if ((_a = remoteVideoElement.value) == null ? void 0 : _a.srcObject) {
|
|
4393
|
+
remoteVideoElement.value.muted = false;
|
|
4394
|
+
}
|
|
4395
|
+
};
|
|
4229
4396
|
onMounted(() => {
|
|
4230
4397
|
checkDeviceMode();
|
|
4231
4398
|
window.addEventListener("resize", checkDeviceMode);
|
|
4232
4399
|
window.addEventListener("pointerdown", checkTouchSupport);
|
|
4233
4400
|
window.addEventListener("pointerup", handleUp);
|
|
4401
|
+
document.addEventListener("click", handleClick);
|
|
4234
4402
|
initVideoContainer();
|
|
4235
4403
|
});
|
|
4236
4404
|
onUnmounted(() => {
|
|
4237
4405
|
window.removeEventListener("resize", checkDeviceMode);
|
|
4238
4406
|
window.removeEventListener("pointerdown", checkTouchSupport);
|
|
4239
4407
|
window.removeEventListener("pointerup", handleUp);
|
|
4408
|
+
document.removeEventListener("click", handleClick);
|
|
4240
4409
|
});
|
|
4241
4410
|
__expose({ startPlay, stopPlay });
|
|
4242
4411
|
return (_ctx, _cache) => {
|
|
@@ -4248,11 +4417,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
4248
4417
|
}, [
|
|
4249
4418
|
createElementVNode("div", {
|
|
4250
4419
|
ref: "keyboardArea",
|
|
4251
|
-
onPointerenter: _cache[9] || (_cache[9] =
|
|
4252
|
-
|
|
4253
|
-
|
|
4420
|
+
onPointerenter: _cache[9] || (_cache[9] = //@ts-ignore
|
|
4421
|
+
(...args) => unref(startListening) && unref(startListening)(...args)),
|
|
4422
|
+
onPointerleave: _cache[10] || (_cache[10] = //@ts-ignore
|
|
4423
|
+
(...args) => unref(stopListening) && unref(stopListening)(...args)),
|
|
4254
4424
|
class: "vContainer",
|
|
4255
|
-
onKeydown: _cache[11] || (_cache[11] = ($event) => unref(disabled) ? null : unref(handleKeyDown)),
|
|
4256
4425
|
style: normalizeStyle([{ height: unref(videoSize).height + "px", width: unref(videoSize).width + "px", transform: `rotate(${unref(videoAngle)}deg)` }, { "position": "relative" }])
|
|
4257
4426
|
}, [
|
|
4258
4427
|
createElementVNode("video", {
|
|
@@ -4280,7 +4449,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
4280
4449
|
autoplay: "",
|
|
4281
4450
|
playsinline: "",
|
|
4282
4451
|
muted: "",
|
|
4283
|
-
disablePictureInPicture:
|
|
4452
|
+
disablePictureInPicture: true
|
|
4284
4453
|
}, null, 34)
|
|
4285
4454
|
], 36)
|
|
4286
4455
|
], 512);
|
|
@@ -4294,12 +4463,15 @@ const _export_sfc = (sfc, props) => {
|
|
|
4294
4463
|
}
|
|
4295
4464
|
return target;
|
|
4296
4465
|
};
|
|
4297
|
-
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
4466
|
+
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-51dd3cb6"]]);
|
|
4298
4467
|
export {
|
|
4468
|
+
ActionCommandType,
|
|
4299
4469
|
ActionType,
|
|
4300
4470
|
ChannelDataType,
|
|
4301
4471
|
ContainerDirection,
|
|
4302
4472
|
EmitType,
|
|
4473
|
+
GestureData,
|
|
4474
|
+
GroupControllerManager,
|
|
4303
4475
|
InputData,
|
|
4304
4476
|
KeyEventData,
|
|
4305
4477
|
index as RemotePlayer,
|