@rongcloud/plugin-call 5.1.2-alpha.1 → 5.1.2-alpha.2

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.umd.js CHANGED
@@ -1,16 +1,14 @@
1
1
  /*
2
- * RCCall - v5.1.2-alpha.1
3
- * CommitId - 5a6d3a159d1171c71f1bb419dfac59eb8e886f91
4
- * Mon Feb 27 2023 10:35:06 GMT+0800 (China Standard Time)
2
+ * RCCall - v5.1.2-alpha.2
3
+ * CommitId - 8d4f8b00cda704283faad34d0e81a4e048e09d08
4
+ * Tue Feb 28 2023 21:09:53 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  (function (global, factory) {
8
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@rongcloud/plugin-call-engine'), require('@rongcloud/engine'), require('@rongcloud/plugin-rtc')) :
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.RCCallEngine, global.RCEngine, global.RCRTC));
11
- })(this, (function (exports, pluginCallEngine, engine, pluginRtc) { 'use strict';
12
-
13
- const logger = new engine.Logger('RCCall');
8
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@rongcloud/engine'), require('@rongcloud/plugin-call-engine'), require('@rongcloud/plugin-rtc')) :
9
+ typeof define === 'function' && define.amd ? define(['exports', '@rongcloud/engine', '@rongcloud/plugin-call-engine', '@rongcloud/plugin-rtc'], factory) :
10
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.RCCall = {}, global.RCEngine, global.RCCallEngine, global.RCRTC));
11
+ })(this, (function (exports, engine, pluginCallEngine, pluginRtc) { 'use strict';
14
12
 
15
13
  /*! *****************************************************************************
16
14
  Copyright (c) Microsoft Corporation.
@@ -255,6 +253,11 @@
255
253
  return { result: false, msg: '\'pushContent\' parameter must be of type \'string\'' };
256
254
  }
257
255
  };
256
+ const validatePushConfig = (pushConfig) => {
257
+ const { pushTitle, pushContent } = pushConfig;
258
+ const conclusion = [validatePushTitle(pushTitle), validatePushContent(pushContent)];
259
+ return conclusion;
260
+ };
258
261
  const validateUserIds = (userIds) => {
259
262
  if (!Array.isArray(userIds)) {
260
263
  return { result: false, msg: '\'userIds\' parameter is required, must be of type \'string[]\'' };
@@ -348,13 +351,14 @@
348
351
  /**
349
352
  * rtc实例
350
353
  */
351
- _rtcClient,
354
+ _rtcClient, _logger,
352
355
  /**
353
356
  * session的其它选项
354
357
  */
355
358
  _options = {}) {
356
359
  this._stateMachine = _stateMachine;
357
360
  this._rtcClient = _rtcClient;
361
+ this._logger = _logger;
358
362
  this._options = _options;
359
363
  /**
360
364
  * 用户传进来的 对session的监听 (要在RCCallClient的_onInvite里判断,要求执行完onSession必须注册session的监听,所以这里是public)
@@ -375,7 +379,7 @@
375
379
  * @param info
376
380
  */
377
381
  onUserStateChange: ({ user, reason }) => {
378
- 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}`);
382
+ 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}`);
379
383
  },
380
384
  /**
381
385
  * 房间状态变更
@@ -383,18 +387,18 @@
383
387
  */
