1.修复音视频频道占用的问题;2.修复音视频禁用状态切换显示问题;3.修改nodeId的生成规则
正在显示
11 个修改的文件
包含
151 行增加
和
57 行删除
| @@ -63,7 +63,7 @@ export default class MessageEntrance extends Emiter { | @@ -63,7 +63,7 @@ export default class MessageEntrance extends Emiter { | ||
| 63 | super(); | 63 | super(); |
| 64 | this.lastClassActiveTime=0;//最后一次课堂激活的时间戳 | 64 | this.lastClassActiveTime=0;//最后一次课堂激活的时间戳 |
| 65 | //sdk 信息 | 65 | //sdk 信息 |
| 66 | - GlobalConfig.sdkVersion = "v2.34.16.20171128"; | 66 | + GlobalConfig.sdkVersion = "v2.35.11.20171130"; |
| 67 | loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); | 67 | loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); |
| 68 | console.log("sdkVersion:" + GlobalConfig.sdkVersion); | 68 | console.log("sdkVersion:" + GlobalConfig.sdkVersion); |
| 69 | //设置 | 69 | //设置 |
| @@ -607,6 +607,9 @@ export default class MessageEntrance extends Emiter { | @@ -607,6 +607,9 @@ export default class MessageEntrance extends Emiter { | ||
| 607 | this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_CLASS_INIT_PARAM); | 607 | this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_CLASS_INIT_PARAM); |
| 608 | return; | 608 | return; |
| 609 | } | 609 | } |
| 610 | + //添加日志捕获 | ||
| 611 | + LogManager.catchConsole(); | ||
| 612 | + | ||
| 610 | loger.warn('=====================STEP1======================='); | 613 | loger.warn('=====================STEP1======================='); |
| 611 | loger.log('初始化课堂->', _param); | 614 | loger.log('初始化课堂->', _param); |
| 612 | //保存参数 | 615 | //保存参数 |
| @@ -1297,7 +1300,7 @@ export default class MessageEntrance extends Emiter { | @@ -1297,7 +1300,7 @@ export default class MessageEntrance extends Emiter { | ||
| 1297 | LogManager.userName = GlobalConfig.userName;//用户名称 | 1300 | LogManager.userName = GlobalConfig.userName;//用户名称 |
| 1298 | LogManager.logUrl = GlobalConfig.logUrl;//日志服务器地址 //http://log.3mang.com | 1301 | LogManager.logUrl = GlobalConfig.logUrl;//日志服务器地址 //http://log.3mang.com |
| 1299 | LogManager.platform = GlobalConfig.platform; | 1302 | LogManager.platform = GlobalConfig.platform; |
| 1300 | - loger.log('加入课堂成功->'); | 1303 | + loger.log('加入课堂成功->classType:'+GlobalConfig.classType); |
| 1301 | loger.log(joinClassSuccessCallBackData); | 1304 | loger.log(joinClassSuccessCallBackData); |
| 1302 | 1305 | ||
| 1303 | //加入课堂成功,广播消息 | 1306 | //加入课堂成功,广播消息 |
| @@ -1325,7 +1328,8 @@ export default class MessageEntrance extends Emiter { | @@ -1325,7 +1328,8 @@ export default class MessageEntrance extends Emiter { | ||
| 1325 | channelId: GlobalConfig.channelId, | 1328 | channelId: GlobalConfig.channelId, |
| 1326 | channelKey: GlobalConfig.channelKey, | 1329 | channelKey: GlobalConfig.channelKey, |
| 1327 | uid: GlobalConfig.userUid, | 1330 | uid: GlobalConfig.userUid, |
| 1328 | - info: "" + GlobalConfig.userRole | 1331 | + info: "" + GlobalConfig.userRole, |
| 1332 | + immediatePublish:false | ||
| 1329 | }); | 1333 | }); |
| 1330 | }, 1600); | 1334 | }, 1600); |
| 1331 | } | 1335 | } |
| @@ -3147,6 +3151,9 @@ export default class MessageEntrance extends Emiter { | @@ -3147,6 +3151,9 @@ export default class MessageEntrance extends Emiter { | ||
| 3147 | let m3u8Stream = _video_ape.getPlayVideoPath({"type": "m3u8", "streamId": streamId}); | 3151 | let m3u8Stream = _video_ape.getPlayVideoPath({"type": "m3u8", "streamId": streamId}); |
| 3148 | let rtmpStream = _video_ape.getPlayVideoPath({"type": "rtmp", "streamId": streamId}); | 3152 | let rtmpStream = _video_ape.getPlayVideoPath({"type": "rtmp", "streamId": streamId}); |
| 3149 | _webRtc.setRtmpM3u8Path({m3u8Url: m3u8Stream.playUrl, rtmpUrl: rtmpStream.playUrl}); | 3153 | _webRtc.setRtmpM3u8Path({m3u8Url: m3u8Stream.playUrl, rtmpUrl: rtmpStream.playUrl}); |
| 3154 | + }else { | ||
| 3155 | + //获取频道失败,不能自动推流 | ||
| 3156 | + isPublish=false; | ||
| 3150 | } | 3157 | } |
| 3151 | } | 3158 | } |
| 3152 | clearTimeout(this.joinChannelTimer); | 3159 | clearTimeout(this.joinChannelTimer); |
| @@ -3159,7 +3166,7 @@ export default class MessageEntrance extends Emiter { | @@ -3159,7 +3166,7 @@ export default class MessageEntrance extends Emiter { | ||
| 3159 | info: "" + GlobalConfig.userRole, | 3166 | info: "" + GlobalConfig.userRole, |
| 3160 | immediatePublish:isPublish | 3167 | immediatePublish:isPublish |
| 3161 | }); | 3168 | }); |
| 3162 | - }, 1000); | 3169 | + }, 1600); |
| 3163 | } | 3170 | } |
| 3164 | } | 3171 | } |
| 3165 | 3172 |
| @@ -45,6 +45,22 @@ class EngineUtils { | @@ -45,6 +45,22 @@ class EngineUtils { | ||
| 45 | return randNumStr; | 45 | return randNumStr; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | + /* | ||
| 49 | + * 生成随机数 randomLen随机数范围; minLen 随机数的最小长度 | ||
| 50 | + * */ | ||
| 51 | + static getRandomInt(randomLen, minLen) { | ||
| 52 | + let randNumStr = ""; | ||
| 53 | + randNumStr=""+parseInt(Math.random() * randomLen); | ||
| 54 | + let distance=minLen-randNumStr.length; | ||
| 55 | + if(distance>0){ | ||
| 56 | + for (let i = 0; i < distance; i++) { | ||
| 57 | + randNumStr="0"+randNumStr; | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + return randNumStr; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + | ||
| 48 | //生成时间戳后9位 保证唯一 | 64 | //生成时间戳后9位 保证唯一 |
| 49 | static creatSoleNumberFromTimestamp() { | 65 | static creatSoleNumberFromTimestamp() { |
| 50 | let time = new Date().getTime(); | 66 | let time = new Date().getTime(); |
| @@ -98,7 +98,7 @@ class EverSocket extends Emiter { | @@ -98,7 +98,7 @@ class EverSocket extends Emiter { | ||
| 98 | * */ | 98 | * */ |
| 99 | send2mcu(len,type){ | 99 | send2mcu(len,type){ |
| 100 | this.sendToMcuList.push(""+len+":"+type); | 100 | this.sendToMcuList.push(""+len+":"+type); |
| 101 | - if(this.sendToMcuList.length>=100){ | 101 | + if(this.sendToMcuList.length>=200){ |
| 102 | loger.log("发送到MCU数据统计->",this.sendToMcuList); | 102 | loger.log("发送到MCU数据统计->",this.sendToMcuList); |
| 103 | this.sendToMcuList=[]; | 103 | this.sendToMcuList=[]; |
| 104 | } | 104 | } |
| @@ -111,7 +111,7 @@ class EverSocket extends Emiter { | @@ -111,7 +111,7 @@ class EverSocket extends Emiter { | ||
| 111 | * */ | 111 | * */ |
| 112 | mcu2client(len,type){ | 112 | mcu2client(len,type){ |
| 113 | this.receiveFromMcuList.push(""+len+":"+type); | 113 | this.receiveFromMcuList.push(""+len+":"+type); |
| 114 | - if(this.receiveFromMcuList.length>100){ | 114 | + if(this.receiveFromMcuList.length>200){ |
| 115 | loger.log("收到MCU数据统计->",this.receiveFromMcuList); | 115 | loger.log("收到MCU数据统计->",this.receiveFromMcuList); |
| 116 | this.receiveFromMcuList=[]; | 116 | this.receiveFromMcuList=[]; |
| 117 | } | 117 | } |
| @@ -241,15 +241,15 @@ class EverSocket extends Emiter { | @@ -241,15 +241,15 @@ class EverSocket extends Emiter { | ||
| 241 | let len=bufferData.byteLength; | 241 | let len=bufferData.byteLength; |
| 242 | if (len> 0) { | 242 | if (len> 0) { |
| 243 | this._emit(EverSocket.MESSAGE, bufferData); | 243 | this._emit(EverSocket.MESSAGE, bufferData); |
| 244 | - this.mcu2client(len,"消息"); | 244 | + this.mcu2client(len,"msg"); |
| 245 | }else { | 245 | }else { |
| 246 | - this.mcu2client(0,"回应"); | 246 | + this.mcu2client(0,"pong"); |
| 247 | } | 247 | } |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | _sendPingHandler() { | 250 | _sendPingHandler() { |
| 251 | if (this._connected) { | 251 | if (this._connected) { |
| 252 | - this.send2mcu(0,"心跳"); | 252 | + this.send2mcu(0,"ping"); |
| 253 | this.websocket.send(new ArrayBuffer); | 253 | this.websocket.send(new ArrayBuffer); |
| 254 | } else { | 254 | } else { |
| 255 | this._reConnection(); | 255 | this._reConnection(); |
| @@ -2,12 +2,58 @@ | @@ -2,12 +2,58 @@ | ||
| 2 | * | 2 | * |
| 3 | * LOG 信息管理(上传和输出) | 3 | * LOG 信息管理(上传和输出) |
| 4 | * */ | 4 | * */ |
| 5 | - | 5 | +const WEBRTC_LOG="WebRtcLog-" |
| 6 | class LogManager { | 6 | class LogManager { |
| 7 | constructor() { | 7 | constructor() { |
| 8 | 8 | ||
| 9 | } | 9 | } |
| 10 | - | 10 | + //捕获日志输出 |
| 11 | + static catchConsole(){ | ||
| 12 | + console.oldLog = console.log; | ||
| 13 | + console.log("捕获日志输出"); | ||
| 14 | + console.log = (...args)=> { | ||
| 15 | + if(args[0]=="INFO:"||args[0]=="DEBUG:"||args[0]=="WARNING:"||args[0]=="ERROR:") { | ||
| 16 | + LogManager.addLog(LogManager.LOG,WEBRTC_LOG+JSON.stringify(args)); | ||
| 17 | + }else { | ||
| 18 | + if(!args){ | ||
| 19 | + return; | ||
| 20 | + } | ||
| 21 | + if(args.length==1){ | ||
| 22 | + console.oldLog(args[0]); | ||
| 23 | + }else{ | ||
| 24 | + console.oldLog(args); | ||
| 25 | + } | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | + console.warn = (...args)=> { | ||
| 29 | + if(args[0]=="INFO:"||args[0]=="DEBUG:"||args[0]=="WARNING:"||args[0]=="ERROR:") { | ||
| 30 | + LogManager.addLog(LogManager.LOG,WEBRTC_LOG+JSON.stringify(args)); | ||
| 31 | + }else { | ||
| 32 | + if(!args){ | ||
| 33 | + return; | ||
| 34 | + } | ||
| 35 | + if(args.length==1){ | ||
| 36 | + console.oldLog(args[0]); | ||
| 37 | + }else{ | ||
| 38 | + console.oldLog(args); | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | + console.error = (...args)=> { | ||
| 43 | + if(args[0]=="INFO:"||args[0]=="DEBUG:"||args[0]=="WARNING:"||args[0]=="ERROR:") { | ||
| 44 | + LogManager.addLog(LogManager.LOG,WEBRTC_LOG+JSON.stringify(args)); | ||
| 45 | + }else { | ||
| 46 | + if(!args){ | ||
| 47 | + return; | ||
| 48 | + } | ||
| 49 | + if(args.length==1){ | ||
| 50 | + console.oldLog(args[0]); | ||
| 51 | + }else{ | ||
| 52 | + console.oldLog(args); | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + } | ||
| 11 | /* | 57 | /* |
| 12 | * 添加需要上报的日志信息到队列中 | 58 | * 添加需要上报的日志信息到队列中 |
| 13 | * _type | 59 | * _type |
| @@ -243,7 +243,7 @@ class SystemConfig { | @@ -243,7 +243,7 @@ class SystemConfig { | ||
| 243 | var isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1 || sUserAgent.indexOf("Windows 7") > -1; | 243 | var isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1 || sUserAgent.indexOf("Windows 7") > -1; |
| 244 | if (isWin7) return "Win7"; | 244 | if (isWin7) return "Win7"; |
| 245 | } | 245 | } |
| 246 | - return "other"; | 246 | + return String(navigator.platform)||String(sUserAgent); |
| 247 | } | 247 | } |
| 248 | } | 248 | } |
| 249 | export default SystemConfig; | 249 | export default SystemConfig; |
| @@ -353,14 +353,16 @@ class MediaModule { | @@ -353,14 +353,16 @@ class MediaModule { | ||
| 353 | let counter = 0; | 353 | let counter = 0; |
| 354 | for (let key in this.mediaChannels) { | 354 | for (let key in this.mediaChannels) { |
| 355 | let item = this.mediaChannels[key]; | 355 | let item = this.mediaChannels[key]; |
| 356 | - if (item && item.status == ApeConsts.CHANNEL_STATUS_RELEASED) { | 356 | + if (item ) { |
| 357 | + if(item.status == ApeConsts.CHANNEL_STATUS_RELEASED||(item.userId ==GlobalConfig.userId&&item.userRole==GlobalConfig.userRole)){ | ||
| 357 | loger.log("已获取空闲的通道->channelId:" + item.channelId); | 358 | loger.log("已获取空闲的通道->channelId:" + item.channelId); |
| 358 | return item.channelId; | 359 | return item.channelId; |
| 359 | } | 360 | } |
| 361 | + } | ||
| 360 | counter++; | 362 | counter++; |
| 361 | } | 363 | } |
| 362 | loger.log("获取空闲的通道", "mediaChannels", this.mediaChannels, "counter:", counter); | 364 | loger.log("获取空闲的通道", "mediaChannels", this.mediaChannels, "counter:", counter); |
| 363 | - //loger.log(this.mediaChannels); | 365 | + |
| 364 | if(this.maxMediaChannel>0){ | 366 | if(this.maxMediaChannel>0){ |
| 365 | if (counter < this.maxMediaChannel) { | 367 | if (counter < this.maxMediaChannel) { |
| 366 | return this.MEDIA_OBJ_TABLE_ID + (counter); | 368 | return this.MEDIA_OBJ_TABLE_ID + (counter); |
| @@ -51,13 +51,13 @@ class VideoApe extends Ape { | @@ -51,13 +51,13 @@ class VideoApe extends Ape { | ||
| 51 | /////////////发送数据操作//////////////////////////////////////////// | 51 | /////////////发送数据操作//////////////////////////////////////////// |
| 52 | //获取播流地址 | 52 | //获取播流地址 |
| 53 | getPlayVideoPath(_param) { | 53 | getPlayVideoPath(_param) { |
| 54 | - loger.log('getPlayVideoPath'); | 54 | + //loger.log('getPlayVideoPath'); |
| 55 | return this.mediaModule.getMediaPlayPath(_param); | 55 | return this.mediaModule.getMediaPlayPath(_param); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | //获取推流地址 | 58 | //获取推流地址 |
| 59 | getPublishVideoPath(_param) { | 59 | getPublishVideoPath(_param) { |
| 60 | - loger.log('获取推流地址->'); | 60 | + //loger.log('获取推流地址->'); |
| 61 | if (!this.mcu.connected) { | 61 | if (!this.mcu.connected) { |
| 62 | loger.warn(GlobalConfig.getCurrentStatus()); | 62 | loger.warn(GlobalConfig.getCurrentStatus()); |
| 63 | return {"code": ApeConsts.RETURN_FAILED, "data": "已经断开连接"}; | 63 | return {"code": ApeConsts.RETURN_FAILED, "data": "已经断开连接"}; |
| @@ -75,7 +75,9 @@ class VideoApe extends Ape { | @@ -75,7 +75,9 @@ class VideoApe extends Ape { | ||
| 75 | let allChannels = MediaModule.allMediaChannelsList; | 75 | let allChannels = MediaModule.allMediaChannelsList; |
| 76 | for (let i in allChannels) { | 76 | for (let i in allChannels) { |
| 77 | let channel = allChannels[i]; | 77 | let channel = allChannels[i]; |
| 78 | - if (channel && channel.status == ApeConsts.CHANNEL_STATUS_OPENING && channel.userRole != ApeConsts.invisible) { | 78 | + if (channel && channel.status == ApeConsts.CHANNEL_STATUS_OPENING && |
| 79 | + channel.userRole != ApeConsts.invisible&& | ||
| 80 | + channel.userId!=GlobalConfig.userId) { | ||
| 79 | //正在开启的才计数,监课开启的不计算在内 | 81 | //正在开启的才计数,监课开启的不计算在内 |
| 80 | openChannel++; | 82 | openChannel++; |
| 81 | } | 83 | } |
| @@ -177,6 +179,10 @@ class VideoApe extends Ape { | @@ -177,6 +179,10 @@ class VideoApe extends Ape { | ||
| 177 | } | 179 | } |
| 178 | } | 180 | } |
| 179 | 181 | ||
| 182 | + //每次推流的时候重置状态 | ||
| 183 | + GlobalConfig.videoEnabled=true; | ||
| 184 | + GlobalConfig.audioEnabled=true; | ||
| 185 | + | ||
| 180 | let channelInfo = this.mediaModule.getDefaultChannelInfo(); | 186 | let channelInfo = this.mediaModule.getDefaultChannelInfo(); |
| 181 | channelInfo.owner = GlobalConfig.nodeId; | 187 | channelInfo.owner = GlobalConfig.nodeId; |
| 182 | channelInfo.status = ApeConsts.CHANNEL_STATUS_OPENING; | 188 | channelInfo.status = ApeConsts.CHANNEL_STATUS_OPENING; |
| @@ -748,6 +754,8 @@ class VideoApe extends Ape { | @@ -748,6 +754,8 @@ class VideoApe extends Ape { | ||
| 748 | if (unpackChannelInfo.status == ApeConsts.CHANNEL_STATUS_OPENING) { | 754 | if (unpackChannelInfo.status == ApeConsts.CHANNEL_STATUS_OPENING) { |
| 749 | GlobalConfig.openCamera = EngineUtils.creatTimestamp(); | 755 | GlobalConfig.openCamera = EngineUtils.creatTimestamp(); |
| 750 | GlobalConfig.openMicrophones = GlobalConfig.openCamera; | 756 | GlobalConfig.openMicrophones = GlobalConfig.openCamera; |
| 757 | + GlobalConfig.videoEnabled=true; | ||
| 758 | + GlobalConfig.audioEnabled=true; | ||
| 751 | } else { | 759 | } else { |
| 752 | GlobalConfig.openCamera = 0; | 760 | GlobalConfig.openCamera = 0; |
| 753 | GlobalConfig.openMicrophones = 0; | 761 | GlobalConfig.openMicrophones = 0; |
| @@ -59,13 +59,15 @@ class WebRtcApe extends Emiter { | @@ -59,13 +59,15 @@ class WebRtcApe extends Emiter { | ||
| 59 | //240P 20 320x240 15 200 | 59 | //240P 20 320x240 15 200 |
| 60 | //360P_8 37 480x360 30 490 | 60 | //360P_8 37 480x360 30 490 |
| 61 | this.videoResolution = "240P"; | 61 | this.videoResolution = "240P"; |
| 62 | - this.isOpenVideo = true; | 62 | + this.isOpenVideo = true;//是否开启摄像头,默认为开启,如果获取不到麦克风的时候会设置为false |
| 63 | 63 | ||
| 64 | this.firstPublishSuccess = false;//记录加入频道成功之后是否推流成功过,离开频道之后需要设置为false | 64 | this.firstPublishSuccess = false;//记录加入频道成功之后是否推流成功过,离开频道之后需要设置为false |
| 65 | 65 | ||
| 66 | this.isPublish = false;//当前是否正在推流 | 66 | this.isPublish = false;//当前是否正在推流 |
| 67 | this.videoScale = 1;//视图的缩放比例,默认为1; | 67 | this.videoScale = 1;//视图的缩放比例,默认为1; |
| 68 | 68 | ||
| 69 | + this.isEnableVideo=true; | ||
| 70 | + this.isEnableAudio=true; | ||
| 69 | 71 | ||
| 70 | this.normalRemoteViewId = ""; | 72 | this.normalRemoteViewId = ""; |
| 71 | this.normalRemoteStyle = ""; | 73 | this.normalRemoteStyle = ""; |
| @@ -172,10 +174,6 @@ class WebRtcApe extends Emiter { | @@ -172,10 +174,6 @@ class WebRtcApe extends Emiter { | ||
| 172 | }); | 174 | }); |
| 173 | this.client.on('stream-added', (evt)=> { | 175 | this.client.on('stream-added', (evt)=> { |
| 174 | let stream = evt.stream; | 176 | let stream = evt.stream; |
| 175 | - /* loger.log("添加一个远程视频流: " + stream.getId(),new Date().getTime()); | ||
| 176 | - this.client.subscribe(stream, (err)=> { | ||
| 177 | - loger.log("添加一个远程视频流->failed", err); | ||
| 178 | - });*/ | ||
| 179 | this.reAddRemoteStream(stream); | 177 | this.reAddRemoteStream(stream); |
| 180 | }); | 178 | }); |
| 181 | this.client.on('stream-subscribed', (evt)=> { | 179 | this.client.on('stream-subscribed', (evt)=> { |
| @@ -189,7 +187,6 @@ class WebRtcApe extends Emiter { | @@ -189,7 +187,6 @@ class WebRtcApe extends Emiter { | ||
| 189 | $('#' + this.xdyRemote + stream.getId()).remove(); | 187 | $('#' + this.xdyRemote + stream.getId()).remove(); |
| 190 | loger.log("远程视频流已经断开:" + stream.getId()); | 188 | loger.log("远程视频流已经断开:" + stream.getId()); |
| 191 | } | 189 | } |
| 192 | - | ||
| 193 | }); | 190 | }); |
| 194 | 191 | ||
| 195 | this.client.on('peer-leave', (evt)=> { | 192 | this.client.on('peer-leave', (evt)=> { |
| @@ -266,6 +263,9 @@ class WebRtcApe extends Emiter { | @@ -266,6 +263,9 @@ class WebRtcApe extends Emiter { | ||
| 266 | let viewDiv = `<div id="${this.xdyRemote + uid}" class="${this.normalWebRtcVideoClass}" style="width:${this.normalRemoteVideoWidth * this.videoScale}px;height:${this.normalRemoteVideoHeight * this.videoScale}px;float: left;margin-right: 1px;">${nameDiv + videoAndAudioBox}</div>`; | 263 | let viewDiv = `<div id="${this.xdyRemote + uid}" class="${this.normalWebRtcVideoClass}" style="width:${this.normalRemoteVideoWidth * this.videoScale}px;height:${this.normalRemoteVideoHeight * this.videoScale}px;float: left;margin-right: 1px;">${nameDiv + videoAndAudioBox}</div>`; |
| 267 | $(this.normalRemoteViewId).append(viewDiv); | 264 | $(this.normalRemoteViewId).append(viewDiv); |
| 268 | } | 265 | } |
| 266 | + let audioPlayIcoBox=`<div class="audioPlayIcoBox " id=${"audioPlayIcoBox" + uid} ></div>`; | ||
| 267 | + $("#" + this.xdyRemote + uid).append(audioPlayIcoBox); | ||
| 268 | + | ||
| 269 | $("#" + this.videoMutedIdName + uid).off("click", this._clickVideoMuted.bind(this)); | 269 | $("#" + this.videoMutedIdName + uid).off("click", this._clickVideoMuted.bind(this)); |
| 270 | $("#" + this.audioMutedIdName + uid).off("click", this._clickAudioMuted.bind(this)); | 270 | $("#" + this.audioMutedIdName + uid).off("click", this._clickAudioMuted.bind(this)); |
| 271 | 271 | ||
| @@ -401,6 +401,10 @@ class WebRtcApe extends Emiter { | @@ -401,6 +401,10 @@ class WebRtcApe extends Emiter { | ||
| 401 | //一般只有在刷新重进频道的时候会用到 | 401 | //一般只有在刷新重进频道的时候会用到 |
| 402 | this.immediatePublish = _params.immediatePublish || false; | 402 | this.immediatePublish = _params.immediatePublish || false; |
| 403 | 403 | ||
| 404 | + this.isEnableVideo=true; | ||
| 405 | + this.isEnableAudio=true; | ||
| 406 | + GlobalConfig.videoEnabled=true; | ||
| 407 | + GlobalConfig.audioEnabled=true; | ||
| 404 | //根据不同身份设置不同的分辨率 | 408 | //根据不同身份设置不同的分辨率 |
| 405 | if (GlobalConfig.isTeachOrAssistant) { | 409 | if (GlobalConfig.isTeachOrAssistant) { |
| 406 | if (GlobalConfig.maxMediaChannels == 1) { | 410 | if (GlobalConfig.maxMediaChannels == 1) { |
| @@ -474,9 +478,15 @@ class WebRtcApe extends Emiter { | @@ -474,9 +478,15 @@ class WebRtcApe extends Emiter { | ||
| 474 | }); | 478 | }); |
| 475 | 479 | ||
| 476 | if (this.isOpenVideo) { | 480 | if (this.isOpenVideo) { |
| 477 | - //设置分辨率 | 481 | + loger.log("摄像头已经获取->设置本地视频分辨率:"+this.videoResolution); |
| 482 | + //设置视频分辨率 | ||
| 478 | this.localStream.setVideoProfile(this.videoResolution); | 483 | this.localStream.setVideoProfile(this.videoResolution); |
| 484 | + }else{ | ||
| 485 | + //没有视频,设置为最低 | ||
| 486 | + loger.log("摄像头没有获取到->设置本地流分辨率:120P"); | ||
| 487 | + this.localStream.setVideoProfile("120P"); | ||
| 479 | } | 488 | } |
| 489 | + | ||
| 480 | } | 490 | } |
| 481 | 491 | ||
| 482 | leaveChannel() { | 492 | leaveChannel() { |
| @@ -502,9 +512,7 @@ class WebRtcApe extends Emiter { | @@ -502,9 +512,7 @@ class WebRtcApe extends Emiter { | ||
| 502 | //loger.log("立即删除停止推流人员的视图"); | 512 | //loger.log("立即删除停止推流人员的视图"); |
| 503 | $('#' + this.xdyRemote + _data.nodeId).remove(); | 513 | $('#' + this.xdyRemote + _data.nodeId).remove(); |
| 504 | } catch (err) { | 514 | } catch (err) { |
| 505 | - | ||
| 506 | } | 515 | } |
| 507 | - | ||
| 508 | } | 516 | } |
| 509 | 517 | ||
| 510 | /* | 518 | /* |
| @@ -578,6 +586,8 @@ class WebRtcApe extends Emiter { | @@ -578,6 +586,8 @@ class WebRtcApe extends Emiter { | ||
| 578 | //自己的视图往前添加 | 586 | //自己的视图往前添加 |
| 579 | $(this.localViewId).prepend(videoBox); | 587 | $(this.localViewId).prepend(videoBox); |
| 580 | $("#" + viewName).css("transform", 'rotateY(180deg)'); | 588 | $("#" + viewName).css("transform", 'rotateY(180deg)'); |
| 589 | + let audioPlayIcoBox=`<div class="audioPlayIcoBox " id=${"audioPlayIcoBox" + this.uid} ></div>`; | ||
| 590 | + $("#" + viewName).append(audioPlayIcoBox); | ||
| 581 | 591 | ||
| 582 | //显示自己的名字 | 592 | //显示自己的名字 |
| 583 | let user = GlobalConfig.getUserInfoFromeNodeId(this.uid); | 593 | let user = GlobalConfig.getUserInfoFromeNodeId(this.uid); |
| @@ -857,6 +867,11 @@ class WebRtcApe extends Emiter { | @@ -857,6 +867,11 @@ class WebRtcApe extends Emiter { | ||
| 857 | } | 867 | } |
| 858 | } | 868 | } |
| 859 | } | 869 | } |
| 870 | + if( GlobalConfig.cameras&& GlobalConfig.cameras.length<1){ | ||
| 871 | + this.isOpenVideo=false; | ||
| 872 | + }else { | ||
| 873 | + this.isOpenVideo=true; | ||
| 874 | + } | ||
| 860 | let _deviceData = {cameras: GlobalConfig.cameras, microphones: GlobalConfig.microphones}; | 875 | let _deviceData = {cameras: GlobalConfig.cameras, microphones: GlobalConfig.microphones}; |
| 861 | if (_callback) { | 876 | if (_callback) { |
| 862 | _callback(_deviceData); | 877 | _callback(_deviceData); |
| @@ -922,27 +937,18 @@ class WebRtcApe extends Emiter { | @@ -922,27 +937,18 @@ class WebRtcApe extends Emiter { | ||
| 922 | if (_data.nodeId != GlobalConfig.nodeId) { | 937 | if (_data.nodeId != GlobalConfig.nodeId) { |
| 923 | //不是自己的只设置状态显示即可 | 938 | //不是自己的只设置状态显示即可 |
| 924 | //音频 | 939 | //音频 |
| 925 | - if (_data.audio == false) { | ||
| 926 | - //$("#" + this.audioMutedIdName + _data.nodeId).removeClass("microphoneOn"); | ||
| 927 | - //$("#" + this.audioMutedIdName + _data.nodeId).addClass("audioAndVideMuted microphoneOff"); | ||
| 928 | - this.setUidAudioEnabledStatus(_data.nodeId,false); | ||
| 929 | - } else { | ||
| 930 | - //$("#" + this.audioMutedIdName + _data.nodeId).removeClass("microphoneOff"); | ||
| 931 | - //$("#" + this.audioMutedIdName + _data.nodeId).addClass("audioAndVideMuted microphoneOn"); | ||
| 932 | - this.setUidAudioEnabledStatus(_data.nodeId,true); | ||
| 933 | - } | 940 | + this.setUidAudioEnabledStatus(_data.nodeId,Boolean(_data.audio)); |
| 934 | //视频 | 941 | //视频 |
| 935 | - if (_data.video == false) { | ||
| 936 | - //$("#" + this.audioMutedIdName + _data.nodeId).removeClass("microphoneOn"); | ||
| 937 | - //$("#" + this.audioMutedIdName + _data.nodeId).addClass("audioAndVideMuted microphoneOff"); | ||
| 938 | - this.setUidVideoEnabledStatus(_data.nodeId,false); | ||
| 939 | - } else { | ||
| 940 | - //$("#" + this.audioMutedIdName + _data.nodeId).removeClass("microphoneOff"); | ||
| 941 | - //$("#" + this.audioMutedIdName + _data.nodeId).addClass("audioAndVideMuted microphoneOn"); | ||
| 942 | - this.setUidVideoEnabledStatus(_data.nodeId,true); | ||
| 943 | - } | 942 | + this.setUidVideoEnabledStatus(_data.nodeId,Boolean(_data.video)); |
| 944 | } else { | 943 | } else { |
| 945 | //控制自己的音频 | 944 | //控制自己的音频 |
| 945 | + if(this.isEnableVideo==_data.video&&this.isEnableAudio==_data.audio){ | ||
| 946 | + return; | ||
| 947 | + } | ||
| 948 | + //记录自己当前的音视频禁用状态 | ||
| 949 | + this.isEnableVideo=_data.video; | ||
| 950 | + this.isEnableAudio=_data.audio; | ||
| 951 | + | ||
| 946 | if (_data.audio == false) { | 952 | if (_data.audio == false) { |
| 947 | this.disableAudio(_data.nodeId); | 953 | this.disableAudio(_data.nodeId); |
| 948 | } else { | 954 | } else { |
| @@ -966,11 +972,9 @@ class WebRtcApe extends Emiter { | @@ -966,11 +972,9 @@ class WebRtcApe extends Emiter { | ||
| 966 | * 开启禁音 | 972 | * 开启禁音 |
| 967 | * */ | 973 | * */ |
| 968 | disableAudio(uid) { | 974 | disableAudio(uid) { |
| 969 | - loger.log("开启禁音:" + uid); | ||
| 970 | if (parseInt(uid) == GlobalConfig.nodeId) { | 975 | if (parseInt(uid) == GlobalConfig.nodeId) { |
| 976 | + loger.log("开启禁音:" + uid); | ||
| 971 | if (this.localStream) { | 977 | if (this.localStream) { |
| 972 | - //$("#" + this.audioMutedIdName + uid).removeClass("microphoneOn"); | ||
| 973 | - //$("#" + this.audioMutedIdName + uid).addClass("audioAndVideMuted microphoneOff"); | ||
| 974 | this.setUidAudioEnabledStatus(uid,false); | 978 | this.setUidAudioEnabledStatus(uid,false); |
| 975 | this.localStream.disableAudio(); | 979 | this.localStream.disableAudio(); |
| 976 | } | 980 | } |
| @@ -981,12 +985,10 @@ class WebRtcApe extends Emiter { | @@ -981,12 +985,10 @@ class WebRtcApe extends Emiter { | ||
| 981 | * 开启音频 | 985 | * 开启音频 |
| 982 | * */ | 986 | * */ |
| 983 | enableAudio(uid) { | 987 | enableAudio(uid) { |
| 984 | - loger.log("开启音频:" + uid); | ||
| 985 | if (parseInt(uid) == GlobalConfig.nodeId) { | 988 | if (parseInt(uid) == GlobalConfig.nodeId) { |
| 989 | + loger.log("开启音频:" + uid); | ||
| 986 | if (this.localStream) { | 990 | if (this.localStream) { |
| 987 | this.localStream.enableAudio(); | 991 | this.localStream.enableAudio(); |
| 988 | - //$("#" + this.audioMutedIdName + _uid).removeClass("microphoneOff"); | ||
| 989 | - //$("#" + this.audioMutedIdName + _uid).addClass("audioAndVideMuted microphoneOn"); | ||
| 990 | this.setUidAudioEnabledStatus(uid,true); | 992 | this.setUidAudioEnabledStatus(uid,true); |
| 991 | } | 993 | } |
| 992 | } | 994 | } |
| @@ -1015,11 +1017,9 @@ class WebRtcApe extends Emiter { | @@ -1015,11 +1017,9 @@ class WebRtcApe extends Emiter { | ||
| 1015 | * 禁用摄像头 | 1017 | * 禁用摄像头 |
| 1016 | * */ | 1018 | * */ |
| 1017 | disableVideo(uid) { | 1019 | disableVideo(uid) { |
| 1018 | - loger.log("禁用摄像头:" + uid); | ||
| 1019 | if (parseInt(uid) == GlobalConfig.nodeId) { | 1020 | if (parseInt(uid) == GlobalConfig.nodeId) { |
| 1021 | + loger.log("禁用摄像头:" + uid); | ||
| 1020 | if (this.localStream) { | 1022 | if (this.localStream) { |
| 1021 | - //$("#" + this.audioMutedIdName + uid).removeClass("microphoneOn"); | ||
| 1022 | - //$("#" + this.audioMutedIdName + uid).addClass("audioAndVideMuted microphoneOff"); | ||
| 1023 | this.setUidVideoEnabledStatus(uid,false); | 1023 | this.setUidVideoEnabledStatus(uid,false); |
| 1024 | this.localStream.disableVideo(); | 1024 | this.localStream.disableVideo(); |
| 1025 | } | 1025 | } |
| @@ -1030,12 +1030,10 @@ class WebRtcApe extends Emiter { | @@ -1030,12 +1030,10 @@ class WebRtcApe extends Emiter { | ||
| 1030 | * 开启摄像头 | 1030 | * 开启摄像头 |
| 1031 | * */ | 1031 | * */ |
| 1032 | enableVideo(uid) { | 1032 | enableVideo(uid) { |
| 1033 | - loger.log("开启摄像头:" + uid); | ||
| 1034 | if (parseInt(uid) == GlobalConfig.nodeId) { | 1033 | if (parseInt(uid) == GlobalConfig.nodeId) { |
| 1035 | if (this.localStream) { | 1034 | if (this.localStream) { |
| 1035 | + loger.log("开启摄像头:" + uid); | ||
| 1036 | this.localStream.enableVideo(); | 1036 | this.localStream.enableVideo(); |
| 1037 | - //$("#" + this.audioMutedIdName + _uid).removeClass("microphoneOff"); | ||
| 1038 | - //$("#" + this.audioMutedIdName + _uid).addClass("audioAndVideMuted microphoneOn"); | ||
| 1039 | this.setUidVideoEnabledStatus(uid,true); | 1037 | this.setUidVideoEnabledStatus(uid,true); |
| 1040 | } | 1038 | } |
| 1041 | } | 1039 | } |
| @@ -1053,11 +1051,13 @@ class WebRtcApe extends Emiter { | @@ -1053,11 +1051,13 @@ class WebRtcApe extends Emiter { | ||
| 1053 | $("#" + this.videoMutedIdName + uid).removeClass("cameraOff"); | 1051 | $("#" + this.videoMutedIdName + uid).removeClass("cameraOff"); |
| 1054 | $("#" + this.videoMutedIdName + uid).addClass("audioAndVideMuted cameraOn"); | 1052 | $("#" + this.videoMutedIdName + uid).addClass("audioAndVideMuted cameraOn"); |
| 1055 | $("#" + this.videoMutedIdName + uid).attr("title",this.closeCameraTitle); | 1053 | $("#" + this.videoMutedIdName + uid).attr("title",this.closeCameraTitle); |
| 1054 | + $("#audioPlayIcoBox" + uid).hide(); | ||
| 1056 | }else{ | 1055 | }else{ |
| 1057 | //禁用 | 1056 | //禁用 |
| 1058 | $("#" + this.videoMutedIdName + uid).removeClass("cameraOn"); | 1057 | $("#" + this.videoMutedIdName + uid).removeClass("cameraOn"); |
| 1059 | $("#" + this.videoMutedIdName + uid).addClass("audioAndVideMuted cameraOff"); | 1058 | $("#" + this.videoMutedIdName + uid).addClass("audioAndVideMuted cameraOff"); |
| 1060 | $("#" + this.videoMutedIdName + uid).attr("title",this.openCameraTitle); | 1059 | $("#" + this.videoMutedIdName + uid).attr("title",this.openCameraTitle); |
| 1060 | + $("#audioPlayIcoBox" + uid).show(); | ||
| 1061 | } | 1061 | } |
| 1062 | } | 1062 | } |
| 1063 | 1063 |
| @@ -43,3 +43,17 @@ | @@ -43,3 +43,17 @@ | ||
| 43 | .cameraOn { | 43 | .cameraOn { |
| 44 | background-image: url(../../assets/img/cameraOn_22.png); | 44 | background-image: url(../../assets/img/cameraOn_22.png); |
| 45 | } | 45 | } |
| 46 | + | ||
| 47 | +/*只开启音频时的界面图标*/ | ||
| 48 | +.audioPlayIcoBox{ | ||
| 49 | + display: none; | ||
| 50 | + position: absolute; | ||
| 51 | + pointer-events: none; | ||
| 52 | + width: 100%; | ||
| 53 | + height: 100%; | ||
| 54 | + background-position: center; | ||
| 55 | + z-index: 1; | ||
| 56 | + /*background-size: 100%;*/ | ||
| 57 | + background-repeat: no-repeat; | ||
| 58 | + background-image: url(../../assets/img/audioPlayIco.png); | ||
| 59 | +} |
src/assets/img/audioPlayIco.png
0 → 100644
2.8 KB
| @@ -227,7 +227,8 @@ class MCU extends Emiter { | @@ -227,7 +227,8 @@ class MCU extends Emiter { | ||
| 227 | this.classInfo = _classInfo; | 227 | this.classInfo = _classInfo; |
| 228 | 228 | ||
| 229 | // 创建刷新nodeId | 229 | // 创建刷新nodeId |
| 230 | - let randNodeId =parseInt(Math.random()*1000)+""+parseInt(Math.random()*1000)+""+parseInt(Math.random()*1000); | 230 | + //let randNodeId =parseInt(Math.random()*1000)+""+parseInt(Math.random()*1000)+""+parseInt(Math.random()*1000); |
| 231 | + let randNodeId=""+ EngineUtils.getRandomInt(1000,3)+ EngineUtils.getRandomInt(1000,3)+ EngineUtils.getRandomInt(1000,3); | ||
| 231 | //生成的字符串nodeId转换为数字 | 232 | //生成的字符串nodeId转换为数字 |
| 232 | randNodeId=parseInt(randNodeId); | 233 | randNodeId=parseInt(randNodeId); |
| 233 | 234 |
-
请 注册 或 登录 后发表评论