Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
27acd105
提交
27acd105
authored
10月 17, 2017
作者:
José Luis Millán
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enable/Disable periodic stats retrieval for Transport, Producer and Consumer
上级
df553ad3
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
333 行增加
和
0 行删除
+333
-0
Consumer.js
lib/Consumer.js
+84
-0
Peer.js
lib/Peer.js
+78
-0
PlainRtpTransport.js
lib/PlainRtpTransport.js
+20
-0
Producer.js
lib/Producer.js
+77
-0
WebRtcTransport.js
lib/WebRtcTransport.js
+74
-0
没有找到文件。
lib/Consumer.js
浏览文件 @
27acd105
...
...
@@ -52,6 +52,14 @@ class Consumer extends EnhancedEventEmitter
// @type {Boolean}
this
.
_sourcePaused
=
false
;
// Periodic stats flag.
// @type {Boolean}
this
.
_statsEnabled
=
false
;
// Periodic stats interval identifier.
// @type {Boolean}
this
.
_statsInterval
=
null
;
// Preferred profile.
// @type {String}
this
.
_preferredProfile
=
'default'
;
...
...
@@ -189,6 +197,12 @@ class Consumer extends EnhancedEventEmitter
this
.
_closed
=
true
;
if
(
this
.
_statsEnabled
)
{
this
.
_statsEnabled
=
false
;
clearInterval
(
this
.
_statsInterval
);
}
// Notify if it has a Peer.
if
(
this
.
hasPeer
())
{
...
...
@@ -418,6 +432,76 @@ class Consumer extends EnhancedEventEmitter
return
this
.
paused
;
}
/**
* Enables periodic stats retrieval.
*
*/
enableStats
()
{
logger
.
debug
(
'enableStats()'
);
if
(
this
.
_closed
)
{
logger
.
error
(
'enableStats() | Consumer closed'
);
return
;
}
if
(
this
.
_statsEnabled
)
{
return
;
}
this
.
_statsEnabled
=
true
;
this
.
_statsInterval
=
setInterval
(()
=>
{
if
(
this
.
_paused
||
!
this
.
enabled
)
return
;
this
.
getStats
()
.
then
((
stats
)
=>
{
const
data
=
{
id
:
this
.
id
,
peerName
:
this
.
peer
.
name
,
stats
}
this
.
emit
(
'@notify'
,
'consumerStats'
,
data
);
})
.
catch
((
error
)
=>
{
logger
.
error
(
'"getStats" request failed: %s'
,
String
(
error
));
});
},
1000
);
}
/**
* Disables periodic stats retrieval.
*
*/
disableStats
()
{
logger
.
debug
(
'disableStats()'
);
if
(
this
.
_closed
)
{
logger
.
error
(
'disableStats() | Consumer closed'
);
return
;
}
if
(
!
this
.
_statsEnabled
)
{
return
;
}
this
.
_statsEnabled
=
false
;
clearInterval
(
this
.
_statsInterval
);
}
/**
* The remote Consumer was paused.
* Invoked via remote notification.
...
...
lib/Peer.js
浏览文件 @
27acd105
...
...
@@ -505,6 +505,32 @@ class Peer extends EnhancedEventEmitter
break
;
}
case
'enableTransportStats'
:
{
const
{
id
,
appData
}
=
notification
;
const
transport
=
this
.
_transports
.
get
(
id
);
if
(
!
transport
)
throw
new
Error
(
'Transport not found'
);
transport
.
enableStats
(
appData
);
break
;
}
case
'disableTransportStats'
:
{
const
{
id
,
appData
}
=
notification
;
const
transport
=
this
.
_transports
.
get
(
id
);
if
(
!
transport
)
throw
new
Error
(
'Transport not found'
);
transport
.
disableStats
(
appData
);
break
;
}
case
'updateProducer'
:
{
const
{
id
,
rtpParameters
}
=
notification
;
...
...
@@ -558,6 +584,32 @@ class Peer extends EnhancedEventEmitter
break
;
}
case
'enableProducerStats'
:
{
const
{
id
,
appData
}
=
notification
;
const
producer
=
this
.
_producers
.
get
(
id
);
if
(
!
producer
)
throw
new
Error
(
'Producer not found'
);
producer
.
enableStats
(
appData
);
break
;
}
case
'disableProducerStats'
:
{
const
{
id
,
appData
}
=
notification
;
const
producer
=
this
.
_producers
.
get
(
id
);
if
(
!
producer
)
throw
new
Error
(
'Producer not found'
);
producer
.
disableStats
(
appData
);
break
;
}
case
'pauseConsumer'
:
{
const
{
id
,
appData
}
=
notification
;
...
...
@@ -597,6 +649,32 @@ class Peer extends EnhancedEventEmitter
break
;
}
case
'enableConsumerStats'
:
{
const
{
id
,
appData
}
=
notification
;
const
consumer
=
this
.
_consumers
.
get
(
id
);
if
(
!
consumer
)
throw
new
Error
(
'Consumer not found'
);
consumer
.
enableStats
(
appData
);
break
;
}
case
'disableConsumerStats'
:
{
const
{
id
,
appData
}
=
notification
;
const
consumer
=
this
.
_consumers
.
get
(
id
);
if
(
!
consumer
)
throw
new
Error
(
'Consumer not found'
);
consumer
.
disableStats
(
appData
);
break
;
}
default
:
throw
new
Error
(
`unknown notification method "
${
method
}
"`
);
}
...
...
lib/PlainRtpTransport.js
浏览文件 @
27acd105
...
...
@@ -115,6 +115,26 @@ class PlainRtpTransport extends EnhancedEventEmitter
});
}
/**
* Enables periodic stats retrieval.
*
* Not implemented.
*
*/
enableStats
()
{
}
/**
* Disables periodic stats retrieval.
*
* Not implemented.
*
*/
disableStats
()
{
}
_handleWorkerNotifications
()
{
// Subscribe to notifications.
...
...
lib/Producer.js
浏览文件 @
27acd105
...
...
@@ -47,6 +47,14 @@ class Producer extends EnhancedEventEmitter
// @type {Boolean}
this
.
_remotelyPaused
=
Boolean
(
options
.
remotelyPaused
);
// Periodic stats flag.
// @type {Boolean}
this
.
_statsEnabled
=
false
;
// Periodic stats interval identifier.
// @type {Boolean}
this
.
_statsInterval
=
null
;
// Preferred profile.
// @type {String}
this
.
_preferredProfile
=
'default'
;
...
...
@@ -156,6 +164,12 @@ class Producer extends EnhancedEventEmitter
this
.
_closed
=
true
;
if
(
this
.
_statsEnabled
)
{
this
.
_statsEnabled
=
false
;
clearInterval
(
this
.
_statsInterval
);
}
// If our Transport is still alive, it means that the app really wants to close
// the client-side Producer. Otherwise, if the Transport is closed the client-side
// Producer will get 'unhandled', so don't close it from here.
...
...
@@ -323,6 +337,69 @@ class Producer extends EnhancedEventEmitter
return
this
.
paused
;
}
/**
* Enables periodic stats retrieval.
*
*/
enableStats
()
{
logger
.
debug
(
'enableStats()'
);
if
(
this
.
_closed
)
{
logger
.
error
(
'enableStats() | Producer closed'
);
return
;
}
if
(
this
.
_statsEnabled
)
{
return
;
}
this
.
_statsEnabled
=
true
;
this
.
_statsInterval
=
setInterval
(()
=>
{
if
(
this
.
_paused
||
!
this
.
enabled
)
return
;
this
.
getStats
()
.
then
((
data
)
=>
{
this
.
emit
(
'@notify'
,
'producerStats'
,
data
);
})
.
catch
((
error
)
=>
{
logger
.
error
(
'"getStats" failed: %s'
,
String
(
error
));
});
},
1000
);
}
/**
* Disables periodic stats retrieval.
*
*/
disableStats
()
{
logger
.
debug
(
'disableStats()'
);
if
(
this
.
_closed
)
{
logger
.
error
(
'disableStats() | Producer closed'
);
return
;
}
if
(
!
this
.
_statsEnabled
)
{
return
;
}
this
.
_statsEnabled
=
false
;
clearInterval
(
this
.
_statsInterval
);
}
/**
* The remote Producer was paused.
* Invoked via remote notification.
...
...
lib/WebRtcTransport.js
浏览文件 @
27acd105
...
...
@@ -65,6 +65,14 @@ class WebRtcTransport extends EnhancedEventEmitter
// App data.
this
.
_appData
=
undefined
;
// Periodic stats flag.
// @type {Boolean}
this
.
_statsEnabled
=
false
;
// Periodic stats interval identifier.
// @type {Boolean}
this
.
_statsInterval
=
null
;
this
.
_handleWorkerNotifications
();
}
...
...
@@ -148,6 +156,12 @@ class WebRtcTransport extends EnhancedEventEmitter
this
.
_closed
=
true
;
if
(
this
.
_statsEnabled
)
{
this
.
_statsEnabled
=
false
;
clearInterval
(
this
.
_statsInterval
);
}
this
.
emit
(
'@notify'
,
'transportClosed'
,
{
id
:
this
.
id
,
appData
});
this
.
emit
(
'@close'
);
...
...
@@ -156,6 +170,66 @@ class WebRtcTransport extends EnhancedEventEmitter
this
.
_destroy
(
notifyChannel
);
}
/**
* Enables periodic stats retrieval.
*
*/
enableStats
()
{
logger
.
debug
(
'enableStats()'
);
if
(
this
.
_closed
)
{
logger
.
error
(
'enableStats() | WebRtcTransport closed'
);
return
;
}
if
(
this
.
_statsEnabled
)
{
return
;
}
this
.
_statsEnabled
=
true
;
this
.
_statsInterval
=
setInterval
(()
=>
{
this
.
getStats
()
.
then
((
data
)
=>
{
this
.
emit
(
'@notify'
,
'transportStats'
,
data
);
})
.
catch
((
error
)
=>
{
logger
.
error
(
'"getStats" request failed: %s'
,
String
(
error
));
});
},
1000
);
}
/**
* Disables periodic stats retrieval.
*
*/
disableStats
()
{
logger
.
debug
(
'disableStats()'
);
if
(
this
.
_closed
)
{
logger
.
error
(
'disableStats() | WebRtcTransport closed'
);
return
;
}
if
(
!
this
.
_statsEnabled
)
{
return
;
}
this
.
_statsEnabled
=
false
;
clearInterval
(
this
.
_statsInterval
);
}
/**
* Remote WebRtcTransport was closed.
* Invoked via remote notification.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论