Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
e1989577
提交
e1989577
authored
12月 31, 2015
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup
上级
180a19d5
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
55 行增加
和
19 行删除
+55
-19
Channel.js
lib/Channel.js
+12
-0
Worker.js
lib/Worker.js
+4
-4
Logger.h
worker/include/Logger.h
+1
-1
Loop.cpp
worker/src/Loop.cpp
+0
-2
main.cpp
worker/src/main.cpp
+38
-12
没有找到文件。
lib/Channel.js
浏览文件 @
e1989577
...
@@ -142,6 +142,18 @@ class Channel extends EventEmitter
...
@@ -142,6 +142,18 @@ class Channel extends EventEmitter
this
.
_socket
.
removeAllListeners
(
'end'
);
this
.
_socket
.
removeAllListeners
(
'end'
);
this
.
_socket
.
removeAllListeners
(
'error'
);
this
.
_socket
.
removeAllListeners
(
'error'
);
// Destroy the socket after a while to allow pending incoming
// messages
setTimeout
(()
=>
{
try
{
this
.
_socket
.
destroy
();
}
catch
(
error
)
{}
},
250
);
}
}
request
(
method
,
data
)
request
(
method
,
data
)
...
...
lib/Worker.js
浏览文件 @
e1989577
...
@@ -51,19 +51,19 @@ class Worker extends EventEmitter
...
@@ -51,19 +51,19 @@ class Worker extends EventEmitter
this
.
_child
.
stdout
.
on
(
'data'
,
(
buffer
)
=>
this
.
_child
.
stdout
.
on
(
'data'
,
(
buffer
)
=>
{
{
buffer
.
toString
(
'utf8'
).
split
(
'
\
f
'
).
forEach
((
line
)
=>
buffer
.
toString
(
'utf8'
).
split
(
'
\
n
'
).
forEach
((
line
)
=>
{
{
if
(
line
)
if
(
line
)
logger
.
debug
(
`mediasoup-worker's stdout
[id:
${
id
}
]
:
${
line
}
`
);
logger
.
debug
(
`mediasoup-worker's stdout:
${
line
}
`
);
});
});
});
});
this
.
_child
.
stderr
.
on
(
'data'
,
(
buffer
)
=>
this
.
_child
.
stderr
.
on
(
'data'
,
(
buffer
)
=>
{
{
buffer
.
toString
(
'utf8'
).
split
(
'
\
f
'
).
forEach
((
line
)
=>
buffer
.
toString
(
'utf8'
).
split
(
'
\
n
'
).
forEach
((
line
)
=>
{
{
if
(
line
)
if
(
line
)
logger
.
error
(
`mediasoup-worker's stderr
[id:
${
id
}
]
:
${
line
}
`
);
logger
.
error
(
`mediasoup-worker's stderr:
${
line
}
`
);
});
});
});
});
...
...
worker/include/Logger.h
浏览文件 @
e1989577
...
@@ -67,7 +67,7 @@ bool Logger::HasDebugLevel()
...
@@ -67,7 +67,7 @@ bool Logger::HasDebugLevel()
// NOTE: Each file including Logger.h MUST define its own MS_CLASS macro.
// NOTE: Each file including Logger.h MUST define its own MS_CLASS macro.
#define _MS_LOG_SEPARATOR_CHAR_STD "\
f
"
#define _MS_LOG_SEPARATOR_CHAR_STD "\
n
"
#ifdef MS_DEVEL
#ifdef MS_DEVEL
#define _MS_LOG_STR "[%s] %s:%d | %s::%s()"
#define _MS_LOG_STR "[%s] %s:%d | %s::%s()"
...
...
worker/src/Loop.cpp
浏览文件 @
e1989577
...
@@ -292,9 +292,7 @@ void Loop::onChannelUnixStreamSocketRemotelyClosed(Channel::UnixStreamSocket* so
...
@@ -292,9 +292,7 @@ void Loop::onChannelUnixStreamSocketRemotelyClosed(Channel::UnixStreamSocket* so
// pipe and then exit.
// pipe and then exit.
// If the pipe is remotely closed it means that mediasoup Node process
// If the pipe is remotely closed it means that mediasoup Node process
// abruptly died (SIGKILL?) so we must die.
// abruptly died (SIGKILL?) so we must die.
MS_ERROR_STD
(
"Channel remotely closed, killing myself"
);
MS_ERROR_STD
(
"Channel remotely closed, killing myself"
);
this
->
channel
=
nullptr
;
this
->
channel
=
nullptr
;
Close
();
Close
();
...
...
worker/src/main.cpp
浏览文件 @
e1989577
...
@@ -26,33 +26,42 @@
...
@@ -26,33 +26,42 @@
static
void
init
();
static
void
init
();
static
void
ignoreSignals
();
static
void
ignoreSignals
();
static
void
destroy
();
static
void
destroy
();
static
void
exitSuccess
();
static
void
exitWithError
();
int
main
(
int
argc
,
char
*
argv
[]
,
char
**
envp
)
int
main
(
int
argc
,
char
*
argv
[])
{
{
// Initialize libuv stuff (we need it for the Channel).
// Ensure we are called by our Node library.
DepLibUV
::
ClassInit
();
if
(
argc
==
1
||
!
std
::
getenv
(
"MEDIASOUP_CHANNEL_FD"
))
{
fprintf
(
stderr
,
"YOU ARE NOT MY REAL FATHER
\n
"
);
std
::
_Exit
(
EXIT_FAILURE
);
}
std
::
string
id
=
std
::
string
(
argv
[
1
]);
int
channelFd
=
std
::
stoi
(
std
::
getenv
(
"MEDIASOUP_CHANNEL_FD"
));
int
channelFd
=
std
::
stoi
(
std
::
getenv
(
"MEDIASOUP_CHANNEL_FD"
));
// Initialize libuv stuff (we need it for the Channel).
DepLibUV
::
ClassInit
();
// Set the Channel socket (this will be handled and deleted by the Loop).
// Set the Channel socket (this will be handled and deleted by the Loop).
Channel
::
UnixStreamSocket
*
channel
=
new
Channel
::
UnixStreamSocket
(
channelFd
);
Channel
::
UnixStreamSocket
*
channel
=
new
Channel
::
UnixStreamSocket
(
channelFd
);
std
::
string
id
=
std
::
string
(
argv
[
1
]);
// Initialize the Logger.
Logger
::
Init
(
id
,
channel
);
Logger
::
Init
(
id
,
channel
);
// Setup the configuration.
try
try
{
{
Settings
::
SetConfiguration
(
argc
,
argv
);
Settings
::
SetConfiguration
(
argc
,
argv
);
}
}
catch
(
const
MediaSoupError
&
error
)
catch
(
const
MediaSoupError
&
error
)
{
{
MS_ERROR
(
"failed to start: %s"
,
error
.
what
());
MS_ERROR
(
"configuration error: %s"
,
error
.
what
());
usleep
(
100000
);
exitWithError
();
std
::
_Exit
(
EXIT_FAILURE
);
}
}
// Print configuration.
// Print
the effective
configuration.
Settings
::
PrintConfiguration
();
Settings
::
PrintConfiguration
();
MS_DEBUG
(
"starting "
MS_PROCESS_NAME
" [pid:%ld]"
,
(
long
)
getpid
());
MS_DEBUG
(
"starting "
MS_PROCESS_NAME
" [pid:%ld]"
,
(
long
)
getpid
());
...
@@ -80,14 +89,13 @@ int main(int argc, char* argv[], char** envp)
...
@@ -80,14 +89,13 @@ int main(int argc, char* argv[], char** envp)
destroy
();
destroy
();
MS_DEBUG_STD
(
"success exit"
);
MS_DEBUG_STD
(
"success exit"
);
std
::
_Exit
(
EXIT_SUCCESS
);
exitSuccess
(
);
}
}
catch
(
const
MediaSoupError
&
error
)
catch
(
const
MediaSoupError
&
error
)
{
{
destroy
();
destroy
();
MS_ERROR_STD
(
"failure exit: %s"
,
error
.
what
());
MS_ERROR_STD
(
"failure exit: %s"
,
error
.
what
());
usleep
(
100000
);
exitWithError
();
std
::
_Exit
(
EXIT_FAILURE
);
}
}
}
}
...
@@ -154,3 +162,21 @@ void destroy()
...
@@ -154,3 +162,21 @@ void destroy()
RTC
::
DTLSAgent
::
ClassDestroy
();
RTC
::
DTLSAgent
::
ClassDestroy
();
Utils
::
Crypto
::
ClassDestroy
();
Utils
::
Crypto
::
ClassDestroy
();
}
}
void
exitSuccess
()
{
// Wait a bit so peding messages to stdout/Channel arrive to the main process.
usleep
(
100000
);
// And exit with success status.
std
::
_Exit
(
EXIT_SUCCESS
);
}
void
exitWithError
()
{
// Wait a bit so peding messages to stderr arrive to the main process.
usleep
(
100000
);
// And exit with error status.
std
::
_Exit
(
EXIT_FAILURE
);
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论