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-21 12:13:01 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
77236920b6a1d478e7fbf39ac75d2c61e95a33b7
77236920
1 parent
f1b1dc0c
add config utest, for default vhost
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
101 行增加
和
0 行删除
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/utest/srs_utest_config.cpp
trunk/src/app/srs_app_config.cpp
查看文件 @
7723692
...
...
@@ -2312,6 +2312,10 @@ SrsConfDirective* SrsConfig::get_ingest_by_id(string vhost, string ingest_id)
bool
SrsConfig
::
get_ingest_enabled
(
SrsConfDirective
*
ingest
)
{
if
(
!
ingest
)
{
return
false
;
}
SrsConfDirective
*
conf
=
ingest
->
get
(
"enabled"
);
if
(
!
conf
||
conf
->
arg0
()
!=
"on"
)
{
...
...
@@ -2323,6 +2327,10 @@ bool SrsConfig::get_ingest_enabled(SrsConfDirective* ingest)
string
SrsConfig
::
get_ingest_ffmpeg
(
SrsConfDirective
*
ingest
)
{
if
(
!
ingest
)
{
return
""
;
}
SrsConfDirective
*
conf
=
ingest
->
get
(
"ffmpeg"
);
if
(
!
conf
)
{
...
...
@@ -2334,6 +2342,10 @@ string SrsConfig::get_ingest_ffmpeg(SrsConfDirective* ingest)
string
SrsConfig
::
get_ingest_input_type
(
SrsConfDirective
*
ingest
)
{
if
(
!
ingest
)
{
return
SRS_CONF_DEFAULT_INGEST_TYPE_FILE
;
}
SrsConfDirective
*
conf
=
ingest
->
get
(
"input"
);
if
(
!
conf
)
{
...
...
@@ -2351,6 +2363,10 @@ string SrsConfig::get_ingest_input_type(SrsConfDirective* ingest)
string
SrsConfig
::
get_ingest_input_url
(
SrsConfDirective
*
ingest
)
{
if
(
!
ingest
)
{
return
""
;
}
SrsConfDirective
*
conf
=
ingest
->
get
(
"input"
);
if
(
!
conf
)
{
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
7723692
...
...
@@ -449,28 +449,33 @@ public:
* whether gop_cache is enabled of vhost.
* gop_cache used to cache last gop, for client to fast startup.
* @return true when gop_cache is ok; otherwise, false.
* @remark, default true.
*/
virtual
bool
get_gop_cache
(
std
::
string
vhost
);
/**
* whether atc is enabled of vhost.
* atc always use encoder timestamp, SRS never adjust the time.
* @return true when atc is ok; otherwise, false.
* @remark, default false.
*/
virtual
bool
get_atc
(
std
::
string
vhost
);
/**
* whether atc_auto is enabled of vhost.
* atc_auto used to auto enable atc, when metadata specified the bravo_atc.
* @return true when atc_auto is ok; otherwise, false.
* @remark, default true.
*/
virtual
bool
get_atc_auto
(
std
::
string
vhost
);
/**
* get the time_jitter algorithm.
* @return the time_jitter algorithm, defined in SrsRtmpJitterAlgorithm.
* @remark, default full.
*/
virtual
int
get_time_jitter
(
std
::
string
vhost
);
/**
* get the cache queue length, in seconds.
* when exceed the queue length, drop packet util I frame.
* @remark, default 10.
*/
virtual
double
get_queue_length
(
std
::
string
vhost
);
/**
...
...
@@ -478,20 +483,24 @@ public:
* each args of directive is a refer config.
* when the client refer(pageUrl) not match the refer config,
* SRS will reject the connection.
* @remark, default NULL.
*/
virtual
SrsConfDirective
*
get_refer
(
std
::
string
vhost
);
/**
* get the play refer, refer for play clients.
* @remark, default NULL.
*/
virtual
SrsConfDirective
*
get_refer_play
(
std
::
string
vhost
);
/**
* get the publish refer, refer for publish clients.
* @remark, default NULL.
*/
virtual
SrsConfDirective
*
get_refer_publish
(
std
::
string
vhost
);
/**
* get the chunk size of vhost.
* @param vhost, the vhost to get the chunk size. use global if not specified.
* empty string to get the global.
* @remark, default 60000.
*/
virtual
int
get_chunk_size
(
std
::
string
vhost
);
private
:
...
...
trunk/src/utest/srs_utest_config.cpp
查看文件 @
7723692
...
...
@@ -27,6 +27,7 @@ using namespace std;
#include <srs_app_config.hpp>
#include <srs_kernel_consts.hpp>
#include <srs_kernel_error.hpp>
#include <srs_app_source.hpp>
MockSrsConfigBuffer
::
MockSrsConfigBuffer
(
string
buf
)
{
...
...
@@ -1837,6 +1838,14 @@ VOID TEST(ConfigMainTest, ParseFullConf)
EXPECT_EQ
(
8080
,
conf
.
get_http_stream_listen
());
EXPECT_STREQ
(
"./objs/nginx/html"
,
conf
.
get_http_stream_dir
().
c_str
());
EXPECT_EQ
(
10000
,
conf
.
get_pithy_print_publish
());
EXPECT_EQ
(
10000
,
conf
.
get_pithy_print_play
());
EXPECT_EQ
(
10000
,
conf
.
get_pithy_print_forwarder
());
EXPECT_EQ
(
10000
,
conf
.
get_pithy_print_encoder
());
EXPECT_EQ
(
10000
,
conf
.
get_pithy_print_ingester
());
EXPECT_EQ
(
10000
,
conf
.
get_pithy_print_hls
());
EXPECT_EQ
(
10000
,
conf
.
get_pithy_print_edge
());
EXPECT_TRUE
(
NULL
!=
conf
.
get_vhost
(
"__defaultVhost__"
));
EXPECT_TRUE
(
NULL
!=
conf
.
get_vhost
(
"same.edge.srs.com"
));
EXPECT_TRUE
(
NULL
!=
conf
.
get_vhost
(
"change.edge.srs.com"
));
...
...
@@ -1865,4 +1874,71 @@ VOID TEST(ConfigMainTest, ParseFullConf)
EXPECT_TRUE
(
NULL
!=
conf
.
get_vhost
(
"jitter.srs.com"
));
EXPECT_TRUE
(
NULL
!=
conf
.
get_vhost
(
"atc.srs.com"
));
EXPECT_TRUE
(
NULL
!=
conf
.
get_vhost
(
"removed.srs.com"
));
string
vhost
=
"__defaultVhost__"
;
EXPECT_TRUE
(
conf
.
get_vhost_enabled
(
vhost
));
EXPECT_TRUE
(
conf
.
get_vhost_enabled
(
conf
.
get_vhost
(
vhost
)));
EXPECT_TRUE
(
conf
.
get_gop_cache
(
vhost
));
EXPECT_FALSE
(
conf
.
get_atc
(
vhost
));
EXPECT_TRUE
(
conf
.
get_atc_auto
(
vhost
));
EXPECT_TRUE
(
conf
.
get_time_jitter
(
vhost
)
==
SrsRtmpJitterAlgorithmFULL
);
EXPECT_FLOAT_EQ
(
30
,
conf
.
get_queue_length
(
vhost
));
EXPECT_TRUE
(
NULL
==
conf
.
get_refer
(
vhost
));
EXPECT_TRUE
(
NULL
==
conf
.
get_refer_play
(
vhost
));
EXPECT_TRUE
(
NULL
==
conf
.
get_refer_publish
(
vhost
));
EXPECT_EQ
(
60000
,
conf
.
get_chunk_size
(
vhost
));
EXPECT_TRUE
(
NULL
==
conf
.
get_forward
(
vhost
));
EXPECT_TRUE
(
NULL
==
conf
.
get_vhost_on_connect
(
vhost
));
EXPECT_TRUE
(
NULL
==
conf
.
get_vhost_on_close
(
vhost
));
EXPECT_TRUE
(
NULL
==
conf
.
get_vhost_on_publish
(
vhost
));
EXPECT_TRUE
(
NULL
==
conf
.
get_vhost_on_unpublish
(
vhost
));
EXPECT_TRUE
(
NULL
==
conf
.
get_vhost_on_play
(
vhost
));
EXPECT_TRUE
(
NULL
==
conf
.
get_vhost_on_stop
(
vhost
));
EXPECT_TRUE
(
NULL
==
conf
.
get_vhost_on_dvr_hss_reap_flv
(
vhost
));
EXPECT_FALSE
(
conf
.
get_bw_check_enabled
(
vhost
));
EXPECT_TRUE
(
conf
.
get_bw_check_key
(
vhost
).
empty
());
EXPECT_EQ
(
30000
,
conf
.
get_bw_check_interval_ms
(
vhost
));
EXPECT_EQ
(
1000
,
conf
.
get_bw_check_limit_kbps
(
vhost
));
EXPECT_FALSE
(
conf
.
get_vhost_is_edge
(
vhost
));
EXPECT_FALSE
(
conf
.
get_vhost_is_edge
(
conf
.
get_vhost
(
vhost
)));
EXPECT_TRUE
(
NULL
==
conf
.
get_vhost_edge_origin
(
vhost
));
EXPECT_FALSE
(
conf
.
get_vhost_edge_token_traverse
(
vhost
));
EXPECT_TRUE
(
NULL
==
conf
.
get_transcode
(
vhost
,
""
));
EXPECT_FALSE
(
conf
.
get_transcode_enabled
(
NULL
));
EXPECT_TRUE
(
conf
.
get_transcode_ffmpeg
(
NULL
).
empty
());
EXPECT_TRUE
(
conf
.
get_transcode_engines
(
NULL
).
size
()
==
0
);
EXPECT_FALSE
(
conf
.
get_engine_enabled
(
NULL
));
EXPECT_STREQ
(
"flv"
,
conf
.
get_engine_iformat
(
NULL
).
c_str
());
EXPECT_TRUE
(
conf
.
get_engine_vfilter
(
NULL
).
size
()
==
0
);
EXPECT_TRUE
(
conf
.
get_engine_vcodec
(
NULL
).
empty
());
EXPECT_TRUE
(
conf
.
get_engine_vbitrate
(
NULL
)
==
0
);
EXPECT_TRUE
(
conf
.
get_engine_vfps
(
NULL
)
==
0
);
EXPECT_TRUE
(
conf
.
get_engine_vwidth
(
NULL
)
==
0
);
EXPECT_TRUE
(
conf
.
get_engine_vheight
(
NULL
)
==
0
);
EXPECT_TRUE
(
conf
.
get_engine_vthreads
(
NULL
)
==
0
);
EXPECT_TRUE
(
conf
.
get_engine_vprofile
(
NULL
).
empty
());
EXPECT_TRUE
(
conf
.
get_engine_vpreset
(
NULL
).
empty
());
EXPECT_TRUE
(
conf
.
get_engine_vparams
(
NULL
).
size
()
==
0
);
EXPECT_TRUE
(
conf
.
get_engine_acodec
(
NULL
).
empty
());
EXPECT_TRUE
(
conf
.
get_engine_abitrate
(
NULL
)
==
0
);
EXPECT_TRUE
(
conf
.
get_engine_asample_rate
(
NULL
)
==
0
);
EXPECT_TRUE
(
conf
.
get_engine_achannels
(
NULL
)
==
0
);
EXPECT_TRUE
(
conf
.
get_engine_aparams
(
NULL
).
size
()
==
0
);
EXPECT_STREQ
(
"flv"
,
conf
.
get_engine_oformat
(
NULL
).
c_str
());
EXPECT_TRUE
(
conf
.
get_engine_output
(
NULL
).
empty
());
EXPECT_TRUE
(
conf
.
get_ingesters
(
vhost
).
size
()
==
0
);
EXPECT_TRUE
(
NULL
==
conf
.
get_ingest_by_id
(
vhost
,
""
));
EXPECT_FALSE
(
conf
.
get_ingest_enabled
(
NULL
));
EXPECT_TRUE
(
conf
.
get_ingest_ffmpeg
(
NULL
).
empty
());
EXPECT_STREQ
(
"file"
,
conf
.
get_ingest_input_type
(
NULL
).
c_str
());
EXPECT_TRUE
(
conf
.
get_ingest_input_url
(
NULL
).
empty
());
EXPECT_FALSE
(
conf
.
get_hls_enabled
(
vhost
));
EXPECT_STREQ
(
"./objs/nginx/html"
,
conf
.
get_hls_path
(
vhost
).
c_str
());
EXPECT_EQ
(
10
,
conf
.
get_hls_fragment
(
vhost
));
EXPECT_EQ
(
60
,
conf
.
get_hls_window
(
vhost
));
EXPECT_FALSE
(
conf
.
get_dvr_enabled
(
vhost
));
EXPECT_STREQ
(
"./objs/nginx/html"
,
conf
.
get_dvr_path
(
vhost
).
c_str
());
EXPECT_STREQ
(
"session"
,
conf
.
get_dvr_plan
(
vhost
).
c_str
());
EXPECT_EQ
(
30
,
conf
.
get_dvr_duration
(
vhost
));
EXPECT_TRUE
(
SrsRtmpJitterAlgorithmFULL
==
conf
.
get_dvr_time_jitter
(
vhost
));
}
...
...
请
注册
或
登录
后发表评论