李勇

1.屏幕共享增加助教和主讲人的权限,也可以共享;2.修改webRtc推流显示时的名字和位置;3.修改随机生成的userId和名字的长度

@@ -62,7 +62,7 @@ export default class MessageEntrance extends Emiter { @@ -62,7 +62,7 @@ export default class MessageEntrance extends Emiter {
62 constructor() { 62 constructor() {
63 super(); 63 super();
64 //sdk 信息 64 //sdk 信息
65 - GlobalConfig.sdkVersion = "v2.13.5.20170927"; 65 + GlobalConfig.sdkVersion = "v2.14.5.20170927";
66 loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); 66 loger.warn("sdkVersion:" + GlobalConfig.sdkVersion);
67 67
68 //设置 68 //设置
@@ -560,7 +560,7 @@ export default class MessageEntrance extends Emiter { @@ -560,7 +560,7 @@ export default class MessageEntrance extends Emiter {
560 GlobalConfig.portal= GlobalConfig.replacePort(GlobalConfig.portal,":80",""); 560 GlobalConfig.portal= GlobalConfig.replacePort(GlobalConfig.portal,":80","");
561 } 561 }
562 562
563 - GlobalConfig.userId = _param.userId || "0"; 563 + GlobalConfig.userId = ""+_param.userId || "0";
564 //H5处理 564 //H5处理
565 GlobalConfig.isH5 = _param.isH5 || false;//外部传入的参数,是否是H5 565 GlobalConfig.isH5 = _param.isH5 || false;//外部传入的参数,是否是H5
566 if (GlobalConfig.isH5 == true) { 566 if (GlobalConfig.isH5 == true) {
@@ -575,13 +575,6 @@ export default class MessageEntrance extends Emiter { @@ -575,13 +575,6 @@ export default class MessageEntrance extends Emiter {
575 GlobalConfig.microphones = _param.microphones || []; 575 GlobalConfig.microphones = _param.microphones || [];
576 } 576 }
577 577
578 - //如果没有名字,随机起一个名字  
579 - GlobalConfig.userName = _param.userName || "user_" + (new Date().getTime() % 1000000);  
580 -  
581 - //如果没有userId或者为"0",随机生成  
582 - if (GlobalConfig.userId == "0") {  
583 - GlobalConfig.userId = "user_" + (new Date().getTime() % 1000000);  
584 - }  
585 //设置角色身份 578 //设置角色身份
586 GlobalConfig.userRole = _param.userRole || ApeConsts.normal; 579 GlobalConfig.userRole = _param.userRole || ApeConsts.normal;
587 if (GlobalConfig.userRole != ApeConsts.host && 580 if (GlobalConfig.userRole != ApeConsts.host &&
@@ -591,6 +584,25 @@ export default class MessageEntrance extends Emiter { @@ -591,6 +584,25 @@ export default class MessageEntrance extends Emiter {
591 GlobalConfig.userRole != ApeConsts.invisible) { 584 GlobalConfig.userRole != ApeConsts.invisible) {
592 GlobalConfig.userRole = ApeConsts.normal; 585 GlobalConfig.userRole = ApeConsts.normal;
593 } 586 }
  587 + //如果没有名字或没有userId的时候,需要随机生成
  588 + let timestampStr=new Date().getTime().toString();
  589 + timestampStr=timestampStr.substr(timestampStr.length-4);
  590 + if(GlobalConfig.userRole==ApeConsts.host){
  591 + timestampStr="T"+timestampStr;
  592 + }else if(GlobalConfig.userRole==ApeConsts.assistant) {
  593 + timestampStr = "A" + timestampStr;
  594 + }else if(GlobalConfig.userRole==ApeConsts.presenter){
  595 + timestampStr="P"+timestampStr;
  596 + }else {
  597 + timestampStr="S"+timestampStr;
  598 + }
  599 + //如果没有名字,随机起一个名字
  600 + GlobalConfig.userName = _param.userName ||timestampStr;
  601 + //如果没有userId或者为"0",随机生成
  602 + if (!GlobalConfig.userId||GlobalConfig.userId == "0") {
  603 + GlobalConfig.userId = timestampStr;
  604 + }
  605 +
594 //客户端决定是否延迟接收消息 606 //客户端决定是否延迟接收消息
595 GlobalConfig.messageDelay = _param.messageDelay || false; 607 GlobalConfig.messageDelay = _param.messageDelay || false;
596 608
@@ -1697,8 +1709,10 @@ export default class MessageEntrance extends Emiter { @@ -1697,8 +1709,10 @@ export default class MessageEntrance extends Emiter {
1697 loger.log('获取课堂课堂信息完成.',_data.appConfig); 1709 loger.log('获取课堂课堂信息完成.',_data.appConfig);
1698 //包含整个课堂最全的信息,储存数据 1710 //包含整个课堂最全的信息,储存数据
1699 if (_data) { 1711 if (_data) {
1700 - //老师默认启用画笔功能,其他身份默认禁用画笔功能  
1701 - if(GlobalConfig.userRole==ApeConsts.host){ 1712 + //老师\助教默认启用画笔功能,其他身份默认禁用画笔功能
  1713 + if(GlobalConfig.userRole==ApeConsts.host||
  1714 + GlobalConfig.userRole==ApeConsts.assistant||
  1715 + GlobalConfig.userRole==ApeConsts.presenter){
1702 GlobalConfig.selfDisEnableDrawTime=0; 1716 GlobalConfig.selfDisEnableDrawTime=0;
1703 } 1717 }
1704 1718
@@ -286,7 +286,7 @@ class VideoApe extends Ape { @@ -286,7 +286,7 @@ class VideoApe extends Ape {
286 publishType = 'live'; 286 publishType = 'live';
287 } 287 }
288 //老师能开启屏幕共享 288 //老师能开启屏幕共享
289 - if (GlobalConfig.isHost) { 289 + if (GlobalConfig.isHost||GlobalConfig.isAssistant||GlobalConfig.isPresenter) {
290 //获取屏幕共享推流的地址 290 //获取屏幕共享推流的地址
291 let shareResult = this.mediaModule.getMediaPublishPathForScreenShare(this.shareApe.channelId, publishType); 291 let shareResult = this.mediaModule.getMediaPublishPathForScreenShare(this.shareApe.channelId, publishType);
292 shareResult.ip = _param.ip || "";//外部可以设置屏幕共享的IP 292 shareResult.ip = _param.ip || "";//外部可以设置屏幕共享的IP
@@ -303,7 +303,7 @@ class VideoApe extends Ape { @@ -303,7 +303,7 @@ class VideoApe extends Ape {
303 return {"code": ApeConsts.RETURN_FAILED, "data": "已经断开连接"}; 303 return {"code": ApeConsts.RETURN_FAILED, "data": "已经断开连接"};
304 } 304 }
305 //只有老师能停止屏幕共享 305 //只有老师能停止屏幕共享
306 - if (GlobalConfig.isHost) { 306 + if (GlobalConfig.isHost||GlobalConfig.isAssistant||GlobalConfig.isPresenter) {
307 let channelInfo = this.shareApe.getDefaultChannelInfo(); 307 let channelInfo = this.shareApe.getDefaultChannelInfo();
308 channelInfo.status = ApeConsts.CHANNEL_STATUS_RELEASED; 308 channelInfo.status = ApeConsts.CHANNEL_STATUS_RELEASED;
309 this.sendTableUpdateHandler(channelInfo); 309 this.sendTableUpdateHandler(channelInfo);
@@ -144,50 +144,6 @@ class WebRtcApe extends Emiter { @@ -144,50 +144,6 @@ class WebRtcApe extends Emiter {
144 let stream = evt.stream; 144 let stream = evt.stream;
145 this.addRemoetStreamView(stream); 145 this.addRemoetStreamView(stream);
146 }); 146 });
147 - /* this.client.on('stream-subscribed', (evt)=> {  
148 - let stream = evt.stream;  
149 - if(stream){  
150 - //let viewDiv=`<div id="${this.xdyRemote + stream.getId()}" style="width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;"></div>`;  
151 - let uid=stream.getId();  
152 - let user=GlobalConfig.getUserInfoFromeNodeId(uid);  
153 - let userName="";  
154 - let userRole=""  
155 - if(user){  
156 - userName=user.name||"";  
157 - userRole=user.userRole;  
158 - }  
159 -  
160 - let nameDiv=`<div style="width:98%;height:20px; position: absolute; z-index: 1;left: 4px;overflow:hidden;font-size: 14px; color: #cccccc;display:${this.nameDisplay}">${userName}</div>`;  
161 -  
162 - if(userRole==ApeConsts.invisible){  
163 - //把远程视频添加到监课列表  
164 - loger.log("获取远程视频流成功->监课:"+userName+"->" + uid,new Date().getTime());  
165 - let viewDiv=`<div id="${this.xdyRemote + uid}" style="width:${this.invisibleVideoWidth}px;height:${this.invisibleVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`;  
166 - $(this.invisibleViewId).append(viewDiv);  
167 - }else if(userRole==ApeConsts.host){  
168 - //把远程视图添加到老师列表  
169 - loger.log("获取远程视频流成功->老师:"+userName+"->" + uid,new Date().getTime());  
170 - let viewDiv=`<div id="${this.xdyRemote + uid}" style="width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`;  
171 - $(this.hostRemoteViewId).append(viewDiv);  
172 - }else {  
173 - //把视图添加到学生列表  
174 - loger.log("获取远程视频流成功->学生:"+userName+"->" +uid,new Date().getTime());  
175 - let viewDiv=`<div id="${this.xdyRemote + uid}" style="width:${this.normalRemoteVideoWidth}px;height:${this.normalRemoteVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`;  
176 - $(this.normalRemoteViewId).append(viewDiv);  
177 - }  
178 - //播放视频,隐藏控制条  
179 - try{  
180 - $("bar_"+stream.getId()).hide();  
181 - stream.play(this.xdyRemote + stream.getId());  
182 - }catch (err){  
183 - }  
184 - if(user.deviceType==1||user.deviceType==2){  
185 - this.remoteVideoList[user.nodeId]=stream;  
186 - }  
187 - console.log("移动端远程视频流集合->",this.remoteVideoList);  
188 - }  
189 - });*/  
190 -  
191 this.client.on('stream-removed', (evt)=> { 147 this.client.on('stream-removed', (evt)=> {
192 let stream = evt.stream; 148 let stream = evt.stream;
193 if (stream) { 149 if (stream) {
@@ -215,7 +171,6 @@ class WebRtcApe extends Emiter { @@ -215,7 +171,6 @@ class WebRtcApe extends Emiter {
215 171
216 addRemoetStreamView(stream) { 172 addRemoetStreamView(stream) {
217 if (stream) { 173 if (stream) {
218 - //let viewDiv=`<div id="${this.xdyRemote + stream.getId()}" style="width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;"></div>`;  
219 let uid = stream.getId(); 174 let uid = stream.getId();
220 let user = GlobalConfig.getUserInfoFromeNodeId(uid); 175 let user = GlobalConfig.getUserInfoFromeNodeId(uid);
221 let userName = ""; 176 let userName = "";
@@ -224,16 +179,16 @@ class WebRtcApe extends Emiter { @@ -224,16 +179,16 @@ class WebRtcApe extends Emiter {
224 userName = user.name || "unknow"; 179 userName = user.name || "unknow";
225 userRole = user.userRole; 180 userRole = user.userRole;
226 } 181 }
227 - let nameDiv = `<div style="width:98%;height:20px; position: absolute; z-index: 1;left: 4px;overflow:hidden;font-size: 14px; color: #cccccc;display:${this.nameDisplay}">${userName}</div>`; 182 + let nameDiv = `<div style="width:98%;height:20px; position: absolute;bottom: 0; z-index: 1;left: 4px;overflow:hidden;font-size: 14px;text-align: right; color: #cccccc;display:${this.nameDisplay}">${userName}</div>`;
228 183
229 if (userRole == ApeConsts.invisible) { 184 if (userRole == ApeConsts.invisible) {
230 //把远程视频添加到监课列表 185 //把远程视频添加到监课列表
231 loger.log("获取远程视频流成功->监课:" + userName + "->" + uid, new Date().getTime()); 186 loger.log("获取远程视频流成功->监课:" + userName + "->" + uid, new Date().getTime());
232 let viewDiv = `<div id="${this.xdyRemote + uid}" style="width:${this.invisibleVideoWidth}px;height:${this.invisibleVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`; 187 let viewDiv = `<div id="${this.xdyRemote + uid}" style="width:${this.invisibleVideoWidth}px;height:${this.invisibleVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`;
233 $(this.invisibleViewId).append(viewDiv); 188 $(this.invisibleViewId).append(viewDiv);
234 - } else if (userRole == ApeConsts.host) { 189 + } else if (userRole == ApeConsts.host||userRole == ApeConsts.assistant||userRole == ApeConsts.presenter) {
235 //把远程视图添加到老师列表 190 //把远程视图添加到老师列表
236 - loger.log("获取远程视频流成功->老师:" + userName + "->" + uid, new Date().getTime()); 191 + loger.log("获取远程视频流成功->userRole:"+userRole+":" + userName + "->" + uid, new Date().getTime());
237 let viewDiv = `<div id="${this.xdyRemote + uid}" style="width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`; 192 let viewDiv = `<div id="${this.xdyRemote + uid}" style="width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`;
238 $(this.hostRemoteViewId).append(viewDiv); 193 $(this.hostRemoteViewId).append(viewDiv);
239 } else { 194 } else {
@@ -251,7 +206,6 @@ class WebRtcApe extends Emiter { @@ -251,7 +206,6 @@ class WebRtcApe extends Emiter {
251 if (user && (user.deviceType == 1 || user.deviceType == 2)) { 206 if (user && (user.deviceType == 1 || user.deviceType == 2)) {
252 this.remoteVideoList[user.nodeId] = stream; 207 this.remoteVideoList[user.nodeId] = stream;
253 } 208 }
254 - console.log("移动端远程视频流集合->", this.remoteVideoList);  
255 } 209 }
256 } 210 }
257 211
@@ -277,7 +231,7 @@ class WebRtcApe extends Emiter { @@ -277,7 +231,7 @@ class WebRtcApe extends Emiter {
277 setTimeout(()=> { 231 setTimeout(()=> {
278 loger.warn("连接远程的流失败->尝试重新连接", err); 232 loger.warn("连接远程的流失败->尝试重新连接", err);
279 this.reAddRemoteStream(_stream); 233 this.reAddRemoteStream(_stream);
280 - }, 1400); 234 + }, 1200);
281 } else { 235 } else {
282 loger.warn("添加一个远程视频流->失败", err); 236 loger.warn("添加一个远程视频流->失败", err);
283 } 237 }
@@ -431,7 +385,7 @@ class WebRtcApe extends Emiter { @@ -431,7 +385,7 @@ class WebRtcApe extends Emiter {
431 if (user) { 385 if (user) {
432 userName = user.name || ""; 386 userName = user.name || "";
433 } 387 }
434 - let nameDiv = `<div id="${"videoOwnerName_" + this.uid}" style="width:98%;height:20px; position: absolute; z-index: 1;left: 4px;overflow:hidden;font-size: 14px; color: #cccccc;display:${this.nameDisplay}">${userName}</div>`; 388 + let nameDiv = `<div id="${"videoOwnerName_" + this.uid}" style="width:98%;height:20px; position: absolute;bottom: 0; z-index: 1;left: 4px;overflow:hidden;font-size: 14px;text-align: right; color: #cccccc;display:${this.nameDisplay}">${userName}</div>`;
435 $(this.localViewId).prepend(nameDiv); 389 $(this.localViewId).prepend(nameDiv);
436 390
437 loger.log("webRtc->推流->", viewName, new Date().getTime()); 391 loger.log("webRtc->推流->", viewName, new Date().getTime());