384
388
  onStateChange: (info) => __awaiter(this, void 0, void 0, function* () {
385
389
  const { state, reason } = info;
386
- logger.info(`[RCCallSession onStateChange] : state->${state} reason->${reason}`);
390
+ this._logger.info('_', `[RCCallSession onStateChange] : state->${state} reason->${reason}`);
387
391
  // 如果在通话中,就加房间
388
392
  if (state === pluginCallEngine.RCCallSessionState.KEEPING) {
389
393
  const roomId = this._stateMachine.getCallId();
390
- logger.info(`[RCCallSession onStateChange] roomId: ${roomId}`);
394
+ this._logger.info('_', `[RCCallSession onStateChange] roomId: ${roomId}`);
391
395
  try {
392
396
  // 加房间
393
397
  yield this._joinRoom(roomId);
394
398
  }
395
399
  catch (error) {
396
400
  this._exceptionClose(pluginCallEngine.RCCallEndReason.NETWORK_ERROR);
397
- logger.error(`[RCCallSession onStateChange] joinRoom throw exception roomId -> ${roomId}`);
401
+ this._logger.error('_', `[RCCallSession onStateChange] joinRoom throw exception roomId -> ${roomId}`);
398
402
  console.error(error);
399
403
  }
400
404
  /**
@@ -414,7 +418,7 @@
414
418
  return;
415
419
  }
416
420
  this._options.localTracks && this._destroyTracks(this._options.localTracks);
417
- logger.info('[RCCallSession onStateChange] localTracks destroyed');
421
+ this._logger.info('_', '[RCCallSession onStateChange] localTracks destroyed');
418
422
  this._leaveRoom();
419
423
  this._room = null;
420
424
  }
@@ -424,13 +428,13 @@
424
428
  * @param sender 发起用户信息
425
429
  */
426
430
  onRinging: (sender) => {
427
- logger.info(`[RCCallSession onRinging]sender: sender.userId -> ${sender.userId}`);
431
+ this._logger.info('_', `[RCCallSession onRinging]sender: sender.userId -> ${sender.userId}`);
428
432
  try {
429
433
  // 通知用户响铃
430
434
  this._listener.onRinging(sender, this);
431
435
  }
432
436
  catch (error) {
433
- logger.error('[RCCallSession onRinging] method exception -> onRinging');
437
+ this._logger.error('_', '[RCCallSession onRinging] method exception -> onRinging');
434
438
  console.error(error);
435
439
  }
436
440
  },
@@ -438,13 +442,13 @@
438
442
  * 当远端用户同意接听
439
443
  */
440
444
  onAccept: (sender) => {
441
- logger.info(`[RCCallSession onAccept]sender: sender.userId -> ${sender.userId}`);
445
+ this._logger.info('_', `[RCCallSession onAccept]sender: sender.userId -> ${sender.userId}`);
442
446
  try {
443
447
  // 通知本端,远端用户已接听
444
448
  this._listener.onAccept(sender, this);
445
449
  }
446
450
  catch (error) {
447
- logger.error('[RCCallSession onAccept] method exception -> onAccept');
451
+ this._logger.error('_', '[RCCallSession onAccept] method exception -> onAccept');
448
452
  console.error(error);
449
453
  }
450
454
  },
@@ -452,13 +456,13 @@
452
456
  * 当有远端用户挂断
453
457
  */
454
458
  onHungup: (sender, reason) => {
455
- logger.info(`[RCCallSession onHungup]sender: sender.userId -> ${sender.userId} reason->${reason}`);
459
+ this._logger.info('_', `[RCCallSession onHungup]sender: sender.userId -> ${sender.userId} reason->${reason}`);
456
460
  try {
457
461
  // 通知本端,远端用户已挂断
458
462
  this._listener.onHungup(sender, reason, this);
459
463
  }
460
464
  catch (error) {
461
- logger.error('[RCCallSession onHungup] method exception -> onHungup');
465
+ this._logger.error('_', '[RCCallSession onHungup] method exception -> onHungup');
462
466
  console.error(error);
463
467
  }
464
468
  },
@@ -467,13 +471,13 @@
467
471
  * @param sender 发起用户信息
468
472
  */
469
473
  onMemberModify: ({ sender, invitedUsers }) => {
470
- logger.info(`[RCCallSession onMemberModify] sender.userId -> ${sender.userId}`);
474
+ this._logger.info('_', `[RCCallSession onMemberModify] sender.userId -> ${sender.userId}`);
471
475
  try {
472
476
  // 通知用户人员变更
473
477
  this._listener.onMemberModify(sender, invitedUsers, this);
474
478
  }
475
479
  catch (error) {
476
- logger.error('[RCCallSession onMemberModify] method exception -> onMemberModify');
480
+ this._logger.error('_', '[RCCallSession onMemberModify] method exception -> onMemberModify');
477
481
  console.error(error);
478
482
  }
479
483
  },
@@ -482,7 +486,7 @@
482
486
  * @param sender 发起用户信息
483
487
  */
484
488
  onMediaModify: ({ sender, mediaType }) => {
485
- logger.info(`[RCCallSession onMediaModify]sender: sender.userId -> ${sender.userId} mediaType: ${mediaType}`);
489
+ this._logger.info('_', `[RCCallSession onMediaModify]sender: sender.userId -> ${sender.userId} mediaType: ${mediaType}`);
486
490
  if (mediaType === pluginCallEngine.RCCallMediaType.AUDIO) {
487
491
  // 远端收到通话降级通知后,远端执行降级通话(不发消息)
488
492
  this._setMediaTypeToAudio();
@@ -491,7 +495,7 @@
491
495
  this._listener.onMediaModify(sender, mediaType, this);
492
496
  }
493
497
  catch (error) {
494
- logger.error('[RCCallSession onMediaModify] method exception -> onMediaModify');
498
+ this._logger.error('_', '[RCCallSession onMediaModify] method exception -> onMediaModify');
495
499
  console.error(error);
496
500
  }
497
501
  },
@@ -500,10 +504,15 @@
500
504
  * @param sender 发起用户信息
501
505
  */
502
506
  crossAppkey: (isCrossAppkey) => {
503
- logger.info(`[RCCallSession crossAppkey] 是否跨 appkey: ${isCrossAppkey}`);
507
+ this._logger.info('_', `[RCCallSession crossAppkey] 是否跨 appkey: ${isCrossAppkey}`);
504
508
  this._options.isCrossAppkey = isCrossAppkey;
505
509
  }
506
510
  });
511
+ /**
512
+ * 设置挂断的推送信息
513
+ */
514
+ const { pushTitle, pushContent } = this._options.hungupPushConfig;
515
+ this._stateMachine.setHungupPushConfig(pushTitle, pushContent);
507
516
  }
