正在显示
7 个修改的文件
包含
50 行增加
和
45 行删除
| @@ -62,7 +62,7 @@ export default class MessageEntrance extends Emiter { | @@ -62,7 +62,7 @@ export default class MessageEntrance extends Emiter { | ||
| 62 | constructor() { | 62 | constructor() { |
| 63 | super(); | 63 | super(); |
| 64 | //sdk 信息 | 64 | //sdk 信息 |
| 65 | - GlobalConfig.sdkVersion = "v2.8.8.20170917"; | 65 | + GlobalConfig.sdkVersion = "v2.8.17.20170918"; |
| 66 | loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); | 66 | loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); |
| 67 | 67 | ||
| 68 | //设置 | 68 | //设置 |
| @@ -1103,6 +1103,7 @@ export default class MessageEntrance extends Emiter { | @@ -1103,6 +1103,7 @@ export default class MessageEntrance extends Emiter { | ||
| 1103 | GlobalConfig.channelId = ""+GlobalConfig.siteId+"_"+GlobalConfig.classId; | 1103 | GlobalConfig.channelId = ""+GlobalConfig.siteId+"_"+GlobalConfig.classId; |
| 1104 | GlobalConfig.userUid = GlobalConfig.nodeId; | 1104 | GlobalConfig.userUid = GlobalConfig.nodeId; |
| 1105 | GlobalConfig.channelKey=""; | 1105 | GlobalConfig.channelKey=""; |
| 1106 | + GlobalConfig.rosters={};//情况人员数据列表 | ||
| 1106 | 1107 | ||
| 1107 | //判断是否需要获取加入音视频通话频道的channelKey | 1108 | //判断是否需要获取加入音视频通话频道的channelKey |
| 1108 | if(GlobalConfig.appCertificate){ | 1109 | if(GlobalConfig.appCertificate){ |
| @@ -1985,6 +1986,10 @@ export default class MessageEntrance extends Emiter { | @@ -1985,6 +1986,10 @@ export default class MessageEntrance extends Emiter { | ||
| 1985 | } | 1986 | } |
| 1986 | //webRtc推流状态发生改变 | 1987 | //webRtc推流状态发生改变 |
| 1987 | mediaPublishStatusChange(_data){ | 1988 | mediaPublishStatusChange(_data){ |
| 1989 | + if (!_mcu.connected) { | ||
| 1990 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1991 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1992 | + } | ||
| 1988 | if (_video_ape) { | 1993 | if (_video_ape) { |
| 1989 | _video_ape.mediaPublishStatusChange(_data); | 1994 | _video_ape.mediaPublishStatusChange(_data); |
| 1990 | } | 1995 | } |
| @@ -2832,7 +2837,7 @@ export default class MessageEntrance extends Emiter { | @@ -2832,7 +2837,7 @@ export default class MessageEntrance extends Emiter { | ||
| 2832 | openCamera: GlobalConfig.openCamera, | 2837 | openCamera: GlobalConfig.openCamera, |
| 2833 | openMicrophones: GlobalConfig.openMicrophones | 2838 | openMicrophones: GlobalConfig.openMicrophones |
| 2834 | }); | 2839 | }); |
| 2835 | - this._mediaRecordControl({"status":1}); | 2840 | + this._mediaRecordControl({"status":WebRtcApe.RECORD_STATUS_1}); |
| 2836 | return ; | 2841 | return ; |
| 2837 | } | 2842 | } |
| 2838 | 2843 | ||
| @@ -2858,11 +2863,12 @@ export default class MessageEntrance extends Emiter { | @@ -2858,11 +2863,12 @@ export default class MessageEntrance extends Emiter { | ||
| 2858 | openCamera: GlobalConfig.openCamera, | 2863 | openCamera: GlobalConfig.openCamera, |
| 2859 | openMicrophones: GlobalConfig.openMicrophones | 2864 | openMicrophones: GlobalConfig.openMicrophones |
| 2860 | }); | 2865 | }); |
| 2861 | - this._mediaRecordControl({"status":0}); | 2866 | + this._mediaRecordControl({"status":WebRtcApe.RECORD_STATUS_0}); |
| 2862 | return ; | 2867 | return ; |
| 2863 | } | 2868 | } |
| 2864 | 2869 | ||
| 2865 | if(_webRtc){ | 2870 | if(_webRtc){ |
| 2871 | + this._mediaRecordControl({"status":WebRtcApe.RECORD_STATUS_0}); | ||
| 2866 | _webRtc.unpublish(_params); | 2872 | _webRtc.unpublish(_params); |
| 2867 | } | 2873 | } |
| 2868 | } | 2874 | } |
| @@ -396,6 +396,10 @@ export default class Ape extends Emiter { | @@ -396,6 +396,10 @@ export default class Ape extends Emiter { | ||
| 396 | this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_SEND_FAILED_NO_JOIN); | 396 | this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_SEND_FAILED_NO_JOIN); |
| 397 | return; | 397 | return; |
| 398 | } | 398 | } |
| 399 | + if(!this._classInfo){ | ||
| 400 | + loger.warn("课堂数据还未获取,不能发送消息"); | ||
| 401 | + return; | ||
| 402 | + } | ||
| 399 | let uniformPdu = pdu.create_uniform_pdu( | 403 | let uniformPdu = pdu.create_uniform_pdu( |
| 400 | appPdu.type, | 404 | appPdu.type, |
| 401 | this._classInfo.nodeId, | 405 | this._classInfo.nodeId, |
| @@ -424,8 +424,8 @@ class DocApe extends Ape { | @@ -424,8 +424,8 @@ class DocApe extends Ape { | ||
| 424 | //console.log(docDataModelPdu); | 424 | //console.log(docDataModelPdu); |
| 425 | //console.log(docDataModel); | 425 | //console.log(docDataModel); |
| 426 | if (docDataModel == null) { | 426 | if (docDataModel == null) { |
| 427 | - loger.log('文档翻页->文档不存在', paramInfo); | ||
| 428 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | 427 | + loger.warn('文档翻页->文档不存在', paramInfo); |
| 428 | + //this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 429 | return; | 429 | return; |
| 430 | } | 430 | } |
| 431 | //更新数据的字段 | 431 | //更新数据的字段 |
| @@ -317,8 +317,8 @@ class MediaSharedApe extends Ape { | @@ -317,8 +317,8 @@ class MediaSharedApe extends Ape { | ||
| 317 | //获取已经存在的数据 | 317 | //获取已经存在的数据 |
| 318 | let pduDataModel = this.mediaSharedList[paramInfo.itemIdx]; | 318 | let pduDataModel = this.mediaSharedList[paramInfo.itemIdx]; |
| 319 | if (pduDataModel == null) { | 319 | if (pduDataModel == null) { |
| 320 | - loger.log('媒体文件SEEK->媒体文件不存在', paramInfo); | ||
| 321 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | 320 | + loger.warn('媒体文件SEEK->媒体文件不存在', paramInfo); |
| 321 | + //this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 322 | return; | 322 | return; |
| 323 | } | 323 | } |
| 324 | //更新数据的字段 | 324 | //更新数据的字段 |
| @@ -320,8 +320,8 @@ class MusicSharedApe extends Ape { | @@ -320,8 +320,8 @@ class MusicSharedApe extends Ape { | ||
| 320 | //获取已经存在的数据 | 320 | //获取已经存在的数据 |
| 321 | let pduDataModel = this.musicSharedList[paramInfo.itemIdx]; | 321 | let pduDataModel = this.musicSharedList[paramInfo.itemIdx]; |
| 322 | if (pduDataModel == null) { | 322 | if (pduDataModel == null) { |
| 323 | - loger.log('伴音文件SEEK->伴音文件不存在', paramInfo); | ||
| 324 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | 323 | + loger.warn('伴音文件SEEK->伴音文件不存在', paramInfo); |
| 324 | + //this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 325 | return; | 325 | return; |
| 326 | } | 326 | } |
| 327 | //更新数据的字段 | 327 | //更新数据的字段 |
| @@ -370,7 +370,10 @@ class VideoApe extends Ape { | @@ -370,7 +370,10 @@ class VideoApe extends Ape { | ||
| 370 | loger.warn(GlobalConfig.getCurrentStatus()); | 370 | loger.warn(GlobalConfig.getCurrentStatus()); |
| 371 | return {"code": ApeConsts.RETURN_FAILED, "data": "已经断开连接"}; | 371 | return {"code": ApeConsts.RETURN_FAILED, "data": "已经断开连接"}; |
| 372 | } | 372 | } |
| 373 | - | 373 | + if (this._classInfo ==null||EngineUtils.isEmptyObject(this._classInfo)){ |
| 374 | + //还未加入频道成功,暂时不能发送消息 | ||
| 375 | + return; | ||
| 376 | + } | ||
| 374 | /* if (this._classInfo ===null || EngineUtils.isEmptyObject(this._classInfo)) { | 377 | /* if (this._classInfo ===null || EngineUtils.isEmptyObject(this._classInfo)) { |
| 375 | loger.log('不能发送Video消息.McuClient还未初始化数据!'); | 378 | loger.log('不能发送Video消息.McuClient还未初始化数据!'); |
| 376 | if (GlobalConfig.getCurrentStatus().code == 0 || GlobalConfig.getCurrentStatus().code == 1) { | 379 | if (GlobalConfig.getCurrentStatus().code == 0 || GlobalConfig.getCurrentStatus().code == 1) { |
| @@ -113,7 +113,21 @@ class WebRtcApe extends Emiter { | @@ -113,7 +113,21 @@ class WebRtcApe extends Emiter { | ||
| 113 | }); | 113 | }); |
| 114 | } | 114 | } |
| 115 | }); | 115 | }); |
| 116 | - | 116 | + this.client.on('stream-published', (evt)=> { |
| 117 | + loger.log("webRtc->推流成功->",new Date().getTime()); | ||
| 118 | + this.isPublish=true; | ||
| 119 | + GlobalConfig.openCamera = EngineUtils.creatTimestamp(); | ||
| 120 | + GlobalConfig.openMicrophones = GlobalConfig.openCamera; | ||
| 121 | + this._emit(MessageTypes.USER_DEVICE_STATUS_CHAANGE, { | ||
| 122 | + nodeId: GlobalConfig.nodeId, | ||
| 123 | + userRole: GlobalConfig.userRole, | ||
| 124 | + userName: GlobalConfig.userName, | ||
| 125 | + userId: GlobalConfig.userId, | ||
| 126 | + openCamera: GlobalConfig.openCamera, | ||
| 127 | + openMicrophones: GlobalConfig.openMicrophones | ||
| 128 | + }); | ||
| 129 | + this.changePublishStatusAndServerRecord(WebRtcApe.RECORD_STATUS_1); | ||
| 130 | + }); | ||
| 117 | this.client.on('stream-added', (evt)=> { | 131 | this.client.on('stream-added', (evt)=> { |
| 118 | let stream = evt.stream; | 132 | let stream = evt.stream; |
| 119 | /* loger.log("添加一个远程视频流: " + stream.getId(),new Date().getTime()); | 133 | /* loger.log("添加一个远程视频流: " + stream.getId(),new Date().getTime()); |
| @@ -122,7 +136,6 @@ class WebRtcApe extends Emiter { | @@ -122,7 +136,6 @@ class WebRtcApe extends Emiter { | ||
| 122 | });*/ | 136 | });*/ |
| 123 | this.reAddRemoteStream(stream); | 137 | this.reAddRemoteStream(stream); |
| 124 | }); | 138 | }); |
| 125 | - | ||
| 126 | this.client.on('stream-subscribed', (evt)=> { | 139 | this.client.on('stream-subscribed', (evt)=> { |
| 127 | let stream = evt.stream; | 140 | let stream = evt.stream; |
| 128 | if(stream){ | 141 | if(stream){ |
| @@ -181,6 +194,7 @@ class WebRtcApe extends Emiter { | @@ -181,6 +194,7 @@ class WebRtcApe extends Emiter { | ||
| 181 | let uid = evt.uid; | 194 | let uid = evt.uid; |
| 182 | loger.log("当前正在讲话的uid:" + uid); | 195 | loger.log("当前正在讲话的uid:" + uid); |
| 183 | }); | 196 | }); |
| 197 | + | ||
| 184 | } | 198 | } |
| 185 | //重新添加远程视频 | 199 | //重新添加远程视频 |
| 186 | reAddRemoteStream(_stream){ | 200 | reAddRemoteStream(_stream){ |
| @@ -194,7 +208,6 @@ class WebRtcApe extends Emiter { | @@ -194,7 +208,6 @@ class WebRtcApe extends Emiter { | ||
| 194 | } | 208 | } |
| 195 | loger.log("添加一个远程视频流: " + _stream.getId(),new Date().getTime()); | 209 | loger.log("添加一个远程视频流: " + _stream.getId(),new Date().getTime()); |
| 196 | this.client.subscribe(_stream, (err)=> { | 210 | this.client.subscribe(_stream, (err)=> { |
| 197 | - loger.warn("添加一个远程视频流->失败", err); | ||
| 198 | //clearTimeout(this.reAddRemoteStreamDelay); | 211 | //clearTimeout(this.reAddRemoteStreamDelay); |
| 199 | if(err=="INVALID_REMOTE_STREAM"){ | 212 | if(err=="INVALID_REMOTE_STREAM"){ |
| 200 | //流已经无效,不需要再重连 | 213 | //流已经无效,不需要再重连 |
| @@ -204,11 +217,11 @@ class WebRtcApe extends Emiter { | @@ -204,11 +217,11 @@ class WebRtcApe extends Emiter { | ||
| 204 | if(err=="PEERCONNECTION_FAILED"){ | 217 | if(err=="PEERCONNECTION_FAILED"){ |
| 205 | //this.reAddRemoteStreamDelay=setTimeout(()=>{ | 218 | //this.reAddRemoteStreamDelay=setTimeout(()=>{ |
| 206 | setTimeout(()=>{ | 219 | setTimeout(()=>{ |
| 207 | - loger.warn("连接远程的流失败->尝试重新连接"); | 220 | + loger.warn("连接远程的流失败->尝试重新连接",err); |
| 208 | this.reAddRemoteStream(_stream); | 221 | this.reAddRemoteStream(_stream); |
| 209 | },1400); | 222 | },1400); |
| 210 | - } | ||
| 211 | - | 223 | + }else { |
| 224 | + loger.warn("添加一个远程视频流->失败", err); } | ||
| 212 | }); | 225 | }); |
| 213 | } | 226 | } |
| 214 | 227 | ||
| @@ -233,6 +246,7 @@ class WebRtcApe extends Emiter { | @@ -233,6 +246,7 @@ class WebRtcApe extends Emiter { | ||
| 233 | reGetLoaclStream(){ | 246 | reGetLoaclStream(){ |
| 234 | if(this.isPublish){ | 247 | if(this.isPublish){ |
| 235 | loger.log("重新获取摄像头和麦克风并重新推流"); | 248 | loger.log("重新获取摄像头和麦克风并重新推流"); |
| 249 | + //this.changePublishStatusAndServerRecord(WebRtcApe.RECORD_STATUS_0); | ||
| 236 | this.unpublish(); | 250 | this.unpublish(); |
| 237 | this.openLoaclStream(); | 251 | this.openLoaclStream(); |
| 238 | //切换设备后自动重推流 | 252 | //切换设备后自动重推流 |
| @@ -325,27 +339,14 @@ class WebRtcApe extends Emiter { | @@ -325,27 +339,14 @@ class WebRtcApe extends Emiter { | ||
| 325 | this.isPublish=false; | 339 | this.isPublish=false; |
| 326 | this.unpublish(); | 340 | this.unpublish(); |
| 327 | }); | 341 | }); |
| 328 | - this.client.on('stream-published', (evt)=> { | ||
| 329 | - loger.log("webRtc->推流成功->",new Date().getTime()); | ||
| 330 | - this.isPublish=true; | ||
| 331 | - GlobalConfig.openCamera = EngineUtils.creatTimestamp(); | ||
| 332 | - GlobalConfig.openMicrophones = GlobalConfig.openCamera; | ||
| 333 | - this._emit(MessageTypes.USER_DEVICE_STATUS_CHAANGE, { | ||
| 334 | - nodeId: GlobalConfig.nodeId, | ||
| 335 | - userRole: GlobalConfig.userRole, | ||
| 336 | - userName: GlobalConfig.userName, | ||
| 337 | - userId: GlobalConfig.userId, | ||
| 338 | - openCamera: GlobalConfig.openCamera, | ||
| 339 | - openMicrophones: GlobalConfig.openMicrophones | ||
| 340 | - }); | ||
| 341 | - this.changePublishStatusAndServerRecord(WebRtcApe.RECORD_STATUS_1); | ||
| 342 | - }); | ||
| 343 | - | ||
| 344 | }, (err)=> { | 342 | }, (err)=> { |
| 345 | loger.warn("webRtc->推流->本地流开启失败", err); | 343 | loger.warn("webRtc->推流->本地流开启失败", err); |
| 346 | this.isPublish=false; | 344 | this.isPublish=false; |
| 347 | this.clearLocalView(); | 345 | this.clearLocalView(); |
| 348 | this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED,err); | 346 | this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED,err); |
| 347 | + if(err&&err.msg=="STREAM_ALREADY_INITIALIZED"){ | ||
| 348 | + this.unpublish(); | ||
| 349 | + } | ||
| 349 | }); | 350 | }); |
| 350 | } | 351 | } |
| 351 | 352 | ||
| @@ -371,7 +372,6 @@ class WebRtcApe extends Emiter { | @@ -371,7 +372,6 @@ class WebRtcApe extends Emiter { | ||
| 371 | openCamera: GlobalConfig.openCamera, | 372 | openCamera: GlobalConfig.openCamera, |
| 372 | openMicrophones: GlobalConfig.openMicrophones | 373 | openMicrophones: GlobalConfig.openMicrophones |
| 373 | }); | 374 | }); |
| 374 | - this.changePublishStatusAndServerRecord(WebRtcApe.RECORD_STATUS_0); | ||
| 375 | } | 375 | } |
| 376 | //清除本地视图 | 376 | //清除本地视图 |
| 377 | clearLocalView(){ | 377 | clearLocalView(){ |
| @@ -459,6 +459,7 @@ class WebRtcApe extends Emiter { | @@ -459,6 +459,7 @@ class WebRtcApe extends Emiter { | ||
| 459 | 459 | ||
| 460 | clearTimeout(this.changeDevicesDelay); | 460 | clearTimeout(this.changeDevicesDelay); |
| 461 | this.changeDevicesDelay=setTimeout(()=>{ | 461 | this.changeDevicesDelay=setTimeout(()=>{ |
| 462 | + this.changePublishStatusAndServerRecord(WebRtcApe.RECORD_STATUS_0); | ||
| 462 | //重新获取本地视图流 | 463 | //重新获取本地视图流 |
| 463 | this.reGetLoaclStream(); | 464 | this.reGetLoaclStream(); |
| 464 | },1400); | 465 | },1400); |
| @@ -508,16 +509,7 @@ class WebRtcApe extends Emiter { | @@ -508,16 +509,7 @@ class WebRtcApe extends Emiter { | ||
| 508 | //组织数据,发送给服务器,控制录制和开启录制-推流和停止推流 status:0 停止推流 1:开始推流(同时开启录制),2:停止录制(同时停止推流) | 509 | //组织数据,发送给服务器,控制录制和开启录制-推流和停止推流 status:0 停止推流 1:开始推流(同时开启录制),2:停止录制(同时停止推流) |
| 509 | packMediaInfoData(_status){ | 510 | packMediaInfoData(_status){ |
| 510 | let curTimestamp= new Date().getTime(); | 511 | let curTimestamp= new Date().getTime(); |
| 511 | - let data=`appId=${GlobalConfig.appId} | ||
| 512 | - &channel=${GlobalConfig.channelId} | ||
| 513 | - &channelKey=${GlobalConfig.appCertificate} | ||
| 514 | - &uid=${GlobalConfig.userUid} | ||
| 515 | - &status=${_status} | ||
| 516 | - &userId=${GlobalConfig.userId} | ||
| 517 | - &userName=${GlobalConfig.userName} | ||
| 518 | - &userRole=${GlobalConfig.userRole} | ||
| 519 | - ×tamp=${curTimestamp} | ||
| 520 | - &recordTimestamp=${GlobalConfig.recordTimestamp}`; | 512 | + let data=`appId=${GlobalConfig.appId}&channel=${GlobalConfig.channelId}&channelKey=${GlobalConfig.appCertificate}&uid=${GlobalConfig.userUid}&status=${_status}&userId=${GlobalConfig.userId}&userName=${GlobalConfig.userName}&userRole=${GlobalConfig.userRole}×tamp=${curTimestamp}&recordTimestamp=${GlobalConfig.recordTimestamp}`; |
| 521 | 513 | ||
| 522 | //mcu记录一份数据 | 514 | //mcu记录一份数据 |
| 523 | this._emit(MessageTypes.MEDIA_PUBLISH_STATUS_CHANGE, { | 515 | this._emit(MessageTypes.MEDIA_PUBLISH_STATUS_CHANGE, { |
| @@ -611,8 +603,8 @@ class WebRtcApe extends Emiter { | @@ -611,8 +603,8 @@ class WebRtcApe extends Emiter { | ||
| 611 | } | 603 | } |
| 612 | } | 604 | } |
| 613 | WebRtcApe.prototype.RECORD_STATUS_0 = WebRtcApe.RECORD_STATUS_0 =0; //停止推流 | 605 | WebRtcApe.prototype.RECORD_STATUS_0 = WebRtcApe.RECORD_STATUS_0 =0; //停止推流 |
| 614 | -WebRtcApe.prototype.RECORD_STATUS_1 = WebRtcApe.RECORD_STATUS_1 =0; //开始推流 | ||
| 615 | -WebRtcApe.prototype.RECORD_STATUS_2 = WebRtcApe.RECORD_STATUS_2 =0; //停止录制 | 606 | +WebRtcApe.prototype.RECORD_STATUS_1 = WebRtcApe.RECORD_STATUS_1 =1; //开始推流 |
| 607 | +WebRtcApe.prototype.RECORD_STATUS_2 = WebRtcApe.RECORD_STATUS_2 =2; //停止录制 | ||
| 616 | export default new WebRtcApe; | 608 | export default new WebRtcApe; |
| 617 | 609 | ||
| 618 | 610 |
-
请 注册 或 登录 后发表评论