正在显示
2 个修改的文件
包含
44 行增加
和
9 行删除
| @@ -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.2.20170916"; | 65 | + GlobalConfig.sdkVersion = "v2.8.7.20170916"; |
| 66 | loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); | 66 | loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); |
| 67 | 67 | ||
| 68 | //设置 | 68 | //设置 |
| @@ -2978,7 +2978,7 @@ export default class MessageEntrance extends Emiter { | @@ -2978,7 +2978,7 @@ export default class MessageEntrance extends Emiter { | ||
| 2978 | case WebRtcApe.RECORD_STATUS_0: | 2978 | case WebRtcApe.RECORD_STATUS_0: |
| 2979 | case WebRtcApe.RECORD_STATUS_1: | 2979 | case WebRtcApe.RECORD_STATUS_1: |
| 2980 | //推流/停止推流/开启录制 统一使用一个接口 | 2980 | //推流/停止推流/开启录制 统一使用一个接口 |
| 2981 | - _webRtc.changePublishStatusAndServerRecord(_params.type); | 2981 | + _webRtc.changePublishStatusAndServerRecord(_params.status); |
| 2982 | break; | 2982 | break; |
| 2983 | case WebRtcApe.RECORD_STATUS_2: | 2983 | case WebRtcApe.RECORD_STATUS_2: |
| 2984 | //停止录制 | 2984 | //停止录制 |
| @@ -24,6 +24,9 @@ class WebRtcApe extends Emiter { | @@ -24,6 +24,9 @@ class WebRtcApe extends Emiter { | ||
| 24 | this.uid = 0; | 24 | this.uid = 0; |
| 25 | this.info = "" | 25 | this.info = "" |
| 26 | 26 | ||
| 27 | + this.reAddRemoteStreamDelay=0;//重连远程视频的计时器 | ||
| 28 | + this.rePublishDelay=0;//重新推流的间隔 | ||
| 29 | + | ||
| 27 | this.mode = "interop"; | 30 | this.mode = "interop"; |
| 28 | this.client = null; | 31 | this.client = null; |
| 29 | this.localStream = null; | 32 | this.localStream = null; |
| @@ -113,10 +116,11 @@ class WebRtcApe extends Emiter { | @@ -113,10 +116,11 @@ class WebRtcApe extends Emiter { | ||
| 113 | 116 | ||
| 114 | this.client.on('stream-added', (evt)=> { | 117 | this.client.on('stream-added', (evt)=> { |
| 115 | let stream = evt.stream; | 118 | let stream = evt.stream; |
| 116 | - loger.log("添加一个远程视频流: " + stream.getId(),new Date().getTime()); | 119 | + /* loger.log("添加一个远程视频流: " + stream.getId(),new Date().getTime()); |
| 117 | this.client.subscribe(stream, (err)=> { | 120 | this.client.subscribe(stream, (err)=> { |
| 118 | loger.log("添加一个远程视频流->failed", err); | 121 | loger.log("添加一个远程视频流->failed", err); |
| 119 | - }); | 122 | + });*/ |
| 123 | + this.reAddRemoteStream(stream); | ||
| 120 | }); | 124 | }); |
| 121 | 125 | ||
| 122 | this.client.on('stream-subscribed', (evt)=> { | 126 | this.client.on('stream-subscribed', (evt)=> { |
| @@ -156,7 +160,6 @@ class WebRtcApe extends Emiter { | @@ -156,7 +160,6 @@ class WebRtcApe extends Emiter { | ||
| 156 | }catch (err){ | 160 | }catch (err){ |
| 157 | } | 161 | } |
| 158 | } | 162 | } |
| 159 | - | ||
| 160 | }); | 163 | }); |
| 161 | 164 | ||
| 162 | this.client.on('stream-removed', (evt)=> { | 165 | this.client.on('stream-removed', (evt)=> { |
| @@ -179,6 +182,30 @@ class WebRtcApe extends Emiter { | @@ -179,6 +182,30 @@ class WebRtcApe extends Emiter { | ||
| 179 | loger.log("当前正在讲话的uid:" + uid); | 182 | loger.log("当前正在讲话的uid:" + uid); |
| 180 | }); | 183 | }); |
| 181 | } | 184 | } |
| 185 | + //重新添加远程视频 | ||
| 186 | + reAddRemoteStream(_stream){ | ||
| 187 | + if(!_stream){ | ||
| 188 | + return; | ||
| 189 | + } | ||
| 190 | + let user=GlobalConfig.getUserRoleFromeNodeId(_stream.getId()); | ||
| 191 | + if(user.openCamera<=0){ | ||
| 192 | + loger.log("远程流已经停止,不需要再连接: " + _stream.getId(),new Date().getTime()); | ||
| 193 | + return; | ||
| 194 | + } | ||
| 195 | + loger.log("添加一个远程视频流: " + _stream.getId(),new Date().getTime()); | ||
| 196 | + this.client.subscribe(_stream, (err)=> { | ||
| 197 | + loger.warn("添加一个远程视频流->失败", err); | ||
| 198 | + clearTimeout(this.reAddRemoteStreamDelay); | ||
| 199 | + if(err=="INVALID_REMOTE_STREAM"){ | ||
| 200 | + //流已经无效,不需要再重连 | ||
| 201 | + return; | ||
| 202 | + } | ||
| 203 | + this.reAddRemoteStreamDelay=setTimeout(()=>{ | ||
| 204 | + loger.warn("连接远程的流失败->尝试重新连接"); | ||
| 205 | + this.reAddRemoteStream(_stream); | ||
| 206 | + },1400); | ||
| 207 | + }); | ||
| 208 | + } | ||
| 182 | 209 | ||
| 183 | joinChannel(_params) { | 210 | joinChannel(_params) { |
| 184 | this.channelId = _params.channelId||""; | 211 | this.channelId = _params.channelId||""; |
| @@ -291,6 +318,7 @@ class WebRtcApe extends Emiter { | @@ -291,6 +318,7 @@ class WebRtcApe extends Emiter { | ||
| 291 | GlobalConfig.openCamera =0; | 318 | GlobalConfig.openCamera =0; |
| 292 | GlobalConfig.openMicrophones =0; | 319 | GlobalConfig.openMicrophones =0; |
| 293 | this.isPublish=false; | 320 | this.isPublish=false; |
| 321 | + this.clearLocalView(); | ||
| 294 | }); | 322 | }); |
| 295 | this.client.on('stream-published', (evt)=> { | 323 | this.client.on('stream-published', (evt)=> { |
| 296 | loger.log("webRtc->推流成功->",new Date().getTime()); | 324 | loger.log("webRtc->推流成功->",new Date().getTime()); |
| @@ -305,11 +333,13 @@ class WebRtcApe extends Emiter { | @@ -305,11 +333,13 @@ class WebRtcApe extends Emiter { | ||
| 305 | openCamera: GlobalConfig.openCamera, | 333 | openCamera: GlobalConfig.openCamera, |
| 306 | openMicrophones: GlobalConfig.openMicrophones | 334 | openMicrophones: GlobalConfig.openMicrophones |
| 307 | }); | 335 | }); |
| 336 | + this.changePublishStatusAndServerRecord(WebRtcApe.RECORD_STATUS_1); | ||
| 308 | }); | 337 | }); |
| 309 | 338 | ||
| 310 | }, (err)=> { | 339 | }, (err)=> { |
| 311 | loger.warn("webRtc->推流->本地流开启失败", err); | 340 | loger.warn("webRtc->推流->本地流开启失败", err); |
| 312 | this.isPublish=false; | 341 | this.isPublish=false; |
| 342 | + this.clearLocalView(); | ||
| 313 | this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED,err); | 343 | this._emit(MessageTypes.WEB_RTC_PUBLISH_FAILED,err); |
| 314 | }); | 344 | }); |
| 315 | } | 345 | } |
| @@ -324,9 +354,9 @@ class WebRtcApe extends Emiter { | @@ -324,9 +354,9 @@ class WebRtcApe extends Emiter { | ||
| 324 | loger.log("webRtc->停止推流->失败" + err); | 354 | loger.log("webRtc->停止推流->失败" + err); |
| 325 | }); | 355 | }); |
| 326 | this.localStream.close(); | 356 | this.localStream.close(); |
| 327 | - //$(this.localViewId).html(""); | ||
| 328 | - $('#localVideoBox_' + this.uid).remove(); | ||
| 329 | - $("#videoOwnerName_"+this.uid).remove(); | 357 | + //$('#localVideoBox_' + this.uid).remove(); |
| 358 | + //$("#videoOwnerName_"+this.uid).remove(); | ||
| 359 | + this.clearLocalView(); | ||
| 330 | this.isPublish=false; | 360 | this.isPublish=false; |
| 331 | GlobalConfig.openCamera =0; | 361 | GlobalConfig.openCamera =0; |
| 332 | GlobalConfig.openMicrophones =0; | 362 | GlobalConfig.openMicrophones =0; |
| @@ -338,8 +368,13 @@ class WebRtcApe extends Emiter { | @@ -338,8 +368,13 @@ class WebRtcApe extends Emiter { | ||
| 338 | openCamera: GlobalConfig.openCamera, | 368 | openCamera: GlobalConfig.openCamera, |
| 339 | openMicrophones: GlobalConfig.openMicrophones | 369 | openMicrophones: GlobalConfig.openMicrophones |
| 340 | }); | 370 | }); |
| 371 | + this.changePublishStatusAndServerRecord(WebRtcApe.RECORD_STATUS_0); | ||
| 372 | + } | ||
| 373 | + //清除本地视图 | ||
| 374 | + clearLocalView(){ | ||
| 375 | + $('#localVideoBox_' + this.uid).remove(); | ||
| 376 | + $("#videoOwnerName_"+this.uid).remove(); | ||
| 341 | } | 377 | } |
| 342 | - | ||
| 343 | /* | 378 | /* |
| 344 | * 设置本地回显视图 | 379 | * 设置本地回显视图 |
| 345 | * */ | 380 | * */ |
-
请 注册 或 登录 后发表评论