lavc/h264dec: Improve "Increasing reorder buffer" message loglevel.
[ffmpeg.git] / ffserver_config.c
index d17b57e..0ec93b5 100644 (file)
@@ -42,8 +42,8 @@ static void report_config_error(const char *filename, int line_num,
                                 int log_level, int *errors, const char *fmt,
                                 ...);
 
-#define ERROR(...)   report_config_error(config->filename, config->line_num,\
-                                         AV_LOG_ERROR, &config->errors,  __VA_ARGS__)
+#define ERROR(...) report_config_error(config->filename, config->line_num,\
+                                       AV_LOG_ERROR, &config->errors, __VA_ARGS__)
 #define WARNING(...) report_config_error(config->filename, config->line_num,\
                                          AV_LOG_WARNING, &config->warnings, __VA_ARGS__)
 
@@ -116,7 +116,8 @@ void ffserver_parse_acl_row(FFServerStream *stream, FFServerStream* feed,
 {
     char arg[1024];
     FFServerIPAddressACL acl;
-    int errors = 0;
+    FFServerIPAddressACL *nacl;
+    FFServerIPAddressACL **naclp;
 
     ffserver_get_arg(arg, sizeof(arg), &p);
     if (av_strcasecmp(arg, "allow") == 0)
@@ -126,7 +127,7 @@ void ffserver_parse_acl_row(FFServerStream *stream, FFServerStream* feed,
     else {
         fprintf(stderr, "%s:%d: ACL action '%s' should be ALLOW or DENY.\n",
                 filename, line_num, arg);
-        errors++;
+        goto bail;
     }
 
     ffserver_get_arg(arg, sizeof(arg), &p);
@@ -135,9 +136,10 @@ void ffserver_parse_acl_row(FFServerStream *stream, FFServerStream* feed,
         fprintf(stderr,
                 "%s:%d: ACL refers to invalid host or IP address '%s'\n",
                 filename, line_num, arg);
-        errors++;
-    } else
-        acl.last = acl.first;
+        goto bail;
+    }
+
+    acl.last = acl.first;
 
     ffserver_get_arg(arg, sizeof(arg), &p);
 
@@ -146,37 +148,37 @@ void ffserver_parse_acl_row(FFServerStream *stream, FFServerStream* feed,
             fprintf(stderr,
                     "%s:%d: ACL refers to invalid host or IP address '%s'\n",
                     filename, line_num, arg);
-            errors++;
+            goto bail;
         }
     }
 
-    if (!errors) {
-        FFServerIPAddressACL *nacl = av_mallocz(sizeof(*nacl));
-        FFServerIPAddressACL **naclp = 0;
+    nacl = av_mallocz(sizeof(*nacl));
+    naclp = 0;
 
-        acl.next = 0;
-        *nacl = acl;
+    acl.next = 0;
+    *nacl = acl;
 
-        if (stream)
-            naclp = &stream->acl;
-        else if (feed)
-            naclp = &feed->acl;
-        else if (ext_acl)
-            naclp = &ext_acl;
-        else {
-            fprintf(stderr, "%s:%d: ACL found not in <Stream> or <Feed>\n",
-                    filename, line_num);
-            errors++;
-        }
+    if (stream)
+        naclp = &stream->acl;
+    else if (feed)
+        naclp = &feed->acl;
+    else if (ext_acl)
+        naclp = &ext_acl;
+    else
+        fprintf(stderr, "%s:%d: ACL found not in <Stream> or <Feed>\n",
+                filename, line_num);
 
-        if (naclp) {
-            while (*naclp)
-                naclp = &(*naclp)->next;
+    if (naclp) {
+        while (*naclp)
+            naclp = &(*naclp)->next;
+
+        *naclp = nacl;
+    } else
+        av_free(nacl);
+
+bail:
+  return;
 
-            *naclp = nacl;
-        } else
-            av_free(nacl);
-    }
 }
 
 /* add a codec and set the default parameters */
