李勇

修改webRtc推流的分辨率,根据不同身份和课堂类型设置

@@ -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.18.10.20171019"; 65 + GlobalConfig.sdkVersion = "v2.18.14.20171020";
66 loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); 66 loger.warn("sdkVersion:" + GlobalConfig.sdkVersion);
67 67
68 //设置 68 //设置
@@ -1226,8 +1226,8 @@ export default class MessageEntrance extends Emiter { @@ -1226,8 +1226,8 @@ export default class MessageEntrance extends Emiter {
1226 1226
1227 //主讲人和老师可以设置旁录 1227 //主讲人和老师可以设置旁录
1228 if(GlobalConfig.appId&&!GlobalConfig.openFlash){ 1228 if(GlobalConfig.appId&&!GlobalConfig.openFlash){
1229 - //加入之前先设置旁录地址,只有直播支持旁路  
1230 - if(_webRtc&&GlobalConfig.isTeachOrAssistant){ 1229 + //加入之前先设置旁录地址,只有直播支持旁路(1路流)
  1230 + if(_webRtc&&GlobalConfig.isTeachOrAssistant&&GlobalConfig.maxMediaChannels==1){
1231 let curTimestamp = new Date().getTime(); 1231 let curTimestamp = new Date().getTime();
1232 let streamId=GlobalConfig.siteId+"_"+GlobalConfig.classId+"_"+GlobalConfig.userId+"_"+curTimestamp; 1232 let streamId=GlobalConfig.siteId+"_"+GlobalConfig.classId+"_"+GlobalConfig.userId+"_"+curTimestamp;
1233 //传入固定的流Id 1233 //传入固定的流Id
@@ -12,6 +12,10 @@ var AgoraRTC = require('../AgoraRTCSDK-1.14.0'); @@ -12,6 +12,10 @@ var AgoraRTC = require('../AgoraRTCSDK-1.14.0');
12 let loger = Loger.getLoger('WebRtcApe'); 12 let loger = Loger.getLoger('WebRtcApe');
13 const SIZE_480=480; 13 const SIZE_480=480;
14 const SIZE_360=360; 14 const SIZE_360=360;
  15 +const SIZE_320=320;
  16 +const SIZE_240=240;
  17 +const SIZE_160=160;
  18 +const SIZE_120=120;
15 class WebRtcApe extends Emiter { 19 class WebRtcApe extends Emiter {
16 constructor() { 20 constructor() {
17 super(); 21 super();
@@ -47,8 +51,10 @@ class WebRtcApe extends Emiter { @@ -47,8 +51,10 @@ class WebRtcApe extends Emiter {
47 this.pFrameRate=30; 51 this.pFrameRate=30;
48 this.pBitrate=500; 52 this.pBitrate=500;
49 53
50 - this.videoResolution = "360P_8";//480x360 30 490  
51 - //this.videoResolution = "240P";// 54 + //120P 0 160x120 15 65
  55 + //240P 20 320x240 15 200
  56 + //360P_8 37 480x360 30 490
  57 + this.videoResolution = "240P";
52 this.isOpenVideo = true; 58 this.isOpenVideo = true;
53 59
54 this.isPublish = false;//当前是否正在推流 60 this.isPublish = false;//当前是否正在推流
@@ -346,7 +352,21 @@ class WebRtcApe extends Emiter { @@ -346,7 +352,21 @@ class WebRtcApe extends Emiter {
346 this.info = _params.info || ""; 352 this.info = _params.info || "";
347 this.channelKey = _params.channelKey || null; 353 this.channelKey = _params.channelKey || null;
348 354
349 - loger.log("开始加入视频通话频道->channelId:" + this.channelId, "uid:" + this.uid); 355 + //根据不同身份设置不同的分辨率
  356 + if(GlobalConfig.isTeachOrAssistant){
  357 + if(GlobalConfig.maxMediaChannels==2){
  358 + //1v1时使用标清
  359 + this.videoResolution="240P";
  360 + }else {
  361 + this.videoResolution="360P_8";
  362 + }
  363 + }if(GlobalConfig.isInvisible){
  364 + this.videoResolution="120P";
  365 + }else {
  366 + this.videoResolution="240P";
  367 + }
  368 +
  369 + loger.log("开始加入视频通话频道->channelId:" + this.channelId, "uid:" + this.uid,"videoResolution:"+this.videoResolution);
350 this.client.join(this.channelKey, "" + this.channelId, this.uid, (uid)=> { 370 this.client.join(this.channelKey, "" + this.channelId, this.uid, (uid)=> {
351 this.uid = uid; 371 this.uid = uid;
352 loger.log("加入视频通话频道->成功->channelId:" + this.channelId, "uid:" + this.uid); 372 loger.log("加入视频通话频道->成功->channelId:" + this.channelId, "uid:" + this.uid);
@@ -712,20 +732,16 @@ class WebRtcApe extends Emiter { @@ -712,20 +732,16 @@ class WebRtcApe extends Emiter {
712 for (let i = 0; i < devices.length; i++) { 732 for (let i = 0; i < devices.length; i++) {
713 let device = devices[i]; 733 let device = devices[i];
714 //{"deviceId":"default","kind":"audiooutput","label":"默认","groupId":"cf49a03ca26700235629fc13d3e6630bd34407c66438d157056a34dd3ae03ef5"} 734 //{"deviceId":"default","kind":"audiooutput","label":"默认","groupId":"cf49a03ca26700235629fc13d3e6630bd34407c66438d157056a34dd3ae03ef5"}
715 - if (device.kind == 'audioinput') {  
716 - if (!device.label) {  
717 - device.label = "麦克风_" + i;  
718 - }  
719 - this.microphones.push(device);  
720 - GlobalConfig.microphones.push(device.label);  
721 - } else if (device.kind == 'videoinput') {  
722 - if (!device.label) {  
723 - device.label = "摄像头_" + i; 735 + if(device){
  736 + if (device.kind == 'audioinput') {
  737 + this.microphones.push(device);
  738 + GlobalConfig.microphones.push(device.label);
  739 + } else if (device.kind == 'videoinput') {
  740 + this.cameras.push(device);
  741 + GlobalConfig.cameras.push(device.label);
  742 + } else {
  743 + loger.warn('其他设备: ', device);
724 } 744 }
725 - this.cameras.push(device);  
726 - GlobalConfig.cameras.push(device.label);  
727 - } else {  
728 - loger.warn('其他设备: ', device);  
729 } 745 }
730 } 746 }
731 let _deviceData = {cameras: GlobalConfig.cameras, microphones: GlobalConfig.microphones}; 747 let _deviceData = {cameras: GlobalConfig.cameras, microphones: GlobalConfig.microphones};