李勇

1.修复音视频禁用状态显示同步的问题;2.增加摄像头麦克风和权限未获取成功时的各种提示

... ... @@ -63,7 +63,7 @@ export default class MessageEntrance extends Emiter {
super();
this.lastClassActiveTime=0;//最后一次课堂激活的时间戳
//sdk 信息
GlobalConfig.sdkVersion = "v2.38.6.201712013";
GlobalConfig.sdkVersion = "v2.38.11.20171214";
loger.warn("sdkVersion:" + GlobalConfig.sdkVersion);
console.log("sdkVersion:" + GlobalConfig.sdkVersion);
//设置
... ...
... ... @@ -849,7 +849,7 @@ class ConferApe extends Ape {
this.changeHandUpStatus(msgObj);
}
} catch (err) {
loger.warn('chatMsg->JSON数据解析失败');
loger.warn('CLASS_ACTION_HANDUP_STATUS_CHANGE->JSON数据解析失败');
}
break;
case ApeConsts.CLASS_ACTION_DRAW_STATUS_CHANGE:
... ... @@ -860,7 +860,7 @@ class ConferApe extends Ape {
this.changeUserDrawStatus(drawMsgObj);
}
} catch (err) {
loger.warn('chatMsg->JSON数据解析失败');
loger.warn('CLASS_ACTION_DRAW_STATUS_CHANGE->JSON数据解析失败');
}
break;
case ApeConsts.USER_ACTION_SILENCE_STATUS_CHANGE:
... ... @@ -871,18 +871,19 @@ class ConferApe extends Ape {
this.changeSilenceStatus(silenceMsg);
}
} catch (err) {
loger.warn('chatMsg->JSON数据解析失败');
loger.warn('USER_ACTION_SILENCE_STATUS_CHANGE->JSON数据解析失败');
}
break;
case ApeConsts.MEDIA_ENABLED_CHANGE:
let mediaMsgObj = null;
try {
mediaMsgObj = JSON.parse(chatMsg.message);
//console.log("MEDIA_ENABLED_CHANGE",mediaMsgObj,chatMsg);
if (mediaMsgObj) {
this.receiveChangeUserMediaEnabledStatus(mediaMsgObj);
}
} catch (err) {
loger.warn('chatMsg->JSON数据解析失败',chatMsg.message);
loger.warn('MEDIA_ENABLED_CHANGE->JSON数据解析失败',chatMsg.message,err.message);
}
break;
default:
... ...
... ... @@ -755,8 +755,8 @@ class VideoApe extends Ape {
if (unpackChannelInfo.status == ApeConsts.CHANNEL_STATUS_OPENING) {
GlobalConfig.openCamera = EngineUtils.creatTimestamp();
GlobalConfig.openMicrophones = GlobalConfig.openCamera;
GlobalConfig.videoEnabled=true;
GlobalConfig.audioEnabled=true;
//GlobalConfig.videoEnabled=true;
//GlobalConfig.audioEnabled=true;
} else {
GlobalConfig.openCamera = 0;
GlobalConfig.openMicrophones = 0;
... ...
... ... @@ -48,7 +48,7 @@ class WebRtcApe extends Emiter {
this.curCameraId = "";
this.curMicrophoneId = "";
this.speakerList=[];//记录讲话的记录
this.speakerList = [];//记录讲话的记录
this.remoteVideoList = {};//记录远程视频流
this.pWidth = SIZE_480;
... ... @@ -63,7 +63,7 @@ class WebRtcApe extends Emiter {
this.isOpenVideo = true;//是否开启摄像头,默认为开启,如果获取不到麦克风的时候会设置为false
this.firstPublishSuccess = false;//记录加入频道成功之后是否推流成功过,离开频道之后需要设置为false
this.isWebSocketDisconnect=false;//记录中途是否已经断开
this.isWebSocketDisconnect = false;//记录中途是否已经断开
this.isPublish = false;//当前是否正在推流
this.videoScale = 1;//视图的缩放比例,默认为1;
... ... @@ -149,7 +149,7 @@ class WebRtcApe extends Emiter {
this.channelKey = "";
this.client.on('error', (err) => {
loger.log("WebRtc异常:", err);
switch (err.reason){
switch (err.reason) {
case "DYNAMIC_KEY_TIMEOUT":
this.client.renewChannelKey(this.channelKey, ()=> {
loger.log("Renew channel key successfully");
... ... @@ -159,12 +159,12 @@ class WebRtcApe extends Emiter {
break;
case "SOCKET_DISCONNECTED":
//连接断开
this.isWebSocketDisconnect=true;
this.isWebSocketDisconnect = true;
this._emit(MessageTypes.WEB_RTC_LEAVE_CHANNEL);
break;
case "SOCKET_ERROR":
//连接断开
this.isWebSocketDisconnect=true;
this.isWebSocketDisconnect = true;
this._emit(MessageTypes.WEB_RTC_LEAVE_CHANNEL);
break;
default :
... ... @@ -221,17 +221,17 @@ class WebRtcApe extends Emiter {
let uid = evt.uid;
let user = GlobalConfig.getUserInfoFromeNodeId(parseInt(uid));
//console.log("active-speaker",user);
/* if (user) {
let roleRole = GlobalConfig.getUserRoleToString(user.role);
this.speakerList.push("当前正在讲话的 [" + roleRole + "] name:" + user.name + " uid:" + uid);
} else {
this.speakerList.push("当前正在讲话的uid:" + uid);
}*/
/* //记录正在讲话的数据,大于50条上报一次
if(this.speakerList.length>20){
loger.log(this.speakerList);
this.speakerList=[];
}*/
/* if (user) {
let roleRole = GlobalConfig.getUserRoleToString(user.role);
this.speakerList.push("当前正在讲话的 [" + roleRole + "] name:" + user.name + " uid:" + uid);
} else {
this.speakerList.push("当前正在讲话的uid:" + uid);
}*/
/* //记录正在讲话的数据,大于50条上报一次
if(this.speakerList.length>20){
loger.log(this.speakerList);
this.speakerList=[];
}*/
});
}
... ... @@ -251,7 +251,7 @@ class WebRtcApe extends Emiter {
if (len < 1) {
loger.log("添加之前先删除之前存在的重复视图", uid);
$("#" + this.xdyRemote + uid).remove();
}
}
let audioMutedDiv = "";
let videoMutedDiv = "";
... ... @@ -314,7 +314,11 @@ class WebRtcApe extends Emiter {
$("#player_" + uid).css("pointer-events", "none");
//更新音视频禁用状态显示
if (uid != GlobalConfig.nodeId) {
this.receiveWebRtcMeiaEnabledChange({nodeId: uid, video: Boolean(user.videoEnabled), audio: Boolean(user.audioEnabled)});
this.receiveWebRtcMeiaEnabledChange({
nodeId: uid,
video: Boolean(user.videoEnabled),
audio: Boolean(user.audioEnabled)
});
}
if (user && (user.deviceType == GlobalConfig.deviceIOS || user.deviceType == GlobalConfig.deviceAndroid)) {
this.remoteVideoList[user.nodeId] = stream;
... ... @@ -325,16 +329,17 @@ class WebRtcApe extends Emiter {
}
/*
*
* 断线后重连成功
* */
reJoinChannelSuccess(){
if(this.isWebSocketDisconnect){
*
* 断线后重连成功
* */
reJoinChannelSuccess() {
if (this.isWebSocketDisconnect) {
loger.log("断线重连成功");
this._emit(MessageTypes.WEB_RTC_REJOIN_SUCCESS);
}
this.isWebSocketDisconnect=false;
this.isWebSocketDisconnect = false;
}
//清除无效的视图
clearInvalidVideoView() {
let normalList = document.getElementsByClassName(this.normalWebRtcVideoClass);
... ... @@ -471,7 +476,7 @@ class WebRtcApe extends Emiter {
this.client.join(this.channelKey, "" + this.channelId, this.uid, (uid)=> {
this.uid = uid;
loger.log("加入视频通话频道->成功->channelId:" + this.channelId, "uid:" + this.uid);
this.isWebSocketDisconnect=false;
this.isWebSocketDisconnect = false;
this._emit(MessageTypes.WEB_RTC_JOIN_SUCCESS);
this.openLoaclStream();
... ... @@ -520,12 +525,12 @@ class WebRtcApe extends Emiter {
screen: false
});
this.localStream.on("accessAllowed", function(){
this.localStream.on("accessAllowed", function () {
loger.warn("摄像头麦克风->已经获取权限");
})
// The user has denied access to the camera and mic.
this.localStream.on("accessDenied", function(){
this.localStream.on("accessDenied", function () {
loger.warn("摄像头和麦克风->权限获取失败");
})
... ... @@ -672,7 +677,8 @@ class WebRtcApe extends Emiter {
this.localStream.play(viewName);
this.client.publish(this.localStream, (err)=> {
loger.log("webRtc->推流失败: " + err);
this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED, {type:"error",msg:err.msg||err});
//this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED, {type:"error",msg:err.msg||err});
this._publishError(err.msg || err);
this.isPublish = false;
this.unpublish();
});
... ... @@ -680,41 +686,58 @@ class WebRtcApe extends Emiter {
loger.warn("webRtc->推流->本地流开启失败", err);
this.isPublish = false;
this.clearLocalView();
this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED, {type:"error",msg:err.msg||err});
if (err) {
switch (err.msg) {
case "DEVICES_NOT_FOUND":
this.curCameraId = "";
this.curMicrophoneId = "";
this.unpublish();
break;
case "NOT_SUPPORTED":
this.curCameraId = "";
this.curMicrophoneId = "";
this.unpublish();
break;
case "PERMISSION_DENIED":
this.curCameraId = "";
this.curMicrophoneId = "";
this.unpublish();
break;
case "CONSTRAINT_NOT_SATISFIED":
this.curCameraId = "";
this.curMicrophoneId = "";
this.unpublish();
break;
case "STREAM_ALREADY_INITIALIZED":
this.curCameraId = "";
this.curMicrophoneId = "";
this.unpublish();
break;
default:
break
}
}
this._publishError(err.msg || err);
});
}
/*
* 推流失败
* */
_publishError(_msg) {
switch (_msg) {
case "DEVICES_NOT_FOUND":
if (this.cameras.length < 1 && this.microphones.length < 1) {
this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED, {type: "error", msg: "DEVICES_NOT_FOUND"});
} else if (this.cameras.length < 1 && this.microphones.length >0) {
this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED, {type: "error", msg: "DEVICES_NOT_FOUND_CAMERA"});
} else if (this.cameras.length >0 && this.microphones.length < 1) {
this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED, {type: "error", msg: "DEVICES_NOT_FOUND_MIC"});
}
this.curCameraId = "";
this.curMicrophoneId = "";
this.unpublish();
break;
case "NOT_SUPPORTED":
this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED, {type: "error", msg: _msg});
this.curCameraId = "";
this.curMicrophoneId = "";
this.unpublish();
break;
case "PERMISSION_DENIED":
this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED, {type: "error", msg: _msg});
this.curCameraId = "";
this.curMicrophoneId = "";
this.unpublish();
break;
case "CONSTRAINT_NOT_SATISFIED":
this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED, {type: "error", msg: _msg});
this.curCameraId = "";
this.curMicrophoneId = "";
this.unpublish();
break;
case "STREAM_ALREADY_INITIALIZED":
this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED, {type: "error", msg: _msg});
this.curCameraId = "";
this.curMicrophoneId = "";
this.unpublish();
break;
default:
this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED, {type: "error", msg: _msg});
break
}
}
unpublish() {
clearTimeout(this.rePublishDelay);
if (!this.client) {
... ... @@ -924,10 +947,10 @@ class WebRtcApe extends Emiter {
if (device) {
if (device.kind == 'audioinput') {
this.microphones.push(device);
GlobalConfig.microphones.push(device.label||"microphone"+i);
GlobalConfig.microphones.push(device.label || "microphone" + i);
} else if (device.kind == 'videoinput') {
this.cameras.push(device);
GlobalConfig.cameras.push(device.label||"camera"+i);
GlobalConfig.cameras.push(device.label || "camera" + i);
} else {
loger.warn('其他设备: ', device);
}
... ... @@ -958,17 +981,17 @@ class WebRtcApe extends Emiter {
uid = parseInt(idArr[1]);
}
let user = GlobalConfig.getUserInfoFromeNodeId(parseInt(uid));
let userName="";
let roleRole="";
let userName = "";
let roleRole = "";
if (user) {
roleRole = GlobalConfig.getUserRoleToString(user.role);
userName = user.name;
}
if (className.indexOf("cameraOn") > 0) {
loger.log("点击禁用视频按钮->用户:["+roleRole+"] " +userName+" uid:"+uid);
loger.log("点击禁用视频按钮->用户:[" + roleRole + "] " + userName + " uid:" + uid);
this.sendChangeUserMediaEnabled({nodeId: uid, video: false, audio: true});
} else {
loger.log("点击解除视频禁用按钮->用户:["+roleRole+"] " +userName+" uid:"+uid);
loger.log("点击解除视频禁用按钮->用户:[" + roleRole + "] " + userName + " uid:" + uid);
this.sendChangeUserMediaEnabled({nodeId: uid, video: true, audio: true});
}
}
... ... @@ -984,18 +1007,18 @@ class WebRtcApe extends Emiter {
uid = parseInt(idArr[1]);
}
let user = GlobalConfig.getUserInfoFromeNodeId(parseInt(uid));
let userName="";
let roleRole="";
let userName = "";
let roleRole = "";
if (user) {
roleRole = GlobalConfig.getUserRoleToString(user.role);
userName = user.name;
}
if (className.indexOf("microphoneOn") > 0) {
loger.log("点击禁音按钮->用户:["+roleRole+"] " +userName+" uid:"+uid);
loger.log("点击禁音按钮->用户:[" + roleRole + "] " + userName + " uid:" + uid);
this.sendChangeUserMediaEnabled({nodeId: uid, video: true, audio: false});
} else {
loger.log("点击解除禁音按钮->用户:["+roleRole+"] " +userName+" uid:"+uid);
loger.log("点击解除禁音按钮->用户:[" + roleRole + "] " + userName + " uid:" + uid);
this.sendChangeUserMediaEnabled({nodeId: uid, video: true, audio: true});
}
}
... ... @@ -1025,6 +1048,10 @@ class WebRtcApe extends Emiter {
//控制自己的音频
if (this.isEnableVideo == _data.video && this.isEnableAudio == _data.audio) {
loger.log("收到控制音视频禁用消息->自己当前状态一不需要设置:", _data);
//音频
this.setUidAudioEnabledStatus(_data.nodeId, Boolean(_data.audio));
//视频
this.setUidVideoEnabledStatus(_data.nodeId, Boolean(_data.video));
return;
}
//记录自己当前的音视频禁用状态
... ... @@ -1130,7 +1157,7 @@ class WebRtcApe extends Emiter {
* */
setUidVideoEnabledStatus(uid, isEnable) {
let user = GlobalConfig.getUserInfoFromeNodeId(parseInt(uid));
if(user&&user.cameras&&user.cameras.length<1){
if (user && user.cameras && user.cameras.length < 1) {
//用户没有摄像头 显示音频封面
$("#audioPlayIcoBox" + uid).show();
$("#" + this.videoMutedIdName + uid).hide();
... ...