李勇

修改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.8.7.20170916"; 65 + GlobalConfig.sdkVersion = "v2.8.8.20170917";
66 loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); 66 loger.warn("sdkVersion:" + GlobalConfig.sdkVersion);
67 67
68 //设置 68 //设置
@@ -195,15 +195,20 @@ class WebRtcApe extends Emiter { @@ -195,15 +195,20 @@ class WebRtcApe extends Emiter {
195 loger.log("添加一个远程视频流: " + _stream.getId(),new Date().getTime()); 195 loger.log("添加一个远程视频流: " + _stream.getId(),new Date().getTime());
196 this.client.subscribe(_stream, (err)=> { 196 this.client.subscribe(_stream, (err)=> {
197 loger.warn("添加一个远程视频流->失败", err); 197 loger.warn("添加一个远程视频流->失败", err);
198 - clearTimeout(this.reAddRemoteStreamDelay); 198 + //clearTimeout(this.reAddRemoteStreamDelay);
199 if(err=="INVALID_REMOTE_STREAM"){ 199 if(err=="INVALID_REMOTE_STREAM"){
200 //流已经无效,不需要再重连 200 //流已经无效,不需要再重连
  201 + loger.warn("流已经无效->不需要再重连", err);
201 return; 202 return;
202 } 203 }
203 - this.reAddRemoteStreamDelay=setTimeout(()=>{  
204 - loger.warn("连接远程的流失败->尝试重新连接");  
205 - this.reAddRemoteStream(_stream);  
206 - },1400); 204 + if(err=="PEERCONNECTION_FAILED"){
  205 + //this.reAddRemoteStreamDelay=setTimeout(()=>{
  206 + setTimeout(()=>{
  207 + loger.warn("连接远程的流失败->尝试重新连接");
  208 + this.reAddRemoteStream(_stream);
  209 + },1400);
  210 + }
  211 +
207 }); 212 });
208 } 213 }
209 214
@@ -234,7 +239,7 @@ class WebRtcApe extends Emiter { @@ -234,7 +239,7 @@ class WebRtcApe extends Emiter {
234 this.rePublishDelay=setTimeout(()=>{ 239 this.rePublishDelay=setTimeout(()=>{
235 this.publish(); 240 this.publish();
236 },1200); 241 },1200);
237 - this.publish(); 242 + //this.publish();
238 }else { 243 }else {
239 this.openLoaclStream(); 244 this.openLoaclStream();
240 } 245 }
@@ -318,7 +323,7 @@ class WebRtcApe extends Emiter { @@ -318,7 +323,7 @@ class WebRtcApe extends Emiter {
318 GlobalConfig.openCamera =0; 323 GlobalConfig.openCamera =0;
319 GlobalConfig.openMicrophones =0; 324 GlobalConfig.openMicrophones =0;
320 this.isPublish=false; 325 this.isPublish=false;
321 - this.clearLocalView(); 326 + this.unpublish();
322 }); 327 });
323 this.client.on('stream-published', (evt)=> { 328 this.client.on('stream-published', (evt)=> {
324 loger.log("webRtc->推流成功->",new Date().getTime()); 329 loger.log("webRtc->推流成功->",new Date().getTime());
@@ -354,8 +359,6 @@ class WebRtcApe extends Emiter { @@ -354,8 +359,6 @@ class WebRtcApe extends Emiter {
354 loger.log("webRtc->停止推流->失败" + err); 359 loger.log("webRtc->停止推流->失败" + err);
355 }); 360 });
356 this.localStream.close(); 361 this.localStream.close();
357 - //$('#localVideoBox_' + this.uid).remove();  
358 - //$("#videoOwnerName_"+this.uid).remove();  
359 this.clearLocalView(); 362 this.clearLocalView();
360 this.isPublish=false; 363 this.isPublish=false;
361 GlobalConfig.openCamera =0; 364 GlobalConfig.openCamera =0;