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
2015-07-06 11:11:59 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f39faa78bb48b58e90cfa38eed27ad84655d988c
f39faa78
1 parent
3b8daafc
refine config default values of srs, prepare to move each default values to functions.
显示空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
144 行增加
和
99 行删除
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_dvr.cpp
trunk/src/app/srs_app_ingest.cpp
trunk/src/app/srs_app_source.cpp
trunk/src/app/srs_app_config.cpp
查看文件 @
f39faa7
...
...
@@ -55,11 +55,98 @@ using namespace _srs_internal;
#define SRS_CONF_PERFER_FALSE(conf_arg) conf_arg == "on"
#define SRS_CONF_PERFER_TRUE(conf_arg) conf_arg != "off"
///////////////////////////////////////////////////////////
// default consts values
///////////////////////////////////////////////////////////
#define SRS_CONF_DEFAULT_PID_FILE "./objs/srs.pid"
#define SRS_CONF_DEFAULT_LOG_FILE "./objs/srs.log"
#define SRS_CONF_DEFAULT_LOG_LEVEL "trace"
#define SRS_CONF_DEFAULT_LOG_TANK_CONSOLE "console"
#define SRS_CONF_DEFAULT_COFNIG_FILE "conf/srs.conf"
#define SRS_CONF_DEFAULT_FF_LOG_DIR "./objs"
#define SRS_CONF_DEFAULT_UTC_TIME false
#define SRS_CONF_DEFAULT_MAX_CONNECTIONS 1000
#define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html"
#define SRS_CONF_DEFAULT_HLS_M3U8_FILE "[app]/[stream].m3u8"
#define SRS_CONF_DEFAULT_HLS_TS_FILE "[app]/[stream]-[seq].ts"
#define SRS_CONF_DEFAULT_HLS_TS_FLOOR false
#define SRS_CONF_DEFAULT_HLS_FRAGMENT 10
#define SRS_CONF_DEFAULT_HLS_TD_RATIO 1.5
#define SRS_CONF_DEFAULT_HLS_AOF_RATIO 2.0
#define SRS_CONF_DEFAULT_HLS_WINDOW 60
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE "ignore"
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_DISCONNECT "disconnect"
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE "continue"
#define SRS_CONF_DEFAULT_HLS_ON_ERROR SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE
#define SRS_CONF_DEFAULT_HLS_STORAGE "disk"
#define SRS_CONF_DEFAULT_HLS_MOUNT "[vhost]/[app]/[stream].m3u8"
#define SRS_CONF_DEFAULT_HLS_ACODEC "aac"
#define SRS_CONF_DEFAULT_HLS_VCODEC "h264"
#define SRS_CONF_DEFAULT_HLS_CLEANUP true
#define SRS_CONF_DEFAULT_HLS_WAIT_KEYFRAME true
#define SRS_CONF_DEFAULT_HLS_NB_NOTIFY 64
#define SRS_CONF_DEFAULT_DVR_PATH "./objs/nginx/html/[app]/[stream].[timestamp].flv"
#define SRS_CONF_DEFAULT_DVR_PLAN_SESSION "session"
#define SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT "segment"
#define SRS_CONF_DEFAULT_DVR_PLAN_APPEND "append"
#define SRS_CONF_DEFAULT_DVR_PLAN SRS_CONF_DEFAULT_DVR_PLAN_SESSION
#define SRS_CONF_DEFAULT_DVR_DURATION 30
#define SRS_CONF_DEFAULT_TIME_JITTER "full"
#define SRS_CONF_DEFAULT_ATC_AUTO true
#define SRS_CONF_DEFAULT_MIX_CORRECT false
// in seconds, the paused queue length.
#define SRS_CONF_DEFAULT_PAUSED_LENGTH 10
// the interval in seconds for bandwidth check
#define SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL 30
// the interval in seconds for bandwidth check
#define SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS 1000
#define SRS_CONF_DEFAULT_HTTP_MOUNT "[vhost]/"
#define SRS_CONF_DEFAULT_HTTP_REMUX_MOUNT "[vhost]/[app]/[stream].flv"
#define SRS_CONF_DEFAULT_HTTP_DIR SRS_CONF_DEFAULT_HLS_PATH
#define SRS_CONF_DEFAULT_HTTP_AUDIO_FAST_CACHE 0
#define SRS_CONF_DEFAULT_HTTP_STREAM_PORT "8080"
#define SRS_CONF_DEFAULT_HTTP_API_PORT "1985"
#define SRS_CONF_DEFAULT_HTTP_API_CROSSDOMAIN true
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_ENABLED false
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_INTERVAL 9.9
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_URL "http://"SRS_CONSTS_LOCALHOST":8085/api/v1/servers"
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_SUMMARIES false
#define SRS_CONF_DEFAULT_SECURITY_ENABLED false
#define SRS_CONF_DEFAULT_STREAM_CASTER_ENABLED false
#define SRS_CONF_DEFAULT_STREAM_CASTER_MPEGTS_OVER_UDP "mpegts_over_udp"
#define SRS_CONF_DEFAULT_STREAM_CASTER_RTSP "rtsp"
#define SRS_CONF_DEFAULT_STREAM_CASTER_FLV "flv"
#define SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX 0
#define SRS_CONF_DEFAULT_PITHY_PRINT_MS 10000
#define SRS_CONF_DEFAULT_INGEST_TYPE_FILE "file"
#define SRS_CONF_DEFAULT_INGEST_TYPE_STREAM "stream"
#define SRS_CONF_DEFAULT_TRANSCODE_IFORMAT "flv"
#define SRS_CONF_DEFAULT_TRANSCODE_OFORMAT "flv"
#define SRS_CONF_DEFAULT_EDGE_MODE false
#define SRS_CONF_DEFAULT_EDGE_TOKEN_TRAVERSE false
#define SRS_CONF_DEFAULT_EDGE_TRANSFORM_VHOST "[vhost]"
// hds default value
#define SRS_CONF_DEFAULT_HDS_PATH "./objs/nginx/html"
#define SRS_CONF_DEFAULT_HDS_WINDOW (60)
#define SRS_CONF_DEFAULT_HDS_FRAGMENT (10)
// '\n'
#define SRS_LF (char)
0x0a
#define SRS_LF (char)
SRS_CONSTS_LF
// '\r'
#define SRS_CR (char)
0x0d
#define SRS_CR (char)
SRS_CONSTS_CR
bool
is_common_space
(
char
ch
)
{
...
...
@@ -4284,3 +4371,37 @@ bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b)
return
true
;
}
bool
srs_config_hls_is_on_error_ignore
(
string
strategy
)
{
return
strategy
==
SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE
;
}
bool
srs_config_hls_is_on_error_continue
(
string
strategy
)
{
return
strategy
==
SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE
;
}
bool
srs_config_ingest_is_file
(
string
type
)
{
return
type
==
SRS_CONF_DEFAULT_INGEST_TYPE_FILE
;
}
bool
srs_config_ingest_is_stream
(
string
type
)
{
return
type
==
SRS_CONF_DEFAULT_INGEST_TYPE_STREAM
;
}
bool
srs_config_dvr_is_plan_segment
(
string
plan
)
{
return
plan
==
SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT
;
}
bool
srs_config_dvr_is_plan_session
(
string
plan
)
{
return
plan
==
SRS_CONF_DEFAULT_DVR_PLAN_SESSION
;
}
bool
srs_config_dvr_is_plan_append
(
string
plan
)
{
return
plan
==
SRS_CONF_DEFAULT_DVR_PLAN_APPEND
;
}
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
f39faa7
...
...
@@ -34,93 +34,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_reload.hpp>
///////////////////////////////////////////////////////////
// default consts values
///////////////////////////////////////////////////////////
#define SRS_CONF_DEFAULT_PID_FILE "./objs/srs.pid"
#define SRS_CONF_DEFAULT_LOG_FILE "./objs/srs.log"
#define SRS_CONF_DEFAULT_LOG_LEVEL "trace"
#define SRS_CONF_DEFAULT_LOG_TANK_CONSOLE "console"
#define SRS_CONF_DEFAULT_COFNIG_FILE "conf/srs.conf"
#define SRS_CONF_DEFAULT_FF_LOG_DIR "./objs"
#define SRS_CONF_DEFAULT_UTC_TIME false
#define SRS_CONF_DEFAULT_MAX_CONNECTIONS 1000
#define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html"
#define SRS_CONF_DEFAULT_HLS_M3U8_FILE "[app]/[stream].m3u8"
#define SRS_CONF_DEFAULT_HLS_TS_FILE "[app]/[stream]-[seq].ts"
#define SRS_CONF_DEFAULT_HLS_TS_FLOOR false
#define SRS_CONF_DEFAULT_HLS_FRAGMENT 10
#define SRS_CONF_DEFAULT_HLS_TD_RATIO 1.5
#define SRS_CONF_DEFAULT_HLS_AOF_RATIO 2.0
#define SRS_CONF_DEFAULT_HLS_WINDOW 60
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE "ignore"
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_DISCONNECT "disconnect"
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE "continue"
#define SRS_CONF_DEFAULT_HLS_ON_ERROR SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE
#define SRS_CONF_DEFAULT_HLS_STORAGE "disk"
#define SRS_CONF_DEFAULT_HLS_MOUNT "[vhost]/[app]/[stream].m3u8"
#define SRS_CONF_DEFAULT_HLS_ACODEC "aac"
#define SRS_CONF_DEFAULT_HLS_VCODEC "h264"
#define SRS_CONF_DEFAULT_HLS_CLEANUP true
#define SRS_CONF_DEFAULT_HLS_WAIT_KEYFRAME true
#define SRS_CONF_DEFAULT_HLS_NB_NOTIFY 64
#define SRS_CONF_DEFAULT_DVR_PATH "./objs/nginx/html/[app]/[stream].[timestamp].flv"
#define SRS_CONF_DEFAULT_DVR_PLAN_SESSION "session"
#define SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT "segment"
#define SRS_CONF_DEFAULT_DVR_PLAN_APPEND "append"
#define SRS_CONF_DEFAULT_DVR_PLAN SRS_CONF_DEFAULT_DVR_PLAN_SESSION
#define SRS_CONF_DEFAULT_DVR_DURATION 30
#define SRS_CONF_DEFAULT_TIME_JITTER "full"
#define SRS_CONF_DEFAULT_ATC_AUTO true
#define SRS_CONF_DEFAULT_MIX_CORRECT false
// in seconds, the paused queue length.
#define SRS_CONF_DEFAULT_PAUSED_LENGTH 10
// the interval in seconds for bandwidth check
#define SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL 30
// the interval in seconds for bandwidth check
#define SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS 1000
#define SRS_CONF_DEFAULT_HTTP_MOUNT "[vhost]/"
#define SRS_CONF_DEFAULT_HTTP_REMUX_MOUNT "[vhost]/[app]/[stream].flv"
#define SRS_CONF_DEFAULT_HTTP_DIR SRS_CONF_DEFAULT_HLS_PATH
#define SRS_CONF_DEFAULT_HTTP_AUDIO_FAST_CACHE 0
#define SRS_CONF_DEFAULT_HTTP_STREAM_PORT "8080"
#define SRS_CONF_DEFAULT_HTTP_API_PORT "1985"
#define SRS_CONF_DEFAULT_HTTP_API_CROSSDOMAIN true
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_ENABLED false
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_INTERVAL 9.9
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_URL "http://"SRS_CONSTS_LOCALHOST":8085/api/v1/servers"
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_SUMMARIES false
#define SRS_CONF_DEFAULT_SECURITY_ENABLED false
#define SRS_CONF_DEFAULT_STREAM_CASTER_ENABLED false
#define SRS_CONF_DEFAULT_STREAM_CASTER_MPEGTS_OVER_UDP "mpegts_over_udp"
#define SRS_CONF_DEFAULT_STREAM_CASTER_RTSP "rtsp"
#define SRS_CONF_DEFAULT_STREAM_CASTER_FLV "flv"
#define SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX 0
#define SRS_CONF_DEFAULT_PITHY_PRINT_MS 10000
#define SRS_CONF_DEFAULT_INGEST_TYPE_FILE "file"
#define SRS_CONF_DEFAULT_INGEST_TYPE_STREAM "stream"
#define SRS_CONF_DEFAULT_TRANSCODE_IFORMAT "flv"
#define SRS_CONF_DEFAULT_TRANSCODE_OFORMAT "flv"
#define SRS_CONF_DEFAULT_EDGE_MODE false
#define SRS_CONF_DEFAULT_EDGE_TOKEN_TRAVERSE false
#define SRS_CONF_DEFAULT_EDGE_TRANSFORM_VHOST "[vhost]"
// hds default value
#define SRS_CONF_DEFAULT_HDS_PATH "./objs/nginx/html"
#define SRS_CONF_DEFAULT_HDS_WINDOW (60)
#define SRS_CONF_DEFAULT_HDS_FRAGMENT (10)
namespace
_srs_internal
{
class
SrsConfigBuffer
;
...
...
@@ -1218,7 +1131,18 @@ namespace _srs_internal
/**
* deep compare directive.
*/
bool
srs_directive_equals
(
SrsConfDirective
*
a
,
SrsConfDirective
*
b
);
extern
bool
srs_directive_equals
(
SrsConfDirective
*
a
,
SrsConfDirective
*
b
);
/**
* helper utilities, used for compare the consts values.
*/
extern
bool
srs_config_hls_is_on_error_ignore
(
std
::
string
strategy
);
extern
bool
srs_config_hls_is_on_error_continue
(
std
::
string
strategy
);
extern
bool
srs_config_ingest_is_file
(
std
::
string
type
);
extern
bool
srs_config_ingest_is_stream
(
std
::
string
type
);
extern
bool
srs_config_dvr_is_plan_segment
(
std
::
string
plan
);
extern
bool
srs_config_dvr_is_plan_session
(
std
::
string
plan
);
extern
bool
srs_config_dvr_is_plan_append
(
std
::
string
plan
);
// global config
extern
SrsConfig
*
_srs_config
;
...
...
trunk/src/app/srs_app_dvr.cpp
查看文件 @
f39faa7
...
...
@@ -639,11 +639,11 @@ int SrsDvrPlan::on_reap_segment()
SrsDvrPlan
*
SrsDvrPlan
::
create_plan
(
string
vhost
)
{
std
::
string
plan
=
_srs_config
->
get_dvr_plan
(
vhost
);
if
(
plan
==
SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT
)
{
if
(
srs_config_dvr_is_plan_segment
(
plan
)
)
{
return
new
SrsDvrSegmentPlan
();
}
else
if
(
plan
==
SRS_CONF_DEFAULT_DVR_PLAN_SESSION
)
{
}
else
if
(
srs_config_dvr_is_plan_session
(
plan
)
)
{
return
new
SrsDvrSessionPlan
();
}
else
if
(
plan
==
SRS_CONF_DEFAULT_DVR_PLAN_APPEND
)
{
}
else
if
(
srs_config_dvr_is_plan_append
(
plan
)
)
{
return
new
SrsDvrAppendPlan
();
}
else
{
srs_error
(
"invalid dvr plan=%s, vhost=%s"
,
plan
.
c_str
(),
vhost
.
c_str
());
...
...
trunk/src/app/srs_app_ingest.cpp
查看文件 @
f39faa7
...
...
@@ -369,7 +369,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S
return
ret
;
}
if
(
input_type
==
SRS_CONF_DEFAULT_INGEST_TYPE_FILE
)
{
if
(
srs_config_ingest_is_file
(
input_type
)
)
{
std
::
string
input_url
=
_srs_config
->
get_ingest_input_url
(
ingest
);
if
(
input_url
.
empty
())
{
ret
=
ERROR_ENCODER_NO_INPUT
;
...
...
@@ -383,7 +383,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S
if
((
ret
=
ffmpeg
->
initialize
(
input_url
,
output
,
log_file
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
}
else
if
(
input_type
==
SRS_CONF_DEFAULT_INGEST_TYPE_STREAM
)
{
}
else
if
(
srs_config_ingest_is_stream
(
input_type
)
)
{
std
::
string
input_url
=
_srs_config
->
get_ingest_input_url
(
ingest
);
if
(
input_url
.
empty
())
{
ret
=
ERROR_ENCODER_NO_INPUT
;
...
...
trunk/src/app/srs_app_source.cpp
查看文件 @
f39faa7
...
...
@@ -1522,7 +1522,7 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg)
// apply the error strategy for hls.
// @see https://github.com/simple-rtmp-server/srs/issues/264
std
::
string
hls_error_strategy
=
_srs_config
->
get_hls_on_error
(
_req
->
vhost
);
if
(
hls_error_strategy
==
SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE
)
{
if
(
srs_config_hls_is_on_error_ignore
(
hls_error_strategy
)
)
{
srs_warn
(
"hls process audio message failed, ignore and disable hls. ret=%d"
,
ret
);
// unpublish, ignore ret.
...
...
@@ -1530,7 +1530,7 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg)
// ignore.
ret
=
ERROR_SUCCESS
;
}
else
if
(
hls_error_strategy
==
SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE
)
{
}
else
if
(
srs_config_hls_is_on_error_continue
(
hls_error_strategy
)
)
{
// compare the sequence header with audio, continue when it's actually an sequence header.
if
(
ret
==
ERROR_HLS_DECODE_ERROR
&&
cache_sh_audio
&&
cache_sh_audio
->
size
==
msg
->
size
)
{
srs_warn
(
"the audio is actually a sequence header, ignore this packet."
);
...
...
@@ -1726,7 +1726,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg)
// apply the error strategy for hls.
// @see https://github.com/simple-rtmp-server/srs/issues/264
std
::
string
hls_error_strategy
=
_srs_config
->
get_hls_on_error
(
_req
->
vhost
);
if
(
hls_error_strategy
==
SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE
)
{
if
(
srs_config_hls_is_on_error_ignore
(
hls_error_strategy
)
)
{
srs_warn
(
"hls process video message failed, ignore and disable hls. ret=%d"
,
ret
);
// unpublish, ignore ret.
...
...
@@ -1734,7 +1734,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg)
// ignore.
ret
=
ERROR_SUCCESS
;
}
else
if
(
hls_error_strategy
==
SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE
)
{
}
else
if
(
srs_config_hls_is_on_error_continue
(
hls_error_strategy
)
)
{
// compare the sequence header with video, continue when it's actually an sequence header.
if
(
ret
==
ERROR_HLS_DECODE_ERROR
&&
cache_sh_video
&&
cache_sh_video
->
size
==
msg
->
size
)
{
srs_warn
(
"the video is actually a sequence header, ignore this packet."
);
...
...
请
注册
或
登录
后发表评论