@byteplus/vepusher 2.0.4-rc.3 → 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.
@@ -1,28 +1,10 @@
1
- import { AudioTrack } from '@byted/ve-capture';
2
1
  import { default as default_2 } from 'eventemitter3';
3
- import { EventEmitter } from 'eventemitter3';
4
- import { MediaAudioTrack } from '@byted/ve-capture';
5
- import { MediaVideoTrack } from '@byted/ve-capture';
6
- import { PictureTrack } from '@byted/ve-capture';
7
- import { ScreenAudioTrack } from '@byted/ve-capture';
8
- import { ScreenVideoTrack } from '@byted/ve-capture';
9
- import { TrackSourceMixerNode } from '@byted/ve-capture';
10
- import { TrackSourceViewNode } from '@byted/ve-capture';
11
- import { VideoTrack } from '@byted/ve-capture';
12
- import { ViewConfig } from '@byted/ve-capture';
13
2
 
14
3
  declare enum AUDIO_DEFAULT_QUALITY {
15
4
  STANDARD = "48000x40",
16
5
  HIGH = "48000x128"
17
6
  }
18
7
 
19
- declare abstract class AudioStream extends Stream {
20
- abstract get mixerNode(): TrackSourceMixerNode | null;
21
- abstract destroy(): void;
22
- get isVideoStream(): boolean;
23
- get isAudioStream(): boolean;
24
- }
25
-
26
8
  /** {zh}
27
9
  * @detail config
28
10
  * @list config
@@ -74,22 +56,114 @@ declare type ConfigOptions = {
74
56
  /** {zh}
75
57
  * @brief 推流中断重试配置,包含是否开启,重试最大超时时间,不传入时默认开启断线重连,最大超时时间默认3分钟
76
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
+ */
77
62
  reconnectConfig?: {
78
63
  /** {zh}
79
- * @brief 是否开启断线重连
64
+ * @brief 是否开启断线重连。
65
+ */
66
+ /** {en}
67
+ * @brief Whether to enable reconnection after disconnection.
80
68
  */
81
69
  enable: boolean;
82
70
  /** {zh}
83
- * @brief 最大重试超时时间,单位为 s
71
+ * @brief 最大重试超时时间,单位为秒。
72
+ */
73
+ /** {en}
74
+ * @brief Maximum retry timeout time, in seconds.
84
75
  */
85
76
  maxTimeout?: number;
86
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;
87
130
  };
88
131
 
132
+ /** {zh}
133
+ * @detail events
134
+ * @brief 直播链接状态码
135
+ */
136
+ /** {en}
137
+ *
138
+ */
89
139
  declare enum ConnectionState {
140
+ /** {zh}
141
+ * @brief 断开连接,默认时断开连接。
142
+ */
143
+ /** {en}
144
+ * @brief Disconnected by default.
145
+ */
90
146
  DISCONNECTED = 0,
147
+ /** {zh}
148
+ * @brief 连接中。
149
+ */
150
+ /** {en}
151
+ * @brief Connecting.
152
+ */
91
153
  CONNECTING = 1,
154
+ /** {zh}
155
+ * @brief 已连接。
156
+ */
157
+ /** {en}
158
+ * @brief Connected.
159
+ */
92
160
  CONNECTED = 2,
161
+ /** {zh}
162
+ * @brief 重连中。
163
+ */
164
+ /** {en}
165
+ * @brief Reconnecting.
166
+ */
93
167
  RECONNECTING = 3,
94
168
  }
95
169
 
