Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
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
winlin
2014-07-17 11:28:20 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
784d7499cf5f7297a755394e2d9dc0ab16e27daa
784d7499
1 parent
f3e85a00
refine config, add error line log
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
62 行增加
和
61 行删除
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_config.cpp
查看文件 @
784d749
...
...
@@ -154,6 +154,7 @@ int SrsConfDirective::parse_conf(_srs_internal::SrsConfigBuffer* buffer, SrsDire
while
(
true
)
{
std
::
vector
<
string
>
args
;
ret
=
read_token
(
buffer
,
args
);
/**
...
...
@@ -169,21 +170,21 @@ int SrsConfDirective::parse_conf(_srs_internal::SrsConfigBuffer* buffer, SrsDire
}
if
(
ret
==
ERROR_SYSTEM_CONFIG_BLOCK_END
)
{
if
(
type
!=
parse_block
)
{
srs_error
(
"line %d: unexpected
\"
}
\"
"
,
buffer
->
line
);
srs_error
(
"line %d: unexpected
\"
}
\"
"
,
buffer
->
line
+
1
);
return
ret
;
}
return
ERROR_SUCCESS
;
}
if
(
ret
==
ERROR_SYSTEM_CONFIG_EOF
)
{
if
(
type
==
parse_block
)
{
srs_error
(
"line %d: unexpected end of file, expecting
\"
}
\"
"
,
buffer
->
line
);
srs_error
(
"line %d: unexpected end of file, expecting
\"
}
\"
"
,
conf_line
+
1
);
return
ret
;
}
return
ERROR_SUCCESS
;
}
if
(
args
.
empty
())
{
srs_error
(
"line %d: empty directive."
,
buffer
->
line
);
srs_error
(
"line %d: empty directive."
,
conf_line
+
1
);
return
ret
;
}
...
...
@@ -258,7 +259,7 @@ int SrsConfDirective::read_token(_srs_internal::SrsConfigBuffer* buffer, vector<
if
(
ch
==
'{'
)
{
return
ERROR_SYSTEM_CONFIG_BLOCK_START
;
}
srs_error
(
"line %d: unexpected '%c'"
,
buffer
->
line
,
ch
);
srs_error
(
"line %d: unexpected '%c'"
,
buffer
->
line
+
1
,
ch
);
return
ERROR_SYSTEM_CONFIG_INVALID
;
}
...
...
@@ -271,19 +272,19 @@ int SrsConfDirective::read_token(_srs_internal::SrsConfigBuffer* buffer, vector<
switch
(
ch
)
{
case
';'
:
if
(
args
.
size
()
==
0
)
{
srs_error
(
"line %d: unexpected ';'"
,
buffer
->
line
);
srs_error
(
"line %d: unexpected ';'"
,
buffer
->
line
+
1
);
return
ERROR_SYSTEM_CONFIG_INVALID
;
}
return
ERROR_SYSTEM_CONFIG_DIRECTIVE
;
case
'{'
:
if
(
args
.
size
()
==
0
)
{
srs_error
(
"line %d: unexpected '{'"
,
buffer
->
line
);
srs_error
(
"line %d: unexpected '{'"
,
buffer
->
line
+
1
);
return
ERROR_SYSTEM_CONFIG_INVALID
;
}
return
ERROR_SYSTEM_CONFIG_BLOCK_START
;
case
'}'
:
if
(
args
.
size
()
!=
0
)
{
srs_error
(
"line %d: unexpected '}'"
,
buffer
->
line
);
srs_error
(
"line %d: unexpected '}'"
,
buffer
->
line
+
1
);
return
ERROR_SYSTEM_CONFIG_INVALID
;
}
return
ERROR_SYSTEM_CONFIG_BLOCK_END
;
...
...
@@ -1068,59 +1069,6 @@ int SrsConfig::parse_options(int argc, char** argv)
return
ret
;
}
int
SrsConfig
::
parse_file
(
const
char
*
filename
)
{
int
ret
=
ERROR_SUCCESS
;
config_file
=
filename
;
if
(
config_file
.
empty
())
{
return
ERROR_SYSTEM_CONFIG_INVALID
;
}
_srs_internal
::
SrsConfigBuffer
buffer
;
if
((
ret
=
buffer
.
fullfill
(
config_file
.
c_str
()))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
if
((
ret
=
root
->
parse
(
&
buffer
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
SrsConfDirective
*
conf
=
NULL
;
// check rtmp port specified by directive listen.
if
((
conf
=
get_listen
())
==
NULL
||
conf
->
args
.
size
()
==
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"line %d: conf error, "
"directive
\"
listen
\"
is empty, ret=%d"
,
(
conf
?
conf
->
conf_line
:
0
),
ret
);
return
ret
;
}
// TODO: check the hls.
// TODO: check forward.
// TODO: check ffmpeg.
// TODO: check http.
// TODO: check pid.
// check log
std
::
string
log_filename
=
this
->
get_log_file
();
if
(
get_log_tank_file
()
&&
log_filename
.
empty
())
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"must specifies the file to write log to. ret=%d"
,
ret
);
return
ret
;
}
if
(
get_log_tank_file
())
{
srs_trace
(
"write log to file %s"
,
log_filename
.
c_str
());
srs_trace
(
"you can: tailf %s"
,
log_filename
.
c_str
());
srs_trace
(
"@see: %s"
,
SRS_WIKI_URL_LOG
);
}
else
{
srs_trace
(
"write log to console"
);
}
return
ret
;
}
int
SrsConfig
::
parse_argv
(
int
&
i
,
char
**
argv
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -1197,6 +1145,59 @@ void SrsConfig::print_help(char** argv)
argv
[
0
],
argv
[
0
],
argv
[
0
],
argv
[
0
]);
}
int
SrsConfig
::
parse_file
(
const
char
*
filename
)
{
int
ret
=
ERROR_SUCCESS
;
config_file
=
filename
;
if
(
config_file
.
empty
())
{
return
ERROR_SYSTEM_CONFIG_INVALID
;
}
_srs_internal
::
SrsConfigBuffer
buffer
;
if
((
ret
=
buffer
.
fullfill
(
config_file
.
c_str
()))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
if
((
ret
=
root
->
parse
(
&
buffer
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
SrsConfDirective
*
conf
=
NULL
;
// check rtmp port specified by directive listen.
if
((
conf
=
get_listen
())
==
NULL
||
conf
->
args
.
size
()
==
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"line %d: conf error, "
"directive
\"
listen
\"
is empty, ret=%d"
,
(
conf
?
conf
->
conf_line
:
0
),
ret
);
return
ret
;
}
// TODO: check the hls.
// TODO: check forward.
// TODO: check ffmpeg.
// TODO: check http.
// TODO: check pid.
// check log
std
::
string
log_filename
=
this
->
get_log_file
();
if
(
get_log_tank_file
()
&&
log_filename
.
empty
())
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"must specifies the file to write log to. ret=%d"
,
ret
);
return
ret
;
}
if
(
get_log_tank_file
())
{
srs_trace
(
"write log to file %s"
,
log_filename
.
c_str
());
srs_trace
(
"you can: tailf %s"
,
log_filename
.
c_str
());
srs_trace
(
"@see: %s"
,
SRS_WIKI_URL_LOG
);
}
else
{
srs_trace
(
"write log to console"
);
}
return
ret
;
}
string
SrsConfig
::
cwd
()
{
return
_cwd
;
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
784d749
...
...
@@ -245,9 +245,9 @@ private:
public:
virtual
int
parse_options
(
int
argc
,
char
**
argv
);
private
:
virtual
int
parse_file
(
const
char
*
filename
);
virtual
int
parse_argv
(
int
&
i
,
char
**
argv
);
virtual
void
print_help
(
char
**
argv
);
virtual
int
parse_file
(
const
char
*
filename
);
public
:
virtual
std
::
string
cwd
();
virtual
std
::
string
argv
();
...
...
请
注册
或
登录
后发表评论