Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
李勇
/
McuClient
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
李勇
8 years ago
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
39d0e699ba378936bd24da20f50a472d8bfd5b29
39d0e699
1 parent
354ad184
1.修改webRtc推流拉流的处理,修复多次添加监听推流成功的bug;2.修改控制webRtc录制状态信息的接口
隐藏空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
50 行增加
和
45 行删除
src/EngineEntrance.js
src/apes/Ape.js
src/apes/DocApe.js
src/apes/MediaSharedApe.js
src/apes/MusicSharedApe.js
src/apes/VideoApe.js
src/apes/WebRtcApe.js
src/EngineEntrance.js
查看文件 @
39d0e69
...
...
@@ -62,7 +62,7 @@ export default class MessageEntrance extends Emiter {
constructor
()
{
super
();
//sdk 信息
GlobalConfig
.
sdkVersion
=
"v2.8.
8.20170917
"
;
GlobalConfig
.
sdkVersion
=
"v2.8.
17.20170918
"
;
loger
.
warn
(
"sdkVersion:"
+
GlobalConfig
.
sdkVersion
);
//设置
...
...
@@ -1103,6 +1103,7 @@ export default class MessageEntrance extends Emiter {
GlobalConfig
.
channelId
=
""
+
GlobalConfig
.
siteId
+
"_"
+
GlobalConfig
.
classId
;
GlobalConfig
.
userUid
=
GlobalConfig
.
nodeId
;
GlobalConfig
.
channelKey
=
""
;
GlobalConfig
.
rosters
=
{};
//情况人员数据列表
//判断是否需要获取加入音视频通话频道的channelKey
if
(
GlobalConfig
.
appCertificate
){
...
...
@@ -1985,6 +1986,10 @@ export default class MessageEntrance extends Emiter {
}
//webRtc推流状态发生改变
mediaPublishStatusChange
(
_data
){
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_video_ape
)
{
_video_ape
.
mediaPublishStatusChange
(
_data
);
}
...
...
@@ -2832,7 +2837,7 @@ export default class MessageEntrance extends Emiter {
openCamera
:
GlobalConfig
.
openCamera
,
openMicrophones
:
GlobalConfig
.
openMicrophones
});
this
.
_mediaRecordControl
({
"status"
:
1
});
this
.
_mediaRecordControl
({
"status"
:
WebRtcApe
.
RECORD_STATUS_
1
});
return
;
}
...
...
@@ -2858,11 +2863,12 @@ export default class MessageEntrance extends Emiter {
openCamera
:
GlobalConfig
.
openCamera
,
openMicrophones
:
GlobalConfig
.
openMicrophones
});
this
.
_mediaRecordControl
({
"status"
:
0
});
this
.
_mediaRecordControl
({
"status"
:
WebRtcApe
.
RECORD_STATUS_
0
});
return
;
}
if
(
_webRtc
){
this
.
_mediaRecordControl
({
"status"
:
WebRtcApe
.
RECORD_STATUS_0
});
_webRtc
.
unpublish
(
_params
);
}
}
...
...
src/apes/Ape.js
查看文件 @
39d0e69
...
...
@@ -396,6 +396,10 @@ export default class Ape extends Emiter {
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_SEND_FAILED_NO_JOIN
);
return
;
}
if
(
!
this
.
_classInfo
){
loger
.
warn
(
"课堂数据还未获取,不能发送消息"
);
return
;
}
let
uniformPdu
=
pdu
.
create_uniform_pdu
(
appPdu
.
type
,
this
.
_classInfo
.
nodeId
,
...
...
src/apes/DocApe.js
查看文件 @
39d0e69
...
...
@@ -424,8 +424,8 @@ class DocApe extends Ape {
//console.log(docDataModelPdu);
//console.log(docDataModel);
if
(
docDataModel
==
null
)
{
loger
.
log
(
'文档翻页->文档不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
loger
.
warn
(
'文档翻页->文档不存在'
,
paramInfo
);
//this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return
;
}
//更新数据的字段
...
...
src/apes/MediaSharedApe.js
查看文件 @
39d0e69
...
...
@@ -317,8 +317,8 @@ class MediaSharedApe extends Ape {
//获取已经存在的数据
let
pduDataModel
=
this
.
mediaSharedList
[
paramInfo
.
itemIdx
];
if
(
pduDataModel
==
null
)
{
loger
.
log
(
'媒体文件SEEK->媒体文件不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
loger
.
warn
(
'媒体文件SEEK->媒体文件不存在'
,
paramInfo
);
//this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return
;
}
//更新数据的字段
...
...
src/apes/MusicSharedApe.js
查看文件 @
39d0e69
...
...
@@ -320,8 +320,8 @@ class MusicSharedApe extends Ape {
//获取已经存在的数据
let
pduDataModel
=
this
.
musicSharedList
[
paramInfo
.
itemIdx
];
if
(
pduDataModel
==
null
)
{
loger
.
log
(
'伴音文件SEEK->伴音文件不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
loger
.
warn
(
'伴音文件SEEK->伴音文件不存在'
,
paramInfo
);
//this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return
;
}
//更新数据的字段
...
...
src/apes/VideoApe.js
查看文件 @
39d0e69
...
...
@@ -370,7 +370,10 @@ class VideoApe extends Ape {
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
"已经断开连接"
};
}
if
(
this
.
_classInfo
==
null
||
EngineUtils
.
isEmptyObject
(
this
.
_classInfo
)){
//还未加入频道成功,暂时不能发送消息
return
;
}
/* if (this._classInfo ===null || EngineUtils.isEmptyObject(this._classInfo)) {
loger.log('不能发送Video消息.McuClient还未初始化数据!');
if (GlobalConfig.getCurrentStatus().code == 0 || GlobalConfig.getCurrentStatus().code == 1) {
...
...
src/apes/WebRtcApe.js
查看文件 @
39d0e69
...
...
@@ -113,7 +113,21 @@ class WebRtcApe extends Emiter {
});
}
});
this
.
client
.
on
(
'stream-published'
,
(
evt
)
=>
{
loger
.
log
(
"webRtc->推流成功->"
,
new
Date
().
getTime
());
this
.
isPublish
=
true
;
GlobalConfig
.
openCamera
=
EngineUtils
.
creatTimestamp
();
GlobalConfig
.
openMicrophones
=
GlobalConfig
.
openCamera
;
this
.
_emit
(
MessageTypes
.
USER_DEVICE_STATUS_CHAANGE
,
{
nodeId
:
GlobalConfig
.
nodeId
,
userRole
:
GlobalConfig
.
userRole
,
userName
:
GlobalConfig
.
userName
,
userId
:
GlobalConfig
.
userId
,
openCamera
:
GlobalConfig
.
openCamera
,
openMicrophones
:
GlobalConfig
.
openMicrophones
});
this
.
changePublishStatusAndServerRecord
(
WebRtcApe
.
RECORD_STATUS_1
);
});
this
.
client
.
on
(
'stream-added'
,
(
evt
)
=>
{
let
stream
=
evt
.
stream
;
/* loger.log("添加一个远程视频流: " + stream.getId(),new Date().getTime());
...
...
@@ -122,7 +136,6 @@ class WebRtcApe extends Emiter {
});*/
this
.
reAddRemoteStream
(
stream
);
});
this
.
client
.
on
(
'stream-subscribed'
,
(
evt
)
=>
{
let
stream
=
evt
.
stream
;
if
(
stream
){
...
...
@@ -181,6 +194,7 @@ class WebRtcApe extends Emiter {
let
uid
=
evt
.
uid
;
loger
.
log
(
"当前正在讲话的uid:"
+
uid
);
});
}
//重新添加远程视频
reAddRemoteStream
(
_stream
){
...
...
@@ -194,7 +208,6 @@ class WebRtcApe extends Emiter {
}
loger
.
log
(
"添加一个远程视频流: "
+
_stream
.
getId
(),
new
Date
().
getTime
());
this
.
client
.
subscribe
(
_stream
,
(
err
)
=>
{
loger
.
warn
(
"添加一个远程视频流->失败"
,
err
);
//clearTimeout(this.reAddRemoteStreamDelay);
if
(
err
==
"INVALID_REMOTE_STREAM"
){
//流已经无效,不需要再重连
...
...
@@ -204,11 +217,11 @@ class WebRtcApe extends Emiter {
if
(
err
==
"PEERCONNECTION_FAILED"
){
//this.reAddRemoteStreamDelay=setTimeout(()=>{
setTimeout
(()
=>
{
loger
.
warn
(
"连接远程的流失败->尝试重新连接"
);
loger
.
warn
(
"连接远程的流失败->尝试重新连接"
,
err
);
this
.
reAddRemoteStream
(
_stream
);
},
1400
);
}
}
else
{
loger
.
warn
(
"添加一个远程视频流->失败"
,
err
);
}
});
}
...
...
@@ -233,6 +246,7 @@ class WebRtcApe extends Emiter {
reGetLoaclStream
(){
if
(
this
.
isPublish
){
loger
.
log
(
"重新获取摄像头和麦克风并重新推流"
);
//this.changePublishStatusAndServerRecord(WebRtcApe.RECORD_STATUS_0);
this
.
unpublish
();
this
.
openLoaclStream
();
//切换设备后自动重推流
...
...
@@ -325,27 +339,14 @@ class WebRtcApe extends Emiter {
this
.
isPublish
=
false
;
this
.
unpublish
();
});
this
.
client
.
on
(
'stream-published'
,
(
evt
)
=>
{
loger
.
log
(
"webRtc->推流成功->"
,
new
Date
().
getTime
());
this
.
isPublish
=
true
;
GlobalConfig
.
openCamera
=
EngineUtils
.
creatTimestamp
();
GlobalConfig
.
openMicrophones
=
GlobalConfig
.
openCamera
;
this
.
_emit
(
MessageTypes
.
USER_DEVICE_STATUS_CHAANGE
,
{
nodeId
:
GlobalConfig
.
nodeId
,
userRole
:
GlobalConfig
.
userRole
,
userName
:
GlobalConfig
.
userName
,
userId
:
GlobalConfig
.
userId
,
openCamera
:
GlobalConfig
.
openCamera
,
openMicrophones
:
GlobalConfig
.
openMicrophones
});
this
.
changePublishStatusAndServerRecord
(
WebRtcApe
.
RECORD_STATUS_1
);
});
},
(
err
)
=>
{
loger
.
warn
(
"webRtc->推流->本地流开启失败"
,
err
);
this
.
isPublish
=
false
;
this
.
clearLocalView
();
this
.
_emit
(
MessageTypes
.
WEB_RTC_PUBLISH_FAILED
,
err
);
if
(
err
&&
err
.
msg
==
"STREAM_ALREADY_INITIALIZED"
){
this
.
unpublish
();
}
});
}
...
...
@@ -371,7 +372,6 @@ class WebRtcApe extends Emiter {
openCamera
:
GlobalConfig
.
openCamera
,
openMicrophones
:
GlobalConfig
.
openMicrophones
});
this
.
changePublishStatusAndServerRecord
(
WebRtcApe
.
RECORD_STATUS_0
);
}
//清除本地视图
clearLocalView
(){
...
...
@@ -459,6 +459,7 @@ class WebRtcApe extends Emiter {
clearTimeout
(
this
.
changeDevicesDelay
);
this
.
changeDevicesDelay
=
setTimeout
(()
=>
{
this
.
changePublishStatusAndServerRecord
(
WebRtcApe
.
RECORD_STATUS_0
);
//重新获取本地视图流
this
.
reGetLoaclStream
();
},
1400
);
...
...
@@ -508,16 +509,7 @@ class WebRtcApe extends Emiter {
//组织数据,发送给服务器,控制录制和开启录制-推流和停止推流 status:0 停止推流 1:开始推流(同时开启录制),2:停止录制(同时停止推流)
packMediaInfoData
(
_status
){
let
curTimestamp
=
new
Date
().
getTime
();
let
data
=
`
appId
=
$
{
GlobalConfig
.
appId
}
&
channel
=
$
{
GlobalConfig
.
channelId
}
&
channelKey
=
$
{
GlobalConfig
.
appCertificate
}
&
uid
=
$
{
GlobalConfig
.
userUid
}
&
status
=
$
{
_status
}
&
userId
=
$
{
GlobalConfig
.
userId
}
&
userName
=
$
{
GlobalConfig
.
userName
}
&
userRole
=
$
{
GlobalConfig
.
userRole
}
&
timestamp
=
$
{
curTimestamp
}
&
recordTimestamp
=
$
{
GlobalConfig
.
recordTimestamp
}
`
;
let
data
=
`
appId
=
$
{
GlobalConfig
.
appId
}
&
channel
=
$
{
GlobalConfig
.
channelId
}
&
channelKey
=
$
{
GlobalConfig
.
appCertificate
}
&
uid
=
$
{
GlobalConfig
.
userUid
}
&
status
=
$
{
_status
}
&
userId
=
$
{
GlobalConfig
.
userId
}
&
userName
=
$
{
GlobalConfig
.
userName
}
&
userRole
=
$
{
GlobalConfig
.
userRole
}
&
timestamp
=
$
{
curTimestamp
}
&
recordTimestamp
=
$
{
GlobalConfig
.
recordTimestamp
}
`
;
//mcu记录一份数据
this
.
_emit
(
MessageTypes
.
MEDIA_PUBLISH_STATUS_CHANGE
,
{
...
...
@@ -611,8 +603,8 @@ class WebRtcApe extends Emiter {
}
}
WebRtcApe
.
prototype
.
RECORD_STATUS_0
=
WebRtcApe
.
RECORD_STATUS_0
=
0
;
//停止推流
WebRtcApe
.
prototype
.
RECORD_STATUS_1
=
WebRtcApe
.
RECORD_STATUS_1
=
0
;
//开始推流
WebRtcApe
.
prototype
.
RECORD_STATUS_2
=
WebRtcApe
.
RECORD_STATUS_2
=
0
;
//停止录制
WebRtcApe
.
prototype
.
RECORD_STATUS_1
=
WebRtcApe
.
RECORD_STATUS_1
=
1
;
//开始推流
WebRtcApe
.
prototype
.
RECORD_STATUS_2
=
WebRtcApe
.
RECORD_STATUS_2
=
2
;
//停止录制
export
default
new
WebRtcApe
;
...
...
请
注册
或
登录
后发表评论