@@ -218,21 +292,31 @@ declare interface IProperty {
218
292
  */
219
293
  setVideoFps: number;
220
294
  /** {zh}
221
- * @brief 设置推流视频的码率,单位为 kbps。
295
+ * @deprecated
296
+ * @brief 设置推流视频的码率,单位为 bps。
222
297
  */
223
298
  /** {en}
224
- *
225
- * @brief Set the push stream video bitrate in kbps.
299
+ * @deprecated
300
+ * @brief Set the push stream video bitrate in bps.
226
301
  */
227
302
  setVideoBitrate: number;
228
303
  /** {zh}
229
- * @brief 设置推流时音频的码率,单位为 kbps。
304
+ * @brief 设置推流时视频的码率,单位为 kbps。
305
+ */
306
+ setVideoKBitrate: number;
307
+ /** {zh}
308
+ * @deprecated
309
+ * @brief 设置推流时音频的码率,单位为 bps。
230
310
  */
231
311
  /** {en}
232
- *
233
- * @brief Set the audio bitrate for push stream in kbps.
312
+ * @deprecated
313
+ * @brief Set the audio bitrate for push stream in bps.
234
314
  */
235
315
  setAudioBitrate: number;
316
+ /** {zh}
317
+ * @brief 设置推流时音频的码率,单位为 kbps。
318
+ */
319
+ setAudioKBitrate: number;
236
320
  /** {zh}
237
321
  * @brief 设置麦克风采集的采样率,单位为 Hz。
238
322
  */
@@ -260,9 +344,11 @@ declare interface IProperty {
260
344
  * @hidden
261
345
  * @brief 设置推流时默认采集的方向,默认是横屏
262
346
  */
263
- /**
264
- * {zh}
265
- * @brief 更新推流地址,作用:断线重连时会使用最新的推流地址,避免推流过程中推流地址超时
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.
266
352
  */
267
353
  updatePushUrl: string;
268
354
  }
@@ -354,6 +440,72 @@ declare interface IVideoStreamLayoutParams {
354
440
  mirrorType?: MirrorType;
355
441
  }
356
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
+
357
509
  /** {zh}
358
510
  * @detail api
359
511
  * @list api
@@ -369,6 +521,7 @@ declare class LivePusher extends default_2<RTMEvents> {
369
521
  private _streamComposeController;
370
522
  private _streamConsumeController;
371
523
  private _observer;
524
+ private _options;
372
525
  /** {zh}
373
526
  * @brief 查询是否支持 RTM 或 WebTransport 推流。
374
527
  * @param mode 推流模式。
@@ -773,7 +926,15 @@ declare class LivePusher extends default_2<RTMEvents> {
773
926
  * @param config Attributes of the mixing canvas, such as width, height, frame rate, etc.
774
927
  */
775
928
  setMixingConfig(config: IMixingViewConfig): void;
776
- getMixingConfig(): ViewConfig;
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;
777
938
  /** {zh}
778
939
  * @brief 设置视频的预览区域。本地视频会在指定的容器内进行预览,同时预览内容与推流的画面和声音完全一致。
779
940
  * @param containerId 用于指定预览区域的 HTML 容器元素 ID。
@@ -988,7 +1149,14 @@ declare class LivePusher extends default_2<RTMEvents> {
988
1149
  * @return 对应流的 `MediaStream` 对象,可用于本地渲染或其他处理。
989
1150
  */
990
1151
  getMediaStream(streamId: string): MediaStream;
991
- getStream(streamId: string): VideoStream | AudioStream;
1152
+ /** {zh}
1153
+ * @hidden
1154
+ * @brief 获取原始的Stream对象
1155
+ */
1156
+ /** {en}
1157
+ * @hidden
1158
+ */
1159
+ getStream(streamId: string): any;
992
1160
  /** {zh}
993
1161
  * @brief 停止推流。
994
1162
  * @return 返回 `Promise` 对象。
@@ -1037,15 +1205,7 @@ declare class LivePusher extends default_2<RTMEvents> {
1037
1205
  * @return `video` element of the preview screen.
1038
1206
  */
1039
1207
  getPreviewElement(): HTMLVideoElement | null | undefined;
1040
- getVideoStreamRenderConfig(streamId: string): {
1041
- width: number;
1042
- height: number;
1043
- paintWidth: number;
1044
- paintHeight: number;
1045
- x: number;
1046
- y: number;
1047
- zOrder: number;
1048
- } | undefined;
1208
+ getVideoStreamRenderConfig(streamId: string): IVideoStreamRenderConfig | undefined;
1049
1209
  private _bindEvent;
1050
1210
  /** {zh}
1051
1211
  * @brief 清理 SDK 实例,避免可能会产生的内存泄露。
@@ -1252,10 +1412,47 @@ declare class Observer implements IVePusherEvents {
1252
1412
  * @notes The callback will be triggered when stopping capture actively or when capture stops passively due to an internal error.
1253
1413
  */
1254
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
+ */
1255
1421
  onLiveConnectStateChange: (state: ConnectionState) => void;
1256
- onReconnectStateChange: (state: ReconnectState, params?: {
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
+ */
1257
1442
  failedCode?: ReconnectFailedCode;
1443
+ /** {zh}
1444
+ * @brief 重连等待中、重连中的当前重试次数。
1445
+ */
1446
+ /** {en}
1447
+ * @brief The current retry times in the waiting or reconnecting state.
1448
+ */
1258
1449
  retryTime?: number;
1450
+ /** {zh}
1451
+ * @brief 重连等待中的当前等待时间,单位为毫秒。
1452
+ */
1453
+ /** {en}
1454
+ * @brief The current waiting time in the waiting state, in milliseconds.
1455
+ */
1259
1456
  waitingTime?: number;
1260
1457
  }) => void;
1261
1458
  /** {zh}
@@ -1283,18 +1480,69 @@ declare class Observer implements IVePusherEvents {
1283
1480
  */
1284
1481
  declare type PushMode = 'rtm' | 'webTransport';
1285
1482
 
1483
+ /** {zh}
1484
+ * @detail events
1485
+ * @brief 重连重连失败码
1486
+ */
1286
1487
  declare enum ReconnectFailedCode {
1287
- // 推流地址失效,需要重新生成推流地址推流
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
+ */
1288
1494
  PushUrlInvalid = 1001,
1289
- // 重连超时
1495
+ /** {zh}
1496
+ * @brief 重连超时
1497
+ */
1498
+ /** {en}
1499
+ * @brief Reconnect timeout
1500
+ */
1290
1501
  ReconnectTimeout = 1002,
1291
1502
  }
1292
1503
 
1504
+ /** {zh}
1505
+ * @detail events
1506
+ * @brief 推流重连状态码
1507
+ */
1508
+ /** {en}
1509
+ *
1510
+ */
1293
1511
  declare enum ReconnectState {
1512
+ /** {zh}
1513
+ * @brief 重连开始。
1514
+ */
1515
+ /** {en}
1516
+ * @brief Reconnect start.
1517
+ */
1294
1518
  START = 1,
1519
+ /** {zh}
1520
+ * @brief 重连等待。
1521
+ */
1522
+ /** {en}
1523
+ * @brief Reconnect waiting.
1524
+ */
1295
1525
  WAITING = 2,
1526
+ /** {zh}
1527
+ * @brief 重连中。
1528
+ */
1529
+ /** {en}
1530
+ * @brief Reconnecting.
1531
+ */
1296
1532
  RECONNECTING = 3,
1533
+ /** {zh}
1534
+ * @brief 重连成功。
1535
+ */
1536
+ /** {en}
1537
+ * @brief Reconnect success.
1538
+ */
1297
1539
  SUCCESS = 4,
1540
+ /** {zh}
1541
+ * @brief 重连失败。
1542
+ */
1543
+ /** {en}
1544
+ * @brief Reconnect failed.
1545
+ */
1298
1546
  FAILED = 5,
1299
1547
  }
1300
1548
 
@@ -1393,7 +1641,8 @@ declare enum RTMErrorCode {
1393
1641
  *
1394
1642
  * @brief Stream connection failed. This error will be returned if the network connection fails or the server address is unreachable.
1395
1643
  */
1396
- PUSH_CONNECT_FAILED = 2003
1644
+ PUSH_CONNECT_FAILED = 2003,
1645
+ AUDIO_RESUME_FAILED = 2004
1397
1646
  }
1398
1647
 
1399
1648
  declare type RTMEvents = {
@@ -1650,6 +1899,10 @@ declare type StatsSnapshoot = {
1650
1899
  * @brief Encoded frames.
1651
1900
  */
1652
1901
  framesEncoded: number;
1902
+ /** {zh}
1903
+ * @brief 编码的视频帧率
1904
+ */
1905
+ framesEncodedPerSecond: number;
1653
1906
  /** {zh}
1654
1907
  * @brief 已编码的关键帧数。
1655
1908
  */
@@ -1730,6 +1983,10 @@ declare type StatsSnapshoot = {
1730
1983
  * @brief Packet loss rate.
1731
1984
  */
1732
1985
  packetsLostPercent: number;
1986
+ /** {zh}
1987
+ * @brief 计算周期
1988
+ */
1989
+ deltaTime?: number;
1733
1990
  };
1734
1991
  audio?: {
1735
1992
  /** {zh}
@@ -1791,62 +2048,6 @@ declare type StatsSnapshoot = {
1791
2048
  };
1792
2049
  };
1793
2050
 
1794
- declare abstract class Stream extends EventEmitter<StreamEvents> {
1795
- type: StreamType;
1796
- id: string;
1797
- protected _volumeDetector?: VolumeDetect | null;
1798
- protected _width: number;
1799
- protected _height: number;
1800
- protected _mediaStream: MediaStream | null;
1801
- protected _source?: MediaStream | MediaStreamTrack | VideoTrack | MediaVideoTrack | MediaAudioTrack | ScreenVideoTrack | ScreenAudioTrack | AudioTrack | PictureTrack | Array<MediaVideoTrack | MediaAudioTrack> | Array<ScreenVideoTrack | ScreenAudioTrack>;
1802
- protected _nextStream: Stream | null;
1803
- protected _trackMap: {
1804
- video?: MediaStreamTrack;
1805
- audio?: MediaStreamTrack;
1806
- };
1807
- constructor(params: {
1808
- type: StreamType;
1809
- stream: MediaStream | MediaStreamTrack | VideoTrack | MediaVideoTrack | MediaAudioTrack | ScreenVideoTrack | ScreenAudioTrack | AudioTrack | PictureTrack | Array<MediaVideoTrack | MediaAudioTrack> | Array<ScreenVideoTrack | ScreenAudioTrack>;
1810
- });
1811
- get source(): MediaStreamTrack | AudioTrack | MediaStream | MediaAudioTrack | ScreenAudioTrack | VideoTrack | PictureTrack | ScreenVideoTrack | MediaVideoTrack | (ScreenAudioTrack | ScreenVideoTrack)[] | (MediaAudioTrack | MediaVideoTrack)[] | undefined;
1812
- get videoTrack(): MediaStreamTrack | undefined;
1813
- get audioTrack(): MediaStreamTrack | undefined;
1814
- get width(): number;
1815
- get height(): number;
1816
- get isVideoStream(): boolean;
1817
- get mediaStream(): MediaStream;
1818
- abstract bindTrackEnd(callback: () => void): void;
1819
- startVolumeDetect(): Promise<void>;
1820
- stopVolumeDetect(): void;
1821
- get volume(): number;
1822
- }
1823
-
1824
- declare type StreamEvents = {
1825
- [StreamEventTypes.SizeChange]: ({ width, height, }: {
1826
- width: number;
1827
- height: number;
1828
- }) => void;
1829
- };
1830
-
1831
- declare const StreamEventTypes: {
1832
- readonly SizeChange: "sizeChange";
1833
- };
1834
-
1835
- declare type StreamEventTypes = typeof StreamEventTypes;
1836
-
1837
- declare enum StreamType {
1838
- Camera = "camera",
1839
- Screen = "screen",
1840
- VideoFile = "videoFile",
1841
- Microphone = "microphone",
1842
- AudioFile = "audioFile",
1843
- Image = "image",
1844
- MixAudio = "mixAudio",
1845
- MixVideo = "mixVideo",
1846
- CustomVideo = "customVideo",
1847
- CustomAudio = "customAudio"
1848
- }
1849
-
1850
2051
  /** {zh}
1851
2052
  * @detail config
1852
2053
  * @brief 内置的推流视频质量。
@@ -1931,21 +2132,4 @@ declare enum VIDEO_DEFAULT_QUALITY {
1931
2132
  '1080p-3' = "1920x1080x30x3150"
1932
2133
  }
1933
2134
 
1934
- declare abstract class VideoStream extends Stream {
1935
- abstract get viewNode(): TrackSourceViewNode | null;
1936
- abstract get mixerNode(): TrackSourceMixerNode | null;
1937
- abstract destroy(): void;
1938
- get isVideoStream(): boolean;
1939
- get isAudioStream(): boolean;
1940
- protected bindTrackSizeChangeEvent(stream: VideoTrack): void;
1941
- }
1942
-
1943
- declare class VolumeDetect {
1944
- _audioCtx: AudioContext | null;
1945
- _volume: number;
1946
- get volume(): number;
1947
- start(audioTrack: MediaStreamTrack, workletUrl?: string): Promise<void>;
1948
- stop(): void;
1949
- }
1950
-
1951
2135
  export { }