正在显示
3 个修改的文件
包含
52 行增加
和
6 行删除
| @@ -330,6 +330,14 @@ export default class MessageEntrance extends Emiter { | @@ -330,6 +330,14 @@ export default class MessageEntrance extends Emiter { | ||
| 330 | GlobalConfig.MSServerPort = server.split(":")[1]; | 330 | GlobalConfig.MSServerPort = server.split(":")[1]; |
| 331 | } | 331 | } |
| 332 | 332 | ||
| 333 | + //m3u8播流地址 | ||
| 334 | + if(_data.rs){ | ||
| 335 | + //RS地址默认使用第一个 | ||
| 336 | + let server = _data.rs.split(";")[0]; | ||
| 337 | + GlobalConfig.RSServerIP = server.split(":")[0]; | ||
| 338 | + GlobalConfig.RSServerPort = server.split(":")[1]; | ||
| 339 | + } | ||
| 340 | + | ||
| 333 | GlobalConfig.docServer = _data.doc; | 341 | GlobalConfig.docServer = _data.doc; |
| 334 | GlobalConfig.h5_mcu_list = _data.h5_mcu_list; | 342 | GlobalConfig.h5_mcu_list = _data.h5_mcu_list; |
| 335 | GlobalConfig.h5Module = _data.h5Module; | 343 | GlobalConfig.h5Module = _data.h5Module; |
| @@ -346,7 +354,7 @@ export default class MessageEntrance extends Emiter { | @@ -346,7 +354,7 @@ export default class MessageEntrance extends Emiter { | ||
| 346 | } | 354 | } |
| 347 | } | 355 | } |
| 348 | 356 | ||
| 349 | - //获取会议所有参数 getClassH5 | 357 | + //获取会议基本信息getClassH5 |
| 350 | _sassGetClassDetailSuccessHandler(_data) { | 358 | _sassGetClassDetailSuccessHandler(_data) { |
| 351 | loger.log('获取getClassDetail完成.'); | 359 | loger.log('获取getClassDetail完成.'); |
| 352 | /* { | 360 | /* { |
| @@ -257,6 +257,10 @@ GlobalConfig.MCUServerPort=9003; | @@ -257,6 +257,10 @@ GlobalConfig.MCUServerPort=9003; | ||
| 257 | GlobalConfig.MSServerIP = "";//推流 播流的地址 | 257 | GlobalConfig.MSServerIP = "";//推流 播流的地址 |
| 258 | GlobalConfig.MSServerPort =""; | 258 | GlobalConfig.MSServerPort =""; |
| 259 | 259 | ||
| 260 | +//m3u8播流地址 | ||
| 261 | +GlobalConfig.RSServerIP =""; | ||
| 262 | +GlobalConfig.RSServerPort =""; | ||
| 263 | + | ||
| 260 | GlobalConfig.maxVideoChannels=0; | 264 | GlobalConfig.maxVideoChannels=0; |
| 261 | GlobalConfig.maxAudioChannels=0; | 265 | GlobalConfig.maxAudioChannels=0; |
| 262 | GlobalConfig.maxMediaChannels=0; | 266 | GlobalConfig.maxMediaChannels=0; |
| @@ -59,7 +59,7 @@ class VideoChat extends Ape { | @@ -59,7 +59,7 @@ class VideoChat extends Ape { | ||
| 59 | if (_param.type == "m3u8") { | 59 | if (_param.type == "m3u8") { |
| 60 | //M3U8 默认用80端口 | 60 | //M3U8 默认用80端口 |
| 61 | //http://123.56.73.119/hls/h5dev_403074980_0_983042_1487641745/index.m3u8 | 61 | //http://123.56.73.119/hls/h5dev_403074980_0_983042_1487641745/index.m3u8 |
| 62 | - path = "http://" + GlobalConfig.MSServerIP | 62 | + path = "http://" + GlobalConfig.RSServerIP |
| 63 | +"/hls/" + _param.siteId | 63 | +"/hls/" + _param.siteId |
| 64 | + "_" + _param.classId | 64 | + "_" + _param.classId |
| 65 | + "_" + _param.userId | 65 | + "_" + _param.userId |
| @@ -95,12 +95,21 @@ class VideoChat extends Ape { | @@ -95,12 +95,21 @@ class VideoChat extends Ape { | ||
| 95 | 95 | ||
| 96 | let port = (GlobalConfig.MSServerPort == "" || GlobalConfig.MSServerPort == null) ? "" : ":" + GlobalConfig.MSServerPort; | 96 | let port = (GlobalConfig.MSServerPort == "" || GlobalConfig.MSServerPort == null) ? "" : ":" + GlobalConfig.MSServerPort; |
| 97 | let timestamp = EngineUtils.creatTimestamp(); | 97 | let timestamp = EngineUtils.creatTimestamp(); |
| 98 | - let publishUrl = "rtmp://" + GlobalConfig.MSServerIP + port + "/live/" +GlobalConfig.siteId+"_"+ GlobalConfig.classId + "_"+GlobalConfig.userId+"_" + freeChannel + "_" + timestamp; | 98 | + let publishUrl = "rtmp://" + GlobalConfig.MSServerIP + port + "/flash/" +GlobalConfig.siteId+"_"+ GlobalConfig.classId + "_"+GlobalConfig.userId+"_" + freeChannel + "_" + timestamp; |
| 99 | return {"code": 0, "data": {"siteId":GlobalConfig.siteId,"classId":GlobalConfig.classId,"userId":GlobalConfig.userId,"channelId": freeChannel, "timestamp": timestamp, "publishUrl": publishUrl}}; | 99 | return {"code": 0, "data": {"siteId":GlobalConfig.siteId,"classId":GlobalConfig.classId,"userId":GlobalConfig.userId,"channelId": freeChannel, "timestamp": timestamp, "publishUrl": publishUrl}}; |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | //推流 | 102 | //推流 |
| 103 | publishVideo(_param) { | 103 | publishVideo(_param) { |
| 104 | + if (_param == null||_param.channelId == null|| | ||
| 105 | + _param.classId == null||_param.userId == null|| | ||
| 106 | + _param.siteId == null|| _param.timestamp==null) | ||
| 107 | + { | ||
| 108 | + loger.warn('publishVideo,参数错误', _param); | ||
| 109 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 110 | + return {"code": 1, "data": ""}; | ||
| 111 | + } | ||
| 112 | + | ||
| 104 | loger.log('publishVideo -> maxVideoChannels', GlobalConfig.maxVideoChannels); | 113 | loger.log('publishVideo -> maxVideoChannels', GlobalConfig.maxVideoChannels); |
| 105 | 114 | ||
| 106 | //同一个nodeId只允许推一个流,如果已经推了就不能再推 | 115 | //同一个nodeId只允许推一个流,如果已经推了就不能再推 |
| @@ -109,20 +118,30 @@ class VideoChat extends Ape { | @@ -109,20 +118,30 @@ class VideoChat extends Ape { | ||
| 109 | return; | 118 | return; |
| 110 | } | 119 | } |
| 111 | 120 | ||
| 121 | + //判断当前是否还有空闲的channle | ||
| 112 | let freeChannel = this.getFreeVideoChannel(); | 122 | let freeChannel = this.getFreeVideoChannel(); |
| 113 | if (freeChannel == 0) { | 123 | if (freeChannel == 0) { |
| 114 | loger.warn("publishVideo,没有空闲的channel "); | 124 | loger.warn("publishVideo,没有空闲的channel "); |
| 115 | return {"code": 1, "data": "不能再打开更多的设备"}; | 125 | return {"code": 1, "data": "不能再打开更多的设备"}; |
| 116 | } | 126 | } |
| 127 | + | ||
| 128 | + //判断当前的频道是否已经占用 | ||
| 129 | + if(this.checkChannelIsOpening(_param.channelId)){ | ||
| 130 | + loger.warn(_param.channelId,"频道已经被占用"); | ||
| 131 | + return {"code":1,"data":"频道已经被占用!"}; | ||
| 132 | + } | ||
| 133 | + | ||
| 117 | let channelInfo={}; | 134 | let channelInfo={}; |
| 118 | channelInfo.status=ApeConsts.CHANNEL_STATUS_OPENING; | 135 | channelInfo.status=ApeConsts.CHANNEL_STATUS_OPENING; |
| 119 | channelInfo.fromNodeId=GlobalConfig.nodeId; | 136 | channelInfo.fromNodeId=GlobalConfig.nodeId; |
| 120 | - channelInfo.channelId=freeChannel; | ||
| 121 | - channelInfo.timestamp=EngineUtils.creatTimestamp(); | ||
| 122 | - channelInfo.classId=GlobalConfig.classId; | 137 | + channelInfo.channelId=_param.channelId;//freeChannel |
| 138 | + channelInfo.timestamp=_param.timestamp;//EngineUtils.creatTimestamp(); | ||
| 139 | + channelInfo.classId=_param.classId;//GlobalConfig.classId; | ||
| 140 | + channelInfo.siteId=_param.siteId;//GlobalConfig.siteId; | ||
| 123 | channelInfo.toNodeId=0; | 141 | channelInfo.toNodeId=0; |
| 124 | channelInfo.mediaType=ApeConsts.MEDIA_TYPE_VIDEO; | 142 | channelInfo.mediaType=ApeConsts.MEDIA_TYPE_VIDEO; |
| 125 | this.sendTableUpdateHandler(channelInfo); | 143 | this.sendTableUpdateHandler(channelInfo); |
| 144 | + return {"code":0,"data":"推流成功!"} | ||
| 126 | } | 145 | } |
| 127 | 146 | ||
| 128 | //停止推流, | 147 | //停止推流, |
| @@ -330,6 +349,7 @@ class VideoChat extends Ape { | @@ -330,6 +349,7 @@ class VideoChat extends Ape { | ||
| 330 | let packPduModel = new pdu['RCVideoChannelInfoPdu']; | 349 | let packPduModel = new pdu['RCVideoChannelInfoPdu']; |
| 331 | packPduModel.status = _param.status||ApeConsts.CHANNEL_STATUS_RELEASED; | 350 | packPduModel.status = _param.status||ApeConsts.CHANNEL_STATUS_RELEASED; |
| 332 | packPduModel.channelId = _itemIdx; | 351 | packPduModel.channelId = _itemIdx; |
| 352 | + packPduModel.siteId=_param.siteId||GlobalConfig.siteId;//GlobalConfig.siteId; | ||
| 333 | packPduModel.classId =parseInt(_param.classId)||parseInt(GlobalConfig.classId); | 353 | packPduModel.classId =parseInt(_param.classId)||parseInt(GlobalConfig.classId); |
| 334 | packPduModel.mediaType =_param.mediaType|| ApeConsts.MEDIA_TYPE_VIDEO; | 354 | packPduModel.mediaType =_param.mediaType|| ApeConsts.MEDIA_TYPE_VIDEO; |
| 335 | packPduModel.timestamp =_param.timestamp||EngineUtils.creatTimestamp(); | 355 | packPduModel.timestamp =_param.timestamp||EngineUtils.creatTimestamp(); |
| @@ -387,6 +407,20 @@ class VideoChat extends Ape { | @@ -387,6 +407,20 @@ class VideoChat extends Ape { | ||
| 387 | } | 407 | } |
| 388 | return 0; | 408 | return 0; |
| 389 | } | 409 | } |
| 410 | + | ||
| 411 | + //检查频道是否已经被占用 | ||
| 412 | + checkChannelIsOpening(_channelId){ | ||
| 413 | + if(_channelId==null){ | ||
| 414 | + loger.warn("checkChannelIsOpening error,channel=",_channelId); | ||
| 415 | + return true; | ||
| 416 | + } | ||
| 417 | + | ||
| 418 | + let channelInfo=this.videoChannels[_channelId]; | ||
| 419 | + if(channelInfo==null||channelInfo.status==ApeConsts.CHANNEL_STATUS_RELEASED){ | ||
| 420 | + return false; | ||
| 421 | + } | ||
| 422 | + return true; | ||
| 423 | + } | ||
| 390 | } | 424 | } |
| 391 | 425 | ||
| 392 | export default VideoChat; | 426 | export default VideoChat; |
-
请 注册 或 登录 后发表评论