@byteplus/vepusher 2.0.4-rc.1 → 2.0.4-rc.3
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 +183 -0
- package/dist/index.es.js +1804 -1542
- package/dist/index.umd.js +8 -8
- package/package.json +1 -1
package/dist/index.es.d.ts
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
import { AudioTrack } from '@byted/ve-capture';
|
|
1
2
|
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';
|
|
2
13
|
|
|
3
14
|
declare enum AUDIO_DEFAULT_QUALITY {
|
|
4
15
|
STANDARD = "48000x40",
|
|
5
16
|
HIGH = "48000x128"
|
|
6
17
|
}
|
|
7
18
|
|
|
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
|
+
|
|
8
26
|
/** {zh}
|
|
9
27
|
* @detail config
|
|
10
28
|
* @list config
|
|
@@ -53,8 +71,28 @@ declare type ConfigOptions = {
|
|
|
53
71
|
* - `webTransport`: Streaming with WebTransport protocol.
|
|
54
72
|
*/
|
|
55
73
|
mode?: PushMode;
|
|
74
|
+
/** {zh}
|
|
75
|
+
* @brief 推流中断重试配置,包含是否开启,重试最大超时时间,不传入时默认开启断线重连,最大超时时间默认3分钟
|
|
76
|
+
*/
|
|
77
|
+
reconnectConfig?: {
|
|
78
|
+
/** {zh}
|
|
79
|
+
* @brief 是否开启断线重连
|
|
80
|
+
*/
|
|
81
|
+
enable: boolean;
|
|
82
|
+
/** {zh}
|
|
83
|
+
* @brief 最大重试超时时间,单位为 s
|
|
84
|
+
*/
|
|
85
|
+
maxTimeout?: number;
|
|
86
|
+
};
|
|
56
87
|
};
|
|
57
88
|
|
|
89
|
+
declare enum ConnectionState {
|
|
90
|
+
DISCONNECTED = 0,
|
|
91
|
+
CONNECTING = 1,
|
|
92
|
+
CONNECTED = 2,
|
|
93
|
+
RECONNECTING = 3,
|
|
94
|
+
}
|
|
95
|
+
|
|
58
96
|
/** {zh}
|
|
59
97
|
* @detail config
|
|
60
98
|
* @list config
|
|
@@ -218,6 +256,15 @@ declare interface IProperty {
|
|
|
218
256
|
*
|
|
219
257
|
*/
|
|
220
258
|
setVolumeDetectScriptUrl: string;
|
|
259
|
+
/** {zh}
|
|
260
|
+
* @hidden
|
|
261
|
+
* @brief 设置推流时默认采集的方向,默认是横屏
|
|
262
|
+
*/
|
|
263
|
+
/**
|
|
264
|
+
* {zh}
|
|
265
|
+
* @brief 更新推流地址,作用:断线重连时会使用最新的推流地址,避免推流过程中推流地址超时
|
|
266
|
+
*/
|
|
267
|
+
updatePushUrl: string;
|
|
221
268
|
}
|
|
222
269
|
|
|
223
270
|
declare type IVePusherEvents = {
|
|
@@ -301,6 +348,10 @@ declare interface IVideoStreamLayoutParams {
|
|
|
301
348
|
* @brief When the video stream contains audio content, the corresponding audio volume ranges from `[0,100]`.
|
|
302
349
|
*/
|
|
303
350
|
volume?: number;
|
|
351
|
+
/** {zh}
|
|
352
|
+
* @brief 镜像类型,默认为不镜像。
|
|
353
|
+
*/
|
|
354
|
+
mirrorType?: MirrorType;
|
|
304
355
|
}
|
|
305
356
|
|
|
306
357
|
/** {zh}
|
|
@@ -722,6 +773,7 @@ declare class LivePusher extends default_2<RTMEvents> {
|
|
|
722
773
|
* @param config Attributes of the mixing canvas, such as width, height, frame rate, etc.
|
|
723
774
|
*/
|
|
724
775
|
setMixingConfig(config: IMixingViewConfig): void;
|
|
776
|
+
getMixingConfig(): ViewConfig;
|
|
725
777
|
/** {zh}
|
|
726
778
|
* @brief 设置视频的预览区域。本地视频会在指定的容器内进行预览,同时预览内容与推流的画面和声音完全一致。
|
|
727
779
|
* @param containerId 用于指定预览区域的 HTML 容器元素 ID。
|
|
@@ -936,6 +988,7 @@ declare class LivePusher extends default_2<RTMEvents> {
|
|
|
936
988
|
* @return 对应流的 `MediaStream` 对象,可用于本地渲染或其他处理。
|
|
937
989
|
*/
|
|
938
990
|
getMediaStream(streamId: string): MediaStream;
|
|
991
|
+
getStream(streamId: string): VideoStream | AudioStream;
|
|
939
992
|
/** {zh}
|
|
940
993
|
* @brief 停止推流。
|
|
941
994
|
* @return 返回 `Promise` 对象。
|
|
@@ -984,6 +1037,15 @@ declare class LivePusher extends default_2<RTMEvents> {
|
|
|
984
1037
|
* @return `video` element of the preview screen.
|
|
985
1038
|
*/
|
|
986
1039
|
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;
|
|
987
1049
|
private _bindEvent;
|
|
988
1050
|
/** {zh}
|
|
989
1051
|
* @brief 清理 SDK 实例,避免可能会产生的内存泄露。
|
|
@@ -1044,6 +1106,33 @@ declare class LivePusher extends default_2<RTMEvents> {
|
|
|
1044
1106
|
}
|
|
1045
1107
|
export default LivePusher;
|
|
1046
1108
|
|
|
1109
|
+
/** {zh}
|
|
1110
|
+
* @detail config
|
|
1111
|
+
* @list config
|
|
1112
|
+
* @brief 视频流镜像方向
|
|
1113
|
+
* @id MirrorType
|
|
1114
|
+
* @name MirrorType
|
|
1115
|
+
*/
|
|
1116
|
+
declare enum MirrorType {
|
|
1117
|
+
/** {zh}
|
|
1118
|
+
* @brief 左右镜像
|
|
1119
|
+
*/
|
|
1120
|
+
LeftToRight = "LeftToRight",
|
|
1121
|
+
/** {zh}
|
|
1122
|
+
* @brief 上下镜像
|
|
1123
|
+
*/
|
|
1124
|
+
UpToDown = "UpToDown",
|
|
1125
|
+
/** {zh}
|
|
1126
|
+
* @brief 左右+上下镜像
|
|
1127
|
+
*/
|
|
1128
|
+
All = "All",
|
|
1129
|
+
/**
|
|
1130
|
+
* {zh}
|
|
1131
|
+
* @brief 不镜像
|
|
1132
|
+
*/
|
|
1133
|
+
None = "None"
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1047
1136
|
/** {zh}
|
|
1048
1137
|
* @detail events
|
|
1049
1138
|
* @list events
|
|
@@ -1163,6 +1252,12 @@ declare class Observer implements IVePusherEvents {
|
|
|
1163
1252
|
* @notes The callback will be triggered when stopping capture actively or when capture stops passively due to an internal error.
|
|
1164
1253
|
*/
|
|
1165
1254
|
onStopCapture: (streamId: string) => void;
|
|
1255
|
+
onLiveConnectStateChange: (state: ConnectionState) => void;
|
|
1256
|
+
onReconnectStateChange: (state: ReconnectState, params?: {
|
|
1257
|
+
failedCode?: ReconnectFailedCode;
|
|
1258
|
+
retryTime?: number;
|
|
1259
|
+
waitingTime?: number;
|
|
1260
|
+
}) => void;
|
|
1166
1261
|
/** {zh}
|
|
1167
1262
|
* @brief 构造函数
|
|
1168
1263
|
* @hidden
|
|
@@ -1188,6 +1283,21 @@ declare class Observer implements IVePusherEvents {
|
|
|
1188
1283
|
*/
|
|
1189
1284
|
declare type PushMode = 'rtm' | 'webTransport';
|
|
1190
1285
|
|
|
1286
|
+
declare enum ReconnectFailedCode {
|
|
1287
|
+
// 推流地址失效,需要重新生成推流地址推流
|
|
1288
|
+
PushUrlInvalid = 1001,
|
|
1289
|
+
// 重连超时
|
|
1290
|
+
ReconnectTimeout = 1002,
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
declare enum ReconnectState {
|
|
1294
|
+
START = 1,
|
|
1295
|
+
WAITING = 2,
|
|
1296
|
+
RECONNECTING = 3,
|
|
1297
|
+
SUCCESS = 4,
|
|
1298
|
+
FAILED = 5,
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1191
1301
|
declare class RTMError extends Error {
|
|
1192
1302
|
code: RTMErrorCode;
|
|
1193
1303
|
message: string;
|
|
@@ -1681,6 +1791,62 @@ declare type StatsSnapshoot = {
|
|
|
1681
1791
|
};
|
|
1682
1792
|
};
|
|
1683
1793
|
|
|
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
|
+
|
|
1684
1850
|
/** {zh}
|
|
1685
1851
|
* @detail config
|
|
1686
1852
|
* @brief 内置的推流视频质量。
|
|
@@ -1765,4 +1931,21 @@ declare enum VIDEO_DEFAULT_QUALITY {
|
|
|
1765
1931
|
'1080p-3' = "1920x1080x30x3150"
|
|
1766
1932
|
}
|
|
1767
1933
|
|
|
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
|
+
|
|
1768
1951
|
export { }
|