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
李勇
2017-07-27 15:39:53 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bd69d567512598f133881c6ae5c3ec0874af8d5a
bd69d567
1 parent
6b4ab883
1.修改媒体共享和伴音模块的seek间隔处理;2.音视频m3u8地址增加playlist ;3.修改mcu\ms\rtmp\hls的地址数据来源
隐藏空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
958 行增加
和
365 行删除
src/EngineEntrance.js
src/GlobalConfig.js
src/IpManager.js
src/MessageTypes.js
src/apes/ConferApe.js
src/apes/MediaModule.js
src/apes/MediaSharedApe.js
src/apes/MusicSharedApe.js
src/EngineEntrance.js
查看文件 @
bd69d56
...
...
@@ -35,7 +35,7 @@ import QuestionApe from 'apes/QuestionApe';
import
UTF8
from
'utf-8'
;
let
loger
=
Loger
.
getLoger
(
'McuClient'
);
let
_sdkInfo
=
{
"version"
:
"v1.52.1.20170726"
,
"author"
:
"www.3mang.com"
};
let
_sdkInfo
=
{
"version"
:
"v1.54.2.20170727"
,
"author"
:
"www.3mang.com"
};
//APE
let
_sass
;
...
...
@@ -66,8 +66,11 @@ export default class MessageEntrance extends Emiter {
this
.
classRecordStatusUpdateTimer
=
0
;
//课堂录制状态发生改变后同步当前所有模块数据的计时器
//初始化状态
this
.
isGetUserIpCallback
=
false
;
//是否获取IP信息返回
this
.
isGetFastestMcuCallback
=
false
;
//是否MCU选点结束
this
.
isGetFastestMsCallback
=
false
;
//是否MS选点结束
this
.
isGetFastestMcuCallback
=
false
;
//是否MCU测速结束
this
.
isGetFastestMsCallback
=
false
;
//是否MS测速结束
this
.
isGetFastestRtmpPullCallback
=
false
;
//是否RTMP拉流地址测试结束
this
.
isGetFastestHlsPullCallback
=
false
;
//是否HLS拉流地址测试结束
this
.
isGetFastestRsCallback
=
false
;
//是否录制回放HLS拉流地址测试结束
//全局的Error处理
this
.
on
(
MessageTypes
.
MCU_ERROR
,
this
.
_mcuErrorHandler
.
bind
(
this
));
...
...
@@ -111,6 +114,8 @@ export default class MessageEntrance extends Emiter {
_confer_ape
.
on
(
MessageTypes
.
CLASS_RECORD_START
,
this
.
_onClassRecordStart
.
bind
(
this
));
//课堂开始录制
_confer_ape
.
on
(
MessageTypes
.
CLASS_RECORD_SUCCESS
,
this
.
_onClassRecordSuccess
.
bind
(
this
));
//课堂开启录制成功
_confer_ape
.
on
(
MessageTypes
.
SWITCH_MS_IP
,
this
.
_switchMsIpHandler
.
bind
(
this
));
//MS动态选点
_confer_ape
.
on
(
MessageTypes
.
SWITCH_RTMP_PULL_IP
,
this
.
_switchRtmpPullIpHandler
.
bind
(
this
));
//MS 拉流地址动态选点
_confer_ape
.
on
(
MessageTypes
.
SWITCH_HLS_IP
,
this
.
_switchHlsIpHandler
.
bind
(
this
));
//MS HLS动态选点
_confer_ape
.
on
(
MessageTypes
.
STOP_ALL_MEDIA_PUBLISH
,
this
.
_stopAllMediaPublishHandler
.
bind
(
this
));
//课堂状态发生改变,需要停止当前的所有推流
_chat_ape
=
new
ChatApe
();
...
...
@@ -166,9 +171,9 @@ export default class MessageEntrance extends Emiter {
this
.
sceneTableChange
=
this
.
_sceneTableChange
.
bind
(
this
);
//切换模块显示
this
.
kickOutRosterFormNodeId
=
this
.
_kickOutRosterFormNodeId
.
bind
(
this
);
//把指定nodeId的人踢出课堂
this
.
kickOutRosterFormNodeId
=
this
.
_kickOutRosterFormNodeId
.
bind
(
this
);
//把指定nodeId的人踢出课堂
this
.
sendThridChannelMessage
=
this
.
_sendThridChannelMessage
.
bind
(
this
);
//通道第三方消息通道发送消息
this
.
sendThridChannelMessage
=
this
.
_sendThridChannelMessage
.
bind
(
this
);
//通道第三方消息通道发送消息
//录制回放
this
.
initRecordPlayback
=
this
.
_initRecordPlayback
.
bind
(
this
);
...
...
@@ -256,12 +261,13 @@ export default class MessageEntrance extends Emiter {
}
_setDebugInfo
(
_data
)
{
loger
.
log
(
"设置debug信息-->"
,
_data
);
if
(
_data
)
{
Loger
.
setLogDebug
(
_data
.
isDebug
);
}
loger
.
log
(
"设置debug信息-->"
,
_data
);
if
(
_data
)
{
Loger
.
setLogDebug
(
_data
.
isDebug
);
}
//设置设备信息
}
//设置设备信息
_setDeviceInfo
(
_data
)
{
loger
.
log
(
"设置设备信息-->"
,
_data
);
if
(
_data
)
{
...
...
@@ -296,7 +302,7 @@ export default class MessageEntrance extends Emiter {
//mcu异常监听
_mcuErrorHandler
(
_data
,
_option
)
{
let
option
=
_option
||
""
;
let
errorMessage
=
{
"code"
:
_data
,
"reson"
:
MessageTypes
.
ErrorReson
[
_data
]
+
" "
+
option
};
let
errorMessage
=
{
"code"
:
_data
,
"reson"
:
MessageTypes
.
ErrorReson
[
_data
]
+
" "
+
option
};
this
.
_emit
(
MessageTypes
.
ERROR_EVENT
,
errorMessage
);
loger
.
error
(
"MCU_ERROR"
,
errorMessage
);
}
...
...
@@ -316,12 +322,6 @@ export default class MessageEntrance extends Emiter {
return
GlobalConfig
.
classStatusInfo
;
}
/*
//关闭课堂,所有人都退出
_doClassClose(_param) {
this._leaveClass();
}*/
//执行离开课堂断开连接的流程
_runClassExit
(
_type
)
{
this
.
_leaveClass
(
_type
);
...
...
@@ -385,7 +385,9 @@ export default class MessageEntrance extends Emiter {
}
//有人员离开
_onClassDeleteRoster
(
_data
)
{}
_onClassDeleteRoster
(
_data
)
{
}
//当前课堂中视频或音频占用channel的nodeId ,在人员列表中不存在,这种情况是占用channel的人员掉线或离开的时候没有释放channel
//的占用状态导致,对于这种情况,需要释放掉
...
...
@@ -399,7 +401,7 @@ export default class MessageEntrance extends Emiter {
loger
.
warn
(
"onClassNonentityRoster.参数错误"
)
return
;
}
let
data
=
{
"nodeId"
:
_param
.
nodeId
};
let
data
=
{
"nodeId"
:
_param
.
nodeId
};
if
(
_video_ape
)
{
_video_ape
.
stopPublishVideo
(
data
);
...
...
@@ -437,25 +439,25 @@ export default class MessageEntrance extends Emiter {
GlobalConfig
.
portal
=
_param
.
portal
;
//H5处理
GlobalConfig
.
isH5
=
_param
.
isH5
||
false
;
//外部传入的参数,是否是H5
if
(
GlobalConfig
.
isH5
==
true
){
GlobalConfig
.
platform
=
"H5"
;
GlobalConfig
.
deviceType
=
3
//3是H5
GlobalConfig
.
isH5
=
_param
.
isH5
||
false
;
//外部传入的参数,是否是H5
if
(
GlobalConfig
.
isH5
==
true
)
{
GlobalConfig
.
platform
=
"H5"
;
GlobalConfig
.
deviceType
=
3
//3是H5
loger
.
warn
(
"设备类型是H5"
);
}
//IOS 安卓处理,需要外部传入摄像头和麦克风信息
if
(
GlobalConfig
.
isMobile
){
GlobalConfig
.
cameras
=
_param
.
cameras
||
[];
GlobalConfig
.
microphones
=
_param
.
microphones
||
[];
if
(
GlobalConfig
.
isMobile
)
{
GlobalConfig
.
cameras
=
_param
.
cameras
||
[];
GlobalConfig
.
microphones
=
_param
.
microphones
||
[];
}
//如果没有名字,随机起一个名字
GlobalConfig
.
userName
=
_param
.
userName
||
"user_"
+
(
new
Date
().
getTime
()
%
1000000
);
//如果没有userId或者为"0",随机生成
if
(
!
GlobalConfig
.
userId
||
GlobalConfig
.
userId
==
"0"
){
GlobalConfig
.
userId
=
"user_"
+
(
new
Date
().
getTime
()
%
1000000
);
if
(
!
GlobalConfig
.
userId
||
GlobalConfig
.
userId
==
"0"
)
{
GlobalConfig
.
userId
=
"user_"
+
(
new
Date
().
getTime
()
%
1000000
);
}
//设置角色身份
GlobalConfig
.
userRole
=
_param
.
userRole
||
ApeConsts
.
normal
;
...
...
@@ -527,7 +529,6 @@ export default class MessageEntrance extends Emiter {
//host默认需要密码,Sass服务器只判断学生是否需要密码,没有判断老师的
GlobalConfig
.
passwordRequired
=
_data
.
passwordRequired
||
false
;
//md5验证的时候需要Sass返回的值,不能更改
loger
.
log
(
'初始化课堂验证完成.'
);
//设置当前的课堂状态
...
...
@@ -559,17 +560,18 @@ export default class MessageEntrance extends Emiter {
}
}
//根据UserIp获取ip信息,选点
getUserIpInfo
()
{
//加载本地Server.json文件,UserIp获取ip信息,选点
loadServerJsonAndgetUserIpInfo
()
{
let
_this
=
this
;
if
(
_ipManager
)
{
//先加载本地Server.json文件,然后获取userIp新
_ipManager
.
loadServerJosn
(
function
(
_data
)
{
_ipManager
.
getUserIpInfo
(
""
,
GlobalConfig
.
userIp
,
_this
.
_getUserIpCallbackHandler
.
bind
(
_this
),
2000
);
})
}
}
//获取IP信息完成
//
本地JOSN加载完成-
获取IP信息完成
_getUserIpCallbackHandler
(
_data
)
{
//获取IP信息,返回一次就不再处理
if
(
this
.
isGetUserIpCallback
)
{
...
...
@@ -583,61 +585,177 @@ export default class MessageEntrance extends Emiter {
GlobalConfig
.
isp
=
_data
.
isp
;
//服务商
}
//合并MCU 、MS的列表
this
.
_mergeMcuAndMsList
();
//根据用户的userIp信息从sever.json和Sass中选择最终mcu和推流拉流数据列表
this
.
_choiceMcuAndMsListFromServerAndSass
();
//开始选点
loger
.
warn
(
"加入课堂之前->开始测速选择默认服务"
);
//加入课堂之前开始第一次选点
let
_this
=
this
;
//有一些站点不需要进行MS选点,需要先检查一下
if
(
GlobalConfig
.
siteId_letv
==
GlobalConfig
.
siteId
)
{
//MS不需要选点
loger
.
log
(
"MS不需要选点->siteId->"
,
GlobalConfig
.
siteId
);
_this
.
isGetFastestMcuCallback
=
true
;
_this
.
_startConnectMCU
();
}
else
{
this
.
_getFastestMsServer
(
function
(
_data
)
{
loger
.
log
(
"MS选点结束->"
,
_data
);
//推流地址测速
this
.
_getFastestIpFromServer
(
GlobalConfig
.
msListFinal
,
function
(
_data
)
{
loger
.
log
(
"推流地址测速->"
,
_data
);
if
(
_data
&&
_data
.
ip
)
{
GlobalConfig
.
MS_PUBLISH_IP
=
_data
.
ip
||
""
;
GlobalConfig
.
MS_PUBLISH_PORT
=
_data
.
port
||
""
;
}
loger
.
log
(
"当前使用的MS->"
,
GlobalConfig
.
MS_PUBLISH_IP
,
GlobalConfig
.
MS_PUBLISH_PORT
);
_this
.
isGetFastestMcuCallback
=
true
;
_this
.
isGetFastestMsCallback
=
true
;
_this
.
_startConnectMCU
();
});
}
//录制回放HLS拉流地址测速
this
.
_getFastestIpFromServer
(
GlobalConfig
.
rsListFinal
,
function
(
_data
)
{
loger
.
log
(
"录制回放HLS拉流地址测速->"
,
_data
);
if
(
_data
&&
_data
.
ip
)
{
GlobalConfig
.
RS_RECORD_PLAY_IP
=
_data
.
ip
||
""
;
GlobalConfig
.
RS_RECORD_PLAY_PORT
=
_data
.
port
||
""
;
}
_this
.
isGetFastestRsCallback
=
true
;
_this
.
_startConnectMCU
();
});
//RTMP拉流地址测速
this
.
_getFastestIpFromServer
(
GlobalConfig
.
rtmpPullListFinal
,
function
(
_data
)
{
loger
.
log
(
"RTMP拉流地址测速->"
,
_data
);
if
(
_data
&&
_data
.
ip
)
{
GlobalConfig
.
MS_PLAY_RTMP_IP
=
_data
.
ip
||
""
;
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
_data
.
port
||
""
;
}
_this
.
isGetFastestRtmpPullCallback
=
true
;
_this
.
_startConnectMCU
();
});
//HLS拉流地址测速
this
.
_getFastestIpFromServer
(
GlobalConfig
.
hlsListFinal
,
function
(
_data
)
{
loger
.
log
(
"HLS拉流地址测速->"
,
_data
);
if
(
_data
&&
_data
.
ip
)
{
GlobalConfig
.
MS_PLAY_HLS_IP
=
_data
.
ip
||
""
;
GlobalConfig
.
MS_PLAY_HLS_PORT
=
_data
.
port
||
""
;
}
_this
.
isGetFastestHlsPullCallback
=
true
;
_this
.
_startConnectMCU
();
});
//MCU测速
this
.
_getFastestMcuServer
(
function
(
_data
)
{
loger
.
log
(
"MCU
选点结束
->"
,
_data
);
loger
.
log
(
"MCU
测速
->"
,
_data
);
if
(
_data
&&
_data
.
ip
)
{
GlobalConfig
.
MCUServerIP
=
_data
.
ip
||
""
;
GlobalConfig
.
MCUServerPort
=
_data
.
port
||
""
;
}
loger
.
log
(
"当前使用的MCU->"
,
GlobalConfig
.
MCUServerIP
,
GlobalConfig
.
MCUServerPort
);
_this
.
isGetFastestMsCallback
=
true
;
_this
.
isGetFastestMcuCallback
=
true
;
_this
.
_startConnectMCU
();
});
}
//开始连接MCU(MCU和MS都选点结束之后才开始连接)
/* //本地JOSN加载完成-获取IP信息完成
_getUserIpCallbackHandler(_data) {
//获取IP信息,返回一次就不再处理
if (this.isGetUserIpCallback) {
return;
}
this.isGetUserIpCallback = true;
if (_data && _data.ret == "ok") {
GlobalConfig.country = _data.country; //国家
GlobalConfig.city = _data.city; //城市
GlobalConfig.province = _data.province; //服务商
GlobalConfig.isp = _data.isp; //服务商
}
//合并MCU 、MS的列表
this._choiceMcuAndMsList();
//开始选点
let _this = this;
//有一些站点不需要进行MS选点,需要先检查一下
if (GlobalConfig.siteId_letv == GlobalConfig.siteId) {
//MS不需要选点
loger.log("MS不需要选点->siteId->", GlobalConfig.siteId);
_this.isGetFastestMcuCallback = true;
_this._startConnectMCU();
} else {
this._getFastestMsServer(function (_data) {
loger.log("MS选点结束->", _data);
if (_data && _data.ip) {
GlobalConfig.MS_PUBLISH_IP = _data.ip || "";
GlobalConfig.MS_PUBLISH_PORT = _data.port || "";
}
loger.log("当前使用的MS->", GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT);
_this.isGetFastestMcuCallback = true;
_this._startConnectMCU();
});
}
this._getFastestMcuServer(function (_data) {
loger.log("MCU选点结束->", _data);
if (_data && _data.ip) {
GlobalConfig.MCUServerIP = _data.ip || "";
GlobalConfig.MCUServerPort = _data.port || "";
}
loger.log("当前使用的MCU->", GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort);
_this.isGetFastestMsCallback = true;
_this._startConnectMCU();
});
}*/
//开始连接MCU(所有服务地址测试完成之后开始连接)
_startConnectMCU
()
{
if
(
this
.
isGetFastestMcuCallback
&&
this
.
isGetFastestMsCallback
)
{
if
(
this
.
isGetFastestMcuCallback
&&
this
.
isGetFastestMsCallback
&&
this
.
isGetFastestRtmpPullCallback
&&
this
.
isGetFastestHlsPullCallback
&&
this
.
isGetFastestRsCallback
)
{
//mcu完成
//ms推流测速完成
//rtmp拉流测速完成
//hls拉流测速完成
//hls录制回放拉流测速完成
this
.
_joinMCU
();
}
}
//合并Sever和Sass的mcu、ms列表
_mergeMcuAndMsList
()
{
//从Sever和Sass中选择的mcu、ms列表,如果server.json中存在就不使用Sass
_choiceMcuAndMsListFromServerAndSass
()
{
//1.根据user信息获取服务器列表
if
(
_ipManager
)
{
GlobalConfig
.
mcuListFromServer
=
_ipManager
.
getServerMcuList
(
GlobalConfig
.
mcuListFromServer
=
_ipManager
.
getServerListForUserInfo
(
"MCU"
,
GlobalConfig
.
country
,
GlobalConfig
.
province
,
GlobalConfig
.
city
,
GlobalConfig
.
isp
,
Server
.
serverList
);
GlobalConfig
.
msListFromServer
=
_ipManager
.
getServerListForUserInfo
(
"MS"
,
GlobalConfig
.
country
,
GlobalConfig
.
province
,
GlobalConfig
.
city
,
GlobalConfig
.
isp
,
Server
.
serverList
);
GlobalConfig
.
rtmpPullListFromServer
=
_ipManager
.
getServerListForUserInfo
(
"RTMP_PULL"
,
GlobalConfig
.
country
,
GlobalConfig
.
province
,
GlobalConfig
.
city
,
GlobalConfig
.
isp
,
Server
.
serverList
);
GlobalConfig
.
rsPullListFromServer
=
_ipManager
.
getServerListForUserInfo
(
"RS_PULL"
,
GlobalConfig
.
country
,
GlobalConfig
.
province
,
GlobalConfig
.
city
,
GlobalConfig
.
isp
,
Server
.
serverList
);
GlobalConfig
.
msListFromServer
=
_ipManager
.
getServerMsList
(
GlobalConfig
.
hlsPullListFromServer
=
_ipManager
.
getServerListForUserInfo
(
"HLS_PULL"
,
GlobalConfig
.
country
,
GlobalConfig
.
province
,
GlobalConfig
.
city
,
...
...
@@ -645,60 +763,130 @@ export default class MessageEntrance extends Emiter {
Server
.
serverList
);
}
console
.
log
(
" GlobalConfig.mcuListFromServer"
,
GlobalConfig
.
mcuListFromServer
);
console
.
log
(
" GlobalConfig.msListFromServer"
,
GlobalConfig
.
msListFromServer
);
console
.
log
(
" GlobalConfig.mcuList"
,
GlobalConfig
.
mcuList
);
console
.
log
(
" GlobalConfig.msList"
,
GlobalConfig
.
msList
);
loger
.
warn
(
"Server中获取的服务器信息;"
)
loger
.
warn
(
" GlobalConfig.mcuListFromServer"
,
GlobalConfig
.
mcuListFromServer
);
loger
.
warn
(
" GlobalConfig.msListFromServer"
,
GlobalConfig
.
msListFromServer
);
loger
.
warn
(
" GlobalConfig.rtmpPullListFromServer"
,
GlobalConfig
.
rtmpPullListFromServer
);
loger
.
warn
(
" GlobalConfig.hlsPullListFromServer"
,
GlobalConfig
.
hlsPullListFromServer
);
loger
.
warn
(
" GlobalConfig.rsPullListFromServer"
,
GlobalConfig
.
rsPullListFromServer
);
//********合并所有MCU、MS 列表********
//****server.json中的数据和从Sass获取的msList mcuList 数据需要分开,不能同时共存****
/*GlobalConfig.mcuListAll.length = 0;
GlobalConfig.mcuListAll = GlobalConfig.mcuListAll.concat(GlobalConfig.mcuList, GlobalConfig.mcuListFromServer);
GlobalConfig.msListAll.length = 0;
GlobalConfig.msListAll = GlobalConfig.msListAll.concat(GlobalConfig.msList, GlobalConfig.msListFromServer);*/
GlobalConfig
.
mcuListAll
.
length
=
0
;
//********选择最终使用的MCU、MS 和拉流列表********
//****优先使用server.json中的数据,如果没有再使用Sass中的数据****
//MCU
GlobalConfig
.
mcuListFinal
=
[];
if
(
GlobalConfig
.
mcuListFromServer
.
length
>
0
)
{
//使用server中的MCU数据
loger
.
warn
(
"使用server中的MCU数据"
)
GlobalConfig
.
mcuListAll
=
GlobalConfig
.
mcuListFromServer
;
GlobalConfig
.
mcuListFinal
=
GlobalConfig
.
mcuListFromServer
;
}
else
{
//使用Sass中的数据
loger
.
warn
(
"使用Sass中的MCU数据"
)
GlobalConfig
.
mcuListAll
=
GlobalConfig
.
mcuList
;
GlobalConfig
.
mcuListFinal
=
GlobalConfig
.
mcuList
;
}
GlobalConfig
.
msListAll
.
length
=
0
;
//MS推流
GlobalConfig
.
msListFinal
=
[]
if
(
GlobalConfig
.
msListFromServer
.
length
>
0
)
{
loger
.
warn
(
"使用server中的MS数据"
)
GlobalConfig
.
msListAll
=
GlobalConfig
.
msListFromServer
;
GlobalConfig
.
msListFinal
=
GlobalConfig
.
msListFromServer
;
}
else
{
GlobalConfig
.
msListFinal
=
GlobalConfig
.
msList
;
}
//RS录制回放HLS拉流
GlobalConfig
.
rsListFinal
=
[]
if
(
GlobalConfig
.
msListFromServer
.
length
>
0
)
{
GlobalConfig
.
rsListFinal
=
GlobalConfig
.
rsPullListFromServer
;
}
else
{
GlobalConfig
.
rsListFinal
=
GlobalConfig
.
rsList
;
}
//RTMP拉流
GlobalConfig
.
rtmpPullListFinal
=
[];
if
(
GlobalConfig
.
rtmpPullListFromServer
.
length
>
0
)
{
GlobalConfig
.
rtmpPullListFinal
=
GlobalConfig
.
rtmpPullListFromServer
;
}
else
{
GlobalConfig
.
rtmpPullListFinal
=
GlobalConfig
.
rtmpPullList
;
}
//HLS拉流流
GlobalConfig
.
hlsListFinal
=
[];
if
(
GlobalConfig
.
hlsPullListFromServer
.
length
>
0
)
{
GlobalConfig
.
hlsListFinal
=
GlobalConfig
.
hlsPullListFromServer
;
}
else
{
loger
.
warn
(
"使用Sass中的MS数据"
)
GlobalConfig
.
msListAll
=
GlobalConfig
.
msList
;
GlobalConfig
.
hlsListFinal
=
GlobalConfig
.
hlsPullList
;
}
console
.
warn
(
"mcuListAll"
,
GlobalConfig
.
mcuListAll
);
console
.
warn
(
"msListAll"
,
GlobalConfig
.
msListAll
);
//拉流地址列表的特殊处理,
// 1.如果RTMP拉流地址没有配置,就默认使用MS推流地址列表
if
(
!
GlobalConfig
.
rtmpPullListFinal
||
GlobalConfig
.
rtmpPullListFinal
.
length
<
1
)
{
GlobalConfig
.
rtmpPullListFinal
=
GlobalConfig
.
msListFinal
;
}
// 2.如果HLS拉流地址没有配置,就默认使用录制回放RS拉流地址列表中的数据
if
(
!
GlobalConfig
.
hlsListFinal
||
GlobalConfig
.
hlsListFinal
.
length
<
1
)
{
GlobalConfig
.
hlsListFinal
=
GlobalConfig
.
rsListFinal
;
;
}
loger
.
warn
(
"课堂最终使用的服务列表->"
);
loger
.
warn
(
" GlobalConfig.mcuListFinal"
,
GlobalConfig
.
mcuListFinal
);
loger
.
warn
(
" GlobalConfig.msListFinal"
,
GlobalConfig
.
msListFinal
);
loger
.
warn
(
" GlobalConfig.rtmpPullListFinal"
,
GlobalConfig
.
rtmpPullListFinal
);
loger
.
warn
(
" GlobalConfig.hlsListFinal"
,
GlobalConfig
.
hlsListFinal
);
loger
.
warn
(
" GlobalConfig.rsListFinal"
,
GlobalConfig
.
rsListFinal
);
}
//开始测速
_getFastestIpFromServer
(
_dataArr
,
_callback
)
{
if
(
_ipManager
)
{
_ipManager
.
testFastestIpFromServer
(
_dataArr
,
_callback
);
}
else
{
if
(
_callback
)
{
_callback
({
'ip'
:
""
});
}
}
}
//开始MCU选点操作
_getFastestMcuServer
(
_callback
)
{
if
(
_ipManager
)
{
_ipManager
.
getFastestMcuServer
(
GlobalConfig
.
mcuList
Al
l
,
_callback
);
_ipManager
.
getFastestMcuServer
(
GlobalConfig
.
mcuList
Fina
l
,
_callback
);
}
else
{
if
(
_callback
)
{
_callback
({
'ip'
:
""
});
_callback
({
'ip'
:
""
});
}
}
}
//
//
开始MS选点操作
//开始MS选点操作
_getFastestMsServer
(
_callback
)
{
if
(
_ipManager
)
{
_ipManager
.
getFastestMsServer
(
GlobalConfig
.
msListAll
,
_callback
);
_ipManager
.
getFastestMsServer
(
GlobalConfig
.
msListFinal
,
_callback
);
}
else
{
if
(
_callback
)
{
_callback
({
ip
:
""
});
}
}
}
//开始MS-PULL选点操作
_getFastestRtmpPullServer
(
_callback
)
{
if
(
_ipManager
)
{
_ipManager
.
getFastestMsServer
(
GlobalConfig
.
rtmpPullListFinal
,
_callback
);
}
else
{
if
(
_callback
)
{
_callback
({
ip
:
""
});
_callback
({
ip
:
""
});
}
}
}
//开始MS-HLS选点操作
_getFastestHlsServer
(
_callback
)
{
if
(
_ipManager
)
{
_ipManager
.
getFastestMsServer
(
GlobalConfig
.
rtmpPullListFinal
,
_callback
);
}
else
{
if
(
_callback
)
{
_callback
({
ip
:
""
});
}
}
}
...
...
@@ -716,7 +904,7 @@ export default class MessageEntrance extends Emiter {
//只有加入课堂之后才能保存数据
if
(
GlobalConfig
.
getCurrentStatus
().
code
==
GlobalConfig
.
statusCode_2
.
code
)
{
//POST 保存数据
_sass
.
saveClassStatusInfo
({
"classStatusInfo"
:
GlobalConfig
.
classStatusInfo
});
//保存课堂状态信息
_sass
.
saveClassStatusInfo
({
"classStatusInfo"
:
GlobalConfig
.
classStatusInfo
});
//保存课堂状态信息
}
else
{
loger
.
error
(
"不能保存课堂数据"
,
GlobalConfig
.
getCurrentStatus
());
}
...
...
@@ -739,12 +927,12 @@ export default class MessageEntrance extends Emiter {
//Sass校验流程结束之后,开始加入MCU
_joinMCU
()
{
loger
.
log
(
'加入课堂->.'
);
loger
.
warn
(
"课堂服务信息->"
);
loger
.
warn
(
"最终使用课堂服务信息->"
);
loger
.
warn
(
'MCU服务器地址->mcu->'
,
GlobalConfig
.
MCUServerIP
,
GlobalConfig
.
MCUServerPort
);
loger
.
warn
(
'推流地址->MS->'
,
GlobalConfig
.
MS_PUBLISH_IP
,
GlobalConfig
.
MS_PUBLISH_PORT
);
loger
.
warn
(
'RTMP播流地址->RTMP->'
,
GlobalConfig
.
MS_PLAY_RTMP_IP
,
GlobalConfig
.
MS_PLAY_RTMP_PORT
);
loger
.
warn
(
'HLS播流地址->HLS->'
,
GlobalConfig
.
MS_PLAY_HLS_IP
,
GlobalConfig
.
MS_PLAY_HLS_PORT
);
loger
.
warn
(
'RTMP拉流地址->RTMP->'
,
GlobalConfig
.
MS_PLAY_RTMP_IP
,
GlobalConfig
.
MS_PLAY_RTMP_PORT
);
loger
.
warn
(
'HLS拉流地址->HLS->'
,
GlobalConfig
.
MS_PLAY_HLS_IP
,
GlobalConfig
.
MS_PLAY_HLS_PORT
);
loger
.
warn
(
'HLS录制回放拉流地址->HLS->'
,
GlobalConfig
.
RS_RECORD_PLAY_IP
,
GlobalConfig
.
RS_RECORD_PLAY_PORT
);
if
(
_mcu
)
{
_mcu
.
joinMCU
(
GlobalConfig
.
getClassInfo
());
...
...
@@ -879,19 +1067,11 @@ export default class MessageEntrance extends Emiter {
//课堂状态发生改变,需要停止当前的所有推流
_stopAllMediaPublishHandler
(
_data
)
{
loger
.
log
(
'课堂状态发生改变,需要停止当前的所有推流'
);
this
.
_emit
(
MessageTypes
.
MEDIA_STOP_PUBLISH
);
/* let allChannels=MediaModule.allMediaChannelsList;
let channl=null;
for(let i in allChannels){
channl=allChannels[i];
if(channl&&channl.status==ApeConsts.CHANNEL_STATUS_OPENING&&channl.fromNodeId==GlobalConfig.nodeId){
this._emit(MessageTypes.MEDIA_STOP_PUBLISH);
return;
}
}*/
}
//手动切换MS -> {ip;"xxx.xx.xx","port":"xxxx"}
loger
.
log
(
'课堂状态发生改变,需要停止当前的所有推流'
);
this
.
_emit
(
MessageTypes
.
MEDIA_STOP_PUBLISH
);
}
//手动切换MS -> {ip;"xxx.xx.xx","port":"xxxx"}
_switchMediaServer
(
_param
)
{
if
(
GlobalConfig
.
isRecordPlayBack
)
{
//录制回放不做操作
...
...
@@ -916,32 +1096,26 @@ export default class MessageEntrance extends Emiter {
loger
.
warn
(
'录制回放->不进行MS动态选点'
);
return
;
}
loger
.
log
(
'MS->动态选点'
);
let
_this
=
this
;
this
.
_getFastestMsServer
(
function
(
_data
)
{
loger
.
log
(
"MS选点结束->"
,
_data
);
//记录当前的IP地址,选点结束后需要判断一下是否是新的IP;
let
oldIp
=
GlobalConfig
.
M
CUServer
IP
;
let
oldIp
=
GlobalConfig
.
M
S_PUBLISH_
IP
;
if
(
_data
&&
_data
.
ip
)
{
GlobalConfig
.
MS_PUBLISH_IP
=
_data
.
ip
||
""
;
GlobalConfig
.
MS_PUBLISH_PORT
=
_data
.
port
||
""
;
}
else
{
//随机选择一个
if
(
GlobalConfig
.
msList
&&
GlobalConfig
.
msList
.
length
>
0
)
{
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
msList
.
length
);
GlobalConfig
.
MS_PUBLISH_IP
=
GlobalConfig
.
msList
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PUBLISH_PORT
=
GlobalConfig
.
msList
[
index
].
port
||
""
;
if
(
GlobalConfig
.
msListFinal
&&
GlobalConfig
.
msListFinal
.
length
>
0
)
{
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
msListFinal
.
length
);
GlobalConfig
.
MS_PUBLISH_IP
=
GlobalConfig
.
msListFinal
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PUBLISH_PORT
=
GlobalConfig
.
msListFinal
[
index
].
port
||
""
;
}
}
if
(
oldIp
&&
oldIp
!=
GlobalConfig
.
MS_PUBLISH_IP
)
{
/* loger.log('MS->切换地址->', GlobalConfig.MSServerIP, GlobalConfig.MSServerPort);
//判断是否需要断开当前的连接重连新的服务器
if (_param && _param.reConnect == true) {
loger.log('MS->最新地址->', GlobalConfig.MSServerIP, GlobalConfig.MSServerPort);
}*/
//选点完成需要更新用户数据
if
(
_confer_ape
)
{
_confer_ape
.
updateUserInfo
();
...
...
@@ -951,7 +1125,70 @@ export default class MessageEntrance extends Emiter {
//如果选点结束后获得的ip和当前的IP相同,不需要切换
loger
.
log
(
'MS不需要切换->IP'
,
GlobalConfig
.
MS_PUBLISH_IP
);
}
});
}
//切换MS -PULL地址
_switchRtmpPullIpHandler
(
_param
)
{
if
(
GlobalConfig
.
isRecordPlayBack
)
{
//录制回放不做操作
loger
.
warn
(
'录制回放->不进行MS-PULL动态选点'
);
return
;
}
if
(
!
GlobalConfig
.
rtmpPullListFinal
||
GlobalConfig
.
rtmpPullListFinal
.
length
<
1
){
return
;
}
let
_this
=
this
;
this
.
_getFastestRtmpPullServer
(
function
(
_data
)
{
loger
.
log
(
"MS->PULL->选点结束->"
,
_data
);
if
(
_data
&&
_data
.
ip
)
{
GlobalConfig
.
MS_PLAY_RTMP_IP
=
_data
.
ip
||
""
;
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
_data
.
port
||
""
;
}
else
{
//随机选择一个
if
(
GlobalConfig
.
rtmpPullListFinal
&&
GlobalConfig
.
rtmpPullListFinal
.
length
>
0
)
{
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
rtmpPullListFinal
.
length
);
GlobalConfig
.
MS_PLAY_RTMP_IP
=
GlobalConfig
.
rtmpPullListFinal
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
GlobalConfig
.
rtmpPullListFinal
[
index
].
port
||
""
;
}
}
//如果RTMP没有配置地址,那么还是使用推流的地址
if
(
!
GlobalConfig
.
MS_PLAY_RTMP_IP
){
GlobalConfig
.
MS_PLAY_RTMP_IP
=
GlobalConfig
.
MS_PUBLISH_IP
;
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
GlobalConfig
.
MS_PUBLISH_PORT
;
}
});
}
//切换MS HLS地址
_switchHlsIpHandler
(
_param
)
{
if
(
GlobalConfig
.
isRecordPlayBack
)
{
//录制回放不做操作
loger
.
warn
(
'录制回放->不进行MS-HLS动态选点'
);
return
;
}
if
(
!
GlobalConfig
.
hlsListFinal
||
GlobalConfig
.
hlsListFinal
.
length
<
1
){
return
;
}
let
_this
=
this
;
this
.
_getFastestHlsServer
(
function
(
_data
)
{
loger
.
log
(
"HLS选点结束->"
,
_data
);
if
(
_data
&&
_data
.
ip
)
{
GlobalConfig
.
MS_PLAY_HLS_IP
=
_data
.
ip
||
""
;
GlobalConfig
.
MS_PLAY_HLS_PORT
=
_data
.
port
||
""
;
}
else
{
//随机选择一个
if
(
GlobalConfig
.
hlsListFinal
&&
GlobalConfig
.
hlsListFinal
.
length
>
0
)
{
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
hlsListFinal
.
length
);
GlobalConfig
.
MS_PLAY_HLS_IP
=
GlobalConfig
.
hlsListFinal
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PLAY_HLS_PORT
=
GlobalConfig
.
hlsListFinal
[
index
].
port
||
""
;
}
}
//如果HLS没有配置地址,那么还是使用推流的地址
if
(
!
GlobalConfig
.
MS_PLAY_HLS_IP
){
GlobalConfig
.
MS_PLAY_HLS_IP
=
GlobalConfig
.
RS_RECORD_PLAY_IP
;
GlobalConfig
.
MS_PLAY_HLS_PORT
=
GlobalConfig
.
RS_RECORD_PLAY_PORT
;
}
});
}
...
...
@@ -1035,32 +1272,34 @@ export default class MessageEntrance extends Emiter {
//暂停上课
_sendPauseClass
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_confer_ape
)
{
_confer_ape
.
pauseClass
(
_param
);
}
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
//更新设备信息
if
(
_confer_ape
)
{
_confer_ape
.
pauseClass
(
_param
);
}
}
//更新设备信息
_updateDeviceInfo
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
'更新设备信息->失败'
,
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
!
GlobalConfig
.
classJoinSuccess
)
{
loger
.
warn
(
'更新设备信息->失败->还没有加入课堂成功'
,
GlobalConfig
.
getCurrentStatus
());
}
if
(
_confer_ape
)
{
_confer_ape
.
updateDeviceInfo
(
_param
);
}
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
'更新设备信息->失败'
,
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
!
GlobalConfig
.
classJoinSuccess
)
{
loger
.
warn
(
'更新设备信息->失败->还没有加入课堂成功'
,
GlobalConfig
.
getCurrentStatus
());
}
if
(
_confer_ape
)
{
_confer_ape
.
updateDeviceInfo
(
_param
);
}
//文档-媒体共享-屏幕共享模块切换
}
//文档-媒体共享-屏幕共享模块切换
_sceneTableChange
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_confer_ape
)
{
_confer_ape
.
sceneTableChange
(
_param
);
...
...
@@ -1068,10 +1307,10 @@ export default class MessageEntrance extends Emiter {
}
//通过第三方消息通道发送消息
_sendThridChannelMessage
(
_param
){
_sendThridChannelMessage
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_confer_ape
)
{
_confer_ape
.
onThirdReciveParentMessage
(
_param
);
...
...
@@ -1079,10 +1318,10 @@ export default class MessageEntrance extends Emiter {
}
//将指定nodeId的人踢出课堂
_kickOutRosterFormNodeId
(
_param
){
_kickOutRosterFormNodeId
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_confer_ape
)
{
_confer_ape
.
kickOutRosterFormNodeId
(
_param
);
...
...
@@ -1093,7 +1332,7 @@ export default class MessageEntrance extends Emiter {
_controlSilenceStatus
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_confer_ape
)
{
_confer_ape
.
controlSilenceStatus
(
_param
);
...
...
@@ -1104,7 +1343,7 @@ export default class MessageEntrance extends Emiter {
_controlHandUpStatus
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_confer_ape
)
{
_confer_ape
.
controlHandUpStatus
(
_param
);
...
...
@@ -1113,19 +1352,20 @@ export default class MessageEntrance extends Emiter {
//举手状态切换
_changeHandUpStatus
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_confer_ape
)
{
_confer_ape
.
changeHandUpStatus
(
_param
);
}
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_confer_ape
)
{
_confer_ape
.
changeHandUpStatus
(
_param
);
}
//停止上课
}
//停止上课
_sendCloseClass
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_confer_ape
)
{
_confer_ape
.
closeClass
(
_param
);
...
...
@@ -1136,7 +1376,7 @@ export default class MessageEntrance extends Emiter {
_leaveClass
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
//停止推流
...
...
@@ -1169,7 +1409,7 @@ export default class MessageEntrance extends Emiter {
}
}
//获取课堂所有参数 api/meeting/detail.do? flash中的接口文件是 getClassParam.do
//获取课堂所有参数
(20170727新规则)
api/meeting/detail.do? flash中的接口文件是 getClassParam.do
_sassGetClassParamSuccessHandler
(
_data
)
{
loger
.
log
(
'获取课堂课堂信息完成.'
);
//包含整个课堂最全的信息,储存数据
...
...
@@ -1202,124 +1442,36 @@ export default class MessageEntrance extends Emiter {
GlobalConfig
.
setDocListPrepare
(
_data
.
docListPrepare
);
//提前上传的文档列表
GlobalConfig
.
setRecordList
(
_data
.
recordList
);
//录制回放地址
GlobalConfig
.
setDocList
(
_data
.
docList
);
//文档地址
GlobalConfig
.
setMsList
(
_data
.
msList
);
//推流播流服务器地址(需要对列表中的地址进行分类,里面包含了推流和拉流的地址,目前主要是乐视的需要区分开)
GlobalConfig
.
setRsList
(
_data
.
rsList
);
//播放m3u8格式的地址(录制回放时使用)
GlobalConfig
.
setMcuList
(
_data
.
mcuList
);
//mcu
GlobalConfig
.
setMusicList
(
_data
.
musicList
);
//
GlobalConfig
.
setMusicListPrepare
(
_data
.
musicListPrepare
);
//提前上传的声音文件列表
GlobalConfig
.
setVideoCDNAddr
(
_data
.
videoCDNAddr
);
//cdn加速的拉流地址,直播的时候才使用
GlobalConfig
.
setMediaShareList
(
_data
.
sharedMediaList
);
//提前上传的媒体共享文件列表
//MCU地址
if
(
_data
.
mcuList
&&
_data
.
mcuList
.
length
>
0
)
{
//随机选择一个
let
index
=
parseInt
(
Math
.
random
()
*
_data
.
mcuList
.
length
);
GlobalConfig
.
MCUServerIP
=
_data
.
mcuList
[
index
].
ip
||
""
;
GlobalConfig
.
MCUServerPort
=
_data
.
mcuList
[
index
].
port
||
""
;
loger
.
log
(
'初始->MCU->.'
,
GlobalConfig
.
MCUServerIP
,
GlobalConfig
.
MCUServerPort
);
}
//录制回放时m3u8播流地址
if
(
_data
.
rsList
&&
_data
.
rsList
.
length
>
0
)
{
let
index
=
parseInt
(
Math
.
random
()
*
_data
.
rsList
.
length
);
GlobalConfig
.
RS_RECORD_PLAY_IP
=
_data
.
rsList
[
index
].
ip
||
""
;
GlobalConfig
.
RS_RECORD_PLAY_PORT
=
_data
.
rsList
[
index
].
port
||
""
;
loger
.
log
(
'初始->RS->.'
,
GlobalConfig
.
RS_RECORD_PLAY_IP
,
GlobalConfig
.
RS_RECORD_PLAY_PORT
);
}
//上课中音视频推流地址
if
(
GlobalConfig
.
msList
&&
GlobalConfig
.
msList
.
length
>
0
)
{
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
msList
.
length
);
GlobalConfig
.
MS_PUBLISH_IP
=
GlobalConfig
.
msList
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PUBLISH_PORT
=
GlobalConfig
.
msList
[
index
].
port
||
""
;
}
loger
.
log
(
'初始->MS->.'
,
GlobalConfig
.
MS_PUBLISH_IP
,
GlobalConfig
.
MS_PUBLISH_PORT
);
//播流的地址和推流地址需要分开的时候,单独设置拉流的地址 rtmp(目前乐视使用)
if
(
GlobalConfig
.
pullRtmpList
&&
GlobalConfig
.
pullRtmpList
.
length
>
0
)
{
//有单独的rtmp拉流地址
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
pullRtmpList
.
length
);
GlobalConfig
.
MS_PLAY_RTMP_IP
=
GlobalConfig
.
pullRtmpList
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
GlobalConfig
.
pullRtmpList
[
index
].
port
||
""
;
}
else
{
//如果没有单独的rtmp拉流地址,和推流地址一样即可
GlobalConfig
.
MS_PLAY_RTMP_IP
=
GlobalConfig
.
MS_PUBLISH_IP
;
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
GlobalConfig
.
MS_PUBLISH_PORT
;
}
loger
.
log
(
'初始->MSPull->.'
,
GlobalConfig
.
MS_PLAY_RTMP_IP
,
GlobalConfig
.
MS_PLAY_RTMP_PORT
);
//播流的地址和推流地址需要分开的时候,单独设置拉流的地址 hls(目前乐视使用)
if
(
GlobalConfig
.
hlsList
&&
GlobalConfig
.
hlsList
.
length
>
0
)
{
//有单独的hls拉流地址
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
hlsList
.
length
);
GlobalConfig
.
MS_PLAY_HLS_IP
=
GlobalConfig
.
hlsList
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PLAY_HLS_PORT
=
GlobalConfig
.
hlsList
[
index
].
port
||
""
;
}
else
{
//没有单独的hls拉流地址,和录制回放地址一样即可
GlobalConfig
.
MS_PLAY_HLS_IP
=
GlobalConfig
.
RS_RECORD_PLAY_IP
;
GlobalConfig
.
MS_PLAY_HLS_PORT
=
GlobalConfig
.
RS_RECORD_PLAY_PORT
;
}
loger
.
log
(
'初始->MSHls->.'
,
GlobalConfig
.
MS_PLAY_HLS_IP
,
GlobalConfig
.
MS_PLAY_HLS_PORT
);
//直播的时候,拉流(rtmp和hls)需要从 videoCDNAddr中获取
//20170531-新规则,所有课堂类型都支持加速
// if(GlobalConfig.classType==ApeConsts.CLASS_TYPE_2&&GlobalConfig.videoCDNAddrList.length>0){
//20170629-直播课堂和移动端设备的时候支持
if
(
GlobalConfig
.
classType
==
ApeConsts
.
CLASS_TYPE_2
||
GlobalConfig
.
isMobile
)
{
if
(
GlobalConfig
.
videoCDNAddrList
.
length
>
0
)
{
//videoCDNAddrList中rtmppush和hls是混在一起的,需要分离开;
let
listLen
=
GlobalConfig
.
videoCDNAddrList
.
length
;
for
(
let
i
=
0
;
i
<
listLen
;
i
++
)
{
let
ipItem
=
GlobalConfig
.
videoCDNAddrList
[
i
];
if
(
ipItem
)
{
if
(
ipItem
.
indexOf
(
'hls'
)
>=
0
)
{
//直播的时候m3u8拉流地址
GlobalConfig
.
MS_PLAY_HLS_IP
=
ipItem
;
//ip包含了端口
GlobalConfig
.
MS_PLAY_HLS_PORT
=
""
;
loger
.
log
(
'videoCDNAddr>初始->MSHls'
,
GlobalConfig
.
MS_PLAY_HLS_IP
);
}
if
(
ipItem
.
indexOf
(
'rtmppull'
)
>=
0
)
{
//直播的时候rtmp拉流地址
GlobalConfig
.
MS_PLAY_RTMP_IP
=
ipItem
;
//ip包含了端口
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
''
;
loger
.
log
(
'videoCDNAddr->初始->MSPull'
,
GlobalConfig
.
MS_PLAY_RTMP_IP
);
}
}
}
}
else
{
loger
.
error
(
'videoCDNAddr数据无效->'
,
GlobalConfig
.
videoCDNAddr
);
}
}
else
{
loger
.
warn
(
'非直播课堂或不是移动端->不需要videoCDN加速'
);
//存从Sass获取的MS和MCU服务列表
if
(
_data
.
msList2
)
{
GlobalConfig
.
setMsList
(
_data
.
msList2
.
msList
);
//储存Sass ms拉流地址
GlobalConfig
.
setRtmpPullList
(
_data
.
msList2
.
rtmpPullArray
);
//储存Sass ms拉流地址
GlobalConfig
.
setHlsPullList
(
_data
.
msList2
.
hlsPullArray
);
//储存Sass ms拉流地址
GlobalConfig
.
setRsList
(
_data
.
msList2
.
rsList
);
//储存Sass 录制回放hls拉流地址
}
//Sass mcu
GlobalConfig
.
setMcuList
(
_data
.
mcuList
);
//mcu
//文档地址
if
(
_data
.
docList
&&
_data
.
docList
.
length
>
0
)
{
//doc上传地址,随机获取一个
let
index
=
parseInt
(
Math
.
random
()
*
_data
.
docList
.
length
);
loger
.
log
(
"docServer->"
,
_data
.
docList
[
index
]);
GlobalConfig
.
DOCServerIP
=
_data
.
docList
[
index
].
ip
||
""
;
GlobalConfig
.
DOCServerPort
=
_data
.
docList
[
index
].
port
||
""
;
loger
.
log
(
'初始->DOC->.'
,
GlobalConfig
.
DOCServerIP
,
GlobalConfig
.
DOCServerPort
);
}
//record
if
(
_data
.
recordList
&&
_data
.
recordList
.
length
>
0
)
{
let
index
=
parseInt
(
Math
.
random
()
*
_data
.
recordList
.
length
);
GlobalConfig
.
RecordServerIP
=
_data
.
recordList
[
index
].
ip
||
""
;
GlobalConfig
.
RecordServerPort
=
_data
.
recordList
[
index
].
port
||
""
;
loger
.
log
(
'初始->RECORD->.'
,
GlobalConfig
.
RecordServerIP
,
GlobalConfig
.
RecordServerPort
);
}
loger
.
warn
(
'从Sass获取的推流拉流列表数据:'
);
loger
.
warn
(
'Sass->msList->'
,
GlobalConfig
.
msList
);
loger
.
warn
(
'Sass->rtmpPullList->'
,
GlobalConfig
.
rtmpPullList
);
loger
.
warn
(
'Sass->hlsPullList->'
,
GlobalConfig
.
hlsPullList
);
loger
.
warn
(
'Sass->rsList->'
,
GlobalConfig
.
rsList
);
//获取MCU和MS 推流拉流、录制回放的默认地址,后面还会进行测速选择
this
.
getMcuAndMsDefaultServerIp
();
}
//这里需要考虑是否加延迟处理,课堂信息刚获取完成,客户端需要根据数据创建界面UI,等创建完成后再加入课堂是最合适的(目前没有加延迟)
//课堂获取Sass数据完成
this
.
_emit
(
MessageTypes
.
CLASS_GET_INFO_SUCCESS
,
GlobalConfig
.
getClassInfo
());
if
(
_data
.
currentInfo
)
{
//根据从Sass获取的数据信息,同步最后一次保存的课堂状态信息
loger
.
log
(
"本地同步最后一次保存过的课堂状态信息"
);
try
{
GlobalConfig
.
setClassStatusInfo
(
JSON
.
parse
(
_data
.
currentInfo
));
}
catch
(
err
)
{
...
...
@@ -1332,31 +1484,287 @@ export default class MessageEntrance extends Emiter {
loger
.
log
(
"还没有保存过课堂状信息"
);
}
//课堂数据获取完成->进入课堂或进入录制回放
//录制回放不需要获取ip信息和选点
if
(
GlobalConfig
.
isRecordPlayBack
)
{
if
(
_recordPlayback
)
{
//开启录制回放流程
loger
.
log
(
"开启录制回放流程"
);
loger
.
warn
(
"开启录制回放流程"
);
_recordPlayback
.
readyRecordPlay
();
}
else
{
loger
.
warn
(
"开启录制回放流程失败->还未创建模块"
);
}
}
else
{
//根据用户的userIp获取信息,选点
this
.
getUserIpInfo
();
//根据用户的userIp获取信息,获取服务列表选点,选点测速完成后才加入MCU
this
.
loadServerJsonAndgetUserIpInfo
();
}
}
//获取各个服务的默认ip,之后会进行测速选择更快的ip
getMcuAndMsDefaultServerIp
()
{
//MCU地址
if
(
GlobalConfig
.
mcuList
&&
GlobalConfig
.
mcuList
.
length
>
0
)
{
//还未开始选点之前随机选择一个
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
mcuList
.
length
);
GlobalConfig
.
MCUServerIP
=
GlobalConfig
.
mcuList
[
index
].
ip
||
""
;
GlobalConfig
.
MCUServerPort
=
GlobalConfig
.
mcuList
[
index
].
port
||
""
;
}
//录制回放时m3u8播流地址
if
(
GlobalConfig
.
rsList
&&
GlobalConfig
.
rsList
.
length
>
0
)
{
//还未开始选点之前随机选择一个
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
rsList
.
length
);
GlobalConfig
.
RS_RECORD_PLAY_IP
=
GlobalConfig
.
rsList
[
index
].
ip
||
""
;
GlobalConfig
.
RS_RECORD_PLAY_PORT
=
GlobalConfig
.
rsList
[
index
].
port
||
""
;
}
//推流地址
if
(
GlobalConfig
.
msList
&&
GlobalConfig
.
msList
.
length
>
0
)
{
//还未开始选点之前随机选择一个
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
msList
.
length
);
GlobalConfig
.
MS_PUBLISH_IP
=
GlobalConfig
.
msList
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PUBLISH_PORT
=
GlobalConfig
.
msList
[
index
].
port
||
""
;
}
//RTMP拉流
if
(
GlobalConfig
.
rtmpPullList
&&
GlobalConfig
.
rtmpPullList
.
length
>
0
)
{
// //还未开始选点之前随机选择一个
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
rtmpPullList
.
length
);
GlobalConfig
.
MS_PLAY_RTMP_IP
=
GlobalConfig
.
rtmpPullList
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
GlobalConfig
.
rtmpPullList
[
index
].
port
||
""
;
}
else
{
//如果没有单独的rtmp拉流地址,和推流地址一样即可
GlobalConfig
.
MS_PLAY_RTMP_IP
=
GlobalConfig
.
MS_PUBLISH_IP
;
GlobalConfig
.
MS_PLAY_RTMP_PORT
=
GlobalConfig
.
MS_PUBLISH_PORT
;
}
//课堂中HLS拉流地址
if
(
GlobalConfig
.
hlsPullList
&&
GlobalConfig
.
hlsPullList
.
length
>
0
)
{
//有单独的hls拉流地址
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
hlsPullList
.
length
);
GlobalConfig
.
MS_PLAY_HLS_IP
=
GlobalConfig
.
hlsPullList
[
index
].
ip
||
""
;
GlobalConfig
.
MS_PLAY_HLS_PORT
=
GlobalConfig
.
hlsPullList
[
index
].
port
||
""
;
}
else
{
//没有单独的hls拉流地址,和录制回放地址一样即可
GlobalConfig
.
MS_PLAY_HLS_IP
=
GlobalConfig
.
RS_RECORD_PLAY_IP
;
GlobalConfig
.
MS_PLAY_HLS_PORT
=
GlobalConfig
.
RS_RECORD_PLAY_PORT
;
}
//文档服务器地址
if
(
GlobalConfig
.
docList
&&
GlobalConfig
.
docList
.
length
>
0
)
{
//doc上传地址,随机获取一个
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
docList
.
length
);
GlobalConfig
.
DOCServerIP
=
GlobalConfig
.
docList
[
index
].
ip
||
""
;
GlobalConfig
.
DOCServerPort
=
GlobalConfig
.
docList
[
index
].
port
||
""
;
}
//录制回放文件的下载地址
if
(
GlobalConfig
.
recordList
&&
GlobalConfig
.
recordList
.
length
>
0
)
{
let
index
=
parseInt
(
Math
.
random
()
*
GlobalConfig
.
recordList
.
length
);
GlobalConfig
.
RecordServerIP
=
GlobalConfig
.
recordList
[
index
].
ip
||
""
;
GlobalConfig
.
RecordServerPort
=
GlobalConfig
.
recordList
[
index
].
port
||
""
;
}
loger
.
warn
(
'默认->MCU地址->.'
,
GlobalConfig
.
MCUServerIP
,
GlobalConfig
.
MCUServerPort
);
loger
.
warn
(
'默认->MS推流地址->.'
,
GlobalConfig
.
MS_PUBLISH_IP
,
GlobalConfig
.
MS_PUBLISH_PORT
);
loger
.
warn
(
'默认->HLS点播地址->.'
,
GlobalConfig
.
RS_RECORD_PLAY_IP
,
GlobalConfig
.
RS_RECORD_PLAY_PORT
);
loger
.
warn
(
'默认->HLS拉流地址->.'
,
GlobalConfig
.
MS_PLAY_HLS_IP
,
GlobalConfig
.
MS_PLAY_HLS_PORT
);
loger
.
warn
(
'默认->RTMP拉流地址->.'
,
GlobalConfig
.
MS_PLAY_RTMP_IP
,
GlobalConfig
.
MS_PLAY_RTMP_PORT
);
loger
.
warn
(
'默认->文档服务器地址->.'
,
GlobalConfig
.
DOCServerIP
,
GlobalConfig
.
DOCServerPort
);
loger
.
warn
(
'默认->录制回放文件下载地址->.'
,
GlobalConfig
.
RecordServerIP
,
GlobalConfig
.
RecordServerPort
);
}
//获取课堂所有参数 api/meeting/detail.do? flash中的接口文件是 getClassParam.do(20170727之前的规则)
/*_sassGetClassParamSuccessHandler(_data) {
loger.log('获取课堂课堂信息完成.');
//包含整个课堂最全的信息,储存数据
if (_data) {
GlobalConfig.mcuDelay = _data.h5Delay || 0; //mcu消息延迟的时间间隔,单位(秒),结合客户端传的messageDelay的值使用
GlobalConfig.className = _data.meetingName || "";
GlobalConfig.classBeginTime = _data.beginTime || "";
GlobalConfig.classEndTime = _data.endTime || "";
GlobalConfig.userIp = _data.userIp || "";
GlobalConfig.maxVideoChannels = _data.maxVideoChannels;
GlobalConfig.maxAudioChannels = _data.maxAudioChannels;
GlobalConfig.maxMediaChannels = Math.max(GlobalConfig.maxVideoChannels, GlobalConfig.maxAudioChannels);
GlobalConfig.ssTunnelAppURL = _data.ssTunnelAppURL || ''; //屏幕共享插件的地址
//视频质量相关设置,每次加入课堂都按最新的获取设置
GlobalConfig.fps = _data.fps || 15;
GlobalConfig.gop = _data.gop || 3;
GlobalConfig.videoQuality = parseInt(_data.videoQuality);
GlobalConfig.curVideoQuality = GlobalConfig.videoQuality;
//是否自动开始(身份是host的时候才用到的)
GlobalConfig.isAutoStartClass = _data.autoRecord || 0;
GlobalConfig.serverTime = _data.serverTime || new Date().getTime(); //获取服务器时间戳
GlobalConfig.serverAndLoacTimeDistanc = (new Date().getTime() - GlobalConfig.serverTime) / 1000; //当前系统时间和服务器时间的差值 (秒)
loger.warn("服务器时间:" + GlobalConfig.serverTime + " 系统时间:" + new Date().getTime() + " 时间差:" + GlobalConfig.serverAndLoacTimeDistanc);
GlobalConfig.setDocListPrepare(_data.docListPrepare); //提前上传的文档列表
GlobalConfig.setRecordList(_data.recordList); //录制回放地址
GlobalConfig.setDocList(_data.docList); //文档地址
GlobalConfig.setMsList(_data.msList); //推流播流服务器地址(需要对列表中的地址进行分类,里面包含了推流和拉流的地址,目前主要是乐视的需要区分开)
GlobalConfig.setRsList(_data.rsList); //播放m3u8格式的地址(录制回放时使用)
GlobalConfig.setMcuList(_data.mcuList); //mcu
GlobalConfig.setMusicList(_data.musicList); //
GlobalConfig.setMusicListPrepare(_data.musicListPrepare); //提前上传的声音文件列表
GlobalConfig.setVideoCDNAddr(_data.videoCDNAddr); //cdn加速的拉流地址,直播的时候才使用
GlobalConfig.setMediaShareList(_data.sharedMediaList); //提前上传的媒体共享文件列表
//MCU地址
if (_data.mcuList && _data.mcuList.length > 0) {
//随机选择一个
let index = parseInt(Math.random() * _data.mcuList.length);
GlobalConfig.MCUServerIP = _data.mcuList[index].ip || "";
GlobalConfig.MCUServerPort = _data.mcuList[index].port || "";
loger.log('初始->MCU->.', GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort);
}
//录制回放时m3u8播流地址
if (_data.rsList && _data.rsList.length > 0) {
let index = parseInt(Math.random() * _data.rsList.length);
GlobalConfig.RS_RECORD_PLAY_IP = _data.rsList[index].ip || "";
GlobalConfig.RS_RECORD_PLAY_PORT = _data.rsList[index].port || "";
loger.log('初始->RS->.', GlobalConfig.RS_RECORD_PLAY_IP, GlobalConfig.RS_RECORD_PLAY_PORT);
}
//上课中音视频推流地址
if (GlobalConfig.msList && GlobalConfig.msList.length > 0) {
let index = parseInt(Math.random() * GlobalConfig.msList.length);
GlobalConfig.MS_PUBLISH_IP = GlobalConfig.msList[index].ip || "";
GlobalConfig.MS_PUBLISH_PORT = GlobalConfig.msList[index].port || "";
}
loger.log('初始->MS->.', GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT);
//播流的地址和推流地址需要分开的时候,单独设置拉流的地址 rtmp(目前乐视使用)
if (GlobalConfig.rtmpPullList && GlobalConfig.rtmpPullList.length > 0) {
//有单独的rtmp拉流地址
let index = parseInt(Math.random() * GlobalConfig.rtmpPullList.length);
GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.rtmpPullList[index].ip || "";
GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.rtmpPullList[index].port || "";
} else {
//如果没有单独的rtmp拉流地址,和推流地址一样即可
GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.MS_PUBLISH_IP;
GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.MS_PUBLISH_PORT;
}
loger.log('初始->MSPull->.', GlobalConfig.MS_PLAY_RTMP_IP, GlobalConfig.MS_PLAY_RTMP_PORT);
//播流的地址和推流地址需要分开的时候,单独设置拉流的地址 hls(目前乐视使用)
if (GlobalConfig.hlsList && GlobalConfig.hlsList.length > 0) {
//有单独的hls拉流地址
let index = parseInt(Math.random() * GlobalConfig.hlsList.length);
GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.hlsList[index].ip || "";
GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.hlsList[index].port || "";
} else {
//没有单独的hls拉流地址,和录制回放地址一样即可
GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.RS_RECORD_PLAY_IP;
GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.RS_RECORD_PLAY_PORT;
}
loger.log('初始->MSHls->.', GlobalConfig.MS_PLAY_HLS_IP, GlobalConfig.MS_PLAY_HLS_PORT);
//直播的时候,拉流(rtmp和hls)需要从 videoCDNAddr中获取
//20170531-新规则,所有课堂类型都支持加速
// if(GlobalConfig.classType==ApeConsts.CLASS_TYPE_2&&GlobalConfig.videoCDNAddrList.length>0){
//20170629-直播课堂和移动端设备的时候支持
if (GlobalConfig.classType == ApeConsts.CLASS_TYPE_2 || GlobalConfig.isMobile) {
if (GlobalConfig.videoCDNAddrList.length > 0) {
//videoCDNAddrList中rtmppush和hls是混在一起的,需要分离开;
let listLen = GlobalConfig.videoCDNAddrList.length;
for (let i = 0; i < listLen; i++) {
let ipItem = GlobalConfig.videoCDNAddrList[i];
if (ipItem) {
if (ipItem.indexOf('hls') >= 0) {
//直播的时候m3u8拉流地址
GlobalConfig.MS_PLAY_HLS_IP = ipItem; //ip包含了端口
GlobalConfig.MS_PLAY_HLS_PORT = "";
loger.log('videoCDNAddr>初始->MSHls', GlobalConfig.MS_PLAY_HLS_IP);
}
if (ipItem.indexOf('rtmppull')>= 0) {
//直播的时候rtmp拉流地址
GlobalConfig.MS_PLAY_RTMP_IP = ipItem; //ip包含了端口
GlobalConfig.MS_PLAY_RTMP_PORT = '';
loger.log('videoCDNAddr->初始->MSPull', GlobalConfig.MS_PLAY_RTMP_IP);
}
}
}
} else {
loger.error('videoCDNAddr数据无效->', GlobalConfig.videoCDNAddr);
}
} else {
loger.warn('非直播课堂或不是移动端->不需要videoCDN加速');
}
//文档地址
if (_data.docList && _data.docList.length > 0) {
//doc上传地址,随机获取一个
let index = parseInt(Math.random() * _data.docList.length);
loger.log("docServer->", _data.docList[index]);
GlobalConfig.DOCServerIP = _data.docList[index].ip || "";
GlobalConfig.DOCServerPort = _data.docList[index].port || "";
loger.log('初始->DOC->.', GlobalConfig.DOCServerIP, GlobalConfig.DOCServerPort);
}
//record
if (_data.recordList && _data.recordList.length > 0) {
let index = parseInt(Math.random() * _data.recordList.length);
GlobalConfig.RecordServerIP = _data.recordList[index].ip || "";
GlobalConfig.RecordServerPort = _data.recordList[index].port || "";
loger.log('初始->RECORD->.', GlobalConfig.RecordServerIP, GlobalConfig.RecordServerPort);
}
}
//这里需要考虑是否加延迟处理,课堂信息刚获取完成,客户端需要根据数据创建界面UI,等创建完成后再加入课堂是最合适的(目前没有加延迟)
this._emit(MessageTypes.CLASS_GET_INFO_SUCCESS, GlobalConfig.getClassInfo());
if (_data.currentInfo) {
//根据从Sass获取的数据信息,同步最后一次保存的课堂状态信息
loger.log("本地同步最后一次保存过的课堂状态信息");
try {
GlobalConfig.setClassStatusInfo(JSON.parse(_data.currentInfo));
} catch (err) {
loger.warn("从Sass获取的课堂数据JSON转换失败->");
console.log("currentInfo", _data.currentInfo);
GlobalConfig.setClassStatusInfo(_data.currentInfo);
}
loger.log(GlobalConfig.classStatusInfo);
} else {
loger.log("还没有保存过课堂状信息");
}
//录制回放不需要获取ip信息和选点
if (GlobalConfig.isRecordPlayBack) {
if (_recordPlayback) {
//开启录制回放流程
loger.log("开启录制回放流程");
_recordPlayback.readyRecordPlay();
} else {
loger.warn("开启录制回放流程失败->还未创建模块");
}
} else {
//根据用户的userIp获取信息,选点
this.getUserIpInfo();
}
}*/
//ChatApe
// 发送聊天消息
_sendChatMsg
(
_messageInfo
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_messageInfo
===
null
||
EngineUtils
.
isEmptyObject
(
_messageInfo
))
{
loger
.
log
(
'发送聊天消息失败->参数错误'
,
_messageInfo
);
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_chat_ape
)
{
_chat_ape
.
sendChatMsg
(
_messageInfo
);
...
...
@@ -1366,11 +1774,11 @@ export default class MessageEntrance extends Emiter {
//监听摄像头麦克风状态
userDeviecStatusChange
(
_data
)
{
/* nodeId:GlobalConfig.nodeId,
userRole:GlobalConfig.userRole,
userName:GlobalConfig.userName,
userId:GlobalConfig.userId,
openCamera:GlobalConfig.openCamera,
openMicrophones:GlobalConfig.openMicrophones*/
userRole:GlobalConfig.userRole,
userName:GlobalConfig.userName,
userId:GlobalConfig.userId,
openCamera:GlobalConfig.openCamera,
openMicrophones:GlobalConfig.openMicrophones*/
if
(
_confer_ape
)
{
_confer_ape
.
updaterUserDeviecStatusChange
(
_data
);
}
...
...
@@ -1379,17 +1787,19 @@ export default class MessageEntrance extends Emiter {
//屏幕共享
//开始屏幕共享
_publishScreenShare
(
_param
)
{
if
(
_video_ape
)
{
_video_ape
.
publishScreenShare
(
_param
);
}
if
(
_video_ape
)
{
_video_ape
.
publishScreenShare
(
_param
);
}
//停止屏幕共享
}
//停止屏幕共享
_stopPublishScreenShare
(
_param
)
{
if
(
_video_ape
)
{
_video_ape
.
stopPublishScreenShare
(
_param
);
}
if
(
_video_ape
)
{
_video_ape
.
stopPublishScreenShare
(
_param
);
}
//VidoeApe
}
//VidoeApe
videoUpdate
(
_data
)
{
//视频同步的消息发送改变,需要通知ferApe模块中的用户更新状态
if
(
_confer_ape
)
{
...
...
@@ -1400,7 +1810,7 @@ export default class MessageEntrance extends Emiter {
_sendVideoBroadcastMsg
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_video_ape
)
{
return
_video_ape
.
sendVideoBroadcastMsg
(
_param
);
...
...
@@ -1428,7 +1838,7 @@ export default class MessageEntrance extends Emiter {
_publishVideo
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_video_ape
)
{
return
_video_ape
.
publishVideo
(
_param
);
...
...
@@ -1438,7 +1848,7 @@ export default class MessageEntrance extends Emiter {
_stopPublishVideo
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_video_ape
)
{
return
_video_ape
.
stopPublishVideo
(
_param
);
...
...
@@ -1456,7 +1866,7 @@ export default class MessageEntrance extends Emiter {
sendAudioCommandMsg
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_audio_ape
)
{
return
_audio_ape
.
sendAudioBroadcastMsg
(
_param
);
...
...
@@ -1484,7 +1894,7 @@ export default class MessageEntrance extends Emiter {
_publishAudio
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_audio_ape
)
{
return
_audio_ape
.
publishAudio
(
_param
);
...
...
@@ -1494,7 +1904,7 @@ export default class MessageEntrance extends Emiter {
_stopPublishAudio
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
""
};
}
if
(
_audio_ape
)
{
return
_audio_ape
.
stopPublishAudio
(
_param
);
...
...
@@ -1561,7 +1971,7 @@ export default class MessageEntrance extends Emiter {
return
_doc_ape
.
getDocFullAddress
(
_param
);
}
else
{
loger
.
error
(
"文档模块还没有创建无法获取"
);
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
"文档模块还没有创建无法获取"
};
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
"文档模块还没有创建无法获取"
};
}
}
...
...
@@ -1608,25 +2018,27 @@ export default class MessageEntrance extends Emiter {
//操作文档(翻页)
_sendDocumentSwitchPage
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
documentSwitchPage
(
_param
);
}
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
//操作文档(页码上的动画步骤操作)
if
(
_doc_ape
)
{
_doc_ape
.
documentSwitchPage
(
_param
);
}
}
//操作文档(页码上的动画步骤操作)
_sendDocumentSwitchAnimation
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
documentSwitchAnimation
(
_param
);
}
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_doc_ape
)
{
_doc_ape
.
documentSwitchAnimation
(
_param
);
}
//操作文档(缩放、滚动...)
}
//操作文档(缩放、滚动...)
_sendDocumentCommand
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
...
...
@@ -1820,15 +2232,16 @@ export default class MessageEntrance extends Emiter {
//音乐播放
_sendMusicSharedPlay
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_musicShareApe
)
{
_musicShareApe
.
musicSharedPlay
(
_param
);
}
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
//音乐停止
if
(
_musicShareApe
)
{
_musicShareApe
.
musicSharedPlay
(
_param
);
}
}
//音乐停止
_sendMusicSharedStop
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
...
...
@@ -1852,15 +2265,16 @@ export default class MessageEntrance extends Emiter {
//播放
_sendMediaSharedPlay
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_mediaShareApe
)
{
_mediaShareApe
.
mediaSharedPlay
(
_param
);
}
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
return
;
}
if
(
_mediaShareApe
)
{
_mediaShareApe
.
mediaSharedPlay
(
_param
);
}
//停止
}
//停止
_sendMediaSharedStop
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
...
...
@@ -1885,7 +2299,7 @@ export default class MessageEntrance extends Emiter {
"status"
:
0
,
"creatUserId"
:
value
.
creatUserId
,
"creatUserName"
:
value
.
createUserName
,
"url"
:
value
.
url
||
value
.
absoluteLocation
,
//伴音上传的接口有差异,课堂内上传返回的是url字段,后台带入的字段是absoluteLocation
"url"
:
value
.
url
||
value
.
absoluteLocation
,
//伴音上传的接口有差异,课堂内上传返回的是url字段,后台带入的字段是absoluteLocation
"fileType"
:
value
.
type
,
"fileId"
:
""
+
value
.
id
,
"fileName"
:
value
.
name
,
...
...
@@ -2078,6 +2492,7 @@ export default class MessageEntrance extends Emiter {
_questionApe
.
creatQuestion
(
_param
);
}
}
_getQuestion
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
...
...
@@ -2087,6 +2502,7 @@ export default class MessageEntrance extends Emiter {
_questionApe
.
getQuestion
(
_param
);
}
}
_getQuestionResult
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
...
...
@@ -2096,6 +2512,7 @@ export default class MessageEntrance extends Emiter {
_questionApe
.
getQuestionResult
(
_param
);
}
}
_stopQuestion
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
...
...
@@ -2105,6 +2522,7 @@ export default class MessageEntrance extends Emiter {
_questionApe
.
stopQuestion
(
_param
);
}
}
_sendAnswer
(
_param
)
{
if
(
!
_mcu
.
connected
)
{
loger
.
warn
(
GlobalConfig
.
getCurrentStatus
());
...
...
src/GlobalConfig.js
查看文件 @
bd69d56
...
...
@@ -237,19 +237,20 @@ class GlobalConfig {
//ms列表
static
setMsList
(
_data
)
{
if
(
_data
==
null
)
return
;
this
.
msList
=
_data
;
//MSlist列表中的地址需要进行筛选,目前有的站点播流和推流需要分开
if
(
GlobalConfig
.
siteId
==
GlobalConfig
.
siteId_letv
)
{
/*
if (GlobalConfig.siteId == GlobalConfig.siteId_letv) {
this.msList = [];
this
.
pullRtmpList
=
[];
this
.
hlsList
=
[];
this.rtmpPullListFinal = [];
this.hlsListFinal = [];
let len = _data.length;
for (let i = 0; i < len; i++) {
let item = _data[i];
if (item && item.ip) {
if (item.ip.indexOf('pull.') >= 0) {
this
.
pullRtmpList
.
push
(
item
);
this.
rtmpPullListFinal
.push(item);
} else if (item.ip.indexOf('lehls.') >= 0) {
this
.
hlsList
.
push
(
item
);
this.hlsList
Final
.push(item);
} else {
this.msList.push(item);
}
...
...
@@ -257,16 +258,43 @@ class GlobalConfig {
}
loger.log("msListAll->", _data);
loger.log("msList->", this.msList);
loger
.
log
(
"pullList->"
,
this
.
pullRtmpList
);
loger
.
log
(
"hlsList->"
,
this
.
hlsList
);
loger.log("pullList->", this.rtmpPullListFinal);
loger.log("hlsList->", this.hlsListFinal);
} else {
this.msList = _data;
}
}
*/
}
static
getMsList
()
{
return
this
.
msList
;
}
//rtmpPullList列表
static
setRtmpPullList
(
_data
)
{
if
(
_data
==
null
)
return
;
this
.
rtmpPullList
=
_data
;
}
static
getRtmpPullList
()
{
return
this
.
rtmpPullList
;
}
//hlsPullList列表
static
setHlsPullList
(
_data
)
{
if
(
_data
==
null
)
return
;
this
.
hlsPullList
=
_data
;
}
static
getHlsPullList
()
{
return
this
.
hlsPullList
;
}
//rs列表
static
setRsList
(
_data
)
{
if
(
_data
==
null
)
return
;
this
.
rsList
=
_data
;
}
static
getRsList
()
{
return
this
.
rsList
;
}
//mcu列表
static
setMcuList
(
_data
)
{
if
(
_data
==
null
)
return
;
...
...
@@ -293,14 +321,7 @@ class GlobalConfig {
return
this
.
musicListPrepare
;
}
//rs列表
static
setRsList
(
_data
)
{
if
(
_data
==
null
)
return
;
this
.
rsList
=
_data
;
}
static
getRsList
()
{
return
this
.
rsList
;
}
//CDN加速的 拉流地址 rtmp 和hls(m3u8)
static
setVideoCDNAddr
(
_data
)
{
...
...
@@ -331,8 +352,45 @@ GlobalConfig.mcuDelay = 0; //默认的延迟时间(单位-秒)
GlobalConfig
.
docDelay
=
1600
;
//文档模块加入成功之后延迟发送送成功的消息给主模块(sdk内部使用)
GlobalConfig
.
portal
=
"112.126.80.182:80"
;
//Sass IP
//GlobalConfig.ip="112.126.80.182";
//GlobalConfig.port="80";
//从Sass获取的
GlobalConfig
.
country
=
""
;
//国家
GlobalConfig
.
city
=
""
;
//城市
GlobalConfig
.
province
=
""
;
//服务商
GlobalConfig
.
isp
=
""
;
//服务商
GlobalConfig
.
sharedMediaList
=
[];
// 已经提前上传的媒体文件列表,进入课堂后需要自动加载
GlobalConfig
.
sharedMusicList
=
[];
// 已经提前上传的音乐文件列表,进入课堂后需要自动加载
GlobalConfig
.
docListPrepare
=
[];
// 已经提前上传的文档,进入课堂后需要自动加载
GlobalConfig
.
recordList
=
[];
//录制服务器地址集合
GlobalConfig
.
docList
=
[];
//文档服务器地址集合
GlobalConfig
.
musicList
=
[];
//music服务器地址集合
GlobalConfig
.
musicListPrepare
=
[];
//提提前上传的music集合
GlobalConfig
.
videoCDNAddr
=
''
;
GlobalConfig
.
videoCDNAddrList
=
[];
//从videoCDNAddr转换来的,videoCDNAddr字符串用分号隔开了多个ip
//从Sass获取的数据
GlobalConfig
.
mcuList
=
[];
//录制服务器地址集合
GlobalConfig
.
msList
=
[];
//从Sass获取的ms推流地址集合,也可以拉流
GlobalConfig
.
rtmpPullList
=
[];
//从Sass获取的rtmp拉流地址集合
GlobalConfig
.
hlsPullList
=
[];
//从sasss获取的hls拉流服务器地址集合
GlobalConfig
.
rsList
=
[];
//录制回放中视频hls点播地址
//根据userIP从server获取的数据
GlobalConfig
.
mcuListFromServer
=
[];
//根据userIP从server获取的mcu列表
GlobalConfig
.
msListFromServer
=
[];
//根据userIP从server获取的ms列表
GlobalConfig
.
rtmpPullListFromServer
=
[];
//根据userIP从server获取的rtmp拉流地址列表
GlobalConfig
.
hlsPullListFromServer
=
[];
//根据userIP从server获取的hls拉流地址列表
GlobalConfig
.
rsPullListFromServer
=
[];
//根据userIP从server获取的录制回放hls列表
//最终使用的选点列表集合-(从server.json中获取或Sass中获取)
GlobalConfig
.
mcuListFinal
=
[];
//最终选择的MCU集合
GlobalConfig
.
msListFinal
=
[];
//最终选择的MS 推流地址集合
GlobalConfig
.
rtmpPullListFinal
=
[];
//最终选择的RTMP推流地址集合
GlobalConfig
.
hlsListFinal
=
[];
//最终选择的HLS拉流地址集合
GlobalConfig
.
rsListFinal
=
[];
//最终选择的录制回放HLS拉流地址集合
//连接MCU的IP+端口
GlobalConfig
.
MCUServerIP
=
""
;
...
...
@@ -443,34 +501,7 @@ GlobalConfig.currentSceneTableId = 0; //文档区域的当前模块id显示的
GlobalConfig
.
classAllParam
=
{};
//Sass直接返回的所有课堂信息(最全)
GlobalConfig
.
classDetail
=
{};
//Sass直接返回的当前课堂基本信息
//从Sass获取的
GlobalConfig
.
sharedMediaList
=
[];
// 已经提前上传的媒体文件列表,进入课堂后需要自动加载
GlobalConfig
.
sharedMusicList
=
[];
// 已经提前上传的音乐文件列表,进入课堂后需要自动加载
GlobalConfig
.
docListPrepare
=
[];
// 已经提前上传的文档,进入课堂后需要自动加载
GlobalConfig
.
recordList
=
[];
//录制服务器地址集合
GlobalConfig
.
docList
=
[];
//文档服务器地址集合
GlobalConfig
.
mcuList
=
[];
//录制服务器地址集合
GlobalConfig
.
msList
=
[];
//ms服务器地址集合
GlobalConfig
.
musicList
=
[];
//music服务器地址集合
GlobalConfig
.
musicListPrepare
=
[];
//提提前上传的music集合
GlobalConfig
.
rsList
=
[];
//录制回放中视频点播地址
GlobalConfig
.
videoCDNAddr
=
''
;
GlobalConfig
.
videoCDNAddrList
=
[];
//从videoCDNAddr转换来的,videoCDNAddr字符串用分号隔开了多个ip
//乐视的推流和播放需要分开
GlobalConfig
.
pullRtmpList
=
[];
//rtmp播流地址集合(推流和播流地址需要区分的站点使用)
GlobalConfig
.
hlsList
=
[];
//hls播流地址集合(推流和播流地址需要区分的站点使用)
//根据IP从server获取
GlobalConfig
.
mcuListFromServer
=
[];
//根据userIP从server获取的mcu列表
GlobalConfig
.
msListFromServer
=
[];
//根据userIP从server获取的ms列表
GlobalConfig
.
country
=
""
;
//国家
GlobalConfig
.
city
=
""
;
//城市
GlobalConfig
.
province
=
""
;
//服务商
GlobalConfig
.
isp
=
""
;
//服务商
GlobalConfig
.
mcuListAll
=
[];
//所有MCU集合(sass+server)
GlobalConfig
.
msListAll
=
[];
//所有MS集合(sass+server)
GlobalConfig
.
isRecordPlayBack
=
false
;
//是否是录制回放,默认是否
GlobalConfig
.
allowRecordMaxTime
=
14400
;
//(秒)允许录制的最长时间,默认是4小时
...
...
src/IpManager.js
查看文件 @
bd69d56
...
...
@@ -249,6 +249,78 @@ class IpManager extends Emiter {
}
//服务器列表测速,参数是一个ip数组,返回一个ip
testFastestIpFromServer
(
_ipList
,
_callback
,
_timeOutDelay
)
{
loger
.
log
(
'开始测试->'
,
_ipList
);
let
callbackData
=
{
ip
:
""
};
if
(
_ipList
==
null
||
_ipList
.
length
<
1
)
{
if
(
_callback
)
{
_callback
(
callbackData
);
}
return
;
}
//对传入的ip数组进行组织
let
newList
=
new
Object
();
let
listLen
=
_ipList
.
length
;
for
(
let
i
=
0
;
i
<
listLen
;
i
++
)
{
let
msItem
=
_ipList
[
i
];
if
(
msItem
&&
msItem
.
ip
)
{
//测速的时候,ip地址要拼接成带端口的完整地址,测速的端口是固定的
newList
[
msItem
.
ip
+
':'
+
SPEED_TEST_PORT
]
=
msItem
.
ip
+
':'
+
SPEED_TEST_PORT
;
}
}
//过滤完重复ip
let
ipListArr
=
new
Array
();
for
(
let
k
in
newList
){
ipListArr
.
push
(
k
);
}
if
(
ipListArr
==
null
||
ipListArr
.
length
<
1
)
{
if
(
_callback
)
{
_callback
(
callbackData
);
}
return
;
}
loger
.
log
(
'测速地址列表->'
,
ipListArr
);
try
{
iphunter
(
ipListArr
,
function
(
fatest_ip_response
)
{
if
(
!
fatest_ip_response
)
{
loger
.
warn
(
'测速返回-> nothing!'
);
if
(
_callback
)
{
_callback
(
callbackData
);
}
}
else
{
loger
.
log
(
'测速返回->完成 -> '
,
fatest_ip_response
);
let
fastestIp
=
fatest_ip_response
.
replace
((
':'
+
SPEED_TEST_PORT
),
''
)
||
""
callbackData
.
ip
=
fastestIp
;
callbackData
.
port
=
''
;
//根据ip从原来的ip列表中查找端口
let
listLen
=
_ipList
.
length
;
for
(
let
i
=
0
;
i
<
listLen
;
i
++
)
{
let
msItem
=
_ipList
[
i
];
if
(
msItem
&&
msItem
.
ip
)
{
if
(
fastestIp
==
msItem
.
ip
)
{
callbackData
.
port
=
msItem
.
port
||
MS_DEFAULT_PORT
;
break
;
}
}
}
//返回数据
if
(
_callback
)
{
_callback
(
callbackData
);
}
}
},
_timeOutDelay
||
TIME_OUT
);
}
catch
(
err
)
{
loger
.
warn
(
'测速失败->ERROR -> '
,
err
.
message
);
if
(
_callback
)
{
_callback
(
callbackData
);
}
}
}
//根据user信息从配置文件中MCU连接地址
getServerMcuList
(
country
,
province
,
ctiy
,
isp
,
jsona
)
{
let
countryData
=
jsona
.
MCU
[
country
];
...
...
@@ -333,6 +405,63 @@ class IpManager extends Emiter {
return
[];
}
//根据user信息从server配置文件中获取服务列表信息
// _type()
/* "MS":{},
"RTMP_PULL":{},
"HLS_PULL":{},
"RS_PULL":{},
"MCU":{}*/
getServerListForUserInfo
(
_type
,
_country
,
province
,
ctiy
,
isp
,
jsona
)
{
if
(
!
jsona
){
return
[];
}
if
(
!
jsona
[
_type
]){
return
[]
}
let
countryData
=
jsona
[
_type
][
_country
];
//按country没有查找到就返回default
if
(
!
countryData
)
{
countryData
=
jsona
[
_type
].
default
||
[];
// loger.log("_returnServerMS->countryData->default",countryData);
return
countryData
;
}
if
(
_country
!=
"中国"
)
{
// loger.log("_returnServerMS->countryData",countryData);
return
countryData
;
}
//中国的需要细分
//按isp查找
let
ispData
=
countryData
.
isp
[
isp
];
//isp查找到就返回
if
(
ispData
)
{
// loger.log("_returnServerMS->ispData",ispData);
return
ispData
;
}
//isp没查找到,用province
let
provinceData
=
countryData
.
province
[
province
];
//用province查找到就返回
if
(
provinceData
)
{
// loger.log("_returnServerMS->provinceData",provinceData);
return
provinceData
;
}
//isp province都没有,使用default
let
defaultData
=
countryData
.
default
if
(
defaultData
)
{
// loger.log("_returnServerMS->defaultData",defaultData);
return
defaultData
;
}
else
{
// loger.log("_returnServerMS->defaultData","");
return
[];
}
return
[];
}
}
export
default
IpManager
;
...
...
src/MessageTypes.js
查看文件 @
bd69d56
...
...
@@ -106,6 +106,8 @@ MessageTypes.WHITEBOARD_ANNOTATION_UPDATE = "whiteboard_annotation_update"; // '
//MCU MS
MessageTypes
.
SWITCH_MCU_IP
=
"switch_mcu_ip"
;
//切换mcu 重新选点
MessageTypes
.
SWITCH_MS_IP
=
"switch_ms_ip"
;
//切换ms 重新选点
MessageTypes
.
SWITCH_RTMP_PULL_IP
=
"switch_rtmp_pull_ip"
;
//切换ms MS拉流选点
MessageTypes
.
SWITCH_HLS_IP
=
"switch_hls_ip"
;
//切换ms HLS拉流选点
//录制回放
MessageTypes
.
RECORD_PLAYBACK_UPDATE
=
"record_playback_update"
;
//录制回放更新信息
...
...
src/apes/ConferApe.js
查看文件 @
bd69d56
...
...
@@ -128,7 +128,7 @@ class ConferApe extends Ape {
nodeInfoRecordPdu
.
isp
=
GlobalConfig
.
isp
;
//服务商
//用户的MS列表
let
msListAll
=
GlobalConfig
.
msList
Al
l
;
let
msListAll
=
GlobalConfig
.
msList
Fina
l
;
for
(
let
k
=
0
;
k
<
msListAll
.
length
;
k
++
)
{
let
msItem
=
msListAll
[
k
];
if
(
msItem
)
{
...
...
@@ -632,7 +632,12 @@ class ConferApe extends Ape {
//进行MS动态选点,选择最快的MS服务器地址(录制回放不做处理)
if
(
!
GlobalConfig
.
isRecordPlayBack
&&
GlobalConfig
.
classTimestamp
%
GlobalConfig
.
msDynamicChooseIpDelay
==
0
)
{
//MS推流选点
this
.
_emit
(
MessageTypes
.
SWITCH_MS_IP
);
//MS拉流选点
this
.
_emit
(
MessageTypes
.
SWITCH_RTMP_PULL_IP
);
//HLS拉流选点
this
.
_emit
(
MessageTypes
.
SWITCH_HLS_IP
);
}
}
...
...
src/apes/MediaModule.js
查看文件 @
bd69d56
...
...
@@ -47,8 +47,7 @@ class MediaModule {
path
=
"http://"
+
GlobalConfig
.
MS_PLAY_HLS_IP
+
port
+
"/live/"
+
_param
.
streamId
+
".m3u8"
;
//新版的规则,不需要加playlist 20170724
//+ "/"+fileName;//
+
"/"
+
fileName
;
//
}
else
{
...
...
src/apes/MediaSharedApe.js
查看文件 @
bd69d56
...
...
@@ -404,13 +404,15 @@ class MediaSharedApe extends Ape {
getMediaPackFullInfo
.
status
==
1
&&
getMediaPackFullInfo
.
mediaVolume
==
this
.
lastActiveData
.
mediaVolume
){
let
timeDistance
=
Math
.
abs
(
new
Date
().
getTime
()
-
parseInt
(
this
.
lastActiveData
.
time
))
/
1000
;
let
seekDistance
=
Math
.
abs
(
getMediaPackFullInfo
.
seek
-
this
.
lastActiveData
.
seek
)
-
timeDistance
;
seekDistance
=
Math
.
abs
(
seekDistance
);
let
seek2seek
=
Math
.
abs
(
getMediaPackFullInfo
.
seek
-
this
.
lastActiveData
.
seek
)
let
seekDistance
=
seek2seek
-
timeDistance
;
seekDistance
=
parseInt
(
Math
.
abs
(
seekDistance
));
loger
.
warn
(
"timeDistance:"
+
timeDistance
+
" seek2seek:"
+
seek2seek
+
" seekDistance:"
+
seekDistance
);
if
(
seekDistance
<=
5
){
//记录最后一次的数据
loger
.
warn
(
"媒体共享更新数据->数据只有SEEK发生改变,低于5秒不需要再更新->timeDistance:"
+
timeDistance
+
"->seekDistance"
+
seekDistance
);
//记录最后一次激活的数据
this
.
lastActiveData
=
getMediaPackFullInfo
||
{}
;
this
.
lastActiveData
=
getMediaPackFullInfo
;
this
.
lastActiveData
.
time
=
new
Date
().
getTime
();
return
;
}
...
...
src/apes/MusicSharedApe.js
查看文件 @
bd69d56
...
...
@@ -401,9 +401,16 @@ class MusicSharedApe extends Ape {
getMusicPackFullInfo
.
status
==
1
&&
getMusicPackFullInfo
.
musicVolume
==
this
.
lastActiveData
.
musicVolume
){
let
timeDistance
=
Math
.
abs
(
new
Date
().
getTime
()
-
parseInt
(
this
.
lastActiveData
.
time
))
/
1000
;
/*
let timeDistance=Math.abs(new Date().getTime()-parseInt(this.lastActiveData.time))/1000;
let seekDistance=Math.abs(getMusicPackFullInfo.seek-this.lastActiveData.seek)-timeDistance;
seekDistance=Math.abs(seekDistance);
*/
let
timeDistance
=
Math
.
abs
(
new
Date
().
getTime
()
-
parseInt
(
this
.
lastActiveData
.
time
))
/
1000
;
let
seek2seek
=
Math
.
abs
(
getMusicPackFullInfo
.
seek
-
this
.
lastActiveData
.
seek
)
let
seekDistance
=
seek2seek
-
timeDistance
;
seekDistance
=
parseInt
(
Math
.
abs
(
seekDistance
));
loger
.
warn
(
"timeDistance:"
+
timeDistance
+
" seek2seek:"
+
seek2seek
+
" seekDistance:"
+
seekDistance
);
if
(
seekDistance
<
5
){
//记录最后一次的数据
loger
.
warn
(
"伴音更新数据->数据只有SEEK发生改变,低于5秒不需要再更新->timeDistance:"
+
timeDistance
+
"->seekDistance"
+
seekDistance
);
...
...
请
注册
或
登录
后发表评论