aliyun-rtc-sdk 7.1.4 → 7.1.6

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