508
517
  /**
509
518
  * 加入房间
@@ -532,7 +541,7 @@
532
541
  else {
533
542
  this._exceptionClose(pluginCallEngine.RCCallEndReason.NETWORK_ERROR);
534
543
  }
535
- logger.info(`[RCCallClient _joinRoom] join room failed: roomId -> ${roomId} RCRTCCode -> ${code}`);
544
+ this._logger.info('_', `[RCCallClient _joinRoom] join room failed: roomId -> ${roomId} RCRTCCode -> ${code}`);
536
545
  return { code: pluginCallEngine.RCCallErrorCode.JOIN_ROOM_ERROR };
537
546
  }
538
547
  /**
@@ -555,7 +564,7 @@
555
564
  }
556
565
  catch (error) {
557
566
  this._exceptionClose(pluginCallEngine.RCCallEndReason.NETWORK_ERROR);
558
- logger.error(`[RCCallSession _joinRoom] _rtcClient.joinRTCRoom throw exception roomId -> ${roomId}`);
567
+ this._logger.error('_', `[RCCallSession _joinRoom] _rtcClient.joinRTCRoom throw exception roomId -> ${roomId}`);
559
568
  console.error(error);
560
569
  return { code: pluginCallEngine.RCCallErrorCode.JOIN_ROOM_ERROR };
561
570
  }
@@ -570,7 +579,7 @@
570
579
  catch (error) {
571
580
  // 结束通话session
572
581
  this._exceptionClose(pluginCallEngine.RCCallEndReason.SUBSCRIBE_ERROR);
573
- logger.error(`[RCCallSession _joinRoom] _subscribeInRoomRemoteTrack Exception roomId -> ${roomId}`);
582
+ this._logger.error('_', `[RCCallSession _joinRoom] _subscribeInRoomRemoteTrack Exception roomId -> ${roomId}`);
574
583
  console.error(error);
575
584
  return { code: pluginCallEngine.RCCallErrorCode.JOIN_ROOM_ERROR };
576
585
  }
@@ -581,7 +590,7 @@
581
590
  catch (error) {
582
591
  // 结束通话session
583
592
  this._exceptionClose(pluginCallEngine.RCCallEndReason.PUBLISH_ERROR);
584
- logger.error(`[RCCallSession _joinRoom] _publish Exception roomId -> ${roomId}`);
593
+ this._logger.error('_', `[RCCallSession _joinRoom] _publish Exception roomId -> ${roomId}`);
585
594
  console.error(error);
586
595
  return { code: pluginCallEngine.RCCallErrorCode.JOIN_ROOM_ERROR };
587
596
  }
@@ -599,7 +608,7 @@
599
608
  const { code } = yield this._subscribeRetry(tracks, this._options.isAllowSubscribeRetry, this._RETRYCOUNT);
600
609
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
601
610
  this._exceptionClose(pluginCallEngine.RCCallEndReason.SUBSCRIBE_ERROR);
602
- logger.error(`[RCCallSession _subscribeInRoomRemoteTrack] Resource subscription failed roomId -> ${this._stateMachine.getCallId()} RTC code -> ${code}`);
611
+ this._logger.error('_', `[RCCallSession _subscribeInRoomRemoteTrack] Resource subscription failed roomId -> ${this._stateMachine.getCallId()} RTC code -> ${code}`);
603
612
  }
604
613
  }
605
614
  });
@@ -618,7 +627,7 @@
618
627
  this._listener.onTrackSubscribeFail && this._listener.onTrackSubscribeFail(code, this);
619
628
  }
620
629
  catch (error) {
621
- logger.error('[RCCallSession] _listener.onTrackSubscribeFail exception');
630
+ this._logger.error('_', '[RCCallSession] _listener.onTrackSubscribeFail exception');
622
631
  console.error(error);
623
632
  }
624
633
  // 如果不允许重试,直接返回
@@ -644,7 +653,7 @@
644
653
  // 若资源发布失败
645
654
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
646
655
  this._exceptionClose(pluginCallEngine.RCCallEndReason.PUBLISH_ERROR);
647
- logger.info(`[RCCallSession _publist] Resource publishing failed: roomId -> ${this._stateMachine.getCallId()} RCRTCCode -> ${code}`);
656
+ this._logger.info('_', `[RCCallSession _publist] Resource publishing failed: roomId -> ${this._stateMachine.getCallId()} RCRTCCode -> ${code}`);
648
657
  return;
649
658
  }
650
659
  // 如果是主动发起的呼叫,已提前抛出了资源, 被动呼叫,这里才需要抛出
@@ -668,7 +677,7 @@
668
677
  this._listener.onTrackPublishFail && this._listener.onTrackPublishFail(code, this);
669
678
  }
670
679
  catch (error) {
671
- logger.error('[RCCallSession] _listener.onTrackPublishFail exception');
680
+ this._logger.error('_', '[RCCallSession] _listener.onTrackPublishFail exception');
672
681
  console.error(error);
673
682
  }
674
683
  // 如果不允许重试,直接返回
@@ -692,10 +701,10 @@
692
701
  // 退出房间
693
702
  const callBack = yield this._rtcClient.leaveRoom(this._room);
694
703
  // 成功退出房间,触发RCCallClient实例上的onSessionClose监听,抛给用户信息
695
- logger.info('[RCCallSession _leaveRoom] Successfully exited the room', callBack);
704
+ this._logger.info('_', `[RCCallSession _leaveRoom] Successfully exited the room code: ${callBack.code}`);
696
705
  }
697
706
  catch (error) {
698
- logger.error('[RCCallSession _leaveRoom] leaveRoom throw exception');
707
+ this._logger.error('_', '[RCCallSession _leaveRoom] leaveRoom throw exception');
699
708
  console.error(error);
700
709
  }
701
710
  finally {
@@ -734,19 +743,19 @@
734
743
  if (mediaType === pluginCallEngine.RCCallMediaType.AUDIO) {
735
744
  const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && constraints.audio && Object.assign({}, constraints.audio));
736
745
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
737
- logger.error(`[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ${code}`);
746
+ this._logger.error('_', `[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ${code}`);
738
747
  return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
739
748
  }
740
- logger.info('[RCCallSession _getLocalTrackCore] successfully get Audio local tracks');
749
+ this._logger.info('_', '[RCCallSession _getLocalTrackCore] successfully get Audio local tracks');
741
750
  return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, tracks: [track] };
742
751
  }
743
752
  else {
744
753
  const { code, tracks } = yield this._rtcClient.createMicrophoneAndCameraTracks('RongCloudRTC', constraints && Object.assign({}, constraints));
745
754
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
746
- logger.error(`[RCCallSession _getLocalTrackCore] get Audio and Video local tracks failed RCT code -> ${code}`);
755
+ this._logger.error('_', `[RCCallSession _getLocalTrackCore] get Audio and Video local tracks failed RCT code -> ${code}`);
747
756
  return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR };
748
757
  }
749
- logger.info('[RCCallSession _getLocalTrackCore] successfully get audio and video local tracks');
758
+ this._logger.info('_', '[RCCallSession _getLocalTrackCore] successfully get audio and video local tracks');
750
759
  return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, tracks };
751
760
  }
752
761
  });
@@ -790,7 +799,7 @@
790
799
  const localTracks = [];
791
800
  const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', audioConstraints);
792
801
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
793
- logger.error(`[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ${code}`);
802
+ this._logger.error('_', `[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ${code}`);
794
803
  return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
795
804
  }
796
805
  this._options.localTracks && this._options.localTracks.forEach((track) => {
@@ -821,12 +830,14 @@
821
830
  * 群呼叫中继续邀请
822
831
  * @param userIds 被邀请用户 ID 列表
823
832
  * @param options.extra 消息的扩展信息
824
- * @param options.pushTitle 通知的标题
825
- * @param options.pushContent 通知内容
833
+ * @deprecated 5.1.2 废弃 options.pushTitle 通知的标题
834
+ * @deprecated 5.1.2 废弃 options.pushContent 通知内容
826
835
  */
