yjz-web-sdk 1.0.2-beta.4 → 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.
|
@@ -37,6 +37,14 @@ export declare enum ActionCommandType {
|
|
|
37
37
|
export interface ActionCommand {
|
|
38
38
|
type: ActionCommandType;
|
|
39
39
|
}
|
|
40
|
+
export declare enum ActionCommandEventType {
|
|
41
|
+
/** 云机控制拉流端是否推流 Camera 和 MIC 数据到云机侧,或拉流端控制云机是否推流三方播放的音频 */
|
|
42
|
+
ACTION_CONTROL_VIDEO_AND_AUDIO = "ACTION_CONTROL_VIDEO_AND_AUDIO",
|
|
43
|
+
/** 控制是否推送视频 */
|
|
44
|
+
ACTION_CONTROL_VIDEO = "ACTION_CONTROL_VIDEO",
|
|
45
|
+
/** 控制是否推送音频 */
|
|
46
|
+
ACTION_CONTROL_AUDIO = "ACTION_CONTROL_AUDIO"
|
|
47
|
+
}
|
|
40
48
|
export declare const ActionType: {
|
|
41
49
|
readonly ACTION_DOWN: 0;
|
|
42
50
|
readonly ACTION_MOVE: 2;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { WebRTCConfigOptions } from "../rtc/WebRTCConfig.ts";
|
|
2
|
-
import type
|
|
3
|
-
|
|
2
|
+
import { type ChannelDataType } from "../data/WebrtcDataType.ts";
|
|
3
|
+
import { EventEmitter } from "eventemitter3";
|
|
4
|
+
export declare class GroupControllerManager extends EventEmitter {
|
|
4
5
|
private webRTCConfigList;
|
|
5
6
|
private sdkList;
|
|
6
7
|
private loopTimer;
|
package/lib/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { WebRTCSdk } from './core/WebRTCSdk';
|
|
|
2
2
|
import { getKeyEventData } from "./core/util/KeyCodeUtil";
|
|
3
3
|
import { transformCoordinate, valueToPercentage } from "./core/util/ScreenControlUtil";
|
|
4
4
|
import { ActionType, ChannelDataType, ContainerDirection, InputData, KeyEventData, TouchData, WheelData, GestureData, type ActionCommand, ActionCommandType } from "./core/data/WebrtcDataType";
|
|
5
|
+
import type { WebRTCConfigOptions } from './core/rtc/WebRTCConfig';
|
|
5
6
|
import { GroupControllerManager } from "./core/groupctrl/GroupControllerManager.ts";
|
|
6
7
|
import { EmitType } from "./core/data/WebRtcError";
|
|
7
8
|
import RemotePlayer from './components/RemotePlayer/index.vue';
|
|
8
|
-
export { WebRTCSdk, getKeyEventData, transformCoordinate, valueToPercentage, ActionType, ChannelDataType, InputData, KeyEventData, TouchData, ContainerDirection, EmitType, WheelData, GestureData, type ActionCommand, ActionCommandType, GroupControllerManager, RemotePlayer };
|
|
9
|
+
export { WebRTCSdk, getKeyEventData, transformCoordinate, valueToPercentage, ActionType, ChannelDataType, InputData, KeyEventData, TouchData, ContainerDirection, EmitType, WheelData, GestureData, type ActionCommand, ActionCommandType, GroupControllerManager, type WebRTCConfigOptions, RemotePlayer };
|
package/lib/yjz-web-sdk.js
CHANGED
|
@@ -327,7 +327,6 @@ class SignalingClient extends EventEmitter {
|
|
|
327
327
|
start() {
|
|
328
328
|
this.webSocket = new WebSocket(this.config.signalServerUrl);
|
|
329
329
|
this.webSocket.onopen = () => {
|
|
330
|
-
console.log("sendSignInMessagesendSignInMessagesendSignInMessage");
|
|
331
330
|
this.sendSignInMessage();
|
|
332
331
|
if (this.timeout === null) {
|
|
333
332
|
this.timeout = setTimeout(() => {
|
|
@@ -399,7 +398,8 @@ class SignalingClient extends EventEmitter {
|
|
|
399
398
|
sendRequestScreenshot(visible) {
|
|
400
399
|
const message = {
|
|
401
400
|
type: SendType.RequestScreenshot,
|
|
402
|
-
visible
|
|
401
|
+
visible,
|
|
402
|
+
roomId: this.config.roomId
|
|
403
403
|
};
|
|
404
404
|
const jsonMessage = JSON.stringify(message);
|
|
405
405
|
this.sendMessage(jsonMessage);
|
|
@@ -3034,7 +3034,6 @@ const setLocalDescriptionWithCreateAnswer = (peerConnection, answer, sendAnswer,
|
|
|
3034
3034
|
sendAnswer == null ? void 0 : sendAnswer(answer.sdp ?? "");
|
|
3035
3035
|
}).catch((error) => {
|
|
3036
3036
|
onError == null ? void 0 : onError(createWebRtcError(FailCode.LOCAL_DES, error));
|
|
3037
|
-
console.log("21321322212213");
|
|
3038
3037
|
});
|
|
3039
3038
|
};
|
|
3040
3039
|
const createPeerConnection = (config) => {
|
|
@@ -3519,7 +3518,6 @@ class WebRTCClient extends EventEmitter {
|
|
|
3519
3518
|
totalDecodeTime = report.totalDecodeTime || 0;
|
|
3520
3519
|
framesDecoded = report.framesDecoded || 0;
|
|
3521
3520
|
framesReceived = report.framesReceived || 0;
|
|
3522
|
-
console.log("接收:", report.framesReceived, "解码:", report.framesDecoded);
|
|
3523
3521
|
pliCount = (report.pliCount || 0) + (report.firCount || 0);
|
|
3524
3522
|
}
|
|
3525
3523
|
}
|
|
@@ -3593,7 +3591,6 @@ class WebRTCSdk extends EventEmitter {
|
|
|
3593
3591
|
this.config.myId = message.myId;
|
|
3594
3592
|
break;
|
|
3595
3593
|
case MessageType.Offer:
|
|
3596
|
-
console.log("handleSignaling===>", message);
|
|
3597
3594
|
if (message.senderId && message.sdp) {
|
|
3598
3595
|
this.config.targetId = message.senderId;
|
|
3599
3596
|
this.webRTCClient.handleOffer(message.sdp);
|
|
@@ -3629,9 +3626,8 @@ class WebRTCSdk extends EventEmitter {
|
|
|
3629
3626
|
this.sendPong();
|
|
3630
3627
|
break;
|
|
3631
3628
|
case MessageType.SendScreenshot:
|
|
3632
|
-
const base64Str = message.screenshot
|
|
3629
|
+
const base64Str = `data:image/png;base64,${message.screenshot}`;
|
|
3633
3630
|
this.emit(EmitType.screenshot, { "room_id": this.config.roomId, "base64": base64Str });
|
|
3634
|
-
console.log(base64Str);
|
|
3635
3631
|
break;
|
|
3636
3632
|
}
|
|
3637
3633
|
});
|
|
@@ -3719,11 +3715,6 @@ class WebRTCSdk extends EventEmitter {
|
|
|
3719
3715
|
}
|
|
3720
3716
|
/** 开始推流:触发媒体采集与轨道添加 */
|
|
3721
3717
|
async startPush() {
|
|
3722
|
-
try {
|
|
3723
|
-
await this.webRTCClient.readyCapture();
|
|
3724
|
-
} catch (error) {
|
|
3725
|
-
this.emit("error", { type: "camera", error });
|
|
3726
|
-
}
|
|
3727
3718
|
}
|
|
3728
3719
|
/** 发送信道数据 */
|
|
3729
3720
|
sendChannelData(type, data) {
|
|
@@ -3952,8 +3943,9 @@ function rotatePoint90(width, height, inputX, inputY) {
|
|
|
3952
3943
|
const yRotated = -x0 + offsetShortSide;
|
|
3953
3944
|
return [xRotated, yRotated];
|
|
3954
3945
|
}
|
|
3955
|
-
class GroupControllerManager {
|
|
3946
|
+
class GroupControllerManager extends EventEmitter {
|
|
3956
3947
|
constructor() {
|
|
3948
|
+
super(...arguments);
|
|
3957
3949
|
__publicField(this, "webRTCConfigList", []);
|
|
3958
3950
|
__publicField(this, "sdkList", []);
|
|
3959
3951
|
__publicField(this, "loopTimer", null);
|
|
@@ -3970,14 +3962,11 @@ class GroupControllerManager {
|
|
|
3970
3962
|
}
|
|
3971
3963
|
this.webRTCConfigList = configList;
|
|
3972
3964
|
configList.forEach((config) => {
|
|
3973
|
-
console.log("Connection Info:", {
|
|
3974
|
-
roomId: config.roomId,
|
|
3975
|
-
signalServer: config.signalServerUrl,
|
|
3976
|
-
turnServer: config.turnServerUri,
|
|
3977
|
-
isControl: config.isControl
|
|
3978
|
-
});
|
|
3979
3965
|
const sdk = new WebRTCSdk(config);
|
|
3980
3966
|
sdk.startConnection();
|
|
3967
|
+
sdk.on(EmitType.screenshot, (screenshot) => {
|
|
3968
|
+
this.emit(EmitType.screenshot, screenshot);
|
|
3969
|
+
});
|
|
3981
3970
|
this.sdkList.push(sdk);
|
|
3982
3971
|
});
|
|
3983
3972
|
this.startLoop();
|
|
@@ -3987,6 +3976,7 @@ class GroupControllerManager {
|
|
|
3987
3976
|
this.sdkList = [];
|
|
3988
3977
|
this.visibilityMap.clear();
|
|
3989
3978
|
this.previousVisibilityMap.clear();
|
|
3979
|
+
this.removeAllListeners();
|
|
3990
3980
|
this.stopLoop();
|
|
3991
3981
|
}
|
|
3992
3982
|
getConnectionList() {
|
|
@@ -4127,21 +4117,10 @@ function useRemoteVideo(videoContainer, remoteVideoElement, videoAngle) {
|
|
|
4127
4117
|
width: remoteVideoElement.value.videoWidth,
|
|
4128
4118
|
height: remoteVideoElement.value.videoHeight
|
|
4129
4119
|
};
|
|
4130
|
-
console.log("remoteVideo.value====>", remoteVideo.value);
|
|
4131
4120
|
screenStatus.value = true;
|
|
4132
4121
|
});
|
|
4133
|
-
remoteVideoElement.value.addEventListener("loadedmetadata", () => {
|
|
4134
|
-
scheduleFrame();
|
|
4135
|
-
});
|
|
4136
4122
|
}
|
|
4137
4123
|
};
|
|
4138
|
-
const scheduleFrame = () => {
|
|
4139
|
-
if (!remoteVideoElement.value) return;
|
|
4140
|
-
id.value = remoteVideoElement.value.requestVideoFrameCallback((now, metadata) => {
|
|
4141
|
-
console.log("now", now, "Frame at", metadata.presentationTime.toFixed(2), "ms");
|
|
4142
|
-
scheduleFrame();
|
|
4143
|
-
});
|
|
4144
|
-
};
|
|
4145
4124
|
const startPlay = (track) => {
|
|
4146
4125
|
if (!remoteVideoElement.value) return;
|
|
4147
4126
|
if (!remoteVideoElement.value.srcObject) {
|
package/lib/yjz-web-sdk.umd.cjs
CHANGED
|
@@ -17,7 +17,7 @@ r(this,"webSocket",null),r(this,"timeout",null),this.config=e}
|
|
|
17
17
|
/**
|
|
18
18
|
* 用于从控请求当前截屏
|
|
19
19
|
* @param visible 当前从控page控件是否可见
|
|
20
|
-
*/sendRequestScreenshot(e){const t={type:l.RequestScreenshot,visible:e},n=JSON.stringify(t);this.sendMessage(n)}}let g=!0,v=!0;function y(e,t,n){const r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function S(e,t,n){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);const o=e=>{const t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,o),i.apply(this,[e,o])};const o=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(n))return o.apply(this,arguments);const r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function T(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(g=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function R(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(v=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function b(){if("object"==typeof window){if(g)return;"undefined"!=typeof console&&console.log}}function P(e){return"[object Object]"===Object.prototype.toString.call(e)}function w(e){return P(e)?Object.keys(e).reduce((function(t,n){const r=P(e[n]),i=r?w(e[n]):e[n],o=r&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,{[n]:i})}),{}):e}function E(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach((r=>{r.endsWith("Id")?E(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach((t=>{E(e,e.get(t),n)}))})))}function k(e,t,n){const r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((n=>{n.type===r&&n.trackId===t.id&&E(e,n,i)}))})),i}const _=b;function A(e,t){const n=e&&e.navigator;if(!n.mediaDevices)return;const r=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((n=>{if("require"===n||"advanced"===n||"mediaSource"===n)return;const r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];let e={};"number"==typeof r.ideal?(e[i("min",n)]=r.ideal,t.optional.push(e),e={},e[i("max",n)]=r.ideal,t.optional.push(e)):(e[i("",n)]=r.ideal,t.optional.push(e))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach((e=>{void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const s=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||s)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return n.mediaDevices.enumerateDevices().then((n=>{let s=(n=n.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!s&&n.length&&t.includes("back")&&(s=n[n.length-1]),s&&(e.video.deviceId=o.exact?{exact:s.deviceId}:{ideal:s.deviceId}),e.video=r(e.video),_("chrome: "+JSON.stringify(e)),i(e)}))}e.video=r(e.video)}return _("chrome: "+JSON.stringify(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,r){i(e,(e=>{n.webkitGetUserMedia(e,t,(e=>{r&&r(o(e))}))}))}.bind(n),n.mediaDevices.getUserMedia){const e=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(t){return i(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(o(e))))))}}}function D(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function O(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.track.id)):{track:n.track};const i=new Event("track");i.track=n.track,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)})),t.stream.getTracks().forEach((n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.id)):{track:n};const i=new Event("track");i.track=n,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else S(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function I(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){let i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function M(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>
|
|
20
|
+
*/sendRequestScreenshot(e){const t={type:l.RequestScreenshot,visible:e,roomId:this.config.roomId},n=JSON.stringify(t);this.sendMessage(n)}}let g=!0,v=!0;function y(e,t,n){const r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function S(e,t,n){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);const o=e=>{const t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,o),i.apply(this,[e,o])};const o=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(n))return o.apply(this,arguments);const r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function T(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(g=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function R(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(v=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function b(){if("object"==typeof window){if(g)return;"undefined"!=typeof console&&console.log}}function P(e){return"[object Object]"===Object.prototype.toString.call(e)}function w(e){return P(e)?Object.keys(e).reduce((function(t,n){const r=P(e[n]),i=r?w(e[n]):e[n],o=r&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,{[n]:i})}),{}):e}function E(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach((r=>{r.endsWith("Id")?E(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach((t=>{E(e,e.get(t),n)}))})))}function k(e,t,n){const r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((n=>{n.type===r&&n.trackId===t.id&&E(e,n,i)}))})),i}const _=b;function A(e,t){const n=e&&e.navigator;if(!n.mediaDevices)return;const r=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((n=>{if("require"===n||"advanced"===n||"mediaSource"===n)return;const r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];let e={};"number"==typeof r.ideal?(e[i("min",n)]=r.ideal,t.optional.push(e),e={},e[i("max",n)]=r.ideal,t.optional.push(e)):(e[i("",n)]=r.ideal,t.optional.push(e))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach((e=>{void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const s=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||s)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return n.mediaDevices.enumerateDevices().then((n=>{let s=(n=n.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!s&&n.length&&t.includes("back")&&(s=n[n.length-1]),s&&(e.video.deviceId=o.exact?{exact:s.deviceId}:{ideal:s.deviceId}),e.video=r(e.video),_("chrome: "+JSON.stringify(e)),i(e)}))}e.video=r(e.video)}return _("chrome: "+JSON.stringify(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,r){i(e,(e=>{n.webkitGetUserMedia(e,t,(e=>{r&&r(o(e))}))}))}.bind(n),n.mediaDevices.getUserMedia){const e=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(t){return i(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(o(e))))))}}}function D(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function O(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.track.id)):{track:n.track};const i=new Event("track");i.track=n.track,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)})),t.stream.getTracks().forEach((n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.id)):{track:n};const i=new Event("track");i.track=n,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else S(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function I(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){let i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function M(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>
|
|
21
21
|
/* Note: this will include stats of all senders that
|
|
22
22
|
* send a track with the same id as sender.track as
|
|
23
23
|
* it is not possible to identify the RTCRtpSender.
|
|
@@ -74,7 +74,7 @@ bitrate:T,pliCount:c,averageDecodeTime:R,framesDecoded:a,framesReceived:d};this.
|
|
|
74
74
|
* 处理 signal 消息,根据不同消息类型分发到 webRTCClient 或直接触发 SDK 事件
|
|
75
75
|
* @param message 信令消息
|
|
76
76
|
*/
|
|
77
|
-
r(this,"handleSignaling",(e=>{switch(e.type){case p.Peers:this.config.myId=e.myId;break;case p.Offer:e.senderId&&e.sdp&&(this.config.targetId=e.senderId,this.webRTCClient.handleOffer(e.sdp));break;case p.Answer:e.sdp&&this.webRTCClient.handleAnswer(e.sdp);break;case p.IceCandidates:if(e.ice)try{const t=JSON.parse(e.ice);t.candidate=t.sdp,this.webRTCClient.handleIceCandidate(new RTCIceCandidate(t))}catch(t){this.emit("error",{type:"iceCandidate",error:t})}break;case p.SignOut:e.myId===this.config.myId&&(this.webRTCClient.closeConnection(),this.signalingClient.close(),this.removeAllListeners());break;case p.NotAvailable:this.emit(m.webrtcError,f(h.NOT_AVAILABLE,""));break;case p.Ping:this.sendPong();break;case p.SendScreenshot:const n
|
|
77
|
+
r(this,"handleSignaling",(e=>{switch(e.type){case p.Peers:this.config.myId=e.myId;break;case p.Offer:e.senderId&&e.sdp&&(this.config.targetId=e.senderId,this.webRTCClient.handleOffer(e.sdp));break;case p.Answer:e.sdp&&this.webRTCClient.handleAnswer(e.sdp);break;case p.IceCandidates:if(e.ice)try{const t=JSON.parse(e.ice);t.candidate=t.sdp,this.webRTCClient.handleIceCandidate(new RTCIceCandidate(t))}catch(t){this.emit("error",{type:"iceCandidate",error:t})}break;case p.SignOut:e.myId===this.config.myId&&(this.webRTCClient.closeConnection(),this.signalingClient.close(),this.removeAllListeners());break;case p.NotAvailable:this.emit(m.webrtcError,f(h.NOT_AVAILABLE,""));break;case p.Ping:this.sendPong();break;case p.SendScreenshot:const n=`data:image/png;base64,${e.screenshot}`;this.emit(m.screenshot,{room_id:this.config.roomId,base64:n})}})),
|
|
78
78
|
/** 发送 Offer 信令 */
|
|
79
79
|
r(this,"sendOffer",(e=>{if(e&&e.length>0){const t={type:l.Offer,identity:l.Identity,roomId:this.config.roomId,senderId:this.config.myId,targetId:this.config.targetId,sdp:e};this.signalingClient.sendMessage(JSON.stringify(t))}})),
|
|
80
80
|
/** 发送 Answer 信令 */
|
|
@@ -83,7 +83,7 @@ r(this,"sendAnswer",(e=>{if(e&&e.length>0){const t={type:l.Answer,identity:l.Ide
|
|
|
83
83
|
r(this,"sendICEMessage",(e=>{if(e&&e.length>0){const t={type:l.IceCandidates,identity:l.Identity,roomId:this.config.roomId,senderId:this.config.myId,targetId:this.config.targetId,ice:e};this.signalingClient.sendMessage(JSON.stringify(t))}})),this.config=new Te(e),this.signalingClient=new C(this.config),this.webRTCClient=new xe(this.config),this.signalingClient.on(m.signalMessage,(e=>this.handleSignaling(e))),this.signalingClient.on(m.webrtcError,(e=>{this.emit(m.webrtcError,e)})),this.webRTCClient.on(m.sendOffer,(e=>this.sendOffer(e))),this.webRTCClient.on(m.sendAnswer,(e=>this.sendAnswer(e))),this.webRTCClient.on(m.sendICEMessage,(e=>this.sendICEMessage(e))),this.webRTCClient.on(m.streamTrack,(e=>this.emit(m.streamTrack,e))),this.webRTCClient.on(m.iceConnectionState,(e=>this.emit(m.iceConnectionState,e))),this.webRTCClient.on(m.cloudStatusChanged,(e=>this.emit(m.cloudStatusChanged,e))),this.webRTCClient.on(m.cloudClipData,(e=>this.emit(m.cloudClipData,e))),this.webRTCClient.on(m.webrtcError,(e=>{this.emit(m.webrtcError,e)})),this.webRTCClient.on(m.statisticInfo,(e=>{this.emit(m.statisticInfo,e)}))}
|
|
84
84
|
/** 开始连接 signal 服务 */startConnection(){this.signalingClient.start()}
|
|
85
85
|
/** 停止连接,并发送退出信令 */stop(){this.webRTCClient.closeConnection(),this.sendSignOut(),this.removeAllListeners()}
|
|
86
|
-
/** 开始推流:触发媒体采集与轨道添加 */async startPush(){
|
|
86
|
+
/** 开始推流:触发媒体采集与轨道添加 */async startPush(){}
|
|
87
87
|
/** 发送信道数据 */sendChannelData(e,t){this.webRTCClient.sendChannelData(e,t)}sendRequestScreenshot(e){this.signalingClient.sendRequestScreenshot(e)}sendPong(){const e={type:l.Pong},t=JSON.stringify(e);this.signalingClient.sendMessage(t)}sendSignOut(){const e={type:l.SignOut,identity:l.Identity,roomId:this.config.roomId,myId:this.config.myId};this.signalingClient.sendMessage(JSON.stringify(e))}}const Ne={
|
|
88
88
|
// 数字键
|
|
89
89
|
Digit1:8,Digit2:9,Digit3:10,Digit4:11,Digit5:12,Digit6:13,Digit7:14,Digit8:15,Digit9:16,Digit0:7,
|
|
@@ -102,7 +102,7 @@ F1:131,F2:132,F3:133,F4:134,F5:135,F6:136,F7:137,F8:138,F9:139,F10:140,F11:141,F
|
|
|
102
102
|
// 数字小键盘
|
|
103
103
|
Numpad0:7,Numpad1:8,Numpad2:9,Numpad3:10,Numpad4:11,Numpad5:12,Numpad6:13,Numpad7:14,Numpad8:15,Numpad9:16,NumpadAdd:157,NumpadSubtract:156,NumpadMultiply:155,NumpadDivide:154,NumpadDecimal:158,NumpadEnter:66,
|
|
104
104
|
// 其他特殊键
|
|
105
|
-
Insert:124,Delete:112,Home:122,End:123,PageUp:92,PageDown:93,ScrollLock:116,Pause:121,ContextMenu:117},je=e=>{const t=Ne[e.code]??-1,n=(e=>{let t=0;return e.shiftKey&&(t|=1),e.altKey&&(t|=2),e.ctrlKey&&(t|=4096),e.metaKey&&(t|=65536),t})(e);return{keyCode:t,meta:n}};function Ue(e,t,n,r,i,o,s,a){let c,d;-90===i?(d=t,c=n*e/r):(d=e,c=n*t/r);const p=(d-c)/2,l=d/2,h=p,u=d-p,f=l-p;if(-90===i){const e=ze(p,l,h,u,f,a);return-90===o?[s,e]:[t-e,s]}{const n=ze(p,l,h,u,f,s);if(-90===o){const[r,i]=function(e,t,n,r){const i=t/2,o=e/2,s=n-o,a=r-i;return[a+i,-s+o]}(e,t,n,a);return[r,i]}return[n,a]}}function Fe(e,t,n,r,i,o,s,a){let c,d;return 0===i&&0===o?(c=s/e,d=a/t):-90===i&&0===o?(c=s/t,d=a/e):-90===i&&-90===o?(c=s/e*(r/n),d=a/t*(n/r)):(c=s/t*(r/n),d=a/e*(n/r)),[c,d]}function ze(e,t,n,r,i,o){return o>=n&&o<=t-.1?(o-e)*t/i:o===t?t:o>=t+.1&&o<=r?t+(o-t)*t/i:o}const Ke=((e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n})(t.defineComponent({__name:"index",props:{streamAngle:{default:0},videoAngle:{default:0},cursorType:{default:0},cloudDeviceSize:{default:()=>({width:0,height:0})},disabled:{type:Boolean,default:!0}},emits:["channelEvent"],setup(e,{expose:n,emit:r}){const i=r,o=e,{streamAngle:s,videoAngle:a,cursorType:c,cloudDeviceSize:d,disabled:p}=t.toRefs(o),l=t.ref(null),h=t.ref(null),{isMobile:u,checkDeviceMode:f,checkTouchSupport:m,handleUp:C}=function(){const e=t.ref(!1);return{isMobile:e,checkDeviceMode:()=>{e.value=/Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent)},checkTouchSupport:()=>{navigator.maxTouchPoints>0&&(e.value=!0)},handleUp:()=>{}}}(),g=function(e){return t.computed((()=>{switch(e.value){case 1:return"circle-cursor";case 2:return"triangle-cursor";default:return"default-cursor"}}))}(c),{videoSize:v,dimensions:y,widthRadio:S,initVideoContainer:T,startPlay:R,stopPlay:b}=function(e,n,r){const i=t.ref(!1),o=t.ref({}),s=t.ref({width:0,height:0}),a=t.ref(0),c=t.ref(0),d=t.ref(null),p=t.ref(0)
|
|
105
|
+
Insert:124,Delete:112,Home:122,End:123,PageUp:92,PageDown:93,ScrollLock:116,Pause:121,ContextMenu:117},je=e=>{const t=Ne[e.code]??-1,n=(e=>{let t=0;return e.shiftKey&&(t|=1),e.altKey&&(t|=2),e.ctrlKey&&(t|=4096),e.metaKey&&(t|=65536),t})(e);return{keyCode:t,meta:n}};function Ue(e,t,n,r,i,o,s,a){let c,d;-90===i?(d=t,c=n*e/r):(d=e,c=n*t/r);const p=(d-c)/2,l=d/2,h=p,u=d-p,f=l-p;if(-90===i){const e=ze(p,l,h,u,f,a);return-90===o?[s,e]:[t-e,s]}{const n=ze(p,l,h,u,f,s);if(-90===o){const[r,i]=function(e,t,n,r){const i=t/2,o=e/2,s=n-o,a=r-i;return[a+i,-s+o]}(e,t,n,a);return[r,i]}return[n,a]}}function Fe(e,t,n,r,i,o,s,a){let c,d;return 0===i&&0===o?(c=s/e,d=a/t):-90===i&&0===o?(c=s/t,d=a/e):-90===i&&-90===o?(c=s/e*(r/n),d=a/t*(n/r)):(c=s/t*(r/n),d=a/e*(n/r)),[c,d]}function ze(e,t,n,r,i,o){return o>=n&&o<=t-.1?(o-e)*t/i:o===t?t:o>=t+.1&&o<=r?t+(o-t)*t/i:o}const Ke=((e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n})(t.defineComponent({__name:"index",props:{streamAngle:{default:0},videoAngle:{default:0},cursorType:{default:0},cloudDeviceSize:{default:()=>({width:0,height:0})},disabled:{type:Boolean,default:!0}},emits:["channelEvent"],setup(e,{expose:n,emit:r}){const i=r,o=e,{streamAngle:s,videoAngle:a,cursorType:c,cloudDeviceSize:d,disabled:p}=t.toRefs(o),l=t.ref(null),h=t.ref(null),{isMobile:u,checkDeviceMode:f,checkTouchSupport:m,handleUp:C}=function(){const e=t.ref(!1);return{isMobile:e,checkDeviceMode:()=>{e.value=/Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent)},checkTouchSupport:()=>{navigator.maxTouchPoints>0&&(e.value=!0)},handleUp:()=>{}}}(),g=function(e){return t.computed((()=>{switch(e.value){case 1:return"circle-cursor";case 2:return"triangle-cursor";default:return"default-cursor"}}))}(c),{videoSize:v,dimensions:y,widthRadio:S,initVideoContainer:T,startPlay:R,stopPlay:b}=function(e,n,r){const i=t.ref(!1),o=t.ref({}),s=t.ref({width:0,height:0}),a=t.ref(0),c=t.ref(0),d=t.ref(null),p=t.ref(0);return{videoSize:t.computed((()=>{let e=0,t=0;const n=r.value%180!=0,i=n?s.value.height:s.value.width,d=n?s.value.width:s.value.height;if(o.value.width&&o.value.height){const n=o.value.width/o.value.height,r=i/n;r>d?(t=d,e=t*n):(e=i,t=r),a.value=o.value.width/e,c.value=o.value.height/t}return{width:e,height:t}})),remoteVideo:o,dimensions:s,widthRadio:a,heightRadio:c,screenStatus:i,initVideoContainer:()=>{d.value=new ResizeObserver((e=>{for(const t of e){const{width:e,height:n}=t.contentRect;s.value={width:e,height:n}}})),e.value&&d.value.observe(e.value),n.value&&n.value.addEventListener("resize",(()=>{n.value&&(o.value={width:n.value.videoWidth,height:n.value.videoHeight},i.value=!0)}))},startPlay:e=>{n.value&&(n.value.srcObject||(n.value.srcObject=new MediaStream),n.value.playsInline=!0,n.value.setAttribute("webkit-playsinline","true"),n.value.srcObject.addTrack(e))},stopPlay:()=>{i.value=!1,n.value&&n.value.srcObject&&(n.value.srcObject.getTracks().forEach((e=>e.stop())),n.value.srcObject=null,n.value.cancelVideoFrameCallback(p.value))}}}(l,h,a),{onTouchStart:P,onTouchMove:w,onTouchEnd:E,handleMouseDown:k,handleMouseMove:_,handleMouseEnter:A,handleMouseUp:D,handleMouseLeave:O,handleWheel:I}=function(e){const{isMobile:n,remoteVideoElement:r,cloudDeviceSize:i,streamAngle:o,videoAngle:s,widthRadio:a,emit:c}=e,d=t.ref(!1),p=t.ref(0),l=t.ref(new Array(20).fill(0)),h=t.ref(new Array(10).fill(0)),u=t.ref(0),f=t.ref(0),m=(e,t)=>{if(!r.value)return;const n=Math.trunc(e.timeStamp-h.value[0]),a=r.value.getBoundingClientRect();let d=e.clientX-a.left,u=e.clientY-a.top;const f=i.value.width,m=i.value.height,C=Ue(a.width,a.height,f,m,s.value,o.value,d,u);if(!C||C.length<2)return;if(d=C[0],u=C[1],t===_e.ACTION_MOVE){const e=l.value[10]-u,t=l.value[0]-d;if(Math.abs(e)<p.value&&Math.abs(t)<p.value)return}l.value[0]=d,l.value[10]=u;const g=Fe(a.width,a.height,f,m,s.value,o.value,d,u),v=new Oe(t,0,g[0],g[1],n);c("channelEvent",Ee.ClickData,v)};return{isPointerDown:d,onTouchStart:e=>{if(!n.value)return;const t=Array.from(e.touches);if(t.length>0){h.value[0]=e.timeStamp,p.value=Math.trunc(4/a.value),u.value=t[0].clientX,f.value=t[0].clientY;const n={clientX:u.value,clientY:f.value,timeStamp:e.timeStamp};m(n,_e.ACTION_DOWN)}},onTouchMove:e=>{if(!n.value)return;const t=Array.from(e.touches);if(t.length>0){u.value=t[0].clientX,f.value=t[0].clientY;const n={clientX:u.value,clientY:f.value,timeStamp:e.timeStamp};m(n,_e.ACTION_MOVE)}},onTouchEnd:e=>{if(!n.value)return;const t={clientX:u.value,clientY:f.value,timeStamp:e.timeStamp};m(t,_e.ACTION_UP)},handleMouseDown:e=>{n.value||(d.value=!0,r.value&&r.value.setPointerCapture(e.pointerId),h.value[0]=e.timeStamp,p.value=Math.trunc(4/a.value),m(e,_e.ACTION_DOWN))},handleMouseMove:e=>{!n.value&&d.value&&m(e,_e.ACTION_MOVE)},handleMouseEnter:e=>{n.value||1!==e.buttons||d.value||(d.value=!0,r.value&&r.value.setPointerCapture(e.pointerId),h.value[0]=e.timeStamp,p.value=Math.trunc(4/a.value),m(e,_e.ACTION_DOWN))},handleMouseUp:e=>{!n.value&&d.value&&(d.value=!1,m(e,_e.ACTION_UP),r.value&&r.value.releasePointerCapture(e.pointerId))},handleMouseLeave:e=>{d.value&&(m(e,_e.ACTION_UP),d.value=!1,r.value&&r.value.releasePointerCapture(e.pointerId))},handleWheel:e=>{const t=-1*Math.sign(e.deltaY),n=new Ie(t);c("channelEvent",Ee.ActionWheel,n)}}}({isMobile:u,remoteVideoElement:h,cloudDeviceSize:d,streamAngle:s,videoAngle:a,widthRadio:S,emit:i}),{startListening:M,stopListening:x}=function(e,n){const r=t.ref(!1),i=e=>{const t=je(e);n("channelEvent",Ee.ActionInput,t)};return{startListening:()=>{e&&(r.value=!0,document.addEventListener("keydown",i))},stopListening:()=>{e&&(r.value=!1,document.removeEventListener("keydown",i))}}}(p,i);!function(e,n){let r=null;t.onMounted((()=>{e.value&&(r=new ResizeObserver((e=>{for(const t of e){const{width:e,height:r}=t.contentRect;n.value={width:e,height:r}}})),r.observe(e.value))})),t.onUnmounted((()=>{null==r||r.disconnect()}))}(l,y);const L=()=>{var e;(null==(e=h.value)?void 0:e.srcObject)&&(h.value.muted=!1)};return t.onMounted((()=>{f(),window.addEventListener("resize",f),window.addEventListener("pointerdown",m),window.addEventListener("pointerup",C),document.addEventListener("click",L),T()})),t.onUnmounted((()=>{window.removeEventListener("resize",f),window.removeEventListener("pointerdown",m),window.removeEventListener("pointerup",C),document.removeEventListener("click",L)})),n({startPlay:R,stopPlay:b}),(e,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"videoContainer",ref:l,class:"flex flex-1 items-center justify-center",style:{width:"100%",height:"100%",background:"black",position:"relative",overflow:"hidden"}},[t.createElementVNode("div",{ref:"keyboardArea",onPointerenter:n[9]||(n[9]=//@ts-ignore
|
|
106
106
|
(...e)=>t.unref(M)&&t.unref(M)(...e)),onPointerleave:n[10]||(n[10]=//@ts-ignore
|
|
107
107
|
(...e)=>t.unref(x)&&t.unref(x)(...e)),class:"vContainer",style:t.normalizeStyle([{height:t.unref(v).height+"px",width:t.unref(v).width+"px",transform:`rotate(${t.unref(a)}deg)`},{position:"relative"}])},[t.createElementVNode("video",{ref_key:"remoteVideoElement",ref:h,class:t.normalizeClass(["video-control",[t.unref(g),{"no-events":t.unref(p)}]]),onTouchstart:n[0]||(n[0]=//@ts-ignore
|
|
108
108
|
(...e)=>t.unref(P)&&t.unref(P)(...e)),onTouchmove:n[1]||(n[1]=//@ts-ignore
|
|
@@ -113,7 +113,7 @@ Insert:124,Delete:112,Home:122,End:123,PageUp:92,PageDown:93,ScrollLock:116,Paus
|
|
|
113
113
|
(...e)=>t.unref(_)&&t.unref(_)(...e)),onPointerup:n[6]||(n[6]=//@ts-ignore
|
|
114
114
|
(...e)=>t.unref(D)&&t.unref(D)(...e)),onPointerleave:n[7]||(n[7]=//@ts-ignore
|
|
115
115
|
(...e)=>t.unref(O)&&t.unref(O)(...e)),onWheel:n[8]||(n[8]=//@ts-ignore
|
|
116
|
-
(...e)=>t.unref(I)&&t.unref(I)(...e)),autoplay:"",playsinline:"",muted:"",disablePictureInPicture:!0},null,34)],36)],512))}}),[["__scopeId","data-v-51dd3cb6"]]);e.ActionCommandType=ke,e.ActionType=_e,e.ChannelDataType=Ee,e.ContainerDirection=De,e.EmitType=m,e.GestureData=class{constructor(e){r(this,"mode"),this.mode=e}},e.GroupControllerManager=class{constructor(){r(this,"webRTCConfigList",[]),r(this,"sdkList",[]),r(this,"loopTimer",null),r(this,"visibilityMap",new Map),r(this,"previousVisibilityMap",new Map)}startGroupControl(e){if(!Array.isArray(e)||0===e.length)throw new Error("群控列表为空");const t=e.filter((e=>e.isControl)).length;if(1!==t)throw new Error(`一次群控发起,有且只有一个主控,当前主控个数为 ${t}。`);this.webRTCConfigList=e,e.forEach((e=>{const t=new Le(e);t.startConnection(),this.sdkList.push(t)})),this.startLoop()}stopGroupControl(){this.sdkList.forEach((e=>e.stop())),this.sdkList=[],this.visibilityMap.clear(),this.previousVisibilityMap.clear(),this.stopLoop()}getConnectionList(){return this.webRTCConfigList}
|
|
116
|
+
(...e)=>t.unref(I)&&t.unref(I)(...e)),autoplay:"",playsinline:"",muted:"",disablePictureInPicture:!0},null,34)],36)],512))}}),[["__scopeId","data-v-51dd3cb6"]]);e.ActionCommandType=ke,e.ActionType=_e,e.ChannelDataType=Ee,e.ContainerDirection=De,e.EmitType=m,e.GestureData=class{constructor(e){r(this,"mode"),this.mode=e}},e.GroupControllerManager=class extends d{constructor(){super(...arguments),r(this,"webRTCConfigList",[]),r(this,"sdkList",[]),r(this,"loopTimer",null),r(this,"visibilityMap",new Map),r(this,"previousVisibilityMap",new Map)}startGroupControl(e){if(!Array.isArray(e)||0===e.length)throw new Error("群控列表为空");const t=e.filter((e=>e.isControl)).length;if(1!==t)throw new Error(`一次群控发起,有且只有一个主控,当前主控个数为 ${t}。`);this.webRTCConfigList=e,e.forEach((e=>{const t=new Le(e);t.startConnection(),t.on(m.screenshot,(e=>{this.emit(m.screenshot,e)})),this.sdkList.push(t)})),this.startLoop()}stopGroupControl(){this.sdkList.forEach((e=>e.stop())),this.sdkList=[],this.visibilityMap.clear(),this.previousVisibilityMap.clear(),this.removeAllListeners(),this.stopLoop()}getConnectionList(){return this.webRTCConfigList}
|
|
117
117
|
/**
|
|
118
118
|
* 设置某个视图的可见状态
|
|
119
119
|
* @param viewId 视图 ID
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yjz-web-sdk",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "针对于亚矩阵项目的云手机投屏和屏幕控制",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^22.14.1",
|
|
42
|
-
"@types/webrtc": "^0.0.46",
|
|
43
42
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
44
43
|
"@vue/tsconfig": "^0.7.0",
|
|
45
44
|
"rollup-plugin-visualizer": "5.9.3",
|