李勇

1.MS推流和拉流的地址分开,msList中包含了推流和拉流的地址(乐视的需要单独分开)

... ... @@ -250,8 +250,8 @@ class ServerCheck extends Emiter {
} else {
GlobalConfig.MCUServerIP = tempMcuIp;
GlobalConfig.MCUServerPort = tempMcuPort;
GlobalConfig.MSServerIP = tempMsIp;
GlobalConfig.MSServerPort = tempMsPort;
GlobalConfig.MS_PUBLISH_IP = tempMsIp;
GlobalConfig.MS_PUBLISH_PORT = tempMsPort;
// loger.log("Server选点完成", "mcu-->",GlobalConfig.MCUServerIP,GlobalConfig.MCUServerPort,"ms---->",GlobalConfig.MSServerIP,GlobalConfig.MSServerPort);
this._emit(ServerCheck.SEVER_CHECK_BEST_IP_SUCCESS);
}
... ... @@ -262,10 +262,10 @@ class ServerCheck extends Emiter {
GlobalConfig.MCUServerPort = tempMcuPort;
}
if (tempMsIp) {
GlobalConfig.MSServerIP = tempMsIp;
GlobalConfig.MSServerPort = tempMsPort;
GlobalConfig.MS_PUBLISH_IP = tempMsIp;
GlobalConfig.MS_PUBLISH_PORT = tempMsPort;
}
loger.log("Sass选点完成", "mcu-->", GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort, "ms---->", GlobalConfig.MSServerIP, GlobalConfig.MSServerPort);
loger.log("Sass选点完成", "mcu-->", GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort, "ms---->", GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT);
this._emit(ServerCheck.SEVER_CHECK_BEST_IP_SUCCESS);
}
} else {
... ...
此 diff 太大无法显示。
... ... @@ -27,7 +27,7 @@ import Server from "config/Server";
import UTF8 from 'utf-8';
let loger = Loger.getLoger('McuClient');
let _sdkInfo = {"version": "v1.9.20.20170426", "author": "www.3mang.com"};
let _sdkInfo = {"version": "v1.10.0.20170427", "author": "www.3mang.com"};
//APE
let _sass;
... ... @@ -442,17 +442,15 @@ export default class MessageEntrance extends Emiter {
GlobalConfig.setDocListPrepare(_data.docListPrepare); //提前上传的文档列表
GlobalConfig.setRecordList(_data.recordList);//录制回放地址
GlobalConfig.setDocList(_data.docList);//文档地址
GlobalConfig.setMsList(_data.msList);//推流播流服务器地址
GlobalConfig.setRsList(_data.rsList);//播放m3u8格式的地址
GlobalConfig.setMsList(_data.msList);//推流播流服务器地址(需要对列表中的地址进行分类,里面包含了推流和拉流的地址,目前主要是乐视的需要区分开)
GlobalConfig.setRsList(_data.rsList);//播放m3u8格式的地址(录制回放时使用)
GlobalConfig.setMcuList(_data.mcuList);//mcu
GlobalConfig.setMusicList(_data.musicList);//
GlobalConfig.setMusicListPrepare(_data.musicListPrepare);//提前上传的声音文件列表
//MCU地址
if (_data.mcuList && _data.mcuList.length > 0) {
/* //MCU地址默认使用第一个
GlobalConfig.MCUServerIP = _data.mcuList[0].ip || "";
GlobalConfig.MCUServerPort = _data.mcuList[0].port || "";*/
//随机选择一个
let index = parseInt(Math.random() * _data.mcuList.length);
GlobalConfig.MCUServerIP = _data.mcuList[index].ip || "";
... ... @@ -460,29 +458,48 @@ export default class MessageEntrance extends Emiter {
loger.log('初始->MCU->.', GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort);
}
//上课中视频推流播流地址
if (_data.msList && _data.msList.length > 0) {
//MS地址默认使用第一个
/* GlobalConfig.MSServerIP = _data.msList[0].ip || "";
GlobalConfig.MSServerPort = _data.msList[0].port || "";*/
let index = parseInt(Math.random() * _data.msList.length);
GlobalConfig.MSServerIP = _data.msList[index].ip || "";
GlobalConfig.MSServerPort = _data.msList[index].port || "";
loger.log('初始->MS->.', GlobalConfig.MSServerIP, GlobalConfig.MSServerPort);
}
//录制回放时m3u8播流地址
if (_data.rsList && _data.rsList.length > 0) {
//RS地址默认使用第一个
//GlobalConfig.RSServerIP = _data.rsList[0].ip || "";
//GlobalConfig.RSServerPort = _data.rsList[0].port || "";
let index = parseInt(Math.random() * _data.rsList.length);
GlobalConfig.RSServerIP = _data.rsList[index].ip || "";
GlobalConfig.RSServerPort = _data.rsList[index].port || "";
loger.log('初始->RS->.', GlobalConfig.RSServerIP, GlobalConfig.RSServerPort);
GlobalConfig.RS_RECORD_PLAY_IP = _data.rsList[index].ip || "";
GlobalConfig.RS_RECORD_PLAY_PORT = _data.rsList[index].port || "";
loger.log('初始->RS->.', GlobalConfig.RS_RECORD_PLAY_IP, GlobalConfig.RS_RECORD_PLAY_PORT);
}
//上课中音视频推流地址
if (GlobalConfig.msList && GlobalConfig.msList.length > 0) {
let index = parseInt(Math.random() * GlobalConfig.msList.length);
GlobalConfig.MS_PUBLISH_IP = GlobalConfig.msList[index].ip || "";
GlobalConfig.MS_PUBLISH_PORT = GlobalConfig.msList[index].port || "";
}
loger.log('初始->MS->.', GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT);
//播流的地址和推流地址需要分开的时候,单独设置拉流的地址 rtmp(目前乐视使用)
if (GlobalConfig.pullRtmpList &&GlobalConfig.pullRtmpList.length > 0) {
//有单独的rtmp拉流地址
let index = parseInt(Math.random() *GlobalConfig.pullRtmpList.length);
GlobalConfig.MS_PLAY_RTMP_IP =GlobalConfig.pullRtmpList[index].ip || "";
GlobalConfig.MS_PLAY_RTMP_PORT =GlobalConfig.pullRtmpList[index].port || "";
}else {
//如果没有单独的rtmp拉流地址,和推流地址一样即可
GlobalConfig.MS_PLAY_RTMP_IP= GlobalConfig.MS_PUBLISH_IP;
GlobalConfig.MS_PLAY_RTMP_PORT =GlobalConfig.MS_PUBLISH_PORT;
}
loger.log('初始->MSPull->.', GlobalConfig.MS_PLAY_RTMP_IP, GlobalConfig.MS_PLAY_RTMP_PORT);
//播流的地址和推流地址需要分开的时候,单独设置拉流的地址 hls(目前乐视使用)
if (GlobalConfig.hlsList &&GlobalConfig.hlsList.length > 0) {
//有单独的hls拉流地址
let index = parseInt(Math.random() *GlobalConfig.hlsList.length);
GlobalConfig.MS_PLAY_HLS_IP =GlobalConfig.hlsList[index].ip || "";
GlobalConfig.MS_PLAY_HLS_PORT =GlobalConfig.hlsList[index].port || "";
}else {
//没有单独的hls拉流地址,和录制回放地址一样即可
GlobalConfig.MS_PLAY_HLS_IP =GlobalConfig.RS_RECORD_PLAY_IP;
GlobalConfig.MS_PLAY_HLS_PORT =GlobalConfig.RS_RECORD_PLAY_PORT ;
}
loger.log('初始->MSHls->.', GlobalConfig.MS_PLAY_HLS_IP, GlobalConfig.MS_PLAY_HLS_PORT);
//文档地址
if (_data.docList && _data.docList.length > 0) {
... ... @@ -496,10 +513,6 @@ export default class MessageEntrance extends Emiter {
//record
if (_data.recordList && _data.recordList.length > 0) {
//地址默认使用第一个
//GlobalConfig.RecordServerIP = _data.recordList[0].ip || "";
//GlobalConfig.RecordServerPort = _data.recordList[0].port || "";
let index = parseInt(Math.random() * _data.recordList.length);
GlobalConfig.RecordServerIP = _data.recordList[index].ip || "";
GlobalConfig.RecordServerPort = _data.recordList[index].port || "";
... ... @@ -563,16 +576,26 @@ export default class MessageEntrance extends Emiter {
//开始选点
let _this = this;
this._getFastestMsServer(function (_data) {
loger.log("MS选点结束->", _data);
if (_data && _data.ip) {
GlobalConfig.MSServerIP = _data.ip || "";
GlobalConfig.MSServerPort = _data.port || "";
}
loger.log("当前使用的MS->", GlobalConfig.MSServerIP, GlobalConfig.MSServerPort);
//有一些站点不需要进行MS选点,需要先检查一下
if(GlobalConfig.siteId_letv==GlobalConfig.siteId){
//MS不需要选点
loger.log("MS不需要选点->siteId->", GlobalConfig.siteId);
_this.isGetFastestMcuCallback = true;
_this._startConnectMCU();
});
}else {
this._getFastestMsServer(function (_data) {
loger.log("MS选点结束->", _data);
if (_data && _data.ip) {
GlobalConfig.MS_PUBLISH_IP = _data.ip || "";
GlobalConfig.MS_PUBLISH_PORT = _data.port || "";
}
loger.log("当前使用的MS->", GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT);
_this.isGetFastestMcuCallback = true;
_this._startConnectMCU();
});
}
this._getFastestMcuServer(function (_data) {
loger.log("MCU选点结束->", _data);
if (_data && _data.ip) {
... ... @@ -610,7 +633,6 @@ export default class MessageEntrance extends Emiter {
Server.serverList);
}
//console.log(" GlobalConfig.mcuListFromServer", GlobalConfig.mcuListFromServer)
//console.log(" GlobalConfig.msListFromServer", GlobalConfig.msListFromServer)
//合并所有MCU、MS 列表
... ... @@ -812,28 +834,28 @@ export default class MessageEntrance extends Emiter {
let oldIp= GlobalConfig.MCUServerIP;
if (_data && _data.ip) {
GlobalConfig.MSServerIP = _data.ip || "";
GlobalConfig.MSServerPort = _data.port || "";
GlobalConfig.MS_PUBLISH_IP = _data.ip || "";
GlobalConfig.MS_PUBLISH_PORT = _data.port || "";
} else {
//随机选择一个
if (GlobalConfig.msList && GlobalConfig.msList.length > 0) {
let index = parseInt(Math.random() * GlobalConfig.msList.length);
GlobalConfig.MSServerIP = GlobalConfig.msList[index].ip || "";
GlobalConfig.MSServerPort = GlobalConfig.msList[index].port || "";
GlobalConfig.MS_PUBLISH_IP = GlobalConfig.msList[index].ip || "";
GlobalConfig.MS_PUBLISH_PORT = GlobalConfig.msList[index].port || "";
}
}
if(oldIp&&oldIp!=GlobalConfig.MSServerIP){
if(oldIp&&oldIp!=GlobalConfig.MS_PUBLISH_IP){
/* loger.log('MS->切换地址->', GlobalConfig.MSServerIP, GlobalConfig.MSServerPort);
//判断是否需要断开当前的连接重连新的服务器
if (_param && _param.reConnect == true) {
loger.log('MS->最新地址->', GlobalConfig.MSServerIP, GlobalConfig.MSServerPort);
}*/
loger.log('MS->最新地址->', GlobalConfig.MSServerIP, GlobalConfig.MSServerPort);
loger.log('MS->最新地址->', GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT);
}else {
//如果选点结束后获得的ip和当前的IP相同,不需要切换
loger.log('MS不需要切换->IP',GlobalConfig.MSServerIP);
loger.log('MS不需要切换->IP',GlobalConfig.MS_PUBLISH_IP);
}
});
... ...
... ... @@ -195,7 +195,31 @@ class GlobalConfig {
//ms列表
static setMsList(_data){
if(_data==null) return;
this.msList=_data;
//MSlist列表中的地址需要进行筛选,目前有的站点播流和推流需要分开
if(GlobalConfig.siteId==GlobalConfig.siteId_letv){
this.msList=[];
this.pullRtmpList=[];
this.hlsList=[];
let len=_data.length;
for(let i=0;i<len;i++){
let item=_data[i];
if(item&&item.ip){
if(item.ip.indexOf('pull.')>=0){
this.pullRtmpList.push(item);
}else if(item.ip.indexOf('hls.')>=0){
this.hlsList.push(item);
}else {
this.msList.push(item);
}
}
}
loger.log("msListAll->",_data);
loger.log("msList->",this.msList);
loger.log("pullList->",this.pullRtmpList);
loger.log("hlsList->",this.hlsList);
}else {
this.msList=_data;
}
}
static getMsList(){
return this.msList;
... ... @@ -254,15 +278,26 @@ GlobalConfig.portal="112.126.80.182:80";//Sass IP
//GlobalConfig.ip="112.126.80.182";
//GlobalConfig.port="80";
//连接MCU的IP+端口
GlobalConfig.MCUServerIP="";
GlobalConfig.MCUServerPort='';
GlobalConfig.MSServerIP = "";//推流 播流的地址
GlobalConfig.MSServerPort ="";
//推流地址+端口
GlobalConfig.MS_PUBLISH_IP = "";
GlobalConfig.MS_PUBLISH_PORT ="";
//rtmp 拉流地址+端口(rtmp)
GlobalConfig.MS_PLAY_RTMP_IP="";
GlobalConfig.MS_PLAY_RTMP_PORT="";
//HLS 拉流地址+端口 (m3u8)
GlobalConfig.MS_PLAY_HLS_IP="";
GlobalConfig.MS_PLAY_HLS_PORT="";
//m3u8播流地址
GlobalConfig.RSServerIP ="";
GlobalConfig.RSServerPort ="";
//录制回放 m3u8播流地址()
GlobalConfig.RS_RECORD_PLAY_IP ="";
GlobalConfig.RS_RECORD_PLAY_PORT ="";
//DOC
GlobalConfig.DOCServerIP ="";
... ... @@ -340,6 +375,10 @@ GlobalConfig.musicListPrepare=[];//提提前上传的music集合
GlobalConfig.rsList=[];//录制回放中视频点播地址
//乐视的推流和播放需要分开
GlobalConfig.pullRtmpList=[];//rtmp播流地址集合(推流和播流地址需要区分的站点使用)
GlobalConfig.hlsList=[];//hls播流地址集合(推流和播流地址需要区分的站点使用)
//根据IP从server获取
GlobalConfig.mcuListFromServer=[];//根据userIP从server获取的mcu列表
GlobalConfig.msListFromServer=[];//根据userIP从server获取的ms列表
... ... @@ -354,4 +393,8 @@ GlobalConfig.msListAll=[];//所有MS集合(sass+server)
GlobalConfig.isRecordPlayBack=false;//是否是录制回放,默认是否
GlobalConfig.allowRecordMaxTime=14400;//(秒)允许录制的最长时间,默认是4小时
GlobalConfig.siteId_letv='shchuanbao';//乐视,MS不需要动态选点的站点
export default GlobalConfig;
... ...
... ... @@ -20,34 +20,47 @@ class MediaModule {
//获取播流地址
getMediaPlayPath(_param) {
loger.log('getMediaPlayPath');
loger.log('获取播放地址->');
if (_param == null||_param.streamId == null)
{
loger.warn('getMediaPlayPath,参数错误', _param);
loger.warn('获取播放地址->参数错误', _param);
//this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return {"code": ApeConsts.RETURN_FAILED, "data": ""};
}
let path = "";
let port="";
let fileName='';
if (_param.type == "m3u8") {
//M3U8
//http://123.56.73.119:6001/live/h5dev_2106728010_8ab3b0ed5a3a9220015a3a958f0d0003_983041_1489113860/index.m3u8
port = (GlobalConfig.RSServerPort == "" || GlobalConfig.RSServerPort == null) ? "":":" + GlobalConfig.RSServerPort;
path = "http://" + GlobalConfig.RSServerIP
if(GlobalConfig.siteId==GlobalConfig.siteId_letv){
//乐视的hls地址规则
fileName='desc.m3u8';
}else {
fileName='index.m3u8';
}
port = (GlobalConfig.MS_PLAY_HLS_PORT == "" || GlobalConfig.MS_PLAY_HLS_PORT == null) ? "":":" + GlobalConfig.MS_PLAY_HLS_PORT;
path = "http://" + GlobalConfig.MS_PLAY_HLS_IP
+ port + "/live/"
+ _param.streamId
+ "/index.m3u8";
+ "/"+fileName;
} else {
port = (GlobalConfig.MSServerPort == "" || GlobalConfig.MSServerPort == null) ? "":":" + GlobalConfig.MSServerPort;
path = "rtmp://" + GlobalConfig.MSServerIP
//RTMP
port = (GlobalConfig.MS_PLAY_RTMP_PORT == "" || GlobalConfig.MS_PLAY_RTMP_PORT == null) ? "":":" + GlobalConfig.MS_PLAY_RTMP_PORT;
path = "rtmp://" + GlobalConfig.MS_PLAY_RTMP_IP
+ port + "/live/"
+ _param.streamId;
}
path=path.replace("::",":");//如果ip和port之间有多的:需要去掉
return {"code": ApeConsts.RETURN_SUCCESS, "data": "","playUrl": path};
}
//获取录制回放时点播的地址,只有m3u8
getMediaRecordPlaybackPath(_param) {
loger.log('getMediaRecordPlaybackPath');
... ... @@ -57,8 +70,8 @@ class MediaModule {
return {"code": ApeConsts.RETURN_FAILED, "data": ""};
}
//M3U8 http://123.56.73.119:6001/live/h5dev_2106728010_8ab3b0ed5a3a9220015a3a958f0d0003_983041_1489113860/total.m3u8
let port = (GlobalConfig.RSServerPort == "" || GlobalConfig.RSServerPort == null) ? "":":" + GlobalConfig.RSServerPort;
let path = "http://" + GlobalConfig.RSServerIP
let port = (GlobalConfig.RS_RECORD_PLAY_PORT == "" || GlobalConfig.RS_RECORD_PLAY_PORT == null) ? "":":" + GlobalConfig.RS_RECORD_PLAY_PORT;
let path = "http://" + GlobalConfig.RS_RECORD_PLAY_IP
+ port + "/live/"
+ _param.streamId
+ "/total.m3u8";
... ... @@ -84,7 +97,7 @@ class MediaModule {
}
//端口,有端口就显示 ":xxx",没有端口就是""
let port = (GlobalConfig.MSServerPort == "" || GlobalConfig.MSServerPort == null) ? "":":" + GlobalConfig.MSServerPort;
let port = (GlobalConfig.MS_PUBLISH_PORT == "" || GlobalConfig.MS_PUBLISH_PORT == null) ? "":":" + GlobalConfig.MS_PUBLISH_PORT;
//时间戳
let timestamp = EngineUtils.creatTimestamp();
... ... @@ -93,7 +106,7 @@ class MediaModule {
+"_" + freeChannel + "_" + timestamp;
//生成推流地址和推流数据(同步数据的时候用)
let publishUrl = "rtmp://" + GlobalConfig.MSServerIP
let publishUrl = "rtmp://" + GlobalConfig.MS_PUBLISH_IP
+ port + "/"+pubType+"/" +streamId;
publishUrl=publishUrl.replace("::",":");//如果ip和port之间有多的:需要去掉
... ...