@tencentcloud/trtc-cloud-wx 0.0.17 → 0.0.19
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 +814 -304
package/trtc-cloud-wx.js
CHANGED
|
@@ -413,6 +413,57 @@ function _nonIterableSpread() {
|
|
|
413
413
|
function _nonIterableRest() {
|
|
414
414
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
415
415
|
}
|
|
416
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
417
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
418
|
+
if (!it) {
|
|
419
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
420
|
+
if (it) o = it;
|
|
421
|
+
var i = 0;
|
|
422
|
+
var F = function () {};
|
|
423
|
+
return {
|
|
424
|
+
s: F,
|
|
425
|
+
n: function () {
|
|
426
|
+
if (i >= o.length) return {
|
|
427
|
+
done: true
|
|
428
|
+
};
|
|
429
|
+
return {
|
|
430
|
+
done: false,
|
|
431
|
+
value: o[i++]
|
|
432
|
+
};
|
|
433
|
+
},
|
|
434
|
+
e: function (e) {
|
|
435
|
+
throw e;
|
|
436
|
+
},
|
|
437
|
+
f: F
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
441
|
+
}
|
|
442
|
+
var normalCompletion = true,
|
|
443
|
+
didErr = false,
|
|
444
|
+
err;
|
|
445
|
+
return {
|
|
446
|
+
s: function () {
|
|
447
|
+
it = it.call(o);
|
|
448
|
+
},
|
|
449
|
+
n: function () {
|
|
450
|
+
var step = it.next();
|
|
451
|
+
normalCompletion = step.done;
|
|
452
|
+
return step;
|
|
453
|
+
},
|
|
454
|
+
e: function (e) {
|
|
455
|
+
didErr = true;
|
|
456
|
+
err = e;
|
|
457
|
+
},
|
|
458
|
+
f: function () {
|
|
459
|
+
try {
|
|
460
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
461
|
+
} finally {
|
|
462
|
+
if (didErr) throw err;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
}
|
|
416
467
|
function _toPrimitive(input, hint) {
|
|
417
468
|
if (typeof input !== "object" || input === null) return input;
|
|
418
469
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -444,6 +495,13 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
444
495
|
***************************************************************************** */
|
|
445
496
|
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
446
497
|
|
|
498
|
+
function __decorate(decorators, target, key, desc) {
|
|
499
|
+
var c = arguments.length,
|
|
500
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
501
|
+
d;
|
|
502
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
503
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
504
|
+
}
|
|
447
505
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
448
506
|
function adopt(value) {
|
|
449
507
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -562,6 +620,284 @@ exports.TRTCBeautyStyle = void 0;
|
|
|
562
620
|
TRTCBeautyStyle[TRTCBeautyStyle["TRTCBeautyStyleNature"] = 1] = "TRTCBeautyStyleNature";
|
|
563
621
|
})(exports.TRTCBeautyStyle || (exports.TRTCBeautyStyle = {}));
|
|
564
622
|
|
|
623
|
+
var Task = /*#__PURE__*/function () {
|
|
624
|
+
function Task(optinos) {
|
|
625
|
+
_classCallCheck(this, Task);
|
|
626
|
+
var _optinos$priority = optinos.priority,
|
|
627
|
+
priority = _optinos$priority === void 0 ? 0 : _optinos$priority,
|
|
628
|
+
action = optinos.action,
|
|
629
|
+
args = optinos.args,
|
|
630
|
+
resolve = optinos.resolve,
|
|
631
|
+
reject = optinos.reject,
|
|
632
|
+
ctx = optinos.ctx,
|
|
633
|
+
name = optinos.name;
|
|
634
|
+
this.ctx = ctx;
|
|
635
|
+
this.priority = priority;
|
|
636
|
+
this.action = action;
|
|
637
|
+
this.args = args;
|
|
638
|
+
this.resolve = resolve;
|
|
639
|
+
this.reject = reject;
|
|
640
|
+
this.name = name;
|
|
641
|
+
this.single = this.whetherSingle(name);
|
|
642
|
+
this.sequenceNumber = Task.nextSequenceNumber++;
|
|
643
|
+
}
|
|
644
|
+
_createClass(Task, [{
|
|
645
|
+
key: "whetherSingle",
|
|
646
|
+
value: function whetherSingle(funName) {
|
|
647
|
+
switch (funName) {
|
|
648
|
+
case 'enterRoom':
|
|
649
|
+
return true;
|
|
650
|
+
default:
|
|
651
|
+
return false;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}]);
|
|
655
|
+
return Task;
|
|
656
|
+
}();
|
|
657
|
+
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
|
+
var TaskQueueState;
|
|
675
|
+
(function (TaskQueueState) {
|
|
676
|
+
TaskQueueState["IDLE"] = "idle";
|
|
677
|
+
TaskQueueState["PENDING"] = "pending";
|
|
678
|
+
TaskQueueState["PROCESS"] = "process";
|
|
679
|
+
})(TaskQueueState || (TaskQueueState = {}));
|
|
680
|
+
var TaskQueueEvent;
|
|
681
|
+
(function (TaskQueueEvent) {
|
|
682
|
+
TaskQueueEvent["SET"] = "SET";
|
|
683
|
+
TaskQueueEvent["SETPROCESS"] = "SETPROCESS";
|
|
684
|
+
TaskQueueEvent["SETDONE"] = "SETDONE";
|
|
685
|
+
})(TaskQueueEvent || (TaskQueueEvent = {}));
|
|
686
|
+
var TaskMachine = /*#__PURE__*/function () {
|
|
687
|
+
function TaskMachine() {
|
|
688
|
+
_classCallCheck(this, TaskMachine);
|
|
689
|
+
this.isProcessing = false; // 添加一个标志以跟踪任务是否正在处理
|
|
690
|
+
this.pusherDomReady = false;
|
|
691
|
+
this.state = TaskQueueState.IDLE;
|
|
692
|
+
this.context = {
|
|
693
|
+
taskQueue: [],
|
|
694
|
+
debounceTimeout: null
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
_createClass(TaskMachine, [{
|
|
698
|
+
key: "setPusherDomReady",
|
|
699
|
+
value: function setPusherDomReady(isReady) {
|
|
700
|
+
this.pusherDomReady = isReady;
|
|
701
|
+
return this.pusherDomReady;
|
|
702
|
+
}
|
|
703
|
+
}, {
|
|
704
|
+
key: "send",
|
|
705
|
+
value: function send(event) {
|
|
706
|
+
switch (this.state) {
|
|
707
|
+
case TaskQueueState.IDLE:
|
|
708
|
+
if (event === TaskQueueEvent.SET) {
|
|
709
|
+
this.state = TaskQueueState.PENDING;
|
|
710
|
+
this.processTasks();
|
|
711
|
+
}
|
|
712
|
+
break;
|
|
713
|
+
case TaskQueueState.PENDING:
|
|
714
|
+
if (event === TaskQueueEvent.SETPROCESS) {
|
|
715
|
+
this.processTasks();
|
|
716
|
+
}
|
|
717
|
+
if (event === TaskQueueEvent.SETDONE) {
|
|
718
|
+
this.state = TaskQueueState.IDLE;
|
|
719
|
+
}
|
|
720
|
+
break;
|
|
721
|
+
case TaskQueueState.PROCESS:
|
|
722
|
+
if (event === TaskQueueEvent.SETDONE) {
|
|
723
|
+
this.state = TaskQueueState.IDLE;
|
|
724
|
+
}
|
|
725
|
+
break;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}, {
|
|
729
|
+
key: "addTask",
|
|
730
|
+
value: function addTask(task) {
|
|
731
|
+
this.addTaskToQueue(task);
|
|
732
|
+
if (this.state === TaskQueueState.IDLE) {
|
|
733
|
+
this.send(TaskQueueEvent.SET);
|
|
734
|
+
} else if (this.state === TaskQueueState.PENDING) {
|
|
735
|
+
this.send(TaskQueueEvent.SETPROCESS);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
}, {
|
|
739
|
+
key: "addTaskToQueue",
|
|
740
|
+
value: function addTaskToQueue(task) {
|
|
741
|
+
this.context.taskQueue.push(task);
|
|
742
|
+
this.context.taskQueue.sort(function (a, b) {
|
|
743
|
+
if (a.priority !== b.priority) {
|
|
744
|
+
return a.priority - b.priority;
|
|
745
|
+
}
|
|
746
|
+
return a.sequenceNumber - b.sequenceNumber;
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
}, {
|
|
750
|
+
key: "processTasks",
|
|
751
|
+
value: function processTasks() {
|
|
752
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
753
|
+
var _this = this;
|
|
754
|
+
var currentTasks, singleTasks, exceptSingleTask, _iterator, _step, _task3, args, task, sequenceTask, r, _iterator2, _step2, _task, _iterator3, _step3, _task2;
|
|
755
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
756
|
+
while (1) switch (_context.prev = _context.next) {
|
|
757
|
+
case 0:
|
|
758
|
+
if (!(this.isProcessing || !this.pusherDomReady || this.context.taskQueue.length === 0)) {
|
|
759
|
+
_context.next = 2;
|
|
760
|
+
break;
|
|
761
|
+
}
|
|
762
|
+
return _context.abrupt("return");
|
|
763
|
+
case 2:
|
|
764
|
+
this.isProcessing = true;
|
|
765
|
+
this.state = TaskQueueState.PROCESS;
|
|
766
|
+
currentTasks = _toConsumableArray(this.context.taskQueue);
|
|
767
|
+
this.context.taskQueue = [];
|
|
768
|
+
singleTasks = currentTasks.filter(function (task) {
|
|
769
|
+
return task.single;
|
|
770
|
+
});
|
|
771
|
+
exceptSingleTask = currentTasks.filter(function (task) {
|
|
772
|
+
return !task.single;
|
|
773
|
+
});
|
|
774
|
+
_iterator = _createForOfIteratorHelper(singleTasks);
|
|
775
|
+
_context.prev = 9;
|
|
776
|
+
_iterator.s();
|
|
777
|
+
case 11:
|
|
778
|
+
if ((_step = _iterator.n()).done) {
|
|
779
|
+
_context.next = 24;
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
_task3 = _step.value;
|
|
783
|
+
_context.prev = 13;
|
|
784
|
+
_context.next = 16;
|
|
785
|
+
return _task3.action.call(_task3.ctx, _task3.args, _task3.name);
|
|
786
|
+
case 16:
|
|
787
|
+
_task3.result = _context.sent;
|
|
788
|
+
_context.next = 22;
|
|
789
|
+
break;
|
|
790
|
+
case 19:
|
|
791
|
+
_context.prev = 19;
|
|
792
|
+
_context.t0 = _context["catch"](13);
|
|
793
|
+
_task3.err = _context.t0;
|
|
794
|
+
case 22:
|
|
795
|
+
_context.next = 11;
|
|
796
|
+
break;
|
|
797
|
+
case 24:
|
|
798
|
+
_context.next = 29;
|
|
799
|
+
break;
|
|
800
|
+
case 26:
|
|
801
|
+
_context.prev = 26;
|
|
802
|
+
_context.t1 = _context["catch"](9);
|
|
803
|
+
_iterator.e(_context.t1);
|
|
804
|
+
case 29:
|
|
805
|
+
_context.prev = 29;
|
|
806
|
+
_iterator.f();
|
|
807
|
+
return _context.finish(29);
|
|
808
|
+
case 32:
|
|
809
|
+
args = exceptSingleTask.reduce(function (acc, cur) {
|
|
810
|
+
return Object.assign(Object.assign({}, acc), typeof cur.args === 'function' ? cur.args() : cur.args);
|
|
811
|
+
}, {});
|
|
812
|
+
task = exceptSingleTask[0];
|
|
813
|
+
sequenceTask = currentTasks.sort(function (a, b) {
|
|
814
|
+
return a.sequenceNumber - b.sequenceNumber;
|
|
815
|
+
});
|
|
816
|
+
_context.prev = 35;
|
|
817
|
+
r = null;
|
|
818
|
+
if (!task) {
|
|
819
|
+
_context.next = 41;
|
|
820
|
+
break;
|
|
821
|
+
}
|
|
822
|
+
_context.next = 40;
|
|
823
|
+
return task.action.call(task.ctx, args);
|
|
824
|
+
case 40:
|
|
825
|
+
r = _context.sent;
|
|
826
|
+
case 41:
|
|
827
|
+
_iterator2 = _createForOfIteratorHelper(sequenceTask);
|
|
828
|
+
try {
|
|
829
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
830
|
+
_task = _step2.value;
|
|
831
|
+
if (_task.err) {
|
|
832
|
+
_task.reject(_task.err);
|
|
833
|
+
} else {
|
|
834
|
+
_task.resolve(_task.result || r);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
} catch (err) {
|
|
838
|
+
_iterator2.e(err);
|
|
839
|
+
} finally {
|
|
840
|
+
_iterator2.f();
|
|
841
|
+
}
|
|
842
|
+
_context.next = 49;
|
|
843
|
+
break;
|
|
844
|
+
case 45:
|
|
845
|
+
_context.prev = 45;
|
|
846
|
+
_context.t2 = _context["catch"](35);
|
|
847
|
+
_iterator3 = _createForOfIteratorHelper(sequenceTask);
|
|
848
|
+
try {
|
|
849
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
850
|
+
_task2 = _step3.value;
|
|
851
|
+
_task2.reject(_context.t2);
|
|
852
|
+
}
|
|
853
|
+
} catch (err) {
|
|
854
|
+
_iterator3.e(err);
|
|
855
|
+
} finally {
|
|
856
|
+
_iterator3.f();
|
|
857
|
+
}
|
|
858
|
+
case 49:
|
|
859
|
+
this.isProcessing = false;
|
|
860
|
+
this.send(TaskQueueEvent.SETDONE);
|
|
861
|
+
if (this.context.taskQueue.length > 0) {
|
|
862
|
+
Promise.resolve().then(function () {
|
|
863
|
+
_this.processTasks();
|
|
864
|
+
})["catch"](console.error);
|
|
865
|
+
}
|
|
866
|
+
case 52:
|
|
867
|
+
case "end":
|
|
868
|
+
return _context.stop();
|
|
869
|
+
}
|
|
870
|
+
}, _callee, this, [[9, 26, 29, 32], [13, 19], [35, 45]]);
|
|
871
|
+
}));
|
|
872
|
+
}
|
|
873
|
+
}]);
|
|
874
|
+
return TaskMachine;
|
|
875
|
+
}();
|
|
876
|
+
var taskMachine = new TaskMachine();
|
|
877
|
+
var setHandle = function setHandle(target, key, descriptor) {
|
|
878
|
+
var originalMethod = descriptor.value;
|
|
879
|
+
descriptor.value = function () {
|
|
880
|
+
var _this2 = this;
|
|
881
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
882
|
+
args[_key] = arguments[_key];
|
|
883
|
+
}
|
|
884
|
+
return new Promise(function (resolve, reject) {
|
|
885
|
+
var params = args[0],
|
|
886
|
+
funName = args[1];
|
|
887
|
+
taskMachine.addTask(new Task({
|
|
888
|
+
ctx: _this2,
|
|
889
|
+
priority: TaskPriorityMap[funName] || 0,
|
|
890
|
+
action: originalMethod,
|
|
891
|
+
args: params,
|
|
892
|
+
name: funName,
|
|
893
|
+
resolve: resolve,
|
|
894
|
+
reject: reject
|
|
895
|
+
}));
|
|
896
|
+
});
|
|
897
|
+
};
|
|
898
|
+
return descriptor;
|
|
899
|
+
};
|
|
900
|
+
|
|
565
901
|
var _TRTCVideoResolutionM, _TRTCBeautyStyleMap, _TRTCVideoFillModeMap;
|
|
566
902
|
var translateTRTCAppScene = function translateTRTCAppScene(scene) {
|
|
567
903
|
switch (scene) {
|
|
@@ -814,20 +1150,20 @@ var Logger = /*#__PURE__*/function () {
|
|
|
814
1150
|
var logger = new Logger();
|
|
815
1151
|
|
|
816
1152
|
var name = "@tencentcloud/trtc-cloud-wx";
|
|
817
|
-
var version = "0.0.
|
|
1153
|
+
var version = "0.0.19";
|
|
818
1154
|
var description = "";
|
|
819
1155
|
var main = "dist/trtc-cloud-wx.js";
|
|
820
1156
|
var module$1 = "dist/trtc-cloud-wx.js";
|
|
821
1157
|
var type = "module";
|
|
822
1158
|
var scripts = {
|
|
823
|
-
build: "npm run clear && rollup -c",
|
|
1159
|
+
build: "npm run clear && rollup -c && node ./build/copy_to_roomkit.js",
|
|
824
1160
|
dev: "node ./build/chokidar.js",
|
|
825
1161
|
clear: "node ./build/clear.js",
|
|
826
1162
|
copy: "node ./build/copy.js",
|
|
827
1163
|
doc: "npx typedoc --tsconfig typedoc.json",
|
|
828
1164
|
"doc:watch": "typedoc --watch",
|
|
829
1165
|
"doc:build": "jsdoc -c jsdoc.json",
|
|
830
|
-
publish: "
|
|
1166
|
+
publish: "bash ./sdk_publish.bash"
|
|
831
1167
|
};
|
|
832
1168
|
var keywords = [
|
|
833
1169
|
];
|
|
@@ -899,7 +1235,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
899
1235
|
this.role = exports.TRTCRoleType.TRTCRoleAnchor;
|
|
900
1236
|
this.userId = '';
|
|
901
1237
|
this.isEnterRoom = false;
|
|
902
|
-
this.
|
|
1238
|
+
this.isVideoMuted = false;
|
|
903
1239
|
this.isOpenCamera = false;
|
|
904
1240
|
this.audioVolumeEvaluation = 0;
|
|
905
1241
|
this.allTimer = {};
|
|
@@ -919,6 +1255,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
919
1255
|
}, {
|
|
920
1256
|
key: "destroy",
|
|
921
1257
|
value: function destroy() {
|
|
1258
|
+
this.offTRTCEvent();
|
|
922
1259
|
this.EventEmitter.removeAllListeners();
|
|
923
1260
|
this.InterfaceEventEmitter.removeAllListeners();
|
|
924
1261
|
this.trtc.exitRoom();
|
|
@@ -929,8 +1266,8 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
929
1266
|
this.trtc = new TRTC(this);
|
|
930
1267
|
this.trtc.setLogLevel(3);
|
|
931
1268
|
this.TRTC_EVENT = this.trtc.EVENT;
|
|
932
|
-
this.trtc.createPusher({});
|
|
933
1269
|
this.bindTRTCEvent();
|
|
1270
|
+
this.bindComponentEvent();
|
|
934
1271
|
this.handleNetworkQuality = this.getHandleNetworkQuality(2000);
|
|
935
1272
|
}
|
|
936
1273
|
}, {
|
|
@@ -940,17 +1277,34 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
940
1277
|
this.role = exports.TRTCRoleType.TRTCRoleAnchor;
|
|
941
1278
|
this.userId = '';
|
|
942
1279
|
this.isEnterRoom = false;
|
|
943
|
-
this.
|
|
1280
|
+
this.isVideoMuted = false;
|
|
944
1281
|
this.isOpenCamera = false;
|
|
945
1282
|
Object.keys(this.allTimer).forEach(function (key) {
|
|
946
1283
|
clearInterval(_this.allTimer[key]);
|
|
947
1284
|
_this.allTimer[key] = null;
|
|
948
1285
|
});
|
|
949
1286
|
}
|
|
1287
|
+
}, {
|
|
1288
|
+
key: "bindComponentEvent",
|
|
1289
|
+
value: function bindComponentEvent() {
|
|
1290
|
+
var _this2 = this;
|
|
1291
|
+
this.InterfaceEventEmitter.on('pusherDomReady', function (isReady) {
|
|
1292
|
+
taskMachine.setPusherDomReady(isReady);
|
|
1293
|
+
if (isReady) {
|
|
1294
|
+
_this2.trtc.createPusher({});
|
|
1295
|
+
taskMachine.send(TaskQueueEvent.SETPROCESS);
|
|
1296
|
+
} else {
|
|
1297
|
+
if (_this2.isEnterRoom) {
|
|
1298
|
+
_this2.exitRoom();
|
|
1299
|
+
}
|
|
1300
|
+
taskMachine.send(TaskQueueEvent.SETDONE);
|
|
1301
|
+
}
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
950
1304
|
}, {
|
|
951
1305
|
key: "bindTRTCEvent",
|
|
952
1306
|
value: function bindTRTCEvent() {
|
|
953
|
-
var
|
|
1307
|
+
var _this3 = this;
|
|
954
1308
|
this.trtc.on(this.TRTC_EVENT.LOCAL_LEAVE, function (event) {
|
|
955
1309
|
// todo 第二个参数为进房耗时 此处调用start的时候处理
|
|
956
1310
|
// this.emit('onEnterRoom', 0)
|
|
@@ -959,42 +1313,42 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
959
1313
|
var _event$data = event.data,
|
|
960
1314
|
code = _event$data.code,
|
|
961
1315
|
message = _event$data.message;
|
|
962
|
-
|
|
1316
|
+
_this3.emit('onError', code, message);
|
|
963
1317
|
});
|
|
964
1318
|
this.trtc.on(this.TRTC_EVENT.REMOTE_USER_JOIN, function (event) {
|
|
965
1319
|
var userID = event.data.userID;
|
|
966
|
-
|
|
1320
|
+
_this3.emit('onRemoteUserEnterRoom', userID);
|
|
967
1321
|
});
|
|
968
1322
|
// 远端用户退出
|
|
969
1323
|
this.trtc.on(this.TRTC_EVENT.REMOTE_USER_LEAVE, function (event) {
|
|
970
1324
|
var _event$data2 = event.data,
|
|
971
1325
|
userID = _event$data2.userID;
|
|
972
1326
|
_event$data2.playerList;
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1327
|
+
_this3.InterfaceEventEmitter.emit('onRemoteUserLeaveRoom', userID, 0);
|
|
1328
|
+
_this3.emit('onUserVideoAvailable', userID, 0);
|
|
1329
|
+
_this3.emit('onUserSubStreamAvailable', userID, 0);
|
|
1330
|
+
_this3.emit('onRemoteUserLeaveRoom', userID, 0);
|
|
977
1331
|
});
|
|
978
1332
|
// 远端用户推送视频
|
|
979
1333
|
this.trtc.on(this.TRTC_EVENT.REMOTE_VIDEO_ADD, function (event) {
|
|
980
1334
|
var player = event.data.player;
|
|
981
|
-
|
|
1335
|
+
_this3.emit(player.streamType === 'aux' ? 'onUserSubStreamAvailable' : 'onUserVideoAvailable', player.userID, 1);
|
|
982
1336
|
});
|
|
983
1337
|
// 远端用户取消推送视频
|
|
984
1338
|
this.trtc.on(this.TRTC_EVENT.REMOTE_VIDEO_REMOVE, function (event) {
|
|
985
1339
|
var player = event.data.player;
|
|
986
|
-
|
|
1340
|
+
_this3.emit(player.streamType === 'aux' ? 'onUserSubStreamAvailable' : 'onUserVideoAvailable', player.userID, 0);
|
|
987
1341
|
});
|
|
988
1342
|
// 远端用户推送音频
|
|
989
1343
|
this.trtc.on(this.TRTC_EVENT.REMOTE_AUDIO_ADD, function (event) {
|
|
990
1344
|
var player = event.data.player;
|
|
991
|
-
|
|
992
|
-
|
|
1345
|
+
_this3.emit('onUserAudioAvailable', player.userID, 1);
|
|
1346
|
+
_this3.muteRemoteAudio(player.userID, false);
|
|
993
1347
|
});
|
|
994
1348
|
// 远端用户取消推送音频
|
|
995
1349
|
this.trtc.on(this.TRTC_EVENT.REMOTE_AUDIO_REMOVE, function (event) {
|
|
996
1350
|
var player = event.data.player;
|
|
997
|
-
|
|
1351
|
+
_this3.emit('onUserAudioAvailable', player.userID, 0);
|
|
998
1352
|
});
|
|
999
1353
|
this.trtc.on(this.TRTC_EVENT.REMOTE_AUDIO_VOLUME_UPDATE, function (event) {
|
|
1000
1354
|
var playerList = event.data.playerList;
|
|
@@ -1004,7 +1358,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1004
1358
|
volume: player.volume
|
|
1005
1359
|
};
|
|
1006
1360
|
});
|
|
1007
|
-
|
|
1361
|
+
_this3.handleAudioVolumeUpdate(userVolumes);
|
|
1008
1362
|
});
|
|
1009
1363
|
this.trtc.on(this.TRTC_EVENT.LOCAL_AUDIO_VOLUME_UPDATE, function (event) {
|
|
1010
1364
|
var pusher = event.data.pusher;
|
|
@@ -1012,25 +1366,39 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1012
1366
|
userId: pusher.userID,
|
|
1013
1367
|
volume: pusher.volume
|
|
1014
1368
|
}];
|
|
1015
|
-
|
|
1369
|
+
_this3.handleAudioVolumeUpdate(userVolumes);
|
|
1016
1370
|
});
|
|
1017
1371
|
this.trtc.on(this.TRTC_EVENT.LOCAL_NET_STATE_UPDATE, function (event) {
|
|
1018
1372
|
var pusher = event.data.pusher;
|
|
1019
|
-
|
|
1373
|
+
_this3.handleNetworkQuality({
|
|
1020
1374
|
pusher: pusher
|
|
1021
1375
|
});
|
|
1022
1376
|
});
|
|
1023
1377
|
this.trtc.on(this.TRTC_EVENT.REMOTE_NET_STATE_UPDATE, function (event) {
|
|
1024
1378
|
var playerList = event.data.playerList;
|
|
1025
|
-
|
|
1379
|
+
_this3.handleNetworkQuality({
|
|
1026
1380
|
playerList: playerList
|
|
1027
1381
|
});
|
|
1028
1382
|
});
|
|
1029
1383
|
}
|
|
1384
|
+
}, {
|
|
1385
|
+
key: "offTRTCEvent",
|
|
1386
|
+
value: function offTRTCEvent() {
|
|
1387
|
+
this.trtc.off(this.TRTC_EVENT.LOCAL_LEAVE);
|
|
1388
|
+
this.trtc.off(this.TRTC_EVENT.ERROR);
|
|
1389
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_USER_JOIN);
|
|
1390
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_USER_LEAVE);
|
|
1391
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_VIDEO_ADD);
|
|
1392
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_VIDEO_REMOVE);
|
|
1393
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_AUDIO_ADD);
|
|
1394
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_AUDIO_REMOVE);
|
|
1395
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_AUDIO_VOLUME_UPDATE);
|
|
1396
|
+
this.trtc.off(this.TRTC_EVENT.REMOTE_NET_STATE_UPDATE);
|
|
1397
|
+
}
|
|
1030
1398
|
}, {
|
|
1031
1399
|
key: "getHandleAudioVolumeUpdate",
|
|
1032
1400
|
value: function getHandleAudioVolumeUpdate(interval) {
|
|
1033
|
-
var
|
|
1401
|
+
var _this4 = this;
|
|
1034
1402
|
var _a;
|
|
1035
1403
|
if ((_a = this.allTimer) === null || _a === void 0 ? void 0 : _a.AudioVolume) {
|
|
1036
1404
|
clearInterval(this.allTimer.AudioVolume);
|
|
@@ -1047,12 +1415,12 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1047
1415
|
this.InterfaceEventEmitter.on('onRemoteUserLeaveRoom', filterUselessItem, this.getHandleAudioVolumeUpdate);
|
|
1048
1416
|
return function (userVolumes) {
|
|
1049
1417
|
tempUserVolumes = uniqueFunc([].concat(_toConsumableArray(userVolumes), _toConsumableArray(tempUserVolumes)), 'userId');
|
|
1050
|
-
if (
|
|
1418
|
+
if (_this4.allTimer.AudioVolume) return;
|
|
1051
1419
|
var timer = setInterval(function () {
|
|
1052
|
-
|
|
1420
|
+
_this4.emit('onUserVoiceVolume', tempUserVolumes, tempUserVolumes.length, 0 // todo 此参数无用,暂时废弃
|
|
1053
1421
|
);
|
|
1054
1422
|
}, interval);
|
|
1055
|
-
|
|
1423
|
+
_this4.allTimer.AudioVolume = timer;
|
|
1056
1424
|
};
|
|
1057
1425
|
}
|
|
1058
1426
|
}, {
|
|
@@ -1061,7 +1429,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1061
1429
|
}, {
|
|
1062
1430
|
key: "getHandleNetworkQuality",
|
|
1063
1431
|
value: function getHandleNetworkQuality(interval) {
|
|
1064
|
-
var
|
|
1432
|
+
var _this5 = this;
|
|
1065
1433
|
var _a;
|
|
1066
1434
|
if ((_a = this.allTimer) === null || _a === void 0 ? void 0 : _a.networkQuality) {
|
|
1067
1435
|
clearInterval(this.allTimer.networkQuality);
|
|
@@ -1092,11 +1460,11 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1092
1460
|
};
|
|
1093
1461
|
});
|
|
1094
1462
|
}
|
|
1095
|
-
if (
|
|
1463
|
+
if (_this5.allTimer.networkQuality) return;
|
|
1096
1464
|
var timer = setInterval(function () {
|
|
1097
|
-
|
|
1465
|
+
_this5.emit('onNetworkQuality', resultQuality.localQuality, resultQuality.remoteQuality);
|
|
1098
1466
|
}, interval);
|
|
1099
|
-
|
|
1467
|
+
_this5.allTimer.networkQuality = timer;
|
|
1100
1468
|
};
|
|
1101
1469
|
}
|
|
1102
1470
|
}, {
|
|
@@ -1136,67 +1504,78 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1136
1504
|
}, {
|
|
1137
1505
|
key: "enterRoom",
|
|
1138
1506
|
value: function enterRoom(params, scene) {
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1507
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1508
|
+
var _this6 = this;
|
|
1509
|
+
var startTime, sdkAppId, userId, userSig, roomId, strRoomId, role, privateMapKey;
|
|
1510
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1511
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1512
|
+
case 0:
|
|
1513
|
+
startTime = new Date().getTime();
|
|
1514
|
+
sdkAppId = params.sdkAppId, userId = params.userId, userSig = params.userSig, roomId = params.roomId, strRoomId = params.strRoomId, role = params.role, privateMapKey = params.privateMapKey;
|
|
1515
|
+
logger.setInfo({
|
|
1516
|
+
sdkAppId: sdkAppId,
|
|
1517
|
+
userId: userId,
|
|
1518
|
+
roomId: strRoomId
|
|
1519
|
+
});
|
|
1520
|
+
logger.info('enterRoom with options: ', JSON.stringify(params), scene);
|
|
1521
|
+
this.userId = userId;
|
|
1522
|
+
this.isEnterRoom = true;
|
|
1523
|
+
_context2.next = 8;
|
|
1524
|
+
return this.setPusherAttributes({
|
|
1525
|
+
sdkAppID: sdkAppId,
|
|
1526
|
+
userID: userId,
|
|
1527
|
+
userSig: userSig,
|
|
1528
|
+
roomID: roomId,
|
|
1529
|
+
strRoomID: strRoomId,
|
|
1530
|
+
role: role,
|
|
1531
|
+
privateMapKey: privateMapKey,
|
|
1532
|
+
scene: translateTRTCAppScene(scene),
|
|
1533
|
+
enableMic: false,
|
|
1534
|
+
enableCamera: false,
|
|
1535
|
+
videoPreview: false
|
|
1536
|
+
}, 'enterRoom');
|
|
1537
|
+
case 8:
|
|
1538
|
+
this.trtc.getPusherInstance().start({
|
|
1539
|
+
success: function success() {
|
|
1540
|
+
return __awaiter(_this6, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1541
|
+
var endTime;
|
|
1542
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1543
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1544
|
+
case 0:
|
|
1545
|
+
logger.info('enterRoom success');
|
|
1546
|
+
this.scene = scene;
|
|
1547
|
+
endTime = new Date().getTime();
|
|
1548
|
+
this.emit('onEnterRoom', endTime - startTime);
|
|
1549
|
+
if (!(this.trtc.getPusherAttributes().videoPreview === true)) {
|
|
1550
|
+
_context.next = 8;
|
|
1551
|
+
break;
|
|
1552
|
+
}
|
|
1553
|
+
_context.next = 7;
|
|
1554
|
+
return this.setPusherAttributes({
|
|
1555
|
+
videoPreview: false,
|
|
1556
|
+
enableCamera: true
|
|
1557
|
+
}, 'other');
|
|
1558
|
+
case 7:
|
|
1559
|
+
this.emit('onSendFirstLocalVideoFrame', exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
1560
|
+
case 8:
|
|
1561
|
+
case "end":
|
|
1562
|
+
return _context.stop();
|
|
1563
|
+
}
|
|
1564
|
+
}, _callee, this);
|
|
1565
|
+
}));
|
|
1566
|
+
},
|
|
1567
|
+
fail: function fail() {
|
|
1568
|
+
_this6.isEnterRoom = false;
|
|
1569
|
+
logger.info('enterRoom fail');
|
|
1570
|
+
_this6.emit('onEnterRoom', -1);
|
|
1571
|
+
}
|
|
1572
|
+
});
|
|
1573
|
+
case 9:
|
|
1574
|
+
case "end":
|
|
1575
|
+
return _context2.stop();
|
|
1576
|
+
}
|
|
1577
|
+
}, _callee2, this);
|
|
1578
|
+
}));
|
|
1200
1579
|
}
|
|
1201
1580
|
/**
|
|
1202
1581
|
* @category 房间
|
|
@@ -1204,7 +1583,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1204
1583
|
}, {
|
|
1205
1584
|
key: "exitRoom",
|
|
1206
1585
|
value: function exitRoom() {
|
|
1207
|
-
var
|
|
1586
|
+
var _this7 = this;
|
|
1208
1587
|
logger.info('exitRoom');
|
|
1209
1588
|
var _this$trtc$exitRoom = this.trtc.exitRoom(),
|
|
1210
1589
|
pusher = _this$trtc$exitRoom.pusher;
|
|
@@ -1212,8 +1591,8 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1212
1591
|
pusher: pusher,
|
|
1213
1592
|
callback: function callback() {
|
|
1214
1593
|
logger.info('exitRoom success');
|
|
1215
|
-
|
|
1216
|
-
|
|
1594
|
+
_this7.reset();
|
|
1595
|
+
_this7.emit('onExitRoom', 0);
|
|
1217
1596
|
}
|
|
1218
1597
|
});
|
|
1219
1598
|
}
|
|
@@ -1230,26 +1609,36 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1230
1609
|
}, {
|
|
1231
1610
|
key: "switchRole",
|
|
1232
1611
|
value: function switchRole(role) {
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1612
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
1613
|
+
var tempRole;
|
|
1614
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1615
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1616
|
+
case 0:
|
|
1617
|
+
logger.info('switchRole with options: ', role);
|
|
1618
|
+
tempRole = this.role;
|
|
1619
|
+
this.role = role;
|
|
1620
|
+
if (!(tempRole === role || role === exports.TRTCRoleType.TRTCRoleAnchor)) {
|
|
1621
|
+
_context3.next = 7;
|
|
1622
|
+
break;
|
|
1623
|
+
}
|
|
1624
|
+
logger.info('switchRole success');
|
|
1625
|
+
this.emit('onSwitchRole', 0, '');
|
|
1626
|
+
return _context3.abrupt("return");
|
|
1627
|
+
case 7:
|
|
1628
|
+
_context3.next = 9;
|
|
1629
|
+
return this.setPusherAttributes({
|
|
1630
|
+
enableCamera: false,
|
|
1631
|
+
enableMic: false
|
|
1632
|
+
}, 'switchRole');
|
|
1633
|
+
case 9:
|
|
1634
|
+
logger.info('switchRole success');
|
|
1635
|
+
this.emit('onSwitchRole', 0, '');
|
|
1636
|
+
case 11:
|
|
1637
|
+
case "end":
|
|
1638
|
+
return _context3.stop();
|
|
1639
|
+
}
|
|
1640
|
+
}, _callee3, this);
|
|
1641
|
+
}));
|
|
1253
1642
|
}
|
|
1254
1643
|
}, {
|
|
1255
1644
|
key: "connectOtherRoom",
|
|
@@ -1267,42 +1656,42 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1267
1656
|
}, {
|
|
1268
1657
|
key: "startLocalPreview",
|
|
1269
1658
|
value: function startLocalPreview() {
|
|
1270
|
-
var _this8 = this;
|
|
1271
1659
|
var frontCamera = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1660
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
1661
|
+
var _this8 = this;
|
|
1662
|
+
var pusher;
|
|
1663
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1664
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
1665
|
+
case 0:
|
|
1666
|
+
logger.info('startLocalPreview with options: ', frontCamera);
|
|
1667
|
+
if (!(this.role !== exports.TRTCRoleType.TRTCRoleAnchor)) {
|
|
1668
|
+
_context4.next = 3;
|
|
1669
|
+
break;
|
|
1670
|
+
}
|
|
1671
|
+
return _context4.abrupt("return");
|
|
1672
|
+
case 3:
|
|
1673
|
+
_context4.next = 5;
|
|
1674
|
+
return this.setPusherAttributes(function () {
|
|
1675
|
+
return {
|
|
1676
|
+
videoPreview: _this8.isEnterRoom ? _this8.isVideoMuted : true,
|
|
1677
|
+
enableCamera: _this8.isEnterRoom ? !_this8.isVideoMuted : false,
|
|
1678
|
+
frontCamera: frontCamera ? 'front' : 'back'
|
|
1679
|
+
};
|
|
1680
|
+
}, 'startLocalPreview');
|
|
1681
|
+
case 5:
|
|
1682
|
+
pusher = _context4.sent;
|
|
1683
|
+
logger.info('startLocalPreview success');
|
|
1684
|
+
this.emit('onFirstVideoFrame', '', exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig, pusher.videoWidth, pusher.videoHeight);
|
|
1685
|
+
if (this.isEnterRoom) {
|
|
1686
|
+
this.emit('onSendFirstLocalVideoFrame', exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
1687
|
+
}
|
|
1688
|
+
this.isOpenCamera = true;
|
|
1689
|
+
case 10:
|
|
1690
|
+
case "end":
|
|
1691
|
+
return _context4.stop();
|
|
1303
1692
|
}
|
|
1304
|
-
});
|
|
1305
|
-
});
|
|
1693
|
+
}, _callee4, this);
|
|
1694
|
+
}));
|
|
1306
1695
|
}
|
|
1307
1696
|
/**
|
|
1308
1697
|
* 停止本地摄像头采集和预览
|
|
@@ -1311,20 +1700,26 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1311
1700
|
}, {
|
|
1312
1701
|
key: "stopLocalPreview",
|
|
1313
1702
|
value: function stopLocalPreview() {
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1703
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
1704
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1705
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
1706
|
+
case 0:
|
|
1707
|
+
logger.info('stopLocalPreview');
|
|
1708
|
+
_context5.next = 3;
|
|
1709
|
+
return this.setPusherAttributes({
|
|
1710
|
+
videoPreview: false,
|
|
1711
|
+
enableCamera: false
|
|
1712
|
+
}, 'stopLocalPreview');
|
|
1713
|
+
case 3:
|
|
1714
|
+
logger.info('stopLocalPreview success');
|
|
1715
|
+
this.isOpenCamera = false;
|
|
1716
|
+
this.emit('onUserVideoAvailable', this.userId, 0);
|
|
1717
|
+
case 6:
|
|
1718
|
+
case "end":
|
|
1719
|
+
return _context5.stop();
|
|
1720
|
+
}
|
|
1721
|
+
}, _callee5, this);
|
|
1722
|
+
}));
|
|
1328
1723
|
}
|
|
1329
1724
|
/**
|
|
1330
1725
|
* 修改本地摄像头预览的 HTML 元素,小程序不支持
|
|
@@ -1349,34 +1744,49 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1349
1744
|
}, {
|
|
1350
1745
|
key: "muteLocalVideo",
|
|
1351
1746
|
value: function muteLocalVideo(mute, streamType) {
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
switch (streamType) {
|
|
1361
|
-
case exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig:
|
|
1362
|
-
case exports.TRTCVideoStreamType.TRTCVideoStreamTypeSub:
|
|
1363
|
-
_this10.isMuted = mute;
|
|
1364
|
-
pusher = _this10.trtc.setPusherAttributes({
|
|
1365
|
-
videoPreview: mute,
|
|
1366
|
-
enableCamera: !mute
|
|
1367
|
-
});
|
|
1368
|
-
_this10.InterfaceEventEmitter.emit('pusherAttributesChange', {
|
|
1369
|
-
pusher: pusher,
|
|
1370
|
-
callback: function callback() {
|
|
1371
|
-
logger.info('muteLocalVideo success');
|
|
1372
|
-
resolve(null);
|
|
1747
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
1748
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1749
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
1750
|
+
case 0:
|
|
1751
|
+
logger.info('muteLocalVideo called with options: ', mute, streamType);
|
|
1752
|
+
if (this.isOpenCamera) {
|
|
1753
|
+
_context6.next = 4;
|
|
1754
|
+
break;
|
|
1373
1755
|
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1756
|
+
logger.info('muteLocalVideo early exit: isOpenCamera is false');
|
|
1757
|
+
return _context6.abrupt("return");
|
|
1758
|
+
case 4:
|
|
1759
|
+
_context6.t0 = streamType;
|
|
1760
|
+
_context6.next = _context6.t0 === exports.TRTCVideoStreamType.TRTCVideoStreamTypeBig ? 7 : _context6.t0 === exports.TRTCVideoStreamType.TRTCVideoStreamTypeSub ? 7 : 20;
|
|
1761
|
+
break;
|
|
1762
|
+
case 7:
|
|
1763
|
+
this.isVideoMuted = mute;
|
|
1764
|
+
logger.info('muteLocalVideo: isVideoMuted set to ', mute);
|
|
1765
|
+
_context6.prev = 9;
|
|
1766
|
+
_context6.next = 12;
|
|
1767
|
+
return this.setPusherAttributes({
|
|
1768
|
+
videoPreview: mute,
|
|
1769
|
+
enableCamera: !mute
|
|
1770
|
+
}, 'muteLocalVideo');
|
|
1771
|
+
case 12:
|
|
1772
|
+
logger.info('muteLocalVideo: setPusherAttributes success');
|
|
1773
|
+
_context6.next = 18;
|
|
1774
|
+
break;
|
|
1775
|
+
case 15:
|
|
1776
|
+
_context6.prev = 15;
|
|
1777
|
+
_context6.t1 = _context6["catch"](9);
|
|
1778
|
+
logger.error('muteLocalVideo: setPusherAttributes failed with error ', _context6.t1);
|
|
1779
|
+
case 18:
|
|
1780
|
+
logger.info('muteLocalVideo success');
|
|
1781
|
+
return _context6.abrupt("break", 21);
|
|
1782
|
+
case 20:
|
|
1783
|
+
logger.info('muteLocalVideo: streamType not supported ', streamType);
|
|
1784
|
+
case 21:
|
|
1785
|
+
case "end":
|
|
1786
|
+
return _context6.stop();
|
|
1787
|
+
}
|
|
1788
|
+
}, _callee6, this, [[9, 15]]);
|
|
1789
|
+
}));
|
|
1380
1790
|
}
|
|
1381
1791
|
/**
|
|
1382
1792
|
* 开始显示远端视频画面
|
|
@@ -1388,7 +1798,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1388
1798
|
}, {
|
|
1389
1799
|
key: "startRemoteView",
|
|
1390
1800
|
value: function startRemoteView(userId, view, streamType) {
|
|
1391
|
-
var
|
|
1801
|
+
var _this9 = this;
|
|
1392
1802
|
logger.info('startRemoteView with options: ', userId, view, streamType);
|
|
1393
1803
|
var streamId = translateTRTCStreamId(userId, streamType);
|
|
1394
1804
|
var playerAttributes = this.setTRTCPlayerAttributes(streamId, {
|
|
@@ -1402,7 +1812,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1402
1812
|
playerAttributes: playerAttributes,
|
|
1403
1813
|
callback: function callback() {
|
|
1404
1814
|
logger.info('startRemoteView success');
|
|
1405
|
-
|
|
1815
|
+
_this9.emit('onFirstVideoFrame', userId, streamType, 0, 0);
|
|
1406
1816
|
}
|
|
1407
1817
|
});
|
|
1408
1818
|
}
|
|
@@ -1452,18 +1862,18 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1452
1862
|
}, {
|
|
1453
1863
|
key: "stopAllRemoteView",
|
|
1454
1864
|
value: function stopAllRemoteView() {
|
|
1455
|
-
var
|
|
1865
|
+
var _this10 = this;
|
|
1456
1866
|
logger.info('stopAllRemoteView');
|
|
1457
1867
|
var playerList = this.trtc.getPlayerList();
|
|
1458
1868
|
playerList.forEach(function (player) {
|
|
1459
1869
|
var streamId = player.streamID;
|
|
1460
|
-
var playerAttributes =
|
|
1870
|
+
var playerAttributes = _this10.setTRTCPlayerAttributes(streamId, {
|
|
1461
1871
|
muteVideo: true,
|
|
1462
1872
|
stopVideo: true
|
|
1463
1873
|
});
|
|
1464
|
-
|
|
1874
|
+
_this10.InterfaceEventEmitter.emit('playerAttributesChange', {
|
|
1465
1875
|
streamId: streamId,
|
|
1466
|
-
view:
|
|
1876
|
+
view: _this10.renderMap.get(streamId),
|
|
1467
1877
|
playerAttributes: playerAttributes,
|
|
1468
1878
|
callback: function callback() {
|
|
1469
1879
|
logger.info('stopAllRemoteView success');
|
|
@@ -1493,17 +1903,17 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1493
1903
|
}, {
|
|
1494
1904
|
key: "muteAllRemoteVideoStreams",
|
|
1495
1905
|
value: function muteAllRemoteVideoStreams(mute) {
|
|
1496
|
-
var
|
|
1906
|
+
var _this11 = this;
|
|
1497
1907
|
logger.info('muteAllRemoteVideoStreams with options: ', mute);
|
|
1498
1908
|
var playerList = this.trtc.getPlayerList();
|
|
1499
1909
|
playerList.forEach(function (player) {
|
|
1500
1910
|
var streamId = player.streamID;
|
|
1501
|
-
var playerAttributes =
|
|
1911
|
+
var playerAttributes = _this11.setTRTCPlayerAttributes(streamId, {
|
|
1502
1912
|
muteVideo: mute
|
|
1503
1913
|
});
|
|
1504
|
-
|
|
1914
|
+
_this11.InterfaceEventEmitter.emit('playerAttributesChange', {
|
|
1505
1915
|
streamId: streamId,
|
|
1506
|
-
view:
|
|
1916
|
+
view: _this11.renderMap.get(streamId),
|
|
1507
1917
|
playerAttributes: playerAttributes,
|
|
1508
1918
|
callback: function callback() {
|
|
1509
1919
|
logger.info('muteAllRemoteVideoStreams success');
|
|
@@ -1522,49 +1932,56 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1522
1932
|
}, {
|
|
1523
1933
|
key: "setVideoEncoderParam",
|
|
1524
1934
|
value: function setVideoEncoderParam(params) {
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1935
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1936
|
+
var videoResolution, videoFps, minVideoBitrate, _translateTRTCVideoRe, videoWidth, videoHeight;
|
|
1937
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1938
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1939
|
+
case 0:
|
|
1940
|
+
logger.info('setVideoEncoderParam with options: ', JSON.stringify(params));
|
|
1941
|
+
videoResolution = params.videoResolution, params.resMode, videoFps = params.videoFps, params.videoBitrate, minVideoBitrate = params.minVideoBitrate;
|
|
1942
|
+
_translateTRTCVideoRe = translateTRTCVideoResolution(videoResolution), videoWidth = _translateTRTCVideoRe.videoWidth, videoHeight = _translateTRTCVideoRe.videoHeight; // const videoOrientation = translateTRTCVideoResolutionMode(resMode);
|
|
1943
|
+
_context7.next = 5;
|
|
1944
|
+
return this.setPusherAttributes({
|
|
1945
|
+
videoWidth: videoWidth,
|
|
1946
|
+
videoHeight: videoHeight,
|
|
1947
|
+
// videoOrientation,
|
|
1948
|
+
fps: videoFps,
|
|
1949
|
+
minBitrate: minVideoBitrate
|
|
1950
|
+
}, 'setVideoEncoderParam');
|
|
1951
|
+
case 5:
|
|
1952
|
+
logger.info('setVideoEncoderParam success');
|
|
1953
|
+
case 6:
|
|
1954
|
+
case "end":
|
|
1955
|
+
return _context7.stop();
|
|
1956
|
+
}
|
|
1957
|
+
}, _callee7, this);
|
|
1958
|
+
}));
|
|
1548
1959
|
}
|
|
1549
1960
|
}, {
|
|
1550
1961
|
key: "setLocalRenderParams",
|
|
1551
1962
|
value: function setLocalRenderParams(params) {
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1963
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1964
|
+
var rotation, mirrorType, videoOrientation, localMirror;
|
|
1965
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1966
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1967
|
+
case 0:
|
|
1968
|
+
logger.info('setLocalRenderParams with options: ', JSON.stringify(params));
|
|
1969
|
+
rotation = params.rotation, params.fillMode, mirrorType = params.mirrorType;
|
|
1970
|
+
videoOrientation = translateTRTCVideoRotation(rotation);
|
|
1971
|
+
localMirror = translateTRTCVideoMirrorType(mirrorType);
|
|
1972
|
+
_context8.next = 6;
|
|
1973
|
+
return this.setPusherAttributes({
|
|
1974
|
+
videoOrientation: videoOrientation,
|
|
1975
|
+
localMirror: localMirror
|
|
1976
|
+
}, 'setLocalRenderParams');
|
|
1977
|
+
case 6:
|
|
1978
|
+
logger.info('setLocalRenderParams success');
|
|
1979
|
+
case 7:
|
|
1980
|
+
case "end":
|
|
1981
|
+
return _context8.stop();
|
|
1982
|
+
}
|
|
1983
|
+
}, _callee8, this);
|
|
1984
|
+
}));
|
|
1568
1985
|
}
|
|
1569
1986
|
/**
|
|
1570
1987
|
* 设置远端图像的渲染模式
|
|
@@ -1596,54 +2013,98 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1596
2013
|
}, {
|
|
1597
2014
|
key: "startLocalAudio",
|
|
1598
2015
|
value: function startLocalAudio(quality) {
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
2016
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
2017
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
2018
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
2019
|
+
case 0:
|
|
2020
|
+
logger.info('startLocalAudio with options: ', quality);
|
|
2021
|
+
if (!(this.role !== exports.TRTCRoleType.TRTCRoleAnchor)) {
|
|
2022
|
+
_context9.next = 3;
|
|
2023
|
+
break;
|
|
2024
|
+
}
|
|
2025
|
+
throw new Error('Current role is audience, unable to access mic. Call switchRole to become a host.');
|
|
2026
|
+
case 3:
|
|
2027
|
+
_context9.next = 5;
|
|
2028
|
+
return this.setPusherAttributes({
|
|
2029
|
+
enableMic: true
|
|
2030
|
+
}, 'startLocalAudio');
|
|
2031
|
+
case 5:
|
|
2032
|
+
logger.info('startLocalAudio success');
|
|
2033
|
+
this.emit('onMicDidReady');
|
|
2034
|
+
this.emit('onUserAudioAvailable', this.userId, 1);
|
|
2035
|
+
if (this.enterRoom) {
|
|
2036
|
+
this.emit('onSendFirstLocalAudioFrame');
|
|
2037
|
+
}
|
|
2038
|
+
case 9:
|
|
2039
|
+
case "end":
|
|
2040
|
+
return _context9.stop();
|
|
1612
2041
|
}
|
|
1613
|
-
}
|
|
1614
|
-
});
|
|
2042
|
+
}, _callee9, this);
|
|
2043
|
+
}));
|
|
1615
2044
|
}
|
|
1616
2045
|
}, {
|
|
1617
2046
|
key: "stopLocalAudio",
|
|
1618
2047
|
value: function stopLocalAudio() {
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
2048
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
2049
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
2050
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
2051
|
+
case 0:
|
|
2052
|
+
logger.info('stopLocalAudio');
|
|
2053
|
+
_context10.next = 3;
|
|
2054
|
+
return this.setPusherAttributes({
|
|
2055
|
+
enableMic: false
|
|
2056
|
+
}, 'stopLocalAudio');
|
|
2057
|
+
case 3:
|
|
2058
|
+
logger.info('stopLocalAudio success');
|
|
2059
|
+
this.emit('onUserAudioAvailable', this.userId, 0);
|
|
2060
|
+
case 5:
|
|
2061
|
+
case "end":
|
|
2062
|
+
return _context10.stop();
|
|
2063
|
+
}
|
|
2064
|
+
}, _callee10, this);
|
|
2065
|
+
}));
|
|
1631
2066
|
}
|
|
1632
2067
|
}, {
|
|
1633
2068
|
key: "muteLocalAudio",
|
|
1634
2069
|
value: function muteLocalAudio(mute) {
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
2070
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
2071
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
2072
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
2073
|
+
case 0:
|
|
2074
|
+
logger.info('muteLocalAudio called with options: ', mute);
|
|
2075
|
+
_context11.prev = 1;
|
|
2076
|
+
_context11.next = 4;
|
|
2077
|
+
return this.setPusherAttributes({
|
|
2078
|
+
muted: mute
|
|
2079
|
+
}, 'muteLocalAudio');
|
|
2080
|
+
case 4:
|
|
2081
|
+
logger.info('setPusherAttributes executed successfully');
|
|
2082
|
+
_context11.next = 11;
|
|
2083
|
+
break;
|
|
2084
|
+
case 7:
|
|
2085
|
+
_context11.prev = 7;
|
|
2086
|
+
_context11.t0 = _context11["catch"](1);
|
|
2087
|
+
logger.error('Error in setPusherAttributes: ', _context11.t0);
|
|
2088
|
+
throw _context11.t0;
|
|
2089
|
+
case 11:
|
|
2090
|
+
_context11.prev = 11;
|
|
2091
|
+
this.emit('onUserAudioAvailable', this.userId, mute === true ? 0 : 1);
|
|
2092
|
+
logger.info('onUserAudioAvailable event emitted successfully');
|
|
2093
|
+
_context11.next = 20;
|
|
2094
|
+
break;
|
|
2095
|
+
case 16:
|
|
2096
|
+
_context11.prev = 16;
|
|
2097
|
+
_context11.t1 = _context11["catch"](11);
|
|
2098
|
+
logger.error('Error in emitting onUserAudioAvailable event: ', _context11.t1);
|
|
2099
|
+
throw _context11.t1;
|
|
2100
|
+
case 20:
|
|
2101
|
+
logger.info('muteLocalAudio execution finished');
|
|
2102
|
+
case 21:
|
|
2103
|
+
case "end":
|
|
2104
|
+
return _context11.stop();
|
|
2105
|
+
}
|
|
2106
|
+
}, _callee11, this, [[1, 7], [11, 16]]);
|
|
2107
|
+
}));
|
|
1647
2108
|
}
|
|
1648
2109
|
}, {
|
|
1649
2110
|
key: "muteRemoteAudio",
|
|
@@ -1665,17 +2126,17 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1665
2126
|
}, {
|
|
1666
2127
|
key: "muteAllRemoteAudio",
|
|
1667
2128
|
value: function muteAllRemoteAudio(mute) {
|
|
1668
|
-
var
|
|
2129
|
+
var _this12 = this;
|
|
1669
2130
|
logger.info('muteAllRemoteAudio with options: ', mute);
|
|
1670
2131
|
var playerList = this.trtc.getPlayerList();
|
|
1671
2132
|
playerList.forEach(function (player) {
|
|
1672
2133
|
var streamId = player.streamID;
|
|
1673
|
-
var playerAttributes =
|
|
2134
|
+
var playerAttributes = _this12.setTRTCPlayerAttributes(streamId, {
|
|
1674
2135
|
muteAudio: mute
|
|
1675
2136
|
});
|
|
1676
|
-
|
|
2137
|
+
_this12.InterfaceEventEmitter.emit('playerAttributesChange', {
|
|
1677
2138
|
streamId: streamId,
|
|
1678
|
-
view:
|
|
2139
|
+
view: _this12.renderMap.get(streamId),
|
|
1679
2140
|
playerAttributes: playerAttributes,
|
|
1680
2141
|
callback: function callback() {
|
|
1681
2142
|
logger.info('muteAllRemoteAudio success');
|
|
@@ -1695,23 +2156,30 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1695
2156
|
}, {
|
|
1696
2157
|
key: "switchCamera",
|
|
1697
2158
|
value: function switchCamera(frontCamera) {
|
|
1698
|
-
var
|
|
2159
|
+
var _this13 = this;
|
|
1699
2160
|
logger.info('switchCamera with options: ', frontCamera);
|
|
1700
2161
|
var pusher = this.trtc.getPusherInstance();
|
|
1701
2162
|
if (frontCamera === (pusher.pusherAttributes.frontCamera === 'front')) return Promise.resolve();
|
|
1702
2163
|
return new Promise(function (resolve, reject) {
|
|
1703
2164
|
wx.createLivePusherContext().switchCamera({
|
|
1704
2165
|
success: function success(event) {
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
2166
|
+
return __awaiter(_this13, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
2167
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
2168
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
2169
|
+
case 0:
|
|
2170
|
+
_context12.next = 2;
|
|
2171
|
+
return this.setPusherAttributes({
|
|
2172
|
+
frontCamera: frontCamera
|
|
2173
|
+
}, 'switchCamera');
|
|
2174
|
+
case 2:
|
|
2175
|
+
logger.info('switchCamera success');
|
|
2176
|
+
resolve(event);
|
|
2177
|
+
case 4:
|
|
2178
|
+
case "end":
|
|
2179
|
+
return _context12.stop();
|
|
2180
|
+
}
|
|
2181
|
+
}, _callee12, this);
|
|
2182
|
+
}));
|
|
1715
2183
|
},
|
|
1716
2184
|
fail: function fail(error) {
|
|
1717
2185
|
logger.info('switchCamera fail');
|
|
@@ -1723,18 +2191,25 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1723
2191
|
}, {
|
|
1724
2192
|
key: "setBeautyStyle",
|
|
1725
2193
|
value: function setBeautyStyle(style, beauty, white, ruddiness) {
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
2194
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
2195
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
2196
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2197
|
+
case 0:
|
|
2198
|
+
logger.info('setBeautyStyle with options: ', style, beauty, white, ruddiness);
|
|
2199
|
+
_context13.next = 3;
|
|
2200
|
+
return this.setPusherAttributes({
|
|
2201
|
+
beautyStyle: style,
|
|
2202
|
+
beautyLevel: beauty,
|
|
2203
|
+
whitenessLevel: white
|
|
2204
|
+
}, 'setBeautyStyle');
|
|
2205
|
+
case 3:
|
|
2206
|
+
logger.info('setBeautyStyle success');
|
|
2207
|
+
case 4:
|
|
2208
|
+
case "end":
|
|
2209
|
+
return _context13.stop();
|
|
2210
|
+
}
|
|
2211
|
+
}, _callee13, this);
|
|
2212
|
+
}));
|
|
1738
2213
|
}
|
|
1739
2214
|
}, {
|
|
1740
2215
|
key: "sendSEIMsg",
|
|
@@ -1898,6 +2373,40 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1898
2373
|
}
|
|
1899
2374
|
}
|
|
1900
2375
|
}
|
|
2376
|
+
}, {
|
|
2377
|
+
key: "setPusherAttributes",
|
|
2378
|
+
value: function setPusherAttributes(params, funName) {
|
|
2379
|
+
var _this14 = this;
|
|
2380
|
+
// 定义一个超时时间(以毫秒为单位)
|
|
2381
|
+
var timeoutDuration = 2000;
|
|
2382
|
+
var timeoutPromise = new Promise(function (resolve, reject) {
|
|
2383
|
+
setTimeout(function () {
|
|
2384
|
+
reject(new Error('setPusherAttributes timed out'));
|
|
2385
|
+
}, timeoutDuration);
|
|
2386
|
+
});
|
|
2387
|
+
var originalPromise = new Promise(function (resolve, reject) {
|
|
2388
|
+
try {
|
|
2389
|
+
var pusher = {};
|
|
2390
|
+
switch (funName) {
|
|
2391
|
+
case 'enterRoom':
|
|
2392
|
+
pusher = _this14.trtc.enterRoom(params);
|
|
2393
|
+
break;
|
|
2394
|
+
default:
|
|
2395
|
+
pusher = _this14.trtc.setPusherAttributes(params);
|
|
2396
|
+
break;
|
|
2397
|
+
}
|
|
2398
|
+
_this14.InterfaceEventEmitter.emit('pusherAttributesChange', {
|
|
2399
|
+
pusher: pusher,
|
|
2400
|
+
callback: function callback() {
|
|
2401
|
+
resolve(pusher);
|
|
2402
|
+
}
|
|
2403
|
+
});
|
|
2404
|
+
} catch (err) {
|
|
2405
|
+
reject(err);
|
|
2406
|
+
}
|
|
2407
|
+
});
|
|
2408
|
+
return Promise.race([originalPromise, timeoutPromise]);
|
|
2409
|
+
}
|
|
1901
2410
|
}], [{
|
|
1902
2411
|
key: "getTRTCShareInstance",
|
|
1903
2412
|
value: function getTRTCShareInstance() {
|
|
@@ -1920,6 +2429,7 @@ var TRTCCloud = /*#__PURE__*/function () {
|
|
|
1920
2429
|
}]);
|
|
1921
2430
|
return TRTCCloud;
|
|
1922
2431
|
}();
|
|
2432
|
+
__decorate([setHandle], TRTCCloud.prototype, "setPusherAttributes", null);
|
|
1923
2433
|
|
|
1924
2434
|
exports.TRTCCloud = TRTCCloud;
|
|
1925
2435
|
exports.default = TRTCCloud;
|