Re: [FFmpeg-devel] [PATCH 3/4] ffserver_conf: factorize parse function per config tag

2014-10-22 Thread Reynaldo H. Verdejo Pinochet
Feel free to push after removing the explicit/redundant
initialization of FFServerConfig config as Reimar suggested.

While you are at this though, can you remove braces on
single statement ifs? appreciated.

Thanks


-- 
Reynaldo H. Verdejo Pinochet
Open Source Group
Samsung Research America / Silicon Valley
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/4] ffserver_conf: factorize parse function per config tag

2014-10-21 Thread Stefano Sabatini
On date Monday 2014-10-20 23:57:01 +0200, Lukasz Marek encoded:
 Signed-off-by: Lukasz Marek lukasz.m.lu...@gmail.com
 ---
  ffserver.c|6 +
  ffserver_config.c | 1138 
 ++---
  ffserver_config.h |7 +
  3 files changed, 566 insertions(+), 585 deletions(-)
 
 diff --git a/ffserver.c b/ffserver.c
 index af6e8e1..22560ce 100644
 --- a/ffserver.c
 +++ b/ffserver.c
 @@ -208,6 +208,12 @@ static FFServerConfig config = {
  .logfilename = {0},
  .http_addr = {0},
  .rtsp_addr = {0},
 +.errors = 0,
 +.warnings = 0,
 +.audio_id = AV_CODEC_ID_NONE,
 +.video_id = AV_CODEC_ID_NONE,
 +.audio_enc = {0},
 +.video_enc = {0},
  };

Probably good, also I like the idea to split the big parsing function.

[...]
-- 
FFmpeg = Forgiving Frenzy Miracolous Perfectionist Evanescent Gadget
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/4] ffserver_conf: factorize parse function per config tag

2014-10-21 Thread Reimar Döffinger
On 21.10.2014, at 12:15, Stefano Sabatini stefa...@gmail.com wrote:
 On date Monday 2014-10-20 23:57:01 +0200, Lukasz Marek encoded:
 Signed-off-by: Lukasz Marek lukasz.m.lu...@gmail.com
 ---
 ffserver.c|6 +
 ffserver_config.c | 1138 
 ++---
 ffserver_config.h |7 +
 3 files changed, 566 insertions(+), 585 deletions(-)
 
 diff --git a/ffserver.c b/ffserver.c
 index af6e8e1..22560ce 100644
 --- a/ffserver.c
 +++ b/ffserver.c
 @@ -208,6 +208,12 @@ static FFServerConfig config = {
 .logfilename = {0},
 .http_addr = {0},
 .rtsp_addr = {0},
 +.errors = 0,
 +.warnings = 0,
 +.audio_id = AV_CODEC_ID_NONE,
 +.video_id = AV_CODEC_ID_NONE,
 +.audio_enc = {0},
 +.video_enc = {0},
 };
 
 Probably good, also I like the idea to split the big parsing function.

I was going to ask if it wouldn't me better to use memset or just a single {0} 
to ensure that the whole struct is initialized at least and then assign the 
values for which you want something else.
Though since it is static variable all that is kind of pointless since it 
defaults to 0 initialization.
I which case I'd prefer if all the explicit initialization 0 was removed, it 
feels like a lot of clutter to do effectively nothing.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/4] ffserver_conf: factorize parse function per config tag

2014-10-20 Thread Lukasz Marek
Signed-off-by: Lukasz Marek lukasz.m.lu...@gmail.com
---
 ffserver.c|6 +
 ffserver_config.c | 1138 ++---
 ffserver_config.h |7 +
 3 files changed, 566 insertions(+), 585 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index af6e8e1..22560ce 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -208,6 +208,12 @@ static FFServerConfig config = {
 .logfilename = {0},
 .http_addr = {0},
 .rtsp_addr = {0},
+.errors = 0,
+.warnings = 0,
+.audio_id = AV_CODEC_ID_NONE,
+.video_id = AV_CODEC_ID_NONE,
+.audio_enc = {0},
+.video_enc = {0},
 };
 
 static void new_connection(int server_fd, int is_rtsp);
diff --git a/ffserver_config.c b/ffserver_config.c
index 351c4e9..18b1e72 100644
--- a/ffserver_config.c
+++ b/ffserver_config.c
@@ -334,18 +334,531 @@ static void report_config_error(const char *filename, 
int line_num, int log_leve
 (*errors)++;
 }
 
