李勇

修改视频通话模块的状态显示问题

@@ -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.35.11.20171130"; 66 + GlobalConfig.sdkVersion = "v2.36.4.20171201";
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 //设置
@@ -2206,13 +2206,6 @@ export default class MessageEntrance extends Emiter { @@ -2206,13 +2206,6 @@ export default class MessageEntrance extends Emiter {
2206 2206
2207 //监听摄像头麦克风状态 2207 //监听摄像头麦克风状态
2208 userDeviecStatusChange(_data) { 2208 userDeviecStatusChange(_data) {
2209 - /* nodeId:GlobalConfig.nodeId,  
2210 - userRole:GlobalConfig.userRole,  
2211 - userName:GlobalConfig.userName,  
2212 - userId:GlobalConfig.userId,  
2213 - openCamera:GlobalConfig.openCamera,  
2214 - openMicrophones:GlobalConfig.openMicrophones*/  
2215 -  
2216 if (!_mcu.connected) { 2209 if (!_mcu.connected) {
2217 loger.warn(GlobalConfig.getCurrentStatus()); 2210 loger.warn(GlobalConfig.getCurrentStatus());
2218 return {"code": ApeConsts.RETURN_FAILED, "data": ""}; 2211 return {"code": ApeConsts.RETURN_FAILED, "data": ""};
@@ -2234,11 +2227,19 @@ export default class MessageEntrance extends Emiter { @@ -2234,11 +2227,19 @@ export default class MessageEntrance extends Emiter {
2234 if (_data.status == WebRtcApe.RECORD_STATUS_1) { 2227 if (_data.status == WebRtcApe.RECORD_STATUS_1) {
2235 let publishData = this._getVideoPublishPath(); 2228 let publishData = this._getVideoPublishPath();
2236 let publishUrl = ""; 2229 let publishUrl = "";
  2230 + //判断是否可以推流
2237 if (publishData && publishData.code == 0) { 2231 if (publishData && publishData.code == 0) {
2238 _data.publishUrl = publishData.publishUrl || ""; 2232 _data.publishUrl = publishData.publishUrl || "";
  2233 + _video_ape.mediaPublishStatusChange(_data);
  2234 + }else{
  2235 + loger.log("webRtc推流状态发生改变->推流失败", publishData);
  2236 + this._unpublishMedia();
2239 } 2237 }
  2238 + }else {
  2239 + //停止推流
  2240 + _video_ape.mediaPublishStatusChange(_data);
2240 } 2241 }
2241 - _video_ape.mediaPublishStatusChange(_data); 2242 +
2242 } 2243 }
2243 } 2244 }
2244 2245
@@ -97,11 +97,11 @@ class EverSocket extends Emiter { @@ -97,11 +97,11 @@ class EverSocket extends Emiter {
97 * type 类型 97 * type 类型
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>=200){ 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 + }*/
105 } 105 }
106 106
107 //统计收到MCU的数据 107 //统计收到MCU的数据
@@ -110,11 +110,11 @@ class EverSocket extends Emiter { @@ -110,11 +110,11 @@ class EverSocket extends Emiter {
110 * type 类型 110 * type 类型
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>200){ 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 + }*/
118 } 118 }
119 119
120 _setConnected(isConn = true) { 120 _setConnected(isConn = true) {
@@ -1218,7 +1218,7 @@ class RecordPlayBackParse extends Emiter { @@ -1218,7 +1218,7 @@ class RecordPlayBackParse extends Emiter {
1218 if (sessionId == ApeConsts.VIDEO_SESSION_ID) { 1218 if (sessionId == ApeConsts.VIDEO_SESSION_ID) {
1219 try { 1219 try {
1220 let videoChannelInfo = pdu['RCVideoChannelInfoPdu'].decode(tableItem.itemData); 1220 let videoChannelInfo = pdu['RCVideoChannelInfoPdu'].decode(tableItem.itemData);
1221 - //loger.log('RCVideoChannelInfoPdu->timestamp',timestamp,videoChannelInfo); 1221 + loger.log('RCVideoChannelInfoPdu->timestamp',timestamp,videoChannelInfo);
1222 //储存音视频模块的数据 1222 //储存音视频模块的数据
1223 if (!this.mediaChannleList[videoChannelInfo.channelId]) { 1223 if (!this.mediaChannleList[videoChannelInfo.channelId]) {
1224 this.mediaChannleList[videoChannelInfo.channelId] = {}; 1224 this.mediaChannleList[videoChannelInfo.channelId] = {};
@@ -1227,7 +1227,7 @@ class RecordPlayBackParse extends Emiter { @@ -1227,7 +1227,7 @@ class RecordPlayBackParse extends Emiter {
1227 if (videoChannelInfo && videoChannelInfo.status == 1) { 1227 if (videoChannelInfo && videoChannelInfo.status == 1) {
1228 statusStr = "开"; 1228 statusStr = "开";
1229 this.allStreams[videoChannelInfo.streamId] = videoChannelInfo; 1229 this.allStreams[videoChannelInfo.streamId] = videoChannelInfo;
1230 - console.log("视频流" + videoChannelInfo.streamId); 1230 + //console.log("视频流" + videoChannelInfo.streamId);
1231 if(videoChannelInfo){ 1231 if(videoChannelInfo){
1232 videoChannelInfo.channel=videoChannelInfo.siteId+"_"+videoChannelInfo.classId; 1232 videoChannelInfo.channel=videoChannelInfo.siteId+"_"+videoChannelInfo.classId;
1233 videoChannelInfo.uid=videoChannelInfo.fromNodeId; 1233 videoChannelInfo.uid=videoChannelInfo.fromNodeId;
@@ -82,6 +82,7 @@ class VideoApe extends Ape { @@ -82,6 +82,7 @@ class VideoApe extends Ape {
82 openChannel++; 82 openChannel++;
83 } 83 }
84 } 84 }
  85 +
85 //如果已经开启的数量大于等于最大允许开启的数量,不允许再推流 86 //如果已经开启的数量大于等于最大允许开启的数量,不允许再推流
86 if (openChannel >= GlobalConfig.maxMediaChannels) { 87 if (openChannel >= GlobalConfig.maxMediaChannels) {
87 loger.warn('不能再打开设备->当前开启的设备数量->', openChannel); 88 loger.warn('不能再打开设备->当前开启的设备数量->', openChannel);
@@ -48,6 +48,7 @@ class WebRtcApe extends Emiter { @@ -48,6 +48,7 @@ class WebRtcApe extends Emiter {
48 this.curCameraId = ""; 48 this.curCameraId = "";
49 this.curMicrophoneId = ""; 49 this.curMicrophoneId = "";
50 50
  51 + this.speakerList=[];//记录讲话的记录
51 this.remoteVideoList = {};//记录远程视频流 52 this.remoteVideoList = {};//记录远程视频流
52 53
53 this.pWidth = SIZE_480; 54 this.pWidth = SIZE_480;
@@ -66,8 +67,8 @@ class WebRtcApe extends Emiter { @@ -66,8 +67,8 @@ class WebRtcApe extends Emiter {
66 this.isPublish = false;//当前是否正在推流 67 this.isPublish = false;//当前是否正在推流
67 this.videoScale = 1;//视图的缩放比例,默认为1; 68 this.videoScale = 1;//视图的缩放比例,默认为1;
68 69
69 - this.isEnableVideo=true;  
70 - this.isEnableAudio=true; 70 + this.isEnableVideo = true;
  71 + this.isEnableAudio = true;
71 72
72 this.normalRemoteViewId = ""; 73 this.normalRemoteViewId = "";
73 this.normalRemoteStyle = ""; 74 this.normalRemoteStyle = "";
@@ -93,10 +94,10 @@ class WebRtcApe extends Emiter { @@ -93,10 +94,10 @@ class WebRtcApe extends Emiter {
93 this.audioMutedIdName = "audioMutedIdName_"; 94 this.audioMutedIdName = "audioMutedIdName_";
94 this.videoMutedIdName = "videoMutedIdName_"; 95 this.videoMutedIdName = "videoMutedIdName_";
95 96
96 - this.closeCameraTitle="close Camera";  
97 - this.openCameraTitle="open Camera";  
98 - this.closeMicrophoneTitle="close Microphone";  
99 - this.openMicrophoneTitle="open Microphone"; 97 + this.closeCameraTitle = "close Camera";
  98 + this.openCameraTitle = "open Camera";
  99 + this.closeMicrophoneTitle = "close Microphone";
  100 + this.openMicrophoneTitle = "open Microphone";
100 101
101 this.localWebRtcVideoClass = 'localWebRtcVideoClass';//本地视图统一的class名称 102 this.localWebRtcVideoClass = 'localWebRtcVideoClass';//本地视图统一的class名称
102 this.invisibleWebRtcVideoClass = 'invisibleWebRtcVideoClass'; 103 this.invisibleWebRtcVideoClass = 'invisibleWebRtcVideoClass';
@@ -162,6 +163,10 @@ class WebRtcApe extends Emiter { @@ -162,6 +163,10 @@ class WebRtcApe extends Emiter {
162 this.firstPublishSuccess = true; 163 this.firstPublishSuccess = true;
163 GlobalConfig.openCamera = EngineUtils.creatTimestamp(); 164 GlobalConfig.openCamera = EngineUtils.creatTimestamp();
164 GlobalConfig.openMicrophones = GlobalConfig.openCamera; 165 GlobalConfig.openMicrophones = GlobalConfig.openCamera;
  166 + this.isEnableVideo = true;
  167 + this.isEnableAudio = true;
  168 + GlobalConfig.videoEnabled = true;
  169 + GlobalConfig.audioEnabled = true;
165 this._emit(MessageTypes.USER_DEVICE_STATUS_CHAANGE, { 170 this._emit(MessageTypes.USER_DEVICE_STATUS_CHAANGE, {
166 nodeId: GlobalConfig.nodeId, 171 nodeId: GlobalConfig.nodeId,
167 userRole: GlobalConfig.userRole, 172 userRole: GlobalConfig.userRole,
@@ -199,13 +204,18 @@ class WebRtcApe extends Emiter { @@ -199,13 +204,18 @@ class WebRtcApe extends Emiter {
199 }); 204 });
200 this.client.on("active-speaker", (evt)=> { 205 this.client.on("active-speaker", (evt)=> {
201 let uid = evt.uid; 206 let uid = evt.uid;
202 - let user=GlobalConfig.getUserInfoFromeNodeId(parseInt(uid)); 207 + let user = GlobalConfig.getUserInfoFromeNodeId(parseInt(uid));
203 //console.log("active-speaker",user); 208 //console.log("active-speaker",user);
204 - if(user){  
205 - let roleRole=GlobalConfig.getUserRoleToString(user.role);  
206 - loger.log("当前正在讲话的 ["+roleRole+"] name:"+user.name+" uid:" + uid);  
207 - }else{  
208 - loger.log("当前正在讲话的uid:" + uid); 209 + if (user) {
  210 + let roleRole = GlobalConfig.getUserRoleToString(user.role);
  211 + this.speakerList.push("当前正在讲话的 [" + roleRole + "] name:" + user.name + " uid:" + uid);
  212 + } else {
  213 + this.speakerList.push("当前正在讲话的uid:" + uid);
  214 + }
  215 + //记录正在讲话的数据,大于50条上报一次
  216 + if(this.speakerList.length>20){
  217 + loger.log(this.speakerList);
  218 + this.speakerList=[];
209 } 219 }
210 }); 220 });
211 221
@@ -221,49 +231,50 @@ class WebRtcApe extends Emiter { @@ -221,49 +231,50 @@ class WebRtcApe extends Emiter {
221 userName = user.name || "unknow"; 231 userName = user.name || "unknow";
222 userRole = user.userRole; 232 userRole = user.userRole;
223 } 233 }
224 -  
225 - //添加之前先删除之前存在的重复视图 234 + //添加之前先删除之前存在的重复视图 (查找子元素)
226 let len = $("#" + this.xdyRemote + uid + " #player_" + uid).length; 235 let len = $("#" + this.xdyRemote + uid + " #player_" + uid).length;
227 if (len < 1) { 236 if (len < 1) {
228 loger.log("添加之前先删除之前存在的重复视图", uid); 237 loger.log("添加之前先删除之前存在的重复视图", uid);
229 $("#" + this.xdyRemote + uid).remove(); 238 $("#" + this.xdyRemote + uid).remove();
230 - } 239 + }
  240 +
231 let audioMutedDiv = ""; 241 let audioMutedDiv = "";
232 - let videoMutedDiv="";  
233 - let videoAndAudioBox="" 242 + let videoMutedDiv = "";
  243 + let videoAndAudioBox = ""
234 if (GlobalConfig.isTeachOrAssistant || GlobalConfig.isInvisible) { 244 if (GlobalConfig.isTeachOrAssistant || GlobalConfig.isInvisible) {
235 - if(user&&user.videoEnabled==true){ 245 + if (user && user.videoEnabled == true) {
236 videoMutedDiv = `<div class="audioAndVideMuted cameraOn" id=${this.videoMutedIdName + uid} title="${this.closeCameraTitle}"></div>` 246 videoMutedDiv = `<div class="audioAndVideMuted cameraOn" id=${this.videoMutedIdName + uid} title="${this.closeCameraTitle}"></div>`
237 - }else{ 247 + } else {
238 videoMutedDiv = `<div class="audioAndVideMuted cameraOff" id=${this.videoMutedIdName + uid} title="${this.closeCameraTitle}"></div>` 248 videoMutedDiv = `<div class="audioAndVideMuted cameraOff" id=${this.videoMutedIdName + uid} title="${this.closeCameraTitle}"></div>`
239 } 249 }
240 - if(user&&user.audioEnabled==true){ 250 + if (user && user.audioEnabled == true) {
241 audioMutedDiv = `<div class="audioAndVideMuted microphoneOn " id=${this.audioMutedIdName + uid} title="${this.closeMicrophoneTitle}"></div>`; 251 audioMutedDiv = `<div class="audioAndVideMuted microphoneOn " id=${this.audioMutedIdName + uid} title="${this.closeMicrophoneTitle}"></div>`;
242 - }else{ 252 + } else {
243 audioMutedDiv = `<div class="audioAndVideMuted microphoneOff " id=${this.audioMutedIdName + uid} title="${this.closeMicrophoneTitle}"></div>`; 253 audioMutedDiv = `<div class="audioAndVideMuted microphoneOff " id=${this.audioMutedIdName + uid} title="${this.closeMicrophoneTitle}"></div>`;
244 } 254 }
245 - videoAndAudioBox=`<div class="audioAndVideBox unOpenVideo">${videoMutedDiv+audioMutedDiv}</div>`; 255 + videoAndAudioBox = `<div class="audioAndVideBox unOpenVideo">${videoMutedDiv + audioMutedDiv}</div>`;
246 } 256 }
  257 +
247 if (userRole == ApeConsts.invisible) { 258 if (userRole == ApeConsts.invisible) {
248 - let nameDiv = `<div style="${this.invisibleVideoWidth}px;height:22px; position: absolute;bottom: 2px; right:4px; z-index: 1;overflow:hidden;font-size: 14px;text-align: right; vertical-align: middle;color: #e7e7e7display:${this.nameDisplay}">${userName}</div>`; 259 + let nameDiv = `<div style="${this.invisibleVideoWidth}px;height:22px; position: absolute;bottom: 2px; right:4px; z-index: 2;overflow:hidden;font-size: 14px;text-align: right; vertical-align: middle;color: #e7e7e7display:${this.nameDisplay}">${userName}</div>`;
249 //把远程视频添加到监课列表 260 //把远程视频添加到监课列表
250 loger.log("获取远程视频流成功->监课:" + userName + "->" + uid, new Date().getTime()); 261 loger.log("获取远程视频流成功->监课:" + userName + "->" + uid, new Date().getTime());
251 let viewDiv = `<div id="${this.xdyRemote + uid}" class="${this.invisibleWebRtcVideoClass}" style="width:${this.invisibleVideoWidth * this.videoScale}px;height:${this.invisibleVideoHeight * this.videoScale}px;float: left;margin-right: 1px;">${nameDiv + videoAndAudioBox}</div>`; 262 let viewDiv = `<div id="${this.xdyRemote + uid}" class="${this.invisibleWebRtcVideoClass}" style="width:${this.invisibleVideoWidth * this.videoScale}px;height:${this.invisibleVideoHeight * this.videoScale}px;float: left;margin-right: 1px;">${nameDiv + videoAndAudioBox}</div>`;
252 $(this.invisibleViewId).append(viewDiv); 263 $(this.invisibleViewId).append(viewDiv);
253 } else if (userRole == ApeConsts.host || userRole == ApeConsts.assistant || userRole == ApeConsts.presenter) { 264 } else if (userRole == ApeConsts.host || userRole == ApeConsts.assistant || userRole == ApeConsts.presenter) {
254 - let nameDiv = `<div style="width:${this.hostRemoteVideoWidth}px;height:22px; position: absolute;bottom: 2px;right:4px; z-index: 1;overflow:hidden;font-size: 14px;text-align: right;vertical-align: middle;color: #e7e7e7;display:${this.nameDisplay}">${userName }</div>`; 265 + let nameDiv = `<div style="width:${this.hostRemoteVideoWidth}px;height:22px; position: absolute;bottom: 2px;right:4px; z-index: 2;overflow:hidden;font-size: 14px;text-align: right;vertical-align: middle;color: #e7e7e7;display:${this.nameDisplay}">${userName }</div>`;
255 //把远程视图添加到老师列表 266 //把远程视图添加到老师列表
256 loger.log("获取远程视频流成功->userRole:" + userRole + ":" + userName + "->" + uid, new Date().getTime()); 267 loger.log("获取远程视频流成功->userRole:" + userRole + ":" + userName + "->" + uid, new Date().getTime());
257 let viewDiv = `<div id="${this.xdyRemote + uid}" class="${this.hostWebRtcVideoClass}" style="width:${this.hostRemoteVideoWidth * this.videoScale}px;height:${this.hostRemoteVideoHeight * this.videoScale}px;float: left;margin-right: 1px;">${nameDiv + videoAndAudioBox}</div>`; 268 let viewDiv = `<div id="${this.xdyRemote + uid}" class="${this.hostWebRtcVideoClass}" style="width:${this.hostRemoteVideoWidth * this.videoScale}px;height:${this.hostRemoteVideoHeight * this.videoScale}px;float: left;margin-right: 1px;">${nameDiv + videoAndAudioBox}</div>`;
258 $(this.hostRemoteViewId).prepend(viewDiv); 269 $(this.hostRemoteViewId).prepend(viewDiv);
259 } else { 270 } else {
260 - let nameDiv = `<div style="width:${this.normalRemoteVideoWidth}px;height:22px; position: absolute;bottom: 2px;right:4px; z-index: 1;overflow:hidden;font-size: 14px;text-align: right;vertical-align: middle;color: #e7e7e7;display:${this.nameDisplay}">${userName}</div>`; 271 + let nameDiv = `<div style="width:${this.normalRemoteVideoWidth}px;height:22px; position: absolute;bottom: 2px;right:4px; z-index: 2;overflow:hidden;font-size: 14px;text-align: right;vertical-align: middle;color: #e7e7e7;display:${this.nameDisplay}">${userName}</div>`;
261 //把视图添加到学生列表 272 //把视图添加到学生列表
262 loger.log("获取远程视频流成功->学生:" + userName + "->" + uid, new Date().getTime()); 273 loger.log("获取远程视频流成功->学生:" + userName + "->" + uid, new Date().getTime());
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>`; 274 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>`;
264 $(this.normalRemoteViewId).append(viewDiv); 275 $(this.normalRemoteViewId).append(viewDiv);
265 } 276 }
266 - let audioPlayIcoBox=`<div class="audioPlayIcoBox " id=${"audioPlayIcoBox" + uid} ></div>`; 277 + let audioPlayIcoBox = `<div class="audioPlayIcoBox " id=${"audioPlayIcoBox" + uid} ></div>`;
267 $("#" + this.xdyRemote + uid).append(audioPlayIcoBox); 278 $("#" + this.xdyRemote + uid).append(audioPlayIcoBox);
268 279
269 $("#" + this.videoMutedIdName + uid).off("click", this._clickVideoMuted.bind(this)); 280 $("#" + this.videoMutedIdName + uid).off("click", this._clickVideoMuted.bind(this));
@@ -284,7 +295,12 @@ class WebRtcApe extends Emiter { @@ -284,7 +295,12 @@ class WebRtcApe extends Emiter {
284 $("#" + this.xdyRemote + uid).remove(); 295 $("#" + this.xdyRemote + uid).remove();
285 } 296 }
286 } 297 }
287 - $("#player_" + uid).css("pointer-events","none"); 298 + //设置视图画面不可点
  299 + $("#player_" + uid).css("pointer-events", "none");
  300 + //更新音视频禁用状态显示
  301 + if (uid != GlobalConfig.nodeId) {
  302 + this.receiveWebRtcMeiaEnabledChange({nodeId: uid, video: Boolean(user.videoEnabled), audio: Boolean(user.audioEnabled)});
  303 + }
288 if (user && (user.deviceType == GlobalConfig.deviceIOS || user.deviceType == GlobalConfig.deviceAndroid)) { 304 if (user && (user.deviceType == GlobalConfig.deviceIOS || user.deviceType == GlobalConfig.deviceAndroid)) {
289 this.remoteVideoList[user.nodeId] = stream; 305 this.remoteVideoList[user.nodeId] = stream;
290 } 306 }
@@ -401,10 +417,10 @@ class WebRtcApe extends Emiter { @@ -401,10 +417,10 @@ class WebRtcApe extends Emiter {
401 //一般只有在刷新重进频道的时候会用到 417 //一般只有在刷新重进频道的时候会用到
402 this.immediatePublish = _params.immediatePublish || false; 418 this.immediatePublish = _params.immediatePublish || false;
403 419
404 - this.isEnableVideo=true;  
405 - this.isEnableAudio=true;  
406 - GlobalConfig.videoEnabled=true;  
407 - GlobalConfig.audioEnabled=true; 420 + this.isEnableVideo = true;
  421 + this.isEnableAudio = true;
  422 + GlobalConfig.videoEnabled = true;
  423 + GlobalConfig.audioEnabled = true;
408 //根据不同身份设置不同的分辨率 424 //根据不同身份设置不同的分辨率
409 if (GlobalConfig.isTeachOrAssistant) { 425 if (GlobalConfig.isTeachOrAssistant) {
410 if (GlobalConfig.maxMediaChannels == 1) { 426 if (GlobalConfig.maxMediaChannels == 1) {
@@ -478,10 +494,10 @@ class WebRtcApe extends Emiter { @@ -478,10 +494,10 @@ class WebRtcApe extends Emiter {
478 }); 494 });
479 495
480 if (this.isOpenVideo) { 496 if (this.isOpenVideo) {
481 - loger.log("摄像头已经获取->设置本地视频分辨率:"+this.videoResolution); 497 + loger.log("摄像头已经获取->设置本地视频分辨率:" + this.videoResolution);
482 //设置视频分辨率 498 //设置视频分辨率
483 this.localStream.setVideoProfile(this.videoResolution); 499 this.localStream.setVideoProfile(this.videoResolution);
484 - }else{ 500 + } else {
485 //没有视频,设置为最低 501 //没有视频,设置为最低
486 loger.log("摄像头没有获取到->设置本地流分辨率:120P"); 502 loger.log("摄像头没有获取到->设置本地流分辨率:120P");
487 this.localStream.setVideoProfile("120P"); 503 this.localStream.setVideoProfile("120P");
@@ -586,7 +602,7 @@ class WebRtcApe extends Emiter { @@ -586,7 +602,7 @@ class WebRtcApe extends Emiter {
586 //自己的视图往前添加 602 //自己的视图往前添加
587 $(this.localViewId).prepend(videoBox); 603 $(this.localViewId).prepend(videoBox);
588 $("#" + viewName).css("transform", 'rotateY(180deg)'); 604 $("#" + viewName).css("transform", 'rotateY(180deg)');
589 - let audioPlayIcoBox=`<div class="audioPlayIcoBox " id=${"audioPlayIcoBox" + this.uid} ></div>`; 605 + let audioPlayIcoBox = `<div class="audioPlayIcoBox " id=${"audioPlayIcoBox" + this.uid} ></div>`;
590 $("#" + viewName).append(audioPlayIcoBox); 606 $("#" + viewName).append(audioPlayIcoBox);
591 607
592 //显示自己的名字 608 //显示自己的名字
@@ -595,21 +611,16 @@ class WebRtcApe extends Emiter { @@ -595,21 +611,16 @@ class WebRtcApe extends Emiter {
595 if (user) { 611 if (user) {
596 userName = user.name || ""; 612 userName = user.name || "";
597 } 613 }
598 - /* let audioMutedDiv = "";  
599 - if (GlobalConfig.isTeachOrAssistant) {  
600 - audioMutedDiv = `<div class="audioAndVideMuted microphoneOn openVideo" id=${this.audioMutedIdName + this.uid}></div>`;  
601 - }  
602 -*/  
603 let audioMutedDiv = ""; 614 let audioMutedDiv = "";
604 - let videoMutedDiv="";  
605 - let videoAndAudioBox="" 615 + let videoMutedDiv = "";
  616 + let videoAndAudioBox = ""
606 if (GlobalConfig.isTeachOrAssistant) { 617 if (GlobalConfig.isTeachOrAssistant) {
607 - videoMutedDiv =`<div class="audioAndVideMuted cameraOn " id=${this.videoMutedIdName + this.uid} title="${this.closeCameraTitle}"></div>`;  
608 - audioMutedDiv =`<div class="audioAndVideMuted microphoneOn " id=${this.audioMutedIdName + this.uid} title="${this.closeMicrophoneTitle}"></div>`;  
609 - videoAndAudioBox=`<div class="audioAndVideBox openVideo">${videoMutedDiv+audioMutedDiv}</div>`; 618 + videoMutedDiv = `<div class="audioAndVideMuted cameraOn " id=${this.videoMutedIdName + this.uid} title="${this.closeCameraTitle}"></div>`;
  619 + audioMutedDiv = `<div class="audioAndVideMuted microphoneOn " id=${this.audioMutedIdName + this.uid} title="${this.closeMicrophoneTitle}"></div>`;
  620 + videoAndAudioBox = `<div class="audioAndVideBox openVideo">${videoMutedDiv + audioMutedDiv}</div>`;
610 } 621 }
611 622
612 - let nameDiv = `<div id="${"videoOwnerName_" + this.uid}" class="localVideoOwnerName" style="width:${this.localVideoWidth}px;height:26px; position: absolute;bottom: 2px; z-index: 1;overflow:hidden;font-size: 14px;text-align: right; vertical-align:bottom;color: #e7e7e7;display:${this.nameDisplay}">${userName+videoAndAudioBox}</div>`; 623 + let nameDiv = `<div id="${"videoOwnerName_" + this.uid}" class="localVideoOwnerName" style="width:${this.localVideoWidth}px;height:26px; position: absolute;bottom: 2px; z-index: 1;overflow:hidden;font-size: 14px;text-align: right; vertical-align:bottom;color: #e7e7e7;display:${this.nameDisplay}">${userName + videoAndAudioBox}</div>`;
613 $(this.localViewId).prepend(nameDiv); 624 $(this.localViewId).prepend(nameDiv);
614 625
615 $("#" + this.videoMutedIdName + this.uid).off("click", this._clickVideoMuted.bind(this)); 626 $("#" + this.videoMutedIdName + this.uid).off("click", this._clickVideoMuted.bind(this));
@@ -622,8 +633,6 @@ class WebRtcApe extends Emiter { @@ -622,8 +633,6 @@ class WebRtcApe extends Emiter {
622 this.localStream.play(viewName); 633 this.localStream.play(viewName);
623 this.client.publish(this.localStream, (err)=> { 634 this.client.publish(this.localStream, (err)=> {
624 loger.log("webRtc->推流失败: " + err); 635 loger.log("webRtc->推流失败: " + err);
625 - GlobalConfig.openCamera = 0;  
626 - GlobalConfig.openMicrophones = 0;  
627 this.isPublish = false; 636 this.isPublish = false;
628 this.unpublish(); 637 this.unpublish();
629 }); 638 });
@@ -678,6 +687,10 @@ class WebRtcApe extends Emiter { @@ -678,6 +687,10 @@ class WebRtcApe extends Emiter {
678 this.localStream.close(); 687 this.localStream.close();
679 this.clearLocalView(); 688 this.clearLocalView();
680 this.isPublish = false; 689 this.isPublish = false;
  690 + this.isEnableVideo = true;
  691 + this.isEnableAudio = true;
  692 + GlobalConfig.videoEnabled = true;
  693 + GlobalConfig.audioEnabled = true;
681 GlobalConfig.openCamera = 0; 694 GlobalConfig.openCamera = 0;
682 GlobalConfig.openMicrophones = 0; 695 GlobalConfig.openMicrophones = 0;
683 this._emit(MessageTypes.USER_DEVICE_STATUS_CHAANGE, { 696 this._emit(MessageTypes.USER_DEVICE_STATUS_CHAANGE, {
@@ -858,19 +871,19 @@ class WebRtcApe extends Emiter { @@ -858,19 +871,19 @@ class WebRtcApe extends Emiter {
858 if (device) { 871 if (device) {
859 if (device.kind == 'audioinput') { 872 if (device.kind == 'audioinput') {
860 this.microphones.push(device); 873 this.microphones.push(device);
861 - GlobalConfig.microphones.push(device.label); 874 + GlobalConfig.microphones.push(device.label||"microphone"+i);
862 } else if (device.kind == 'videoinput') { 875 } else if (device.kind == 'videoinput') {
863 this.cameras.push(device); 876 this.cameras.push(device);
864 - GlobalConfig.cameras.push(device.label); 877 + GlobalConfig.cameras.push(device.label||"camera"+i);
865 } else { 878 } else {
866 loger.warn('其他设备: ', device); 879 loger.warn('其他设备: ', device);
867 } 880 }
868 } 881 }
869 } 882 }
870 - if( GlobalConfig.cameras&& GlobalConfig.cameras.length<1){  
871 - this.isOpenVideo=false;  
872 - }else {  
873 - this.isOpenVideo=true; 883 + if (GlobalConfig.cameras && GlobalConfig.cameras.length < 1) {
  884 + this.isOpenVideo = false;
  885 + } else {
  886 + this.isOpenVideo = true;
874 } 887 }
875 let _deviceData = {cameras: GlobalConfig.cameras, microphones: GlobalConfig.microphones}; 888 let _deviceData = {cameras: GlobalConfig.cameras, microphones: GlobalConfig.microphones};
876 if (_callback) { 889 if (_callback) {
@@ -879,10 +892,11 @@ class WebRtcApe extends Emiter { @@ -879,10 +892,11 @@ class WebRtcApe extends Emiter {
879 this._emit(MessageTypes.GET_DEVICES_SUCCESS, _deviceData); 892 this._emit(MessageTypes.GET_DEVICES_SUCCESS, _deviceData);
880 }); 893 });
881 } 894 }
  895 +
882 /* 896 /*
883 - *  
884 - * 点击禁用和开启视频  
885 - * */ 897 + *
  898 + * 点击禁用和开启视频
  899 + * */
886 _clickVideoMuted(evt) { 900 _clickVideoMuted(evt) {
887 let className = evt.currentTarget.className; 901 let className = evt.currentTarget.className;
888 let idArr = (evt.currentTarget.id).split("_"); 902 let idArr = (evt.currentTarget.id).split("_");
@@ -894,13 +908,14 @@ class WebRtcApe extends Emiter { @@ -894,13 +908,14 @@ class WebRtcApe extends Emiter {
894 loger.log("点击禁用视频->" + uid); 908 loger.log("点击禁用视频->" + uid);
895 this.sendChangeUserMediaEnabled({nodeId: uid, video: false, audio: true}); 909 this.sendChangeUserMediaEnabled({nodeId: uid, video: false, audio: true});
896 } else { 910 } else {
897 - loger.log("点击解除视频禁用->"+uid); 911 + loger.log("点击解除视频禁用->" + uid);
898 this.sendChangeUserMediaEnabled({nodeId: uid, video: true, audio: true}); 912 this.sendChangeUserMediaEnabled({nodeId: uid, video: true, audio: true});
899 } 913 }
900 } 914 }
  915 +
901 /* 916 /*
902 - * 点击禁音和开启按钮切换  
903 - * */ 917 + * 点击禁音和开启按钮切换
  918 + * */
904 _clickAudioMuted(evt) { 919 _clickAudioMuted(evt) {
905 let className = evt.currentTarget.className; 920 let className = evt.currentTarget.className;
906 let idArr = (evt.currentTarget.id).split("_"); 921 let idArr = (evt.currentTarget.id).split("_");
@@ -925,11 +940,10 @@ class WebRtcApe extends Emiter { @@ -925,11 +940,10 @@ class WebRtcApe extends Emiter {
925 } 940 }
926 941
927 /* 942 /*
928 - * 收到控制音视频禁用消息 943 + * 收到控制音视频禁用消息 {nodeId: uid, video: true, audio: false}
929 * */ 944 * */
930 receiveWebRtcMeiaEnabledChange(_data) { 945 receiveWebRtcMeiaEnabledChange(_data) {
931 - loger.log("收到控制音视频禁用消息", _data);  
932 - // {nodeId: uid, video: true, audio: false} 946 + loger.log("收到控制音视频禁用消息", _data, "myNodeId:" + GlobalConfig.nodeId + " isEnableVideo:" + this.isEnableVideo + " isEnableAudio:" + this.isEnableAudio);
933 if (!_data) { 947 if (!_data) {
934 return; 948 return;
935 } 949 }
@@ -937,17 +951,18 @@ class WebRtcApe extends Emiter { @@ -937,17 +951,18 @@ class WebRtcApe extends Emiter {
937 if (_data.nodeId != GlobalConfig.nodeId) { 951 if (_data.nodeId != GlobalConfig.nodeId) {
938 //不是自己的只设置状态显示即可 952 //不是自己的只设置状态显示即可
939 //音频 953 //音频
940 - this.setUidAudioEnabledStatus(_data.nodeId,Boolean(_data.audio)); 954 + this.setUidAudioEnabledStatus(_data.nodeId, Boolean(_data.audio));
941 //视频 955 //视频
942 - this.setUidVideoEnabledStatus(_data.nodeId,Boolean(_data.video)); 956 + this.setUidVideoEnabledStatus(_data.nodeId, Boolean(_data.video));
943 } else { 957 } else {
944 //控制自己的音频 958 //控制自己的音频
945 - if(this.isEnableVideo==_data.video&&this.isEnableAudio==_data.audio){ 959 + if (this.isEnableVideo == _data.video && this.isEnableAudio == _data.audio) {
  960 + loger.log("收到控制音视频禁用消息->自己当前状态一直不需要设置:", _data);
946 return; 961 return;
947 } 962 }
948 //记录自己当前的音视频禁用状态 963 //记录自己当前的音视频禁用状态
949 - this.isEnableVideo=_data.video;  
950 - this.isEnableAudio=_data.audio; 964 + this.isEnableVideo = _data.video;
  965 + this.isEnableAudio = _data.audio;
951 966
952 if (_data.audio == false) { 967 if (_data.audio == false) {
953 this.disableAudio(_data.nodeId); 968 this.disableAudio(_data.nodeId);
@@ -961,10 +976,10 @@ class WebRtcApe extends Emiter { @@ -961,10 +976,10 @@ class WebRtcApe extends Emiter {
961 this.enableVideo(_data.nodeId); 976 this.enableVideo(_data.nodeId);
962 } 977 }
963 //更新同步用户的媒体禁用状态 978 //更新同步用户的媒体禁用状态
964 - loger.log("更新同步用户的媒体禁用状态",_data);  
965 - if(_data){  
966 - this._emit(WebRtcApe.UPDATE_USER_MEDIA_MUTED_STATUS,_data);  
967 - } 979 + loger.log("更新同步用户的媒体禁用状态", _data);
  980 + if (_data) {
  981 + this._emit(WebRtcApe.UPDATE_USER_MEDIA_MUTED_STATUS, _data);
  982 + }
968 } 983 }
969 } 984 }
970 985
@@ -975,7 +990,7 @@ class WebRtcApe extends Emiter { @@ -975,7 +990,7 @@ class WebRtcApe extends Emiter {
975 if (parseInt(uid) == GlobalConfig.nodeId) { 990 if (parseInt(uid) == GlobalConfig.nodeId) {
976 loger.log("开启禁音:" + uid); 991 loger.log("开启禁音:" + uid);
977 if (this.localStream) { 992 if (this.localStream) {
978 - this.setUidAudioEnabledStatus(uid,false); 993 + this.setUidAudioEnabledStatus(uid, false);
979 this.localStream.disableAudio(); 994 this.localStream.disableAudio();
980 } 995 }
981 } 996 }
@@ -989,7 +1004,7 @@ class WebRtcApe extends Emiter { @@ -989,7 +1004,7 @@ class WebRtcApe extends Emiter {
989 loger.log("开启音频:" + uid); 1004 loger.log("开启音频:" + uid);
990 if (this.localStream) { 1005 if (this.localStream) {
991 this.localStream.enableAudio(); 1006 this.localStream.enableAudio();
992 - this.setUidAudioEnabledStatus(uid,true); 1007 + this.setUidAudioEnabledStatus(uid, true);
993 } 1008 }
994 } 1009 }
995 } 1010 }
@@ -1000,16 +1015,16 @@ class WebRtcApe extends Emiter { @@ -1000,16 +1015,16 @@ class WebRtcApe extends Emiter {
1000 * isEnable true开启 false 禁用 1015 * isEnable true开启 false 禁用
1001 * 1016 *
1002 * */ 1017 * */
1003 - setUidAudioEnabledStatus(uid, isEnable){  
1004 - loger.log("设置音频禁用按钮的状态",uid,isEnable);  
1005 - if(isEnable==true){ 1018 + setUidAudioEnabledStatus(uid, isEnable) {
  1019 + loger.log("设置音频禁用按钮的状态", uid, isEnable);
  1020 + if (isEnable == true) {
1006 $("#" + this.audioMutedIdName + uid).removeClass("microphoneOff"); 1021 $("#" + this.audioMutedIdName + uid).removeClass("microphoneOff");
1007 $("#" + this.audioMutedIdName + uid).addClass("audioAndVideMuted microphoneOn"); 1022 $("#" + this.audioMutedIdName + uid).addClass("audioAndVideMuted microphoneOn");
1008 - $("#" + this.audioMutedIdName + uid).attr("title",this.closeMicrophoneTitle);  
1009 - }else{ 1023 + $("#" + this.audioMutedIdName + uid).attr("title", this.closeMicrophoneTitle);
  1024 + } else {
1010 $("#" + this.audioMutedIdName + uid).removeClass("microphoneOn"); 1025 $("#" + this.audioMutedIdName + uid).removeClass("microphoneOn");
1011 $("#" + this.audioMutedIdName + uid).addClass("audioAndVideMuted microphoneOff"); 1026 $("#" + this.audioMutedIdName + uid).addClass("audioAndVideMuted microphoneOff");
1012 - $("#" + this.audioMutedIdName + uid).attr("title",this.openMicrophoneTitle); 1027 + $("#" + this.audioMutedIdName + uid).attr("title", this.openMicrophoneTitle);
1013 } 1028 }
1014 } 1029 }
1015 1030
@@ -1020,7 +1035,7 @@ class WebRtcApe extends Emiter { @@ -1020,7 +1035,7 @@ class WebRtcApe extends Emiter {
1020 if (parseInt(uid) == GlobalConfig.nodeId) { 1035 if (parseInt(uid) == GlobalConfig.nodeId) {
1021 loger.log("禁用摄像头:" + uid); 1036 loger.log("禁用摄像头:" + uid);
1022 if (this.localStream) { 1037 if (this.localStream) {
1023 - this.setUidVideoEnabledStatus(uid,false); 1038 + this.setUidVideoEnabledStatus(uid, false);
1024 this.localStream.disableVideo(); 1039 this.localStream.disableVideo();
1025 } 1040 }
1026 } 1041 }
@@ -1034,30 +1049,40 @@ class WebRtcApe extends Emiter { @@ -1034,30 +1049,40 @@ class WebRtcApe extends Emiter {
1034 if (this.localStream) { 1049 if (this.localStream) {
1035 loger.log("开启摄像头:" + uid); 1050 loger.log("开启摄像头:" + uid);
1036 this.localStream.enableVideo(); 1051 this.localStream.enableVideo();
1037 - this.setUidVideoEnabledStatus(uid,true); 1052 + this.setUidVideoEnabledStatus(uid, true);
1038 } 1053 }
1039 } 1054 }
1040 } 1055 }
  1056 +
1041 /* 1057 /*
1042 - * 设置视频禁用按钮的状态 1058 + * 设置视频禁用按钮的状态
1043 * uid nodeId 1059 * uid nodeId
1044 * isEnable true开启 false 禁用 1060 * isEnable true开启 false 禁用
1045 * 1061 *
1046 - * */  
1047 - setUidVideoEnabledStatus(uid, isEnable){  
1048 - loger.log("设置视频禁用按钮的状态",uid,isEnable);  
1049 - if(isEnable==true){ 1062 + * */
  1063 + setUidVideoEnabledStatus(uid, isEnable) {
  1064 + loger.log("设置视频禁用按钮的状态", uid, isEnable);
  1065 + let user = GlobalConfig.getUserInfoFromeNodeId(parseInt(uid));
  1066 + if(user&&user.cameras&&user.cameras.length<1){
  1067 + //用户没有摄像头 显示音频封面
  1068 + $("#audioPlayIcoBox" + uid).show();
  1069 + $("#" + this.videoMutedIdName + uid).hide();
  1070 + return;
  1071 + }
  1072 + if (isEnable == true) {
1050 //开启 1073 //开启
  1074 + $("#audioPlayIcoBox" + uid).hide();
1051 $("#" + this.videoMutedIdName + uid).removeClass("cameraOff"); 1075 $("#" + this.videoMutedIdName + uid).removeClass("cameraOff");
1052 $("#" + this.videoMutedIdName + uid).addClass("audioAndVideMuted cameraOn"); 1076 $("#" + this.videoMutedIdName + uid).addClass("audioAndVideMuted cameraOn");
1053 - $("#" + this.videoMutedIdName + uid).attr("title",this.closeCameraTitle);  
1054 - $("#audioPlayIcoBox" + uid).hide();  
1055 - }else{ 1077 + $("#" + this.videoMutedIdName + uid).attr("title", this.closeCameraTitle);
  1078 +
  1079 + } else {
1056 //禁用 1080 //禁用
  1081 + $("#audioPlayIcoBox" + uid).show();
1057 $("#" + this.videoMutedIdName + uid).removeClass("cameraOn"); 1082 $("#" + this.videoMutedIdName + uid).removeClass("cameraOn");
1058 $("#" + this.videoMutedIdName + uid).addClass("audioAndVideMuted cameraOff"); 1083 $("#" + this.videoMutedIdName + uid).addClass("audioAndVideMuted cameraOff");
1059 - $("#" + this.videoMutedIdName + uid).attr("title",this.openCameraTitle);  
1060 - $("#audioPlayIcoBox" + uid).show(); 1084 + $("#" + this.videoMutedIdName + uid).attr("title", this.openCameraTitle);
  1085 +
1061 } 1086 }
1062 } 1087 }
1063 1088
@@ -55,5 +55,6 @@ @@ -55,5 +55,6 @@
55 z-index: 1; 55 z-index: 1;
56 /*background-size: 100%;*/ 56 /*background-size: 100%;*/
57 background-repeat: no-repeat; 57 background-repeat: no-repeat;
58 - background-image: url(../../assets/img/audioPlayIco.png); 58 + background-color: #232323;
  59 + background-image: url(../../assets/img/audioPlayIco.gif);
59 } 60 }