@@ -195,19 +197,44 @@ static void add_codec(FFServerStream *stream, AVCodecContext *av,
     av_dict_copy(&recommended, *opts, 0);
     av_opt_set_dict2(av->priv_data, opts, AV_OPT_SEARCH_CHILDREN);
     av_opt_set_dict2(av, opts, AV_OPT_SEARCH_CHILDREN);
+
     if (av_dict_count(*opts))
         av_log(NULL, AV_LOG_WARNING,
                "Something is wrong, %d options are not set!\n",
                av_dict_count(*opts));
 
-    if (config->stream_use_defaults) {
-    //TODO: reident
+    if (!config->stream_use_defaults) {
+        switch(av->codec_type) {
+        case AVMEDIA_TYPE_AUDIO:
+            if (av->bit_rate == 0)
+                report_config_error(config->filename, config->line_num,
+                                    AV_LOG_ERROR, &config->errors,
+                                    "audio bit rate is not set\n");
+            if (av->sample_rate == 0)
+                report_config_error(config->filename, config->line_num,
+                                    AV_LOG_ERROR, &config->errors,
+                                    "audio sample rate is not set\n");
+            break;
+        case AVMEDIA_TYPE_VIDEO:
+            if (av->width == 0 || av->height == 0)
+                report_config_error(config->filename, config->line_num,
+                                    AV_LOG_ERROR, &config->errors,
+                                    "video size is not set\n");
+            break;
+        default:
+            av_assert0(0);
+        }
+        goto done;
+    }
+
+    /* stream_use_defaults = true */
+
     /* compute default parameters */
     switch(av->codec_type) {
     case AVMEDIA_TYPE_AUDIO:
-        if (!av_dict_get(recommended, "ab", NULL, 0)) {
+        if (!av_dict_get(recommended, "b", NULL, 0)) {
             av->bit_rate = 64000;
-            av_dict_set_int(&recommended, "ab", av->bit_rate, 0);
+            av_dict_set_int(&recommended, "b", av->bit_rate, 0);
             WARNING("Setting default value for audio bit rate = %d. "
                     "Use NoDefaults to disable it.\n",
                     av->bit_rate);
@@ -287,29 +314,8 @@ static void add_codec(FFServerStream *stream, AVCodecContext *av,
     default:
         abort();
     }
-    } else {
-        switch(av->codec_type) {
-        case AVMEDIA_TYPE_AUDIO:
-            if (av->bit_rate == 0)
-                report_config_error(config->filename, config->line_num,
-                                    AV_LOG_ERROR, &config->errors,
-                                    "audio bit rate is not set\n");
-            if (av->sample_rate == 0)
-                report_config_error(config->filename, config->line_num,
-                                    AV_LOG_ERROR, &config->errors,
-                                    "audio sample rate is not set\n");
-            break;
-        case AVMEDIA_TYPE_VIDEO:
-            if (av->width == 0 || av->height == 0)
-                report_config_error(config->filename, config->line_num,
-                                    AV_LOG_ERROR, &config->errors,
-                                    "video size is not set\n");
-            break;
-        default:
-            av_assert0(0);
-        }
-    }
 
+done:
     st = av_mallocz(sizeof(AVStream));
     if (!st)
         return;
@@ -454,7 +460,7 @@ static int ffserver_set_int_param(int *dest, const char *value, int factor,
     if (tmp < min || tmp > max)
         goto error;
     if (factor) {
-        if (FFABS(tmp) > INT_MAX / FFABS(factor))
+        if (tmp == INT_MIN || FFABS(tmp) > INT_MAX / FFABS(factor))
             goto error;
         tmp *= factor;
     }
@@ -679,8 +685,8 @@ static int ffserver_parse_config_global(FFServerConfig *config, const char *cmd,
     return 0;
 }
 
-static int ffserver_parse_config_feed(FFServerConfig *config, const char *cmd, const char **p,
-                                      FFServerStream **pfeed)
+static int ffserver_parse_config_feed(FFServerConfig *config, const char *cmd,
+                                      const char **p, FFServerStream **pfeed)
 {
     FFServerStream *feed;
     char arg[1024];
@@ -787,7 +793,8 @@ static int ffserver_parse_config_feed(FFServerConfig *config, const char *cmd, c
     return 0;
 }
 
-static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd, const char **p,
+static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd,
+                                        const char **p,
                                         FFServerStream **pstream)
 {
     char arg[1024], arg2[1024];
@@ -858,8 +865,10 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd,
         } else {
             stream->stream_type = STREAM_TYPE_LIVE;
             /* JPEG cannot be used here, so use single frame MJPEG */
-            if (!strcmp(arg, "jpeg"))
-                strcpy(arg, "mjpeg");
+            if (!strcmp(arg, "jpeg")) {
+                strcpy(arg, "singlejpeg");
+                stream->single_frame=1;
+            }
             stream->fmt = ffserver_guess_format(arg, NULL, NULL);
             if (!stream->fmt)
                 ERROR("Unknown Format: '%s'\n", arg);
@@ -917,7 +926,7 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd,
         ffserver_get_arg(arg, sizeof(arg), p);
         ffserver_set_float_param(&f, arg, 1000, -FLT_MAX, FLT_MAX, config,
                 "Invalid %s: '%s'\n", cmd, arg);
-        if (ffserver_save_avoption_int("ab", (int64_t)lrintf(f),
+        if (ffserver_save_avoption_int("b", (int64_t)lrintf(f),
                                        AV_OPT_FLAG_AUDIO_PARAM, config) < 0)
             goto nomem;
     } else if (!av_strcasecmp(cmd, "AudioChannels")) {
@@ -1129,6 +1138,8 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd,
         av_dict_free(&config->audio_opts);
         avcodec_free_context(&config->dummy_vctx);
         avcodec_free_context(&config->dummy_actx);
+        config->no_video = 0;
+        config->no_audio = 0;
         *pstream = NULL;
     } else if (!av_strcasecmp(cmd, "File") ||
                !av_strcasecmp(cmd, "ReadOnlyFile")) {