+#define ERROR(...)   report_config_error(config-filename, line_num, 
AV_LOG_ERROR,   config-errors,   __VA_ARGS__)
+#define WARNING(...) report_config_error(config-filename, line_num, 
AV_LOG_WARNING, config-warnings, __VA_ARGS__)
+
+static int ffserver_parse_config_global(FFServerConfig *config, const char 
*cmd,
+const char **p, int line_num)
+{
+int val;
+char arg[1024];
+if (!av_strcasecmp(cmd, Port) || !av_strcasecmp(cmd, HTTPPort)) {
+if (!av_strcasecmp(cmd, Port))
+WARNING(Port option is deprecated, use HTTPPort instead\n);
+ffserver_get_arg(arg, sizeof(arg), p);
+val = atoi(arg);
+if (val  1 || val  65536) {
+ERROR(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);
+} else if (!av_strcasecmp(cmd, HTTPBindAddress) || !av_strcasecmp(cmd, 
BindAddress)) {
+if (!av_strcasecmp(cmd, BindAddress))
+WARNING(BindAddress option is deprecated, use HTTPBindAddress 
instead\n);
+ffserver_get_arg(arg, sizeof(arg), p);
+if (resolve_host(config-http_addr.sin_addr, arg) != 0) {
+ERROR(%s:%d: Invalid host/IP address: %s\n, arg);
+}
+} else if (!av_strcasecmp(cmd, NoDaemon)) {
+WARNING(NoDaemon option has no effect, you should remove it\n);
+} else if (!av_strcasecmp(cmd, RTSPPort)) {
+ffserver_get_arg(arg, sizeof(arg), p);
+val = atoi(arg);
+if (val  1 || val  65536) {
+ERROR(%s:%d: Invalid port: %s\n, arg);
+}
+config-rtsp_addr.sin_port = htons(atoi(arg));
+} else if (!av_strcasecmp(cmd, RTSPBindAddress)) {
+ffserver_get_arg(arg, sizeof(arg), p);
+if (resolve_host(config-rtsp_addr.sin_addr, arg) != 0) {
+ERROR(Invalid host/IP address: %s\n, arg);
+}
+} else if (!av_strcasecmp(cmd, MaxHTTPConnections)) {
+ffserver_get_arg(arg, sizeof(arg), p);
+val = atoi(arg);
+if (val  1 || val  65536) {
+ERROR(Invalid MaxHTTPConnections: %s\n, arg);
+}
+config-nb_max_http_connections = val;
+} else if (!av_strcasecmp(cmd, MaxClients)) {
+ffserver_get_arg(arg, sizeof(arg), p);
+val = atoi(arg);
+if (val  1 || val  config-nb_max_http_connections) {
+ERROR(Invalid MaxClients: %s\n, arg);
+} else {
+config-nb_max_connections = val;
+}
+} else if (!av_strcasecmp(cmd, MaxBandwidth)) {
+int64_t llval;
+ffserver_get_arg(arg, sizeof(arg), p);
+llval = strtoll(arg, NULL, 10);
+if (llval  10 || llval  1000) {
+ERROR(Invalid MaxBandwidth: %s\n, arg);
+} else
+config-max_bandwidth = llval;
+} else if (!av_strcasecmp(cmd, CustomLog)) {
+if (!config-debug)
+ffserver_get_arg(config-logfilename, sizeof(config-logfilename), 
p);
+} else if (!av_strcasecmp(cmd, LoadModule)) {
+ERROR(Loadable modules no longer supported\n);
+} else
+ERROR(Incorrect keyword: '%s'\n, cmd);
+return 0;
+}
+
+static int ffserver_parse_config_feed(FFServerConfig *config, const char *cmd, 
const char **p,
+  int line_num, FFServerStream **pfeed)
+{
+FFServerStream *feed;
+char arg[1024];
+av_assert0(pfeed);
+feed = *pfeed;
+if (!av_strcasecmp(cmd, Feed)) {
+char *q;
+FFServerStream *s;
+feed = av_mallocz(sizeof(FFServerStream));
+if (!feed)
+return AVERROR(ENOMEM);
+ffserver_get_arg(feed-filename, sizeof(feed-filename), p);
+q = strrchr(feed-filename, '');
+if (*q)
+*q = '\0';
+
+for (s = config-first_feed; s; s = s-next) {
+if (!strcmp(feed-filename, s-filename)) {
+ERROR(Feed '%s' already registered\n, s-filename);
+