@byteplus/vepusher 2.0.4-rc.2 → 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 +152 -0
- package/dist/index.es.js +1745 -1518
- 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 = {
|
|
@@ -726,6 +773,7 @@ declare class LivePusher extends default_2<RTMEvents> {
|
|
|
726
773
|
* @param config Attributes of the mixing canvas, such as width, height, frame rate, etc.
|
|
727
774
|
*/
|
|
728
775
|
setMixingConfig(config: IMixingViewConfig): void;
|
|
776
|
+
getMixingConfig(): ViewConfig;
|
|
729
777
|
/** {zh}
|
|
730
778
|
* @brief 设置视频的预览区域。本地视频会在指定的容器内进行预览,同时预览内容与推流的画面和声音完全一致。
|
|
731
779
|
* @param containerId 用于指定预览区域的 HTML 容器元素 ID。
|
|
@@ -940,6 +988,7 @@ declare class LivePusher extends default_2<RTMEvents> {
|
|
|
940
988
|
* @return 对应流的 `MediaStream` 对象,可用于本地渲染或其他处理。
|
|
941
989
|
*/
|
|
942
990
|
getMediaStream(streamId: string): MediaStream;
|
|
991
|
+
getStream(streamId: string): VideoStream | AudioStream;
|
|
943
992
|
/** {zh}
|
|
944
993
|
* @brief 停止推流。
|
|
945
994
|
* @return 返回 `Promise` 对象。
|
|
@@ -988,6 +1037,15 @@ declare class LivePusher extends default_2<RTMEvents> {
|
|
|
988
1037
|
* @return `video` element of the preview screen.
|
|
989
1038
|
*/
|
|
990
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;
|
|
991
1049
|
private _bindEvent;
|
|
992
1050
|
/** {zh}
|
|
993
1051
|
* @brief 清理 SDK 实例,避免可能会产生的内存泄露。
|
|
@@ -1194,6 +1252,12 @@ declare class Observer implements IVePusherEvents {
|
|
|
1194
1252
|
* @notes The callback will be triggered when stopping capture actively or when capture stops passively due to an internal error.
|
|
1195
1253
|
*/
|
|
1196
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;
|
|
1197
1261
|
/** {zh}
|
|
1198
1262
|
* @brief 构造函数
|
|
1199
1263
|
* @hidden
|
|
@@ -1219,6 +1283,21 @@ declare class Observer implements IVePusherEvents {
|
|
|
1219
1283
|
*/
|
|
1220
1284
|
declare type PushMode = 'rtm' | 'webTransport';
|
|
1221
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
|
+
|
|
1222
1301
|
declare class RTMError extends Error {
|
|
1223
1302
|
code: RTMErrorCode;
|
|
1224
1303
|
message: string;
|
|
@@ -1712,6 +1791,62 @@ declare type StatsSnapshoot = {
|
|
|
1712
1791
|
};
|
|
1713
1792
|
};
|
|
1714
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
|
+
|
|
1715
1850
|
/** {zh}
|
|
1716
1851
|
* @detail config
|
|
1717
1852
|
* @brief 内置的推流视频质量。
|
|
@@ -1796,4 +1931,21 @@ declare enum VIDEO_DEFAULT_QUALITY {
|
|
|
1796
1931
|
'1080p-3' = "1920x1080x30x3150"
|
|
1797
1932
|
}
|
|
1798
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
|
+
|
|
1799
1951
|
export { }
|