[FFmpeg-devel] [PATCH] ffserver: extend report_config_error() facilities, and use it for warnings

Stefano Sabatini stefasab at gmail.com
Fri Nov 29 08:55:43 CET 2013


---
 ffserver.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index f9efaf7..51bddf6 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -4038,12 +4038,12 @@ static AVOutputFormat *ffserver_guess_format(const char *short_name, const char
     return fmt;
 }
 
-static void report_config_error(const char *filename, int line_num, int *errors, const char *fmt, ...)
+static void report_config_error(const char *filename, int line_num, int log_level, int *errors, const char *fmt, ...)
 {
     va_list vl;
     va_start(vl, fmt);
-    fprintf(stderr, "%s:%d: ", filename, line_num);
-    vfprintf(stderr, fmt, vl);
+    av_log(NULL, log_level, "%s:%d: ", filename, line_num);
+    av_vlog(NULL, log_level, fmt, vl);
     va_end(vl);
 
     (*errors)++;
@@ -4056,7 +4056,7 @@ static int parse_ffconfig(const char *filename)
     char cmd[64];
     char arg[1024], arg2[1024];
     const char *p;
-    int val, errors, line_num;
+    int val, errors, warnings, line_num;
     FFStream **last_stream, *stream, *redirect;
     FFStream **last_feed, *feed, *s;
     AVCodecContext audio_enc, video_enc;
@@ -4070,7 +4070,7 @@ static int parse_ffconfig(const char *filename)
         return ret;
     }
 
-    errors = 0;
+    errors = warnings = 0;
     line_num = 0;
     first_stream = NULL;
     last_stream = &first_stream;
@@ -4081,8 +4081,9 @@ static int parse_ffconfig(const char *filename)
     redirect = NULL;
     audio_id = AV_CODEC_ID_NONE;
     video_id = AV_CODEC_ID_NONE;
+#define ERROR(...)   report_config_error(filename, line_num, AV_LOG_ERROR,   &errors,   __VA_ARGS__)
+#define WARNING(...) report_config_error(filename, line_num, AV_LOG_WARNING, &warnings, __VA_ARGS__)
 
-#define ERROR(...) report_config_error(filename, line_num, &errors, __VA_ARGS__)
     for(;;) {
         if (fgets(line, sizeof(line), f) == NULL)
             break;
@@ -4108,7 +4109,7 @@ static int parse_ffconfig(const char *filename)
                 ERROR("%s:%d: Invalid host/IP address: %s\n", arg);
             }
         } else if (!av_strcasecmp(cmd, "NoDaemon")) {
-            // do nothing here, its the default now
+            WARNING("NoDaemon option has no effect, you should remove it\n");
         } else if (!av_strcasecmp(cmd, "RTSPPort")) {
             get_arg(arg, sizeof(arg), &p);
             val = atoi(arg);
@@ -4230,9 +4231,8 @@ static int parse_ffconfig(const char *filename)
                 if (!arg[0]) {
                     feed->truncate = 1;
                 } else {
-                    av_log(NULL, AV_LOG_WARNING,
-                           "Truncate N syntax in configuration file is deprecated, "
-                           "use Truncate alone with no arguments\n");
+                    WARNING("Truncate N syntax in configuration file is deprecated, "
+                            "use Truncate alone with no arguments\n");
                     feed->truncate = strtod(arg, NULL);
                 }
             }
@@ -4364,9 +4364,8 @@ static int parse_ffconfig(const char *filename)
                 char key[32];
                 int i, ret;
 
-                av_log(NULL, AV_LOG_WARNING,
-                       "'%s' option in configuration file is deprecated, "
-                       "use 'Metadata %s VALUE' instead\n", cmd, cmd);
+                WARNING("'%s' option in configuration file is deprecated, "
+                        "use 'Metadata %s VALUE' instead\n", cmd, cmd);
                 for (i = 0; i < strlen(cmd); i++)
                     key[i] = av_tolower(cmd[i]);
                 key[i] = 0;
-- 
1.8.1.2



More information about the ffmpeg-devel mailing list