yjz-web-sdk 1.0.8-beta.7 → 1.0.8-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/WebRTCSdk.d.ts +6 -0
- package/lib/core/data/WebRtcError.d.ts +10 -0
- package/lib/core/rtc/WebRTCClient.d.ts +18 -0
- package/lib/core/rtc/WebRTCConfig.d.ts +1 -0
- package/lib/core/rtc/WebRtcNegotiate.d.ts +2 -1
- package/lib/core/signal/SignalingClient.d.ts +2 -0
- package/lib/core/util/FileTypeUtils.d.ts +5 -0
- package/lib/index.d.ts +2 -2
- package/lib/yjz-web-sdk.js +417 -55
- package/lib/yjz-web-sdk.umd.cjs +42 -30
- package/package.json +1 -2
package/lib/core/WebRTCSdk.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare class WebRTCSdk extends EventEmitter {
|
|
|
13
13
|
isConnecting: boolean;
|
|
14
14
|
private connectCount;
|
|
15
15
|
private MAX_COUNT;
|
|
16
|
+
private timeout;
|
|
16
17
|
constructor(options: WebRTCConfigOptions);
|
|
17
18
|
initConfig(): Promise<void>;
|
|
18
19
|
/** 开始连接 signal 服务 */
|
|
@@ -20,12 +21,16 @@ export declare class WebRTCSdk extends EventEmitter {
|
|
|
20
21
|
private prepareConnection;
|
|
21
22
|
reconnect(): Promise<void>;
|
|
22
23
|
initConnectConfig(): void;
|
|
24
|
+
initSignalingClient(): void;
|
|
23
25
|
switchControl(isControl: boolean): void;
|
|
24
26
|
resetConfig(): void;
|
|
25
27
|
/** 停止连接,并发送退出信令 */
|
|
26
28
|
stop(): void;
|
|
27
29
|
/** 开始推流:触发媒体采集与轨道添加 */
|
|
28
30
|
startPush(): Promise<void>;
|
|
31
|
+
startPushLocal(file: File): Promise<void>;
|
|
32
|
+
stopPush(): void;
|
|
33
|
+
stopPushLocal(): void;
|
|
29
34
|
/** 发送信道数据 */
|
|
30
35
|
sendChannelData(type: ChannelDataType, data: any): void;
|
|
31
36
|
sendControlEvent(key: number): void;
|
|
@@ -35,6 +40,7 @@ export declare class WebRTCSdk extends EventEmitter {
|
|
|
35
40
|
* @param message 信令消息
|
|
36
41
|
*/
|
|
37
42
|
private handleSignaling;
|
|
43
|
+
clearTimer: () => void;
|
|
38
44
|
/** 发送 Offer 信令 */
|
|
39
45
|
sendOffer: (offerSdp: string) => void;
|
|
40
46
|
/** 发送 Answer 信令 */
|
|
@@ -28,10 +28,20 @@ export interface WebRtcError {
|
|
|
28
28
|
message: string;
|
|
29
29
|
rawError?: any;
|
|
30
30
|
}
|
|
31
|
+
export declare enum CameraFailCode {
|
|
32
|
+
LOCAL_STREAM_FAIL = 20001,
|
|
33
|
+
CAMERA_STREAM_FAIL = 20002
|
|
34
|
+
}
|
|
31
35
|
export declare function createWebRtcError(code: FailCode, rawError?: any): WebRtcError;
|
|
36
|
+
export declare function createCameraError(code: CameraFailCode, message: string): CameraError;
|
|
37
|
+
export interface CameraError {
|
|
38
|
+
code: CameraFailCode;
|
|
39
|
+
message: string;
|
|
40
|
+
}
|
|
32
41
|
export declare enum EmitType {
|
|
33
42
|
signalMessage = "signalMessage",
|
|
34
43
|
webrtcError = "webrtcError",
|
|
44
|
+
cameraError = "cameraError",
|
|
35
45
|
sendAnswer = "sendAnswer",
|
|
36
46
|
sendOffer = "sendOffer",
|
|
37
47
|
sendICEMessage = "sendICEMessage",
|
|
@@ -5,7 +5,9 @@ export declare class WebRTCClient extends EventEmitter {
|
|
|
5
5
|
private readonly config;
|
|
6
6
|
private peerConnection;
|
|
7
7
|
private localStream;
|
|
8
|
+
private rotatedStream;
|
|
8
9
|
private isPushingStream;
|
|
10
|
+
private isPushingLocalStream;
|
|
9
11
|
private dataChannel;
|
|
10
12
|
private statsTimer;
|
|
11
13
|
private lastReportTime;
|
|
@@ -15,6 +17,12 @@ export declare class WebRTCClient extends EventEmitter {
|
|
|
15
17
|
private lostPacketCount;
|
|
16
18
|
private maxLostRate;
|
|
17
19
|
private lastSecondDecodedCount;
|
|
20
|
+
private fileVideo?;
|
|
21
|
+
private canvas?;
|
|
22
|
+
private canvasStream;
|
|
23
|
+
private rafId;
|
|
24
|
+
private currentMedia;
|
|
25
|
+
private fileImage?;
|
|
18
26
|
constructor(config: WebRTCConfig);
|
|
19
27
|
startPush(): Promise<void>;
|
|
20
28
|
handleOffer(offerSdp: string): void;
|
|
@@ -32,4 +40,14 @@ export declare class WebRTCClient extends EventEmitter {
|
|
|
32
40
|
private checkStats;
|
|
33
41
|
private processStats;
|
|
34
42
|
private getConnectionType;
|
|
43
|
+
/** 获取或创建 video 元素(懒初始化) */
|
|
44
|
+
private getFileVideo;
|
|
45
|
+
/** 获取或创建 canvas 元素(懒初始化) */
|
|
46
|
+
private getCanvas;
|
|
47
|
+
loadMedia(file: File): Promise<void>;
|
|
48
|
+
startPushLocal: (file: File) => Promise<void>;
|
|
49
|
+
startCanvasStream(fps?: number): MediaStream;
|
|
50
|
+
getFileImage(): HTMLImageElement;
|
|
51
|
+
/** 停止推流并释放资源 */
|
|
52
|
+
stopLocal(): void;
|
|
35
53
|
}
|
|
@@ -4,5 +4,6 @@ export declare const setRemoteDescriptionWithHandleOffer: (peerConnection: RTCPe
|
|
|
4
4
|
export declare const createPeerConnection: (config: WebRTCConfig) => RTCPeerConnection;
|
|
5
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
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
|
|
7
|
+
export declare const createOffer: (peerConnection: RTCPeerConnection, sendOfferMessage: (sdp: string) => void) => Promise<void>;
|
|
8
|
+
export declare const setLocalDescriptionWithCreateOffer: (peerConnection: RTCPeerConnection, offer: RTCSessionDescriptionInit, sendOfferMessage: (sdp: string) => void) => Promise<void>;
|
|
8
9
|
export declare const addIceCandidate: (peerConnection: RTCPeerConnection, candidate: RTCIceCandidateInit, onError?: (error: WebRtcError) => void) => void;
|
package/lib/index.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ import { ActionType, ChannelDataType, ContainerDirection, InputData, KeyEventDat
|
|
|
6
6
|
import { type TurnServerConfig, type TurnTestResult, type TurnTestSummary } from "./core/data/TurnType";
|
|
7
7
|
import type { WebRTCConfigOptions } from './core/rtc/WebRTCConfig';
|
|
8
8
|
import { GroupControllerManager } from "./core/groupctrl/GroupControllerManager";
|
|
9
|
-
import { EmitType } from "./core/data/WebRtcError";
|
|
9
|
+
import { EmitType, type CameraError, type WebRtcError } from "./core/data/WebRtcError";
|
|
10
10
|
import RemotePlayer from './components/RemotePlayer/index.vue';
|
|
11
|
-
export { WebRTCSdk, getKeyEventData, transformCoordinate, valueToPercentage, ActionType, ChannelDataType, InputData, KeyEventData, TouchData, ContainerDirection, EmitType, WheelData, GestureData, ClarityData, type ActionCommand, ActionCommandType, GroupControllerManager, type WebRTCConfigOptions, ActionCommandEventType, ActionCommandEventValue, RemotePlayer, TrackEventData, type TurnServerConfig, type TurnTestResult, type TurnTestSummary, testMultipleTurnServers };
|
|
11
|
+
export { WebRTCSdk, getKeyEventData, transformCoordinate, valueToPercentage, ActionType, ChannelDataType, InputData, KeyEventData, TouchData, ContainerDirection, EmitType, WheelData, GestureData, ClarityData, type ActionCommand, ActionCommandType, GroupControllerManager, type WebRTCConfigOptions, ActionCommandEventType, ActionCommandEventValue, RemotePlayer, TrackEventData, type TurnServerConfig, type TurnTestResult, type TurnTestSummary, testMultipleTurnServers, type CameraError, type WebRtcError };
|