@rongcloud/plugin-call 5.0.1-alpha.11 → 5.0.1-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +45 -11
- package/dist/index.esm.js +161 -97
- package/dist/index.js +166 -114
- package/dist/index.umd.js +169 -117
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* RCCall - v5.0.1-alpha.
|
|
3
|
-
* CommitId -
|
|
4
|
-
*
|
|
2
|
+
* RCCall - v5.0.1-alpha.15
|
|
3
|
+
* CommitId - 822cbe0e445807b91c775e9bc034fba931189ece
|
|
4
|
+
* Mon Oct 18 2021 08:45:49 GMT+0800 (China Standard Time)
|
|
5
5
|
* ©2020 RongCloud, Inc. All rights reserved.
|
|
6
6
|
*/
|
|
7
7
|
import { ConversationType, RTCJoinType, LogLevel, PluginContext, IRuntime, IRTCJoinedInfo, IPluginGenerator } from '@rongcloud/engine';
|
|
8
8
|
import { RCCallStateMachine, RCCallErrorCode, RCCallMediaType, IUserData, RCCallUserState, RCCallSessionState, IEndSummary, IOfflineRecord, RCCallLanguage, RCCallEndReason, IInvitedUsers } from '@rongcloud/plugin-call-engine';
|
|
9
9
|
export { IEndSummary, IInvitedUsers, IOfflineRecord, ISenderInfo, RCCallEndReason, RCCallErrorCode, RCCallLanguage, RCCallMediaType, RCCallSessionState, RCCallUserState } from '@rongcloud/plugin-call-engine';
|
|
10
|
-
import { RCRTCClient, RCTrack, RCRTCCode, IRCRTCStateReport, RCRTCPingResult, RCLocalTrack, ICameraVideoProfile
|
|
10
|
+
import { RCRTCClient, IMicphoneAudioProfile, RCTrack, RCRTCCode, IRCRTCStateReport, RCRTCPingResult, RCLocalTrack, ICameraVideoProfile } from '@rongcloud/plugin-rtc';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 产生session的场景
|
|
14
|
+
*/
|
|
15
|
+
declare enum ProduceTypes {
|
|
16
|
+
/**
|
|
17
|
+
* 主叫
|
|
18
|
+
*/
|
|
19
|
+
CALLER = 1,
|
|
20
|
+
/**
|
|
21
|
+
* 被叫
|
|
22
|
+
*/
|
|
23
|
+
CALLEE = 2
|
|
24
|
+
}
|
|
11
25
|
|
|
12
26
|
declare class RCCallSession {
|
|
13
27
|
/**
|
|
@@ -27,7 +41,7 @@ declare class RCCallSession {
|
|
|
27
41
|
*/
|
|
28
42
|
private _room;
|
|
29
43
|
/**
|
|
30
|
-
* 用户传进来的 对session的监听
|
|
44
|
+
* 用户传进来的 对session的监听 (要在RCCallClient的_onInvite里判断,要求执行完onSession必须注册session的监听,所以这里是public)
|
|
31
45
|
*/
|
|
32
46
|
_listener: ISessionListener | null;
|
|
33
47
|
/**
|
|
@@ -93,11 +107,11 @@ declare class RCCallSession {
|
|
|
93
107
|
private _getLocalTrackCore;
|
|
94
108
|
private _getLocalTrack;
|
|
95
109
|
/**
|
|
96
|
-
*
|
|
110
|
+
* 通话中更换音频设备
|
|
97
111
|
*/
|
|
98
|
-
|
|
112
|
+
changeAudioDevice(audioConstraints?: IMicphoneAudioProfile): Promise<{
|
|
99
113
|
code: RCCallErrorCode;
|
|
100
|
-
}
|
|
114
|
+
}>;
|
|
101
115
|
/**
|
|
102
116
|
* 群呼叫中继续邀请
|
|
103
117
|
* @param userIds 被邀请用户 ID 列表
|
|
@@ -128,6 +142,10 @@ declare class RCCallSession {
|
|
|
128
142
|
* 获得本地视频
|
|
129
143
|
*/
|
|
130
144
|
private _getLocalVideoTracks;
|
|
145
|
+
/**
|
|
146
|
+
* 获得本地音频
|
|
147
|
+
*/
|
|
148
|
+
private _getLocalAudioTracks;
|
|
131
149
|
/**
|
|
132
150
|
* 把通话的MediaType升级到音视频
|
|
133
151
|
*/
|
|
@@ -156,6 +174,14 @@ declare class RCCallSession {
|
|
|
156
174
|
enableVideoTrack(): Promise<{
|
|
157
175
|
code: RCCallErrorCode;
|
|
158
176
|
}>;
|
|
177
|
+
/**
|
|
178
|
+
* 禁用音频track
|
|
179
|
+
*/
|
|
180
|
+
disableAudioTrack(): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* 启用音频track
|
|
183
|
+
*/
|
|
184
|
+
enableAudioTrack(): Promise<void>;
|
|
159
185
|
/**
|
|
160
186
|
* 销毁本地流
|
|
161
187
|
*/
|
|
@@ -177,7 +203,7 @@ declare class RCCallSession {
|
|
|
177
203
|
*/
|
|
178
204
|
getSessionId(): string;
|
|
179
205
|
/**
|
|
180
|
-
* 获取房间当前会话 Id,当房间内已无成员时房间会回收,重新加入时 sessionId
|
|
206
|
+
* 获取房间当前会话 Id,当房间内已无成员时房间会回收,重新加入时 sessionId 将更新,(用户录制资源用的)
|
|
181
207
|
*/
|
|
182
208
|
getRTCSessionId(): string;
|
|
183
209
|
/**
|
|
@@ -381,6 +407,10 @@ interface IRCCallSessionOptions {
|
|
|
381
407
|
* 允许降级获得流,获得音视频不成功 ,降级获得音频
|
|
382
408
|
*/
|
|
383
409
|
isAllowDemotionGetStream?: boolean;
|
|
410
|
+
/**
|
|
411
|
+
* 产生session的场景,是主叫产生 或 被叫产生
|
|
412
|
+
*/
|
|
413
|
+
produceType?: ProduceTypes;
|
|
384
414
|
}
|
|
385
415
|
/**
|
|
386
416
|
* RCCallClient call方法的传参
|
|
@@ -409,7 +439,7 @@ interface IRCCallParams {
|
|
|
409
439
|
}
|
|
410
440
|
interface IMediaStreamConstraints {
|
|
411
441
|
video?: ICameraVideoProfile;
|
|
412
|
-
audio
|
|
442
|
+
audio?: IMicphoneAudioProfile;
|
|
413
443
|
}
|
|
414
444
|
/**
|
|
415
445
|
* RCCallClient callInGroup方法的传参
|
|
@@ -454,6 +484,10 @@ declare class RCCallClient {
|
|
|
454
484
|
* 监听onInvite
|
|
455
485
|
*/
|
|
456
486
|
private _onInvite;
|
|
487
|
+
/**
|
|
488
|
+
* 监听离线消息报告
|
|
489
|
+
* @param record
|
|
490
|
+
*/
|
|
457
491
|
_onOfflineRecord(record: IOfflineRecord): void;
|
|
458
492
|
/**
|
|
459
493
|
* 注册用户信息。注册后,在发起邀请或挂断等操作时,会将该信息一并发送给对端
|
|
@@ -494,7 +528,7 @@ declare class RCCallClient {
|
|
|
494
528
|
/**
|
|
495
529
|
* 调RTC API 获得本地流
|
|
496
530
|
*/
|
|
497
|
-
private
|
|
531
|
+
private _getLocalTrackCore;
|
|
498
532
|
private _getLocalTrack;
|
|
499
533
|
/**
|
|
500
534
|
* 从sessionList删除某个session
|
package/dist/index.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* RCCall - v5.0.1-alpha.
|
|
3
|
-
* CommitId -
|
|
4
|
-
*
|
|
2
|
+
* RCCall - v5.0.1-alpha.15
|
|
3
|
+
* CommitId - 822cbe0e445807b91c775e9bc034fba931189ece
|
|
4
|
+
* Mon Oct 18 2021 08:45:49 GMT+0800 (China Standard Time)
|
|
5
5
|
* ©2020 RongCloud, Inc. All rights reserved.
|
|
6
6
|
*/
|
|
7
7
|
import { RCCallMediaType, RCCallLanguage, RCCallSessionState, RCCallEndReason, RCCallErrorCode, RCCallEngine } from '@rongcloud/plugin-call-engine';
|
|
8
8
|
export { RCCallEndReason, RCCallErrorCode, RCCallLanguage, RCCallMediaType, RCCallSessionState, RCCallUserState } from '@rongcloud/plugin-call-engine';
|
|
9
|
-
import { Logger, RTCJoinType, LogLevel, ErrorCode } from '@rongcloud/engine';
|
|
9
|
+
import { Logger, RTCJoinType, LogLevel, ConversationType, ErrorCode } from '@rongcloud/engine';
|
|
10
10
|
import { RCRTCCode, RCKickReason } from '@rongcloud/plugin-rtc';
|
|
11
11
|
|
|
12
12
|
const logger = new Logger('RCCall');
|
|
@@ -36,6 +36,21 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* 产生session的场景
|
|
41
|
+
*/
|
|
42
|
+
var ProduceTypes;
|
|
43
|
+
(function (ProduceTypes) {
|
|
44
|
+
/**
|
|
45
|
+
* 主叫
|
|
46
|
+
*/
|
|
47
|
+
ProduceTypes[ProduceTypes["CALLER"] = 1] = "CALLER";
|
|
48
|
+
/**
|
|
49
|
+
* 被叫
|
|
50
|
+
*/
|
|
51
|
+
ProduceTypes[ProduceTypes["CALLEE"] = 2] = "CALLEE";
|
|
52
|
+
})(ProduceTypes || (ProduceTypes = {}));
|
|
53
|
+
|
|
39
54
|
class EventEmitter {
|
|
40
55
|
constructor() {
|
|
41
56
|
this.list = {};
|
|
@@ -233,6 +248,44 @@ const validateUserIds = (userIds) => {
|
|
|
233
248
|
}
|
|
234
249
|
return { result: true };
|
|
235
250
|
};
|
|
251
|
+
function isRCFrameRate(val) {
|
|
252
|
+
const arrs = ['FPS_10', 'FPS_15', 'FPS_24', 'FPS_30'];
|
|
253
|
+
return arrs.includes(val);
|
|
254
|
+
}
|
|
255
|
+
function isRCResolution(val) {
|
|
256
|
+
const arrs = ['W176_H132', 'W176_H144', 'W256_H144', 'W320_H180', 'W240_H240', 'W320_H240', 'W480_H360', 'W640_H360', 'W480_H480', 'W640_H480', 'W720_H480', 'W1280_H720', 'W1920_H1080'];
|
|
257
|
+
return arrs.includes(val);
|
|
258
|
+
}
|
|
259
|
+
const validateMediaStreamConstraints = (constraints) => {
|
|
260
|
+
if (constraints && constraints.audio && typeof constraints.audio.micphoneId !== 'undefined' && typeof constraints.audio.micphoneId !== 'string') {
|
|
261
|
+
return { result: false, msg: '\'constraints.audio.micphoneId\' must be of type \'string\'' };
|
|
262
|
+
}
|
|
263
|
+
if (constraints && constraints.audio && typeof constraints.audio.sampleRate !== 'undefined' && typeof constraints.audio.sampleRate !== 'number') {
|
|
264
|
+
return { result: false, msg: '\'constraints.audio.sampleRate\' must be of type \'number\'' };
|
|
265
|
+
}
|
|
266
|
+
if (constraints && constraints.video && typeof constraints.video.cameraId !== 'undefined' && typeof constraints.video.cameraId !== 'string') {
|
|
267
|
+
return { result: false, msg: '\'constraints.video.cameraId\' must be of type \'string\'' };
|
|
268
|
+
}
|
|
269
|
+
// if (constraints && constraints.video && typeof constraints.video.faceMode !== 'undefined' && constraints.video.cameraId !== 'user' && constraints.video.faceMode !== 'environment') {
|
|
270
|
+
// return { result: false, msg: '\'constraints.video.cameraId\' must be \'user\' or \'environment\'' }
|
|
271
|
+
// }
|
|
272
|
+
if (constraints && constraints.video && typeof constraints.video.frameRate !== 'undefined' && typeof constraints.video.frameRate !== 'string') {
|
|
273
|
+
return { result: false, msg: '\'constraints.video.frameRate\' must be of type \'string\'' };
|
|
274
|
+
}
|
|
275
|
+
if (constraints && constraints.video && typeof constraints.video.frameRate !== 'undefined' && !isRCFrameRate(constraints.video.frameRate)) {
|
|
276
|
+
return { result: false, msg: '\'frameRate\' value is out of range' };
|
|
277
|
+
}
|
|
278
|
+
if (constraints && constraints.video && typeof constraints.video.resolution !== 'undefined' && typeof constraints.video.resolution !== 'string') {
|
|
279
|
+
return { result: false, msg: '\'constraints.video.frameRate\' must be of type \'string\'' };
|
|
280
|
+
}
|
|
281
|
+
if (constraints && constraints.video && typeof constraints.video.resolution !== 'undefined' && !isRCResolution(constraints.video.resolution)) {
|
|
282
|
+
return { result: false, msg: '\'resolution\' value is out of range' };
|
|
283
|
+
}
|
|
284
|
+
if (constraints && constraints.video && (!constraints.video.frameRate || !constraints.video.resolution)) {
|
|
285
|
+
return { result: false, msg: '\'resolution\' and \'resolution\' is required' };
|
|
286
|
+
}
|
|
287
|
+
return { result: true };
|
|
288
|
+
};
|
|
236
289
|
|
|
237
290
|
class RCCallSession {
|
|
238
291
|
constructor(
|
|
@@ -252,7 +305,7 @@ class RCCallSession {
|
|
|
252
305
|
this._rtcClient = _rtcClient;
|
|
253
306
|
this._options = _options;
|
|
254
307
|
/**
|
|
255
|
-
* 用户传进来的 对session的监听
|
|
308
|
+
* 用户传进来的 对session的监听 (要在RCCallClient的_onInvite里判断,要求执行完onSession必须注册session的监听,所以这里是public)
|
|
256
309
|
*/
|
|
257
310
|
this._listener = null;
|
|
258
311
|
/**
|
|
@@ -499,10 +552,6 @@ class RCCallSession {
|
|
|
499
552
|
*/
|
|
500
553
|
_publish() {
|
|
501
554
|
return __awaiter(this, void 0, void 0, function* () {
|
|
502
|
-
// 主叫方发起call时,提前获得了本地资源的情况
|
|
503
|
-
if (!this._options.localTracks) {
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
506
555
|
const tracks = this._options.localTracks;
|
|
507
556
|
const { code } = yield this._publishRetry(tracks, this._options.isAllowPublishRetry, this._RETRYCOUNT);
|
|
508
557
|
// 若资源发布失败
|
|
@@ -511,8 +560,11 @@ class RCCallSession {
|
|
|
511
560
|
logger.info(`[RCCallSession _publist] Resource publishing failed: roomId -> ${this._stateMachine.getCallId()} RCRTCCode -> ${code}`);
|
|
512
561
|
return;
|
|
513
562
|
}
|
|
514
|
-
//
|
|
515
|
-
this.
|
|
563
|
+
// 如果是主动发起的呼叫,已提前抛出了资源, 被动呼叫,这里才需要抛出
|
|
564
|
+
if (this._options.produceType === ProduceTypes.CALLEE) {
|
|
565
|
+
// 向外抛出本地流, 通知业务层trackReady
|
|
566
|
+
this._notifyTrackReady(tracks);
|
|
567
|
+
}
|
|
516
568
|
});
|
|
517
569
|
}
|
|
518
570
|
/**
|
|
@@ -593,7 +645,7 @@ class RCCallSession {
|
|
|
593
645
|
return __awaiter(this, void 0, void 0, function* () {
|
|
594
646
|
// 检测是否能够获得本地流
|
|
595
647
|
if (mediaType === RCCallMediaType.AUDIO) {
|
|
596
|
-
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && Object.assign({}, constraints.audio));
|
|
648
|
+
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && constraints.audio && Object.assign({}, constraints.audio));
|
|
597
649
|
if (code !== RCRTCCode.SUCCESS) {
|
|
598
650
|
logger.error(`[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ${code}`);
|
|
599
651
|
return { code: RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
|
|
@@ -641,87 +693,44 @@ class RCCallSession {
|
|
|
641
693
|
});
|
|
642
694
|
}
|
|
643
695
|
/**
|
|
644
|
-
*
|
|
696
|
+
* 通话中更换音频设备
|
|
645
697
|
*/
|
|
646
|
-
|
|
698
|
+
changeAudioDevice(audioConstraints) {
|
|
647
699
|
return __awaiter(this, void 0, void 0, function* () {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
// 新产生的track
|
|
657
|
-
let recentTracks = [];
|
|
658
|
-
const mediaType = this._stateMachine.getMediaType();
|
|
659
|
-
// 如果当前是音视频通话 并且有视频参数和音频参数
|
|
660
|
-
if (mediaType === RCCallMediaType.AUDIO_VIDEO && constraints.video && constraints.audio) {
|
|
661
|
-
const { code, tracks } = yield this._rtcClient.createMicrophoneAndCameraTracks('RongCloudRTC', Object.assign({}, constraints));
|
|
662
|
-
if (code !== RCRTCCode.SUCCESS) {
|
|
663
|
-
logger.error(`[RCCallSession changeDevice] get local Audo and Video tracks failed RCT code -> ${code}`);
|
|
664
|
-
return { code: RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR };
|
|
665
|
-
}
|
|
666
|
-
// 把之前的track销毁
|
|
667
|
-
this._options.localTracks && this._destroyTracks(this._options.localTracks);
|
|
668
|
-
recentTracks = tracks;
|
|
669
|
-
this._options.localTracks = recentTracks;
|
|
670
|
-
// 如果当前是音视频通话 并且有视频参数
|
|
700
|
+
// 新设备的track
|
|
701
|
+
const recentTracks = [];
|
|
702
|
+
// 整理后的本地track
|
|
703
|
+
const localTracks = [];
|
|
704
|
+
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', audioConstraints);
|
|
705
|
+
if (code !== RCRTCCode.SUCCESS) {
|
|
706
|
+
logger.error(`[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ${code}`);
|
|
707
|
+
return { code: RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
|
|
671
708
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
return { code: RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR };
|
|
709
|
+
this._options.localTracks && this._options.localTracks.forEach((track) => {
|
|
710
|
+
if (track.isAudioTrack()) {
|
|
711
|
+
// 之前的音频都销毁
|
|
712
|
+
track.destroy();
|
|
677
713
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
// 之前的视频都销毁
|
|
682
|
-
track.destroy();
|
|
683
|
-
}
|
|
684
|
-
else {
|
|
685
|
-
// 只留下之前的音频
|
|
686
|
-
localTracks.push(track);
|
|
687
|
-
}
|
|
688
|
-
});
|
|
689
|
-
recentTracks = [track];
|
|
690
|
-
// 加上本地新产生的视频
|
|
691
|
-
localTracks.push(track);
|
|
692
|
-
this._options.localTracks = localTracks;
|
|
693
|
-
// 如果当前是音视频通话 并且有音频参数 或 音频通话有音频参数
|
|
694
|
-
}
|
|
695
|
-
else if (constraints.audio) {
|
|
696
|
-
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', Object.assign({}, constraints.audio));
|
|
697
|
-
if (code !== RCRTCCode.SUCCESS) {
|
|
698
|
-
logger.error(`[RCCallSession changeDevice] get local Audio tracks failed RCT code -> ${code}`);
|
|
699
|
-
return { code: RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
|
|
714
|
+
else {
|
|
715
|
+
// 只把之前的视频留下
|
|
716
|
+
localTracks.push(track);
|
|
700
717
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
track.destroy();
|
|
707
|
-
}
|
|
708
|
-
else {
|
|
709
|
-
// 只把之前的视频留下
|
|
710
|
-
localTracks.push(track);
|
|
711
|
-
}
|
|
712
|
-
});
|
|
713
|
-
recentTracks = [track];
|
|
714
|
-
// 加上本地新产生的音频
|
|
715
|
-
localTracks.push(track);
|
|
716
|
-
this._options.localTracks = localTracks;
|
|
717
|
-
}
|
|
718
|
+
});
|
|
719
|
+
recentTracks.push(track);
|
|
720
|
+
// 加上本地新产生的音频
|
|
721
|
+
localTracks.push(track);
|
|
722
|
+
this._options.localTracks = localTracks;
|
|
718
723
|
// 通知业务层trackReady
|
|
719
724
|
this._notifyTrackReady(recentTracks);
|
|
720
725
|
// 如果当前已加入房间,发布新流
|
|
721
726
|
if (this._room) {
|
|
722
727
|
// 发布新流
|
|
723
|
-
this.
|
|
728
|
+
const { code } = yield this._room.publish(recentTracks);
|
|
729
|
+
if (code !== RCRTCCode.SUCCESS) {
|
|
730
|
+
return { code: RCCallErrorCode.AUDIO_PUBLISH_ERROR };
|
|
731
|
+
}
|
|
724
732
|
}
|
|
733
|
+
return { code: RCCallErrorCode.SUCCESS };
|
|
725
734
|
});
|
|
726
735
|
}
|
|
727
736
|
/**
|
|
@@ -730,6 +739,11 @@ class RCCallSession {
|
|
|
730
739
|
*/
|
|
731
740
|
invite(userIds) {
|
|
732
741
|
return __awaiter(this, void 0, void 0, function* () {
|
|
742
|
+
const conversationType = this._stateMachine.getConversationType();
|
|
743
|
+
// 如果当前不是群组通话,直接返回错误码
|
|
744
|
+
if (conversationType !== ConversationType.GROUP) {
|
|
745
|
+
return { code: RCCallErrorCode.CONVERSATION_NOT_GROUP_ERROR };
|
|
746
|
+
}
|
|
733
747
|
const conclusion = validateUserIds(userIds);
|
|
734
748
|
if (!conclusion.result) {
|
|
735
749
|
throw new Error(`[RCCallSession invite] ${conclusion.msg}`);
|
|
@@ -743,10 +757,11 @@ class RCCallSession {
|
|
|
743
757
|
*/
|
|
744
758
|
accept(constraints) {
|
|
745
759
|
return __awaiter(this, void 0, void 0, function* () {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
760
|
+
const conclusion = validateMediaStreamConstraints(constraints);
|
|
761
|
+
if (!conclusion.result) {
|
|
762
|
+
throw new Error(`[RCCallSession accept] ${conclusion.msg}`);
|
|
763
|
+
}
|
|
764
|
+
// 接听之前,先挂断当前之外的session,现阶段不允许用户先择接听session,事先会在状态机内部挂断,这里抛出去,会清理其它的seesion
|
|
750
765
|
eventEmitter.emit('hungupOtherSession', { session: this });
|
|
751
766
|
const mediaType = this._stateMachine.getMediaType();
|
|
752
767
|
const { code: _code, tracks } = yield this._getLocalTrack(mediaType, constraints);
|
|
@@ -799,6 +814,21 @@ class RCCallSession {
|
|
|
799
814
|
}
|
|
800
815
|
return localVideoTracks;
|
|
801
816
|
}
|
|
817
|
+
/**
|
|
818
|
+
* 获得本地音频
|
|
819
|
+
*/
|
|
820
|
+
_getLocalAudioTracks() {
|
|
821
|
+
let localAudiotracks = [];
|
|
822
|
+
if (!this._room) {
|
|
823
|
+
return localAudiotracks;
|
|
824
|
+
}
|
|
825
|
+
if (this._options.localTracks) {
|
|
826
|
+
localAudiotracks = this._options.localTracks.filter((track) => {
|
|
827
|
+
return track.isAudioTrack();
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
return localAudiotracks;
|
|
831
|
+
}
|
|
802
832
|
/**
|
|
803
833
|
* 把通话的MediaType升级到音视频
|
|
804
834
|
*/
|
|
@@ -942,6 +972,30 @@ class RCCallSession {
|
|
|
942
972
|
return { code: RCCallErrorCode.SUCCESS };
|
|
943
973
|
});
|
|
944
974
|
}
|
|
975
|
+
/**
|
|
976
|
+
* 禁用音频track
|
|
977
|
+
*/
|
|
978
|
+
disableAudioTrack() {
|
|
979
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
980
|
+
const tracks = this._getLocalAudioTracks();
|
|
981
|
+
// 禁用音频
|
|
982
|
+
tracks.forEach((track) => {
|
|
983
|
+
track.mute();
|
|
984
|
+
});
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* 启用音频track
|
|
989
|
+
*/
|
|
990
|
+
enableAudioTrack() {
|
|
991
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
992
|
+
const tracks = this._getLocalAudioTracks();
|
|
993
|
+
// 启用音频
|
|
994
|
+
tracks.forEach((track) => {
|
|
995
|
+
track.unmute();
|
|
996
|
+
});
|
|
997
|
+
});
|
|
998
|
+
}
|
|
945
999
|
/**
|
|
946
1000
|
* 销毁本地流
|
|
947
1001
|
*/
|
|
@@ -1157,7 +1211,7 @@ class RCCallSession {
|
|
|
1157
1211
|
return this._stateMachine.getCallId();
|
|
1158
1212
|
}
|
|
1159
1213
|
/**
|
|
1160
|
-
* 获取房间当前会话 Id,当房间内已无成员时房间会回收,重新加入时 sessionId
|
|
1214
|
+
* 获取房间当前会话 Id,当房间内已无成员时房间会回收,重新加入时 sessionId 将更新,(用户录制资源用的)
|
|
1161
1215
|
*/
|
|
1162
1216
|
getRTCSessionId() {
|
|
1163
1217
|
return this._room.getSessionId();
|
|
@@ -1254,7 +1308,7 @@ class RCCallClient {
|
|
|
1254
1308
|
lang: RCCallLanguage.ZH
|
|
1255
1309
|
}, _options);
|
|
1256
1310
|
// 初始化callEngine, 并监听onInvite
|
|
1257
|
-
this._callEngine = new RCCallEngine(this._context, logger, {
|
|
1311
|
+
this._callEngine = new RCCallEngine(this._context, _runtime, logger, {
|
|
1258
1312
|
/**
|
|
1259
1313
|
* 监听收到invite
|
|
1260
1314
|
*/
|
|
@@ -1321,7 +1375,9 @@ class RCCallClient {
|
|
|
1321
1375
|
*/
|
|
1322
1376
|
joinType: this._options.joinType,
|
|
1323
1377
|
// 允许降级获得流,获得音视频不成功 ,降级获得音频, 默认不允许
|
|
1324
|
-
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream
|
|
1378
|
+
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
|
|
1379
|
+
// 标明是被叫产生的session
|
|
1380
|
+
produceType: ProduceTypes.CALLEE
|
|
1325
1381
|
});
|
|
1326
1382
|
logger.info('[RCCallClient _onInvite] Received invite message, successfully created session');
|
|
1327
1383
|
/**
|
|
@@ -1348,6 +1404,10 @@ class RCCallClient {
|
|
|
1348
1404
|
throw new Error('[RCCallSession _options.onSession] session Must Have Listener');
|
|
1349
1405
|
}
|
|
1350
1406
|
}
|
|
1407
|
+
/**
|
|
1408
|
+
* 监听离线消息报告
|
|
1409
|
+
* @param record
|
|
1410
|
+
*/
|
|
1351
1411
|
_onOfflineRecord(record) {
|
|
1352
1412
|
try {
|
|
1353
1413
|
// 执行用户API的监听
|
|
@@ -1416,7 +1476,9 @@ class RCCallClient {
|
|
|
1416
1476
|
*/
|
|
1417
1477
|
joinType: this._options.joinType,
|
|
1418
1478
|
// 允许降级获得流,获得音视频不成功 ,降级获得音频, 默认不允许
|
|
1419
|
-
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream
|
|
1479
|
+
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
|
|
1480
|
+
// 标明是主叫产生的session
|
|
1481
|
+
produceType: ProduceTypes.CALLER
|
|
1420
1482
|
});
|
|
1421
1483
|
// session上注册监听事件
|
|
1422
1484
|
session.registerSessionListener(listener);
|
|
@@ -1485,7 +1547,9 @@ class RCCallClient {
|
|
|
1485
1547
|
*/
|
|
1486
1548
|
joinType: this._options.joinType,
|
|
1487
1549
|
// 允许降级获得流,获得音视频不成功 ,降级获得音频, 默认不允许
|
|
1488
|
-
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream
|
|
1550
|
+
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
|
|
1551
|
+
// 标明是主叫产生的session
|
|
1552
|
+
produceType: ProduceTypes.CALLER
|
|
1489
1553
|
});
|
|
1490
1554
|
// session上注册监听事件
|
|
1491
1555
|
session.registerSessionListener(listener);
|
|
@@ -1508,11 +1572,11 @@ class RCCallClient {
|
|
|
1508
1572
|
/**
|
|
1509
1573
|
* 调RTC API 获得本地流
|
|
1510
1574
|
*/
|
|
1511
|
-
|
|
1575
|
+
_getLocalTrackCore(mediaType, constraints) {
|
|
1512
1576
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1513
1577
|
// 检测是否能够获得本地流
|
|
1514
1578
|
if (mediaType === RCCallMediaType.AUDIO) {
|
|
1515
|
-
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && Object.assign({}, constraints.audio));
|
|
1579
|
+
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && constraints.audio && Object.assign({}, constraints.audio));
|
|
1516
1580
|
if (code !== RCRTCCode.SUCCESS) {
|
|
1517
1581
|
logger.error(`[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ${code}`);
|
|
1518
1582
|
return { code: RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
|
|
@@ -1535,10 +1599,10 @@ class RCCallClient {
|
|
|
1535
1599
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1536
1600
|
// 如果是允许降级获得流,并且是获得音视频
|
|
1537
1601
|
if (this._options.isAllowDemotionGetStream && mediaType === RCCallMediaType.AUDIO_VIDEO) {
|
|
1538
|
-
const { code, tracks } = yield this.
|
|
1602
|
+
const { code, tracks } = yield this._getLocalTrackCore(RCCallMediaType.AUDIO_VIDEO, constraints);
|
|
1539
1603
|
// 如果音视频不能获得,就降组获得音频
|
|
1540
1604
|
if (code !== RCCallErrorCode.SUCCESS) {
|
|
1541
|
-
const { code, tracks } = yield this.
|
|
1605
|
+
const { code, tracks } = yield this._getLocalTrackCore(RCCallMediaType.AUDIO, constraints);
|
|
1542
1606
|
if (code !== RCCallErrorCode.SUCCESS) {
|
|
1543
1607
|
return { code };
|
|
1544
1608
|
}
|
|
@@ -1547,7 +1611,7 @@ class RCCallClient {
|
|
|
1547
1611
|
return { code, tracks: tracks };
|
|
1548
1612
|
}
|
|
1549
1613
|
else {
|
|
1550
|
-
const { code: _code, tracks } = yield this.
|
|
1614
|
+
const { code: _code, tracks } = yield this._getLocalTrackCore(mediaType, constraints);
|
|
1551
1615
|
if (_code !== RCCallErrorCode.SUCCESS) {
|
|
1552
1616
|
return { code: _code };
|
|
1553
1617
|
}
|
|
@@ -1594,7 +1658,7 @@ const installer = {
|
|
|
1594
1658
|
}
|
|
1595
1659
|
logger.setLogLevel(options.logLevel);
|
|
1596
1660
|
logger.setLogStdout(options.logStdout);
|
|
1597
|
-
logger.warn(`RCCall Version: ${"5.0.1-alpha.
|
|
1661
|
+
logger.warn(`RCCall Version: ${"5.0.1-alpha.15"}, Commit: ${"822cbe0e445807b91c775e9bc034fba931189ece"}`);
|
|
1598
1662
|
return new RCCallClient(context, runtime, options);
|
|
1599
1663
|
}
|
|
1600
1664
|
};
|