@byteplus/vepusher 1.1.1-rc.0 → 2.0.1-rc.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/dist/index.es.d.ts +1768 -0
- package/dist/index.es.js +8301 -0
- package/dist/index.umd.js +93 -0
- package/package.json +9 -12
- package/LICENSE +0 -20
- package/README.md +0 -18
- package/dist/vepusher.es.js +0 -34248
- package/dist/vepusher.umd.js +0 -123
- package/es/capture.d.ts +0 -35
- package/es/connect.d.ts +0 -4
- package/es/constant.d.ts +0 -9
- package/es/device.d.ts +0 -25
- package/es/index.d.ts +0 -20
- package/es/interface/index.d.ts +0 -21
- package/es/observer.d.ts +0 -15
- package/es/pusher.d.ts +0 -19
- package/es/rtm.d.ts +0 -3
- package/es/state.d.ts +0 -34
- package/es/utils/convertToRTCDevice.d.ts +0 -4
- package/es/utils/http.d.ts +0 -0
- package/es/utils/logger.d.ts +0 -0
- package/es/videoMixing.d.ts +0 -0
|
@@ -0,0 +1,1768 @@
|
|
|
1
|
+
import { default as default_2 } from 'eventemitter3';
|
|
2
|
+
|
|
3
|
+
declare enum AUDIO_DEFAULT_QUALITY {
|
|
4
|
+
STANDARD = "48000x40",
|
|
5
|
+
HIGH = "48000x128"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** {zh}
|
|
9
|
+
* @detail config
|
|
10
|
+
* @list config
|
|
11
|
+
* @brief 推流 SDK 的初始化配置项,用于指定超时、重试次数、间隔时间以及推流模式。
|
|
12
|
+
* @id ConfigOptions
|
|
13
|
+
* @name ConfigOptions
|
|
14
|
+
*/
|
|
15
|
+
/** {en}
|
|
16
|
+
* @detail config
|
|
17
|
+
* @list config
|
|
18
|
+
* @brief The initialization configuration options for BytePlus MediaLive Broadcast SDK specify the timeout, retry attempts, interval duration, and streaming mode.
|
|
19
|
+
*/
|
|
20
|
+
declare type ConfigOptions = {
|
|
21
|
+
/** {zh}
|
|
22
|
+
* @brief 请求推流地址的超时时间,单位为 ms。
|
|
23
|
+
*/
|
|
24
|
+
/** {en}
|
|
25
|
+
*
|
|
26
|
+
* @brief The timeout for requesting the push stream address, in milliseconds.
|
|
27
|
+
*/
|
|
28
|
+
timeout?: number;
|
|
29
|
+
/** {zh}
|
|
30
|
+
* @brief 请求推流地址失败后的重试次数。
|
|
31
|
+
*/
|
|
32
|
+
/** {en}
|
|
33
|
+
*
|
|
34
|
+
* @brief The number of retry attempts after failing to request the push stream address.
|
|
35
|
+
*/
|
|
36
|
+
retryCount?: number;
|
|
37
|
+
/** {zh}
|
|
38
|
+
* @brief 重试请求推流地址的间隔时间,单位为 ms。
|
|
39
|
+
*/
|
|
40
|
+
/** {en}
|
|
41
|
+
*
|
|
42
|
+
* @brief Interval time for retrying the request for the push stream address, in milliseconds (ms).
|
|
43
|
+
*/
|
|
44
|
+
retryDelay?: number;
|
|
45
|
+
/** {zh}
|
|
46
|
+
* @brief 默认的推流方式。
|
|
47
|
+
* - `rtm`:RTM 协议推流。
|
|
48
|
+
* - `webTransport`:WebTransport 协议推流。
|
|
49
|
+
*/
|
|
50
|
+
/** {en}
|
|
51
|
+
* @brief Default streaming method.
|
|
52
|
+
* - `rtm`: Streaming with RTM protocol.
|
|
53
|
+
* - `webTransport`: Streaming with WebTransport protocol.
|
|
54
|
+
*/
|
|
55
|
+
mode?: PushMode;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** {zh}
|
|
59
|
+
* @detail config
|
|
60
|
+
* @list config
|
|
61
|
+
* @brief 混音时音频流的配置信息。
|
|
62
|
+
*/
|
|
63
|
+
/** {en}
|
|
64
|
+
* @detail config
|
|
65
|
+
* @list config
|
|
66
|
+
* @brief Configuration information of the audio stream during mixing.
|
|
67
|
+
*/
|
|
68
|
+
declare interface IAudioStreamLayoutParams {
|
|
69
|
+
/** {zh}
|
|
70
|
+
* @brief 音频流的 ID。
|
|
71
|
+
*/
|
|
72
|
+
/** {en}
|
|
73
|
+
*
|
|
74
|
+
* @brief The ID of the audio stream.
|
|
75
|
+
*/
|
|
76
|
+
streamId: string;
|
|
77
|
+
/** {zh}
|
|
78
|
+
* @brief 音频流的音量,取值范围为 `[0,100]`。
|
|
79
|
+
*/
|
|
80
|
+
/** {en}
|
|
81
|
+
*
|
|
82
|
+
* @brief The volume of the audio stream ranges from `[0,100]`.
|
|
83
|
+
*/
|
|
84
|
+
volume?: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** {zh}
|
|
88
|
+
* @detail config
|
|
89
|
+
* @list config
|
|
90
|
+
* @brief 合流画布的基本信息,如尺寸、帧率、背景色等。
|
|
91
|
+
*/
|
|
92
|
+
/** {en}
|
|
93
|
+
* @detail config
|
|
94
|
+
* @list config
|
|
95
|
+
* @brief Basic information of the merge canvas, such as dimensions, frame rate, background color, etc.
|
|
96
|
+
*/
|
|
97
|
+
declare interface IMixingViewConfig {
|
|
98
|
+
/** {zh}
|
|
99
|
+
* @brief 合流画布的宽度。
|
|
100
|
+
*/
|
|
101
|
+
/** {en}
|
|
102
|
+
*
|
|
103
|
+
* @brief The width of the merge canvas.
|
|
104
|
+
*/
|
|
105
|
+
width?: number;
|
|
106
|
+
/** {zh}
|
|
107
|
+
* @brief 合流画布的高度。
|
|
108
|
+
*/
|
|
109
|
+
/** {en}
|
|
110
|
+
*
|
|
111
|
+
* @brief The height of the merge canvas.
|
|
112
|
+
*/
|
|
113
|
+
height?: number;
|
|
114
|
+
/** {zh}
|
|
115
|
+
* @brief 合流画布的帧率,单位为 fps。建议将 `frameRate` 设置为 15fps 或更高,以保证画面的流畅度。
|
|
116
|
+
*/
|
|
117
|
+
/** {en}
|
|
118
|
+
*
|
|
119
|
+
* @brief The frame rate of the merge canvas, measured in fps. It is recommended to set `frameRate` to 15 fps or higher to ensure smoothness.
|
|
120
|
+
*/
|
|
121
|
+
frameRate?: number;
|
|
122
|
+
/** {zh}
|
|
123
|
+
* @brief 合流画布的背景颜色,默认为黑色。
|
|
124
|
+
*/
|
|
125
|
+
/** {en}
|
|
126
|
+
*
|
|
127
|
+
* @brief The background color of the merge canvas, which defaults to black.
|
|
128
|
+
*/
|
|
129
|
+
backgroundColor?: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** {zh}
|
|
133
|
+
* @detail api
|
|
134
|
+
* @brief 用于精细化设置推流 SDK 内部的配置,包括视频采集分辨率、帧率以及音频相关参数等。
|
|
135
|
+
* @notes 设置视频分辨率为 1920×1080,帧率为 30,代码示例:
|
|
136
|
+
* ```js
|
|
137
|
+
* livePusher.setProperty('setVideoResolution', { width: 1920, height: 1080 });
|
|
138
|
+
* livePusher.setProperty('setVideoFps', 30);
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
/** {en}
|
|
142
|
+
* @detail api
|
|
143
|
+
* @brief Used for fine-tuning the internal configurations of the streaming SDK, including video capture resolution, frame rate, and audio-related parameters.
|
|
144
|
+
* @notes Set the video resolution to 1920×1080, frame rate to 30. Code example:
|
|
145
|
+
* ```js
|
|
146
|
+
* livePusher.setProperty('setVideoResolution', { width: 1920, height: 1080 });
|
|
147
|
+
* livePusher.setProperty('setVideoFps', 30);
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
declare interface IProperty {
|
|
151
|
+
/** {zh}
|
|
152
|
+
* @brief 设置视频采集的分辨率。
|
|
153
|
+
*/
|
|
154
|
+
/** {en}
|
|
155
|
+
*
|
|
156
|
+
* @brief Set the video capture resolution.
|
|
157
|
+
*/
|
|
158
|
+
setVideoResolution: {
|
|
159
|
+
/** {zh}
|
|
160
|
+
* @brief 分辨率宽度。
|
|
161
|
+
*/
|
|
162
|
+
/** {en}
|
|
163
|
+
* @brief Width.
|
|
164
|
+
*/
|
|
165
|
+
width: number;
|
|
166
|
+
/** {zh}
|
|
167
|
+
* @brief 分辨率高度。
|
|
168
|
+
*/
|
|
169
|
+
/** {en}
|
|
170
|
+
* @brief Height.
|
|
171
|
+
*/
|
|
172
|
+
height: number;
|
|
173
|
+
};
|
|
174
|
+
/** {zh}
|
|
175
|
+
* @brief 设置视频采集的帧率。
|
|
176
|
+
*/
|
|
177
|
+
/** {en}
|
|
178
|
+
*
|
|
179
|
+
* @brief Set the frame rate for video capture.
|
|
180
|
+
*/
|
|
181
|
+
setVideoFps: number;
|
|
182
|
+
/** {zh}
|
|
183
|
+
* @brief 设置推流视频的码率,单位为 kbps。
|
|
184
|
+
*/
|
|
185
|
+
/** {en}
|
|
186
|
+
*
|
|
187
|
+
* @brief Set the push stream video bitrate in kbps.
|
|
188
|
+
*/
|
|
189
|
+
setVideoBitrate: number;
|
|
190
|
+
/** {zh}
|
|
191
|
+
* @brief 设置推流时音频的码率,单位为 kbps。
|
|
192
|
+
*/
|
|
193
|
+
/** {en}
|
|
194
|
+
*
|
|
195
|
+
* @brief Set the audio bitrate for push stream in kbps.
|
|
196
|
+
*/
|
|
197
|
+
setAudioBitrate: number;
|
|
198
|
+
/** {zh}
|
|
199
|
+
* @brief 设置麦克风采集的采样率,单位为 Hz。
|
|
200
|
+
*/
|
|
201
|
+
/** {en}
|
|
202
|
+
*
|
|
203
|
+
* @brief Set the microphone sampling rate in Hz.
|
|
204
|
+
*/
|
|
205
|
+
setAudioSampleRate: number;
|
|
206
|
+
/** {zh}
|
|
207
|
+
* @brief 设置推流模式。
|
|
208
|
+
*/
|
|
209
|
+
/** {en}
|
|
210
|
+
*
|
|
211
|
+
* @brief Set push stream mode.
|
|
212
|
+
*/
|
|
213
|
+
setPushMode: PushMode;
|
|
214
|
+
/**
|
|
215
|
+
* @hidden
|
|
216
|
+
*/
|
|
217
|
+
/** {en}
|
|
218
|
+
*
|
|
219
|
+
*/
|
|
220
|
+
setVolumeDetectScriptUrl: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare type IVePusherEvents = {
|
|
224
|
+
onError: (code: number, msg: string, extraInfo?: any) => void
|
|
225
|
+
onWarning: (msg: string) => void
|
|
226
|
+
onCaptureFirstAudioFrame: () => void
|
|
227
|
+
onCaptureFirstVideoFrame: () => void
|
|
228
|
+
onPushStatusUpdate: (status: number, msg: string) => void
|
|
229
|
+
onMicrophoneChanged: (changedDevice: MediaDeviceInfo) => void
|
|
230
|
+
onCameraChanged: (changedDevice: MediaDeviceInfo) => void
|
|
231
|
+
onStopCapture: (streamId: string) => void
|
|
232
|
+
onCaptureInterrupted: (streamId: string) => void
|
|
233
|
+
onPushStart: () => void
|
|
234
|
+
onPushStop: () => void
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** {zh}
|
|
238
|
+
* @detail config
|
|
239
|
+
* @list config
|
|
240
|
+
* @brief 合流视频源配置信息
|
|
241
|
+
*/
|
|
242
|
+
/** {en}
|
|
243
|
+
* @detail config
|
|
244
|
+
* @list config
|
|
245
|
+
* @brief Configuration Information for Merged Video Sources
|
|
246
|
+
*/
|
|
247
|
+
declare interface IVideoStreamLayoutParams {
|
|
248
|
+
/** {zh}
|
|
249
|
+
* @brief 布局的 x 坐标,单位为 px。
|
|
250
|
+
*/
|
|
251
|
+
/** {en}
|
|
252
|
+
* @brief The x coordinate of the layout, measured in px.
|
|
253
|
+
*/
|
|
254
|
+
x: number;
|
|
255
|
+
/** {zh}
|
|
256
|
+
* @brief 布局的 y 坐标,单位为 px。
|
|
257
|
+
*/
|
|
258
|
+
/** {en}
|
|
259
|
+
* @brief The y-coordinate of the layout, in px.
|
|
260
|
+
*/
|
|
261
|
+
y: number;
|
|
262
|
+
/** {zh}
|
|
263
|
+
* @brief 布局的宽度,单位为 px。
|
|
264
|
+
*/
|
|
265
|
+
/** {en}
|
|
266
|
+
* @brief The width of the layout, measured in px.
|
|
267
|
+
*/
|
|
268
|
+
width: number;
|
|
269
|
+
/** {zh}
|
|
270
|
+
* @brief 布局的高度,单位为 px。
|
|
271
|
+
*/
|
|
272
|
+
/** {en}
|
|
273
|
+
* @brief The height of the layout, in px.
|
|
274
|
+
*/
|
|
275
|
+
height: number;
|
|
276
|
+
/** {zh}
|
|
277
|
+
* @brief 布局的层级,值越大越靠上。
|
|
278
|
+
*/
|
|
279
|
+
/** {en}
|
|
280
|
+
* @brief The higher the layout level, the more it will be on top.
|
|
281
|
+
*/
|
|
282
|
+
zOrder: number;
|
|
283
|
+
/** {zh}
|
|
284
|
+
* @brief 是否保持宽高比。
|
|
285
|
+
*/
|
|
286
|
+
/** {en}
|
|
287
|
+
* @brief Whether to maintain the aspect ratio.
|
|
288
|
+
*/
|
|
289
|
+
keepRatio?: boolean;
|
|
290
|
+
/** {zh}
|
|
291
|
+
* @brief 视频流的 ID。
|
|
292
|
+
*/
|
|
293
|
+
/** {en}
|
|
294
|
+
* @brief The ID of the video stream.
|
|
295
|
+
*/
|
|
296
|
+
streamId: string;
|
|
297
|
+
/** {zh}
|
|
298
|
+
* @brief 当视频流包含音频内容,对应音频的音量,取值范围为 `[0,100]`。
|
|
299
|
+
*/
|
|
300
|
+
/** {en}
|
|
301
|
+
* @brief When the video stream contains audio content, the corresponding audio volume ranges from `[0,100]`.
|
|
302
|
+
*/
|
|
303
|
+
volume?: number;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** {zh}
|
|
307
|
+
* @detail api
|
|
308
|
+
* @list api
|
|
309
|
+
* @brief 推流 SDK 的核心类,用于管理音视频采集、合流、推流等。
|
|
310
|
+
*/
|
|
311
|
+
/** {en}
|
|
312
|
+
* @detail api
|
|
313
|
+
* @list api
|
|
314
|
+
* @brief The core class of the BytePlus MediaLive Broadcast SDK, handling audio/video capture, local mixing, and streaming.
|
|
315
|
+
*/
|
|
316
|
+
declare class LivePusher extends default_2<RTMEvents> {
|
|
317
|
+
private _streamManagerController;
|
|
318
|
+
private _streamComposeController;
|
|
319
|
+
private _streamConsumeController;
|
|
320
|
+
private _observer;
|
|
321
|
+
/** {zh}
|
|
322
|
+
* @brief 查询是否支持 RTM 或 WebTransport 推流。
|
|
323
|
+
* @param mode 推流模式。
|
|
324
|
+
* - `rtm`:表示查询是否支持 RTM 推流。
|
|
325
|
+
* - `webTransport`:表示查询是否支持 WebTransport 推流。
|
|
326
|
+
* @return
|
|
327
|
+
* - `true`:支持该推流模式。
|
|
328
|
+
* - `false`:不支持该推流模式。
|
|
329
|
+
*/
|
|
330
|
+
/** {en}
|
|
331
|
+
* @return - `true`: The specified streaming mode is supported.
|
|
332
|
+
* - `false`: The specified streaming mode is not supported.
|
|
333
|
+
*/
|
|
334
|
+
static isSupported(mode: PushMode): Promise<boolean>;
|
|
335
|
+
/** {zh}
|
|
336
|
+
* @brief 创建一个新的 `LivePusher` 实例。
|
|
337
|
+
* @param options 配置选项,定义推流相关的参数。
|
|
338
|
+
* @return LivePusher 实例。
|
|
339
|
+
*/
|
|
340
|
+
/** {en}
|
|
341
|
+
* @brief Create a new `LivePusher` instance.
|
|
342
|
+
* @param options Configuration options defining parameters for push streaming.
|
|
343
|
+
* @return LivePusher instance.
|
|
344
|
+
*/
|
|
345
|
+
constructor(options?: ConfigOptions);
|
|
346
|
+
/** {zh}
|
|
347
|
+
* @brief 获取设备列表,包括音频输入设备和视频输入设备。
|
|
348
|
+
* @param kind 指定设备类型,不传时默认获取所有设备。
|
|
349
|
+
* - `audioinput`:音频输入设备。
|
|
350
|
+
* - `videoinput`:视频输入设备。
|
|
351
|
+
* @return - 成功:返回包含 [`MediaDeviceInfo`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo) 对象的数组,每个对象表示一个音频输入设备或视频输入设备的详细信息。
|
|
352
|
+
* - 失败:返回错误信息。
|
|
353
|
+
*/
|
|
354
|
+
/** {en}
|
|
355
|
+
*
|
|
356
|
+
* @brief Retrieves the list of available audio input and video input devices.
|
|
357
|
+
* @param kind Specify the device type. If omitted, returns all available devices.
|
|
358
|
+
* - `audioinput`: Audio input device.
|
|
359
|
+
* - `videoinput`: Video input device.
|
|
360
|
+
* @return - `Success`: Returns an array of [`MediaDeviceInfo`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo) objects, each representing detailed information about an audio input device or a video input device.
|
|
361
|
+
* - `Failure`: Returns an error message.
|
|
362
|
+
*/
|
|
363
|
+
getDevicesList(kind?: 'audioinput' | 'videoinput'): Promise<MediaDeviceInfo[]>;
|
|
364
|
+
/** {zh}
|
|
365
|
+
* @brief 获取摄像头设备列表。
|
|
366
|
+
* @return - 成功:返回包含 [`MediaDeviceInfo`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo) 对象的数组,每个对象表示一个视频输入设备(摄像头)。
|
|
367
|
+
* - 失败:返回错误信息。
|
|
368
|
+
*/
|
|
369
|
+
/** {en}
|
|
370
|
+
*
|
|
371
|
+
* @brief Get the list of camera devices.
|
|
372
|
+
* @return - **Success**: Returns an array of [`MediaDeviceInfo`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo) objects, each representing a camera device.
|
|
373
|
+
* - **Failure**: Returns an error message.
|
|
374
|
+
*/
|
|
375
|
+
getCameras(): Promise<MediaDeviceInfo[]>;
|
|
376
|
+
/** {zh}
|
|
377
|
+
* @brief 获取麦克风设备列表。
|
|
378
|
+
* @return - 成功:返回返回一个包含 [`MediaDeviceInfo`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo) 对象的数组,每个对象表示一个音频输入设备(麦克风)。
|
|
379
|
+
* - 失败:返回错误信息。
|
|
380
|
+
*/
|
|
381
|
+
/** {en}
|
|
382
|
+
*
|
|
383
|
+
* @brief Retrieve available microphone devices.
|
|
384
|
+
* @return - **Success**: Returns an array of [`MediaDeviceInfo`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo) objects, each representing a microphone device.
|
|
385
|
+
* - **Failure**: Returns an error message.
|
|
386
|
+
*/
|
|
387
|
+
getMicrophones(): Promise<MediaDeviceInfo[]>;
|
|
388
|
+
/** {zh}
|
|
389
|
+
* @brief 启动摄像头视频采集。
|
|
390
|
+
* @param deviceId 指定要启动采集的摄像头设备 ID,可以通过 [`getDevicesList`](#livepusher-getdeviceslist) 或 [`getCameras`](#livepusher-getcameras) 获取。
|
|
391
|
+
*
|
|
392
|
+
* 移动端支持传入 `user` 和 `environment`。
|
|
393
|
+
* - `user`:获取前置摄像头。
|
|
394
|
+
* - `environment`:获取后置摄像头。
|
|
395
|
+
* @notes 如果主播未授权访问摄像头,会抛出权限错误。
|
|
396
|
+
* @return 返回 `Promise` 对象。
|
|
397
|
+
* - 成功:返回采集的流 ID,流 ID 作为合流、停止采集的参数使用。
|
|
398
|
+
* - 失败:返回错误信息。
|
|
399
|
+
*/
|
|
400
|
+
/** {en}
|
|
401
|
+
*
|
|
402
|
+
* @brief Start camera video capture.
|
|
403
|
+
* @param deviceId Specify the camera device ID to start capturing. You can obtain it using [`getDevicesList`](#livepusher-getdeviceslist) or [`getCameras`](#livepusher-getcameras).
|
|
404
|
+
* On mobile devices, you can pass `user` or `environment`:
|
|
405
|
+
* - `user`: Access the front camera.
|
|
406
|
+
* - `environment`: Access the rear camera.
|
|
407
|
+
* @notes If camera permission is denied, an error will be thrown.
|
|
408
|
+
* @return Returns a `Promise` object.
|
|
409
|
+
* - **Success**: Returns the captured stream ID, which is used as a parameter for mixing and stopping the capture.
|
|
410
|
+
* - **Failure**: Returns an error message.
|
|
411
|
+
*/
|
|
412
|
+
startCamera(deviceId?: string): Promise<string>;
|
|
413
|
+
/** {zh}
|
|
414
|
+
* @brief 停止摄像头视频采集。
|
|
415
|
+
* @param streamId 指定需要停止采集的流 ID,在成功调用 [`startCamera`](#livepusher-startcamera) 时返回。不传时默认停止所有摄像头采集。
|
|
416
|
+
*/
|
|
417
|
+
/** {en}
|
|
418
|
+
*
|
|
419
|
+
* @brief Stop video capture from the camera.
|
|
420
|
+
* @param streamId Specify the stream ID returned by [`startCamera`](#livepusher-startcamera) to stop capturing. If omitted, stops all camera captures.
|
|
421
|
+
*/
|
|
422
|
+
stopCamera(streamId?: string): void;
|
|
423
|
+
/** {zh}
|
|
424
|
+
* @brief 启动麦克风音频采集。
|
|
425
|
+
* @param deviceId 指定需要启动采集的设备 ID,可以通过 [`getDevicesList`](#livepusher-getdeviceslist) 或 [`getMicrophones`](#livepusher-getmicrophones) 获取。
|
|
426
|
+
* @notes 如果主播未授予麦克风权限,会抛出权限错误。
|
|
427
|
+
* @return 返回 `Promise` 对象。
|
|
428
|
+
* - 成功:返回采集的流 ID,流 ID 作为混音、停止采集的参数使用。
|
|
429
|
+
* - 失败:返回错误信息。
|
|
430
|
+
*/
|
|
431
|
+
/** {en}
|
|
432
|
+
*
|
|
433
|
+
* @brief Start microphone audio capture.
|
|
434
|
+
* @param deviceId Specify the device ID to start capturing, which can be obtained using [`getDevicesList`](#livepusher-getdeviceslist) or [`getMicrophones`](#livepusher-getmicrophones).
|
|
435
|
+
* @notes If the host has not granted microphone permission, a permission error will be thrown.
|
|
436
|
+
* @return Returns a `Promise` object.
|
|
437
|
+
* - **Success**: Returns the captured stream ID, which is used as a parameter for mixing and stopping the capture.
|
|
438
|
+
* - **Failure**: Returns an error message.
|
|
439
|
+
*/
|
|
440
|
+
startMicrophone(deviceId?: string): Promise<string>;
|
|
441
|
+
/** {zh}
|
|
442
|
+
* @brief 停止麦克风音频采集。
|
|
443
|
+
* @param streamId 指定需要停止采集的流 ID,在成功调用 [`startMicrophone`](#livepusher-startmicrophone) 时返回。不传时默认停止所有麦克风采集。
|
|
444
|
+
*/
|
|
445
|
+
/** {en}
|
|
446
|
+
*
|
|
447
|
+
* @brief Stop microphone audio capture.
|
|
448
|
+
* @param streamId The stream ID returned by [`startMicrophone`](#livepusher-startmicrophone). If omitted, stops all microphone captures.
|
|
449
|
+
*/
|
|
450
|
+
stopMicrophone(streamId?: string): void;
|
|
451
|
+
/** {zh}
|
|
452
|
+
* @brief 启动视频文件采集。
|
|
453
|
+
* @param url 视频文件的 URL,支持在线地址或 Blob URL。
|
|
454
|
+
* - 在线地址:指互联网上公开可访问的视频文件 URL,例如,`https://example.com/video.mp4`。
|
|
455
|
+
* - Blob URL:指通过浏览器 Blob 对象动态生成的临时地址,例如,`blob:http://example.com/abc1234`。
|
|
456
|
+
* @notes 暂时仅支持 Chrome 浏览器采集。
|
|
457
|
+
* @return 返回 `Promise` 对象。
|
|
458
|
+
* - 成功:返回采集的流 ID,该流 ID 可用于合流或停止采集。
|
|
459
|
+
* - 失败:返回错误信息。
|
|
460
|
+
*/
|
|
461
|
+
/** {en}
|
|
462
|
+
*
|
|
463
|
+
* @brief Start video file capture.
|
|
464
|
+
* @param url The URL of the video file, supporting both online URLs and Blob URLs.
|
|
465
|
+
* - **Online URL**: A publicly accessible video file URL on the internet, e.g., `https://example.com/video.mp4`.
|
|
466
|
+
* - **Blob URL**: A temporary address dynamically generated using the browser's Blob object, e.g., `blob:http://example.com/abc1234`.
|
|
467
|
+
* @notes Currently, only Google Chrome is supported for data capture.
|
|
468
|
+
* @return Returns a `Promise` object.
|
|
469
|
+
* - ** Success**: Returns the captured stream ID, which can be used for merging or stopping the capture.
|
|
470
|
+
* - ** Failure**: Returns an error object.
|
|
471
|
+
*/
|
|
472
|
+
startVideoFileCapture(url: string): Promise<string | undefined>;
|
|
473
|
+
/** {zh}
|
|
474
|
+
* @brief 停止视频文件采集。
|
|
475
|
+
* @param streamId 指定需要停止采集的流 ID,在成功调用 [`startVideoFileCapture`](#livepusher-startvideofilecapture) 时返回。不传时默认停止所有视频文件采集。
|
|
476
|
+
*/
|
|
477
|
+
/** {en}
|
|
478
|
+
*
|
|
479
|
+
* @brief Stop video file capture.
|
|
480
|
+
* @param streamId The captured stream ID, which is the return value of [`startVideoFileCapture`](#livepusher-startvideofilecapture). If streamId is not provided, all video file captures will be stopped by default.
|
|
481
|
+
*/
|
|
482
|
+
stopVideoFileCapture(streamId?: string): void;
|
|
483
|
+
/** {zh}
|
|
484
|
+
* @brief 启动屏幕采集。
|
|
485
|
+
* @param audio 是否采集系统声音或者标签⻚声音。
|
|
486
|
+
* - `true`:采集。
|
|
487
|
+
* - `false`:不采集。
|
|
488
|
+
* @notes - 屏幕声音采集功能仅在 Chrome 74+ 和 Edge 79+ 浏览器版本中可用。
|
|
489
|
+
* - 详细信息请参考 [`getDisplayMedia()`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia#browser_compatibility) 获取浏览器兼容性。
|
|
490
|
+
* @return 返回 `Promise` 对象。
|
|
491
|
+
* - 成功:返回采集的流 ID,流 ID 作为合流、停止采集的参数使用。
|
|
492
|
+
* - 失败:返回错误信息。
|
|
493
|
+
*/
|
|
494
|
+
/** {en}
|
|
495
|
+
*
|
|
496
|
+
* @brief Start screen capture.
|
|
497
|
+
* @param audio Whether to capture system or tab sound.
|
|
498
|
+
* - `true`: Capture sound.
|
|
499
|
+
* - `false`: Do not capture sound.
|
|
500
|
+
* @notes - Screen sound capture function is only available in Chrome 74+ and Edge 79+ browser versions.
|
|
501
|
+
* - For more details, please refer to [`getDisplayMedia()`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia#browser_compatibility) for browser compatibility.
|
|
502
|
+
* @return Returns a `Promise` object.
|
|
503
|
+
* - ** Success**: Returns the captured stream ID, which is used as a parameter for stream mixing and stopping capture.
|
|
504
|
+
* - ** Failure**: Returns an error object.
|
|
505
|
+
*/
|
|
506
|
+
startScreenCapture(audio?: boolean): Promise<string>;
|
|
507
|
+
/** {zh}
|
|
508
|
+
* @brief 停止屏幕采集。
|
|
509
|
+
* @param streamId 指定需要停止采集的流 ID,在成功调用 [`startScreenCapture`](#livepusher-startscreencapture) 时返回。不传时默认停止所有屏幕采集。
|
|
510
|
+
*/
|
|
511
|
+
/** {en}
|
|
512
|
+
*
|
|
513
|
+
* @brief Stop screen capture.
|
|
514
|
+
* @param streamId The captured stream ID. The stream ID corresponds to the return value of [`startScreenCapture`](#livepusher-startscreencapture). If streamId is not provided, it will stop the capture of all screens by default.
|
|
515
|
+
*/
|
|
516
|
+
stopScreenCapture(streamId?: string): void;
|
|
517
|
+
/** {zh}
|
|
518
|
+
* @brief 启动音频文件采集。
|
|
519
|
+
* @notes 暂时仅支持 Chrome 浏览器采集。
|
|
520
|
+
* @param url 音频文件的 URL。支持文件在线地址和 Blob URL。
|
|
521
|
+
* - 在线地址:指互联网上公开可访问的音频文件 URL,例如,`https://example.com/audio-file.mp3`。
|
|
522
|
+
* - Blob URL:指通过浏览器 Blob 对象动态生成的临时地址,例如,`blob:http://example.com/71d7a6d8`。
|
|
523
|
+
* @return 返回 `Promise` 对象。
|
|
524
|
+
* - 成功:返回采集的流 ID,流 ID 可以作为混音、停止采集的参数使用。
|
|
525
|
+
* - 失败:返回错误信息。
|
|
526
|
+
*/
|
|
527
|
+
/** {en}
|
|
528
|
+
*
|
|
529
|
+
* @brief Start audio file capture.
|
|
530
|
+
* @param url The URL of the audio file
|
|
531
|
+
* - **Online URL**: A publicly accessible audio file URL on the internet, e.g., `https://example.com/audio-file.mp3`.
|
|
532
|
+
* - **Blob URL**: A temporary URL dynamically generated by the browser's Blob object, e.g., `blob:http://example.com/71d7a6d8`.
|
|
533
|
+
* @notes Currently, only Google Chrome is supported for data capture.
|
|
534
|
+
* @return Returns a `Promise` object.
|
|
535
|
+
* - ** Success**: Returns the captured stream ID, which can be used as a parameter for mixing or stopping capture.
|
|
536
|
+
* - ** Failure**: Returns an error object.
|
|
537
|
+
*/
|
|
538
|
+
startAudioFileCapture(url: string): Promise<string | undefined>;
|
|
539
|
+
/** {zh}
|
|
540
|
+
* @brief 停止音频文件采集。
|
|
541
|
+
* @param streamId 指定需要停止采集的流 ID,在成功调用 [`startAudioFileCapture`](#livepusher-startaudiofilecapture) 时返回。不传时默认停止所有音频文件采集。
|
|
542
|
+
*/
|
|
543
|
+
/** {en}
|
|
544
|
+
*
|
|
545
|
+
* @brief Stop audio file capture.
|
|
546
|
+
* @param streamId The captured stream ID, which corresponds to the return value of [`startAudioFileCapture`](#livepusher-startaudiofilecapture). If streamId is not provided, all audio file captures will be stopped by default.
|
|
547
|
+
*/
|
|
548
|
+
stopAudioFileCapture(streamId?: string): void;
|
|
549
|
+
/** {zh}
|
|
550
|
+
* @brief 启动图片采集。
|
|
551
|
+
* @param url 图片文件的 URL。支持文件在线地址和 Blob URL。
|
|
552
|
+
* - 在线地址:指互联网上公开可访问的图片文件 URL,例如,`https://example.com/image-file.png`。
|
|
553
|
+
* - Blob URL:指通过浏览器 Blob 对象动态生成的临时地址,例如,`blob:http://example.com/71d7a6d8`。
|
|
554
|
+
* @return 返回 `Promise` 对象。
|
|
555
|
+
* - 成功:返回采集的流 ID,流 ID 可以作为合流、停止采集的参数使用。
|
|
556
|
+
* - 失败:返回错误信息。
|
|
557
|
+
*/
|
|
558
|
+
/** {en}
|
|
559
|
+
*
|
|
560
|
+
* @brief Start image capture.
|
|
561
|
+
* @param url URL of the image file
|
|
562
|
+
* - **Online URL**: A publicly accessible image file URL on the internet, e.g., `https://example.com/image-file.png`.
|
|
563
|
+
* - **Blob URL**: A temporary URL dynamically generated by the browser's Blob object, e.g., `blob:http://example.com/71d7a6d8`.
|
|
564
|
+
* @return Returns a `Promise` object.
|
|
565
|
+
* - ** Success**: Returns the captured stream ID, which can be used as a parameter for merging or stopping the capture.
|
|
566
|
+
* - ** Failure**: Returns an error object.
|
|
567
|
+
*/
|
|
568
|
+
startImageCapture(url: string): Promise<string | undefined>;
|
|
569
|
+
/** {zh}
|
|
570
|
+
* @brief 停止图片采集。
|
|
571
|
+
* @param streamId 指定需要停止采集的流 ID,在成功调用 [`startImageCapture`](#livepusher-startimagecapture) 时返回。不传时默认停止所有图片采集。
|
|
572
|
+
*/
|
|
573
|
+
/** {en}
|
|
574
|
+
*
|
|
575
|
+
* @brief Stop image capture.
|
|
576
|
+
* @param streamId The ID of the stream to capture. The stream ID corresponds to the return value of [`startImageCapture`](#livepusher-startimagecapture). If `streamId` is not provided, all image capturing will be stopped by default.
|
|
577
|
+
*/
|
|
578
|
+
stopImageCapture(streamId?: string): void;
|
|
579
|
+
/** {zh}
|
|
580
|
+
* @brief 启动自定义视频流采集。
|
|
581
|
+
* @param track 需要采集的视频流。可以来自设备摄像头、屏幕共享或通过 `Canvas` 绘制生成的视频。例如,通过摄像头或屏幕共享获取的 `VideoTrack`。
|
|
582
|
+
* @return - 成功:返回采集的流 ID,流 ID 可以作为合流、停止采集的参数使用。
|
|
583
|
+
* - 失败:返回错误信息。
|
|
584
|
+
*/
|
|
585
|
+
/** {en}
|
|
586
|
+
*
|
|
587
|
+
* @brief Start custom video stream capture.
|
|
588
|
+
* @param track The video stream to be captured. It can come from a device camera, screen sharing, or a video generated via `Canvas` rendering. For example, a `VideoTrack` obtained from a camera or screen sharing.
|
|
589
|
+
* @return - ** Success**: Returns the captured stream ID, which can be used as a parameter for merging or stopping the capture.
|
|
590
|
+
* - ** Failure**: Returns an error object.
|
|
591
|
+
*/
|
|
592
|
+
startCustomVideoCapture(track: MediaStreamTrack): string | undefined;
|
|
593
|
+
/** {zh}
|
|
594
|
+
* @brief 停止自定义视频流采集。
|
|
595
|
+
* @param streamId 指定需要停止采集的流 ID,在成功调用 [`startCustomVideoCapture`](#livepusher-startcustomvideocapture) 时返回。不传时默认停止所有自定义视频流的采集。
|
|
596
|
+
*/
|
|
597
|
+
/** {en}
|
|
598
|
+
*
|
|
599
|
+
* @brief Stop capturing the custom video stream.
|
|
600
|
+
* @param streamId The captured stream ID, returned by [`startCustomVideoCapture`](#livepusher-startcustomvideocapture). If not provided, all custom video streams will be stopped.
|
|
601
|
+
*/
|
|
602
|
+
stopCustomVideoCapture(streamId?: string): void;
|
|
603
|
+
/** {zh}
|
|
604
|
+
* @brief 启动自定义音频流采集。
|
|
605
|
+
* @param track 需要采集的自定义音频流,可以来自麦克风、音频文件或其他音频源。例如,通过麦克风获取的 `AudioTrack`。
|
|
606
|
+
* @return - 成功:返回采集的流 ID,流 ID 可以作为混音、停止采集的参数使用。
|
|
607
|
+
* - 失败:返回错误信息。
|
|
608
|
+
*/
|
|
609
|
+
/** {en}
|
|
610
|
+
*
|
|
611
|
+
* @brief Start capturing the custom audio stream.
|
|
612
|
+
* @param track The custom audio stream to be captured. It can come from a microphone, an audio file, or other audio sources. For example, an `AudioTrack` obtained from a microphone.
|
|
613
|
+
* @return - ** Success**: Returns the captured stream ID, which can be used as a parameter for mixing and stopping capture.
|
|
614
|
+
* - ** Failure**: Returns an error object.
|
|
615
|
+
*/
|
|
616
|
+
startCustomAudioCapture(track: MediaStreamTrack): string | undefined;
|
|
617
|
+
/** {zh}
|
|
618
|
+
* @brief 停止自定义音频流采集。
|
|
619
|
+
* @param streamId 指定需要停止采集的流 ID,在成功调用 [`startCustomAudioCapture`](#livepusher-startcustomaudiocapture) 时返回。不传时默认停止所有自定义音频流的采集。
|
|
620
|
+
*/
|
|
621
|
+
/** {en}
|
|
622
|
+
*
|
|
623
|
+
* @brief Stop custom audio stream capture.
|
|
624
|
+
* @param streamId The captured stream ID, which is the return value corresponding to [`startCustomAudioCapture`](#livepusher-startcustomaudiocapture). If streamId is not provided, the capture of all custom audio streams will be stopped by default.
|
|
625
|
+
*/
|
|
626
|
+
stopCustomAudioCapture(streamId?: string): void;
|
|
627
|
+
/** {zh}
|
|
628
|
+
* @brief 开始音量检测。用于监测指定音频流或最终合流输出的音量值。
|
|
629
|
+
* @param streamId 指定需要检测音量的流 ID。
|
|
630
|
+
* - 当 `streamId` 为 `undefined` 时,检测最终合流输出的音量,包括所有参与合流的音频。
|
|
631
|
+
* - 如果指定 `streamId`,仅检测该音频流的音量。
|
|
632
|
+
* @notes - 确保音频流已启动并正常推流,调用前请检查音频轨道是否有效。
|
|
633
|
+
* - 启动音量检测后,可通过 [`getVolume()`](#livepusher-getvolume) 方法获取实时音量值。
|
|
634
|
+
* @return 返回 `Promise` 对象。
|
|
635
|
+
* - 成功:无返回值。
|
|
636
|
+
* - 失败:返回错误信息。
|
|
637
|
+
*/
|
|
638
|
+
/** {en}
|
|
639
|
+
*
|
|
640
|
+
* @brief Start volume detection. Used to monitor the volume level of a specified audio stream or the final mixed output.
|
|
641
|
+
* @param streamId Specify the stream ID for volume detection.
|
|
642
|
+
* - If `streamId` is `undefined`, the volume of the final mixed output, including all participating audio streams, will be detected.
|
|
643
|
+
* - If `streamId` is specified, only the volume of the specified audio stream will be detected.
|
|
644
|
+
* @notes - Ensure the audio stream has started and is streaming correctly; check if the audio track is valid before calling.
|
|
645
|
+
* - After starting volume detection, use the [`getVolume()`](#livepusher-getvolume) method to obtain real-time volume levels.
|
|
646
|
+
* @return Returns a `Promise` object.
|
|
647
|
+
* - ** Success**: No return value.
|
|
648
|
+
* - ** Failure**: Returns an error message.
|
|
649
|
+
*/
|
|
650
|
+
startVolumeDetect(streamId?: string): Promise<void>;
|
|
651
|
+
/** {zh}
|
|
652
|
+
* @brief 停止音量检测。
|
|
653
|
+
* @param streamId 指定需要停止音量检测的流 ID。
|
|
654
|
+
* - 当 `streamId` 为 `undefined` 时,停止最终合流输出的音量检测。
|
|
655
|
+
* - 如果指定 `streamId`,仅停止该音频流的音量检测。
|
|
656
|
+
* @notes - 适用于需要停止对某一特定音频流或最终输出音频流进行音量检测的场景。
|
|
657
|
+
* - 停止音量检测后,您将无法再通过 [`getVolume()`](#livepusher-getvolume) 方法获取对应流的音量。
|
|
658
|
+
*/
|
|
659
|
+
/** {en}
|
|
660
|
+
*
|
|
661
|
+
* @brief Stop volume detection.
|
|
662
|
+
* @param streamId Specify the stream ID for stopping volume detection.
|
|
663
|
+
* - If `streamId` is `undefined`, volume detection for the final mixed output will be stopped.
|
|
664
|
+
* - If `streamId` is specified, only volume detection for the specified audio stream will be stopped.
|
|
665
|
+
* @notes - Applicable when needing to stop volume detection for a specific audio stream or the final output audio stream.
|
|
666
|
+
* - After stopping the volume detection, the volume of the corresponding stream can no longer be obtained through the [`getVolume()`](#livepusher-getvolume) method.
|
|
667
|
+
*/
|
|
668
|
+
stopVolumeDetect(streamId?: string): void;
|
|
669
|
+
/** {zh}
|
|
670
|
+
* @brief 获取音量。
|
|
671
|
+
* @param streamId 指定需要获取音量的流 ID。
|
|
672
|
+
* - 当 `streamId` 为 `undefined` 时,返回最终合流输出的音量,包括所有参与合流的音频。
|
|
673
|
+
* - 如果指定 `streamId`,仅输出该音频流的音量。
|
|
674
|
+
* @notes 在调用此方法之前,您需要先调用 [`startVolumeDetect()`](#livepusher-startvolumedetect) 方法启动音量检测。调用示例:
|
|
675
|
+
* ```js
|
|
676
|
+
* await livePusher.startVolumeDetect()
|
|
677
|
+
* const volume = livePusher.getVolume()
|
|
678
|
+
* console.log(volume)
|
|
679
|
+
* ```
|
|
680
|
+
* @return 返回指定流 ID 的音量值,范围为 `[1,10]`,数值越大表示音量越高。
|
|
681
|
+
*/
|
|
682
|
+
/** {en}
|
|
683
|
+
*
|
|
684
|
+
* @brief Get volume.
|
|
685
|
+
* @param streamId Specify the stream ID to retrieve the volume.
|
|
686
|
+
* - If `streamId` is `undefined`, the volume of the final mixed output, including all participating audio streams, will be returned.
|
|
687
|
+
* - If `streamId` is specified, only the volume of the specified audio stream will be returned.
|
|
688
|
+
* @notes Before calling this method, you need to call the [`startVolumeDetect()`](#livepusher-startvolumedetect) method to start volume detection. Usage example:
|
|
689
|
+
* ```js
|
|
690
|
+
* await livePusher.startVolumeDetect()
|
|
691
|
+
* const volume = livePusher.getVolume()
|
|
692
|
+
* console.log(volume)
|
|
693
|
+
* ```
|
|
694
|
+
* @return Returns the volume level for the specified stream ID, ranging from `[1, 10]`, with higher values indicating higher volume.
|
|
695
|
+
*/
|
|
696
|
+
getVolume(streamId?: string): number;
|
|
697
|
+
/** {zh}
|
|
698
|
+
* @brief 启用或禁用合流功能。
|
|
699
|
+
* @param enable 指定是否启用本地合流。
|
|
700
|
+
* - `true`:启用。
|
|
701
|
+
* - `false`:停用。
|
|
702
|
+
* @notes - 合流必须在推流前设置,推流过程中无法切换该状态。
|
|
703
|
+
* - 启用合流前后,均可以调用 [`setMixingConfig()`](#livepusher-setmixingconfig) 配置合流画布参数(如宽度、高度、帧率等),以确保合流画面符合预期。
|
|
704
|
+
* @param enable 指定是否启用本地合流。
|
|
705
|
+
*/
|
|
706
|
+
/** {en}
|
|
707
|
+
*
|
|
708
|
+
* @brief Enable or disable local mixing functionality.
|
|
709
|
+
* @param enable Specifies whether to enable local mixing.
|
|
710
|
+
* - `true`: Enabled.
|
|
711
|
+
* - `false`: Disabled.
|
|
712
|
+
* @notes - Local mixing must be enabled before starting the push stream, and cannot be switched once the stream is running.
|
|
713
|
+
* - You can call [`setMixingConfig()`](#livepusher-setmixingconfig) both before and after enabling local mixing to configure canvas parameters (e.g., width, height, frame rate), ensuring the merged output meets your requirements.
|
|
714
|
+
*/
|
|
715
|
+
enableMixing(enable: boolean): void;
|
|
716
|
+
/** {zh}
|
|
717
|
+
* @brief 配置合流参数,包括合流画布的宽度、高度、帧率等。
|
|
718
|
+
* @param config 合流画布的配置信息,例如宽、高、帧率等参数。
|
|
719
|
+
*/
|
|
720
|
+
/** {en}
|
|
721
|
+
* @brief Configure the mixing parameters, including the width, height, and frame rate of the mixing canvas.
|
|
722
|
+
* @param config Attributes of the mixing canvas, such as width, height, frame rate, etc.
|
|
723
|
+
*/
|
|
724
|
+
setMixingConfig(config: IMixingViewConfig): void;
|
|
725
|
+
/** {zh}
|
|
726
|
+
* @brief 设置视频的预览区域。本地视频会在指定的容器内进行预览,同时预览内容与推流的画面和声音完全一致。
|
|
727
|
+
* @param containerId 用于指定预览区域的 HTML 容器元素 ID。
|
|
728
|
+
*/
|
|
729
|
+
/** {en}
|
|
730
|
+
*
|
|
731
|
+
* @brief Set the preview area of the video. The local video will be previewed within the specified container, and the preview content will be identical to the streamed video and audio.
|
|
732
|
+
* @param containerId Used to specify the HTML container element ID for the preview area.
|
|
733
|
+
*/
|
|
734
|
+
setRenderView(containerId: string): void;
|
|
735
|
+
/** {zh}
|
|
736
|
+
* @brief 开始本地视频预览。启用本地视频的预览功能,主播可以通过预览区域查看本地视频效果。
|
|
737
|
+
*/
|
|
738
|
+
/** {en}
|
|
739
|
+
*
|
|
740
|
+
* @brief Start local video preview. Enabling the local video preview feature allows the host to see the local video effect through the preview area.
|
|
741
|
+
*/
|
|
742
|
+
startPreview(): void;
|
|
743
|
+
/** {zh}
|
|
744
|
+
* @brief 停止本地视频预览。
|
|
745
|
+
* @notes 调用此接口停止本地视频的预览功能时,不会影响实际推流。
|
|
746
|
+
*/
|
|
747
|
+
/** {en}
|
|
748
|
+
*
|
|
749
|
+
* @brief Stop local video preview.
|
|
750
|
+
* @notes When calling this API to stop the local video preview, it will not affect the actual stream.
|
|
751
|
+
*/
|
|
752
|
+
stopPreview(): void;
|
|
753
|
+
/** {zh}
|
|
754
|
+
* @brief 开始推流,支持 RTM 和 WebTransport 两种推流方式。
|
|
755
|
+
* @param rtmUrl 推流地址,可以登录[视频直播控制台](https://console.volcengine.com/live/main/locationGenerate)获取 RTM 或 WebTransport 推流地址。
|
|
756
|
+
* @return 返回 `Promise` 对象。
|
|
757
|
+
* - 成功:无返回值。
|
|
758
|
+
* - 失败:返回错误信息。
|
|
759
|
+
*/
|
|
760
|
+
/** {en}
|
|
761
|
+
*
|
|
762
|
+
* @brief Start streaming, supporting both RTM and WebTransport streaming methods.
|
|
763
|
+
* @param rtmUrl The streaming URL can be generated using the [BytePlus MediaLive Console](https://console.byteplus.com/live/main/locationGenerate), where you can obtain an RTM or WebTransport push stream address.
|
|
764
|
+
* @return Returns a `Promise` object.
|
|
765
|
+
* - ** Success**: No return value.
|
|
766
|
+
* - ** Failure**: Returns an error message.
|
|
767
|
+
*/
|
|
768
|
+
startPush(rtmUrl: string): Promise<void>;
|
|
769
|
+
/** {zh}
|
|
770
|
+
* @brief 将视频流添加到合流画布中,可以将多个视频流(例如主播的摄像头画面、屏幕共享画面)合成到同一个合流画布中,如果视频流中包含音频信息,音频也会被添加到混音模块中。
|
|
771
|
+
* @notes 必须在已调用 [`enableMixing()`](#livepusher-enablemixing) 方法启用合流功能后使用。
|
|
772
|
+
* @param config 视频流布局参数,可以是单个对象或多个对象组成的数组。
|
|
773
|
+
*/
|
|
774
|
+
/** {en}
|
|
775
|
+
*
|
|
776
|
+
* @brief Adding video streams to the mixing canvas allows multiple video streams (e.g., the broadcaster's camera feed, screen sharing) to be combined into the same mixing canvas. If the video streams contain audio information, the audio will also be added to the mixing module.
|
|
777
|
+
* @notes Must be used after the [`enableMixing()`](#livepusher-enablemixing) method has been called to enable the mixing function.
|
|
778
|
+
* @param config The video stream layout parameters can be a single object or an array of multiple objects.
|
|
779
|
+
*/
|
|
780
|
+
addVideoStream(config: IVideoStreamLayoutParams | IVideoStreamLayoutParams[]): void;
|
|
781
|
+
/** {zh}
|
|
782
|
+
* @brief 从合流画布中移除指定的视频流。当需要从合流画布中删除某个视频画面时使用。
|
|
783
|
+
* @param streamId 要移除的视频流的 ID。
|
|
784
|
+
*/
|
|
785
|
+
/** {en}
|
|
786
|
+
*
|
|
787
|
+
* @brief Remove the specified video stream from the mixing canvas. Use this to remove a video stream from the mixing canvas.
|
|
788
|
+
* @param streamId The video stream ID to be removed
|
|
789
|
+
*/
|
|
790
|
+
removeVideoStream(streamId: string): void;
|
|
791
|
+
/** {zh}
|
|
792
|
+
* @brief 更新已添加的视频流的布局参数,例如位置、大小等,适用于动态布局调整等场景。
|
|
793
|
+
* @param config 视频流更新参数,可以是单个对象或多个对象组成的数组。
|
|
794
|
+
*/
|
|
795
|
+
/** {en}
|
|
796
|
+
*
|
|
797
|
+
* @brief Update the layout parameters of the added video stream, such as position and size. This is applicable to scenarios like dynamic layout adjustments.
|
|
798
|
+
* @param config Update the video stream parameters. When an array is passed, multiple video streams are updated.
|
|
799
|
+
*/
|
|
800
|
+
updateVideoStream(config: IVideoStreamLayoutParams | IVideoStreamLayoutParams[]): void;
|
|
801
|
+
/** {zh}
|
|
802
|
+
* @brief 隐藏合流画布中的视频流。当需要暂时隐藏某个视频画面,但不想从合流画布中移除该视频流时使用。
|
|
803
|
+
* @param streamId 要隐藏的视频流的 ID。如果不传,则隐藏所有视频流。
|
|
804
|
+
*/
|
|
805
|
+
/** {en}
|
|
806
|
+
*
|
|
807
|
+
* @brief Hide the video stream in the mixing canvas. Use this when a video needs to be temporarily hidden without removing the video stream from the mixing canvas.
|
|
808
|
+
* @param streamId The ID of the video stream to hide. If omitted, all video streams will be hidden.
|
|
809
|
+
*/
|
|
810
|
+
muteVideoStream(streamId?: string): void;
|
|
811
|
+
/** {zh}
|
|
812
|
+
* @brief 取消隐藏合流画布中的视频流,需要重新显示之前隐藏的视频流时使用。
|
|
813
|
+
* @param streamId 要重新显示的视频流的 ID。如果不传,则重新显示所有视频流。
|
|
814
|
+
*/
|
|
815
|
+
/** {en}
|
|
816
|
+
*
|
|
817
|
+
* @brief Unhides the video stream in the mixing canvas. Use this when you need to show a video stream that was previously hidden.
|
|
818
|
+
* @param streamId To unhide video stream id; if not provided, unhide all video streams.
|
|
819
|
+
*/
|
|
820
|
+
unmuteVideoStream(streamId?: string): void;
|
|
821
|
+
/** {zh}
|
|
822
|
+
* @brief 将音频流添加到混音模块中(需要启用合流功能)。当需要在合流音频中加入额外的音频源时使用,例如,添加背景音乐。
|
|
823
|
+
* @notes 必须在已调用 [`enableMixing()`](#livepusher-enablemixing) 方法启用合流功能后使用。
|
|
824
|
+
* @param config 音频流参数,可以是单个对象或多个对象组成的数组。
|
|
825
|
+
*/
|
|
826
|
+
/** {en}
|
|
827
|
+
*
|
|
828
|
+
* @brief Add an audio stream to the mix module (requires enabling the co-streaming feature). This is used when an additional audio source needs to be included in the co-streamed audio, such as adding background music.
|
|
829
|
+
* @notes The method [`enableMixing()`](#livepusher-enablemixing) must be called to enable the mixing function before use.
|
|
830
|
+
* @param config Audio stream parameters can be a single object or an array of multiple objects.
|
|
831
|
+
*/
|
|
832
|
+
addAudioStream(config: IAudioStreamLayoutParams | IAudioStreamLayoutParams[]): void;
|
|
833
|
+
/** {zh}
|
|
834
|
+
* @brief 移除指定的音频流。如果目标是单独的音频流,则直接移除;如果目标是一个包含音频轨道的视频流,仅会影响该视频流中的音频部分,而不会对视频画面产生任何影响。
|
|
835
|
+
* @param streamId 要移除的流 ID。如果不传,则移除所有音频流。
|
|
836
|
+
*/
|
|
837
|
+
/** {en}
|
|
838
|
+
*
|
|
839
|
+
* @brief Remove the specified audio stream. If the target is an individual audio stream, it will be removed directly; if the target is a video stream containing an audio track, only the audio portion will be affected, leaving the video intact.
|
|
840
|
+
* @param streamId The stream ID to be removed. If omitted, all audio streams will be removed.
|
|
841
|
+
*/
|
|
842
|
+
removeAudioStream(streamId: string): void;
|
|
843
|
+
/** {zh}
|
|
844
|
+
* @brief 更新音频流的音量大小。在混音场景中调整某个或多个音频流的音量,例如,主播语音、背景音乐和视频音频的平衡调整。
|
|
845
|
+
* @param config 要更新的音频流参数,支持单个对象或数组以更新多个音频流。
|
|
846
|
+
* @notes 您可以按照如下顺序调用接口。
|
|
847
|
+
* - 调用 `enableMixing(true)` 开启合流功能。
|
|
848
|
+
* - 使用 `addAudioStream()` 添加音频流到混音模块。
|
|
849
|
+
* - 调用 `updateAudioStream()` 更新音频流的参数。
|
|
850
|
+
*/
|
|
851
|
+
/** {en}
|
|
852
|
+
*
|
|
853
|
+
* @brief Update the volume of the audio stream. Adjust the volume of one or multiple audio streams in a mixing scenario, such as balancing the host's voice, background music, and video audio.
|
|
854
|
+
* @param config Update the audio stream parameters. Pass in an array to update multiple audio streams.
|
|
855
|
+
* @notes You can call the interfaces in the following order.
|
|
856
|
+
* - Call `enableMixing(true)` to enable the mixing function.
|
|
857
|
+
* - Use `addAudioStream()` to add an audio stream to the mixing module.
|
|
858
|
+
* - Call `updateAudioStream()` to update the parameters of the audio stream.
|
|
859
|
+
*/
|
|
860
|
+
updateAudioStream(config: IAudioStreamLayoutParams | IAudioStreamLayoutParams[]): void;
|
|
861
|
+
/** {zh}
|
|
862
|
+
* @brief 静音指定的音频流或包含音频轨道的视频流。在某个音频流内容不需要被输出时使用。
|
|
863
|
+
* @param streamId 要静音的流 ID。如果不传,则静音所有音频流。
|
|
864
|
+
* @notes 静音指定的音频流。如果目标是单独的音频流,则直接静音;如果目标是一个包含音频轨道的视频流,仅会影响该视频流中的音频部分,而不会对视频画面产生任何影响。
|
|
865
|
+
*/
|
|
866
|
+
/** {en}
|
|
867
|
+
*
|
|
868
|
+
* @brief Mute the specified audio stream or video stream containing an audio track. Use this when certain audio stream content does not need to be output.
|
|
869
|
+
* @param streamId The ID of the stream to mute. If omitted, mute all streams.
|
|
870
|
+
* @notes Mute the specified audio stream. If the target is an individual audio stream, mute it directly. If the target is a video stream containing an audio track, it will only affect the audio part of the video stream without impacting the video footage.
|
|
871
|
+
*/
|
|
872
|
+
muteAudioStream(streamId?: string): void;
|
|
873
|
+
/** {zh}
|
|
874
|
+
* @brief 取消对指定音频流的静音操作,或取消所有音频流的静音状态。
|
|
875
|
+
* @param streamId 要取消静音的流 ID,不传时取消所有流的静音。
|
|
876
|
+
*/
|
|
877
|
+
/** {en}
|
|
878
|
+
*
|
|
879
|
+
* @brief Cancel the mute operation for a specific audio stream or unmute all audio streams.
|
|
880
|
+
* @param streamId The stream ID to unmute. If omitted, all streams will be unmuted.
|
|
881
|
+
*/
|
|
882
|
+
unmuteAudioStream(streamId?: string): void;
|
|
883
|
+
/** {zh}
|
|
884
|
+
* @notes - 部分属性设置可能需要在推流前完成(如分辨率和帧率),请确保在推流启动前调用相关配置。
|
|
885
|
+
* - 属性 `setPushMode` 的设置应在初始化阶段完成,不支持动态切换。
|
|
886
|
+
* @brief 设置推流和采集相关的配置属性,包括视频分辨率、帧率、码率、音频采样率等。适用于需要调整某些关键配置的场景,例如,调整视频采集的清晰度、根据目标服务选择推流协议(如 RTM 或 WebTransport)等。
|
|
887
|
+
* @param key 要设置的属性名称。
|
|
888
|
+
* @param value 对应属性的值,根据 `key` 的类型填写。
|
|
889
|
+
*/
|
|
890
|
+
/** {en}
|
|
891
|
+
* @notes - Some attributes need to be configured before starting the stream (such as resolution and frame rate). Please ensure to call the relevant configuration before starting the stream.
|
|
892
|
+
* - The attribute `setPushMode` should be configured during the initialization stage and does not support dynamic switching.
|
|
893
|
+
* @brief Set streaming and capturing related configuration properties, including video resolution, frame rate, bitrate, audio sampling rate, etc. Suitable for scenarios where key configurations need to be adjusted, such as adjusting the clarity of video capture, selecting a streaming protocol (e.g., RTM or WebTransport) based on the target service, etc.
|
|
894
|
+
* @param key The name of the attribute to be set.
|
|
895
|
+
* @param value Fill in the value of the corresponding attribute according to the type of `key`.
|
|
896
|
+
*/
|
|
897
|
+
setProperty<K extends keyof IProperty>(key: K, value: IProperty[K]): void;
|
|
898
|
+
/** {zh}
|
|
899
|
+
* @brief 设置推流和采集的视频质量。
|
|
900
|
+
* @param quality 视频质量,详情请参见 [VIDEO_DEFAULT_QUALITY](1438157#video_default_quality)
|
|
901
|
+
*/
|
|
902
|
+
/** {en}
|
|
903
|
+
*
|
|
904
|
+
* @brief Set the video quality for streaming and capturing.
|
|
905
|
+
* @param quality Video Quality, see [VIDEO_DEFAULT_QUALITY](docs-configuration#video_default_quality)
|
|
906
|
+
*/
|
|
907
|
+
setVideoQuality(quality: keyof typeof VIDEO_DEFAULT_QUALITY): void;
|
|
908
|
+
/** {zh}
|
|
909
|
+
* @brief 设置推流和采集音频的质量,包括采样率和码率:
|
|
910
|
+
* - 采样率:仅影响麦克风的音频采集质量。
|
|
911
|
+
* - 码率:决定最终推流音频的质量。
|
|
912
|
+
* @param quality 音频质量。
|
|
913
|
+
* - `STANDARD`:标准音质(低码率),适合语音通话、网络差场景。
|
|
914
|
+
* - `HIGH`:高音质(高码率),适合音乐直播、高质量场景。
|
|
915
|
+
*/
|
|
916
|
+
/** {en}
|
|
917
|
+
*
|
|
918
|
+
* @brief Set the quality of audio streaming and capturing, including sample rate and bitrate:
|
|
919
|
+
* - Sample rate: Only affects the audio capture quality of the microphone.
|
|
920
|
+
* - Bitrate: Determines the quality of the final streaming audio.
|
|
921
|
+
* @param quality Audio quality.
|
|
922
|
+
* - `STANDARD`: Standard audio quality (low bitrate), suitable for voice calls and poor network conditions.
|
|
923
|
+
* - `HIGH`: High audio quality (high bitrate), suitable for music streaming and high-quality scenarios.
|
|
924
|
+
*/
|
|
925
|
+
setAudioQuality(quality: keyof typeof AUDIO_DEFAULT_QUALITY): void;
|
|
926
|
+
/** {en}
|
|
927
|
+
* @hidden
|
|
928
|
+
* @brief Get the `MediaStream` object for the specified stream.
|
|
929
|
+
* @param streamId The required stream ID.
|
|
930
|
+
* @return The corresponding `MediaStream` object can be used for local rendering or other processing.
|
|
931
|
+
*/
|
|
932
|
+
/** {zh}
|
|
933
|
+
* @hidden
|
|
934
|
+
* @brief 获取指定流的 `MediaStream` 对象。
|
|
935
|
+
* @param streamId 需要获取的流 ID。
|
|
936
|
+
* @return 对应流的 `MediaStream` 对象,可用于本地渲染或其他处理。
|
|
937
|
+
*/
|
|
938
|
+
getMediaStream(streamId: string): MediaStream;
|
|
939
|
+
/** {zh}
|
|
940
|
+
* @brief 停止推流。
|
|
941
|
+
* @return 返回 `Promise` 对象。
|
|
942
|
+
* - 成功:无返回值。
|
|
943
|
+
* - 失败:返回错误信息。
|
|
944
|
+
*/
|
|
945
|
+
/** {en}
|
|
946
|
+
*
|
|
947
|
+
* @brief Stop streaming.
|
|
948
|
+
* @return Returns a `Promise` object.
|
|
949
|
+
* - ** Success**: No return value.
|
|
950
|
+
* - ** Failure**: Returns an error message.
|
|
951
|
+
*/
|
|
952
|
+
stopPush(): Promise<void>;
|
|
953
|
+
/** {zh}
|
|
954
|
+
* @brief 判断当前是否正在推流。
|
|
955
|
+
* @return - `true`:正在推流。
|
|
956
|
+
* - `false`:未推流。
|
|
957
|
+
*/
|
|
958
|
+
/** {en}
|
|
959
|
+
*
|
|
960
|
+
* @brief Determine if the current streaming is ongoing.
|
|
961
|
+
* @return - `true`: Streaming in progress.
|
|
962
|
+
* - `false`: Not streaming.
|
|
963
|
+
*/
|
|
964
|
+
isPushing(): boolean;
|
|
965
|
+
/** {zh}
|
|
966
|
+
* @brief 获取当前推流状态信息。用于监控推流质量,调整参数。
|
|
967
|
+
* @return 当前推流的统计数据(如丢包率、码率)。
|
|
968
|
+
*/
|
|
969
|
+
/** {en}
|
|
970
|
+
*
|
|
971
|
+
* @brief Get the current stream status information. This function is used to monitor streaming quality and adjust parameters.
|
|
972
|
+
* @return Statistics of the current stream (e.g., packet loss rate, bitrate).
|
|
973
|
+
*/
|
|
974
|
+
getStats(): Promise<RTMPStats | StatsSnapshoot | undefined>;
|
|
975
|
+
/** {zh}
|
|
976
|
+
* @brief 获取预览的 `video` 元素。用于设置预览区域的音量或样式。
|
|
977
|
+
* @notes 开始预览后可以通过 `getPreviewElement` 获取到对应的预览元素设置预览的音量大小。
|
|
978
|
+
* @return 预览画面的 `video` 元素。
|
|
979
|
+
*/
|
|
980
|
+
/** {en}
|
|
981
|
+
*
|
|
982
|
+
* @brief Get the preview `video` element. Used to set the volume or style of the preview area.
|
|
983
|
+
* @notes After starting the preview, use `getPreviewElement` to obtain the corresponding preview element and set the preview volume.
|
|
984
|
+
* @return `video` element of the preview screen.
|
|
985
|
+
*/
|
|
986
|
+
getPreviewElement(): HTMLVideoElement | null | undefined;
|
|
987
|
+
private _bindEvent;
|
|
988
|
+
/** {zh}
|
|
989
|
+
* @brief 清理 SDK 实例,避免可能会产生的内存泄露。
|
|
990
|
+
* @notes 如果正在推流,调用该接口会导致推流中断。
|
|
991
|
+
* @return 返回 `Promise` 对象。
|
|
992
|
+
* - 成功:无返回值。
|
|
993
|
+
* - 失败:返回错误信息。
|
|
994
|
+
*/
|
|
995
|
+
/** {en}
|
|
996
|
+
*
|
|
997
|
+
* @brief Clean up the SDK instance to avoid potential memory leaks.
|
|
998
|
+
* @notes Calling this interface during a live stream will cause the stream to be interrupted.
|
|
999
|
+
* @return Returns a `Promise` object.
|
|
1000
|
+
* - ** Success**: no return value.
|
|
1001
|
+
* - ** Failure**: returns an error message.
|
|
1002
|
+
*/
|
|
1003
|
+
destroy(): Promise<void>;
|
|
1004
|
+
/** {zh}
|
|
1005
|
+
* @default ???
|
|
1006
|
+
* @brief 推流器的观察者,用于接收推流状态、错误、警告等通知回调。
|
|
1007
|
+
*/
|
|
1008
|
+
/** {en}
|
|
1009
|
+
* @default ???
|
|
1010
|
+
* @brief Receives notifications about streaming status, errors, warnings, and more.
|
|
1011
|
+
*/
|
|
1012
|
+
get observer(): Observer;
|
|
1013
|
+
/** {zh}
|
|
1014
|
+
* @brief 当前是否为开启合流的状态,默认为 `false`。合流是将多个音视频流(如摄像头、麦克风、屏幕分享等)合并为一个流,便于推送到远端或录制。
|
|
1015
|
+
* - `true`:启用合流,将所有输入流整合为单一流。
|
|
1016
|
+
* - `false`:不启用合流,独立推送各流。
|
|
1017
|
+
* @default ???
|
|
1018
|
+
* @return 是否开启合流
|
|
1019
|
+
*/
|
|
1020
|
+
/** {en}
|
|
1021
|
+
*
|
|
1022
|
+
* @brief Indicates whether local mixing is enabled. The default value is `false`.
|
|
1023
|
+
* Local mixing merges multiple audio and video streams (e.g., camera, microphone, screen sharing) into a single stream for easier remote transmission or recording.
|
|
1024
|
+
* - `true`: Enables local mixing, merging all input streams into a single stream.
|
|
1025
|
+
* - `false`: Disables local mixing, pushing each stream independently.
|
|
1026
|
+
* @default ???
|
|
1027
|
+
* @return Enable local mixing
|
|
1028
|
+
*/
|
|
1029
|
+
get isEnableMixing(): boolean;
|
|
1030
|
+
/** {zh}
|
|
1031
|
+
* @brief 当前推流模式。
|
|
1032
|
+
* - `rtm`:使用 RTM 传输协议。
|
|
1033
|
+
* - `webTransport`:使用 WebTransport 传输协议。
|
|
1034
|
+
* @return 推流模式
|
|
1035
|
+
*/
|
|
1036
|
+
/** {en}
|
|
1037
|
+
*
|
|
1038
|
+
* @brief The current streaming mode.
|
|
1039
|
+
* - `rtm`: RTM transport protocol.
|
|
1040
|
+
* - `webTransport`: WebTransport protocol.
|
|
1041
|
+
* @return Streaming Mode
|
|
1042
|
+
*/
|
|
1043
|
+
get pushMode(): PushMode;
|
|
1044
|
+
}
|
|
1045
|
+
export default LivePusher;
|
|
1046
|
+
|
|
1047
|
+
/** {zh}
|
|
1048
|
+
* @detail events
|
|
1049
|
+
* @list events
|
|
1050
|
+
* @brief 用于接收音视频采集和推流过程中的各种事件回调。提供了对错误、警告、状态更新以及设备切换等信息的监听能力,帮助您实时监控推流器的状态。
|
|
1051
|
+
*/
|
|
1052
|
+
/** {en}
|
|
1053
|
+
* @detail events
|
|
1054
|
+
* @list events
|
|
1055
|
+
* @brief Used to receive various event callbacks during the audio and video capture and streaming process. Provides the ability to listen for information such as errors, warnings, status updates, and device switching, helping to monitor the status of the streamer in real-time.
|
|
1056
|
+
*/
|
|
1057
|
+
declare class Observer implements IVePusherEvents {
|
|
1058
|
+
/** {zh}
|
|
1059
|
+
* @brief 错误通知回调。适用于捕获推流或采集中发生的致命错误,可结合错误码进行问题排查和日志记录。
|
|
1060
|
+
* @param code: 错误码
|
|
1061
|
+
* @param msg: 错误信息
|
|
1062
|
+
* @param extraInfo: 扩展信息
|
|
1063
|
+
*/
|
|
1064
|
+
/** {en}
|
|
1065
|
+
*
|
|
1066
|
+
* @brief Error notification callback. Used to capture fatal errors occurring during streaming or capture. Can be used in conjunction with error codes for troubleshooting and logging.
|
|
1067
|
+
*/
|
|
1068
|
+
onError: (code: number, msg: string, extraInfo?: any) => void;
|
|
1069
|
+
/** {zh}
|
|
1070
|
+
* @brief 警告通知回调,用于提醒可能影响推流但不致命的异常状态。
|
|
1071
|
+
* @param msg: 警告信息
|
|
1072
|
+
*/
|
|
1073
|
+
/** {en}
|
|
1074
|
+
*
|
|
1075
|
+
* @brief Warning notification callback used to alert about abnormal conditions that may affect streaming but are not fatal.
|
|
1076
|
+
*/
|
|
1077
|
+
onWarning: (msg: string) => void;
|
|
1078
|
+
/** {zh}
|
|
1079
|
+
* @brief 首帧音频采集完成的回调通知。适用于启动采集后确认音频源是否正常工作。
|
|
1080
|
+
*/
|
|
1081
|
+
/** {en}
|
|
1082
|
+
*
|
|
1083
|
+
* @brief The callback notification for the completion of the first frame audio capture. This is used to confirm if the audio source is working properly after starting the capture.
|
|
1084
|
+
*/
|
|
1085
|
+
onCaptureFirstAudioFrame: () => void;
|
|
1086
|
+
/** {zh}
|
|
1087
|
+
* @brief 首帧视频采集完成的回调通知。适用于启动采集后确认视频源是否正常工作。
|
|
1088
|
+
*/
|
|
1089
|
+
/** {en}
|
|
1090
|
+
*
|
|
1091
|
+
* @brief The callback notification for the completion of the first frame video capture. This is used to confirm whether the video source is working properly after starting the capture.
|
|
1092
|
+
*/
|
|
1093
|
+
onCaptureFirstVideoFrame: () => void;
|
|
1094
|
+
/** {zh}
|
|
1095
|
+
* @brief 推流状态更新回调,提供状态代码和状态描述信息。可用于实时监控推流器状态(如连接断开、重试中),并作出相应处理。
|
|
1096
|
+
* @param status: 连接状态码
|
|
1097
|
+
* @param msg: 连接状态信息
|
|
1098
|
+
*/
|
|
1099
|
+
/** {en}
|
|
1100
|
+
*
|
|
1101
|
+
* @brief The stream state update callback provides status codes and status descriptions. This can be used to monitor the status of the stream in real-time (e.g., disconnection, retrying) and take appropriate actions.
|
|
1102
|
+
*/
|
|
1103
|
+
onPushStatusUpdate: (status: number, msg: string) => void;
|
|
1104
|
+
/** {zh}
|
|
1105
|
+
* @brief 麦克风设备切换时的回调,返回切换后的设备信息。适用于监听音频设备的状态改变,例如,设备热插拔。
|
|
1106
|
+
* @param changedDevice: 麦克风设备信息
|
|
1107
|
+
*/
|
|
1108
|
+
/** {en}
|
|
1109
|
+
*
|
|
1110
|
+
* @brief The callback for switching the microphone device returns the information of the switched device. It is used to monitor the status changes of audio devices, such as hot swapping of devices.
|
|
1111
|
+
*/
|
|
1112
|
+
onMicrophoneChanged: (changedDevice: MediaDeviceInfo) => void;
|
|
1113
|
+
/** {zh}
|
|
1114
|
+
* @brief 摄像头设备切换时的回调,返回切换后的设备信息。适用于监听主播切换视频输入设备的场景(如在线直播)。
|
|
1115
|
+
* @param changedDevice: 摄像头设备信息
|
|
1116
|
+
*/
|
|
1117
|
+
/** {en}
|
|
1118
|
+
*
|
|
1119
|
+
* @brief The callback for switching camera devices returns the information of the switched device. It is suitable for scenarios where the host switches video input devices, such as live streaming.
|
|
1120
|
+
*/
|
|
1121
|
+
onCameraChanged: (changedDevice: MediaDeviceInfo) => void;
|
|
1122
|
+
/** {zh}
|
|
1123
|
+
* @brief 采集流被中断的回调,返回被中断的流 ID。适用于设备异常导致采集流停止时的处理。
|
|
1124
|
+
* @param streamId: 采集流id
|
|
1125
|
+
* @notes 麦克风、摄像头、屏幕采集流被中断时触发。同时```onStopCapture```也会同时被触发
|
|
1126
|
+
*/
|
|
1127
|
+
/** {en}
|
|
1128
|
+
*
|
|
1129
|
+
* @brief Callback for stream interruption, returns the ID of the interrupted stream. This is used for handling situations where the stream stops due to device anomalies.
|
|
1130
|
+
* @notes Triggers when the microphone, camera, or screen capture stream is interrupted. The `onStopCapture` event is also triggered simultaneously.
|
|
1131
|
+
*/
|
|
1132
|
+
onCaptureInterrupted: (streamId: string) => void;
|
|
1133
|
+
/** {zh}
|
|
1134
|
+
* @brief 开始推流的回调通知。
|
|
1135
|
+
* @notes
|
|
1136
|
+
* - 在RTM模式下为RTC连接变为connected时触发
|
|
1137
|
+
* - 在WebTransport模式下为第一帧信息发送时触发
|
|
1138
|
+
*/
|
|
1139
|
+
/** {en}
|
|
1140
|
+
*
|
|
1141
|
+
* @brief Callback notification for starting a live stream.
|
|
1142
|
+
* @notes - Triggered when the RTC connection becomes connected in RTM mode
|
|
1143
|
+
* - Triggered when the first frame of information is sent in WebTransport mode
|
|
1144
|
+
*/
|
|
1145
|
+
onPushStart: () => void;
|
|
1146
|
+
/** {zh}
|
|
1147
|
+
* @brief 停止推流的回调通知。
|
|
1148
|
+
* @notes 主动调用停止推流、内部错误被动停止推流时会触发回调
|
|
1149
|
+
*/
|
|
1150
|
+
/** {en}
|
|
1151
|
+
*
|
|
1152
|
+
* @brief Callback notification for stopping the stream.
|
|
1153
|
+
* @notes The callback will be triggered when the stream is actively stopped or passively stopped due to an internal error.
|
|
1154
|
+
*/
|
|
1155
|
+
onPushStop: () => void;
|
|
1156
|
+
/** {zh}
|
|
1157
|
+
* @brief 停止采集的回调,返回停止采集的流 ID。
|
|
1158
|
+
* @notes 主动调用停止采集、内部错误被动停止采集时会触发回调
|
|
1159
|
+
*/
|
|
1160
|
+
/** {en}
|
|
1161
|
+
*
|
|
1162
|
+
* @brief The callback for stopping the capture returns the ID of the stopped stream.
|
|
1163
|
+
* @notes The callback will be triggered when stopping capture actively or when capture stops passively due to an internal error.
|
|
1164
|
+
*/
|
|
1165
|
+
onStopCapture: (streamId: string) => void;
|
|
1166
|
+
/** {zh}
|
|
1167
|
+
* @brief 构造函数
|
|
1168
|
+
* @hidden
|
|
1169
|
+
*/
|
|
1170
|
+
/** {en}
|
|
1171
|
+
* @brief Constructor
|
|
1172
|
+
* @hidden
|
|
1173
|
+
*/
|
|
1174
|
+
constructor();
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
/** {zh}
|
|
1178
|
+
* @detail config
|
|
1179
|
+
* @brief 推流模式
|
|
1180
|
+
* @notes
|
|
1181
|
+
* - `rtm`:使用 RTM 推流。
|
|
1182
|
+
* - `webTransport`:使用 WebTransport 推流。
|
|
1183
|
+
*/
|
|
1184
|
+
/** {en}
|
|
1185
|
+
* @notes - `rtm`: Use RTM for streaming.
|
|
1186
|
+
* - `webTransport`: Use WebTransport for streaming.
|
|
1187
|
+
* @brief Streaming Mode
|
|
1188
|
+
*/
|
|
1189
|
+
declare type PushMode = 'rtm' | 'webTransport';
|
|
1190
|
+
|
|
1191
|
+
declare class RTMError extends Error {
|
|
1192
|
+
code: RTMErrorCode;
|
|
1193
|
+
message: string;
|
|
1194
|
+
ext: Record<string, unknown> | undefined;
|
|
1195
|
+
constructor(code: RTMErrorCode, message: string, ext?: Record<string, unknown>);
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
/** {zh}
|
|
1199
|
+
* @detail errorcode
|
|
1200
|
+
* @brief 推流 SDK 中的错误码,用于标识音视频采集和推流过程中的异常情况。通过错误码,您可以快速定位问题并采取相应措施。
|
|
1201
|
+
*/
|
|
1202
|
+
/** {en}
|
|
1203
|
+
* @detail errorcode
|
|
1204
|
+
* @brief Error codes in the BytePlus MediaLive Broadcast SDK are used to identify issues during the process of audio and video capture and streaming. By using these error codes, problems can be quickly located and appropriate measures can be taken.
|
|
1205
|
+
*/
|
|
1206
|
+
declare enum RTMErrorCode {
|
|
1207
|
+
/** {zh}
|
|
1208
|
+
* @brief 打开摄像头失败。
|
|
1209
|
+
*/
|
|
1210
|
+
/** {en}
|
|
1211
|
+
*
|
|
1212
|
+
* @brief Failed to open the camera.
|
|
1213
|
+
*/
|
|
1214
|
+
OPEN_CAMERA_FAILED = 1001,
|
|
1215
|
+
/** {zh}
|
|
1216
|
+
* @brief 打开麦克风失败。
|
|
1217
|
+
*/
|
|
1218
|
+
/** {en}
|
|
1219
|
+
*
|
|
1220
|
+
* @brief Failed to open the microphone.
|
|
1221
|
+
*/
|
|
1222
|
+
OPEN_MICROPHONE_FAILED = 1002,
|
|
1223
|
+
/** {zh}
|
|
1224
|
+
* @brief 开启屏幕分享失败。
|
|
1225
|
+
*/
|
|
1226
|
+
/** {en}
|
|
1227
|
+
*
|
|
1228
|
+
* @brief Failed to start screen sharing.
|
|
1229
|
+
*/
|
|
1230
|
+
OPEN_SCREEN_FAILED = 1003,
|
|
1231
|
+
/** {zh}
|
|
1232
|
+
* @brief 采集视频文件失败。当尝试加载视频文件为流时,文件路径错误或格式不被支持会触发此错误。
|
|
1233
|
+
*/
|
|
1234
|
+
/** {en}
|
|
1235
|
+
*
|
|
1236
|
+
* @brief Failed to load video file. This error occurs when the file path is incorrect or the format is not supported while attempting to load the video file as a stream.
|
|
1237
|
+
*/
|
|
1238
|
+
VIDEO_FILE_CAPTURE_FAILED = 1004,
|
|
1239
|
+
/** {zh}
|
|
1240
|
+
* @brief 采集音频文件失败。当尝试加载音频文件为流时,文件路径错误或格式不被支持会触发此错误。
|
|
1241
|
+
*/
|
|
1242
|
+
/** {en}
|
|
1243
|
+
*
|
|
1244
|
+
* @brief Failed to capture audio file. This error occurs when attempting to load an audio file as a stream if the file path is incorrect or the format is not supported.
|
|
1245
|
+
*/
|
|
1246
|
+
AUDIO_FILE_CAPTURE_FAILED = 1005,
|
|
1247
|
+
/** {zh}
|
|
1248
|
+
* @brief 采集图片文件失败。当尝试加载图片文件为流时,文件路径错误或格式不被支持会触发此错误。
|
|
1249
|
+
*/
|
|
1250
|
+
/** {en}
|
|
1251
|
+
*
|
|
1252
|
+
* @brief Failed to capture image file. This error occurs when the file path is incorrect or the format is not supported while trying to load the image file as a stream.
|
|
1253
|
+
*/
|
|
1254
|
+
IMAGE_FILE_CAPTURE_FAILED = 1006,
|
|
1255
|
+
/** {zh}
|
|
1256
|
+
* @brief 音量检测失败。当音频流不可用或检测逻辑异常时触发此错误。
|
|
1257
|
+
*/
|
|
1258
|
+
/** {en}
|
|
1259
|
+
*
|
|
1260
|
+
* @brief Volume detection failed. This error is triggered when the audio stream is unavailable or the detection logic is abnormal.
|
|
1261
|
+
*/
|
|
1262
|
+
VOLUME_DETECT_FAILED = 1008,
|
|
1263
|
+
/** {zh}
|
|
1264
|
+
* @brief 推流失败。推流地址不可达、网络不稳定或服务端返回错误时适用。
|
|
1265
|
+
*/
|
|
1266
|
+
/** {en}
|
|
1267
|
+
*
|
|
1268
|
+
* @brief Failed to push stream. Applicable when the push stream address is unreachable, the network is unstable, or the server returns an error.
|
|
1269
|
+
*/
|
|
1270
|
+
PUBLISH_FAILED = 2001,
|
|
1271
|
+
/** {zh}
|
|
1272
|
+
* @brief 更新推流内容失败。在非合流场景下,替换视频源失败时出现该错误。
|
|
1273
|
+
*/
|
|
1274
|
+
/** {en}
|
|
1275
|
+
*
|
|
1276
|
+
* @brief Failed to update streaming content. This error occurs when replacing the video source fails in non-mixing scenarios.
|
|
1277
|
+
*/
|
|
1278
|
+
UPDATE_PUBLISH_FAILED = 2002,
|
|
1279
|
+
/** {zh}
|
|
1280
|
+
* @brief 推流连接失败。网络连接失败或服务器地址不可达的场景下会返回此错误。
|
|
1281
|
+
*/
|
|
1282
|
+
/** {en}
|
|
1283
|
+
*
|
|
1284
|
+
* @brief Stream connection failed. This error will be returned if the network connection fails or the server address is unreachable.
|
|
1285
|
+
*/
|
|
1286
|
+
PUSH_CONNECT_FAILED = 2003
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
declare type RTMEvents = {
|
|
1290
|
+
[RTMEventsTypes.Error]: (e: RTMError) => void;
|
|
1291
|
+
[RTMEventsTypes.TrackEnded]: (e: MediaStreamTrack) => void;
|
|
1292
|
+
[RTMEventsTypes.VideoDeviceStateChanged]: (e: any) => void;
|
|
1293
|
+
[RTMEventsTypes.AudioDeviceStateChanged]: (e: any) => void;
|
|
1294
|
+
[RTMEventsTypes.CaptureFirstVideoFrame]: () => void;
|
|
1295
|
+
[RTMEventsTypes.CaptureFirstAudioFrame]: () => void;
|
|
1296
|
+
[RTMEventsTypes.NotAllowedAutoPlay]: () => void;
|
|
1297
|
+
[RTMEventsTypes.NotAllowedMixAudioPlay]: () => void;
|
|
1298
|
+
[RTMEventsTypes.RTCConnectStateChanged]: (e: RTCPeerConnectionState) => void;
|
|
1299
|
+
[RTMEventsTypes.PushStart]: () => void;
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1302
|
+
declare enum RTMEventsTypes {
|
|
1303
|
+
Error = "error",
|
|
1304
|
+
TrackEnded = "trackended",
|
|
1305
|
+
CaptureFirstVideoFrame = "capturefirstvideoframe",
|
|
1306
|
+
CaptureFirstAudioFrame = "capturefirstaudioframe",
|
|
1307
|
+
AudioMixingStateChanged = "audiomixingstatechanged",
|
|
1308
|
+
NotAllowedAutoPlay = "notallowedautoplay",
|
|
1309
|
+
NotAllowedMixAudioPlay = "notallowedmixaudioplay",
|
|
1310
|
+
RTCConnectStateChanged = "rtcconnectstatechanged",
|
|
1311
|
+
PushStart = "pushstart",
|
|
1312
|
+
/** 视频媒体设备状态改变 */
|
|
1313
|
+
/** {en}
|
|
1314
|
+
*
|
|
1315
|
+
*/
|
|
1316
|
+
VideoDeviceStateChanged = "videoDeviceStateChanged",
|
|
1317
|
+
/** 音频媒体设备状态改变 */
|
|
1318
|
+
/** {en}
|
|
1319
|
+
*
|
|
1320
|
+
*/
|
|
1321
|
+
AudioDeviceStateChanged = "audioDeviceStateChanged"
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
/** {zh}
|
|
1325
|
+
* @detail api
|
|
1326
|
+
* @brief 描述 WebTransport 推流状态信息。
|
|
1327
|
+
* @name RTMPStats
|
|
1328
|
+
* @id RTMPStats
|
|
1329
|
+
* @notes 查看视频推流分辨率,代码示例:
|
|
1330
|
+
* ```js
|
|
1331
|
+
* const rtmpStats = await livePusher.getStats(); console.log('视频分辨率:', rtmpStats.video.frameWidth, '×', rtmpStats.video.frameHeight);
|
|
1332
|
+
* ```
|
|
1333
|
+
*/
|
|
1334
|
+
/** {en}
|
|
1335
|
+
* @detail api
|
|
1336
|
+
* @brief Describe the WebTransport push stream status information.
|
|
1337
|
+
* @notes To check the video push stream resolution, see the code example below:
|
|
1338
|
+
* ```js
|
|
1339
|
+
* const rtmpStats = await livePusher.getStats();
|
|
1340
|
+
* console.log('Video resolution:', rtmpStats.video.frameWidth, '×', rtmpStats.video.frameHeight);
|
|
1341
|
+
* ```
|
|
1342
|
+
*/
|
|
1343
|
+
declare type RTMPStats = {
|
|
1344
|
+
video: {
|
|
1345
|
+
/** {zh}
|
|
1346
|
+
* @brief 推流视频码率,单位为 bps。
|
|
1347
|
+
*/
|
|
1348
|
+
/** {en}
|
|
1349
|
+
*
|
|
1350
|
+
* @brief The push stream video bitrate, in bps.
|
|
1351
|
+
*/
|
|
1352
|
+
sendBitrate: number;
|
|
1353
|
+
/** {zh}
|
|
1354
|
+
* @brief 推流帧率。
|
|
1355
|
+
*/
|
|
1356
|
+
/** {en}
|
|
1357
|
+
*
|
|
1358
|
+
* @brief Frame rate of the push stream.
|
|
1359
|
+
*/
|
|
1360
|
+
framesPerSecond: number;
|
|
1361
|
+
/** {zh}
|
|
1362
|
+
* @brief 已编码帧数。
|
|
1363
|
+
*/
|
|
1364
|
+
/** {en}
|
|
1365
|
+
*
|
|
1366
|
+
* @brief Number of encoded frames.
|
|
1367
|
+
*/
|
|
1368
|
+
framesEncoded: number;
|
|
1369
|
+
/** {zh}
|
|
1370
|
+
* @brief 已编码关键帧数。
|
|
1371
|
+
*/
|
|
1372
|
+
/** {en}
|
|
1373
|
+
*
|
|
1374
|
+
* @brief Number of encoded keyframes.
|
|
1375
|
+
*/
|
|
1376
|
+
keyFramesEncoded: number;
|
|
1377
|
+
/** {zh}
|
|
1378
|
+
* @brief 视频推流上传速度,单位为 bps。
|
|
1379
|
+
*/
|
|
1380
|
+
/** {en}
|
|
1381
|
+
*
|
|
1382
|
+
* @brief The video stream upload speed, measured in bps.
|
|
1383
|
+
*/
|
|
1384
|
+
sendSpeed: number;
|
|
1385
|
+
/** {zh}
|
|
1386
|
+
* @brief 视频编码格式,例如,H.264。
|
|
1387
|
+
*/
|
|
1388
|
+
/** {en}
|
|
1389
|
+
*
|
|
1390
|
+
* @brief Video encoding formats, such as H.264.
|
|
1391
|
+
*/
|
|
1392
|
+
codec: string;
|
|
1393
|
+
/** {zh}
|
|
1394
|
+
* @brief 视频分辨率宽度。
|
|
1395
|
+
*/
|
|
1396
|
+
/** {en}
|
|
1397
|
+
*
|
|
1398
|
+
* @brief Video resolution width.
|
|
1399
|
+
*/
|
|
1400
|
+
frameWidth: number;
|
|
1401
|
+
/** {zh}
|
|
1402
|
+
* @brief 视频分辨率高度。
|
|
1403
|
+
*/
|
|
1404
|
+
/** {en}
|
|
1405
|
+
*
|
|
1406
|
+
* @brief Video resolution height.
|
|
1407
|
+
*/
|
|
1408
|
+
frameHeight: number;
|
|
1409
|
+
/** {zh}
|
|
1410
|
+
* @brief GOP(关键帧间隔)大小。
|
|
1411
|
+
*/
|
|
1412
|
+
/** {en}
|
|
1413
|
+
*
|
|
1414
|
+
* @brief GOP (keyframe interval) size.
|
|
1415
|
+
*/
|
|
1416
|
+
gopSize: number;
|
|
1417
|
+
};
|
|
1418
|
+
audio: {
|
|
1419
|
+
/** {zh}
|
|
1420
|
+
* @brief 推流音频码率,单位为 bps。
|
|
1421
|
+
*/
|
|
1422
|
+
/** {en}
|
|
1423
|
+
*
|
|
1424
|
+
* @brief The bitrate of the streaming audio, measured in bps.
|
|
1425
|
+
*/
|
|
1426
|
+
sendBitrate: number;
|
|
1427
|
+
/** {zh}
|
|
1428
|
+
* @brief 已编码帧数。
|
|
1429
|
+
*/
|
|
1430
|
+
/** {en}
|
|
1431
|
+
*
|
|
1432
|
+
* @brief Encoded frame count.
|
|
1433
|
+
*/
|
|
1434
|
+
framesEncoded: number;
|
|
1435
|
+
/** {zh}
|
|
1436
|
+
* @brief 音频编码格式。
|
|
1437
|
+
*/
|
|
1438
|
+
/** {en}
|
|
1439
|
+
*
|
|
1440
|
+
* @brief Audio encoding format.
|
|
1441
|
+
*/
|
|
1442
|
+
codec: string;
|
|
1443
|
+
/** {zh}
|
|
1444
|
+
* @brief 音频通道数,例如,单声道和立体声。
|
|
1445
|
+
*/
|
|
1446
|
+
/** {en}
|
|
1447
|
+
*
|
|
1448
|
+
* @brief Number of audio channels, such as mono and stereo.
|
|
1449
|
+
*/
|
|
1450
|
+
channels: number;
|
|
1451
|
+
/** {zh}
|
|
1452
|
+
* @brief 音频采样率,单位为 Hz。
|
|
1453
|
+
*/
|
|
1454
|
+
/** {en}
|
|
1455
|
+
*
|
|
1456
|
+
* @brief The audio sampling rate, in Hz.
|
|
1457
|
+
*/
|
|
1458
|
+
sampleRate: number;
|
|
1459
|
+
};
|
|
1460
|
+
};
|
|
1461
|
+
|
|
1462
|
+
/** {zh}
|
|
1463
|
+
* @detail api
|
|
1464
|
+
* @brief 描述 RTM 推流状态的详细信息,包括视频和音频的各项指标。
|
|
1465
|
+
* @id StatsSnapshoot
|
|
1466
|
+
* @name StatsSnapshoot
|
|
1467
|
+
* @notes 获取推流状态快照,示例如下:
|
|
1468
|
+
* ```js
|
|
1469
|
+
* const stats = await livePusher.getStats();
|
|
1470
|
+
* console.log('当前视频码率:', stats.video.sendBitrate);
|
|
1471
|
+
* console.log('音频丢包率:', stats.audio.packetsLostPercent);
|
|
1472
|
+
* ```
|
|
1473
|
+
*/
|
|
1474
|
+
/** {en}
|
|
1475
|
+
* @detail api
|
|
1476
|
+
* @id StatsSnapshoot
|
|
1477
|
+
* @name StatsSnapshoot
|
|
1478
|
+
* @brief Describes detailed information about the status of the RTM push stream, including various video and audio metrics.
|
|
1479
|
+
* @notes To get a snapshot of the push stream status, see the example below:
|
|
1480
|
+
* ```js
|
|
1481
|
+
* const stats = await livePusher.getStats();
|
|
1482
|
+
* console.log('Current video bitrate:', stats.video.sendBitrate);
|
|
1483
|
+
* console.log('Audio packet loss rate:', stats.audio.packetsLostPercent);
|
|
1484
|
+
* ```
|
|
1485
|
+
*/
|
|
1486
|
+
declare type StatsSnapshoot = {
|
|
1487
|
+
/** {zh}
|
|
1488
|
+
* @brief 视频信息。
|
|
1489
|
+
*/
|
|
1490
|
+
/** {en}
|
|
1491
|
+
*
|
|
1492
|
+
* @brief Video Information.
|
|
1493
|
+
*/
|
|
1494
|
+
video?: {
|
|
1495
|
+
/** {zh}
|
|
1496
|
+
* @brief 推流视频编码方式,例如,H.264。
|
|
1497
|
+
*/
|
|
1498
|
+
/** {en}
|
|
1499
|
+
*
|
|
1500
|
+
* @brief Use the push stream video codec method, for example, H.264.
|
|
1501
|
+
*/
|
|
1502
|
+
codec: string;
|
|
1503
|
+
/** {zh}
|
|
1504
|
+
* @brief 推流视频码率,单位为 bps。
|
|
1505
|
+
*/
|
|
1506
|
+
/** {en}
|
|
1507
|
+
*
|
|
1508
|
+
* @brief The push stream video bit rate, in bps.
|
|
1509
|
+
*/
|
|
1510
|
+
sendBitrate: number;
|
|
1511
|
+
/** {zh}
|
|
1512
|
+
* @brief 视频分辨率宽度。
|
|
1513
|
+
*/
|
|
1514
|
+
/** {en}
|
|
1515
|
+
*
|
|
1516
|
+
* @brief Video resolution width.
|
|
1517
|
+
*/
|
|
1518
|
+
frameWidth: number;
|
|
1519
|
+
/** {zh}
|
|
1520
|
+
* @brief 视频分辨率高度。
|
|
1521
|
+
*/
|
|
1522
|
+
/** {en}
|
|
1523
|
+
*
|
|
1524
|
+
* @brief The height of the video resolution.
|
|
1525
|
+
*/
|
|
1526
|
+
frameHeight: number;
|
|
1527
|
+
/** {zh}
|
|
1528
|
+
* @brief 视频帧率。
|
|
1529
|
+
*/
|
|
1530
|
+
/** {en}
|
|
1531
|
+
*
|
|
1532
|
+
* @brief Frame rate.
|
|
1533
|
+
*/
|
|
1534
|
+
framesPerSecond: number;
|
|
1535
|
+
/** {zh}
|
|
1536
|
+
* @brief 已编码的帧数。
|
|
1537
|
+
*/
|
|
1538
|
+
/** {en}
|
|
1539
|
+
*
|
|
1540
|
+
* @brief Encoded frames.
|
|
1541
|
+
*/
|
|
1542
|
+
framesEncoded: number;
|
|
1543
|
+
/** {zh}
|
|
1544
|
+
* @brief 已编码的关键帧数。
|
|
1545
|
+
*/
|
|
1546
|
+
/** {en}
|
|
1547
|
+
*
|
|
1548
|
+
* @brief Number of encoded keyframes.
|
|
1549
|
+
*/
|
|
1550
|
+
keyFramesEncoded: number;
|
|
1551
|
+
/** {zh}
|
|
1552
|
+
* @brief 已发送的帧数。
|
|
1553
|
+
*/
|
|
1554
|
+
/** {en}
|
|
1555
|
+
*
|
|
1556
|
+
* @brief Number of frames sent.
|
|
1557
|
+
*/
|
|
1558
|
+
framesSent: number;
|
|
1559
|
+
/** {zh}
|
|
1560
|
+
* @brief 单帧平均编码时间,单位为 ms。
|
|
1561
|
+
*/
|
|
1562
|
+
/** {en}
|
|
1563
|
+
*
|
|
1564
|
+
* @brief The average encoding time per frame, measured in milliseconds (ms).
|
|
1565
|
+
*/
|
|
1566
|
+
frameEncodeAvgTime: number;
|
|
1567
|
+
/** {zh}
|
|
1568
|
+
* @brief 已发送的数据包数量。
|
|
1569
|
+
*/
|
|
1570
|
+
/** {en}
|
|
1571
|
+
*
|
|
1572
|
+
* @brief The number of packets sent.
|
|
1573
|
+
*/
|
|
1574
|
+
packetsSent: number;
|
|
1575
|
+
/** {zh}
|
|
1576
|
+
* @brief 数据包发送前平均缓存时间,单位为 ms。
|
|
1577
|
+
*/
|
|
1578
|
+
/** {en}
|
|
1579
|
+
*
|
|
1580
|
+
* @brief The average buffering time before sending the data packet, measured in ms.
|
|
1581
|
+
*/
|
|
1582
|
+
packetSendDelay: number;
|
|
1583
|
+
/** {zh}
|
|
1584
|
+
* @brief 收到的 NACK 包数。
|
|
1585
|
+
*/
|
|
1586
|
+
/** {en}
|
|
1587
|
+
*
|
|
1588
|
+
* @brief The number of received NACK packets.
|
|
1589
|
+
*/
|
|
1590
|
+
nackCount: number;
|
|
1591
|
+
/** {zh}
|
|
1592
|
+
* @brief 收到的 FIR(全帧请求)包数。
|
|
1593
|
+
*/
|
|
1594
|
+
/** {en}
|
|
1595
|
+
*
|
|
1596
|
+
* @brief The number of received FIR (Full Intra Request) packets.
|
|
1597
|
+
*/
|
|
1598
|
+
firCount: number;
|
|
1599
|
+
/** {zh}
|
|
1600
|
+
* @brief 收到的 PLI(图像丢失指示)包数。
|
|
1601
|
+
*/
|
|
1602
|
+
/** {en}
|
|
1603
|
+
*
|
|
1604
|
+
* @brief The number of received PLI (Picture Loss Indication) packets.
|
|
1605
|
+
*/
|
|
1606
|
+
pliCount: number;
|
|
1607
|
+
/** {zh}
|
|
1608
|
+
* @brief 丢失的数据包数量。
|
|
1609
|
+
*/
|
|
1610
|
+
/** {en}
|
|
1611
|
+
*
|
|
1612
|
+
* @brief Number of lost data packets.
|
|
1613
|
+
*/
|
|
1614
|
+
packetsLost: number;
|
|
1615
|
+
/** {zh}
|
|
1616
|
+
* @brief 丢包率。
|
|
1617
|
+
*/
|
|
1618
|
+
/** {en}
|
|
1619
|
+
*
|
|
1620
|
+
* @brief Packet loss rate.
|
|
1621
|
+
*/
|
|
1622
|
+
packetsLostPercent: number;
|
|
1623
|
+
};
|
|
1624
|
+
audio?: {
|
|
1625
|
+
/** {zh}
|
|
1626
|
+
* @brief 音频编码格式,例如 AAC。
|
|
1627
|
+
*/
|
|
1628
|
+
/** {en}
|
|
1629
|
+
*
|
|
1630
|
+
* @brief Audio encoding format, such as AAC.
|
|
1631
|
+
*/
|
|
1632
|
+
codec: string | undefined;
|
|
1633
|
+
/** {zh}
|
|
1634
|
+
* @brief 音频通道数,例如,单声道或立体声。
|
|
1635
|
+
*/
|
|
1636
|
+
/** {en}
|
|
1637
|
+
*
|
|
1638
|
+
* @brief The number of audio channels, such as mono or stereo.
|
|
1639
|
+
*/
|
|
1640
|
+
channels: number | undefined;
|
|
1641
|
+
/** {zh}
|
|
1642
|
+
* @brief 推流音频码率,单位为 bps
|
|
1643
|
+
*/
|
|
1644
|
+
/** {en}
|
|
1645
|
+
*
|
|
1646
|
+
* @brief push stream audio bitrate, unit in bps
|
|
1647
|
+
*/
|
|
1648
|
+
sendBitrate: number | undefined;
|
|
1649
|
+
/** {zh}
|
|
1650
|
+
* @brief 已发送的数据包数量。
|
|
1651
|
+
*/
|
|
1652
|
+
/** {en}
|
|
1653
|
+
*
|
|
1654
|
+
* @brief The number of packets sent.
|
|
1655
|
+
*/
|
|
1656
|
+
packetsSent: number | undefined;
|
|
1657
|
+
/** {zh}
|
|
1658
|
+
* @brief 收到的 NACK 包数。
|
|
1659
|
+
*/
|
|
1660
|
+
/** {en}
|
|
1661
|
+
*
|
|
1662
|
+
* @brief The number of received NACK packets.
|
|
1663
|
+
*/
|
|
1664
|
+
nackCount: number | undefined;
|
|
1665
|
+
/** {zh}
|
|
1666
|
+
* @brief 丢失的数据包数量。
|
|
1667
|
+
*/
|
|
1668
|
+
/** {en}
|
|
1669
|
+
*
|
|
1670
|
+
* @brief The number of lost data packets.
|
|
1671
|
+
*/
|
|
1672
|
+
packetsLost: number | undefined;
|
|
1673
|
+
/** {zh}
|
|
1674
|
+
* @brief 丢包率。
|
|
1675
|
+
*/
|
|
1676
|
+
/** {en}
|
|
1677
|
+
*
|
|
1678
|
+
* @brief Packet loss rate.
|
|
1679
|
+
*/
|
|
1680
|
+
packetsLostPercent: number | undefined;
|
|
1681
|
+
};
|
|
1682
|
+
};
|
|
1683
|
+
|
|
1684
|
+
/** {zh}
|
|
1685
|
+
* @detail config
|
|
1686
|
+
* @brief 内置的推流视频质量。
|
|
1687
|
+
*/
|
|
1688
|
+
declare enum VIDEO_DEFAULT_QUALITY {
|
|
1689
|
+
/** {zh}
|
|
1690
|
+
* @brief 分辨率为 160 x 120,帧率为 15fps,码率为 200kbps
|
|
1691
|
+
*/
|
|
1692
|
+
/** {en}
|
|
1693
|
+
* @brief Resolution: 160 x 120, FPS: 15, Bitrate: 200kbps
|
|
1694
|
+
*/
|
|
1695
|
+
'120p' = "160x120x15x200",
|
|
1696
|
+
/** {zh}
|
|
1697
|
+
* @brief 分辨率为 320 x 180,帧率为 15fps,码率为 350kbps
|
|
1698
|
+
*/
|
|
1699
|
+
/** {en}
|
|
1700
|
+
* @brief Resolution: 320 x 180, FPS: 15, Bitrate: 350kbps
|
|
1701
|
+
*/
|
|
1702
|
+
'180p' = "320x180x15x350",
|
|
1703
|
+
/** {zh}
|
|
1704
|
+
* @brief 分辨率为 320 x 240,帧率为 15fps,码率为 400kbps
|
|
1705
|
+
*/
|
|
1706
|
+
/** {en}
|
|
1707
|
+
* @brief Resolution: 320 x 240, FPS: 15, Bitrate: 400kbps
|
|
1708
|
+
*/
|
|
1709
|
+
'240p' = "320x240x15x400",
|
|
1710
|
+
/** {zh}
|
|
1711
|
+
* @brief 分辨率为 640 x 360,帧率为 15fps,码率为 800kbps
|
|
1712
|
+
*/
|
|
1713
|
+
/** {en}
|
|
1714
|
+
* @brief Resolution: 640 x 360, FPS: 15, Bitrate: 800kbps
|
|
1715
|
+
*/
|
|
1716
|
+
'360p' = "640x360x15x800",
|
|
1717
|
+
/** {zh}
|
|
1718
|
+
* @brief 分辨率为 640 x 480,帧率为 15fps,码率为 900kbps
|
|
1719
|
+
*/
|
|
1720
|
+
/** {en}
|
|
1721
|
+
* @brief Resolution: 640 x 480, FPS: 15, Bitrate: 900kbps
|
|
1722
|
+
*/
|
|
1723
|
+
'480p' = "640x480x15x900",
|
|
1724
|
+
/** {zh}
|
|
1725
|
+
* @brief 分辨率为 1280 x 720,帧率为 15fps,码率为 1500kbps
|
|
1726
|
+
*/
|
|
1727
|
+
/** {en}
|
|
1728
|
+
* @brief Resolution: 1280 x 720, FPS: 15, Bitrate: 1500kbps
|
|
1729
|
+
*/
|
|
1730
|
+
'720p-1' = "1280x720x15x1500",
|
|
1731
|
+
/** {zh}
|
|
1732
|
+
* @brief 分辨率为 1280 x 720,帧率为 25fps,码率为 1500kbps
|
|
1733
|
+
*/
|
|
1734
|
+
/** {en}
|
|
1735
|
+
* @brief Resolution: 1280 x 720, FPS: 25, Bitrate: 1500kbps
|
|
1736
|
+
*/
|
|
1737
|
+
'720p-2' = "1280x720x25x1500",
|
|
1738
|
+
/** {zh}
|
|
1739
|
+
* @brief 分辨率为 1280 x 720,帧率为 30fps,码率为 1500kbps
|
|
1740
|
+
*/
|
|
1741
|
+
/** {en}
|
|
1742
|
+
* @brief Resolution: 1280 x 720, FPS: 30, Bitrate: 1500kbps
|
|
1743
|
+
*/
|
|
1744
|
+
'720p-3' = "1280x720x30x1500",
|
|
1745
|
+
/** {zh}
|
|
1746
|
+
* @brief 分辨率为 1920 x 1080,帧率为 15fps,码率为 2080kbps
|
|
1747
|
+
*/
|
|
1748
|
+
/** {en}
|
|
1749
|
+
* @brief Resolution: 1920 x 1080, FPS: 15, Bitrate: 2080kbps
|
|
1750
|
+
*/
|
|
1751
|
+
'1080p-1' = "1920x1080x15x2080",
|
|
1752
|
+
/** {zh}
|
|
1753
|
+
* @brief 分辨率为 1920 x 1080,帧率为 25fps,码率为 3000kbps
|
|
1754
|
+
*/
|
|
1755
|
+
/** {en}
|
|
1756
|
+
* @brief Resolution: 1920 x 1080, FPS: 25, Bitrate: 3000kbps
|
|
1757
|
+
*/
|
|
1758
|
+
'1080p-2' = "1920x1080x25x3000",
|
|
1759
|
+
/** {zh}
|
|
1760
|
+
* @brief 分辨率为 1920 x 1080,帧率为 30fps,码率为 3150kbps
|
|
1761
|
+
*/
|
|
1762
|
+
/** {en}
|
|
1763
|
+
* @brief Resolution: 1920 x 1080, FPS: 30, Bitrate: 3150kbps
|
|
1764
|
+
*/
|
|
1765
|
+
'1080p-3' = "1920x1080x30x3150"
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
export { }
|