@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.umd.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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
|
(function (global, factory) {
|
|
8
8
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@rongcloud/plugin-call-engine'), require('@rongcloud/engine'), require('@rongcloud/plugin-rtc')) :
|
|
9
9
|
typeof define === 'function' && define.amd ? define(['exports', '@rongcloud/plugin-call-engine', '@rongcloud/engine', '@rongcloud/plugin-rtc'], factory) :
|
|
10
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.RCCall = {}, global.
|
|
11
|
-
}(this, (function (exports, pluginCallEngine, engine, pluginRtc) { 'use strict';
|
|
10
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.RCCall = {}, global.RCCallEngine, global.RCEngine, global.RCRTC));
|
|
11
|
+
})(this, (function (exports, pluginCallEngine, engine, pluginRtc) { 'use strict';
|
|
12
12
|
|
|
13
13
|
const logger = new engine.Logger('RCCall');
|
|
14
14
|
|
|
@@ -37,6 +37,21 @@
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* 产生session的场景
|
|
42
|
+
*/
|
|
43
|
+
var ProduceTypes;
|
|
44
|
+
(function (ProduceTypes) {
|
|
45
|
+
/**
|
|
46
|
+
* 主叫
|
|
47
|
+
*/
|
|
48
|
+
ProduceTypes[ProduceTypes["CALLER"] = 1] = "CALLER";
|
|
49
|
+
/**
|
|
50
|
+
* 被叫
|
|
51
|
+
*/
|
|
52
|
+
ProduceTypes[ProduceTypes["CALLEE"] = 2] = "CALLEE";
|
|
53
|
+
})(ProduceTypes || (ProduceTypes = {}));
|
|
54
|
+
|
|
40
55
|
class EventEmitter {
|
|
41
56
|
constructor() {
|
|
42
57
|
this.list = {};
|
|
@@ -234,6 +249,44 @@
|
|
|
234
249
|
}
|
|
235
250
|
return { result: true };
|
|
236
251
|
};
|
|
252
|
+
function isRCFrameRate(val) {
|
|
253
|
+
const arrs = ['FPS_10', 'FPS_15', 'FPS_24', 'FPS_30'];
|
|
254
|
+
return arrs.includes(val);
|
|
255
|
+
}
|
|
256
|
+
function isRCResolution(val) {
|
|
257
|
+
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'];
|
|
258
|
+
return arrs.includes(val);
|
|
259
|
+
}
|
|
260
|
+
const validateMediaStreamConstraints = (constraints) => {
|
|
261
|
+
if (constraints && constraints.audio && typeof constraints.audio.micphoneId !== 'undefined' && typeof constraints.audio.micphoneId !== 'string') {
|
|
262
|
+
return { result: false, msg: '\'constraints.audio.micphoneId\' must be of type \'string\'' };
|
|
263
|
+
}
|
|
264
|
+
if (constraints && constraints.audio && typeof constraints.audio.sampleRate !== 'undefined' && typeof constraints.audio.sampleRate !== 'number') {
|
|
265
|
+
return { result: false, msg: '\'constraints.audio.sampleRate\' must be of type \'number\'' };
|
|
266
|
+
}
|
|
267
|
+
if (constraints && constraints.video && typeof constraints.video.cameraId !== 'undefined' && typeof constraints.video.cameraId !== 'string') {
|
|
268
|
+
return { result: false, msg: '\'constraints.video.cameraId\' must be of type \'string\'' };
|
|
269
|
+
}
|
|
270
|
+
// if (constraints && constraints.video && typeof constraints.video.faceMode !== 'undefined' && constraints.video.cameraId !== 'user' && constraints.video.faceMode !== 'environment') {
|
|
271
|
+
// return { result: false, msg: '\'constraints.video.cameraId\' must be \'user\' or \'environment\'' }
|
|
272
|
+
// }
|
|
273
|
+
if (constraints && constraints.video && typeof constraints.video.frameRate !== 'undefined' && typeof constraints.video.frameRate !== 'string') {
|
|
274
|
+
return { result: false, msg: '\'constraints.video.frameRate\' must be of type \'string\'' };
|
|
275
|
+
}
|
|
276
|
+
if (constraints && constraints.video && typeof constraints.video.frameRate !== 'undefined' && !isRCFrameRate(constraints.video.frameRate)) {
|
|
277
|
+
return { result: false, msg: '\'frameRate\' value is out of range' };
|
|
278
|
+
}
|
|
279
|
+
if (constraints && constraints.video && typeof constraints.video.resolution !== 'undefined' && typeof constraints.video.resolution !== 'string') {
|
|
280
|
+
return { result: false, msg: '\'constraints.video.frameRate\' must be of type \'string\'' };
|
|
281
|
+
}
|
|
282
|
+
if (constraints && constraints.video && typeof constraints.video.resolution !== 'undefined' && !isRCResolution(constraints.video.resolution)) {
|
|
283
|
+
return { result: false, msg: '\'resolution\' value is out of range' };
|
|
284
|
+
}
|
|
285
|
+
if (constraints && constraints.video && (!constraints.video.frameRate || !constraints.video.resolution)) {
|
|
286
|
+
return { result: false, msg: '\'resolution\' and \'resolution\' is required' };
|
|
287
|
+
}
|
|
288
|
+
return { result: true };
|
|
289
|
+
};
|
|
237
290
|
|
|
238
291
|
class RCCallSession {
|
|
239
292
|
constructor(
|
|
@@ -253,7 +306,7 @@
|
|
|
253
306
|
this._rtcClient = _rtcClient;
|
|
254
307
|
this._options = _options;
|
|
255
308
|
/**
|
|
256
|
-
* 用户传进来的 对session的监听
|
|
309
|
+
* 用户传进来的 对session的监听 (要在RCCallClient的_onInvite里判断,要求执行完onSession必须注册session的监听,所以这里是public)
|
|
257
310
|
*/
|
|
258
311
|
this._listener = null;
|
|
259
312
|
/**
|
|
@@ -500,10 +553,6 @@
|
|
|
500
553
|
*/
|
|
501
554
|
_publish() {
|
|
502
555
|
return __awaiter(this, void 0, void 0, function* () {
|
|
503
|
-
// 主叫方发起call时,提前获得了本地资源的情况
|
|
504
|
-
if (!this._options.localTracks) {
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
556
|
const tracks = this._options.localTracks;
|
|
508
557
|
const { code } = yield this._publishRetry(tracks, this._options.isAllowPublishRetry, this._RETRYCOUNT);
|
|
509
558
|
// 若资源发布失败
|
|
@@ -512,8 +561,11 @@
|
|
|
512
561
|
logger.info(`[RCCallSession _publist] Resource publishing failed: roomId -> ${this._stateMachine.getCallId()} RCRTCCode -> ${code}`);
|
|
513
562
|
return;
|
|
514
563
|
}
|
|
515
|
-
//
|
|
516
|
-
this.
|
|
564
|
+
// 如果是主动发起的呼叫,已提前抛出了资源, 被动呼叫,这里才需要抛出
|
|
565
|
+
if (this._options.produceType === ProduceTypes.CALLEE) {
|
|
566
|
+
// 向外抛出本地流, 通知业务层trackReady
|
|
567
|
+
this._notifyTrackReady(tracks);
|
|
568
|
+
}
|
|
517
569
|
});
|
|
518
570
|
}
|
|
519
571
|
/**
|
|
@@ -594,7 +646,7 @@
|
|
|
594
646
|
return __awaiter(this, void 0, void 0, function* () {
|
|
595
647
|
// 检测是否能够获得本地流
|
|
596
648
|
if (mediaType === pluginCallEngine.RCCallMediaType.AUDIO) {
|
|
597
|
-
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && Object.assign({}, constraints.audio));
|
|
649
|
+
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && constraints.audio && Object.assign({}, constraints.audio));
|
|
598
650
|
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
599
651
|
logger.error(`[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ${code}`);
|
|
600
652
|
return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
|
|
@@ -642,87 +694,44 @@
|
|
|
642
694
|
});
|
|
643
695
|
}
|
|
644
696
|
/**
|
|
645
|
-
*
|
|
697
|
+
* 通话中更换音频设备
|
|
646
698
|
*/
|
|
647
|
-
|
|
699
|
+
changeAudioDevice(audioConstraints) {
|
|
648
700
|
return __awaiter(this, void 0, void 0, function* () {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
// 新产生的track
|
|
658
|
-
let recentTracks = [];
|
|
659
|
-
const mediaType = this._stateMachine.getMediaType();
|
|
660
|
-
// 如果当前是音视频通话 并且有视频参数和音频参数
|
|
661
|
-
if (mediaType === pluginCallEngine.RCCallMediaType.AUDIO_VIDEO && constraints.video && constraints.audio) {
|
|
662
|
-
const { code, tracks } = yield this._rtcClient.createMicrophoneAndCameraTracks('RongCloudRTC', Object.assign({}, constraints));
|
|
663
|
-
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
664
|
-
logger.error(`[RCCallSession changeDevice] get local Audo and Video tracks failed RCT code -> ${code}`);
|
|
665
|
-
return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR };
|
|
666
|
-
}
|
|
667
|
-
// 把之前的track销毁
|
|
668
|
-
this._options.localTracks && this._destroyTracks(this._options.localTracks);
|
|
669
|
-
recentTracks = tracks;
|
|
670
|
-
this._options.localTracks = recentTracks;
|
|
671
|
-
// 如果当前是音视频通话 并且有视频参数
|
|
701
|
+
// 新设备的track
|
|
702
|
+
const recentTracks = [];
|
|
703
|
+
// 整理后的本地track
|
|
704
|
+
const localTracks = [];
|
|
705
|
+
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', audioConstraints);
|
|
706
|
+
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
707
|
+
logger.error(`[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ${code}`);
|
|
708
|
+
return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
|
|
672
709
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR };
|
|
710
|
+
this._options.localTracks && this._options.localTracks.forEach((track) => {
|
|
711
|
+
if (track.isAudioTrack()) {
|
|
712
|
+
// 之前的音频都销毁
|
|
713
|
+
track.destroy();
|
|
678
714
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
// 之前的视频都销毁
|
|
683
|
-
track.destroy();
|
|
684
|
-
}
|
|
685
|
-
else {
|
|
686
|
-
// 只留下之前的音频
|
|
687
|
-
localTracks.push(track);
|
|
688
|
-
}
|
|
689
|
-
});
|
|
690
|
-
recentTracks = [track];
|
|
691
|
-
// 加上本地新产生的视频
|
|
692
|
-
localTracks.push(track);
|
|
693
|
-
this._options.localTracks = localTracks;
|
|
694
|
-
// 如果当前是音视频通话 并且有音频参数 或 音频通话有音频参数
|
|
695
|
-
}
|
|
696
|
-
else if (constraints.audio) {
|
|
697
|
-
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', Object.assign({}, constraints.audio));
|
|
698
|
-
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
699
|
-
logger.error(`[RCCallSession changeDevice] get local Audio tracks failed RCT code -> ${code}`);
|
|
700
|
-
return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
|
|
715
|
+
else {
|
|
716
|
+
// 只把之前的视频留下
|
|
717
|
+
localTracks.push(track);
|
|
701
718
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
track.destroy();
|
|
708
|
-
}
|
|
709
|
-
else {
|
|
710
|
-
// 只把之前的视频留下
|
|
711
|
-
localTracks.push(track);
|
|
712
|
-
}
|
|
713
|
-
});
|
|
714
|
-
recentTracks = [track];
|
|
715
|
-
// 加上本地新产生的音频
|
|
716
|
-
localTracks.push(track);
|
|
717
|
-
this._options.localTracks = localTracks;
|
|
718
|
-
}
|
|
719
|
+
});
|
|
720
|
+
recentTracks.push(track);
|
|
721
|
+
// 加上本地新产生的音频
|
|
722
|
+
localTracks.push(track);
|
|
723
|
+
this._options.localTracks = localTracks;
|
|
719
724
|
// 通知业务层trackReady
|
|
720
725
|
this._notifyTrackReady(recentTracks);
|
|
721
726
|
// 如果当前已加入房间,发布新流
|
|
722
727
|
if (this._room) {
|
|
723
728
|
// 发布新流
|
|
724
|
-
this.
|
|
729
|
+
const { code } = yield this._room.publish(recentTracks);
|
|
730
|
+
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
731
|
+
return { code: pluginCallEngine.RCCallErrorCode.AUDIO_PUBLISH_ERROR };
|
|
732
|
+
}
|
|
725
733
|
}
|
|
734
|
+
return { code: pluginCallEngine.RCCallErrorCode.SUCCESS };
|
|
726
735
|
});
|
|
727
736
|
}
|
|
728
737
|
/**
|
|
@@ -731,6 +740,11 @@
|
|
|
731
740
|
*/
|
|
732
741
|
invite(userIds) {
|
|
733
742
|
return __awaiter(this, void 0, void 0, function* () {
|
|
743
|
+
const conversationType = this._stateMachine.getConversationType();
|
|
744
|
+
// 如果当前不是群组通话,直接返回错误码
|
|
745
|
+
if (conversationType !== engine.ConversationType.GROUP) {
|
|
746
|
+
return { code: pluginCallEngine.RCCallErrorCode.CONVERSATION_NOT_GROUP_ERROR };
|
|
747
|
+
}
|
|
734
748
|
const conclusion = validateUserIds(userIds);
|
|
735
749
|
if (!conclusion.result) {
|
|
736
750
|
throw new Error(`[RCCallSession invite] ${conclusion.msg}`);
|
|
@@ -744,10 +758,11 @@
|
|
|
744
758
|
*/
|
|
745
759
|
accept(constraints) {
|
|
746
760
|
return __awaiter(this, void 0, void 0, function* () {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
761
|
+
const conclusion = validateMediaStreamConstraints(constraints);
|
|
762
|
+
if (!conclusion.result) {
|
|
763
|
+
throw new Error(`[RCCallSession accept] ${conclusion.msg}`);
|
|
764
|
+
}
|
|
765
|
+
// 接听之前,先挂断当前之外的session,现阶段不允许用户先择接听session,事先会在状态机内部挂断,这里抛出去,会清理其它的seesion
|
|
751
766
|
eventEmitter.emit('hungupOtherSession', { session: this });
|
|
752
767
|
const mediaType = this._stateMachine.getMediaType();
|
|
753
768
|
const { code: _code, tracks } = yield this._getLocalTrack(mediaType, constraints);
|
|
@@ -800,6 +815,21 @@
|
|
|
800
815
|
}
|
|
801
816
|
return localVideoTracks;
|
|
802
817
|
}
|
|
818
|
+
/**
|
|
819
|
+
* 获得本地音频
|
|
820
|
+
*/
|
|
821
|
+
_getLocalAudioTracks() {
|
|
822
|
+
let localAudiotracks = [];
|
|
823
|
+
if (!this._room) {
|
|
824
|
+
return localAudiotracks;
|
|
825
|
+
}
|
|
826
|
+
if (this._options.localTracks) {
|
|
827
|
+
localAudiotracks = this._options.localTracks.filter((track) => {
|
|
828
|
+
return track.isAudioTrack();
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
return localAudiotracks;
|
|
832
|
+
}
|
|
803
833
|
/**
|
|
804
834
|
* 把通话的MediaType升级到音视频
|
|
805
835
|
*/
|
|
@@ -943,6 +973,30 @@
|
|
|
943
973
|
return { code: pluginCallEngine.RCCallErrorCode.SUCCESS };
|
|
944
974
|
});
|
|
945
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* 禁用音频track
|
|
978
|
+
*/
|
|
979
|
+
disableAudioTrack() {
|
|
980
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
981
|
+
const tracks = this._getLocalAudioTracks();
|
|
982
|
+
// 禁用音频
|
|
983
|
+
tracks.forEach((track) => {
|
|
984
|
+
track.mute();
|
|
985
|
+
});
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* 启用音频track
|
|
990
|
+
*/
|
|
991
|
+
enableAudioTrack() {
|
|
992
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
993
|
+
const tracks = this._getLocalAudioTracks();
|
|
994
|
+
// 启用音频
|
|
995
|
+
tracks.forEach((track) => {
|
|
996
|
+
track.unmute();
|
|
997
|
+
});
|
|
998
|
+
});
|
|
999
|
+
}
|
|
946
1000
|
/**
|
|
947
1001
|
* 销毁本地流
|
|
948
1002
|
*/
|
|
@@ -1158,7 +1212,7 @@
|
|
|
1158
1212
|
return this._stateMachine.getCallId();
|
|
1159
1213
|
}
|
|
1160
1214
|
/**
|
|
1161
|
-
* 获取房间当前会话 Id,当房间内已无成员时房间会回收,重新加入时 sessionId
|
|
1215
|
+
* 获取房间当前会话 Id,当房间内已无成员时房间会回收,重新加入时 sessionId 将更新,(用户录制资源用的)
|
|
1162
1216
|
*/
|
|
1163
1217
|
getRTCSessionId() {
|
|
1164
1218
|
return this._room.getSessionId();
|
|
@@ -1255,7 +1309,7 @@
|
|
|
1255
1309
|
lang: pluginCallEngine.RCCallLanguage.ZH
|
|
1256
1310
|
}, _options);
|
|
1257
1311
|
// 初始化callEngine, 并监听onInvite
|
|
1258
|
-
this._callEngine = new pluginCallEngine.RCCallEngine(this._context, logger, {
|
|
1312
|
+
this._callEngine = new pluginCallEngine.RCCallEngine(this._context, _runtime, logger, {
|
|
1259
1313
|
/**
|
|
1260
1314
|
* 监听收到invite
|
|
1261
1315
|
*/
|
|
@@ -1322,7 +1376,9 @@
|
|
|
1322
1376
|
*/
|
|
1323
1377
|
joinType: this._options.joinType,
|
|
1324
1378
|
// 允许降级获得流,获得音视频不成功 ,降级获得音频, 默认不允许
|
|
1325
|
-
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream
|
|
1379
|
+
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
|
|
1380
|
+
// 标明是被叫产生的session
|
|
1381
|
+
produceType: ProduceTypes.CALLEE
|
|
1326
1382
|
});
|
|
1327
1383
|
logger.info('[RCCallClient _onInvite] Received invite message, successfully created session');
|
|
1328
1384
|
/**
|
|
@@ -1349,6 +1405,10 @@
|
|
|
1349
1405
|
throw new Error('[RCCallSession _options.onSession] session Must Have Listener');
|
|
1350
1406
|
}
|
|
1351
1407
|
}
|
|
1408
|
+
/**
|
|
1409
|
+
* 监听离线消息报告
|
|
1410
|
+
* @param record
|
|
1411
|
+
*/
|
|
1352
1412
|
_onOfflineRecord(record) {
|
|
1353
1413
|
try {
|
|
1354
1414
|
// 执行用户API的监听
|
|
@@ -1417,7 +1477,9 @@
|
|
|
1417
1477
|
*/
|
|
1418
1478
|
joinType: this._options.joinType,
|
|
1419
1479
|
// 允许降级获得流,获得音视频不成功 ,降级获得音频, 默认不允许
|
|
1420
|
-
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream
|
|
1480
|
+
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
|
|
1481
|
+
// 标明是主叫产生的session
|
|
1482
|
+
produceType: ProduceTypes.CALLER
|
|
1421
1483
|
});
|
|
1422
1484
|
// session上注册监听事件
|
|
1423
1485
|
session.registerSessionListener(listener);
|
|
@@ -1486,7 +1548,9 @@
|
|
|
1486
1548
|
*/
|
|
1487
1549
|
joinType: this._options.joinType,
|
|
1488
1550
|
// 允许降级获得流,获得音视频不成功 ,降级获得音频, 默认不允许
|
|
1489
|
-
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream
|
|
1551
|
+
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
|
|
1552
|
+
// 标明是主叫产生的session
|
|
1553
|
+
produceType: ProduceTypes.CALLER
|
|
1490
1554
|
});
|
|
1491
1555
|
// session上注册监听事件
|
|
1492
1556
|
session.registerSessionListener(listener);
|
|
@@ -1509,11 +1573,11 @@
|
|
|
1509
1573
|
/**
|
|
1510
1574
|
* 调RTC API 获得本地流
|
|
1511
1575
|
*/
|
|
1512
|
-
|
|
1576
|
+
_getLocalTrackCore(mediaType, constraints) {
|
|
1513
1577
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1514
1578
|
// 检测是否能够获得本地流
|
|
1515
1579
|
if (mediaType === pluginCallEngine.RCCallMediaType.AUDIO) {
|
|
1516
|
-
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && Object.assign({}, constraints.audio));
|
|
1580
|
+
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && constraints.audio && Object.assign({}, constraints.audio));
|
|
1517
1581
|
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
1518
1582
|
logger.error(`[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ${code}`);
|
|
1519
1583
|
return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
|
|
@@ -1536,10 +1600,10 @@
|
|
|
1536
1600
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1537
1601
|
// 如果是允许降级获得流,并且是获得音视频
|
|
1538
1602
|
if (this._options.isAllowDemotionGetStream && mediaType === pluginCallEngine.RCCallMediaType.AUDIO_VIDEO) {
|
|
1539
|
-
const { code, tracks } = yield this.
|
|
1603
|
+
const { code, tracks } = yield this._getLocalTrackCore(pluginCallEngine.RCCallMediaType.AUDIO_VIDEO, constraints);
|
|
1540
1604
|
// 如果音视频不能获得,就降组获得音频
|
|
1541
1605
|
if (code !== pluginCallEngine.RCCallErrorCode.SUCCESS) {
|
|
1542
|
-
const { code, tracks } = yield this.
|
|
1606
|
+
const { code, tracks } = yield this._getLocalTrackCore(pluginCallEngine.RCCallMediaType.AUDIO, constraints);
|
|
1543
1607
|
if (code !== pluginCallEngine.RCCallErrorCode.SUCCESS) {
|
|
1544
1608
|
return { code };
|
|
1545
1609
|
}
|
|
@@ -1548,7 +1612,7 @@
|
|
|
1548
1612
|
return { code, tracks: tracks };
|
|
1549
1613
|
}
|
|
1550
1614
|
else {
|
|
1551
|
-
const { code: _code, tracks } = yield this.
|
|
1615
|
+
const { code: _code, tracks } = yield this._getLocalTrackCore(mediaType, constraints);
|
|
1552
1616
|
if (_code !== pluginCallEngine.RCCallErrorCode.SUCCESS) {
|
|
1553
1617
|
return { code: _code };
|
|
1554
1618
|
}
|
|
@@ -1595,46 +1659,34 @@
|
|
|
1595
1659
|
}
|
|
1596
1660
|
logger.setLogLevel(options.logLevel);
|
|
1597
1661
|
logger.setLogStdout(options.logStdout);
|
|
1598
|
-
logger.warn(`RCCall Version: ${"5.0.1-alpha.
|
|
1662
|
+
logger.warn(`RCCall Version: ${"5.0.1-alpha.15"}, Commit: ${"822cbe0e445807b91c775e9bc034fba931189ece"}`);
|
|
1599
1663
|
return new RCCallClient(context, runtime, options);
|
|
1600
1664
|
}
|
|
1601
1665
|
};
|
|
1602
1666
|
|
|
1603
1667
|
Object.defineProperty(exports, 'RCCallEndReason', {
|
|
1604
1668
|
enumerable: true,
|
|
1605
|
-
get: function () {
|
|
1606
|
-
return pluginCallEngine.RCCallEndReason;
|
|
1607
|
-
}
|
|
1669
|
+
get: function () { return pluginCallEngine.RCCallEndReason; }
|
|
1608
1670
|
});
|
|
1609
1671
|
Object.defineProperty(exports, 'RCCallErrorCode', {
|
|
1610
1672
|
enumerable: true,
|
|
1611
|
-
get: function () {
|
|
1612
|
-
return pluginCallEngine.RCCallErrorCode;
|
|
1613
|
-
}
|
|
1673
|
+
get: function () { return pluginCallEngine.RCCallErrorCode; }
|
|
1614
1674
|
});
|
|
1615
1675
|
Object.defineProperty(exports, 'RCCallLanguage', {
|
|
1616
1676
|
enumerable: true,
|
|
1617
|
-
get: function () {
|
|
1618
|
-
return pluginCallEngine.RCCallLanguage;
|
|
1619
|
-
}
|
|
1677
|
+
get: function () { return pluginCallEngine.RCCallLanguage; }
|
|
1620
1678
|
});
|
|
1621
1679
|
Object.defineProperty(exports, 'RCCallMediaType', {
|
|
1622
1680
|
enumerable: true,
|
|
1623
|
-
get: function () {
|
|
1624
|
-
return pluginCallEngine.RCCallMediaType;
|
|
1625
|
-
}
|
|
1681
|
+
get: function () { return pluginCallEngine.RCCallMediaType; }
|
|
1626
1682
|
});
|
|
1627
1683
|
Object.defineProperty(exports, 'RCCallSessionState', {
|
|
1628
1684
|
enumerable: true,
|
|
1629
|
-
get: function () {
|
|
1630
|
-
return pluginCallEngine.RCCallSessionState;
|
|
1631
|
-
}
|
|
1685
|
+
get: function () { return pluginCallEngine.RCCallSessionState; }
|
|
1632
1686
|
});
|
|
1633
1687
|
Object.defineProperty(exports, 'RCCallUserState', {
|
|
1634
1688
|
enumerable: true,
|
|
1635
|
-
get: function () {
|
|
1636
|
-
return pluginCallEngine.RCCallUserState;
|
|
1637
|
-
}
|
|
1689
|
+
get: function () { return pluginCallEngine.RCCallUserState; }
|
|
1638
1690
|
});
|
|
1639
1691
|
exports.RCCallClient = RCCallClient;
|
|
1640
1692
|
exports.RCCallSession = RCCallSession;
|
|
@@ -1642,4 +1694,4 @@
|
|
|
1642
1694
|
|
|
1643
1695
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1644
1696
|
|
|
1645
|
-
}))
|
|
1697
|
+
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rongcloud/plugin-call",
|
|
3
|
-
"version": "5.0.1-alpha.
|
|
3
|
+
"version": "5.0.1-alpha.15",
|
|
4
4
|
"description": "@rongcloud/plugin-call",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"__attrs__": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@rongcloud/engine": "~4.5.0-alpha.1",
|
|
36
|
-
"@rongcloud/plugin-rtc": "
|
|
36
|
+
"@rongcloud/plugin-rtc": "5.1.10-alpha.1"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@rongcloud/plugin-call-engine": "~5.0.1-alpha.
|
|
39
|
+
"@rongcloud/plugin-call-engine": "~5.0.1-alpha.15"
|
|
40
40
|
},
|
|
41
|
-
"__commit__": "
|
|
41
|
+
"__commit__": "822cbe0e445807b91c775e9bc034fba931189ece"
|
|
42
42
|
}
|