@tencentcloud/trtc-cloud-wx 0.0.19 → 0.0.20-beta.1
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/package.json +1 -1
- package/trtc-cloud-wx.js +770 -336
package/trtc-cloud-wx.js
CHANGED
|
@@ -620,9 +620,102 @@ exports.TRTCBeautyStyle = void 0;
|
|
|
620
620
|
TRTCBeautyStyle[TRTCBeautyStyle["TRTCBeautyStyleNature"] = 1] = "TRTCBeautyStyleNature";
|
|
621
621
|
})(exports.TRTCBeautyStyle || (exports.TRTCBeautyStyle = {}));
|
|
622
622
|
|
|
623
|
+
var Handletype;
|
|
624
|
+
(function (Handletype) {
|
|
625
|
+
Handletype["setPusher"] = "setPusher";
|
|
626
|
+
Handletype["setPlayer"] = "setPlayer";
|
|
627
|
+
})(Handletype || (Handletype = {}));
|
|
628
|
+
// 数字越高,set优先级越高
|
|
629
|
+
var TaskMap = {
|
|
630
|
+
enterRoom: {
|
|
631
|
+
priority: 0,
|
|
632
|
+
type: Handletype.setPusher
|
|
633
|
+
},
|
|
634
|
+
switchRole: {
|
|
635
|
+
priority: 1,
|
|
636
|
+
type: Handletype.setPusher
|
|
637
|
+
},
|
|
638
|
+
startLocalPreview: {
|
|
639
|
+
priority: 0,
|
|
640
|
+
type: Handletype.setPusher
|
|
641
|
+
},
|
|
642
|
+
stopLocalPreview: {
|
|
643
|
+
priority: 0,
|
|
644
|
+
type: Handletype.setPusher
|
|
645
|
+
},
|
|
646
|
+
muteLocalVideo: {
|
|
647
|
+
priority: 1,
|
|
648
|
+
type: Handletype.setPusher
|
|
649
|
+
},
|
|
650
|
+
setVideoEncoderParam: {
|
|
651
|
+
priority: 0,
|
|
652
|
+
type: Handletype.setPusher
|
|
653
|
+
},
|
|
654
|
+
setLocalRenderParams: {
|
|
655
|
+
priority: 0,
|
|
656
|
+
type: Handletype.setPusher
|
|
657
|
+
},
|
|
658
|
+
startLocalAudio: {
|
|
659
|
+
priority: 0,
|
|
660
|
+
type: Handletype.setPusher
|
|
661
|
+
},
|
|
662
|
+
stopLocalAudio: {
|
|
663
|
+
priority: 0,
|
|
664
|
+
type: Handletype.setPusher
|
|
665
|
+
},
|
|
666
|
+
muteLocalAudio: {
|
|
667
|
+
priority: 1,
|
|
668
|
+
type: Handletype.setPusher
|
|
669
|
+
},
|
|
670
|
+
switchCamera: {
|
|
671
|
+
priority: 0,
|
|
672
|
+
type: Handletype.setPusher
|
|
673
|
+
},
|
|
674
|
+
setBeautyStyle: {
|
|
675
|
+
priority: 0,
|
|
676
|
+
type: Handletype.setPusher
|
|
677
|
+
},
|
|
678
|
+
exitRoom: {
|
|
679
|
+
priority: 9,
|
|
680
|
+
type: Handletype.setPusher
|
|
681
|
+
},
|
|
682
|
+
startRemoteView: {
|
|
683
|
+
priority: 0,
|
|
684
|
+
type: Handletype.setPlayer
|
|
685
|
+
},
|
|
686
|
+
updateRemoteView: {
|
|
687
|
+
priority: 0,
|
|
688
|
+
type: Handletype.setPlayer
|
|
689
|
+
},
|
|
690
|
+
stopAllRemoteView: {
|
|
691
|
+
priority: 1,
|
|
692
|
+
type: Handletype.setPlayer
|
|
693
|
+
},
|
|
694
|
+
muteRemoteVideoStream: {
|
|
695
|
+
priority: 1,
|
|
696
|
+
type: Handletype.setPlayer
|
|
697
|
+
},
|
|
698
|
+
muteAllRemoteVideoStreams: {
|
|
699
|
+
priority: 1,
|
|
700
|
+
type: Handletype.setPlayer
|
|
701
|
+
},
|
|
702
|
+
setRemoteRenderParams: {
|
|
703
|
+
priority: 0,
|
|
704
|
+
type: Handletype.setPlayer
|
|
705
|
+
},
|
|
706
|
+
muteRemoteAudio: {
|
|
707
|
+
priority: 1,
|
|
708
|
+
type: Handletype.setPlayer
|
|
709
|
+
},
|
|
710
|
+
muteAllRemoteAudio: {
|
|
711
|
+
priority: 1,
|
|
712
|
+
type: Handletype.setPlayer
|
|
713
|
+
}
|
|
714
|
+
};
|
|
623
715
|
var Task = /*#__PURE__*/function () {
|
|
624
716
|
function Task(optinos) {
|
|
625
717
|
_classCallCheck(this, Task);
|
|
718
|
+
var _a;
|
|
626
719
|
var _optinos$priority = optinos.priority,
|
|
627
720
|
priority = _optinos$priority === void 0 ? 0 : _optinos$priority,
|
|
628
721
|
action = optinos.action,
|
|
@@ -639,6 +732,7 @@ var Task = /*#__PURE__*/function () {
|
|
|
639
732
|
this.reject = reject;
|
|
640
733
|
this.name = name;
|
|
641
734
|
this.single = this.whetherSingle(name);
|
|
735
|
+
this.type = ((_a = TaskMap[name]) === null || _a === void 0 ? void 0 : _a.type) || Handletype.setPusher;
|
|
642
736
|
this.sequenceNumber = Task.nextSequenceNumber++;
|
|
643
737
|
}
|
|
644
738
|
_createClass(Task, [{
|
|
@@ -655,22 +749,6 @@ var Task = /*#__PURE__*/function () {
|
|
|
655
749
|
return Task;
|
|
656
750
|
}();
|
|
657
751
|
Task.nextSequenceNumber = 0;
|
|
658
|
-
// 数字越高,set优先级越高
|
|
659
|
-
var TaskPriorityMap = {
|
|
660
|
-
enterRoom: 0,
|
|
661
|
-
switchRole: 1,
|
|
662
|
-
startLocalPreview: 0,
|
|
663
|
-
stopLocalPreview: 0,
|
|
664
|
-
muteLocalVideo: 1,
|
|
665
|
-
setVideoEncoderParam: 0,
|
|
666
|
-
setLocalRenderParams: 0,
|
|
667
|
-
startLocalAudio: 0,
|
|
668
|
-
stopLocalAudio: 0,
|
|
669
|
-
muteLocalAudio: 1,
|
|
670
|
-
switchCamera: 0,
|
|
671
|
-
setBeautyStyle: 0,
|
|
672
|
-
exitRoom: 9
|
|
673
|
-
};
|
|
674
752
|
var TaskQueueState;
|
|
675
753
|
(function (TaskQueueState) {
|
|
676
754
|
TaskQueueState["IDLE"] = "idle";
|
|
@@ -686,13 +764,11 @@ var TaskQueueEvent;
|
|
|
686
764
|
var TaskMachine = /*#__PURE__*/function () {
|
|
687
765
|
function TaskMachine() {
|
|
688
766
|
_classCallCheck(this, TaskMachine);
|
|
689
|
-
this.isProcessing = false; //
|
|
767
|
+
this.isProcessing = false; // 表示 pusherTaskQueue 是否正在处理
|
|
690
768
|
this.pusherDomReady = false;
|
|
769
|
+
this.pusherTaskQueue = []; // 存储所有 pusher 任务
|
|
770
|
+
this.playerTasks = {}; // 存储每个 player 的任务队列
|
|
691
771
|
this.state = TaskQueueState.IDLE;
|
|
692
|
-
this.context = {
|
|
693
|
-
taskQueue: [],
|
|
694
|
-
debounceTimeout: null
|
|
695
|
-
};
|
|
696
772
|
}
|
|
697
773
|
_createClass(TaskMachine, [{
|
|
698
774
|
key: "setPusherDomReady",
|
|
@@ -700,19 +776,42 @@ var TaskMachine = /*#__PURE__*/function () {
|
|
|
700
776
|
this.pusherDomReady = isReady;
|
|
701
777
|
return this.pusherDomReady;
|
|
702
778
|
}
|
|
779
|
+
}, {
|
|
780
|
+
key: "setPlayerDomReady",
|
|
781
|
+
value: function setPlayerDomReady(view, isReady) {
|
|
782
|
+
if (!this.playerTasks[view]) {
|
|
783
|
+
this.playerTasks[view] = {
|
|
784
|
+
taskQueue: [],
|
|
785
|
+
isProcessing: false,
|
|
786
|
+
domReady: false
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
this.playerTasks[view].domReady = isReady;
|
|
790
|
+
if (isReady) {
|
|
791
|
+
this.processPlayerTasks(view);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
703
794
|
}, {
|
|
704
795
|
key: "send",
|
|
705
|
-
value: function send(event) {
|
|
796
|
+
value: function send(event, view) {
|
|
706
797
|
switch (this.state) {
|
|
707
798
|
case TaskQueueState.IDLE:
|
|
708
799
|
if (event === TaskQueueEvent.SET) {
|
|
709
800
|
this.state = TaskQueueState.PENDING;
|
|
710
|
-
|
|
801
|
+
if (view) {
|
|
802
|
+
this.processPlayerTasks(view);
|
|
803
|
+
} else {
|
|
804
|
+
this.processPusherTasks();
|
|
805
|
+
}
|
|
711
806
|
}
|
|
712
807
|
break;
|
|
713
808
|
case TaskQueueState.PENDING:
|
|
714
809
|
if (event === TaskQueueEvent.SETPROCESS) {
|
|
715
|
-
|
|
810
|
+
if (view) {
|
|
811
|
+
this.processPlayerTasks(view);
|
|
812
|
+
} else {
|
|
813
|
+
this.processPusherTasks();
|
|
814
|
+
}
|
|
716
815
|
}
|
|
717
816
|
if (event === TaskQueueEvent.SETDONE) {
|
|
718
817
|
this.state = TaskQueueState.IDLE;
|
|
@@ -728,43 +827,81 @@ var TaskMachine = /*#__PURE__*/function () {
|
|
|
728
827
|
}, {
|
|
729
828
|
key: "addTask",
|
|
730
829
|
value: function addTask(task) {
|
|
731
|
-
|
|
732
|
-
|
|
830
|
+
if (task.type === Handletype.setPusher) {
|
|
831
|
+
this.addPusherTask(task);
|
|
832
|
+
} else {
|
|
833
|
+
this.addPlayerTask(task.args.view, task);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}, {
|
|
837
|
+
key: "addPusherTask",
|
|
838
|
+
value: function addPusherTask(task) {
|
|
839
|
+
this.addTaskToQueue(task, this.pusherTaskQueue);
|
|
840
|
+
if (this.state === TaskQueueState.PROCESS && !this.isProcessing) {
|
|
841
|
+
this.processPusherTasks();
|
|
842
|
+
} else if (this.state === TaskQueueState.IDLE) {
|
|
733
843
|
this.send(TaskQueueEvent.SET);
|
|
734
844
|
} else if (this.state === TaskQueueState.PENDING) {
|
|
735
845
|
this.send(TaskQueueEvent.SETPROCESS);
|
|
736
846
|
}
|
|
737
847
|
}
|
|
848
|
+
}, {
|
|
849
|
+
key: "addPlayerTask",
|
|
850
|
+
value: function addPlayerTask(view, task) {
|
|
851
|
+
if (!this.playerTasks[view]) {
|
|
852
|
+
this.playerTasks[view] = {
|
|
853
|
+
taskQueue: [],
|
|
854
|
+
isProcessing: false,
|
|
855
|
+
domReady: false
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
this.addTaskToQueue(task, this.playerTasks[view].taskQueue);
|
|
859
|
+
if (this.state === TaskQueueState.PROCESS && !this.playerTasks[view].isProcessing) {
|
|
860
|
+
this.processPlayerTasks(view);
|
|
861
|
+
} else if (this.state === TaskQueueState.IDLE) {
|
|
862
|
+
this.send(TaskQueueEvent.SET, view);
|
|
863
|
+
} else if (this.state === TaskQueueState.PENDING) {
|
|
864
|
+
this.send(TaskQueueEvent.SETPROCESS, view);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
738
867
|
}, {
|
|
739
868
|
key: "addTaskToQueue",
|
|
740
|
-
value: function addTaskToQueue(task) {
|
|
741
|
-
|
|
742
|
-
|
|
869
|
+
value: function addTaskToQueue(task, queue) {
|
|
870
|
+
queue.push(task);
|
|
871
|
+
queue.sort(function (a, b) {
|
|
743
872
|
if (a.priority !== b.priority) {
|
|
744
873
|
return a.priority - b.priority;
|
|
745
874
|
}
|
|
746
875
|
return a.sequenceNumber - b.sequenceNumber;
|
|
747
876
|
});
|
|
748
877
|
}
|
|
878
|
+
/**
|
|
879
|
+
* 处理任务队列
|
|
880
|
+
* @param taskQueue
|
|
881
|
+
* @param isProcessing
|
|
882
|
+
* @param domReady
|
|
883
|
+
* @param setProcessing
|
|
884
|
+
* @returns
|
|
885
|
+
*/
|
|
749
886
|
}, {
|
|
750
887
|
key: "processTasks",
|
|
751
|
-
value: function processTasks() {
|
|
888
|
+
value: function processTasks(taskQueue, isProcessing, domReady, setProcessing, view) {
|
|
752
889
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
753
890
|
var _this = this;
|
|
754
|
-
var currentTasks, singleTasks, exceptSingleTask, _iterator, _step, _task3,
|
|
891
|
+
var currentTasks, singleTasks, exceptSingleTask, _iterator, _step, _task3, params, task, sequenceTask, r, _iterator2, _step2, _task, _iterator3, _step3, _task2;
|
|
755
892
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
756
893
|
while (1) switch (_context.prev = _context.next) {
|
|
757
894
|
case 0:
|
|
758
|
-
if (!(
|
|
895
|
+
if (!(isProcessing || !domReady || taskQueue.length === 0)) {
|
|
759
896
|
_context.next = 2;
|
|
760
897
|
break;
|
|
761
898
|
}
|
|
762
899
|
return _context.abrupt("return");
|
|
763
900
|
case 2:
|
|
764
|
-
|
|
901
|
+
setProcessing(true);
|
|
765
902
|
this.state = TaskQueueState.PROCESS;
|
|
766
|
-
currentTasks = _toConsumableArray(
|
|
767
|
-
|
|
903
|
+
currentTasks = _toConsumableArray(taskQueue);
|
|
904
|
+
taskQueue.length = 0;
|
|
768
905
|
singleTasks = currentTasks.filter(function (task) {
|
|
769
906
|
return task.single;
|
|
770
907
|
});
|
|
@@ -782,7 +919,7 @@ var TaskMachine = /*#__PURE__*/function () {
|
|
|
782
919
|
_task3 = _step.value;
|
|
783
920
|
_context.prev = 13;
|
|
784
921
|
_context.next = 16;
|
|
785
|
-
return _task3.action.call(_task3.ctx, _task3.args, _task3.name);
|
|
922
|
+
return _task3.action.call(_task3.ctx, _task3.args, _task3.name, TaskMap[_task3.name].type);
|
|
786
923
|
case 16:
|
|
787
924
|
_task3.result = _context.sent;
|
|
788
925
|
_context.next = 22;
|
|
@@ -806,8 +943,9 @@ var TaskMachine = /*#__PURE__*/function () {
|
|
|
806
943
|
_iterator.f();
|
|
807
944
|
return _context.finish(29);
|
|
808
945
|
case 32:
|
|
809
|
-
|
|
810
|
-
|
|
946
|
+
params = exceptSingleTask.reduce(function (acc, cur) {
|
|
947
|
+
var params = cur.args.params;
|
|
948
|
+
return Object.assign(Object.assign({}, acc), typeof params === 'function' ? params() : params);
|
|
811
949
|
}, {});
|
|
812
950
|
task = exceptSingleTask[0];
|
|
813
951
|
sequenceTask = currentTasks.sort(function (a, b) {
|
|
@@ -816,14 +954,31 @@ var TaskMachine = /*#__PURE__*/function () {
|
|
|
816
954
|
_context.prev = 35;
|
|
817
955
|
r = null;
|
|
818
956
|
if (!task) {
|
|
819
|
-
_context.next =
|
|
957
|
+
_context.next = 47;
|
|
820
958
|
break;
|
|
821
959
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
960
|
+
if (!view) {
|
|
961
|
+
_context.next = 44;
|
|
962
|
+
break;
|
|
963
|
+
}
|
|
964
|
+
_context.next = 41;
|
|
965
|
+
return task.action.call(task.ctx, {
|
|
966
|
+
params: params,
|
|
967
|
+
streamId: task.args.streamId,
|
|
968
|
+
view: view
|
|
969
|
+
}, task.name, Handletype.setPlayer);
|
|
826
970
|
case 41:
|
|
971
|
+
r = _context.sent;
|
|
972
|
+
_context.next = 47;
|
|
973
|
+
break;
|
|
974
|
+
case 44:
|
|
975
|
+
_context.next = 46;
|
|
976
|
+
return task.action.call(task.ctx, {
|
|
977
|
+
params: params
|
|
978
|
+
}, task.name, Handletype.setPusher);
|
|
979
|
+
case 46:
|
|
980
|
+
r = _context.sent;
|
|
981
|
+
case 47:
|
|
827
982
|
_iterator2 = _createForOfIteratorHelper(sequenceTask);
|
|
828
983
|
try {
|
|
829
984
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -839,10 +994,10 @@ var TaskMachine = /*#__PURE__*/function () {
|
|
|
839
994
|
} finally {
|
|
840
995
|
_iterator2.f();
|
|
841
996
|
}
|
|
842
|
-
_context.next =
|
|
997
|
+
_context.next = 55;
|
|
843
998
|
break;
|
|
844
|
-
case
|
|
845
|
-
_context.prev =
|
|
999
|
+
case 51:
|
|
1000
|
+
_context.prev = 51;
|
|
846
1001
|
_context.t2 = _context["catch"](35);
|
|
847
1002
|
_iterator3 = _createForOfIteratorHelper(sequenceTask);
|
|
848
1003
|
try {
|
|
@@ -855,19 +1010,63 @@ var TaskMachine = /*#__PURE__*/function () {
|
|
|
855
1010
|
} finally {
|
|
856
1011
|
_iterator3.f();
|
|
857
1012
|
}
|
|
858
|
-
case
|
|
859
|
-
|
|
860
|
-
this.send(TaskQueueEvent.SETDONE);
|
|
861
|
-
if (
|
|
1013
|
+
case 55:
|
|
1014
|
+
setProcessing(false);
|
|
1015
|
+
this.send(TaskQueueEvent.SETDONE, view);
|
|
1016
|
+
if (taskQueue.length > 0) {
|
|
862
1017
|
Promise.resolve().then(function () {
|
|
863
|
-
_this.processTasks();
|
|
1018
|
+
_this.processTasks(taskQueue, isProcessing, domReady, setProcessing, view);
|
|
864
1019
|
})["catch"](console.error);
|
|
865
1020
|
}
|
|
866
|
-
case
|
|
1021
|
+
case 58:
|
|
867
1022
|
case "end":
|
|
868
1023
|
return _context.stop();
|
|
869
1024
|
}
|
|
870
|
-
}, _callee, this, [[9, 26, 29, 32], [13, 19], [35,
|
|
1025
|
+
}, _callee, this, [[9, 26, 29, 32], [13, 19], [35, 51]]);
|
|
1026
|
+
}));
|
|
1027
|
+
}
|
|
1028
|
+
}, {
|
|
1029
|
+
key: "processPusherTasks",
|
|
1030
|
+
value: function processPusherTasks() {
|
|
1031
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1032
|
+
var _this2 = this;
|
|
1033
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1034
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1035
|
+
case 0:
|
|
1036
|
+
_context2.next = 2;
|
|
1037
|
+
return this.processTasks(this.pusherTaskQueue, this.isProcessing, this.pusherDomReady, function (value) {
|
|
1038
|
+
_this2.isProcessing = value;
|
|
1039
|
+
});
|
|
1040
|
+
case 2:
|
|
1041
|
+
case "end":
|
|
1042
|
+
return _context2.stop();
|
|
1043
|
+
}
|
|
1044
|
+
}, _callee2, this);
|
|
1045
|
+
}));
|
|
1046
|
+
}
|
|
1047
|
+
}, {
|
|
1048
|
+
key: "processPlayerTasks",
|
|
1049
|
+
value: function processPlayerTasks(view) {
|
|
1050
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
1051
|
+
var _this3 = this;
|
|
1052
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1053
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1054
|
+
case 0:
|
|
1055
|
+
if (this.playerTasks[view]) {
|
|
1056
|
+
_context3.next = 2;
|
|
1057
|
+
break;
|
|
1058
|
+
}
|
|
1059
|
+
return _context3.abrupt("return");
|
|
1060
|
+
case 2:
|
|
1061
|
+
_context3.next = 4;
|
|
1062
|
+
return this.processTasks(this.playerTasks[view].taskQueue, this.playerTasks[view].isProcessing, this.playerTasks[view].domReady, function (value) {
|
|
1063
|
+
_this3.playerTasks[view].isProcessing = value;
|
|
1064
|
+
}, view);
|
|
1065
|
+
case 4:
|
|
1066
|
+
case "end":
|
|
1067
|
+
return _context3.stop();
|
|
1068
|
+
}
|
|
1069
|
+
}, _callee3, this);
|
|
871
1070
|
}));
|
|
872
1071
|
}
|
|
873
1072
|
}]);
|
|
@@ -877,22 +1076,27 @@ var taskMachine = new TaskMachine();
|
|
|
877
1076
|
var setHandle = function setHandle(target, key, descriptor) {
|
|
878
1077
|
var originalMethod = descriptor.value;
|
|
879
1078
|
descriptor.value = function () {
|
|
880
|
-
var
|
|
1079
|
+
var _this4 = this;
|
|
881
1080
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
882
1081
|
args[_key] = arguments[_key];
|
|
883
1082
|
}
|
|
1083
|
+
var params = args[0],
|
|
1084
|
+
funName = args[1];
|
|
884
1085
|
return new Promise(function (resolve, reject) {
|
|
885
|
-
var
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1086
|
+
var _a;
|
|
1087
|
+
try {
|
|
1088
|
+
taskMachine.addTask(new Task({
|
|
1089
|
+
ctx: _this4,
|
|
1090
|
+
priority: ((_a = TaskMap[funName]) === null || _a === void 0 ? void 0 : _a.priority) || 0,
|
|
1091
|
+
action: originalMethod,
|
|
1092
|
+
args: params,
|
|
1093
|
+
name: funName,
|
|
1094
|
+
resolve: resolve,
|
|
1095
|
+
reject: reject
|
|
1096
|
+
}));
|
|
1097
|
+
} catch (error) {
|
|
1098
|
+
reject(error);
|
|
1099
|
+
}
|
|
896
1100
|
});
|
|
897
1101
|
};
|
|
898
1102
|
return descriptor;
|
|
@@ -1150,7 +1354,7 @@ var Logger = /*#__PURE__*/function () {
|
|
|
1150
1354
|
var logger = new Logger();
|
|
1151
1355
|
|
|
1152
1356
|
var name = "@tencentcloud/trtc-cloud-wx";
|
|
1153
|
-
var version = "0.0.
|
|
1357
|
+
var version = "0.0.20-beta.1";
|
|
1154
1358
|
var description = "";
|
|
1155
1359
|
var main = "dist/trtc-cloud-wx.js";
|
|
1156
1360
|
var module$1 = "dist/trtc-cloud-wx.js";
|
|
@@ -1300,6 +1504,16 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1300
1504
|
taskMachine.send(TaskQueueEvent.SETDONE);
|
|
1301
1505
|
}
|
|
1302
1506
|
});
|
|
1507
|
+
this.InterfaceEventEmitter.on('playerDomReady', function (_ref) {
|
|
1508
|
+
var isReady = _ref.isReady,
|
|
1509
|
+
view = _ref.view;
|
|
1510
|
+
taskMachine.setPlayerDomReady(view, isReady);
|
|
1511
|
+
if (isReady) {
|
|
1512
|
+
taskMachine.send(TaskQueueEvent.SETPROCESS, view);
|
|
1513
|
+
} else {
|
|
1514
|
+
taskMachine.send(TaskQueueEvent.SETDONE, view);
|
|
1515
|
+
}
|
|
1516
|
+
});
|
|
1303
1517
|
}
|
|
1304
1518
|
}, {
|
|
1305
1519
|
key: "bindTRTCEvent",
|
|
@@ -1521,18 +1735,20 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1521
1735
|
this.userId = userId;
|
|
1522
1736
|
this.isEnterRoom = true;
|
|
1523
1737
|
_context2.next = 8;
|
|
1524
|
-
return this.
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1738
|
+
return this.setAttributes({
|
|
1739
|
+
params: {
|
|
1740
|
+
sdkAppID: sdkAppId,
|
|
1741
|
+
userID: userId,
|
|
1742
|
+
userSig: userSig,
|
|
1743
|
+
roomID: roomId,
|
|
1744
|
+
strRoomID: strRoomId,
|
|
1745
|
+
role: role,
|
|
1746
|
+
privateMapKey: privateMapKey,
|
|
1747
|
+
scene: translateTRTCAppScene(scene),
|
|
1748
|
+
enableMic: false,
|
|
1749
|
+
enableCamera: false,
|
|
1750
|
+
videoPreview: false
|
|
1751
|
+
}
|
|
1536
1752
|
}, 'enterRoom');
|
|
1537
1753
|
case 8:
|
|
1538
1754
|
this.trtc.getPusherInstance().start({
|
|
@@ -1551,9 +1767,11 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1551
1767
|
break;
|
|
1552
1768
|
}
|
|
1553
1769
|
_context.next = 7;
|
|
1554
|
-
return this.
|
|
1555
|
-
|
|
1556
|
-
|
|
1770
|
+
return this.setAttributes({
|
|
1771
|
+
params: {
|
|
1772
|
+
videoPreview: false,
|
|
1773
|
+
enableCamera: true
|
|
1774
|
+
}
|
|
1557
1775
|
}, 'other');
|
|
1558
1776
|
case 7:
|
|
1559
1777
|
this.emit('onSendFirstLocalVideoFrame', exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
@@ -1626,9 +1844,11 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1626
1844
|
return _context3.abrupt("return");
|
|
1627
1845
|
case 7:
|
|
1628
1846
|
_context3.next = 9;
|
|
1629
|
-
return this.
|
|
1630
|
-
|
|
1631
|
-
|
|
1847
|
+
return this.setAttributes({
|
|
1848
|
+
params: {
|
|
1849
|
+
enableCamera: false,
|
|
1850
|
+
enableMic: false
|
|
1851
|
+
}
|
|
1632
1852
|
}, 'switchRole');
|
|
1633
1853
|
case 9:
|
|
1634
1854
|
logger.info('switchRole success');
|
|
@@ -1671,12 +1891,14 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1671
1891
|
return _context4.abrupt("return");
|
|
1672
1892
|
case 3:
|
|
1673
1893
|
_context4.next = 5;
|
|
1674
|
-
return this.
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1894
|
+
return this.setAttributes({
|
|
1895
|
+
params: function params() {
|
|
1896
|
+
return {
|
|
1897
|
+
videoPreview: _this8.isEnterRoom ? _this8.isVideoMuted : true,
|
|
1898
|
+
enableCamera: _this8.isEnterRoom ? !_this8.isVideoMuted : false,
|
|
1899
|
+
frontCamera: frontCamera ? 'front' : 'back'
|
|
1900
|
+
};
|
|
1901
|
+
}
|
|
1680
1902
|
}, 'startLocalPreview');
|
|
1681
1903
|
case 5:
|
|
1682
1904
|
pusher = _context4.sent;
|
|
@@ -1706,9 +1928,11 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1706
1928
|
case 0:
|
|
1707
1929
|
logger.info('stopLocalPreview');
|
|
1708
1930
|
_context5.next = 3;
|
|
1709
|
-
return this.
|
|
1710
|
-
|
|
1711
|
-
|
|
1931
|
+
return this.setAttributes({
|
|
1932
|
+
params: {
|
|
1933
|
+
videoPreview: false,
|
|
1934
|
+
enableCamera: false
|
|
1935
|
+
}
|
|
1712
1936
|
}, 'stopLocalPreview');
|
|
1713
1937
|
case 3:
|
|
1714
1938
|
logger.info('stopLocalPreview success');
|
|
@@ -1764,18 +1988,20 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1764
1988
|
logger.info('muteLocalVideo: isVideoMuted set to ', mute);
|
|
1765
1989
|
_context6.prev = 9;
|
|
1766
1990
|
_context6.next = 12;
|
|
1767
|
-
return this.
|
|
1768
|
-
|
|
1769
|
-
|
|
1991
|
+
return this.setAttributes({
|
|
1992
|
+
params: {
|
|
1993
|
+
videoPreview: mute,
|
|
1994
|
+
enableCamera: !mute
|
|
1995
|
+
}
|
|
1770
1996
|
}, 'muteLocalVideo');
|
|
1771
1997
|
case 12:
|
|
1772
|
-
logger.info('muteLocalVideo:
|
|
1998
|
+
logger.info('muteLocalVideo: setAttributes success');
|
|
1773
1999
|
_context6.next = 18;
|
|
1774
2000
|
break;
|
|
1775
2001
|
case 15:
|
|
1776
2002
|
_context6.prev = 15;
|
|
1777
2003
|
_context6.t1 = _context6["catch"](9);
|
|
1778
|
-
logger.error('muteLocalVideo:
|
|
2004
|
+
logger.error('muteLocalVideo: setAttributes failed with error ', _context6.t1);
|
|
1779
2005
|
case 18:
|
|
1780
2006
|
logger.info('muteLocalVideo success');
|
|
1781
2007
|
return _context6.abrupt("break", 21);
|
|
@@ -1798,23 +2024,32 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1798
2024
|
}, {
|
|
1799
2025
|
key: "startRemoteView",
|
|
1800
2026
|
value: function startRemoteView(userId, view, streamType) {
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
2027
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
2028
|
+
var streamId;
|
|
2029
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
2030
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
2031
|
+
case 0:
|
|
2032
|
+
logger.info('startRemoteView with options: ', userId, view, streamType);
|
|
2033
|
+
streamId = translateTRTCStreamId(userId, streamType);
|
|
2034
|
+
this.renderMap.set(streamId, view);
|
|
2035
|
+
_context7.next = 5;
|
|
2036
|
+
return this.setAttributes({
|
|
2037
|
+
params: {
|
|
2038
|
+
muteVideo: false,
|
|
2039
|
+
stopVideo: false
|
|
2040
|
+
},
|
|
2041
|
+
streamId: streamId,
|
|
2042
|
+
view: view
|
|
2043
|
+
}, 'startRemoteView');
|
|
2044
|
+
case 5:
|
|
2045
|
+
logger.info('startRemoteView success');
|
|
2046
|
+
this.emit('onFirstVideoFrame', userId, streamType, 0, 0);
|
|
2047
|
+
case 7:
|
|
2048
|
+
case "end":
|
|
2049
|
+
return _context7.stop();
|
|
2050
|
+
}
|
|
2051
|
+
}, _callee7, this);
|
|
2052
|
+
}));
|
|
1818
2053
|
}
|
|
1819
2054
|
/**
|
|
1820
2055
|
* 停止显示远端视频画面,同时不再拉取该远端用户的视频数据流
|
|
@@ -1824,20 +2059,30 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1824
2059
|
}, {
|
|
1825
2060
|
key: "stopRemoteView",
|
|
1826
2061
|
value: function stopRemoteView(userId, streamType) {
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
2062
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
2063
|
+
var streamId;
|
|
2064
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
2065
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
2066
|
+
case 0:
|
|
2067
|
+
logger.info('stopRemoteView with options: ', userId, streamType);
|
|
2068
|
+
streamId = translateTRTCStreamId(userId, streamType);
|
|
2069
|
+
_context8.next = 4;
|
|
2070
|
+
return this.setAttributes({
|
|
2071
|
+
params: {
|
|
2072
|
+
muteVideo: true,
|
|
2073
|
+
stopVideo: true
|
|
2074
|
+
},
|
|
2075
|
+
streamId: streamId,
|
|
2076
|
+
view: this.renderMap.get(streamId)
|
|
2077
|
+
}, 'stopRemoteView');
|
|
2078
|
+
case 4:
|
|
2079
|
+
logger.info('stopRemoteView success');
|
|
2080
|
+
case 5:
|
|
2081
|
+
case "end":
|
|
2082
|
+
return _context8.stop();
|
|
2083
|
+
}
|
|
2084
|
+
}, _callee8, this);
|
|
2085
|
+
}));
|
|
1841
2086
|
}
|
|
1842
2087
|
/**
|
|
1843
2088
|
* 修改远端视频渲染的 HTML 元素,小程序不支持
|
|
@@ -1851,75 +2096,141 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1851
2096
|
}, {
|
|
1852
2097
|
key: "updateRemoteView",
|
|
1853
2098
|
value: function updateRemoteView(userId, view, streamType) {
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
2099
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
2100
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
2101
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
2102
|
+
case 0:
|
|
2103
|
+
logger.info('updateRemoteView with options: ', userId, view, streamType);
|
|
2104
|
+
if (!(view !== null)) {
|
|
2105
|
+
_context9.next = 5;
|
|
2106
|
+
break;
|
|
2107
|
+
}
|
|
2108
|
+
_context9.next = 4;
|
|
2109
|
+
return this.startRemoteView(userId, view, streamType);
|
|
2110
|
+
case 4:
|
|
2111
|
+
return _context9.abrupt("return");
|
|
2112
|
+
case 5:
|
|
2113
|
+
_context9.next = 7;
|
|
2114
|
+
return this.stopRemoteView(userId, streamType);
|
|
2115
|
+
case 7:
|
|
2116
|
+
case "end":
|
|
2117
|
+
return _context9.stop();
|
|
2118
|
+
}
|
|
2119
|
+
}, _callee9, this);
|
|
2120
|
+
}));
|
|
1860
2121
|
}
|
|
1861
2122
|
// 停止显示所有远端视频画面,同时不再拉取该远端用户的视频数据流
|
|
1862
2123
|
}, {
|
|
1863
2124
|
key: "stopAllRemoteView",
|
|
1864
2125
|
value: function stopAllRemoteView() {
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
2126
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
2127
|
+
var _this9 = this;
|
|
2128
|
+
var playerList;
|
|
2129
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
2130
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
2131
|
+
case 0:
|
|
2132
|
+
logger.info('stopAllRemoteView');
|
|
2133
|
+
playerList = this.trtc.getPlayerList();
|
|
2134
|
+
playerList.forEach(function (player) {
|
|
2135
|
+
return __awaiter(_this9, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
2136
|
+
var streamId;
|
|
2137
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
2138
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
2139
|
+
case 0:
|
|
2140
|
+
streamId = player.streamID;
|
|
2141
|
+
_context10.next = 3;
|
|
2142
|
+
return this.setAttributes({
|
|
2143
|
+
params: {
|
|
2144
|
+
muteVideo: true,
|
|
2145
|
+
stopVideo: true
|
|
2146
|
+
},
|
|
2147
|
+
streamId: streamId,
|
|
2148
|
+
view: this.renderMap.get(streamId)
|
|
2149
|
+
}, 'stopAllRemoteView');
|
|
2150
|
+
case 3:
|
|
2151
|
+
case "end":
|
|
2152
|
+
return _context10.stop();
|
|
2153
|
+
}
|
|
2154
|
+
}, _callee10, this);
|
|
2155
|
+
}));
|
|
2156
|
+
});
|
|
2157
|
+
logger.info('stopAllRemoteView success');
|
|
2158
|
+
case 4:
|
|
2159
|
+
case "end":
|
|
2160
|
+
return _context11.stop();
|
|
1880
2161
|
}
|
|
1881
|
-
});
|
|
1882
|
-
});
|
|
2162
|
+
}, _callee11, this);
|
|
2163
|
+
}));
|
|
1883
2164
|
}
|
|
1884
2165
|
// 暂停接收指定的远端视频流
|
|
1885
2166
|
// 该接口仅停止接收远程用户的视频流,但并不释放显示资源,所以视频画面会冻屏在 mute 前的最后一帧。
|
|
1886
2167
|
}, {
|
|
1887
2168
|
key: "muteRemoteVideoStream",
|
|
1888
2169
|
value: function muteRemoteVideoStream(userId, mute, streamType) {
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
2170
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
2171
|
+
var streamId;
|
|
2172
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
2173
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
2174
|
+
case 0:
|
|
2175
|
+
logger.info('muteRemoteVideoStream');
|
|
2176
|
+
streamId = translateTRTCStreamId(userId, streamType);
|
|
2177
|
+
_context12.next = 4;
|
|
2178
|
+
return this.setAttributes({
|
|
2179
|
+
params: {
|
|
2180
|
+
muteVideo: mute
|
|
2181
|
+
},
|
|
2182
|
+
streamId: streamId,
|
|
2183
|
+
view: this.renderMap.get(streamId)
|
|
2184
|
+
}, 'muteRemoteVideoStream');
|
|
2185
|
+
case 4:
|
|
2186
|
+
logger.info('muteRemoteVideoStream success');
|
|
2187
|
+
case 5:
|
|
2188
|
+
case "end":
|
|
2189
|
+
return _context12.stop();
|
|
2190
|
+
}
|
|
2191
|
+
}, _callee12, this);
|
|
2192
|
+
}));
|
|
1902
2193
|
}
|
|
1903
2194
|
}, {
|
|
1904
2195
|
key: "muteAllRemoteVideoStreams",
|
|
1905
2196
|
value: function muteAllRemoteVideoStreams(mute) {
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
2197
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
2198
|
+
var _this10 = this;
|
|
2199
|
+
var playerList;
|
|
2200
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
2201
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
2202
|
+
case 0:
|
|
2203
|
+
logger.info('muteAllRemoteVideoStreams with options: ', mute);
|
|
2204
|
+
playerList = this.trtc.getPlayerList();
|
|
2205
|
+
playerList.forEach(function (player) {
|
|
2206
|
+
return __awaiter(_this10, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
2207
|
+
var streamId;
|
|
2208
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
2209
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2210
|
+
case 0:
|
|
2211
|
+
streamId = player.streamID;
|
|
2212
|
+
_context13.next = 3;
|
|
2213
|
+
return this.setAttributes({
|
|
2214
|
+
params: {
|
|
2215
|
+
muteVideo: mute
|
|
2216
|
+
},
|
|
2217
|
+
streamId: streamId,
|
|
2218
|
+
view: this.renderMap.get(streamId)
|
|
2219
|
+
}, 'muteAllRemoteVideoStreams');
|
|
2220
|
+
case 3:
|
|
2221
|
+
case "end":
|
|
2222
|
+
return _context13.stop();
|
|
2223
|
+
}
|
|
2224
|
+
}, _callee13, this);
|
|
2225
|
+
}));
|
|
2226
|
+
});
|
|
2227
|
+
logger.info('muteAllRemoteVideoStreams success');
|
|
2228
|
+
case 4:
|
|
2229
|
+
case "end":
|
|
2230
|
+
return _context14.stop();
|
|
1920
2231
|
}
|
|
1921
|
-
});
|
|
1922
|
-
});
|
|
2232
|
+
}, _callee14, this);
|
|
2233
|
+
}));
|
|
1923
2234
|
}
|
|
1924
2235
|
}, {
|
|
1925
2236
|
key: "setTRTCPlayerAttributes",
|
|
@@ -1932,55 +2243,59 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1932
2243
|
}, {
|
|
1933
2244
|
key: "setVideoEncoderParam",
|
|
1934
2245
|
value: function setVideoEncoderParam(params) {
|
|
1935
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2246
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
1936
2247
|
var videoResolution, videoFps, minVideoBitrate, _translateTRTCVideoRe, videoWidth, videoHeight;
|
|
1937
|
-
return _regeneratorRuntime().wrap(function
|
|
1938
|
-
while (1) switch (
|
|
2248
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
2249
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1939
2250
|
case 0:
|
|
1940
2251
|
logger.info('setVideoEncoderParam with options: ', JSON.stringify(params));
|
|
1941
2252
|
videoResolution = params.videoResolution, params.resMode, videoFps = params.videoFps, params.videoBitrate, minVideoBitrate = params.minVideoBitrate;
|
|
1942
|
-
_translateTRTCVideoRe = translateTRTCVideoResolution(videoResolution), videoWidth = _translateTRTCVideoRe.videoWidth, videoHeight = _translateTRTCVideoRe.videoHeight;
|
|
1943
|
-
|
|
1944
|
-
return this.
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
2253
|
+
_translateTRTCVideoRe = translateTRTCVideoResolution(videoResolution), videoWidth = _translateTRTCVideoRe.videoWidth, videoHeight = _translateTRTCVideoRe.videoHeight;
|
|
2254
|
+
_context15.next = 5;
|
|
2255
|
+
return this.setAttributes({
|
|
2256
|
+
params: {
|
|
2257
|
+
videoWidth: videoWidth,
|
|
2258
|
+
videoHeight: videoHeight,
|
|
2259
|
+
// videoOrientation,
|
|
2260
|
+
fps: videoFps,
|
|
2261
|
+
minBitrate: minVideoBitrate
|
|
2262
|
+
}
|
|
1950
2263
|
}, 'setVideoEncoderParam');
|
|
1951
2264
|
case 5:
|
|
1952
2265
|
logger.info('setVideoEncoderParam success');
|
|
1953
2266
|
case 6:
|
|
1954
2267
|
case "end":
|
|
1955
|
-
return
|
|
2268
|
+
return _context15.stop();
|
|
1956
2269
|
}
|
|
1957
|
-
},
|
|
2270
|
+
}, _callee15, this);
|
|
1958
2271
|
}));
|
|
1959
2272
|
}
|
|
1960
2273
|
}, {
|
|
1961
2274
|
key: "setLocalRenderParams",
|
|
1962
2275
|
value: function setLocalRenderParams(params) {
|
|
1963
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2276
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1964
2277
|
var rotation, mirrorType, videoOrientation, localMirror;
|
|
1965
|
-
return _regeneratorRuntime().wrap(function
|
|
1966
|
-
while (1) switch (
|
|
2278
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
2279
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1967
2280
|
case 0:
|
|
1968
2281
|
logger.info('setLocalRenderParams with options: ', JSON.stringify(params));
|
|
1969
2282
|
rotation = params.rotation, params.fillMode, mirrorType = params.mirrorType;
|
|
1970
2283
|
videoOrientation = translateTRTCVideoRotation(rotation);
|
|
1971
2284
|
localMirror = translateTRTCVideoMirrorType(mirrorType);
|
|
1972
|
-
|
|
1973
|
-
return this.
|
|
1974
|
-
|
|
1975
|
-
|
|
2285
|
+
_context16.next = 6;
|
|
2286
|
+
return this.setAttributes({
|
|
2287
|
+
params: {
|
|
2288
|
+
videoOrientation: videoOrientation,
|
|
2289
|
+
localMirror: localMirror
|
|
2290
|
+
}
|
|
1976
2291
|
}, 'setLocalRenderParams');
|
|
1977
2292
|
case 6:
|
|
1978
2293
|
logger.info('setLocalRenderParams success');
|
|
1979
2294
|
case 7:
|
|
1980
2295
|
case "end":
|
|
1981
|
-
return
|
|
2296
|
+
return _context16.stop();
|
|
1982
2297
|
}
|
|
1983
|
-
},
|
|
2298
|
+
}, _callee16, this);
|
|
1984
2299
|
}));
|
|
1985
2300
|
}
|
|
1986
2301
|
/**
|
|
@@ -1992,41 +2307,51 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1992
2307
|
}, {
|
|
1993
2308
|
key: "setRemoteRenderParams",
|
|
1994
2309
|
value: function setRemoteRenderParams(userId, streamType, params) {
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2310
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
2311
|
+
var fillMode, rotation, streamId;
|
|
2312
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
2313
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2314
|
+
case 0:
|
|
2315
|
+
logger.info('setRemoteRenderParams with options: ', userId, streamType, JSON.stringify(params));
|
|
2316
|
+
fillMode = params.fillMode, rotation = params.rotation, params.mirrorType;
|
|
2317
|
+
streamId = translateTRTCStreamId(userId, streamType); // 音频默认都是主流
|
|
2318
|
+
_context17.next = 5;
|
|
2319
|
+
return this.setAttributes({
|
|
2320
|
+
params: {
|
|
2321
|
+
objectFit: translateVideoFillMod(fillMode),
|
|
2322
|
+
orientation: translateTRTCVideoRotation(rotation)
|
|
2323
|
+
},
|
|
2324
|
+
streamId: streamId,
|
|
2325
|
+
view: this.renderMap.get(streamId)
|
|
2326
|
+
}, 'setRemoteRenderParams');
|
|
2327
|
+
case 5:
|
|
2328
|
+
logger.info('setRemoteRenderParams success');
|
|
2329
|
+
case 6:
|
|
2330
|
+
case "end":
|
|
2331
|
+
return _context17.stop();
|
|
2332
|
+
}
|
|
2333
|
+
}, _callee17, this);
|
|
2334
|
+
}));
|
|
2012
2335
|
}
|
|
2013
2336
|
}, {
|
|
2014
2337
|
key: "startLocalAudio",
|
|
2015
2338
|
value: function startLocalAudio(quality) {
|
|
2016
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2017
|
-
return _regeneratorRuntime().wrap(function
|
|
2018
|
-
while (1) switch (
|
|
2339
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
2340
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
2341
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
2019
2342
|
case 0:
|
|
2020
2343
|
logger.info('startLocalAudio with options: ', quality);
|
|
2021
2344
|
if (!(this.role !== exports.TRTCRoleType.TRTCRoleAnchor)) {
|
|
2022
|
-
|
|
2345
|
+
_context18.next = 3;
|
|
2023
2346
|
break;
|
|
2024
2347
|
}
|
|
2025
2348
|
throw new Error('Current role is audience, unable to access mic. Call switchRole to become a host.');
|
|
2026
2349
|
case 3:
|
|
2027
|
-
|
|
2028
|
-
return this.
|
|
2029
|
-
|
|
2350
|
+
_context18.next = 5;
|
|
2351
|
+
return this.setAttributes({
|
|
2352
|
+
params: {
|
|
2353
|
+
enableMic: true
|
|
2354
|
+
}
|
|
2030
2355
|
}, 'startLocalAudio');
|
|
2031
2356
|
case 5:
|
|
2032
2357
|
logger.info('startLocalAudio success');
|
|
@@ -2037,112 +2362,146 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
2037
2362
|
}
|
|
2038
2363
|
case 9:
|
|
2039
2364
|
case "end":
|
|
2040
|
-
return
|
|
2365
|
+
return _context18.stop();
|
|
2041
2366
|
}
|
|
2042
|
-
},
|
|
2367
|
+
}, _callee18, this);
|
|
2043
2368
|
}));
|
|
2044
2369
|
}
|
|
2045
2370
|
}, {
|
|
2046
2371
|
key: "stopLocalAudio",
|
|
2047
2372
|
value: function stopLocalAudio() {
|
|
2048
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2049
|
-
return _regeneratorRuntime().wrap(function
|
|
2050
|
-
while (1) switch (
|
|
2373
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
2374
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2375
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
2051
2376
|
case 0:
|
|
2052
2377
|
logger.info('stopLocalAudio');
|
|
2053
|
-
|
|
2054
|
-
return this.
|
|
2055
|
-
|
|
2378
|
+
_context19.next = 3;
|
|
2379
|
+
return this.setAttributes({
|
|
2380
|
+
params: {
|
|
2381
|
+
enableMic: false
|
|
2382
|
+
}
|
|
2056
2383
|
}, 'stopLocalAudio');
|
|
2057
2384
|
case 3:
|
|
2058
2385
|
logger.info('stopLocalAudio success');
|
|
2059
2386
|
this.emit('onUserAudioAvailable', this.userId, 0);
|
|
2060
2387
|
case 5:
|
|
2061
2388
|
case "end":
|
|
2062
|
-
return
|
|
2389
|
+
return _context19.stop();
|
|
2063
2390
|
}
|
|
2064
|
-
},
|
|
2391
|
+
}, _callee19, this);
|
|
2065
2392
|
}));
|
|
2066
2393
|
}
|
|
2067
2394
|
}, {
|
|
2068
2395
|
key: "muteLocalAudio",
|
|
2069
2396
|
value: function muteLocalAudio(mute) {
|
|
2070
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2071
|
-
return _regeneratorRuntime().wrap(function
|
|
2072
|
-
while (1) switch (
|
|
2397
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
2398
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2399
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
2073
2400
|
case 0:
|
|
2074
2401
|
logger.info('muteLocalAudio called with options: ', mute);
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
return this.
|
|
2078
|
-
|
|
2402
|
+
_context20.prev = 1;
|
|
2403
|
+
_context20.next = 4;
|
|
2404
|
+
return this.setAttributes({
|
|
2405
|
+
params: {
|
|
2406
|
+
muted: mute
|
|
2407
|
+
}
|
|
2079
2408
|
}, 'muteLocalAudio');
|
|
2080
2409
|
case 4:
|
|
2081
|
-
logger.info('
|
|
2082
|
-
|
|
2410
|
+
logger.info('setAttributes executed successfully');
|
|
2411
|
+
_context20.next = 11;
|
|
2083
2412
|
break;
|
|
2084
2413
|
case 7:
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
logger.error('Error in
|
|
2088
|
-
throw
|
|
2414
|
+
_context20.prev = 7;
|
|
2415
|
+
_context20.t0 = _context20["catch"](1);
|
|
2416
|
+
logger.error('Error in setAttributes: ', _context20.t0);
|
|
2417
|
+
throw _context20.t0;
|
|
2089
2418
|
case 11:
|
|
2090
|
-
|
|
2419
|
+
_context20.prev = 11;
|
|
2091
2420
|
this.emit('onUserAudioAvailable', this.userId, mute === true ? 0 : 1);
|
|
2092
2421
|
logger.info('onUserAudioAvailable event emitted successfully');
|
|
2093
|
-
|
|
2422
|
+
_context20.next = 20;
|
|
2094
2423
|
break;
|
|
2095
2424
|
case 16:
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
logger.error('Error in emitting onUserAudioAvailable event: ',
|
|
2099
|
-
throw
|
|
2425
|
+
_context20.prev = 16;
|
|
2426
|
+
_context20.t1 = _context20["catch"](11);
|
|
2427
|
+
logger.error('Error in emitting onUserAudioAvailable event: ', _context20.t1);
|
|
2428
|
+
throw _context20.t1;
|
|
2100
2429
|
case 20:
|
|
2101
2430
|
logger.info('muteLocalAudio execution finished');
|
|
2102
2431
|
case 21:
|
|
2103
2432
|
case "end":
|
|
2104
|
-
return
|
|
2433
|
+
return _context20.stop();
|
|
2105
2434
|
}
|
|
2106
|
-
},
|
|
2435
|
+
}, _callee20, this, [[1, 7], [11, 16]]);
|
|
2107
2436
|
}));
|
|
2108
2437
|
}
|
|
2109
2438
|
}, {
|
|
2110
2439
|
key: "muteRemoteAudio",
|
|
2111
2440
|
value: function muteRemoteAudio(userId, mute) {
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2441
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
2442
|
+
var streamId;
|
|
2443
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2444
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
2445
|
+
case 0:
|
|
2446
|
+
logger.info('muteRemoteAudio with options: ', userId, mute);
|
|
2447
|
+
streamId = translateTRTCStreamId(userId, exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig); // 音频默认都是主流
|
|
2448
|
+
_context21.next = 4;
|
|
2449
|
+
return this.setAttributes({
|
|
2450
|
+
params: {
|
|
2451
|
+
muteAudio: mute
|
|
2452
|
+
},
|
|
2453
|
+
streamId: streamId,
|
|
2454
|
+
view: this.renderMap.get(streamId)
|
|
2455
|
+
}, 'muteRemoteAudio');
|
|
2456
|
+
case 4:
|
|
2457
|
+
logger.info('muteRemoteAudio success');
|
|
2458
|
+
case 5:
|
|
2459
|
+
case "end":
|
|
2460
|
+
return _context21.stop();
|
|
2461
|
+
}
|
|
2462
|
+
}, _callee21, this);
|
|
2463
|
+
}));
|
|
2125
2464
|
}
|
|
2126
2465
|
}, {
|
|
2127
2466
|
key: "muteAllRemoteAudio",
|
|
2128
2467
|
value: function muteAllRemoteAudio(mute) {
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2468
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
2469
|
+
var _this11 = this;
|
|
2470
|
+
var playerList;
|
|
2471
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2472
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2473
|
+
case 0:
|
|
2474
|
+
logger.info('muteAllRemoteAudio with options: ', mute);
|
|
2475
|
+
playerList = this.trtc.getPlayerList();
|
|
2476
|
+
playerList.forEach(function (player) {
|
|
2477
|
+
return __awaiter(_this11, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
2478
|
+
var streamId;
|
|
2479
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2480
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
2481
|
+
case 0:
|
|
2482
|
+
streamId = player.streamID;
|
|
2483
|
+
_context22.next = 3;
|
|
2484
|
+
return this.setAttributes({
|
|
2485
|
+
params: {
|
|
2486
|
+
muteAudio: mute
|
|
2487
|
+
},
|
|
2488
|
+
streamId: streamId,
|
|
2489
|
+
view: this.renderMap.get(streamId)
|
|
2490
|
+
}, 'muteRemoteAudio');
|
|
2491
|
+
case 3:
|
|
2492
|
+
case "end":
|
|
2493
|
+
return _context22.stop();
|
|
2494
|
+
}
|
|
2495
|
+
}, _callee22, this);
|
|
2496
|
+
}));
|
|
2497
|
+
});
|
|
2498
|
+
logger.info('muteAllRemoteAudio success');
|
|
2499
|
+
case 4:
|
|
2500
|
+
case "end":
|
|
2501
|
+
return _context23.stop();
|
|
2143
2502
|
}
|
|
2144
|
-
});
|
|
2145
|
-
});
|
|
2503
|
+
}, _callee23, this);
|
|
2504
|
+
}));
|
|
2146
2505
|
}
|
|
2147
2506
|
}, {
|
|
2148
2507
|
key: "enableAudioVolumeEvaluation",
|
|
@@ -2156,29 +2515,31 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
2156
2515
|
}, {
|
|
2157
2516
|
key: "switchCamera",
|
|
2158
2517
|
value: function switchCamera(frontCamera) {
|
|
2159
|
-
var
|
|
2518
|
+
var _this12 = this;
|
|
2160
2519
|
logger.info('switchCamera with options: ', frontCamera);
|
|
2161
2520
|
var pusher = this.trtc.getPusherInstance();
|
|
2162
2521
|
if (frontCamera === (pusher.pusherAttributes.frontCamera === 'front')) return Promise.resolve();
|
|
2163
2522
|
return new Promise(function (resolve, reject) {
|
|
2164
2523
|
wx.createLivePusherContext().switchCamera({
|
|
2165
2524
|
success: function success(event) {
|
|
2166
|
-
return __awaiter(
|
|
2167
|
-
return _regeneratorRuntime().wrap(function
|
|
2168
|
-
while (1) switch (
|
|
2525
|
+
return __awaiter(_this12, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
2526
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2527
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2169
2528
|
case 0:
|
|
2170
|
-
|
|
2171
|
-
return this.
|
|
2172
|
-
|
|
2529
|
+
_context24.next = 2;
|
|
2530
|
+
return this.setAttributes({
|
|
2531
|
+
params: {
|
|
2532
|
+
frontCamera: frontCamera
|
|
2533
|
+
}
|
|
2173
2534
|
}, 'switchCamera');
|
|
2174
2535
|
case 2:
|
|
2175
2536
|
logger.info('switchCamera success');
|
|
2176
2537
|
resolve(event);
|
|
2177
2538
|
case 4:
|
|
2178
2539
|
case "end":
|
|
2179
|
-
return
|
|
2540
|
+
return _context24.stop();
|
|
2180
2541
|
}
|
|
2181
|
-
},
|
|
2542
|
+
}, _callee24, this);
|
|
2182
2543
|
}));
|
|
2183
2544
|
},
|
|
2184
2545
|
fail: function fail(error) {
|
|
@@ -2191,24 +2552,26 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
2191
2552
|
}, {
|
|
2192
2553
|
key: "setBeautyStyle",
|
|
2193
2554
|
value: function setBeautyStyle(style, beauty, white, ruddiness) {
|
|
2194
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2195
|
-
return _regeneratorRuntime().wrap(function
|
|
2196
|
-
while (1) switch (
|
|
2555
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
2556
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2557
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2197
2558
|
case 0:
|
|
2198
2559
|
logger.info('setBeautyStyle with options: ', style, beauty, white, ruddiness);
|
|
2199
|
-
|
|
2200
|
-
return this.
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2560
|
+
_context25.next = 3;
|
|
2561
|
+
return this.setAttributes({
|
|
2562
|
+
params: {
|
|
2563
|
+
beautyStyle: style,
|
|
2564
|
+
beautyLevel: beauty,
|
|
2565
|
+
whitenessLevel: white
|
|
2566
|
+
}
|
|
2204
2567
|
}, 'setBeautyStyle');
|
|
2205
2568
|
case 3:
|
|
2206
2569
|
logger.info('setBeautyStyle success');
|
|
2207
2570
|
case 4:
|
|
2208
2571
|
case "end":
|
|
2209
|
-
return
|
|
2572
|
+
return _context25.stop();
|
|
2210
2573
|
}
|
|
2211
|
-
},
|
|
2574
|
+
}, _callee25, this);
|
|
2212
2575
|
}));
|
|
2213
2576
|
}
|
|
2214
2577
|
}, {
|
|
@@ -2374,38 +2737,109 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
2374
2737
|
}
|
|
2375
2738
|
}
|
|
2376
2739
|
}, {
|
|
2377
|
-
key: "
|
|
2378
|
-
value: function
|
|
2379
|
-
var
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2740
|
+
key: "pusherAttributesChange",
|
|
2741
|
+
value: function pusherAttributesChange(pusher) {
|
|
2742
|
+
var _this13 = this;
|
|
2743
|
+
return new Promise(function (resolve) {
|
|
2744
|
+
_this13.InterfaceEventEmitter.emit('pusherAttributesChange', {
|
|
2745
|
+
pusher: pusher,
|
|
2746
|
+
callback: function callback() {
|
|
2747
|
+
resolve(pusher);
|
|
2748
|
+
}
|
|
2749
|
+
});
|
|
2386
2750
|
});
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2751
|
+
}
|
|
2752
|
+
}, {
|
|
2753
|
+
key: "playerAttributesChange",
|
|
2754
|
+
value: function playerAttributesChange(params) {
|
|
2755
|
+
var _this14 = this;
|
|
2756
|
+
var streamId = params.streamId,
|
|
2757
|
+
playerAttributes = params.playerAttributes;
|
|
2758
|
+
return new Promise(function (resolve) {
|
|
2759
|
+
_this14.InterfaceEventEmitter.emit('playerAttributesChange', {
|
|
2760
|
+
streamId: streamId,
|
|
2761
|
+
view: _this14.renderMap.get(streamId),
|
|
2762
|
+
playerAttributes: playerAttributes,
|
|
2763
|
+
callback: function callback() {
|
|
2764
|
+
resolve(playerAttributes);
|
|
2397
2765
|
}
|
|
2398
|
-
|
|
2399
|
-
pusher: pusher,
|
|
2400
|
-
callback: function callback() {
|
|
2401
|
-
resolve(pusher);
|
|
2402
|
-
}
|
|
2403
|
-
});
|
|
2404
|
-
} catch (err) {
|
|
2405
|
-
reject(err);
|
|
2406
|
-
}
|
|
2766
|
+
});
|
|
2407
2767
|
});
|
|
2408
|
-
|
|
2768
|
+
}
|
|
2769
|
+
}, {
|
|
2770
|
+
key: "setAttributes",
|
|
2771
|
+
value: function setAttributes(options, funName, handleType) {
|
|
2772
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
2773
|
+
var _this15 = this,
|
|
2774
|
+
_handleMap;
|
|
2775
|
+
var timeoutDuration, timeoutPromise, params, streamId, handleMap, originalPromise;
|
|
2776
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2777
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2778
|
+
case 0:
|
|
2779
|
+
// 定义一个超时时间(以毫秒为单位)
|
|
2780
|
+
timeoutDuration = 2000;
|
|
2781
|
+
timeoutPromise = new Promise(function (resolve, reject) {
|
|
2782
|
+
setTimeout(function () {
|
|
2783
|
+
reject(new Error('setAttributes timed out'));
|
|
2784
|
+
}, timeoutDuration);
|
|
2785
|
+
});
|
|
2786
|
+
params = options.params, streamId = options.streamId, options.view;
|
|
2787
|
+
handleMap = (_handleMap = {}, _defineProperty(_handleMap, Handletype.setPlayer, function () {
|
|
2788
|
+
return __awaiter(_this15, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
2789
|
+
var playerAttributes;
|
|
2790
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2791
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2792
|
+
case 0:
|
|
2793
|
+
_context26.next = 2;
|
|
2794
|
+
return this.playerAttributesChange({
|
|
2795
|
+
playerAttributes: this.setTRTCPlayerAttributes(streamId, params),
|
|
2796
|
+
streamId: streamId
|
|
2797
|
+
});
|
|
2798
|
+
case 2:
|
|
2799
|
+
playerAttributes = _context26.sent;
|
|
2800
|
+
return _context26.abrupt("return", playerAttributes);
|
|
2801
|
+
case 4:
|
|
2802
|
+
case "end":
|
|
2803
|
+
return _context26.stop();
|
|
2804
|
+
}
|
|
2805
|
+
}, _callee26, this);
|
|
2806
|
+
}));
|
|
2807
|
+
}), _defineProperty(_handleMap, Handletype.setPusher, function () {
|
|
2808
|
+
return __awaiter(_this15, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
2809
|
+
var _pusher, pusher;
|
|
2810
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2811
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2812
|
+
case 0:
|
|
2813
|
+
if (!(funName === 'enterRoom')) {
|
|
2814
|
+
_context27.next = 5;
|
|
2815
|
+
break;
|
|
2816
|
+
}
|
|
2817
|
+
_context27.next = 3;
|
|
2818
|
+
return this.pusherAttributesChange(this.trtc.enterRoom(params));
|
|
2819
|
+
case 3:
|
|
2820
|
+
_pusher = _context27.sent;
|
|
2821
|
+
return _context27.abrupt("return", _pusher);
|
|
2822
|
+
case 5:
|
|
2823
|
+
_context27.next = 7;
|
|
2824
|
+
return this.pusherAttributesChange(this.trtc.setPusherAttributes(params));
|
|
2825
|
+
case 7:
|
|
2826
|
+
pusher = _context27.sent;
|
|
2827
|
+
return _context27.abrupt("return", pusher);
|
|
2828
|
+
case 9:
|
|
2829
|
+
case "end":
|
|
2830
|
+
return _context27.stop();
|
|
2831
|
+
}
|
|
2832
|
+
}, _callee27, this);
|
|
2833
|
+
}));
|
|
2834
|
+
}), _handleMap);
|
|
2835
|
+
originalPromise = handleMap[handleType] ? handleMap[handleType]() : Promise.reject(new Error('setAttributes fail'));
|
|
2836
|
+
return _context28.abrupt("return", Promise.race([originalPromise, timeoutPromise]));
|
|
2837
|
+
case 6:
|
|
2838
|
+
case "end":
|
|
2839
|
+
return _context28.stop();
|
|
2840
|
+
}
|
|
2841
|
+
}, _callee28);
|
|
2842
|
+
}));
|
|
2409
2843
|
}
|
|
2410
2844
|
}], [{
|
|
2411
2845
|
key: "getTRTCShareInstance",
|
|
@@ -2429,7 +2863,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
2429
2863
|
}]);
|
|
2430
2864
|
return TRTCCloud;
|
|
2431
2865
|
}();
|
|
2432
|
-
__decorate([setHandle], TRTCCloud.prototype, "
|
|
2866
|
+
__decorate([setHandle], TRTCCloud.prototype, "setAttributes", null);
|
|
2433
2867
|
|
|
2434
2868
|
exports.TRTCCloud = TRTCCloud;
|
|
2435
2869
|
exports.default = TRTCCloud;
|