winlin

refine the log, move default to each functions.

@@ -58,86 +58,8 @@ using namespace _srs_internal; @@ -58,86 +58,8 @@ using namespace _srs_internal;
58 #define SRS_CONF_PERFER_FALSE(conf_arg) conf_arg == "on" 58 #define SRS_CONF_PERFER_FALSE(conf_arg) conf_arg == "on"
59 #define SRS_CONF_PERFER_TRUE(conf_arg) conf_arg != "off" 59 #define SRS_CONF_PERFER_TRUE(conf_arg) conf_arg != "off"
60 60
61 -///////////////////////////////////////////////////////////  
62 -// default consts values  
63 -///////////////////////////////////////////////////////////  
64 -#define SRS_CONF_DEFAULT_PID_FILE "./objs/srs.pid"  
65 -#define SRS_CONF_DEFAULT_LOG_FILE "./objs/srs.log"  
66 -#define SRS_CONF_DEFAULT_LOG_LEVEL "trace"  
67 -#define SRS_CONF_DEFAULT_LOG_TANK_CONSOLE "console" 61 +// default config file.
68 #define SRS_CONF_DEFAULT_COFNIG_FILE "conf/srs.conf" 62 #define SRS_CONF_DEFAULT_COFNIG_FILE "conf/srs.conf"
69 -#define SRS_CONF_DEFAULT_FF_LOG_DIR "./objs"  
70 -#define SRS_CONF_DEFAULT_UTC_TIME false  
71 -  
72 -#define SRS_CONF_DEFAULT_MAX_CONNECTIONS 1000  
73 -#define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html"  
74 -#define SRS_CONF_DEFAULT_HLS_M3U8_FILE "[app]/[stream].m3u8"  
75 -#define SRS_CONF_DEFAULT_HLS_TS_FILE "[app]/[stream]-[seq].ts"  
76 -#define SRS_CONF_DEFAULT_HLS_TS_FLOOR false  
77 -#define SRS_CONF_DEFAULT_HLS_FRAGMENT 10  
78 -#define SRS_CONF_DEFAULT_HLS_TD_RATIO 1.5  
79 -#define SRS_CONF_DEFAULT_HLS_AOF_RATIO 2.0  
80 -#define SRS_CONF_DEFAULT_HLS_WINDOW 60  
81 -#define SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE "ignore"  
82 -#define SRS_CONF_DEFAULT_HLS_ON_ERROR_DISCONNECT "disconnect"  
83 -#define SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE "continue"  
84 -#define SRS_CONF_DEFAULT_HLS_ON_ERROR SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE  
85 -#define SRS_CONF_DEFAULT_HLS_STORAGE "disk"  
86 -#define SRS_CONF_DEFAULT_HLS_MOUNT "[vhost]/[app]/[stream].m3u8"  
87 -#define SRS_CONF_DEFAULT_HLS_ACODEC "aac"  
88 -#define SRS_CONF_DEFAULT_HLS_VCODEC "h264"  
89 -#define SRS_CONF_DEFAULT_HLS_CLEANUP true  
90 -#define SRS_CONF_DEFAULT_HLS_WAIT_KEYFRAME true  
91 -#define SRS_CONF_DEFAULT_HLS_NB_NOTIFY 64  
92 -#define SRS_CONF_DEFAULT_DVR_PATH "./objs/nginx/html/[app]/[stream].[timestamp].flv"  
93 -#define SRS_CONF_DEFAULT_DVR_PLAN_SESSION "session"  
94 -#define SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT "segment"  
95 -#define SRS_CONF_DEFAULT_DVR_PLAN_APPEND "append"  
96 -#define SRS_CONF_DEFAULT_DVR_PLAN SRS_CONF_DEFAULT_DVR_PLAN_SESSION  
97 -#define SRS_CONF_DEFAULT_DVR_DURATION 30  
98 -#define SRS_CONF_DEFAULT_TIME_JITTER "full"  
99 -#define SRS_CONF_DEFAULT_ATC_AUTO true  
100 -#define SRS_CONF_DEFAULT_MIX_CORRECT false  
101 -// in seconds, the paused queue length.  
102 -#define SRS_CONF_DEFAULT_PAUSED_LENGTH 10  
103 -// the interval in seconds for bandwidth check  
104 -#define SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL 30  
105 -// the interval in seconds for bandwidth check  
106 -#define SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS 1000  
107 -  
108 -#define SRS_CONF_DEFAULT_HTTP_REMUX_MOUNT "[vhost]/[app]/[stream].flv"  
109 -#define SRS_CONF_DEFAULT_HTTP_DIR SRS_CONF_DEFAULT_HLS_PATH  
110 -#define SRS_CONF_DEFAULT_HTTP_AUDIO_FAST_CACHE 0  
111 -  
112 -#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_ENABLED false  
113 -#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_INTERVAL 9.9  
114 -#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_URL "http://"SRS_CONSTS_LOCALHOST":8085/api/v1/servers"  
115 -#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_SUMMARIES false  
116 -  
117 -#define SRS_CONF_DEFAULT_SECURITY_ENABLED false  
118 -  
119 -#define SRS_CONF_DEFAULT_STREAM_CASTER_ENABLED false  
120 -#define SRS_CONF_DEFAULT_STREAM_CASTER_MPEGTS_OVER_UDP "mpegts_over_udp"  
121 -#define SRS_CONF_DEFAULT_STREAM_CASTER_RTSP "rtsp"  
122 -#define SRS_CONF_DEFAULT_STREAM_CASTER_FLV "flv"  
123 -  
124 -#define SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX 0  
125 -  
126 -#define SRS_CONF_DEFAULT_PITHY_PRINT_MS 10000  
127 -  
128 -#define SRS_CONF_DEFAULT_INGEST_TYPE_FILE "file"  
129 -#define SRS_CONF_DEFAULT_INGEST_TYPE_STREAM "stream"  
130 -  
131 -#define SRS_CONF_DEFAULT_TRANSCODE_IFORMAT "flv"  
132 -#define SRS_CONF_DEFAULT_TRANSCODE_OFORMAT "flv"  
133 -  
134 -#define SRS_CONF_DEFAULT_EDGE_TOKEN_TRAVERSE false  
135 -#define SRS_CONF_DEFAULT_EDGE_TRANSFORM_VHOST "[vhost]"  
136 -  
137 -// hds default value  
138 -#define SRS_CONF_DEFAULT_HDS_PATH "./objs/nginx/html"  
139 -#define SRS_CONF_DEFAULT_HDS_WINDOW (60)  
140 -#define SRS_CONF_DEFAULT_HDS_FRAGMENT (10)  
141 63
142 // '\n' 64 // '\n'
143 #define SRS_LF (char)SRS_CONSTS_LF 65 #define SRS_LF (char)SRS_CONSTS_LF
@@ -3067,8 +2989,6 @@ string SrsConfig::argv() @@ -3067,8 +2989,6 @@ string SrsConfig::argv()
3067 2989
3068 bool SrsConfig::get_deamon() 2990 bool SrsConfig::get_deamon()
3069 { 2991 {
3070 - srs_assert(root);  
3071 -  
3072 SrsConfDirective* conf = root->get("daemon"); 2992 SrsConfDirective* conf = root->get("daemon");
3073 if (!conf || conf->arg0().empty()) { 2993 if (!conf || conf->arg0().empty()) {
3074 return true; 2994 return true;
@@ -3084,11 +3004,11 @@ SrsConfDirective* SrsConfig::get_root() @@ -3084,11 +3004,11 @@ SrsConfDirective* SrsConfig::get_root()
3084 3004
3085 int SrsConfig::get_max_connections() 3005 int SrsConfig::get_max_connections()
3086 { 3006 {
3087 - srs_assert(root); 3007 + static int DEFAULT = 1000;
3088 3008
3089 SrsConfDirective* conf = root->get("max_connections"); 3009 SrsConfDirective* conf = root->get("max_connections");
3090 if (!conf || conf->arg0().empty()) { 3010 if (!conf || conf->arg0().empty()) {
3091 - return SRS_CONF_DEFAULT_MAX_CONNECTIONS; 3011 + return DEFAULT;
3092 } 3012 }
3093 3013
3094 return ::atoi(conf->arg0().c_str()); 3014 return ::atoi(conf->arg0().c_str());
@@ -3112,10 +3032,12 @@ vector<string> SrsConfig::get_listens() @@ -3112,10 +3032,12 @@ vector<string> SrsConfig::get_listens()
3112 3032
3113 string SrsConfig::get_pid_file() 3033 string SrsConfig::get_pid_file()
3114 { 3034 {
  3035 + static string DEFAULT = "./objs/srs.pid";
  3036 +
3115 SrsConfDirective* conf = root->get("pid"); 3037 SrsConfDirective* conf = root->get("pid");
3116 3038
3117 - if (!conf) {  
3118 - return SRS_CONF_DEFAULT_PID_FILE; 3039 + if (!conf || conf->arg0().empty()) {
  3040 + return DEFAULT;
3119 } 3041 }
3120 3042
3121 return conf->arg0(); 3043 return conf->arg0();
@@ -3123,19 +3045,23 @@ string SrsConfig::get_pid_file() @@ -3123,19 +3045,23 @@ string SrsConfig::get_pid_file()
3123 3045
3124 int SrsConfig::get_pithy_print_ms() 3046 int SrsConfig::get_pithy_print_ms()
3125 { 3047 {
3126 - SrsConfDirective* pithy = root->get("pithy_print_ms");  
3127 - if (!pithy || pithy->arg0().empty()) {  
3128 - return SRS_CONF_DEFAULT_PITHY_PRINT_MS; 3048 + static int DEFAULT = 10000;
  3049 +
  3050 + SrsConfDirective* conf = root->get("pithy_print_ms");
  3051 + if (!conf || conf->arg0().empty()) {
  3052 + return DEFAULT;
3129 } 3053 }
3130 3054
3131 - return ::atoi(pithy->arg0().c_str()); 3055 + return ::atoi(conf->arg0().c_str());
3132 } 3056 }
3133 3057
3134 bool SrsConfig::get_utc_time() 3058 bool SrsConfig::get_utc_time()
3135 { 3059 {
  3060 + static bool DEFAULT = false;
  3061 +
3136 SrsConfDirective* conf = root->get("utc_time"); 3062 SrsConfDirective* conf = root->get("utc_time");
3137 if (!conf || conf->arg0().empty()) { 3063 if (!conf || conf->arg0().empty()) {
3138 - return SRS_CONF_DEFAULT_UTC_TIME; 3064 + return DEFAULT;
3139 } 3065 }
3140 3066
3141 return SRS_CONF_PERFER_FALSE(conf->arg0()); 3067 return SRS_CONF_PERFER_FALSE(conf->arg0());
@@ -3160,75 +3086,99 @@ vector<SrsConfDirective*> SrsConfig::get_stream_casters() @@ -3160,75 +3086,99 @@ vector<SrsConfDirective*> SrsConfig::get_stream_casters()
3160 return stream_casters; 3086 return stream_casters;
3161 } 3087 }
3162 3088
3163 -bool SrsConfig::get_stream_caster_enabled(SrsConfDirective* sc) 3089 +bool SrsConfig::get_stream_caster_enabled(SrsConfDirective* conf)
3164 { 3090 {
3165 - srs_assert(sc);  
3166 -  
3167 - SrsConfDirective* conf = sc->get("enabled"); 3091 + static bool DEFAULT = false;
  3092 +
  3093 + if (!conf) {
  3094 + return DEFAULT;
  3095 + }
  3096 +
  3097 + conf = conf->get("enabled");
3168 if (!conf || conf->arg0().empty()) { 3098 if (!conf || conf->arg0().empty()) {
3169 - return SRS_CONF_DEFAULT_STREAM_CASTER_ENABLED; 3099 + return DEFAULT;
3170 } 3100 }
3171 3101
3172 return SRS_CONF_PERFER_FALSE(conf->arg0()); 3102 return SRS_CONF_PERFER_FALSE(conf->arg0());
3173 } 3103 }
3174 3104
3175 -string SrsConfig::get_stream_caster_engine(SrsConfDirective* sc) 3105 +string SrsConfig::get_stream_caster_engine(SrsConfDirective* conf)
3176 { 3106 {
3177 - srs_assert(sc); 3107 + static string DEFAULT = "";
  3108 +
  3109 + if (!conf) {
  3110 + return DEFAULT;
  3111 + }
3178 3112
3179 - SrsConfDirective* conf = sc->get("caster"); 3113 + conf = conf->get("caster");
3180 if (!conf || conf->arg0().empty()) { 3114 if (!conf || conf->arg0().empty()) {
3181 - return ""; 3115 + return DEFAULT;
3182 } 3116 }
3183 3117
3184 return conf->arg0(); 3118 return conf->arg0();
3185 } 3119 }
3186 3120
3187 -string SrsConfig::get_stream_caster_output(SrsConfDirective* sc) 3121 +string SrsConfig::get_stream_caster_output(SrsConfDirective* conf)
3188 { 3122 {
3189 - srs_assert(sc);  
3190 -  
3191 - SrsConfDirective* conf = sc->get("output"); 3123 + static string DEFAULT = "";
  3124 +
  3125 + if (!conf) {
  3126 + return DEFAULT;
  3127 + }
  3128 +
  3129 + conf = conf->get("output");
3192 if (!conf || conf->arg0().empty()) { 3130 if (!conf || conf->arg0().empty()) {
3193 - return ""; 3131 + return DEFAULT;
3194 } 3132 }
3195 - 3133 +
3196 return conf->arg0(); 3134 return conf->arg0();
3197 } 3135 }
3198 3136
3199 -int SrsConfig::get_stream_caster_listen(SrsConfDirective* sc) 3137 +int SrsConfig::get_stream_caster_listen(SrsConfDirective* conf)
3200 { 3138 {
3201 - srs_assert(sc); 3139 + static int DEFAULT = 0;
  3140 +
  3141 + if (!conf) {
  3142 + return DEFAULT;
  3143 + }
3202 3144
3203 - SrsConfDirective* conf = sc->get("listen"); 3145 + conf = conf->get("listen");
3204 if (!conf || conf->arg0().empty()) { 3146 if (!conf || conf->arg0().empty()) {
3205 - return 0; 3147 + return DEFAULT;
3206 } 3148 }
3207 3149
3208 return ::atoi(conf->arg0().c_str()); 3150 return ::atoi(conf->arg0().c_str());
3209 } 3151 }
3210 3152
3211 -int SrsConfig::get_stream_caster_rtp_port_min(SrsConfDirective* sc) 3153 +int SrsConfig::get_stream_caster_rtp_port_min(SrsConfDirective* conf)
3212 { 3154 {
3213 - srs_assert(sc);  
3214 -  
3215 - SrsConfDirective* conf = sc->get("rtp_port_min"); 3155 + static int DEFAULT = 0;
  3156 +
  3157 + if (!conf) {
  3158 + return DEFAULT;
  3159 + }
  3160 +
  3161 + conf = conf->get("rtp_port_min");
3216 if (!conf || conf->arg0().empty()) { 3162 if (!conf || conf->arg0().empty()) {
3217 - return 0; 3163 + return DEFAULT;
3218 } 3164 }
3219 - 3165 +
3220 return ::atoi(conf->arg0().c_str()); 3166 return ::atoi(conf->arg0().c_str());
3221 } 3167 }
3222 3168
3223 -int SrsConfig::get_stream_caster_rtp_port_max(SrsConfDirective* sc) 3169 +int SrsConfig::get_stream_caster_rtp_port_max(SrsConfDirective* conf)
3224 { 3170 {
3225 - srs_assert(sc);  
3226 -  
3227 - SrsConfDirective* conf = sc->get("rtp_port_max"); 3171 + static int DEFAULT = 0;
  3172 +
  3173 + if (!conf) {
  3174 + return DEFAULT;
  3175 + }
  3176 +
  3177 + conf = conf->get("rtp_port_max");
3228 if (!conf || conf->arg0().empty()) { 3178 if (!conf || conf->arg0().empty()) {
3229 - return 0; 3179 + return DEFAULT;
3230 } 3180 }
3231 - 3181 +
3232 return ::atoi(conf->arg0().c_str()); 3182 return ::atoi(conf->arg0().c_str());
3233 } 3183 }
3234 3184
@@ -3272,20 +3222,24 @@ void SrsConfig::get_vhosts(vector<SrsConfDirective*>& vhosts) @@ -3272,20 +3222,24 @@ void SrsConfig::get_vhosts(vector<SrsConfDirective*>& vhosts)
3272 3222
3273 bool SrsConfig::get_vhost_enabled(string vhost) 3223 bool SrsConfig::get_vhost_enabled(string vhost)
3274 { 3224 {
3275 - SrsConfDirective* vhost_conf = get_vhost(vhost); 3225 + SrsConfDirective* conf = get_vhost(vhost);
3276 3226
3277 - return get_vhost_enabled(vhost_conf); 3227 + return get_vhost_enabled(conf);
3278 } 3228 }
3279 3229
3280 -bool SrsConfig::get_vhost_enabled(SrsConfDirective* vhost) 3230 +bool SrsConfig::get_vhost_enabled(SrsConfDirective* conf)
3281 { 3231 {
3282 - if (!vhost) { 3232 + static bool DEFAULT = true;
  3233 +
  3234 + // false for NULL vhost.
  3235 + if (!conf) {
3283 return false; 3236 return false;
3284 } 3237 }
3285 3238
3286 - SrsConfDirective* conf = vhost->get("enabled"); 3239 + // perfer true for exists one.
  3240 + conf = conf->get("enabled");
3287 if (!conf || conf->arg0().empty()) { 3241 if (!conf || conf->arg0().empty()) {
3288 - return true; 3242 + return DEFAULT;
3289 } 3243 }
3290 3244
3291 return SRS_CONF_PERFER_TRUE(conf->arg0()); 3245 return SRS_CONF_PERFER_TRUE(conf->arg0());
@@ -3294,7 +3248,6 @@ bool SrsConfig::get_vhost_enabled(SrsConfDirective* vhost) @@ -3294,7 +3248,6 @@ bool SrsConfig::get_vhost_enabled(SrsConfDirective* vhost)
3294 bool SrsConfig::get_gop_cache(string vhost) 3248 bool SrsConfig::get_gop_cache(string vhost)
3295 { 3249 {
3296 SrsConfDirective* conf = get_vhost(vhost); 3250 SrsConfDirective* conf = get_vhost(vhost);
3297 -  
3298 if (!conf) { 3251 if (!conf) {
3299 return SRS_PERF_GOP_CACHE; 3252 return SRS_PERF_GOP_CACHE;
3300 } 3253 }
@@ -3309,15 +3262,16 @@ bool SrsConfig::get_gop_cache(string vhost) @@ -3309,15 +3262,16 @@ bool SrsConfig::get_gop_cache(string vhost)
3309 3262
3310 bool SrsConfig::get_debug_srs_upnode(string vhost) 3263 bool SrsConfig::get_debug_srs_upnode(string vhost)
3311 { 3264 {
  3265 + static bool DEFAULT = true;
  3266 +
3312 SrsConfDirective* conf = get_vhost(vhost); 3267 SrsConfDirective* conf = get_vhost(vhost);
3313 -  
3314 if (!conf) { 3268 if (!conf) {
3315 - return true; 3269 + return DEFAULT;
3316 } 3270 }
3317 3271
3318 conf = conf->get("debug_srs_upnode"); 3272 conf = conf->get("debug_srs_upnode");
3319 if (!conf || conf->arg0().empty()) { 3273 if (!conf || conf->arg0().empty()) {
3320 - return true; 3274 + return DEFAULT;
3321 } 3275 }
3322 3276
3323 return SRS_CONF_PERFER_TRUE(conf->arg0()); 3277 return SRS_CONF_PERFER_TRUE(conf->arg0());
@@ -3325,15 +3279,16 @@ bool SrsConfig::get_debug_srs_upnode(string vhost) @@ -3325,15 +3279,16 @@ bool SrsConfig::get_debug_srs_upnode(string vhost)
3325 3279
3326 bool SrsConfig::get_atc(string vhost) 3280 bool SrsConfig::get_atc(string vhost)
3327 { 3281 {
  3282 + static bool DEFAULT = false;
  3283 +
3328 SrsConfDirective* conf = get_vhost(vhost); 3284 SrsConfDirective* conf = get_vhost(vhost);
3329 -  
3330 if (!conf) { 3285 if (!conf) {
3331 - return false; 3286 + return DEFAULT;
3332 } 3287 }
3333 3288
3334 conf = conf->get("atc"); 3289 conf = conf->get("atc");
3335 if (!conf || conf->arg0().empty()) { 3290 if (!conf || conf->arg0().empty()) {
3336 - return false; 3291 + return DEFAULT;
3337 } 3292 }
3338 3293
3339 return SRS_CONF_PERFER_FALSE(conf->arg0()); 3294 return SRS_CONF_PERFER_FALSE(conf->arg0());
@@ -3341,48 +3296,50 @@ bool SrsConfig::get_atc(string vhost) @@ -3341,48 +3296,50 @@ bool SrsConfig::get_atc(string vhost)
3341 3296
3342 bool SrsConfig::get_atc_auto(string vhost) 3297 bool SrsConfig::get_atc_auto(string vhost)
3343 { 3298 {
  3299 + static bool DEFAULT = false;
  3300 +
3344 SrsConfDirective* conf = get_vhost(vhost); 3301 SrsConfDirective* conf = get_vhost(vhost);
3345 -  
3346 if (!conf) { 3302 if (!conf) {
3347 - return SRS_CONF_DEFAULT_ATC_AUTO; 3303 + return DEFAULT;
3348 } 3304 }
3349 3305
3350 conf = conf->get("atc_auto"); 3306 conf = conf->get("atc_auto");
3351 if (!conf || conf->arg0().empty()) { 3307 if (!conf || conf->arg0().empty()) {
3352 - return SRS_CONF_DEFAULT_ATC_AUTO; 3308 + return DEFAULT;
3353 } 3309 }
3354 3310
3355 - return SRS_CONF_PERFER_TRUE(conf->arg0()); 3311 + return SRS_CONF_PERFER_FALSE(conf->arg0());
3356 } 3312 }
3357 3313
3358 int SrsConfig::get_time_jitter(string vhost) 3314 int SrsConfig::get_time_jitter(string vhost)
3359 { 3315 {
3360 - SrsConfDirective* conf = get_vhost(vhost);  
3361 -  
3362 - std::string time_jitter = SRS_CONF_DEFAULT_TIME_JITTER; 3316 + static string DEFAULT = "full";
3363 3317
3364 - if (conf) {  
3365 - conf = conf->get("time_jitter"); 3318 + SrsConfDirective* conf = get_vhost(vhost);
  3319 + if (!conf) {
  3320 + return _srs_time_jitter_string2int(DEFAULT);
  3321 + }
3366 3322
3367 - if (conf && !conf->arg0().empty()) {  
3368 - time_jitter = conf->arg0();  
3369 - } 3323 + conf = conf->get("time_jitter");
  3324 + if (!conf || conf->arg0().empty()) {
  3325 + return _srs_time_jitter_string2int(DEFAULT);
3370 } 3326 }
3371 3327
3372 - return _srs_time_jitter_string2int(time_jitter); 3328 + return _srs_time_jitter_string2int(conf->arg0());
3373 } 3329 }
3374 3330
3375 bool SrsConfig::get_mix_correct(string vhost) 3331 bool SrsConfig::get_mix_correct(string vhost)
3376 { 3332 {
3377 - SrsConfDirective* conf = get_vhost(vhost); 3333 + static bool DEFAULT = false;
3378 3334
  3335 + SrsConfDirective* conf = get_vhost(vhost);
3379 if (!conf) { 3336 if (!conf) {
3380 - return SRS_CONF_DEFAULT_MIX_CORRECT; 3337 + return DEFAULT;
3381 } 3338 }
3382 3339
3383 conf = conf->get("mix_correct"); 3340 conf = conf->get("mix_correct");
3384 if (!conf || conf->arg0().empty()) { 3341 if (!conf || conf->arg0().empty()) {
3385 - return SRS_CONF_DEFAULT_MIX_CORRECT; 3342 + return DEFAULT;
3386 } 3343 }
3387 3344
3388 return SRS_CONF_PERFER_FALSE(conf->arg0()); 3345 return SRS_CONF_PERFER_FALSE(conf->arg0());
@@ -3391,7 +3348,6 @@ bool SrsConfig::get_mix_correct(string vhost) @@ -3391,7 +3348,6 @@ bool SrsConfig::get_mix_correct(string vhost)
3391 double SrsConfig::get_queue_length(string vhost) 3348 double SrsConfig::get_queue_length(string vhost)
3392 { 3349 {
3393 SrsConfDirective* conf = get_vhost(vhost); 3350 SrsConfDirective* conf = get_vhost(vhost);
3394 -  
3395 if (!conf) { 3351 if (!conf) {
3396 return SRS_PERF_PLAY_QUEUE; 3352 return SRS_PERF_PLAY_QUEUE;
3397 } 3353 }
@@ -3426,7 +3382,7 @@ bool SrsConfig::get_refer_enabled(string vhost) @@ -3426,7 +3382,7 @@ bool SrsConfig::get_refer_enabled(string vhost)
3426 return SRS_CONF_PERFER_FALSE(conf->arg0()); 3382 return SRS_CONF_PERFER_FALSE(conf->arg0());
3427 } 3383 }
3428 3384
3429 -SrsConfDirective* SrsConfig::get_refer(string vhost) 3385 +SrsConfDirective* SrsConfig::get_refer_all(string vhost)
3430 { 3386 {
3431 static SrsConfDirective* DEFAULT = NULL; 3387 static SrsConfDirective* DEFAULT = NULL;
3432 3388
@@ -3484,7 +3440,6 @@ int SrsConfig::get_chunk_size(string vhost) @@ -3484,7 +3440,6 @@ int SrsConfig::get_chunk_size(string vhost)
3484 } 3440 }
3485 3441
3486 SrsConfDirective* conf = get_vhost(vhost); 3442 SrsConfDirective* conf = get_vhost(vhost);
3487 -  
3488 if (!conf) { 3443 if (!conf) {
3489 // vhost does not specify the chunk size, 3444 // vhost does not specify the chunk size,
3490 // use the global instead. 3445 // use the global instead.
@@ -3504,7 +3459,6 @@ int SrsConfig::get_chunk_size(string vhost) @@ -3504,7 +3459,6 @@ int SrsConfig::get_chunk_size(string vhost)
3504 bool SrsConfig::get_mr_enabled(string vhost) 3459 bool SrsConfig::get_mr_enabled(string vhost)
3505 { 3460 {
3506 SrsConfDirective* conf = get_vhost(vhost); 3461 SrsConfDirective* conf = get_vhost(vhost);
3507 -  
3508 if (!conf) { 3462 if (!conf) {
3509 return SRS_PERF_MR_ENABLED; 3463 return SRS_PERF_MR_ENABLED;
3510 } 3464 }
@@ -3525,7 +3479,6 @@ bool SrsConfig::get_mr_enabled(string vhost) @@ -3525,7 +3479,6 @@ bool SrsConfig::get_mr_enabled(string vhost)
3525 int SrsConfig::get_mr_sleep_ms(string vhost) 3479 int SrsConfig::get_mr_sleep_ms(string vhost)
3526 { 3480 {
3527 SrsConfDirective* conf = get_vhost(vhost); 3481 SrsConfDirective* conf = get_vhost(vhost);
3528 -  
3529 if (!conf) { 3482 if (!conf) {
3530 return SRS_PERF_MR_SLEEP; 3483 return SRS_PERF_MR_SLEEP;
3531 } 3484 }
@@ -3546,7 +3499,6 @@ int SrsConfig::get_mr_sleep_ms(string vhost) @@ -3546,7 +3499,6 @@ int SrsConfig::get_mr_sleep_ms(string vhost)
3546 int SrsConfig::get_mw_sleep_ms(string vhost) 3499 int SrsConfig::get_mw_sleep_ms(string vhost)
3547 { 3500 {
3548 SrsConfDirective* conf = get_vhost(vhost); 3501 SrsConfDirective* conf = get_vhost(vhost);
3549 -  
3550 if (!conf) { 3502 if (!conf) {
3551 return SRS_PERF_MW_SLEEP; 3503 return SRS_PERF_MW_SLEEP;
3552 } 3504 }
@@ -3562,7 +3514,6 @@ int SrsConfig::get_mw_sleep_ms(string vhost) @@ -3562,7 +3514,6 @@ int SrsConfig::get_mw_sleep_ms(string vhost)
3562 bool SrsConfig::get_realtime_enabled(string vhost) 3514 bool SrsConfig::get_realtime_enabled(string vhost)
3563 { 3515 {
3564 SrsConfDirective* conf = get_vhost(vhost); 3516 SrsConfDirective* conf = get_vhost(vhost);
3565 -  
3566 if (!conf) { 3517 if (!conf) {
3567 return SRS_PERF_MIN_LATENCY_ENABLED; 3518 return SRS_PERF_MIN_LATENCY_ENABLED;
3568 } 3519 }
@@ -3677,7 +3628,6 @@ int SrsConfig::get_global_chunk_size() @@ -3677,7 +3628,6 @@ int SrsConfig::get_global_chunk_size()
3677 SrsConfDirective* SrsConfig::get_forward(string vhost) 3628 SrsConfDirective* SrsConfig::get_forward(string vhost)
3678 { 3629 {
3679 SrsConfDirective* conf = get_vhost(vhost); 3630 SrsConfDirective* conf = get_vhost(vhost);
3680 -  
3681 if (!conf) { 3631 if (!conf) {
3682 return NULL; 3632 return NULL;
3683 } 3633 }
@@ -3688,7 +3638,6 @@ SrsConfDirective* SrsConfig::get_forward(string vhost) @@ -3688,7 +3638,6 @@ SrsConfDirective* SrsConfig::get_forward(string vhost)
3688 SrsConfDirective* SrsConfig::get_vhost_http_hooks(string vhost) 3638 SrsConfDirective* SrsConfig::get_vhost_http_hooks(string vhost)
3689 { 3639 {
3690 SrsConfDirective* conf = get_vhost(vhost); 3640 SrsConfDirective* conf = get_vhost(vhost);
3691 -  
3692 if (!conf) { 3641 if (!conf) {
3693 return NULL; 3642 return NULL;
3694 } 3643 }
@@ -3698,15 +3647,16 @@ SrsConfDirective* SrsConfig::get_vhost_http_hooks(string vhost) @@ -3698,15 +3647,16 @@ SrsConfDirective* SrsConfig::get_vhost_http_hooks(string vhost)
3698 3647
3699 bool SrsConfig::get_vhost_http_hooks_enabled(string vhost) 3648 bool SrsConfig::get_vhost_http_hooks_enabled(string vhost)
3700 { 3649 {
3701 - SrsConfDirective* conf = get_vhost_http_hooks(vhost); 3650 + static bool DEFAULT = false;
3702 3651
  3652 + SrsConfDirective* conf = get_vhost_http_hooks(vhost);
3703 if (!conf) { 3653 if (!conf) {
3704 - return false; 3654 + return DEFAULT;
3705 } 3655 }
3706 3656
3707 conf = conf->get("enabled"); 3657 conf = conf->get("enabled");
3708 if (!conf || conf->arg0().empty()) { 3658 if (!conf || conf->arg0().empty()) {
3709 - return false; 3659 + return DEFAULT;
3710 } 3660 }
3711 3661
3712 return SRS_CONF_PERFER_FALSE(conf->arg0()); 3662 return SRS_CONF_PERFER_FALSE(conf->arg0());
@@ -3715,7 +3665,6 @@ bool SrsConfig::get_vhost_http_hooks_enabled(string vhost) @@ -3715,7 +3665,6 @@ bool SrsConfig::get_vhost_http_hooks_enabled(string vhost)
3715 SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost) 3665 SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost)
3716 { 3666 {
3717 SrsConfDirective* conf = get_vhost_http_hooks(vhost); 3667 SrsConfDirective* conf = get_vhost_http_hooks(vhost);
3718 -  
3719 if (!conf) { 3668 if (!conf) {
3720 return NULL; 3669 return NULL;
3721 } 3670 }
@@ -3726,7 +3675,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost) @@ -3726,7 +3675,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost)
3726 SrsConfDirective* SrsConfig::get_vhost_on_close(string vhost) 3675 SrsConfDirective* SrsConfig::get_vhost_on_close(string vhost)
3727 { 3676 {
3728 SrsConfDirective* conf = get_vhost_http_hooks(vhost); 3677 SrsConfDirective* conf = get_vhost_http_hooks(vhost);
3729 -  
3730 if (!conf) { 3678 if (!conf) {
3731 return NULL; 3679 return NULL;
3732 } 3680 }
@@ -3737,7 +3685,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_close(string vhost) @@ -3737,7 +3685,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_close(string vhost)
3737 SrsConfDirective* SrsConfig::get_vhost_on_publish(string vhost) 3685 SrsConfDirective* SrsConfig::get_vhost_on_publish(string vhost)
3738 { 3686 {
3739 SrsConfDirective* conf = get_vhost_http_hooks(vhost); 3687 SrsConfDirective* conf = get_vhost_http_hooks(vhost);
3740 -  
3741 if (!conf) { 3688 if (!conf) {
3742 return NULL; 3689 return NULL;
3743 } 3690 }
@@ -3748,7 +3695,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_publish(string vhost) @@ -3748,7 +3695,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_publish(string vhost)
3748 SrsConfDirective* SrsConfig::get_vhost_on_unpublish(string vhost) 3695 SrsConfDirective* SrsConfig::get_vhost_on_unpublish(string vhost)
3749 { 3696 {
3750 SrsConfDirective* conf = get_vhost_http_hooks(vhost); 3697 SrsConfDirective* conf = get_vhost_http_hooks(vhost);
3751 -  
3752 if (!conf) { 3698 if (!conf) {
3753 return NULL; 3699 return NULL;
3754 } 3700 }
@@ -3759,7 +3705,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_unpublish(string vhost) @@ -3759,7 +3705,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_unpublish(string vhost)
3759 SrsConfDirective* SrsConfig::get_vhost_on_play(string vhost) 3705 SrsConfDirective* SrsConfig::get_vhost_on_play(string vhost)
3760 { 3706 {
3761 SrsConfDirective* conf = get_vhost_http_hooks(vhost); 3707 SrsConfDirective* conf = get_vhost_http_hooks(vhost);
3762 -  
3763 if (!conf) { 3708 if (!conf) {
3764 return NULL; 3709 return NULL;
3765 } 3710 }
@@ -3770,7 +3715,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_play(string vhost) @@ -3770,7 +3715,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_play(string vhost)
3770 SrsConfDirective* SrsConfig::get_vhost_on_stop(string vhost) 3715 SrsConfDirective* SrsConfig::get_vhost_on_stop(string vhost)
3771 { 3716 {
3772 SrsConfDirective* conf = get_vhost_http_hooks(vhost); 3717 SrsConfDirective* conf = get_vhost_http_hooks(vhost);
3773 -  
3774 if (!conf) { 3718 if (!conf) {
3775 return NULL; 3719 return NULL;
3776 } 3720 }
@@ -3781,7 +3725,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_stop(string vhost) @@ -3781,7 +3725,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_stop(string vhost)
3781 SrsConfDirective* SrsConfig::get_vhost_on_dvr(string vhost) 3725 SrsConfDirective* SrsConfig::get_vhost_on_dvr(string vhost)
3782 { 3726 {
3783 SrsConfDirective* conf = get_vhost_http_hooks(vhost); 3727 SrsConfDirective* conf = get_vhost_http_hooks(vhost);
3784 -  
3785 if (!conf) { 3728 if (!conf) {
3786 return NULL; 3729 return NULL;
3787 } 3730 }
@@ -3792,7 +3735,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_dvr(string vhost) @@ -3792,7 +3735,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_dvr(string vhost)
3792 SrsConfDirective* SrsConfig::get_vhost_on_hls(string vhost) 3735 SrsConfDirective* SrsConfig::get_vhost_on_hls(string vhost)
3793 { 3736 {
3794 SrsConfDirective* conf = get_vhost_http_hooks(vhost); 3737 SrsConfDirective* conf = get_vhost_http_hooks(vhost);
3795 -  
3796 if (!conf) { 3738 if (!conf) {
3797 return NULL; 3739 return NULL;
3798 } 3740 }
@@ -3803,7 +3745,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_hls(string vhost) @@ -3803,7 +3745,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_hls(string vhost)
3803 SrsConfDirective* SrsConfig::get_vhost_on_hls_notify(string vhost) 3745 SrsConfDirective* SrsConfig::get_vhost_on_hls_notify(string vhost)
3804 { 3746 {
3805 SrsConfDirective* conf = get_vhost_http_hooks(vhost); 3747 SrsConfDirective* conf = get_vhost_http_hooks(vhost);
3806 -  
3807 if (!conf) { 3748 if (!conf) {
3808 return NULL; 3749 return NULL;
3809 } 3750 }
@@ -3813,20 +3754,21 @@ SrsConfDirective* SrsConfig::get_vhost_on_hls_notify(string vhost) @@ -3813,20 +3754,21 @@ SrsConfDirective* SrsConfig::get_vhost_on_hls_notify(string vhost)
3813 3754
3814 bool SrsConfig::get_bw_check_enabled(string vhost) 3755 bool SrsConfig::get_bw_check_enabled(string vhost)
3815 { 3756 {
  3757 + static bool DEFAULT = false;
  3758 +
3816 SrsConfDirective* conf = get_vhost(vhost); 3759 SrsConfDirective* conf = get_vhost(vhost);
3817 -  
3818 if (!conf) { 3760 if (!conf) {
3819 - return false; 3761 + return DEFAULT;
3820 } 3762 }
3821 3763
3822 conf = conf->get("bandcheck"); 3764 conf = conf->get("bandcheck");
3823 if (!conf) { 3765 if (!conf) {
3824 - return false; 3766 + return DEFAULT;
3825 } 3767 }
3826 3768
3827 conf = conf->get("enabled"); 3769 conf = conf->get("enabled");
3828 if (!conf || conf->arg0().empty()) { 3770 if (!conf || conf->arg0().empty()) {
3829 - return false; 3771 + return DEFAULT;
3830 } 3772 }
3831 3773
3832 return SRS_CONF_PERFER_FALSE(conf->arg0()); 3774 return SRS_CONF_PERFER_FALSE(conf->arg0());
@@ -3834,20 +3776,21 @@ bool SrsConfig::get_bw_check_enabled(string vhost) @@ -3834,20 +3776,21 @@ bool SrsConfig::get_bw_check_enabled(string vhost)
3834 3776
3835 string SrsConfig::get_bw_check_key(string vhost) 3777 string SrsConfig::get_bw_check_key(string vhost)
3836 { 3778 {
  3779 + static string DEFAULT = "";
  3780 +
3837 SrsConfDirective* conf = get_vhost(vhost); 3781 SrsConfDirective* conf = get_vhost(vhost);
3838 -  
3839 if (!conf) { 3782 if (!conf) {
3840 - return ""; 3783 + return DEFAULT;
3841 } 3784 }
3842 3785
3843 conf = conf->get("bandcheck"); 3786 conf = conf->get("bandcheck");
3844 if (!conf) { 3787 if (!conf) {
3845 - return ""; 3788 + return DEFAULT;
3846 } 3789 }
3847 3790
3848 conf = conf->get("key"); 3791 conf = conf->get("key");
3849 - if (!conf) {  
3850 - return ""; 3792 + if (!conf || conf->arg0().empty()) {
  3793 + return DEFAULT;
3851 } 3794 }
3852 3795
3853 return conf->arg0(); 3796 return conf->arg0();
@@ -3855,20 +3798,21 @@ string SrsConfig::get_bw_check_key(string vhost) @@ -3855,20 +3798,21 @@ string SrsConfig::get_bw_check_key(string vhost)
3855 3798
3856 int SrsConfig::get_bw_check_interval_ms(string vhost) 3799 int SrsConfig::get_bw_check_interval_ms(string vhost)
3857 { 3800 {
  3801 + static int DEFAULT = 30 * 1000;
  3802 +
3858 SrsConfDirective* conf = get_vhost(vhost); 3803 SrsConfDirective* conf = get_vhost(vhost);
3859 -  
3860 if (!conf) { 3804 if (!conf) {
3861 - return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL * 1000; 3805 + return DEFAULT;
3862 } 3806 }
3863 3807
3864 conf = conf->get("bandcheck"); 3808 conf = conf->get("bandcheck");
3865 if (!conf) { 3809 if (!conf) {
3866 - return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL * 1000; 3810 + return DEFAULT;
3867 } 3811 }
3868 3812
3869 conf = conf->get("interval"); 3813 conf = conf->get("interval");
3870 if (!conf) { 3814 if (!conf) {
3871 - return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL * 1000; 3815 + return DEFAULT;
3872 } 3816 }
3873 3817
3874 return (int)(::atof(conf->arg0().c_str()) * 1000); 3818 return (int)(::atof(conf->arg0().c_str()) * 1000);
@@ -3876,20 +3820,21 @@ int SrsConfig::get_bw_check_interval_ms(string vhost) @@ -3876,20 +3820,21 @@ int SrsConfig::get_bw_check_interval_ms(string vhost)
3876 3820
3877 int SrsConfig::get_bw_check_limit_kbps(string vhost) 3821 int SrsConfig::get_bw_check_limit_kbps(string vhost)
3878 { 3822 {
  3823 + static int DEFAULT = 1000;
  3824 +
3879 SrsConfDirective* conf = get_vhost(vhost); 3825 SrsConfDirective* conf = get_vhost(vhost);
3880 -  
3881 if (!conf) { 3826 if (!conf) {
3882 - return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS; 3827 + return DEFAULT;
3883 } 3828 }
3884 3829
3885 conf = conf->get("bandcheck"); 3830 conf = conf->get("bandcheck");
3886 if (!conf) { 3831 if (!conf) {
3887 - return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS; 3832 + return DEFAULT;
3888 } 3833 }
3889 3834
3890 conf = conf->get("limit_kbps"); 3835 conf = conf->get("limit_kbps");
3891 if (!conf) { 3836 if (!conf) {
3892 - return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS; 3837 + return DEFAULT;
3893 } 3838 }
3894 3839
3895 return ::atoi(conf->arg0().c_str()); 3840 return ::atoi(conf->arg0().c_str());
@@ -3904,8 +3849,8 @@ bool SrsConfig::get_vhost_is_edge(string vhost) @@ -3904,8 +3849,8 @@ bool SrsConfig::get_vhost_is_edge(string vhost)
3904 bool SrsConfig::get_vhost_is_edge(SrsConfDirective* vhost) 3849 bool SrsConfig::get_vhost_is_edge(SrsConfDirective* vhost)
3905 { 3850 {
3906 static bool DEFAULT = false; 3851 static bool DEFAULT = false;
  3852 +
3907 SrsConfDirective* conf = vhost; 3853 SrsConfDirective* conf = vhost;
3908 -  
3909 if (!conf) { 3854 if (!conf) {
3910 return DEFAULT; 3855 return DEFAULT;
3911 } 3856 }
@@ -3921,7 +3866,6 @@ bool SrsConfig::get_vhost_is_edge(SrsConfDirective* vhost) @@ -3921,7 +3866,6 @@ bool SrsConfig::get_vhost_is_edge(SrsConfDirective* vhost)
3921 SrsConfDirective* SrsConfig::get_vhost_edge_origin(string vhost) 3866 SrsConfDirective* SrsConfig::get_vhost_edge_origin(string vhost)
3922 { 3867 {
3923 SrsConfDirective* conf = get_vhost(vhost); 3868 SrsConfDirective* conf = get_vhost(vhost);
3924 -  
3925 if (!conf) { 3869 if (!conf) {
3926 return NULL; 3870 return NULL;
3927 } 3871 }
@@ -3931,15 +3875,16 @@ SrsConfDirective* SrsConfig::get_vhost_edge_origin(string vhost) @@ -3931,15 +3875,16 @@ SrsConfDirective* SrsConfig::get_vhost_edge_origin(string vhost)
3931 3875
3932 bool SrsConfig::get_vhost_edge_token_traverse(string vhost) 3876 bool SrsConfig::get_vhost_edge_token_traverse(string vhost)
3933 { 3877 {
3934 - SrsConfDirective* conf = get_vhost(vhost); 3878 + static bool DEFAULT = false;
3935 3879
  3880 + SrsConfDirective* conf = get_vhost(vhost);
3936 if (!conf) { 3881 if (!conf) {
3937 - return SRS_CONF_DEFAULT_EDGE_TOKEN_TRAVERSE; 3882 + return DEFAULT;
3938 } 3883 }
3939 3884
3940 conf = conf->get("token_traverse"); 3885 conf = conf->get("token_traverse");
3941 if (!conf || conf->arg0().empty()) { 3886 if (!conf || conf->arg0().empty()) {
3942 - return SRS_CONF_DEFAULT_EDGE_TOKEN_TRAVERSE; 3887 + return DEFAULT;
3943 } 3888 }
3944 3889
3945 return SRS_CONF_PERFER_FALSE(conf->arg0()); 3890 return SRS_CONF_PERFER_FALSE(conf->arg0());
@@ -3947,15 +3892,16 @@ bool SrsConfig::get_vhost_edge_token_traverse(string vhost) @@ -3947,15 +3892,16 @@ bool SrsConfig::get_vhost_edge_token_traverse(string vhost)
3947 3892
3948 string SrsConfig::get_vhost_edge_transform_vhost(string vhost) 3893 string SrsConfig::get_vhost_edge_transform_vhost(string vhost)
3949 { 3894 {
3950 - SrsConfDirective* conf = get_vhost(vhost); 3895 + static string DEFAULT = "[vhost]";
3951 3896
  3897 + SrsConfDirective* conf = get_vhost(vhost);
3952 if (!conf) { 3898 if (!conf) {
3953 - return SRS_CONF_DEFAULT_EDGE_TRANSFORM_VHOST; 3899 + return DEFAULT;
3954 } 3900 }
3955 3901
3956 conf = conf->get("vhost"); 3902 conf = conf->get("vhost");
3957 if (!conf || conf->arg0().empty()) { 3903 if (!conf || conf->arg0().empty()) {
3958 - return SRS_CONF_DEFAULT_EDGE_TRANSFORM_VHOST; 3904 + return DEFAULT;
3959 } 3905 }
3960 3906
3961 return conf->arg0(); 3907 return conf->arg0();
@@ -3963,20 +3909,21 @@ string SrsConfig::get_vhost_edge_transform_vhost(string vhost) @@ -3963,20 +3909,21 @@ string SrsConfig::get_vhost_edge_transform_vhost(string vhost)
3963 3909
3964 bool SrsConfig::get_security_enabled(string vhost) 3910 bool SrsConfig::get_security_enabled(string vhost)
3965 { 3911 {
3966 - SrsConfDirective* conf = get_vhost(vhost); 3912 + static bool DEFAULT = false;
3967 3913
  3914 + SrsConfDirective* conf = get_vhost(vhost);
3968 if (!conf) { 3915 if (!conf) {
3969 - return SRS_CONF_DEFAULT_SECURITY_ENABLED; 3916 + return DEFAULT;
3970 } 3917 }
3971 3918
3972 SrsConfDirective* security = conf->get("security"); 3919 SrsConfDirective* security = conf->get("security");
3973 if (!security) { 3920 if (!security) {
3974 - return SRS_CONF_DEFAULT_SECURITY_ENABLED; 3921 + return DEFAULT;
3975 } 3922 }
3976 3923
3977 conf = security->get("enabled"); 3924 conf = security->get("enabled");
3978 if (!conf || conf->arg0().empty()) { 3925 if (!conf || conf->arg0().empty()) {
3979 - return SRS_CONF_DEFAULT_SECURITY_ENABLED; 3926 + return DEFAULT;
3980 } 3927 }
3981 3928
3982 return SRS_CONF_PERFER_FALSE(conf->arg0()); 3929 return SRS_CONF_PERFER_FALSE(conf->arg0());
@@ -3985,149 +3932,146 @@ bool SrsConfig::get_security_enabled(string vhost) @@ -3985,149 +3932,146 @@ bool SrsConfig::get_security_enabled(string vhost)
3985 SrsConfDirective* SrsConfig::get_security_rules(string vhost) 3932 SrsConfDirective* SrsConfig::get_security_rules(string vhost)
3986 { 3933 {
3987 SrsConfDirective* conf = get_vhost(vhost); 3934 SrsConfDirective* conf = get_vhost(vhost);
3988 -  
3989 if (!conf) { 3935 if (!conf) {
3990 return NULL; 3936 return NULL;
3991 } 3937 }
3992 3938
3993 - SrsConfDirective* security = conf->get("security");  
3994 - if (!security) {  
3995 - return NULL;  
3996 - }  
3997 -  
3998 - return security; 3939 + return conf->get("security");
3999 } 3940 }
4000 3941
4001 SrsConfDirective* SrsConfig::get_transcode(string vhost, string scope) 3942 SrsConfDirective* SrsConfig::get_transcode(string vhost, string scope)
4002 { 3943 {
4003 SrsConfDirective* conf = get_vhost(vhost); 3944 SrsConfDirective* conf = get_vhost(vhost);
4004 -  
4005 if (!conf) { 3945 if (!conf) {
4006 return NULL; 3946 return NULL;
4007 } 3947 }
4008 3948
4009 - SrsConfDirective* transcode = conf->get("transcode");  
4010 - if (!transcode) { 3949 + conf = conf->get("transcode");
  3950 + if (!conf || conf->arg0() != scope) {
4011 return NULL; 3951 return NULL;
4012 } 3952 }
4013 3953
4014 - if (transcode->arg0() == scope) {  
4015 - return transcode;  
4016 - }  
4017 -  
4018 - return NULL; 3954 + return conf;
4019 } 3955 }
4020 3956
4021 -bool SrsConfig::get_transcode_enabled(SrsConfDirective* transcode) 3957 +bool SrsConfig::get_transcode_enabled(SrsConfDirective* conf)
4022 { 3958 {
4023 - if (!transcode) {  
4024 - return false; 3959 + static bool DEFAULT = false;
  3960 +
  3961 + if (!conf) {
  3962 + return DEFAULT;
4025 } 3963 }
4026 3964
4027 - SrsConfDirective* conf = transcode->get("enabled"); 3965 + conf = conf->get("enabled");
4028 if (!conf || conf->arg0().empty()) { 3966 if (!conf || conf->arg0().empty()) {
4029 - return false; 3967 + return DEFAULT;
4030 } 3968 }
4031 3969
4032 return SRS_CONF_PERFER_FALSE(conf->arg0()); 3970 return SRS_CONF_PERFER_FALSE(conf->arg0());
4033 } 3971 }
4034 3972
4035 -string SrsConfig::get_transcode_ffmpeg(SrsConfDirective* transcode) 3973 +string SrsConfig::get_transcode_ffmpeg(SrsConfDirective* conf)
4036 { 3974 {
4037 - if (!transcode) {  
4038 - return "";  
4039 - } 3975 + static string DEFAULT = "";
4040 3976
4041 - SrsConfDirective* conf = transcode->get("ffmpeg");  
4042 if (!conf) { 3977 if (!conf) {
4043 - return ""; 3978 + return DEFAULT;
  3979 + }
  3980 +
  3981 + conf = conf->get("ffmpeg");
  3982 + if (!conf || conf->arg0().empty()) {
  3983 + return DEFAULT;
4044 } 3984 }
4045 3985
4046 return conf->arg0(); 3986 return conf->arg0();
4047 } 3987 }
4048 3988
4049 -vector<SrsConfDirective*> SrsConfig::get_transcode_engines(SrsConfDirective* transcode) 3989 +vector<SrsConfDirective*> SrsConfig::get_transcode_engines(SrsConfDirective* conf)
4050 { 3990 {
4051 vector<SrsConfDirective*> engines; 3991 vector<SrsConfDirective*> engines;
4052 3992
4053 - if (!transcode) { 3993 + if (!conf) {
4054 return engines; 3994 return engines;
4055 } 3995 }
4056 3996
4057 - for (int i = 0; i < (int)transcode->directives.size(); i++) {  
4058 - SrsConfDirective* conf = transcode->directives[i]; 3997 + for (int i = 0; i < (int)conf->directives.size(); i++) {
  3998 + SrsConfDirective* engine = conf->directives[i];
4059 3999
4060 - if (conf->name == "engine") {  
4061 - engines.push_back(conf); 4000 + if (engine->name == "engine") {
  4001 + engines.push_back(engine);
4062 } 4002 }
4063 } 4003 }
4064 4004
4065 return engines; 4005 return engines;
4066 } 4006 }
4067 4007
4068 -bool SrsConfig::get_engine_enabled(SrsConfDirective* engine) 4008 +bool SrsConfig::get_engine_enabled(SrsConfDirective* conf)
4069 { 4009 {
4070 - if (!engine) {  
4071 - return false; 4010 + static bool DEFAULT = false;
  4011 +
  4012 + if (!conf) {
  4013 + return DEFAULT;
4072 } 4014 }
4073 4015
4074 - SrsConfDirective* conf = engine->get("enabled"); 4016 + conf = conf->get("enabled");
4075 if (!conf || conf->arg0().empty()) { 4017 if (!conf || conf->arg0().empty()) {
4076 - return false; 4018 + return DEFAULT;
4077 } 4019 }
4078 4020
4079 return SRS_CONF_PERFER_FALSE(conf->arg0()); 4021 return SRS_CONF_PERFER_FALSE(conf->arg0());
4080 } 4022 }
4081 4023
4082 -string SrsConfig::get_engine_iformat(SrsConfDirective* engine) 4024 +string SrsConfig::get_engine_iformat(SrsConfDirective* conf)
4083 { 4025 {
4084 - if (!engine) {  
4085 - return SRS_CONF_DEFAULT_TRANSCODE_IFORMAT;  
4086 - } 4026 + static string DEFAULT = "flv";
4087 4027
4088 - SrsConfDirective* conf = engine->get("iformat");  
4089 if (!conf) { 4028 if (!conf) {
4090 - return SRS_CONF_DEFAULT_TRANSCODE_IFORMAT; 4029 + return DEFAULT;
  4030 + }
  4031 +
  4032 + conf = conf->get("iformat");
  4033 + if (!conf || conf->arg0().empty()) {
  4034 + return DEFAULT;
4091 } 4035 }
4092 4036
4093 return conf->arg0(); 4037 return conf->arg0();
4094 } 4038 }
4095 4039
4096 -vector<string> SrsConfig::get_engine_vfilter(SrsConfDirective* engine) 4040 +vector<string> SrsConfig::get_engine_vfilter(SrsConfDirective* conf)
4097 { 4041 {
4098 vector<string> vfilter; 4042 vector<string> vfilter;
4099 4043
4100 - if (!engine) { 4044 + if (!conf) {
4101 return vfilter; 4045 return vfilter;
4102 } 4046 }
4103 4047
4104 - SrsConfDirective* conf = engine->get("vfilter"); 4048 + conf = conf->get("vfilter");
4105 if (!conf) { 4049 if (!conf) {
4106 return vfilter; 4050 return vfilter;
4107 } 4051 }
4108 4052
4109 for (int i = 0; i < (int)conf->directives.size(); i++) { 4053 for (int i = 0; i < (int)conf->directives.size(); i++) {
4110 - SrsConfDirective* p = conf->directives[i];  
4111 - if (!p) { 4054 + SrsConfDirective* filter = conf->directives[i];
  4055 + if (!filter) {
4112 continue; 4056 continue;
4113 } 4057 }
4114 4058
4115 - vfilter.push_back("-" + p->name);  
4116 - vfilter.push_back(p->arg0()); 4059 + vfilter.push_back("-" + filter->name);
  4060 + vfilter.push_back(filter->arg0());
4117 } 4061 }
4118 4062
4119 return vfilter; 4063 return vfilter;
4120 } 4064 }
4121 4065
4122 -string SrsConfig::get_engine_vcodec(SrsConfDirective* engine) 4066 +string SrsConfig::get_engine_vcodec(SrsConfDirective* conf)
4123 { 4067 {
4124 static string DEFAULT = ""; 4068 static string DEFAULT = "";
4125 4069
4126 - if (!engine) { 4070 + if (!conf) {
4127 return DEFAULT; 4071 return DEFAULT;
4128 } 4072 }
4129 4073
4130 - SrsConfDirective* conf = engine->get("vcodec"); 4074 + conf = conf->get("vcodec");
4131 if (!conf) { 4075 if (!conf) {
4132 return DEFAULT; 4076 return DEFAULT;
4133 } 4077 }
@@ -4135,15 +4079,15 @@ string SrsConfig::get_engine_vcodec(SrsConfDirective* engine) @@ -4135,15 +4079,15 @@ string SrsConfig::get_engine_vcodec(SrsConfDirective* engine)
4135 return conf->arg0(); 4079 return conf->arg0();
4136 } 4080 }
4137 4081
4138 -int SrsConfig::get_engine_vbitrate(SrsConfDirective* engine) 4082 +int SrsConfig::get_engine_vbitrate(SrsConfDirective* conf)
4139 { 4083 {
4140 static int DEFAULT = 0; 4084 static int DEFAULT = 0;
4141 4085
4142 - if (!engine) { 4086 + if (!conf) {
4143 return DEFAULT; 4087 return DEFAULT;
4144 } 4088 }
4145 4089
4146 - SrsConfDirective* conf = engine->get("vbitrate"); 4090 + conf = conf->get("vbitrate");
4147 if (!conf || conf->arg0().empty()) { 4091 if (!conf || conf->arg0().empty()) {
4148 return DEFAULT; 4092 return DEFAULT;
4149 } 4093 }
@@ -4151,15 +4095,15 @@ int SrsConfig::get_engine_vbitrate(SrsConfDirective* engine) @@ -4151,15 +4095,15 @@ int SrsConfig::get_engine_vbitrate(SrsConfDirective* engine)
4151 return ::atoi(conf->arg0().c_str()); 4095 return ::atoi(conf->arg0().c_str());
4152 } 4096 }
4153 4097
4154 -double SrsConfig::get_engine_vfps(SrsConfDirective* engine) 4098 +double SrsConfig::get_engine_vfps(SrsConfDirective* conf)
4155 { 4099 {
4156 static double DEFAULT = 0; 4100 static double DEFAULT = 0;
4157 4101
4158 - if (!engine) { 4102 + if (!conf) {
4159 return DEFAULT; 4103 return DEFAULT;
4160 } 4104 }
4161 4105
4162 - SrsConfDirective* conf = engine->get("vfps"); 4106 + conf = conf->get("vfps");
4163 if (!conf || conf->arg0().empty()) { 4107 if (!conf || conf->arg0().empty()) {
4164 return DEFAULT; 4108 return DEFAULT;
4165 } 4109 }
@@ -4167,15 +4111,15 @@ double SrsConfig::get_engine_vfps(SrsConfDirective* engine) @@ -4167,15 +4111,15 @@ double SrsConfig::get_engine_vfps(SrsConfDirective* engine)
4167 return ::atof(conf->arg0().c_str()); 4111 return ::atof(conf->arg0().c_str());
4168 } 4112 }
4169 4113
4170 -int SrsConfig::get_engine_vwidth(SrsConfDirective* engine) 4114 +int SrsConfig::get_engine_vwidth(SrsConfDirective* conf)
4171 { 4115 {
4172 static int DEFAULT = 0; 4116 static int DEFAULT = 0;
4173 4117
4174 - if (!engine) { 4118 + if (!conf) {
4175 return DEFAULT; 4119 return DEFAULT;
4176 } 4120 }
4177 4121
4178 - SrsConfDirective* conf = engine->get("vwidth"); 4122 + conf = conf->get("vwidth");
4179 if (!conf || conf->arg0().empty()) { 4123 if (!conf || conf->arg0().empty()) {
4180 return DEFAULT; 4124 return DEFAULT;
4181 } 4125 }
@@ -4183,15 +4127,15 @@ int SrsConfig::get_engine_vwidth(SrsConfDirective* engine) @@ -4183,15 +4127,15 @@ int SrsConfig::get_engine_vwidth(SrsConfDirective* engine)
4183 return ::atoi(conf->arg0().c_str()); 4127 return ::atoi(conf->arg0().c_str());
4184 } 4128 }
4185 4129
4186 -int SrsConfig::get_engine_vheight(SrsConfDirective* engine) 4130 +int SrsConfig::get_engine_vheight(SrsConfDirective* conf)
4187 { 4131 {
4188 static int DEFAULT = 0; 4132 static int DEFAULT = 0;
4189 4133
4190 - if (!engine) { 4134 + if (!conf) {
4191 return DEFAULT; 4135 return DEFAULT;
4192 } 4136 }
4193 4137
4194 - SrsConfDirective* conf = engine->get("vheight"); 4138 + conf = conf->get("vheight");
4195 if (!conf || conf->arg0().empty()) { 4139 if (!conf || conf->arg0().empty()) {
4196 return DEFAULT; 4140 return DEFAULT;
4197 } 4141 }
@@ -4199,15 +4143,15 @@ int SrsConfig::get_engine_vheight(SrsConfDirective* engine) @@ -4199,15 +4143,15 @@ int SrsConfig::get_engine_vheight(SrsConfDirective* engine)
4199 return ::atoi(conf->arg0().c_str()); 4143 return ::atoi(conf->arg0().c_str());
4200 } 4144 }
4201 4145
4202 -int SrsConfig::get_engine_vthreads(SrsConfDirective* engine) 4146 +int SrsConfig::get_engine_vthreads(SrsConfDirective* conf)
4203 { 4147 {
4204 static int DEFAULT = 1; 4148 static int DEFAULT = 1;
4205 4149
4206 - if (!engine) { 4150 + if (!conf) {
4207 return DEFAULT; 4151 return DEFAULT;
4208 } 4152 }
4209 4153
4210 - SrsConfDirective* conf = engine->get("vthreads"); 4154 + conf = conf->get("vthreads");
4211 if (!conf || conf->arg0().empty()) { 4155 if (!conf || conf->arg0().empty()) {
4212 return DEFAULT; 4156 return DEFAULT;
4213 } 4157 }
@@ -4215,85 +4159,89 @@ int SrsConfig::get_engine_vthreads(SrsConfDirective* engine) @@ -4215,85 +4159,89 @@ int SrsConfig::get_engine_vthreads(SrsConfDirective* engine)
4215 return ::atoi(conf->arg0().c_str()); 4159 return ::atoi(conf->arg0().c_str());
4216 } 4160 }
4217 4161
4218 -string SrsConfig::get_engine_vprofile(SrsConfDirective* engine) 4162 +string SrsConfig::get_engine_vprofile(SrsConfDirective* conf)
4219 { 4163 {
4220 - if (!engine) {  
4221 - return ""; 4164 + static string DEFAULT = "";
  4165 +
  4166 + if (!conf) {
  4167 + return DEFAULT;
4222 } 4168 }
4223 4169
4224 - SrsConfDirective* conf = engine->get("vprofile"); 4170 + conf = conf->get("vprofile");
4225 if (!conf) { 4171 if (!conf) {
4226 - return ""; 4172 + return DEFAULT;
4227 } 4173 }
4228 4174
4229 return conf->arg0(); 4175 return conf->arg0();
4230 } 4176 }
4231 4177
4232 -string SrsConfig::get_engine_vpreset(SrsConfDirective* engine) 4178 +string SrsConfig::get_engine_vpreset(SrsConfDirective* conf)
4233 { 4179 {
4234 - if (!engine) {  
4235 - return ""; 4180 + static string DEFAULT = "";
  4181 +
  4182 + if (!conf) {
  4183 + return DEFAULT;
4236 } 4184 }
4237 4185
4238 - SrsConfDirective* conf = engine->get("vpreset"); 4186 + conf = conf->get("vpreset");
4239 if (!conf) { 4187 if (!conf) {
4240 - return ""; 4188 + return DEFAULT;
4241 } 4189 }
4242 4190
4243 return conf->arg0(); 4191 return conf->arg0();
4244 } 4192 }
4245 4193
4246 -vector<string> SrsConfig::get_engine_vparams(SrsConfDirective* engine) 4194 +vector<string> SrsConfig::get_engine_vparams(SrsConfDirective* conf)
4247 { 4195 {
4248 vector<string> vparams; 4196 vector<string> vparams;
4249 4197
4250 - if (!engine) { 4198 + if (!conf) {
4251 return vparams; 4199 return vparams;
4252 } 4200 }
4253 4201
4254 - SrsConfDirective* conf = engine->get("vparams"); 4202 + conf = conf->get("vparams");
4255 if (!conf) { 4203 if (!conf) {
4256 return vparams; 4204 return vparams;
4257 } 4205 }
4258 4206
4259 for (int i = 0; i < (int)conf->directives.size(); i++) { 4207 for (int i = 0; i < (int)conf->directives.size(); i++) {
4260 - SrsConfDirective* p = conf->directives[i];  
4261 - if (!p) { 4208 + SrsConfDirective* filter = conf->directives[i];
  4209 + if (!filter) {
4262 continue; 4210 continue;
4263 } 4211 }
4264 4212
4265 - vparams.push_back("-" + p->name);  
4266 - vparams.push_back(p->arg0()); 4213 + vparams.push_back("-" + filter->name);
  4214 + vparams.push_back(filter->arg0());
4267 } 4215 }
4268 4216
4269 return vparams; 4217 return vparams;
4270 } 4218 }
4271 4219
4272 -string SrsConfig::get_engine_acodec(SrsConfDirective* engine) 4220 +string SrsConfig::get_engine_acodec(SrsConfDirective* conf)
4273 { 4221 {
4274 static string DEFAULT = ""; 4222 static string DEFAULT = "";
4275 4223
4276 - if (!engine) { 4224 + if (!conf) {
4277 return DEFAULT; 4225 return DEFAULT;
4278 } 4226 }
4279 4227
4280 - SrsConfDirective* conf = engine->get("acodec");  
4281 - if (!conf) { 4228 + conf = conf->get("acodec");
  4229 + if (!conf || conf->arg0().empty()) {
4282 return DEFAULT; 4230 return DEFAULT;
4283 } 4231 }
4284 4232
4285 return conf->arg0(); 4233 return conf->arg0();
4286 } 4234 }
4287 4235
4288 -int SrsConfig::get_engine_abitrate(SrsConfDirective* engine) 4236 +int SrsConfig::get_engine_abitrate(SrsConfDirective* conf)
4289 { 4237 {
4290 static int DEFAULT = 0; 4238 static int DEFAULT = 0;
4291 4239
4292 - if (!engine) { 4240 + if (!conf) {
4293 return DEFAULT; 4241 return DEFAULT;
4294 } 4242 }
4295 4243
4296 - SrsConfDirective* conf = engine->get("abitrate"); 4244 + conf = conf->get("abitrate");
4297 if (!conf || conf->arg0().empty()) { 4245 if (!conf || conf->arg0().empty()) {
4298 return DEFAULT; 4246 return DEFAULT;
4299 } 4247 }
@@ -4301,15 +4249,15 @@ int SrsConfig::get_engine_abitrate(SrsConfDirective* engine) @@ -4301,15 +4249,15 @@ int SrsConfig::get_engine_abitrate(SrsConfDirective* engine)
4301 return ::atoi(conf->arg0().c_str()); 4249 return ::atoi(conf->arg0().c_str());
4302 } 4250 }
4303 4251
4304 -int SrsConfig::get_engine_asample_rate(SrsConfDirective* engine) 4252 +int SrsConfig::get_engine_asample_rate(SrsConfDirective* conf)
4305 { 4253 {
4306 static int DEFAULT = 0; 4254 static int DEFAULT = 0;
4307 4255
4308 - if (!engine) { 4256 + if (!conf) {
4309 return DEFAULT; 4257 return DEFAULT;
4310 } 4258 }
4311 4259
4312 - SrsConfDirective* conf = engine->get("asample_rate"); 4260 + conf = conf->get("asample_rate");
4313 if (!conf || conf->arg0().empty()) { 4261 if (!conf || conf->arg0().empty()) {
4314 return DEFAULT; 4262 return DEFAULT;
4315 } 4263 }
@@ -4317,15 +4265,15 @@ int SrsConfig::get_engine_asample_rate(SrsConfDirective* engine) @@ -4317,15 +4265,15 @@ int SrsConfig::get_engine_asample_rate(SrsConfDirective* engine)
4317 return ::atoi(conf->arg0().c_str()); 4265 return ::atoi(conf->arg0().c_str());
4318 } 4266 }
4319 4267
4320 -int SrsConfig::get_engine_achannels(SrsConfDirective* engine) 4268 +int SrsConfig::get_engine_achannels(SrsConfDirective* conf)
4321 { 4269 {
4322 static int DEFAULT = 0; 4270 static int DEFAULT = 0;
4323 4271
4324 - if (!engine) { 4272 + if (!conf) {
4325 return DEFAULT; 4273 return DEFAULT;
4326 } 4274 }
4327 4275
4328 - SrsConfDirective* conf = engine->get("achannels"); 4276 + conf = conf->get("achannels");
4329 if (!conf || conf->arg0().empty()) { 4277 if (!conf || conf->arg0().empty()) {
4330 return DEFAULT; 4278 return DEFAULT;
4331 } 4279 }
@@ -4333,60 +4281,64 @@ int SrsConfig::get_engine_achannels(SrsConfDirective* engine) @@ -4333,60 +4281,64 @@ int SrsConfig::get_engine_achannels(SrsConfDirective* engine)
4333 return ::atoi(conf->arg0().c_str()); 4281 return ::atoi(conf->arg0().c_str());
4334 } 4282 }
4335 4283
4336 -vector<string> SrsConfig::get_engine_aparams(SrsConfDirective* engine) 4284 +vector<string> SrsConfig::get_engine_aparams(SrsConfDirective* conf)
4337 { 4285 {
4338 vector<string> aparams; 4286 vector<string> aparams;
4339 4287
4340 - if (!engine) { 4288 + if (!conf) {
4341 return aparams; 4289 return aparams;
4342 } 4290 }
4343 4291
4344 - SrsConfDirective* conf = engine->get("aparams"); 4292 + conf = conf->get("aparams");
4345 if (!conf) { 4293 if (!conf) {
4346 return aparams; 4294 return aparams;
4347 } 4295 }
4348 4296
4349 for (int i = 0; i < (int)conf->directives.size(); i++) { 4297 for (int i = 0; i < (int)conf->directives.size(); i++) {
4350 - SrsConfDirective* p = conf->directives[i];  
4351 - if (!p) { 4298 + SrsConfDirective* filter = conf->directives[i];
  4299 + if (!filter) {
4352 continue; 4300 continue;
4353 } 4301 }
4354 4302
4355 - aparams.push_back("-" + p->name);  
4356 - aparams.push_back(p->arg0()); 4303 + aparams.push_back("-" + filter->name);
  4304 + aparams.push_back(filter->arg0());
4357 } 4305 }
4358 4306
4359 return aparams; 4307 return aparams;
4360 } 4308 }
4361 4309
4362 -string SrsConfig::get_engine_oformat(SrsConfDirective* engine) 4310 +string SrsConfig::get_engine_oformat(SrsConfDirective* conf)
4363 { 4311 {
4364 - if (!engine) {  
4365 - return SRS_CONF_DEFAULT_TRANSCODE_OFORMAT;  
4366 - } 4312 + static string DEFAULT = "flv";
4367 4313
4368 - SrsConfDirective* conf = engine->get("oformat");  
4369 if (!conf) { 4314 if (!conf) {
4370 - return SRS_CONF_DEFAULT_TRANSCODE_OFORMAT; 4315 + return DEFAULT;
  4316 + }
  4317 +
  4318 + conf = conf->get("oformat");
  4319 + if (!conf || conf->arg0().empty()) {
  4320 + return DEFAULT;
4371 } 4321 }
4372 4322
4373 return conf->arg0(); 4323 return conf->arg0();
4374 } 4324 }
4375 4325
4376 -string SrsConfig::get_engine_output(SrsConfDirective* engine) 4326 +string SrsConfig::get_engine_output(SrsConfDirective* conf)
4377 { 4327 {
4378 - if (!engine) {  
4379 - return "";  
4380 - } 4328 + static string DEFAULT = "";
4381 4329
4382 - SrsConfDirective* conf = engine->get("output");  
4383 if (!conf) { 4330 if (!conf) {
4384 - return ""; 4331 + return DEFAULT;
4385 } 4332 }
4386 4333
4387 - return conf->arg0();  
4388 -}  
4389 - 4334 + conf = conf->get("output");
  4335 + if (!conf || conf->arg0().empty()) {
  4336 + return DEFAULT;
  4337 + }
  4338 +
  4339 + return conf->arg0();
  4340 +}
  4341 +
4390 SrsConfDirective* SrsConfig::get_exec(string vhost) 4342 SrsConfDirective* SrsConfig::get_exec(string vhost)
4391 { 4343 {
4392 SrsConfDirective* conf = get_vhost(vhost); 4344 SrsConfDirective* conf = get_vhost(vhost);
@@ -4437,16 +4389,16 @@ vector<SrsConfDirective*> SrsConfig::get_ingesters(string vhost) @@ -4437,16 +4389,16 @@ vector<SrsConfDirective*> SrsConfig::get_ingesters(string vhost)
4437 { 4389 {
4438 vector<SrsConfDirective*> ingeters; 4390 vector<SrsConfDirective*> ingeters;
4439 4391
4440 - SrsConfDirective* vhost_conf = get_vhost(vhost);  
4441 - if (!vhost_conf) { 4392 + SrsConfDirective* conf = get_vhost(vhost);
  4393 + if (!conf) {
4442 return ingeters; 4394 return ingeters;
4443 } 4395 }
4444 4396
4445 - for (int i = 0; i < (int)vhost_conf->directives.size(); i++) {  
4446 - SrsConfDirective* conf = vhost_conf->directives[i]; 4397 + for (int i = 0; i < (int)conf->directives.size(); i++) {
  4398 + SrsConfDirective* ingester = conf->directives[i];
4447 4399
4448 - if (conf->name == "ingest") {  
4449 - ingeters.push_back(conf); 4400 + if (ingester->name == "ingest") {
  4401 + ingeters.push_back(ingester);
4450 } 4402 }
4451 } 4403 }
4452 4404
@@ -4460,77 +4412,78 @@ SrsConfDirective* SrsConfig::get_ingest_by_id(string vhost, string ingest_id) @@ -4460,77 +4412,78 @@ SrsConfDirective* SrsConfig::get_ingest_by_id(string vhost, string ingest_id)
4460 return NULL; 4412 return NULL;
4461 } 4413 }
4462 4414
4463 - conf = conf->get("ingest", ingest_id);  
4464 - return conf; 4415 + return conf->get("ingest", ingest_id);
4465 } 4416 }
4466 4417
4467 -bool SrsConfig::get_ingest_enabled(SrsConfDirective* ingest) 4418 +bool SrsConfig::get_ingest_enabled(SrsConfDirective* conf)
4468 { 4419 {
4469 - if (!ingest) {  
4470 - return false;  
4471 - } 4420 + static bool DEFAULT = false;
4472 4421
4473 - SrsConfDirective* conf = ingest->get("enabled"); 4422 + if (!conf) {
  4423 + return DEFAULT;
  4424 + }
4474 4425
  4426 + conf = conf->get("enabled");
4475 if (!conf || conf->arg0().empty()) { 4427 if (!conf || conf->arg0().empty()) {
4476 - return false; 4428 + return DEFAULT;
4477 } 4429 }
4478 4430
4479 return SRS_CONF_PERFER_FALSE(conf->arg0()); 4431 return SRS_CONF_PERFER_FALSE(conf->arg0());
4480 } 4432 }
4481 4433
4482 -string SrsConfig::get_ingest_ffmpeg(SrsConfDirective* ingest) 4434 +string SrsConfig::get_ingest_ffmpeg(SrsConfDirective* conf)
4483 { 4435 {
4484 - if (!ingest) {  
4485 - return "";  
4486 - } 4436 + static string DEFAULT = "";
4487 4437
4488 - SrsConfDirective* conf = ingest->get("ffmpeg"); 4438 + if (!conf) {
  4439 + return DEFAULT;
  4440 + }
4489 4441
  4442 + conf = conf->get("ffmpeg");
4490 if (!conf) { 4443 if (!conf) {
4491 - return ""; 4444 + return DEFAULT;
4492 } 4445 }
4493 4446
4494 return conf->arg0(); 4447 return conf->arg0();
4495 } 4448 }
4496 4449
4497 -string SrsConfig::get_ingest_input_type(SrsConfDirective* ingest) 4450 +string SrsConfig::get_ingest_input_type(SrsConfDirective* conf)
4498 { 4451 {
4499 - if (!ingest) {  
4500 - return SRS_CONF_DEFAULT_INGEST_TYPE_FILE;  
4501 - } 4452 + static string DEFAULT = "file";
4502 4453
4503 - SrsConfDirective* conf = ingest->get("input"); 4454 + if (!conf) {
  4455 + return DEFAULT;
  4456 + }
4504 4457
  4458 + conf = conf->get("input");
4505 if (!conf) { 4459 if (!conf) {
4506 - return SRS_CONF_DEFAULT_INGEST_TYPE_FILE; 4460 + return DEFAULT;
4507 } 4461 }
4508 4462
4509 conf = conf->get("type"); 4463 conf = conf->get("type");
4510 -  
4511 - if (!conf) {  
4512 - return SRS_CONF_DEFAULT_INGEST_TYPE_FILE; 4464 + if (!conf || conf->arg0().empty()) {
  4465 + return DEFAULT;
4513 } 4466 }
4514 4467
4515 return conf->arg0(); 4468 return conf->arg0();
4516 } 4469 }
4517 4470
4518 -string SrsConfig::get_ingest_input_url(SrsConfDirective* ingest) 4471 +string SrsConfig::get_ingest_input_url(SrsConfDirective* conf)
4519 { 4472 {
4520 - if (!ingest) {  
4521 - return "";  
4522 - } 4473 + static string DEFAULT = "";
4523 4474
4524 - SrsConfDirective* conf = ingest->get("input"); 4475 + if (!conf) {
  4476 + return DEFAULT;
  4477 + }
4525 4478
  4479 + conf = conf->get("input");
4526 if (!conf) { 4480 if (!conf) {
4527 - return ""; 4481 + return DEFAULT;
4528 } 4482 }
4529 4483
4530 conf = conf->get("url"); 4484 conf = conf->get("url");
4531 -  
4532 - if (!conf) {  
4533 - return ""; 4485 + if (!conf || conf->arg0().empty()) {
  4486 + return DEFAULT;
4534 } 4487 }
4535 4488
4536 return conf->arg0(); 4489 return conf->arg0();
@@ -4538,23 +4491,23 @@ string SrsConfig::get_ingest_input_url(SrsConfDirective* ingest) @@ -4538,23 +4491,23 @@ string SrsConfig::get_ingest_input_url(SrsConfDirective* ingest)
4538 4491
4539 bool SrsConfig::get_log_tank_file() 4492 bool SrsConfig::get_log_tank_file()
4540 { 4493 {
4541 - srs_assert(root); 4494 + static bool DEFAULT = true;
4542 4495
4543 SrsConfDirective* conf = root->get("srs_log_tank"); 4496 SrsConfDirective* conf = root->get("srs_log_tank");
4544 if (!conf || conf->arg0().empty()) { 4497 if (!conf || conf->arg0().empty()) {
4545 - return true; 4498 + return DEFAULT;
4546 } 4499 }
4547 4500
4548 - return conf->arg0() != SRS_CONF_DEFAULT_LOG_TANK_CONSOLE; 4501 + return conf->arg0() != "console";
4549 } 4502 }
4550 4503
4551 string SrsConfig::get_log_level() 4504 string SrsConfig::get_log_level()
4552 { 4505 {
4553 - srs_assert(root); 4506 + static string DEFAULT = "trace";
4554 4507
4555 SrsConfDirective* conf = root->get("srs_log_level"); 4508 SrsConfDirective* conf = root->get("srs_log_level");
4556 if (!conf || conf->arg0().empty()) { 4509 if (!conf || conf->arg0().empty()) {
4557 - return SRS_CONF_DEFAULT_LOG_LEVEL; 4510 + return DEFAULT;
4558 } 4511 }
4559 4512
4560 return conf->arg0(); 4513 return conf->arg0();
@@ -4562,11 +4515,11 @@ string SrsConfig::get_log_level() @@ -4562,11 +4515,11 @@ string SrsConfig::get_log_level()
4562 4515
4563 string SrsConfig::get_log_file() 4516 string SrsConfig::get_log_file()
4564 { 4517 {
4565 - srs_assert(root); 4518 + static string DEFAULT = "./objs/srs.log";
4566 4519
4567 SrsConfDirective* conf = root->get("srs_log_file"); 4520 SrsConfDirective* conf = root->get("srs_log_file");
4568 if (!conf || conf->arg0().empty()) { 4521 if (!conf || conf->arg0().empty()) {
4569 - return SRS_CONF_DEFAULT_LOG_FILE; 4522 + return DEFAULT;
4570 } 4523 }
4571 4524
4572 return conf->arg0(); 4525 return conf->arg0();
@@ -4580,11 +4533,11 @@ bool SrsConfig::get_ffmpeg_log_enabled() @@ -4580,11 +4533,11 @@ bool SrsConfig::get_ffmpeg_log_enabled()
4580 4533
4581 string SrsConfig::get_ffmpeg_log_dir() 4534 string SrsConfig::get_ffmpeg_log_dir()
4582 { 4535 {
4583 - srs_assert(root); 4536 + static string DEFAULT = "./objs";
4584 4537
4585 SrsConfDirective* conf = root->get("ff_log_dir"); 4538 SrsConfDirective* conf = root->get("ff_log_dir");
4586 if (!conf || conf->arg0().empty()) { 4539 if (!conf || conf->arg0().empty()) {
4587 - return SRS_CONF_DEFAULT_FF_LOG_DIR; 4540 + return DEFAULT;
4588 } 4541 }
4589 4542
4590 return conf->arg0(); 4543 return conf->arg0();
@@ -4603,16 +4556,17 @@ SrsConfDirective* SrsConfig::get_hls(string vhost) @@ -4603,16 +4556,17 @@ SrsConfDirective* SrsConfig::get_hls(string vhost)
4603 4556
4604 bool SrsConfig::get_hls_enabled(string vhost) 4557 bool SrsConfig::get_hls_enabled(string vhost)
4605 { 4558 {
4606 - SrsConfDirective* hls = get_hls(vhost); 4559 + static bool DEFAULT = false;
4607 4560
4608 - if (!hls) {  
4609 - return false;  
4610 - } 4561 + SrsConfDirective* conf = get_hls(vhost);
4611 4562
4612 - SrsConfDirective* conf = hls->get("enabled"); 4563 + if (!conf) {
  4564 + return DEFAULT;
  4565 + }
4613 4566
  4567 + conf = conf->get("enabled");
4614 if (!conf || conf->arg0().empty()) { 4568 if (!conf || conf->arg0().empty()) {
4615 - return false; 4569 + return DEFAULT;
4616 } 4570 }
4617 4571
4618 return SRS_CONF_PERFER_FALSE(conf->arg0()); 4572 return SRS_CONF_PERFER_FALSE(conf->arg0());
@@ -4620,16 +4574,16 @@ bool SrsConfig::get_hls_enabled(string vhost) @@ -4620,16 +4574,16 @@ bool SrsConfig::get_hls_enabled(string vhost)
4620 4574
4621 string SrsConfig::get_hls_entry_prefix(string vhost) 4575 string SrsConfig::get_hls_entry_prefix(string vhost)
4622 { 4576 {
4623 - SrsConfDirective* hls = get_hls(vhost); 4577 + static string DEFAULT = "";
4624 4578
4625 - if (!hls) {  
4626 - return ""; 4579 + SrsConfDirective* conf = get_hls(vhost);
  4580 + if (!conf) {
  4581 + return DEFAULT;
4627 } 4582 }
4628 4583
4629 - SrsConfDirective* conf = hls->get("hls_entry_prefix");  
4630 - 4584 + conf = conf->get("hls_entry_prefix");
4631 if (!conf) { 4585 if (!conf) {
4632 - return ""; 4586 + return DEFAULT;
4633 } 4587 }
4634 4588
4635 return conf->arg0(); 4589 return conf->arg0();
@@ -4637,16 +4591,16 @@ string SrsConfig::get_hls_entry_prefix(string vhost) @@ -4637,16 +4591,16 @@ string SrsConfig::get_hls_entry_prefix(string vhost)
4637 4591
4638 string SrsConfig::get_hls_path(string vhost) 4592 string SrsConfig::get_hls_path(string vhost)
4639 { 4593 {
4640 - SrsConfDirective* hls = get_hls(vhost); 4594 + static string DEFAULT = "./objs/nginx/html";
4641 4595
4642 - if (!hls) {  
4643 - return SRS_CONF_DEFAULT_HLS_PATH; 4596 + SrsConfDirective* conf = get_hls(vhost);
  4597 + if (!conf) {
  4598 + return DEFAULT;
4644 } 4599 }
4645 4600
4646 - SrsConfDirective* conf = hls->get("hls_path");  
4647 -  
4648 - if (!conf) {  
4649 - return SRS_CONF_DEFAULT_HLS_PATH; 4601 + conf = conf->get("hls_path");
  4602 + if (!conf || conf->arg0().empty()) {
  4603 + return DEFAULT;
4650 } 4604 }
4651 4605
4652 return conf->arg0(); 4606 return conf->arg0();
@@ -4654,16 +4608,16 @@ string SrsConfig::get_hls_path(string vhost) @@ -4654,16 +4608,16 @@ string SrsConfig::get_hls_path(string vhost)
4654 4608
4655 string SrsConfig::get_hls_m3u8_file(string vhost) 4609 string SrsConfig::get_hls_m3u8_file(string vhost)
4656 { 4610 {
4657 - SrsConfDirective* hls = get_hls(vhost); 4611 + static string DEFAULT = "[app]/[stream].m3u8";
4658 4612
4659 - if (!hls) {  
4660 - return SRS_CONF_DEFAULT_HLS_M3U8_FILE; 4613 + SrsConfDirective* conf = get_hls(vhost);
  4614 + if (!conf) {
  4615 + return DEFAULT;
4661 } 4616 }
4662 4617
4663 - SrsConfDirective* conf = hls->get("hls_m3u8_file");  
4664 -  
4665 - if (!conf) {  
4666 - return SRS_CONF_DEFAULT_HLS_M3U8_FILE; 4618 + conf = conf->get("hls_m3u8_file");
  4619 + if (!conf || conf->arg0().empty()) {
  4620 + return DEFAULT;
4667 } 4621 }
4668 4622
4669 return conf->arg0(); 4623 return conf->arg0();
@@ -4671,16 +4625,16 @@ string SrsConfig::get_hls_m3u8_file(string vhost) @@ -4671,16 +4625,16 @@ string SrsConfig::get_hls_m3u8_file(string vhost)
4671 4625
4672 string SrsConfig::get_hls_ts_file(string vhost) 4626 string SrsConfig::get_hls_ts_file(string vhost)
4673 { 4627 {
4674 - SrsConfDirective* hls = get_hls(vhost); 4628 + static string DEFAULT = "[app]/[stream]-[seq].ts";
4675 4629
4676 - if (!hls) {  
4677 - return SRS_CONF_DEFAULT_HLS_TS_FILE; 4630 + SrsConfDirective* conf = get_hls(vhost);
  4631 + if (!conf) {
  4632 + return DEFAULT;
4678 } 4633 }
4679 4634
4680 - SrsConfDirective* conf = hls->get("hls_ts_file");  
4681 -  
4682 - if (!conf) {  
4683 - return SRS_CONF_DEFAULT_HLS_TS_FILE; 4635 + conf = conf->get("hls_ts_file");
  4636 + if (!conf || conf->arg0().empty()) {
  4637 + return DEFAULT;
4684 } 4638 }
4685 4639
4686 return conf->arg0(); 4640 return conf->arg0();
@@ -4688,16 +4642,16 @@ string SrsConfig::get_hls_ts_file(string vhost) @@ -4688,16 +4642,16 @@ string SrsConfig::get_hls_ts_file(string vhost)
4688 4642
4689 bool SrsConfig::get_hls_ts_floor(string vhost) 4643 bool SrsConfig::get_hls_ts_floor(string vhost)
4690 { 4644 {
4691 - SrsConfDirective* hls = get_hls(vhost); 4645 + static bool DEFAULT = false;
4692 4646
4693 - if (!hls) {  
4694 - return SRS_CONF_DEFAULT_HLS_TS_FLOOR; 4647 + SrsConfDirective* conf = get_hls(vhost);
  4648 + if (!conf) {
  4649 + return DEFAULT;
4695 } 4650 }
4696 4651
4697 - SrsConfDirective* conf = hls->get("hls_ts_floor");  
4698 - 4652 + conf = conf->get("hls_ts_floor");
4699 if (!conf || conf->arg0().empty()) { 4653 if (!conf || conf->arg0().empty()) {
4700 - return SRS_CONF_DEFAULT_HLS_TS_FLOOR; 4654 + return DEFAULT;
4701 } 4655 }
4702 4656
4703 return SRS_CONF_PERFER_FALSE(conf->arg0()); 4657 return SRS_CONF_PERFER_FALSE(conf->arg0());
@@ -4705,16 +4659,16 @@ bool SrsConfig::get_hls_ts_floor(string vhost) @@ -4705,16 +4659,16 @@ bool SrsConfig::get_hls_ts_floor(string vhost)
4705 4659
4706 double SrsConfig::get_hls_fragment(string vhost) 4660 double SrsConfig::get_hls_fragment(string vhost)
4707 { 4661 {
4708 - SrsConfDirective* hls = get_hls(vhost); 4662 + static double DEFAULT = 10;
4709 4663
4710 - if (!hls) {  
4711 - return SRS_CONF_DEFAULT_HLS_FRAGMENT; 4664 + SrsConfDirective* conf = get_hls(vhost);
  4665 + if (!conf) {
  4666 + return DEFAULT;
4712 } 4667 }
4713 4668
4714 - SrsConfDirective* conf = hls->get("hls_fragment");  
4715 -  
4716 - if (!conf) {  
4717 - return SRS_CONF_DEFAULT_HLS_FRAGMENT; 4669 + conf = conf->get("hls_fragment");
  4670 + if (!conf || conf->arg0().empty()) {
  4671 + return DEFAULT;
4718 } 4672 }
4719 4673
4720 return ::atof(conf->arg0().c_str()); 4674 return ::atof(conf->arg0().c_str());
@@ -4722,16 +4676,16 @@ double SrsConfig::get_hls_fragment(string vhost) @@ -4722,16 +4676,16 @@ double SrsConfig::get_hls_fragment(string vhost)
4722 4676
4723 double SrsConfig::get_hls_td_ratio(string vhost) 4677 double SrsConfig::get_hls_td_ratio(string vhost)
4724 { 4678 {
4725 - SrsConfDirective* hls = get_hls(vhost); 4679 + static double DEFAULT = 1.5;
4726 4680
4727 - if (!hls) {  
4728 - return SRS_CONF_DEFAULT_HLS_TD_RATIO; 4681 + SrsConfDirective* conf = get_hls(vhost);
  4682 + if (!conf) {
  4683 + return DEFAULT;
4729 } 4684 }
4730 4685
4731 - SrsConfDirective* conf = hls->get("hls_td_ratio");  
4732 -  
4733 - if (!conf) {  
4734 - return SRS_CONF_DEFAULT_HLS_TD_RATIO; 4686 + conf = conf->get("hls_td_ratio");
  4687 + if (!conf || conf->arg0().empty()) {
  4688 + return DEFAULT;
4735 } 4689 }
4736 4690
4737 return ::atof(conf->arg0().c_str()); 4691 return ::atof(conf->arg0().c_str());
@@ -4739,16 +4693,16 @@ double SrsConfig::get_hls_td_ratio(string vhost) @@ -4739,16 +4693,16 @@ double SrsConfig::get_hls_td_ratio(string vhost)
4739 4693
4740 double SrsConfig::get_hls_aof_ratio(string vhost) 4694 double SrsConfig::get_hls_aof_ratio(string vhost)
4741 { 4695 {
4742 - SrsConfDirective* hls = get_hls(vhost); 4696 + static double DEFAULT = 2.0;
4743 4697
4744 - if (!hls) {  
4745 - return SRS_CONF_DEFAULT_HLS_AOF_RATIO; 4698 + SrsConfDirective* conf = get_hls(vhost);
  4699 + if (!conf) {
  4700 + return DEFAULT;
4746 } 4701 }
4747 4702
4748 - SrsConfDirective* conf = hls->get("hls_aof_ratio");  
4749 -  
4750 - if (!conf) {  
4751 - return SRS_CONF_DEFAULT_HLS_AOF_RATIO; 4703 + conf = conf->get("hls_aof_ratio");
  4704 + if (!conf || conf->arg0().empty()) {
  4705 + return DEFAULT;
4752 } 4706 }
4753 4707
4754 return ::atof(conf->arg0().c_str()); 4708 return ::atof(conf->arg0().c_str());
@@ -4756,33 +4710,33 @@ double SrsConfig::get_hls_aof_ratio(string vhost) @@ -4756,33 +4710,33 @@ double SrsConfig::get_hls_aof_ratio(string vhost)
4756 4710
4757 double SrsConfig::get_hls_window(string vhost) 4711 double SrsConfig::get_hls_window(string vhost)
4758 { 4712 {
4759 - SrsConfDirective* hls = get_hls(vhost); 4713 + static double DEFAULT = 60;
4760 4714
4761 - if (!hls) {  
4762 - return SRS_CONF_DEFAULT_HLS_WINDOW; 4715 + SrsConfDirective* conf = get_hls(vhost);
  4716 + if (!conf) {
  4717 + return DEFAULT;
4763 } 4718 }
4764 4719
4765 - SrsConfDirective* conf = hls->get("hls_window");  
4766 -  
4767 - if (!conf) {  
4768 - return SRS_CONF_DEFAULT_HLS_WINDOW; 4720 + conf = conf->get("hls_window");
  4721 + if (!conf || conf->arg0().empty()) {
  4722 + return DEFAULT;
4769 } 4723 }
4770 - 4724 +
4771 return ::atof(conf->arg0().c_str()); 4725 return ::atof(conf->arg0().c_str());
4772 } 4726 }
4773 4727
4774 string SrsConfig::get_hls_on_error(string vhost) 4728 string SrsConfig::get_hls_on_error(string vhost)
4775 { 4729 {
4776 - SrsConfDirective* hls = get_hls(vhost); 4730 + static string DEFAULT = "ignore";
4777 4731
4778 - if (!hls) {  
4779 - return SRS_CONF_DEFAULT_HLS_ON_ERROR; 4732 + SrsConfDirective* conf = get_hls(vhost);
  4733 + if (!conf) {
  4734 + return DEFAULT;
4780 } 4735 }
4781 4736
4782 - SrsConfDirective* conf = hls->get("hls_on_error");  
4783 -  
4784 - if (!conf) {  
4785 - return SRS_CONF_DEFAULT_HLS_ON_ERROR; 4737 + conf = conf->get("hls_on_error");
  4738 + if (!conf || conf->arg0().empty()) {
  4739 + return DEFAULT;
4786 } 4740 }
4787 4741
4788 return conf->arg0(); 4742 return conf->arg0();
@@ -4790,83 +4744,84 @@ string SrsConfig::get_hls_on_error(string vhost) @@ -4790,83 +4744,84 @@ string SrsConfig::get_hls_on_error(string vhost)
4790 4744
4791 string SrsConfig::get_hls_storage(string vhost) 4745 string SrsConfig::get_hls_storage(string vhost)
4792 { 4746 {
4793 - SrsConfDirective* hls = get_hls(vhost); 4747 + static string DEFAULT = "disk";
4794 4748
4795 - if (!hls) {  
4796 - return SRS_CONF_DEFAULT_HLS_STORAGE; 4749 + SrsConfDirective* conf = get_hls(vhost);
  4750 + if (!conf) {
  4751 + return DEFAULT;
4797 } 4752 }
4798 4753
4799 - SrsConfDirective* conf = hls->get("hls_storage");  
4800 -  
4801 - if (!conf) {  
4802 - return SRS_CONF_DEFAULT_HLS_STORAGE; 4754 + conf = conf->get("hls_storage");
  4755 + if (!conf || conf->arg0().empty()) {
  4756 + return DEFAULT;
4803 } 4757 }
4804 - 4758 +
4805 return conf->arg0(); 4759 return conf->arg0();
4806 } 4760 }
4807 4761
4808 string SrsConfig::get_hls_mount(string vhost) 4762 string SrsConfig::get_hls_mount(string vhost)
4809 { 4763 {
4810 - SrsConfDirective* hls = get_hls(vhost); 4764 + static string DEFAULT = "[vhost]/[app]/[stream].m3u8";
4811 4765
4812 - if (!hls) {  
4813 - return SRS_CONF_DEFAULT_HLS_MOUNT; 4766 + SrsConfDirective* conf = get_hls(vhost);
  4767 + if (!conf) {
  4768 + return DEFAULT;
4814 } 4769 }
4815 4770
4816 - SrsConfDirective* conf = hls->get("hls_mount");  
4817 -  
4818 - if (!conf) {  
4819 - return SRS_CONF_DEFAULT_HLS_MOUNT; 4771 + conf = conf->get("hls_mount");
  4772 + if (!conf || conf->arg0().empty()) {
  4773 + return DEFAULT;
4820 } 4774 }
4821 - 4775 +
4822 return conf->arg0(); 4776 return conf->arg0();
4823 } 4777 }
4824 4778
4825 string SrsConfig::get_hls_acodec(string vhost) 4779 string SrsConfig::get_hls_acodec(string vhost)
4826 { 4780 {
4827 - SrsConfDirective* hls = get_hls(vhost); 4781 + static string DEFAULT = "aac";
4828 4782
4829 - if (!hls) {  
4830 - return SRS_CONF_DEFAULT_HLS_ACODEC; 4783 + SrsConfDirective* conf = get_hls(vhost);
  4784 + if (!conf) {
  4785 + return DEFAULT;
4831 } 4786 }
4832 4787
4833 - SrsConfDirective* conf = hls->get("hls_acodec");  
4834 -  
4835 - if (!conf) {  
4836 - return SRS_CONF_DEFAULT_HLS_ACODEC; 4788 + conf = conf->get("hls_acodec");
  4789 + if (!conf || conf->arg0().empty()) {
  4790 + return DEFAULT;
4837 } 4791 }
4838 - 4792 +
4839 return conf->arg0(); 4793 return conf->arg0();
4840 } 4794 }
4841 4795
4842 string SrsConfig::get_hls_vcodec(string vhost) 4796 string SrsConfig::get_hls_vcodec(string vhost)
4843 { 4797 {
4844 - SrsConfDirective* hls = get_hls(vhost); 4798 + static string DEFAULT = "h264";
4845 4799
4846 - if (!hls) {  
4847 - return SRS_CONF_DEFAULT_HLS_VCODEC; 4800 + SrsConfDirective* conf = get_hls(vhost);
  4801 + if (!conf) {
  4802 + return DEFAULT;
4848 } 4803 }
4849 4804
4850 - SrsConfDirective* conf = hls->get("hls_vcodec");  
4851 - 4805 + conf = conf->get("hls_vcodec");
4852 if (!conf || conf->arg0().empty()) { 4806 if (!conf || conf->arg0().empty()) {
4853 - return SRS_CONF_DEFAULT_HLS_VCODEC; 4807 + return DEFAULT;
4854 } 4808 }
4855 - 4809 +
4856 return conf->arg0(); 4810 return conf->arg0();
4857 } 4811 }
4858 4812
4859 int SrsConfig::get_vhost_hls_nb_notify(string vhost) 4813 int SrsConfig::get_vhost_hls_nb_notify(string vhost)
4860 { 4814 {
4861 - SrsConfDirective* conf = get_hls(vhost); 4815 + static int DEFAULT = 64;
4862 4816
  4817 + SrsConfDirective* conf = get_hls(vhost);
4863 if (!conf) { 4818 if (!conf) {
4864 - return SRS_CONF_DEFAULT_HLS_NB_NOTIFY; 4819 + return DEFAULT;
4865 } 4820 }
4866 4821
4867 conf = conf->get("hls_nb_notify"); 4822 conf = conf->get("hls_nb_notify");
4868 if (!conf || conf->arg0().empty()) { 4823 if (!conf || conf->arg0().empty()) {
4869 - return SRS_CONF_DEFAULT_HLS_NB_NOTIFY; 4824 + return DEFAULT;
4870 } 4825 }
4871 4826
4872 return ::atoi(conf->arg0().c_str()); 4827 return ::atoi(conf->arg0().c_str());
@@ -4874,16 +4829,16 @@ int SrsConfig::get_vhost_hls_nb_notify(string vhost) @@ -4874,16 +4829,16 @@ int SrsConfig::get_vhost_hls_nb_notify(string vhost)
4874 4829
4875 bool SrsConfig::get_hls_cleanup(string vhost) 4830 bool SrsConfig::get_hls_cleanup(string vhost)
4876 { 4831 {
4877 - SrsConfDirective* hls = get_hls(vhost); 4832 + static bool DEFAULT = true;
4878 4833
4879 - if (!hls) {  
4880 - return SRS_CONF_DEFAULT_HLS_CLEANUP; 4834 + SrsConfDirective* conf = get_hls(vhost);
  4835 + if (!conf) {
  4836 + return DEFAULT;
4881 } 4837 }
4882 4838
4883 - SrsConfDirective* conf = hls->get("hls_cleanup");  
4884 - 4839 + conf = conf->get("hls_cleanup");
4885 if (!conf || conf->arg0().empty()) { 4840 if (!conf || conf->arg0().empty()) {
4886 - return SRS_CONF_DEFAULT_HLS_CLEANUP; 4841 + return DEFAULT;
4887 } 4842 }
4888 4843
4889 return SRS_CONF_PERFER_TRUE(conf->arg0()); 4844 return SRS_CONF_PERFER_TRUE(conf->arg0());
@@ -4891,10 +4846,9 @@ bool SrsConfig::get_hls_cleanup(string vhost) @@ -4891,10 +4846,9 @@ bool SrsConfig::get_hls_cleanup(string vhost)
4891 4846
4892 int SrsConfig::get_hls_dispose(string vhost) 4847 int SrsConfig::get_hls_dispose(string vhost)
4893 { 4848 {
4894 - SrsConfDirective* conf = get_hls(vhost);  
4895 -  
4896 - int DEFAULT = 0; 4849 + static int DEFAULT = 0;
4897 4850
  4851 + SrsConfDirective* conf = get_hls(vhost);
4898 if (!conf) { 4852 if (!conf) {
4899 return DEFAULT; 4853 return DEFAULT;
4900 } 4854 }
@@ -4909,16 +4863,16 @@ int SrsConfig::get_hls_dispose(string vhost) @@ -4909,16 +4863,16 @@ int SrsConfig::get_hls_dispose(string vhost)
4909 4863
4910 bool SrsConfig::get_hls_wait_keyframe(string vhost) 4864 bool SrsConfig::get_hls_wait_keyframe(string vhost)
4911 { 4865 {
4912 - SrsConfDirective* hls = get_hls(vhost); 4866 + static bool DEFAULT = true;
4913 4867
4914 - if (!hls) {  
4915 - return SRS_CONF_DEFAULT_HLS_WAIT_KEYFRAME; 4868 + SrsConfDirective* conf = get_hls(vhost);
  4869 + if (!conf) {
  4870 + return DEFAULT;
4916 } 4871 }
4917 4872
4918 - SrsConfDirective* conf = hls->get("hls_wait_keyframe");  
4919 - 4873 + conf = conf->get("hls_wait_keyframe");
4920 if (!conf || conf->arg0().empty()) { 4874 if (!conf || conf->arg0().empty()) {
4921 - return SRS_CONF_DEFAULT_HLS_WAIT_KEYFRAME; 4875 + return DEFAULT;
4922 } 4876 }
4923 4877
4924 return SRS_CONF_PERFER_TRUE(conf->arg0()); 4878 return SRS_CONF_PERFER_TRUE(conf->arg0());
@@ -4937,16 +4891,16 @@ SrsConfDirective *SrsConfig::get_hds(const string &vhost) @@ -4937,16 +4891,16 @@ SrsConfDirective *SrsConfig::get_hds(const string &vhost)
4937 4891
4938 bool SrsConfig::get_hds_enabled(const string &vhost) 4892 bool SrsConfig::get_hds_enabled(const string &vhost)
4939 { 4893 {
4940 - SrsConfDirective* hds = get_hds(vhost);  
4941 -  
4942 - if (!hds) {  
4943 - return false; 4894 + static bool DEFAULT = false;
  4895 +
  4896 + SrsConfDirective* conf = get_hds(vhost);
  4897 + if (!conf) {
  4898 + return DEFAULT;
4944 } 4899 }
4945 4900
4946 - SrsConfDirective* conf = hds->get("enabled");  
4947 - 4901 + conf = conf->get("enabled");
4948 if (!conf || conf->arg0().empty()) { 4902 if (!conf || conf->arg0().empty()) {
4949 - return false; 4903 + return DEFAULT;
4950 } 4904 }
4951 4905
4952 return SRS_CONF_PERFER_FALSE(conf->arg0()); 4906 return SRS_CONF_PERFER_FALSE(conf->arg0());
@@ -4954,59 +4908,58 @@ bool SrsConfig::get_hds_enabled(const string &vhost) @@ -4954,59 +4908,58 @@ bool SrsConfig::get_hds_enabled(const string &vhost)
4954 4908
4955 string SrsConfig::get_hds_path(const string &vhost) 4909 string SrsConfig::get_hds_path(const string &vhost)
4956 { 4910 {
4957 - SrsConfDirective* hds = get_hds(vhost);  
4958 -  
4959 - if (!hds) {  
4960 - return SRS_CONF_DEFAULT_HDS_PATH;  
4961 - }  
4962 -  
4963 - SrsConfDirective* conf = hds->get("hds_path");  
4964 - 4911 + static string DEFAULT = "./objs/nginx/html";
  4912 +
  4913 + SrsConfDirective* conf = get_hds(vhost);
4965 if (!conf) { 4914 if (!conf) {
4966 - return SRS_CONF_DEFAULT_HDS_PATH; 4915 + return DEFAULT;
4967 } 4916 }
4968 - 4917 +
  4918 + conf = conf->get("hds_path");
  4919 + if (!conf || conf->arg0().empty()) {
  4920 + return DEFAULT;
  4921 + }
  4922 +
4969 return conf->arg0(); 4923 return conf->arg0();
4970 } 4924 }
4971 4925
4972 double SrsConfig::get_hds_fragment(const string &vhost) 4926 double SrsConfig::get_hds_fragment(const string &vhost)
4973 { 4927 {
4974 - SrsConfDirective* hds = get_hds(vhost);  
4975 -  
4976 - if (!hds) {  
4977 - return SRS_CONF_DEFAULT_HDS_FRAGMENT;  
4978 - }  
4979 -  
4980 - SrsConfDirective* conf = hds->get("hds_fragment");  
4981 - 4928 + static double DEFAULT = 10;
  4929 +
  4930 + SrsConfDirective* conf = get_hds(vhost);
4982 if (!conf) { 4931 if (!conf) {
4983 - return SRS_CONF_DEFAULT_HDS_FRAGMENT; 4932 + return DEFAULT;
4984 } 4933 }
4985 - 4934 +
  4935 + conf = conf->get("hds_fragment");
  4936 + if (!conf || conf->arg0().empty()) {
  4937 + return DEFAULT;
  4938 + }
  4939 +
4986 return ::atof(conf->arg0().c_str()); 4940 return ::atof(conf->arg0().c_str());
4987 } 4941 }
4988 4942
4989 double SrsConfig::get_hds_window(const string &vhost) 4943 double SrsConfig::get_hds_window(const string &vhost)
4990 { 4944 {
4991 - SrsConfDirective* hds = get_hds(vhost);  
4992 -  
4993 - if (!hds) {  
4994 - return SRS_CONF_DEFAULT_HDS_WINDOW;  
4995 - }  
4996 -  
4997 - SrsConfDirective* conf = hds->get("hds_window");  
4998 - 4945 + static double DEFAULT = 60;
  4946 +
  4947 + SrsConfDirective* conf = get_hds(vhost);
4999 if (!conf) { 4948 if (!conf) {
5000 - return SRS_CONF_DEFAULT_HDS_WINDOW; 4949 + return DEFAULT;
5001 } 4950 }
5002 - 4951 +
  4952 + conf = conf->get("hds_window");
  4953 + if (!conf || conf->arg0().empty()) {
  4954 + return DEFAULT;
  4955 + }
  4956 +
5003 return ::atof(conf->arg0().c_str()); 4957 return ::atof(conf->arg0().c_str());
5004 } 4958 }
5005 4959
5006 SrsConfDirective* SrsConfig::get_dvr(string vhost) 4960 SrsConfDirective* SrsConfig::get_dvr(string vhost)
5007 { 4961 {
5008 SrsConfDirective* conf = get_vhost(vhost); 4962 SrsConfDirective* conf = get_vhost(vhost);
5009 -  
5010 if (!conf) { 4963 if (!conf) {
5011 return NULL; 4964 return NULL;
5012 } 4965 }
@@ -5016,16 +4969,16 @@ SrsConfDirective* SrsConfig::get_dvr(string vhost) @@ -5016,16 +4969,16 @@ SrsConfDirective* SrsConfig::get_dvr(string vhost)
5016 4969
5017 bool SrsConfig::get_dvr_enabled(string vhost) 4970 bool SrsConfig::get_dvr_enabled(string vhost)
5018 { 4971 {
5019 - SrsConfDirective* dvr = get_dvr(vhost); 4972 + static bool DEFAULT = false;
5020 4973
5021 - if (!dvr) {  
5022 - return false; 4974 + SrsConfDirective* conf = get_dvr(vhost);
  4975 + if (!conf) {
  4976 + return DEFAULT;
5023 } 4977 }
5024 4978
5025 - SrsConfDirective* conf = dvr->get("enabled");  
5026 - 4979 + conf = conf->get("enabled");
5027 if (!conf || conf->arg0().empty()) { 4980 if (!conf || conf->arg0().empty()) {
5028 - return false; 4981 + return DEFAULT;
5029 } 4982 }
5030 4983
5031 return SRS_CONF_PERFER_FALSE(conf->arg0()); 4984 return SRS_CONF_PERFER_FALSE(conf->arg0());
@@ -5033,16 +4986,16 @@ bool SrsConfig::get_dvr_enabled(string vhost) @@ -5033,16 +4986,16 @@ bool SrsConfig::get_dvr_enabled(string vhost)
5033 4986
5034 string SrsConfig::get_dvr_path(string vhost) 4987 string SrsConfig::get_dvr_path(string vhost)
5035 { 4988 {
5036 - SrsConfDirective* dvr = get_dvr(vhost); 4989 + static string DEFAULT = "./objs/nginx/html/[app]/[stream].[timestamp].flv";
5037 4990
5038 - if (!dvr) {  
5039 - return SRS_CONF_DEFAULT_DVR_PATH; 4991 + SrsConfDirective* conf = get_dvr(vhost);
  4992 + if (!conf) {
  4993 + return DEFAULT;
5040 } 4994 }
5041 4995
5042 - SrsConfDirective* conf = dvr->get("dvr_path");  
5043 -  
5044 - if (!conf) {  
5045 - return SRS_CONF_DEFAULT_DVR_PATH; 4996 + conf = conf->get("dvr_path");
  4997 + if (!conf || conf->arg0().empty()) {
  4998 + return DEFAULT;
5046 } 4999 }
5047 5000
5048 return conf->arg0(); 5001 return conf->arg0();
@@ -5050,16 +5003,16 @@ string SrsConfig::get_dvr_path(string vhost) @@ -5050,16 +5003,16 @@ string SrsConfig::get_dvr_path(string vhost)
5050 5003
5051 string SrsConfig::get_dvr_plan(string vhost) 5004 string SrsConfig::get_dvr_plan(string vhost)
5052 { 5005 {
5053 - SrsConfDirective* dvr = get_dvr(vhost); 5006 + static string DEFAULT = "session";
5054 5007
5055 - if (!dvr) {  
5056 - return SRS_CONF_DEFAULT_DVR_PLAN; 5008 + SrsConfDirective* conf = get_dvr(vhost);
  5009 + if (!conf) {
  5010 + return DEFAULT;
5057 } 5011 }
5058 5012
5059 - SrsConfDirective* conf = dvr->get("dvr_plan");  
5060 -  
5061 - if (!conf) {  
5062 - return SRS_CONF_DEFAULT_DVR_PLAN; 5013 + conf = conf->get("dvr_plan");
  5014 + if (!conf || conf->arg0().empty()) {
  5015 + return DEFAULT;
5063 } 5016 }
5064 5017
5065 return conf->arg0(); 5018 return conf->arg0();
@@ -5067,16 +5020,16 @@ string SrsConfig::get_dvr_plan(string vhost) @@ -5067,16 +5020,16 @@ string SrsConfig::get_dvr_plan(string vhost)
5067 5020
5068 int SrsConfig::get_dvr_duration(string vhost) 5021 int SrsConfig::get_dvr_duration(string vhost)
5069 { 5022 {
5070 - SrsConfDirective* dvr = get_dvr(vhost); 5023 + static int DEFAULT = 30;
5071 5024
5072 - if (!dvr) {  
5073 - return SRS_CONF_DEFAULT_DVR_DURATION; 5025 + SrsConfDirective* conf = get_dvr(vhost);
  5026 + if (!conf) {
  5027 + return DEFAULT;
5074 } 5028 }
5075 5029
5076 - SrsConfDirective* conf = dvr->get("dvr_duration");  
5077 -  
5078 - if (!conf) {  
5079 - return SRS_CONF_DEFAULT_DVR_DURATION; 5030 + conf = conf->get("dvr_duration");
  5031 + if (!conf || conf->arg0().empty()) {
  5032 + return DEFAULT;
5080 } 5033 }
5081 5034
5082 return ::atoi(conf->arg0().c_str()); 5035 return ::atoi(conf->arg0().c_str());
@@ -5084,16 +5037,16 @@ int SrsConfig::get_dvr_duration(string vhost) @@ -5084,16 +5037,16 @@ int SrsConfig::get_dvr_duration(string vhost)
5084 5037
5085 bool SrsConfig::get_dvr_wait_keyframe(string vhost) 5038 bool SrsConfig::get_dvr_wait_keyframe(string vhost)
5086 { 5039 {
5087 - SrsConfDirective* dvr = get_dvr(vhost); 5040 + static bool DEFAULT = true;
5088 5041
5089 - if (!dvr) {  
5090 - return true; 5042 + SrsConfDirective* conf = get_dvr(vhost);
  5043 + if (!conf) {
  5044 + return DEFAULT;
5091 } 5045 }
5092 5046
5093 - SrsConfDirective* conf = dvr->get("dvr_wait_keyframe");  
5094 - 5047 + conf = conf->get("dvr_wait_keyframe");
5095 if (!conf || conf->arg0().empty()) { 5048 if (!conf || conf->arg0().empty()) {
5096 - return true; 5049 + return DEFAULT;
5097 } 5050 }
5098 5051
5099 return SRS_CONF_PERFER_TRUE(conf->arg0()); 5052 return SRS_CONF_PERFER_TRUE(conf->arg0());
@@ -5101,19 +5054,20 @@ bool SrsConfig::get_dvr_wait_keyframe(string vhost) @@ -5101,19 +5054,20 @@ bool SrsConfig::get_dvr_wait_keyframe(string vhost)
5101 5054
5102 int SrsConfig::get_dvr_time_jitter(string vhost) 5055 int SrsConfig::get_dvr_time_jitter(string vhost)
5103 { 5056 {
5104 - SrsConfDirective* dvr = get_dvr(vhost); 5057 + static string DEFAULT = "full";
5105 5058
5106 - std::string time_jitter = SRS_CONF_DEFAULT_TIME_JITTER; 5059 + SrsConfDirective* conf = get_dvr(vhost);
5107 5060
5108 - if (dvr) {  
5109 - SrsConfDirective* conf = dvr->get("time_jitter"); 5061 + if (!conf) {
  5062 + return _srs_time_jitter_string2int(DEFAULT);
  5063 + }
5110 5064
5111 - if (conf) {  
5112 - time_jitter = conf->arg0();  
5113 - } 5065 + conf = conf->get("time_jitter");
  5066 + if (!conf || conf->arg0().empty()) {
  5067 + return _srs_time_jitter_string2int(DEFAULT);
5114 } 5068 }
5115 5069
5116 - return _srs_time_jitter_string2int(time_jitter); 5070 + return _srs_time_jitter_string2int(conf->arg0());
5117 } 5071 }
5118 5072
5119 bool SrsConfig::get_http_api_enabled() 5073 bool SrsConfig::get_http_api_enabled()
@@ -5161,7 +5115,6 @@ bool SrsConfig::get_http_api_crossdomain() @@ -5161,7 +5115,6 @@ bool SrsConfig::get_http_api_crossdomain()
5161 static bool DEFAULT = true; 5115 static bool DEFAULT = true;
5162 5116
5163 SrsConfDirective* conf = root->get("http_api"); 5117 SrsConfDirective* conf = root->get("http_api");
5164 -  
5165 if (!conf) { 5118 if (!conf) {
5166 return DEFAULT; 5119 return DEFAULT;
5167 } 5120 }
@@ -5267,7 +5220,6 @@ string SrsConfig::get_http_stream_listen() @@ -5267,7 +5220,6 @@ string SrsConfig::get_http_stream_listen()
5267 static string DEFAULT = "8080"; 5220 static string DEFAULT = "8080";
5268 5221
5269 SrsConfDirective* conf = root->get("http_server"); 5222 SrsConfDirective* conf = root->get("http_server");
5270 -  
5271 if (!conf) { 5223 if (!conf) {
5272 return DEFAULT; 5224 return DEFAULT;
5273 } 5225 }
@@ -5365,19 +5317,21 @@ string SrsConfig::get_vhost_http_dir(string vhost) @@ -5365,19 +5317,21 @@ string SrsConfig::get_vhost_http_dir(string vhost)
5365 5317
5366 bool SrsConfig::get_vhost_http_remux_enabled(string vhost) 5318 bool SrsConfig::get_vhost_http_remux_enabled(string vhost)
5367 { 5319 {
  5320 + static bool DEFAULT = false;
  5321 +
5368 SrsConfDirective* conf = get_vhost(vhost); 5322 SrsConfDirective* conf = get_vhost(vhost);
5369 if (!conf) { 5323 if (!conf) {
5370 - return false; 5324 + return DEFAULT;
5371 } 5325 }
5372 5326
5373 conf = conf->get("http_remux"); 5327 conf = conf->get("http_remux");
5374 if (!conf) { 5328 if (!conf) {
5375 - return false; 5329 + return DEFAULT;
5376 } 5330 }
5377 5331
5378 conf = conf->get("enabled"); 5332 conf = conf->get("enabled");
5379 if (!conf || conf->arg0().empty()) { 5333 if (!conf || conf->arg0().empty()) {
5380 - return false; 5334 + return DEFAULT;
5381 } 5335 }
5382 5336
5383 return SRS_CONF_PERFER_FALSE(conf->arg0()); 5337 return SRS_CONF_PERFER_FALSE(conf->arg0());
@@ -5385,23 +5339,21 @@ bool SrsConfig::get_vhost_http_remux_enabled(string vhost) @@ -5385,23 +5339,21 @@ bool SrsConfig::get_vhost_http_remux_enabled(string vhost)
5385 5339
5386 double SrsConfig::get_vhost_http_remux_fast_cache(string vhost) 5340 double SrsConfig::get_vhost_http_remux_fast_cache(string vhost)
5387 { 5341 {
  5342 + static double DEFAULT = 0;
  5343 +
5388 SrsConfDirective* conf = get_vhost(vhost); 5344 SrsConfDirective* conf = get_vhost(vhost);
5389 if (!conf) { 5345 if (!conf) {
5390 - return SRS_CONF_DEFAULT_HTTP_AUDIO_FAST_CACHE; 5346 + return DEFAULT;
5391 } 5347 }
5392 5348
5393 conf = conf->get("http_remux"); 5349 conf = conf->get("http_remux");
5394 if (!conf) { 5350 if (!conf) {
5395 - return SRS_CONF_DEFAULT_HTTP_AUDIO_FAST_CACHE; 5351 + return DEFAULT;
5396 } 5352 }
5397 5353
5398 conf = conf->get("fast_cache"); 5354 conf = conf->get("fast_cache");
5399 - if (!conf) {  
5400 - return SRS_CONF_DEFAULT_HTTP_AUDIO_FAST_CACHE;  
5401 - }  
5402 -  
5403 - if (conf->arg0().empty()) {  
5404 - return SRS_CONF_DEFAULT_HTTP_AUDIO_FAST_CACHE; 5355 + if (!conf || conf->arg0().empty()) {
  5356 + return DEFAULT;
5405 } 5357 }
5406 5358
5407 return ::atof(conf->arg0().c_str()); 5359 return ::atof(conf->arg0().c_str());
@@ -5409,19 +5361,21 @@ double SrsConfig::get_vhost_http_remux_fast_cache(string vhost) @@ -5409,19 +5361,21 @@ double SrsConfig::get_vhost_http_remux_fast_cache(string vhost)
5409 5361
5410 string SrsConfig::get_vhost_http_remux_mount(string vhost) 5362 string SrsConfig::get_vhost_http_remux_mount(string vhost)
5411 { 5363 {
  5364 + static string DEFAULT = "[vhost]/[app]/[stream].flv";
  5365 +
5412 SrsConfDirective* conf = get_vhost(vhost); 5366 SrsConfDirective* conf = get_vhost(vhost);
5413 if (!conf) { 5367 if (!conf) {
5414 - return SRS_CONF_DEFAULT_HTTP_REMUX_MOUNT; 5368 + return DEFAULT;
5415 } 5369 }
5416 5370
5417 conf = conf->get("http_remux"); 5371 conf = conf->get("http_remux");
5418 if (!conf) { 5372 if (!conf) {
5419 - return SRS_CONF_DEFAULT_HTTP_REMUX_MOUNT; 5373 + return DEFAULT;
5420 } 5374 }
5421 5375
5422 conf = conf->get("mount"); 5376 conf = conf->get("mount");
5423 if (!conf || conf->arg0().empty()) { 5377 if (!conf || conf->arg0().empty()) {
5424 - return SRS_CONF_DEFAULT_HTTP_REMUX_MOUNT; 5378 + return DEFAULT;
5425 } 5379 }
5426 5380
5427 return conf->arg0(); 5381 return conf->arg0();
@@ -5429,22 +5383,24 @@ string SrsConfig::get_vhost_http_remux_mount(string vhost) @@ -5429,22 +5383,24 @@ string SrsConfig::get_vhost_http_remux_mount(string vhost)
5429 5383
5430 bool SrsConfig::get_vhost_http_remux_hstrs(string vhost) 5384 bool SrsConfig::get_vhost_http_remux_hstrs(string vhost)
5431 { 5385 {
  5386 + static bool DEFAULT = true;
  5387 +
5432 SrsConfDirective* conf = get_vhost(vhost); 5388 SrsConfDirective* conf = get_vhost(vhost);
5433 if (!conf) { 5389 if (!conf) {
5434 - return false; 5390 + return DEFAULT;
5435 } 5391 }
5436 5392
5437 conf = conf->get("http_remux"); 5393 conf = conf->get("http_remux");
5438 if (!conf) { 5394 if (!conf) {
5439 - return false; 5395 + return DEFAULT;
5440 } 5396 }
5441 5397
5442 conf = conf->get("hstrs"); 5398 conf = conf->get("hstrs");
5443 if (!conf || conf->arg0().empty()) { 5399 if (!conf || conf->arg0().empty()) {
5444 - return false; 5400 + return DEFAULT;
5445 } 5401 }
5446 5402
5447 - return SRS_CONF_PERFER_FALSE(conf->arg0()); 5403 + return SRS_CONF_PERFER_TRUE(conf->arg0());
5448 } 5404 }
5449 5405
5450 SrsConfDirective* SrsConfig::get_heartbeart() 5406 SrsConfDirective* SrsConfig::get_heartbeart()
@@ -5454,15 +5410,16 @@ SrsConfDirective* SrsConfig::get_heartbeart() @@ -5454,15 +5410,16 @@ SrsConfDirective* SrsConfig::get_heartbeart()
5454 5410
5455 bool SrsConfig::get_heartbeat_enabled() 5411 bool SrsConfig::get_heartbeat_enabled()
5456 { 5412 {
5457 - SrsConfDirective* conf = get_heartbeart(); 5413 + static bool DEFAULT = false;
5458 5414
  5415 + SrsConfDirective* conf = get_heartbeart();
5459 if (!conf) { 5416 if (!conf) {
5460 - return SRS_CONF_DEFAULT_HTTP_HEAETBEAT_ENABLED; 5417 + return DEFAULT;
5461 } 5418 }
5462 5419
5463 conf = conf->get("enabled"); 5420 conf = conf->get("enabled");
5464 if (!conf || conf->arg0().empty()) { 5421 if (!conf || conf->arg0().empty()) {
5465 - return SRS_CONF_DEFAULT_HTTP_HEAETBEAT_ENABLED; 5422 + return DEFAULT;
5466 } 5423 }
5467 5424
5468 return SRS_CONF_PERFER_FALSE(conf->arg0()); 5425 return SRS_CONF_PERFER_FALSE(conf->arg0());
@@ -5470,14 +5427,16 @@ bool SrsConfig::get_heartbeat_enabled() @@ -5470,14 +5427,16 @@ bool SrsConfig::get_heartbeat_enabled()
5470 5427
5471 int64_t SrsConfig::get_heartbeat_interval() 5428 int64_t SrsConfig::get_heartbeat_interval()
5472 { 5429 {
5473 - SrsConfDirective* conf = get_heartbeart(); 5430 + static int64_t DEFAULT = (int64_t)(9.9 * 1000);
5474 5431
  5432 + SrsConfDirective* conf = get_heartbeart();
5475 if (!conf) { 5433 if (!conf) {
5476 - return (int64_t)(SRS_CONF_DEFAULT_HTTP_HEAETBEAT_INTERVAL * 1000); 5434 + return DEFAULT;
5477 } 5435 }
  5436 +
5478 conf = conf->get("interval"); 5437 conf = conf->get("interval");
5479 if (!conf || conf->arg0().empty()) { 5438 if (!conf || conf->arg0().empty()) {
5480 - return (int64_t)(SRS_CONF_DEFAULT_HTTP_HEAETBEAT_INTERVAL * 1000); 5439 + return DEFAULT;
5481 } 5440 }
5482 5441
5483 return (int64_t)(::atof(conf->arg0().c_str()) * 1000); 5442 return (int64_t)(::atof(conf->arg0().c_str()) * 1000);
@@ -5485,15 +5444,16 @@ int64_t SrsConfig::get_heartbeat_interval() @@ -5485,15 +5444,16 @@ int64_t SrsConfig::get_heartbeat_interval()
5485 5444
5486 string SrsConfig::get_heartbeat_url() 5445 string SrsConfig::get_heartbeat_url()
5487 { 5446 {
5488 - SrsConfDirective* conf = get_heartbeart(); 5447 + static string DEFAULT = "http://"SRS_CONSTS_LOCALHOST":8085/api/v1/servers";
5489 5448
  5449 + SrsConfDirective* conf = get_heartbeart();
5490 if (!conf) { 5450 if (!conf) {
5491 - return SRS_CONF_DEFAULT_HTTP_HEAETBEAT_URL; 5451 + return DEFAULT;
5492 } 5452 }
5493 5453
5494 conf = conf->get("url"); 5454 conf = conf->get("url");
5495 if (!conf || conf->arg0().empty()) { 5455 if (!conf || conf->arg0().empty()) {
5496 - return SRS_CONF_DEFAULT_HTTP_HEAETBEAT_URL; 5456 + return DEFAULT;
5497 } 5457 }
5498 5458
5499 return conf->arg0(); 5459 return conf->arg0();
@@ -5501,15 +5461,16 @@ string SrsConfig::get_heartbeat_url() @@ -5501,15 +5461,16 @@ string SrsConfig::get_heartbeat_url()
5501 5461
5502 string SrsConfig::get_heartbeat_device_id() 5462 string SrsConfig::get_heartbeat_device_id()
5503 { 5463 {
5504 - SrsConfDirective* conf = get_heartbeart(); 5464 + static string DEFAULT = "";
5505 5465
  5466 + SrsConfDirective* conf = get_heartbeart();
5506 if (!conf) { 5467 if (!conf) {
5507 - return ""; 5468 + return DEFAULT;
5508 } 5469 }
5509 5470
5510 conf = conf->get("device_id"); 5471 conf = conf->get("device_id");
5511 if (!conf || conf->arg0().empty()) { 5472 if (!conf || conf->arg0().empty()) {
5512 - return ""; 5473 + return DEFAULT;
5513 } 5474 }
5514 5475
5515 return conf->arg0(); 5476 return conf->arg0();
@@ -5517,15 +5478,16 @@ string SrsConfig::get_heartbeat_device_id() @@ -5517,15 +5478,16 @@ string SrsConfig::get_heartbeat_device_id()
5517 5478
5518 bool SrsConfig::get_heartbeat_summaries() 5479 bool SrsConfig::get_heartbeat_summaries()
5519 { 5480 {
5520 - SrsConfDirective* conf = get_heartbeart(); 5481 + static bool DEFAULT = false;
5521 5482
  5483 + SrsConfDirective* conf = get_heartbeart();
5522 if (!conf) { 5484 if (!conf) {
5523 - return SRS_CONF_DEFAULT_HTTP_HEAETBEAT_SUMMARIES; 5485 + return DEFAULT;
5524 } 5486 }
5525 5487
5526 conf = conf->get("summaries"); 5488 conf = conf->get("summaries");
5527 if (!conf || conf->arg0().empty()) { 5489 if (!conf || conf->arg0().empty()) {
5528 - return SRS_CONF_DEFAULT_HTTP_HEAETBEAT_SUMMARIES; 5490 + return DEFAULT;
5529 } 5491 }
5530 5492
5531 return SRS_CONF_PERFER_FALSE(conf->arg0()); 5493 return SRS_CONF_PERFER_FALSE(conf->arg0());
@@ -5538,15 +5500,16 @@ SrsConfDirective* SrsConfig::get_stats() @@ -5538,15 +5500,16 @@ SrsConfDirective* SrsConfig::get_stats()
5538 5500
5539 int SrsConfig::get_stats_network() 5501 int SrsConfig::get_stats_network()
5540 { 5502 {
5541 - SrsConfDirective* conf = get_stats(); 5503 + static int DEFAULT = 0;
5542 5504
  5505 + SrsConfDirective* conf = get_stats();
5543 if (!conf) { 5506 if (!conf) {
5544 - return SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX; 5507 + return DEFAULT;
5545 } 5508 }
5546 5509
5547 conf = conf->get("network"); 5510 conf = conf->get("network");
5548 if (!conf || conf->arg0().empty()) { 5511 if (!conf || conf->arg0().empty()) {
5549 - return SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX; 5512 + return DEFAULT;
5550 } 5513 }
5551 5514
5552 return ::atoi(conf->arg0().c_str()); 5515 return ::atoi(conf->arg0().c_str());
@@ -5555,7 +5518,6 @@ int SrsConfig::get_stats_network() @@ -5555,7 +5518,6 @@ int SrsConfig::get_stats_network()
5555 SrsConfDirective* SrsConfig::get_stats_disk_device() 5518 SrsConfDirective* SrsConfig::get_stats_disk_device()
5556 { 5519 {
5557 SrsConfDirective* conf = get_stats(); 5520 SrsConfDirective* conf = get_stats();
5558 -  
5559 if (!conf) { 5521 if (!conf) {
5560 return NULL; 5522 return NULL;
5561 } 5523 }
@@ -5663,52 +5625,52 @@ bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b) @@ -5663,52 +5625,52 @@ bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b)
5663 5625
5664 bool srs_config_hls_is_on_error_ignore(string strategy) 5626 bool srs_config_hls_is_on_error_ignore(string strategy)
5665 { 5627 {
5666 - return strategy == SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE; 5628 + return strategy == "ignore";
5667 } 5629 }
5668 5630
5669 bool srs_config_hls_is_on_error_continue(string strategy) 5631 bool srs_config_hls_is_on_error_continue(string strategy)
5670 { 5632 {
5671 - return strategy == SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE; 5633 + return strategy == "continue";
5672 } 5634 }
5673 5635
5674 bool srs_config_ingest_is_file(string type) 5636 bool srs_config_ingest_is_file(string type)
5675 { 5637 {
5676 - return type == SRS_CONF_DEFAULT_INGEST_TYPE_FILE; 5638 + return type == "file";
5677 } 5639 }
5678 5640
5679 bool srs_config_ingest_is_stream(string type) 5641 bool srs_config_ingest_is_stream(string type)
5680 { 5642 {
5681 - return type == SRS_CONF_DEFAULT_INGEST_TYPE_STREAM; 5643 + return type == "stream";
5682 } 5644 }
5683 5645
5684 bool srs_config_dvr_is_plan_segment(string plan) 5646 bool srs_config_dvr_is_plan_segment(string plan)
5685 { 5647 {
5686 - return plan == SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT; 5648 + return plan == "segment";
5687 } 5649 }
5688 5650
5689 bool srs_config_dvr_is_plan_session(string plan) 5651 bool srs_config_dvr_is_plan_session(string plan)
5690 { 5652 {
5691 - return plan == SRS_CONF_DEFAULT_DVR_PLAN_SESSION; 5653 + return plan == "session";
5692 } 5654 }
5693 5655
5694 bool srs_config_dvr_is_plan_append(string plan) 5656 bool srs_config_dvr_is_plan_append(string plan)
5695 { 5657 {
5696 - return plan == SRS_CONF_DEFAULT_DVR_PLAN_APPEND; 5658 + return plan == "append";
5697 } 5659 }
5698 5660
5699 bool srs_stream_caster_is_udp(string caster) 5661 bool srs_stream_caster_is_udp(string caster)
5700 { 5662 {
5701 - return caster == SRS_CONF_DEFAULT_STREAM_CASTER_MPEGTS_OVER_UDP; 5663 + return caster == "mpegts_over_udp";
5702 } 5664 }
5703 5665
5704 bool srs_stream_caster_is_rtsp(string caster) 5666 bool srs_stream_caster_is_rtsp(string caster)
5705 { 5667 {
5706 - return caster == SRS_CONF_DEFAULT_STREAM_CASTER_RTSP; 5668 + return caster == "rtsp";
5707 } 5669 }
5708 5670
5709 bool srs_stream_caster_is_flv(string caster) 5671 bool srs_stream_caster_is_flv(string caster)
5710 { 5672 {
5711 - return caster == SRS_CONF_DEFAULT_STREAM_CASTER_FLV; 5673 + return caster == "flv";
5712 } 5674 }
5713 5675
5714 int srs_config_transform_vhost(SrsConfDirective* root) 5676 int srs_config_transform_vhost(SrsConfDirective* root)
@@ -431,27 +431,27 @@ public: @@ -431,27 +431,27 @@ public:
431 /** 431 /**
432 * get whether the specified stream_caster is enabled. 432 * get whether the specified stream_caster is enabled.
433 */ 433 */
434 - virtual bool get_stream_caster_enabled(SrsConfDirective* sc); 434 + virtual bool get_stream_caster_enabled(SrsConfDirective* conf);
435 /** 435 /**
436 * get the engine of stream_caster, the caster config. 436 * get the engine of stream_caster, the caster config.
437 */ 437 */
438 - virtual std::string get_stream_caster_engine(SrsConfDirective* sc); 438 + virtual std::string get_stream_caster_engine(SrsConfDirective* conf);
439 /** 439 /**
440 * get the output rtmp url of stream_caster, the output config. 440 * get the output rtmp url of stream_caster, the output config.
441 */ 441 */
442 - virtual std::string get_stream_caster_output(SrsConfDirective* sc); 442 + virtual std::string get_stream_caster_output(SrsConfDirective* conf);
443 /** 443 /**
444 * get the listen port of stream caster. 444 * get the listen port of stream caster.
445 */ 445 */
446 - virtual int get_stream_caster_listen(SrsConfDirective* sc); 446 + virtual int get_stream_caster_listen(SrsConfDirective* conf);
447 /** 447 /**
448 * get the min udp port for rtp of stream caster rtsp. 448 * get the min udp port for rtp of stream caster rtsp.
449 */ 449 */
450 - virtual int get_stream_caster_rtp_port_min(SrsConfDirective* sc); 450 + virtual int get_stream_caster_rtp_port_min(SrsConfDirective* conf);
451 /** 451 /**
452 * get the max udp port for rtp of stream caster rtsp. 452 * get the max udp port for rtp of stream caster rtsp.
453 */ 453 */
454 - virtual int get_stream_caster_rtp_port_max(SrsConfDirective* sc); 454 + virtual int get_stream_caster_rtp_port_max(SrsConfDirective* conf);
455 // vhost specified section 455 // vhost specified section
456 public: 456 public:
457 /** 457 /**
@@ -474,7 +474,7 @@ public: @@ -474,7 +474,7 @@ public:
474 * @param vhost, the vhost directive. 474 * @param vhost, the vhost directive.
475 * @return true when vhost is ok; otherwise, false. 475 * @return true when vhost is ok; otherwise, false.
476 */ 476 */
477 - virtual bool get_vhost_enabled(SrsConfDirective* vhost); 477 + virtual bool get_vhost_enabled(SrsConfDirective* conf);
478 /** 478 /**
479 * whether gop_cache is enabled of vhost. 479 * whether gop_cache is enabled of vhost.
480 * gop_cache used to cache last gop, for client to fast startup. 480 * gop_cache used to cache last gop, for client to fast startup.
@@ -530,8 +530,7 @@ public: @@ -530,8 +530,7 @@ public:
530 * get the refer hotlink-denial for all type. 530 * get the refer hotlink-denial for all type.
531 * @return the refer, NULL for not configed. 531 * @return the refer, NULL for not configed.
532 */ 532 */
533 - // TODO: FIXME: rename to get_refer_all  
534 - virtual SrsConfDirective* get_refer(std::string vhost); 533 + virtual SrsConfDirective* get_refer_all(std::string vhost);
535 /** 534 /**
536 * get the refer hotlink-denial for play. 535 * get the refer hotlink-denial for play.
537 * @return the refer, NULL for not configed. 536 * @return the refer, NULL for not configed.
@@ -698,7 +697,7 @@ public: @@ -698,7 +697,7 @@ public:
698 * for edge, publish client will be proxyed to upnode, 697 * for edge, publish client will be proxyed to upnode,
699 * for edge, play client will share a connection to get stream from upnode. 698 * for edge, play client will share a connection to get stream from upnode.
700 */ 699 */
701 - virtual bool get_vhost_is_edge(SrsConfDirective* vhost); 700 + virtual bool get_vhost_is_edge(SrsConfDirective* conf);
702 /** 701 /**
703 * get the origin config of edge, 702 * get the origin config of edge,
704 * specifies the origin ip address, port. 703 * specifies the origin ip address, port.
@@ -743,106 +742,106 @@ public: @@ -743,106 +742,106 @@ public:
743 /** 742 /**
744 * whether the transcode directive is enabled. 743 * whether the transcode directive is enabled.
745 */ 744 */
746 - virtual bool get_transcode_enabled(SrsConfDirective* transcode); 745 + virtual bool get_transcode_enabled(SrsConfDirective* conf);
747 /** 746 /**
748 * get the ffmpeg tool path of transcode. 747 * get the ffmpeg tool path of transcode.
749 */ 748 */
750 - virtual std::string get_transcode_ffmpeg(SrsConfDirective* transcode); 749 + virtual std::string get_transcode_ffmpeg(SrsConfDirective* conf);
751 /** 750 /**
752 * get the engines of transcode. 751 * get the engines of transcode.
753 */ 752 */
754 - virtual std::vector<SrsConfDirective*> get_transcode_engines(SrsConfDirective* transcode); 753 + virtual std::vector<SrsConfDirective*> get_transcode_engines(SrsConfDirective* conf);
755 /** 754 /**
756 * whether the engine is enabled. 755 * whether the engine is enabled.
757 */ 756 */
758 - virtual bool get_engine_enabled(SrsConfDirective* engine); 757 + virtual bool get_engine_enabled(SrsConfDirective* conf);
759 /** 758 /**
760 * get the iformat of engine 759 * get the iformat of engine
761 */ 760 */
762 - virtual std::string get_engine_iformat(SrsConfDirective* engine); 761 + virtual std::string get_engine_iformat(SrsConfDirective* conf);
763 /** 762 /**
764 * get the vfilter of engine, 763 * get the vfilter of engine,
765 * the video filter set before the vcodec of FFMPEG. 764 * the video filter set before the vcodec of FFMPEG.
766 */ 765 */
767 - virtual std::vector<std::string> get_engine_vfilter(SrsConfDirective* engine); 766 + virtual std::vector<std::string> get_engine_vfilter(SrsConfDirective* conf);
768 /** 767 /**
769 * get the vcodec of engine, 768 * get the vcodec of engine,
770 * the codec of video, can be vn, copy or libx264 769 * the codec of video, can be vn, copy or libx264
771 */ 770 */
772 - virtual std::string get_engine_vcodec(SrsConfDirective* engine); 771 + virtual std::string get_engine_vcodec(SrsConfDirective* conf);
773 /** 772 /**
774 * get the vbitrate of engine, 773 * get the vbitrate of engine,
775 * the bitrate in kbps of video, for example, 800kbps 774 * the bitrate in kbps of video, for example, 800kbps
776 */ 775 */
777 - virtual int get_engine_vbitrate(SrsConfDirective* engine); 776 + virtual int get_engine_vbitrate(SrsConfDirective* conf);
778 /** 777 /**
779 * get the vfps of engine. 778 * get the vfps of engine.
780 * the video fps, for example, 25fps 779 * the video fps, for example, 25fps
781 */ 780 */
782 - virtual double get_engine_vfps(SrsConfDirective* engine); 781 + virtual double get_engine_vfps(SrsConfDirective* conf);
783 /** 782 /**
784 * get the vwidth of engine, 783 * get the vwidth of engine,
785 * the video width, for example, 1024 784 * the video width, for example, 1024
786 */ 785 */
787 - virtual int get_engine_vwidth(SrsConfDirective* engine); 786 + virtual int get_engine_vwidth(SrsConfDirective* conf);
788 /** 787 /**
789 * get the vheight of engine, 788 * get the vheight of engine,
790 * the video height, for example, 576 789 * the video height, for example, 576
791 */ 790 */
792 - virtual int get_engine_vheight(SrsConfDirective* engine); 791 + virtual int get_engine_vheight(SrsConfDirective* conf);
793 /** 792 /**
794 * get the vthreads of engine, 793 * get the vthreads of engine,
795 * the video transcode libx264 threads, for instance, 8 794 * the video transcode libx264 threads, for instance, 8
796 */ 795 */
797 - virtual int get_engine_vthreads(SrsConfDirective* engine); 796 + virtual int get_engine_vthreads(SrsConfDirective* conf);
798 /** 797 /**
799 * get the vprofile of engine, 798 * get the vprofile of engine,
800 * the libx264 profile, can be high,main,baseline 799 * the libx264 profile, can be high,main,baseline
801 */ 800 */
802 - virtual std::string get_engine_vprofile(SrsConfDirective* engine); 801 + virtual std::string get_engine_vprofile(SrsConfDirective* conf);
803 /** 802 /**
804 * get the vpreset of engine, 803 * get the vpreset of engine,
805 * the libx264 preset, can be ultrafast,superfast,veryfast,faster,fast,medium,slow,slower,veryslow,placebo 804 * the libx264 preset, can be ultrafast,superfast,veryfast,faster,fast,medium,slow,slower,veryslow,placebo
806 */ 805 */
807 - virtual std::string get_engine_vpreset(SrsConfDirective* engine); 806 + virtual std::string get_engine_vpreset(SrsConfDirective* conf);
808 /** 807 /**
809 * get the additional video params. 808 * get the additional video params.
810 */ 809 */
811 - virtual std::vector<std::string> get_engine_vparams(SrsConfDirective* engine); 810 + virtual std::vector<std::string> get_engine_vparams(SrsConfDirective* conf);
812 /** 811 /**
813 * get the acodec of engine, 812 * get the acodec of engine,
814 * the audio codec can be an, copy or libfdk_aac 813 * the audio codec can be an, copy or libfdk_aac
815 */ 814 */
816 - virtual std::string get_engine_acodec(SrsConfDirective* engine); 815 + virtual std::string get_engine_acodec(SrsConfDirective* conf);
817 /** 816 /**
818 * get the abitrate of engine, 817 * get the abitrate of engine,
819 * the audio bitrate in kbps, for instance, 64kbps. 818 * the audio bitrate in kbps, for instance, 64kbps.
820 */ 819 */
821 - virtual int get_engine_abitrate(SrsConfDirective* engine); 820 + virtual int get_engine_abitrate(SrsConfDirective* conf);
822 /** 821 /**
823 * get the asample_rate of engine, 822 * get the asample_rate of engine,
824 * the audio sample_rate, for instance, 44100HZ 823 * the audio sample_rate, for instance, 44100HZ
825 */ 824 */
826 - virtual int get_engine_asample_rate(SrsConfDirective* engine); 825 + virtual int get_engine_asample_rate(SrsConfDirective* conf);
827 /** 826 /**
828 * get the achannels of engine, 827 * get the achannels of engine,
829 * the audio channel, for instance, 1 for mono, 2 for stereo. 828 * the audio channel, for instance, 1 for mono, 2 for stereo.
830 */ 829 */
831 - virtual int get_engine_achannels(SrsConfDirective* engine); 830 + virtual int get_engine_achannels(SrsConfDirective* conf);
832 /** 831 /**
833 * get the aparams of engine, 832 * get the aparams of engine,
834 * the audio additional params. 833 * the audio additional params.
835 */ 834 */
836 - virtual std::vector<std::string> get_engine_aparams(SrsConfDirective* engine); 835 + virtual std::vector<std::string> get_engine_aparams(SrsConfDirective* conf);
837 /** 836 /**
838 * get the oformat of engine 837 * get the oformat of engine
839 */ 838 */
840 - virtual std::string get_engine_oformat(SrsConfDirective* engine); 839 + virtual std::string get_engine_oformat(SrsConfDirective* conf);
841 /** 840 /**
842 * get the output of engine, for example, rtmp://localhost/live/livestream, 841 * get the output of engine, for example, rtmp://localhost/live/livestream,
843 * @remark, we will use some variable, for instance, [vhost] to substitude with vhost. 842 * @remark, we will use some variable, for instance, [vhost] to substitude with vhost.
844 */ 843 */
845 - virtual std::string get_engine_output(SrsConfDirective* engine); 844 + virtual std::string get_engine_output(SrsConfDirective* conf);
846 // vhost exec secion 845 // vhost exec secion
847 private: 846 private:
848 /** 847 /**
@@ -871,19 +870,19 @@ public: @@ -871,19 +870,19 @@ public:
871 /** 870 /**
872 * whether ingest is enalbed. 871 * whether ingest is enalbed.
873 */ 872 */
874 - virtual bool get_ingest_enabled(SrsConfDirective* ingest); 873 + virtual bool get_ingest_enabled(SrsConfDirective* conf);
875 /** 874 /**
876 * get the ingest ffmpeg tool 875 * get the ingest ffmpeg tool
877 */ 876 */
878 - virtual std::string get_ingest_ffmpeg(SrsConfDirective* ingest); 877 + virtual std::string get_ingest_ffmpeg(SrsConfDirective* conf);
879 /** 878 /**
880 * get the ingest input type, file or stream. 879 * get the ingest input type, file or stream.
881 */ 880 */
882 - virtual std::string get_ingest_input_type(SrsConfDirective* ingest); 881 + virtual std::string get_ingest_input_type(SrsConfDirective* conf);
883 /** 882 /**
884 * get the ingest input url. 883 * get the ingest input url.
885 */ 884 */
886 - virtual std::string get_ingest_input_url(SrsConfDirective* ingest); 885 + virtual std::string get_ingest_input_url(SrsConfDirective* conf);
887 // log section 886 // log section
888 public: 887 public:
889 /** 888 /**
@@ -580,7 +580,7 @@ int SrsRtmpConn::check_vhost() @@ -580,7 +580,7 @@ int SrsRtmpConn::check_vhost()
580 } 580 }
581 581
582 if (_srs_config->get_refer_enabled(req->vhost)) { 582 if (_srs_config->get_refer_enabled(req->vhost)) {
583 - if ((ret = refer->check(req->pageUrl, _srs_config->get_refer(req->vhost))) != ERROR_SUCCESS) { 583 + if ((ret = refer->check(req->pageUrl, _srs_config->get_refer_all(req->vhost))) != ERROR_SUCCESS) {
584 srs_error("check refer failed. ret=%d", ret); 584 srs_error("check refer failed. ret=%d", ret);
585 return ret; 585 return ret;
586 } 586 }