2 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "libavutil/opt.h"
23 #include "libavutil/parseutils.h"
24 #include "libavutil/avstring.h"
25 #include "libavutil/pixdesc.h"
26 #include "libavutil/avassert.h"
28 // FIXME those are internal headers, ffserver _really_ shouldn't use them
29 #include "libavformat/ffm.h"
32 #include "ffserver_config.h"
34 static int ffserver_save_avoption(const char *opt, const char *arg, int type,
35 FFServerConfig *config);
36 static void vreport_config_error(const char *filename, int line_num, int log_level,
37 int *errors, const char *fmt, va_list vl);
38 static void report_config_error(const char *filename, int line_num, int log_level,
39 int *errors, const char *fmt, ...);
41 /* FIXME: make ffserver work with IPv6 */
42 /* resolve host with also IP address parsing */
43 static int resolve_host(struct in_addr *sin_addr, const char *hostname)
46 if (!ff_inet_aton(hostname, sin_addr)) {
48 struct addrinfo *ai, *cur;
49 struct addrinfo hints = { 0 };
50 hints.ai_family = AF_INET;
51 if (getaddrinfo(hostname, NULL, &hints, &ai))
53 /* getaddrinfo returns a linked list of addrinfo structs.
54 * Even if we set ai_family = AF_INET above, make sure
55 * that the returned one actually is of the correct type. */
56 for (cur = ai; cur; cur = cur->ai_next) {
57 if (cur->ai_family == AF_INET) {
58 *sin_addr = ((struct sockaddr_in *)cur->ai_addr)->sin_addr;
67 hp = gethostbyname(hostname);
70 memcpy(sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));
76 void ffserver_get_arg(char *buf, int buf_size, const char **pp)
83 while (av_isspace(*p)) p++;
86 if (*p == '\"' || *p == '\'')
98 if ((q - buf) < buf_size - 1)
103 if (quote && *p == quote)
108 void ffserver_parse_acl_row(FFServerStream *stream, FFServerStream* feed,
109 FFServerIPAddressACL *ext_acl,
110 const char *p, const char *filename, int line_num)
113 FFServerIPAddressACL acl;
116 ffserver_get_arg(arg, sizeof(arg), &p);
117 if (av_strcasecmp(arg, "allow") == 0)
118 acl.action = IP_ALLOW;
119 else if (av_strcasecmp(arg, "deny") == 0)
120 acl.action = IP_DENY;
122 fprintf(stderr, "%s:%d: ACL action '%s' is not ALLOW or DENY\n",
123 filename, line_num, arg);
127 ffserver_get_arg(arg, sizeof(arg), &p);
129 if (resolve_host(&acl.first, arg)) {
130 fprintf(stderr, "%s:%d: ACL refers to invalid host or IP address '%s'\n",
131 filename, line_num, arg);
134 acl.last = acl.first;
136 ffserver_get_arg(arg, sizeof(arg), &p);
139 if (resolve_host(&acl.last, arg)) {
141 "%s:%d: ACL refers to invalid host or IP address '%s'\n",
142 filename, line_num, arg);
148 FFServerIPAddressACL *nacl = av_mallocz(sizeof(*nacl));
149 FFServerIPAddressACL **naclp = 0;
155 naclp = &stream->acl;
161 fprintf(stderr, "%s:%d: ACL found not in <stream> or <feed>\n",
168 naclp = &(*naclp)->next;
176 /* add a codec and set the default parameters */
177 static void add_codec(FFServerStream *stream, AVCodecContext *av)
181 if(stream->nb_streams >= FF_ARRAY_ELEMS(stream->streams))
184 /* compute default parameters */
185 switch(av->codec_type) {
186 case AVMEDIA_TYPE_AUDIO:
187 if (av->bit_rate == 0)
188 av->bit_rate = 64000;
189 if (av->sample_rate == 0)
190 av->sample_rate = 22050;
191 if (av->channels == 0)
194 case AVMEDIA_TYPE_VIDEO:
195 if (av->bit_rate == 0)
196 av->bit_rate = 64000;
197 if (av->time_base.num == 0){
198 av->time_base.den = 5;
199 av->time_base.num = 1;
201 if (av->width == 0 || av->height == 0) {
205 /* Bitrate tolerance is less for streaming */
206 if (av->bit_rate_tolerance == 0)
207 av->bit_rate_tolerance = FFMAX(av->bit_rate / 4,
208 (int64_t)av->bit_rate*av->time_base.num/av->time_base.den);
213 if (av->max_qdiff == 0)
218 if (!av->nsse_weight)
221 av->frame_skip_cmp = FF_CMP_DCTMAX;
223 av->me_method = ME_EPZS;
225 /* FIXME: rc_buffer_aggressivity and rc_eq are deprecated */
226 av->rc_buffer_aggressivity = 1.0;
229 av->rc_eq = av_strdup("tex^qComp");
230 if (!av->i_quant_factor)
231 av->i_quant_factor = -0.8;
232 if (!av->b_quant_factor)
233 av->b_quant_factor = 1.25;
234 if (!av->b_quant_offset)
235 av->b_quant_offset = 1.25;
236 if (!av->rc_max_rate)
237 av->rc_max_rate = av->bit_rate * 2;
239 if (av->rc_max_rate && !av->rc_buffer_size) {
240 av->rc_buffer_size = av->rc_max_rate;
249 st = av_mallocz(sizeof(AVStream));
253 stream->streams[stream->nb_streams++] = st;
256 static int ffserver_set_codec(AVCodecContext *ctx, const char *codec_name, FFServerConfig *config)
259 AVCodec *codec = avcodec_find_encoder_by_name(codec_name);
260 if (!codec || codec->type != ctx->codec_type) {
261 report_config_error(config->filename, config->line_num, AV_LOG_ERROR,
262 &config->errors, "Invalid codec name: %s\n", codec_name);
265 if (ctx->codec_id == AV_CODEC_ID_NONE && !ctx->priv_data) {
266 if ((ret = avcodec_get_context_defaults3(ctx, codec)) < 0)
270 if (ctx->codec_id != codec->id)
271 report_config_error(config->filename, config->line_num, AV_LOG_ERROR, &config->errors,
272 "Inconsistent configuration: trying to set %s codec option, but %s codec is used previously\n",
273 codec_name, avcodec_get_name(ctx->codec_id));
277 static int ffserver_opt_preset(const char *arg, int type, FFServerConfig *config)
280 char filename[1000], tmp[1000], tmp2[1000], line[1000];
282 AVCodecContext *avctx;
283 const AVCodec *codec;
286 case AV_OPT_FLAG_AUDIO_PARAM:
287 avctx = config->dummy_actx;
289 case AV_OPT_FLAG_VIDEO_PARAM:
290 avctx = config->dummy_vctx;
295 codec = avcodec_find_encoder(avctx->codec_id);
297 if (!(f = get_preset_file(filename, sizeof(filename), arg, 0,
298 codec ? codec->name : NULL))) {
299 av_log(NULL, AV_LOG_ERROR, "File for preset '%s' not found\n", arg);
300 return AVERROR(EINVAL);
304 int e= fscanf(f, "%999[^\n]\n", line) - 1;
305 if(line[0] == '#' && !e)
307 e|= sscanf(line, "%999[^=]=%999[^\n]\n", tmp, tmp2) - 2;
309 av_log(NULL, AV_LOG_ERROR, "%s: Invalid syntax: '%s'\n", filename, line);
310 ret = AVERROR(EINVAL);
313 if ((!strcmp(tmp, "acodec") && avctx->codec_type == AVMEDIA_TYPE_AUDIO) ||
314 !strcmp(tmp, "vcodec") && avctx->codec_type == AVMEDIA_TYPE_VIDEO)
316 if (ffserver_set_codec(avctx, tmp2, config) < 0)
318 } else if (!strcmp(tmp, "scodec")) {
319 av_log(NULL, AV_LOG_ERROR, "Subtitles preset found.\n");
320 ret = AVERROR(EINVAL);
322 } else if (ffserver_save_avoption(tmp, tmp2, type, config) < 0)
331 static AVOutputFormat *ffserver_guess_format(const char *short_name, const char *filename, const char *mime_type)
333 AVOutputFormat *fmt = av_guess_format(short_name, filename, mime_type);
336 AVOutputFormat *stream_fmt;
337 char stream_format_name[64];
339 snprintf(stream_format_name, sizeof(stream_format_name), "%s_stream",
341 stream_fmt = av_guess_format(stream_format_name, NULL, NULL);
350 static void vreport_config_error(const char *filename, int line_num, int log_level, int *errors, const char *fmt, va_list vl)
352 av_log(NULL, log_level, "%s:%d: ", filename, line_num);
353 av_vlog(NULL, log_level, fmt, vl);
358 static void report_config_error(const char *filename, int line_num, int log_level, int *errors, const char *fmt, ...)
362 vreport_config_error(filename, line_num, log_level, errors, fmt, vl);
366 static int ffserver_set_int_param(int *dest, const char *value, int factor, int min, int max,
367 FFServerConfig *config, const char *error_msg, ...)
371 if (!value || !value[0])
374 tmp = strtol(value, &tailp, 0);
375 if (tmp < min || tmp > max)
378 if (FFABS(tmp) > INT_MAX / FFABS(factor))
382 if (tailp[0] || errno)
390 va_start(vl, error_msg);
391 vreport_config_error(config->filename, config->line_num, AV_LOG_ERROR,
392 &config->errors, error_msg, vl);
395 return AVERROR(EINVAL);
398 static int ffserver_set_float_param(float *dest, const char *value, float factor, float min, float max,
399 FFServerConfig *config, const char *error_msg, ...)
403 if (!value || !value[0])
406 tmp = strtod(value, &tailp);
407 if (tmp < min || tmp > max)
411 if (tailp[0] || errno)
419 va_start(vl, error_msg);
420 vreport_config_error(config->filename, config->line_num, AV_LOG_ERROR,
421 &config->errors, error_msg, vl);
424 return AVERROR(EINVAL);
427 static int ffserver_save_avoption(const char *opt, const char *arg, int type, FFServerConfig *config)
429 static int hinted = 0;
431 AVDictionaryEntry *e;
432 const AVOption *o = NULL;
433 const char *option = NULL;
434 const char *codec_name = NULL;
438 enum AVCodecID guessed_codec_id;
441 case AV_OPT_FLAG_VIDEO_PARAM:
442 ctx = config->dummy_vctx;
443 dict = &config->video_opts;
444 guessed_codec_id = config->guessed_video_codec_id != AV_CODEC_ID_NONE ?
445 config->guessed_video_codec_id : AV_CODEC_ID_H264;
447 case AV_OPT_FLAG_AUDIO_PARAM:
448 ctx = config->dummy_actx;
449 dict = &config->audio_opts;
450 guessed_codec_id = config->guessed_audio_codec_id != AV_CODEC_ID_NONE ?
451 config->guessed_audio_codec_id : AV_CODEC_ID_AAC;
457 if (strchr(opt, ':')) {
458 //explicit private option
459 snprintf(buff, sizeof(buff), "%s", opt);
461 option = strchr(buff, ':');
462 buff[option - buff] = '\0';
464 if ((ret = ffserver_set_codec(ctx, codec_name, config)) < 0)
466 if (!ctx->codec || !ctx->priv_data)
472 o = av_opt_find(ctx, option, NULL, type | AV_OPT_FLAG_ENCODING_PARAM, AV_OPT_SEARCH_CHILDREN);
474 report_config_error(config->filename, config->line_num, AV_LOG_ERROR,
475 &config->errors, "Option not found: %s\n", opt);
476 if (!hinted && ctx->codec_id == AV_CODEC_ID_NONE) {
478 report_config_error(config->filename, config->line_num, AV_LOG_ERROR, NULL,
479 "If '%s' is a codec private option, then prefix it with codec name, "
480 "for example '%s:%s %s' or define codec earlier.\n",
481 opt, avcodec_get_name(guessed_codec_id) ,opt, arg);
483 } else if ((ret = av_opt_set(ctx, option, arg, AV_OPT_SEARCH_CHILDREN)) < 0) {
484 report_config_error(config->filename, config->line_num, AV_LOG_ERROR,
485 &config->errors, "Invalid value for option %s (%s): %s\n", opt,
486 arg, av_err2str(ret));
487 } else if ((e = av_dict_get(*dict, option, NULL, 0))) {
488 if ((o->type == AV_OPT_TYPE_FLAGS) && arg && (arg[0] == '+' || arg[0] == '-'))
489 return av_dict_set(dict, option, arg, AV_DICT_APPEND);
490 report_config_error(config->filename, config->line_num, AV_LOG_ERROR,
492 "Redeclaring value of the option %s, previous value: %s\n",
494 } else if (av_dict_set(dict, option, arg, 0) < 0) {
495 return AVERROR(ENOMEM);
500 #define ERROR(...) report_config_error(config->filename, config->line_num, AV_LOG_ERROR, &config->errors, __VA_ARGS__)
501 #define WARNING(...) report_config_error(config->filename, config->line_num, AV_LOG_WARNING, &config->warnings, __VA_ARGS__)
503 static int ffserver_parse_config_global(FFServerConfig *config, const char *cmd,
508 if (!av_strcasecmp(cmd, "Port") || !av_strcasecmp(cmd, "HTTPPort")) {
509 if (!av_strcasecmp(cmd, "Port"))
510 WARNING("Port option is deprecated, use HTTPPort instead\n");
511 ffserver_get_arg(arg, sizeof(arg), p);
512 ffserver_set_int_param(&val, arg, 0, 1, 65535, config,
513 "Invalid port: %s\n", arg);
515 WARNING("Trying to use IETF assigned system port: %d\n", val);
516 config->http_addr.sin_port = htons(val);
517 } else if (!av_strcasecmp(cmd, "HTTPBindAddress") || !av_strcasecmp(cmd, "BindAddress")) {
518 if (!av_strcasecmp(cmd, "BindAddress"))
519 WARNING("BindAddress option is deprecated, use HTTPBindAddress instead\n");
520 ffserver_get_arg(arg, sizeof(arg), p);
521 if (resolve_host(&config->http_addr.sin_addr, arg))
522 ERROR("Invalid host/IP address: %s\n", arg);
523 } else if (!av_strcasecmp(cmd, "NoDaemon")) {
524 WARNING("NoDaemon option has no effect, you should remove it\n");
525 } else if (!av_strcasecmp(cmd, "RTSPPort")) {
526 ffserver_get_arg(arg, sizeof(arg), p);
527 ffserver_set_int_param(&val, arg, 0, 1, 65535, config,
528 "Invalid port: %s\n", arg);
529 config->rtsp_addr.sin_port = htons(val);
530 } else if (!av_strcasecmp(cmd, "RTSPBindAddress")) {
531 ffserver_get_arg(arg, sizeof(arg), p);
532 if (resolve_host(&config->rtsp_addr.sin_addr, arg))
533 ERROR("Invalid host/IP address: %s\n", arg);
534 } else if (!av_strcasecmp(cmd, "MaxHTTPConnections")) {
535 ffserver_get_arg(arg, sizeof(arg), p);
536 ffserver_set_int_param(&val, arg, 0, 1, 65535, config,
537 "Invalid MaxHTTPConnections: %s\n", arg);
538 config->nb_max_http_connections = val;
539 if (config->nb_max_connections > config->nb_max_http_connections)
540 ERROR("Inconsistent configuration: MaxClients(%d) > MaxHTTPConnections(%d)\n",
541 config->nb_max_connections, config->nb_max_http_connections);
542 } else if (!av_strcasecmp(cmd, "MaxClients")) {
543 ffserver_get_arg(arg, sizeof(arg), p);
544 ffserver_set_int_param(&val, arg, 0, 1, 65535, config,
545 "Invalid MaxClients: %s\n", arg);
546 config->nb_max_connections = val;
547 if (config->nb_max_connections > config->nb_max_http_connections)
548 ERROR("Inconsistent configuration: MaxClients(%d) > MaxHTTPConnections(%d)\n",
549 config->nb_max_connections, config->nb_max_http_connections);
550 } else if (!av_strcasecmp(cmd, "MaxBandwidth")) {
553 ffserver_get_arg(arg, sizeof(arg), p);
555 llval = strtoll(arg, &tailp, 10);
556 if (llval < 10 || llval > 10000000 || tailp[0] || errno)
557 ERROR("Invalid MaxBandwidth: %s\n", arg);
559 config->max_bandwidth = llval;
560 } else if (!av_strcasecmp(cmd, "CustomLog")) {
562 ffserver_get_arg(config->logfilename, sizeof(config->logfilename), p);
563 } else if (!av_strcasecmp(cmd, "LoadModule")) {
564 ERROR("Loadable modules are no longer supported\n");
566 ERROR("Incorrect keyword: '%s'\n", cmd);
570 static int ffserver_parse_config_feed(FFServerConfig *config, const char *cmd, const char **p,
571 FFServerStream **pfeed)
573 FFServerStream *feed;
577 if (!av_strcasecmp(cmd, "<Feed")) {
580 feed = av_mallocz(sizeof(FFServerStream));
582 return AVERROR(ENOMEM);
583 ffserver_get_arg(feed->filename, sizeof(feed->filename), p);
584 q = strrchr(feed->filename, '>');
588 for (s = config->first_feed; s; s = s->next) {
589 if (!strcmp(feed->filename, s->filename))
590 ERROR("Feed '%s' already registered\n", s->filename);
593 feed->fmt = av_guess_format("ffm", NULL, NULL);
594 /* default feed file */
595 snprintf(feed->feed_filename, sizeof(feed->feed_filename),
596 "/tmp/%s.ffm", feed->filename);
597 feed->feed_max_size = 5 * 1024 * 1024;
599 feed->feed = feed; /* self feeding :-) */
604 if (!av_strcasecmp(cmd, "Launch")) {
607 feed->child_argv = av_mallocz(64 * sizeof(char *));
608 if (!feed->child_argv)
609 return AVERROR(ENOMEM);
610 for (i = 0; i < 62; i++) {
611 ffserver_get_arg(arg, sizeof(arg), p);
615 feed->child_argv[i] = av_strdup(arg);
616 if (!feed->child_argv[i])
617 return AVERROR(ENOMEM);
620 feed->child_argv[i] =
621 av_asprintf("http://%s:%d/%s",
622 (config->http_addr.sin_addr.s_addr == INADDR_ANY) ? "127.0.0.1" :
623 inet_ntoa(config->http_addr.sin_addr), ntohs(config->http_addr.sin_port),
625 if (!feed->child_argv[i])
626 return AVERROR(ENOMEM);
627 } else if (!av_strcasecmp(cmd, "ACL")) {
628 ffserver_parse_acl_row(NULL, feed, NULL, *p, config->filename,
630 } else if (!av_strcasecmp(cmd, "File") || !av_strcasecmp(cmd, "ReadOnlyFile")) {
631 ffserver_get_arg(feed->feed_filename, sizeof(feed->feed_filename), p);
632 feed->readonly = !av_strcasecmp(cmd, "ReadOnlyFile");
633 } else if (!av_strcasecmp(cmd, "Truncate")) {
634 ffserver_get_arg(arg, sizeof(arg), p);
635 /* assume Truncate is true in case no argument is specified */
639 WARNING("Truncate N syntax in configuration file is deprecated, "
640 "use Truncate alone with no arguments\n");
641 feed->truncate = strtod(arg, NULL);
643 } else if (!av_strcasecmp(cmd, "FileMaxSize")) {
647 ffserver_get_arg(arg, sizeof(arg), p);
649 fsize = strtod(p1, &p1);
650 switch(av_toupper(*p1)) {
655 fsize *= 1024 * 1024;
658 fsize *= 1024 * 1024 * 1024;
661 ERROR("Invalid file size: %s\n", arg);
664 feed->feed_max_size = (int64_t)fsize;
665 if (feed->feed_max_size < FFM_PACKET_SIZE*4)
666 ERROR("Feed max file size is too small, must be at least %d\n",
668 } else if (!av_strcasecmp(cmd, "</Feed>")) {
671 ERROR("Invalid entry '%s' inside <Feed></Feed>\n", cmd);
676 static void ffserver_apply_stream_config(AVCodecContext *enc, const AVDictionary *conf, AVDictionary **opts)
678 AVDictionaryEntry *e;
680 /* Return values from ffserver_set_*_param are ignored.
681 Values are initially parsed and checked before inserting to
685 if ((e = av_dict_get(conf, "VideoBitRateRangeMin", NULL, 0)))
686 ffserver_set_int_param(&enc->rc_min_rate, e->value, 1000, INT_MIN,
687 INT_MAX, NULL, 0, NULL);
688 if ((e = av_dict_get(conf, "VideoBitRateRangeMax", NULL, 0)))
689 ffserver_set_int_param(&enc->rc_max_rate, e->value, 1000, INT_MIN,
690 INT_MAX, NULL, 0, NULL);
691 if ((e = av_dict_get(conf, "Debug", NULL, 0)))
692 ffserver_set_int_param(&enc->debug, e->value, 0, INT_MIN, INT_MAX,
694 if ((e = av_dict_get(conf, "Strict", NULL, 0)))
695 ffserver_set_int_param(&enc->strict_std_compliance, e->value, 0,
696 INT_MIN, INT_MAX, NULL, 0, NULL);
697 if ((e = av_dict_get(conf, "VideoBufferSize", NULL, 0)))
698 ffserver_set_int_param(&enc->rc_buffer_size, e->value, 8*1024,
699 INT_MIN, INT_MAX, NULL, 0, NULL);
700 if ((e = av_dict_get(conf, "VideoBitRateTolerance", NULL, 0)))
701 ffserver_set_int_param(&enc->bit_rate_tolerance, e->value, 1000,
702 INT_MIN, INT_MAX, NULL, 0, NULL);
703 if ((e = av_dict_get(conf, "VideoBitRate", NULL, 0)))
704 ffserver_set_int_param(&enc->bit_rate, e->value, 1000, INT_MIN,
705 INT_MAX, NULL, 0, NULL);
706 if ((e = av_dict_get(conf, "VideoSizeWidth", NULL, 0)))
707 ffserver_set_int_param(&enc->width, e->value, 0, INT_MIN, INT_MAX,
709 if ((e = av_dict_get(conf, "VideoSizeHeight", NULL, 0)))
710 ffserver_set_int_param(&enc->height, e->value, 0, INT_MIN, INT_MAX,
712 if ((e = av_dict_get(conf, "PixelFormat", NULL, 0))) {
714 ffserver_set_int_param(&val, e->value, 0, INT_MIN, INT_MAX, NULL, 0,
718 if ((e = av_dict_get(conf, "VideoGopSize", NULL, 0)))
719 ffserver_set_int_param(&enc->gop_size, e->value, 0, INT_MIN, INT_MAX,
721 if ((e = av_dict_get(conf, "VideoFrameRateNum", NULL, 0)))
722 ffserver_set_int_param(&enc->time_base.num, e->value, 0, INT_MIN,
723 INT_MAX, NULL, 0, NULL);
724 if ((e = av_dict_get(conf, "VideoFrameRateDen", NULL, 0)))
725 ffserver_set_int_param(&enc->time_base.den, e->value, 0, INT_MIN,
726 INT_MAX, NULL, 0, NULL);
727 if ((e = av_dict_get(conf, "VideoQDiff", NULL, 0)))
728 ffserver_set_int_param(&enc->max_qdiff, e->value, 0, INT_MIN, INT_MAX,
730 if ((e = av_dict_get(conf, "VideoQMax", NULL, 0)))
731 ffserver_set_int_param(&enc->qmax, e->value, 0, INT_MIN, INT_MAX, NULL,
733 if ((e = av_dict_get(conf, "VideoQMin", NULL, 0)))
734 ffserver_set_int_param(&enc->qmin, e->value, 0, INT_MIN, INT_MAX, NULL,
736 if ((e = av_dict_get(conf, "LumiMask", NULL, 0)))
737 ffserver_set_float_param(&enc->lumi_masking, e->value, 0, -FLT_MAX,
738 FLT_MAX, NULL, 0, NULL);
739 if ((e = av_dict_get(conf, "DarkMask", NULL, 0)))
740 ffserver_set_float_param(&enc->dark_masking, e->value, 0, -FLT_MAX,
741 FLT_MAX, NULL, 0, NULL);
742 if (av_dict_get(conf, "BitExact", NULL, 0))
743 enc->flags |= CODEC_FLAG_BITEXACT;
744 if (av_dict_get(conf, "DctFastint", NULL, 0))
745 enc->dct_algo = FF_DCT_FASTINT;
746 if (av_dict_get(conf, "IdctSimple", NULL, 0))
747 enc->idct_algo = FF_IDCT_SIMPLE;
748 if (av_dict_get(conf, "VideoHighQuality", NULL, 0))
749 enc->mb_decision = FF_MB_DECISION_BITS;
750 if ((e = av_dict_get(conf, "VideoTag", NULL, 0)))
751 enc->codec_tag = MKTAG(e->value[0], e->value[1], e->value[2], e->value[3]);
752 if ((e = av_dict_get(conf, "Qscale", NULL, 0))) {
753 enc->flags |= CODEC_FLAG_QSCALE;
754 ffserver_set_int_param(&enc->global_quality, e->value, FF_QP2LAMBDA,
755 INT_MIN, INT_MAX, NULL, 0, NULL);
757 if (av_dict_get(conf, "Video4MotionVector", NULL, 0)) {
758 enc->mb_decision = FF_MB_DECISION_BITS; //FIXME remove
759 enc->flags |= CODEC_FLAG_4MV;
762 if ((e = av_dict_get(conf, "AudioChannels", NULL, 0)))
763 ffserver_set_int_param(&enc->channels, e->value, 0, INT_MIN, INT_MAX,
765 if ((e = av_dict_get(conf, "AudioSampleRate", NULL, 0)))
766 ffserver_set_int_param(&enc->sample_rate, e->value, 0, INT_MIN,
767 INT_MAX, NULL, 0, NULL);
768 if ((e = av_dict_get(conf, "AudioBitRate", NULL, 0)))
769 ffserver_set_int_param(&enc->bit_rate, e->value, 0, INT_MIN, INT_MAX,
772 av_opt_set_dict2(enc->priv_data, opts, AV_OPT_SEARCH_CHILDREN);
773 av_opt_set_dict2(enc, opts, AV_OPT_SEARCH_CHILDREN);
775 if (av_dict_count(*opts))
776 av_log(NULL, AV_LOG_ERROR, "Something went wrong, %d options not set!!!\n", av_dict_count(*opts));
779 static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd, const char **p,
780 FFServerStream **pstream)
782 char arg[1024], arg2[1024];
783 FFServerStream *stream;
789 if (!av_strcasecmp(cmd, "<Stream")) {
792 stream = av_mallocz(sizeof(FFServerStream));
794 return AVERROR(ENOMEM);
795 config->dummy_actx = avcodec_alloc_context3(NULL);
796 config->dummy_vctx = avcodec_alloc_context3(NULL);
797 if (!config->dummy_vctx || !config->dummy_actx) {
799 avcodec_free_context(&config->dummy_vctx);
800 avcodec_free_context(&config->dummy_actx);
801 return AVERROR(ENOMEM);
803 config->dummy_actx->codec_type = AVMEDIA_TYPE_AUDIO;
804 config->dummy_vctx->codec_type = AVMEDIA_TYPE_VIDEO;
805 ffserver_get_arg(stream->filename, sizeof(stream->filename), p);
806 q = strrchr(stream->filename, '>');
810 for (s = config->first_stream; s; s = s->next) {
811 if (!strcmp(stream->filename, s->filename))
812 ERROR("Stream '%s' already registered\n", s->filename);
815 stream->fmt = ffserver_guess_format(NULL, stream->filename, NULL);
817 config->guessed_audio_codec_id = stream->fmt->audio_codec;
818 config->guessed_video_codec_id = stream->fmt->video_codec;
820 config->guessed_audio_codec_id = AV_CODEC_ID_NONE;
821 config->guessed_video_codec_id = AV_CODEC_ID_NONE;
827 if (!av_strcasecmp(cmd, "Feed")) {
828 FFServerStream *sfeed;
829 ffserver_get_arg(arg, sizeof(arg), p);
830 sfeed = config->first_feed;
832 if (!strcmp(sfeed->filename, arg))
834 sfeed = sfeed->next_feed;
837 ERROR("Feed with name '%s' for stream '%s' is not defined\n", arg,
840 stream->feed = sfeed;
841 } else if (!av_strcasecmp(cmd, "Format")) {
842 ffserver_get_arg(arg, sizeof(arg), p);
843 if (!strcmp(arg, "status")) {
844 stream->stream_type = STREAM_TYPE_STATUS;
847 stream->stream_type = STREAM_TYPE_LIVE;
848 /* JPEG cannot be used here, so use single frame MJPEG */
849 if (!strcmp(arg, "jpeg"))
850 strcpy(arg, "mjpeg");
851 stream->fmt = ffserver_guess_format(arg, NULL, NULL);
853 ERROR("Unknown Format: %s\n", arg);
856 config->guessed_audio_codec_id = stream->fmt->audio_codec;
857 config->guessed_video_codec_id = stream->fmt->video_codec;
859 } else if (!av_strcasecmp(cmd, "InputFormat")) {
860 ffserver_get_arg(arg, sizeof(arg), p);
861 stream->ifmt = av_find_input_format(arg);
863 ERROR("Unknown input format: %s\n", arg);
864 } else if (!av_strcasecmp(cmd, "FaviconURL")) {
865 if (stream->stream_type == STREAM_TYPE_STATUS)
866 ffserver_get_arg(stream->feed_filename,
867 sizeof(stream->feed_filename), p);
869 ERROR("FaviconURL only permitted for status streams\n");
870 } else if (!av_strcasecmp(cmd, "Author") ||
871 !av_strcasecmp(cmd, "Comment") ||
872 !av_strcasecmp(cmd, "Copyright") ||
873 !av_strcasecmp(cmd, "Title")) {
876 ffserver_get_arg(arg, sizeof(arg), p);
877 for (i = 0; i < strlen(cmd); i++)
878 key[i] = av_tolower(cmd[i]);
880 WARNING("'%s' option in configuration file is deprecated, "
881 "use 'Metadata %s VALUE' instead\n", cmd, key);
882 if (av_dict_set(&stream->metadata, key, arg, 0) < 0)
884 } else if (!av_strcasecmp(cmd, "Metadata")) {
885 ffserver_get_arg(arg, sizeof(arg), p);
886 ffserver_get_arg(arg2, sizeof(arg2), p);
887 if (av_dict_set(&stream->metadata, arg, arg2, 0) < 0)
889 } else if (!av_strcasecmp(cmd, "Preroll")) {
890 ffserver_get_arg(arg, sizeof(arg), p);
891 stream->prebuffer = atof(arg) * 1000;
892 } else if (!av_strcasecmp(cmd, "StartSendOnKey")) {
893 stream->send_on_key = 1;
894 } else if (!av_strcasecmp(cmd, "AudioCodec")) {
895 ffserver_get_arg(arg, sizeof(arg), p);
896 ffserver_set_codec(config->dummy_actx, arg, config);
897 } else if (!av_strcasecmp(cmd, "VideoCodec")) {
898 ffserver_get_arg(arg, sizeof(arg), p);
899 ffserver_set_codec(config->dummy_vctx, arg, config);
900 } else if (!av_strcasecmp(cmd, "MaxTime")) {
901 ffserver_get_arg(arg, sizeof(arg), p);
902 stream->max_time = atof(arg) * 1000;
903 } else if (!av_strcasecmp(cmd, "AudioBitRate")) {
905 ffserver_get_arg(arg, sizeof(arg), p);
906 ffserver_set_float_param(&f, arg, 1000, 0, FLT_MAX, config,
907 "Invalid %s: %s\n", cmd, arg);
908 if (av_dict_set_int(&config->audio_conf, cmd, lrintf(f), 0) < 0)
910 } else if (!av_strcasecmp(cmd, "AudioChannels")) {
911 ffserver_get_arg(arg, sizeof(arg), p);
912 ffserver_set_int_param(NULL, arg, 0, 1, 8, config,
913 "Invalid %s: %s, valid range is 1-8.", cmd, arg);
914 if (av_dict_set(&config->audio_conf, cmd, arg, 0) < 0)
916 } else if (!av_strcasecmp(cmd, "AudioSampleRate")) {
917 ffserver_get_arg(arg, sizeof(arg), p);
918 ffserver_set_int_param(NULL, arg, 0, 0, INT_MAX, config,
919 "Invalid %s: %s", cmd, arg);
920 if (av_dict_set(&config->audio_conf, cmd, arg, 0) < 0)
922 } else if (!av_strcasecmp(cmd, "VideoBitRateRange")) {
923 int minrate, maxrate;
924 ffserver_get_arg(arg, sizeof(arg), p);
925 if (sscanf(arg, "%d-%d", &minrate, &maxrate) == 2) {
926 if (av_dict_set_int(&config->video_conf, "VideoBitRateRangeMin", minrate, 0) < 0 ||
927 av_dict_set_int(&config->video_conf, "VideoBitRateRangeMax", maxrate, 0) < 0)
930 ERROR("Incorrect format for VideoBitRateRange -- should be "
931 "<min>-<max>: %s\n", arg);
932 } else if (!av_strcasecmp(cmd, "Debug")) {
933 ffserver_get_arg(arg, sizeof(arg), p);
934 ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config,
935 "Invalid %s: %s", cmd, arg);
936 if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
938 } else if (!av_strcasecmp(cmd, "Strict")) {
939 ffserver_get_arg(arg, sizeof(arg), p);
940 ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config,
941 "Invalid %s: %s", cmd, arg);
942 if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
944 } else if (!av_strcasecmp(cmd, "VideoBufferSize")) {
945 ffserver_get_arg(arg, sizeof(arg), p);
946 ffserver_set_int_param(NULL, arg, 8*1024, 0, INT_MAX, config,
947 "Invalid %s: %s", cmd, arg);
948 if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
950 } else if (!av_strcasecmp(cmd, "VideoBitRateTolerance")) {
951 ffserver_get_arg(arg, sizeof(arg), p);
952 ffserver_set_int_param(NULL, arg, 1000, INT_MIN, INT_MAX, config,
953 "Invalid %s: %s", cmd, arg);
954 if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
956 } else if (!av_strcasecmp(cmd, "VideoBitRate")) {
957 ffserver_get_arg(arg, sizeof(arg), p);
958 ffserver_set_int_param(NULL, arg, 1000, 0, INT_MAX, config,
959 "Invalid %s: %s", cmd, arg);
960 if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
962 } else if (!av_strcasecmp(cmd, "VideoSize")) {
964 ffserver_get_arg(arg, sizeof(arg), p);
965 ret = av_parse_video_size(&w, &h, arg);
967 ERROR("Invalid video size '%s'\n", arg);
968 else if ((w % 2) || (h % 2))
969 WARNING("Image size is not a multiple of 2\n");
970 if (av_dict_set_int(&config->video_conf, "VideoSizeWidth", w, 0) < 0 ||
971 av_dict_set_int(&config->video_conf, "VideoSizeHeight", h, 0) < 0)
973 } else if (!av_strcasecmp(cmd, "VideoFrameRate")) {
974 AVRational frame_rate;
975 ffserver_get_arg(arg, sizeof(arg), p);
976 if (av_parse_video_rate(&frame_rate, arg) < 0) {
977 ERROR("Incorrect frame rate: %s\n", arg);
979 if (av_dict_set_int(&config->video_conf, "VideoFrameRateNum", frame_rate.num, 0) < 0 ||
980 av_dict_set_int(&config->video_conf, "VideoFrameRateDen", frame_rate.den, 0) < 0)
983 } else if (!av_strcasecmp(cmd, "PixelFormat")) {
984 enum AVPixelFormat pix_fmt;
985 ffserver_get_arg(arg, sizeof(arg), p);
986 pix_fmt = av_get_pix_fmt(arg);
987 if (pix_fmt == AV_PIX_FMT_NONE)
988 ERROR("Unknown pixel format: %s\n", arg);
989 if (av_dict_set_int(&config->video_conf, cmd, pix_fmt, 0) < 0)
991 } else if (!av_strcasecmp(cmd, "VideoGopSize")) {
992 ffserver_get_arg(arg, sizeof(arg), p);
993 ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config,
994 "Invalid %s: %s", cmd, arg);
995 if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
997 } else if (!av_strcasecmp(cmd, "VideoIntraOnly")) {
998 if (av_dict_set(&config->video_conf, "VideoGopSize", "1", 0) < 0)
1000 } else if (!av_strcasecmp(cmd, "VideoHighQuality")) {
1001 if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
1003 } else if (!av_strcasecmp(cmd, "Video4MotionVector")) {
1004 if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
1006 } else if (!av_strcasecmp(cmd, "AVOptionVideo") ||
1007 !av_strcasecmp(cmd, "AVOptionAudio")) {
1009 ffserver_get_arg(arg, sizeof(arg), p);
1010 ffserver_get_arg(arg2, sizeof(arg2), p);
1011 if (!av_strcasecmp(cmd, "AVOptionVideo"))
1012 ret = ffserver_save_avoption(arg, arg2, AV_OPT_FLAG_VIDEO_PARAM, config);
1014 ret = ffserver_save_avoption(arg, arg2, AV_OPT_FLAG_AUDIO_PARAM, config);
1017 } else if (!av_strcasecmp(cmd, "AVPresetVideo") ||
1018 !av_strcasecmp(cmd, "AVPresetAudio")) {
1019 ffserver_get_arg(arg, sizeof(arg), p);
1020 if (!av_strcasecmp(cmd, "AVPresetVideo"))
1021 ffserver_opt_preset(arg, AV_OPT_FLAG_VIDEO_PARAM, config);
1023 ffserver_opt_preset(arg, AV_OPT_FLAG_AUDIO_PARAM, config);
1024 } else if (!av_strcasecmp(cmd, "VideoTag")) {
1025 ffserver_get_arg(arg, sizeof(arg), p);
1026 if (strlen(arg) == 4) {
1027 if (av_dict_set(&config->video_conf, "VideoTag", arg, 0) < 0)
1030 } else if (!av_strcasecmp(cmd, "BitExact")) {
1031 if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
1033 } else if (!av_strcasecmp(cmd, "DctFastint")) {
1034 if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
1036 } else if (!av_strcasecmp(cmd, "IdctSimple")) {
1037 if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
1039 } else if (!av_strcasecmp(cmd, "Qscale")) {
1040 ffserver_get_arg(arg, sizeof(arg), p);
1041 if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
1043 } else if (!av_strcasecmp(cmd, "VideoQDiff")) {
1044 ffserver_get_arg(arg, sizeof(arg), p);
1045 ffserver_set_int_param(NULL, arg, 0, 1, 31, config,
1046 "%s out of range\n", cmd);
1047 if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
1049 } else if (!av_strcasecmp(cmd, "VideoQMax")) {
1050 ffserver_get_arg(arg, sizeof(arg), p);
1051 ffserver_set_int_param(NULL, arg, 0, 1, 31, config,
1052 "%s out of range\n", cmd);
1053 if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
1055 } else if (!av_strcasecmp(cmd, "VideoQMin")) {
1056 ffserver_get_arg(arg, sizeof(arg), p);
1057 ffserver_set_int_param(NULL, arg, 0, 1, 31, config,
1058 "%s out of range\n", cmd);
1059 if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
1061 } else if (!av_strcasecmp(cmd, "LumiMask")) {
1062 ffserver_get_arg(arg, sizeof(arg), p);
1063 ffserver_set_float_param(NULL, arg, 0, -FLT_MAX, FLT_MAX, config,
1064 "Invalid %s: %s", cmd, arg);
1065 if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
1067 } else if (!av_strcasecmp(cmd, "DarkMask")) {
1068 ffserver_get_arg(arg, sizeof(arg), p);
1069 ffserver_set_float_param(NULL, arg, 0, -FLT_MAX, FLT_MAX, config,
1070 "Invalid %s: %s", cmd, arg);
1071 if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
1073 } else if (!av_strcasecmp(cmd, "NoVideo")) {
1074 config->no_video = 1;
1075 } else if (!av_strcasecmp(cmd, "NoAudio")) {
1076 config->no_audio = 1;
1077 } else if (!av_strcasecmp(cmd, "ACL")) {
1078 ffserver_parse_acl_row(stream, NULL, NULL, *p, config->filename,
1080 } else if (!av_strcasecmp(cmd, "DynamicACL")) {
1081 ffserver_get_arg(stream->dynamic_acl, sizeof(stream->dynamic_acl), p);
1082 } else if (!av_strcasecmp(cmd, "RTSPOption")) {
1083 ffserver_get_arg(arg, sizeof(arg), p);
1084 av_freep(&stream->rtsp_option);
1085 stream->rtsp_option = av_strdup(arg);
1086 } else if (!av_strcasecmp(cmd, "MulticastAddress")) {
1087 ffserver_get_arg(arg, sizeof(arg), p);
1088 if (resolve_host(&stream->multicast_ip, arg))
1089 ERROR("Invalid host/IP address: %s\n", arg);
1090 stream->is_multicast = 1;
1091 stream->loop = 1; /* default is looping */
1092 } else if (!av_strcasecmp(cmd, "MulticastPort")) {
1093 ffserver_get_arg(arg, sizeof(arg), p);
1094 ffserver_set_int_param(&val, arg, 0, 1, 65535, config,
1095 "Invalid MulticastPort: %s\n", arg);
1096 stream->multicast_port = val;
1097 } else if (!av_strcasecmp(cmd, "MulticastTTL")) {
1098 ffserver_get_arg(arg, sizeof(arg), p);
1099 ffserver_set_int_param(&val, arg, 0, INT_MIN, INT_MAX, config,
1100 "Invalid MulticastTTL: %s\n", arg);
1101 stream->multicast_ttl = val;
1102 } else if (!av_strcasecmp(cmd, "NoLoop")) {
1104 } else if (!av_strcasecmp(cmd, "</Stream>")) {
1105 if (stream->feed && stream->fmt && strcmp(stream->fmt->name, "ffm")) {
1106 if (config->dummy_actx->codec_id == AV_CODEC_ID_NONE)
1107 config->dummy_actx->codec_id = config->guessed_audio_codec_id;
1108 if (!config->no_audio && config->dummy_actx->codec_id != AV_CODEC_ID_NONE) {
1109 AVCodecContext *audio_enc = avcodec_alloc_context3(avcodec_find_encoder(config->dummy_actx->codec_id));
1110 ffserver_apply_stream_config(audio_enc, config->audio_conf, &config->audio_opts);
1111 add_codec(stream, audio_enc);
1113 if (config->dummy_vctx->codec_id == AV_CODEC_ID_NONE)
1114 config->dummy_vctx->codec_id = config->guessed_video_codec_id;
1115 if (!config->no_video && config->dummy_vctx->codec_id != AV_CODEC_ID_NONE) {
1116 AVCodecContext *video_enc = avcodec_alloc_context3(avcodec_find_encoder(config->dummy_vctx->codec_id));
1117 ffserver_apply_stream_config(video_enc, config->video_conf, &config->video_opts);
1118 add_codec(stream, video_enc);
1121 av_dict_free(&config->video_opts);
1122 av_dict_free(&config->video_conf);
1123 av_dict_free(&config->audio_opts);
1124 av_dict_free(&config->audio_conf);
1125 avcodec_free_context(&config->dummy_vctx);
1126 avcodec_free_context(&config->dummy_actx);
1128 } else if (!av_strcasecmp(cmd, "File") || !av_strcasecmp(cmd, "ReadOnlyFile")) {
1129 ffserver_get_arg(stream->feed_filename, sizeof(stream->feed_filename),
1132 ERROR("Invalid entry '%s' inside <Stream></Stream>\n", cmd);
1136 av_log(NULL, AV_LOG_ERROR, "Out of memory. Aborting.\n");
1137 av_dict_free(&config->video_opts);
1138 av_dict_free(&config->video_conf);
1139 av_dict_free(&config->audio_opts);
1140 av_dict_free(&config->audio_conf);
1141 avcodec_free_context(&config->dummy_vctx);
1142 avcodec_free_context(&config->dummy_actx);
1143 return AVERROR(ENOMEM);
1146 static int ffserver_parse_config_redirect(FFServerConfig *config, const char *cmd, const char **p,
1147 FFServerStream **predirect)
1149 FFServerStream *redirect;
1150 av_assert0(predirect);
1151 redirect = *predirect;
1153 if (!av_strcasecmp(cmd, "<Redirect")) {
1155 redirect = av_mallocz(sizeof(FFServerStream));
1157 return AVERROR(ENOMEM);
1159 ffserver_get_arg(redirect->filename, sizeof(redirect->filename), p);
1160 q = strrchr(redirect->filename, '>');
1163 redirect->stream_type = STREAM_TYPE_REDIRECT;
1164 *predirect = redirect;
1167 av_assert0(redirect);
1168 if (!av_strcasecmp(cmd, "URL")) {
1169 ffserver_get_arg(redirect->feed_filename,
1170 sizeof(redirect->feed_filename), p);
1171 } else if (!av_strcasecmp(cmd, "</Redirect>")) {
1172 if (!redirect->feed_filename[0])
1173 ERROR("No URL found for <Redirect>\n");
1176 ERROR("Invalid entry '%s' inside <Redirect></Redirect>\n", cmd);
1181 int ffserver_parse_ffconfig(const char *filename, FFServerConfig *config)
1187 FFServerStream **last_stream, *stream = NULL, *redirect = NULL;
1188 FFServerStream **last_feed, *feed = NULL;
1193 config->line_num = 0;
1194 f = fopen(filename, "r");
1196 ret = AVERROR(errno);
1197 av_log(NULL, AV_LOG_ERROR,
1198 "Could not open the configuration file '%s'\n", filename);
1202 config->first_stream = NULL;
1203 last_stream = &config->first_stream;
1204 config->first_feed = NULL;
1205 last_feed = &config->first_feed;
1206 config->errors = config->warnings = 0;
1209 if (fgets(line, sizeof(line), f) == NULL)
1213 while (av_isspace(*p))
1215 if (*p == '\0' || *p == '#')
1218 ffserver_get_arg(cmd, sizeof(cmd), &p);
1220 if (feed || !av_strcasecmp(cmd, "<Feed")) {
1221 int opening = !av_strcasecmp(cmd, "<Feed");
1222 if (opening && (stream || feed || redirect)) {
1223 ERROR("Already in a tag\n");
1225 if ((ret = ffserver_parse_config_feed(config, cmd, &p, &feed)) < 0)
1228 /* add in stream list */
1229 *last_stream = feed;
1230 last_stream = &feed->next;
1231 /* add in feed list */
1233 last_feed = &feed->next_feed;
1236 } else if (stream || !av_strcasecmp(cmd, "<Stream")) {
1237 int opening = !av_strcasecmp(cmd, "<Stream");
1238 if (opening && (stream || feed || redirect)) {
1239 ERROR("Already in a tag\n");
1241 if ((ret = ffserver_parse_config_stream(config, cmd, &p, &stream)) < 0)
1244 /* add in stream list */
1245 *last_stream = stream;
1246 last_stream = &stream->next;
1249 } else if (redirect || !av_strcasecmp(cmd, "<Redirect")) {
1250 int opening = !av_strcasecmp(cmd, "<Redirect");
1251 if (opening && (stream || feed || redirect))
1252 ERROR("Already in a tag\n");
1254 if ((ret = ffserver_parse_config_redirect(config, cmd, &p, &redirect)) < 0)
1257 /* add in stream list */
1258 *last_stream = redirect;
1259 last_stream = &redirect->next;
1263 ffserver_parse_config_global(config, cmd, &p);
1266 if (stream || feed || redirect)
1267 ERROR("Not closed tag %s\n", stream ? "<Stream>" : (feed ? "<Feed>" : "<Redirect>"));
1273 return AVERROR(EINVAL);