@rongcloud/plugin-call 5.1.2-alpha.1 → 5.1.2-alpha.3
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/RCCallClient.d.ts +22 -9
- package/dist/RCCallSession.d.ts +5 -4
- package/dist/index.d.ts +50 -15
- package/dist/index.esm.js +163 -116
- package/dist/index.js +163 -116
- package/dist/index.umd.js +166 -119
- package/dist/interface.d.ts +21 -0
- package/dist/validation.d.ts +2 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* RCCall - v5.1.2-alpha.
|
|
3
|
-
* CommitId -
|
|
4
|
-
*
|
|
2
|
+
* RCCall - v5.1.2-alpha.3
|
|
3
|
+
* CommitId - 18608f24276587122c6fe1b54515d19aec29be0f
|
|
4
|
+
* Wed Mar 01 2023 21:12:56 GMT+0800 (China Standard Time)
|
|
5
5
|
* ©2020 RongCloud, Inc. All rights reserved.
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
10
10
|
|
|
11
|
-
var pluginCallEngine = require('@rongcloud/plugin-call-engine');
|
|
12
11
|
var engine = require('@rongcloud/engine');
|
|
12
|
+
var pluginCallEngine = require('@rongcloud/plugin-call-engine');
|
|
13
13
|
var pluginRtc = require('@rongcloud/plugin-rtc');
|
|
14
14
|
|
|
15
|
-
const logger = new engine.Logger('RCCall');
|
|
16
|
-
|
|
17
15
|
/*! *****************************************************************************
|
|
18
16
|
Copyright (c) Microsoft Corporation.
|
|
19
17
|
|
|
@@ -257,6 +255,13 @@ const validatePushContent = (pushContent) => {
|
|
|
257
255
|
return { result: false, msg: '\'pushContent\' parameter must be of type \'string\'' };
|
|
258
256
|
}
|
|
259
257
|
};
|
|
258
|
+
const validatePushConfig = (pushConfig) => {
|
|
259
|
+
const { pushTitle, pushContent } = pushConfig;
|
|
260
|
+
const conclusion = [];
|
|
261
|
+
pushTitle && conclusion.push(validatePushTitle(pushTitle));
|
|
262
|
+
pushContent && conclusion.push(validatePushContent(pushContent));
|
|
263
|
+
return conclusion;
|
|
264
|
+
};
|
|
260
265
|
const validateUserIds = (userIds) => {
|
|
261
266
|
if (!Array.isArray(userIds)) {
|
|
262
267
|
return { result: false, msg: '\'userIds\' parameter is required, must be of type \'string[]\'' };
|
|
@@ -350,13 +355,14 @@ class RCCallSession {
|
|
|
350
355
|
/**
|
|
351
356
|
* rtc实例
|
|
352
357
|
*/
|
|
353
|
-
_rtcClient,
|
|
358
|
+
_rtcClient, _logger,
|
|
354
359
|
/**
|
|
355
360
|
* session的其它选项
|
|
356
361
|
*/
|
|
357
362
|
_options = {}) {
|
|
358
363
|
this._stateMachine = _stateMachine;
|
|
359
364
|
this._rtcClient = _rtcClient;
|
|
365
|
+
this._logger = _logger;
|
|
360
366
|
this._options = _options;
|
|
361
367
|
/**
|
|
362
368
|
* 用户传进来的 对session的监听 (要在RCCallClient的_onInvite里判断,要求执行完onSession必须注册session的监听,所以这里是public)
|
|
@@ -377,7 +383,7 @@ class RCCallSession {
|
|
|
377
383
|
* @param info
|
|
378
384
|
*/
|
|
379
385
|
onUserStateChange: ({ user, reason }) => {
|
|
380
|
-
|
|
386
|
+
this._logger.info('_', `[RCCallSession onUserStateChange] userId->${user === null || user === void 0 ? void 0 : user.userId} state->${user === null || user === void 0 ? void 0 : user.state} reason->${reason}`);
|
|
381
387
|
},
|
|
382
388
|
/**
|
|
383
389
|
* 房间状态变更
|
|
@@ -385,18 +391,18 @@ class RCCallSession {
|
|
|
385
391
|
*/
|
|
386
392
|
onStateChange: (info) => __awaiter(this, void 0, void 0, function* () {
|
|
387
393
|
const { state, reason } = info;
|
|
388
|
-
|
|
394
|
+
this._logger.info('_', `[RCCallSession onStateChange] : state->${state} reason->${reason}`);
|
|
389
395
|
// 如果在通话中,就加房间
|
|
390
396
|
if (state === pluginCallEngine.RCCallSessionState.KEEPING) {
|
|
391
397
|
const roomId = this._stateMachine.getCallId();
|
|
392
|
-
|
|
398
|
+
this._logger.info('_', `[RCCallSession onStateChange] roomId: ${roomId}`);
|
|
393
399
|
try {
|
|
394
400
|
// 加房间
|
|
395
401
|
yield this._joinRoom(roomId);
|
|
396
402
|
}
|
|
397
403
|
catch (error) {
|
|
398
404
|
this._exceptionClose(pluginCallEngine.RCCallEndReason.NETWORK_ERROR);
|
|
399
|
-
|
|
405
|
+
this._logger.error('_', `[RCCallSession onStateChange] joinRoom throw exception roomId -> ${roomId}`);
|
|
400
406
|
console.error(error);
|
|
401
407
|
}
|
|
402
408
|
/**
|
|
@@ -416,7 +422,7 @@ class RCCallSession {
|
|
|
416
422
|
return;
|
|
417
423
|
}
|
|
418
424
|
this._options.localTracks && this._destroyTracks(this._options.localTracks);
|
|
419
|
-
|
|
425
|
+
this._logger.info('_', '[RCCallSession onStateChange] localTracks destroyed');
|
|
420
426
|
this._leaveRoom();
|
|
421
427
|
this._room = null;
|
|
422
428
|
}
|
|
@@ -426,13 +432,13 @@ class RCCallSession {
|
|
|
426
432
|
* @param sender 发起用户信息
|
|
427
433
|
*/
|
|
428
434
|
onRinging: (sender) => {
|
|
429
|
-
|
|
435
|
+
this._logger.info('_', `[RCCallSession onRinging]sender: sender.userId -> ${sender.userId}`);
|
|
430
436
|
try {
|
|
431
437
|
// 通知用户响铃
|
|
432
438
|
this._listener.onRinging(sender, this);
|
|
433
439
|
}
|
|
434
440
|
catch (error) {
|
|
435
|
-
|
|
441
|
+
this._logger.error('_', '[RCCallSession onRinging] method exception -> onRinging');
|
|
436
442
|
console.error(error);
|
|
437
443
|
}
|
|
438
444
|
},
|
|
@@ -440,13 +446,13 @@ class RCCallSession {
|
|
|
440
446
|
* 当远端用户同意接听
|
|
441
447
|
*/
|
|
442
448
|
onAccept: (sender) => {
|
|
443
|
-
|
|
449
|
+
this._logger.info('_', `[RCCallSession onAccept]sender: sender.userId -> ${sender.userId}`);
|
|
444
450
|
try {
|
|
445
451
|
// 通知本端,远端用户已接听
|
|
446
452
|
this._listener.onAccept(sender, this);
|
|
447
453
|
}
|
|
448
454
|
catch (error) {
|
|
449
|
-
|
|
455
|
+
this._logger.error('_', '[RCCallSession onAccept] method exception -> onAccept');
|
|
450
456
|
console.error(error);
|
|
451
457
|
}
|
|
452
458
|
},
|
|
@@ -454,13 +460,13 @@ class RCCallSession {
|
|
|
454
460
|
* 当有远端用户挂断
|
|
455
461
|
*/
|
|
456
462
|
onHungup: (sender, reason) => {
|
|
457
|
-
|
|
463
|
+
this._logger.info('_', `[RCCallSession onHungup]sender: sender.userId -> ${sender.userId} reason->${reason}`);
|
|
458
464
|
try {
|
|
459
465
|
// 通知本端,远端用户已挂断
|
|
460
466
|
this._listener.onHungup(sender, reason, this);
|
|
461
467
|
}
|
|
462
468
|
catch (error) {
|
|
463
|
-
|
|
469
|
+
this._logger.error('_', '[RCCallSession onHungup] method exception -> onHungup');
|
|
464
470
|
console.error(error);
|
|
465
471
|
}
|
|
466
472
|
},
|
|
@@ -469,13 +475,13 @@ class RCCallSession {
|
|
|
469
475
|
* @param sender 发起用户信息
|
|
470
476
|
*/
|
|
471
477
|
onMemberModify: ({ sender, invitedUsers }) => {
|
|
472
|
-
|
|
478
|
+
this._logger.info('_', `[RCCallSession onMemberModify] sender.userId -> ${sender.userId}`);
|
|
473
479
|
try {
|
|
474
480
|
// 通知用户人员变更
|
|
475
481
|
this._listener.onMemberModify(sender, invitedUsers, this);
|
|
476
482
|
}
|
|
477
483
|
catch (error) {
|
|
478
|
-
|
|
484
|
+
this._logger.error('_', '[RCCallSession onMemberModify] method exception -> onMemberModify');
|
|
479
485
|
console.error(error);
|
|
480
486
|
}
|
|
481
487
|
},
|
|
@@ -484,7 +490,7 @@ class RCCallSession {
|
|
|
484
490
|
* @param sender 发起用户信息
|
|
485
491
|
*/
|
|
486
492
|
onMediaModify: ({ sender, mediaType }) => {
|
|
487
|
-
|
|
493
|
+
this._logger.info('_', `[RCCallSession onMediaModify]sender: sender.userId -> ${sender.userId} mediaType: ${mediaType}`);
|
|
488
494
|
if (mediaType === pluginCallEngine.RCCallMediaType.AUDIO) {
|
|
489
495
|
// 远端收到通话降级通知后,远端执行降级通话(不发消息)
|
|
490
496
|
this._setMediaTypeToAudio();
|
|
@@ -493,7 +499,7 @@ class RCCallSession {
|
|
|
493
499
|
this._listener.onMediaModify(sender, mediaType, this);
|
|
494
500
|
}
|
|
495
501
|
catch (error) {
|
|
496
|
-
|
|
502
|
+
this._logger.error('_', '[RCCallSession onMediaModify] method exception -> onMediaModify');
|
|
497
503
|
console.error(error);
|
|
498
504
|
}
|
|
499
505
|
},
|
|
@@ -502,10 +508,15 @@ class RCCallSession {
|
|
|
502
508
|
* @param sender 发起用户信息
|
|
503
509
|
*/
|
|
504
510
|
crossAppkey: (isCrossAppkey) => {
|
|
505
|
-
|
|
511
|
+
this._logger.info('_', `[RCCallSession crossAppkey] 是否跨 appkey: ${isCrossAppkey}`);
|
|
506
512
|
this._options.isCrossAppkey = isCrossAppkey;
|
|
507
513
|
}
|
|
508
514
|
});
|
|
515
|
+
/**
|
|
516
|
+
* 设置挂断的推送信息
|
|
517
|
+
*/
|
|
518
|
+
const { pushTitle, pushContent } = this._options.hungupPushConfig;
|
|
519
|
+
this._stateMachine.setHungupPushConfig(pushTitle, pushContent);
|
|
509
520
|
}
|
|
510
521
|
/**
|
|
511
522
|
* 加入房间
|
|
@@ -534,7 +545,7 @@ class RCCallSession {
|
|
|
534
545
|
else {
|
|
535
546
|
this._exceptionClose(pluginCallEngine.RCCallEndReason.NETWORK_ERROR);
|
|
536
547
|
}
|
|
537
|
-
|
|
548
|
+
this._logger.info('_', `[RCCallClient _joinRoom] join room failed: roomId -> ${roomId} RCRTCCode -> ${code}`);
|
|
538
549
|
return { code: pluginCallEngine.RCCallErrorCode.JOIN_ROOM_ERROR };
|
|
539
550
|
}
|
|
540
551
|
/**
|
|
@@ -557,7 +568,7 @@ class RCCallSession {
|
|
|
557
568
|
}
|
|
558
569
|
catch (error) {
|
|
559
570
|
this._exceptionClose(pluginCallEngine.RCCallEndReason.NETWORK_ERROR);
|
|
560
|
-
|
|
571
|
+
this._logger.error('_', `[RCCallSession _joinRoom] _rtcClient.joinRTCRoom throw exception roomId -> ${roomId}`);
|
|
561
572
|
console.error(error);
|
|
562
573
|
return { code: pluginCallEngine.RCCallErrorCode.JOIN_ROOM_ERROR };
|
|
563
574
|
}
|
|
@@ -572,7 +583,7 @@ class RCCallSession {
|
|
|
572
583
|
catch (error) {
|
|
573
584
|
// 结束通话session
|
|
574
585
|
this._exceptionClose(pluginCallEngine.RCCallEndReason.SUBSCRIBE_ERROR);
|
|
575
|
-
|
|
586
|
+
this._logger.error('_', `[RCCallSession _joinRoom] _subscribeInRoomRemoteTrack Exception roomId -> ${roomId}`);
|
|
576
587
|
console.error(error);
|
|
577
588
|
return { code: pluginCallEngine.RCCallErrorCode.JOIN_ROOM_ERROR };
|
|
578
589
|
}
|
|
@@ -583,7 +594,7 @@ class RCCallSession {
|
|
|
583
594
|
catch (error) {
|
|
584
595
|
// 结束通话session
|
|
585
596
|
this._exceptionClose(pluginCallEngine.RCCallEndReason.PUBLISH_ERROR);
|
|
586
|
-
|
|
597
|
+
this._logger.error('_', `[RCCallSession _joinRoom] _publish Exception roomId -> ${roomId}`);
|
|
587
598
|
console.error(error);
|
|
588
599
|
return { code: pluginCallEngine.RCCallErrorCode.JOIN_ROOM_ERROR };
|
|
589
600
|
}
|
|
@@ -601,7 +612,7 @@ class RCCallSession {
|
|
|
601
612
|
const { code } = yield this._subscribeRetry(tracks, this._options.isAllowSubscribeRetry, this._RETRYCOUNT);
|
|
602
613
|
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
603
614
|
this._exceptionClose(pluginCallEngine.RCCallEndReason.SUBSCRIBE_ERROR);
|
|
604
|
-
|
|
615
|
+
this._logger.error('_', `[RCCallSession _subscribeInRoomRemoteTrack] Resource subscription failed roomId -> ${this._stateMachine.getCallId()} RTC code -> ${code}`);
|
|
605
616
|
}
|
|
606
617
|
}
|
|
607
618
|
});
|
|
@@ -620,7 +631,7 @@ class RCCallSession {
|
|
|
620
631
|
this._listener.onTrackSubscribeFail && this._listener.onTrackSubscribeFail(code, this);
|
|
621
632
|
}
|
|
622
633
|
catch (error) {
|
|
623
|
-
|
|
634
|
+
this._logger.error('_', '[RCCallSession] _listener.onTrackSubscribeFail exception');
|
|
624
635
|
console.error(error);
|
|
625
636
|
}
|
|
626
637
|
// 如果不允许重试,直接返回
|
|
@@ -646,7 +657,7 @@ class RCCallSession {
|
|
|
646
657
|
// 若资源发布失败
|
|
647
658
|
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
648
659
|
this._exceptionClose(pluginCallEngine.RCCallEndReason.PUBLISH_ERROR);
|
|
649
|
-
|
|
660
|
+
this._logger.info('_', `[RCCallSession _publist] Resource publishing failed: roomId -> ${this._stateMachine.getCallId()} RCRTCCode -> ${code}`);
|
|
650
661
|
return;
|
|
651
662
|
}
|
|
652
663
|
// 如果是主动发起的呼叫,已提前抛出了资源, 被动呼叫,这里才需要抛出
|
|
@@ -670,7 +681,7 @@ class RCCallSession {
|
|
|
670
681
|
this._listener.onTrackPublishFail && this._listener.onTrackPublishFail(code, this);
|
|
671
682
|
}
|
|
672
683
|
catch (error) {
|
|
673
|
-
|
|
684
|
+
this._logger.error('_', '[RCCallSession] _listener.onTrackPublishFail exception');
|
|
674
685
|
console.error(error);
|
|
675
686
|
}
|
|
676
687
|
// 如果不允许重试,直接返回
|
|
@@ -694,10 +705,10 @@ class RCCallSession {
|
|
|
694
705
|
// 退出房间
|
|
695
706
|
const callBack = yield this._rtcClient.leaveRoom(this._room);
|
|
696
707
|
// 成功退出房间,触发RCCallClient实例上的onSessionClose监听,抛给用户信息
|
|
697
|
-
|
|
708
|
+
this._logger.info('_', `[RCCallSession _leaveRoom] Successfully exited the room code: ${callBack.code}`);
|
|
698
709
|
}
|
|
699
710
|
catch (error) {
|
|
700
|
-
|
|
711
|
+
this._logger.error('_', '[RCCallSession _leaveRoom] leaveRoom throw exception');
|
|
701
712
|
console.error(error);
|
|
702
713
|
}
|
|
703
714
|
finally {
|
|
@@ -736,19 +747,19 @@ class RCCallSession {
|
|
|
736
747
|
if (mediaType === pluginCallEngine.RCCallMediaType.AUDIO) {
|
|
737
748
|
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && constraints.audio && Object.assign({}, constraints.audio));
|
|
738
749
|
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
739
|
-
|
|
750
|
+
this._logger.error('_', `[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ${code}`);
|
|
740
751
|
return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
|
|
741
752
|
}
|
|
742
|
-
|
|
753
|
+
this._logger.info('_', '[RCCallSession _getLocalTrackCore] successfully get Audio local tracks');
|
|
743
754
|
return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, tracks: [track] };
|
|
744
755
|
}
|
|
745
756
|
else {
|
|
746
757
|
const { code, tracks } = yield this._rtcClient.createMicrophoneAndCameraTracks('RongCloudRTC', constraints && Object.assign({}, constraints));
|
|
747
758
|
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
748
|
-
|
|
759
|
+
this._logger.error('_', `[RCCallSession _getLocalTrackCore] get Audio and Video local tracks failed RCT code -> ${code}`);
|
|
749
760
|
return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR };
|
|
750
761
|
}
|
|
751
|
-
|
|
762
|
+
this._logger.info('_', '[RCCallSession _getLocalTrackCore] successfully get audio and video local tracks');
|
|
752
763
|
return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, tracks };
|
|
753
764
|
}
|
|
754
765
|
});
|
|
@@ -792,7 +803,7 @@ class RCCallSession {
|
|
|
792
803
|
const localTracks = [];
|
|
793
804
|
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', audioConstraints);
|
|
794
805
|
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
795
|
-
|
|
806
|
+
this._logger.error('_', `[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ${code}`);
|
|
796
807
|
return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
|
|
797
808
|
}
|
|
798
809
|
this._options.localTracks && this._options.localTracks.forEach((track) => {
|
|
@@ -823,12 +834,14 @@ class RCCallSession {
|
|
|
823
834
|
* 群呼叫中继续邀请
|
|
824
835
|
* @param userIds 被邀请用户 ID 列表
|
|
825
836
|
* @param options.extra 消息的扩展信息
|
|
826
|
-
* @
|
|
827
|
-
* @
|
|
837
|
+
* @deprecated 5.1.2 废弃 options.pushTitle 通知的标题
|
|
838
|
+
* @deprecated 5.1.2 废弃 options.pushContent 通知内容
|
|
828
839
|
*/
|
|
829
840
|
invite(userIds, options = {}) {
|
|
841
|
+
var _a, _b;
|
|
830
842
|
return __awaiter(this, void 0, void 0, function* () {
|
|
831
|
-
const { extra = ''
|
|
843
|
+
const { extra = '' } = options;
|
|
844
|
+
const { pushTitle = '', pushContent = '' } = (((_a = this._options.callPushConfig) === null || _a === void 0 ? void 0 : _a.pushTitle) || ((_b = this._options.callPushConfig) === null || _b === void 0 ? void 0 : _b.pushContent)) ? this._options.callPushConfig : options;
|
|
832
845
|
const conclusion = [validateUserIds(userIds), validateExtra(extra), validatePushTitle(pushTitle), validatePushContent(pushContent)];
|
|
833
846
|
const messages = [];
|
|
834
847
|
const result = conclusion.every((obj) => {
|
|
@@ -862,7 +875,7 @@ class RCCallSession {
|
|
|
862
875
|
// 发送接听的消息
|
|
863
876
|
const { code } = yield this._stateMachine.accept();
|
|
864
877
|
if (code !== pluginCallEngine.RCCallErrorCode.SUCCESS) {
|
|
865
|
-
|
|
878
|
+
this._logger.error('_', `[RCCallSession accept]Send accept message failed -> code: ${code}`);
|
|
866
879
|
return { code };
|
|
867
880
|
}
|
|
868
881
|
return { code };
|
|
@@ -886,7 +899,7 @@ class RCCallSession {
|
|
|
886
899
|
return __awaiter(this, void 0, void 0, function* () {
|
|
887
900
|
const { code } = yield this._stateMachine.changeMediaType(mediaType);
|
|
888
901
|
if (code !== pluginCallEngine.RCCallErrorCode.SUCCESS) {
|
|
889
|
-
|
|
902
|
+
this._logger.error('_', `[RCCallSession _changeMediaType] change media type fail code-> ${code}`);
|
|
890
903
|
}
|
|
891
904
|
return { code };
|
|
892
905
|
});
|
|
@@ -935,7 +948,7 @@ class RCCallSession {
|
|
|
935
948
|
const { code: _code } = yield this._room.publish([track]);
|
|
936
949
|
// 若资源发布失败
|
|
937
950
|
if (_code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
938
|
-
|
|
951
|
+
this._logger.error('_', `[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ${code}`);
|
|
939
952
|
return;
|
|
940
953
|
}
|
|
941
954
|
// 通知业务层trackReady
|
|
@@ -959,7 +972,7 @@ class RCCallSession {
|
|
|
959
972
|
// 取消发布视频
|
|
960
973
|
const { code } = yield this._room.unpublish(tracks);
|
|
961
974
|
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
962
|
-
|
|
975
|
+
this._logger.error('_', `[RCCallSession disableVideo] unpublish failed -> ${code}`);
|
|
963
976
|
}
|
|
964
977
|
// 关闭摄像头
|
|
965
978
|
this._destroyTracks(tracks);
|
|
@@ -985,12 +998,12 @@ class RCCallSession {
|
|
|
985
998
|
disableVideoTrack() {
|
|
986
999
|
return __awaiter(this, void 0, void 0, function* () {
|
|
987
1000
|
if (!this._room) {
|
|
988
|
-
|
|
1001
|
+
this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
|
|
989
1002
|
return { code: pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR };
|
|
990
1003
|
}
|
|
991
1004
|
const tracks = this._getLocalVideoTracks();
|
|
992
1005
|
if (!tracks.length) {
|
|
993
|
-
|
|
1006
|
+
this._logger.error('_', `[RCCallSession disableVideoTrack] Room missing video track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
|
|
994
1007
|
return { code: pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR };
|
|
995
1008
|
}
|
|
996
1009
|
// 禁用视频
|
|
@@ -1004,7 +1017,7 @@ class RCCallSession {
|
|
|
1004
1017
|
// 取消发布视频
|
|
1005
1018
|
const { code } = yield this._room.unpublish(tracks);
|
|
1006
1019
|
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
1007
|
-
|
|
1020
|
+
this._logger.error('_', `[RCCallSession disableVideo] unpublish failed -> ${code}`);
|
|
1008
1021
|
return { code: pluginCallEngine.RCCallErrorCode.UNPUBLISH_VIDEO_ERROR };
|
|
1009
1022
|
}
|
|
1010
1023
|
tracks.forEach((track) => {
|
|
@@ -1020,14 +1033,14 @@ class RCCallSession {
|
|
|
1020
1033
|
enableVideoTrack() {
|
|
1021
1034
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1022
1035
|
if (!this._room) {
|
|
1023
|
-
|
|
1036
|
+
this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
|
|
1024
1037
|
return { code: pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR };
|
|
1025
1038
|
}
|
|
1026
1039
|
// 如果不需关闭摄像头
|
|
1027
1040
|
if (!this._options.isOffCameraWhenVideoDisable) {
|
|
1028
1041
|
const tracks = this._getLocalVideoTracks();
|
|
1029
1042
|
if (!tracks.length) {
|
|
1030
|
-
|
|
1043
|
+
this._logger.error('_', `[RCCallSession EnableVideoTrack] Room missing video track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
|
|
1031
1044
|
return { code: pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR };
|
|
1032
1045
|
}
|
|
1033
1046
|
// 启用视频
|
|
@@ -1039,7 +1052,7 @@ class RCCallSession {
|
|
|
1039
1052
|
// 获得本端视频资源
|
|
1040
1053
|
const { code, track } = yield this._rtcClient.createCameraVideoTrack();
|
|
1041
1054
|
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
1042
|
-
|
|
1055
|
+
this._logger.error('_', `[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ${code}`);
|
|
1043
1056
|
return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR };
|
|
1044
1057
|
}
|
|
1045
1058
|
const localTracks = [];
|
|
@@ -1062,7 +1075,7 @@ class RCCallSession {
|
|
|
1062
1075
|
const { code: _code } = yield this._room.publish([track]);
|
|
1063
1076
|
// 若资源发布失败
|
|
1064
1077
|
if (_code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
1065
|
-
|
|
1078
|
+
this._logger.error('_', `[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ${code}`);
|
|
1066
1079
|
return { code: pluginCallEngine.RCCallErrorCode.VIDEO_PUBLISH_ERROR };
|
|
1067
1080
|
}
|
|
1068
1081
|
// 启用
|
|
@@ -1078,7 +1091,7 @@ class RCCallSession {
|
|
|
1078
1091
|
disableAudioTrack() {
|
|
1079
1092
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1080
1093
|
if (!this._room) {
|
|
1081
|
-
|
|
1094
|
+
this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
|
|
1082
1095
|
return { code: pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR };
|
|
1083
1096
|
}
|
|
1084
1097
|
const tracks = this._getLocalAudioTracks();
|
|
@@ -1094,12 +1107,12 @@ class RCCallSession {
|
|
|
1094
1107
|
enableAudioTrack() {
|
|
1095
1108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1096
1109
|
if (!this._room) {
|
|
1097
|
-
|
|
1110
|
+
this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
|
|
1098
1111
|
return { code: pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR };
|
|
1099
1112
|
}
|
|
1100
1113
|
const tracks = this._getLocalAudioTracks();
|
|
1101
1114
|
if (!tracks.length) {
|
|
1102
|
-
|
|
1115
|
+
this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
|
|
1103
1116
|
return { code: pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR };
|
|
1104
1117
|
}
|
|
1105
1118
|
// 启用音频
|
|
@@ -1125,7 +1138,7 @@ class RCCallSession {
|
|
|
1125
1138
|
this._listener.onTrackReady(track, this);
|
|
1126
1139
|
}
|
|
1127
1140
|
catch (error) {
|
|
1128
|
-
|
|
1141
|
+
this._logger.error('_', '[RCCallSession _notifyTrackReady] _listener onTrackReady exception');
|
|
1129
1142
|
console.error(error);
|
|
1130
1143
|
}
|
|
1131
1144
|
});
|
|
@@ -1179,7 +1192,7 @@ class RCCallSession {
|
|
|
1179
1192
|
* @param audioTrack RCRemoteAudioTrack 类实例
|
|
1180
1193
|
*/
|
|
1181
1194
|
onAudioMuteChange: (audioTrack) => {
|
|
1182
|
-
|
|
1195
|
+
this._logger.info('_', `[RCCallSession onAudioMuteChange] userId->${audioTrack.getUserId()} muted -> ${audioTrack.isOwnerMuted()}`);
|
|
1183
1196
|
const muteUser = {
|
|
1184
1197
|
userId: audioTrack.getUserId(),
|
|
1185
1198
|
muted: audioTrack.isOwnerMuted(),
|
|
@@ -1191,7 +1204,7 @@ class RCCallSession {
|
|
|
1191
1204
|
this._listener.onAudioMuteChange(muteUser, this);
|
|
1192
1205
|
}
|
|
1193
1206
|
catch (error) {
|
|
1194
|
-
|
|
1207
|
+
this._logger.error('_', '[RCCallSession onAudioMuteChange] Missing listening method -> onTrackMuteChange');
|
|
1195
1208
|
console.error(error);
|
|
1196
1209
|
}
|
|
1197
1210
|
},
|
|
@@ -1200,7 +1213,7 @@ class RCCallSession {
|
|
|
1200
1213
|
* @param videoTrack RCRemoteVideoTrack 类实例对象
|
|
1201
1214
|
*/
|
|
1202
1215
|
onVideoMuteChange: (videoTrack) => {
|
|
1203
|
-
|
|
1216
|
+
this._logger.info('_', `[RCCallSession onVideoMuteChange]userId->${videoTrack.getUserId()} muted -> ${videoTrack.isOwnerMuted()}`);
|
|
1204
1217
|
const muteUser = {
|
|
1205
1218
|
userId: videoTrack.getUserId(),
|
|
1206
1219
|
muted: videoTrack.isOwnerMuted(),
|
|
@@ -1212,7 +1225,7 @@ class RCCallSession {
|
|
|
1212
1225
|
this._listener.onVideoMuteChange(muteUser, this);
|
|
1213
1226
|
}
|
|
1214
1227
|
catch (error) {
|
|
1215
|
-
|
|
1228
|
+
this._logger.error('_', '[RCCallSession onVideoMuteChange] Missing listening method -> onVideoMuteChange');
|
|
1216
1229
|
console.error(error);
|
|
1217
1230
|
}
|
|
1218
1231
|
},
|
|
@@ -1227,7 +1240,7 @@ class RCCallSession {
|
|
|
1227
1240
|
// 按业务需求选择需要订阅资源,通过 room.subscribe 接口进行订阅
|
|
1228
1241
|
const { code } = yield this._room.subscribe(tracks);
|
|
1229
1242
|
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
1230
|
-
|
|
1243
|
+
this._logger.error('_', `[RCCallSession onTrackPublish] subscribe failed RTCCode ->${code}`);
|
|
1231
1244
|
}
|
|
1232
1245
|
}
|
|
1233
1246
|
}),
|
|
@@ -1267,20 +1280,20 @@ class RCCallSession {
|
|
|
1267
1280
|
* @param userIds
|
|
1268
1281
|
*/
|
|
1269
1282
|
onUserLeave: (userIds) => {
|
|
1270
|
-
|
|
1283
|
+
this._logger.info('_', `[RCCallSession onUserLeave] listening onUserLeave userIds -> ${userIds === null || userIds === void 0 ? void 0 : userIds.join(',')}`);
|
|
1271
1284
|
this._stateMachine.userLeave(userIds);
|
|
1272
1285
|
},
|
|
1273
1286
|
/**
|
|
1274
1287
|
* RTC 每次 Ping 结果
|
|
1275
1288
|
*/
|
|
1276
1289
|
onPing: (result) => {
|
|
1277
|
-
|
|
1290
|
+
this._logger.info('_', `[RCCallSession onPing]${result}`);
|
|
1278
1291
|
try {
|
|
1279
1292
|
// 通知给业务
|
|
1280
1293
|
this._listener.onPing && this._listener.onPing(result, this);
|
|
1281
1294
|
}
|
|
1282
1295
|
catch (error) {
|
|
1283
|
-
|
|
1296
|
+
this._logger.error('_', '[RCCallSession onPing] listening onPing exception');
|
|
1284
1297
|
console.error(error);
|
|
1285
1298
|
}
|
|
1286
1299
|
}
|
|
@@ -1301,7 +1314,7 @@ class RCCallSession {
|
|
|
1301
1314
|
this._listener.onRTCStateReport && this._listener.onRTCStateReport(report, this);
|
|
1302
1315
|
}
|
|
1303
1316
|
catch (error) {
|
|
1304
|
-
|
|
1317
|
+
this._logger.error('_', '[RCCallSession onStateReport] listener onStateReport exception');
|
|
1305
1318
|
console.error(error);
|
|
1306
1319
|
}
|
|
1307
1320
|
},
|
|
@@ -1314,7 +1327,7 @@ class RCCallSession {
|
|
|
1314
1327
|
this._listener.onICEConnectionStateChange && this._listener.onICEConnectionStateChange(state, this);
|
|
1315
1328
|
}
|
|
1316
1329
|
catch (error) {
|
|
1317
|
-
|
|
1330
|
+
this._logger.error('_', '[RCCallSession onICEConnectionStateChange] onICEConnectionStateChange exception');
|
|
1318
1331
|
console.error(error);
|
|
1319
1332
|
}
|
|
1320
1333
|
}
|
|
@@ -1391,20 +1404,17 @@ class RCCallSession {
|
|
|
1391
1404
|
}
|
|
1392
1405
|
}
|
|
1393
1406
|
|
|
1394
|
-
// plugin-call 版本上报
|
|
1395
|
-
engine.VersionManage.add('plugin-call', "5.1.2-alpha.1");
|
|
1396
|
-
// 校验当前安装的 engine 版本是否可用
|
|
1397
|
-
if (!engine.VersionManage.validEngine("^5.5.4")) {
|
|
1398
|
-
logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error,plugin-call required engine version at least '${"^5.5.4"}'.`);
|
|
1399
|
-
}
|
|
1400
1407
|
class RCCallClient {
|
|
1401
|
-
constructor(_context, _runtime, _options) {
|
|
1408
|
+
constructor(_context, _runtime, _logger, _options) {
|
|
1402
1409
|
this._context = _context;
|
|
1403
1410
|
this._runtime = _runtime;
|
|
1411
|
+
this._logger = _logger;
|
|
1404
1412
|
/**
|
|
1405
1413
|
* session列表
|
|
1406
1414
|
*/
|
|
1407
1415
|
this._sessionList = [];
|
|
1416
|
+
this._callPushConfig = {};
|
|
1417
|
+
this._hungupPushConfig = {};
|
|
1408
1418
|
this._rtcClient = _options.rtcClient;
|
|
1409
1419
|
this._options = Object.assign({
|
|
1410
1420
|
/**
|
|
@@ -1436,7 +1446,7 @@ class RCCallClient {
|
|
|
1436
1446
|
lang: pluginCallEngine.RCCallLanguage.ZH
|
|
1437
1447
|
}, _options);
|
|
1438
1448
|
// 初始化callEngine, 并监听onInvite
|
|
1439
|
-
this._callEngine = new pluginCallEngine.RCCallEngine(this._context, _runtime,
|
|
1449
|
+
this._callEngine = new pluginCallEngine.RCCallEngine(this._context, _runtime, this._logger, {
|
|
1440
1450
|
/**
|
|
1441
1451
|
* 监听收到invite
|
|
1442
1452
|
*/
|
|
@@ -1458,15 +1468,15 @@ class RCCallClient {
|
|
|
1458
1468
|
this._options.onSessionClose(session, summaryInfo);
|
|
1459
1469
|
}
|
|
1460
1470
|
catch (error) {
|
|
1461
|
-
|
|
1471
|
+
this._logger.error('_', '[RCCCallClient] options.onSessionClose exception');
|
|
1462
1472
|
console.log(error);
|
|
1463
1473
|
}
|
|
1464
1474
|
});
|
|
1465
1475
|
// 接听之前挂断其它的session
|
|
1466
1476
|
eventEmitter.on('hungupOtherSession', ({ session }) => {
|
|
1467
1477
|
const id = session.getSessionId();
|
|
1468
|
-
|
|
1469
|
-
|
|
1478
|
+
this._logger.info('_', `[RCCallClient hungupOtherSession] sessionId ready to accept -> ${id}`);
|
|
1479
|
+
this._logger.info('_', `[RCCallClient hungupOtherSession] sessionList ->${this._sessionList.map(ses => ses.getSessionId()).join(',')}`);
|
|
1470
1480
|
let i = 0;
|
|
1471
1481
|
while (this._sessionList.length > 1) {
|
|
1472
1482
|
// 如果与要接听的session不一致
|
|
@@ -1481,15 +1491,15 @@ class RCCallClient {
|
|
|
1481
1491
|
i++;
|
|
1482
1492
|
}
|
|
1483
1493
|
}
|
|
1484
|
-
|
|
1494
|
+
this._logger.info('_', `[RCCallClient hungupOtherSession] current sessionList length ->${this._sessionList.length}`);
|
|
1485
1495
|
});
|
|
1486
1496
|
}
|
|
1487
1497
|
/**
|
|
1488
1498
|
* 监听onInvite
|
|
1489
1499
|
*/
|
|
1490
1500
|
_onInvite(stateMachine, extra) {
|
|
1491
|
-
|
|
1492
|
-
const session = new RCCallSession(stateMachine, this._rtcClient, {
|
|
1501
|
+
this._logger.info('_', '[RCCallClient _onInvite] Received invite message');
|
|
1502
|
+
const session = new RCCallSession(stateMachine, this._rtcClient, this._logger, {
|
|
1493
1503
|
// 是否允许订阅重试
|
|
1494
1504
|
isAllowSubscribeRetry: this._options.isAllowSubscribeRetry,
|
|
1495
1505
|
// 是否允许发布重试
|
|
@@ -1505,9 +1515,11 @@ class RCCallClient {
|
|
|
1505
1515
|
// 允许降级获得流,获得音视频不成功 ,降级获得音频, 默认不允许
|
|
1506
1516
|
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
|
|
1507
1517
|
// 标明是被叫产生的session
|
|
1508
|
-
produceType: ProduceTypes.CALLEE
|
|
1518
|
+
produceType: ProduceTypes.CALLEE,
|
|
1519
|
+
callPushConfig: this._callPushConfig,
|
|
1520
|
+
hungupPushConfig: this._hungupPushConfig
|
|
1509
1521
|
});
|
|
1510
|
-
|
|
1522
|
+
this._logger.info('_', '[RCCallClient _onInvite] Received invite message, successfully created session');
|
|
1511
1523
|
/**
|
|
1512
1524
|
* 如果通话的时候不允许接听新的通话,直接挂断, 这些工作在callEngine里完成
|
|
1513
1525
|
*/
|
|
@@ -1517,7 +1529,7 @@ class RCCallClient {
|
|
|
1517
1529
|
this._options.onSession(session, extra);
|
|
1518
1530
|
}
|
|
1519
1531
|
catch (error) {
|
|
1520
|
-
|
|
1532
|
+
this._logger.error('_', '[RCCallClient _options.onSession] onSession exception');
|
|
1521
1533
|
console.log(error);
|
|
1522
1534
|
}
|
|
1523
1535
|
// 必须在onSession里注册session监听事件,这里检测一下有没有注册
|
|
@@ -1528,7 +1540,7 @@ class RCCallClient {
|
|
|
1528
1540
|
}
|
|
1529
1541
|
}
|
|
1530
1542
|
else {
|
|
1531
|
-
|
|
1543
|
+
this._logger.error('_', '[RCCallClient _options.onSession] session Must Have Listener');
|
|
1532
1544
|
throw new Error('[RCCallSession _options.onSession] session Must Have Listener');
|
|
1533
1545
|
}
|
|
1534
1546
|
}
|
|
@@ -1542,7 +1554,7 @@ class RCCallClient {
|
|
|
1542
1554
|
this._options.onOfflineRecord && this._options.onOfflineRecord(record);
|
|
1543
1555
|
}
|
|
1544
1556
|
catch (error) {
|
|
1545
|
-
|
|
1557
|
+
this._logger.error('_', '[RCCallClient _options.onOfflineRecord] onOfflineRecord exception');
|
|
1546
1558
|
console.log(error);
|
|
1547
1559
|
}
|
|
1548
1560
|
}
|
|
@@ -1554,7 +1566,7 @@ class RCCallClient {
|
|
|
1554
1566
|
*/
|
|
1555
1567
|
registerUserInfo(info = {}) {
|
|
1556
1568
|
this._callEngine.registerUserInfo(info);
|
|
1557
|
-
|
|
1569
|
+
this._logger.info('_', '[RCCallClient registerUserInfo] successfully register user info data');
|
|
1558
1570
|
}
|
|
1559
1571
|
/**
|
|
1560
1572
|
* 跨App单呼,发送invite消息,回调回来接收stateMachine, 建session
|
|
@@ -1564,8 +1576,8 @@ class RCCallClient {
|
|
|
1564
1576
|
* @param params.constraints 获取音频或音视频资源时的参数 可选
|
|
1565
1577
|
* @param params.channelId 组织 Id 可选
|
|
1566
1578
|
* @param params.extra 消息扩展信息
|
|
1567
|
-
* @
|
|
1568
|
-
* @
|
|
1579
|
+
* @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
|
|
1580
|
+
* @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
|
|
1569
1581
|
* @param params.bitrate 需要设置的码率参数
|
|
1570
1582
|
*
|
|
1571
1583
|
*/
|
|
@@ -1582,8 +1594,8 @@ class RCCallClient {
|
|
|
1582
1594
|
* @param params.constraints 获取音频或音视频资源时的参数 可选
|
|
1583
1595
|
* @param params.channelId 组织 Id 可选
|
|
1584
1596
|
* @param params.extra 消息扩展信息
|
|
1585
|
-
* @
|
|
1586
|
-
* @
|
|
1597
|
+
* @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
|
|
1598
|
+
* @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
|
|
1587
1599
|
* @param params.bitrate 需要设置的码率参数
|
|
1588
1600
|
*
|
|
1589
1601
|
*/
|
|
@@ -1594,8 +1606,9 @@ class RCCallClient {
|
|
|
1594
1606
|
}
|
|
1595
1607
|
__call({ targetId, mediaType = pluginCallEngine.RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', pushTitle = '', pushContent = '', bitrate, isCrossAppkey = false }) {
|
|
1596
1608
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1597
|
-
|
|
1598
|
-
|
|
1609
|
+
const { pushTitle: pushTitleValue = '', pushContent: pushContentValue = '' } = (this._callPushConfig.pushTitle || this._callPushConfig.pushContent) ? this._callPushConfig : { pushTitle, pushContent };
|
|
1610
|
+
this._logger.info('_', `[RCCallClient call] extra->${extra} pushTitle->${pushTitleValue} pushContent->${pushContentValue}`);
|
|
1611
|
+
const conclusion = [validateTargetId(targetId), validateMediaType(mediaType), validateListener(listener), validateExtra(extra), validatePushTitle(pushTitleValue), validatePushContent(pushContentValue)];
|
|
1599
1612
|
const messages = [];
|
|
1600
1613
|
const result = conclusion.every((obj) => {
|
|
1601
1614
|
!obj.result && messages.push(obj.msg);
|
|
@@ -1623,10 +1636,10 @@ class RCCallClient {
|
|
|
1623
1636
|
listener.onTrackReady(track);
|
|
1624
1637
|
});
|
|
1625
1638
|
// 调用callEngine的call返回一个状态机的实例
|
|
1626
|
-
const { code, stateMachine } = yield this._callEngine.call(channelId, targetId, mediaType, extra,
|
|
1639
|
+
const { code, stateMachine } = yield this._callEngine.call(channelId, targetId, mediaType, extra, pushTitleValue, pushContentValue, isCrossAppkey);
|
|
1627
1640
|
if (code === pluginCallEngine.RCCallErrorCode.SUCCESS && stateMachine) {
|
|
1628
|
-
|
|
1629
|
-
const session = new RCCallSession(stateMachine, this._rtcClient, {
|
|
1641
|
+
this._logger.info('_', '[RCCallClient call] successfully created state machine');
|
|
1642
|
+
const session = new RCCallSession(stateMachine, this._rtcClient, this._logger, {
|
|
1630
1643
|
localTracks,
|
|
1631
1644
|
// 是否允许订阅重试
|
|
1632
1645
|
isAllowSubscribeRetry: this._options.isAllowSubscribeRetry,
|
|
@@ -1644,16 +1657,18 @@ class RCCallClient {
|
|
|
1644
1657
|
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
|
|
1645
1658
|
// 标明是主叫产生的session
|
|
1646
1659
|
produceType: ProduceTypes.CALLER,
|
|
1647
|
-
isCrossAppkey
|
|
1660
|
+
isCrossAppkey,
|
|
1661
|
+
callPushConfig: this._callPushConfig,
|
|
1662
|
+
hungupPushConfig: this._hungupPushConfig
|
|
1648
1663
|
});
|
|
1649
1664
|
// session上注册监听事件
|
|
1650
1665
|
session.registerSessionListener(listener);
|
|
1651
1666
|
this._sessionList.push(session);
|
|
1652
|
-
|
|
1667
|
+
this._logger.info('_', `[RCCallClient call] successfully created session object, sessionId: ${session.getSessionId()}`);
|
|
1653
1668
|
return { code, session };
|
|
1654
1669
|
}
|
|
1655
1670
|
else {
|
|
1656
|
-
|
|
1671
|
+
this._logger.error('_', `[RCCallClient call] call failed code ->: ${code}`);
|
|
1657
1672
|
localTracks.forEach(track => {
|
|
1658
1673
|
// 禁用视频
|
|
1659
1674
|
track.mute();
|
|
@@ -1673,13 +1688,14 @@ class RCCallClient {
|
|
|
1673
1688
|
* @param params.constraints 获取音频或音视频资源时的参数 可选
|
|
1674
1689
|
* @param params.channelId 组织 Id 可选
|
|
1675
1690
|
* @param params.extra 消息扩展信息 可选
|
|
1676
|
-
* @
|
|
1677
|
-
* @
|
|
1691
|
+
* @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
|
|
1692
|
+
* @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
|
|
1678
1693
|
* @param params.bitrate 需要设置的码率参数
|
|
1679
1694
|
*/
|
|
1680
1695
|
callInGroup({ targetId, userIds, mediaType = pluginCallEngine.RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', pushTitle = '', pushContent = '', bitrate }) {
|
|
1681
1696
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1682
|
-
const
|
|
1697
|
+
const { pushTitle: pushTitleValue = '', pushContent: pushContentValue = '' } = (this._callPushConfig.pushTitle || this._callPushConfig.pushContent) ? this._callPushConfig : { pushTitle, pushContent };
|
|
1698
|
+
const conclusion = [validateTargetId(targetId), validateUserIds(userIds), validateMediaType(mediaType), validateListener(listener), validateExtra(extra), validatePushTitle(pushTitleValue), validatePushContent(pushContentValue)];
|
|
1683
1699
|
const messages = [];
|
|
1684
1700
|
const result = conclusion.every((obj) => {
|
|
1685
1701
|
!obj.result && messages.push(obj.msg);
|
|
@@ -1707,10 +1723,10 @@ class RCCallClient {
|
|
|
1707
1723
|
listener.onTrackReady(track);
|
|
1708
1724
|
});
|
|
1709
1725
|
// 往组里发消息
|
|
1710
|
-
const { code, stateMachine } = yield this._callEngine.callInGroup(channelId, targetId, mediaType, userIds, extra,
|
|
1726
|
+
const { code, stateMachine } = yield this._callEngine.callInGroup(channelId, targetId, mediaType, userIds, extra, pushTitleValue, pushContentValue);
|
|
1711
1727
|
if (code === pluginCallEngine.RCCallErrorCode.SUCCESS && stateMachine) {
|
|
1712
|
-
|
|
1713
|
-
const session = new RCCallSession(stateMachine, this._rtcClient, {
|
|
1728
|
+
this._logger.info('_', '[RCCallClient callInGroup] successfully created state machine');
|
|
1729
|
+
const session = new RCCallSession(stateMachine, this._rtcClient, this._logger, {
|
|
1714
1730
|
localTracks,
|
|
1715
1731
|
// 是否允许订阅重试
|
|
1716
1732
|
isAllowSubscribeRetry: this._options.isAllowSubscribeRetry,
|
|
@@ -1727,16 +1743,18 @@ class RCCallClient {
|
|
|
1727
1743
|
// 允许降级获得流,获得音视频不成功 ,降级获得音频, 默认不允许
|
|
1728
1744
|
isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
|
|
1729
1745
|
// 标明是主叫产生的session
|
|
1730
|
-
produceType: ProduceTypes.CALLER
|
|
1746
|
+
produceType: ProduceTypes.CALLER,
|
|
1747
|
+
callPushConfig: this._callPushConfig,
|
|
1748
|
+
hungupPushConfig: this._hungupPushConfig
|
|
1731
1749
|
});
|
|
1732
1750
|
// session上注册监听事件
|
|
1733
1751
|
session.registerSessionListener(listener);
|
|
1734
1752
|
this._sessionList.push(session);
|
|
1735
|
-
|
|
1753
|
+
this._logger.info('_', `[RCCallClient callInGroup] successfully created session object, sessionId: ${session.getSessionId()}`);
|
|
1736
1754
|
return { code, session };
|
|
1737
1755
|
}
|
|
1738
1756
|
else {
|
|
1739
|
-
|
|
1757
|
+
this._logger.info('_', `[RCCallClient callInGroup] callInGroup failed code -> ${code}`);
|
|
1740
1758
|
localTracks.forEach(track => {
|
|
1741
1759
|
// 禁用视频
|
|
1742
1760
|
track.mute();
|
|
@@ -1756,19 +1774,19 @@ class RCCallClient {
|
|
|
1756
1774
|
if (mediaType === pluginCallEngine.RCCallMediaType.AUDIO) {
|
|
1757
1775
|
const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && constraints.audio && Object.assign({}, constraints.audio));
|
|
1758
1776
|
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
1759
|
-
|
|
1777
|
+
this._logger.error('_', `[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ${code}`);
|
|
1760
1778
|
return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
|
|
1761
1779
|
}
|
|
1762
|
-
|
|
1780
|
+
this._logger.info('_', '[RCCallClient _getTrack] successfully get Audio local tracks');
|
|
1763
1781
|
return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, tracks: [track] };
|
|
1764
1782
|
}
|
|
1765
1783
|
else {
|
|
1766
1784
|
const { code, tracks } = yield this._rtcClient.createMicrophoneAndCameraTracks('RongCloudRTC', constraints && Object.assign({}, constraints));
|
|
1767
1785
|
if (code !== pluginRtc.RCRTCCode.SUCCESS) {
|
|
1768
|
-
|
|
1786
|
+
this._logger.error('_', `[RCCallClient _getTrack] get Audio and Video local tracks failed RCT code -> ${code}`);
|
|
1769
1787
|
return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR };
|
|
1770
1788
|
}
|
|
1771
|
-
|
|
1789
|
+
this._logger.info('_', '[RCCallClient _getTrack] successfully get audio and video local tracks');
|
|
1772
1790
|
return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, tracks };
|
|
1773
1791
|
}
|
|
1774
1792
|
});
|
|
@@ -1811,14 +1829,40 @@ class RCCallClient {
|
|
|
1811
1829
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1812
1830
|
const { code, data } = yield this._context.getRTCJoinedUserInfo(this._context.getCurrentId());
|
|
1813
1831
|
if (code !== engine.ErrorCode.SUCCESS) {
|
|
1814
|
-
|
|
1832
|
+
this._logger.error('_', `getJoinedUserInfo error code: ${code}`);
|
|
1815
1833
|
return { code: pluginCallEngine.RCCallErrorCode.QUERY_JOINED_USER_INFO_ERROR };
|
|
1816
1834
|
}
|
|
1817
1835
|
return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, data };
|
|
1818
1836
|
});
|
|
1819
1837
|
}
|
|
1838
|
+
/**
|
|
1839
|
+
* 设置呼叫、挂断推送数据
|
|
1840
|
+
* @param callPushConfig 呼叫推送配置
|
|
1841
|
+
* @param callPushConfig.pushTitle 呼叫推送标题
|
|
1842
|
+
* @param callPushConfig.pushContent 呼叫推送内容
|
|
1843
|
+
* @param hungupPushConfig 挂断推送配置
|
|
1844
|
+
* @param hungupPushConfig.pushTitle 挂断推送标题
|
|
1845
|
+
* @param hungupPushConfig.pushContent 挂断推送内容
|
|
1846
|
+
*/
|
|
1847
|
+
setPushConfig(callPushConfig = {}, hungupPushConfig = {}) {
|
|
1848
|
+
const conclusion = [callPushConfig, hungupPushConfig].map((pushConfig) => {
|
|
1849
|
+
return validatePushConfig(pushConfig);
|
|
1850
|
+
})[0];
|
|
1851
|
+
const messages = [];
|
|
1852
|
+
const result = conclusion.every((obj) => {
|
|
1853
|
+
!obj.result && messages.push(obj.msg);
|
|
1854
|
+
return obj.result;
|
|
1855
|
+
});
|
|
1856
|
+
if (!result) {
|
|
1857
|
+
throw new Error(`[RCCallClient callInGroup callPushConfig or hungupPushConfig] ${messages.join('\n')}`);
|
|
1858
|
+
}
|
|
1859
|
+
this._callPushConfig = callPushConfig;
|
|
1860
|
+
this._hungupPushConfig = hungupPushConfig;
|
|
1861
|
+
}
|
|
1820
1862
|
}
|
|
1821
1863
|
|
|
1864
|
+
// plugin-call 版本上报
|
|
1865
|
+
engine.VersionManage.add('plugin-call', "5.1.2-alpha.3");
|
|
1822
1866
|
const installer = {
|
|
1823
1867
|
tag: 'RCCall',
|
|
1824
1868
|
verify(runtime) {
|
|
@@ -1830,10 +1874,13 @@ const installer = {
|
|
|
1830
1874
|
if (!conclusion.result) {
|
|
1831
1875
|
throw new Error(`[RCCallLib installer steup]${conclusion.msg}`);
|
|
1832
1876
|
}
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1877
|
+
// 校验当前安装的 engine 版本是否可用
|
|
1878
|
+
if (!engine.VersionManage.validEngine("^5.7.0")) {
|
|
1879
|
+
throw new Error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-call required engine version at least '${"^5.7.0"}'.`);
|
|
1880
|
+
}
|
|
1881
|
+
const logger = context.createLogger('RCCall', 'RTC');
|
|
1882
|
+
logger.warn('_', `RCCall Version: ${"5.1.2-alpha.3"}, Commit: ${"18608f24276587122c6fe1b54515d19aec29be0f"}`);
|
|
1883
|
+
return new RCCallClient(context, runtime, logger, options);
|
|
1837
1884
|
}
|
|
1838
1885
|
};
|
|
1839
1886
|
|