李勇

1.修改Saas开启音视频录制接口的参数;2.webRtc模块增加视频所有者的名称显示;3.新增接口,根据用户的nodeId查找用户信息

... ... @@ -62,7 +62,7 @@ export default class MessageEntrance extends Emiter {
constructor() {
super();
//sdk 信息
GlobalConfig.sdkVersion = "v2.5.8.20170915";
GlobalConfig.sdkVersion = "v2.5.12.20170915";
loger.warn("sdkVersion:" + GlobalConfig.sdkVersion);
//设置
... ...
... ... @@ -165,7 +165,12 @@ class GlobalConfig {
}else {
return "normal"
}
}
/*
* 根据nodeId获取用户的信息
* */
static getUserInfoFromeNodeId(_nodeId){
return this.rosters[_nodeId];
}
// 判断自己是否主持人角色
static get isHost() {
... ...
... ... @@ -602,14 +602,34 @@ class Sass extends Emiter {
loger.log("调用服务器端开启录制->失败->接口地址无效");
return;
}
/* {
"appId": "xxxxxxx",
"channel": "xxxxx_xxxx",
"channelKey": "xxxxxx",
"uid": 11111,
"userId": "xxx",
"userName": "xxx",
"userRole": "xxx",
"timestamp": "发送消息的的客户端时间戳",
"recordTimestamp": "当前录制进行的时间戳(回放时使用)"
}*/
//{"appId":"eb253cc7b40c4a8b82f0a5b6f93c2ce0","channel":"testcdn_580908347","channelKey":null,"uid":594312157} //录制的channelKey是appCertificate
let url=GlobalConfig.locationProtocol+GlobalConfig.recordInterfaces;
let curTimestamp= new Date().getTime();
fetch(encodeURI(url), {
method: 'POST',
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: `appId=${GlobalConfig.appId}&channel=${GlobalConfig.channelId}&channelKey=${GlobalConfig.appCertificate}&uid=${GlobalConfig.userUid}`,
body: `appId=${GlobalConfig.appId}
&channel=${GlobalConfig.channelId}
&channelKey=${GlobalConfig.appCertificate}
&uid=${GlobalConfig.userUid}
&userId=${GlobalConfig.userId}
&userName=${GlobalConfig.userName}
&userRole=${GlobalConfig.userRole}
&timestamp=${curTimestamp}
&recordTimestamp=${GlobalConfig.recordTimestamp}`,
timeout: 4000
})
.then(ret => {
... ... @@ -630,32 +650,9 @@ class Sass extends Emiter {
.catch(err => {
loger.error(`调用服务器端开启录制.状态码:${err}`);
});
/*let userIpInfo={
"appID":GlobalConfig.appId,
"channel":GlobalConfig.channelId,
"channelKey": GlobalConfig.channelKey,
"uid": GlobalConfig.userUid
}
let location=GlobalConfig.recordInterfaces;//'http://123.56.73.119:3000/users/Recording';
loger.log("调用服务器端开启录制->",location,userIpInfo);
$.ajax(
{
type:'post',
url : location,
dataType : 'json',
data: userIpInfo,
success : function(data) {
loger.log("调用服务器端开启录制->success",data);
},
error : function(data) {
//alert(data.code);
loger.log("调用服务器端开启录制->error",data);
}
}
);*/
}
//答题卡-------------------------------------------------------
//创建答题数据
creatQuestion(_param) {
... ...
... ... @@ -14,6 +14,7 @@ let loger = Loger.getLoger('WebRtcApe');
class WebRtcApe extends Emiter {
constructor() {
super();
this.nameDisplay="block";//默认显示名字
this.appId = '';
this.appCertificate = "";
this.appRecordingKey = "";
... ... @@ -122,28 +123,37 @@ class WebRtcApe extends Emiter {
let stream = evt.stream;
if(stream){
//let viewDiv=`<div id="${this.xdyRemote + stream.getId()}" style="width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;"></div>`;
if(GlobalConfig.getUserRoleFromeNodeId(stream.getId())==ApeConsts.invisible){
let uid=stream.getId();
let user=GlobalConfig.getUserInfoFromeNodeId(uid);
let userName="";
let userRole=""
if(user){
userName=user.name||"";
userRole=user.userRole;
}
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>`;
if(userRole==ApeConsts.invisible){
//把远程视频添加到监课列表
loger.log("获取远程视频流成功->监课:" + stream.getId(),new Date().getTime());
let viewDiv=`<div id="${this.xdyRemote + stream.getId()}" style="width:${this.invisibleVideoWidth}px;height:${this.invisibleVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;"></div>`;
loger.log("获取远程视频流成功->监课:"+userName+"->" + uid,new Date().getTime());
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>`;
$(this.invisibleViewId).append(viewDiv);
}else if(GlobalConfig.getUserRoleFromeNodeId(stream.getId())==ApeConsts.host){
}else if(userRole==ApeConsts.host){
//把远程视图添加到老师列表
loger.log("获取远程视频流成功->老师:" + stream.getId(),new Date().getTime());
let viewDiv=`<div id="${this.xdyRemote + stream.getId()}" style="width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;"></div>`;
loger.log("获取远程视频流成功->老师:"+userName+"->" + uid,new Date().getTime());
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>`;
$(this.hostRemoteViewId).append(viewDiv);
}else {
//把视图添加到学生列表
loger.log("获取远程视频流成功->学生:" + stream.getId(),new Date().getTime());
let viewDiv=`<div id="${this.xdyRemote + stream.getId()}" style="width:${this.normalRemoteVideoWidth}px;height:${this.normalRemoteVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;"></div>`;
loger.log("获取远程视频流成功->学生:"+userName+"->" +uid,new Date().getTime());
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>`;
$(this.normalRemoteViewId).append(viewDiv);
}
//播放视频
//播放视频,隐藏控制条
try{
$("bar_"+stream.getId()).hide();
stream.play(this.xdyRemote + stream.getId());
}catch (err){
}
}
... ... @@ -253,7 +263,6 @@ class WebRtcApe extends Emiter {
return;
}
this.localStream.init(()=> {
//let viewName = this.localViewId.replace("#", "");
let viewName='localVideoBox_'+this.uid;
let videoBox=document.createElement("div");
videoBox.id=viewName;
... ... @@ -262,9 +271,18 @@ class WebRtcApe extends Emiter {
videoBox.style.float='left';
videoBox.style.marginRight="1px";
videoBox.style.pointerEvents='none';
$(this.localViewId).prepend(videoBox);//自己的视图往前添加
//自己的视图往前添加
$(this.localViewId).prepend(videoBox);
$("#"+viewName).css("transform", 'rotateY(180deg)');
//显示自己的名字
let user=GlobalConfig.getUserInfoFromeNodeId(this.uid);
let userName="";
if(user){
userName=user.name||"";
}
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>`;
$(this.localViewId).prepend(nameDiv);
loger.log("webRtc->推流->",viewName,new Date().getTime());
this.localStream.play(viewName);
... ... @@ -308,6 +326,7 @@ class WebRtcApe extends Emiter {
this.localStream.close();
//$(this.localViewId).html("");
$('#localVideoBox_' + this.uid).remove();
$("videoOwnerName_"+this.uid).remove();
this.isPublish=false;
GlobalConfig.openCamera =0;
... ... @@ -331,6 +350,7 @@ class WebRtcApe extends Emiter {
this.localStyle = _params.styleStr||"";
this.localVideoWidth=parseInt(_params.width)||320;
this.localVideoHeight=parseInt(_params.height)||240;
this.nameDisplay=_params.nameDisplay||"block";
}
/*
... ...