aliyun-rtc-sdk 6.11.5-beta.6 → 6.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -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});
|
package/dist/types/index.d.ts
CHANGED
|
@@ -326,6 +326,7 @@ export declare class AliRtcEngine extends default_2<AliRtcEngineEventListener> {
|
|
|
326
326
|
* @note 只可以在 {@link joinChannel} 之前设置
|
|
327
327
|
*/
|
|
328
328
|
setAudioOnlyMode(audioOnly: boolean): void;
|
|
329
|
+
setAudioRedEnabled(audioRedEnabled: boolean): void;
|
|
329
330
|
/**
|
|
330
331
|
* 设定鉴权信息过期事件定时器
|
|
331
332
|
* @param expireTimestamp 鉴权信息过期时间
|
|
@@ -3158,6 +3159,7 @@ declare class RtsManager extends default_2<RtsManagerEventListener> {
|
|
|
3158
3159
|
static logName: string;
|
|
3159
3160
|
private rts;
|
|
3160
3161
|
private encodedInsertableStreams;
|
|
3162
|
+
private audioRedEnabled;
|
|
3161
3163
|
private localStreamManager;
|
|
3162
3164
|
private connecting;
|
|
3163
3165
|
private connected;
|
|
@@ -3168,6 +3170,7 @@ declare class RtsManager extends default_2<RtsManagerEventListener> {
|
|
|
3168
3170
|
private _publishingTracks;
|
|
3169
3171
|
constructor(localStreamManager: LocalStreamManager);
|
|
3170
3172
|
setEncodedInsertableStreams(enable: boolean): void;
|
|
3173
|
+
setAudioRedEnabled(enable: boolean): void;
|
|
3171
3174
|
destroy(): void;
|
|
3172
3175
|
private startConnect;
|
|
3173
3176
|
private setConnected;
|
|
@@ -3595,6 +3598,7 @@ declare class UserManager extends default_2<UserManagerListener> {
|
|
|
3595
3598
|
enableAudioVolumeIndication(interval: number): void;
|
|
3596
3599
|
refreshAuthInfo(authInfo: AliRtcRefreshAuthInfo): void;
|
|
3597
3600
|
setEnableMediaExtensionMsg(enable: boolean): void;
|
|
3601
|
+
setAudioRedEnabled(enable: boolean): void;
|
|
3598
3602
|
}
|
|
3599
3603
|
|
|
3600
3604
|
declare interface UserManagerConfig {
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aliyun-rtc-sdk",
|
|
3
|
-
"version": "6.11.5
|
|
3
|
+
"version": "6.11.5",
|
|
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.
|
|
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"
|