@havue/solutions 1.1.2 → 1.2.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/bc-connect/dist/bc-connect.mjs +71 -68
- package/bc-connect/dist/bc-connect.umd.js +71 -68
- package/bc-connect/dist/types/src/manager.d.ts +70 -62
- package/bc-connect/package.json +1 -1
- package/bc-connect/src/manager.ts +84 -73
- package/dist/solutions.full.js +138 -122
- package/dist/solutions.full.min.js +4 -4
- package/dist/solutions.full.min.js.map +1 -1
- package/dist/types/bc-connect/src/manager.d.ts +70 -62
- package/dist/types/ws-video-manager/src/loader/websocket-loader.d.ts +13 -10
- package/dist/types/ws-video-manager/src/manager/index.d.ts +54 -37
- package/dist/types/ws-video-manager/src/render/drawer.d.ts +7 -7
- package/dist/types/ws-video-manager/src/render/index.d.ts +35 -19
- package/package.json +4 -4
- package/vite.config.ts +1 -1
- package/ws-video-manager/dist/types/src/loader/websocket-loader.d.ts +13 -10
- package/ws-video-manager/dist/types/src/manager/index.d.ts +54 -37
- package/ws-video-manager/dist/types/src/render/drawer.d.ts +7 -7
- package/ws-video-manager/dist/types/src/render/index.d.ts +35 -19
- package/ws-video-manager/dist/ws-video-manager.mjs +67 -54
- package/ws-video-manager/dist/ws-video-manager.umd.js +67 -54
- package/ws-video-manager/package.json +1 -1
- package/ws-video-manager/src/loader/websocket-loader.ts +15 -11
- package/ws-video-manager/src/manager/index.ts +57 -40
- package/ws-video-manager/src/render/drawer.ts +22 -20
- package/ws-video-manager/src/render/index.ts +61 -27
- package/ws-video-manager/src/render/mp4box.ts +1 -1
|
@@ -1,63 +1,71 @@
|
|
|
1
|
-
/** 事件数据类型 */
|
|
1
|
+
/** 事件数据类型 | Event Datatypes */
|
|
2
2
|
export type BcConnectSendMessageType = {
|
|
3
|
-
/** 事件类型 */
|
|
3
|
+
/** 事件类型 | type */
|
|
4
4
|
type: string;
|
|
5
|
-
/** 数据 */
|
|
5
|
+
/** 数据 | data */
|
|
6
6
|
data: any;
|
|
7
|
-
/** 发送事件的实例id */
|
|
7
|
+
/** 发送事件的实例id | BroadcastChannelManager instance id */
|
|
8
8
|
id: number;
|
|
9
|
-
/**
|
|
9
|
+
/** 此消息的目标实例id | The target instance id for this message */
|
|
10
10
|
targetId?: number;
|
|
11
11
|
};
|
|
12
|
-
/** 事件类型 */
|
|
12
|
+
/** 事件类型 | Event types */
|
|
13
13
|
export declare enum BcConnectEventTypeEnum {
|
|
14
|
-
/** 初始广播 */
|
|
15
|
-
Broadcast = "
|
|
16
|
-
/** 回复初始广播 */
|
|
17
|
-
Broadcast_Reply = "
|
|
18
|
-
/** 主节点心跳 */
|
|
19
|
-
Main_Node_Hearbeat = "
|
|
20
|
-
/** 回复主节点心跳 */
|
|
21
|
-
Res_Main_Node_Hearbeat = "
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
|
|
14
|
+
/** 初始广播 | Initial broadcast */
|
|
15
|
+
Broadcast = "__BCM_INIT__",
|
|
16
|
+
/** 回复初始广播 | Reply to initial broadcast */
|
|
17
|
+
Broadcast_Reply = "__BCM_INIT_REPLY__",
|
|
18
|
+
/** 主节点心跳 | Master node heartbeat */
|
|
19
|
+
Main_Node_Hearbeat = "__BCM_MAIN_NODE_HEARBEAT__",
|
|
20
|
+
/** 回复主节点心跳 | Reply to the master node heartbeat */
|
|
21
|
+
Res_Main_Node_Hearbeat = "__BCM_MAIN_NODE_HEARBEAT_REPLY__",
|
|
22
|
+
/**
|
|
23
|
+
* 长时间未收到主节点心跳,申请成为主节点
|
|
24
|
+
* It has not received the heartbeat of the master node for a long time.
|
|
25
|
+
* Apply to become the master node
|
|
26
|
+
*/
|
|
27
|
+
Req_Be_Main_Node = "__BCM_REQ_BE_MAIN_NODE__",
|
|
28
|
+
/** 拒绝其他节点成为主节点 | Reject other nodes as master nodes */
|
|
29
|
+
Res_Be_Main_Node = "__BCM_REQ_BE_MAIN_NODE_REJECT__",
|
|
30
|
+
/** 当前节点类型更改 | The current node type has changed */
|
|
31
|
+
Node_Type_Change = "__BCM_NODE_TYPE_CHANGE__",
|
|
32
|
+
/** 其他标签页BC节点id列表更新 | Other TAB node id list updated */
|
|
33
|
+
Friend_List_Update = "__BCM_FRIEND_LIST_UPDATE__"
|
|
30
34
|
}
|
|
31
|
-
/**
|
|
35
|
+
/** BroadcastChannel节点类型 | BroadcastChannel node type */
|
|
32
36
|
export declare enum BcConnectNodeTypeEnum {
|
|
33
37
|
Main = "main",
|
|
34
38
|
Normal = "normal"
|
|
35
39
|
}
|
|
36
40
|
/**
|
|
37
41
|
* 使用BroadcastChannel与其他标签页进行通信
|
|
42
|
+
* Use BroadcastChannel to communicate with other tabs
|
|
38
43
|
*/
|
|
39
44
|
export declare class BroadcastChannelManager {
|
|
40
|
-
/** 通道名称 */
|
|
45
|
+
/** 通道名称 | Channel name */
|
|
41
46
|
private _bcName;
|
|
42
|
-
/** BroadcastChannel
|
|
47
|
+
/** BroadcastChannel instance */
|
|
43
48
|
private _broadcastChannel;
|
|
44
|
-
/**
|
|
49
|
+
/** Event map */
|
|
45
50
|
private _eventMap;
|
|
46
|
-
/** 主节点发送心跳的interval */
|
|
51
|
+
/** 主节点发送心跳的interval | The interval at which the master node sends the heartbeat */
|
|
47
52
|
private _mainNodeMsgInterval;
|
|
48
|
-
/** 认为主节点掉线的timeout */
|
|
53
|
+
/** 认为主节点掉线的timeout | timeout to consider the primary node to be offline */
|
|
49
54
|
private _mainNodeMsgTimeoutTimer;
|
|
50
|
-
/** 更新友方列表的timeout */
|
|
55
|
+
/** 更新友方列表的timeout | Update the timeout of the friend list */
|
|
51
56
|
private _updateFriendListTimer;
|
|
52
|
-
/** 当前实例id */
|
|
57
|
+
/** 当前实例id | Current instance id */
|
|
53
58
|
id: number;
|
|
54
|
-
/**
|
|
59
|
+
/** 其他广播通道id列表 | List of other broadcast channel ids */
|
|
55
60
|
private _oldFrendChannelIdList;
|
|
56
|
-
/**
|
|
61
|
+
/** 正在更新的id数组 | The id array being updated */
|
|
57
62
|
private _friendChannelIdSet;
|
|
58
|
-
/** 当前节点类型 */
|
|
63
|
+
/** 当前节点类型 | Current node type */
|
|
59
64
|
private _nodeType;
|
|
60
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* 是否开启调试模式,会在控制台打印相关信息
|
|
67
|
+
* If debug mode is enabled, it will print information to the console
|
|
68
|
+
*/
|
|
61
69
|
private _debug;
|
|
62
70
|
constructor(name: string, debug?: boolean);
|
|
63
71
|
get nodeType(): BcConnectNodeTypeEnum | undefined;
|
|
@@ -65,73 +73,73 @@ export declare class BroadcastChannelManager {
|
|
|
65
73
|
connect(): void;
|
|
66
74
|
close(): void;
|
|
67
75
|
/**
|
|
68
|
-
* 切换节点类型
|
|
76
|
+
* 切换节点类型 | Switching node type
|
|
69
77
|
* @param {BcConnectNodeTypeEnum} type
|
|
70
78
|
* @returns
|
|
71
79
|
*/
|
|
72
80
|
private _setNodeType;
|
|
73
|
-
/**
|
|
81
|
+
/** 更新广播id列表 | Update the list of broadcast ids */
|
|
74
82
|
private _updateFriendList;
|
|
75
|
-
/** 绑定事件 */
|
|
83
|
+
/** 绑定事件 | Bind event */
|
|
76
84
|
private _bindBroadcastChannelEvent;
|
|
77
|
-
/** 监听节点类型切换事件 */
|
|
85
|
+
/** 监听节点类型切换事件 | */
|
|
78
86
|
private _bindNodeEvent;
|
|
79
|
-
/**
|
|
87
|
+
/** 获取最新的节点列表 | Get the latest node list */
|
|
80
88
|
private _getNewFriendList;
|
|
81
89
|
/**
|
|
82
|
-
* 更新当前节点类型
|
|
90
|
+
* 更新当前节点类型 | Update the current node type
|
|
83
91
|
*/
|
|
84
92
|
private _updataNodeType;
|
|
85
93
|
private _timeoutToBeMainNode;
|
|
86
94
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
95
|
+
* 保存最新的节点列表到_oldFrendChannelIdList,清空_friendChannelIdSet
|
|
96
|
+
* Save the latest node list to _oldFrendChannelIdList and clear _friendChannelIdSet
|
|
89
97
|
*/
|
|
90
98
|
private _catchOldFriend;
|
|
91
99
|
/**
|
|
92
|
-
* 申请成为主节点
|
|
100
|
+
* 申请成为主节点 | Apply to be a master node
|
|
93
101
|
*/
|
|
94
102
|
private _req_beMainNode;
|
|
95
103
|
/**
|
|
96
|
-
*
|
|
97
|
-
* @param id
|
|
104
|
+
* add node
|
|
105
|
+
* @param id id
|
|
98
106
|
*/
|
|
99
107
|
_addFriend(id: number): void;
|
|
100
108
|
/**
|
|
101
|
-
* 广播消息
|
|
102
|
-
* @param type 消息类型
|
|
103
|
-
* @param data 数据
|
|
109
|
+
* 广播消息 | Send Broadcast message
|
|
110
|
+
* @param type 消息类型 | Message type
|
|
111
|
+
* @param data 数据 | data
|
|
104
112
|
*/
|
|
105
113
|
send(type: string, data?: any): void;
|
|
106
114
|
/**
|
|
107
|
-
* 给特定id的节点发送消息
|
|
108
|
-
* @param type 消息类型
|
|
109
|
-
* @param targetId 目标节点id
|
|
110
|
-
* @param data 数据
|
|
115
|
+
* 给特定id的节点发送消息 | Send a message to a node with a specific id
|
|
116
|
+
* @param type 消息类型 | Message type
|
|
117
|
+
* @param targetId 目标节点id | Target Node id
|
|
118
|
+
* @param data 数据 | data
|
|
111
119
|
*/
|
|
112
120
|
sendToTarget(type: string, targetId: number, data?: any): void;
|
|
113
121
|
/**
|
|
114
|
-
* 注册事件
|
|
115
|
-
* @param { string } event 事件类型
|
|
116
|
-
* @param callback 回调
|
|
122
|
+
* 注册事件 | Registering events
|
|
123
|
+
* @param { string } event 事件类型 | Event type
|
|
124
|
+
* @param callback 回调 | callback
|
|
117
125
|
* @returns void
|
|
118
126
|
*/
|
|
119
127
|
on(event: string, callback: (_: BcConnectSendMessageType) => void): void;
|
|
120
128
|
/**
|
|
121
|
-
* 注销事件
|
|
122
|
-
* @param { string } event 事件类型
|
|
123
|
-
* @param callback 事件回调
|
|
129
|
+
* 注销事件 | Remove events
|
|
130
|
+
* @param { string } event 事件类型 | Event type
|
|
131
|
+
* @param callback 事件回调 | callback
|
|
124
132
|
* @returns
|
|
125
133
|
*/
|
|
126
134
|
off(event: string, callback?: (_: BcConnectSendMessageType) => void): void;
|
|
127
135
|
/**
|
|
128
|
-
* 触发事件
|
|
129
|
-
* @param { string } event 事件类型
|
|
130
|
-
* @param data 数据
|
|
136
|
+
* 触发事件 | Triggering events
|
|
137
|
+
* @param { string } event 事件类型 | Event type
|
|
138
|
+
* @param data 数据 | data
|
|
131
139
|
*/
|
|
132
140
|
emit(event: string, data: BcConnectSendMessageType): void;
|
|
133
141
|
/**
|
|
134
|
-
* 销毁
|
|
142
|
+
* 销毁 | destroy
|
|
135
143
|
*/
|
|
136
144
|
destroy(): void;
|
|
137
145
|
}
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
/** 心跳配置 */
|
|
1
|
+
/** 心跳配置 | Heartbeat configuration */
|
|
2
2
|
type HeartbeatConfigType = {
|
|
3
|
-
/** 只发送一次 */
|
|
3
|
+
/** 只发送一次 | Only send it once */
|
|
4
4
|
once: boolean;
|
|
5
|
-
/** 心跳消息 */
|
|
5
|
+
/** 心跳消息 | Heartbeat message */
|
|
6
6
|
message: string;
|
|
7
|
-
/**
|
|
7
|
+
/** 心跳间隔 | Interval of heartbeat */
|
|
8
8
|
interval?: number;
|
|
9
9
|
};
|
|
10
|
-
/** 重连配置 */
|
|
10
|
+
/** 重连配置 | Reconnect configuration */
|
|
11
11
|
type InterruptConfigType = {
|
|
12
|
-
/** 是否重连 */
|
|
12
|
+
/** 是否重连 | Reconnect or not */
|
|
13
13
|
reconnect: boolean;
|
|
14
|
-
/** 最大重连次数 */
|
|
14
|
+
/** 最大重连次数 | Maximum number of reconnections */
|
|
15
15
|
maxReconnectTimes: number;
|
|
16
|
-
/** 每次重连延时 */
|
|
16
|
+
/** 每次重连延时 | Delay per reconnection */
|
|
17
17
|
delay: number;
|
|
18
18
|
};
|
|
19
19
|
export type WebSocketOptionsType = {
|
|
20
|
-
/** WebSocket
|
|
20
|
+
/** WebSocket subprotocol: WebSocket(url: string, protocols: string | string[]) */
|
|
21
21
|
protocols?: string | string[];
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* WebSocket 连接接收的二进制数据类型
|
|
24
|
+
* the type of binary data being received over the WebSocket connection
|
|
25
|
+
*/
|
|
23
26
|
binaryType?: WebSocket['binaryType'];
|
|
24
27
|
heartbeat?: HeartbeatConfigType;
|
|
25
28
|
interrupt?: InterruptConfigType;
|
|
@@ -3,21 +3,31 @@ import type { RenderConstructorOptionType, VideoInfo } from '../render';
|
|
|
3
3
|
import { EventBus } from '@havue/shared';
|
|
4
4
|
import { RenderEventsEnum, AudioState, VideoState } from '../render';
|
|
5
5
|
export type WsVideoManaCstorOptionType = {
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* websocket流连接数量限制, 移动端默认10个,pc端默认32个
|
|
8
|
+
* Limit the number of websocket streaming connections to 10 by default for mobile and 32 by default for pc
|
|
9
|
+
*/
|
|
7
10
|
connectLimit?: number;
|
|
8
|
-
/** WebSocketLoader
|
|
11
|
+
/** WebSocketLoader configuration */
|
|
9
12
|
wsOptions?: WebSocketOptionsType;
|
|
10
13
|
/**
|
|
11
14
|
* websocket重连时,重新解析视频编码方式,
|
|
12
15
|
* 默认 true
|
|
16
|
+
*
|
|
17
|
+
* When the websocket reconnects, the video encoding is reparsed.
|
|
18
|
+
* The default is true
|
|
13
19
|
*/
|
|
14
20
|
reparseMimeOnReconnect?: boolean;
|
|
15
21
|
/** Render 实例配置 */
|
|
16
22
|
renderOptions?: Partial<RenderConstructorOptionType>;
|
|
17
23
|
/**
|
|
18
|
-
* 是否使用WebGL,
|
|
19
|
-
*
|
|
20
|
-
*
|
|
24
|
+
* 是否使用WebGL,默认 false,
|
|
25
|
+
* WebGL在不同游览器,以及受限于显存,不能同时创建过多WebGL上下文,一般8-16个
|
|
26
|
+
*
|
|
27
|
+
* Whether to use WebGL, false by default,
|
|
28
|
+
* WebGL can not be created too many WebGL contexts at the same time in different browsers,
|
|
29
|
+
* and due to the limitations of video memory, usually 8-16 WebGL contexts
|
|
30
|
+
*/
|
|
21
31
|
useWebgl?: boolean;
|
|
22
32
|
};
|
|
23
33
|
export declare enum EventEnums {
|
|
@@ -35,7 +45,7 @@ type Events = {
|
|
|
35
45
|
};
|
|
36
46
|
export declare const WsVideoManagerEventEnums: typeof EventEnums & typeof RenderEventsEnum;
|
|
37
47
|
export declare class WsVideoManager extends EventBus<Events> {
|
|
38
|
-
/** socket
|
|
48
|
+
/** socket相关信息map | map of socket information */
|
|
39
49
|
private _wsInfoMap;
|
|
40
50
|
private _option;
|
|
41
51
|
private _reqAnimationID;
|
|
@@ -44,100 +54,107 @@ export declare class WsVideoManager extends EventBus<Events> {
|
|
|
44
54
|
get connectLimit(): number;
|
|
45
55
|
private _setAnimate;
|
|
46
56
|
/**
|
|
47
|
-
* 添加socket
|
|
48
|
-
* @param url socket
|
|
57
|
+
* 添加socket连接 | Adding a socket connection
|
|
58
|
+
* @param url socket url
|
|
49
59
|
* @returns
|
|
50
60
|
*/
|
|
51
61
|
private _addSocket;
|
|
52
62
|
/**
|
|
53
|
-
* 绑定render事件
|
|
54
|
-
* @param url 连接地址
|
|
55
|
-
* @param render Render
|
|
63
|
+
* 绑定render事件 | Binding the render event
|
|
64
|
+
* @param url 连接地址 | websocket url
|
|
65
|
+
* @param render Render instance
|
|
56
66
|
*/
|
|
57
67
|
private _bindRenderEvent;
|
|
58
68
|
/**
|
|
59
|
-
*
|
|
60
|
-
* @param url socket
|
|
69
|
+
* Destroying the socket connect
|
|
70
|
+
* @param url socket url
|
|
61
71
|
*/
|
|
62
72
|
private _removeSocket;
|
|
63
73
|
/**
|
|
64
|
-
* 绑定socket事件
|
|
65
|
-
* @param url
|
|
66
|
-
* @param socket WebSocketLoader
|
|
74
|
+
* 绑定socket事件 | Binding socket events
|
|
75
|
+
* @param url websocket url
|
|
76
|
+
* @param socket WebSocketLoader instance
|
|
67
77
|
*/
|
|
68
78
|
private _bindSocketEvent;
|
|
69
79
|
private _emitWsUrlListChange;
|
|
70
80
|
/**
|
|
71
|
-
* url对应的 socket实例是否已存在
|
|
72
|
-
* @param url
|
|
81
|
+
* url对应的 socket实例是否已存在 | Whether the socket instance for the url already exists
|
|
82
|
+
* @param url websocket url
|
|
73
83
|
* @returns boolean
|
|
74
84
|
*/
|
|
75
85
|
private _isSocketExist;
|
|
76
86
|
/**
|
|
77
87
|
* 添加url对应socket,以及需要绘制的canvas元素
|
|
78
|
-
*
|
|
79
|
-
* @param
|
|
88
|
+
* Add the socket for the url and the canvas element to draw
|
|
89
|
+
* @param canvas canvas
|
|
90
|
+
* @param url websocket url
|
|
80
91
|
*/
|
|
81
92
|
addCanvas(canvas: HTMLCanvasElement, url: string, renderOptions?: Partial<RenderConstructorOptionType>): void;
|
|
82
93
|
/**
|
|
83
|
-
* 初始化canvas背景
|
|
84
|
-
* @param canvas canvas
|
|
94
|
+
* 初始化canvas背景 | Initialize the canvas background
|
|
95
|
+
* @param canvas canvas
|
|
85
96
|
* @returns
|
|
86
97
|
*/
|
|
87
98
|
/**
|
|
88
|
-
* 删除canvas元素
|
|
89
|
-
* @param canvas canvas
|
|
99
|
+
* 删除canvas元素 || Remove the canvas element
|
|
100
|
+
* @param canvas canvas
|
|
90
101
|
*/
|
|
91
102
|
removeCanvas(canvas: HTMLCanvasElement): void;
|
|
92
103
|
/**
|
|
93
|
-
*
|
|
94
|
-
* @param canvas canvas
|
|
104
|
+
* 获取canvas是否已经添加过 | Gets whether the canvas has already been added
|
|
105
|
+
* @param canvas canvas
|
|
95
106
|
* @returns boolean
|
|
96
107
|
*/
|
|
97
108
|
isCanvasExist(canvas: HTMLCanvasElement): boolean;
|
|
98
|
-
/** 设置全部render静音状态 */
|
|
109
|
+
/** 设置全部render静音状态 | Mute all render */
|
|
99
110
|
setAllVideoMutedState(muted: boolean): void;
|
|
100
|
-
/** 更新单个render实例的配置 */
|
|
111
|
+
/** 更新单个render实例的配置 | Update the configuration of a single render instance */
|
|
101
112
|
updateRenderOptions(url: string, options?: Partial<RenderConstructorOptionType>): void;
|
|
102
113
|
/**
|
|
103
|
-
* 设置单个render静音状态
|
|
114
|
+
* 设置单个render静音状态 | Set a single render to be silent
|
|
104
115
|
* @param url
|
|
105
|
-
* @param muted
|
|
116
|
+
* @param {boolean} muted 是否静音 | Muted or not
|
|
106
117
|
*/
|
|
107
118
|
setOneMutedState(url: string, muted: boolean): void;
|
|
108
119
|
/**
|
|
109
120
|
* 获取url对应render video元素是否静音
|
|
110
|
-
*
|
|
121
|
+
* Gets whether the render video element of the url is muted
|
|
122
|
+
* @param url websocket url
|
|
111
123
|
*/
|
|
112
124
|
getOneMutedState(url: string): boolean;
|
|
113
125
|
/**
|
|
114
126
|
* 单个解除静音,其他未静音的变成静音,只播放一个
|
|
115
|
-
*
|
|
127
|
+
* Unmute a single video and mute all other videos
|
|
128
|
+
* @param url websocket url
|
|
116
129
|
*/
|
|
117
130
|
playOneAudio(url: string): void;
|
|
118
131
|
/**
|
|
119
132
|
* 设置单个render是否继续处理ws数据
|
|
133
|
+
* Sets whether a single render continues to process ws data
|
|
120
134
|
* @param url
|
|
121
135
|
*/
|
|
122
136
|
setOneVideoPausedState(url: string, paused: boolean): void;
|
|
123
|
-
/** 设置全部render是否继续处理ws数据 */
|
|
137
|
+
/** 设置全部render是否继续处理ws数据 | Sets whether all render continues to process ws data */
|
|
124
138
|
setAllVideoPausedState(paused: boolean): void;
|
|
125
139
|
/**
|
|
126
|
-
* 获取url对应render video
|
|
127
|
-
*
|
|
140
|
+
* 获取url对应render video元素的播放状态
|
|
141
|
+
* Get the playback status of the render video element corresponding to the url
|
|
142
|
+
* @param url websocket url
|
|
128
143
|
*/
|
|
129
144
|
getOneVideoPausedState(url: string): boolean;
|
|
130
145
|
/**
|
|
131
146
|
* 单个视频继续播放,其他暂停处理数据
|
|
132
|
-
*
|
|
147
|
+
* A single video continues to play while others pause to process data
|
|
148
|
+
* @param url websocket url
|
|
133
149
|
*/
|
|
134
150
|
playOneVideo(url: string): void;
|
|
135
151
|
/**
|
|
136
152
|
* 刷新socket,以及播放时间
|
|
153
|
+
* Refresh the socket, and the playback time
|
|
137
154
|
*/
|
|
138
155
|
refresh(url?: string): void;
|
|
139
156
|
/**
|
|
140
|
-
* 销毁
|
|
157
|
+
* 销毁 | Destroy
|
|
141
158
|
*/
|
|
142
159
|
destroy(): void;
|
|
143
160
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 绘制视频到canvas中
|
|
2
|
+
* 绘制视频到canvas中 | Draw video into canvas
|
|
3
3
|
*/
|
|
4
4
|
declare class CanvasDrawer {
|
|
5
5
|
private _canvas;
|
|
@@ -17,27 +17,27 @@ declare class CanvasDrawer {
|
|
|
17
17
|
constructor(canvas: HTMLCanvasElement, useWebgl?: boolean);
|
|
18
18
|
private init2d;
|
|
19
19
|
/**
|
|
20
|
-
* 初始化 webgl
|
|
20
|
+
* 初始化 webgl | Initialize webgl
|
|
21
21
|
*/
|
|
22
22
|
private initGl;
|
|
23
23
|
/**
|
|
24
|
-
* 创建着色器源码
|
|
24
|
+
* 创建着色器源码 | Create shader source code
|
|
25
25
|
*/
|
|
26
26
|
private createShaderSource;
|
|
27
27
|
/**
|
|
28
|
-
* 创建着色器
|
|
28
|
+
* 创建着色器 | Create shaders
|
|
29
29
|
*/
|
|
30
30
|
private createShader;
|
|
31
31
|
/**
|
|
32
|
-
* 创建着色器程序
|
|
32
|
+
* 创建着色器程序 | Create program
|
|
33
33
|
*/
|
|
34
34
|
private createProgram;
|
|
35
35
|
/**
|
|
36
|
-
* 绘制
|
|
36
|
+
* 绘制 | draw
|
|
37
37
|
*/
|
|
38
38
|
draw(video: HTMLVideoElement): void;
|
|
39
39
|
/**
|
|
40
|
-
* 销毁
|
|
40
|
+
* 销毁 | Destroy
|
|
41
41
|
*/
|
|
42
42
|
destroy(): void;
|
|
43
43
|
}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { EventBus } from '@havue/shared';
|
|
2
2
|
export type RenderConstructorOptionType = {
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* 当前播放currentTime和最新视频时长最多相差 秒数,默认0.3s
|
|
5
|
+
* The delay of currentTime relative to the latest video duration is 0.3s by default
|
|
6
|
+
*/
|
|
4
7
|
liveMaxLatency: number;
|
|
5
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* 最多缓存ws传输的未处理的buffer数据大小, 默认200kb。
|
|
10
|
+
* The maximum amount of unprocessed buffer data to be cached for websocket transfers.
|
|
11
|
+
* 200kb by default
|
|
12
|
+
*/
|
|
6
13
|
maxCacheBufByte: number;
|
|
7
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* 最多存储的时间,用于清除在currentTime之前x秒时间节点前的buffer数据, 默认10s
|
|
16
|
+
* The maximum amount of time used to clear the buffer before a time node x seconds before currentTime (default 10s)
|
|
17
|
+
*/
|
|
8
18
|
maxCache: number;
|
|
9
19
|
};
|
|
10
20
|
export declare const WS_VIDEO_RENDER_DEFAULT_OPTIONS: Readonly<{
|
|
@@ -35,29 +45,32 @@ export type RenderEvents = {
|
|
|
35
45
|
[RenderEventsEnum.VIDEO_INFO_UPDATE]: (info: VideoInfo) => void;
|
|
36
46
|
};
|
|
37
47
|
export declare class Render extends EventBus<RenderEvents> {
|
|
38
|
-
/** video元素 */
|
|
48
|
+
/** video元素 | videw element */
|
|
39
49
|
private _videoEl;
|
|
40
|
-
/** mp4box
|
|
50
|
+
/** mp4box file */
|
|
41
51
|
private _mp4box;
|
|
42
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* mp4box onFragment获取的视频数据buffer数组
|
|
54
|
+
* mp4box onFragment gets a buffer array of audio and video data
|
|
55
|
+
*/
|
|
43
56
|
private _audioBufsQueue;
|
|
44
57
|
private _videoBufsQueue;
|
|
45
|
-
/** MediaSource
|
|
58
|
+
/** MediaSource instance */
|
|
46
59
|
private _mediaSource;
|
|
47
|
-
/** SourceBuffer
|
|
60
|
+
/** SourceBuffer instance */
|
|
48
61
|
private _audioSourceBuffer;
|
|
49
62
|
private _videoSourceBuffer;
|
|
50
63
|
private _audioTrackId;
|
|
51
64
|
private _videoTrackId;
|
|
52
|
-
/** 用于MediaSource的mimeType */
|
|
65
|
+
/** 用于MediaSource的mimeType | mime type of the video */
|
|
53
66
|
private _mimeType;
|
|
54
67
|
private _audioMimeType;
|
|
55
68
|
private _videoMimeType;
|
|
56
|
-
/** 是否暂停播放 */
|
|
69
|
+
/** 是否暂停播放 | Pause or not */
|
|
57
70
|
private _paused;
|
|
58
71
|
private _options;
|
|
59
72
|
private _cacheAnimationID;
|
|
60
|
-
/** fmp4初始化片段是否已经添加 */
|
|
73
|
+
/** fmp4初始化片段是否已经添加 | fmp4 Initializes whether the fragment has been added */
|
|
61
74
|
private _isAudioInitSegmentAdded;
|
|
62
75
|
private _isVideoInitSegmentAdded;
|
|
63
76
|
private _offset;
|
|
@@ -67,51 +80,54 @@ export declare class Render extends EventBus<RenderEvents> {
|
|
|
67
80
|
set paused(paused: boolean);
|
|
68
81
|
get paused(): boolean;
|
|
69
82
|
get videoEl(): HTMLVideoElement | undefined;
|
|
70
|
-
/** 更新实例配置 */
|
|
83
|
+
/** 更新实例配置 | Update configuration */
|
|
71
84
|
updateOptions(option?: Partial<RenderConstructorOptionType>): void;
|
|
72
85
|
/**
|
|
73
|
-
* 添加视频流buffer数据
|
|
86
|
+
* 添加视频流buffer数据 | Add video stream buffer data
|
|
74
87
|
* @param buf
|
|
75
88
|
*/
|
|
76
89
|
appendMediaBuffer(bufs: Array<ArrayBuffer & {
|
|
77
90
|
fileStart: number;
|
|
78
91
|
}>): void;
|
|
79
92
|
/**
|
|
80
|
-
* mp4box解析完成
|
|
81
|
-
* @param info mp4box解析信息
|
|
93
|
+
* mp4box解析完成 | handle Mp4box onReady
|
|
94
|
+
* @param info mp4box解析信息 | mp4box parses the information
|
|
82
95
|
*/
|
|
83
96
|
private _onMp4boxReady;
|
|
84
97
|
private _onSegment;
|
|
85
98
|
/**
|
|
86
|
-
* 初始化视频元素
|
|
99
|
+
* 初始化视频元素 | Initialize the video element
|
|
87
100
|
*/
|
|
88
101
|
private _setupVideo;
|
|
89
102
|
/**
|
|
90
103
|
* 是否支持Media Source Extention
|
|
104
|
+
* whether Media Source Extention is supported
|
|
91
105
|
* @returns boolean
|
|
92
106
|
*/
|
|
93
107
|
isSupportMSE(): boolean;
|
|
94
108
|
/**
|
|
95
|
-
* 初始化MSE
|
|
109
|
+
* 初始化MSE | Init MSE
|
|
96
110
|
* @returns
|
|
97
111
|
*/
|
|
98
112
|
private _setupMSE;
|
|
99
113
|
private _setupSourceBuffer;
|
|
100
114
|
/**
|
|
101
115
|
* 将_bufsQueue中的数据添加到SourceBuffer中
|
|
116
|
+
* Add the data from _bufsQueue to the SourceBuffer
|
|
102
117
|
* @returns
|
|
103
118
|
*/
|
|
104
119
|
private _cache;
|
|
105
120
|
/**
|
|
106
121
|
* 刷新播放时间为最新
|
|
122
|
+
* Refresh the playback time to the latest
|
|
107
123
|
*/
|
|
108
124
|
refresh(): void;
|
|
109
|
-
/** 重置解析的视频mime type */
|
|
125
|
+
/** 重置解析的视频mime type | Reset the parsed video mime type */
|
|
110
126
|
resetMimeType(): void;
|
|
111
127
|
private destroyMediaSource;
|
|
112
128
|
destroyMp4box(): void;
|
|
113
129
|
/**
|
|
114
|
-
* 销毁
|
|
130
|
+
* 销毁 | Destroy
|
|
115
131
|
*/
|
|
116
132
|
destroy(): void;
|
|
117
133
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@havue/solutions",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Javascript class for special scene",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"havue",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"lodash": "^4.17.21",
|
|
20
|
-
"@havue/shared": "^1.1
|
|
21
|
-
"@havue/bc-connect": "^1.1
|
|
22
|
-
"@havue/ws-video-manager": "^1.1
|
|
20
|
+
"@havue/shared": "^1.2.1",
|
|
21
|
+
"@havue/bc-connect": "^1.2.1",
|
|
22
|
+
"@havue/ws-video-manager": "^1.2.1"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public",
|
package/vite.config.ts
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
/** 心跳配置 */
|
|
1
|
+
/** 心跳配置 | Heartbeat configuration */
|
|
2
2
|
type HeartbeatConfigType = {
|
|
3
|
-
/** 只发送一次 */
|
|
3
|
+
/** 只发送一次 | Only send it once */
|
|
4
4
|
once: boolean;
|
|
5
|
-
/** 心跳消息 */
|
|
5
|
+
/** 心跳消息 | Heartbeat message */
|
|
6
6
|
message: string;
|
|
7
|
-
/**
|
|
7
|
+
/** 心跳间隔 | Interval of heartbeat */
|
|
8
8
|
interval?: number;
|
|
9
9
|
};
|
|
10
|
-
/** 重连配置 */
|
|
10
|
+
/** 重连配置 | Reconnect configuration */
|
|
11
11
|
type InterruptConfigType = {
|
|
12
|
-
/** 是否重连 */
|
|
12
|
+
/** 是否重连 | Reconnect or not */
|
|
13
13
|
reconnect: boolean;
|
|
14
|
-
/** 最大重连次数 */
|
|
14
|
+
/** 最大重连次数 | Maximum number of reconnections */
|
|
15
15
|
maxReconnectTimes: number;
|
|
16
|
-
/** 每次重连延时 */
|
|
16
|
+
/** 每次重连延时 | Delay per reconnection */
|
|
17
17
|
delay: number;
|
|
18
18
|
};
|
|
19
19
|
export type WebSocketOptionsType = {
|
|
20
|
-
/** WebSocket
|
|
20
|
+
/** WebSocket subprotocol: WebSocket(url: string, protocols: string | string[]) */
|
|
21
21
|
protocols?: string | string[];
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* WebSocket 连接接收的二进制数据类型
|
|
24
|
+
* the type of binary data being received over the WebSocket connection
|
|
25
|
+
*/
|
|
23
26
|
binaryType?: WebSocket['binaryType'];
|
|
24
27
|
heartbeat?: HeartbeatConfigType;
|
|
25
28
|
interrupt?: InterruptConfigType;
|