李勇

1.修改媒体共享和伴音模块的seek间隔处理;2.音视频m3u8地址增加playlist ;3.修改mcu\ms\rtmp\hls的地址数据来源

@@ -35,7 +35,7 @@ import QuestionApe from 'apes/QuestionApe'; @@ -35,7 +35,7 @@ import QuestionApe from 'apes/QuestionApe';
35 import UTF8 from 'utf-8'; 35 import UTF8 from 'utf-8';
36 36
37 let loger = Loger.getLoger('McuClient'); 37 let loger = Loger.getLoger('McuClient');
38 -let _sdkInfo = { "version": "v1.52.1.20170726", "author": "www.3mang.com" }; 38 +let _sdkInfo = {"version": "v1.54.2.20170727", "author": "www.3mang.com"};
39 39
40 //APE 40 //APE
41 let _sass; 41 let _sass;
@@ -66,8 +66,11 @@ export default class MessageEntrance extends Emiter { @@ -66,8 +66,11 @@ export default class MessageEntrance extends Emiter {
66 this.classRecordStatusUpdateTimer = 0; //课堂录制状态发生改变后同步当前所有模块数据的计时器 66 this.classRecordStatusUpdateTimer = 0; //课堂录制状态发生改变后同步当前所有模块数据的计时器
67 //初始化状态 67 //初始化状态
68 this.isGetUserIpCallback = false; //是否获取IP信息返回 68 this.isGetUserIpCallback = false; //是否获取IP信息返回
69 - this.isGetFastestMcuCallback = false; //是否MCU选点结束  
70 - this.isGetFastestMsCallback = false; //是否MS选点结束 69 + this.isGetFastestMcuCallback = false; //是否MCU测速结束
  70 + this.isGetFastestMsCallback = false; //是否MS测速结束
  71 + this.isGetFastestRtmpPullCallback = false; //是否RTMP拉流地址测试结束
  72 + this.isGetFastestHlsPullCallback = false; //是否HLS拉流地址测试结束
  73 + this.isGetFastestRsCallback = false; //是否录制回放HLS拉流地址测试结束
71 74
72 //全局的Error处理 75 //全局的Error处理
73 this.on(MessageTypes.MCU_ERROR, this._mcuErrorHandler.bind(this)); 76 this.on(MessageTypes.MCU_ERROR, this._mcuErrorHandler.bind(this));
@@ -111,6 +114,8 @@ export default class MessageEntrance extends Emiter { @@ -111,6 +114,8 @@ export default class MessageEntrance extends Emiter {
111 _confer_ape.on(MessageTypes.CLASS_RECORD_START, this._onClassRecordStart.bind(this)); //课堂开始录制 114 _confer_ape.on(MessageTypes.CLASS_RECORD_START, this._onClassRecordStart.bind(this)); //课堂开始录制
112 _confer_ape.on(MessageTypes.CLASS_RECORD_SUCCESS, this._onClassRecordSuccess.bind(this)); //课堂开启录制成功 115 _confer_ape.on(MessageTypes.CLASS_RECORD_SUCCESS, this._onClassRecordSuccess.bind(this)); //课堂开启录制成功
113 _confer_ape.on(MessageTypes.SWITCH_MS_IP, this._switchMsIpHandler.bind(this)); //MS动态选点 116 _confer_ape.on(MessageTypes.SWITCH_MS_IP, this._switchMsIpHandler.bind(this)); //MS动态选点
  117 + _confer_ape.on(MessageTypes.SWITCH_RTMP_PULL_IP, this._switchRtmpPullIpHandler.bind(this)); //MS 拉流地址动态选点
  118 + _confer_ape.on(MessageTypes.SWITCH_HLS_IP, this._switchHlsIpHandler.bind(this)); //MS HLS动态选点
114 _confer_ape.on(MessageTypes.STOP_ALL_MEDIA_PUBLISH, this._stopAllMediaPublishHandler.bind(this)); //课堂状态发生改变,需要停止当前的所有推流 119 _confer_ape.on(MessageTypes.STOP_ALL_MEDIA_PUBLISH, this._stopAllMediaPublishHandler.bind(this)); //课堂状态发生改变,需要停止当前的所有推流
115 120
116 _chat_ape = new ChatApe(); 121 _chat_ape = new ChatApe();
@@ -166,9 +171,9 @@ export default class MessageEntrance extends Emiter { @@ -166,9 +171,9 @@ export default class MessageEntrance extends Emiter {
166 171
167 this.sceneTableChange = this._sceneTableChange.bind(this); //切换模块显示 172 this.sceneTableChange = this._sceneTableChange.bind(this); //切换模块显示
168 173
169 - this.kickOutRosterFormNodeId= this._kickOutRosterFormNodeId.bind(this); //把指定nodeId的人踢出课堂 174 + this.kickOutRosterFormNodeId = this._kickOutRosterFormNodeId.bind(this); //把指定nodeId的人踢出课堂
170 175
171 - this.sendThridChannelMessage=this._sendThridChannelMessage.bind(this);//通道第三方消息通道发送消息 176 + this.sendThridChannelMessage = this._sendThridChannelMessage.bind(this);//通道第三方消息通道发送消息
172 177
173 //录制回放 178 //录制回放
174 this.initRecordPlayback = this._initRecordPlayback.bind(this); 179 this.initRecordPlayback = this._initRecordPlayback.bind(this);
@@ -256,12 +261,13 @@ export default class MessageEntrance extends Emiter { @@ -256,12 +261,13 @@ export default class MessageEntrance extends Emiter {
256 } 261 }
257 262
258 _setDebugInfo(_data) { 263 _setDebugInfo(_data) {
259 - loger.log("设置debug信息-->", _data);  
260 - if (_data) {  
261 - Loger.setLogDebug(_data.isDebug);  
262 - } 264 + loger.log("设置debug信息-->", _data);
  265 + if (_data) {
  266 + Loger.setLogDebug(_data.isDebug);
263 } 267 }
264 - //设置设备信息 268 + }
  269 +
  270 + //设置设备信息
265 _setDeviceInfo(_data) { 271 _setDeviceInfo(_data) {
266 loger.log("设置设备信息-->", _data); 272 loger.log("设置设备信息-->", _data);
267 if (_data) { 273 if (_data) {
@@ -296,7 +302,7 @@ export default class MessageEntrance extends Emiter { @@ -296,7 +302,7 @@ export default class MessageEntrance extends Emiter {
296 //mcu异常监听 302 //mcu异常监听
297 _mcuErrorHandler(_data, _option) { 303 _mcuErrorHandler(_data, _option) {
298 let option = _option || ""; 304 let option = _option || "";
299 - let errorMessage = { "code": _data, "reson": MessageTypes.ErrorReson[_data] + " " + option }; 305 + let errorMessage = {"code": _data, "reson": MessageTypes.ErrorReson[_data] + " " + option};
300 this._emit(MessageTypes.ERROR_EVENT, errorMessage); 306 this._emit(MessageTypes.ERROR_EVENT, errorMessage);
301 loger.error("MCU_ERROR", errorMessage); 307 loger.error("MCU_ERROR", errorMessage);
302 } 308 }
@@ -316,12 +322,6 @@ export default class MessageEntrance extends Emiter { @@ -316,12 +322,6 @@ export default class MessageEntrance extends Emiter {
316 return GlobalConfig.classStatusInfo; 322 return GlobalConfig.classStatusInfo;
317 } 323 }
318 324
319 - /*  
320 - //关闭课堂,所有人都退出  
321 - _doClassClose(_param) {  
322 - this._leaveClass();  
323 - }*/  
324 -  
325 //执行离开课堂断开连接的流程 325 //执行离开课堂断开连接的流程
326 _runClassExit(_type) { 326 _runClassExit(_type) {
327 this._leaveClass(_type); 327 this._leaveClass(_type);
@@ -385,7 +385,9 @@ export default class MessageEntrance extends Emiter { @@ -385,7 +385,9 @@ export default class MessageEntrance extends Emiter {
385 } 385 }
386 386
387 //有人员离开 387 //有人员离开
388 - _onClassDeleteRoster(_data) {} 388 + _onClassDeleteRoster(_data) {
  389 +
  390 + }
389 391
390 //当前课堂中视频或音频占用channel的nodeId ,在人员列表中不存在,这种情况是占用channel的人员掉线或离开的时候没有释放channel 392 //当前课堂中视频或音频占用channel的nodeId ,在人员列表中不存在,这种情况是占用channel的人员掉线或离开的时候没有释放channel
391 //的占用状态导致,对于这种情况,需要释放掉 393 //的占用状态导致,对于这种情况,需要释放掉
@@ -399,7 +401,7 @@ export default class MessageEntrance extends Emiter { @@ -399,7 +401,7 @@ export default class MessageEntrance extends Emiter {
399 loger.warn("onClassNonentityRoster.参数错误") 401 loger.warn("onClassNonentityRoster.参数错误")
400 return; 402 return;
401 } 403 }
402 - let data = { "nodeId": _param.nodeId }; 404 + let data = {"nodeId": _param.nodeId};
403 if (_video_ape) { 405 if (_video_ape) {
404 _video_ape.stopPublishVideo(data); 406 _video_ape.stopPublishVideo(data);
405 407
@@ -437,25 +439,25 @@ export default class MessageEntrance extends Emiter { @@ -437,25 +439,25 @@ export default class MessageEntrance extends Emiter {
437 GlobalConfig.portal = _param.portal; 439 GlobalConfig.portal = _param.portal;
438 440
439 //H5处理 441 //H5处理
440 - GlobalConfig.isH5=_param.isH5||false;//外部传入的参数,是否是H5  
441 - if(GlobalConfig.isH5==true){  
442 - GlobalConfig.platform = "H5";  
443 - GlobalConfig.deviceType=3//3是H5 442 + GlobalConfig.isH5 = _param.isH5 || false;//外部传入的参数,是否是H5
  443 + if (GlobalConfig.isH5 == true) {
  444 + GlobalConfig.platform = "H5";
  445 + GlobalConfig.deviceType = 3//3是H5
444 loger.warn("设备类型是H5"); 446 loger.warn("设备类型是H5");
445 } 447 }
446 448
447 //IOS 安卓处理,需要外部传入摄像头和麦克风信息 449 //IOS 安卓处理,需要外部传入摄像头和麦克风信息
448 - if(GlobalConfig.isMobile){  
449 - GlobalConfig.cameras=_param.cameras||[];  
450 - GlobalConfig.microphones=_param.microphones||[]; 450 + if (GlobalConfig.isMobile) {
  451 + GlobalConfig.cameras = _param.cameras || [];
  452 + GlobalConfig.microphones = _param.microphones || [];
451 } 453 }
452 454
453 //如果没有名字,随机起一个名字 455 //如果没有名字,随机起一个名字
454 GlobalConfig.userName = _param.userName || "user_" + (new Date().getTime() % 1000000); 456 GlobalConfig.userName = _param.userName || "user_" + (new Date().getTime() % 1000000);
455 457
456 //如果没有userId或者为"0",随机生成 458 //如果没有userId或者为"0",随机生成
457 - if(!GlobalConfig.userId||GlobalConfig.userId=="0"){  
458 - GlobalConfig.userId="user_" + (new Date().getTime() % 1000000); 459 + if (!GlobalConfig.userId || GlobalConfig.userId == "0") {
  460 + GlobalConfig.userId = "user_" + (new Date().getTime() % 1000000);
459 } 461 }
460 //设置角色身份 462 //设置角色身份
461 GlobalConfig.userRole = _param.userRole || ApeConsts.normal; 463 GlobalConfig.userRole = _param.userRole || ApeConsts.normal;
@@ -527,7 +529,6 @@ export default class MessageEntrance extends Emiter { @@ -527,7 +529,6 @@ export default class MessageEntrance extends Emiter {
527 529
528 //host默认需要密码,Sass服务器只判断学生是否需要密码,没有判断老师的 530 //host默认需要密码,Sass服务器只判断学生是否需要密码,没有判断老师的
529 GlobalConfig.passwordRequired = _data.passwordRequired || false; //md5验证的时候需要Sass返回的值,不能更改 531 GlobalConfig.passwordRequired = _data.passwordRequired || false; //md5验证的时候需要Sass返回的值,不能更改
530 -  
531 loger.log('初始化课堂验证完成.'); 532 loger.log('初始化课堂验证完成.');
532 533
533 //设置当前的课堂状态 534 //设置当前的课堂状态
@@ -559,17 +560,18 @@ export default class MessageEntrance extends Emiter { @@ -559,17 +560,18 @@ export default class MessageEntrance extends Emiter {
559 } 560 }
560 } 561 }
561 562
562 - //根据UserIp获取ip信息,选点  
563 - getUserIpInfo() { 563 + //加载本地Server.json文件,UserIp获取ip信息,选点
  564 + loadServerJsonAndgetUserIpInfo() {
564 let _this = this; 565 let _this = this;
565 if (_ipManager) { 566 if (_ipManager) {
  567 + //先加载本地Server.json文件,然后获取userIp新
566 _ipManager.loadServerJosn(function (_data) { 568 _ipManager.loadServerJosn(function (_data) {
567 _ipManager.getUserIpInfo("", GlobalConfig.userIp, _this._getUserIpCallbackHandler.bind(_this), 2000); 569 _ipManager.getUserIpInfo("", GlobalConfig.userIp, _this._getUserIpCallbackHandler.bind(_this), 2000);
568 }) 570 })
569 } 571 }
570 } 572 }
571 573
572 - //获取IP信息完成 574 + //本地JOSN加载完成-获取IP信息完成
573 _getUserIpCallbackHandler(_data) { 575 _getUserIpCallbackHandler(_data) {
574 //获取IP信息,返回一次就不再处理 576 //获取IP信息,返回一次就不再处理
575 if (this.isGetUserIpCallback) { 577 if (this.isGetUserIpCallback) {
@@ -583,61 +585,177 @@ export default class MessageEntrance extends Emiter { @@ -583,61 +585,177 @@ export default class MessageEntrance extends Emiter {
583 GlobalConfig.isp = _data.isp; //服务商 585 GlobalConfig.isp = _data.isp; //服务商
584 } 586 }
585 587
586 - //合并MCU 、MS的列表  
587 - this._mergeMcuAndMsList(); 588 + //根据用户的userIp信息从sever.json和Sass中选择最终mcu和推流拉流数据列表
  589 + this._choiceMcuAndMsListFromServerAndSass();
588 590
589 - //开始选点 591 + loger.warn("加入课堂之前->开始测速选择默认服务");
  592 + //加入课堂之前开始第一次选点
590 let _this = this; 593 let _this = this;
591 594
592 - //有一些站点不需要进行MS选点,需要先检查一下  
593 - if (GlobalConfig.siteId_letv == GlobalConfig.siteId) {  
594 - //MS不需要选点  
595 - loger.log("MS不需要选点->siteId->", GlobalConfig.siteId);  
596 - _this.isGetFastestMcuCallback = true;  
597 - _this._startConnectMCU();  
598 - } else {  
599 - this._getFastestMsServer(function (_data) {  
600 - loger.log("MS选点结束->", _data); 595 +
  596 + //推流地址测速
  597 + this._getFastestIpFromServer(GlobalConfig.msListFinal,
  598 + function (_data) {
  599 + loger.log("推流地址测速->", _data);
601 if (_data && _data.ip) { 600 if (_data && _data.ip) {
602 GlobalConfig.MS_PUBLISH_IP = _data.ip || ""; 601 GlobalConfig.MS_PUBLISH_IP = _data.ip || "";
603 GlobalConfig.MS_PUBLISH_PORT = _data.port || ""; 602 GlobalConfig.MS_PUBLISH_PORT = _data.port || "";
604 } 603 }
605 - loger.log("当前使用的MS->", GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT);  
606 - _this.isGetFastestMcuCallback = true; 604 + _this.isGetFastestMsCallback = true;
607 _this._startConnectMCU(); 605 _this._startConnectMCU();
608 }); 606 });
609 - }  
610 607
  608 + //录制回放HLS拉流地址测速
  609 + this._getFastestIpFromServer(GlobalConfig.rsListFinal, function (_data) {
  610 + loger.log("录制回放HLS拉流地址测速->", _data);
  611 + if (_data && _data.ip) {
  612 + GlobalConfig.RS_RECORD_PLAY_IP = _data.ip || "";
  613 + GlobalConfig.RS_RECORD_PLAY_PORT = _data.port || "";
  614 + }
  615 + _this.isGetFastestRsCallback = true;
  616 + _this._startConnectMCU();
  617 + });
  618 +
  619 + //RTMP拉流地址测速
  620 + this._getFastestIpFromServer(GlobalConfig.rtmpPullListFinal, function (_data) {
  621 + loger.log("RTMP拉流地址测速->", _data);
  622 + if (_data && _data.ip) {
  623 + GlobalConfig.MS_PLAY_RTMP_IP = _data.ip || "";
  624 + GlobalConfig.MS_PLAY_RTMP_PORT = _data.port || "";
  625 + }
  626 + _this.isGetFastestRtmpPullCallback = true;
  627 + _this._startConnectMCU();
  628 + });
  629 +
  630 + //HLS拉流地址测速
  631 + this._getFastestIpFromServer(GlobalConfig.hlsListFinal, function (_data) {
  632 + loger.log("HLS拉流地址测速->", _data);
  633 + if (_data && _data.ip) {
  634 + GlobalConfig.MS_PLAY_HLS_IP = _data.ip || "";
  635 + GlobalConfig.MS_PLAY_HLS_PORT = _data.port || "";
  636 + }
  637 + _this.isGetFastestHlsPullCallback = true;
  638 + _this._startConnectMCU();
  639 + });
  640 +
  641 + //MCU测速
611 this._getFastestMcuServer(function (_data) { 642 this._getFastestMcuServer(function (_data) {
612 - loger.log("MCU选点结束->", _data); 643 + loger.log("MCU测速->", _data);
613 if (_data && _data.ip) { 644 if (_data && _data.ip) {
614 GlobalConfig.MCUServerIP = _data.ip || ""; 645 GlobalConfig.MCUServerIP = _data.ip || "";
615 GlobalConfig.MCUServerPort = _data.port || ""; 646 GlobalConfig.MCUServerPort = _data.port || "";
616 } 647 }
617 - loger.log("当前使用的MCU->", GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort);  
618 - _this.isGetFastestMsCallback = true; 648 + _this.isGetFastestMcuCallback = true;
619 _this._startConnectMCU(); 649 _this._startConnectMCU();
620 }); 650 });
621 } 651 }
622 652
623 - //开始连接MCU(MCU和MS都选点结束之后才开始连接) 653 +
  654 + /* //本地JOSN加载完成-获取IP信息完成
  655 + _getUserIpCallbackHandler(_data) {
  656 + //获取IP信息,返回一次就不再处理
  657 + if (this.isGetUserIpCallback) {
  658 + return;
  659 + }
  660 + this.isGetUserIpCallback = true;
  661 + if (_data && _data.ret == "ok") {
  662 + GlobalConfig.country = _data.country; //国家
  663 + GlobalConfig.city = _data.city; //城市
  664 + GlobalConfig.province = _data.province; //服务商
  665 + GlobalConfig.isp = _data.isp; //服务商
  666 + }
  667 +
  668 + //合并MCU 、MS的列表
  669 + this._choiceMcuAndMsList();
  670 +
  671 + //开始选点
  672 + let _this = this;
  673 +
  674 + //有一些站点不需要进行MS选点,需要先检查一下
  675 + if (GlobalConfig.siteId_letv == GlobalConfig.siteId) {
  676 + //MS不需要选点
  677 + loger.log("MS不需要选点->siteId->", GlobalConfig.siteId);
  678 + _this.isGetFastestMcuCallback = true;
  679 + _this._startConnectMCU();
  680 + } else {
  681 + this._getFastestMsServer(function (_data) {
  682 + loger.log("MS选点结束->", _data);
  683 + if (_data && _data.ip) {
  684 + GlobalConfig.MS_PUBLISH_IP = _data.ip || "";
  685 + GlobalConfig.MS_PUBLISH_PORT = _data.port || "";
  686 + }
  687 + loger.log("当前使用的MS->", GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT);
  688 + _this.isGetFastestMcuCallback = true;
  689 + _this._startConnectMCU();
  690 + });
  691 + }
  692 +
  693 + this._getFastestMcuServer(function (_data) {
  694 + loger.log("MCU选点结束->", _data);
  695 + if (_data && _data.ip) {
  696 + GlobalConfig.MCUServerIP = _data.ip || "";
  697 + GlobalConfig.MCUServerPort = _data.port || "";
  698 + }
  699 + loger.log("当前使用的MCU->", GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort);
  700 + _this.isGetFastestMsCallback = true;
  701 + _this._startConnectMCU();
  702 + });
  703 + }*/
  704 +
  705 + //开始连接MCU(所有服务地址测试完成之后开始连接)
624 _startConnectMCU() { 706 _startConnectMCU() {
625 - if (this.isGetFastestMcuCallback && this.isGetFastestMsCallback) { 707 + if (this.isGetFastestMcuCallback &&
  708 + this.isGetFastestMsCallback &&
  709 + this.isGetFastestRtmpPullCallback &&
  710 + this.isGetFastestHlsPullCallback &&
  711 + this.isGetFastestRsCallback) {
  712 + //mcu完成
  713 + //ms推流测速完成
  714 + //rtmp拉流测速完成
  715 + //hls拉流测速完成
  716 + //hls录制回放拉流测速完成
626 this._joinMCU(); 717 this._joinMCU();
627 } 718 }
628 } 719 }
629 720
630 - //合并Sever和Sass的mcu、ms列表  
631 - _mergeMcuAndMsList() { 721 + //从Sever和Sass中选择的mcu、ms列表,如果server.json中存在就不使用Sass
  722 + _choiceMcuAndMsListFromServerAndSass() {
  723 + //1.根据user信息获取服务器列表
632 if (_ipManager) { 724 if (_ipManager) {
633 - GlobalConfig.mcuListFromServer = _ipManager.getServerMcuList( 725 + GlobalConfig.mcuListFromServer = _ipManager.getServerListForUserInfo(
  726 + "MCU",
  727 + GlobalConfig.country,
  728 + GlobalConfig.province,
  729 + GlobalConfig.city,
  730 + GlobalConfig.isp,
  731 + Server.serverList);
  732 +
  733 + GlobalConfig.msListFromServer = _ipManager.getServerListForUserInfo(
  734 + "MS",
  735 + GlobalConfig.country,
  736 + GlobalConfig.province,
  737 + GlobalConfig.city,
  738 + GlobalConfig.isp,
  739 + Server.serverList);
  740 +
  741 + GlobalConfig.rtmpPullListFromServer = _ipManager.getServerListForUserInfo(
  742 + "RTMP_PULL",
  743 + GlobalConfig.country,
  744 + GlobalConfig.province,
  745 + GlobalConfig.city,
  746 + GlobalConfig.isp,
  747 + Server.serverList);
  748 +
  749 + GlobalConfig.rsPullListFromServer = _ipManager.getServerListForUserInfo(
  750 + "RS_PULL",
634 GlobalConfig.country, 751 GlobalConfig.country,
635 GlobalConfig.province, 752 GlobalConfig.province,
636 GlobalConfig.city, 753 GlobalConfig.city,
637 GlobalConfig.isp, 754 GlobalConfig.isp,
638 Server.serverList); 755 Server.serverList);
639 756
640 - GlobalConfig.msListFromServer = _ipManager.getServerMsList( 757 + GlobalConfig.hlsPullListFromServer = _ipManager.getServerListForUserInfo(
  758 + "HLS_PULL",
641 GlobalConfig.country, 759 GlobalConfig.country,
642 GlobalConfig.province, 760 GlobalConfig.province,
643 GlobalConfig.city, 761 GlobalConfig.city,
@@ -645,60 +763,130 @@ export default class MessageEntrance extends Emiter { @@ -645,60 +763,130 @@ export default class MessageEntrance extends Emiter {
645 Server.serverList); 763 Server.serverList);
646 } 764 }
647 765
648 - console.log(" GlobalConfig.mcuListFromServer", GlobalConfig.mcuListFromServer);  
649 - console.log(" GlobalConfig.msListFromServer", GlobalConfig.msListFromServer);  
650 - console.log(" GlobalConfig.mcuList", GlobalConfig.mcuList);  
651 - console.log(" GlobalConfig.msList", GlobalConfig.msList); 766 + loger.warn("Server中获取的服务器信息;")
  767 + loger.warn(" GlobalConfig.mcuListFromServer", GlobalConfig.mcuListFromServer);
  768 + loger.warn(" GlobalConfig.msListFromServer", GlobalConfig.msListFromServer);
  769 + loger.warn(" GlobalConfig.rtmpPullListFromServer", GlobalConfig.rtmpPullListFromServer);
  770 + loger.warn(" GlobalConfig.hlsPullListFromServer", GlobalConfig.hlsPullListFromServer);
  771 + loger.warn(" GlobalConfig.rsPullListFromServer", GlobalConfig.rsPullListFromServer);
652 772
653 - //********合并所有MCU、MS 列表********  
654 - //****server.json中的数据和从Sass获取的msList mcuList 数据需要分开,不能同时共存****  
655 - /*GlobalConfig.mcuListAll.length = 0;  
656 - GlobalConfig.mcuListAll = GlobalConfig.mcuListAll.concat(GlobalConfig.mcuList, GlobalConfig.mcuListFromServer);  
657 - GlobalConfig.msListAll.length = 0;  
658 - GlobalConfig.msListAll = GlobalConfig.msListAll.concat(GlobalConfig.msList, GlobalConfig.msListFromServer);*/  
659 773
660 - GlobalConfig.mcuListAll.length = 0; 774 + //********选择最终使用的MCU、MS 和拉流列表********
  775 + //****优先使用server.json中的数据,如果没有再使用Sass中的数据****
  776 +
  777 + //MCU
  778 + GlobalConfig.mcuListFinal = [];
661 if (GlobalConfig.mcuListFromServer.length > 0) { 779 if (GlobalConfig.mcuListFromServer.length > 0) {
662 //使用server中的MCU数据 780 //使用server中的MCU数据
663 - loger.warn("使用server中的MCU数据")  
664 - GlobalConfig.mcuListAll = GlobalConfig.mcuListFromServer; 781 + GlobalConfig.mcuListFinal = GlobalConfig.mcuListFromServer;
665 } else { 782 } else {
666 //使用Sass中的数据 783 //使用Sass中的数据
667 - loger.warn("使用Sass中的MCU数据")  
668 - GlobalConfig.mcuListAll = GlobalConfig.mcuList; 784 + GlobalConfig.mcuListFinal = GlobalConfig.mcuList;
669 } 785 }
670 786
671 - GlobalConfig.msListAll.length = 0; 787 + //MS推流
  788 + GlobalConfig.msListFinal = []
672 if (GlobalConfig.msListFromServer.length > 0) { 789 if (GlobalConfig.msListFromServer.length > 0) {
673 - loger.warn("使用server中的MS数据")  
674 - GlobalConfig.msListAll = GlobalConfig.msListFromServer; 790 + GlobalConfig.msListFinal = GlobalConfig.msListFromServer;
  791 + } else {
  792 + GlobalConfig.msListFinal = GlobalConfig.msList;
  793 + }
  794 +
  795 + //RS录制回放HLS拉流
  796 + GlobalConfig.rsListFinal = []
  797 + if (GlobalConfig.msListFromServer.length > 0) {
  798 + GlobalConfig.rsListFinal = GlobalConfig.rsPullListFromServer;
  799 + } else {
  800 + GlobalConfig.rsListFinal = GlobalConfig.rsList;
  801 + }
  802 +
  803 + //RTMP拉流
  804 + GlobalConfig.rtmpPullListFinal = [];
  805 + if (GlobalConfig.rtmpPullListFromServer.length > 0) {
  806 + GlobalConfig.rtmpPullListFinal = GlobalConfig.rtmpPullListFromServer;
  807 + } else {
  808 + GlobalConfig.rtmpPullListFinal = GlobalConfig.rtmpPullList;
  809 + }
  810 +
  811 + //HLS拉流流
  812 + GlobalConfig.hlsListFinal = [];
  813 + if (GlobalConfig.hlsPullListFromServer.length > 0) {
  814 + GlobalConfig.hlsListFinal = GlobalConfig.hlsPullListFromServer;
675 } else { 815 } else {
676 - loger.warn("使用Sass中的MS数据")  
677 - GlobalConfig.msListAll = GlobalConfig.msList; 816 + GlobalConfig.hlsListFinal = GlobalConfig.hlsPullList;
678 } 817 }
679 818
680 - console.warn("mcuListAll", GlobalConfig.mcuListAll);  
681 - console.warn("msListAll", GlobalConfig.msListAll); 819 + //拉流地址列表的特殊处理,
  820 + // 1.如果RTMP拉流地址没有配置,就默认使用MS推流地址列表
  821 + if (!GlobalConfig.rtmpPullListFinal || GlobalConfig.rtmpPullListFinal.length < 1) {
  822 + GlobalConfig.rtmpPullListFinal = GlobalConfig.msListFinal;
  823 + }
  824 + // 2.如果HLS拉流地址没有配置,就默认使用录制回放RS拉流地址列表中的数据
  825 + if (!GlobalConfig.hlsListFinal || GlobalConfig.hlsListFinal.length < 1) {
  826 + GlobalConfig.hlsListFinal = GlobalConfig.rsListFinal;
  827 + ;
  828 + }
  829 +
  830 + loger.warn("课堂最终使用的服务列表->");
  831 + loger.warn(" GlobalConfig.mcuListFinal", GlobalConfig.mcuListFinal);
  832 + loger.warn(" GlobalConfig.msListFinal", GlobalConfig.msListFinal);
  833 + loger.warn(" GlobalConfig.rtmpPullListFinal", GlobalConfig.rtmpPullListFinal);
  834 + loger.warn(" GlobalConfig.hlsListFinal", GlobalConfig.hlsListFinal);
  835 + loger.warn(" GlobalConfig.rsListFinal", GlobalConfig.rsListFinal);
  836 +
  837 + }
  838 +
  839 + //开始测速
  840 + _getFastestIpFromServer(_dataArr, _callback) {
  841 + if (_ipManager) {
  842 + _ipManager.testFastestIpFromServer(_dataArr, _callback);
  843 + } else {
  844 + if (_callback) {
  845 + _callback({'ip': ""});
  846 + }
  847 + }
682 } 848 }
683 849
684 //开始MCU选点操作 850 //开始MCU选点操作
685 _getFastestMcuServer(_callback) { 851 _getFastestMcuServer(_callback) {
686 if (_ipManager) { 852 if (_ipManager) {
687 - _ipManager.getFastestMcuServer(GlobalConfig.mcuListAll, _callback); 853 + _ipManager.getFastestMcuServer(GlobalConfig.mcuListFinal, _callback);
688 } else { 854 } else {
689 if (_callback) { 855 if (_callback) {
690 - _callback({ 'ip': "" }); 856 + _callback({'ip': ""});
691 } 857 }
692 } 858 }
693 } 859 }
694 860
695 - // //开始MS选点操作 861 + //开始MS选点操作
696 _getFastestMsServer(_callback) { 862 _getFastestMsServer(_callback) {
697 if (_ipManager) { 863 if (_ipManager) {
698 - _ipManager.getFastestMsServer(GlobalConfig.msListAll, _callback); 864 + _ipManager.getFastestMsServer(GlobalConfig.msListFinal, _callback);
  865 + } else {
  866 + if (_callback) {
  867 + _callback({ip: ""});
  868 + }
  869 + }
  870 + }
  871 +
  872 + //开始MS-PULL选点操作
  873 + _getFastestRtmpPullServer(_callback) {
  874 + if (_ipManager) {
  875 + _ipManager.getFastestMsServer(GlobalConfig.rtmpPullListFinal, _callback);
699 } else { 876 } else {
700 if (_callback) { 877 if (_callback) {
701 - _callback({ ip: "" }); 878 + _callback({ip: ""});
  879 + }
  880 + }
  881 + }
  882 +
  883 + //开始MS-HLS选点操作
  884 + _getFastestHlsServer(_callback) {
  885 + if (_ipManager) {
  886 + _ipManager.getFastestMsServer(GlobalConfig.rtmpPullListFinal, _callback);
  887 + } else {
  888 + if (_callback) {
  889 + _callback({ip: ""});
702 } 890 }
703 } 891 }
704 } 892 }
@@ -716,7 +904,7 @@ export default class MessageEntrance extends Emiter { @@ -716,7 +904,7 @@ export default class MessageEntrance extends Emiter {
716 //只有加入课堂之后才能保存数据 904 //只有加入课堂之后才能保存数据
717 if (GlobalConfig.getCurrentStatus().code == GlobalConfig.statusCode_2.code) { 905 if (GlobalConfig.getCurrentStatus().code == GlobalConfig.statusCode_2.code) {
718 //POST 保存数据 906 //POST 保存数据
719 - _sass.saveClassStatusInfo({ "classStatusInfo": GlobalConfig.classStatusInfo }); //保存课堂状态信息 907 + _sass.saveClassStatusInfo({"classStatusInfo": GlobalConfig.classStatusInfo}); //保存课堂状态信息
720 } else { 908 } else {
721 loger.error("不能保存课堂数据", GlobalConfig.getCurrentStatus()); 909 loger.error("不能保存课堂数据", GlobalConfig.getCurrentStatus());
722 } 910 }
@@ -739,12 +927,12 @@ export default class MessageEntrance extends Emiter { @@ -739,12 +927,12 @@ export default class MessageEntrance extends Emiter {
739 //Sass校验流程结束之后,开始加入MCU 927 //Sass校验流程结束之后,开始加入MCU
740 _joinMCU() { 928 _joinMCU() {
741 loger.log('加入课堂->.'); 929 loger.log('加入课堂->.');
742 - loger.warn("课堂服务信息->");  
743 - 930 + loger.warn("最终使用课堂服务信息->");
744 loger.warn('MCU服务器地址->mcu->', GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort); 931 loger.warn('MCU服务器地址->mcu->', GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort);
745 loger.warn('推流地址->MS->', GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT); 932 loger.warn('推流地址->MS->', GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT);
746 - loger.warn('RTMP播流地址->RTMP->', GlobalConfig.MS_PLAY_RTMP_IP, GlobalConfig.MS_PLAY_RTMP_PORT);  
747 - loger.warn('HLS播流地址->HLS->', GlobalConfig.MS_PLAY_HLS_IP, GlobalConfig.MS_PLAY_HLS_PORT); 933 + loger.warn('RTMP拉流地址->RTMP->', GlobalConfig.MS_PLAY_RTMP_IP, GlobalConfig.MS_PLAY_RTMP_PORT);
  934 + loger.warn('HLS拉流地址->HLS->', GlobalConfig.MS_PLAY_HLS_IP, GlobalConfig.MS_PLAY_HLS_PORT);
  935 + loger.warn('HLS录制回放拉流地址->HLS->', GlobalConfig.RS_RECORD_PLAY_IP, GlobalConfig.RS_RECORD_PLAY_PORT);
748 936
749 if (_mcu) { 937 if (_mcu) {
750 _mcu.joinMCU(GlobalConfig.getClassInfo()); 938 _mcu.joinMCU(GlobalConfig.getClassInfo());
@@ -879,19 +1067,11 @@ export default class MessageEntrance extends Emiter { @@ -879,19 +1067,11 @@ export default class MessageEntrance extends Emiter {
879 1067
880 //课堂状态发生改变,需要停止当前的所有推流 1068 //课堂状态发生改变,需要停止当前的所有推流
881 _stopAllMediaPublishHandler(_data) { 1069 _stopAllMediaPublishHandler(_data) {
882 - loger.log('课堂状态发生改变,需要停止当前的所有推流');  
883 - this._emit(MessageTypes.MEDIA_STOP_PUBLISH);  
884 - /* let allChannels=MediaModule.allMediaChannelsList;  
885 - let channl=null;  
886 - for(let i in allChannels){  
887 - channl=allChannels[i];  
888 - if(channl&&channl.status==ApeConsts.CHANNEL_STATUS_OPENING&&channl.fromNodeId==GlobalConfig.nodeId){  
889 - this._emit(MessageTypes.MEDIA_STOP_PUBLISH);  
890 - return;  
891 - }  
892 - }*/  
893 - }  
894 - //手动切换MS -> {ip;"xxx.xx.xx","port":"xxxx"} 1070 + loger.log('课堂状态发生改变,需要停止当前的所有推流');
  1071 + this._emit(MessageTypes.MEDIA_STOP_PUBLISH);
  1072 + }
  1073 +
  1074 + //手动切换MS -> {ip;"xxx.xx.xx","port":"xxxx"}
895 _switchMediaServer(_param) { 1075 _switchMediaServer(_param) {
896 if (GlobalConfig.isRecordPlayBack) { 1076 if (GlobalConfig.isRecordPlayBack) {
897 //录制回放不做操作 1077 //录制回放不做操作
@@ -916,32 +1096,26 @@ export default class MessageEntrance extends Emiter { @@ -916,32 +1096,26 @@ export default class MessageEntrance extends Emiter {
916 loger.warn('录制回放->不进行MS动态选点'); 1096 loger.warn('录制回放->不进行MS动态选点');
917 return; 1097 return;
918 } 1098 }
919 - loger.log('MS->动态选点');  
920 let _this = this; 1099 let _this = this;
921 this._getFastestMsServer(function (_data) { 1100 this._getFastestMsServer(function (_data) {
922 loger.log("MS选点结束->", _data); 1101 loger.log("MS选点结束->", _data);
923 //记录当前的IP地址,选点结束后需要判断一下是否是新的IP; 1102 //记录当前的IP地址,选点结束后需要判断一下是否是新的IP;
924 - let oldIp = GlobalConfig.MCUServerIP; 1103 + let oldIp = GlobalConfig.MS_PUBLISH_IP;
925 1104
926 if (_data && _data.ip) { 1105 if (_data && _data.ip) {
  1106 +
927 GlobalConfig.MS_PUBLISH_IP = _data.ip || ""; 1107 GlobalConfig.MS_PUBLISH_IP = _data.ip || "";
928 GlobalConfig.MS_PUBLISH_PORT = _data.port || ""; 1108 GlobalConfig.MS_PUBLISH_PORT = _data.port || "";
929 } else { 1109 } else {
930 //随机选择一个 1110 //随机选择一个
931 - if (GlobalConfig.msList && GlobalConfig.msList.length > 0) {  
932 - let index = parseInt(Math.random() * GlobalConfig.msList.length);  
933 - GlobalConfig.MS_PUBLISH_IP = GlobalConfig.msList[index].ip || "";  
934 - GlobalConfig.MS_PUBLISH_PORT = GlobalConfig.msList[index].port || ""; 1111 + if (GlobalConfig.msListFinal && GlobalConfig.msListFinal.length > 0) {
  1112 + let index = parseInt(Math.random() * GlobalConfig.msListFinal.length);
  1113 + GlobalConfig.MS_PUBLISH_IP = GlobalConfig.msListFinal[index].ip || "";
  1114 + GlobalConfig.MS_PUBLISH_PORT = GlobalConfig.msListFinal[index].port || "";
935 } 1115 }
936 } 1116 }
937 1117
938 if (oldIp && oldIp != GlobalConfig.MS_PUBLISH_IP) { 1118 if (oldIp && oldIp != GlobalConfig.MS_PUBLISH_IP) {
939 - /* loger.log('MS->切换地址->', GlobalConfig.MSServerIP, GlobalConfig.MSServerPort);  
940 - //判断是否需要断开当前的连接重连新的服务器  
941 - if (_param && _param.reConnect == true) {  
942 - loger.log('MS->最新地址->', GlobalConfig.MSServerIP, GlobalConfig.MSServerPort);  
943 - }*/  
944 -  
945 //选点完成需要更新用户数据 1119 //选点完成需要更新用户数据
946 if (_confer_ape) { 1120 if (_confer_ape) {
947 _confer_ape.updateUserInfo(); 1121 _confer_ape.updateUserInfo();
@@ -951,7 +1125,70 @@ export default class MessageEntrance extends Emiter { @@ -951,7 +1125,70 @@ export default class MessageEntrance extends Emiter {
951 //如果选点结束后获得的ip和当前的IP相同,不需要切换 1125 //如果选点结束后获得的ip和当前的IP相同,不需要切换
952 loger.log('MS不需要切换->IP', GlobalConfig.MS_PUBLISH_IP); 1126 loger.log('MS不需要切换->IP', GlobalConfig.MS_PUBLISH_IP);
953 } 1127 }
  1128 + });
  1129 + }
954 1130
  1131 + //切换MS -PULL地址
  1132 + _switchRtmpPullIpHandler(_param) {
  1133 + if (GlobalConfig.isRecordPlayBack) {
  1134 + //录制回放不做操作
  1135 + loger.warn('录制回放->不进行MS-PULL动态选点');
  1136 + return;
  1137 + }
  1138 + if(!GlobalConfig.rtmpPullListFinal||GlobalConfig.rtmpPullListFinal.length<1){
  1139 + return;
  1140 + }
  1141 + let _this = this;
  1142 + this._getFastestRtmpPullServer(function (_data) {
  1143 + loger.log("MS->PULL->选点结束->", _data);
  1144 + if (_data && _data.ip) {
  1145 + GlobalConfig.MS_PLAY_RTMP_IP = _data.ip || "";
  1146 + GlobalConfig.MS_PLAY_RTMP_PORT = _data.port || "";
  1147 + } else {
  1148 + //随机选择一个
  1149 + if (GlobalConfig.rtmpPullListFinal && GlobalConfig.rtmpPullListFinal.length > 0) {
  1150 + let index = parseInt(Math.random() * GlobalConfig.rtmpPullListFinal.length);
  1151 + GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.rtmpPullListFinal[index].ip || "";
  1152 + GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.rtmpPullListFinal[index].port || "";
  1153 + }
  1154 + }
  1155 + //如果RTMP没有配置地址,那么还是使用推流的地址
  1156 + if(!GlobalConfig.MS_PLAY_RTMP_IP){
  1157 + GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.MS_PUBLISH_IP;
  1158 + GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.MS_PUBLISH_PORT;
  1159 + }
  1160 + });
  1161 + }
  1162 +
  1163 + //切换MS HLS地址
  1164 + _switchHlsIpHandler(_param) {
  1165 + if (GlobalConfig.isRecordPlayBack) {
  1166 + //录制回放不做操作
  1167 + loger.warn('录制回放->不进行MS-HLS动态选点');
  1168 + return;
  1169 + }
  1170 + if(!GlobalConfig.hlsListFinal||GlobalConfig.hlsListFinal.length<1){
  1171 + return;
  1172 + }
  1173 + let _this = this;
  1174 + this._getFastestHlsServer(function (_data) {
  1175 + loger.log("HLS选点结束->", _data);
  1176 + if (_data && _data.ip) {
  1177 + GlobalConfig.MS_PLAY_HLS_IP = _data.ip || "";
  1178 + GlobalConfig.MS_PLAY_HLS_PORT = _data.port || "";
  1179 + } else {
  1180 + //随机选择一个
  1181 + if (GlobalConfig.hlsListFinal && GlobalConfig.hlsListFinal.length > 0) {
  1182 + let index = parseInt(Math.random() * GlobalConfig.hlsListFinal.length);
  1183 + GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.hlsListFinal[index].ip || "";
  1184 + GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.hlsListFinal[index].port || "";
  1185 + }
  1186 + }
  1187 + //如果HLS没有配置地址,那么还是使用推流的地址
  1188 + if(!GlobalConfig.MS_PLAY_HLS_IP){
  1189 + GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.RS_RECORD_PLAY_IP;
  1190 + GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.RS_RECORD_PLAY_PORT;
  1191 + }
955 }); 1192 });
956 } 1193 }
957 1194
@@ -1035,32 +1272,34 @@ export default class MessageEntrance extends Emiter { @@ -1035,32 +1272,34 @@ export default class MessageEntrance extends Emiter {
1035 1272
1036 //暂停上课 1273 //暂停上课
1037 _sendPauseClass(_param) { 1274 _sendPauseClass(_param) {
1038 - if (!_mcu.connected) {  
1039 - loger.warn(GlobalConfig.getCurrentStatus());  
1040 - return;  
1041 - }  
1042 - if (_confer_ape) {  
1043 - _confer_ape.pauseClass(_param);  
1044 - } 1275 + if (!_mcu.connected) {
  1276 + loger.warn(GlobalConfig.getCurrentStatus());
  1277 + return;
1045 } 1278 }
1046 - //更新设备信息 1279 + if (_confer_ape) {
  1280 + _confer_ape.pauseClass(_param);
  1281 + }
  1282 + }
  1283 +
  1284 + //更新设备信息
1047 _updateDeviceInfo(_param) { 1285 _updateDeviceInfo(_param) {
1048 - if (!_mcu.connected) {  
1049 - loger.warn('更新设备信息->失败', GlobalConfig.getCurrentStatus());  
1050 - return { "code": ApeConsts.RETURN_FAILED, "data": "" };  
1051 - }  
1052 - if (!GlobalConfig.classJoinSuccess) {  
1053 - loger.warn('更新设备信息->失败->还没有加入课堂成功', GlobalConfig.getCurrentStatus());  
1054 - }  
1055 - if (_confer_ape) {  
1056 - _confer_ape.updateDeviceInfo(_param);  
1057 - } 1286 + if (!_mcu.connected) {
  1287 + loger.warn('更新设备信息->失败', GlobalConfig.getCurrentStatus());
  1288 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
  1289 + }
  1290 + if (!GlobalConfig.classJoinSuccess) {
  1291 + loger.warn('更新设备信息->失败->还没有加入课堂成功', GlobalConfig.getCurrentStatus());
  1292 + }
  1293 + if (_confer_ape) {
  1294 + _confer_ape.updateDeviceInfo(_param);
1058 } 1295 }
1059 - //文档-媒体共享-屏幕共享模块切换 1296 + }
  1297 +
  1298 + //文档-媒体共享-屏幕共享模块切换
1060 _sceneTableChange(_param) { 1299 _sceneTableChange(_param) {
1061 if (!_mcu.connected) { 1300 if (!_mcu.connected) {
1062 loger.warn(GlobalConfig.getCurrentStatus()); 1301 loger.warn(GlobalConfig.getCurrentStatus());
1063 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1302 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1064 } 1303 }
1065 if (_confer_ape) { 1304 if (_confer_ape) {
1066 _confer_ape.sceneTableChange(_param); 1305 _confer_ape.sceneTableChange(_param);
@@ -1068,10 +1307,10 @@ export default class MessageEntrance extends Emiter { @@ -1068,10 +1307,10 @@ export default class MessageEntrance extends Emiter {
1068 } 1307 }
1069 1308
1070 //通过第三方消息通道发送消息 1309 //通过第三方消息通道发送消息
1071 - _sendThridChannelMessage(_param){ 1310 + _sendThridChannelMessage(_param) {
1072 if (!_mcu.connected) { 1311 if (!_mcu.connected) {
1073 loger.warn(GlobalConfig.getCurrentStatus()); 1312 loger.warn(GlobalConfig.getCurrentStatus());
1074 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1313 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1075 } 1314 }
1076 if (_confer_ape) { 1315 if (_confer_ape) {
1077 _confer_ape.onThirdReciveParentMessage(_param); 1316 _confer_ape.onThirdReciveParentMessage(_param);
@@ -1079,10 +1318,10 @@ export default class MessageEntrance extends Emiter { @@ -1079,10 +1318,10 @@ export default class MessageEntrance extends Emiter {
1079 } 1318 }
1080 1319
1081 //将指定nodeId的人踢出课堂 1320 //将指定nodeId的人踢出课堂
1082 - _kickOutRosterFormNodeId(_param){ 1321 + _kickOutRosterFormNodeId(_param) {
1083 if (!_mcu.connected) { 1322 if (!_mcu.connected) {
1084 loger.warn(GlobalConfig.getCurrentStatus()); 1323 loger.warn(GlobalConfig.getCurrentStatus());
1085 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1324 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1086 } 1325 }
1087 if (_confer_ape) { 1326 if (_confer_ape) {
1088 _confer_ape.kickOutRosterFormNodeId(_param); 1327 _confer_ape.kickOutRosterFormNodeId(_param);
@@ -1093,7 +1332,7 @@ export default class MessageEntrance extends Emiter { @@ -1093,7 +1332,7 @@ export default class MessageEntrance extends Emiter {
1093 _controlSilenceStatus(_param) { 1332 _controlSilenceStatus(_param) {
1094 if (!_mcu.connected) { 1333 if (!_mcu.connected) {
1095 loger.warn(GlobalConfig.getCurrentStatus()); 1334 loger.warn(GlobalConfig.getCurrentStatus());
1096 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1335 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1097 } 1336 }
1098 if (_confer_ape) { 1337 if (_confer_ape) {
1099 _confer_ape.controlSilenceStatus(_param); 1338 _confer_ape.controlSilenceStatus(_param);
@@ -1104,7 +1343,7 @@ export default class MessageEntrance extends Emiter { @@ -1104,7 +1343,7 @@ export default class MessageEntrance extends Emiter {
1104 _controlHandUpStatus(_param) { 1343 _controlHandUpStatus(_param) {
1105 if (!_mcu.connected) { 1344 if (!_mcu.connected) {
1106 loger.warn(GlobalConfig.getCurrentStatus()); 1345 loger.warn(GlobalConfig.getCurrentStatus());
1107 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1346 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1108 } 1347 }
1109 if (_confer_ape) { 1348 if (_confer_ape) {
1110 _confer_ape.controlHandUpStatus(_param); 1349 _confer_ape.controlHandUpStatus(_param);
@@ -1113,19 +1352,20 @@ export default class MessageEntrance extends Emiter { @@ -1113,19 +1352,20 @@ export default class MessageEntrance extends Emiter {
1113 1352
1114 //举手状态切换 1353 //举手状态切换
1115 _changeHandUpStatus(_param) { 1354 _changeHandUpStatus(_param) {
1116 - if (!_mcu.connected) {  
1117 - loger.warn(GlobalConfig.getCurrentStatus());  
1118 - return { "code": ApeConsts.RETURN_FAILED, "data": "" };  
1119 - }  
1120 - if (_confer_ape) {  
1121 - _confer_ape.changeHandUpStatus(_param);  
1122 - } 1355 + if (!_mcu.connected) {
  1356 + loger.warn(GlobalConfig.getCurrentStatus());
  1357 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
  1358 + }
  1359 + if (_confer_ape) {
  1360 + _confer_ape.changeHandUpStatus(_param);
1123 } 1361 }
1124 - //停止上课 1362 + }
  1363 +
  1364 + //停止上课
1125 _sendCloseClass(_param) { 1365 _sendCloseClass(_param) {
1126 if (!_mcu.connected) { 1366 if (!_mcu.connected) {
1127 loger.warn(GlobalConfig.getCurrentStatus()); 1367 loger.warn(GlobalConfig.getCurrentStatus());
1128 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1368 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1129 } 1369 }
1130 if (_confer_ape) { 1370 if (_confer_ape) {
1131 _confer_ape.closeClass(_param); 1371 _confer_ape.closeClass(_param);
@@ -1136,7 +1376,7 @@ export default class MessageEntrance extends Emiter { @@ -1136,7 +1376,7 @@ export default class MessageEntrance extends Emiter {
1136 _leaveClass(_param) { 1376 _leaveClass(_param) {
1137 if (!_mcu.connected) { 1377 if (!_mcu.connected) {
1138 loger.warn(GlobalConfig.getCurrentStatus()); 1378 loger.warn(GlobalConfig.getCurrentStatus());
1139 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1379 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1140 } 1380 }
1141 1381
1142 //停止推流 1382 //停止推流
@@ -1169,7 +1409,7 @@ export default class MessageEntrance extends Emiter { @@ -1169,7 +1409,7 @@ export default class MessageEntrance extends Emiter {
1169 } 1409 }
1170 } 1410 }
1171 1411
1172 - //获取课堂所有参数 api/meeting/detail.do? flash中的接口文件是 getClassParam.do 1412 + //获取课堂所有参数(20170727新规则) api/meeting/detail.do? flash中的接口文件是 getClassParam.do
1173 _sassGetClassParamSuccessHandler(_data) { 1413 _sassGetClassParamSuccessHandler(_data) {
1174 loger.log('获取课堂课堂信息完成.'); 1414 loger.log('获取课堂课堂信息完成.');
1175 //包含整个课堂最全的信息,储存数据 1415 //包含整个课堂最全的信息,储存数据
@@ -1202,124 +1442,36 @@ export default class MessageEntrance extends Emiter { @@ -1202,124 +1442,36 @@ export default class MessageEntrance extends Emiter {
1202 GlobalConfig.setDocListPrepare(_data.docListPrepare); //提前上传的文档列表 1442 GlobalConfig.setDocListPrepare(_data.docListPrepare); //提前上传的文档列表
1203 GlobalConfig.setRecordList(_data.recordList); //录制回放地址 1443 GlobalConfig.setRecordList(_data.recordList); //录制回放地址
1204 GlobalConfig.setDocList(_data.docList); //文档地址 1444 GlobalConfig.setDocList(_data.docList); //文档地址
1205 - GlobalConfig.setMsList(_data.msList); //推流播流服务器地址(需要对列表中的地址进行分类,里面包含了推流和拉流的地址,目前主要是乐视的需要区分开)  
1206 - GlobalConfig.setRsList(_data.rsList); //播放m3u8格式的地址(录制回放时使用)  
1207 - GlobalConfig.setMcuList(_data.mcuList); //mcu  
1208 GlobalConfig.setMusicList(_data.musicList); // 1445 GlobalConfig.setMusicList(_data.musicList); //
1209 GlobalConfig.setMusicListPrepare(_data.musicListPrepare); //提前上传的声音文件列表 1446 GlobalConfig.setMusicListPrepare(_data.musicListPrepare); //提前上传的声音文件列表
1210 GlobalConfig.setVideoCDNAddr(_data.videoCDNAddr); //cdn加速的拉流地址,直播的时候才使用 1447 GlobalConfig.setVideoCDNAddr(_data.videoCDNAddr); //cdn加速的拉流地址,直播的时候才使用
1211 GlobalConfig.setMediaShareList(_data.sharedMediaList); //提前上传的媒体共享文件列表 1448 GlobalConfig.setMediaShareList(_data.sharedMediaList); //提前上传的媒体共享文件列表
1212 1449
1213 - //MCU地址  
1214 - if (_data.mcuList && _data.mcuList.length > 0) {  
1215 - //随机选择一个  
1216 - let index = parseInt(Math.random() * _data.mcuList.length);  
1217 - GlobalConfig.MCUServerIP = _data.mcuList[index].ip || "";  
1218 - GlobalConfig.MCUServerPort = _data.mcuList[index].port || "";  
1219 - loger.log('初始->MCU->.', GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort);  
1220 - }  
1221 -  
1222 - //录制回放时m3u8播流地址  
1223 - if (_data.rsList && _data.rsList.length > 0) {  
1224 - let index = parseInt(Math.random() * _data.rsList.length);  
1225 - GlobalConfig.RS_RECORD_PLAY_IP = _data.rsList[index].ip || "";  
1226 - GlobalConfig.RS_RECORD_PLAY_PORT = _data.rsList[index].port || "";  
1227 - loger.log('初始->RS->.', GlobalConfig.RS_RECORD_PLAY_IP, GlobalConfig.RS_RECORD_PLAY_PORT);  
1228 - }  
1229 -  
1230 - //上课中音视频推流地址  
1231 - if (GlobalConfig.msList && GlobalConfig.msList.length > 0) {  
1232 - let index = parseInt(Math.random() * GlobalConfig.msList.length);  
1233 - GlobalConfig.MS_PUBLISH_IP = GlobalConfig.msList[index].ip || "";  
1234 - GlobalConfig.MS_PUBLISH_PORT = GlobalConfig.msList[index].port || "";  
1235 - }  
1236 - loger.log('初始->MS->.', GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT);  
1237 -  
1238 - //播流的地址和推流地址需要分开的时候,单独设置拉流的地址 rtmp(目前乐视使用)  
1239 - if (GlobalConfig.pullRtmpList && GlobalConfig.pullRtmpList.length > 0) {  
1240 - //有单独的rtmp拉流地址  
1241 - let index = parseInt(Math.random() * GlobalConfig.pullRtmpList.length);  
1242 - GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.pullRtmpList[index].ip || "";  
1243 - GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.pullRtmpList[index].port || "";  
1244 - } else {  
1245 - //如果没有单独的rtmp拉流地址,和推流地址一样即可  
1246 - GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.MS_PUBLISH_IP;  
1247 - GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.MS_PUBLISH_PORT;  
1248 - }  
1249 -  
1250 - loger.log('初始->MSPull->.', GlobalConfig.MS_PLAY_RTMP_IP, GlobalConfig.MS_PLAY_RTMP_PORT);  
1251 -  
1252 - //播流的地址和推流地址需要分开的时候,单独设置拉流的地址 hls(目前乐视使用)  
1253 - if (GlobalConfig.hlsList && GlobalConfig.hlsList.length > 0) {  
1254 - //有单独的hls拉流地址  
1255 - let index = parseInt(Math.random() * GlobalConfig.hlsList.length);  
1256 - GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.hlsList[index].ip || "";  
1257 - GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.hlsList[index].port || "";  
1258 - } else {  
1259 - //没有单独的hls拉流地址,和录制回放地址一样即可  
1260 - GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.RS_RECORD_PLAY_IP;  
1261 - GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.RS_RECORD_PLAY_PORT;  
1262 - }  
1263 - loger.log('初始->MSHls->.', GlobalConfig.MS_PLAY_HLS_IP, GlobalConfig.MS_PLAY_HLS_PORT);  
1264 -  
1265 - //直播的时候,拉流(rtmp和hls)需要从 videoCDNAddr中获取  
1266 - //20170531-新规则,所有课堂类型都支持加速  
1267 - // if(GlobalConfig.classType==ApeConsts.CLASS_TYPE_2&&GlobalConfig.videoCDNAddrList.length>0){  
1268 -  
1269 - //20170629-直播课堂和移动端设备的时候支持  
1270 - if (GlobalConfig.classType == ApeConsts.CLASS_TYPE_2 || GlobalConfig.isMobile) {  
1271 - if (GlobalConfig.videoCDNAddrList.length > 0) {  
1272 - //videoCDNAddrList中rtmppush和hls是混在一起的,需要分离开;  
1273 - let listLen = GlobalConfig.videoCDNAddrList.length;  
1274 - for (let i = 0; i < listLen; i++) {  
1275 - let ipItem = GlobalConfig.videoCDNAddrList[i];  
1276 - if (ipItem) {  
1277 - if (ipItem.indexOf('hls') >= 0) {  
1278 - //直播的时候m3u8拉流地址  
1279 - GlobalConfig.MS_PLAY_HLS_IP = ipItem; //ip包含了端口  
1280 - GlobalConfig.MS_PLAY_HLS_PORT = "";  
1281 - loger.log('videoCDNAddr>初始->MSHls', GlobalConfig.MS_PLAY_HLS_IP);  
1282 - }  
1283 - if (ipItem.indexOf('rtmppull')>= 0) {  
1284 - //直播的时候rtmp拉流地址  
1285 - GlobalConfig.MS_PLAY_RTMP_IP = ipItem; //ip包含了端口  
1286 - GlobalConfig.MS_PLAY_RTMP_PORT = '';  
1287 - loger.log('videoCDNAddr->初始->MSPull', GlobalConfig.MS_PLAY_RTMP_IP);  
1288 - }  
1289 - }  
1290 - }  
1291 - } else {  
1292 - loger.error('videoCDNAddr数据无效->', GlobalConfig.videoCDNAddr);  
1293 - }  
1294 - } else {  
1295 - loger.warn('非直播课堂或不是移动端->不需要videoCDN加速'); 1450 + //存从Sass获取的MS和MCU服务列表
  1451 + if (_data.msList2) {
  1452 + GlobalConfig.setMsList(_data.msList2.msList); //储存Sass ms拉流地址
  1453 + GlobalConfig.setRtmpPullList(_data.msList2.rtmpPullArray); //储存Sass ms拉流地址
  1454 + GlobalConfig.setHlsPullList(_data.msList2.hlsPullArray); //储存Sass ms拉流地址
  1455 + GlobalConfig.setRsList(_data.msList2.rsList); //储存Sass 录制回放hls拉流地址
1296 } 1456 }
  1457 + //Sass mcu
  1458 + GlobalConfig.setMcuList(_data.mcuList); //mcu
1297 1459
1298 - //文档地址  
1299 - if (_data.docList && _data.docList.length > 0) {  
1300 - //doc上传地址,随机获取一个  
1301 - let index = parseInt(Math.random() * _data.docList.length);  
1302 - loger.log("docServer->", _data.docList[index]);  
1303 - GlobalConfig.DOCServerIP = _data.docList[index].ip || "";  
1304 - GlobalConfig.DOCServerPort = _data.docList[index].port || "";  
1305 - loger.log('初始->DOC->.', GlobalConfig.DOCServerIP, GlobalConfig.DOCServerPort);  
1306 - }  
1307 -  
1308 - //record  
1309 - if (_data.recordList && _data.recordList.length > 0) {  
1310 - let index = parseInt(Math.random() * _data.recordList.length);  
1311 - GlobalConfig.RecordServerIP = _data.recordList[index].ip || "";  
1312 - GlobalConfig.RecordServerPort = _data.recordList[index].port || "";  
1313 - loger.log('初始->RECORD->.', GlobalConfig.RecordServerIP, GlobalConfig.RecordServerPort);  
1314 - } 1460 + loger.warn('从Sass获取的推流拉流列表数据:');
  1461 + loger.warn('Sass->msList->', GlobalConfig.msList);
  1462 + loger.warn('Sass->rtmpPullList->', GlobalConfig.rtmpPullList);
  1463 + loger.warn('Sass->hlsPullList->', GlobalConfig.hlsPullList);
  1464 + loger.warn('Sass->rsList->', GlobalConfig.rsList);
1315 1465
  1466 + //获取MCU和MS 推流拉流、录制回放的默认地址,后面还会进行测速选择
  1467 + this.getMcuAndMsDefaultServerIp();
1316 } 1468 }
1317 - //这里需要考虑是否加延迟处理,课堂信息刚获取完成,客户端需要根据数据创建界面UI,等创建完成后再加入课堂是最合适的(目前没有加延迟) 1469 +
  1470 + //课堂获取Sass数据完成
1318 this._emit(MessageTypes.CLASS_GET_INFO_SUCCESS, GlobalConfig.getClassInfo()); 1471 this._emit(MessageTypes.CLASS_GET_INFO_SUCCESS, GlobalConfig.getClassInfo());
1319 1472
1320 if (_data.currentInfo) { 1473 if (_data.currentInfo) {
1321 //根据从Sass获取的数据信息,同步最后一次保存的课堂状态信息 1474 //根据从Sass获取的数据信息,同步最后一次保存的课堂状态信息
1322 - loger.log("本地同步最后一次保存过的课堂状态信息");  
1323 try { 1475 try {
1324 GlobalConfig.setClassStatusInfo(JSON.parse(_data.currentInfo)); 1476 GlobalConfig.setClassStatusInfo(JSON.parse(_data.currentInfo));
1325 } catch (err) { 1477 } catch (err) {
@@ -1332,31 +1484,287 @@ export default class MessageEntrance extends Emiter { @@ -1332,31 +1484,287 @@ export default class MessageEntrance extends Emiter {
1332 loger.log("还没有保存过课堂状信息"); 1484 loger.log("还没有保存过课堂状信息");
1333 } 1485 }
1334 1486
  1487 + //课堂数据获取完成->进入课堂或进入录制回放
1335 //录制回放不需要获取ip信息和选点 1488 //录制回放不需要获取ip信息和选点
1336 if (GlobalConfig.isRecordPlayBack) { 1489 if (GlobalConfig.isRecordPlayBack) {
1337 if (_recordPlayback) { 1490 if (_recordPlayback) {
1338 //开启录制回放流程 1491 //开启录制回放流程
1339 - loger.log("开启录制回放流程"); 1492 + loger.warn("开启录制回放流程");
1340 _recordPlayback.readyRecordPlay(); 1493 _recordPlayback.readyRecordPlay();
1341 } else { 1494 } else {
1342 loger.warn("开启录制回放流程失败->还未创建模块"); 1495 loger.warn("开启录制回放流程失败->还未创建模块");
1343 } 1496 }
1344 } else { 1497 } else {
1345 - //根据用户的userIp获取信息,选点  
1346 - this.getUserIpInfo(); 1498 + //根据用户的userIp获取信息,获取服务列表选点,选点测速完成后才加入MCU
  1499 + this.loadServerJsonAndgetUserIpInfo();
1347 } 1500 }
1348 } 1501 }
1349 1502
  1503 + //获取各个服务的默认ip,之后会进行测速选择更快的ip
  1504 + getMcuAndMsDefaultServerIp() {
  1505 + //MCU地址
  1506 + if (GlobalConfig.mcuList && GlobalConfig.mcuList.length > 0) {
  1507 + //还未开始选点之前随机选择一个
  1508 + let index = parseInt(Math.random() * GlobalConfig.mcuList.length);
  1509 + GlobalConfig.MCUServerIP = GlobalConfig.mcuList[index].ip || "";
  1510 + GlobalConfig.MCUServerPort = GlobalConfig.mcuList[index].port || "";
  1511 + }
  1512 +
  1513 + //录制回放时m3u8播流地址
  1514 + if (GlobalConfig.rsList && GlobalConfig.rsList.length > 0) {
  1515 + //还未开始选点之前随机选择一个
  1516 + let index = parseInt(Math.random() * GlobalConfig.rsList.length);
  1517 + GlobalConfig.RS_RECORD_PLAY_IP = GlobalConfig.rsList[index].ip || "";
  1518 + GlobalConfig.RS_RECORD_PLAY_PORT = GlobalConfig.rsList[index].port || "";
  1519 + }
  1520 +
  1521 + //推流地址
  1522 + if (GlobalConfig.msList && GlobalConfig.msList.length > 0) {
  1523 + //还未开始选点之前随机选择一个
  1524 + let index = parseInt(Math.random() * GlobalConfig.msList.length);
  1525 + GlobalConfig.MS_PUBLISH_IP = GlobalConfig.msList[index].ip || "";
  1526 + GlobalConfig.MS_PUBLISH_PORT = GlobalConfig.msList[index].port || "";
  1527 + }
  1528 +
  1529 + //RTMP拉流
  1530 + if (GlobalConfig.rtmpPullList && GlobalConfig.rtmpPullList.length > 0) {
  1531 + // //还未开始选点之前随机选择一个
  1532 + let index = parseInt(Math.random() * GlobalConfig.rtmpPullList.length);
  1533 + GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.rtmpPullList[index].ip || "";
  1534 + GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.rtmpPullList[index].port || "";
  1535 + } else {
  1536 + //如果没有单独的rtmp拉流地址,和推流地址一样即可
  1537 + GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.MS_PUBLISH_IP;
  1538 + GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.MS_PUBLISH_PORT;
  1539 + }
  1540 +
  1541 + //课堂中HLS拉流地址
  1542 + if (GlobalConfig.hlsPullList && GlobalConfig.hlsPullList.length > 0) {
  1543 + //有单独的hls拉流地址
  1544 + let index = parseInt(Math.random() * GlobalConfig.hlsPullList.length);
  1545 + GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.hlsPullList[index].ip || "";
  1546 + GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.hlsPullList[index].port || "";
  1547 + } else {
  1548 + //没有单独的hls拉流地址,和录制回放地址一样即可
  1549 + GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.RS_RECORD_PLAY_IP;
  1550 + GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.RS_RECORD_PLAY_PORT;
  1551 + }
  1552 +
  1553 +
  1554 + //文档服务器地址
  1555 + if (GlobalConfig.docList && GlobalConfig.docList.length > 0) {
  1556 + //doc上传地址,随机获取一个
  1557 + let index = parseInt(Math.random() * GlobalConfig.docList.length);
  1558 + GlobalConfig.DOCServerIP = GlobalConfig.docList[index].ip || "";
  1559 + GlobalConfig.DOCServerPort = GlobalConfig.docList[index].port || "";
  1560 +
  1561 + }
  1562 + //录制回放文件的下载地址
  1563 + if (GlobalConfig.recordList && GlobalConfig.recordList.length > 0) {
  1564 + let index = parseInt(Math.random() * GlobalConfig.recordList.length);
  1565 + GlobalConfig.RecordServerIP = GlobalConfig.recordList[index].ip || "";
  1566 + GlobalConfig.RecordServerPort = GlobalConfig.recordList[index].port || "";
  1567 +
  1568 + }
  1569 + loger.warn('默认->MCU地址->.', GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort);
  1570 +
  1571 + loger.warn('默认->MS推流地址->.', GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT);
  1572 + loger.warn('默认->HLS点播地址->.', GlobalConfig.RS_RECORD_PLAY_IP, GlobalConfig.RS_RECORD_PLAY_PORT);
  1573 + loger.warn('默认->HLS拉流地址->.', GlobalConfig.MS_PLAY_HLS_IP, GlobalConfig.MS_PLAY_HLS_PORT);
  1574 + loger.warn('默认->RTMP拉流地址->.', GlobalConfig.MS_PLAY_RTMP_IP, GlobalConfig.MS_PLAY_RTMP_PORT);
  1575 +
  1576 + loger.warn('默认->文档服务器地址->.', GlobalConfig.DOCServerIP, GlobalConfig.DOCServerPort);
  1577 + loger.warn('默认->录制回放文件下载地址->.', GlobalConfig.RecordServerIP, GlobalConfig.RecordServerPort);
  1578 + }
  1579 +
  1580 + //获取课堂所有参数 api/meeting/detail.do? flash中的接口文件是 getClassParam.do(20170727之前的规则)
  1581 + /*_sassGetClassParamSuccessHandler(_data) {
  1582 + loger.log('获取课堂课堂信息完成.');
  1583 + //包含整个课堂最全的信息,储存数据
  1584 + if (_data) {
  1585 + GlobalConfig.mcuDelay = _data.h5Delay || 0; //mcu消息延迟的时间间隔,单位(秒),结合客户端传的messageDelay的值使用
  1586 + GlobalConfig.className = _data.meetingName || "";
  1587 + GlobalConfig.classBeginTime = _data.beginTime || "";
  1588 + GlobalConfig.classEndTime = _data.endTime || "";
  1589 + GlobalConfig.userIp = _data.userIp || "";
  1590 +
  1591 + GlobalConfig.maxVideoChannels = _data.maxVideoChannels;
  1592 + GlobalConfig.maxAudioChannels = _data.maxAudioChannels;
  1593 + GlobalConfig.maxMediaChannels = Math.max(GlobalConfig.maxVideoChannels, GlobalConfig.maxAudioChannels);
  1594 +
  1595 + GlobalConfig.ssTunnelAppURL = _data.ssTunnelAppURL || ''; //屏幕共享插件的地址
  1596 +
  1597 + //视频质量相关设置,每次加入课堂都按最新的获取设置
  1598 + GlobalConfig.fps = _data.fps || 15;
  1599 + GlobalConfig.gop = _data.gop || 3;
  1600 + GlobalConfig.videoQuality = parseInt(_data.videoQuality);
  1601 + GlobalConfig.curVideoQuality = GlobalConfig.videoQuality;
  1602 +
  1603 + //是否自动开始(身份是host的时候才用到的)
  1604 + GlobalConfig.isAutoStartClass = _data.autoRecord || 0;
  1605 +
  1606 + GlobalConfig.serverTime = _data.serverTime || new Date().getTime(); //获取服务器时间戳
  1607 + GlobalConfig.serverAndLoacTimeDistanc = (new Date().getTime() - GlobalConfig.serverTime) / 1000; //当前系统时间和服务器时间的差值 (秒)
  1608 + loger.warn("服务器时间:" + GlobalConfig.serverTime + " 系统时间:" + new Date().getTime() + " 时间差:" + GlobalConfig.serverAndLoacTimeDistanc);
  1609 +
  1610 + GlobalConfig.setDocListPrepare(_data.docListPrepare); //提前上传的文档列表
  1611 + GlobalConfig.setRecordList(_data.recordList); //录制回放地址
  1612 + GlobalConfig.setDocList(_data.docList); //文档地址
  1613 + GlobalConfig.setMsList(_data.msList); //推流播流服务器地址(需要对列表中的地址进行分类,里面包含了推流和拉流的地址,目前主要是乐视的需要区分开)
  1614 + GlobalConfig.setRsList(_data.rsList); //播放m3u8格式的地址(录制回放时使用)
  1615 + GlobalConfig.setMcuList(_data.mcuList); //mcu
  1616 + GlobalConfig.setMusicList(_data.musicList); //
  1617 + GlobalConfig.setMusicListPrepare(_data.musicListPrepare); //提前上传的声音文件列表
  1618 + GlobalConfig.setVideoCDNAddr(_data.videoCDNAddr); //cdn加速的拉流地址,直播的时候才使用
  1619 + GlobalConfig.setMediaShareList(_data.sharedMediaList); //提前上传的媒体共享文件列表
  1620 +
  1621 + //MCU地址
  1622 + if (_data.mcuList && _data.mcuList.length > 0) {
  1623 + //随机选择一个
  1624 + let index = parseInt(Math.random() * _data.mcuList.length);
  1625 + GlobalConfig.MCUServerIP = _data.mcuList[index].ip || "";
  1626 + GlobalConfig.MCUServerPort = _data.mcuList[index].port || "";
  1627 + loger.log('初始->MCU->.', GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort);
  1628 + }
  1629 +
  1630 + //录制回放时m3u8播流地址
  1631 + if (_data.rsList && _data.rsList.length > 0) {
  1632 + let index = parseInt(Math.random() * _data.rsList.length);
  1633 + GlobalConfig.RS_RECORD_PLAY_IP = _data.rsList[index].ip || "";
  1634 + GlobalConfig.RS_RECORD_PLAY_PORT = _data.rsList[index].port || "";
  1635 + loger.log('初始->RS->.', GlobalConfig.RS_RECORD_PLAY_IP, GlobalConfig.RS_RECORD_PLAY_PORT);
  1636 + }
  1637 +
  1638 + //上课中音视频推流地址
  1639 + if (GlobalConfig.msList && GlobalConfig.msList.length > 0) {
  1640 + let index = parseInt(Math.random() * GlobalConfig.msList.length);
  1641 + GlobalConfig.MS_PUBLISH_IP = GlobalConfig.msList[index].ip || "";
  1642 + GlobalConfig.MS_PUBLISH_PORT = GlobalConfig.msList[index].port || "";
  1643 + }
  1644 + loger.log('初始->MS->.', GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT);
  1645 +
  1646 + //播流的地址和推流地址需要分开的时候,单独设置拉流的地址 rtmp(目前乐视使用)
  1647 + if (GlobalConfig.rtmpPullList && GlobalConfig.rtmpPullList.length > 0) {
  1648 + //有单独的rtmp拉流地址
  1649 + let index = parseInt(Math.random() * GlobalConfig.rtmpPullList.length);
  1650 + GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.rtmpPullList[index].ip || "";
  1651 + GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.rtmpPullList[index].port || "";
  1652 + } else {
  1653 + //如果没有单独的rtmp拉流地址,和推流地址一样即可
  1654 + GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.MS_PUBLISH_IP;
  1655 + GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.MS_PUBLISH_PORT;
  1656 + }
  1657 +
  1658 + loger.log('初始->MSPull->.', GlobalConfig.MS_PLAY_RTMP_IP, GlobalConfig.MS_PLAY_RTMP_PORT);
  1659 +
  1660 + //播流的地址和推流地址需要分开的时候,单独设置拉流的地址 hls(目前乐视使用)
  1661 + if (GlobalConfig.hlsList && GlobalConfig.hlsList.length > 0) {
  1662 + //有单独的hls拉流地址
  1663 + let index = parseInt(Math.random() * GlobalConfig.hlsList.length);
  1664 + GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.hlsList[index].ip || "";
  1665 + GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.hlsList[index].port || "";
  1666 + } else {
  1667 + //没有单独的hls拉流地址,和录制回放地址一样即可
  1668 + GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.RS_RECORD_PLAY_IP;
  1669 + GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.RS_RECORD_PLAY_PORT;
  1670 + }
  1671 + loger.log('初始->MSHls->.', GlobalConfig.MS_PLAY_HLS_IP, GlobalConfig.MS_PLAY_HLS_PORT);
  1672 +
  1673 + //直播的时候,拉流(rtmp和hls)需要从 videoCDNAddr中获取
  1674 + //20170531-新规则,所有课堂类型都支持加速
  1675 + // if(GlobalConfig.classType==ApeConsts.CLASS_TYPE_2&&GlobalConfig.videoCDNAddrList.length>0){
  1676 +
  1677 + //20170629-直播课堂和移动端设备的时候支持
  1678 + if (GlobalConfig.classType == ApeConsts.CLASS_TYPE_2 || GlobalConfig.isMobile) {
  1679 + if (GlobalConfig.videoCDNAddrList.length > 0) {
  1680 + //videoCDNAddrList中rtmppush和hls是混在一起的,需要分离开;
  1681 + let listLen = GlobalConfig.videoCDNAddrList.length;
  1682 + for (let i = 0; i < listLen; i++) {
  1683 + let ipItem = GlobalConfig.videoCDNAddrList[i];
  1684 + if (ipItem) {
  1685 + if (ipItem.indexOf('hls') >= 0) {
  1686 + //直播的时候m3u8拉流地址
  1687 + GlobalConfig.MS_PLAY_HLS_IP = ipItem; //ip包含了端口
  1688 + GlobalConfig.MS_PLAY_HLS_PORT = "";
  1689 + loger.log('videoCDNAddr>初始->MSHls', GlobalConfig.MS_PLAY_HLS_IP);
  1690 + }
  1691 + if (ipItem.indexOf('rtmppull')>= 0) {
  1692 + //直播的时候rtmp拉流地址
  1693 + GlobalConfig.MS_PLAY_RTMP_IP = ipItem; //ip包含了端口
  1694 + GlobalConfig.MS_PLAY_RTMP_PORT = '';
  1695 + loger.log('videoCDNAddr->初始->MSPull', GlobalConfig.MS_PLAY_RTMP_IP);
  1696 + }
  1697 + }
  1698 + }
  1699 + } else {
  1700 + loger.error('videoCDNAddr数据无效->', GlobalConfig.videoCDNAddr);
  1701 + }
  1702 + } else {
  1703 + loger.warn('非直播课堂或不是移动端->不需要videoCDN加速');
  1704 + }
  1705 +
  1706 + //文档地址
  1707 + if (_data.docList && _data.docList.length > 0) {
  1708 + //doc上传地址,随机获取一个
  1709 + let index = parseInt(Math.random() * _data.docList.length);
  1710 + loger.log("docServer->", _data.docList[index]);
  1711 + GlobalConfig.DOCServerIP = _data.docList[index].ip || "";
  1712 + GlobalConfig.DOCServerPort = _data.docList[index].port || "";
  1713 + loger.log('初始->DOC->.', GlobalConfig.DOCServerIP, GlobalConfig.DOCServerPort);
  1714 + }
  1715 +
  1716 + //record
  1717 + if (_data.recordList && _data.recordList.length > 0) {
  1718 + let index = parseInt(Math.random() * _data.recordList.length);
  1719 + GlobalConfig.RecordServerIP = _data.recordList[index].ip || "";
  1720 + GlobalConfig.RecordServerPort = _data.recordList[index].port || "";
  1721 + loger.log('初始->RECORD->.', GlobalConfig.RecordServerIP, GlobalConfig.RecordServerPort);
  1722 + }
  1723 +
  1724 + }
  1725 + //这里需要考虑是否加延迟处理,课堂信息刚获取完成,客户端需要根据数据创建界面UI,等创建完成后再加入课堂是最合适的(目前没有加延迟)
  1726 + this._emit(MessageTypes.CLASS_GET_INFO_SUCCESS, GlobalConfig.getClassInfo());
  1727 +
  1728 + if (_data.currentInfo) {
  1729 + //根据从Sass获取的数据信息,同步最后一次保存的课堂状态信息
  1730 + loger.log("本地同步最后一次保存过的课堂状态信息");
  1731 + try {
  1732 + GlobalConfig.setClassStatusInfo(JSON.parse(_data.currentInfo));
  1733 + } catch (err) {
  1734 + loger.warn("从Sass获取的课堂数据JSON转换失败->");
  1735 + console.log("currentInfo", _data.currentInfo);
  1736 + GlobalConfig.setClassStatusInfo(_data.currentInfo);
  1737 + }
  1738 + loger.log(GlobalConfig.classStatusInfo);
  1739 + } else {
  1740 + loger.log("还没有保存过课堂状信息");
  1741 + }
  1742 +
  1743 + //录制回放不需要获取ip信息和选点
  1744 + if (GlobalConfig.isRecordPlayBack) {
  1745 + if (_recordPlayback) {
  1746 + //开启录制回放流程
  1747 + loger.log("开启录制回放流程");
  1748 + _recordPlayback.readyRecordPlay();
  1749 + } else {
  1750 + loger.warn("开启录制回放流程失败->还未创建模块");
  1751 + }
  1752 + } else {
  1753 + //根据用户的userIp获取信息,选点
  1754 + this.getUserIpInfo();
  1755 + }
  1756 + }*/
  1757 +
1350 //ChatApe 1758 //ChatApe
1351 // 发送聊天消息 1759 // 发送聊天消息
1352 _sendChatMsg(_messageInfo) { 1760 _sendChatMsg(_messageInfo) {
1353 if (!_mcu.connected) { 1761 if (!_mcu.connected) {
1354 loger.warn(GlobalConfig.getCurrentStatus()); 1762 loger.warn(GlobalConfig.getCurrentStatus());
1355 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1763 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1356 } 1764 }
1357 if (_messageInfo === null || EngineUtils.isEmptyObject(_messageInfo)) { 1765 if (_messageInfo === null || EngineUtils.isEmptyObject(_messageInfo)) {
1358 loger.log('发送聊天消息失败->参数错误', _messageInfo); 1766 loger.log('发送聊天消息失败->参数错误', _messageInfo);
1359 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1767 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1360 } 1768 }
1361 if (_chat_ape) { 1769 if (_chat_ape) {
1362 _chat_ape.sendChatMsg(_messageInfo); 1770 _chat_ape.sendChatMsg(_messageInfo);
@@ -1366,11 +1774,11 @@ export default class MessageEntrance extends Emiter { @@ -1366,11 +1774,11 @@ export default class MessageEntrance extends Emiter {
1366 //监听摄像头麦克风状态 1774 //监听摄像头麦克风状态
1367 userDeviecStatusChange(_data) { 1775 userDeviecStatusChange(_data) {
1368 /* nodeId:GlobalConfig.nodeId, 1776 /* nodeId:GlobalConfig.nodeId,
1369 - userRole:GlobalConfig.userRole,  
1370 - userName:GlobalConfig.userName,  
1371 - userId:GlobalConfig.userId,  
1372 - openCamera:GlobalConfig.openCamera,  
1373 - openMicrophones:GlobalConfig.openMicrophones*/ 1777 + userRole:GlobalConfig.userRole,
  1778 + userName:GlobalConfig.userName,
  1779 + userId:GlobalConfig.userId,
  1780 + openCamera:GlobalConfig.openCamera,
  1781 + openMicrophones:GlobalConfig.openMicrophones*/
1374 if (_confer_ape) { 1782 if (_confer_ape) {
1375 _confer_ape.updaterUserDeviecStatusChange(_data); 1783 _confer_ape.updaterUserDeviecStatusChange(_data);
1376 } 1784 }
@@ -1379,17 +1787,19 @@ export default class MessageEntrance extends Emiter { @@ -1379,17 +1787,19 @@ export default class MessageEntrance extends Emiter {
1379 //屏幕共享 1787 //屏幕共享
1380 //开始屏幕共享 1788 //开始屏幕共享
1381 _publishScreenShare(_param) { 1789 _publishScreenShare(_param) {
1382 - if (_video_ape) {  
1383 - _video_ape.publishScreenShare(_param);  
1384 - } 1790 + if (_video_ape) {
  1791 + _video_ape.publishScreenShare(_param);
1385 } 1792 }
1386 - //停止屏幕共享 1793 + }
  1794 +
  1795 + //停止屏幕共享
1387 _stopPublishScreenShare(_param) { 1796 _stopPublishScreenShare(_param) {
1388 - if (_video_ape) {  
1389 - _video_ape.stopPublishScreenShare(_param);  
1390 - } 1797 + if (_video_ape) {
  1798 + _video_ape.stopPublishScreenShare(_param);
1391 } 1799 }
1392 - //VidoeApe 1800 + }
  1801 +
  1802 + //VidoeApe
1393 videoUpdate(_data) { 1803 videoUpdate(_data) {
1394 //视频同步的消息发送改变,需要通知ferApe模块中的用户更新状态 1804 //视频同步的消息发送改变,需要通知ferApe模块中的用户更新状态
1395 if (_confer_ape) { 1805 if (_confer_ape) {
@@ -1400,7 +1810,7 @@ export default class MessageEntrance extends Emiter { @@ -1400,7 +1810,7 @@ export default class MessageEntrance extends Emiter {
1400 _sendVideoBroadcastMsg(_param) { 1810 _sendVideoBroadcastMsg(_param) {
1401 if (!_mcu.connected) { 1811 if (!_mcu.connected) {
1402 loger.warn(GlobalConfig.getCurrentStatus()); 1812 loger.warn(GlobalConfig.getCurrentStatus());
1403 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1813 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1404 } 1814 }
1405 if (_video_ape) { 1815 if (_video_ape) {
1406 return _video_ape.sendVideoBroadcastMsg(_param); 1816 return _video_ape.sendVideoBroadcastMsg(_param);
@@ -1428,7 +1838,7 @@ export default class MessageEntrance extends Emiter { @@ -1428,7 +1838,7 @@ export default class MessageEntrance extends Emiter {
1428 _publishVideo(_param) { 1838 _publishVideo(_param) {
1429 if (!_mcu.connected) { 1839 if (!_mcu.connected) {
1430 loger.warn(GlobalConfig.getCurrentStatus()); 1840 loger.warn(GlobalConfig.getCurrentStatus());
1431 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1841 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1432 } 1842 }
1433 if (_video_ape) { 1843 if (_video_ape) {
1434 return _video_ape.publishVideo(_param); 1844 return _video_ape.publishVideo(_param);
@@ -1438,7 +1848,7 @@ export default class MessageEntrance extends Emiter { @@ -1438,7 +1848,7 @@ export default class MessageEntrance extends Emiter {
1438 _stopPublishVideo(_param) { 1848 _stopPublishVideo(_param) {
1439 if (!_mcu.connected) { 1849 if (!_mcu.connected) {
1440 loger.warn(GlobalConfig.getCurrentStatus()); 1850 loger.warn(GlobalConfig.getCurrentStatus());
1441 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1851 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1442 } 1852 }
1443 if (_video_ape) { 1853 if (_video_ape) {
1444 return _video_ape.stopPublishVideo(_param); 1854 return _video_ape.stopPublishVideo(_param);
@@ -1456,7 +1866,7 @@ export default class MessageEntrance extends Emiter { @@ -1456,7 +1866,7 @@ export default class MessageEntrance extends Emiter {
1456 sendAudioCommandMsg(_param) { 1866 sendAudioCommandMsg(_param) {
1457 if (!_mcu.connected) { 1867 if (!_mcu.connected) {
1458 loger.warn(GlobalConfig.getCurrentStatus()); 1868 loger.warn(GlobalConfig.getCurrentStatus());
1459 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1869 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1460 } 1870 }
1461 if (_audio_ape) { 1871 if (_audio_ape) {
1462 return _audio_ape.sendAudioBroadcastMsg(_param); 1872 return _audio_ape.sendAudioBroadcastMsg(_param);
@@ -1484,7 +1894,7 @@ export default class MessageEntrance extends Emiter { @@ -1484,7 +1894,7 @@ export default class MessageEntrance extends Emiter {
1484 _publishAudio(_param) { 1894 _publishAudio(_param) {
1485 if (!_mcu.connected) { 1895 if (!_mcu.connected) {
1486 loger.warn(GlobalConfig.getCurrentStatus()); 1896 loger.warn(GlobalConfig.getCurrentStatus());
1487 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1897 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1488 } 1898 }
1489 if (_audio_ape) { 1899 if (_audio_ape) {
1490 return _audio_ape.publishAudio(_param); 1900 return _audio_ape.publishAudio(_param);
@@ -1494,7 +1904,7 @@ export default class MessageEntrance extends Emiter { @@ -1494,7 +1904,7 @@ export default class MessageEntrance extends Emiter {
1494 _stopPublishAudio(_param) { 1904 _stopPublishAudio(_param) {
1495 if (!_mcu.connected) { 1905 if (!_mcu.connected) {
1496 loger.warn(GlobalConfig.getCurrentStatus()); 1906 loger.warn(GlobalConfig.getCurrentStatus());
1497 - return { "code": ApeConsts.RETURN_FAILED, "data": "" }; 1907 + return {"code": ApeConsts.RETURN_FAILED, "data": ""};
1498 } 1908 }
1499 if (_audio_ape) { 1909 if (_audio_ape) {
1500 return _audio_ape.stopPublishAudio(_param); 1910 return _audio_ape.stopPublishAudio(_param);
@@ -1561,7 +1971,7 @@ export default class MessageEntrance extends Emiter { @@ -1561,7 +1971,7 @@ export default class MessageEntrance extends Emiter {
1561 return _doc_ape.getDocFullAddress(_param); 1971 return _doc_ape.getDocFullAddress(_param);
1562 } else { 1972 } else {
1563 loger.error("文档模块还没有创建无法获取"); 1973 loger.error("文档模块还没有创建无法获取");
1564 - return { "code": ApeConsts.RETURN_FAILED, "data": "文档模块还没有创建无法获取" }; 1974 + return {"code": ApeConsts.RETURN_FAILED, "data": "文档模块还没有创建无法获取"};
1565 } 1975 }
1566 } 1976 }
1567 1977
@@ -1608,25 +2018,27 @@ export default class MessageEntrance extends Emiter { @@ -1608,25 +2018,27 @@ export default class MessageEntrance extends Emiter {
1608 2018
1609 //操作文档(翻页) 2019 //操作文档(翻页)
1610 _sendDocumentSwitchPage(_param) { 2020 _sendDocumentSwitchPage(_param) {
1611 - if (!_mcu.connected) {  
1612 - loger.warn(GlobalConfig.getCurrentStatus());  
1613 - return;  
1614 - }  
1615 - if (_doc_ape) {  
1616 - _doc_ape.documentSwitchPage(_param);  
1617 - } 2021 + if (!_mcu.connected) {
  2022 + loger.warn(GlobalConfig.getCurrentStatus());
  2023 + return;
1618 } 2024 }
1619 - //操作文档(页码上的动画步骤操作) 2025 + if (_doc_ape) {
  2026 + _doc_ape.documentSwitchPage(_param);
  2027 + }
  2028 + }
  2029 +
  2030 + //操作文档(页码上的动画步骤操作)
1620 _sendDocumentSwitchAnimation(_param) { 2031 _sendDocumentSwitchAnimation(_param) {
1621 - if (!_mcu.connected) {  
1622 - loger.warn(GlobalConfig.getCurrentStatus());  
1623 - return;  
1624 - }  
1625 - if (_doc_ape) {  
1626 - _doc_ape.documentSwitchAnimation(_param);  
1627 - } 2032 + if (!_mcu.connected) {
  2033 + loger.warn(GlobalConfig.getCurrentStatus());
  2034 + return;
  2035 + }
  2036 + if (_doc_ape) {
  2037 + _doc_ape.documentSwitchAnimation(_param);
1628 } 2038 }
1629 - //操作文档(缩放、滚动...) 2039 + }
  2040 +
  2041 + //操作文档(缩放、滚动...)
1630 _sendDocumentCommand(_param) { 2042 _sendDocumentCommand(_param) {
1631 if (!_mcu.connected) { 2043 if (!_mcu.connected) {
1632 loger.warn(GlobalConfig.getCurrentStatus()); 2044 loger.warn(GlobalConfig.getCurrentStatus());
@@ -1820,15 +2232,16 @@ export default class MessageEntrance extends Emiter { @@ -1820,15 +2232,16 @@ export default class MessageEntrance extends Emiter {
1820 2232
1821 //音乐播放 2233 //音乐播放
1822 _sendMusicSharedPlay(_param) { 2234 _sendMusicSharedPlay(_param) {
1823 - if (!_mcu.connected) {  
1824 - loger.warn(GlobalConfig.getCurrentStatus());  
1825 - return;  
1826 - }  
1827 - if (_musicShareApe) {  
1828 - _musicShareApe.musicSharedPlay(_param);  
1829 - } 2235 + if (!_mcu.connected) {
  2236 + loger.warn(GlobalConfig.getCurrentStatus());
  2237 + return;
1830 } 2238 }
1831 - //音乐停止 2239 + if (_musicShareApe) {
  2240 + _musicShareApe.musicSharedPlay(_param);
  2241 + }
  2242 + }
  2243 +
  2244 + //音乐停止
1832 _sendMusicSharedStop(_param) { 2245 _sendMusicSharedStop(_param) {
1833 if (!_mcu.connected) { 2246 if (!_mcu.connected) {
1834 loger.warn(GlobalConfig.getCurrentStatus()); 2247 loger.warn(GlobalConfig.getCurrentStatus());
@@ -1852,15 +2265,16 @@ export default class MessageEntrance extends Emiter { @@ -1852,15 +2265,16 @@ export default class MessageEntrance extends Emiter {
1852 2265
1853 //播放 2266 //播放
1854 _sendMediaSharedPlay(_param) { 2267 _sendMediaSharedPlay(_param) {
1855 - if (!_mcu.connected) {  
1856 - loger.warn(GlobalConfig.getCurrentStatus());  
1857 - return;  
1858 - }  
1859 - if (_mediaShareApe) {  
1860 - _mediaShareApe.mediaSharedPlay(_param);  
1861 - } 2268 + if (!_mcu.connected) {
  2269 + loger.warn(GlobalConfig.getCurrentStatus());
  2270 + return;
  2271 + }
  2272 + if (_mediaShareApe) {
  2273 + _mediaShareApe.mediaSharedPlay(_param);
1862 } 2274 }
1863 - //停止 2275 + }
  2276 +
  2277 + //停止
1864 2278
1865 _sendMediaSharedStop(_param) { 2279 _sendMediaSharedStop(_param) {
1866 if (!_mcu.connected) { 2280 if (!_mcu.connected) {
@@ -1885,7 +2299,7 @@ export default class MessageEntrance extends Emiter { @@ -1885,7 +2299,7 @@ export default class MessageEntrance extends Emiter {
1885 "status": 0, 2299 "status": 0,
1886 "creatUserId": value.creatUserId, 2300 "creatUserId": value.creatUserId,
1887 "creatUserName": value.createUserName, 2301 "creatUserName": value.createUserName,
1888 - "url": value.url||value.absoluteLocation,//伴音上传的接口有差异,课堂内上传返回的是url字段,后台带入的字段是absoluteLocation 2302 + "url": value.url || value.absoluteLocation,//伴音上传的接口有差异,课堂内上传返回的是url字段,后台带入的字段是absoluteLocation
1889 "fileType": value.type, 2303 "fileType": value.type,
1890 "fileId": "" + value.id, 2304 "fileId": "" + value.id,
1891 "fileName": value.name, 2305 "fileName": value.name,
@@ -2078,6 +2492,7 @@ export default class MessageEntrance extends Emiter { @@ -2078,6 +2492,7 @@ export default class MessageEntrance extends Emiter {
2078 _questionApe.creatQuestion(_param); 2492 _questionApe.creatQuestion(_param);
2079 } 2493 }
2080 } 2494 }
  2495 +
2081 _getQuestion(_param) { 2496 _getQuestion(_param) {
2082 if (!_mcu.connected) { 2497 if (!_mcu.connected) {
2083 loger.warn(GlobalConfig.getCurrentStatus()); 2498 loger.warn(GlobalConfig.getCurrentStatus());
@@ -2087,6 +2502,7 @@ export default class MessageEntrance extends Emiter { @@ -2087,6 +2502,7 @@ export default class MessageEntrance extends Emiter {
2087 _questionApe.getQuestion(_param); 2502 _questionApe.getQuestion(_param);
2088 } 2503 }
2089 } 2504 }
  2505 +
2090 _getQuestionResult(_param) { 2506 _getQuestionResult(_param) {
2091 if (!_mcu.connected) { 2507 if (!_mcu.connected) {
2092 loger.warn(GlobalConfig.getCurrentStatus()); 2508 loger.warn(GlobalConfig.getCurrentStatus());
@@ -2096,6 +2512,7 @@ export default class MessageEntrance extends Emiter { @@ -2096,6 +2512,7 @@ export default class MessageEntrance extends Emiter {
2096 _questionApe.getQuestionResult(_param); 2512 _questionApe.getQuestionResult(_param);
2097 } 2513 }
2098 } 2514 }
  2515 +
2099 _stopQuestion(_param) { 2516 _stopQuestion(_param) {
2100 if (!_mcu.connected) { 2517 if (!_mcu.connected) {
2101 loger.warn(GlobalConfig.getCurrentStatus()); 2518 loger.warn(GlobalConfig.getCurrentStatus());
@@ -2105,6 +2522,7 @@ export default class MessageEntrance extends Emiter { @@ -2105,6 +2522,7 @@ export default class MessageEntrance extends Emiter {
2105 _questionApe.stopQuestion(_param); 2522 _questionApe.stopQuestion(_param);
2106 } 2523 }
2107 } 2524 }
  2525 +
2108 _sendAnswer(_param) { 2526 _sendAnswer(_param) {
2109 if (!_mcu.connected) { 2527 if (!_mcu.connected) {
2110 loger.warn(GlobalConfig.getCurrentStatus()); 2528 loger.warn(GlobalConfig.getCurrentStatus());
@@ -237,19 +237,20 @@ class GlobalConfig { @@ -237,19 +237,20 @@ class GlobalConfig {
237 //ms列表 237 //ms列表
238 static setMsList(_data) { 238 static setMsList(_data) {
239 if (_data == null) return; 239 if (_data == null) return;
  240 + this.msList = _data;
240 //MSlist列表中的地址需要进行筛选,目前有的站点播流和推流需要分开 241 //MSlist列表中的地址需要进行筛选,目前有的站点播流和推流需要分开
241 - if (GlobalConfig.siteId == GlobalConfig.siteId_letv) { 242 + /* if (GlobalConfig.siteId == GlobalConfig.siteId_letv) {
242 this.msList = []; 243 this.msList = [];
243 - this.pullRtmpList = [];  
244 - this.hlsList = []; 244 + this.rtmpPullListFinal = [];
  245 + this.hlsListFinal = [];
245 let len = _data.length; 246 let len = _data.length;
246 for (let i = 0; i < len; i++) { 247 for (let i = 0; i < len; i++) {
247 let item = _data[i]; 248 let item = _data[i];
248 if (item && item.ip) { 249 if (item && item.ip) {
249 if (item.ip.indexOf('pull.') >= 0) { 250 if (item.ip.indexOf('pull.') >= 0) {
250 - this.pullRtmpList.push(item); 251 + this.rtmpPullListFinal.push(item);
251 } else if (item.ip.indexOf('lehls.') >= 0) { 252 } else if (item.ip.indexOf('lehls.') >= 0) {
252 - this.hlsList.push(item); 253 + this.hlsListFinal.push(item);
253 } else { 254 } else {
254 this.msList.push(item); 255 this.msList.push(item);
255 } 256 }
@@ -257,16 +258,43 @@ class GlobalConfig { @@ -257,16 +258,43 @@ class GlobalConfig {
257 } 258 }
258 loger.log("msListAll->", _data); 259 loger.log("msListAll->", _data);
259 loger.log("msList->", this.msList); 260 loger.log("msList->", this.msList);
260 - loger.log("pullList->", this.pullRtmpList);  
261 - loger.log("hlsList->", this.hlsList); 261 + loger.log("pullList->", this.rtmpPullListFinal);
  262 + loger.log("hlsList->", this.hlsListFinal);
262 } else { 263 } else {
263 this.msList = _data; 264 this.msList = _data;
264 - } 265 + }*/
265 } 266 }
266 static getMsList() { 267 static getMsList() {
267 return this.msList; 268 return this.msList;
268 } 269 }
269 270
  271 + //rtmpPullList列表
  272 + static setRtmpPullList(_data) {
  273 + if (_data == null) return;
  274 + this.rtmpPullList = _data;
  275 + }
  276 + static getRtmpPullList() {
  277 + return this.rtmpPullList;
  278 + }
  279 +
  280 + //hlsPullList列表
  281 + static setHlsPullList(_data) {
  282 + if (_data == null) return;
  283 + this.hlsPullList = _data;
  284 + }
  285 + static getHlsPullList() {
  286 + return this.hlsPullList;
  287 + }
  288 +
  289 + //rs列表
  290 + static setRsList(_data) {
  291 + if (_data == null) return;
  292 + this.rsList = _data;
  293 + }
  294 + static getRsList() {
  295 + return this.rsList;
  296 + }
  297 +
270 //mcu列表 298 //mcu列表
271 static setMcuList(_data) { 299 static setMcuList(_data) {
272 if (_data == null) return; 300 if (_data == null) return;
@@ -293,14 +321,7 @@ class GlobalConfig { @@ -293,14 +321,7 @@ class GlobalConfig {
293 return this.musicListPrepare; 321 return this.musicListPrepare;
294 } 322 }
295 323
296 - //rs列表  
297 - static setRsList(_data) {  
298 - if (_data == null) return;  
299 - this.rsList = _data;  
300 - }  
301 - static getRsList() {  
302 - return this.rsList;  
303 - } 324 +
304 325
305 //CDN加速的 拉流地址 rtmp 和hls(m3u8) 326 //CDN加速的 拉流地址 rtmp 和hls(m3u8)
306 static setVideoCDNAddr(_data) { 327 static setVideoCDNAddr(_data) {
@@ -331,8 +352,45 @@ GlobalConfig.mcuDelay = 0; //默认的延迟时间(单位-秒) @@ -331,8 +352,45 @@ GlobalConfig.mcuDelay = 0; //默认的延迟时间(单位-秒)
331 GlobalConfig.docDelay = 1600; //文档模块加入成功之后延迟发送送成功的消息给主模块(sdk内部使用) 352 GlobalConfig.docDelay = 1600; //文档模块加入成功之后延迟发送送成功的消息给主模块(sdk内部使用)
332 GlobalConfig.portal = "112.126.80.182:80"; //Sass IP 353 GlobalConfig.portal = "112.126.80.182:80"; //Sass IP
333 354
334 -//GlobalConfig.ip="112.126.80.182";  
335 -//GlobalConfig.port="80"; 355 +//从Sass获取的
  356 +GlobalConfig.country = ""; //国家
  357 +GlobalConfig.city = ""; //城市
  358 +GlobalConfig.province = ""; //服务商
  359 +GlobalConfig.isp = ""; //服务商
  360 +
  361 +
  362 +GlobalConfig.sharedMediaList = []; // 已经提前上传的媒体文件列表,进入课堂后需要自动加载
  363 +GlobalConfig.sharedMusicList = []; // 已经提前上传的音乐文件列表,进入课堂后需要自动加载
  364 +GlobalConfig.docListPrepare = []; // 已经提前上传的文档,进入课堂后需要自动加载
  365 +GlobalConfig.recordList = []; //录制服务器地址集合
  366 +GlobalConfig.docList = []; //文档服务器地址集合
  367 +GlobalConfig.musicList = []; //music服务器地址集合
  368 +GlobalConfig.musicListPrepare = []; //提提前上传的music集合
  369 +GlobalConfig.videoCDNAddr = '';
  370 +GlobalConfig.videoCDNAddrList = []; //从videoCDNAddr转换来的,videoCDNAddr字符串用分号隔开了多个ip
  371 +
  372 +//从Sass获取的数据
  373 +GlobalConfig.mcuList = []; //录制服务器地址集合
  374 +GlobalConfig.msList = []; //从Sass获取的ms推流地址集合,也可以拉流
  375 +GlobalConfig.rtmpPullList = []; //从Sass获取的rtmp拉流地址集合
  376 +GlobalConfig.hlsPullList = []; //从sasss获取的hls拉流服务器地址集合
  377 +GlobalConfig.rsList = []; //录制回放中视频hls点播地址
  378 +
  379 +//根据userIP从server获取的数据
  380 +GlobalConfig.mcuListFromServer = []; //根据userIP从server获取的mcu列表
  381 +GlobalConfig.msListFromServer = []; //根据userIP从server获取的ms列表
  382 +GlobalConfig.rtmpPullListFromServer = []; //根据userIP从server获取的rtmp拉流地址列表
  383 +GlobalConfig.hlsPullListFromServer = []; //根据userIP从server获取的hls拉流地址列表
  384 +GlobalConfig.rsPullListFromServer = []; //根据userIP从server获取的录制回放hls列表
  385 +
  386 +//最终使用的选点列表集合-(从server.json中获取或Sass中获取)
  387 +GlobalConfig.mcuListFinal = []; //最终选择的MCU集合
  388 +GlobalConfig.msListFinal = []; //最终选择的MS 推流地址集合
  389 +GlobalConfig.rtmpPullListFinal = []; //最终选择的RTMP推流地址集合
  390 +GlobalConfig.hlsListFinal = []; //最终选择的HLS拉流地址集合
  391 +GlobalConfig.rsListFinal = []; //最终选择的录制回放HLS拉流地址集合
  392 +
  393 +
336 394
337 //连接MCU的IP+端口 395 //连接MCU的IP+端口
338 GlobalConfig.MCUServerIP = ""; 396 GlobalConfig.MCUServerIP = "";
@@ -443,34 +501,7 @@ GlobalConfig.currentSceneTableId = 0; //文档区域的当前模块id显示的 @@ -443,34 +501,7 @@ GlobalConfig.currentSceneTableId = 0; //文档区域的当前模块id显示的
443 GlobalConfig.classAllParam = {}; //Sass直接返回的所有课堂信息(最全) 501 GlobalConfig.classAllParam = {}; //Sass直接返回的所有课堂信息(最全)
444 GlobalConfig.classDetail = {}; //Sass直接返回的当前课堂基本信息 502 GlobalConfig.classDetail = {}; //Sass直接返回的当前课堂基本信息
445 503
446 -//从Sass获取的  
447 -GlobalConfig.sharedMediaList = []; // 已经提前上传的媒体文件列表,进入课堂后需要自动加载  
448 -GlobalConfig.sharedMusicList = []; // 已经提前上传的音乐文件列表,进入课堂后需要自动加载  
449 -GlobalConfig.docListPrepare = []; // 已经提前上传的文档,进入课堂后需要自动加载  
450 -GlobalConfig.recordList = []; //录制服务器地址集合  
451 -GlobalConfig.docList = []; //文档服务器地址集合  
452 -GlobalConfig.mcuList = []; //录制服务器地址集合  
453 -GlobalConfig.msList = []; //ms服务器地址集合  
454 -GlobalConfig.musicList = []; //music服务器地址集合  
455 -GlobalConfig.musicListPrepare = []; //提提前上传的music集合  
456 -GlobalConfig.rsList = []; //录制回放中视频点播地址  
457 -GlobalConfig.videoCDNAddr = '';  
458 -GlobalConfig.videoCDNAddrList = []; //从videoCDNAddr转换来的,videoCDNAddr字符串用分号隔开了多个ip  
459 -  
460 -//乐视的推流和播放需要分开  
461 -GlobalConfig.pullRtmpList = []; //rtmp播流地址集合(推流和播流地址需要区分的站点使用)  
462 -GlobalConfig.hlsList = []; //hls播流地址集合(推流和播流地址需要区分的站点使用)  
463 -  
464 -//根据IP从server获取  
465 -GlobalConfig.mcuListFromServer = []; //根据userIP从server获取的mcu列表  
466 -GlobalConfig.msListFromServer = []; //根据userIP从server获取的ms列表  
467 -GlobalConfig.country = ""; //国家  
468 -GlobalConfig.city = ""; //城市  
469 -GlobalConfig.province = ""; //服务商  
470 -GlobalConfig.isp = ""; //服务商  
471 504
472 -GlobalConfig.mcuListAll = []; //所有MCU集合(sass+server)  
473 -GlobalConfig.msListAll = []; //所有MS集合(sass+server)  
474 505
475 GlobalConfig.isRecordPlayBack = false; //是否是录制回放,默认是否 506 GlobalConfig.isRecordPlayBack = false; //是否是录制回放,默认是否
476 GlobalConfig.allowRecordMaxTime = 14400; //(秒)允许录制的最长时间,默认是4小时 507 GlobalConfig.allowRecordMaxTime = 14400; //(秒)允许录制的最长时间,默认是4小时
@@ -249,6 +249,78 @@ class IpManager extends Emiter { @@ -249,6 +249,78 @@ class IpManager extends Emiter {
249 249
250 } 250 }
251 251
  252 + //服务器列表测速,参数是一个ip数组,返回一个ip
  253 + testFastestIpFromServer(_ipList, _callback, _timeOutDelay) {
  254 + loger.log('开始测试->', _ipList);
  255 + let callbackData = {ip: ""};
  256 + if (_ipList == null || _ipList.length < 1) {
  257 + if (_callback) {
  258 + _callback(callbackData);
  259 + }
  260 + return;
  261 + }
  262 + //对传入的ip数组进行组织
  263 + let newList = new Object();
  264 + let listLen = _ipList.length;
  265 + for (let i = 0; i < listLen; i++) {
  266 + let msItem = _ipList[i];
  267 + if (msItem && msItem.ip) {
  268 + //测速的时候,ip地址要拼接成带端口的完整地址,测速的端口是固定的
  269 + newList[msItem.ip + ':' + SPEED_TEST_PORT]=msItem.ip + ':' + SPEED_TEST_PORT;
  270 + }
  271 + }
  272 + //过滤完重复ip
  273 + let ipListArr =new Array();
  274 + for(let k in newList){
  275 + ipListArr.push(k);
  276 + }
  277 +
  278 + if (ipListArr == null || ipListArr.length < 1) {
  279 + if (_callback) {
  280 + _callback(callbackData);
  281 + }
  282 + return;
  283 + }
  284 + loger.log('测速地址列表->', ipListArr);
  285 + try {
  286 + iphunter(ipListArr, function (fatest_ip_response) {
  287 + if (!fatest_ip_response) {
  288 + loger.warn('测速返回-> nothing!');
  289 + if (_callback) {
  290 + _callback(callbackData);
  291 + }
  292 + } else {
  293 + loger.log('测速返回->完成 -> ', fatest_ip_response);
  294 + let fastestIp = fatest_ip_response.replace((':' + SPEED_TEST_PORT), '') || ""
  295 + callbackData.ip = fastestIp;
  296 + callbackData.port = '';
  297 +
  298 + //根据ip从原来的ip列表中查找端口
  299 + let listLen = _ipList.length;
  300 + for (let i = 0; i < listLen; i++) {
  301 + let msItem = _ipList[i];
  302 + if (msItem && msItem.ip) {
  303 + if (fastestIp == msItem.ip) {
  304 + callbackData.port = msItem.port || MS_DEFAULT_PORT;
  305 + break;
  306 + }
  307 + }
  308 + }
  309 + //返回数据
  310 + if (_callback) {
  311 + _callback(callbackData);
  312 + }
  313 + }
  314 + }, _timeOutDelay || TIME_OUT);
  315 + } catch (err) {
  316 + loger.warn('测速失败->ERROR -> ', err.message);
  317 + if (_callback) {
  318 + _callback(callbackData);
  319 + }
  320 + }
  321 +
  322 + }
  323 +
252 //根据user信息从配置文件中MCU连接地址 324 //根据user信息从配置文件中MCU连接地址
253 getServerMcuList(country, province, ctiy, isp, jsona) { 325 getServerMcuList(country, province, ctiy, isp, jsona) {
254 let countryData = jsona.MCU[country]; 326 let countryData = jsona.MCU[country];
@@ -333,6 +405,63 @@ class IpManager extends Emiter { @@ -333,6 +405,63 @@ class IpManager extends Emiter {
333 return []; 405 return [];
334 } 406 }
335 407
  408 + //根据user信息从server配置文件中获取服务列表信息
  409 + // _type()
  410 + /* "MS":{},
  411 + "RTMP_PULL":{},
  412 + "HLS_PULL":{},
  413 + "RS_PULL":{},
  414 + "MCU":{}*/
  415 + getServerListForUserInfo(_type,_country, province, ctiy, isp, jsona) {
  416 + if(!jsona){
  417 + return [];
  418 + }
  419 + if(! jsona[_type]){
  420 + return []
  421 + }
  422 + let countryData = jsona[_type][_country];
  423 + //按country没有查找到就返回default
  424 + if (!countryData) {
  425 + countryData = jsona[_type].default || [];
  426 + // loger.log("_returnServerMS->countryData->default",countryData);
  427 + return countryData;
  428 + }
  429 +
  430 + if (_country != "中国") {
  431 + // loger.log("_returnServerMS->countryData",countryData);
  432 + return countryData;
  433 + }
  434 +
  435 + //中国的需要细分
  436 + //按isp查找
  437 + let ispData = countryData.isp[isp];
  438 + //isp查找到就返回
  439 + if (ispData) {
  440 + // loger.log("_returnServerMS->ispData",ispData);
  441 + return ispData;
  442 + }
  443 +
  444 + //isp没查找到,用province
  445 + let provinceData = countryData.province[province];
  446 + //用province查找到就返回
  447 + if (provinceData) {
  448 + // loger.log("_returnServerMS->provinceData",provinceData);
  449 + return provinceData;
  450 + }
  451 +
  452 + //isp province都没有,使用default
  453 + let defaultData = countryData.default
  454 + if (defaultData) {
  455 + // loger.log("_returnServerMS->defaultData",defaultData);
  456 + return defaultData;
  457 + } else {
  458 + // loger.log("_returnServerMS->defaultData","");
  459 + return [];
  460 + }
  461 + return [];
  462 + }
  463 +
  464 +
336 } 465 }
337 export default IpManager; 466 export default IpManager;
338 467
@@ -106,6 +106,8 @@ MessageTypes.WHITEBOARD_ANNOTATION_UPDATE = "whiteboard_annotation_update"; // ' @@ -106,6 +106,8 @@ MessageTypes.WHITEBOARD_ANNOTATION_UPDATE = "whiteboard_annotation_update"; // '
106 //MCU MS 106 //MCU MS
107 MessageTypes.SWITCH_MCU_IP = "switch_mcu_ip"; //切换mcu 重新选点 107 MessageTypes.SWITCH_MCU_IP = "switch_mcu_ip"; //切换mcu 重新选点
108 MessageTypes.SWITCH_MS_IP = "switch_ms_ip"; //切换ms 重新选点 108 MessageTypes.SWITCH_MS_IP = "switch_ms_ip"; //切换ms 重新选点
  109 +MessageTypes.SWITCH_RTMP_PULL_IP = "switch_rtmp_pull_ip"; //切换ms MS拉流选点
  110 +MessageTypes.SWITCH_HLS_IP = "switch_hls_ip"; //切换ms HLS拉流选点
109 111
110 //录制回放 112 //录制回放
111 MessageTypes.RECORD_PLAYBACK_UPDATE = "record_playback_update"; //录制回放更新信息 113 MessageTypes.RECORD_PLAYBACK_UPDATE = "record_playback_update"; //录制回放更新信息
@@ -128,7 +128,7 @@ class ConferApe extends Ape { @@ -128,7 +128,7 @@ class ConferApe extends Ape {
128 nodeInfoRecordPdu.isp = GlobalConfig.isp; //服务商 128 nodeInfoRecordPdu.isp = GlobalConfig.isp; //服务商
129 129
130 //用户的MS列表 130 //用户的MS列表
131 - let msListAll = GlobalConfig.msListAll; 131 + let msListAll = GlobalConfig.msListFinal;
132 for (let k = 0; k < msListAll.length; k++) { 132 for (let k = 0; k < msListAll.length; k++) {
133 let msItem = msListAll[k]; 133 let msItem = msListAll[k];
134 if (msItem) { 134 if (msItem) {
@@ -632,7 +632,12 @@ class ConferApe extends Ape { @@ -632,7 +632,12 @@ class ConferApe extends Ape {
632 632
633 //进行MS动态选点,选择最快的MS服务器地址(录制回放不做处理) 633 //进行MS动态选点,选择最快的MS服务器地址(录制回放不做处理)
634 if (!GlobalConfig.isRecordPlayBack && GlobalConfig.classTimestamp % GlobalConfig.msDynamicChooseIpDelay == 0) { 634 if (!GlobalConfig.isRecordPlayBack && GlobalConfig.classTimestamp % GlobalConfig.msDynamicChooseIpDelay == 0) {
  635 + //MS推流选点
635 this._emit(MessageTypes.SWITCH_MS_IP); 636 this._emit(MessageTypes.SWITCH_MS_IP);
  637 + //MS拉流选点
  638 + this._emit(MessageTypes.SWITCH_RTMP_PULL_IP);
  639 + //HLS拉流选点
  640 + this._emit(MessageTypes.SWITCH_HLS_IP);
636 } 641 }
637 } 642 }
638 643
@@ -47,8 +47,7 @@ class MediaModule { @@ -47,8 +47,7 @@ class MediaModule {
47 path = "http://" + GlobalConfig.MS_PLAY_HLS_IP 47 path = "http://" + GlobalConfig.MS_PLAY_HLS_IP
48 + port + "/live/" 48 + port + "/live/"
49 + _param.streamId 49 + _param.streamId
50 - +".m3u8";//新版的规则,不需要加playlist 20170724  
51 - //+ "/"+fileName;// 50 + + "/"+fileName;//
52 51
53 52
54 } else { 53 } else {
@@ -404,13 +404,15 @@ class MediaSharedApe extends Ape { @@ -404,13 +404,15 @@ class MediaSharedApe extends Ape {
404 getMediaPackFullInfo.status==1&& 404 getMediaPackFullInfo.status==1&&
405 getMediaPackFullInfo.mediaVolume==this.lastActiveData.mediaVolume){ 405 getMediaPackFullInfo.mediaVolume==this.lastActiveData.mediaVolume){
406 let timeDistance=Math.abs(new Date().getTime()-parseInt(this.lastActiveData.time))/1000; 406 let timeDistance=Math.abs(new Date().getTime()-parseInt(this.lastActiveData.time))/1000;
407 - let seekDistance=Math.abs(getMediaPackFullInfo.seek-this.lastActiveData.seek)-timeDistance;  
408 - seekDistance=Math.abs(seekDistance); 407 + let seek2seek=Math.abs(getMediaPackFullInfo.seek-this.lastActiveData.seek)
  408 + let seekDistance=seek2seek-timeDistance;
  409 + seekDistance=parseInt(Math.abs(seekDistance));
  410 + loger.warn("timeDistance:"+timeDistance+" seek2seek:"+seek2seek+" seekDistance:"+seekDistance);
409 if(seekDistance<=5){ 411 if(seekDistance<=5){
410 //记录最后一次的数据 412 //记录最后一次的数据
411 loger.warn("媒体共享更新数据->数据只有SEEK发生改变,低于5秒不需要再更新->timeDistance:"+timeDistance+"->seekDistance"+seekDistance); 413 loger.warn("媒体共享更新数据->数据只有SEEK发生改变,低于5秒不需要再更新->timeDistance:"+timeDistance+"->seekDistance"+seekDistance);
412 //记录最后一次激活的数据 414 //记录最后一次激活的数据
413 - this.lastActiveData=getMediaPackFullInfo||{}; 415 + this.lastActiveData=getMediaPackFullInfo;
414 this.lastActiveData.time=new Date().getTime(); 416 this.lastActiveData.time=new Date().getTime();
415 return; 417 return;
416 } 418 }
@@ -401,9 +401,16 @@ class MusicSharedApe extends Ape { @@ -401,9 +401,16 @@ class MusicSharedApe extends Ape {
401 getMusicPackFullInfo.status==1&& 401 getMusicPackFullInfo.status==1&&
402 getMusicPackFullInfo.musicVolume==this.lastActiveData.musicVolume){ 402 getMusicPackFullInfo.musicVolume==this.lastActiveData.musicVolume){
403 403
404 - let timeDistance=Math.abs(new Date().getTime()-parseInt(this.lastActiveData.time))/1000; 404 + /* let timeDistance=Math.abs(new Date().getTime()-parseInt(this.lastActiveData.time))/1000;
405 let seekDistance=Math.abs(getMusicPackFullInfo.seek-this.lastActiveData.seek)-timeDistance; 405 let seekDistance=Math.abs(getMusicPackFullInfo.seek-this.lastActiveData.seek)-timeDistance;
406 seekDistance=Math.abs(seekDistance); 406 seekDistance=Math.abs(seekDistance);
  407 + */
  408 + let timeDistance=Math.abs(new Date().getTime()-parseInt(this.lastActiveData.time))/1000;
  409 + let seek2seek=Math.abs(getMusicPackFullInfo.seek-this.lastActiveData.seek)
  410 + let seekDistance=seek2seek-timeDistance;
  411 + seekDistance=parseInt(Math.abs(seekDistance));
  412 + loger.warn("timeDistance:"+timeDistance+" seek2seek:"+seek2seek+" seekDistance:"+seekDistance);
  413 +
407 if(seekDistance<5){ 414 if(seekDistance<5){
408 //记录最后一次的数据 415 //记录最后一次的数据
409 loger.warn("伴音更新数据->数据只有SEEK发生改变,低于5秒不需要再更新->timeDistance:"+timeDistance+"->seekDistance"+seekDistance); 416 loger.warn("伴音更新数据->数据只有SEEK发生改变,低于5秒不需要再更新->timeDistance:"+timeDistance+"->seekDistance"+seekDistance);