@volcengine/vepusher 2.0.4-rc.2 → 2.0.4-rc.4
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/dist/index.es.d.ts +343 -7
- package/dist/index.es.js +7697 -2582
- package/dist/index.umd.js +35 -25
- package/package.json +1 -1
package/dist/index.es.d.ts
CHANGED
|
@@ -53,8 +53,120 @@ declare type ConfigOptions = {
|
|
|
53
53
|
* - `webTransport`: Streaming with WebTransport protocol.
|
|
54
54
|
*/
|
|
55
55
|
mode?: PushMode;
|
|
56
|
+
/** {zh}
|
|
57
|
+
* @brief 推流中断重试配置,包含是否开启,重试最大超时时间,不传入时默认开启断线重连,最大超时时间默认3分钟
|
|
58
|
+
*/
|
|
59
|
+
/** {en}
|
|
60
|
+
* @brief Push stream interruption retry configuration, including whether to enable, maximum retry timeout time, and default to enabling reconnection, maximum timeout time default 3 minutes.
|
|
61
|
+
*/
|
|
62
|
+
reconnectConfig?: {
|
|
63
|
+
/** {zh}
|
|
64
|
+
* @brief 是否开启断线重连。
|
|
65
|
+
*/
|
|
66
|
+
/** {en}
|
|
67
|
+
* @brief Whether to enable reconnection after disconnection.
|
|
68
|
+
*/
|
|
69
|
+
enable: boolean;
|
|
70
|
+
/** {zh}
|
|
71
|
+
* @brief 最大重试超时时间,单位为秒。
|
|
72
|
+
*/
|
|
73
|
+
/** {en}
|
|
74
|
+
* @brief Maximum retry timeout time, in seconds.
|
|
75
|
+
*/
|
|
76
|
+
maxTimeout?: number;
|
|
77
|
+
};
|
|
78
|
+
/** {zh}
|
|
79
|
+
* @brief 推流日志配置, 默认自动开启日志上报。
|
|
80
|
+
*/
|
|
81
|
+
/** {en}
|
|
82
|
+
* @brief Streaming log configuration, default automatic log reporting.
|
|
83
|
+
*/
|
|
84
|
+
loggerConfig?: {
|
|
85
|
+
/** {zh}
|
|
86
|
+
* @brief 是否开启日志上报。
|
|
87
|
+
*/
|
|
88
|
+
/** {en}
|
|
89
|
+
* @brief Whether to enable log reporting.
|
|
90
|
+
*/
|
|
91
|
+
enable: boolean;
|
|
92
|
+
/** {zh}
|
|
93
|
+
* @brief 火山引擎的账号id,用于日志上报排查。
|
|
94
|
+
*/
|
|
95
|
+
/** {en}
|
|
96
|
+
* @brief Byteplus account ID for log reporting.
|
|
97
|
+
*/
|
|
98
|
+
accountId: number;
|
|
99
|
+
/** {zh}
|
|
100
|
+
* @brief 应用 ID。登录视频直播控制台 > SDK 管理查询。
|
|
101
|
+
*/
|
|
102
|
+
/** {en}
|
|
103
|
+
* @brief Application ID. Query in the SDK Management section of the Byteplus MediaLive Broadcast Console.
|
|
104
|
+
*/
|
|
105
|
+
appId?: number;
|
|
106
|
+
/** {zh}
|
|
107
|
+
* @brief 应用名称。
|
|
108
|
+
*/
|
|
109
|
+
/** {en}
|
|
110
|
+
* @brief Application name.
|
|
111
|
+
*/
|
|
112
|
+
appName?: string;
|
|
113
|
+
/** {zh}
|
|
114
|
+
* @brief 用于识别单一用户的 ID,如不设置,会随机生成一个用户 ID 存在浏览器缓存中。
|
|
115
|
+
*/
|
|
116
|
+
/** {en}
|
|
117
|
+
* @brief User ID for identifying a single user. If not set, a random user ID will be generated and stored in the browser cache.
|
|
118
|
+
*/
|
|
119
|
+
userId?: string;
|
|
120
|
+
/** {zh}
|
|
121
|
+
* @brief 用于识别用户设备的 ID,如不设置,会随机生成一个用户 ID 存在浏览器缓存中。
|
|
122
|
+
*/
|
|
123
|
+
/** {en}
|
|
124
|
+
* @brief User device ID. If not set, a random user ID will be generated and stored in the browser cache.
|
|
125
|
+
*/
|
|
126
|
+
deviceId?: string;
|
|
127
|
+
showInConsole?: boolean;
|
|
128
|
+
};
|
|
129
|
+
checkAudio?: boolean;
|
|
56
130
|
};
|
|
57
131
|
|
|
132
|
+
/** {zh}
|
|
133
|
+
* @detail events
|
|
134
|
+
* @brief 直播链接状态码
|
|
135
|
+
*/
|
|
136
|
+
/** {en}
|
|
137
|
+
*
|
|
138
|
+
*/
|
|
139
|
+
declare enum ConnectionState {
|
|
140
|
+
/** {zh}
|
|
141
|
+
* @brief 断开连接,默认时断开连接。
|
|
142
|
+
*/
|
|
143
|
+
/** {en}
|
|
144
|
+
* @brief Disconnected by default.
|
|
145
|
+
*/
|
|
146
|
+
DISCONNECTED = 0,
|
|
147
|
+
/** {zh}
|
|
148
|
+
* @brief 连接中。
|
|
149
|
+
*/
|
|
150
|
+
/** {en}
|
|
151
|
+
* @brief Connecting.
|
|
152
|
+
*/
|
|
153
|
+
CONNECTING = 1,
|
|
154
|
+
/** {zh}
|
|
155
|
+
* @brief 已连接。
|
|
156
|
+
*/
|
|
157
|
+
/** {en}
|
|
158
|
+
* @brief Connected.
|
|
159
|
+
*/
|
|
160
|
+
CONNECTED = 2,
|
|
161
|
+
/** {zh}
|
|
162
|
+
* @brief 重连中。
|
|
163
|
+
*/
|
|
164
|
+
/** {en}
|
|
165
|
+
* @brief Reconnecting.
|
|
166
|
+
*/
|
|
167
|
+
RECONNECTING = 3,
|
|
168
|
+
}
|
|
169
|
+
|
|
58
170
|
/** {zh}
|
|
59
171
|
* @detail config
|
|
60
172
|
* @list config
|
|
@@ -180,21 +292,31 @@ declare interface IProperty {
|
|
|
180
292
|
*/
|
|
181
293
|
setVideoFps: number;
|
|
182
294
|
/** {zh}
|
|
183
|
-
* @
|
|
295
|
+
* @deprecated
|
|
296
|
+
* @brief 设置推流视频的码率,单位为 bps。
|
|
184
297
|
*/
|
|
185
298
|
/** {en}
|
|
186
|
-
*
|
|
187
|
-
* @brief Set the push stream video bitrate in
|
|
299
|
+
* @deprecated
|
|
300
|
+
* @brief Set the push stream video bitrate in bps.
|
|
188
301
|
*/
|
|
189
302
|
setVideoBitrate: number;
|
|
190
303
|
/** {zh}
|
|
191
|
-
* @brief
|
|
304
|
+
* @brief 设置推流时视频的码率,单位为 kbps。
|
|
305
|
+
*/
|
|
306
|
+
setVideoKBitrate: number;
|
|
307
|
+
/** {zh}
|
|
308
|
+
* @deprecated
|
|
309
|
+
* @brief 设置推流时音频的码率,单位为 bps。
|
|
192
310
|
*/
|
|
193
311
|
/** {en}
|
|
194
|
-
*
|
|
195
|
-
* @brief Set the audio bitrate for push stream in
|
|
312
|
+
* @deprecated
|
|
313
|
+
* @brief Set the audio bitrate for push stream in bps.
|
|
196
314
|
*/
|
|
197
315
|
setAudioBitrate: number;
|
|
316
|
+
/** {zh}
|
|
317
|
+
* @brief 设置推流时音频的码率,单位为 kbps。
|
|
318
|
+
*/
|
|
319
|
+
setAudioKBitrate: number;
|
|
198
320
|
/** {zh}
|
|
199
321
|
* @brief 设置麦克风采集的采样率,单位为 Hz。
|
|
200
322
|
*/
|
|
@@ -218,6 +340,17 @@ declare interface IProperty {
|
|
|
218
340
|
*
|
|
219
341
|
*/
|
|
220
342
|
setVolumeDetectScriptUrl: string;
|
|
343
|
+
/** {zh}
|
|
344
|
+
* @hidden
|
|
345
|
+
* @brief 设置推流时默认采集的方向,默认是横屏
|
|
346
|
+
*/
|
|
347
|
+
/** {zh}
|
|
348
|
+
* @brief 更新推流地址,作用:断线重连时会使用最新的推流地址,避免推流过程中推流地址超时鉴权失败。
|
|
349
|
+
*/
|
|
350
|
+
/** {en}
|
|
351
|
+
* @brief Update the push stream address. The effect: When reconnecting, the latest push stream address will be used to avoid push stream address timeout authentication failure.
|
|
352
|
+
*/
|
|
353
|
+
updatePushUrl: string;
|
|
221
354
|
}
|
|
222
355
|
|
|
223
356
|
declare type IVePusherEvents = {
|
|
@@ -307,6 +440,72 @@ declare interface IVideoStreamLayoutParams {
|
|
|
307
440
|
mirrorType?: MirrorType;
|
|
308
441
|
}
|
|
309
442
|
|
|
443
|
+
/** {zh}
|
|
444
|
+
* @detail api
|
|
445
|
+
* @brief 视频流渲染的配置信息
|
|
446
|
+
* @id IVideoStreamRenderConfig
|
|
447
|
+
* @name IVideoStreamRenderConfig
|
|
448
|
+
*/
|
|
449
|
+
/** {en}
|
|
450
|
+
* @detail api
|
|
451
|
+
* @id IVideoStreamRenderConfig
|
|
452
|
+
* @name IVideoStreamRenderConfig
|
|
453
|
+
*
|
|
454
|
+
*/
|
|
455
|
+
declare interface IVideoStreamRenderConfig {
|
|
456
|
+
/** {zh}
|
|
457
|
+
* @brief 配置的渲染宽度。
|
|
458
|
+
*/
|
|
459
|
+
/** {en}
|
|
460
|
+
* @brief The configured rendering width.
|
|
461
|
+
*/
|
|
462
|
+
width: number;
|
|
463
|
+
/** {zh}
|
|
464
|
+
* @brief 配置的渲染高度。
|
|
465
|
+
*/
|
|
466
|
+
/** {en}
|
|
467
|
+
* @brief The configured rendering height.
|
|
468
|
+
*/
|
|
469
|
+
height: number;
|
|
470
|
+
/** {zh}
|
|
471
|
+
* @brief 实际渲染宽度,(addVideoStream时使用keepRatio,实际渲染宽度可能会根据实际采集的宽高等比例缩放)。
|
|
472
|
+
*
|
|
473
|
+
*/
|
|
474
|
+
/** {en}
|
|
475
|
+
* @brief The actual rendering width. (When adding a video stream, the actual rendering width may be scaled proportionally based on the actual width and height of the video stream.)
|
|
476
|
+
*/
|
|
477
|
+
paintWidth: number;
|
|
478
|
+
/** {zh}
|
|
479
|
+
* @brief 实际渲染高度,(addVideoStream时使用keepRatio,实际渲染高度可能会根据实际采集的宽高等比例缩放)。
|
|
480
|
+
*
|
|
481
|
+
*/
|
|
482
|
+
/** {en}
|
|
483
|
+
* @brief The actual rendering height. (When adding a video stream, the actual rendering height may be scaled proportionally based on the actual width and height of the video stream.)
|
|
484
|
+
*/
|
|
485
|
+
paintHeight: number;
|
|
486
|
+
/** {zh}
|
|
487
|
+
* @brief 渲染的x坐标。
|
|
488
|
+
*/
|
|
489
|
+
/** {en}
|
|
490
|
+
* @brief The rendering x-coordinate.
|
|
491
|
+
*/
|
|
492
|
+
x: number;
|
|
493
|
+
/** {zh}
|
|
494
|
+
* @brief 渲染的y坐标。
|
|
495
|
+
*/
|
|
496
|
+
/** {en}
|
|
497
|
+
* @brief The rendering y-coordinate.
|
|
498
|
+
*/
|
|
499
|
+
y: number;
|
|
500
|
+
/** {zh}
|
|
501
|
+
* @brief 渲染的层级。
|
|
502
|
+
*/
|
|
503
|
+
/** {en}
|
|
504
|
+
* @brief The rendering layer.
|
|
505
|
+
*/
|
|
506
|
+
zOrder: number;
|
|
507
|
+
}
|
|
508
|
+
|
|
310
509
|
/** {zh}
|
|
311
510
|
* @detail api
|
|
312
511
|
* @list api
|
|
@@ -322,6 +521,7 @@ declare class LivePusher extends default_2<RTMEvents> {
|
|
|
322
521
|
private _streamComposeController;
|
|
323
522
|
private _streamConsumeController;
|
|
324
523
|
private _observer;
|
|
524
|
+
private _options;
|
|
325
525
|
/** {zh}
|
|
326
526
|
* @brief 查询是否支持 RTM 或 WebTransport 推流。
|
|
327
527
|
* @param mode 推流模式。
|
|
@@ -726,6 +926,15 @@ declare class LivePusher extends default_2<RTMEvents> {
|
|
|
726
926
|
* @param config Attributes of the mixing canvas, such as width, height, frame rate, etc.
|
|
727
927
|
*/
|
|
728
928
|
setMixingConfig(config: IMixingViewConfig): void;
|
|
929
|
+
/** {zh}
|
|
930
|
+
* @brief 获取配置的合流参数,包括合流画布的宽度、高度、帧率等。
|
|
931
|
+
* @return 返回配置的合流参数。
|
|
932
|
+
*/
|
|
933
|
+
/** {en}
|
|
934
|
+
* @brief Get the configured mixing parameters, including the width, height, and frame rate of the mixing canvas.
|
|
935
|
+
* @return Returns the configured mixing parameters.
|
|
936
|
+
*/
|
|
937
|
+
getMixingConfig(): IMixingViewConfig;
|
|
729
938
|
/** {zh}
|
|
730
939
|
* @brief 设置视频的预览区域。本地视频会在指定的容器内进行预览,同时预览内容与推流的画面和声音完全一致。
|
|
731
940
|
* @param containerId 用于指定预览区域的 HTML 容器元素 ID。
|
|
@@ -940,6 +1149,14 @@ declare class LivePusher extends default_2<RTMEvents> {
|
|
|
940
1149
|
* @return 对应流的 `MediaStream` 对象,可用于本地渲染或其他处理。
|
|
941
1150
|
*/
|
|
942
1151
|
getMediaStream(streamId: string): MediaStream;
|
|
1152
|
+
/** {zh}
|
|
1153
|
+
* @hidden
|
|
1154
|
+
* @brief 获取原始的Stream对象
|
|
1155
|
+
*/
|
|
1156
|
+
/** {en}
|
|
1157
|
+
* @hidden
|
|
1158
|
+
*/
|
|
1159
|
+
getStream(streamId: string): any;
|
|
943
1160
|
/** {zh}
|
|
944
1161
|
* @brief 停止推流。
|
|
945
1162
|
* @return 返回 `Promise` 对象。
|
|
@@ -988,6 +1205,7 @@ declare class LivePusher extends default_2<RTMEvents> {
|
|
|
988
1205
|
* @return `video` element of the preview screen.
|
|
989
1206
|
*/
|
|
990
1207
|
getPreviewElement(): HTMLVideoElement | null | undefined;
|
|
1208
|
+
getVideoStreamRenderConfig(streamId: string): IVideoStreamRenderConfig | undefined;
|
|
991
1209
|
private _bindEvent;
|
|
992
1210
|
/** {zh}
|
|
993
1211
|
* @brief 清理 SDK 实例,避免可能会产生的内存泄露。
|
|
@@ -1194,6 +1412,49 @@ declare class Observer implements IVePusherEvents {
|
|
|
1194
1412
|
* @notes The callback will be triggered when stopping capture actively or when capture stops passively due to an internal error.
|
|
1195
1413
|
*/
|
|
1196
1414
|
onStopCapture: (streamId: string) => void;
|
|
1415
|
+
/** {zh}
|
|
1416
|
+
* @brief 推流过程中直播连接状态变化的回调。
|
|
1417
|
+
*/
|
|
1418
|
+
/** {en}
|
|
1419
|
+
* @brief Callback for changes in the live connection state during the streaming process.
|
|
1420
|
+
*/
|
|
1421
|
+
onLiveConnectStateChange: (state: ConnectionState) => void;
|
|
1422
|
+
/** {zh}
|
|
1423
|
+
* @brief 推流过程中重连状态变化的回调。params中failedCode在失败时会返回,提示重连失败的原因。retryTime在重连等待和重连中会返回,提示当前为第几次重连。waitingTime在重连等待中会返回,提示当前等待的时间,单位为毫秒,两次重连中会等待一定时间,根据重连次数增加等待时间会增加,最大为10秒。
|
|
1424
|
+
*/
|
|
1425
|
+
/** {en}
|
|
1426
|
+
* @brief Callback for changes in the reconnect state during the streaming process. params will return failedCode when the connection fails, indicating the reason for the failure. retryTime will return the current retry times when the connection is in the waiting or reconnecting state, indicating the current retry times. waitingTime will return the waiting time when the connection is in the waiting state, in milliseconds, and the waiting time will increase with the number of retries, up to a maximum of 10 seconds.
|
|
1427
|
+
*/
|
|
1428
|
+
onReconnectStateChange: (
|
|
1429
|
+
/** {zh}
|
|
1430
|
+
* @brief 重连状态。
|
|
1431
|
+
*/
|
|
1432
|
+
/** {en}
|
|
1433
|
+
* @brief Reconnect state.
|
|
1434
|
+
*/
|
|
1435
|
+
state: ReconnectState, params?: {
|
|
1436
|
+
/** {zh}
|
|
1437
|
+
* @brief 重连失败时返回的失败错误码。
|
|
1438
|
+
*/
|
|
1439
|
+
/** {en}
|
|
1440
|
+
* @brief The error code returned when the connection fails.
|
|
1441
|
+
*/
|
|
1442
|
+
failedCode?: ReconnectFailedCode;
|
|
1443
|
+
/** {zh}
|
|
1444
|
+
* @brief 重连等待中、重连中的当前重试次数。
|
|
1445
|
+
*/
|
|
1446
|
+
/** {en}
|
|
1447
|
+
* @brief The current retry times in the waiting or reconnecting state.
|
|
1448
|
+
*/
|
|
1449
|
+
retryTime?: number;
|
|
1450
|
+
/** {zh}
|
|
1451
|
+
* @brief 重连等待中的当前等待时间,单位为毫秒。
|
|
1452
|
+
*/
|
|
1453
|
+
/** {en}
|
|
1454
|
+
* @brief The current waiting time in the waiting state, in milliseconds.
|
|
1455
|
+
*/
|
|
1456
|
+
waitingTime?: number;
|
|
1457
|
+
}) => void;
|
|
1197
1458
|
/** {zh}
|
|
1198
1459
|
* @brief 构造函数
|
|
1199
1460
|
* @hidden
|
|
@@ -1219,6 +1480,72 @@ declare class Observer implements IVePusherEvents {
|
|
|
1219
1480
|
*/
|
|
1220
1481
|
declare type PushMode = 'rtm' | 'webTransport';
|
|
1221
1482
|
|
|
1483
|
+
/** {zh}
|
|
1484
|
+
* @detail events
|
|
1485
|
+
* @brief 重连重连失败码
|
|
1486
|
+
*/
|
|
1487
|
+
declare enum ReconnectFailedCode {
|
|
1488
|
+
/** {zh}
|
|
1489
|
+
* @brief 推流地址失效,需要重新生成推流地址推流
|
|
1490
|
+
*/
|
|
1491
|
+
/** {en}
|
|
1492
|
+
* @brief The push stream address is invalid and needs to regenerate the push stream address to push
|
|
1493
|
+
*/
|
|
1494
|
+
PushUrlInvalid = 1001,
|
|
1495
|
+
/** {zh}
|
|
1496
|
+
* @brief 重连超时
|
|
1497
|
+
*/
|
|
1498
|
+
/** {en}
|
|
1499
|
+
* @brief Reconnect timeout
|
|
1500
|
+
*/
|
|
1501
|
+
ReconnectTimeout = 1002,
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
/** {zh}
|
|
1505
|
+
* @detail events
|
|
1506
|
+
* @brief 推流重连状态码
|
|
1507
|
+
*/
|
|
1508
|
+
/** {en}
|
|
1509
|
+
*
|
|
1510
|
+
*/
|
|
1511
|
+
declare enum ReconnectState {
|
|
1512
|
+
/** {zh}
|
|
1513
|
+
* @brief 重连开始。
|
|
1514
|
+
*/
|
|
1515
|
+
/** {en}
|
|
1516
|
+
* @brief Reconnect start.
|
|
1517
|
+
*/
|
|
1518
|
+
START = 1,
|
|
1519
|
+
/** {zh}
|
|
1520
|
+
* @brief 重连等待。
|
|
1521
|
+
*/
|
|
1522
|
+
/** {en}
|
|
1523
|
+
* @brief Reconnect waiting.
|
|
1524
|
+
*/
|
|
1525
|
+
WAITING = 2,
|
|
1526
|
+
/** {zh}
|
|
1527
|
+
* @brief 重连中。
|
|
1528
|
+
*/
|
|
1529
|
+
/** {en}
|
|
1530
|
+
* @brief Reconnecting.
|
|
1531
|
+
*/
|
|
1532
|
+
RECONNECTING = 3,
|
|
1533
|
+
/** {zh}
|
|
1534
|
+
* @brief 重连成功。
|
|
1535
|
+
*/
|
|
1536
|
+
/** {en}
|
|
1537
|
+
* @brief Reconnect success.
|
|
1538
|
+
*/
|
|
1539
|
+
SUCCESS = 4,
|
|
1540
|
+
/** {zh}
|
|
1541
|
+
* @brief 重连失败。
|
|
1542
|
+
*/
|
|
1543
|
+
/** {en}
|
|
1544
|
+
* @brief Reconnect failed.
|
|
1545
|
+
*/
|
|
1546
|
+
FAILED = 5,
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1222
1549
|
declare class RTMError extends Error {
|
|
1223
1550
|
code: RTMErrorCode;
|
|
1224
1551
|
message: string;
|
|
@@ -1314,7 +1641,8 @@ declare enum RTMErrorCode {
|
|
|
1314
1641
|
*
|
|
1315
1642
|
* @brief Stream connection failed. This error will be returned if the network connection fails or the server address is unreachable.
|
|
1316
1643
|
*/
|
|
1317
|
-
PUSH_CONNECT_FAILED = 2003
|
|
1644
|
+
PUSH_CONNECT_FAILED = 2003,
|
|
1645
|
+
AUDIO_RESUME_FAILED = 2004
|
|
1318
1646
|
}
|
|
1319
1647
|
|
|
1320
1648
|
declare type RTMEvents = {
|
|
@@ -1571,6 +1899,10 @@ declare type StatsSnapshoot = {
|
|
|
1571
1899
|
* @brief Encoded frames.
|
|
1572
1900
|
*/
|
|
1573
1901
|
framesEncoded: number;
|
|
1902
|
+
/** {zh}
|
|
1903
|
+
* @brief 编码的视频帧率
|
|
1904
|
+
*/
|
|
1905
|
+
framesEncodedPerSecond: number;
|
|
1574
1906
|
/** {zh}
|
|
1575
1907
|
* @brief 已编码的关键帧数。
|
|
1576
1908
|
*/
|
|
@@ -1651,6 +1983,10 @@ declare type StatsSnapshoot = {
|
|
|
1651
1983
|
* @brief Packet loss rate.
|
|
1652
1984
|
*/
|
|
1653
1985
|
packetsLostPercent: number;
|
|
1986
|
+
/** {zh}
|
|
1987
|
+
* @brief 计算周期
|
|
1988
|
+
*/
|
|
1989
|
+
deltaTime?: number;
|
|
1654
1990
|
};
|
|
1655
1991
|
audio?: {
|
|
1656
1992
|
/** {zh}
|