李勇

1.人员信息中增加摄像头和麦克风是否被禁用的字段;2.修改用户名长度;3.增加禁用摄像头和麦克风的按钮功能

@@ -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.33.6.20171123"; 66 + GlobalConfig.sdkVersion = "v2.34.5.20171127";
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 //设置
@@ -102,7 +102,8 @@ export default class MessageEntrance extends Emiter { @@ -102,7 +102,8 @@ export default class MessageEntrance extends Emiter {
102 _webRtc.on(MessageTypes.USER_DEVICE_STATUS_CHAANGE, this.userDeviecStatusChange.bind(this)); //监听摄像头和麦克风的开启状态 102 _webRtc.on(MessageTypes.USER_DEVICE_STATUS_CHAANGE, this.userDeviecStatusChange.bind(this)); //监听摄像头和麦克风的开启状态
103 _webRtc.on(MessageTypes.MEDIA_PUBLISH_STATUS_CHANGE, this.mediaPublishStatusChange.bind(this)); //webRtc推流状态发生改变 103 _webRtc.on(MessageTypes.MEDIA_PUBLISH_STATUS_CHANGE, this.mediaPublishStatusChange.bind(this)); //webRtc推流状态发生改变
104 _webRtc.on(WebRtcApe.RE_JOIN_CHANNEL, this._webRtcRejoinChannel.bind(this)); //重先加入音视频频道 104 _webRtc.on(WebRtcApe.RE_JOIN_CHANNEL, this._webRtcRejoinChannel.bind(this)); //重先加入音视频频道
105 - _webRtc.on(MessageTypes.MEDIA_ENABLED_CHANGE, this._mediaEnabledChange.bind(this)); //音视频禁用状态改变 105 + _webRtc.on(MessageTypes.MEDIA_ENABLED_CHANGE, this._mediaEnabledChange.bind(this)); //音视频禁用状态改变 广播消息
  106 + _webRtc.on(MessageTypes.UPDATE_USER_MEDIA_MUTED_STATUS, this._updateUserMediaMutedStatus.bind(this)); //音视频禁用状态改变(自己),同步更新
106 107
107 // Sass平台层 108 // Sass平台层
108 _sass = Sass; 109 _sass = Sass;
@@ -647,20 +648,26 @@ export default class MessageEntrance extends Emiter { @@ -647,20 +648,26 @@ export default class MessageEntrance extends Emiter {
647 648
648 //如果没有名字的时候需要随机生成 649 //如果没有名字的时候需要随机生成
649 let randUserId =parseInt(Math.random()*1000)+"_"+parseInt(Math.random()*1000)+"_"+parseInt(Math.random()*1000); 650 let randUserId =parseInt(Math.random()*1000)+"_"+parseInt(Math.random()*1000)+"_"+parseInt(Math.random()*1000);
  651 + let randUserName=EngineUtils.creatRandomNum(2,".");
650 if (GlobalConfig.userRole == ApeConsts.host) { 652 if (GlobalConfig.userRole == ApeConsts.host) {
651 randUserId = "T" + randUserId; 653 randUserId = "T" + randUserId;
  654 + randUserName= "T" + randUserName;
652 } else if (GlobalConfig.userRole == ApeConsts.assistant) { 655 } else if (GlobalConfig.userRole == ApeConsts.assistant) {
653 randUserId = "A" + randUserId; 656 randUserId = "A" + randUserId;
  657 + randUserName= "A" + randUserName;
654 } else if (GlobalConfig.userRole == ApeConsts.presenter) { 658 } else if (GlobalConfig.userRole == ApeConsts.presenter) {
655 randUserId = "P" + randUserId; 659 randUserId = "P" + randUserId;
  660 + randUserName= "O" + randUserName;
656 } else if (GlobalConfig.userRole == ApeConsts.invisible) { 661 } else if (GlobalConfig.userRole == ApeConsts.invisible) {
657 randUserId = "I" + randUserId; 662 randUserId = "I" + randUserId;
  663 + randUserName= "I" + randUserName;
658 } else { 664 } else {
659 randUserId = "S" + randUserId; 665 randUserId = "S" + randUserId;
  666 + randUserName= "S" + randUserName;
660 } 667 }
661 668
662 //如果没有名字,随机起一个名字 669 //如果没有名字,随机起一个名字
663 - GlobalConfig.userName = _param.userName || randUserId; 670 + GlobalConfig.userName = _param.userName || randUserName;
664 //如果没有userId或者为"0",随机生成 671 //如果没有userId或者为"0",随机生成
665 if (!GlobalConfig.userId || GlobalConfig.userId == "0") { 672 if (!GlobalConfig.userId || GlobalConfig.userId == "0") {
666 GlobalConfig.userId = randUserId; 673 GlobalConfig.userId = randUserId;
@@ -1417,7 +1424,7 @@ export default class MessageEntrance extends Emiter { @@ -1417,7 +1424,7 @@ export default class MessageEntrance extends Emiter {
1417 return; 1424 return;
1418 } 1425 }
1419 if(_webRtc){ 1426 if(_webRtc){
1420 - _webRtc.webRtcMeiaEnabledChange(_data); 1427 + _webRtc.receiveWebRtcMeiaEnabledChange(_data);
1421 } 1428 }
1422 } 1429 }
1423 //手动切换MS -> {ip;"xxx.xx.xx","port":"xxxx"} 1430 //手动切换MS -> {ip;"xxx.xx.xx","port":"xxxx"}
@@ -2179,6 +2186,17 @@ export default class MessageEntrance extends Emiter { @@ -2179,6 +2186,17 @@ export default class MessageEntrance extends Emiter {
2179 _confer_ape.sendMediaEnabledChange(_data); 2186 _confer_ape.sendMediaEnabledChange(_data);
2180 } 2187 }
2181 } 2188 }
  2189 + /*
  2190 + * 同步媒体的禁用状态
  2191 + * */
  2192 + _updateUserMediaMutedStatus(_data){
  2193 + if (!_mcu.connected||GlobalConfig.isRecordPlayBack) {
  2194 + return;
  2195 + }
  2196 + if(_confer_ape){
  2197 + _confer_ape.sendUpdateUserMediaMutedStatus(_data);
  2198 + }
  2199 + }
2182 2200
2183 //监听摄像头麦克风状态 2201 //监听摄像头麦克风状态
2184 userDeviecStatusChange(_data) { 2202 userDeviecStatusChange(_data) {
@@ -557,6 +557,10 @@ GlobalConfig.handUpTime = 0; @@ -557,6 +557,10 @@ GlobalConfig.handUpTime = 0;
557 GlobalConfig.level = 0; 557 GlobalConfig.level = 0;
558 GlobalConfig.openCamera = 0; 558 GlobalConfig.openCamera = 0;
559 GlobalConfig.openMicrophones = 0; 559 GlobalConfig.openMicrophones = 0;
  560 +//音视频是否被禁用
  561 +GlobalConfig.videoEnabled =true;
  562 +GlobalConfig.audioEnabled=true;
  563 +
560 GlobalConfig.selfDisEnableDrawTime = 1;//记录是否禁用画笔,0为启用画笔,大于0时被禁用的时间戳 564 GlobalConfig.selfDisEnableDrawTime = 1;//记录是否禁用画笔,0为启用画笔,大于0时被禁用的时间戳
561 565
562 //视频质量相关设置 566 //视频质量相关设置
@@ -121,6 +121,9 @@ class ConferApe extends Ape { @@ -121,6 +121,9 @@ class ConferApe extends Ape {
121 nodeInfoRecordPdu.videoQuality = GlobalConfig.videoQuality; 121 nodeInfoRecordPdu.videoQuality = GlobalConfig.videoQuality;
122 nodeInfoRecordPdu.userIp = GlobalConfig.userIp; 122 nodeInfoRecordPdu.userIp = GlobalConfig.userIp;
123 123
  124 + nodeInfoRecordPdu.videoEnabled = GlobalConfig.videoEnabled;
  125 + nodeInfoRecordPdu.audioEnabled =GlobalConfig.audioEnabled;
  126 +
124 nodeInfoRecordPdu.curVideoQuality = GlobalConfig.curVideoQuality; 127 nodeInfoRecordPdu.curVideoQuality = GlobalConfig.curVideoQuality;
125 nodeInfoRecordPdu.micGain = GlobalConfig.micGain; 128 nodeInfoRecordPdu.micGain = GlobalConfig.micGain;
126 nodeInfoRecordPdu.micNoise = GlobalConfig.micNoise; 129 nodeInfoRecordPdu.micNoise = GlobalConfig.micNoise;
@@ -1056,6 +1059,14 @@ class ConferApe extends Ape { @@ -1056,6 +1059,14 @@ class ConferApe extends Ape {
1056 if(!GlobalConfig.isH5){ 1059 if(!GlobalConfig.isH5){
1057 this._emit(MessageTypes.CLASS_INSERT_ROSTER, {"nodeId": nodeId, "nodeData": newNodeData}); 1060 this._emit(MessageTypes.CLASS_INSERT_ROSTER, {"nodeId": nodeId, "nodeData": newNodeData});
1058 this.emitRosterChange(); 1061 this.emitRosterChange();
  1062 +
  1063 + //更新webRtc模块的音视频禁用状态
  1064 + //{nodeId: uid, video: true, audio: false}
  1065 + //消息自己的不处理
  1066 + if(nodeId!=GlobalConfig.nodeId&&(newNodeData.openCamera>0||newNodeData.openMicrophones>0)){
  1067 + this.receiveChangeUserMediaEnabledStatus({nodeId:nodeId,video:newNodeData.videoEnabled,audio:newNodeData.audioEnabled});
  1068 + }
  1069 +
1059 } 1070 }
1060 } else { 1071 } else {
1061 //loger.log("更新人员列表数据,rosterExists已经存在",rosterExists); 1072 //loger.log("更新人员列表数据,rosterExists已经存在",rosterExists);
@@ -1069,8 +1080,14 @@ class ConferApe extends Ape { @@ -1069,8 +1080,14 @@ class ConferApe extends Ape {
1069 } 1080 }
1070 if(!GlobalConfig.isH5){ 1081 if(!GlobalConfig.isH5){
1071 this._emit(MessageTypes.CLASS_UPDATE_ROSTER, {"nodeId": nodeId, "nodeData": newNodeData}); 1082 this._emit(MessageTypes.CLASS_UPDATE_ROSTER, {"nodeId": nodeId, "nodeData": newNodeData});
1072 - }  
1073 1083
  1084 + //更新webRtc模块的音视频禁用状态
  1085 + //{nodeId: uid, video: true, audio: false}
  1086 + //消息自己的不处理
  1087 + if(nodeId!=GlobalConfig.nodeId){
  1088 + this.receiveChangeUserMediaEnabledStatus({nodeId:nodeId,video:newNodeData.videoEnabled,audio:newNodeData.audioEnabled});
  1089 + }
  1090 + }
1074 } 1091 }
1075 } 1092 }
1076 1093
@@ -1128,11 +1145,22 @@ class ConferApe extends Ape { @@ -1128,11 +1145,22 @@ class ConferApe extends Ape {
1128 }catch (err){ 1145 }catch (err){
1129 loger.warn("发送->媒体开启或禁用->失败",_data,err.message); 1146 loger.warn("发送->媒体开启或禁用->失败",_data,err.message);
1130 } 1147 }
1131 -  
1132 } 1148 }
1133 1149
1134 /* 1150 /*
1135 - * 收到媒体开启或禁用控制 1151 + * 同步用户的媒体禁用状态
  1152 + * */
  1153 + sendUpdateUserMediaMutedStatus(_data){
  1154 + if(!_data){
  1155 + return;
  1156 + }
  1157 + loger.log('发送同步用户的媒体禁用状态->', _data);
  1158 + GlobalConfig.videoEnabled =Boolean(_data.video);
  1159 + GlobalConfig.audioEnabled =Boolean(_data.audio);
  1160 + this.updateUserInfo();
  1161 + }
  1162 + /*
  1163 + * 收到媒体开启或禁用控制消息或同步消息
1136 * */ 1164 * */
1137 receiveChangeUserMediaEnabledStatus(_data){ 1165 receiveChangeUserMediaEnabledStatus(_data){
1138 this._emit(MessageTypes.RECEIVE_MEDIA_ENABLED_CHANGE,_data); 1166 this._emit(MessageTypes.RECEIVE_MEDIA_ENABLED_CHANGE,_data);
@@ -36,6 +36,7 @@ class WebRtcApe extends Emiter { @@ -36,6 +36,7 @@ class WebRtcApe extends Emiter {
36 this.channelId = ""; 36 this.channelId = "";
37 this.uid = 0; 37 this.uid = 0;
38 this.info = "" 38 this.info = ""
  39 + this.videAndAudioMutedStatusData={};//记录当前自己的摄像头和麦克风禁用状态
39 40
40 this.reAddRemoteStreamDelay = 0;//重连远程视频的计时器 41 this.reAddRemoteStreamDelay = 0;//重连远程视频的计时器
41 this.rePublishDelay = 0;//重新推流的间隔 42 this.rePublishDelay = 0;//重新推流的间隔
@@ -88,6 +89,14 @@ class WebRtcApe extends Emiter { @@ -88,6 +89,14 @@ class WebRtcApe extends Emiter {
88 this.invisibleVideoHeight = SIZE_360; 89 this.invisibleVideoHeight = SIZE_360;
89 this.xdyRemote = "xdy_remote"; 90 this.xdyRemote = "xdy_remote";
90 91
  92 + this.audioMutedIdName = "audioMutedIdName_";
  93 + this.videoMutedIdName = "videoMutedIdName_";
  94 +
  95 + this.closeCameraTitle="close Camera";
  96 + this.openCameraTitle="open Camera";
  97 + this.closeMicrophoneTitle="close Microphone";
  98 + this.openMicrophoneTitle="open Microphone";
  99 +
91 this.localWebRtcVideoClass = 'localWebRtcVideoClass';//本地视图统一的class名称 100 this.localWebRtcVideoClass = 'localWebRtcVideoClass';//本地视图统一的class名称
92 this.invisibleWebRtcVideoClass = 'invisibleWebRtcVideoClass'; 101 this.invisibleWebRtcVideoClass = 'invisibleWebRtcVideoClass';
93 this.normalWebRtcVideoClass = 'normalWebRtcVideoClass'; 102 this.normalWebRtcVideoClass = 'normalWebRtcVideoClass';
@@ -217,31 +226,47 @@ class WebRtcApe extends Emiter { @@ -217,31 +226,47 @@ class WebRtcApe extends Emiter {
217 $("#" + this.xdyRemote + uid).remove(); 226 $("#" + this.xdyRemote + uid).remove();
218 } 227 }
219 let audioMutedDiv = ""; 228 let audioMutedDiv = "";
  229 + let videoMutedDiv="";
  230 + let videoAndAudioBox=""
220 if (GlobalConfig.isTeachOrAssistant || GlobalConfig.isInvisible) { 231 if (GlobalConfig.isTeachOrAssistant || GlobalConfig.isInvisible) {
221 - audioMutedDiv = `<div class="audioMuted audioOpen" id=${"audioMuted_"+uid}></div>`; 232 + if(user&&user.videoEnabled==true){
  233 + videoMutedDiv = `<div class="audioAndVideMuted cameraOn" id=${this.videoMutedIdName + uid} title="${this.closeCameraTitle}"></div>`
  234 + }else{
  235 + videoMutedDiv = `<div class="audioAndVideMuted cameraOff" id=${this.videoMutedIdName + uid} title="${this.closeCameraTitle}"></div>`
  236 + }
  237 + if(user&&user.audioEnabled==true){
  238 + audioMutedDiv = `<div class="audioAndVideMuted microphoneOn " id=${this.audioMutedIdName + uid} title="${this.closeMicrophoneTitle}"></div>`;
  239 + }else{
  240 + audioMutedDiv = `<div class="audioAndVideMuted microphoneff " id=${this.audioMutedIdName + uid} title="${this.closeMicrophoneTitle}"></div>`;
  241 + }
  242 + videoAndAudioBox=`<div class="audioAndVideBox unOpenVideo">${videoMutedDiv+audioMutedDiv}</div>`;
222 } 243 }
223 244
224 if (userRole == ApeConsts.invisible) { 245 if (userRole == ApeConsts.invisible) {
225 - let nameDiv = `<div style=${this.invisibleVideoWidth}px;height:22px; position: absolute;bottom: 2px; z-index: 1;overflow:hidden;font-size: 14px;text-align: right; vertical-align: middle;background-color: #2926251a;color: #e7e7e7display:${this.nameDisplay}">${userName + audioMutedDiv}</div>`; 246 + 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;background-color: #2926251a;color: #e7e7e7display:${this.nameDisplay}">${userName}</div>`;
226 //把远程视频添加到监课列表 247 //把远程视频添加到监课列表
227 loger.log("获取远程视频流成功->监课:" + userName + "->" + uid, new Date().getTime()); 248 loger.log("获取远程视频流成功->监课:" + userName + "->" + uid, new Date().getTime());
228 - 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}</div>`; 249 + 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>`;
229 $(this.invisibleViewId).append(viewDiv); 250 $(this.invisibleViewId).append(viewDiv);
230 } else if (userRole == ApeConsts.host || userRole == ApeConsts.assistant || userRole == ApeConsts.presenter) { 251 } else if (userRole == ApeConsts.host || userRole == ApeConsts.assistant || userRole == ApeConsts.presenter) {
231 - let nameDiv = `<div style="width:${this.hostRemoteVideoWidth}px;height:22px; position: absolute;bottom: 2px; z-index: 1;overflow:hidden;font-size: 14px;text-align: right;vertical-align: middle; background-color: #2926251a;color: #e7e7e7;display:${this.nameDisplay}">${userName + audioMutedDiv}</div>`; 252 + 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; background-color: #2926251a;color: #e7e7e7;display:${this.nameDisplay}">${userName }</div>`;
232 //把远程视图添加到老师列表 253 //把远程视图添加到老师列表
233 loger.log("获取远程视频流成功->userRole:" + userRole + ":" + userName + "->" + uid, new Date().getTime()); 254 loger.log("获取远程视频流成功->userRole:" + userRole + ":" + userName + "->" + uid, new Date().getTime());
234 - 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}</div>`; 255 + 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>`;
235 $(this.hostRemoteViewId).prepend(viewDiv); 256 $(this.hostRemoteViewId).prepend(viewDiv);
236 } else { 257 } else {
237 - let nameDiv = `<div style="width:${this.normalRemoteVideoWidth}px;height:22px; position: absolute;bottom: 2px; z-index: 1;overflow:hidden;font-size: 14px;text-align: right;vertical-align: middle;background-color: #2926251a;color: #e7e7e7;display:${this.nameDisplay}">${userName + audioMutedDiv}</div>`; 258 + 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;background-color: #2926251a;color: #e7e7e7;display:${this.nameDisplay}">${userName}</div>`;
238 //把视图添加到学生列表 259 //把视图添加到学生列表
239 loger.log("获取远程视频流成功->学生:" + userName + "->" + uid, new Date().getTime()); 260 loger.log("获取远程视频流成功->学生:" + userName + "->" + uid, new Date().getTime());
240 - 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}</div>`; 261 + 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>`;
241 $(this.normalRemoteViewId).append(viewDiv); 262 $(this.normalRemoteViewId).append(viewDiv);
242 } 263 }
243 - $("#audioMuted_" + uid).off("click", this._clickAudioMuted.bind(this));  
244 - $("#audioMuted_" + uid).on("click", this._clickAudioMuted.bind(this)); 264 + $("#" + this.videoMutedIdName + uid).off("click", this._clickVideoMuted.bind(this));
  265 + $("#" + this.audioMutedIdName + uid).off("click", this._clickAudioMuted.bind(this));
  266 +
  267 + $("#" + this.videoMutedIdName + uid).on("click", this._clickVideoMuted.bind(this));
  268 + $("#" + this.audioMutedIdName + uid).on("click", this._clickAudioMuted.bind(this));
  269 +
245 //播放视频,隐藏控制条 270 //播放视频,隐藏控制条
246 try { 271 try {
247 $("#bar_" + stream.getId()).hide(); 272 $("#bar_" + stream.getId()).hide();
@@ -554,14 +579,28 @@ class WebRtcApe extends Emiter { @@ -554,14 +579,28 @@ class WebRtcApe extends Emiter {
554 if (user) { 579 if (user) {
555 userName = user.name || ""; 580 userName = user.name || "";
556 } 581 }
  582 + /* let audioMutedDiv = "";
  583 + if (GlobalConfig.isTeachOrAssistant) {
  584 + audioMutedDiv = `<div class="audioAndVideMuted microphoneOn openVideo" id=${this.audioMutedIdName + this.uid}></div>`;
  585 + }
  586 +*/
557 let audioMutedDiv = ""; 587 let audioMutedDiv = "";
  588 + let videoMutedDiv="";
  589 + let videoAndAudioBox=""
558 if (GlobalConfig.isTeachOrAssistant) { 590 if (GlobalConfig.isTeachOrAssistant) {
559 - audioMutedDiv = `<div class="audioMuted audioOpen" id=${"audioMuted_"+this.uid}></div>`; 591 + videoMutedDiv =`<div class="audioAndVideMuted cameraOn " id=${this.videoMutedIdName + this.uid} title="${this.closeCameraTitle}"></div>`;
  592 + audioMutedDiv =`<div class="audioAndVideMuted microphoneOn " id=${this.audioMutedIdName + this.uid} title="${this.closeMicrophoneTitle}"></div>`;
  593 + videoAndAudioBox=`<div class="audioAndVideBox openVideo">${videoMutedDiv+audioMutedDiv}</div>`;
560 } 594 }
561 - let nameDiv = `<div id="${"videoOwnerName_" + this.uid}" class="localVideoOwnerName" style="width:${this.localVideoWidth}px;height:22px; position: absolute;bottom: 2px; z-index: 1;overflow:hidden;font-size: 14px;text-align: right; vertical-align: middle;background-color: #2926251a;color: #e7e7e7;display:${this.nameDisplay}">${userName + audioMutedDiv}</div>`; 595 +
  596 + let nameDiv = `<div id="${"videoOwnerName_" + this.uid}" class="localVideoOwnerName" style="width:${this.localVideoWidth}px;height:26px; position: absolute;bottom: 2px;right:4px; z-index: 1;overflow:hidden;font-size: 14px;text-align: right; vertical-align:bottom;color: #e7e7e7;display:${this.nameDisplay}">${videoAndAudioBox+userName}</div>`;
562 $(this.localViewId).prepend(nameDiv); 597 $(this.localViewId).prepend(nameDiv);
563 - $(".audioMuted").off("click", this._clickAudioMuted.bind(this));  
564 - $(".audioMuted").on("click", this._clickAudioMuted.bind(this)); 598 +
  599 + $("#" + this.videoMutedIdName + this.uid).off("click", this._clickVideoMuted.bind(this));
  600 + $("#" + this.audioMutedIdName + this.uid).off("click", this._clickAudioMuted.bind(this));
  601 +
  602 + $("#" + this.videoMutedIdName + this.uid).on("click", this._clickVideoMuted.bind(this));
  603 + $("#" + this.audioMutedIdName + this.uid).on("click", this._clickAudioMuted.bind(this));
565 604
566 loger.log("webRtc->推流->", viewName, new Date().getTime()); 605 loger.log("webRtc->推流->", viewName, new Date().getTime());
567 this.localStream.play(viewName); 606 this.localStream.play(viewName);
@@ -819,35 +858,67 @@ class WebRtcApe extends Emiter { @@ -819,35 +858,67 @@ class WebRtcApe extends Emiter {
819 this._emit(MessageTypes.GET_DEVICES_SUCCESS, _deviceData); 858 this._emit(MessageTypes.GET_DEVICES_SUCCESS, _deviceData);
820 }); 859 });
821 } 860 }
822 - 861 + /*
  862 + *
  863 + * 点击禁用和开启视频
  864 + * */
  865 + _clickVideoMuted(evt) {
  866 + let className = evt.currentTarget.className;
  867 + loger.log("点击禁用和开启视频", evt.currentTarget.id);
  868 + let idArr = (evt.currentTarget.id).split("_");
  869 + let uid = 10000000;//默认设置一个不存在的uid
  870 + if (idArr && idArr.length > 1) {
  871 + uid = parseInt(idArr[1]);
  872 + }
  873 + if (className.indexOf("cameraOn") > 0) {
  874 + loger.log("点击禁用视频->" + uid);
  875 + this.sendChangeUserMediaEnabled({nodeId: uid, video: false, audio: true});
  876 + /*if (uid != GlobalConfig.nodeId) {
  877 + this.sendChangeUserMediaEnabled({nodeId: uid, video: false, audio: true});
  878 + this.setUidVideoEnabledStatus(uid,false);
  879 + } else {
  880 + this.disableVideo(uid);
  881 + }*/
  882 + } else {
  883 + loger.log("点击开启视频");
  884 + this.sendChangeUserMediaEnabled({nodeId: uid, video: true, audio: true});
  885 + /* if (uid != GlobalConfig.nodeId) {
  886 + this.sendChangeUserMediaEnabled({nodeId: uid, video: true, audio: true});
  887 + this.setUidVideoEnabledStatus(uid,true);
  888 + } else {
  889 + this.enableVideo(uid);
  890 + }*/
  891 + }
  892 + }
  893 + /*
  894 + * 点击禁音和开启按钮切换
  895 + * */
823 _clickAudioMuted(evt) { 896 _clickAudioMuted(evt) {
824 let className = evt.currentTarget.className; 897 let className = evt.currentTarget.className;
825 - console.log("点击禁音",evt.currentTarget.id); 898 + loger.log("点击禁音和开启按钮切换", evt.currentTarget.id);
826 let idArr = (evt.currentTarget.id).split("_"); 899 let idArr = (evt.currentTarget.id).split("_");
827 let uid = 10000000;//默认设置一个不存在的uid 900 let uid = 10000000;//默认设置一个不存在的uid
828 if (idArr && idArr.length > 1) { 901 if (idArr && idArr.length > 1) {
829 uid = parseInt(idArr[1]); 902 uid = parseInt(idArr[1]);
830 } 903 }
831 - if (className.indexOf("audioOpen") > 0) {  
832 - loger.log("点击禁音->"+uid);  
833 - // evt.currentTarget.className="audioMuted audioClose";  
834 - if (uid != GlobalConfig.nodeId) { 904 + if (className.indexOf("microphoneOn") > 0) {
  905 + loger.log("点击禁音->" + uid);
835 this.sendChangeUserMediaEnabled({nodeId: uid, video: true, audio: false}); 906 this.sendChangeUserMediaEnabled({nodeId: uid, video: true, audio: false});
836 - $("#audioMuted_" + uid).removeClass();  
837 - $("#audioMuted_" + uid).addClass("audioMuted audioClose"); 907 + /*if (uid != GlobalConfig.nodeId) {
  908 + this.sendChangeUserMediaEnabled({nodeId: uid, video: true, audio: false});
  909 + this.setUidAudioEnabledStatus(uid,false);
838 } else { 910 } else {
839 this.disableAudio(uid); 911 this.disableAudio(uid);
840 - } 912 + }*/
841 } else { 913 } else {
842 loger.log("点击开启声音"); 914 loger.log("点击开启声音");
843 - //evt.currentTarget.className="audioMuted audioOpen";  
844 - if (uid != GlobalConfig.nodeId) {  
845 this.sendChangeUserMediaEnabled({nodeId: uid, video: true, audio: true}); 915 this.sendChangeUserMediaEnabled({nodeId: uid, video: true, audio: true});
846 - $("#audioMuted_" + uid).removeClass();  
847 - $("#audioMuted_" + uid).addClass("audioMuted audioOpen"); 916 + /*if (uid != GlobalConfig.nodeId) {
  917 + this.sendChangeUserMediaEnabled({nodeId: uid, video: true, audio: true});
  918 + this.setUidAudioEnabledStatus(uid,true);
848 } else { 919 } else {
849 this.enableAudio(uid); 920 this.enableAudio(uid);
850 - } 921 + }*/
851 } 922 }
852 } 923 }
853 924
@@ -861,29 +932,53 @@ class WebRtcApe extends Emiter { @@ -861,29 +932,53 @@ class WebRtcApe extends Emiter {
861 /* 932 /*
862 * 收到控制音视频禁用消息 933 * 收到控制音视频禁用消息
863 * */ 934 * */
864 - webRtcMeiaEnabledChange(_data) {  
865 - loger.log("收到控制音视频禁用消息",_data); 935 + receiveWebRtcMeiaEnabledChange(_data) {
  936 + loger.log("收到控制音视频禁用消息", _data);
866 // {nodeId: uid, video: true, audio: false} 937 // {nodeId: uid, video: true, audio: false}
867 - if(!_data){ 938 + if (!_data) {
868 return; 939 return;
869 } 940 }
870 - if(_data.nodeId!=GlobalConfig.nodeId){  
871 - if(_data.audio==false){  
872 - $("#audioMuted_" + _data.nodeId).removeClass();  
873 - $("#audioMuted_" + _data.nodeId).addClass("audioMuted audioClose");  
874 - }else {  
875 - $("#audioMuted_" + _data.nodeId).removeClass();  
876 - $("#audioMuted_" + _data.nodeId).addClass("audioMuted audioOpen"); 941 + this.videAndAudioMutedStatusData=_data;
  942 + if (_data.nodeId != GlobalConfig.nodeId) {
  943 + //不是自己的只设置状态显示即可
  944 + //音频
  945 + if (_data.audio == false) {
  946 + //$("#" + this.audioMutedIdName + _data.nodeId).removeClass("microphoneOn");
  947 + //$("#" + this.audioMutedIdName + _data.nodeId).addClass("audioAndVideMuted microphoneOff");
  948 + this.setUidAudioEnabledStatus(_data.nodeId,false);
  949 + } else {
  950 + //$("#" + this.audioMutedIdName + _data.nodeId).removeClass("microphoneOff");
  951 + //$("#" + this.audioMutedIdName + _data.nodeId).addClass("audioAndVideMuted microphoneOn");
  952 + this.setUidAudioEnabledStatus(_data.nodeId,true);
  953 + }
  954 + //视频
  955 + if (_data.video == false) {
  956 + //$("#" + this.audioMutedIdName + _data.nodeId).removeClass("microphoneOn");
  957 + //$("#" + this.audioMutedIdName + _data.nodeId).addClass("audioAndVideMuted microphoneOff");
  958 + this.setUidVideoEnabledStatus(_data.nodeId,false);
  959 + } else {
  960 + //$("#" + this.audioMutedIdName + _data.nodeId).removeClass("microphoneOff");
  961 + //$("#" + this.audioMutedIdName + _data.nodeId).addClass("audioAndVideMuted microphoneOn");
  962 + this.setUidVideoEnabledStatus(_data.nodeId,true);
877 } 963 }
878 -  
879 - }else{  
880 - if(_data.audio==false){ 964 + } else {
  965 + //控制自己的音频
  966 + if (_data.audio == false) {
881 this.disableAudio(_data.nodeId); 967 this.disableAudio(_data.nodeId);
882 - }else { 968 + } else {
883 this.enableAudio(_data.nodeId); 969 this.enableAudio(_data.nodeId);
884 } 970 }
  971 + //控制自己的视频
  972 + if (_data.video == false) {
  973 + this.disableVideo(_data.nodeId);
  974 + } else {
  975 + this.enableVideo(_data.nodeId);
  976 + }
  977 + //更新同步用户的媒体禁用状态
  978 + if(this.videAndAudioMutedStatusData){
  979 + this._emit(WebRtcApe.UPDATE_USER_MEDIA_MUTED_STATUS,this.videAndAudioMutedStatusData);
  980 + }
885 } 981 }
886 -  
887 } 982 }
888 983
889 /* 984 /*
@@ -893,8 +988,9 @@ class WebRtcApe extends Emiter { @@ -893,8 +988,9 @@ class WebRtcApe extends Emiter {
893 loger.log("开启禁音:" + uid); 988 loger.log("开启禁音:" + uid);
894 if (parseInt(uid) == GlobalConfig.nodeId) { 989 if (parseInt(uid) == GlobalConfig.nodeId) {
895 if (this.localStream) { 990 if (this.localStream) {
896 - $("#audioMuted_" + uid).removeClass();  
897 - $("#audioMuted_" + uid).addClass("audioMuted audioClose"); 991 + //$("#" + this.audioMutedIdName + uid).removeClass("microphoneOn");
  992 + //$("#" + this.audioMutedIdName + uid).addClass("audioAndVideMuted microphoneOff");
  993 + this.setUidAudioEnabledStatus(uid,false);
898 this.localStream.disableAudio(); 994 this.localStream.disableAudio();
899 } 995 }
900 } 996 }
@@ -903,14 +999,84 @@ class WebRtcApe extends Emiter { @@ -903,14 +999,84 @@ class WebRtcApe extends Emiter {
903 /* 999 /*
904 * 开启音频 1000 * 开启音频
905 * */ 1001 * */
906 - enableAudio(_uid) {  
907 - loger.log("开启音频:" + _uid);  
908 - if (parseInt(_uid) == GlobalConfig.nodeId) { 1002 + enableAudio(uid) {
  1003 + loger.log("开启音频:" + uid);
  1004 + if (parseInt(uid) == GlobalConfig.nodeId) {
909 if (this.localStream) { 1005 if (this.localStream) {
910 this.localStream.enableAudio(); 1006 this.localStream.enableAudio();
911 - $("#audioMuted_" + _uid).removeClass();  
912 - $("#audioMuted_" + _uid).addClass("audioMuted audioOpen"); 1007 + //$("#" + this.audioMutedIdName + _uid).removeClass("microphoneOff");
  1008 + //$("#" + this.audioMutedIdName + _uid).addClass("audioAndVideMuted microphoneOn");
  1009 + this.setUidAudioEnabledStatus(uid,true);
  1010 + }
  1011 + }
  1012 + }
  1013 +
  1014 + /*
  1015 + * 设置音频禁用按钮的状态
  1016 + * uid nodeId
  1017 + * isEnable true开启 false 禁用
  1018 + *
  1019 + * */
  1020 + setUidAudioEnabledStatus(uid, isEnable){
  1021 + loger.log("设置音频禁用按钮的状态",uid,isEnable);
  1022 + if(isEnable==true){
  1023 + $("#" + this.audioMutedIdName + uid).removeClass("microphoneOff");
  1024 + $("#" + this.audioMutedIdName + uid).addClass("audioAndVideMuted microphoneOn");
  1025 + $("#" + this.audioMutedIdName + uid).attr("title",this.closeMicrophoneTitle);
  1026 + }else{
  1027 + $("#" + this.audioMutedIdName + uid).removeClass("microphoneOn");
  1028 + $("#" + this.audioMutedIdName + uid).addClass("audioAndVideMuted microphoneOff");
  1029 + $("#" + this.audioMutedIdName + uid).attr("title",this.openMicrophoneTitle);
  1030 + }
  1031 + }
  1032 +
  1033 + /*
  1034 + * 禁用摄像头
  1035 + * */
  1036 + disableVideo(uid) {
  1037 + loger.log("禁用摄像头:" + uid);
  1038 + if (parseInt(uid) == GlobalConfig.nodeId) {
  1039 + if (this.localStream) {
  1040 + //$("#" + this.audioMutedIdName + uid).removeClass("microphoneOn");
  1041 + //$("#" + this.audioMutedIdName + uid).addClass("audioAndVideMuted microphoneOff");
  1042 + this.setUidVideoEnabledStatus(uid,false);
  1043 + this.localStream.disableVideo();
  1044 + }
  1045 + }
  1046 + }
  1047 +
  1048 + /*
  1049 + * 开启摄像头
  1050 + * */
  1051 + enableVideo(uid) {
  1052 + loger.log("开启摄像头:" + uid);
  1053 + if (parseInt(uid) == GlobalConfig.nodeId) {
  1054 + if (this.localStream) {
  1055 + this.localStream.enableVideo();
  1056 + //$("#" + this.audioMutedIdName + _uid).removeClass("microphoneOff");
  1057 + //$("#" + this.audioMutedIdName + _uid).addClass("audioAndVideMuted microphoneOn");
  1058 + this.setUidVideoEnabledStatus(uid,true);
  1059 + }
  1060 + }
913 } 1061 }
  1062 + /*
  1063 + * 设置视频禁用按钮的状态
  1064 + * uid nodeId
  1065 + * isEnable true开启 false 禁用
  1066 + *
  1067 + * */
  1068 + setUidVideoEnabledStatus(uid, isEnable){
  1069 + loger.log("设置视频禁用按钮的状态",uid,isEnable);
  1070 + if(isEnable==true){
  1071 + //开启
  1072 + $("#" + this.videoMutedIdName + uid).removeClass("cameraOff");
  1073 + $("#" + this.videoMutedIdName + uid).addClass("audioAndVideMuted cameraOn");
  1074 + $("#" + this.videoMutedIdName + uid).attr("title",this.closeCameraTitle);
  1075 + }else{
  1076 + //禁用
  1077 + $("#" + this.videoMutedIdName + uid).removeClass("cameraOn");
  1078 + $("#" + this.videoMutedIdName + uid).addClass("audioAndVideMuted cameraOff");
  1079 + $("#" + this.videoMutedIdName + uid).attr("title",this.openCameraTitle);
914 } 1080 }
915 } 1081 }
916 1082
@@ -918,7 +1084,6 @@ class WebRtcApe extends Emiter { @@ -918,7 +1084,6 @@ class WebRtcApe extends Emiter {
918 packMediaInfoData(_status) { 1084 packMediaInfoData(_status) {
919 let curTimestamp = new Date().getTime(); 1085 let curTimestamp = new Date().getTime();
920 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}&timestamp=${curTimestamp}&recordTimestamp=${GlobalConfig.recordTimestamp}`; 1086 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}&timestamp=${curTimestamp}&recordTimestamp=${GlobalConfig.recordTimestamp}`;
921 -  
922 //markettest_623790840_T9540_1508207080 1087 //markettest_623790840_T9540_1508207080
923 let streamId = GlobalConfig.siteId + "_" + GlobalConfig.classId + "_" + GlobalConfig.userId + "_" + curTimestamp; 1088 let streamId = GlobalConfig.siteId + "_" + GlobalConfig.classId + "_" + GlobalConfig.userId + "_" + curTimestamp;
924 //mcu记录一份数据 1089 //mcu记录一份数据
@@ -1024,7 +1189,7 @@ WebRtcApe.prototype.RECORD_STATUS_0 = WebRtcApe.RECORD_STATUS_0 = 0; //停止推 @@ -1024,7 +1189,7 @@ WebRtcApe.prototype.RECORD_STATUS_0 = WebRtcApe.RECORD_STATUS_0 = 0; //停止推
1024 WebRtcApe.prototype.RECORD_STATUS_1 = WebRtcApe.RECORD_STATUS_1 = 1; //开始推流 1189 WebRtcApe.prototype.RECORD_STATUS_1 = WebRtcApe.RECORD_STATUS_1 = 1; //开始推流
1025 WebRtcApe.prototype.RECORD_STATUS_2 = WebRtcApe.RECORD_STATUS_2 = 2; //停止录制 1190 WebRtcApe.prototype.RECORD_STATUS_2 = WebRtcApe.RECORD_STATUS_2 = 2; //停止录制
1026 WebRtcApe.prototype.RE_JOIN_CHANNEL = WebRtcApe.RE_JOIN_CHANNEL = "reJoninChanel";//重加入频道 1191 WebRtcApe.prototype.RE_JOIN_CHANNEL = WebRtcApe.RE_JOIN_CHANNEL = "reJoninChanel";//重加入频道
1027 - 1192 +WebRtcApe.prototype.UPDATE_USER_MEDIA_MUTED_STATUS = WebRtcApe.UPDATE_USER_MEDIA_MUTED_STATUS = "updateUserMediaMutedStatus";
1028 export default new WebRtcApe; 1193 export default new WebRtcApe;
1029 1194
1030 1195
1 @charset "utf-8"; 1 @charset "utf-8";
2 2
3 -/*禁音按钮*/  
4 -.audioMuted{  
5 - margin-left: 6px;  
6 - float: right; 3 +.audioAndVideBox{
  4 + position: absolute;
  5 + left: 2px;
  6 + bottom: 2px;
  7 + z-index: 2;
  8 +}
  9 +/*已经推流时按钮图标的左边距离*/
  10 +.openVideo{
  11 + left: 36px;
  12 +}
  13 +/*没有推流时按钮图标的左边距离*/
  14 +.unOpenVideo{
  15 + left: 2px;
  16 +}
  17 +
  18 +/*音视频开启禁用和开启的按钮图标属性*/
  19 +.audioAndVideMuted{
  20 + /*position: absolute;*/
  21 + /*bottom: 2px;*/
  22 + /*z-index: 2;*/
  23 + float: left;
  24 + margin: 2px;
7 width: 20px; 25 width: 20px;
8 height: 20px; 26 height: 20px;
9 cursor: pointer; 27 cursor: pointer;
10 - background-size: auto; 28 + background-size: 100%;
11 background-repeat: no-repeat; 29 background-repeat: no-repeat;
12 } 30 }
13 -.audioClose {  
14 - background-image: url(../../assets/img/audioClose.png); 31 +/*禁音频按钮*/
  32 +.microphoneOff {
  33 + background-image: url(../../assets/img/microphoneOff_22.png);
  34 +}
  35 +.microphoneOn {
  36 + background-image: url(../../assets/img/microphoneOn_22.png);
  37 +}
  38 +
  39 +/*禁视频按钮*/
  40 +.cameraOff {
  41 + background-image: url(../../assets/img/cameraOff_22.png);
15 } 42 }
16 -.audioOpen {  
17 - background-image: url(../../assets/img/audioOpen.png); 43 +.cameraOn {
  44 + background-image: url(../../assets/img/cameraOn_22.png);
18 } 45 }
@@ -936,6 +936,8 @@ message RCNodeInfoRecordPdu { @@ -936,6 +936,8 @@ message RCNodeInfoRecordPdu {
936 optional uint32 micNoise=37; 936 optional uint32 micNoise=37;
937 optional bool autoGain=38; 937 optional bool autoGain=38;
938 optional uint32 selfDisEnableDrawTime = 39; 938 optional uint32 selfDisEnableDrawTime = 39;
  939 + optional bool videoEnabled=40;
  940 + optional bool audioEnabled=41;
939 } 941 }
940 942
941 message RCVotingPollSettingsPdu { 943 message RCVotingPollSettingsPdu {