yjz-web-sdk 1.0.0
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/README.md +489 -0
- package/lib/core/WebRTCSdk.d.ts +33 -0
- package/lib/core/data/MessageType.d.ts +28 -0
- package/lib/core/data/WebRTCDataType.d.ts +113 -0
- package/lib/core/data/WebRtcError.d.ts +38 -0
- package/lib/core/rtc/WebRTCClient.d.ts +36 -0
- package/lib/core/rtc/WebRTCConfig.d.ts +25 -0
- package/lib/core/rtc/WebRtcNegotiate.d.ts +8 -0
- package/lib/core/signal/SignalingClient.d.ts +22 -0
- package/lib/core/util/KeyCodeUtil.d.ts +16 -0
- package/lib/core/util/ScreenControlUtil.d.ts +26 -0
- package/lib/index.d.ts +6 -0
- package/lib/vite.svg +1 -0
- package/lib/yjz-web-sdk.js +3872 -0
- package/lib/yjz-web-sdk.umd.cjs +93 -0
- package/package.json +49 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { EventEmitter } from 'eventemitter3';
|
|
2
|
+
import { ChannelDataType } from '../data/WebRTCDataType';
|
|
3
|
+
import type { WebRTCConfig } from "./WebRTCConfig.ts";
|
|
4
|
+
export declare class WebRTCClient extends EventEmitter {
|
|
5
|
+
private config;
|
|
6
|
+
private peerConnection;
|
|
7
|
+
private localStream;
|
|
8
|
+
private isPushingStream;
|
|
9
|
+
private dataChannel;
|
|
10
|
+
private statsTimer;
|
|
11
|
+
private lastReportTime;
|
|
12
|
+
private lastBytesReceived;
|
|
13
|
+
private lastPacketsLost;
|
|
14
|
+
private lastPacketsReceived;
|
|
15
|
+
private lostPacketCount;
|
|
16
|
+
private maxLostRate;
|
|
17
|
+
private decodedCount;
|
|
18
|
+
private lastSecondDecodedCount;
|
|
19
|
+
constructor(config: WebRTCConfig);
|
|
20
|
+
startPush(): Promise<void>;
|
|
21
|
+
handleOffer(offerSdp: RTCSessionDescriptionInit): void;
|
|
22
|
+
handleAnswer(answerSdp: RTCSessionDescriptionInit): void;
|
|
23
|
+
handleIceCandidate(candidate: RTCIceCandidateInit): void;
|
|
24
|
+
sendChannelData(type: ChannelDataType, data: any): void;
|
|
25
|
+
closeConnection(): void;
|
|
26
|
+
private readyCapture;
|
|
27
|
+
private getRotatedStream;
|
|
28
|
+
private setVideoParams;
|
|
29
|
+
stopPush(): void;
|
|
30
|
+
private resetPeerConnection;
|
|
31
|
+
private configDataChannel;
|
|
32
|
+
private handleDataChannelMessage;
|
|
33
|
+
private checkStats;
|
|
34
|
+
private processStats;
|
|
35
|
+
private getConnectionType;
|
|
36
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface WebRTCConfigOptions {
|
|
2
|
+
signalServerUrl?: string;
|
|
3
|
+
myId?: string;
|
|
4
|
+
roomId?: string;
|
|
5
|
+
targetId?: string;
|
|
6
|
+
stunServerUri?: string;
|
|
7
|
+
stunServerUriAli?: string;
|
|
8
|
+
stunServerUriTel?: string;
|
|
9
|
+
turnServerUri?: string;
|
|
10
|
+
turnServerUserName?: string;
|
|
11
|
+
turnServerPassword?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class WebRTCConfig {
|
|
14
|
+
signalServerUrl: string;
|
|
15
|
+
myId: string;
|
|
16
|
+
roomId: string;
|
|
17
|
+
targetId: string;
|
|
18
|
+
stunServerUri: string;
|
|
19
|
+
stunServerUriAli: string;
|
|
20
|
+
stunServerUriTel: string;
|
|
21
|
+
turnServerUri: string;
|
|
22
|
+
turnServerUserName: string;
|
|
23
|
+
turnServerPassword: string;
|
|
24
|
+
constructor(options?: WebRTCConfigOptions);
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type WebRtcError } from "../data/WebRtcError.ts";
|
|
2
|
+
import { WebRTCConfig } from "./WebRTCConfig.ts";
|
|
3
|
+
export declare const setRemoteDescriptionWithHandleOffer: (peerConnection: RTCPeerConnection, sdp: string, sendAnswer?: (sdp: string) => void, onError?: (err: WebRtcError) => void) => void;
|
|
4
|
+
export declare const createPeerConnection: (config: WebRTCConfig) => RTCPeerConnection;
|
|
5
|
+
export declare const configPeerConnection: (peerConnection: RTCPeerConnection, onICEMessage: (candidate: string) => void, onTrack?: (track: MediaStreamTrack) => void, onConnectState?: (state: RTCIceConnectionState) => void, onError?: (error: WebRtcError) => void) => void;
|
|
6
|
+
export declare const setRemoteDescriptionWithHandleAnswer: (peerConnection: RTCPeerConnection, sdp: string, onError?: (error: WebRtcError) => void) => void;
|
|
7
|
+
export declare const createOffer: (peerConnection: RTCPeerConnection, sendOfferMessage: (sdp: string) => void, onError?: (error: WebRtcError) => void) => void;
|
|
8
|
+
export declare const addIceCandidate: (peerConnection: RTCPeerConnection, candidate: RTCIceCandidateInit, onError?: (error: WebRtcError) => void) => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventEmitter } from "eventemitter3";
|
|
2
|
+
import type { WebRTCConfig } from "../rtc/WebRTCConfig.ts";
|
|
3
|
+
export declare class SignalingClient extends EventEmitter {
|
|
4
|
+
private config;
|
|
5
|
+
private webSocket;
|
|
6
|
+
private timeout;
|
|
7
|
+
constructor(config: WebRTCConfig);
|
|
8
|
+
/**
|
|
9
|
+
* 启动 WebSocket 连接,并注册各事件处理
|
|
10
|
+
*/
|
|
11
|
+
start(): void;
|
|
12
|
+
/**
|
|
13
|
+
* 关闭 WebSocket 连接,并通知外部
|
|
14
|
+
*/
|
|
15
|
+
close(): void;
|
|
16
|
+
/**
|
|
17
|
+
* 发送消息到服务端
|
|
18
|
+
* @param message - 消息字符串
|
|
19
|
+
*/
|
|
20
|
+
sendMessage(message: string): void;
|
|
21
|
+
sendSignInMessage(): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 根据浏览器 KeyboardEvent 计算 Android 平台的 meta 状态值
|
|
3
|
+
* @param event - 浏览器的 KeyboardEvent
|
|
4
|
+
* @returns 计算后的 meta 状态
|
|
5
|
+
*/
|
|
6
|
+
export declare const computeAndroidMetaState: (event: KeyboardEvent) => number;
|
|
7
|
+
export interface KeyEventData {
|
|
8
|
+
androidKeyCode: number;
|
|
9
|
+
metaState: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 根据 KeyboardEvent 生成 Android 平台下的按键数据
|
|
13
|
+
* @param event - 浏览器的 KeyboardEvent 对象
|
|
14
|
+
* @returns 包含 androidKeyCode 和 metaState 的对象
|
|
15
|
+
*/
|
|
16
|
+
export declare const getKeyEventData: (event: KeyboardEvent) => KeyEventData;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 根据视图和云端流的尺寸、角度及输入坐标,转换为相应的坐标值
|
|
3
|
+
* @param viewWidth 视图宽度
|
|
4
|
+
* @param viewHeight 视图高度
|
|
5
|
+
* @param cloudWidth 云端流宽度
|
|
6
|
+
* @param cloudHeight 云端流高度
|
|
7
|
+
* @param viewAngle 视图旋转角度(0 或 -90)
|
|
8
|
+
* @param streamAngle 流旋转角度(0 或 -90)
|
|
9
|
+
* @param inputX 输入 X 坐标
|
|
10
|
+
* @param inputY 输入 Y 坐标
|
|
11
|
+
* @returns 转换后的坐标 [x, y],若超出有效区域则返回 null
|
|
12
|
+
*/
|
|
13
|
+
export declare function transformCoordinate(viewWidth: number, viewHeight: number, cloudWidth: number, cloudHeight: number, viewAngle: number, streamAngle: number, inputX: number, inputY: number): [number, number] | null;
|
|
14
|
+
/**
|
|
15
|
+
* 将输入坐标转换为百分比值(相对于视图尺寸),并考虑云端流的宽高比例
|
|
16
|
+
* @param viewWidth 视图宽度
|
|
17
|
+
* @param viewHeight 视图高度
|
|
18
|
+
* @param cloudWidth 云端流宽度
|
|
19
|
+
* @param cloudHeight 云端流高度
|
|
20
|
+
* @param viewAngle 视图旋转角度(0 或 -90)
|
|
21
|
+
* @param streamAngle 流旋转角度(0 或 -90)
|
|
22
|
+
* @param inputX 输入 X 坐标
|
|
23
|
+
* @param inputY 输入 Y 坐标
|
|
24
|
+
* @returns [xRatio, yRatio] 百分比比例值
|
|
25
|
+
*/
|
|
26
|
+
export declare function valueToPercentage(viewWidth: number, viewHeight: number, cloudWidth: number, cloudHeight: number, viewAngle: number, streamAngle: number, inputX: number, inputY: number): [number, number];
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WebRTCSdk } from './core/WebRTCSdk.ts';
|
|
2
|
+
import { getKeyEventData } from "./core/util/KeyCodeUtil.ts";
|
|
3
|
+
import { transformCoordinate, valueToPercentage } from "./core/util/ScreenControlUtil.ts";
|
|
4
|
+
import { ActionType, ChannelDataType, ContainerDirection, InputData, KeyEventData, TouchData } from "./core/data/WebrtcDataType.ts";
|
|
5
|
+
import { EmitType } from "./core/data/WebRtcError.ts";
|
|
6
|
+
export { WebRTCSdk, getKeyEventData, transformCoordinate, valueToPercentage, ActionType, ChannelDataType, InputData, KeyEventData, TouchData, ContainerDirection, EmitType };
|
package/lib/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|