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
772c15435e11be4955e8cfe49561f3836a0efbed
772c1543
1 parent
6d0c6fe1
1.屏幕共享增加助教和主讲人的权限,也可以共享;2.修改webRtc推流显示时的名字和位置;3.修改随机生成的userId和名字的长度
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
32 行增加
和
64 行删除
src/EngineEntrance.js
src/apes/VideoApe.js
src/apes/WebRtcApe.js
src/EngineEntrance.js
查看文件 @
772c154
...
...
@@ -62,7 +62,7 @@ export default class MessageEntrance extends Emiter {
constructor
()
{
super
();
//sdk 信息
GlobalConfig
.
sdkVersion
=
"v2.1
3
.5.20170927"
;
GlobalConfig
.
sdkVersion
=
"v2.1
4
.5.20170927"
;
loger
.
warn
(
"sdkVersion:"
+
GlobalConfig
.
sdkVersion
);
//设置
...
...
@@ -560,7 +560,7 @@ export default class MessageEntrance extends Emiter {
GlobalConfig
.
portal
=
GlobalConfig
.
replacePort
(
GlobalConfig
.
portal
,
":80"
,
""
);
}
GlobalConfig
.
userId
=
_param
.
userId
||
"0"
;
GlobalConfig
.
userId
=
""
+
_param
.
userId
||
"0"
;
//H5处理
GlobalConfig
.
isH5
=
_param
.
isH5
||
false
;
//外部传入的参数,是否是H5
if
(
GlobalConfig
.
isH5
==
true
)
{
...
...
@@ -575,13 +575,6 @@ export default class MessageEntrance extends Emiter {
GlobalConfig
.
microphones
=
_param
.
microphones
||
[];
}
//如果没有名字,随机起一个名字
GlobalConfig
.
userName
=
_param
.
userName
||
"user_"
+
(
new
Date
().
getTime
()
%
1000000
);
//如果没有userId或者为"0",随机生成
if
(
GlobalConfig
.
userId
==
"0"
)
{
GlobalConfig
.
userId
=
"user_"
+
(
new
Date
().
getTime
()
%
1000000
);
}
//设置角色身份
GlobalConfig
.
userRole
=
_param
.
userRole
||
ApeConsts
.
normal
;
if
(
GlobalConfig
.
userRole
!=
ApeConsts
.
host
&&
...
...
@@ -591,6 +584,25 @@ export default class MessageEntrance extends Emiter {
GlobalConfig
.
userRole
!=
ApeConsts
.
invisible
)
{
GlobalConfig
.
userRole
=
ApeConsts
.
normal
;
}
//如果没有名字或没有userId的时候,需要随机生成
let
timestampStr
=
new
Date
().
getTime
().
toString
();
timestampStr
=
timestampStr
.
substr
(
timestampStr
.
length
-
4
);
if
(
GlobalConfig
.
userRole
==
ApeConsts
.
host
){
timestampStr
=
"T"
+
timestampStr
;
}
else
if
(
GlobalConfig
.
userRole
==
ApeConsts
.
assistant
)
{
timestampStr
=
"A"
+
timestampStr
;
}
else
if
(
GlobalConfig
.
userRole
==
ApeConsts
.
presenter
){
timestampStr
=
"P"
+
timestampStr
;
}
else
{
timestampStr
=
"S"
+
timestampStr
;
}
//如果没有名字,随机起一个名字
GlobalConfig
.
userName
=
_param
.
userName
||
timestampStr
;
//如果没有userId或者为"0",随机生成
if
(
!
GlobalConfig
.
userId
||
GlobalConfig
.
userId
==
"0"
)
{
GlobalConfig
.
userId
=
timestampStr
;
}
//客户端决定是否延迟接收消息
GlobalConfig
.
messageDelay
=
_param
.
messageDelay
||
false
;
...
...
@@ -1697,8 +1709,10 @@ export default class MessageEntrance extends Emiter {
loger
.
log
(
'获取课堂课堂信息完成.'
,
_data
.
appConfig
);
//包含整个课堂最全的信息,储存数据
if
(
_data
)
{
//老师默认启用画笔功能,其他身份默认禁用画笔功能
if
(
GlobalConfig
.
userRole
==
ApeConsts
.
host
){
//老师\助教默认启用画笔功能,其他身份默认禁用画笔功能
if
(
GlobalConfig
.
userRole
==
ApeConsts
.
host
||
GlobalConfig
.
userRole
==
ApeConsts
.
assistant
||
GlobalConfig
.
userRole
==
ApeConsts
.
presenter
){
GlobalConfig
.
selfDisEnableDrawTime
=
0
;
}
...
...
src/apes/VideoApe.js
查看文件 @
772c154
...
...
@@ -286,7 +286,7 @@ class VideoApe extends Ape {
publishType
=
'live'
;
}
//老师能开启屏幕共享
if
(
GlobalConfig
.
isHost
)
{
if
(
GlobalConfig
.
isHost
||
GlobalConfig
.
isAssistant
||
GlobalConfig
.
isPresenter
)
{
//获取屏幕共享推流的地址
let
shareResult
=
this
.
mediaModule
.
getMediaPublishPathForScreenShare
(
this
.
shareApe
.
channelId
,
publishType
);
shareResult
.
ip
=
_param
.
ip
||
""
;
//外部可以设置屏幕共享的IP
...
...
@@ -303,7 +303,7 @@ class VideoApe extends Ape {
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
"已经断开连接"
};
}
//只有老师能停止屏幕共享
if
(
GlobalConfig
.
isHost
)
{
if
(
GlobalConfig
.
isHost
||
GlobalConfig
.
isAssistant
||
GlobalConfig
.
isPresenter
)
{
let
channelInfo
=
this
.
shareApe
.
getDefaultChannelInfo
();
channelInfo
.
status
=
ApeConsts
.
CHANNEL_STATUS_RELEASED
;
this
.
sendTableUpdateHandler
(
channelInfo
);
...
...
src/apes/WebRtcApe.js
查看文件 @
772c154
...
...
@@ -144,50 +144,6 @@ class WebRtcApe extends Emiter {
let
stream
=
evt
.
stream
;
this
.
addRemoetStreamView
(
stream
);
});
/* this.client.on('stream-subscribed', (evt)=> {
let stream = evt.stream;
if(stream){
//let viewDiv=`<div id="${this.xdyRemote + stream.getId()}" style="width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;"></div>`;
let uid=stream.getId();
let user=GlobalConfig.getUserInfoFromeNodeId(uid);
let userName="";
let userRole=""
if(user){
userName=user.name||"";
userRole=user.userRole;
}
let nameDiv=`<div style="width:98%;height:20px; position: absolute; z-index: 1;left: 4px;overflow:hidden;font-size: 14px; color: #cccccc;display:${this.nameDisplay}">${userName}</div>`;
if(userRole==ApeConsts.invisible){
//把远程视频添加到监课列表
loger.log("获取远程视频流成功->监课:"+userName+"->" + uid,new Date().getTime());
let viewDiv=`<div id="${this.xdyRemote + uid}" style="width:${this.invisibleVideoWidth}px;height:${this.invisibleVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`;
$(this.invisibleViewId).append(viewDiv);
}else if(userRole==ApeConsts.host){
//把远程视图添加到老师列表
loger.log("获取远程视频流成功->老师:"+userName+"->" + uid,new Date().getTime());
let viewDiv=`<div id="${this.xdyRemote + uid}" style="width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`;
$(this.hostRemoteViewId).append(viewDiv);
}else {
//把视图添加到学生列表
loger.log("获取远程视频流成功->学生:"+userName+"->" +uid,new Date().getTime());
let viewDiv=`<div id="${this.xdyRemote + uid}" style="width:${this.normalRemoteVideoWidth}px;height:${this.normalRemoteVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`;
$(this.normalRemoteViewId).append(viewDiv);
}
//播放视频,隐藏控制条
try{
$("bar_"+stream.getId()).hide();
stream.play(this.xdyRemote + stream.getId());
}catch (err){
}
if(user.deviceType==1||user.deviceType==2){
this.remoteVideoList[user.nodeId]=stream;
}
console.log("移动端远程视频流集合->",this.remoteVideoList);
}
});*/
this
.
client
.
on
(
'stream-removed'
,
(
evt
)
=>
{
let
stream
=
evt
.
stream
;
if
(
stream
)
{
...
...
@@ -215,7 +171,6 @@ class WebRtcApe extends Emiter {
addRemoetStreamView
(
stream
)
{
if
(
stream
)
{
//let viewDiv=`<div id="${this.xdyRemote + stream.getId()}" style="width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;"></div>`;
let
uid
=
stream
.
getId
();
let
user
=
GlobalConfig
.
getUserInfoFromeNodeId
(
uid
);
let
userName
=
""
;
...
...
@@ -224,16 +179,16 @@ class WebRtcApe extends Emiter {
userName
=
user
.
name
||
"unknow"
;
userRole
=
user
.
userRole
;
}
let
nameDiv
=
`
<
div
style
=
"width:98%;height:20px; position: absolute;
z-index: 1;left: 4px;overflow:hidden;font-size: 14px
; color: #cccccc;display:${this.nameDisplay}"
>
$
{
userName
}
<
/div>`
;
let
nameDiv
=
`
<
div
style
=
"width:98%;height:20px; position: absolute;
bottom: 0; z-index: 1;left: 4px;overflow:hidden;font-size: 14px;text-align: right
; color: #cccccc;display:${this.nameDisplay}"
>
$
{
userName
}
<
/div>`
;
if
(
userRole
==
ApeConsts
.
invisible
)
{
//把远程视频添加到监课列表
loger
.
log
(
"获取远程视频流成功->监课:"
+
userName
+
"->"
+
uid
,
new
Date
().
getTime
());
let
viewDiv
=
`
<
div
id
=
"${this.xdyRemote + uid}"
style
=
"width:${this.invisibleVideoWidth}px;height:${this.invisibleVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;"
>
$
{
nameDiv
}
<
/div>`
;
$
(
this
.
invisibleViewId
).
append
(
viewDiv
);
}
else
if
(
userRole
==
ApeConsts
.
host
)
{
}
else
if
(
userRole
==
ApeConsts
.
host
||
userRole
==
ApeConsts
.
assistant
||
userRole
==
ApeConsts
.
presenter
)
{
//把远程视图添加到老师列表
loger
.
log
(
"获取远程视频流成功->
老师
:"
+
userName
+
"->"
+
uid
,
new
Date
().
getTime
());
loger
.
log
(
"获取远程视频流成功->
userRole:"
+
userRole
+
"
:"
+
userName
+
"->"
+
uid
,
new
Date
().
getTime
());
let
viewDiv
=
`
<
div
id
=
"${this.xdyRemote + uid}"
style
=
"width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;"
>
$
{
nameDiv
}
<
/div>`
;
$
(
this
.
hostRemoteViewId
).
append
(
viewDiv
);
}
else
{
...
...
@@ -251,7 +206,6 @@ class WebRtcApe extends Emiter {
if
(
user
&&
(
user
.
deviceType
==
1
||
user
.
deviceType
==
2
))
{
this
.
remoteVideoList
[
user
.
nodeId
]
=
stream
;
}
console
.
log
(
"移动端远程视频流集合->"
,
this
.
remoteVideoList
);
}
}
...
...
@@ -277,7 +231,7 @@ class WebRtcApe extends Emiter {
setTimeout
(()
=>
{
loger
.
warn
(
"连接远程的流失败->尝试重新连接"
,
err
);
this
.
reAddRemoteStream
(
_stream
);
},
1
4
00
);
},
1
2
00
);
}
else
{
loger
.
warn
(
"添加一个远程视频流->失败"
,
err
);
}
...
...
@@ -431,7 +385,7 @@ class WebRtcApe extends Emiter {
if
(
user
)
{
userName
=
user
.
name
||
""
;
}
let
nameDiv
=
`
<
div
id
=
"${"
videoOwnerName_
" + this.uid}"
style
=
"width:98%;height:20px; position: absolute;
z-index: 1;left: 4px;overflow:hidden;font-size: 14px
; color: #cccccc;display:${this.nameDisplay}"
>
$
{
userName
}
<
/div>`
;
let
nameDiv
=
`
<
div
id
=
"${"
videoOwnerName_
" + this.uid}"
style
=
"width:98%;height:20px; position: absolute;
bottom: 0; z-index: 1;left: 4px;overflow:hidden;font-size: 14px;text-align: right
; color: #cccccc;display:${this.nameDisplay}"
>
$
{
userName
}
<
/div>`
;
$
(
this
.
localViewId
).
prepend
(
nameDiv
);
loger
.
log
(
"webRtc->推流->"
,
viewName
,
new
Date
().
getTime
());
...
...
请
注册
或
登录
后发表评论