yjz-web-sdk 1.0.1 → 1.0.2-beta.1
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/components/RemotePlayer/index.vue.d.ts +2 -0
- package/lib/composables/useCursorStyle.d.ts +2 -0
- package/lib/composables/useDeviceMode.d.ts +6 -0
- package/lib/composables/useKeyboardControl.d.ts +6 -0
- package/lib/composables/useMouseTouchControl.d.ts +25 -0
- package/lib/composables/useRemoteVideo.d.ts +12 -0
- package/lib/composables/useResizeObserver.d.ts +3 -0
- package/lib/core/data/WebRtcError.d.ts +2 -1
- package/lib/core/data/{WebRTCDataType.d.ts → WebrtcDataType.d.ts} +67 -11
- package/lib/core/rtc/WebRTCClient.d.ts +5 -6
- package/lib/core/util/KeyCodeUtil.d.ts +2 -2
- package/lib/index.d.ts +7 -6
- package/lib/yjz-web-sdk.css +1 -0
- package/lib/yjz-web-sdk.js +701 -189
- package/lib/yjz-web-sdk.umd.cjs +50 -31
- package/package.json +3 -1
package/lib/yjz-web-sdk.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { ref, computed, onMounted, onUnmounted, defineComponent, toRefs, createElementBlock, openBlock, createElementVNode, normalizeStyle, unref, normalizeClass } from "vue";
|
|
4
5
|
function _mergeNamespaces(n, m) {
|
|
5
6
|
for (var i = 0; i < m.length; i++) {
|
|
6
7
|
const e = m[i];
|
|
@@ -303,6 +304,7 @@ var EmitType = /* @__PURE__ */ ((EmitType2) => {
|
|
|
303
304
|
EmitType2["iceConnectionState"] = "iceConnectionState";
|
|
304
305
|
EmitType2["cloudStatusChanged"] = "cloudStatusChanged";
|
|
305
306
|
EmitType2["statisticInfo"] = "statisticInfo";
|
|
307
|
+
EmitType2["cloudClipData"] = "cloudClipData";
|
|
306
308
|
return EmitType2;
|
|
307
309
|
})(EmitType || {});
|
|
308
310
|
class SignalingClient extends EventEmitter {
|
|
@@ -322,6 +324,7 @@ class SignalingClient extends EventEmitter {
|
|
|
322
324
|
start() {
|
|
323
325
|
this.webSocket = new WebSocket(this.config.signalServerUrl);
|
|
324
326
|
this.webSocket.onopen = () => {
|
|
327
|
+
console.log("sendSignInMessagesendSignInMessagesendSignInMessage");
|
|
325
328
|
this.sendSignInMessage();
|
|
326
329
|
if (this.timeout === null) {
|
|
327
330
|
this.timeout = setTimeout(() => {
|
|
@@ -383,144 +386,6 @@ class SignalingClient extends EventEmitter {
|
|
|
383
386
|
this.sendMessage(jsonMessage);
|
|
384
387
|
}
|
|
385
388
|
}
|
|
386
|
-
var ChannelDataType = /* @__PURE__ */ ((ChannelDataType2) => {
|
|
387
|
-
ChannelDataType2["ClickData"] = "ClickData";
|
|
388
|
-
ChannelDataType2["ClipboardData"] = "ClipboardData";
|
|
389
|
-
ChannelDataType2["ActionCommand"] = "ActionCommand";
|
|
390
|
-
ChannelDataType2["ActionInput"] = "ActionInput";
|
|
391
|
-
ChannelDataType2["ActionChinese"] = "ActionChinese";
|
|
392
|
-
ChannelDataType2["ActionRequestCloudDeviceInfo"] = "ActionRequestCloudDeviceInfo";
|
|
393
|
-
ChannelDataType2["ActionClarity"] = "ActionClarity";
|
|
394
|
-
return ChannelDataType2;
|
|
395
|
-
})(ChannelDataType || {});
|
|
396
|
-
const ActionType = Object.freeze({
|
|
397
|
-
ACTION_DOWN: 0,
|
|
398
|
-
ACTION_MOVE: 2,
|
|
399
|
-
ACTION_UP: 1
|
|
400
|
-
});
|
|
401
|
-
const StreamRotation = {
|
|
402
|
-
ROTATION_0: 0,
|
|
403
|
-
ROTATION_180: 2
|
|
404
|
-
};
|
|
405
|
-
const ContainerDirection = {
|
|
406
|
-
Vertical: 0,
|
|
407
|
-
Horizontal: 1
|
|
408
|
-
};
|
|
409
|
-
class TouchData {
|
|
410
|
-
constructor(action, p, x, y, offsetTime, type = "adb") {
|
|
411
|
-
__publicField(this, "action");
|
|
412
|
-
__publicField(this, "p");
|
|
413
|
-
__publicField(this, "x");
|
|
414
|
-
__publicField(this, "y");
|
|
415
|
-
__publicField(this, "offsetTime");
|
|
416
|
-
__publicField(this, "type");
|
|
417
|
-
this.action = action;
|
|
418
|
-
this.p = p;
|
|
419
|
-
this.x = x;
|
|
420
|
-
this.y = y;
|
|
421
|
-
this.offsetTime = offsetTime;
|
|
422
|
-
this.type = type;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
class InputData {
|
|
426
|
-
constructor(text) {
|
|
427
|
-
__publicField(this, "text");
|
|
428
|
-
this.text = text;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
class KeyEventData {
|
|
432
|
-
constructor(keyCode, meta) {
|
|
433
|
-
__publicField(this, "keyCode");
|
|
434
|
-
__publicField(this, "meta");
|
|
435
|
-
this.keyCode = keyCode;
|
|
436
|
-
this.meta = meta;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
class ChannelData {
|
|
440
|
-
constructor(type, data = null) {
|
|
441
|
-
__publicField(this, "type");
|
|
442
|
-
__publicField(this, "data");
|
|
443
|
-
this.type = type;
|
|
444
|
-
this.data = data;
|
|
445
|
-
}
|
|
446
|
-
toString() {
|
|
447
|
-
return JSON.stringify({ type: this.type, data: this.data });
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* 格式化数据
|
|
451
|
-
* 如果数据已经是字符串,则直接返回;否则使用 JSON.stringify() 转换为字符串
|
|
452
|
-
* @param data 待转换数据
|
|
453
|
-
* @returns 格式化后的字符串
|
|
454
|
-
*/
|
|
455
|
-
static formatData(data) {
|
|
456
|
-
return typeof data === "string" ? data : JSON.stringify(data);
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* 生成点击数据
|
|
460
|
-
* @param touchData 触摸数据,可以是任意类型
|
|
461
|
-
*/
|
|
462
|
-
static click(touchData) {
|
|
463
|
-
return new ChannelData("ClickData", this.formatData(touchData));
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* 生成剪贴板数据
|
|
467
|
-
* @param data 剪贴板数据,可以是字符串或其他类型
|
|
468
|
-
*/
|
|
469
|
-
static clipboard(data) {
|
|
470
|
-
return new ChannelData("ClipboardData", this.formatData(data));
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* 生成输入数据
|
|
474
|
-
* @param data 输入数据对象
|
|
475
|
-
*/
|
|
476
|
-
static input(data) {
|
|
477
|
-
return new ChannelData("ActionInput", this.formatData(data));
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* 生成中文输入数据
|
|
481
|
-
* @param data 中文输入数据
|
|
482
|
-
*/
|
|
483
|
-
static chinese(data) {
|
|
484
|
-
return new ChannelData("ActionChinese", this.formatData(data));
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* 生成请求云设备信息数据
|
|
488
|
-
*/
|
|
489
|
-
static requestCloudDeviceInfo() {
|
|
490
|
-
return new ChannelData("ActionRequestCloudDeviceInfo", "");
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* 生成清晰度数据(clarity)
|
|
494
|
-
* @param data 清晰度数据
|
|
495
|
-
*/
|
|
496
|
-
static clarity(data) {
|
|
497
|
-
return new ChannelData("ActionClarity", this.formatData(data));
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
class WebRTCConfig {
|
|
501
|
-
constructor(options = {}) {
|
|
502
|
-
__publicField(this, "signalServerUrl");
|
|
503
|
-
__publicField(this, "myId");
|
|
504
|
-
__publicField(this, "roomId");
|
|
505
|
-
__publicField(this, "targetId");
|
|
506
|
-
__publicField(this, "stunServerUri");
|
|
507
|
-
__publicField(this, "stunServerUriAli");
|
|
508
|
-
__publicField(this, "stunServerUriTel");
|
|
509
|
-
__publicField(this, "turnServerUri");
|
|
510
|
-
__publicField(this, "turnServerUserName");
|
|
511
|
-
__publicField(this, "turnServerPassword");
|
|
512
|
-
this.signalServerUrl = options.signalServerUrl || "";
|
|
513
|
-
this.myId = options.myId || "";
|
|
514
|
-
this.roomId = options.roomId || "";
|
|
515
|
-
this.targetId = options.targetId || "";
|
|
516
|
-
this.stunServerUri = options.stunServerUri || "stun:stun.l.google.com:19302";
|
|
517
|
-
this.stunServerUriAli = options.stunServerUriAli || "stun:stun.middle.aliyun.com:3478";
|
|
518
|
-
this.stunServerUriTel = options.stunServerUriTel || "stun:stun.qq.com:3478";
|
|
519
|
-
this.turnServerUri = options.turnServerUri || "turn:btweb.yajuzhen.com:3478";
|
|
520
|
-
this.turnServerUserName = options.turnServerUserName || "yangyj";
|
|
521
|
-
this.turnServerPassword = options.turnServerPassword || "hb@2025@168";
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
389
|
let logDisabled_ = true;
|
|
525
390
|
let deprecationWarnings_ = true;
|
|
526
391
|
function extractVersion(uastring, expr, pos) {
|
|
@@ -1783,11 +1648,11 @@ function shimLocalStreamsAPI(window2) {
|
|
|
1783
1648
|
if (!this._localStreams) {
|
|
1784
1649
|
this._localStreams = [];
|
|
1785
1650
|
}
|
|
1786
|
-
const
|
|
1787
|
-
if (
|
|
1651
|
+
const index2 = this._localStreams.indexOf(stream);
|
|
1652
|
+
if (index2 === -1) {
|
|
1788
1653
|
return;
|
|
1789
1654
|
}
|
|
1790
|
-
this._localStreams.splice(
|
|
1655
|
+
this._localStreams.splice(index2, 1);
|
|
1791
1656
|
const tracks = stream.getTracks();
|
|
1792
1657
|
this.getSenders().forEach((sender) => {
|
|
1793
1658
|
if (tracks.includes(sender.track)) {
|
|
@@ -1942,7 +1807,7 @@ function shimRTCIceServerUrls(window2) {
|
|
|
1942
1807
|
return;
|
|
1943
1808
|
}
|
|
1944
1809
|
const OrigPeerConnection = window2.RTCPeerConnection;
|
|
1945
|
-
window2.RTCPeerConnection = function
|
|
1810
|
+
window2.RTCPeerConnection = function RTCPeerConnection2(pcConfig, pcConstraints) {
|
|
1946
1811
|
if (pcConfig && pcConfig.iceServers) {
|
|
1947
1812
|
const newIceServers = [];
|
|
1948
1813
|
for (let i = 0; i < pcConfig.iceServers.length; i++) {
|
|
@@ -2063,7 +1928,7 @@ function requireSdp() {
|
|
|
2063
1928
|
};
|
|
2064
1929
|
SDPUtils2.splitSections = function(blob) {
|
|
2065
1930
|
const parts = blob.split("\nm=");
|
|
2066
|
-
return parts.map((part,
|
|
1931
|
+
return parts.map((part, index2) => (index2 > 0 ? "m=" + part : part).trim() + "\r\n");
|
|
2067
1932
|
};
|
|
2068
1933
|
SDPUtils2.getDescription = function(blob) {
|
|
2069
1934
|
const sections = SDPUtils2.splitSections(blob);
|
|
@@ -3013,7 +2878,7 @@ function adapterFactory({ window: window2 } = {}, options = {
|
|
|
3013
2878
|
}) {
|
|
3014
2879
|
const logging2 = log;
|
|
3015
2880
|
const browserDetails = detectBrowser(window2);
|
|
3016
|
-
const
|
|
2881
|
+
const adapter = {
|
|
3017
2882
|
browserDetails,
|
|
3018
2883
|
commonShim,
|
|
3019
2884
|
extractVersion,
|
|
@@ -3026,14 +2891,14 @@ function adapterFactory({ window: window2 } = {}, options = {
|
|
|
3026
2891
|
case "chrome":
|
|
3027
2892
|
if (!chromeShim || !shimPeerConnection$1 || !options.shimChrome) {
|
|
3028
2893
|
logging2("Chrome shim is not included in this adapter release.");
|
|
3029
|
-
return
|
|
2894
|
+
return adapter;
|
|
3030
2895
|
}
|
|
3031
2896
|
if (browserDetails.version === null) {
|
|
3032
2897
|
logging2("Chrome shim can not determine version, not shimming.");
|
|
3033
|
-
return
|
|
2898
|
+
return adapter;
|
|
3034
2899
|
}
|
|
3035
2900
|
logging2("adapter.js shimming chrome.");
|
|
3036
|
-
|
|
2901
|
+
adapter.browserShim = chromeShim;
|
|
3037
2902
|
shimAddIceCandidateNullOrEmpty(window2, browserDetails);
|
|
3038
2903
|
shimParameterlessSetLocalDescription(window2);
|
|
3039
2904
|
shimGetUserMedia$2(window2, browserDetails);
|
|
@@ -3054,10 +2919,10 @@ function adapterFactory({ window: window2 } = {}, options = {
|
|
|
3054
2919
|
case "firefox":
|
|
3055
2920
|
if (!firefoxShim || !shimPeerConnection || !options.shimFirefox) {
|
|
3056
2921
|
logging2("Firefox shim is not included in this adapter release.");
|
|
3057
|
-
return
|
|
2922
|
+
return adapter;
|
|
3058
2923
|
}
|
|
3059
2924
|
logging2("adapter.js shimming firefox.");
|
|
3060
|
-
|
|
2925
|
+
adapter.browserShim = firefoxShim;
|
|
3061
2926
|
shimAddIceCandidateNullOrEmpty(window2, browserDetails);
|
|
3062
2927
|
shimParameterlessSetLocalDescription(window2);
|
|
3063
2928
|
shimGetUserMedia$1(window2, browserDetails);
|
|
@@ -3079,10 +2944,10 @@ function adapterFactory({ window: window2 } = {}, options = {
|
|
|
3079
2944
|
case "safari":
|
|
3080
2945
|
if (!safariShim || !options.shimSafari) {
|
|
3081
2946
|
logging2("Safari shim is not included in this adapter release.");
|
|
3082
|
-
return
|
|
2947
|
+
return adapter;
|
|
3083
2948
|
}
|
|
3084
2949
|
logging2("adapter.js shimming safari.");
|
|
3085
|
-
|
|
2950
|
+
adapter.browserShim = safariShim;
|
|
3086
2951
|
shimAddIceCandidateNullOrEmpty(window2, browserDetails);
|
|
3087
2952
|
shimParameterlessSetLocalDescription(window2);
|
|
3088
2953
|
shimRTCIceServerUrls(window2);
|
|
@@ -3103,9 +2968,33 @@ function adapterFactory({ window: window2 } = {}, options = {
|
|
|
3103
2968
|
logging2("Unsupported browser!");
|
|
3104
2969
|
break;
|
|
3105
2970
|
}
|
|
3106
|
-
return
|
|
2971
|
+
return adapter;
|
|
2972
|
+
}
|
|
2973
|
+
adapterFactory({ window: typeof window === "undefined" ? void 0 : window });
|
|
2974
|
+
class WebRTCConfig {
|
|
2975
|
+
constructor(options = {}) {
|
|
2976
|
+
__publicField(this, "signalServerUrl");
|
|
2977
|
+
__publicField(this, "myId");
|
|
2978
|
+
__publicField(this, "roomId");
|
|
2979
|
+
__publicField(this, "targetId");
|
|
2980
|
+
__publicField(this, "stunServerUri");
|
|
2981
|
+
__publicField(this, "stunServerUriAli");
|
|
2982
|
+
__publicField(this, "stunServerUriTel");
|
|
2983
|
+
__publicField(this, "turnServerUri");
|
|
2984
|
+
__publicField(this, "turnServerUserName");
|
|
2985
|
+
__publicField(this, "turnServerPassword");
|
|
2986
|
+
this.signalServerUrl = options.signalServerUrl || "";
|
|
2987
|
+
this.myId = options.myId || "";
|
|
2988
|
+
this.roomId = options.roomId || "";
|
|
2989
|
+
this.targetId = options.targetId || "";
|
|
2990
|
+
this.stunServerUri = options.stunServerUri || "stun:stun.l.google.com:19302";
|
|
2991
|
+
this.stunServerUriAli = options.stunServerUriAli || "stun:stun.middle.aliyun.com:3478";
|
|
2992
|
+
this.stunServerUriTel = options.stunServerUriTel || "stun:stun.qq.com:3478";
|
|
2993
|
+
this.turnServerUri = options.turnServerUri || "turn:btweb.yajuzhen.com:3478";
|
|
2994
|
+
this.turnServerUserName = options.turnServerUserName || "yangyj";
|
|
2995
|
+
this.turnServerPassword = options.turnServerPassword || "hb@2025@168";
|
|
2996
|
+
}
|
|
3107
2997
|
}
|
|
3108
|
-
const adapter = adapterFactory({ window: typeof window === "undefined" ? void 0 : window });
|
|
3109
2998
|
const setRemoteDescriptionWithHandleOffer = (peerConnection, sdp2, sendAnswer, onError) => {
|
|
3110
2999
|
const description = new RTCSessionDescription({ type: "offer", sdp: sdp2 });
|
|
3111
3000
|
peerConnection.setRemoteDescription(description).then(() => createAnswer(peerConnection, sendAnswer, onError)).catch((error) => onError == null ? void 0 : onError(createWebRtcError(FailCode.HANDLE_OFFER, error)));
|
|
@@ -3116,7 +3005,10 @@ const createAnswer = (peerConnection, sendAnswer, onError) => {
|
|
|
3116
3005
|
const setLocalDescriptionWithCreateAnswer = (peerConnection, answer, sendAnswer, onError) => {
|
|
3117
3006
|
peerConnection.setLocalDescription(answer).then(() => {
|
|
3118
3007
|
sendAnswer == null ? void 0 : sendAnswer(answer.sdp ?? "");
|
|
3119
|
-
}).catch((error) =>
|
|
3008
|
+
}).catch((error) => {
|
|
3009
|
+
onError == null ? void 0 : onError(createWebRtcError(FailCode.LOCAL_DES, error));
|
|
3010
|
+
console.log("21321322212213");
|
|
3011
|
+
});
|
|
3120
3012
|
};
|
|
3121
3013
|
const createPeerConnection = (config) => {
|
|
3122
3014
|
const iceServers = [
|
|
@@ -3131,18 +3023,11 @@ const createPeerConnection = (config) => {
|
|
|
3131
3023
|
const peerConnectionConfig = {
|
|
3132
3024
|
iceServers,
|
|
3133
3025
|
iceTransportPolicy: "all",
|
|
3134
|
-
|
|
3026
|
+
bundlePolicy: "max-bundle",
|
|
3135
3027
|
rtcpMuxPolicy: "require",
|
|
3136
|
-
|
|
3028
|
+
iceCandidatePoolSize: 10
|
|
3137
3029
|
};
|
|
3138
|
-
|
|
3139
|
-
peerConnectionConfig.sdpSemantics = adapter.browserDetails.version && adapter.browserDetails.version < 72 ? "plan-b" : "unified-plan";
|
|
3140
|
-
}
|
|
3141
|
-
const constraints = {
|
|
3142
|
-
optional: [{ DtlsSrtpKeyAgreement: true }, { googIPv6: true }]
|
|
3143
|
-
};
|
|
3144
|
-
const RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
|
|
3145
|
-
return new RTCPeerConnection(peerConnectionConfig, constraints);
|
|
3030
|
+
return new RTCPeerConnection(peerConnectionConfig);
|
|
3146
3031
|
};
|
|
3147
3032
|
const configPeerConnection = (peerConnection, onICEMessage, onTrack, onConnectState, onError) => {
|
|
3148
3033
|
peerConnection.onicecandidate = (event) => {
|
|
@@ -3161,14 +3046,14 @@ const configPeerConnection = (peerConnection, onICEMessage, onTrack, onConnectSt
|
|
|
3161
3046
|
if (!state) {
|
|
3162
3047
|
return;
|
|
3163
3048
|
}
|
|
3164
|
-
if (state === "failed") {
|
|
3049
|
+
if (state === "failed" || state === "disconnected") {
|
|
3165
3050
|
onError == null ? void 0 : onError(createWebRtcError(FailCode.ICE_STATE, "failed"));
|
|
3166
3051
|
}
|
|
3167
3052
|
onConnectState == null ? void 0 : onConnectState(state);
|
|
3168
3053
|
};
|
|
3169
3054
|
peerConnection.ontrack = (event) => {
|
|
3170
3055
|
const track = event.track;
|
|
3171
|
-
track.contentHint = "
|
|
3056
|
+
track.contentHint = "motion";
|
|
3172
3057
|
onTrack == null ? void 0 : onTrack(track);
|
|
3173
3058
|
};
|
|
3174
3059
|
};
|
|
@@ -3185,6 +3070,162 @@ const setLocalDescriptionWithCreateOffer = (peerConnection, offer, sendOfferMess
|
|
|
3185
3070
|
const addIceCandidate = (peerConnection, candidate, onError) => {
|
|
3186
3071
|
peerConnection.addIceCandidate(candidate).catch((err) => onError == null ? void 0 : onError(createWebRtcError(FailCode.HANDLE_ICE, err)));
|
|
3187
3072
|
};
|
|
3073
|
+
var ChannelDataType = /* @__PURE__ */ ((ChannelDataType2) => {
|
|
3074
|
+
ChannelDataType2["ClickData"] = "ClickData";
|
|
3075
|
+
ChannelDataType2["ClipboardData"] = "ClipboardData";
|
|
3076
|
+
ChannelDataType2["ActionCommand"] = "ActionCommand";
|
|
3077
|
+
ChannelDataType2["ActionInput"] = "ActionInput";
|
|
3078
|
+
ChannelDataType2["ActionChinese"] = "ActionChinese";
|
|
3079
|
+
ChannelDataType2["ActionRequestCloudDeviceInfo"] = "ActionRequestCloudDeviceInfo";
|
|
3080
|
+
ChannelDataType2["ActionClarity"] = "ActionClarity";
|
|
3081
|
+
ChannelDataType2["ActionWheel"] = "ActionWheel";
|
|
3082
|
+
ChannelDataType2["CloudClipData"] = "CloudClipData";
|
|
3083
|
+
ChannelDataType2["ActionCommandEvent"] = "ActionCommandEvent";
|
|
3084
|
+
ChannelDataType2["ActionUpdateCloudStatus"] = "ActionUpdateCloudStatus";
|
|
3085
|
+
ChannelDataType2["ActionGesture"] = "ActionGesture";
|
|
3086
|
+
return ChannelDataType2;
|
|
3087
|
+
})(ChannelDataType || {});
|
|
3088
|
+
var ActionCommandType = /* @__PURE__ */ ((ActionCommandType2) => {
|
|
3089
|
+
ActionCommandType2["ActionBack"] = "ActionBack";
|
|
3090
|
+
ActionCommandType2["ActionHome"] = "ActionHome";
|
|
3091
|
+
ActionCommandType2["ActionRecent"] = "ActionRecent";
|
|
3092
|
+
ActionCommandType2["ActionSwitchNavButtons"] = "ActionSwitchNavButtons";
|
|
3093
|
+
ActionCommandType2["ActionSwitchNavGestural"] = "ActionSwitchNavGestural";
|
|
3094
|
+
return ActionCommandType2;
|
|
3095
|
+
})(ActionCommandType || {});
|
|
3096
|
+
const ActionType = {
|
|
3097
|
+
ACTION_DOWN: 0,
|
|
3098
|
+
ACTION_MOVE: 2,
|
|
3099
|
+
ACTION_UP: 1
|
|
3100
|
+
};
|
|
3101
|
+
const StreamRotation = {
|
|
3102
|
+
ROTATION_0: 0,
|
|
3103
|
+
ROTATION_180: 2
|
|
3104
|
+
};
|
|
3105
|
+
const ContainerDirection = {
|
|
3106
|
+
Vertical: 0,
|
|
3107
|
+
Horizontal: 1
|
|
3108
|
+
};
|
|
3109
|
+
class TouchData {
|
|
3110
|
+
constructor(action, p, x, y, offsetTime, type = "adb") {
|
|
3111
|
+
__publicField(this, "action");
|
|
3112
|
+
__publicField(this, "p");
|
|
3113
|
+
__publicField(this, "x");
|
|
3114
|
+
__publicField(this, "y");
|
|
3115
|
+
__publicField(this, "offsetTime");
|
|
3116
|
+
__publicField(this, "type");
|
|
3117
|
+
this.action = action;
|
|
3118
|
+
this.p = p;
|
|
3119
|
+
this.x = x;
|
|
3120
|
+
this.y = y;
|
|
3121
|
+
this.offsetTime = offsetTime;
|
|
3122
|
+
this.type = type;
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
class InputData {
|
|
3126
|
+
constructor(text) {
|
|
3127
|
+
__publicField(this, "text");
|
|
3128
|
+
this.text = text;
|
|
3129
|
+
}
|
|
3130
|
+
}
|
|
3131
|
+
class WheelData {
|
|
3132
|
+
constructor(axis) {
|
|
3133
|
+
__publicField(this, "axis");
|
|
3134
|
+
this.axis = axis;
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
class KeyEventData {
|
|
3138
|
+
constructor(keyCode, meta) {
|
|
3139
|
+
__publicField(this, "keyCode");
|
|
3140
|
+
__publicField(this, "meta");
|
|
3141
|
+
this.keyCode = keyCode;
|
|
3142
|
+
this.meta = meta;
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
class GestureData {
|
|
3146
|
+
constructor(mode) {
|
|
3147
|
+
__publicField(this, "mode");
|
|
3148
|
+
this.mode = mode;
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
class ChannelData {
|
|
3152
|
+
constructor(type, data = null) {
|
|
3153
|
+
__publicField(this, "type");
|
|
3154
|
+
__publicField(this, "data");
|
|
3155
|
+
this.type = type;
|
|
3156
|
+
this.data = data;
|
|
3157
|
+
}
|
|
3158
|
+
toString() {
|
|
3159
|
+
return JSON.stringify({ type: this.type, data: this.data });
|
|
3160
|
+
}
|
|
3161
|
+
/**
|
|
3162
|
+
* 格式化数据
|
|
3163
|
+
* 如果数据已经是字符串,则直接返回;否则使用 JSON.stringify() 转换为字符串
|
|
3164
|
+
* @param data 待转换数据
|
|
3165
|
+
* @returns 格式化后的字符串
|
|
3166
|
+
*/
|
|
3167
|
+
static formatData(data) {
|
|
3168
|
+
return typeof data === "string" ? data : JSON.stringify(data);
|
|
3169
|
+
}
|
|
3170
|
+
/**
|
|
3171
|
+
* 生成点击数据
|
|
3172
|
+
* @param touchData 触摸数据,可以是任意类型
|
|
3173
|
+
*/
|
|
3174
|
+
static click(touchData) {
|
|
3175
|
+
return new ChannelData("ClickData", this.formatData(touchData));
|
|
3176
|
+
}
|
|
3177
|
+
static action(actionData) {
|
|
3178
|
+
return new ChannelData("ActionCommand", this.formatData(actionData));
|
|
3179
|
+
}
|
|
3180
|
+
/**
|
|
3181
|
+
* 生成剪贴板数据
|
|
3182
|
+
* @param data 剪贴板数据,可以是字符串或其他类型
|
|
3183
|
+
*/
|
|
3184
|
+
static clipboard(data) {
|
|
3185
|
+
return new ChannelData("ClipboardData", this.formatData(data));
|
|
3186
|
+
}
|
|
3187
|
+
/**
|
|
3188
|
+
* 生成输入数据
|
|
3189
|
+
* @param data 输入数据对象
|
|
3190
|
+
*/
|
|
3191
|
+
static input(data) {
|
|
3192
|
+
return new ChannelData("ActionInput", this.formatData(data));
|
|
3193
|
+
}
|
|
3194
|
+
/**
|
|
3195
|
+
* 生成鼠标滚动数据
|
|
3196
|
+
* @param data 输入数据对象
|
|
3197
|
+
*/
|
|
3198
|
+
static wheel(data) {
|
|
3199
|
+
return new ChannelData("ActionWheel", this.formatData(data));
|
|
3200
|
+
}
|
|
3201
|
+
/**
|
|
3202
|
+
* 切换手势模式数据
|
|
3203
|
+
* @param data 输入数据对象
|
|
3204
|
+
*/
|
|
3205
|
+
static gesture(data) {
|
|
3206
|
+
return new ChannelData("ActionGesture", this.formatData(data));
|
|
3207
|
+
}
|
|
3208
|
+
/**
|
|
3209
|
+
* 生成中文输入数据
|
|
3210
|
+
* @param data 中文输入数据
|
|
3211
|
+
*/
|
|
3212
|
+
static chinese(data) {
|
|
3213
|
+
return new ChannelData("ActionChinese", this.formatData(data));
|
|
3214
|
+
}
|
|
3215
|
+
/**
|
|
3216
|
+
* 生成请求云设备信息数据
|
|
3217
|
+
*/
|
|
3218
|
+
static requestCloudDeviceInfo() {
|
|
3219
|
+
return new ChannelData("ActionRequestCloudDeviceInfo", "");
|
|
3220
|
+
}
|
|
3221
|
+
/**
|
|
3222
|
+
* 生成清晰度数据(clarity)
|
|
3223
|
+
* @param data 清晰度数据
|
|
3224
|
+
*/
|
|
3225
|
+
static clarity(data) {
|
|
3226
|
+
return new ChannelData("ActionClarity", this.formatData(data));
|
|
3227
|
+
}
|
|
3228
|
+
}
|
|
3188
3229
|
class WebRTCClient extends EventEmitter {
|
|
3189
3230
|
constructor(config) {
|
|
3190
3231
|
super();
|
|
@@ -3193,14 +3234,13 @@ class WebRTCClient extends EventEmitter {
|
|
|
3193
3234
|
__publicField(this, "localStream", null);
|
|
3194
3235
|
__publicField(this, "isPushingStream", false);
|
|
3195
3236
|
__publicField(this, "dataChannel", null);
|
|
3196
|
-
__publicField(this, "statsTimer"
|
|
3237
|
+
__publicField(this, "statsTimer");
|
|
3197
3238
|
__publicField(this, "lastReportTime", 0);
|
|
3198
3239
|
__publicField(this, "lastBytesReceived", 0);
|
|
3199
3240
|
__publicField(this, "lastPacketsLost", 0);
|
|
3200
3241
|
__publicField(this, "lastPacketsReceived", 0);
|
|
3201
3242
|
__publicField(this, "lostPacketCount", 0);
|
|
3202
3243
|
__publicField(this, "maxLostRate", 0);
|
|
3203
|
-
__publicField(this, "decodedCount", 0);
|
|
3204
3244
|
__publicField(this, "lastSecondDecodedCount", 0);
|
|
3205
3245
|
this.config = config;
|
|
3206
3246
|
}
|
|
@@ -3220,14 +3260,15 @@ class WebRTCClient extends EventEmitter {
|
|
|
3220
3260
|
}, (err) => this.emit(EmitType.webrtcError, err));
|
|
3221
3261
|
}
|
|
3222
3262
|
handleAnswer(answerSdp) {
|
|
3223
|
-
setRemoteDescriptionWithHandleAnswer(this.peerConnection, answerSdp, (err) => this.emit(EmitType.webrtcError, err));
|
|
3263
|
+
setRemoteDescriptionWithHandleAnswer(this.peerConnection, answerSdp ?? "", (err) => this.emit(EmitType.webrtcError, err));
|
|
3224
3264
|
}
|
|
3225
3265
|
handleIceCandidate(candidate) {
|
|
3226
3266
|
addIceCandidate(this.peerConnection, candidate, (err) => this.emit(EmitType.webrtcError, err));
|
|
3227
3267
|
}
|
|
3228
3268
|
sendChannelData(type, data) {
|
|
3269
|
+
var _a;
|
|
3229
3270
|
try {
|
|
3230
|
-
let channelData =
|
|
3271
|
+
let channelData = null;
|
|
3231
3272
|
switch (type) {
|
|
3232
3273
|
case ChannelDataType.ClickData:
|
|
3233
3274
|
channelData = ChannelData.click(data);
|
|
@@ -3247,9 +3288,22 @@ class WebRTCClient extends EventEmitter {
|
|
|
3247
3288
|
case ChannelDataType.ActionClarity:
|
|
3248
3289
|
channelData = ChannelData.clarity(data);
|
|
3249
3290
|
break;
|
|
3291
|
+
case ChannelDataType.ActionWheel:
|
|
3292
|
+
channelData = ChannelData.wheel(data);
|
|
3293
|
+
break;
|
|
3294
|
+
case ChannelDataType.ActionGesture:
|
|
3295
|
+
channelData = ChannelData.gesture(data);
|
|
3296
|
+
break;
|
|
3297
|
+
case ChannelDataType.ActionCommand:
|
|
3298
|
+
channelData = ChannelData.action(data);
|
|
3299
|
+
break;
|
|
3300
|
+
}
|
|
3301
|
+
if (channelData) {
|
|
3302
|
+
const jsonString = JSON.stringify(channelData);
|
|
3303
|
+
const buffer = new TextEncoder().encode(jsonString).buffer;
|
|
3304
|
+
(_a = this.dataChannel) == null ? void 0 : _a.send(buffer);
|
|
3305
|
+
channelData = null;
|
|
3250
3306
|
}
|
|
3251
|
-
const buffer = new TextEncoder().encode(channelData).buffer;
|
|
3252
|
-
this.dataChannel.send(buffer);
|
|
3253
3307
|
} catch (err) {
|
|
3254
3308
|
this.emit(EmitType.webrtcError, createWebRtcError(FailCode.DATACHANNEL_ERR, err));
|
|
3255
3309
|
}
|
|
@@ -3257,7 +3311,7 @@ class WebRTCClient extends EventEmitter {
|
|
|
3257
3311
|
closeConnection() {
|
|
3258
3312
|
if (this.statsTimer) {
|
|
3259
3313
|
clearInterval(this.statsTimer);
|
|
3260
|
-
this.statsTimer =
|
|
3314
|
+
this.statsTimer = void 0;
|
|
3261
3315
|
}
|
|
3262
3316
|
if (this.peerConnection) {
|
|
3263
3317
|
if (typeof this.peerConnection.getSenders === "function" && this.peerConnection.getSenders) {
|
|
@@ -3390,20 +3444,23 @@ class WebRTCClient extends EventEmitter {
|
|
|
3390
3444
|
}
|
|
3391
3445
|
handleDataChannelMessage(event) {
|
|
3392
3446
|
const data = JSON.parse(event.data);
|
|
3393
|
-
if (data.type ===
|
|
3447
|
+
if (data.type === ChannelDataType.ActionCommandEvent) {
|
|
3394
3448
|
const { action, value } = JSON.parse(data.data);
|
|
3395
3449
|
if (action === "ACTION_CONTROL_VIDEO") {
|
|
3396
3450
|
value === "ENABLE" ? this.startPush() : this.stopPush();
|
|
3397
3451
|
}
|
|
3398
|
-
} else if (data.type ===
|
|
3399
|
-
const { rotation, screenWidth, screenHeight } = JSON.parse(data.data);
|
|
3452
|
+
} else if (data.type === ChannelDataType.ActionUpdateCloudStatus) {
|
|
3453
|
+
const { rotation, screenWidth, screenHeight, gestureMode } = JSON.parse(data.data);
|
|
3400
3454
|
const direction = [StreamRotation.ROTATION_0, StreamRotation.ROTATION_180].includes(rotation) ? ContainerDirection.Vertical : ContainerDirection.Horizontal;
|
|
3401
3455
|
const cloudStatus = {
|
|
3402
3456
|
direction,
|
|
3403
3457
|
screenWidth,
|
|
3404
|
-
screenHeight
|
|
3458
|
+
screenHeight,
|
|
3459
|
+
gestureMode
|
|
3405
3460
|
};
|
|
3406
3461
|
this.emit(EmitType.cloudStatusChanged, cloudStatus);
|
|
3462
|
+
} else if (data.type === ChannelDataType.CloudClipData) {
|
|
3463
|
+
this.emit(EmitType.cloudClipData, data.data);
|
|
3407
3464
|
}
|
|
3408
3465
|
}
|
|
3409
3466
|
checkStats() {
|
|
@@ -3433,7 +3490,6 @@ class WebRTCClient extends EventEmitter {
|
|
|
3433
3490
|
videoFps = report.framesPerSecond || 0;
|
|
3434
3491
|
totalDecodeTime = report.totalDecodeTime || 0;
|
|
3435
3492
|
framesDecoded = report.framesDecoded || 0;
|
|
3436
|
-
report.framesReceived || 0;
|
|
3437
3493
|
pliCount = (report.pliCount || 0) + (report.firCount || 0);
|
|
3438
3494
|
}
|
|
3439
3495
|
}
|
|
@@ -3505,6 +3561,7 @@ class WebRTCSdk extends EventEmitter {
|
|
|
3505
3561
|
this.config.myId = message.myId;
|
|
3506
3562
|
break;
|
|
3507
3563
|
case MessageType.Offer:
|
|
3564
|
+
console.log("handleSignaling===>", message);
|
|
3508
3565
|
if (message.senderId && message.sdp) {
|
|
3509
3566
|
this.config.targetId = message.senderId;
|
|
3510
3567
|
this.webRTCClient.handleOffer(message.sdp);
|
|
@@ -3602,6 +3659,10 @@ class WebRTCSdk extends EventEmitter {
|
|
|
3602
3659
|
EmitType.cloudStatusChanged,
|
|
3603
3660
|
(info) => this.emit(EmitType.cloudStatusChanged, info)
|
|
3604
3661
|
);
|
|
3662
|
+
this.webRTCClient.on(
|
|
3663
|
+
EmitType.cloudClipData,
|
|
3664
|
+
(clipData) => this.emit(EmitType.cloudClipData, clipData)
|
|
3665
|
+
);
|
|
3605
3666
|
this.webRTCClient.on(EmitType.webrtcError, (err) => {
|
|
3606
3667
|
this.emit(EmitType.webrtcError, err);
|
|
3607
3668
|
});
|
|
@@ -3775,10 +3836,10 @@ const KeyCodeMap = {
|
|
|
3775
3836
|
};
|
|
3776
3837
|
const getKeyEventData = (event) => {
|
|
3777
3838
|
const keyCode = KeyCodeMap[event.code] ?? -1;
|
|
3778
|
-
const
|
|
3839
|
+
const meta = computeAndroidMetaState(event);
|
|
3779
3840
|
return {
|
|
3780
|
-
|
|
3781
|
-
|
|
3841
|
+
keyCode,
|
|
3842
|
+
meta
|
|
3782
3843
|
};
|
|
3783
3844
|
};
|
|
3784
3845
|
function transformCoordinate(viewWidth, viewHeight, cloudWidth, cloudHeight, viewAngle, streamAngle, inputX, inputY) {
|
|
@@ -3797,9 +3858,6 @@ function transformCoordinate(viewWidth, viewHeight, cloudWidth, cloudHeight, vie
|
|
|
3797
3858
|
const end = short - invalidValue;
|
|
3798
3859
|
const len = mid - invalidValue;
|
|
3799
3860
|
if (viewAngle === -90) {
|
|
3800
|
-
if (inputY < invalidValue || inputY > viewHeight - invalidValue) {
|
|
3801
|
-
return null;
|
|
3802
|
-
}
|
|
3803
3861
|
const resultY = linearTransform(invalidValue, mid, start, end, len, inputY);
|
|
3804
3862
|
if (streamAngle === -90) {
|
|
3805
3863
|
return [inputX, resultY];
|
|
@@ -3807,12 +3865,9 @@ function transformCoordinate(viewWidth, viewHeight, cloudWidth, cloudHeight, vie
|
|
|
3807
3865
|
return [viewHeight - resultY, inputX];
|
|
3808
3866
|
}
|
|
3809
3867
|
} else {
|
|
3810
|
-
if (inputX < invalidValue || inputX > viewWidth - invalidValue) {
|
|
3811
|
-
return null;
|
|
3812
|
-
}
|
|
3813
3868
|
const resultX = linearTransform(invalidValue, mid, start, end, len, inputX);
|
|
3814
3869
|
if (streamAngle === -90) {
|
|
3815
|
-
const [rotX, rotY] = rotatePoint90(viewWidth, viewHeight,
|
|
3870
|
+
const [rotX, rotY] = rotatePoint90(viewWidth, viewHeight, resultX, inputY);
|
|
3816
3871
|
return [rotX, rotY];
|
|
3817
3872
|
} else {
|
|
3818
3873
|
return [resultX, inputY];
|
|
@@ -3848,7 +3903,7 @@ function linearTransform(invalidValue, mid, start, end, len, input) {
|
|
|
3848
3903
|
return input;
|
|
3849
3904
|
}
|
|
3850
3905
|
}
|
|
3851
|
-
function rotatePoint90(width, height,
|
|
3906
|
+
function rotatePoint90(width, height, inputX, inputY) {
|
|
3852
3907
|
const offsetLongSide = height / 2;
|
|
3853
3908
|
const offsetShortSide = width / 2;
|
|
3854
3909
|
const x0 = inputX - offsetShortSide;
|
|
@@ -3857,15 +3912,472 @@ function rotatePoint90(width, height, cloudWidth, cloudHeight, inputX, inputY) {
|
|
|
3857
3912
|
const yRotated = -x0 + offsetShortSide;
|
|
3858
3913
|
return [xRotated, yRotated];
|
|
3859
3914
|
}
|
|
3915
|
+
function useDeviceMode() {
|
|
3916
|
+
const isMobile = ref(false);
|
|
3917
|
+
const checkDeviceMode = () => {
|
|
3918
|
+
isMobile.value = /Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent);
|
|
3919
|
+
};
|
|
3920
|
+
const checkTouchSupport = () => {
|
|
3921
|
+
if (navigator.maxTouchPoints > 0) {
|
|
3922
|
+
isMobile.value = true;
|
|
3923
|
+
}
|
|
3924
|
+
};
|
|
3925
|
+
const handleUp = () => {
|
|
3926
|
+
};
|
|
3927
|
+
return {
|
|
3928
|
+
isMobile,
|
|
3929
|
+
checkDeviceMode,
|
|
3930
|
+
checkTouchSupport,
|
|
3931
|
+
handleUp
|
|
3932
|
+
};
|
|
3933
|
+
}
|
|
3934
|
+
function useCursorStyle(cursorType) {
|
|
3935
|
+
return computed(() => {
|
|
3936
|
+
switch (cursorType.value) {
|
|
3937
|
+
case 1:
|
|
3938
|
+
return "circle-cursor";
|
|
3939
|
+
case 2:
|
|
3940
|
+
return "triangle-cursor";
|
|
3941
|
+
default:
|
|
3942
|
+
return "default-cursor";
|
|
3943
|
+
}
|
|
3944
|
+
});
|
|
3945
|
+
}
|
|
3946
|
+
function useResizeObserver(target, dimension) {
|
|
3947
|
+
let observer = null;
|
|
3948
|
+
const init = () => {
|
|
3949
|
+
if (!target.value) return;
|
|
3950
|
+
observer = new ResizeObserver((entries) => {
|
|
3951
|
+
for (const entry of entries) {
|
|
3952
|
+
const { width, height } = entry.contentRect;
|
|
3953
|
+
dimension.value = { width, height };
|
|
3954
|
+
}
|
|
3955
|
+
});
|
|
3956
|
+
observer.observe(target.value);
|
|
3957
|
+
};
|
|
3958
|
+
const destroy = () => {
|
|
3959
|
+
observer == null ? void 0 : observer.disconnect();
|
|
3960
|
+
};
|
|
3961
|
+
onMounted(init);
|
|
3962
|
+
onUnmounted(destroy);
|
|
3963
|
+
}
|
|
3964
|
+
function useRemoteVideo(videoContainer, remoteVideoElement, videoAngle) {
|
|
3965
|
+
const screenStatus = ref(false);
|
|
3966
|
+
const remoteVideo = ref({});
|
|
3967
|
+
const dimensions = ref({ width: 0, height: 0 });
|
|
3968
|
+
const widthRadio = ref(0);
|
|
3969
|
+
const heightRadio = ref(0);
|
|
3970
|
+
const resizeObserver = ref(null);
|
|
3971
|
+
const id = ref(0);
|
|
3972
|
+
const videoSize = computed(() => {
|
|
3973
|
+
let width = 0;
|
|
3974
|
+
let height = 0;
|
|
3975
|
+
const isRotated = videoAngle.value % 180 !== 0;
|
|
3976
|
+
const containerWidth = isRotated ? dimensions.value.height : dimensions.value.width;
|
|
3977
|
+
const containerHeight = isRotated ? dimensions.value.width : dimensions.value.height;
|
|
3978
|
+
if (remoteVideo.value.width && remoteVideo.value.height) {
|
|
3979
|
+
const aspect = remoteVideo.value.width / remoteVideo.value.height;
|
|
3980
|
+
const videoHeight = containerWidth / aspect;
|
|
3981
|
+
if (videoHeight > containerHeight) {
|
|
3982
|
+
height = containerHeight;
|
|
3983
|
+
width = height * aspect;
|
|
3984
|
+
} else {
|
|
3985
|
+
width = containerWidth;
|
|
3986
|
+
height = videoHeight;
|
|
3987
|
+
}
|
|
3988
|
+
widthRadio.value = remoteVideo.value.width / width;
|
|
3989
|
+
heightRadio.value = remoteVideo.value.height / height;
|
|
3990
|
+
}
|
|
3991
|
+
return { width, height };
|
|
3992
|
+
});
|
|
3993
|
+
const initVideoContainer = () => {
|
|
3994
|
+
resizeObserver.value = new ResizeObserver((entries) => {
|
|
3995
|
+
for (const entry of entries) {
|
|
3996
|
+
const { width, height } = entry.contentRect;
|
|
3997
|
+
dimensions.value = { width, height };
|
|
3998
|
+
}
|
|
3999
|
+
});
|
|
4000
|
+
if (videoContainer.value) {
|
|
4001
|
+
resizeObserver.value.observe(videoContainer.value);
|
|
4002
|
+
}
|
|
4003
|
+
if (remoteVideoElement.value) {
|
|
4004
|
+
remoteVideoElement.value.addEventListener("resize", () => {
|
|
4005
|
+
if (!remoteVideoElement.value) return;
|
|
4006
|
+
remoteVideo.value = {
|
|
4007
|
+
width: remoteVideoElement.value.videoWidth,
|
|
4008
|
+
height: remoteVideoElement.value.videoHeight
|
|
4009
|
+
};
|
|
4010
|
+
console.log("remoteVideo.value====>", remoteVideo.value);
|
|
4011
|
+
screenStatus.value = true;
|
|
4012
|
+
});
|
|
4013
|
+
remoteVideoElement.value.addEventListener("loadedmetadata", () => {
|
|
4014
|
+
scheduleFrame();
|
|
4015
|
+
});
|
|
4016
|
+
}
|
|
4017
|
+
};
|
|
4018
|
+
const scheduleFrame = () => {
|
|
4019
|
+
if (!remoteVideoElement.value) return;
|
|
4020
|
+
id.value = remoteVideoElement.value.requestVideoFrameCallback((now, metadata) => {
|
|
4021
|
+
console.log("now", now, "Frame at", metadata.presentationTime.toFixed(2), "ms");
|
|
4022
|
+
scheduleFrame();
|
|
4023
|
+
});
|
|
4024
|
+
};
|
|
4025
|
+
const startPlay = (track) => {
|
|
4026
|
+
if (!remoteVideoElement.value) return;
|
|
4027
|
+
if (!remoteVideoElement.value.srcObject) {
|
|
4028
|
+
remoteVideoElement.value.srcObject = new MediaStream();
|
|
4029
|
+
}
|
|
4030
|
+
remoteVideoElement.value.playsInline = true;
|
|
4031
|
+
remoteVideoElement.value.setAttribute("webkit-playsinline", "true");
|
|
4032
|
+
remoteVideoElement.value.srcObject.addTrack(track);
|
|
4033
|
+
};
|
|
4034
|
+
const stopPlay = () => {
|
|
4035
|
+
screenStatus.value = false;
|
|
4036
|
+
if (remoteVideoElement.value && remoteVideoElement.value.srcObject) {
|
|
4037
|
+
remoteVideoElement.value.srcObject.getTracks().forEach((track) => track.stop());
|
|
4038
|
+
remoteVideoElement.value.srcObject = null;
|
|
4039
|
+
remoteVideoElement.value.cancelVideoFrameCallback(id.value);
|
|
4040
|
+
}
|
|
4041
|
+
};
|
|
4042
|
+
return {
|
|
4043
|
+
videoSize,
|
|
4044
|
+
remoteVideo,
|
|
4045
|
+
dimensions,
|
|
4046
|
+
widthRadio,
|
|
4047
|
+
heightRadio,
|
|
4048
|
+
screenStatus,
|
|
4049
|
+
initVideoContainer,
|
|
4050
|
+
startPlay,
|
|
4051
|
+
stopPlay
|
|
4052
|
+
};
|
|
4053
|
+
}
|
|
4054
|
+
function useMouseTouchControl(options) {
|
|
4055
|
+
const {
|
|
4056
|
+
isMobile,
|
|
4057
|
+
remoteVideoElement,
|
|
4058
|
+
cloudDeviceSize,
|
|
4059
|
+
streamAngle,
|
|
4060
|
+
videoAngle,
|
|
4061
|
+
widthRadio,
|
|
4062
|
+
emit
|
|
4063
|
+
} = options;
|
|
4064
|
+
const isPointerDown = ref(false);
|
|
4065
|
+
const bound = ref(0);
|
|
4066
|
+
const pointerList = ref(new Array(20).fill(0));
|
|
4067
|
+
const pointerDownTime = ref(new Array(10).fill(0));
|
|
4068
|
+
const endX = ref(0);
|
|
4069
|
+
const endY = ref(0);
|
|
4070
|
+
const handlePointerEvent = (event, action) => {
|
|
4071
|
+
if (!remoteVideoElement.value) return;
|
|
4072
|
+
const offsetTime = Math.trunc(event.timeStamp - pointerDownTime.value[0]);
|
|
4073
|
+
const rect = remoteVideoElement.value.getBoundingClientRect();
|
|
4074
|
+
let x = event.clientX - rect.left;
|
|
4075
|
+
let y = event.clientY - rect.top;
|
|
4076
|
+
const cloudWidth = cloudDeviceSize.value.width;
|
|
4077
|
+
const cloudHeight = cloudDeviceSize.value.height;
|
|
4078
|
+
const result = transformCoordinate(
|
|
4079
|
+
rect.width,
|
|
4080
|
+
rect.height,
|
|
4081
|
+
cloudWidth,
|
|
4082
|
+
cloudHeight,
|
|
4083
|
+
videoAngle.value,
|
|
4084
|
+
streamAngle.value,
|
|
4085
|
+
x,
|
|
4086
|
+
y
|
|
4087
|
+
);
|
|
4088
|
+
if (!result || result.length < 2) return;
|
|
4089
|
+
x = result[0];
|
|
4090
|
+
y = result[1];
|
|
4091
|
+
if (action === ActionType.ACTION_MOVE) {
|
|
4092
|
+
const flipY = pointerList.value[10] - y;
|
|
4093
|
+
const flipX = pointerList.value[0] - x;
|
|
4094
|
+
if (Math.abs(flipY) < bound.value && Math.abs(flipX) < bound.value) return;
|
|
4095
|
+
}
|
|
4096
|
+
pointerList.value[0] = x;
|
|
4097
|
+
pointerList.value[10] = y;
|
|
4098
|
+
const percentResult = valueToPercentage(
|
|
4099
|
+
rect.width,
|
|
4100
|
+
rect.height,
|
|
4101
|
+
cloudWidth,
|
|
4102
|
+
cloudHeight,
|
|
4103
|
+
videoAngle.value,
|
|
4104
|
+
streamAngle.value,
|
|
4105
|
+
x,
|
|
4106
|
+
y
|
|
4107
|
+
);
|
|
4108
|
+
const touchData = new TouchData(action, 0, percentResult[0], percentResult[1], offsetTime);
|
|
4109
|
+
emit("channelEvent", ChannelDataType.ClickData, touchData);
|
|
4110
|
+
};
|
|
4111
|
+
const onTouchStart = (e) => {
|
|
4112
|
+
if (!isMobile.value) return;
|
|
4113
|
+
const touches = Array.from(e.touches);
|
|
4114
|
+
if (touches.length > 0) {
|
|
4115
|
+
pointerDownTime.value[0] = e.timeStamp;
|
|
4116
|
+
bound.value = Math.trunc(4 / widthRadio.value);
|
|
4117
|
+
endX.value = touches[0].clientX;
|
|
4118
|
+
endY.value = touches[0].clientY;
|
|
4119
|
+
const event = {
|
|
4120
|
+
clientX: endX.value,
|
|
4121
|
+
clientY: endY.value,
|
|
4122
|
+
timeStamp: e.timeStamp
|
|
4123
|
+
};
|
|
4124
|
+
handlePointerEvent(event, ActionType.ACTION_DOWN);
|
|
4125
|
+
}
|
|
4126
|
+
};
|
|
4127
|
+
const onTouchMove = (e) => {
|
|
4128
|
+
if (!isMobile.value) return;
|
|
4129
|
+
const touches = Array.from(e.touches);
|
|
4130
|
+
if (touches.length > 0) {
|
|
4131
|
+
endX.value = touches[0].clientX;
|
|
4132
|
+
endY.value = touches[0].clientY;
|
|
4133
|
+
const event = {
|
|
4134
|
+
clientX: endX.value,
|
|
4135
|
+
clientY: endY.value,
|
|
4136
|
+
timeStamp: e.timeStamp
|
|
4137
|
+
};
|
|
4138
|
+
handlePointerEvent(event, ActionType.ACTION_MOVE);
|
|
4139
|
+
}
|
|
4140
|
+
};
|
|
4141
|
+
const onTouchEnd = (e) => {
|
|
4142
|
+
if (!isMobile.value) return;
|
|
4143
|
+
const event = {
|
|
4144
|
+
clientX: endX.value,
|
|
4145
|
+
clientY: endY.value,
|
|
4146
|
+
timeStamp: e.timeStamp
|
|
4147
|
+
};
|
|
4148
|
+
handlePointerEvent(event, ActionType.ACTION_UP);
|
|
4149
|
+
};
|
|
4150
|
+
const handleMouseDown = (event) => {
|
|
4151
|
+
if (isMobile.value) return;
|
|
4152
|
+
isPointerDown.value = true;
|
|
4153
|
+
if (remoteVideoElement.value) {
|
|
4154
|
+
remoteVideoElement.value.setPointerCapture(event.pointerId);
|
|
4155
|
+
}
|
|
4156
|
+
pointerDownTime.value[0] = event.timeStamp;
|
|
4157
|
+
bound.value = Math.trunc(4 / widthRadio.value);
|
|
4158
|
+
handlePointerEvent(event, ActionType.ACTION_DOWN);
|
|
4159
|
+
};
|
|
4160
|
+
const handleMouseMove = (event) => {
|
|
4161
|
+
if (isMobile.value || !isPointerDown.value) return;
|
|
4162
|
+
handlePointerEvent(event, ActionType.ACTION_MOVE);
|
|
4163
|
+
};
|
|
4164
|
+
const handleMouseUp = (event) => {
|
|
4165
|
+
if (isMobile.value || !isPointerDown.value) return;
|
|
4166
|
+
isPointerDown.value = false;
|
|
4167
|
+
handlePointerEvent(event, ActionType.ACTION_UP);
|
|
4168
|
+
if (remoteVideoElement.value) {
|
|
4169
|
+
remoteVideoElement.value.releasePointerCapture(event.pointerId);
|
|
4170
|
+
}
|
|
4171
|
+
};
|
|
4172
|
+
const handleMouseEnter = (event) => {
|
|
4173
|
+
if (isMobile.value) return;
|
|
4174
|
+
if (event.buttons === 1 && !isPointerDown.value) {
|
|
4175
|
+
isPointerDown.value = true;
|
|
4176
|
+
if (remoteVideoElement.value) {
|
|
4177
|
+
remoteVideoElement.value.setPointerCapture(event.pointerId);
|
|
4178
|
+
}
|
|
4179
|
+
pointerDownTime.value[0] = event.timeStamp;
|
|
4180
|
+
bound.value = Math.trunc(4 / widthRadio.value);
|
|
4181
|
+
handlePointerEvent(event, ActionType.ACTION_DOWN);
|
|
4182
|
+
}
|
|
4183
|
+
};
|
|
4184
|
+
const handleMouseLeave = (event) => {
|
|
4185
|
+
if (isPointerDown.value) {
|
|
4186
|
+
handlePointerEvent(event, ActionType.ACTION_UP);
|
|
4187
|
+
isPointerDown.value = false;
|
|
4188
|
+
if (remoteVideoElement.value) {
|
|
4189
|
+
remoteVideoElement.value.releasePointerCapture(event.pointerId);
|
|
4190
|
+
}
|
|
4191
|
+
}
|
|
4192
|
+
};
|
|
4193
|
+
const handleWheel = (e) => {
|
|
4194
|
+
const delta = Math.sign(e.deltaY) * -1;
|
|
4195
|
+
const wheelData = new WheelData(delta);
|
|
4196
|
+
emit("channelEvent", ChannelDataType.ActionWheel, wheelData);
|
|
4197
|
+
};
|
|
4198
|
+
return {
|
|
4199
|
+
isPointerDown,
|
|
4200
|
+
onTouchStart,
|
|
4201
|
+
onTouchMove,
|
|
4202
|
+
onTouchEnd,
|
|
4203
|
+
handleMouseDown,
|
|
4204
|
+
handleMouseMove,
|
|
4205
|
+
handleMouseEnter,
|
|
4206
|
+
handleMouseUp,
|
|
4207
|
+
handleMouseLeave,
|
|
4208
|
+
handleWheel
|
|
4209
|
+
};
|
|
4210
|
+
}
|
|
4211
|
+
function useKeyboardControl(disabled, emit) {
|
|
4212
|
+
const listening = ref(false);
|
|
4213
|
+
const handleKeyDown = (e) => {
|
|
4214
|
+
const data = getKeyEventData(e);
|
|
4215
|
+
emit("channelEvent", ChannelDataType.ActionInput, data);
|
|
4216
|
+
};
|
|
4217
|
+
const startListening = () => {
|
|
4218
|
+
if (!disabled) {
|
|
4219
|
+
return;
|
|
4220
|
+
}
|
|
4221
|
+
listening.value = true;
|
|
4222
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
4223
|
+
};
|
|
4224
|
+
const stopListening = () => {
|
|
4225
|
+
if (!disabled) {
|
|
4226
|
+
return;
|
|
4227
|
+
}
|
|
4228
|
+
listening.value = false;
|
|
4229
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
4230
|
+
};
|
|
4231
|
+
return {
|
|
4232
|
+
startListening,
|
|
4233
|
+
stopListening
|
|
4234
|
+
};
|
|
4235
|
+
}
|
|
4236
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4237
|
+
__name: "index",
|
|
4238
|
+
props: {
|
|
4239
|
+
streamAngle: { default: 0 },
|
|
4240
|
+
videoAngle: { default: 0 },
|
|
4241
|
+
cursorType: { default: 0 },
|
|
4242
|
+
cloudDeviceSize: { default: () => ({ width: 0, height: 0 }) },
|
|
4243
|
+
disabled: { type: Boolean, default: true }
|
|
4244
|
+
},
|
|
4245
|
+
emits: ["channelEvent"],
|
|
4246
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
4247
|
+
const emit = __emit;
|
|
4248
|
+
const props = __props;
|
|
4249
|
+
const { streamAngle, videoAngle, cursorType, cloudDeviceSize, disabled } = toRefs(props);
|
|
4250
|
+
const videoContainer = ref(null);
|
|
4251
|
+
const remoteVideoElement = ref(null);
|
|
4252
|
+
const {
|
|
4253
|
+
isMobile,
|
|
4254
|
+
checkDeviceMode,
|
|
4255
|
+
checkTouchSupport,
|
|
4256
|
+
handleUp
|
|
4257
|
+
} = useDeviceMode();
|
|
4258
|
+
const cursorClass = useCursorStyle(cursorType);
|
|
4259
|
+
const {
|
|
4260
|
+
videoSize,
|
|
4261
|
+
dimensions,
|
|
4262
|
+
widthRadio,
|
|
4263
|
+
initVideoContainer,
|
|
4264
|
+
startPlay,
|
|
4265
|
+
stopPlay
|
|
4266
|
+
} = useRemoteVideo(videoContainer, remoteVideoElement, videoAngle);
|
|
4267
|
+
const {
|
|
4268
|
+
onTouchStart,
|
|
4269
|
+
onTouchMove,
|
|
4270
|
+
onTouchEnd,
|
|
4271
|
+
handleMouseDown,
|
|
4272
|
+
handleMouseMove,
|
|
4273
|
+
handleMouseEnter,
|
|
4274
|
+
handleMouseUp,
|
|
4275
|
+
handleMouseLeave,
|
|
4276
|
+
handleWheel
|
|
4277
|
+
} = useMouseTouchControl({
|
|
4278
|
+
isMobile,
|
|
4279
|
+
remoteVideoElement,
|
|
4280
|
+
cloudDeviceSize,
|
|
4281
|
+
streamAngle,
|
|
4282
|
+
videoAngle,
|
|
4283
|
+
widthRadio,
|
|
4284
|
+
emit
|
|
4285
|
+
});
|
|
4286
|
+
const {
|
|
4287
|
+
startListening,
|
|
4288
|
+
stopListening
|
|
4289
|
+
} = useKeyboardControl(disabled, emit);
|
|
4290
|
+
useResizeObserver(videoContainer, dimensions);
|
|
4291
|
+
const handleClick = () => {
|
|
4292
|
+
var _a;
|
|
4293
|
+
if ((_a = remoteVideoElement.value) == null ? void 0 : _a.srcObject) {
|
|
4294
|
+
remoteVideoElement.value.muted = false;
|
|
4295
|
+
}
|
|
4296
|
+
};
|
|
4297
|
+
onMounted(() => {
|
|
4298
|
+
checkDeviceMode();
|
|
4299
|
+
window.addEventListener("resize", checkDeviceMode);
|
|
4300
|
+
window.addEventListener("pointerdown", checkTouchSupport);
|
|
4301
|
+
window.addEventListener("pointerup", handleUp);
|
|
4302
|
+
document.addEventListener("click", handleClick);
|
|
4303
|
+
initVideoContainer();
|
|
4304
|
+
});
|
|
4305
|
+
onUnmounted(() => {
|
|
4306
|
+
window.removeEventListener("resize", checkDeviceMode);
|
|
4307
|
+
window.removeEventListener("pointerdown", checkTouchSupport);
|
|
4308
|
+
window.removeEventListener("pointerup", handleUp);
|
|
4309
|
+
document.removeEventListener("click", handleClick);
|
|
4310
|
+
});
|
|
4311
|
+
__expose({ startPlay, stopPlay });
|
|
4312
|
+
return (_ctx, _cache) => {
|
|
4313
|
+
return openBlock(), createElementBlock("div", {
|
|
4314
|
+
ref_key: "videoContainer",
|
|
4315
|
+
ref: videoContainer,
|
|
4316
|
+
class: "flex flex-1 items-center justify-center",
|
|
4317
|
+
style: { "width": "100%", "height": "100%", "background": "black", "position": "relative", "overflow": "hidden" }
|
|
4318
|
+
}, [
|
|
4319
|
+
createElementVNode("div", {
|
|
4320
|
+
ref: "keyboardArea",
|
|
4321
|
+
onPointerenter: _cache[9] || (_cache[9] = //@ts-ignore
|
|
4322
|
+
(...args) => unref(startListening) && unref(startListening)(...args)),
|
|
4323
|
+
onPointerleave: _cache[10] || (_cache[10] = //@ts-ignore
|
|
4324
|
+
(...args) => unref(stopListening) && unref(stopListening)(...args)),
|
|
4325
|
+
class: "vContainer",
|
|
4326
|
+
style: normalizeStyle([{ height: unref(videoSize).height + "px", width: unref(videoSize).width + "px", transform: `rotate(${unref(videoAngle)}deg)` }, { "position": "relative" }])
|
|
4327
|
+
}, [
|
|
4328
|
+
createElementVNode("video", {
|
|
4329
|
+
ref_key: "remoteVideoElement",
|
|
4330
|
+
ref: remoteVideoElement,
|
|
4331
|
+
class: normalizeClass(["video-control", [unref(cursorClass), { "no-events": unref(disabled) }]]),
|
|
4332
|
+
onTouchstart: _cache[0] || (_cache[0] = //@ts-ignore
|
|
4333
|
+
(...args) => unref(onTouchStart) && unref(onTouchStart)(...args)),
|
|
4334
|
+
onTouchmove: _cache[1] || (_cache[1] = //@ts-ignore
|
|
4335
|
+
(...args) => unref(onTouchMove) && unref(onTouchMove)(...args)),
|
|
4336
|
+
onTouchend: _cache[2] || (_cache[2] = //@ts-ignore
|
|
4337
|
+
(...args) => unref(onTouchEnd) && unref(onTouchEnd)(...args)),
|
|
4338
|
+
onPointerenter: _cache[3] || (_cache[3] = //@ts-ignore
|
|
4339
|
+
(...args) => unref(handleMouseEnter) && unref(handleMouseEnter)(...args)),
|
|
4340
|
+
onPointerdown: _cache[4] || (_cache[4] = //@ts-ignore
|
|
4341
|
+
(...args) => unref(handleMouseDown) && unref(handleMouseDown)(...args)),
|
|
4342
|
+
onPointermove: _cache[5] || (_cache[5] = //@ts-ignore
|
|
4343
|
+
(...args) => unref(handleMouseMove) && unref(handleMouseMove)(...args)),
|
|
4344
|
+
onPointerup: _cache[6] || (_cache[6] = //@ts-ignore
|
|
4345
|
+
(...args) => unref(handleMouseUp) && unref(handleMouseUp)(...args)),
|
|
4346
|
+
onPointerleave: _cache[7] || (_cache[7] = //@ts-ignore
|
|
4347
|
+
(...args) => unref(handleMouseLeave) && unref(handleMouseLeave)(...args)),
|
|
4348
|
+
onWheel: _cache[8] || (_cache[8] = //@ts-ignore
|
|
4349
|
+
(...args) => unref(handleWheel) && unref(handleWheel)(...args)),
|
|
4350
|
+
autoplay: "",
|
|
4351
|
+
playsinline: "",
|
|
4352
|
+
muted: "",
|
|
4353
|
+
disablePictureInPicture: true
|
|
4354
|
+
}, null, 34)
|
|
4355
|
+
], 36)
|
|
4356
|
+
], 512);
|
|
4357
|
+
};
|
|
4358
|
+
}
|
|
4359
|
+
});
|
|
4360
|
+
const _export_sfc = (sfc, props) => {
|
|
4361
|
+
const target = sfc.__vccOpts || sfc;
|
|
4362
|
+
for (const [key, val] of props) {
|
|
4363
|
+
target[key] = val;
|
|
4364
|
+
}
|
|
4365
|
+
return target;
|
|
4366
|
+
};
|
|
4367
|
+
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-51dd3cb6"]]);
|
|
3860
4368
|
export {
|
|
4369
|
+
ActionCommandType,
|
|
3861
4370
|
ActionType,
|
|
3862
4371
|
ChannelDataType,
|
|
3863
4372
|
ContainerDirection,
|
|
3864
4373
|
EmitType,
|
|
4374
|
+
GestureData,
|
|
3865
4375
|
InputData,
|
|
3866
4376
|
KeyEventData,
|
|
4377
|
+
index as RemotePlayer,
|
|
3867
4378
|
TouchData,
|
|
3868
4379
|
WebRTCSdk,
|
|
4380
|
+
WheelData,
|
|
3869
4381
|
getKeyEventData,
|
|
3870
4382
|
transformCoordinate,
|
|
3871
4383
|
valueToPercentage
|