827
836
  invite(userIds, options = {}) {
837
+ var _a, _b;
828
838
  return __awaiter(this, void 0, void 0, function* () {
829
- const { extra = '', pushTitle = '', pushContent = '' } = options;
839
+ const { extra = '' } = options;
840
+ 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;
830
841
  const conclusion = [validateUserIds(userIds), validateExtra(extra), validatePushTitle(pushTitle), validatePushContent(pushContent)];
831
842
  const messages = [];
832
843
  const result = conclusion.every((obj) => {
@@ -860,7 +871,7 @@
860
871
  // 发送接听的消息
861
872
  const { code } = yield this._stateMachine.accept();
862
873
  if (code !== pluginCallEngine.RCCallErrorCode.SUCCESS) {
863
- logger.error(`[RCCallSession accept]Send accept message failed -> code: ${code}`);
874
+ this._logger.error('_', `[RCCallSession accept]Send accept message failed -> code: ${code}`);
864
875
  return { code };
865
876
  }
866
877
  return { code };
@@ -884,7 +895,7 @@
884
895
  return __awaiter(this, void 0, void 0, function* () {
885
896
  const { code } = yield this._stateMachine.changeMediaType(mediaType);
886
897
  if (code !== pluginCallEngine.RCCallErrorCode.SUCCESS) {
887
- logger.error(`[RCCallSession _changeMediaType] change media type fail code-> ${code}`);
898
+ this._logger.error('_', `[RCCallSession _changeMediaType] change media type fail code-> ${code}`);
888
899
  }
889
900
  return { code };
890
901
  });
@@ -933,7 +944,7 @@
933
944
  const { code: _code } = yield this._room.publish([track]);
934
945
  // 若资源发布失败
935
946
  if (_code !== pluginRtc.RCRTCCode.SUCCESS) {
936
- logger.error(`[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ${code}`);
947
+ this._logger.error('_', `[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ${code}`);
937
948
  return;
938
949
  }
939
950
  // 通知业务层trackReady
@@ -957,7 +968,7 @@
957
968
  // 取消发布视频
958
969
  const { code } = yield this._room.unpublish(tracks);
959
970
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
960
- logger.error(`[RCCallSession disableVideo] unpublish failed -> ${code}`);
971
+ this._logger.error('_', `[RCCallSession disableVideo] unpublish failed -> ${code}`);
961
972
  }
962
973
  // 关闭摄像头
963
974
  this._destroyTracks(tracks);
@@ -983,12 +994,12 @@
983
994
  disableVideoTrack() {
984
995
  return __awaiter(this, void 0, void 0, function* () {
985
996
  if (!this._room) {
986
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
997
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
987
998
  return { code: pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR };
988
999
  }
989
1000
  const tracks = this._getLocalVideoTracks();
990
1001
  if (!tracks.length) {
991
- logger.error(`[RCCallSession disableVideoTrack] Room missing video track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1002
+ this._logger.error('_', `[RCCallSession disableVideoTrack] Room missing video track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
992
1003
  return { code: pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR };
993
1004
  }
994
1005
  // 禁用视频
@@ -1002,7 +1013,7 @@
1002
1013
  // 取消发布视频
1003
1014
  const { code } = yield this._room.unpublish(tracks);
1004
1015
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
1005
- logger.error(`[RCCallSession disableVideo] unpublish failed -> ${code}`);
1016
+ this._logger.error('_', `[RCCallSession disableVideo] unpublish failed -> ${code}`);
1006
1017
  return { code: pluginCallEngine.RCCallErrorCode.UNPUBLISH_VIDEO_ERROR };
1007
1018
  }
1008
1019
  tracks.forEach((track) => {
@@ -1018,14 +1029,14 @@
1018
1029
  enableVideoTrack() {
1019
1030
  return __awaiter(this, void 0, void 0, function* () {
1020
1031
  if (!this._room) {
1021
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1032
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1022
1033
  return { code: pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR };
1023
1034
  }
1024
1035
  // 如果不需关闭摄像头
1025
1036
  if (!this._options.isOffCameraWhenVideoDisable) {
1026
1037
  const tracks = this._getLocalVideoTracks();
1027
1038
  if (!tracks.length) {
1028
- logger.error(`[RCCallSession EnableVideoTrack] Room missing video track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1039
+ this._logger.error('_', `[RCCallSession EnableVideoTrack] Room missing video track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1029
1040
  return { code: pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR };
1030
1041
  }
1031
1042
  // 启用视频
@@ -1037,7 +1048,7 @@
1037
1048
  // 获得本端视频资源
1038
1049
  const { code, track } = yield this._rtcClient.createCameraVideoTrack();
1039
1050
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
1040
- logger.error(`[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ${code}`);
1051
+ this._logger.error('_', `[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ${code}`);
1041
1052
  return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR };
1042
1053
  }
1043
1054
  const localTracks = [];
@@ -1060,7 +1071,7 @@
1060
1071
  const { code: _code } = yield this._room.publish([track]);
1061
1072
  // 若资源发布失败
1062
1073
  if (_code !== pluginRtc.RCRTCCode.SUCCESS) {
1063
- logger.error(`[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ${code}`);
1074
+ this._logger.error('_', `[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ${code}`);
1064
1075
  return { code: pluginCallEngine.RCCallErrorCode.VIDEO_PUBLISH_ERROR };
1065
1076
  }
1066
1077
  // 启用
@@ -1076,7 +1087,7 @@
1076
1087
  disableAudioTrack() {
1077
1088
  return __awaiter(this, void 0, void 0, function* () {
1078
1089
  if (!this._room) {
1079
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1090
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1080
1091
  return { code: pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR };
1081
1092
  }
1082
1093
  const tracks = this._getLocalAudioTracks();
@@ -1092,12 +1103,12 @@
1092
1103
  enableAudioTrack() {
1093
1104
  return __awaiter(this, void 0, void 0, function* () {
1094
1105
  if (!this._room) {
1095
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1106
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR}`);
1096
1107
  return { code: pluginCallEngine.RCCallErrorCode.NOT_IN_ROOM_ERROR };
1097
1108
  }
1098
1109
  const tracks = this._getLocalAudioTracks();
1099
1110
  if (!tracks.length) {
1100
- logger.error(`[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1111
+ this._logger.error('_', `[RCCallSession disableAudioTrack] Room missing audio track -> ${pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}`);
1101
1112
  return { code: pluginCallEngine.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR };
1102
1113
  }
1103
1114
  // 启用音频
@@ -1123,7 +1134,7 @@
1123
1134
  this._listener.onTrackReady(track, this);
1124
1135
  }
1125
1136
  catch (error) {
1126
- logger.error('[RCCallSession _notifyTrackReady] _listener onTrackReady exception');
1137
+ this._logger.error('_', '[RCCallSession _notifyTrackReady] _listener onTrackReady exception');
1127
1138
  console.error(error);
1128
1139
  }
1129
1140
  });
@@ -1177,7 +1188,7 @@
1177
1188
  * @param audioTrack RCRemoteAudioTrack 类实例
1178
1189
  */
1179
1190
  onAudioMuteChange: (audioTrack) => {
1180
- logger.info(`[RCCallSession onAudioMuteChange] userId->${audioTrack.getUserId()} muted -> ${audioTrack.isOwnerMuted()}`);
1191
+ this._logger.info('_', `[RCCallSession onAudioMuteChange] userId->${audioTrack.getUserId()} muted -> ${audioTrack.isOwnerMuted()}`);
1181
1192
  const muteUser = {
1182
1193
  userId: audioTrack.getUserId(),
1183
1194
  muted: audioTrack.isOwnerMuted(),
@@ -1189,7 +1200,7 @@
1189
1200
  this._listener.onAudioMuteChange(muteUser, this);
1190
1201
  }
1191
1202
  catch (error) {
1192
- logger.error('[RCCallSession onAudioMuteChange] Missing listening method -> onTrackMuteChange');
1203
+ this._logger.error('_', '[RCCallSession onAudioMuteChange] Missing listening method -> onTrackMuteChange');
1193
1204
  console.error(error);
1194
1205
  }
1195
1206
  },
@@ -1198,7 +1209,7 @@
1198
1209
  * @param videoTrack RCRemoteVideoTrack 类实例对象
1199
1210
  */
1200
1211
  onVideoMuteChange: (videoTrack) => {
1201
- logger.info(`[RCCallSession onVideoMuteChange]userId->${videoTrack.getUserId()} muted -> ${videoTrack.isOwnerMuted()}`);
1212
+ this._logger.info('_', `[RCCallSession onVideoMuteChange]userId->${videoTrack.getUserId()} muted -> ${videoTrack.isOwnerMuted()}`);
1202
1213
  const muteUser = {
1203
1214
  userId: videoTrack.getUserId(),
1204
1215
  muted: videoTrack.isOwnerMuted(),
@@ -1210,7 +1221,7 @@
1210
1221
  this._listener.onVideoMuteChange(muteUser, this);
1211
1222
  }
1212
1223
  catch (error) {
1213
- logger.error('[RCCallSession onVideoMuteChange] Missing listening method -> onVideoMuteChange');
1224
+ this._logger.error('_', '[RCCallSession onVideoMuteChange] Missing listening method -> onVideoMuteChange');
1214
1225
  console.error(error);
1215
1226
  }
1216
1227
  },
@@ -1225,7 +1236,7 @@
1225
1236
  // 按业务需求选择需要订阅资源,通过 room.subscribe 接口进行订阅
1226
1237
  const { code } = yield this._room.subscribe(tracks);
1227
1238
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
1228
- logger.error(`[RCCallSession onTrackPublish] subscribe failed RTCCode ->${code}`);
1239
+ this._logger.error('_', `[RCCallSession onTrackPublish] subscribe failed RTCCode ->${code}`);
1229
1240
  }
1230
1241
  }
1231
1242
  }),
@@ -1265,20 +1276,20 @@
1265
1276
  * @param userIds
1266
1277
  */
1267
1278
  onUserLeave: (userIds) => {
1268
- logger.info(`[RCCallSession onUserLeave] listening onUserLeave userIds -> ${userIds === null || userIds === void 0 ? void 0 : userIds.join(',')}`);
1279
+ this._logger.info('_', `[RCCallSession onUserLeave] listening onUserLeave userIds -> ${userIds === null || userIds === void 0 ? void 0 : userIds.join(',')}`);
1269
1280
  this._stateMachine.userLeave(userIds);
1270
1281
  },
1271
1282
  /**
1272
1283
  * RTC 每次 Ping 结果
1273
1284
  */
1274
1285
  onPing: (result) => {
1275
- logger.info(`[RCCallSession onPing]${result}`);
1286
+ this._logger.info('_', `[RCCallSession onPing]${result}`);
1276
1287
  try {
1277
1288
  // 通知给业务
1278
1289
  this._listener.onPing && this._listener.onPing(result, this);
1279
1290
  }
1280
1291
  catch (error) {
1281
- logger.error('[RCCallSession onPing] listening onPing exception');
1292
+ this._logger.error('_', '[RCCallSession onPing] listening onPing exception');
1282
1293
  console.error(error);
1283
1294
  }
1284
1295
  }
@@ -1299,7 +1310,7 @@
1299
1310
  this._listener.onRTCStateReport && this._listener.onRTCStateReport(report, this);
1300
1311
  }
1301
1312
  catch (error) {
1302
- logger.error('[RCCallSession onStateReport] listener onStateReport exception');
1313
+ this._logger.error('_', '[RCCallSession onStateReport] listener onStateReport exception');
1303
1314
  console.error(error);
1304
1315
  }
1305
1316
  },
@@ -1312,7 +1323,7 @@
1312
1323
  this._listener.onICEConnectionStateChange && this._listener.onICEConnectionStateChange(state, this);
1313
1324
  }
1314
1325
  catch (error) {
1315
- logger.error('[RCCallSession onICEConnectionStateChange] onICEConnectionStateChange exception');
1326
+ this._logger.error('_', '[RCCallSession onICEConnectionStateChange] onICEConnectionStateChange exception');
1316
1327
  console.error(error);
1317
1328
  }
1318
1329
  }
@@ -1389,20 +1400,17 @@
1389
1400
  }
1390
1401
  }
1391
1402
 
1392
- // plugin-call 版本上报
1393
- engine.VersionManage.add('plugin-call', "5.1.2-alpha.1");
1394
- // 校验当前安装的 engine 版本是否可用
1395
- if (!engine.VersionManage.validEngine("^5.5.4")) {
1396
- logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error,plugin-call required engine version at least '${"^5.5.4"}'.`);
1397
- }
1398
1403
  class RCCallClient {
1399
- constructor(_context, _runtime, _options) {
1404
+ constructor(_context, _runtime, _logger, _options) {
1400
1405
  this._context = _context;
1401
1406
  this._runtime = _runtime;
1407
+ this._logger = _logger;
1402
1408
  /**
1403
1409
  * session列表
1404
1410
  */
1405
1411
  this._sessionList = [];
1412
+ this._callPushConfig = {};
1413
+ this._hungupPushConfig = {};
1406
1414
  this._rtcClient = _options.rtcClient;
1407
1415
  this._options = Object.assign({
1408
1416
  /**
@@ -1434,7 +1442,7 @@
1434
1442
  lang: pluginCallEngine.RCCallLanguage.ZH
1435
1443
  }, _options);
1436
1444
  // 初始化callEngine, 并监听onInvite
1437
- this._callEngine = new pluginCallEngine.RCCallEngine(this._context, _runtime, logger, {
1445
+ this._callEngine = new pluginCallEngine.RCCallEngine(this._context, _runtime, this._logger, {
1438
1446
  /**
1439
1447
  * 监听收到invite
1440
1448
  */
@@ -1456,15 +1464,15 @@
1456
1464
  this._options.onSessionClose(session, summaryInfo);
1457
1465
  }
1458
1466
  catch (error) {
1459
- logger.error('[RCCCallClient] options.onSessionClose exception');
1467
+ this._logger.error('_', '[RCCCallClient] options.onSessionClose exception');
1460
1468
  console.log(error);
1461
1469
  }
1462
1470
  });
1463
1471
  // 接听之前挂断其它的session
1464
1472
  eventEmitter.on('hungupOtherSession', ({ session }) => {
1465
1473
  const id = session.getSessionId();
1466
- logger.info(`[RCCallClient hungupOtherSession] sessionId ready to accept -> ${id}`);
1467
- logger.info(`[RCCallClient hungupOtherSession] sessionList ->${this._sessionList.map(ses => ses.getSessionId()).join(',')}`);
1474
+ this._logger.info('_', `[RCCallClient hungupOtherSession] sessionId ready to accept -> ${id}`);
1475
+ this._logger.info('_', `[RCCallClient hungupOtherSession] sessionList ->${this._sessionList.map(ses => ses.getSessionId()).join(',')}`);
1468
1476
  let i = 0;
1469
1477
  while (this._sessionList.length > 1) {
1470
1478
  // 如果与要接听的session不一致
@@ -1479,15 +1487,15 @@
1479
1487
  i++;
1480
1488
  }
1481
1489
  }
1482
- logger.info(`[RCCallClient hungupOtherSession] current sessionList length ->${this._sessionList.length}`);
1490
+ this._logger.info('_', `[RCCallClient hungupOtherSession] current sessionList length ->${this._sessionList.length}`);
1483
1491
  });
1484
1492
  }
1485
1493
  /**
1486
1494
  * 监听onInvite
1487
1495
  */
1488
1496
  _onInvite(stateMachine, extra) {
1489
- logger.info('[RCCallClient _onInvite] Received invite message');
1490
- const session = new RCCallSession(stateMachine, this._rtcClient, {
1497
+ this._logger.info('_', '[RCCallClient _onInvite] Received invite message');
1498
+ const session = new RCCallSession(stateMachine, this._rtcClient, this._logger, {
1491
1499
  // 是否允许订阅重试
1492
1500
  isAllowSubscribeRetry: this._options.isAllowSubscribeRetry,
1493
1501
  // 是否允许发布重试
@@ -1503,9 +1511,11 @@
1503
1511
  // 允许降级获得流,获得音视频不成功 ,降级获得音频, 默认不允许
1504
1512
  isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
1505
1513
  // 标明是被叫产生的session
1506
- produceType: ProduceTypes.CALLEE
1514
+ produceType: ProduceTypes.CALLEE,
1515
+ callPushConfig: this._callPushConfig,
1516
+ hungupPushConfig: this._hungupPushConfig
1507
1517
  });
1508
- logger.info('[RCCallClient _onInvite] Received invite message, successfully created session');
1518
+ this._logger.info('_', '[RCCallClient _onInvite] Received invite message, successfully created session');
1509
1519
  /**
1510
1520
  * 如果通话的时候不允许接听新的通话,直接挂断, 这些工作在callEngine里完成
1511
1521
  */
@@ -1515,7 +1525,7 @@
1515
1525
  this._options.onSession(session, extra);
1516
1526
  }
1517
1527
  catch (error) {
1518
- logger.error('[RCCallClient _options.onSession] onSession exception');
1528
+ this._logger.error('_', '[RCCallClient _options.onSession] onSession exception');
1519
1529
  console.log(error);
1520
1530
  }
1521
1531
  // 必须在onSession里注册session监听事件,这里检测一下有没有注册
@@ -1526,7 +1536,7 @@
1526
1536
  }
1527
1537
  }
1528
1538
  else {
1529
- logger.error('[RCCallClient _options.onSession] session Must Have Listener');
1539
+ this._logger.error('_', '[RCCallClient _options.onSession] session Must Have Listener');
1530
1540
  throw new Error('[RCCallSession _options.onSession] session Must Have Listener');
1531
1541
  }
1532
1542
  }
@@ -1540,7 +1550,7 @@
1540
1550
  this._options.onOfflineRecord && this._options.onOfflineRecord(record);
1541
1551
  }
1542
1552
  catch (error) {
1543
- logger.error('[RCCallClient _options.onOfflineRecord] onOfflineRecord exception');
1553
+ this._logger.error('_', '[RCCallClient _options.onOfflineRecord] onOfflineRecord exception');
1544
1554
  console.log(error);
1545
1555
  }
1546
1556
  }
@@ -1552,7 +1562,7 @@
1552
1562
  */
1553
1563
  registerUserInfo(info = {}) {
1554
1564
  this._callEngine.registerUserInfo(info);
1555
- logger.info('[RCCallClient registerUserInfo] successfully register user info data');
1565
+ this._logger.info('_', '[RCCallClient registerUserInfo] successfully register user info data');
1556
1566
  }
1557
1567
  /**
1558
1568
  * 跨App单呼,发送invite消息,回调回来接收stateMachine, 建session
@@ -1562,14 +1572,15 @@
1562
1572
  * @param params.constraints 获取音频或音视频资源时的参数 可选
1563
1573
  * @param params.channelId 组织 Id 可选
1564
1574
  * @param params.extra 消息扩展信息
1565
- * @param params.pushTitle 通知的标题
1566
- * @param params.pushContent 通知的内容
1575
+ * @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
1576
+ * @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
1567
1577
  * @param params.bitrate 需要设置的码率参数
1568
1578
  *
1569
1579
  */
1570
1580
  startCrossCall({ targetId, mediaType = pluginCallEngine.RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', pushTitle = '', pushContent = '', bitrate }) {
1571
1581
  return __awaiter(this, void 0, void 0, function* () {
1572
- return this.__call({ targetId, mediaType, listener, constraints, channelId, extra, pushTitle, pushContent, bitrate, isCrossAppkey: true });
1582
+ const { pushTitle: pushTitleValue, pushContent: pushContentValue } = (this._callPushConfig.pushTitle || this._callPushConfig.pushContent) ? this._callPushConfig : { pushTitle, pushContent };
1583
+ return this.__call({ targetId, mediaType, listener, constraints, channelId, extra, pushTitle: pushTitleValue, pushContent: pushContentValue, bitrate, isCrossAppkey: true });
1573
1584
  });
1574
1585
  }
1575
1586
  /**
@@ -1580,19 +1591,20 @@
1580
1591
  * @param params.constraints 获取音频或音视频资源时的参数 可选
1581
1592
  * @param params.channelId 组织 Id 可选
1582
1593
  * @param params.extra 消息扩展信息
1583
- * @param params.pushTitle 通知的标题
1584
- * @param params.pushContent 通知的内容
1594
+ * @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
1595
+ * @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
1585
1596
  * @param params.bitrate 需要设置的码率参数
1586
1597
  *
1587
1598
  */
1588
1599
  call({ targetId, mediaType = pluginCallEngine.RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', pushTitle = '', pushContent = '', bitrate }) {
1589
1600
  return __awaiter(this, void 0, void 0, function* () {
1590
- return this.__call({ targetId, mediaType, listener, constraints, channelId, extra, pushTitle, pushContent, bitrate });
1601
+ const { pushTitle: pushTitleValue, pushContent: pushContentValue } = (this._callPushConfig.pushTitle || this._callPushConfig.pushContent) ? this._callPushConfig : { pushTitle, pushContent };
1602
+ return this.__call({ targetId, mediaType, listener, constraints, channelId, extra, pushTitle: pushTitleValue, pushContent: pushContentValue, bitrate });
1591
1603
  });
1592
1604
  }
1593
1605
  __call({ targetId, mediaType = pluginCallEngine.RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', pushTitle = '', pushContent = '', bitrate, isCrossAppkey = false }) {
1594
1606
  return __awaiter(this, void 0, void 0, function* () {
1595
- logger.info(`[RCCallClient call] extra->${extra} pushTitle->${pushTitle} pushContent->${pushContent}`);
1607
+ this._logger.info('_', `[RCCallClient call] extra->${extra} pushTitle->${pushTitle} pushContent->${pushContent}`);
1596
1608
  const conclusion = [validateTargetId(targetId), validateMediaType(mediaType), validateListener(listener), validateExtra(extra), validatePushTitle(pushTitle), validatePushContent(pushContent)];
1597
1609
  const messages = [];
1598
1610
  const result = conclusion.every((obj) => {
@@ -1623,8 +1635,8 @@
1623
1635
  // 调用callEngine的call返回一个状态机的实例
1624
1636
  const { code, stateMachine } = yield this._callEngine.call(channelId, targetId, mediaType, extra, pushTitle, pushContent, isCrossAppkey);
1625
1637
  if (code === pluginCallEngine.RCCallErrorCode.SUCCESS && stateMachine) {
1626
- logger.info('[RCCallClient call] successfully created state machine');
1627
- const session = new RCCallSession(stateMachine, this._rtcClient, {
1638
+ this._logger.info('_', '[RCCallClient call] successfully created state machine');
1639
+ const session = new RCCallSession(stateMachine, this._rtcClient, this._logger, {
1628
1640
  localTracks,
1629
1641
  // 是否允许订阅重试
1630
1642
  isAllowSubscribeRetry: this._options.isAllowSubscribeRetry,
@@ -1642,16 +1654,18 @@
1642
1654
  isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
1643
1655
  // 标明是主叫产生的session
1644
1656
  produceType: ProduceTypes.CALLER,
1645
- isCrossAppkey
1657
+ isCrossAppkey,
1658
+ callPushConfig: this._callPushConfig,
1659
+ hungupPushConfig: this._hungupPushConfig
1646
1660
  });
1647
1661
  // session上注册监听事件
1648
1662
  session.registerSessionListener(listener);
1649
1663
  this._sessionList.push(session);
1650
- logger.info(`[RCCallClient call] successfully created session object, sessionId: ${session.getSessionId()}`);
1664
+ this._logger.info('_', `[RCCallClient call] successfully created session object, sessionId: ${session.getSessionId()}`);
1651
1665
  return { code, session };
1652
1666
  }
1653
1667
  else {
1654
- logger.error(`[RCCallClient call] call failed code ->: ${code}`);
1668
+ this._logger.error('_', `[RCCallClient call] call failed code ->: ${code}`);
1655
1669
  localTracks.forEach(track => {
1656
1670
  // 禁用视频
1657
1671
  track.mute();
@@ -1671,13 +1685,13 @@
1671
1685
  * @param params.constraints 获取音频或音视频资源时的参数 可选
1672
1686
  * @param params.channelId 组织 Id 可选
1673
1687
  * @param params.extra 消息扩展信息 可选
1674
- * @param params.pushTitle 通知的标题
1675
- * @param params.pushContent 通知的内容
1688
+ * @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
1689
+ * @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
1676
1690
  * @param params.bitrate 需要设置的码率参数
1677
1691
  */
1678
- callInGroup({ targetId, userIds, mediaType = pluginCallEngine.RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', pushTitle = '', pushContent = '', bitrate }) {
1692
+ callInGroup({ targetId, userIds, mediaType = pluginCallEngine.RCCallMediaType.AUDIO, listener, constraints, channelId = '', extra = '', bitrate }) {
1679
1693
  return __awaiter(this, void 0, void 0, function* () {
1680
- const conclusion = [validateTargetId(targetId), validateUserIds(userIds), validateMediaType(mediaType), validateListener(listener), validateExtra(extra), validatePushTitle(pushTitle), validatePushContent(pushContent)];
1694
+ const conclusion = [validateTargetId(targetId), validateUserIds(userIds), validateMediaType(mediaType), validateListener(listener), validateExtra(extra)];
1681
1695
  const messages = [];
1682
1696
  const result = conclusion.every((obj) => {
1683
1697
  !obj.result && messages.push(obj.msg);
@@ -1705,10 +1719,11 @@
1705
1719
  listener.onTrackReady(track);
1706
1720
  });
1707
1721
  // 往组里发消息
1722
+ const { pushTitle, pushContent } = this._callPushConfig;
1708
1723
  const { code, stateMachine } = yield this._callEngine.callInGroup(channelId, targetId, mediaType, userIds, extra, pushTitle, pushContent);
1709
1724
  if (code === pluginCallEngine.RCCallErrorCode.SUCCESS && stateMachine) {
1710
- logger.info('[RCCallClient callInGroup] successfully created state machine');
1711
- const session = new RCCallSession(stateMachine, this._rtcClient, {
1725
+ this._logger.info('_', '[RCCallClient callInGroup] successfully created state machine');
1726
+ const session = new RCCallSession(stateMachine, this._rtcClient, this._logger, {
1712
1727
  localTracks,
1713
1728
  // 是否允许订阅重试
1714
1729
  isAllowSubscribeRetry: this._options.isAllowSubscribeRetry,
@@ -1725,16 +1740,18 @@
1725
1740
  // 允许降级获得流,获得音视频不成功 ,降级获得音频, 默认不允许
1726
1741
  isAllowDemotionGetStream: this._options.isAllowDemotionGetStream,
1727
1742
  // 标明是主叫产生的session
1728
- produceType: ProduceTypes.CALLER
1743
+ produceType: ProduceTypes.CALLER,
1744
+ callPushConfig: this._callPushConfig,
1745
+ hungupPushConfig: this._hungupPushConfig
1729
1746
  });
1730
1747
  // session上注册监听事件
1731
1748
  session.registerSessionListener(listener);
1732
1749
  this._sessionList.push(session);
1733
- logger.info(`[RCCallClient callInGroup] successfully created session object, sessionId: ${session.getSessionId()}`);
1750
+ this._logger.info('_', `[RCCallClient callInGroup] successfully created session object, sessionId: ${session.getSessionId()}`);
1734
1751
  return { code, session };
1735
1752
  }
1736
1753
  else {
1737
- logger.info(`[RCCallClient callInGroup] callInGroup failed code -> ${code}`);
1754
+ this._logger.info('_', `[RCCallClient callInGroup] callInGroup failed code -> ${code}`);
1738
1755
  localTracks.forEach(track => {
1739
1756
  // 禁用视频
1740
1757
  track.mute();
@@ -1754,19 +1771,19 @@
1754
1771
  if (mediaType === pluginCallEngine.RCCallMediaType.AUDIO) {
1755
1772
  const { code, track } = yield this._rtcClient.createMicrophoneAudioTrack('RongCloudRTC', constraints && constraints.audio && Object.assign({}, constraints.audio));
1756
1773
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
1757
- logger.error(`[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ${code}`);
1774
+ this._logger.error('_', `[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ${code}`);
1758
1775
  return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR };
1759
1776
  }
1760
- logger.info('[RCCallClient _getTrack] successfully get Audio local tracks');
1777
+ this._logger.info('_', '[RCCallClient _getTrack] successfully get Audio local tracks');
1761
1778
  return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, tracks: [track] };
1762
1779
  }
1763
1780
  else {
1764
1781
  const { code, tracks } = yield this._rtcClient.createMicrophoneAndCameraTracks('RongCloudRTC', constraints && Object.assign({}, constraints));
1765
1782
  if (code !== pluginRtc.RCRTCCode.SUCCESS) {
1766
- logger.error(`[RCCallClient _getTrack] get Audio and Video local tracks failed RCT code -> ${code}`);
1783
+ this._logger.error('_', `[RCCallClient _getTrack] get Audio and Video local tracks failed RCT code -> ${code}`);
1767
1784
  return { code: pluginCallEngine.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR };
1768
1785
  }
1769
- logger.info('[RCCallClient _getTrack] successfully get audio and video local tracks');
1786
+ this._logger.info('_', '[RCCallClient _getTrack] successfully get audio and video local tracks');
1770
1787
  return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, tracks };
1771
1788
  }
1772
1789
  });
@@ -1809,14 +1826,40 @@
1809
1826
  return __awaiter(this, void 0, void 0, function* () {
1810
1827
  const { code, data } = yield this._context.getRTCJoinedUserInfo(this._context.getCurrentId());
1811
1828
  if (code !== engine.ErrorCode.SUCCESS) {
1812
- logger.error('getJoinedUserInfo error', code);
1829
+ this._logger.error('_', `getJoinedUserInfo error code: ${code}`);
1813
1830
  return { code: pluginCallEngine.RCCallErrorCode.QUERY_JOINED_USER_INFO_ERROR };
1814
1831
  }
1815
1832
  return { code: pluginCallEngine.RCCallErrorCode.SUCCESS, data };
1816
1833
  });
1817
1834
  }
1835
+ /**
1836
+ * 设置呼叫、挂断推送数据
1837
+ * @param callPushConfig 呼叫推送配置
1838
+ * @param callPushConfig.pushTitle 呼叫推送标题
1839
+ * @param callPushConfig.pushContent 呼叫推送内容
1840
+ * @param hungupPushConfig 挂断推送配置
1841
+ * @param hungupPushConfig.pushTitle 挂断推送标题
1842
+ * @param hungupPushConfig.pushContent 挂断推送内容
1843
+ */
1844
+ setPushConfig(callPushConfig = {}, hungupPushConfig = {}) {
1845
+ const conclusion = [callPushConfig, hungupPushConfig].map((pushConfig) => {
1846
+ return validatePushConfig(pushConfig);
1847
+ })[0];
1848
+ const messages = [];
1849
+ const result = conclusion.every((obj) => {
1850
+ !obj.result && messages.push(obj.msg);
1851
+ return obj.result;
1852
+ });
1853
+ if (!result) {
1854
+ throw new Error(`[RCCallClient callInGroup callPushConfig or hungupPushConfig] ${messages.join('\n')}`);
1855
+ }
1856
+ this._callPushConfig = callPushConfig;
1857
+ this._hungupPushConfig = hungupPushConfig;
1858
+ }
1818
1859
  }
1819
1860
 
1861
+ // plugin-call 版本上报
1862
+ engine.VersionManage.add('plugin-call', "5.1.2-alpha.2");
1820
1863
  const installer = {
1821
1864
  tag: 'RCCall',
1822
1865
  verify(runtime) {
@@ -1828,10 +1871,13 @@
1828
1871
  if (!conclusion.result) {
1829
1872
  throw new Error(`[RCCallLib installer steup]${conclusion.msg}`);
1830
1873
  }
1831
- logger.setLogLevel(options.logLevel);
1832
- logger.setLogStdout(options.logStdout);
1833
- logger.warn(`RCCall Version: ${"5.1.2-alpha.1"}, Commit: ${"5a6d3a159d1171c71f1bb419dfac59eb8e886f91"}`);
1834
- return new RCCallClient(context, runtime, options);
1874
+ // 校验当前安装的 engine 版本是否可用
1875
+ if (!engine.VersionManage.validEngine("^5.7.0")) {
1876
+ throw new Error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-call required engine version at least '${"^5.7.0"}'.`);
1877
+ }
1878
+ const logger = context.createLogger('RCCall', 'RTC');
1879
+ logger.warn('_', `RCCall Version: ${"5.1.2-alpha.2"}, Commit: ${"8d4f8b00cda704283faad34d0e81a4e048e09d08"}`);
1880
+ return new RCCallClient(context, runtime, logger, options);
1835
1881
  }
1836
1882
  };
1837
1883