aliyun-rtc-sdk 7.1.4 → 7.1.5

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.
@@ -1437,6 +1437,7 @@ interface PackageAdaptInfo {
1437
1437
  }
1438
1438
  interface JoinResult {
1439
1439
  l1ip?: string;
1440
+ l1subip?: string;
1440
1441
  pushstreamurl: string;
1441
1442
  tid: string;
1442
1443
  users: JoinInfo[];
@@ -1786,1722 +1787,1737 @@ interface LogInfo {
1786
1787
  [key: string]: string | number;
1787
1788
  }
1788
1789
 
1789
- declare enum AliRtcLogLevel {
1790
- DEBUG = 0,
1791
- INFO = 1,
1792
- API = 2,
1793
- WARNING = 3,
1794
- ERROR = 4,
1795
- NONE = 5
1790
+ interface VideoScalerOptions {
1791
+ width: number;
1792
+ height: number;
1793
+ frameRate: number;
1796
1794
  }
1797
-
1798
- interface AliRtcScreenShareStartConfig {
1799
- audio?: boolean;
1800
- videoTrack?: MediaStreamVideoTrack;
1801
- audioTrack?: MediaStreamAudioTrack;
1795
+ interface VideoScaler {
1796
+ getVideoTrack: () => MediaStreamTrack;
1797
+ updateOptions: (options: VideoScalerOptions) => void;
1798
+ dispose: () => void;
1802
1799
  }
1803
1800
 
1804
- declare enum AliRtcLiveTranscodingMixMode {
1805
- /*! 单路模式 */
1806
- LiveTranscodingSingle = 0,
1807
- /*! 混流模式 */
1808
- LiveTranscodingMix = 1
1809
- }
1810
- declare enum AliRtcLiveTranscodingStreamType {
1811
- /*! 原始流 */
1812
- LiveTranscodingOrigin = 0,
1813
- /*! 音频 */
1814
- LiveTranscodingAudio = 1,
1815
- /*! 视频 */
1816
- LiveTranscodingVideo = 2
1817
- }
1818
- declare enum AliRtcLiveTranscodingSourceType {
1819
- /*! 相机流 */
1820
- LiveTranscodingCamera = 0,
1821
- /*! 屏幕流 */
1822
- LiveTranscodingShareScreen = 1
1823
- }
1824
- declare enum AliRtcLiveTranscodingTaskProfile {
1825
- LiveTranscoding_Profile_1IN_1080P = 0,
1826
- LiveTranscoding_Profile_1IN_720P = 1,
1827
- LiveTranscoding_Profile_1IN_360P = 2,
1828
- LiveTranscoding_Profile_2IN_1080P = 3,
1829
- LiveTranscoding_Profile_2IN_720P = 4,
1830
- LiveTranscoding_Profile_2IN_360P = 5,
1831
- LiveTranscoding_Profile_4IN_1080P = 6,
1832
- LiveTranscoding_Profile_4IN_720P = 7,
1833
- LiveTranscoding_Profile_4IN_360P = 8,
1834
- LiveTranscoding_Profile_9IN_1080P = 9,
1835
- LiveTranscoding_Profile_9IN_720P = 10,
1836
- LiveTranscoding_Profile_9IN_360P = 11,
1837
- LiveTranscoding_Profile_12IN_1080P = 12,
1838
- LiveTranscoding_Profile_12IN_720P = 13,
1839
- LiveTranscoding_Profile_12IN_360P = 14,
1840
- LiveTranscoding_Profile_16IN_1080P = 15,
1841
- LiveTranscoding_Profile_16IN_720P = 16,
1842
- LiveTranscoding_Profile_16IN_360P = 17,
1843
- LiveTranscoding_Profile_Mixed = 9999
1844
- }
1845
- declare enum AliRtcLiveTranscodingAudioSampleRate {
1846
- LiveTranscoding_HZ_48000 = 48000,
1847
- LiveTranscoding_HZ_44100 = 44100,
1848
- LiveTranscoding_HZ_32000 = 32000,
1849
- LiveTranscoding_HZ_16000 = 16000,
1850
- LiveTranscoding_HZ_8000 = 8000
1851
- }
1852
- declare enum AliRtcLiveTranscodingSegmentType {
1853
- /*! 无人像分割 */
1854
- LiveTranscodingNoBody = 0,
1855
- /*! 人像分割 */
1856
- LiveTranscodingBody = 1
1857
- }
1858
- declare enum AliRtcLiveTranscodingFontType {
1859
- NOTO_SERIF_CJKSC_REGULAR = 0,
1860
- ALIBABA_PUHUITI_REGULAR = 1,
1861
- ALIBABA_PUHUITI_BOLD = 2,
1862
- ALIBABA_PUHUITI_Heavy = 3,
1863
- ALIBABA_PUHUITI_LIGHT = 4,
1864
- ALIBABA_PUHUITI_MEDIUM = 5
1865
- }
1866
- declare enum AliRtcLiveTranscodingCropMode {
1867
- /*! 缩放模式 */
1868
- LiveTranscodingOrigin = 0,
1869
- /*! 剪裁 */
1870
- LiveTranscodingCrop = 1,
1871
- /*! 填充 */
1872
- LiveTranscodingFill = 2
1873
- }
1874
- declare enum AliRtcLiveTranscodingMediaProcessMode {
1875
- /*! 通用模式 */
1876
- LiveTranscodingNormal = 0,
1877
- /*! 虚拟背景模式 */
1878
- LiveTranscodingVirtualBackground = 1
1879
- }
1880
- declare enum AliRtcLiveTranscodingState {
1881
- LiveTranscodingState_IDLE = 0,
1882
- LiveTranscodingState_CONNNECT = 1,
1883
- LiveTranscodingState_RUNNING = 2,
1884
- LiveTranscodingState_RECOVERING = 3,
1885
- LiveTranscodingState_FAILURE = 4,
1886
- LiveTranscodingState_END = 5
1887
- }
1888
- declare enum AliRtcLiveTranscodingErrorCode {
1889
- LiveTranscodingErrorPublishOk = 0,
1890
- LiveTranscodingErrorStreamNotFound = 17825793,
1891
- LiveTranscodingErrorStreamAlreadyExist = 17825794,
1892
- LiveTranscodingErrorInvalidParam = 17825795,
1893
- LiveTranscodingErrorInternalError = 17825796,
1894
- LiveTranscodingErrorRtmpServerError = 17825797,
1895
- LiveTranscodingErrorRtmpStreamUrlError = 17825798,
1896
- LiveTranscodingErrorPublishTimeout = 17825799,
1897
- LiveTranscodingErrorNotAuthorized = 17825800
1801
+ declare class VideoScalerFactory {
1802
+ static isSupport(): boolean;
1803
+ /**
1804
+ * 获取实例
1805
+ * @param {MediaStreamTrack} videoTrack
1806
+ * @param {IProfile} profile
1807
+ * @return {VideoScaler}
1808
+ */
1809
+ static getInstance(videoTrack: MediaStreamTrack, options: VideoScalerOptions): VideoScaler;
1898
1810
  }
1899
- declare enum AliRtcTrascodingPublishTaskStatus {
1900
- /*! 任务开始 */
1901
- TrascodingPublishTaskStatusStart = 0,
1902
- /*! 任务更新 */
1903
- TrascodingPublishTaskStatusUpdate = 1,
1904
- /*! 任务已停止 */
1905
- TrascodingPublishTaskStatusStop = 2
1811
+
1812
+ interface AudioLevelMonitorListener {
1813
+ audioLevel: (level: number) => void;
1906
1814
  }
1907
- declare enum MPU_TASK_TRANSACTION_TYPE {
1908
- MPU_TASK_TRANSACTION_START = 0,
1909
- MPU_TASK_TRANSACTION_UPDATE = 1,
1910
- MPU_TASK_TRANSACTION_STOP = 2,
1911
- MPU_TASK_TRANSACTION_LIST = 3,
1912
- MPU_TASK_TRANSACTION_POLLING = 4,
1913
- MPU_TASK_TRANSACTION_ACKNOWLEDGE = 5,
1914
- MPU_TASK_TRANSACTION_END = 6
1815
+ declare class AudioLevelMonitor extends EventEmitter$1<AudioLevelMonitorListener> {
1816
+ private audioContext;
1817
+ private stream;
1818
+ private sourceNode?;
1819
+ private analyser?;
1820
+ constructor();
1821
+ getLevel(): number;
1822
+ /**
1823
+ * 开启监听 audio level 的变化
1824
+ *
1825
+ * @param {MediaStreamTrack} track 音频轨
1826
+ * @param {number} [interval=1000] 检测间隔,单位毫秒,默认 1000ms
1827
+ */
1828
+ start(track: MediaStreamTrack, interval?: number): void;
1829
+ stop(): void;
1830
+ dispose(): void;
1915
1831
  }
1916
1832
 
1917
- declare class AliRtcLiveTranscodingEncodeParam {
1918
- videoWidth: number;
1919
- videoHeight: number;
1920
- videoFramerate: number;
1921
- videoBitrate: number;
1922
- videoGop: number;
1923
- audioSamplerate: AliRtcLiveTranscodingAudioSampleRate;
1924
- audioBitrate: number;
1925
- audioChannels: number;
1926
- constructor(videoWidth: number, videoHeight: number, videoFramerate?: number, videoBitrate?: number, videoGop?: number, audioSamplerate?: AliRtcLiveTranscodingAudioSampleRate, audioBitrate?: number, audioChannels?: number);
1833
+ declare class LocalProfileManager {
1834
+ private defaultProfile;
1835
+ profile?: string;
1836
+ profileMap: Map<string, IProfile>;
1837
+ audioProfile?: AudioProfileKey;
1838
+ contentHint?: string;
1839
+ constructor(defaultProfile?: IProfile);
1840
+ updateProfile(profileKey: string, profileValue?: Partial<IProfile>): void;
1841
+ get videoProfile(): string | undefined;
1842
+ updateAudioProfile(profileKey: AudioProfileKey): void;
1843
+ setContentHint(videoTrack: MediaStreamTrack | undefined, contentHint?: string): void;
1844
+ /**
1845
+ * 更新源流 Constraints
1846
+ * 更新 PeerConnectiong Sender 相关配置
1847
+ * @param stream
1848
+ */
1849
+ setVideoProfile(originVideoTrack: MediaStreamTrack | undefined, target: LocalStream | undefined, skipConstraints?: boolean): Promise<void>;
1927
1850
  }
1928
1851
 
1929
- declare class AliRtcTranscodingClockWidget {
1930
- x: number;
1931
- y: number;
1932
- fontSize: number;
1933
- zOrder: number;
1934
- fontColor: number;
1935
- fontType: AliRtcLiveTranscodingFontType;
1936
- constructor(x: number, y: number, fontSize: number);
1937
- constructor(x: number, y: number, fontSize: number, zOrder: number);
1938
- constructor(x: number, y: number, fontSize: number, zOrder: number, fontColor: number);
1939
- constructor(x: number, y: number, fontSize: number, zOrder: number, fontColor: number, fontType: AliRtcLiveTranscodingFontType);
1940
- toJson(videoWidth: number, videoHeight: number): {
1941
- x: number;
1942
- y: number;
1943
- fonttype: AliRtcLiveTranscodingFontType;
1944
- fontsize: number;
1945
- fontcolor: number;
1946
- zorder: number;
1947
- };
1852
+ interface PublishStreamInfo {
1853
+ audio?: LocalStream;
1854
+ video?: LocalStream;
1855
+ videoSmall?: LocalStream;
1856
+ screen?: LocalStream;
1857
+ videoProfile?: LocalProfileManager;
1858
+ screenProfile?: LocalProfileManager;
1948
1859
  }
1949
1860
 
1950
- declare enum DisplayType {
1951
- NOT_DISPLAY = 0,
1952
- ALWAYS = 1,
1953
- WHEN_NO_VIDEO = 2
1861
+ interface PluginManagerListener {
1862
+ added: (plugin: AliRtcPlugin) => void;
1863
+ removed: (plugin: AliRtcPlugin) => void;
1864
+ updated: (plugin: AliRtcPlugin) => void;
1954
1865
  }
1955
- declare class AliRtcTranscodingImage {
1956
- static DisplayType: typeof DisplayType;
1957
- url: string;
1958
- x: number;
1959
- y: number;
1960
- width: number;
1961
- height: number;
1962
- alpha: number;
1963
- display: DisplayType;
1964
- zOrder: number;
1965
- constructor(url: string, x: number, y: number, width: number, height: number);
1966
- constructor(url: string, x: number, y: number, width: number, height: number, zOrder: number);
1967
- constructor(url: string, x: number, y: number, width: number, height: number, zOrder: number, alpha: number);
1968
- constructor(url: string, x: number, y: number, width: number, height: number, zOrder: number, alpha: number, display: DisplayType);
1969
- toJson(videoWidth: number, videoHeight: number): {
1970
- url: string;
1971
- alpha: number;
1972
- display: DisplayType;
1973
- x: number;
1974
- y: number;
1975
- width: number;
1976
- height: number;
1977
- zorder: number;
1978
- };
1866
+ declare class PluginManager extends EventEmitter$1<PluginManagerListener> {
1867
+ private plugins;
1868
+ add(plugin: AliRtcPlugin, options?: any): void;
1869
+ remove(name: string): void;
1870
+ removeAll(): void;
1871
+ get(name: string): AliRtcPlugin | undefined;
1872
+ has(name: string): boolean;
1873
+ getAll(): AliRtcPlugin[];
1979
1874
  }
1980
1875
 
1981
- declare class AliRtcTranscodingText {
1982
- text: string;
1983
- x: number;
1984
- y: number;
1985
- fontSize: number;
1986
- zOrder: number;
1987
- fontColor: number;
1988
- fontType: AliRtcLiveTranscodingFontType;
1989
- constructor(text: string, x: number, y: number, fontSize: number);
1990
- constructor(text: string, x: number, y: number, fontSize: number, zOrder: number);
1991
- constructor(text: string, x: number, y: number, fontSize: number, zOrder: number, fontColor: number);
1992
- constructor(text: string, x: number, y: number, fontSize: number, zOrder: number, fontColor: number, fontType: AliRtcLiveTranscodingFontType);
1993
- toJson(videoWidth: number, videoHeight: number): {
1994
- text: string;
1995
- x: number;
1996
- y: number;
1997
- fonttype: AliRtcLiveTranscodingFontType;
1998
- fontsize: number;
1999
- fontcolor: number;
2000
- zorder: number;
2001
- };
2002
- }
2003
-
2004
- declare class AliRtcTranscodingUser {
2005
- userId: string;
2006
- x: number;
2007
- y: number;
2008
- width: number;
2009
- height: number;
2010
- zOrder?: number;
2011
- sourceType?: AliRtcLiveTranscodingSourceType;
2012
- segmentType: AliRtcLiveTranscodingSegmentType;
2013
- images: AliRtcTranscodingImage[];
2014
- texts: AliRtcTranscodingText[];
2015
- constructor(userId: string, x: number, y: number, width: number, height: number);
2016
- constructor(userId: string, x: number, y: number, width: number, height: number, zOrder: number);
2017
- constructor(userId: string, x: number, y: number, width: number, height: number, zOrder: number, sourceType: AliRtcLiveTranscodingSourceType);
2018
- toJson(index: number, videoWidth: number, videoHeight: number, mediaProcessMode?: AliRtcLiveTranscodingMediaProcessMode): {
2019
- [key: string]: any;
2020
- };
2021
- }
2022
-
2023
- declare class LiveTranscodingMixParam {
2024
- taskProfile: AliRtcLiveTranscodingTaskProfile;
2025
- encodeParam?: AliRtcLiveTranscodingEncodeParam;
2026
- users: AliRtcTranscodingUser[];
2027
- backgroundColor: number;
2028
- backgrounds: AliRtcTranscodingImage[];
2029
- watermarks: AliRtcTranscodingImage[];
2030
- clockWidgets: AliRtcTranscodingClockWidget[];
2031
- cropMode?: AliRtcLiveTranscodingCropMode;
2032
- mediaProcessMode?: AliRtcLiveTranscodingMediaProcessMode;
2033
- constructor(taskProfile: AliRtcLiveTranscodingTaskProfile);
2034
- }
2035
-
2036
- declare class AliRtcLiveTranscodingSingleParam {
2037
- userId?: string;
2038
- streamType?: AliRtcLiveTranscodingStreamType;
2039
- sourceType?: AliRtcLiveTranscodingSourceType;
2040
- constructor(uid?: string, streamType?: AliRtcLiveTranscodingStreamType, sourceType?: AliRtcLiveTranscodingSourceType);
2041
- }
2042
-
2043
- declare class AliRtcLiveTranscodingParam {
2044
- /*! 旁路模式 */
2045
- mixMode: AliRtcLiveTranscodingMixMode;
2046
- /*! 路模式单路参数 */
2047
- singleParam?: AliRtcLiveTranscodingSingleParam;
2048
- /*! 旁路模式混流参数 */
2049
- mixParam?: LiveTranscodingMixParam;
2050
- constructor(mixMode?: AliRtcLiveTranscodingMixMode, singleParam?: AliRtcLiveTranscodingSingleParam, mixParam?: LiveTranscodingMixParam);
2051
- toJson(type: MPU_TASK_TRANSACTION_TYPE, authInfo: AliRtcAuthInfo, taskId: string, streamUrl?: string, messageId?: string): {
2052
- [key: string]: any;
2053
- };
2054
- }
2055
-
2056
- interface AliRtcLocalAudioStats {
2057
- track: AliRtcAudioTrack;
2058
- stats: any;
2059
- }
2060
-
2061
- interface AliRtcLocalVideoStats {
2062
- track: AliRtcVideoTrack;
2063
- streamType?: AliRtcVideoStreamType;
2064
- stats: any;
2065
- }
2066
-
2067
- interface AliRtcRemoteAudioStats {
2068
- uid: string;
2069
- track: AliRtcAudioTrack;
2070
- stats: any;
2071
- }
2072
-
2073
- interface AliRtcRemoteVideoStats {
2074
- uid: string;
2075
- track: AliRtcVideoTrack;
2076
- streamType?: AliRtcVideoStreamType;
2077
- stats: any;
2078
- }
2079
-
2080
- declare enum AliRtcDataMsgType {
2081
- AliEngineDataMsgNone = 0,
2082
- AliEngineDataMsgMusicProgress = 1,
2083
- AliEngineDataMsgCustom = 2
2084
- }
2085
- declare class AliRtcDataChannelMsg {
2086
- data: ArrayBuffer;
2087
- networkTime: number;
2088
- futureOrProgress: number;
2089
- type: AliRtcDataMsgType;
2090
- constructor(data: ArrayBuffer, type?: AliRtcDataMsgType, networkTime?: number, progress?: number);
2091
- toBuffer(): ArrayBuffer;
2092
- static parse(buffer: ArrayBuffer): AliRtcDataChannelMsg | undefined;
1876
+ interface LocalStreamManagerListener {
1877
+ trackended: (type: TrackEvent) => {};
1878
+ publishupdate: () => {};
2093
1879
  }
2094
-
2095
- interface AliRtcEngineEventListener {
1880
+ declare class LocalStreamManager extends EventEmitter$1<LocalStreamManagerListener> {
2096
1881
  /**
2097
- * @brief 网络连接状态改变
2098
- * @param status 连接状态
2099
- * @param reason 连接状态变化原因
1882
+ * @ignore
2100
1883
  */
2101
- connectionStatusChange: (status: AliRtcConnectionStatus, reason: AliRtcConnectionStatusChangeReason) => void;
1884
+ static logName: string;
1885
+ private pluginManager;
1886
+ private slsReporter;
1887
+ private publishingCameraVideoStream;
1888
+ private publishingScreenVideoStream;
1889
+ cameraStreamInfo: AliRtcLocalStreamInfo;
1890
+ screenStreamInfo: AliRtcLocalStreamInfo;
1891
+ private streamInfos;
1892
+ private _audioCaptureDisabled;
1893
+ private _cameraCaptureDisabled;
1894
+ private _publishLocalAudioStreamEnabled;
1895
+ private _publishLocalVideoStreamEnabled;
1896
+ private _publishLocalScreenStreamEnabled;
1897
+ constructor(pluginManager: PluginManager, slsReporter: SLSReporter);
1898
+ get hasCamera(): boolean;
1899
+ get audioCaptureDisabled(): boolean;
1900
+ set audioCaptureDisabled(closed: boolean);
1901
+ get cameraCaptureDisabled(): boolean;
1902
+ set cameraCaptureDisabled(closed: boolean);
1903
+ setAudioMuted(muted: boolean): void;
1904
+ get isAudioMuted(): boolean;
1905
+ setCameraMuted(muted: boolean): void;
1906
+ get isCameraMuted(): boolean;
1907
+ setScreenMuted(muted: boolean): void;
1908
+ get isScreenMuted(): boolean;
1909
+ get publishLocalAudioStreamEnabled(): boolean;
1910
+ set publishLocalAudioStreamEnabled(enable: boolean);
1911
+ get publishLocalVideoStreamEnabled(): boolean;
1912
+ set publishLocalVideoStreamEnabled(enable: boolean);
1913
+ get publishLocalScreenStreamEnabled(): boolean;
1914
+ set publishLocalScreenStreamEnabled(enable: boolean);
1915
+ updateStreams(): Promise<void>;
1916
+ private setAvailableCameraDeviceId;
1917
+ private setAvailableMicrophoneDeviceId;
2102
1918
  /**
2103
- * @brief 本地设备异常回调
2104
- * @param deviceType 设备类型, 参考{@link AliRtcEngine.AliRtcEngineLocalDeviceType}
2105
- * @param exceptionType 设备异常类型, 参考{@link AliRtcEngine.AliRtcEngineLocalDeviceExceptionType}
2106
- * @param msg 异常时携带的信息
2107
- * @note 此回调标识了内部无法恢复了设备异常,收到此回调时用户需要检查设备是否可用
1919
+ * 创建 LocalStream
1920
+ * @param {LocalStreamConfig} params 创建 LocalStream 的配置
1921
+ * @returns {LocalStream} 当前创建的 LocalStream
2108
1922
  */
2109
- localDeviceException: (localDeviceType: AliRtcEngineLocalDeviceType, localDeviceExceptionType: AliRtcEngineLocalDeviceExceptionType, description: string) => void;
1923
+ createLocalStream(params: LocalStreamConfig): Promise<LocalStream | undefined>;
2110
1924
  /**
2111
- * @brief 用户鉴权信息即将过期通知,收到后30秒鉴权过期
2112
- * @note 该回调在鉴权信息30秒前触发,收到该回调后应该及时更新鉴权信息,参考 {@link AliRtcEngine.refreshAuthInfo}
1925
+ * 停止推流,底层调用 rts publishStop,不会导致 DC 马上关闭。适合暂时停推的场景
1926
+ * @param {StopPublishOptions} options
1927
+ * @returns {Promise<PublishStreamInfo>} 如果返回了 audio,则表示需要更新音频流
2113
1928
  */
1929
+ stopLocalStream(options: StopPublishOptions): Promise<void>;
1930
+ get publishStreams(): PublishStreamInfo;
1931
+ createHTTPPublishStream(): Promise<{
1932
+ publishStream: LocalStream | undefined;
1933
+ videoSmallStream: LocalStream | undefined;
1934
+ screenStream: LocalStream | undefined;
1935
+ vMsid: string | undefined;
1936
+ }>;
2114
1937
  /**
2115
- * 被服务器踢出/会议结束频道的消息
2116
- * @param code 原因参考{@link AliRtcEngine.AliRtcOnByeType}
1938
+ * 停止所有流
2117
1939
  */
2118
- bye: (code: AliRtcOnByeType) => void;
1940
+ stop(): void;
2119
1941
  /**
2120
- * @brief 远端用户(通信模式)/(互动模式,主播角色)加入频道回调
2121
- * @details 该回调在以下场景会被触发
2122
- * - 通信模式:远端用户加入频道会触发该回调,如果当前用户在加入频道前已有其他用户在频道中,当前用户加入频道后也会收到已加入频道用户的回调
2123
- * - 互动模式:
2124
- * - 远端主播角色用户加入频道会触发该回调,如果当前用户在加入频道前已有其他主播在频道中,当前用户加入频道后也会收到已加入频道主播的回调
2125
- * - 远端观众角色调用 {@link AliRtcEngine.setClientRole} 切换为主播角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkInteractive},同时设置了推流时,会触发该回调
2126
- *
2127
- * @param uid 用户ID,从App server分配的唯一标示符
2128
- * @param elapsed 用户加入频道时的耗时
2129
- * @note 互动模式下回调行为
2130
- * - 主播间可以互相收到加入频道回调
2131
- * - 观众可以收到主播加入频道回调
2132
- * - 主播无法收到观众加入频道回调
1942
+ * 设置摄像头流 profile
1943
+ * @param {LocalStream | null} stream
1944
+ * @param {string} profileKey
1945
+ * @param {IProfile} profile
2133
1946
  */
2134
- remoteUserOnLineNotify: (uid: string, elapsed: number) => void;
1947
+ setVideoProfile(profileKey?: string, profile?: Partial<IProfile>, skipConstraints?: boolean): Promise<void>;
2135
1948
  /**
2136
- * @brief 远端用户(通信模式)/(互动模式,主播角色)离开频道回调
2137
- * @details 该回调在以下场景会被触发
2138
- * - 通信模式:远端用户离开频道会触发该回调
2139
- * - 互动模式:
2140
- * - 远端主播角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkInteractive} 离开频道
2141
- * - 远端主播切换调用 {@link AliRtcEngine.setClientRole} 切换为观众角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkLive},会触发该回调
2142
- * - 通信模式和互动模式主播角色情况下,当长时间收不到远端用户数据,超时掉线时,会触发该回调
2143
- *
2144
- * @param uid 用户ID,从App server分配的唯一标示符
2145
- * @param reason 用户离线的原因,详见 {@link AliRtcEngine.AliRtcUserOfflineReason}
1949
+ * 设置摄像头流 content hint
1950
+ * @param {string} hint
1951
+ * @note 不传则尝试复用之前的 hint
2146
1952
  */
2147
- remoteUserOffLineNotify: (uid: string, aliRtcUserOfflineReason: AliRtcUserOfflineReason) => void;
1953
+ setVideoContentHint(hint?: string): void;
2148
1954
  /**
2149
- * @brief 远端用户的音视频流发生变化回调
2150
- * @details 该回调在以下场景会被触发
2151
- * - 当远端用户从未推流变更为推流(包括音频和视频)
2152
- * - 当远端用户从已推流变更为未推流(包括音频和视频)
2153
- * - 互动模式下,调用 {@link AliRtcEngine.setClientRole} 切换为主播角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkInteractive},同时设置了推流时,会触发该回调
2154
- *
2155
- * @param uid 用户ID,从App server分配的唯一标示符
2156
- * @param audioTrack 音频流类型,详见 {@link AliRtcEngine.AliRtcAudioTrack}
2157
- * @param videoTrack 视频流类型,详见 {@link AliRtcEngine.AliRtcVideoTrack}
2158
- * @note 该回调仅在通信模式用户和互动模式下的主播角色才会触发
1955
+ * 设置音频流 profile
1956
+ * @param {string} profileKey
2159
1957
  */
2160
- remoteTrackAvailableNotify: (uid: string, aliRtcAudioTrack: AliRtcAudioTrack, aliRtcVideoTrack: AliRtcVideoTrack) => void;
1958
+ setAudioProfile(profileKey: AudioProfileKey): Promise<void>;
2161
1959
  /**
2162
- * @brief 远端用户静音/取消静音回调
2163
- * @param uid 远端用户ID
2164
- * @param isMute 该用户是否静音
2165
- * - true: 静音
2166
- * - false: 取消静音
1960
+ * 设置屏幕共享流 profile
1961
+ * @param {LocalStream} stream
1962
+ * @param {string} profileKey
1963
+ * @param {IProfile} profile
2167
1964
  */
2168
- userAudioMuted: (uid: string, isMute: boolean) => void;
1965
+ setScreenProfile(profileKey?: string, profile?: Partial<IProfile>): Promise<void>;
1966
+ setScreenContentHint(hint?: string): void;
2169
1967
  /**
2170
- * @brief 对端用户发送视频黑帧数据发送通知
2171
- * @param uid 执行muteVideo的用户ID
2172
- * @param isMute
2173
- * - true: 推流黑帧
2174
- * - false: 正常推流
2175
- * @note 该接口用于对端用户发送视频黑帧数据时的回调
1968
+ * 设置 cameraVideoConstraints
1969
+ * @param {IVideoConstraints} cameraVideoConstraints
2176
1970
  */
2177
- userVideoMuted: (uid: string, isMute: boolean) => void;
1971
+ setCameraVideoConstraints(cameraVideoConstraints: MediaTrackConstraints): void;
2178
1972
  /**
2179
- * @brief 对端用户发送屏幕黑帧数据发送通知
2180
- * @param uid 执行muteVideo的用户ID
2181
- * @param isMute
2182
- * - true: 推流黑帧
2183
- * - false: 正常推流
2184
- * @note 该接口用于对端用户发送屏幕黑帧数据时的回调
2185
- */
2186
- userScreenMuted: (uid: string, isMute: boolean) => void;
2187
- /**
2188
- * 音量反馈
2189
- * @param {Array} speakers 用户音量对象数组
2190
- * @param {string} speaker.userId 用户ID
2191
- * @param {number} speaker.volume 音量
2192
- * @note userId 为空字符串时代表是本地麦克风采集的音量
2193
- */
2194
- audioVolume: (speakers: {
2195
- userId: string;
2196
- volume: number;
2197
- }[]) => void;
2198
- /**
2199
- * 发布视频流的数据统计
2200
- * @param aliRtcStats 统计信息
2201
- */
2202
- aliRtcStats: (aliRtcStats: any) => void;
2203
- /**
2204
- * 音频推流变更回调
2205
- * @param track 流标识
2206
- * @param oldState 之前的推流状态
2207
- * @param newState 当前的推流状态
2208
- * @param elapseSinceLastState 状态变更时间间隔(毫秒)
2209
- * @param channel 当前频道
1973
+ * 设置 micAudioConstraints
1974
+ * @param {IAudioConstraints} micAudioConstraints
2210
1975
  */
2211
- audioPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
1976
+ setMicAudioConstraints(micAudioConstraints: MediaTrackConstraints): void;
1977
+ }
1978
+
1979
+ interface DeviceStatus {
1980
+ micOpen: boolean;
1981
+ micInterrupted: boolean;
1982
+ audioDisable: boolean;
1983
+ cameraOpen: boolean;
1984
+ videoDisable: boolean;
1985
+ screenShare: boolean;
1986
+ screenDisable: boolean;
1987
+ backgroundMode: boolean;
1988
+ accompanyPlaying: boolean;
1989
+ }
1990
+
1991
+ interface UpdateTracksResult {
1992
+ restoreSub?: boolean;
1993
+ }
1994
+ declare class RemoteStreamInfo extends EventEmitter$1<StreamListener> {
2212
1995
  /**
2213
- * 音频订阅情况变更回调
2214
- * @param uid 用户ID
2215
- * @param oldState 之前的订阅状态
2216
- * @param newState 当前的订阅状态
2217
- * @param elapseSinceLastState 状态变更时间间隔(毫秒)
2218
- * @param channel 当前频道
1996
+ * @ignore
2219
1997
  */
2220
- audioSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
1998
+ static logName: string;
1999
+ protected audioInfo: RemoteMediaTrackInfo;
2000
+ protected videoLargeInfo: RemoteMediaTrackInfo;
2001
+ protected videoSmallInfo: RemoteMediaTrackInfo;
2002
+ protected screenInfo: RemoteMediaTrackInfo;
2003
+ protected dataInfo: RemoteMediaTrackInfo;
2004
+ protected audioVolume: number;
2005
+ protected audioMuted: boolean;
2006
+ protected userStatus?: DeviceStatus;
2007
+ constructor();
2221
2008
  /**
2222
- * 视频推流变更回调
2223
- * @param oldState 之前的推流状态
2224
- * @param newState 当前的推流状态
2225
- * @param elapseSinceLastState 状态变更时间间隔(毫秒)
2226
- * @param channel 当前频道
2009
+ * 远端流音频轨道信息
2010
+ * @returns
2227
2011
  */
2228
- videoPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
2012
+ getAudioInfo(): RemoteMediaTrackInfo;
2229
2013
  /**
2230
- * 次要流推流变更回调
2231
- * @param oldState 之前的推流状态
2232
- * @param newState 当前的推流状态
2233
- * @param elapseSinceLastState 状态变更时间间隔(毫秒)
2234
- * @param channel 当前频道
2014
+ * 远端流视频轨道信息
2015
+ * @returns
2235
2016
  */
2236
- dualStreamPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
2017
+ getVideoSmallInfo(): RemoteMediaTrackInfo;
2237
2018
  /**
2238
- * 屏幕分享推流变更回调
2239
- * @param oldState 之前的推流状态
2240
- * @param newState 当前的推流状态
2241
- * @param elapseSinceLastState 状态变更时间间隔(毫秒)
2242
- * @param channel 当前频道
2019
+ * 远端流视频轨道信息
2020
+ * @returns
2243
2021
  */
2244
- screenSharePublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
2022
+ getVideoLargeInfo(): RemoteMediaTrackInfo;
2245
2023
  /**
2246
- * DataChannel 推流变更回调
2247
- * @param oldState 之前的推流状态
2248
- * @param newState 当前的推流状态
2249
- * @param elapseSinceLastState 状态变更时间间隔(毫秒)
2250
- * @param channel 当前频道
2024
+ * 远端流屏幕共享轨道信息
2025
+ * @returns
2251
2026
  */
2252
- dataPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
2027
+ getScreenInfo(): RemoteMediaTrackInfo;
2028
+ getDataInfo(): RemoteMediaTrackInfo;
2029
+ get subscribingInfos(): RemoteMediaTrackInfo[];
2030
+ get hasTrack(): boolean;
2253
2031
  /**
2254
- * 相机流订阅情况变更回调
2255
- * @param uid 用户ID
2256
- * @param oldState 之前的订阅状态
2257
- * @param newState 当前的订阅状态
2258
- * @param elapseSinceLastState 状态变更时间间隔(毫秒)
2259
- * @param channel 当前频道
2032
+ * 远端流是否包含音频轨道
2033
+ * @returns
2260
2034
  */
2261
- videoSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
2035
+ get hasAudio(): boolean;
2262
2036
  /**
2263
- * 大小流订阅情况变更回调
2264
- * @param uid 用户ID
2265
- * @param oldStreamType 之前的订阅状态
2266
- * @param newStreamType 当前的订阅状态
2267
- * @param elapseSinceLastState 状态变更时间间隔(毫秒)
2268
- * @param channel 当前频道
2037
+ * 远端流是否包含视频轨道
2038
+ * @returns
2269
2039
  */
2270
- subscribeStreamTypeChanged: (uid: string, oldStreamType: AliRtcVideoStreamType, newStreamType: AliRtcVideoStreamType, elapseSinceLastState: number, channel: string) => void;
2040
+ get hasVideo(): boolean;
2271
2041
  /**
2272
- * 屏幕分享流订阅情况变更回调
2273
- * @param uid 用户ID
2274
- * @param oldState 之前的订阅状态
2275
- * @param newState 当前的订阅状态
2276
- * @param elapseSinceLastState 状态变更时间间隔(毫秒)
2277
- * @param channel 当前频道
2042
+ * 远端流是否包含视频大流轨道
2043
+ * @returns
2278
2044
  */
2279
- screenShareSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
2045
+ get hasVideoLarge(): boolean;
2280
2046
  /**
2281
- * DataChannel 订阅情况变更回调
2282
- * @param uid 用户ID
2283
- * @param oldState 之前的订阅状态
2284
- * @param newState 当前的订阅状态
2285
- * @param elapseSinceLastState 状态变更时间间隔(毫秒)
2286
- * @param channel 当前频道
2047
+ * 远端流是否包含视频小流轨道
2048
+ * @returns
2287
2049
  */
2288
- dataSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
2050
+ get hasVideoSmall(): boolean;
2289
2051
  /**
2290
- * 收到媒体扩展信息回调
2291
- * @param uid 用户ID,媒体信息发送用户的ID
2292
- * @param message 媒体扩展信息
2293
- * @param payloadType payload类型,sendMediaExtensionMsg返回5,sendMediaExtensionMsgEx发送的会返回具体类型
2294
- * @note 当一端通过 {@link AliRtcEngine.sendMediaExtensionMsg} 发送信息后,其他端通过该回调接收数据
2052
+ * 远端流是否包含屏幕共享轨道
2053
+ * @returns
2295
2054
  */
2296
- mediaExtensionMsgReceived: (uid: string, message: ArrayBuffer, payloadType: number) => void;
2055
+ get hasScreen(): boolean;
2056
+ get hasData(): boolean;
2297
2057
  /**
2298
- * @brief 用户鉴权信息即将过期通知,收到后30秒鉴权过期
2299
- * @note 该回调在鉴权信息30秒前触发,收到该回调后应该及时更新鉴权信息,参考 {@link AliRtcEngine.refreshAuthInfo:}
2058
+ * 是否订阅远端流音频轨道
2059
+ * @returns
2300
2060
  */
2301
- authInfoWillExpire: () => void;
2061
+ get isAudioSubscribed(): boolean;
2062
+ get isAudioSubscribing(): boolean;
2302
2063
  /**
2303
- * @brief 用户调用需要鉴权的接口,服务端返回信息过期
2304
- * @note 该回调触发代表鉴权信息已过期,想要继续在会中,需要重新入会,参考 {@link AliRtcEngine.joinChannel:name:onResultWithUserId:}
2064
+ * 是否订阅远端流视频轨道
2065
+ * @returns
2305
2066
  */
2306
- authInfoExpired: () => {};
2067
+ get isVideoSubscribed(): boolean;
2068
+ get isVideoSubscribing(): boolean;
2307
2069
  /**
2308
- * 远程用户的音频自动播放失败
2309
- * @param uid
2310
- * @note 应该在收到该回调时弹出弹窗引导用户点击页面进行播放,用户点击页面后 SDK 会自动尝试播放
2070
+ * 是否订阅远端流视频大流轨道
2071
+ * @returns
2311
2072
  */
2312
- remoteAudioAutoPlayFail: (uid: string) => void;
2073
+ get isVideoLargeSubscribed(): boolean;
2074
+ get isVideoLargeSubscribing(): boolean;
2313
2075
  /**
2314
- * 远程用户的视频自动播放失败
2315
- * @param uid
2316
- * @note 应该在收到该回调时弹出弹窗引导用户点击页面进行播放,用户点击页面后 SDK 会自动尝试播放
2076
+ * 是否订阅远端流视频小流轨道
2077
+ * @returns
2317
2078
  */
2318
- remoteVideoAutoPlayFail: (uid: string, videoTrack: AliRtcVideoTrack) => void;
2079
+ get isVideoSmallSubscribed(): boolean;
2080
+ get isVideoSmallSubscribing(): boolean;
2319
2081
  /**
2320
- * 远程用户的音频播放出错
2321
- * @param uid 用户ID
2322
- * @param reason 出错原因,可选
2082
+ * 是否订阅远端流屏幕共享轨道
2083
+ * @returns
2323
2084
  */
2324
- remoteAudioPlayError: (uid: string, reason: string | undefined) => void;
2085
+ get isScreenSubscribed(): boolean;
2086
+ get isScreenSubscribing(): boolean;
2087
+ get isDataSubscribed(): boolean;
2088
+ get isDataSubscribing(): boolean;
2089
+ get audioCodec(): CodecType;
2090
+ get videoCodec(): CodecType;
2091
+ get audioTrackInfo(): AliRtcAudioTrack;
2092
+ get videoTrackInfo(): AliRtcVideoTrack;
2093
+ updateTracks(tracks?: TrackInfo[]): UpdateTracksResult;
2094
+ protected updateRemoteTrackSsrc(audioSsrc: string, videoLargeSsrc: string, videoSmallSsrc: string, screenSsrc: string, dataSsrc: string): void;
2095
+ markRemoteTrackSubscribing(option: SubscribeOptions): any;
2096
+ updateRemoteTrackSubState(option: SubscribeOptions): any;
2325
2097
  /**
2326
- * 远程用户的视频播放出错
2327
- * @param uid 用户ID
2328
- * @param reason 出错原因,可选
2098
+ * 更新远端用户设备状态
2099
+ * @param status
2100
+ * @returns {boolean} 状态改变返回true,否则返回false
2329
2101
  */
2330
- remoteVideoPlayError: (uid: string, reason: string | undefined) => void;
2102
+ updateRemoteUserDeviceStatus(status: string): boolean;
2103
+ }
2104
+
2105
+ type AliRtcLocalView = string | HTMLVideoElement | string[] | HTMLVideoElement[] | null;
2106
+
2107
+ interface AliRtcRemoteAudioStats {
2108
+ uid: string;
2109
+ track: AliRtcAudioTrack;
2110
+ stats: any;
2111
+ }
2112
+
2113
+ interface AliRtcRemoteVideoStats {
2114
+ uid: string;
2115
+ track: AliRtcVideoTrack;
2116
+ streamType?: AliRtcVideoStreamType;
2117
+ stats: any;
2118
+ }
2119
+
2120
+ declare class AliRtcRemoteUserInfo {
2121
+ private remoteUser;
2122
+ constructor(remoteUser: RemoteUser);
2123
+ get userId(): string;
2124
+ get displayName(): string;
2125
+ get isMuteAudioPlaying(): boolean;
2126
+ get hasAudio(): boolean;
2127
+ get hasCamera(): boolean;
2128
+ get hasCameraLarge(): boolean;
2129
+ get hasCameraSmall(): boolean;
2130
+ get hasScreenShare(): boolean;
2131
+ get isAudioSubscribing(): boolean;
2132
+ get isVideoSubscribing(): boolean;
2133
+ get isVideoLargeSubscribing(): boolean;
2134
+ get isVideoSmallSubscribing(): boolean;
2135
+ get isScreenSubscribing(): boolean;
2136
+ get audioElement(): HTMLAudioElement | undefined;
2137
+ }
2138
+
2139
+ interface RemoteUserViewMap {
2140
+ cameraViews: HTMLVideoElement[];
2141
+ screenViews: HTMLVideoElement[];
2142
+ }
2143
+ declare class RemoteUser extends User {
2331
2144
  /**
2332
- * 远程用户订阅数据通道
2333
- * @param uid 用户ID
2145
+ * @ignore
2334
2146
  */
2335
- remoteUserSubscribedDataChannel: (uid: string) => void;
2336
- /**
2337
- * rtc 传输数据统计
2338
- * @param stats 统计信息
2339
- */
2340
- rtcStats: (stats: any) => void;
2147
+ static logName: string;
2148
+ remoteCallid: string;
2149
+ remoteUserInfo: AliRtcRemoteUserInfo;
2150
+ protected localUser?: LocalUser;
2151
+ protected lastPubId: string;
2152
+ protected stream?: RemoteStream;
2153
+ protected screenStream?: RemoteStream;
2154
+ private viewMap;
2155
+ private audioTrack?;
2156
+ private audioElement?;
2157
+ protected subscribed: boolean;
2158
+ protected mediaStream?: MediaStream;
2159
+ protected secondaryMediaStream?: MediaStream;
2160
+ protected prevSubConfig?: SubConfig;
2161
+ protected signalingManager: SignalingManager;
2162
+ protected slsReporter: SLSReporter;
2163
+ private wantSubAudio;
2164
+ private wantSubVideo;
2165
+ private wantSubScreen;
2166
+ private defaultVideoStreamType;
2167
+ private audioMuted;
2168
+ private playoutVolume;
2169
+ private playoutGainNode?;
2170
+ private audioSubState;
2171
+ private videoSubState;
2172
+ private videoLargeSubState;
2173
+ private videoSmallSubState;
2174
+ private screenSubState;
2175
+ private dataSubState;
2176
+ private dc;
2177
+ private dcMsgWaitingPieces;
2178
+ streamInfo: RemoteStreamInfo;
2179
+ private _streamUrl;
2180
+ private parameter;
2181
+ private monitorTimerId?;
2182
+ private monitorDataCache;
2183
+ private trackTraceIdMap;
2184
+ constructor(config: RemoteUserConfig);
2185
+ get streamUrl(): string;
2186
+ set streamUrl(value: string);
2187
+ isWantSubAudio(): boolean;
2188
+ setWantSubAudio(value: boolean): void;
2189
+ isWantSubVideo(): boolean;
2190
+ setWantSubVideo(value: boolean): void;
2191
+ isWantSubScreen(): boolean;
2192
+ setWantSubScreen(value: boolean): void;
2193
+ setRemoteDefaultVideoStreamType(type: AliRtcVideoStreamType): void;
2194
+ setAudioMuted(value: boolean): void;
2195
+ getAudioElement(): HTMLAudioElement | undefined;
2196
+ private handleAudioContextSuspended;
2197
+ setPlayoutVolume(value: number): void;
2198
+ getAudioMuted(): boolean;
2199
+ get hasAudioTrack(): boolean;
2200
+ get hasVideoTrack(): boolean;
2201
+ get hasVideoLargeTrack(): boolean;
2202
+ get hasVideoSmallTrack(): boolean;
2203
+ get hasScreenTrack(): boolean;
2204
+ get isAudioSubscribing(): boolean;
2205
+ get isVideoSubscribing(): boolean;
2206
+ get isVideoLargeSubscribing(): boolean;
2207
+ get isVideoSmallSubscribing(): boolean;
2208
+ get isScreenSubscribing(): boolean;
2209
+ get isDataSubscribing(): boolean;
2210
+ get audioEnabled(): boolean;
2211
+ get videoEnabled(): boolean;
2212
+ get screenEnabled(): boolean;
2213
+ get getAudioTrack(): MediaStreamAudioTrack | undefined;
2214
+ get getCameraStream(): RemoteStream | undefined;
2215
+ get getScreenStream(): RemoteStream | undefined;
2216
+ setViewConfig(view: AliRtcLocalView, track: AliRtcVideoTrack): void;
2341
2217
  /**
2342
- * 发布视频流的数据统计
2343
- * @param aliRtcStats 统计信息
2218
+ * 销毁
2219
+ * @returns {Promise<void>}
2344
2220
  */
2345
- rtcLocalVideoStats: (stats: AliRtcLocalVideoStats[]) => void;
2221
+ clear(needStopSub?: boolean): Promise<void>;
2346
2222
  /**
2347
- * 发布音频流的数据统计
2348
- * @param aliRtcStats 统计信息
2223
+ * 更新远端用户的设备状态
2224
+ * @param {string} status
2225
+ * @returns {void}
2349
2226
  */
2350
- rtcLocalAudioStats: (stats: AliRtcLocalAudioStats[]) => void;
2227
+ updateRemoteUserDeviceStatus(status: string): void;
2351
2228
  /**
2352
- * 订阅视频流的数据统计
2353
- * @param aliRtcStats 统计信息
2229
+ * 更新远端用户的推流状态,已经停止推流的 tracks 要 delete,或者整体 stop
2230
+ * @param {string} callid
2231
+ * @param {string} pullStreamUrl
2232
+ * @param {TrackInfo[]} tracks
2233
+ * @returns {Promise<TrackChangeState>}
2354
2234
  */
2355
- rtcRemoteVideoStats: (stats: AliRtcRemoteVideoStats[]) => void;
2235
+ updateRemoteTracks(callid: string, pullStreamUrl: string, _pubid: string, tracks?: TrackInfo[]): Promise<UpdateTracksResult>;
2356
2236
  /**
2357
- * 订阅远端音频流的数据统计
2358
- * @param aliRtcStats 统计信息
2237
+ * 订阅远端流
2238
+ * @param {SubscribeOptions} options
2239
+ * @returns {Promise<void>} 返回可播放的 MediaStream,可能为空。如果同时订阅了主流和辅流,只会返回主流对应的 MediaStream
2359
2240
  */
2360
- rtcRemoteAudioStats: (stats: AliRtcRemoteAudioStats[]) => void;
2241
+ subscribe(options?: SubscribeOptions, reason?: SubscribeReason, startTs?: number): Promise<void>;
2361
2242
  /**
2362
- * @brief 错误通知
2363
- * @deprecated 请使用 occurError
2364
- * @details 如果engine出现error,通过这个回调通知app
2365
- * @param error 错误类型,参考 {@link AliRtcError}
2366
- * @param uid 用户 Id,不一定存在
2243
+ * 订阅远端流
2244
+ * @param {SubscribeOptions} options 订阅配置
2245
+ * @param {boolean} secondary 是否订阅辅流
2246
+ * @returns {Promise<SubscribeResult>}
2367
2247
  */
2368
- onOccurError: (error: AliRtcError, uid?: string) => void;
2248
+ private subscribeProxy;
2369
2249
  /**
2370
- * @brief 错误通知
2371
- * @details 如果engine出现error,通过这个回调通知app
2372
- * @param error 错误类型,参考 {@link AliRtcError}
2373
- * @param uid 用户 Id,不一定存在
2250
+ * 移除对某些轨道的订阅
2251
+ * @param {UnSubscribeOptions} options 取消订阅轨道配置
2252
+ * @returns {Promise<SubscribeResult>}
2374
2253
  */
2375
- occurError: (error: AliRtcError, uid?: string) => void;
2254
+ private subscribeDeleteTracks;
2376
2255
  /**
2377
- * @brief 收到数据通道消息
2378
- * @param uid 用户ID
2379
- * @param message 消息
2256
+ * 移除对某些轨道的订阅
2257
+ * @param {Partial<ISubConfigItem>} deleteTrack 删除订阅配置
2258
+ * @returns {Promise<SubscribeResult>}
2380
2259
  */
2381
- dataChannelMsg: (uid: string, message: AliRtcDataChannelMsg) => void;
2260
+ private subscribeDeleteProxy;
2382
2261
  /**
2383
- * @brief AI agent处理结果
2384
- * @param code 返回code码
2385
- * @param action 结果对应的action
2386
- * @param result 结果
2262
+ * 用保存的订阅参数恢复订阅
2387
2263
  */
2388
- AIAgentResult: (code: number, action: string, result: string) => void;
2389
- }
2390
-
2391
- type AliRtcLocalView = string | HTMLVideoElement | string[] | HTMLVideoElement[] | null;
2392
-
2393
- interface AliEngineCameraCapturerConfiguration {
2394
- width?: number;
2395
- height?: number;
2396
- frameRate?: number;
2397
- maxSendFrameRate?: number;
2398
- bitrate?: number;
2399
- cameraDirection?: AliRtcCameraDirection;
2400
- deviceId?: string;
2401
- }
2402
- type VideoProfileWithSendFramerate = Partial<IProfile & {
2403
- maxSendFrameRate: number;
2404
- }>;
2405
-
2406
- declare enum AliRtcRawDataStreamType {
2407
- /** 相机流 */
2408
- AliRtcSdkStreamTypeCapture = 0,
2409
- /** 屏幕共享流 */
2410
- AliRtcSdkStreamTypeScreen = 1
2411
- }
2412
-
2413
- interface AliRtcVideoTrackConfig {
2414
- userId?: string;
2415
- streamType: AliRtcRawDataStreamType;
2416
- }
2417
-
2418
- interface AudioLevelMonitorListener {
2419
- audioLevel: (level: number) => void;
2420
- }
2421
- declare class AudioLevelMonitor extends EventEmitter$1<AudioLevelMonitorListener> {
2422
- private audioContext;
2423
- private stream;
2424
- private sourceNode?;
2425
- private analyser?;
2426
- constructor();
2427
- getLevel(): number;
2264
+ restore(): void;
2265
+ resumeAudio(): Promise<void>;
2266
+ resumeVideo(videoTrack?: AliRtcVideoTrack): Promise<void>;
2267
+ resumePlay(): void;
2428
2268
  /**
2429
- * 开启监听 audio level 的变化
2430
- *
2431
- * @param {MediaStreamTrack} track 音频轨
2432
- * @param {number} [interval=1000] 检测间隔,单位毫秒,默认 1000ms
2269
+ * 停止订阅远端流
2270
+ * @param {string} userId
2271
+ * @param {UnSubscribeOptions} options
2272
+ * @returns {Promise<void>}
2433
2273
  */
2434
- start(track: MediaStreamTrack, interval?: number): void;
2435
- stop(): void;
2436
- dispose(): void;
2437
- }
2438
-
2439
- declare class LocalProfileManager {
2440
- private defaultProfile;
2441
- profile?: string;
2442
- profileMap: Map<string, IProfile>;
2443
- audioProfile?: AudioProfileKey;
2444
- contentHint?: string;
2445
- constructor(defaultProfile?: IProfile);
2446
- updateProfile(profileKey: string, profileValue?: Partial<IProfile>): void;
2447
- get videoProfile(): string | undefined;
2448
- updateAudioProfile(profileKey: AudioProfileKey): void;
2449
- setContentHint(videoTrack: MediaStreamTrack | undefined, contentHint?: string): void;
2274
+ stopSubscribe(options?: UnSubscribeOptions): Promise<void>;
2450
2275
  /**
2451
- * 更新源流 Constraints
2452
- * 更新 PeerConnectiong Sender 相关配置
2453
- * @param stream
2276
+ * 停止对某个拉流 URL 的订阅
2277
+ * @param {url} pullStreamUrl
2278
+ * @returns {Promise<SubscribeResult>}
2454
2279
  */
2455
- setVideoProfile(originVideoTrack: MediaStreamTrack | undefined, target: LocalStream | undefined, skipConstraints?: boolean): Promise<void>;
2456
- }
2457
-
2458
- interface PublishStreamInfo {
2459
- audio?: LocalStream;
2460
- video?: LocalStream;
2461
- videoSmall?: LocalStream;
2462
- screen?: LocalStream;
2463
- videoProfile?: LocalProfileManager;
2464
- screenProfile?: LocalProfileManager;
2465
- }
2466
-
2467
- interface PluginManagerListener {
2468
- added: (plugin: AliRtcPlugin) => void;
2469
- removed: (plugin: AliRtcPlugin) => void;
2470
- updated: (plugin: AliRtcPlugin) => void;
2471
- }
2472
- declare class PluginManager extends EventEmitter$1<PluginManagerListener> {
2473
- private plugins;
2474
- add(plugin: AliRtcPlugin, options?: any): void;
2475
- remove(name: string): void;
2476
- removeAll(): void;
2477
- get(name: string): AliRtcPlugin | undefined;
2478
- has(name: string): boolean;
2479
- getAll(): AliRtcPlugin[];
2480
- }
2481
-
2482
- interface LocalStreamManagerListener {
2483
- trackended: (type: TrackEvent) => {};
2484
- publishupdate: () => {};
2485
- }
2486
- declare class LocalStreamManager extends EventEmitter$1<LocalStreamManagerListener> {
2280
+ private doStopSubscribe;
2281
+ private updateStream;
2282
+ private updateScreenStream;
2283
+ private clearStream;
2284
+ private clearScreenStream;
2285
+ private onDataChannelMessage;
2286
+ private onDataChannelError;
2287
+ private dataChannelConnected;
2288
+ private subscribeDataChannel;
2289
+ private subscribeStopDataChannel;
2290
+ getRetryOptions(): RemoteSubscribeOptions | undefined;
2487
2291
  /**
2488
- * @ignore
2292
+ * 尝试更新订阅
2293
+ * 1. 需要新增订阅的情况:想要订阅 & 没有正在订阅 & 远端有流
2489
2294
  */
2490
- static logName: string;
2491
- private pluginManager;
2492
- private slsReporter;
2493
- private publishingCameraVideoStream;
2494
- private publishingScreenVideoStream;
2495
- cameraStreamInfo: AliRtcLocalStreamInfo;
2496
- screenStreamInfo: AliRtcLocalStreamInfo;
2497
- private streamInfos;
2498
- private _audioCaptureDisabled;
2499
- private _cameraCaptureDisabled;
2500
- private _publishLocalAudioStreamEnabled;
2501
- private _publishLocalVideoStreamEnabled;
2502
- private _publishLocalScreenStreamEnabled;
2503
- constructor(pluginManager: PluginManager, slsReporter: SLSReporter);
2504
- get hasCamera(): boolean;
2505
- get audioCaptureDisabled(): boolean;
2506
- set audioCaptureDisabled(closed: boolean);
2507
- get cameraCaptureDisabled(): boolean;
2508
- set cameraCaptureDisabled(closed: boolean);
2509
- setAudioMuted(muted: boolean): void;
2510
- get isAudioMuted(): boolean;
2511
- setCameraMuted(muted: boolean): void;
2512
- get isCameraMuted(): boolean;
2513
- setScreenMuted(muted: boolean): void;
2514
- get isScreenMuted(): boolean;
2515
- get publishLocalAudioStreamEnabled(): boolean;
2516
- set publishLocalAudioStreamEnabled(enable: boolean);
2517
- get publishLocalVideoStreamEnabled(): boolean;
2518
- set publishLocalVideoStreamEnabled(enable: boolean);
2519
- get publishLocalScreenStreamEnabled(): boolean;
2520
- set publishLocalScreenStreamEnabled(enable: boolean);
2521
- updateStreams(): Promise<void>;
2522
- private setAvailableCameraDeviceId;
2523
- private setAvailableMicrophoneDeviceId;
2524
- /**
2525
- * 创建 LocalStream
2526
- * @param {LocalStreamConfig} params 创建 LocalStream 的配置
2527
- * @returns {LocalStream} 当前创建的 LocalStream
2528
- */
2529
- createLocalStream(params: LocalStreamConfig): Promise<LocalStream | undefined>;
2530
- /**
2531
- * 停止推流,底层调用 rts publishStop,不会导致 DC 马上关闭。适合暂时停推的场景
2532
- * @param {StopPublishOptions} options
2533
- * @returns {Promise<PublishStreamInfo>} 如果返回了 audio,则表示需要更新音频流
2534
- */
2535
- stopLocalStream(options: StopPublishOptions): Promise<void>;
2536
- get publishStreams(): PublishStreamInfo;
2537
- createHTTPPublishStream(): Promise<{
2538
- publishStream: LocalStream | undefined;
2539
- videoSmallStream: LocalStream | undefined;
2540
- screenStream: LocalStream | undefined;
2541
- vMsid: string | undefined;
2542
- }>;
2543
- /**
2544
- * 停止所有流
2545
- */
2546
- stop(): void;
2295
+ updateSubscribe(reason: SubscribeReason): {
2296
+ addOption: SubscribeOptions;
2297
+ deleteOption: SubscribeOptions;
2298
+ };
2299
+ private handleAutoPlayFailed;
2300
+ private handleAudioPaused;
2301
+ private handleVideoPlayFailded;
2302
+ private playAudio;
2303
+ stopPlayAudio(): void;
2304
+ playAll(isScreen?: boolean, isReplace?: boolean): void;
2547
2305
  /**
2548
- * 设置摄像头流 profile
2549
- * @param {LocalStream | null} stream
2550
- * @param {string} profileKey
2551
- * @param {IProfile} profile
2306
+ * 播放
2552
2307
  */
2553
- setVideoProfile(profileKey?: string, profile?: Partial<IProfile>, skipConstraints?: boolean): Promise<void>;
2308
+ private play;
2309
+ stopPlayAll(isScreen?: boolean): void;
2554
2310
  /**
2555
- * 设置摄像头流 content hint
2556
- * @param {string} hint
2557
- * @note 不传则尝试复用之前的 hint
2311
+ * 是否开启声音
2312
+ * @param {boolean} enable
2313
+ * @returns {void}
2558
2314
  */
2559
- setVideoContentHint(hint?: string): void;
2315
+ toggleAudio(enable?: boolean): void;
2560
2316
  /**
2561
- * 设置音频流 profile
2562
- * @param {string} profileKey
2317
+ * 是否开启画面
2318
+ * @param {boolean} enable
2319
+ * @returns {void}
2563
2320
  */
2564
- setAudioProfile(profileKey: AudioProfileKey): Promise<void>;
2321
+ toggleVideo(enable?: boolean): void;
2565
2322
  /**
2566
- * 设置屏幕共享流 profile
2567
- * @param {LocalStream} stream
2568
- * @param {string} profileKey
2569
- * @param {IProfile} profile
2323
+ * 是否开启画面
2324
+ * @param {boolean} enable
2325
+ * @returns {void}
2570
2326
  */
2571
- setScreenProfile(profileKey?: string, profile?: Partial<IProfile>): Promise<void>;
2572
- setScreenContentHint(hint?: string): void;
2327
+ toggleScreen(enable?: boolean): void;
2328
+ getStats(): Promise<{
2329
+ audio: AliRtcRemoteAudioStats[];
2330
+ video: AliRtcRemoteVideoStats[];
2331
+ }>;
2573
2332
  /**
2574
- * 设置 cameraVideoConstraints
2575
- * @param {IVideoConstraints} cameraVideoConstraints
2333
+ * 开启音量检测
2334
+ * @param {number} interval 时间间隔
2576
2335
  */
2577
- setCameraVideoConstraints(cameraVideoConstraints: MediaTrackConstraints): void;
2336
+ enableAudioVolumeIndication(interval: number): void;
2337
+ private reportSubscribeMonitor;
2338
+ private startStreamMonitor;
2578
2339
  /**
2579
- * 设置 micAudioConstraints
2580
- * @param {IAudioConstraints} micAudioConstraints
2340
+ * 停止本地流数据采集
2581
2341
  */
2582
- setMicAudioConstraints(micAudioConstraints: MediaTrackConstraints): void;
2342
+ private stopStreamMonitor;
2583
2343
  }
2584
2344
 
2585
- interface DeviceStatus {
2586
- micOpen: boolean;
2587
- micInterrupted: boolean;
2588
- audioDisable: boolean;
2589
- cameraOpen: boolean;
2590
- videoDisable: boolean;
2591
- screenShare: boolean;
2592
- screenDisable: boolean;
2593
- backgroundMode: boolean;
2594
- accompanyPlaying: boolean;
2345
+ interface RemoteSubscribeOptions {
2346
+ remoteUser: RemoteUser;
2347
+ options: SubscribeOptions;
2595
2348
  }
2596
-
2597
- interface UpdateTracksResult {
2598
- restoreSub?: boolean;
2349
+ declare enum RtsPeerConnectionType {
2350
+ PUBLISH = "publish",
2351
+ SUBSCRIBE = "subscribe"
2599
2352
  }
2600
- declare class RemoteStreamInfo extends EventEmitter$1<StreamListener> {
2353
+ interface RtsManagerEventListener {
2354
+ reconnecting: (type: RtsPeerConnectionType) => {};
2355
+ disconnected: () => {};
2356
+ connected: (isReconnected: boolean, type: RtsPeerConnectionType) => {};
2357
+ subscribeexceeds: () => {};
2358
+ seimessage: (url: string, payloadType: number, data: ArrayBuffer) => {};
2359
+ }
2360
+ declare class RtsManager extends EventEmitter$1<RtsManagerEventListener> {
2601
2361
  /**
2602
2362
  * @ignore
2603
2363
  */
2604
2364
  static logName: string;
2605
- protected audioInfo: RemoteMediaTrackInfo;
2606
- protected videoLargeInfo: RemoteMediaTrackInfo;
2607
- protected videoSmallInfo: RemoteMediaTrackInfo;
2608
- protected screenInfo: RemoteMediaTrackInfo;
2609
- protected dataInfo: RemoteMediaTrackInfo;
2610
- protected audioVolume: number;
2611
- protected audioMuted: boolean;
2612
- protected userStatus?: DeviceStatus;
2613
- constructor();
2365
+ private rts;
2366
+ private encodedInsertableStreams;
2367
+ private audioRedEnabled;
2368
+ private localStreamManager;
2369
+ private slsReporter;
2370
+ private _rtsPeerConnectionType;
2371
+ private connecting;
2372
+ private connected;
2373
+ private _pcTraceId;
2374
+ private _localJoinTime;
2375
+ private connectionResolve?;
2376
+ private connectingPromise?;
2377
+ private dcResolve?;
2378
+ private dcReject?;
2379
+ private dcConnectingPromise?;
2380
+ private _publishingTracks;
2381
+ private parameter;
2382
+ preferredPubL1Ip?: string;
2383
+ preferredSubL1Ip?: string;
2384
+ constructor(localStreamManager: LocalStreamManager, slsReporter: SLSReporter, parameter: Parameter);
2385
+ private addRTSListener;
2614
2386
  /**
2615
- * 远端流音频轨道信息
2616
- * @returns
2387
+ * 更新鉴权信息,传入一个新的带鉴权的 URL,RTS 会去除鉴权信息做更新
2388
+ * @param newUrlWithAuth
2617
2389
  */
2618
- getAudioInfo(): RemoteMediaTrackInfo;
2390
+ updateAuth(newUrlWithAuth: string): void;
2391
+ get pcTraceId(): string;
2392
+ set localJoinTime(time: number);
2393
+ setEncodedInsertableStreams(enable: boolean): void;
2394
+ setAudioRedEnabled(enable: boolean): void;
2395
+ clear(): void;
2396
+ private startConnect;
2397
+ private setConnected;
2398
+ get isConnecting(): boolean;
2399
+ get isConnected(): boolean;
2400
+ get publishingTracks(): TrackInfo[];
2401
+ private getPubMsid;
2402
+ private updatePublishingTracks;
2403
+ private httpPublish;
2404
+ waitPublishSender(streamUrl: string, isAudio?: boolean, msid?: string): Promise<any>;
2405
+ getPublishVideoStats(streamUrl: string, msid?: string): Promise<unknown>;
2406
+ getPublishAudioStats(streamUrl: string, msid?: string): Promise<unknown>;
2407
+ publishAdd(streamUrl: string, stream: LocalStream, callId: string, extra?: PublishExtraParams, isResume?: boolean, waitSender?: boolean, reason?: PublishReason): Promise<string>;
2408
+ publishDelete(streamUrl: string, options: PublishOptions): Promise<string>;
2409
+ publishReplace(streamUrl: string, stream: LocalStream, extra?: PublishExtraParams): Promise<string>;
2410
+ publishStop(streamUrl: string): Promise<string>;
2411
+ publishAddDataChannel(streamUrl: string): Promise<any>;
2412
+ publishStopDataChannel(streamUrl: string, datachannel: any): Promise<void>;
2413
+ unpublish(): Promise<void>;
2619
2414
  /**
2620
- * 远端流视频轨道信息
2621
- * @returns
2415
+ * 获取 sub/subAdd config
2416
+ * @param {ISubscribeConfig | ISubConfigItem} options
2417
+ * @returns {Omit<ISignalConfig | ISubConfigItem, 'url'>}
2622
2418
  */
2623
- getVideoSmallInfo(): RemoteMediaTrackInfo;
2419
+ private getSubConfig;
2420
+ private httpSubscribe;
2421
+ private subscribeAdd;
2422
+ subscribeDelete(subscribeOptions: RemoteSubscribeOptions): Promise<ISubDeleteResult | undefined>;
2423
+ subscribeStop(streamUrl: string): Promise<void>;
2424
+ subscribeAddDataChannel(streamUrl: string): Promise<any>;
2425
+ subscribeStopDatachannel(streamUrl: string, datachannel: any): Promise<any>;
2426
+ publish(streamUrl: string, callId: string, isResume?: boolean, reason?: PublishReason): Promise<{
2427
+ traceId: string;
2428
+ l1ip?: string;
2429
+ }>;
2430
+ private reportSubscribeLatency;
2431
+ subscribe(remoteSubscribeOptions: RemoteSubscribeOptions, reason: SubscribeReason, callId: string, remoteCallId: string, startTs: number, retryCount?: number): Promise<any>;
2432
+ getSubscribeVideoStats(streamUrl: string, msid?: string): Promise<unknown>;
2433
+ getSubscribeAudioStats(streamUrl: string, msid?: string): Promise<unknown>;
2434
+ getStreamByMsid(config: any): LocalStream | RemoteStream;
2435
+ getDatachannelByMsid(config: {
2436
+ url: string;
2437
+ msid?: string;
2438
+ }): any;
2439
+ getPCStats(): Promise<any>;
2440
+ sendSEI(streamUrl: string, data: ArrayBuffer, repeatCount: number, payloadType: number): Promise<void>;
2441
+ }
2442
+
2443
+ declare class User extends EventEmitter$1<UserListener> {
2444
+ protected uid: string;
2445
+ protected name: string;
2446
+ protected rtsManager: RtsManager;
2447
+ callId: string;
2448
+ protected audioLevelMonitor: AudioLevelMonitor;
2449
+ protected audioVolumeIndicationInterval: number;
2450
+ constructor(userId: string, displayname: string, rtsManager: RtsManager, interval: number);
2451
+ get userId(): string;
2452
+ get displayname(): string;
2453
+ protected createCallId(): void;
2454
+ setUserInfo(uid: string, displayName: string): void;
2455
+ refreshUserInfo(uid: string): void;
2624
2456
  /**
2625
- * 远端流视频轨道信息
2626
- * @returns
2457
+ * 获取音频 level
2627
2458
  */
2628
- getVideoLargeInfo(): RemoteMediaTrackInfo;
2459
+ getAudioLevel(): number;
2460
+ enableAudioVolumeIndication(interval: number): void;
2629
2461
  /**
2630
- * 远端流屏幕共享轨道信息
2631
- * @returns
2462
+ * 销毁用户,清空数据
2632
2463
  */
2633
- getScreenInfo(): RemoteMediaTrackInfo;
2634
- getDataInfo(): RemoteMediaTrackInfo;
2635
- get subscribingInfos(): RemoteMediaTrackInfo[];
2636
- get hasTrack(): boolean;
2464
+ clear(): void;
2465
+ }
2466
+
2467
+ interface AliRtcLocalAudioStats {
2468
+ track: AliRtcAudioTrack;
2469
+ stats: any;
2470
+ }
2471
+
2472
+ interface AliRtcLocalVideoStats {
2473
+ track: AliRtcVideoTrack;
2474
+ streamType?: AliRtcVideoStreamType;
2475
+ stats: any;
2476
+ }
2477
+
2478
+ declare enum AliRtcDataMsgType {
2479
+ AliEngineDataMsgNone = 0,
2480
+ AliEngineDataMsgMusicProgress = 1,
2481
+ AliEngineDataMsgCustom = 2
2482
+ }
2483
+ declare class AliRtcDataChannelMsg {
2484
+ data: ArrayBuffer;
2485
+ networkTime: number;
2486
+ futureOrProgress: number;
2487
+ type: AliRtcDataMsgType;
2488
+ constructor(data: ArrayBuffer, type?: AliRtcDataMsgType, networkTime?: number, progress?: number);
2489
+ toBuffer(): ArrayBuffer;
2490
+ static parse(buffer: ArrayBuffer): AliRtcDataChannelMsg | undefined;
2491
+ }
2492
+
2493
+ interface AliEngineCameraCapturerConfiguration {
2494
+ width?: number;
2495
+ height?: number;
2496
+ frameRate?: number;
2497
+ maxSendFrameRate?: number;
2498
+ bitrate?: number;
2499
+ cameraDirection?: AliRtcCameraDirection;
2500
+ deviceId?: string;
2501
+ }
2502
+ type VideoProfileWithSendFramerate = Partial<IProfile & {
2503
+ maxSendFrameRate: number;
2504
+ }>;
2505
+
2506
+ declare class LocalUser extends User {
2637
2507
  /**
2638
- * 远端流是否包含音频轨道
2639
- * @returns
2508
+ * @ignore
2640
2509
  */
2641
- get hasAudio(): boolean;
2510
+ static logName: string;
2511
+ private _url;
2512
+ private joinTime;
2513
+ private publishPromise;
2514
+ private previewElements;
2515
+ private screenPreviewElements;
2516
+ private streamManager;
2517
+ private dc;
2518
+ protected streamTracks?: TrackInfo[];
2519
+ protected publishId: string;
2520
+ protected signalingManager: SignalingManager;
2521
+ private shouldPublish;
2522
+ traceId: string;
2523
+ private monitorTimerId?;
2524
+ private monitorDataCache;
2525
+ private trackTraceIdMap;
2526
+ private candidateDataCache;
2527
+ private pcMediaStatsMap;
2528
+ protected slsReporter: SLSReporter;
2529
+ private audioPubState;
2530
+ private videoPubState;
2531
+ private videoSmallPubState;
2532
+ private screenPubState;
2533
+ private dataPubState;
2534
+ private parameter;
2535
+ constructor(config: LocalUserConfig);
2536
+ get url(): string;
2537
+ set url(value: string);
2538
+ get joined(): boolean;
2539
+ get isPublishing(): boolean;
2540
+ get publishStreams(): PublishStreamInfo;
2541
+ get cameraTrack(): MediaStreamTrack | undefined;
2542
+ get screenTrack(): MediaStreamTrack | undefined;
2543
+ get audioTrack(): MediaStreamTrack | undefined;
2544
+ get hasCamera(): boolean;
2545
+ get hasMicrophone(): boolean;
2546
+ get hasScreenShare(): boolean;
2547
+ get hasCameraTrackInMS(): boolean;
2548
+ get hasCameraDualTrackInMS(): boolean;
2549
+ get hasScreenTrackInMS(): boolean;
2550
+ get hasAudioTrackInMS(): boolean;
2551
+ get cameraDirection(): string | undefined;
2552
+ get audioCaptureDisabled(): boolean;
2553
+ get cameraCaptureDisabled(): boolean;
2554
+ get publishLocalVideoStreamEnabled(): boolean;
2555
+ get publishLocalAudioStreamEnabled(): boolean;
2556
+ get publishLocalScreenStreamEnabled(): boolean;
2557
+ setPublishLocalAudioStreamEnabled(enable: boolean): void;
2558
+ setPublishLocalVideoStreamEnabled(enable: boolean): void;
2559
+ setPublishLocalScreenStreamEnabled(enable: boolean): void;
2560
+ initInfo(authInfo: AliRtcAuthInfo, pushStreamUrl: string): void;
2561
+ setVideoProfile(profile?: VideoProfileWithSendFramerate): Promise<void>;
2562
+ setVideoContentHint(hint: string): void;
2563
+ setScreenContentHint(hint: string): void;
2564
+ setAudioProfile(profileKey: AudioProfileKey): Promise<void>;
2565
+ setScreenProfile(profile?: Partial<IProfile>): Promise<void>;
2566
+ setCameraDirection(direction: AliRtcCameraDirection): void;
2567
+ setCameraDeviceId(deviceId: string): void;
2568
+ muteLocalCamera(mute: boolean): void;
2569
+ muteLocalMic(mute: boolean): void;
2570
+ muteLocalScreen(mute: boolean): void;
2571
+ setMicrophoneDeviceId(deviceId: string): void;
2572
+ setMicrophoneConstraints(constraints: MediaTrackConstraints): void;
2573
+ updatePubId(): void;
2574
+ clearPublishState(): void;
2575
+ leave(): Promise<void>;
2642
2576
  /**
2643
- * 远端流是否包含视频轨道
2644
- * @returns
2577
+ * 销毁,停止推流
2578
+ * @returns {Promise<void>}
2645
2579
  */
2646
- get hasVideo(): boolean;
2580
+ clear(): Promise<void>;
2581
+ resetElement(element: HTMLVideoElement): void;
2582
+ setPreviewElement(previewParams: PreviewConfig): void;
2583
+ startDefaultCameraAndMic(audioOnly?: boolean): Promise<void>;
2647
2584
  /**
2648
- * 远端流是否包含视频大流轨道
2649
- * @returns
2585
+ * 为本地预览设置渲染元素和视频流
2586
+ * @param {AliRtcLocalView} view 渲染元素,null 则为停止显示
2587
+ * @param {AliRtcVideoTrack} track 视频流类型
2650
2588
  */
2651
- get hasVideoLarge(): boolean;
2589
+ setViewConfig(elements: null | HTMLVideoElement[], track: AliRtcVideoTrack): void;
2652
2590
  /**
2653
- * 远端流是否包含视频小流轨道
2591
+ * 开启摄像头采集
2592
+ * @param params
2654
2593
  * @returns
2655
2594
  */
2656
- get hasVideoSmall(): boolean;
2595
+ startCameraCapture(): Promise<LocalStream | undefined>;
2657
2596
  /**
2658
- * 远端流是否包含屏幕共享轨道
2659
- * @returns
2597
+ * 关闭摄像头采集
2598
+ * @note 调用此接口后,入会后、离会再入会,采集设备保持关闭状态
2660
2599
  */
2661
- get hasScreen(): boolean;
2662
- get hasData(): boolean;
2600
+ stopCameraCapture(): Promise<void>;
2663
2601
  /**
2664
- * 是否订阅远端流音频轨道
2602
+ * 开启麦克风采集
2603
+ * @param params
2665
2604
  * @returns
2666
2605
  */
2667
- get isAudioSubscribed(): boolean;
2668
- get isAudioSubscribing(): boolean;
2606
+ startAudioCapture(): Promise<LocalStream | undefined>;
2669
2607
  /**
2670
- * 是否订阅远端流视频轨道
2671
- * @returns
2608
+ * 关闭音频采集
2609
+ * @note 调用此接口后,入会后、离会再入会,采集设备保持关闭状态
2672
2610
  */
2673
- get isVideoSubscribed(): boolean;
2674
- get isVideoSubscribing(): boolean;
2611
+ stopAudioCapture(): Promise<void>;
2612
+ startCameraAndMic(): Promise<LocalStream | undefined>;
2675
2613
  /**
2676
- * 是否订阅远端流视频大流轨道
2677
- * @returns
2614
+ * 预览本地流
2615
+ * @param {PreviewConfig} previewParams
2616
+ * @returns {Promise<MediaStream>}
2678
2617
  */
2679
- get isVideoLargeSubscribed(): boolean;
2680
- get isVideoLargeSubscribing(): boolean;
2618
+ preview(previewParams: PreviewConfig): Promise<MediaStream | undefined>;
2681
2619
  /**
2682
- * 是否订阅远端流视频小流轨道
2683
- * @returns
2620
+ * 在所有预览容器中预览当前流
2621
+ * @param {boolean} screen 是否指定预览辅流
2684
2622
  */
2685
- get isVideoSmallSubscribed(): boolean;
2686
- get isVideoSmallSubscribing(): boolean;
2623
+ previewAll(previewAllParams?: PreviewAllConfig): Promise<void>;
2687
2624
  /**
2688
- * 是否订阅远端流屏幕共享轨道
2625
+ * 停止预览本地流
2626
+ */
2627
+ stopPreview(previewParams?: StopPreviewConfig): void;
2628
+ /**
2629
+ * 恢复推流
2630
+ * @returns {Promise<void>}
2631
+ */
2632
+ resumePublish(): Promise<void>;
2633
+ createLocalStream(params: LocalStreamConfig): Promise<LocalStream | undefined>;
2634
+ stopLocalStream(options: PublishOptions): Promise<void>;
2635
+ private compareAndPublish;
2636
+ private reportAudioProfile;
2637
+ private reportVideoProfile;
2638
+ private reportScreenProfile;
2639
+ private updateDataChannel;
2640
+ private publishDataChannel;
2641
+ /**
2642
+ * 开始推流
2643
+ * @param isResume 是否是恢复推流
2689
2644
  * @returns
2690
2645
  */
2691
- get isScreenSubscribed(): boolean;
2692
- get isScreenSubscribing(): boolean;
2693
- get isDataSubscribed(): boolean;
2694
- get isDataSubscribing(): boolean;
2695
- get audioCodec(): CodecType;
2696
- get videoCodec(): CodecType;
2697
- get audioTrackInfo(): AliRtcAudioTrack;
2698
- get videoTrackInfo(): AliRtcVideoTrack;
2699
- updateTracks(tracks?: TrackInfo[]): UpdateTracksResult;
2700
- protected updateRemoteTrackSsrc(audioSsrc: string, videoLargeSsrc: string, videoSmallSsrc: string, screenSsrc: string, dataSsrc: string): void;
2701
- markRemoteTrackSubscribing(option: SubscribeOptions): any;
2702
- updateRemoteTrackSubState(option: SubscribeOptions): any;
2646
+ startPublish(isResume?: boolean, reason?: PublishReason): Promise<void>;
2703
2647
  /**
2704
- * 更新远端用户设备状态
2705
- * @param status
2706
- * @returns {boolean} 状态改变返回true,否则返回false
2648
+ * 重新执行 progress 并触发 publishupdate
2707
2649
  */
2708
- updateRemoteUserDeviceStatus(status: string): boolean;
2709
- }
2710
-
2711
- declare class AliRtcRemoteUserInfo {
2712
- private remoteUser;
2713
- constructor(remoteUser: RemoteUser);
2714
- get userId(): string;
2715
- get displayName(): string;
2716
- get isMuteAudioPlaying(): boolean;
2717
- get hasAudio(): boolean;
2718
- get hasCamera(): boolean;
2719
- get hasCameraLarge(): boolean;
2720
- get hasCameraSmall(): boolean;
2721
- get hasScreenShare(): boolean;
2722
- get isAudioSubscribing(): boolean;
2723
- get isVideoSubscribing(): boolean;
2724
- get isVideoLargeSubscribing(): boolean;
2725
- get isVideoSmallSubscribing(): boolean;
2726
- get isScreenSubscribing(): boolean;
2727
- get audioElement(): HTMLAudioElement | undefined;
2728
- }
2729
-
2730
- interface RemoteUserViewMap {
2731
- cameraViews: HTMLVideoElement[];
2732
- screenViews: HTMLVideoElement[];
2733
- }
2734
- declare class RemoteUser extends User {
2650
+ updateStreams(): Promise<void>;
2735
2651
  /**
2736
- * @ignore
2652
+ * 对比本地流和正在推流,进行推流更新
2653
+ * @param isResume 是否是恢复推流
2737
2654
  */
2738
- static logName: string;
2739
- remoteCallid: string;
2740
- remoteUserInfo: AliRtcRemoteUserInfo;
2741
- protected localUser?: LocalUser;
2742
- protected lastPubId: string;
2743
- protected stream?: RemoteStream;
2744
- protected screenStream?: RemoteStream;
2745
- private viewMap;
2746
- private audioTrack?;
2747
- private audioElement?;
2748
- protected subscribed: boolean;
2749
- protected mediaStream?: MediaStream;
2750
- protected secondaryMediaStream?: MediaStream;
2751
- protected prevSubConfig?: SubConfig;
2752
- protected signalingManager: SignalingManager;
2753
- protected slsReporter: SLSReporter;
2754
- private wantSubAudio;
2755
- private wantSubVideo;
2756
- private wantSubScreen;
2757
- private defaultVideoStreamType;
2758
- private audioMuted;
2759
- private playoutVolume;
2760
- private playoutGainNode?;
2761
- private audioSubState;
2762
- private videoSubState;
2763
- private videoLargeSubState;
2764
- private videoSmallSubState;
2765
- private screenSubState;
2766
- private dataSubState;
2767
- private dc;
2768
- private dcMsgWaitingPieces;
2769
- streamInfo: RemoteStreamInfo;
2770
- private _streamUrl;
2771
- private parameter;
2772
- private monitorTimerId?;
2773
- private monitorDataCache;
2774
- private trackTraceIdMap;
2775
- constructor(config: RemoteUserConfig);
2776
- get streamUrl(): string;
2777
- set streamUrl(value: string);
2778
- isWantSubAudio(): boolean;
2779
- setWantSubAudio(value: boolean): void;
2780
- isWantSubVideo(): boolean;
2781
- setWantSubVideo(value: boolean): void;
2782
- isWantSubScreen(): boolean;
2783
- setWantSubScreen(value: boolean): void;
2784
- setRemoteDefaultVideoStreamType(type: AliRtcVideoStreamType): void;
2785
- setAudioMuted(value: boolean): void;
2786
- getAudioElement(): HTMLAudioElement | undefined;
2787
- private handleAudioContextSuspended;
2788
- setPlayoutVolume(value: number): void;
2789
- getAudioMuted(): boolean;
2790
- get hasAudioTrack(): boolean;
2791
- get hasVideoTrack(): boolean;
2792
- get hasVideoLargeTrack(): boolean;
2793
- get hasVideoSmallTrack(): boolean;
2794
- get hasScreenTrack(): boolean;
2795
- get isAudioSubscribing(): boolean;
2796
- get isVideoSubscribing(): boolean;
2797
- get isVideoLargeSubscribing(): boolean;
2798
- get isVideoSmallSubscribing(): boolean;
2799
- get isScreenSubscribing(): boolean;
2800
- get isDataSubscribing(): boolean;
2801
- get audioEnabled(): boolean;
2802
- get videoEnabled(): boolean;
2803
- get screenEnabled(): boolean;
2804
- get getAudioTrack(): MediaStreamAudioTrack | undefined;
2805
- get getCameraStream(): RemoteStream | undefined;
2806
- get getScreenStream(): RemoteStream | undefined;
2807
- setViewConfig(view: AliRtcLocalView, track: AliRtcVideoTrack): void;
2808
- /**
2809
- * 销毁
2810
- * @returns {Promise<void>}
2811
- */
2812
- clear(needStopSub?: boolean): Promise<void>;
2813
- /**
2814
- * 更新远端用户的设备状态
2815
- * @param {string} status
2816
- * @returns {void}
2817
- */
2818
- updateRemoteUserDeviceStatus(status: string): void;
2819
- /**
2820
- * 更新远端用户的推流状态,已经停止推流的 tracks 要 delete,或者整体 stop
2821
- * @param {string} callid
2822
- * @param {string} pullStreamUrl
2823
- * @param {TrackInfo[]} tracks
2824
- * @returns {Promise<TrackChangeState>}
2825
- */
2826
- updateRemoteTracks(callid: string, pullStreamUrl: string, _pubid: string, tracks?: TrackInfo[]): Promise<UpdateTracksResult>;
2827
- /**
2828
- * 订阅远端流
2829
- * @param {SubscribeOptions} options
2830
- * @returns {Promise<void>} 返回可播放的 MediaStream,可能为空。如果同时订阅了主流和辅流,只会返回主流对应的 MediaStream
2831
- */
2832
- subscribe(options?: SubscribeOptions, reason?: SubscribeReason, startTs?: number): Promise<void>;
2655
+ publishUpdate(reason?: PublishReason): Promise<PublishInfo | undefined>;
2656
+ private syncPublishToRoomServer;
2657
+ private refreshPushStreamUrl;
2833
2658
  /**
2834
- * 订阅远端流
2835
- * @param {SubscribeOptions} options 订阅配置
2836
- * @param {boolean} secondary 是否订阅辅流
2837
- * @returns {Promise<SubscribeResult>}
2659
+ * 推流,用于 rts subscribe/publish 被调用后,此时 DataChannel 已存在
2660
+ * @param {LocalStream} stream
2661
+ * @returns {Promise<PublishInfo>}
2838
2662
  */
2839
- private subscribeProxy;
2663
+ publishAdd(stream: LocalStream, extra: PublishExtraParams, isResume?: boolean, retryTimes?: number): Promise<PublishInfo>;
2840
2664
  /**
2841
- * 移除对某些轨道的订阅
2842
- * @param {UnSubscribeOptions} options 取消订阅轨道配置
2843
- * @returns {Promise<SubscribeResult>}
2665
+ * 替换推流 Track(仅限于替换已存在的 Track 类型)
2666
+ * @param {LocalStream} stream
2667
+ * @returns {Promise<PublishInfo>}
2844
2668
  */
2845
- private subscribeDeleteTracks;
2669
+ publishReplace(stream: LocalStream, extra?: PublishExtraParams): Promise<PublishInfo>;
2846
2670
  /**
2847
- * 移除对某些轨道的订阅
2848
- * @param {Partial<ISubConfigItem>} deleteTrack 删除订阅配置
2849
- * @returns {Promise<SubscribeResult>}
2671
+ * 停止推某些轨,不销毁 DataChannel 和 LocalStream,用于非销毁场景
2672
+ * @param {PublishOptions} options
2673
+ * @returns {Promise<PublishInfo>}
2850
2674
  */
2851
- private subscribeDeleteProxy;
2675
+ publishDeleteTracks(options: PublishOptions): Promise<PublishInfo>;
2852
2676
  /**
2853
- * 用保存的订阅参数恢复订阅
2677
+ * 停止推流,不销毁 LocalStream,用于非销毁场景
2678
+ * @returns {Promise<PublishInfo>}
2854
2679
  */
2855
- restore(): void;
2856
- resumeAudio(): Promise<void>;
2857
- resumeVideo(videoTrack?: AliRtcVideoTrack): Promise<void>;
2858
- resumePlay(): void;
2680
+ publishStop(): Promise<PublishInfo>;
2859
2681
  /**
2860
- * 停止订阅远端流
2861
- * @param {string} userId
2862
- * @param {UnSubscribeOptions} options
2863
- * @returns {Promise<void>}
2682
+ * 停止推流,销毁 DataChannel,用于销毁的场景
2683
+ * @returns {Promise<PublishInfo>}
2864
2684
  */
2865
- stopSubscribe(options?: UnSubscribeOptions): Promise<void>;
2685
+ unPublish(): Promise<PublishInfo>;
2866
2686
  /**
2867
- * 停止对某个拉流 URL 的订阅
2868
- * @param {url} pullStreamUrl
2869
- * @returns {Promise<SubscribeResult>}
2687
+ * 事件通知本地的设备使用状态
2870
2688
  */
2871
- private doStopSubscribe;
2872
- private updateStream;
2873
- private updateScreenStream;
2874
- private clearStream;
2875
- private clearScreenStream;
2876
- private onDataChannelMessage;
2877
- private onDataChannelError;
2878
- private dataChannelConnected;
2879
- private subscribeDataChannel;
2880
- private subscribeStopDataChannel;
2881
- getRetryOptions(): RemoteSubscribeOptions | undefined;
2689
+ reportSelfDeviceStatus(): void;
2882
2690
  /**
2883
- * 尝试更新订阅
2884
- * 1. 需要新增订阅的情况:想要订阅 & 没有正在订阅 & 远端有流
2691
+ * 从localStream 中获取当前的设备状态
2692
+ * @returns {string}
2885
2693
  */
2886
- updateSubscribe(reason: SubscribeReason): {
2887
- addOption: SubscribeOptions;
2888
- deleteOption: SubscribeOptions;
2889
- };
2890
- private handleAutoPlayFailed;
2891
- private handleAudioPaused;
2892
- private handleVideoPlayFailded;
2893
- private playAudio;
2894
- stopPlayAudio(): void;
2895
- playAll(isScreen?: boolean, isReplace?: boolean): void;
2694
+ private getDeviceStatus;
2695
+ private onTrackEnd;
2696
+ private resetPreviewElements;
2697
+ private resetSecondayPreviewElements;
2698
+ getMediaStats(id: string): any;
2699
+ private reportPublishMonitor;
2700
+ private reportNetwork;
2701
+ private startStreamMonitor;
2896
2702
  /**
2897
- * 播放
2703
+ * 停止本地流数据采集
2898
2704
  */
2899
- private play;
2900
- stopPlayAll(isScreen?: boolean): void;
2705
+ private stopStreamMonitor;
2901
2706
  /**
2902
- * 是否开启声音
2903
- * @param {boolean} enable
2707
+ * 清除本地流
2904
2708
  * @returns {void}
2905
2709
  */
2906
- toggleAudio(enable?: boolean): void;
2710
+ clearStream(): void;
2907
2711
  /**
2908
- * 是否开启画面
2909
- * @param {boolean} enable
2910
- * @returns {void}
2712
+ * 获取当前使用的摄像头 deviceId
2713
+ * @returns {string | undefined}
2911
2714
  */
2912
- toggleVideo(enable?: boolean): void;
2715
+ getCurrentCameraDeviceId(): string | undefined;
2913
2716
  /**
2914
- * 是否开启画面
2915
- * @param {boolean} enable
2916
- * @returns {void}
2717
+ * 获取当前使用的摄像头 deviceId
2718
+ * @returns {string | undefined}
2917
2719
  */
2918
- toggleScreen(enable?: boolean): void;
2720
+ getCurrentMicDeviceId(): string | undefined;
2721
+ enableAudioVolumeIndication(interval: number): void;
2722
+ sendSEI(message: ArrayBuffer, repeatCount: number, payloadType: number): Promise<void>;
2723
+ sendDataChannelMessage(message: AliRtcDataChannelMsg): void;
2919
2724
  getStats(): Promise<{
2920
- audio: AliRtcRemoteAudioStats[];
2921
- video: AliRtcRemoteVideoStats[];
2725
+ audio: AliRtcLocalAudioStats[];
2726
+ video: AliRtcLocalVideoStats[];
2727
+ candidate: any;
2922
2728
  }>;
2923
- /**
2924
- * 开启音量检测
2925
- * @param {number} interval 时间间隔
2926
- */
2927
- enableAudioVolumeIndication(interval: number): void;
2928
- private reportSubscribeMonitor;
2929
- private startStreamMonitor;
2930
- /**
2931
- * 停止本地流数据采集
2932
- */
2933
- private stopStreamMonitor;
2934
2729
  }
2935
2730
 
2936
- interface RemoteSubscribeOptions {
2937
- remoteUser: RemoteUser;
2938
- options: SubscribeOptions;
2731
+ interface AudioMixerPluginOptions {
2732
+ audio?: number;
2733
+ screen?: number;
2939
2734
  }
2940
- declare enum RtsPeerConnectionType {
2941
- PUBLISH = "publish",
2942
- SUBSCRIBE = "subscribe"
2735
+
2736
+ type AliRtcDualVideoPluginOptions = VideoScalerOptions;
2737
+
2738
+ declare enum AliRtcCapabilityProfile {
2739
+ Default = 0,
2740
+ Human = 1,
2741
+ Robot = 2
2943
2742
  }
2944
- interface RtsManagerEventListener {
2945
- reconnecting: (type: RtsPeerConnectionType) => {};
2946
- disconnected: () => {};
2947
- connected: (isReconnected: boolean, type: RtsPeerConnectionType) => {};
2948
- subscribeexceeds: () => {};
2949
- seimessage: (url: string, payloadType: number, data: ArrayBuffer) => {};
2743
+ type AliRtcChannelParam = {
2744
+ userName?: string;
2745
+ capabilityProfile?: AliRtcCapabilityProfile;
2746
+ };
2747
+
2748
+ interface RemoteUserMap {
2749
+ [userId: string]: RemoteUser;
2950
2750
  }
2951
- declare class RtsManager extends EventEmitter$1<RtsManagerEventListener> {
2751
+ declare class BizControl extends EventEmitter$1<BizControlListener> {
2952
2752
  /**
2953
2753
  * @ignore
2954
2754
  */
2955
2755
  static logName: string;
2956
- private rts;
2957
- private encodedInsertableStreams;
2958
- private audioRedEnabled;
2959
- private localStreamManager;
2960
- private slsReporter;
2961
- private _rtsPeerConnectionType;
2962
- private connecting;
2963
- private connected;
2964
- private _pcTraceId;
2965
- private _localJoinTime;
2966
- private connectionResolve?;
2967
- private connectingPromise?;
2968
- private dcResolve?;
2969
- private dcReject?;
2970
- private dcConnectingPromise?;
2971
- private _publishingTracks;
2972
- private parameter;
2973
- preferredPubL1Ip?: string;
2974
- constructor(localStreamManager: LocalStreamManager, slsReporter: SLSReporter, parameter: Parameter);
2975
- private addRTSListener;
2976
- /**
2977
- * 更新鉴权信息,传入一个新的带鉴权的 URL,RTS 会去除鉴权信息做更新
2978
- * @param newUrlWithAuth
2979
- */
2980
- updateAuth(newUrlWithAuth: string): void;
2981
- get pcTraceId(): string;
2982
- set localJoinTime(time: number);
2983
- setEncodedInsertableStreams(enable: boolean): void;
2984
- setAudioRedEnabled(enable: boolean): void;
2985
- clear(): void;
2986
- private startConnect;
2987
- private setConnected;
2988
- get isConnecting(): boolean;
2989
- get isConnected(): boolean;
2990
- get publishingTracks(): TrackInfo[];
2991
- private getPubMsid;
2992
- private updatePublishingTracks;
2993
- private httpPublish;
2994
- waitPublishSender(streamUrl: string, isAudio?: boolean, msid?: string): Promise<any>;
2995
- getPublishVideoStats(streamUrl: string, msid?: string): Promise<unknown>;
2996
- getPublishAudioStats(streamUrl: string, msid?: string): Promise<unknown>;
2997
- publishAdd(streamUrl: string, stream: LocalStream, callId: string, extra?: PublishExtraParams, isResume?: boolean, waitSender?: boolean, reason?: PublishReason): Promise<string>;
2998
- publishDelete(streamUrl: string, options: PublishOptions): Promise<string>;
2999
- publishReplace(streamUrl: string, stream: LocalStream, extra?: PublishExtraParams): Promise<string>;
3000
- publishStop(streamUrl: string): Promise<string>;
3001
- publishAddDataChannel(streamUrl: string): Promise<any>;
3002
- publishStopDataChannel(streamUrl: string, datachannel: any): Promise<void>;
3003
- unpublish(): Promise<void>;
2756
+ protected self: LocalUser;
2757
+ protected userMap: RemoteUserMap;
2758
+ private usersViewMap;
2759
+ rtsManager: RtsManager;
2760
+ protected localStreamManager: LocalStreamManager;
2761
+ protected authInfo?: AliRtcAuthInfo;
2762
+ protected signalingManager: SignalingManager;
2763
+ pluginManager: PluginManager;
2764
+ private audioMixerPlugin?;
2765
+ private dualVideoPlugin?;
2766
+ private blankAudioPlugin?;
2767
+ private audioProcessorPlugin?;
2768
+ protected slsReporter: SLSReporter;
2769
+ private statsMonitorId?;
2770
+ private autoSubAudio;
2771
+ private autoSubVideo;
2772
+ private autoSubScreen;
2773
+ private wantSubAudio;
2774
+ private wantSubVideo;
2775
+ private wantSubScreen;
2776
+ private defaultStreamType;
2777
+ private audioMuted;
2778
+ private playoutVolume;
2779
+ private refreshUrlTimer?;
2780
+ private audioVolumeIndicationInterval;
2781
+ private indicationTimer;
2782
+ private parameter;
2783
+ private audio3AConfig;
2784
+ private dcReadyHelper?;
2785
+ constructor(config: BizControlConfig);
2786
+ private addSignalingManagerListener;
2787
+ isAutoSubAudio(): boolean;
2788
+ setAutoSubAudio(value: boolean): void;
2789
+ isAutoSubVideo(): boolean;
2790
+ setAutoSubVideo(value: boolean): void;
2791
+ isAutoSubScreen(): boolean;
2792
+ setAutoSubScreen(value: boolean): void;
2793
+ isWantSubAudio(): boolean;
2794
+ setWantSubAudio(value: boolean): void;
2795
+ isWantSubVideo(): boolean;
2796
+ setWantSubVideo(value: boolean): void;
2797
+ isWantSubScreen(): boolean;
2798
+ setWantSubScreen(value: boolean): void;
2799
+ setRemoteDefaultVideoStreamType(type: AliRtcVideoStreamType): void;
2800
+ setRemoteUserVideoStreamType(userId: string, type: AliRtcVideoStreamType): void;
2801
+ setAudioMuted(mute: boolean): void;
2802
+ setLocalViewConfig(view: AliRtcLocalView, track: AliRtcVideoTrack): void;
2803
+ setRemoteViewConfig(uid: string, view: AliRtcLocalView, track: AliRtcVideoTrack): void;
2804
+ get channel(): string | undefined;
2805
+ get userId(): string | undefined;
2806
+ get remoteUsers(): RemoteUser[];
3004
2807
  /**
3005
- * 获取 sub/subAdd config
3006
- * @param {ISubscribeConfig | ISubConfigItem} options
3007
- * @returns {Omit<ISignalConfig | ISubConfigItem, 'url'>}
2808
+ * 获取推流对象,只能是自己
3008
2809
  */
3009
- private getSubConfig;
3010
- private httpSubscribe;
3011
- private subscribeAdd;
3012
- subscribeDelete(subscribeOptions: RemoteSubscribeOptions): Promise<ISubDeleteResult | undefined>;
3013
- subscibeStop(streamUrl: string): Promise<void>;
3014
- subscribeAddDataChannel(streamUrl: string): Promise<any>;
3015
- subscribeStopDatachannel(streamUrl: string, datachannel: any): Promise<any>;
3016
- publish(streamUrl: string, callId: string, isResume?: boolean, reason?: PublishReason): Promise<{
3017
- traceId: string;
3018
- l1ip?: string;
3019
- }>;
3020
- private reportSubscribeLatency;
3021
- subscribe(remoteSubscribeOptions: RemoteSubscribeOptions, reason: SubscribeReason, callId: string, remoteCallId: string, startTs: number): Promise<any>;
3022
- getSubscribeVideoStats(streamUrl: string, msid?: string): Promise<unknown>;
3023
- getSubscribeAudioStats(streamUrl: string, msid?: string): Promise<unknown>;
3024
- getStreamByMsid(config: any): LocalStream | RemoteStream;
3025
- getDatachannelByMsid(config: {
3026
- url: string;
3027
- msid?: string;
3028
- }): any;
3029
- getPCStats(): Promise<any>;
3030
- sendSEI(streamUrl: string, data: ArrayBuffer, repeatCount: number, payloadType: number): Promise<void>;
3031
- }
3032
-
3033
- declare class User extends EventEmitter$1<UserListener> {
3034
- protected uid: string;
3035
- protected name: string;
3036
- protected rtsManager: RtsManager;
3037
- callId: string;
3038
- protected audioLevelMonitor: AudioLevelMonitor;
3039
- protected audioVolumeIndicationInterval: number;
3040
- constructor(userId: string, displayname: string, rtsManager: RtsManager, interval: number);
3041
- get userId(): string;
3042
- get displayname(): string;
3043
- protected createCallId(): void;
3044
- setUserInfo(uid: string, displayName: string): void;
3045
- refreshUserInfo(uid: string): void;
2810
+ get publisher(): LocalUser | undefined;
2811
+ get isSubscribing(): boolean;
3046
2812
  /**
3047
- * 获取音频 level
2813
+ * 处理远端用户推流状态变化
2814
+ * @param {string} userId
2815
+ * @param {string} displayname
2816
+ * @param {string} callid
2817
+ * @param {string} pullStreamUrl
2818
+ * @param {TrackInfo[]} tracks
2819
+ * @returns {void}
3048
2820
  */
3049
- getAudioLevel(): number;
3050
- enableAudioVolumeIndication(interval: number): void;
3051
- /**
3052
- * 销毁用户,清空数据
2821
+ onRemotePublishStateChange(publishInfo: PublishUser, updateSubscribe?: boolean): void;
2822
+ /** 定期更新所有人的推拉流地址,便于重连
2823
+ * @param pushStreamUrl 已有的推流地址,根据地址中的过期时间来设置定时器
2824
+ * @private
3053
2825
  */
3054
- clear(): void;
3055
- }
3056
-
3057
- declare class LocalUser extends User {
2826
+ private setTimeoutToUpdateAllStreamUrls;
3058
2827
  /**
3059
- * @ignore
2828
+ * 登陆成功后初始化用户管理,创建自己
2829
+ * @param {AliRtcAuthInfo} authInfo
2830
+ * @param {JoinResult} data
2831
+ * @returns {Promise<void>}
3060
2832
  */
3061
- static logName: string;
3062
- private _url;
3063
- private joinTime;
3064
- private publishPromise;
3065
- private previewElements;
3066
- private screenPreviewElements;
3067
- private streamManager;
3068
- private dc;
3069
- protected streamTracks?: TrackInfo[];
3070
- protected publishId: string;
3071
- protected signalingManager: SignalingManager;
3072
- private shouldPublish;
3073
- traceId: string;
3074
- private monitorTimerId?;
3075
- private monitorDataCache;
3076
- private trackTraceIdMap;
3077
- private candidateDataCache;
3078
- private pcMediaStatsMap;
3079
- protected slsReporter: SLSReporter;
3080
- private audioPubState;
3081
- private videoPubState;
3082
- private videoSmallPubState;
3083
- private screenPubState;
3084
- private dataPubState;
3085
- private parameter;
3086
- constructor(config: LocalUserConfig);
3087
- get url(): string;
3088
- set url(value: string);
3089
- set preferredPubL1Ip(value: string);
3090
- get joined(): boolean;
3091
- get isPublishing(): boolean;
3092
- get publishStreams(): PublishStreamInfo;
3093
- get cameraTrack(): MediaStreamTrack | undefined;
3094
- get screenTrack(): MediaStreamTrack | undefined;
3095
- get audioTrack(): MediaStreamTrack | undefined;
3096
- get hasCamera(): boolean;
3097
- get hasMicrophone(): boolean;
3098
- get hasScreenShare(): boolean;
3099
- get hasCameraTrackInMS(): boolean;
3100
- get hasCameraDualTrackInMS(): boolean;
3101
- get hasScreenTrackInMS(): boolean;
3102
- get hasAudioTrackInMS(): boolean;
3103
- get cameraDirection(): string | undefined;
3104
- get audioCaptureDisabled(): boolean;
3105
- get cameraCaptureDisabled(): boolean;
3106
- get publishLocalVideoStreamEnabled(): boolean;
3107
- get publishLocalAudioStreamEnabled(): boolean;
3108
- get publishLocalScreenStreamEnabled(): boolean;
3109
- setPublishLocalAudioStreamEnabled(enable: boolean): void;
3110
- setPublishLocalVideoStreamEnabled(enable: boolean): void;
3111
- setPublishLocalScreenStreamEnabled(enable: boolean): void;
3112
- initInfo(authInfo: AliRtcAuthInfo, pushStreamUrl: string): void;
3113
- setVideoProfile(profile?: VideoProfileWithSendFramerate): Promise<void>;
3114
- setVideoContentHint(hint: string): void;
3115
- setScreenContentHint(hint: string): void;
3116
- setAudioProfile(profileKey: AudioProfileKey): Promise<void>;
3117
- setScreenProfile(profile?: Partial<IProfile>): Promise<void>;
3118
- setCameraDirection(direction: AliRtcCameraDirection): void;
3119
- setCameraDeviceId(deviceId: string): void;
3120
- muteLocalCamera(mute: boolean): void;
3121
- muteLocalMic(mute: boolean): void;
3122
- muteLocalScreen(mute: boolean): void;
3123
- setMicrophoneDeviceId(deviceId: string): void;
3124
- setMicrophoneConstraints(constraints: MediaTrackConstraints): void;
3125
- updatePubId(): void;
3126
- clearPublishState(): void;
2833
+ init(authInfo: AliRtcAuthInfo, data: JoinResult, channelParam: AliRtcChannelParam): void;
3127
2834
  leave(): Promise<void>;
3128
2835
  /**
3129
- * 销毁,停止推流
2836
+ * 离会后清除所有数据
3130
2837
  * @returns {Promise<void>}
3131
2838
  */
3132
2839
  clear(): Promise<void>;
3133
- resetElement(element: HTMLVideoElement): void;
3134
- setPreviewElement(previewParams: PreviewConfig): void;
3135
- startDefaultCameraAndMic(audioOnly?: boolean): Promise<void>;
2840
+ private startStatsMonitor;
2841
+ private stopStatsMonitor;
3136
2842
  /**
3137
- * 为本地预览设置渲染元素和视频流
3138
- * @param {AliRtcLocalView} view 渲染元素,null 则为停止显示
3139
- * @param {AliRtcVideoTrack} track 视频流类型
2843
+ * 添加远端用户
2844
+ * @param {JoinInfo} userJoinInfo
2845
+ * @param {SubscribeReason} reason
2846
+ * @returns {void}
3140
2847
  */
3141
- setViewConfig(elements: null | HTMLVideoElement[], track: AliRtcVideoTrack): void;
2848
+ addUser(userJoinInfo: JoinInfo, reason: SubscribeReason): RemoteUser;
3142
2849
  /**
3143
- * 开启摄像头采集
3144
- * @param params
3145
- * @returns
2850
+ * 执行添加远端用户
2851
+ * @param {string} userId
2852
+ * @param {string} displayName
2853
+ * @returns {RemoteUser}
3146
2854
  */
3147
- startCameraCapture(): Promise<LocalStream | undefined>;
2855
+ private executeAddUser;
3148
2856
  /**
3149
- * 关闭摄像头采集
3150
- * @note 调用此接口后,入会后、离会再入会,采集设备保持关闭状态
2857
+ * 远端用户设备状态变化
2858
+ * @param {DeviceStatusChangeType} event
2859
+ * @param {string} userId
3151
2860
  */
3152
- stopCameraCapture(): Promise<void>;
2861
+ private onRemoteDeviceStatusChange;
3153
2862
  /**
3154
- * 开启麦克风采集
3155
- * @param params
3156
- * @returns
2863
+ * 远端流数据采集上报
2864
+ * @param {any} stat
3157
2865
  */
3158
- startAudioCapture(): Promise<LocalStream | undefined>;
2866
+ private onRemoteStatReport;
3159
2867
  /**
3160
- * 关闭音频采集
3161
- * @note 调用此接口后,入会后、离会再入会,采集设备保持关闭状态
2868
+ * rts 单 PC 订阅超限
3162
2869
  */
3163
- stopAudioCapture(): Promise<void>;
3164
- startCameraAndMic(): Promise<LocalStream | undefined>;
2870
+ private onSubscribeExceeds;
3165
2871
  /**
3166
- * 预览本地流
3167
- * @param {PreviewConfig} previewParams
3168
- * @returns {Promise<MediaStream>}
2872
+ * 移除远端用户
2873
+ * @param {LeaveInfo} user
2874
+ * @returns {Promise<void>}
2875
+ */
2876
+ removeLeftUser(user: LeaveInfo): Promise<void>;
2877
+ /**
2878
+ * 更新远端用户数据
2879
+ * @param {JoinInfo[]} users
2880
+ * @returns {{joinList: JoinInfo[], leaveList: LeaveInfo[], presentList: JoinInfo[]}}
2881
+ */
2882
+ diffUsers(users: JoinInfo[]): {
2883
+ joinList: JoinInfo[];
2884
+ leaveList: LeaveInfo[];
2885
+ presentList: JoinInfo[];
2886
+ };
2887
+ /**
2888
+ * 根据 userId 获取 RemoteUser
2889
+ * @param {string} userId
2890
+ * @returns {RemoteUser | undefined}
2891
+ */
2892
+ getRemoteUser(userId: string): RemoteUser | undefined;
2893
+ /**
2894
+ * 更新远端用户设备信息
2895
+ * @param {RemoteUserStatus} user
2896
+ * @returns {boolean} true: 用户状态改变 false: 用户状态没有改变
2897
+ */
2898
+ updateRemoteUserDeviceStatus(user: RemoteUserStatus): void;
2899
+ updateAudioWant(uid: string, sub: boolean): void;
2900
+ updateVideoWant(uid: string, sub: boolean): void;
2901
+ updateScreenWant(uid: string, sub: boolean): void;
2902
+ private stopIndication;
2903
+ private startIndication;
2904
+ setEnableDualVideoStream(enabled: boolean, options?: AliRtcDualVideoPluginOptions): void;
2905
+ setAudioVolume(options: AudioMixerPluginOptions): void;
2906
+ enableAudioVolumeIndication(interval: number): void;
2907
+ setPlayoutVolume(volume: number): void;
2908
+ refreshAuthInfo(authInfo: AliRtcRefreshAuthInfo): void;
2909
+ setEnableMediaExtensionMsg(enable: boolean): void;
2910
+ setAudioRedEnabled(enable: boolean): void;
2911
+ setParameter(parameter: string): void;
2912
+ private setupAudioProcessingPluginIfNeeded;
2913
+ getParameter(): string;
2914
+ sendDataChannelMessage(message: AliRtcDataChannelMsg): void;
2915
+ }
2916
+
2917
+ declare enum AliRtcLiveTranscodingMixMode {
2918
+ /*! 单路模式 */
2919
+ LiveTranscodingSingle = 0,
2920
+ /*! 混流模式 */
2921
+ LiveTranscodingMix = 1
2922
+ }
2923
+ declare enum AliRtcLiveTranscodingStreamType {
2924
+ /*! 原始流 */
2925
+ LiveTranscodingOrigin = 0,
2926
+ /*! 音频 */
2927
+ LiveTranscodingAudio = 1,
2928
+ /*! 视频 */
2929
+ LiveTranscodingVideo = 2
2930
+ }
2931
+ declare enum AliRtcLiveTranscodingSourceType {
2932
+ /*! 相机流 */
2933
+ LiveTranscodingCamera = 0,
2934
+ /*! 屏幕流 */
2935
+ LiveTranscodingShareScreen = 1
2936
+ }
2937
+ declare enum AliRtcLiveTranscodingTaskProfile {
2938
+ LiveTranscoding_Profile_1IN_1080P = 0,
2939
+ LiveTranscoding_Profile_1IN_720P = 1,
2940
+ LiveTranscoding_Profile_1IN_360P = 2,
2941
+ LiveTranscoding_Profile_2IN_1080P = 3,
2942
+ LiveTranscoding_Profile_2IN_720P = 4,
2943
+ LiveTranscoding_Profile_2IN_360P = 5,
2944
+ LiveTranscoding_Profile_4IN_1080P = 6,
2945
+ LiveTranscoding_Profile_4IN_720P = 7,
2946
+ LiveTranscoding_Profile_4IN_360P = 8,
2947
+ LiveTranscoding_Profile_9IN_1080P = 9,
2948
+ LiveTranscoding_Profile_9IN_720P = 10,
2949
+ LiveTranscoding_Profile_9IN_360P = 11,
2950
+ LiveTranscoding_Profile_12IN_1080P = 12,
2951
+ LiveTranscoding_Profile_12IN_720P = 13,
2952
+ LiveTranscoding_Profile_12IN_360P = 14,
2953
+ LiveTranscoding_Profile_16IN_1080P = 15,
2954
+ LiveTranscoding_Profile_16IN_720P = 16,
2955
+ LiveTranscoding_Profile_16IN_360P = 17,
2956
+ LiveTranscoding_Profile_Mixed = 9999
2957
+ }
2958
+ declare enum AliRtcLiveTranscodingAudioSampleRate {
2959
+ LiveTranscoding_HZ_48000 = 48000,
2960
+ LiveTranscoding_HZ_44100 = 44100,
2961
+ LiveTranscoding_HZ_32000 = 32000,
2962
+ LiveTranscoding_HZ_16000 = 16000,
2963
+ LiveTranscoding_HZ_8000 = 8000
2964
+ }
2965
+ declare enum AliRtcLiveTranscodingSegmentType {
2966
+ /*! 无人像分割 */
2967
+ LiveTranscodingNoBody = 0,
2968
+ /*! 人像分割 */
2969
+ LiveTranscodingBody = 1
2970
+ }
2971
+ declare enum AliRtcLiveTranscodingFontType {
2972
+ NOTO_SERIF_CJKSC_REGULAR = 0,
2973
+ ALIBABA_PUHUITI_REGULAR = 1,
2974
+ ALIBABA_PUHUITI_BOLD = 2,
2975
+ ALIBABA_PUHUITI_Heavy = 3,
2976
+ ALIBABA_PUHUITI_LIGHT = 4,
2977
+ ALIBABA_PUHUITI_MEDIUM = 5
2978
+ }
2979
+ declare enum AliRtcLiveTranscodingCropMode {
2980
+ /*! 缩放模式 */
2981
+ LiveTranscodingOrigin = 0,
2982
+ /*! 剪裁 */
2983
+ LiveTranscodingCrop = 1,
2984
+ /*! 填充 */
2985
+ LiveTranscodingFill = 2
2986
+ }
2987
+ declare enum AliRtcLiveTranscodingMediaProcessMode {
2988
+ /*! 通用模式 */
2989
+ LiveTranscodingNormal = 0,
2990
+ /*! 虚拟背景模式 */
2991
+ LiveTranscodingVirtualBackground = 1
2992
+ }
2993
+ declare enum AliRtcLiveTranscodingState {
2994
+ LiveTranscodingState_IDLE = 0,
2995
+ LiveTranscodingState_CONNNECT = 1,
2996
+ LiveTranscodingState_RUNNING = 2,
2997
+ LiveTranscodingState_RECOVERING = 3,
2998
+ LiveTranscodingState_FAILURE = 4,
2999
+ LiveTranscodingState_END = 5
3000
+ }
3001
+ declare enum AliRtcLiveTranscodingErrorCode {
3002
+ LiveTranscodingErrorPublishOk = 0,
3003
+ LiveTranscodingErrorStreamNotFound = 17825793,
3004
+ LiveTranscodingErrorStreamAlreadyExist = 17825794,
3005
+ LiveTranscodingErrorInvalidParam = 17825795,
3006
+ LiveTranscodingErrorInternalError = 17825796,
3007
+ LiveTranscodingErrorRtmpServerError = 17825797,
3008
+ LiveTranscodingErrorRtmpStreamUrlError = 17825798,
3009
+ LiveTranscodingErrorPublishTimeout = 17825799,
3010
+ LiveTranscodingErrorNotAuthorized = 17825800
3011
+ }
3012
+ declare enum AliRtcTrascodingPublishTaskStatus {
3013
+ /*! 任务开始 */
3014
+ TrascodingPublishTaskStatusStart = 0,
3015
+ /*! 任务更新 */
3016
+ TrascodingPublishTaskStatusUpdate = 1,
3017
+ /*! 任务已停止 */
3018
+ TrascodingPublishTaskStatusStop = 2
3019
+ }
3020
+ declare enum MPU_TASK_TRANSACTION_TYPE {
3021
+ MPU_TASK_TRANSACTION_START = 0,
3022
+ MPU_TASK_TRANSACTION_UPDATE = 1,
3023
+ MPU_TASK_TRANSACTION_STOP = 2,
3024
+ MPU_TASK_TRANSACTION_LIST = 3,
3025
+ MPU_TASK_TRANSACTION_POLLING = 4,
3026
+ MPU_TASK_TRANSACTION_ACKNOWLEDGE = 5,
3027
+ MPU_TASK_TRANSACTION_END = 6
3028
+ }
3029
+
3030
+ declare class AliRtcLiveTranscodingEncodeParam {
3031
+ videoWidth: number;
3032
+ videoHeight: number;
3033
+ videoFramerate: number;
3034
+ videoBitrate: number;
3035
+ videoGop: number;
3036
+ audioSamplerate: AliRtcLiveTranscodingAudioSampleRate;
3037
+ audioBitrate: number;
3038
+ audioChannels: number;
3039
+ constructor(videoWidth: number, videoHeight: number, videoFramerate?: number, videoBitrate?: number, videoGop?: number, audioSamplerate?: AliRtcLiveTranscodingAudioSampleRate, audioBitrate?: number, audioChannels?: number);
3040
+ }
3041
+
3042
+ declare class AliRtcTranscodingClockWidget {
3043
+ x: number;
3044
+ y: number;
3045
+ fontSize: number;
3046
+ zOrder: number;
3047
+ fontColor: number;
3048
+ fontType: AliRtcLiveTranscodingFontType;
3049
+ constructor(x: number, y: number, fontSize: number);
3050
+ constructor(x: number, y: number, fontSize: number, zOrder: number);
3051
+ constructor(x: number, y: number, fontSize: number, zOrder: number, fontColor: number);
3052
+ constructor(x: number, y: number, fontSize: number, zOrder: number, fontColor: number, fontType: AliRtcLiveTranscodingFontType);
3053
+ toJson(videoWidth: number, videoHeight: number): {
3054
+ x: number;
3055
+ y: number;
3056
+ fonttype: AliRtcLiveTranscodingFontType;
3057
+ fontsize: number;
3058
+ fontcolor: number;
3059
+ zorder: number;
3060
+ };
3061
+ }
3062
+
3063
+ declare enum DisplayType {
3064
+ NOT_DISPLAY = 0,
3065
+ ALWAYS = 1,
3066
+ WHEN_NO_VIDEO = 2
3067
+ }
3068
+ declare class AliRtcTranscodingImage {
3069
+ static DisplayType: typeof DisplayType;
3070
+ url: string;
3071
+ x: number;
3072
+ y: number;
3073
+ width: number;
3074
+ height: number;
3075
+ alpha: number;
3076
+ display: DisplayType;
3077
+ zOrder: number;
3078
+ constructor(url: string, x: number, y: number, width: number, height: number);
3079
+ constructor(url: string, x: number, y: number, width: number, height: number, zOrder: number);
3080
+ constructor(url: string, x: number, y: number, width: number, height: number, zOrder: number, alpha: number);
3081
+ constructor(url: string, x: number, y: number, width: number, height: number, zOrder: number, alpha: number, display: DisplayType);
3082
+ toJson(videoWidth: number, videoHeight: number): {
3083
+ url: string;
3084
+ alpha: number;
3085
+ display: DisplayType;
3086
+ x: number;
3087
+ y: number;
3088
+ width: number;
3089
+ height: number;
3090
+ zorder: number;
3091
+ };
3092
+ }
3093
+
3094
+ declare class AliRtcTranscodingText {
3095
+ text: string;
3096
+ x: number;
3097
+ y: number;
3098
+ fontSize: number;
3099
+ zOrder: number;
3100
+ fontColor: number;
3101
+ fontType: AliRtcLiveTranscodingFontType;
3102
+ constructor(text: string, x: number, y: number, fontSize: number);
3103
+ constructor(text: string, x: number, y: number, fontSize: number, zOrder: number);
3104
+ constructor(text: string, x: number, y: number, fontSize: number, zOrder: number, fontColor: number);
3105
+ constructor(text: string, x: number, y: number, fontSize: number, zOrder: number, fontColor: number, fontType: AliRtcLiveTranscodingFontType);
3106
+ toJson(videoWidth: number, videoHeight: number): {
3107
+ text: string;
3108
+ x: number;
3109
+ y: number;
3110
+ fonttype: AliRtcLiveTranscodingFontType;
3111
+ fontsize: number;
3112
+ fontcolor: number;
3113
+ zorder: number;
3114
+ };
3115
+ }
3116
+
3117
+ declare class AliRtcTranscodingUser {
3118
+ userId: string;
3119
+ x: number;
3120
+ y: number;
3121
+ width: number;
3122
+ height: number;
3123
+ zOrder?: number;
3124
+ sourceType?: AliRtcLiveTranscodingSourceType;
3125
+ segmentType: AliRtcLiveTranscodingSegmentType;
3126
+ images: AliRtcTranscodingImage[];
3127
+ texts: AliRtcTranscodingText[];
3128
+ constructor(userId: string, x: number, y: number, width: number, height: number);
3129
+ constructor(userId: string, x: number, y: number, width: number, height: number, zOrder: number);
3130
+ constructor(userId: string, x: number, y: number, width: number, height: number, zOrder: number, sourceType: AliRtcLiveTranscodingSourceType);
3131
+ toJson(index: number, videoWidth: number, videoHeight: number, mediaProcessMode?: AliRtcLiveTranscodingMediaProcessMode): {
3132
+ [key: string]: any;
3133
+ };
3134
+ }
3135
+
3136
+ declare class LiveTranscodingMixParam {
3137
+ taskProfile: AliRtcLiveTranscodingTaskProfile;
3138
+ encodeParam?: AliRtcLiveTranscodingEncodeParam;
3139
+ users: AliRtcTranscodingUser[];
3140
+ backgroundColor: number;
3141
+ backgrounds: AliRtcTranscodingImage[];
3142
+ watermarks: AliRtcTranscodingImage[];
3143
+ clockWidgets: AliRtcTranscodingClockWidget[];
3144
+ cropMode?: AliRtcLiveTranscodingCropMode;
3145
+ mediaProcessMode?: AliRtcLiveTranscodingMediaProcessMode;
3146
+ constructor(taskProfile: AliRtcLiveTranscodingTaskProfile);
3147
+ }
3148
+
3149
+ declare class AliRtcLiveTranscodingSingleParam {
3150
+ userId?: string;
3151
+ streamType?: AliRtcLiveTranscodingStreamType;
3152
+ sourceType?: AliRtcLiveTranscodingSourceType;
3153
+ constructor(uid?: string, streamType?: AliRtcLiveTranscodingStreamType, sourceType?: AliRtcLiveTranscodingSourceType);
3154
+ }
3155
+
3156
+ declare class AliRtcLiveTranscodingParam {
3157
+ /*! 旁路模式 */
3158
+ mixMode: AliRtcLiveTranscodingMixMode;
3159
+ /*! 路模式单路参数 */
3160
+ singleParam?: AliRtcLiveTranscodingSingleParam;
3161
+ /*! 旁路模式混流参数 */
3162
+ mixParam?: LiveTranscodingMixParam;
3163
+ constructor(mixMode?: AliRtcLiveTranscodingMixMode, singleParam?: AliRtcLiveTranscodingSingleParam, mixParam?: LiveTranscodingMixParam);
3164
+ toJson(type: MPU_TASK_TRANSACTION_TYPE, authInfo: AliRtcAuthInfo, taskId: string, streamUrl?: string, messageId?: string): {
3165
+ [key: string]: any;
3166
+ };
3167
+ }
3168
+
3169
+ declare class AliRtcLiveTranscoding {
3170
+ authInfo?: AliRtcAuthInfo;
3171
+ private slsReporter;
3172
+ constructor(slsReporter: SLSReporter);
3173
+ private doRequest;
3174
+ setAuthInfo(authInfo: AliRtcAuthInfo): void;
3175
+ clear(): void;
3176
+ startPublishLiveStream(streamUrl: string, transcodingParam: AliRtcLiveTranscodingParam): Promise<any>;
3177
+ startPublishLiveStreamWithTaskId(taskId: string, transcodingParam: AliRtcLiveTranscodingParam): Promise<any>;
3178
+ updatePublishLiveStream(streamUrl: string, transcodingParam: AliRtcLiveTranscodingParam): Promise<any>;
3179
+ updatePublishLiveStreamWithTaskId(taskId: string, transcodingParam: AliRtcLiveTranscodingParam): Promise<any>;
3180
+ stopPublishLiveStream(streamUrl: string): Promise<any>;
3181
+ stopPublishLiveStreamWithTaskId(taskId: string): Promise<any>;
3182
+ refreshAuthInfo(authInfo: AliRtcRefreshAuthInfo): void;
3183
+ }
3184
+
3185
+ declare enum AliRtcLogLevel {
3186
+ DEBUG = 0,
3187
+ INFO = 1,
3188
+ API = 2,
3189
+ WARNING = 3,
3190
+ ERROR = 4,
3191
+ NONE = 5
3192
+ }
3193
+
3194
+ interface AliRtcBeautyConfig {
3195
+ whiteningLevel: number;
3196
+ /*! 磨皮等级[0-1.0] */
3197
+ smoothnessLevel: number;
3198
+ }
3199
+
3200
+ interface AliRtcWebTrackConfig {
3201
+ biz: string;
3202
+ extraParams?: string;
3203
+ }
3204
+ interface AliRtcEngineConfig {
3205
+ env?: AliRtcEnv;
3206
+ webTrack?: boolean | AliRtcWebTrackConfig;
3207
+ maxSignalingConnectRetryCount?: number;
3208
+ }
3209
+ interface AliRtcAIAgentParam {
3210
+ /*! ai agent id */
3211
+ agentId: string;
3212
+ /*! ai agent的区域 */
3213
+ region: string;
3214
+ /*! 启动ai agent的action */
3215
+ action: string;
3216
+ /*! 启动ai agent的参数 */
3217
+ params: string;
3218
+ }
3219
+
3220
+ interface AliRtcEngineEventListener {
3221
+ /**
3222
+ * @brief 网络连接状态改变
3223
+ * @param status 连接状态
3224
+ * @param reason 连接状态变化原因
3225
+ */
3226
+ connectionStatusChange: (status: AliRtcConnectionStatus, reason: AliRtcConnectionStatusChangeReason) => void;
3227
+ /**
3228
+ * @brief 本地设备异常回调
3229
+ * @param deviceType 设备类型, 参考{@link AliRtcEngine.AliRtcEngineLocalDeviceType}
3230
+ * @param exceptionType 设备异常类型, 参考{@link AliRtcEngine.AliRtcEngineLocalDeviceExceptionType}
3231
+ * @param msg 异常时携带的信息
3232
+ * @note 此回调标识了内部无法恢复了设备异常,收到此回调时用户需要检查设备是否可用
3233
+ */
3234
+ localDeviceException: (localDeviceType: AliRtcEngineLocalDeviceType, localDeviceExceptionType: AliRtcEngineLocalDeviceExceptionType, description: string) => void;
3235
+ /**
3236
+ * @brief 用户鉴权信息即将过期通知,收到后30秒鉴权过期
3237
+ * @note 该回调在鉴权信息30秒前触发,收到该回调后应该及时更新鉴权信息,参考 {@link AliRtcEngine.refreshAuthInfo}
3169
3238
  */
3170
- preview(previewParams: PreviewConfig): Promise<MediaStream | undefined>;
3171
3239
  /**
3172
- * 在所有预览容器中预览当前流
3173
- * @param {boolean} screen 是否指定预览辅流
3240
+ * 被服务器踢出/会议结束频道的消息
3241
+ * @param code 原因参考{@link AliRtcEngine.AliRtcOnByeType}
3174
3242
  */
3175
- previewAll(previewAllParams?: PreviewAllConfig): Promise<void>;
3243
+ bye: (code: AliRtcOnByeType) => void;
3176
3244
  /**
3177
- * 停止预览本地流
3245
+ * @brief 远端用户(通信模式)/(互动模式,主播角色)加入频道回调
3246
+ * @details 该回调在以下场景会被触发
3247
+ * - 通信模式:远端用户加入频道会触发该回调,如果当前用户在加入频道前已有其他用户在频道中,当前用户加入频道后也会收到已加入频道用户的回调
3248
+ * - 互动模式:
3249
+ * - 远端主播角色用户加入频道会触发该回调,如果当前用户在加入频道前已有其他主播在频道中,当前用户加入频道后也会收到已加入频道主播的回调
3250
+ * - 远端观众角色调用 {@link AliRtcEngine.setClientRole} 切换为主播角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkInteractive},同时设置了推流时,会触发该回调
3251
+ *
3252
+ * @param uid 用户ID,从App server分配的唯一标示符
3253
+ * @param elapsed 用户加入频道时的耗时
3254
+ * @note 互动模式下回调行为
3255
+ * - 主播间可以互相收到加入频道回调
3256
+ * - 观众可以收到主播加入频道回调
3257
+ * - 主播无法收到观众加入频道回调
3178
3258
  */
3179
- stopPreview(previewParams?: StopPreviewConfig): void;
3259
+ remoteUserOnLineNotify: (uid: string, elapsed: number) => void;
3180
3260
  /**
3181
- * 恢复推流
3182
- * @returns {Promise<void>}
3261
+ * @brief 远端用户(通信模式)/(互动模式,主播角色)离开频道回调
3262
+ * @details 该回调在以下场景会被触发
3263
+ * - 通信模式:远端用户离开频道会触发该回调
3264
+ * - 互动模式:
3265
+ * - 远端主播角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkInteractive} 离开频道
3266
+ * - 远端主播切换调用 {@link AliRtcEngine.setClientRole} 切换为观众角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkLive},会触发该回调
3267
+ * - 通信模式和互动模式主播角色情况下,当长时间收不到远端用户数据,超时掉线时,会触发该回调
3268
+ *
3269
+ * @param uid 用户ID,从App server分配的唯一标示符
3270
+ * @param reason 用户离线的原因,详见 {@link AliRtcEngine.AliRtcUserOfflineReason}
3183
3271
  */
3184
- resumePublish(): Promise<void>;
3185
- createLocalStream(params: LocalStreamConfig): Promise<LocalStream | undefined>;
3186
- stopLocalStream(options: PublishOptions): Promise<void>;
3187
- private compareAndPublish;
3188
- private reportAudioProfile;
3189
- private reportVideoProfile;
3190
- private reportScreenProfile;
3191
- private updateDataChannel;
3192
- private publishDataChannel;
3272
+ remoteUserOffLineNotify: (uid: string, aliRtcUserOfflineReason: AliRtcUserOfflineReason) => void;
3193
3273
  /**
3194
- * 开始推流
3195
- * @param isResume 是否是恢复推流
3196
- * @returns
3274
+ * @brief 远端用户的音视频流发生变化回调
3275
+ * @details 该回调在以下场景会被触发
3276
+ * - 当远端用户从未推流变更为推流(包括音频和视频)
3277
+ * - 当远端用户从已推流变更为未推流(包括音频和视频)
3278
+ * - 互动模式下,调用 {@link AliRtcEngine.setClientRole} 切换为主播角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkInteractive},同时设置了推流时,会触发该回调
3279
+ *
3280
+ * @param uid 用户ID,从App server分配的唯一标示符
3281
+ * @param audioTrack 音频流类型,详见 {@link AliRtcEngine.AliRtcAudioTrack}
3282
+ * @param videoTrack 视频流类型,详见 {@link AliRtcEngine.AliRtcVideoTrack}
3283
+ * @note 该回调仅在通信模式用户和互动模式下的主播角色才会触发
3197
3284
  */
3198
- startPublish(isResume?: boolean, reason?: PublishReason): Promise<void>;
3285
+ remoteTrackAvailableNotify: (uid: string, aliRtcAudioTrack: AliRtcAudioTrack, aliRtcVideoTrack: AliRtcVideoTrack) => void;
3199
3286
  /**
3200
- * 重新执行 progress 并触发 publishupdate
3287
+ * @brief 远端用户静音/取消静音回调
3288
+ * @param uid 远端用户ID
3289
+ * @param isMute 该用户是否静音
3290
+ * - true: 静音
3291
+ * - false: 取消静音
3201
3292
  */
3202
- updateStreams(): Promise<void>;
3293
+ userAudioMuted: (uid: string, isMute: boolean) => void;
3203
3294
  /**
3204
- * 对比本地流和正在推流,进行推流更新
3205
- * @param isResume 是否是恢复推流
3295
+ * @brief 对端用户发送视频黑帧数据发送通知
3296
+ * @param uid 执行muteVideo的用户ID
3297
+ * @param isMute
3298
+ * - true: 推流黑帧
3299
+ * - false: 正常推流
3300
+ * @note 该接口用于对端用户发送视频黑帧数据时的回调
3206
3301
  */
3207
- publishUpdate(reason?: PublishReason): Promise<PublishInfo | undefined>;
3208
- private syncPublishToRoomServer;
3209
- private refreshPushStreamUrl;
3302
+ userVideoMuted: (uid: string, isMute: boolean) => void;
3210
3303
  /**
3211
- * 推流,用于 rts subscribe/publish 被调用后,此时 DataChannel 已存在
3212
- * @param {LocalStream} stream
3213
- * @returns {Promise<PublishInfo>}
3304
+ * @brief 对端用户发送屏幕黑帧数据发送通知
3305
+ * @param uid 执行muteVideo的用户ID
3306
+ * @param isMute
3307
+ * - true: 推流黑帧
3308
+ * - false: 正常推流
3309
+ * @note 该接口用于对端用户发送屏幕黑帧数据时的回调
3214
3310
  */
3215
- publishAdd(stream: LocalStream, extra: PublishExtraParams, isResume?: boolean, retryTimes?: number): Promise<PublishInfo>;
3311
+ userScreenMuted: (uid: string, isMute: boolean) => void;
3216
3312
  /**
3217
- * 替换推流 Track(仅限于替换已存在的 Track 类型)
3218
- * @param {LocalStream} stream
3219
- * @returns {Promise<PublishInfo>}
3313
+ * 音量反馈
3314
+ * @param {Array} speakers 用户音量对象数组
3315
+ * @param {string} speaker.userId 用户ID
3316
+ * @param {number} speaker.volume 音量
3317
+ * @note userId 为空字符串时代表是本地麦克风采集的音量
3220
3318
  */
3221
- publishReplace(stream: LocalStream, extra?: PublishExtraParams): Promise<PublishInfo>;
3319
+ audioVolume: (speakers: {
3320
+ userId: string;
3321
+ volume: number;
3322
+ }[]) => void;
3222
3323
  /**
3223
- * 停止推某些轨,不销毁 DataChannel 和 LocalStream,用于非销毁场景
3224
- * @param {PublishOptions} options
3225
- * @returns {Promise<PublishInfo>}
3324
+ * 发布视频流的数据统计
3325
+ * @param aliRtcStats 统计信息
3226
3326
  */
3227
- publishDeleteTracks(options: PublishOptions): Promise<PublishInfo>;
3327
+ aliRtcStats: (aliRtcStats: any) => void;
3228
3328
  /**
3229
- * 停止推流,不销毁 LocalStream,用于非销毁场景
3230
- * @returns {Promise<PublishInfo>}
3329
+ * 音频推流变更回调
3330
+ * @param track 流标识
3331
+ * @param oldState 之前的推流状态
3332
+ * @param newState 当前的推流状态
3333
+ * @param elapseSinceLastState 状态变更时间间隔(毫秒)
3334
+ * @param channel 当前频道
3231
3335
  */
3232
- publishStop(): Promise<PublishInfo>;
3336
+ audioPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
3233
3337
  /**
3234
- * 停止推流,销毁 DataChannel,用于销毁的场景
3235
- * @returns {Promise<PublishInfo>}
3338
+ * 音频订阅情况变更回调
3339
+ * @param uid 用户ID
3340
+ * @param oldState 之前的订阅状态
3341
+ * @param newState 当前的订阅状态
3342
+ * @param elapseSinceLastState 状态变更时间间隔(毫秒)
3343
+ * @param channel 当前频道
3236
3344
  */
3237
- unPublish(): Promise<PublishInfo>;
3345
+ audioSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
3238
3346
  /**
3239
- * 事件通知本地的设备使用状态
3347
+ * 视频推流变更回调
3348
+ * @param oldState 之前的推流状态
3349
+ * @param newState 当前的推流状态
3350
+ * @param elapseSinceLastState 状态变更时间间隔(毫秒)
3351
+ * @param channel 当前频道
3240
3352
  */
3241
- reportSelfDeviceStatus(): void;
3353
+ videoPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
3242
3354
  /**
3243
- * 从localStream 中获取当前的设备状态
3244
- * @returns {string}
3355
+ * 次要流推流变更回调
3356
+ * @param oldState 之前的推流状态
3357
+ * @param newState 当前的推流状态
3358
+ * @param elapseSinceLastState 状态变更时间间隔(毫秒)
3359
+ * @param channel 当前频道
3245
3360
  */
3246
- private getDeviceStatus;
3247
- private onTrackEnd;
3248
- private resetPreviewElements;
3249
- private resetSecondayPreviewElements;
3250
- getMediaStats(id: string): any;
3251
- private reportPublishMonitor;
3252
- private reportNetwork;
3253
- private startStreamMonitor;
3361
+ dualStreamPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
3254
3362
  /**
3255
- * 停止本地流数据采集
3363
+ * 屏幕分享推流变更回调
3364
+ * @param oldState 之前的推流状态
3365
+ * @param newState 当前的推流状态
3366
+ * @param elapseSinceLastState 状态变更时间间隔(毫秒)
3367
+ * @param channel 当前频道
3256
3368
  */
3257
- private stopStreamMonitor;
3369
+ screenSharePublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
3258
3370
  /**
3259
- * 清除本地流
3260
- * @returns {void}
3371
+ * DataChannel 推流变更回调
3372
+ * @param oldState 之前的推流状态
3373
+ * @param newState 当前的推流状态
3374
+ * @param elapseSinceLastState 状态变更时间间隔(毫秒)
3375
+ * @param channel 当前频道
3261
3376
  */
3262
- clearStream(): void;
3377
+ dataPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
3263
3378
  /**
3264
- * 获取当前使用的摄像头 deviceId
3265
- * @returns {string | undefined}
3379
+ * 相机流订阅情况变更回调
3380
+ * @param uid 用户ID
3381
+ * @param oldState 之前的订阅状态
3382
+ * @param newState 当前的订阅状态
3383
+ * @param elapseSinceLastState 状态变更时间间隔(毫秒)
3384
+ * @param channel 当前频道
3266
3385
  */
3267
- getCurrentCameraDeviceId(): string | undefined;
3386
+ videoSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
3268
3387
  /**
3269
- * 获取当前使用的摄像头 deviceId
3270
- * @returns {string | undefined}
3388
+ * 大小流订阅情况变更回调
3389
+ * @param uid 用户ID
3390
+ * @param oldStreamType 之前的订阅状态
3391
+ * @param newStreamType 当前的订阅状态
3392
+ * @param elapseSinceLastState 状态变更时间间隔(毫秒)
3393
+ * @param channel 当前频道
3271
3394
  */
3272
- getCurrentMicDeviceId(): string | undefined;
3273
- enableAudioVolumeIndication(interval: number): void;
3274
- sendSEI(message: ArrayBuffer, repeatCount: number, payloadType: number): Promise<void>;
3275
- sendDataChannelMessage(message: AliRtcDataChannelMsg): void;
3276
- getStats(): Promise<{
3277
- audio: AliRtcLocalAudioStats[];
3278
- video: AliRtcLocalVideoStats[];
3279
- candidate: any;
3280
- }>;
3281
- }
3282
-
3283
- interface AudioMixerPluginOptions {
3284
- audio?: number;
3285
- screen?: number;
3286
- }
3287
-
3288
- interface VideoScalerOptions {
3289
- width: number;
3290
- height: number;
3291
- frameRate: number;
3292
- }
3293
- interface VideoScaler {
3294
- getVideoTrack: () => MediaStreamTrack;
3295
- updateOptions: (options: VideoScalerOptions) => void;
3296
- dispose: () => void;
3297
- }
3298
-
3299
- declare class VideoScalerFactory {
3300
- static isSupport(): boolean;
3395
+ subscribeStreamTypeChanged: (uid: string, oldStreamType: AliRtcVideoStreamType, newStreamType: AliRtcVideoStreamType, elapseSinceLastState: number, channel: string) => void;
3301
3396
  /**
3302
- * 获取实例
3303
- * @param {MediaStreamTrack} videoTrack
3304
- * @param {IProfile} profile
3305
- * @return {VideoScaler}
3397
+ * 屏幕分享流订阅情况变更回调
3398
+ * @param uid 用户ID
3399
+ * @param oldState 之前的订阅状态
3400
+ * @param newState 当前的订阅状态
3401
+ * @param elapseSinceLastState 状态变更时间间隔(毫秒)
3402
+ * @param channel 当前频道
3306
3403
  */
3307
- static getInstance(videoTrack: MediaStreamTrack, options: VideoScalerOptions): VideoScaler;
3308
- }
3309
-
3310
- type AliRtcDualVideoPluginOptions = VideoScalerOptions;
3311
-
3312
- declare enum AliRtcCapabilityProfile {
3313
- Default = 0,
3314
- Human = 1,
3315
- Robot = 2
3316
- }
3317
- type AliRtcChannelParam = {
3318
- userName?: string;
3319
- capabilityProfile?: AliRtcCapabilityProfile;
3320
- };
3321
-
3322
- interface RemoteUserMap {
3323
- [userId: string]: RemoteUser;
3324
- }
3325
- declare class BizControl extends EventEmitter$1<BizControlListener> {
3404
+ screenShareSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
3405
+ /**
3406
+ * DataChannel 订阅情况变更回调
3407
+ * @param uid 用户ID
3408
+ * @param oldState 之前的订阅状态
3409
+ * @param newState 当前的订阅状态
3410
+ * @param elapseSinceLastState 状态变更时间间隔(毫秒)
3411
+ * @param channel 当前频道
3412
+ */
3413
+ dataSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
3326
3414
  /**
3327
- * @ignore
3415
+ * 收到媒体扩展信息回调
3416
+ * @param uid 用户ID,媒体信息发送用户的ID
3417
+ * @param message 媒体扩展信息
3418
+ * @param payloadType payload类型,sendMediaExtensionMsg返回5,sendMediaExtensionMsgEx发送的会返回具体类型
3419
+ * @note 当一端通过 {@link AliRtcEngine.sendMediaExtensionMsg} 发送信息后,其他端通过该回调接收数据
3328
3420
  */
3329
- static logName: string;
3330
- protected self: LocalUser;
3331
- protected userMap: RemoteUserMap;
3332
- private usersViewMap;
3333
- rtsManager: RtsManager;
3334
- protected localStreamManager: LocalStreamManager;
3335
- protected authInfo?: AliRtcAuthInfo;
3336
- protected signalingManager: SignalingManager;
3337
- pluginManager: PluginManager;
3338
- private audioMixerPlugin?;
3339
- private dualVideoPlugin?;
3340
- private blankAudioPlugin?;
3341
- private audioProcessorPlugin?;
3342
- protected slsReporter: SLSReporter;
3343
- private statsMonitorId?;
3344
- private autoSubAudio;
3345
- private autoSubVideo;
3346
- private autoSubScreen;
3347
- private wantSubAudio;
3348
- private wantSubVideo;
3349
- private wantSubScreen;
3350
- private defaultStreamType;
3351
- private audioMuted;
3352
- private playoutVolume;
3353
- private refreshUrlTimer?;
3354
- private audioVolumeIndicationInterval;
3355
- private indicationTimer;
3356
- private parameter;
3357
- private audio3AConfig;
3358
- private dcReadyHelper?;
3359
- constructor(config: BizControlConfig);
3360
- private addSignalingManagerListener;
3361
- isAutoSubAudio(): boolean;
3362
- setAutoSubAudio(value: boolean): void;
3363
- isAutoSubVideo(): boolean;
3364
- setAutoSubVideo(value: boolean): void;
3365
- isAutoSubScreen(): boolean;
3366
- setAutoSubScreen(value: boolean): void;
3367
- isWantSubAudio(): boolean;
3368
- setWantSubAudio(value: boolean): void;
3369
- isWantSubVideo(): boolean;
3370
- setWantSubVideo(value: boolean): void;
3371
- isWantSubScreen(): boolean;
3372
- setWantSubScreen(value: boolean): void;
3373
- setRemoteDefaultVideoStreamType(type: AliRtcVideoStreamType): void;
3374
- setRemoteUserVideoStreamType(userId: string, type: AliRtcVideoStreamType): void;
3375
- setAudioMuted(mute: boolean): void;
3376
- setLocalViewConfig(view: AliRtcLocalView, track: AliRtcVideoTrack): void;
3377
- setRemoteViewConfig(uid: string, view: AliRtcLocalView, track: AliRtcVideoTrack): void;
3378
- get channel(): string | undefined;
3379
- get userId(): string | undefined;
3380
- get remoteUsers(): RemoteUser[];
3421
+ mediaExtensionMsgReceived: (uid: string, message: ArrayBuffer, payloadType: number) => void;
3381
3422
  /**
3382
- * 获取推流对象,只能是自己
3423
+ * @brief 用户鉴权信息即将过期通知,收到后30秒鉴权过期
3424
+ * @note 该回调在鉴权信息30秒前触发,收到该回调后应该及时更新鉴权信息,参考 {@link AliRtcEngine.refreshAuthInfo:}
3383
3425
  */
3384
- get publisher(): LocalUser | undefined;
3385
- get isSubscribing(): boolean;
3426
+ authInfoWillExpire: () => void;
3386
3427
  /**
3387
- * 处理远端用户推流状态变化
3388
- * @param {string} userId
3389
- * @param {string} displayname
3390
- * @param {string} callid
3391
- * @param {string} pullStreamUrl
3392
- * @param {TrackInfo[]} tracks
3393
- * @returns {void}
3428
+ * @brief 用户调用需要鉴权的接口,服务端返回信息过期
3429
+ * @note 该回调触发代表鉴权信息已过期,想要继续在会中,需要重新入会,参考 {@link AliRtcEngine.joinChannel:name:onResultWithUserId:}
3394
3430
  */
3395
- onRemotePublishStateChange(publishInfo: PublishUser, updateSubscribe?: boolean): void;
3396
- /** 定期更新所有人的推拉流地址,便于重连
3397
- * @param pushStreamUrl 已有的推流地址,根据地址中的过期时间来设置定时器
3398
- * @private
3431
+ authInfoExpired: () => {};
3432
+ /**
3433
+ * 远程用户的音频自动播放失败
3434
+ * @param uid
3435
+ * @note 应该在收到该回调时弹出弹窗引导用户点击页面进行播放,用户点击页面后 SDK 会自动尝试播放
3399
3436
  */
3400
- private setTimeoutToUpdateAllStreamUrls;
3437
+ remoteAudioAutoPlayFail: (uid: string) => void;
3401
3438
  /**
3402
- * 登陆成功后初始化用户管理,创建自己
3403
- * @param {AliRtcAuthInfo} authInfo
3404
- * @param {JoinResult} data
3405
- * @returns {Promise<void>}
3439
+ * 远程用户的视频自动播放失败
3440
+ * @param uid
3441
+ * @note 应该在收到该回调时弹出弹窗引导用户点击页面进行播放,用户点击页面后 SDK 会自动尝试播放
3406
3442
  */
3407
- init(authInfo: AliRtcAuthInfo, data: JoinResult, channelParam: AliRtcChannelParam): void;
3408
- leave(): Promise<void>;
3443
+ remoteVideoAutoPlayFail: (uid: string, videoTrack: AliRtcVideoTrack) => void;
3409
3444
  /**
3410
- * 离会后清除所有数据
3411
- * @returns {Promise<void>}
3445
+ * 远程用户的音频播放出错
3446
+ * @param uid 用户ID
3447
+ * @param reason 出错原因,可选
3412
3448
  */
3413
- clear(): Promise<void>;
3414
- private startStatsMonitor;
3415
- private stopStatsMonitor;
3449
+ remoteAudioPlayError: (uid: string, reason: string | undefined) => void;
3416
3450
  /**
3417
- * 添加远端用户
3418
- * @param {JoinInfo} userJoinInfo
3419
- * @param {SubscribeReason} reason
3420
- * @returns {void}
3451
+ * 远程用户的视频播放出错
3452
+ * @param uid 用户ID
3453
+ * @param reason 出错原因,可选
3421
3454
  */
3422
- addUser(userJoinInfo: JoinInfo, reason: SubscribeReason): RemoteUser;
3455
+ remoteVideoPlayError: (uid: string, reason: string | undefined) => void;
3423
3456
  /**
3424
- * 执行添加远端用户
3425
- * @param {string} userId
3426
- * @param {string} displayName
3427
- * @returns {RemoteUser}
3457
+ * 远程用户订阅数据通道
3458
+ * @param uid 用户ID
3428
3459
  */
3429
- private executeAddUser;
3460
+ remoteUserSubscribedDataChannel: (uid: string) => void;
3430
3461
  /**
3431
- * 远端用户设备状态变化
3432
- * @param {DeviceStatusChangeType} event
3433
- * @param {string} userId
3462
+ * rtc 传输数据统计
3463
+ * @param stats 统计信息
3434
3464
  */
3435
- private onRemoteDeviceStatusChange;
3465
+ rtcStats: (stats: any) => void;
3436
3466
  /**
3437
- * 远端流数据采集上报
3438
- * @param {any} stat
3467
+ * 发布视频流的数据统计
3468
+ * @param aliRtcStats 统计信息
3439
3469
  */
3440
- private onRemoteStatReport;
3470
+ rtcLocalVideoStats: (stats: AliRtcLocalVideoStats[]) => void;
3441
3471
  /**
3442
- * rts 单 PC 订阅超限
3472
+ * 发布音频流的数据统计
3473
+ * @param aliRtcStats 统计信息
3443
3474
  */
3444
- private onSubscribeExceeds;
3475
+ rtcLocalAudioStats: (stats: AliRtcLocalAudioStats[]) => void;
3445
3476
  /**
3446
- * 移除远端用户
3447
- * @param {LeaveInfo} user
3448
- * @returns {Promise<void>}
3477
+ * 订阅视频流的数据统计
3478
+ * @param aliRtcStats 统计信息
3449
3479
  */
3450
- removeLeftUser(user: LeaveInfo): Promise<void>;
3480
+ rtcRemoteVideoStats: (stats: AliRtcRemoteVideoStats[]) => void;
3451
3481
  /**
3452
- * 更新远端用户数据
3453
- * @param {JoinInfo[]} users
3454
- * @returns {{joinList: JoinInfo[], leaveList: LeaveInfo[], presentList: JoinInfo[]}}
3482
+ * 订阅远端音频流的数据统计
3483
+ * @param aliRtcStats 统计信息
3455
3484
  */
3456
- diffUsers(users: JoinInfo[]): {
3457
- joinList: JoinInfo[];
3458
- leaveList: LeaveInfo[];
3459
- presentList: JoinInfo[];
3460
- };
3485
+ rtcRemoteAudioStats: (stats: AliRtcRemoteAudioStats[]) => void;
3461
3486
  /**
3462
- * 根据 userId 获取 RemoteUser
3463
- * @param {string} userId
3464
- * @returns {RemoteUser | undefined}
3487
+ * @brief 错误通知
3488
+ * @deprecated 请使用 occurError
3489
+ * @details 如果engine出现error,通过这个回调通知app
3490
+ * @param error 错误类型,参考 {@link AliRtcError}
3491
+ * @param uid 用户 Id,不一定存在
3465
3492
  */
3466
- getRemoteUser(userId: string): RemoteUser | undefined;
3493
+ onOccurError: (error: AliRtcError, uid?: string) => void;
3467
3494
  /**
3468
- * 更新远端用户设备信息
3469
- * @param {RemoteUserStatus} user
3470
- * @returns {boolean} true: 用户状态改变 false: 用户状态没有改变
3495
+ * @brief 错误通知
3496
+ * @details 如果engine出现error,通过这个回调通知app
3497
+ * @param error 错误类型,参考 {@link AliRtcError}
3498
+ * @param uid 用户 Id,不一定存在
3471
3499
  */
3472
- updateRemoteUserDeviceStatus(user: RemoteUserStatus): void;
3473
- updateAudioWant(uid: string, sub: boolean): void;
3474
- updateVideoWant(uid: string, sub: boolean): void;
3475
- updateScreenWant(uid: string, sub: boolean): void;
3476
- private stopIndication;
3477
- private startIndication;
3478
- setEnableDualVideoStream(enabled: boolean, options?: AliRtcDualVideoPluginOptions): void;
3479
- setAudioVolume(options: AudioMixerPluginOptions): void;
3480
- enableAudioVolumeIndication(interval: number): void;
3481
- setPlayoutVolume(volume: number): void;
3482
- refreshAuthInfo(authInfo: AliRtcRefreshAuthInfo): void;
3483
- setEnableMediaExtensionMsg(enable: boolean): void;
3484
- setAudioRedEnabled(enable: boolean): void;
3485
- setParameter(parameter: string): void;
3486
- private setupAudioProcessingPluginIfNeeded;
3487
- getParameter(): string;
3488
- sendDataChannelMessage(message: AliRtcDataChannelMsg): void;
3500
+ occurError: (error: AliRtcError, uid?: string) => void;
3501
+ /**
3502
+ * @brief 收到数据通道消息
3503
+ * @param uid 用户ID
3504
+ * @param message 消息
3505
+ */
3506
+ dataChannelMsg: (uid: string, message: AliRtcDataChannelMsg) => void;
3507
+ /**
3508
+ * @brief AI agent处理结果
3509
+ * @param code 返回code码
3510
+ * @param action 结果对应的action
3511
+ * @param result 结果
3512
+ */
3513
+ AIAgentResult: (code: number, action: string, result: string) => void;
3489
3514
  }
3490
3515
 
3491
- declare class AliRtcLiveTranscoding {
3492
- authInfo?: AliRtcAuthInfo;
3493
- private slsReporter;
3494
- constructor(slsReporter: SLSReporter);
3495
- private doRequest;
3496
- setAuthInfo(authInfo: AliRtcAuthInfo): void;
3497
- clear(): void;
3498
- startPublishLiveStream(streamUrl: string, transcodingParam: AliRtcLiveTranscodingParam): Promise<any>;
3499
- startPublishLiveStreamWithTaskId(taskId: string, transcodingParam: AliRtcLiveTranscodingParam): Promise<any>;
3500
- updatePublishLiveStream(streamUrl: string, transcodingParam: AliRtcLiveTranscodingParam): Promise<any>;
3501
- updatePublishLiveStreamWithTaskId(taskId: string, transcodingParam: AliRtcLiveTranscodingParam): Promise<any>;
3502
- stopPublishLiveStream(streamUrl: string): Promise<any>;
3503
- stopPublishLiveStreamWithTaskId(taskId: string): Promise<any>;
3504
- refreshAuthInfo(authInfo: AliRtcRefreshAuthInfo): void;
3516
+ declare enum AliRtcRawDataStreamType {
3517
+ /** 相机流 */
3518
+ AliRtcSdkStreamTypeCapture = 0,
3519
+ /** 屏幕共享流 */
3520
+ AliRtcSdkStreamTypeScreen = 1
3505
3521
  }
3506
3522
 
3507
3523
  interface AliRtcScreenShareConfiguration {
@@ -3511,30 +3527,15 @@ interface AliRtcScreenShareConfiguration {
3511
3527
  bitrate?: number;
3512
3528
  }
3513
3529
 
3514
- interface AliRtcWebTrackConfig {
3515
- biz: string;
3516
- extraParams?: string;
3517
- }
3518
- interface AliRtcEngineConfig {
3519
- env?: AliRtcEnv;
3520
- webTrack?: boolean | AliRtcWebTrackConfig;
3521
- maxSignalingConnectRetryCount?: number;
3522
- }
3523
- interface AliRtcAIAgentParam {
3524
- /*! ai agent id */
3525
- agentId: string;
3526
- /*! ai agent的区域 */
3527
- region: string;
3528
- /*! 启动ai agent的action */
3529
- action: string;
3530
- /*! 启动ai agent的参数 */
3531
- params: string;
3530
+ interface AliRtcScreenShareStartConfig {
3531
+ audio?: boolean;
3532
+ videoTrack?: MediaStreamVideoTrack;
3533
+ audioTrack?: MediaStreamAudioTrack;
3532
3534
  }
3533
3535
 
3534
- interface AliRtcBeautyConfig {
3535
- whiteningLevel: number;
3536
- /*! 磨皮等级[0-1.0] */
3537
- smoothnessLevel: number;
3536
+ interface AliRtcVideoTrackConfig {
3537
+ userId?: string;
3538
+ streamType: AliRtcRawDataStreamType;
3538
3539
  }
3539
3540
 
3540
3541
  interface ImageHolderPluginOptions {