34 #define MAX_CHILD_ARGS 64
39 int log_level,
int *errors,
const char *
fmt,
42 int log_level,
int *errors,
const char *
fmt,
45 #define ERROR(...) report_config_error(config->filename, config->line_num,\
46 AV_LOG_ERROR, &config->errors, __VA_ARGS__)
47 #define WARNING(...) report_config_error(config->filename, config->line_num,\
48 AV_LOG_WARNING, &config->warnings, __VA_ARGS__)
52 static int resolve_host(
struct in_addr *sin_addr,
const char *hostname)
65 for (cur = ai; cur; cur = cur->
ai_next) {
67 *sin_addr = ((
struct sockaddr_in *)cur->
ai_addr)->sin_addr;
76 hp = gethostbyname(hostname);
79 memcpy(sin_addr, hp->h_addr_list[0],
sizeof(
struct in_addr));
96 if (*p ==
'\"' || *p ==
'\'')
100 if (quote && *p == quote || !quote &&
av_isspace(*p))
102 if ((q - buf) < buf_size - 1)
108 if (quote && *p == quote)
115 const char *p,
const char *filename,
int line_num)
127 fprintf(stderr,
"%s:%d: ACL action '%s' should be ALLOW or DENY.\n",
128 filename, line_num, arg);
136 "%s:%d: ACL refers to invalid host or IP address '%s'\n",
137 filename, line_num, arg);
147 "%s:%d: ACL refers to invalid host or IP address '%s'\n",
148 filename, line_num, arg);
161 naclp = &stream->
acl;
167 fprintf(stderr,
"%s:%d: ACL found not in <Stream> or <Feed>\n",
174 naclp = &(*naclp)->
next;
201 "Something is wrong, %d options are not set!\n",
210 "audio bit rate is not set\n");
214 "audio sample rate is not set\n");
220 "video size is not set\n");
236 WARNING(
"Setting default value for audio bit rate = %d. "
237 "Use NoDefaults to disable it.\n",
243 WARNING(
"Setting default value for audio sample rate = %d. "
244 "Use NoDefaults to disable it.\n",
250 WARNING(
"Setting default value for audio channel count = %d. "
251 "Use NoDefaults to disable it.\n",
259 WARNING(
"Setting default value for video bit rate = %d. "
260 "Use NoDefaults to disable it.\n",
267 WARNING(
"Setting default value for video frame rate = %d. "
268 "Use NoDefaults to disable it.\n",
274 av_dict_set(&recommended,
"video_size",
"160x128", 0);
275 WARNING(
"Setting default value for video size = %dx%d. "
276 "Use NoDefaults to disable it.\n",
284 WARNING(
"Setting default value for video bit rate tolerance = %d. "
285 "Use NoDefaults to disable it.\n",
291 av_dict_set(&recommended,
"rc_eq",
"tex^qComp", 0);
292 WARNING(
"Setting default value for video rate control equation = "
293 "%s. Use NoDefaults to disable it.\n",
299 WARNING(
"Setting default value for video max rate = %d. "
300 "Use NoDefaults to disable it.\n",
307 WARNING(
"Setting default value for video buffer size = %d. "
308 "Use NoDefaults to disable it.\n",
335 "Invalid codec name: '%s'\n", codec_name);
346 "Inconsistent configuration: trying to set '%s' "
347 "codec option, but '%s' codec is used previously\n",
355 char filename[1000], tmp[1000], tmp2[1000],
line[1000];
379 int e= fscanf(f,
"%999[^\n]\n", line) - 1;
380 if(line[0] ==
'#' && !e)
382 e|= sscanf(line,
"%999[^=]=%999[^\n]\n", tmp, tmp2) - 2;
394 }
else if (!strcmp(tmp,
"scodec")) {
408 const char *filename,
409 const char *mime_type)
415 char stream_format_name[64];
417 snprintf(stream_format_name,
sizeof(stream_format_name),
"%s_stream",
429 int log_level,
int *errors,
const char *
fmt,
432 av_log(
NULL, log_level,
"%s:%d: ", filename, line_num);
439 int log_level,
int *errors,
440 const char *
fmt, ...)
450 const char *error_msg, ...)
454 if (!value || !value[0])
457 tmp = strtol(value, &tailp, 0);
458 if (tmp < min || tmp > max)
465 if (tailp[0] || errno)
473 va_start(vl, error_msg);
475 &config->
errors, error_msg, vl);
484 const char *error_msg, ...)
488 if (!value || !value[0])
491 tmp =
strtod(value, &tailp);
492 if (tmp < min || tmp > max)
496 if (tailp[0] || errno)
504 va_start(vl, error_msg);
506 &config->
errors, error_msg, vl);
515 static int hinted = 0;
520 const char *codec_name =
NULL;
543 if (strchr(opt,
':')) {
545 snprintf(buff,
sizeof(buff),
"%s", opt);
547 if(!(option = strchr(buff,
':'))){
550 "Syntax error. Unmatched ':'\n");
554 buff[option - buff] =
'\0';
567 (!strcmp(option,
"time_base") || !strcmp(option,
"pixel_format") ||
568 !strcmp(option,
"video_size") || !strcmp(option,
"codec_tag")))
572 &config->
errors,
"Option not found: '%s'\n", opt);
577 "option, then prefix it with codec name, for "
578 "example '%s:%s %s' or define codec earlier.\n",
584 &config->
errors,
"Invalid value for option %s (%s): %s\n", opt,
588 (arg[0] ==
'+' || arg[0] ==
'-'))
591 &config->
errors,
"Redeclaring value of option '%s'."
592 "Previous value was: '%s'.\n", opt, e->
value);
593 }
else if (
av_dict_set(dict, option, arg, 0) < 0) {
603 snprintf(buf,
sizeof(buf),
"%"PRId64, arg);
614 WARNING(
"Port option is deprecated. Use HTTPPort instead.\n");
617 "Invalid port: %s\n", arg);
619 WARNING(
"Trying to use IETF assigned system port: '%d'\n", val);
624 WARNING(
"BindAddress option is deprecated. Use HTTPBindAddress "
628 ERROR(
"Invalid host/IP address: '%s'\n", arg);
630 WARNING(
"NoDaemon option has no effect. You should remove it.\n");
634 "Invalid port: %s\n", arg);
639 ERROR(
"Invalid host/IP address: %s\n", arg);
643 "Invalid MaxHTTPConnections: %s\n", arg);
646 ERROR(
"Inconsistent configuration: MaxClients(%d) > "
653 "Invalid MaxClients: '%s'\n", arg);
656 ERROR(
"Inconsistent configuration: MaxClients(%d) > "
665 llval = strtoll(arg, &tailp, 10);
666 if (llval < 10 || llval > 10000000 || tailp[0] || errno)
667 ERROR(
"Invalid MaxBandwidth: '%s'\n", arg);
671 if (!config->
debug) {
676 ERROR(
"Loadable modules are no longer supported\n");
682 ERROR(
"Incorrect keyword: '%s'\n", cmd);
738 (config->
http_addr.sin_addr.s_addr == INADDR_ANY) ?
739 "127.0.0.1" : inet_ntoa(config->
http_addr.sin_addr),
756 WARNING(
"Truncate N syntax in configuration file is deprecated. "
757 "Use Truncate alone with no arguments.\n");
772 fsize *= 1024 * 1024;
775 fsize *= 1024 * 1024 * 1024;
778 ERROR(
"Invalid file size: '%s'\n", arg);
783 ERROR(
"Feed max file size is too small. Must be at least %d.\n",
789 ERROR(
"Invalid entry '%s' inside <Feed></Feed>\n", cmd);
797 char arg[1024], arg2[1024];
853 ERROR(
"Feed with name '%s' for stream '%s' is not defined\n", arg,
856 stream->
feed = sfeed;
859 if (!strcmp(arg,
"status")) {
865 if (!strcmp(arg,
"jpeg"))
866 strcpy(arg,
"mjpeg");
869 ERROR(
"Unknown Format: '%s'\n", arg);
879 ERROR(
"Unknown input format: '%s'\n", arg);
885 ERROR(
"FaviconURL only permitted for status streams\n");
893 for (i = 0; i < strlen(cmd); i++)
896 WARNING(
"Deprecated '%s' option in configuration file. Use "
897 "'Metadata %s VALUE' instead.\n", cmd, key);
918 stream->
max_time = atof(arg) * 1000;
923 "Invalid %s: '%s'\n", cmd, arg);
936 int minrate, maxrate;
939 dash = strchr(arg,
'-');
950 ERROR(
"Incorrect format for VideoBitRateRange. It should be "
951 "<min>-<max>: '%s'.\n", arg);
965 "Invalid %s: '%s'", cmd, arg);
971 "Invalid %s: '%s'", cmd, arg);
977 "Invalid %s: '%s'", cmd, arg);
985 ERROR(
"Invalid video size '%s'\n", arg);
988 WARNING(
"Image size is not a multiple of 2\n");
994 arg[0] =
'1'; arg[1] =
'/';
1002 ERROR(
"Unknown pixel format: '%s'\n", arg);
1041 if (strlen(arg) == 4 &&
1043 MKTAG(arg[0], arg[1], arg[2], arg[3]),
1058 "Invalid Qscale: '%s'\n", arg);
1099 ERROR(
"Invalid host/IP address: '%s'\n", arg);
1105 "Invalid MulticastPort: '%s'\n", arg);
1110 "Invalid MulticastTTL: '%s'\n", arg);
1116 if (stream->
feed && stream->
fmt && strcmp(stream->
fmt->
name,
"ffm")) {
1143 WARNING(
"Multiple UseDefaults/NoDefaults entries.\n");
1147 WARNING(
"Multiple UseDefaults/NoDefaults entries.\n");
1150 ERROR(
"Invalid entry '%s' inside <Stream></Stream>\n", cmd);
1163 const char *cmd,
const char **p,
1168 redirect = *predirect;
1177 q = strrchr(redirect->
filename,
'>');
1181 *predirect = redirect;
1190 ERROR(
"No URL found for <Redirect>\n");
1193 ERROR(
"Invalid entry '%s' inside <Redirect></Redirect>\n", cmd);
1210 f = fopen(filename,
"r");
1214 "Could not open the configuration file '%s'\n", filename);
1226 while (fgets(line,
sizeof(line), f) !=
NULL) {
1231 if (*p ==
'\0' || *p ==
'#')
1238 if (opening && (stream || feed || redirect)) {
1239 ERROR(
"Already in a tag\n");
1246 *last_stream = feed;
1248 last_stream = &feed->
next;
1254 if (opening && (stream || feed || redirect)) {
1255 ERROR(
"Already in a tag\n");
1262 *last_stream = stream;
1263 last_stream = &stream->
next;
1268 if (opening && (stream || feed || redirect))
1269 ERROR(
"Already in a tag\n");
1277 *last_stream = redirect;
1278 last_stream = &redirect->
next;
1285 if (stream || feed || redirect)
1286 ERROR(
"Missing closing </%s> tag\n",
1287 stream ?
"Stream" : (feed ?
"Feed" :
"Redirect"));
1307 args = *(
char ***)argsp;