aliyun-rtc-sdk 6.11.5-beta.6 → 6.11.6-beta.1

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.
@@ -0,0 +1,208 @@
1
+ import EventEmitter from 'eventemitter3';
2
+ import { LocalStream, IProfile } from 'aliyun-rts-sdk';
3
+ import { IVideoConstraints, IAudioConstraints } from 'media-device';
4
+ import { QueenEngineWorker } from 'aliyun-queen-engine';
5
+ import { BeautyParams } from 'aliyun-queen-engine/dist/QueenTypes';
6
+
7
+ declare enum VideoStreamSource {
8
+ Camera = 0,
9
+ Screen = 1,
10
+ Image = 2
11
+ }
12
+ declare enum AudioStreamSource {
13
+ Microphone = 0,
14
+ Screen = 1,
15
+ Mixed = 2
16
+ }
17
+ /**
18
+ * ------------------ 模式 ----- 采样率 ----- 声道 ----- 码率(kbps) -----
19
+ *
20
+ * standard: 标准音质 48000 单声道 64
21
+ *
22
+ * high: 高音质 48000 单声道 128
23
+ *
24
+ * standard-stereo: 立体声音质 48000 双声道 80
25
+ *
26
+ * high-stereo: 立体声高音质 48000 双声道 192
27
+ */
28
+ type AudioProfileKey = 'standard' | 'high' | 'standard-stereo' | 'high-stereo';
29
+
30
+ declare enum AliRtcRawDataStreamType {
31
+ /** 相机流 */
32
+ AliRtcSdkStreamTypeCapture = 0,
33
+ /** 屏幕共享流 */
34
+ AliRtcSdkStreamTypeScreen = 1
35
+ }
36
+
37
+ interface AliRtcLocalStreamListener {
38
+ videotrackended: () => void;
39
+ audiotrackended: () => void;
40
+ }
41
+ declare class AliRtcLocalStreamInfo extends EventEmitter<AliRtcLocalStreamListener> {
42
+ type: AliRtcRawDataStreamType;
43
+ originVideoTrack?: MediaStreamTrack;
44
+ videoSource?: VideoStreamSource;
45
+ private _videoMuted;
46
+ originAudioTrack?: MediaStreamTrack;
47
+ audioSource?: AudioStreamSource;
48
+ private _audioMuted;
49
+ private _targetVideoTrack?;
50
+ private _targetDualVideoTrack?;
51
+ private _targetAudioTrack?;
52
+ private _publishVideoStream?;
53
+ private _publishDualVideoStream?;
54
+ private _publishAudioStream?;
55
+ private _previewStream?;
56
+ plugins: AliRtcPlugin[];
57
+ private _profileManager?;
58
+ cameraVideoConstraints?: IVideoConstraints;
59
+ micAudioConstraints?: IAudioConstraints;
60
+ private get profileManager();
61
+ get audioProfile(): AudioProfileKey | undefined;
62
+ constructor(type: AliRtcRawDataStreamType);
63
+ private onVideoTrackEnded;
64
+ private onAudioTrackEnded;
65
+ updateSource(newStream: LocalStream, newVideoSource?: VideoStreamSource, newAudioSource?: AudioStreamSource): Promise<void>;
66
+ get currentProfile(): string | undefined;
67
+ get currentVideoTrack(): MediaStreamTrack | undefined;
68
+ get currentDualVideoTrack(): MediaStreamTrack | undefined;
69
+ get publishVideoStream(): LocalStream | undefined;
70
+ get publishDualVideoStream(): LocalStream | undefined;
71
+ get currentAudioTrack(): MediaStreamTrack | undefined;
72
+ get publishAudioStream(): LocalStream | undefined;
73
+ get previewStream(): LocalStream | undefined;
74
+ /**
75
+ * 更新 VideoTrack
76
+ * @param videoTrack
77
+ */
78
+ updateVideoTrack(videoTrack?: MediaStreamTrack, force?: boolean): Promise<void>;
79
+ /**
80
+ * 更新 DualVideoTrack
81
+ * @param videoTrack
82
+ * @param force
83
+ */
84
+ updateDualVideoTrack(videoTrack?: MediaStreamTrack, force?: boolean): Promise<void>;
85
+ /**
86
+ * 更新 AudioTrack
87
+ * @param audioTrack
88
+ */
89
+ updateAudioTrack(audioTrack?: MediaStreamTrack, force?: boolean): Promise<void>;
90
+ /**
91
+ * 设置音频流静音
92
+ * @param muted
93
+ */
94
+ setAudioMuted(muted: boolean): void;
95
+ get isAudioMuted(): boolean;
96
+ /**
97
+ * 设置视频流静音
98
+ * @param muted
99
+ */
100
+ setVideoMuted(muted: boolean): void;
101
+ get isVideoMuted(): boolean;
102
+ process(localStreamInfos: AliRtcLocalStreamInfo[]): Promise<void>;
103
+ /**
104
+ * 停止视频流
105
+ */
106
+ stopVideo(): void;
107
+ /**
108
+ * 停止音频流
109
+ */
110
+ stopAudio(): void;
111
+ /**
112
+ * 停止视频流和音频流
113
+ */
114
+ stop(): void;
115
+ /**
116
+ * 应该在执行完 plugin 后调用
117
+ * @param profileName
118
+ * @param profileValue
119
+ */
120
+ updateVideoProfile(profileName?: string, profileValue?: IProfile): Promise<void>;
121
+ get videoProfile(): string | undefined;
122
+ setVideoContentHint(hint?: string): void;
123
+ /**
124
+ * 应该在执行完 plugin 后调用
125
+ * @param profileName
126
+ */
127
+ updateAudioProfile(profileKey: AudioProfileKey): Promise<void>;
128
+ /**
129
+ * 复制视频 profile 到指定 LocalStream
130
+ * @param publishStream
131
+ */
132
+ cloneVideoProfile(publishStream: LocalStream): Promise<void>;
133
+ addPlugin(plugin: AliRtcPlugin): void;
134
+ removePlugin(plugin: AliRtcPlugin): boolean;
135
+ }
136
+
137
+ declare enum AliRtcPluginType {
138
+ PRE_PROCESSOR = 0,
139
+ POST_PROCESSOR = 1
140
+ }
141
+ declare enum AliRtcPluginTrackType {
142
+ AUDIO = 0,
143
+ VIDEO = 1,
144
+ BOTH = 2
145
+ }
146
+ interface AliRtcPluginListener {
147
+ enabled: () => void;
148
+ disabled: () => void;
149
+ updated: () => void;
150
+ ready: () => void;
151
+ overload: (info: any) => void;
152
+ error: (error: any) => void;
153
+ unsupported: () => void;
154
+ }
155
+ declare abstract class AliRtcPlugin extends EventEmitter<AliRtcPluginListener> {
156
+ name: string;
157
+ options: any;
158
+ type: AliRtcPluginType;
159
+ streamType: AliRtcRawDataStreamType;
160
+ trackType: AliRtcPluginTrackType;
161
+ zIndex: number;
162
+ private _isEnable;
163
+ lastInputAudioTrack?: MediaStreamTrack;
164
+ lastOutputAudioTrack?: MediaStreamTrack;
165
+ lastInputVideoTrack?: MediaStreamTrack;
166
+ lastOutputVideoTrack?: MediaStreamTrack;
167
+ constructor(name: string, streamType?: AliRtcRawDataStreamType, trackType?: AliRtcPluginTrackType);
168
+ get initOptions(): {};
169
+ getOptions(): any;
170
+ abstract setOptions(options: any): void;
171
+ abstract isSupported(version: string): boolean;
172
+ init(): Promise<void>;
173
+ enable(): void;
174
+ disable(): void;
175
+ get isEnable(): boolean;
176
+ protected audioUpdated(streamInfo: AliRtcLocalStreamInfo): boolean;
177
+ protected videoUpdated(streamInfo: AliRtcLocalStreamInfo): boolean;
178
+ execute(streamInfo: AliRtcLocalStreamInfo, streamInfos: AliRtcLocalStreamInfo[]): Promise<void>;
179
+ abstract shouldUpdate(streamInfo: AliRtcLocalStreamInfo, streamInfos: AliRtcLocalStreamInfo[]): boolean;
180
+ abstract process(streamInfo: AliRtcLocalStreamInfo, streamInfos: AliRtcLocalStreamInfo[]): Promise<void>;
181
+ clear(_streamInfo?: AliRtcLocalStreamInfo): void;
182
+ }
183
+
184
+ type AliRtcBeautyPluginOptions = {
185
+ licenseKey?: string;
186
+ } & BeautyParams;
187
+ declare class AliRtcBeautyPlugin extends AliRtcPlugin {
188
+ engineReady: boolean;
189
+ _queenEngine?: QueenEngineWorker;
190
+ canvas?: HTMLCanvasElement;
191
+ dirty: boolean;
192
+ lastFrameTimestamp: number;
193
+ continuousStuckCount: number;
194
+ get initOptions(): {
195
+ licenseKey: string;
196
+ };
197
+ setOptions(options: AliRtcBeautyPluginOptions): void;
198
+ constructor();
199
+ init(): Promise<void>;
200
+ isSupported(): boolean;
201
+ private initQueen;
202
+ shouldUpdate(streamInfo: AliRtcLocalStreamInfo): boolean;
203
+ process(streamInfo: AliRtcLocalStreamInfo): Promise<void>;
204
+ get queenEngine(): QueenEngineWorker | undefined;
205
+ clear(streamInfo?: AliRtcLocalStreamInfo): void;
206
+ }
207
+
208
+ export { AliRtcBeautyPlugin as default };
@@ -0,0 +1 @@
1
+ (function(r,u){typeof exports=="object"&&typeof module<"u"?module.exports=u(require("eventemitter3"),require("aliyun-queen-engine")):typeof define=="function"&&define.amd?define(["eventemitter3","aliyun-queen-engine"],u):(r=typeof globalThis<"u"?globalThis:r||self,r.AliRtcBeautyPlugin=u(r.n,r.aliyunQueenEngine))})(this,function(r,u){"use strict";var c;(function(t){t[t.AliRtcSdkStreamTypeCapture=0]="AliRtcSdkStreamTypeCapture",t[t.AliRtcSdkStreamTypeScreen=1]="AliRtcSdkStreamTypeScreen"})(c||(c={}));var h=c,p=Object.defineProperty,l=(t,e,i)=>e in t?p(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,n=(t,e,i)=>(l(t,typeof e!="symbol"?e+"":e,i),i),d;(function(t){t[t.PRE_PROCESSOR=0]="PRE_PROCESSOR",t[t.POST_PROCESSOR=1]="POST_PROCESSOR"})(d||(d={}));var a;(function(t){t[t.AUDIO=0]="AUDIO",t[t.VIDEO=1]="VIDEO",t[t.BOTH=2]="BOTH"})(a||(a={}));class T extends r{constructor(e,i=h.AliRtcSdkStreamTypeCapture,s=a.VIDEO){super(),n(this,"name"),n(this,"options"),n(this,"type",d.PRE_PROCESSOR),n(this,"streamType"),n(this,"trackType"),n(this,"zIndex",1),n(this,"_isEnable",!0),n(this,"lastInputAudioTrack"),n(this,"lastOutputAudioTrack"),n(this,"lastInputVideoTrack"),n(this,"lastOutputVideoTrack"),this.name=e,this.streamType=i,this.trackType=s,this.options=this.initOptions}get initOptions(){return{}}getOptions(){return this.options}async init(){}enable(){this._isEnable||(this._isEnable=!0,this.init(),this.emit("enabled"))}disable(){this._isEnable&&(this._isEnable=!1,this.clear(),this.emit("disabled"))}get isEnable(){return this._isEnable}audioUpdated(e){return this.lastInputAudioTrack?.id!==e.currentAudioTrack?.id}videoUpdated(e){return this.lastInputVideoTrack?.id!==e.currentVideoTrack?.id}async execute(e,i){const s=this.shouldUpdate(e,i);this.lastInputAudioTrack=e.currentAudioTrack,this.lastInputVideoTrack=e.currentVideoTrack,s?await this.process(e,i):(this.lastOutputAudioTrack&&(this.trackType===a.BOTH||this.trackType===a.AUDIO)&&this.lastOutputAudioTrack&&e.updateAudioTrack(this.lastOutputAudioTrack),this.lastOutputVideoTrack&&(this.trackType===a.BOTH||this.trackType===a.VIDEO)&&this.lastOutputVideoTrack&&e.updateVideoTrack(this.lastOutputVideoTrack)),this.lastOutputAudioTrack=e.currentAudioTrack,this.lastOutputVideoTrack=e.currentVideoTrack}clear(e){this.lastInputAudioTrack=void 0,this.lastInputVideoTrack=void 0,this.lastOutputAudioTrack=void 0,this.lastOutputVideoTrack=void 0}}var k=Object.defineProperty,y=(t,e,i)=>e in t?k(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,o=(t,e,i)=>(y(t,typeof e!="symbol"?e+"":e,i),i);class g extends T{constructor(){super("AliRtcBeauty"),o(this,"engineReady",!1),o(this,"_queenEngine"),o(this,"canvas"),o(this,"dirty",!1),o(this,"lastFrameTimestamp",0),o(this,"continuousStuckCount",0),this.zIndex=0}get initOptions(){return{licenseKey:""}}setOptions(e){const i=!!e.segmentBackgroundProcess?.enable,s=!!e.setSegmentBackgroundImage?.backgroundImgUrl;this.options={...this.options,...e},s?delete this.options.segmentBackgroundProcess:i&&delete this.options.setSegmentBackgroundImage,this.engineReady&&this.queenEngine?.setEngineParams(this.options)}async init(){await this.initQueen()}isSupported(){const e=!(typeof TransformStream>"u"||typeof MediaStreamTrackProcessor>"u"||typeof MediaStreamTrackGenerator>"u"),i=!(typeof OffscreenCanvas>"u"||typeof WebGL2RenderingContext>"u"),s=WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]));return e&&i&&s}async initQueen(){this.canvas=document.createElement("canvas");const{licenseKey:e=""}=this.options,i=new u.QueenEngineWorker(u.kQueenVersion.Pro);return this._queenEngine=i,await new Promise(s=>{i.init(e,()=>{this.engineReady=!0,this.emit("ready"),i.setEngineParams(this.options),s(i)},function(){},this.canvas)}),i}shouldUpdate(e){return this.videoUpdated(e)||this.dirty}async process(e){if(!e.originVideoTrack){this.clear(e),e.updateVideoTrack();return}if(!this.queenEngine||!this.engineReady)return;this.dirty=!1;const i=this.queenEngine.renderMediaStreamTrack(e.originVideoTrack);i&&e.updateVideoTrack(i)}get queenEngine(){return this._queenEngine}clear(e){this.canvas=void 0,this.engineReady=!1,this._queenEngine=void 0,this.queenEngine?.engineDestory(),super.clear(e)}}return g});
@@ -124,6 +124,10 @@ export declare class AliRtcEngine extends default_2<AliRtcEngineEventListener> {
124
124
  * @ignore
125
125
  */
126
126
  static logName: string;
127
+ /**
128
+ * @ignore
129
+ */
130
+ static logError: boolean;
127
131
  /**
128
132
  * 检查浏览器是否支持 WebRTC
129
133
  * @param {string} direction
@@ -326,6 +330,7 @@ export declare class AliRtcEngine extends default_2<AliRtcEngineEventListener> {
326
330
  * @note 只可以在 {@link joinChannel} 之前设置
327
331
  */
328
332
  setAudioOnlyMode(audioOnly: boolean): void;
333
+ setAudioRedEnabled(audioRedEnabled: boolean): void;
329
334
  /**
330
335
  * 设定鉴权信息过期事件定时器
331
336
  * @param expireTimestamp 鉴权信息过期时间
@@ -338,7 +343,29 @@ export declare class AliRtcEngine extends default_2<AliRtcEngineEventListener> {
338
343
  private clearCheckAuthInfoTimer;
339
344
  private startDefaultDevicesCapture;
340
345
  /**
341
- * @brief 加入频道
346
+ * @brief 加入频道(单参数)
347
+ * @details 该方法让用户加入频道,一个频道内可以加入多个用户进行互相通话。
348
+ * @details 一般在调用该方法前会根据场景先选择频道模式,通过调用 {@link setChannelProfile} 实现,默认频道模式为通信模式 {@link AliRtcSdkChannelProfile.AliRtcSdkCommunication}
349
+ * ``` javascript
350
+ * // 设置频道为互动模式
351
+ * engine.setChannelProfile(AliRtcSdkChannelProfile.AliRtcInteractivelive);
352
+ * // 设置角色为主播角色
353
+ * engine.setClientRole(AliRtcSdkClientRole.AliRtcSdkInteractive);
354
+ * ```
355
+ * @param {string} token 单参数认证信息,从App Server获取。
356
+ * @param {string} channelId 频道ID
357
+ * @param {string} userId 用户ID
358
+ * @param {string} userName 任意用于显示的用户名称。不是User ID
359
+ * @note
360
+ * - 异步接口,方法执行成功则为成功入会
361
+ * - 正常情况一个Appid对应一个App,只有同一个AppId的应用可进行互相童话,不同AppId和channelID不同都不能互通
362
+ * - 当入会成功后,会触发远端用户收到 {@link AliRtcEngineEventListener.remoteUserOnLineNotify} 回调
363
+ * - 如果已在会中想重新入会,需要先调用 {@link leaveChannel} 离会,且确保方法执行成功
364
+ * - 用户加入频道后,默认订阅频道内所有其他用户的音视频流,默认推送音视频流到远端,因此将会产生计费,如果想要取消默认订阅可以 {@link joinChannel} 前调用 {@link setDefaultSubscribeAllRemoteAudioStreams} 和 {@link setDefaultSubscribeAllRemoteVideoStreams}
365
+ */
366
+ joinChannel(token: string, channelId: string, userId: string, userName: string): Promise<void>;
367
+ /**
368
+ * @brief 加入频道(多参数)
342
369
  * @details 该方法让用户加入频道,一个频道内可以加入多个用户进行互相通话。
343
370
  * @details 一般在调用该方法前会根据场景先选择频道模式,通过调用 {@link setChannelProfile} 实现,默认频道模式为通信模式 {@link AliRtcSdkChannelProfile.AliRtcSdkCommunication}
344
371
  * ``` javascript
@@ -635,6 +662,19 @@ export declare class AliRtcEngine extends default_2<AliRtcEngineEventListener> {
635
662
  * - >100:放大音量
636
663
  */
637
664
  setRecordingVolume(volume: number): void;
665
+ /**
666
+ * @brief 设置播放音量
667
+ * @param volume 播放音量,取值范围[0,100], 0:静音;100:原始音量
668
+ * @note 注意此方法与 {@link setRemoteAudioVolume} 相互影响,以后调用的一个为准
669
+ */
670
+ setPlayoutVolume(volume: number): void;
671
+ /**
672
+ * @brief 设置播放音量
673
+ * @param userId 用户ID
674
+ * @param volume 播放音量,取值范围[0,100], 0:静音;100:原始音量
675
+ * @note 注意此方法与 {@link setPlayoutVolume} 相互影响,以后调用的一个为准
676
+ */
677
+ setRemoteAudioVolume(userId: string, volume: number): void;
638
678
  /**
639
679
  * 设置麦克风 profile
640
680
  *
@@ -2781,6 +2821,7 @@ declare class RemoteUser extends User {
2781
2821
  private screenSubState;
2782
2822
  streamInfo: RemoteStreamInfo;
2783
2823
  streamUrl: string;
2824
+ private playoutVolume;
2784
2825
  constructor(config: RemoteUserConfig);
2785
2826
  isWantSubAudio(): boolean;
2786
2827
  setWantSubAudio(value: boolean): void;
@@ -2790,6 +2831,7 @@ declare class RemoteUser extends User {
2790
2831
  setWantSubScreen(value: boolean): void;
2791
2832
  setRemoteDefaultVideoStreamType(type: AliRtcVideoStreamType): void;
2792
2833
  setAudioMuted(value: boolean): void;
2834
+ setPlayoutVolume(value: number): void;
2793
2835
  getAudioMuted(): boolean;
2794
2836
  get hasAudioTrack(): boolean;
2795
2837
  get hasVideoTrack(): boolean;
@@ -2935,6 +2977,7 @@ declare interface RemoteUserConfig {
2935
2977
  signalingManager: SignalingManager;
2936
2978
  localUserId: string;
2937
2979
  audioVolumeIndicationInterval: number;
2980
+ playoutVolume: number;
2938
2981
  }
2939
2982
 
2940
2983
  declare interface RemoteUserMap {
@@ -3158,6 +3201,7 @@ declare class RtsManager extends default_2<RtsManagerEventListener> {
3158
3201
  static logName: string;
3159
3202
  private rts;
3160
3203
  private encodedInsertableStreams;
3204
+ private audioRedEnabled;
3161
3205
  private localStreamManager;
3162
3206
  private connecting;
3163
3207
  private connected;
@@ -3168,6 +3212,7 @@ declare class RtsManager extends default_2<RtsManagerEventListener> {
3168
3212
  private _publishingTracks;
3169
3213
  constructor(localStreamManager: LocalStreamManager);
3170
3214
  setEncodedInsertableStreams(enable: boolean): void;
3215
+ setAudioRedEnabled(enable: boolean): void;
3171
3216
  destroy(): void;
3172
3217
  private startConnect;
3173
3218
  private setConnected;
@@ -3470,6 +3515,7 @@ declare class UserManager extends default_2<UserManagerListener> {
3470
3515
  private wantSubScreen;
3471
3516
  private defaultStreamType;
3472
3517
  private audioMuted;
3518
+ private playoutVolume;
3473
3519
  private audioVolumeIndicationInterval;
3474
3520
  private indicationTimer;
3475
3521
  constructor(config: UserManagerConfig);
@@ -3593,8 +3639,10 @@ declare class UserManager extends default_2<UserManagerListener> {
3593
3639
  private stopIndication;
3594
3640
  private startIndication;
3595
3641
  enableAudioVolumeIndication(interval: number): void;
3642
+ setPlayoutVolume(volume: number): void;
3596
3643
  refreshAuthInfo(authInfo: AliRtcRefreshAuthInfo): void;
3597
3644
  setEnableMediaExtensionMsg(enable: boolean): void;
3645
+ setAudioRedEnabled(enable: boolean): void;
3598
3646
  }
3599
3647
 
3600
3648
  declare interface UserManagerConfig {
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "aliyun-rtc-sdk",
3
- "version": "6.11.5-beta.6",
3
+ "version": "6.11.6-beta.1",
4
+ "type": "module",
4
5
  "description": "rtc web sdk of aliyun",
5
6
  "main": "dist/aliyun-rtc-sdk.js",
6
7
  "types": "dist/types/index.d.ts",
7
8
  "dependencies": {
8
9
  "aliyun-queen-engine": "^6.3.3",
9
- "aliyun-rts-sdk": "2.8.1-beta.1",
10
+ "aliyun-rts-sdk": "2.8.1-beta.5",
10
11
  "browser-log-reporter": "^1.1.5",
11
12
  "eventemitter3": "^5.0.1",
12
13
  "useragent-util": "^1.1.3"
13
14
  },
15
+ "homepage": "https://help.aliyun.com/zh/live/user-guide/quick-use",
14
16
  "files": [
15
17
  "dist/aliyun-rtc-sdk.js",
16
18
  "dist/types",