|
|
|
@ -130,7 +130,8 @@ void ffserver_parse_acl_row(FFServerStream *stream, FFServerStream* feed, |
|
|
|
|
|
|
|
|
|
if (arg[0]) { |
|
|
|
|
if (resolve_host(&acl.last, arg) != 0) { |
|
|
|
|
fprintf(stderr, "%s:%d: ACL refers to invalid host or IP address '%s'\n", |
|
|
|
|
fprintf(stderr, |
|
|
|
|
"%s:%d: ACL refers to invalid host or IP address '%s'\n", |
|
|
|
|
filename, line_num, arg); |
|
|
|
|
errors++; |
|
|
|
|
} |
|
|
|
@ -297,7 +298,8 @@ static int ffserver_opt_preset(const char *arg, |
|
|
|
|
} else if(!strcmp(tmp, "scodec")) { |
|
|
|
|
/* opt_subtitle_codec(tmp2); */ |
|
|
|
|
} else if (avctx && (ret = ffserver_opt_default(tmp, tmp2, avctx, type)) < 0) { |
|
|
|
|
fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", filename, line, tmp, tmp2); |
|
|
|
|
fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as " |
|
|
|
|
"'%s' = '%s'\n", filename, line, tmp, tmp2); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -315,7 +317,8 @@ static AVOutputFormat *ffserver_guess_format(const char *short_name, const char |
|
|
|
|
AVOutputFormat *stream_fmt; |
|
|
|
|
char stream_format_name[64]; |
|
|
|
|
|
|
|
|
|
snprintf(stream_format_name, sizeof(stream_format_name), "%s_stream", fmt->name); |
|
|
|
|
snprintf(stream_format_name, sizeof(stream_format_name), "%s_stream", |
|
|
|
|
fmt->name); |
|
|
|
|
stream_fmt = av_guess_format(stream_format_name, NULL, NULL); |
|
|
|
|
|
|
|
|
|
if (stream_fmt) |
|
|
|
@ -365,7 +368,8 @@ static int ffserver_set_int_param(int *dest, const char *value, int factor, int |
|
|
|
|
if (config) { |
|
|
|
|
va_list vl; |
|
|
|
|
va_start(vl, error_msg); |
|
|
|
|
vreport_config_error(config->filename, line_num, AV_LOG_ERROR, &config->errors, error_msg, vl); |
|
|
|
|
vreport_config_error(config->filename, line_num, AV_LOG_ERROR, |
|
|
|
|
&config->errors, error_msg, vl); |
|
|
|
|
va_end(vl); |
|
|
|
|
} |
|
|
|
|
return AVERROR(EINVAL); |
|
|
|
@ -393,7 +397,8 @@ static int ffserver_set_float_param(float *dest, const char *value, float factor |
|
|
|
|
if (config) { |
|
|
|
|
va_list vl; |
|
|
|
|
va_start(vl, error_msg); |
|
|
|
|
vreport_config_error(config->filename, line_num, AV_LOG_ERROR, &config->errors, error_msg, vl); |
|
|
|
|
vreport_config_error(config->filename, line_num, AV_LOG_ERROR, |
|
|
|
|
&config->errors, error_msg, vl); |
|
|
|
|
va_end(vl); |
|
|
|
|
} |
|
|
|
|
return AVERROR(EINVAL); |
|
|
|
@ -406,14 +411,19 @@ static int ffserver_save_avoption(const char *opt, const char *arg, AVDictionary |
|
|
|
|
AVDictionaryEntry *e; |
|
|
|
|
const AVOption *o = av_opt_find(config->dummy_ctx, opt, NULL, type | AV_OPT_FLAG_ENCODING_PARAM, AV_OPT_SEARCH_CHILDREN); |
|
|
|
|
if (!o) { |
|
|
|
|
report_config_error(config->filename, line_num, AV_LOG_ERROR, &config->errors, "Option not found: %s\n", opt); |
|
|
|
|
report_config_error(config->filename, line_num, AV_LOG_ERROR, |
|
|
|
|
&config->errors, "Option not found: %s\n", opt); |
|
|
|
|
} else if ((ret = av_opt_set(config->dummy_ctx, opt, arg, AV_OPT_SEARCH_CHILDREN)) < 0) { |
|
|
|
|
report_config_error(config->filename, line_num, AV_LOG_ERROR, &config->errors, "Invalid value for option %s (%s): %s\n", opt, arg, av_err2str(ret)); |
|
|
|
|
report_config_error(config->filename, line_num, AV_LOG_ERROR, |
|
|
|
|
&config->errors, "Invalid value for option %s (%s): %s\n", opt, |
|
|
|
|
arg, av_err2str(ret)); |
|
|
|
|
} else if ((e = av_dict_get(*dict, opt, NULL, 0))) { |
|
|
|
|
if ((o->type == AV_OPT_TYPE_FLAGS) && arg && (arg[0] == '+' || arg[0] == '-')) |
|
|
|
|
return av_dict_set(dict, opt, arg, AV_DICT_APPEND); |
|
|
|
|
report_config_error(config->filename, line_num, AV_LOG_ERROR, &config->errors, |
|
|
|
|
"Redeclaring value of the option %s, previous value: %s\n", opt, e->value); |
|
|
|
|
report_config_error(config->filename, line_num, AV_LOG_ERROR, |
|
|
|
|
&config->errors, |
|
|
|
|
"Redeclaring value of the option %s, previous value: %s\n", |
|
|
|
|
opt, e->value); |
|
|
|
|
} else if (av_dict_set(dict, opt, arg, 0) < 0) { |
|
|
|
|
return AVERROR(ENOMEM); |
|
|
|
|
} |
|
|
|
@ -432,7 +442,8 @@ static int ffserver_parse_config_global(FFServerConfig *config, const char *cmd, |
|
|
|
|
if (!av_strcasecmp(cmd, "Port")) |
|
|
|
|
WARNING("Port option is deprecated, use HTTPPort instead\n"); |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(&val, arg, 0, 1, 65535, config, line_num, "Invalid port: %s\n", arg); |
|
|
|
|
ffserver_set_int_param(&val, arg, 0, 1, 65535, config, line_num, |
|
|
|
|
"Invalid port: %s\n", arg); |
|
|
|
|
if (val < 1024) |
|
|
|
|
WARNING("Trying to use IETF assigned system port: %d\n", val); |
|
|
|
|
config->http_addr.sin_port = htons(val); |
|
|
|
@ -446,7 +457,8 @@ static int ffserver_parse_config_global(FFServerConfig *config, const char *cmd, |
|
|
|
|
WARNING("NoDaemon option has no effect, you should remove it\n"); |
|
|
|
|
} else if (!av_strcasecmp(cmd, "RTSPPort")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(&val, arg, 0, 1, 65535, config, line_num, "Invalid port: %s\n", arg); |
|
|
|
|
ffserver_set_int_param(&val, arg, 0, 1, 65535, config, line_num, |
|
|
|
|
"Invalid port: %s\n", arg); |
|
|
|
|
config->rtsp_addr.sin_port = htons(val); |
|
|
|
|
} else if (!av_strcasecmp(cmd, "RTSPBindAddress")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
@ -454,14 +466,16 @@ static int ffserver_parse_config_global(FFServerConfig *config, const char *cmd, |
|
|
|
|
ERROR("Invalid host/IP address: %s\n", arg); |
|
|
|
|
} else if (!av_strcasecmp(cmd, "MaxHTTPConnections")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(&val, arg, 0, 1, 65535, config, line_num, "Invalid MaxHTTPConnections: %s\n", arg); |
|
|
|
|
ffserver_set_int_param(&val, arg, 0, 1, 65535, config, line_num, |
|
|
|
|
"Invalid MaxHTTPConnections: %s\n", arg); |
|
|
|
|
config->nb_max_http_connections = val; |
|
|
|
|
if (config->nb_max_connections > config->nb_max_http_connections) |
|
|
|
|
ERROR("Inconsistent configuration: MaxClients(%d) > MaxHTTPConnections(%d)\n", |
|
|
|
|
config->nb_max_connections, config->nb_max_http_connections); |
|
|
|
|
} else if (!av_strcasecmp(cmd, "MaxClients")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(&val, arg, 0, 1, 65535, config, line_num, "Invalid MaxClients: %s\n", arg); |
|
|
|
|
ffserver_set_int_param(&val, arg, 0, 1, 65535, config, line_num, |
|
|
|
|
"Invalid MaxClients: %s\n", arg); |
|
|
|
|
config->nb_max_connections = val; |
|
|
|
|
if (config->nb_max_connections > config->nb_max_http_connections) |
|
|
|
|
ERROR("Inconsistent configuration: MaxClients(%d) > MaxHTTPConnections(%d)\n", |
|
|
|
@ -544,7 +558,8 @@ static int ffserver_parse_config_feed(FFServerConfig *config, const char *cmd, c |
|
|
|
|
if (!feed->child_argv[i]) |
|
|
|
|
return AVERROR(ENOMEM); |
|
|
|
|
} else if (!av_strcasecmp(cmd, "ACL")) { |
|
|
|
|
ffserver_parse_acl_row(NULL, feed, NULL, *p, config->filename, line_num); |
|
|
|
|
ffserver_parse_acl_row(NULL, feed, NULL, *p, config->filename, |
|
|
|
|
line_num); |
|
|
|
|
} else if (!av_strcasecmp(cmd, "File") || !av_strcasecmp(cmd, "ReadOnlyFile")) { |
|
|
|
|
ffserver_get_arg(feed->feed_filename, sizeof(feed->feed_filename), p); |
|
|
|
|
feed->readonly = !av_strcasecmp(cmd, "ReadOnlyFile"); |
|
|
|
@ -581,7 +596,8 @@ static int ffserver_parse_config_feed(FFServerConfig *config, const char *cmd, c |
|
|
|
|
} |
|
|
|
|
feed->feed_max_size = (int64_t)fsize; |
|
|
|
|
if (feed->feed_max_size < FFM_PACKET_SIZE*4) |
|
|
|
|
ERROR("Feed max file size is too small, must be at least %d\n", FFM_PACKET_SIZE*4); |
|
|
|
|
ERROR("Feed max file size is too small, must be at least %d\n", |
|
|
|
|
FFM_PACKET_SIZE*4); |
|
|
|
|
} else if (!av_strcasecmp(cmd, "</Feed>")) { |
|
|
|
|
*pfeed = NULL; |
|
|
|
|
} else { |
|
|
|
@ -595,48 +611,67 @@ static void ffserver_apply_stream_config(AVCodecContext *enc, const AVDictionary |
|
|
|
|
AVDictionaryEntry *e; |
|
|
|
|
|
|
|
|
|
/* Return values from ffserver_set_*_param are ignored.
|
|
|
|
|
Values are initially parsed and checked before inserting to AVDictionary. */ |
|
|
|
|
Values are initially parsed and checked before inserting to |
|
|
|
|
AVDictionary. */ |
|
|
|
|
|
|
|
|
|
//video params
|
|
|
|
|
if ((e = av_dict_get(conf, "VideoBitRateRangeMin", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->rc_min_rate, e->value, 1000, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->rc_min_rate, e->value, 1000, INT_MIN, |
|
|
|
|
INT_MAX, NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "VideoBitRateRangeMax", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->rc_max_rate, e->value, 1000, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->rc_max_rate, e->value, 1000, INT_MIN, |
|
|
|
|
INT_MAX, NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "Debug", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->debug, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->debug, e->value, 0, INT_MIN, INT_MAX, |
|
|
|
|
NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "Strict", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->strict_std_compliance, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->strict_std_compliance, e->value, 0, |
|
|
|
|
INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "VideoBufferSize", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->rc_buffer_size, e->value, 8*1024, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->rc_buffer_size, e->value, 8*1024, |
|
|
|
|
INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "VideoBitRateTolerance", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->bit_rate_tolerance, e->value, 1000, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->bit_rate_tolerance, e->value, 1000, |
|
|
|
|
INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "VideoBitRate", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->bit_rate, e->value, 1000, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->bit_rate, e->value, 1000, INT_MIN, |
|
|
|
|
INT_MAX, NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "VideoSizeWidth", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->width, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->width, e->value, 0, INT_MIN, INT_MAX, |
|
|
|
|
NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "VideoSizeHeight", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->height, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->height, e->value, 0, INT_MIN, INT_MAX, |
|
|
|
|
NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "PixelFormat", NULL, 0))) { |
|
|
|
|
int val; |
|
|
|
|
ffserver_set_int_param(&val, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&val, e->value, 0, INT_MIN, INT_MAX, NULL, 0, |
|
|
|
|
NULL); |
|
|
|
|
enc->pix_fmt = val; |
|
|
|
|
} |
|
|
|
|
if ((e = av_dict_get(conf, "VideoGopSize", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->gop_size, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->gop_size, e->value, 0, INT_MIN, INT_MAX, |
|
|
|
|
NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "VideoFrameRateNum", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->time_base.num, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->time_base.num, e->value, 0, INT_MIN, |
|
|
|
|
INT_MAX, NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "VideoFrameRateDen", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->time_base.den, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->time_base.den, e->value, 0, INT_MIN, |
|
|
|
|
INT_MAX, NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "VideoQDiff", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->max_qdiff, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->max_qdiff, e->value, 0, INT_MIN, INT_MAX, |
|
|
|
|
NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "VideoQMax", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->qmax, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->qmax, e->value, 0, INT_MIN, INT_MAX, NULL, |
|
|
|
|
0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "VideoQMin", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->qmin, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->qmin, e->value, 0, INT_MIN, INT_MAX, NULL, |
|
|
|
|
0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "LumiMask", NULL, 0))) |
|
|
|
|
ffserver_set_float_param(&enc->lumi_masking, e->value, 0, -FLT_MAX, FLT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_float_param(&enc->lumi_masking, e->value, 0, -FLT_MAX, |
|
|
|
|
FLT_MAX, NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "DarkMask", NULL, 0))) |
|
|
|
|
ffserver_set_float_param(&enc->dark_masking, e->value, 0, -FLT_MAX, FLT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_float_param(&enc->dark_masking, e->value, 0, -FLT_MAX, |
|
|
|
|
FLT_MAX, NULL, 0, NULL); |
|
|
|
|
if (av_dict_get(conf, "BitExact", NULL, 0)) |
|
|
|
|
enc->flags |= CODEC_FLAG_BITEXACT; |
|
|
|
|
if (av_dict_get(conf, "DctFastint", NULL, 0)) |
|
|
|
@ -649,7 +684,8 @@ static void ffserver_apply_stream_config(AVCodecContext *enc, const AVDictionary |
|
|
|
|
enc->codec_tag = MKTAG(e->value[0], e->value[1], e->value[2], e->value[3]); |
|
|
|
|
if (av_dict_get(conf, "Qscale", NULL, 0)) { |
|
|
|
|
enc->flags |= CODEC_FLAG_QSCALE; |
|
|
|
|
ffserver_set_int_param(&enc->global_quality, e->value, FF_QP2LAMBDA, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->global_quality, e->value, FF_QP2LAMBDA, |
|
|
|
|
INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
} |
|
|
|
|
if (av_dict_get(conf, "Video4MotionVector", NULL, 0)) { |
|
|
|
|
enc->mb_decision = FF_MB_DECISION_BITS; //FIXME remove
|
|
|
|
@ -657,11 +693,14 @@ static void ffserver_apply_stream_config(AVCodecContext *enc, const AVDictionary |
|
|
|
|
} |
|
|
|
|
//audio params
|
|
|
|
|
if ((e = av_dict_get(conf, "AudioChannels", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->channels, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->channels, e->value, 0, INT_MIN, INT_MAX, |
|
|
|
|
NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "AudioSampleRate", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->sample_rate, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->sample_rate, e->value, 0, INT_MIN, |
|
|
|
|
INT_MAX, NULL, 0, NULL); |
|
|
|
|
if ((e = av_dict_get(conf, "AudioBitRate", NULL, 0))) |
|
|
|
|
ffserver_set_int_param(&enc->bit_rate, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); |
|
|
|
|
ffserver_set_int_param(&enc->bit_rate, e->value, 0, INT_MIN, INT_MAX, |
|
|
|
|
NULL, 0, NULL); |
|
|
|
|
|
|
|
|
|
av_opt_set_dict2(enc, opts, AV_OPT_SEARCH_CHILDREN); |
|
|
|
|
} |
|
|
|
@ -719,7 +758,8 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd, |
|
|
|
|
sfeed = sfeed->next_feed; |
|
|
|
|
} |
|
|
|
|
if (!sfeed) |
|
|
|
|
ERROR("Feed with name '%s' for stream '%s' is not defined\n", arg, stream->filename); |
|
|
|
|
ERROR("Feed with name '%s' for stream '%s' is not defined\n", arg, |
|
|
|
|
stream->filename); |
|
|
|
|
else |
|
|
|
|
stream->feed = sfeed; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "Format")) { |
|
|
|
@ -747,7 +787,8 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd, |
|
|
|
|
ERROR("Unknown input format: %s\n", arg); |
|
|
|
|
} else if (!av_strcasecmp(cmd, "FaviconURL")) { |
|
|
|
|
if (stream->stream_type == STREAM_TYPE_STATUS) |
|
|
|
|
ffserver_get_arg(stream->feed_filename, sizeof(stream->feed_filename), p); |
|
|
|
|
ffserver_get_arg(stream->feed_filename, |
|
|
|
|
sizeof(stream->feed_filename), p); |
|
|
|
|
else |
|
|
|
|
ERROR("FaviconURL only permitted for status streams\n"); |
|
|
|
|
} else if (!av_strcasecmp(cmd, "Author") || |
|
|
|
@ -790,17 +831,20 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd, |
|
|
|
|
} else if (!av_strcasecmp(cmd, "AudioBitRate")) { |
|
|
|
|
float f; |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_float_param(&f, arg, 1000, 0, FLT_MAX, config, line_num, "Invalid %s: %s\n", cmd, arg); |
|
|
|
|
ffserver_set_float_param(&f, arg, 1000, 0, FLT_MAX, config, line_num, |
|
|
|
|
"Invalid %s: %s\n", cmd, arg); |
|
|
|
|
if (av_dict_set_int(&config->audio_conf, cmd, lrintf(f), 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "AudioChannels")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, 1, 8, config, line_num, "Invalid %s: %s, valid range is 1-8.", cmd, arg); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, 1, 8, config, line_num, |
|
|
|
|
"Invalid %s: %s, valid range is 1-8.", cmd, arg); |
|
|
|
|
if (av_dict_set(&config->audio_conf, cmd, arg, 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "AudioSampleRate")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, 0, INT_MAX, config, line_num, "Invalid %s: %s", cmd, arg); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, 0, INT_MAX, config, line_num, |
|
|
|
|
"Invalid %s: %s", cmd, arg); |
|
|
|
|
if (av_dict_set(&config->audio_conf, cmd, arg, 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "VideoBitRateRange")) { |
|
|
|
@ -811,30 +855,36 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd, |
|
|
|
|
av_dict_set_int(&config->video_conf, "VideoBitRateRangeMax", maxrate, 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else |
|
|
|
|
ERROR("Incorrect format for VideoBitRateRange -- should be <min>-<max>: %s\n", arg); |
|
|
|
|
ERROR("Incorrect format for VideoBitRateRange -- should be " |
|
|
|
|
"<min>-<max>: %s\n", arg); |
|
|
|
|
} else if (!av_strcasecmp(cmd, "Debug")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config, line_num, "Invalid %s: %s", cmd, arg); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config, line_num, |
|
|
|
|
"Invalid %s: %s", cmd, arg); |
|
|
|
|
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "Strict")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config, line_num, "Invalid %s: %s", cmd, arg); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config, line_num, |
|
|
|
|
"Invalid %s: %s", cmd, arg); |
|
|
|
|
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "VideoBufferSize")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 8*1024, 0, INT_MAX, config, line_num, "Invalid %s: %s", cmd, arg); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 8*1024, 0, INT_MAX, config, line_num, |
|
|
|
|
"Invalid %s: %s", cmd, arg); |
|
|
|
|
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "VideoBitRateTolerance")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 1000, INT_MIN, INT_MAX, config, line_num, "Invalid %s: %s", cmd, arg); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 1000, INT_MIN, INT_MAX, config, |
|
|
|
|
line_num, "Invalid %s: %s", cmd, arg); |
|
|
|
|
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "VideoBitRate")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 1000, 0, INT_MAX, config, line_num, "Invalid %s: %s", cmd, arg); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 1000, 0, INT_MAX, config, line_num, |
|
|
|
|
"Invalid %s: %s", cmd, arg); |
|
|
|
|
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "VideoSize")) { |
|
|
|
@ -868,7 +918,8 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd, |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "VideoGopSize")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config, line_num, "Invalid %s: %s", cmd, arg); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config, line_num, |
|
|
|
|
"Invalid %s: %s", cmd, arg); |
|
|
|
|
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "VideoIntraOnly")) { |
|
|
|
@ -926,27 +977,32 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd, |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "VideoQDiff")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, 1, 31, config, line_num, "%s out of range\n", cmd); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, 1, 31, config, line_num, |
|
|
|
|
"%s out of range\n", cmd); |
|
|
|
|
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "VideoQMax")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, 1, 31, config, line_num, "%s out of range\n", cmd); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, 1, 31, config, line_num, |
|
|
|
|
"%s out of range\n", cmd); |
|
|
|
|
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "VideoQMin")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, 1, 31, config, line_num, "%s out of range\n", cmd); |
|
|
|
|
ffserver_set_int_param(NULL, arg, 0, 1, 31, config, line_num, |
|
|
|
|
"%s out of range\n", cmd); |
|
|
|
|
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "LumiMask")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_float_param(NULL, arg, 0, -FLT_MAX, FLT_MAX, config, line_num, "Invalid %s: %s", cmd, arg); |
|
|
|
|
ffserver_set_float_param(NULL, arg, 0, -FLT_MAX, FLT_MAX, config, |
|
|
|
|
line_num, "Invalid %s: %s", cmd, arg); |
|
|
|
|
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "DarkMask")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_float_param(NULL, arg, 0, -FLT_MAX, FLT_MAX, config, line_num, "Invalid %s: %s", cmd, arg); |
|
|
|
|
ffserver_set_float_param(NULL, arg, 0, -FLT_MAX, FLT_MAX, config, |
|
|
|
|
line_num, "Invalid %s: %s", cmd, arg); |
|
|
|
|
if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0) |
|
|
|
|
goto nomem; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "NoVideo")) { |
|
|
|
@ -954,7 +1010,8 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd, |
|
|
|
|
} else if (!av_strcasecmp(cmd, "NoAudio")) { |
|
|
|
|
config->audio_id = AV_CODEC_ID_NONE; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "ACL")) { |
|
|
|
|
ffserver_parse_acl_row(stream, NULL, NULL, *p, config->filename, line_num); |
|
|
|
|
ffserver_parse_acl_row(stream, NULL, NULL, *p, config->filename, |
|
|
|
|
line_num); |
|
|
|
|
} else if (!av_strcasecmp(cmd, "DynamicACL")) { |
|
|
|
|
ffserver_get_arg(stream->dynamic_acl, sizeof(stream->dynamic_acl), p); |
|
|
|
|
} else if (!av_strcasecmp(cmd, "RTSPOption")) { |
|
|
|
@ -969,11 +1026,13 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd, |
|
|
|
|
stream->loop = 1; /* default is looping */ |
|
|
|
|
} else if (!av_strcasecmp(cmd, "MulticastPort")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(&val, arg, 0, 1, 65535, config, line_num, "Invalid MulticastPort: %s\n", arg); |
|
|
|
|
ffserver_set_int_param(&val, arg, 0, 1, 65535, config, line_num, |
|
|
|
|
"Invalid MulticastPort: %s\n", arg); |
|
|
|
|
stream->multicast_port = val; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "MulticastTTL")) { |
|
|
|
|
ffserver_get_arg(arg, sizeof(arg), p); |
|
|
|
|
ffserver_set_int_param(&val, arg, 0, INT_MIN, INT_MAX, config, line_num, "Invalid MulticastTTL: %s\n", arg); |
|
|
|
|
ffserver_set_int_param(&val, arg, 0, INT_MIN, INT_MAX, config, |
|
|
|
|
line_num, "Invalid MulticastTTL: %s\n", arg); |
|
|
|
|
stream->multicast_ttl = val; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "NoLoop")) { |
|
|
|
|
stream->loop = 0; |
|
|
|
@ -985,7 +1044,8 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd, |
|
|
|
|
ffserver_opt_preset(arg, audio_enc, AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_ENCODING_PARAM, |
|
|
|
|
NULL, NULL) < 0) |
|
|
|
|
ERROR("Could not apply preset '%s'\n", arg); |
|
|
|
|
ffserver_apply_stream_config(audio_enc, config->audio_conf, &config->audio_opts); |
|
|
|
|
ffserver_apply_stream_config(audio_enc, config->audio_conf, |
|
|
|
|
&config->audio_opts); |
|
|
|
|
add_codec(stream, audio_enc); |
|
|
|
|
} |
|
|
|
|
if (config->video_id != AV_CODEC_ID_NONE) { |
|
|
|
@ -994,7 +1054,8 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd, |
|
|
|
|
ffserver_opt_preset(arg, video_enc, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_ENCODING_PARAM, |
|
|
|
|
NULL, NULL) < 0) |
|
|
|
|
ERROR("Could not apply preset '%s'\n", arg); |
|
|
|
|
ffserver_apply_stream_config(video_enc, config->video_conf, &config->video_opts); |
|
|
|
|
ffserver_apply_stream_config(video_enc, config->video_conf, |
|
|
|
|
&config->video_opts); |
|
|
|
|
add_codec(stream, video_enc); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1007,7 +1068,8 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd, |
|
|
|
|
avcodec_free_context(&config->dummy_ctx); |
|
|
|
|
*pstream = NULL; |
|
|
|
|
} else if (!av_strcasecmp(cmd, "File") || !av_strcasecmp(cmd, "ReadOnlyFile")) { |
|
|
|
|
ffserver_get_arg(stream->feed_filename, sizeof(stream->feed_filename), p); |
|
|
|
|
ffserver_get_arg(stream->feed_filename, sizeof(stream->feed_filename), |
|
|
|
|
p); |
|
|
|
|
} else { |
|
|
|
|
ERROR("Invalid entry '%s' inside <Stream></Stream>\n", cmd); |
|
|
|
|
} |
|
|
|
@ -1047,7 +1109,8 @@ static int ffserver_parse_config_redirect(FFServerConfig *config, const char *cm |
|
|
|
|
} |
|
|
|
|
av_assert0(redirect); |
|
|
|
|
if (!av_strcasecmp(cmd, "URL")) { |
|
|
|
|
ffserver_get_arg(redirect->feed_filename, sizeof(redirect->feed_filename), p); |
|
|
|
|
ffserver_get_arg(redirect->feed_filename, |
|
|
|
|
sizeof(redirect->feed_filename), p); |
|
|
|
|
} else if (!av_strcasecmp(cmd, "</Redirect>")) { |
|
|
|
|
if (!redirect->feed_filename[0]) |
|
|
|
|
ERROR("No URL found for <Redirect>\n"); |
|
|
|
@ -1074,7 +1137,8 @@ int ffserver_parse_ffconfig(const char *filename, FFServerConfig *config) |
|
|
|
|
f = fopen(filename, "r"); |
|
|
|
|
if (!f) { |
|
|
|
|
ret = AVERROR(errno); |
|
|
|
|
av_log(NULL, AV_LOG_ERROR, "Could not open the configuration file '%s'\n", filename); |
|
|
|
|
av_log(NULL, AV_LOG_ERROR, |
|
|
|
|
"Could not open the configuration file '%s'\n", filename); |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|