]> git.sesse.net Git - cubemap/blobdiff - config.cpp
When checking to see if we want to warn about pacing rate, use the correct default...
[cubemap] / config.cpp
index d47bfec0fbb72fc4fe668939805ad54d7249d861..f5182aac1512e9b8307ac57d16ada0b639260257 100644 (file)
@@ -1,8 +1,11 @@
+#include <arpa/inet.h>
 #include <assert.h>
 #include <ctype.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <map>
 #include <string>
 #include <utility>
@@ -231,6 +234,14 @@ bool parse_stream(const ConfigLine &line, Config *config)
                stream.mark_pool = allocate_mark_pool(from, to, config);
        }
 
+       // Parse the pacing rate, converting from kilobits to bytes as needed.
+       map<string, string>::const_iterator pacing_rate_it = line.parameters.find("pacing_rate_kbit");
+       if (pacing_rate_it == line.parameters.end()) {
+               stream.pacing_rate = ~0U;
+       } else {
+               stream.pacing_rate = atoi(pacing_rate_it->second.c_str()) * 1024 / 8;
+       }
+
        config->streams.push_back(stream);
        return true;
 }
@@ -313,9 +324,18 @@ bool parse_udpstream(const ConfigLine &line, Config *config)
                udpstream.mark_pool = allocate_mark_pool(from, to, config);
        }
 
+       // Parse the pacing rate, converting from kilobits to bytes as needed.
+       map<string, string>::const_iterator pacing_rate_it = line.parameters.find("pacing_rate_kbit");
+       if (pacing_rate_it == line.parameters.end()) {
+               udpstream.pacing_rate = ~0U;
+       } else {
+               udpstream.pacing_rate = atoi(pacing_rate_it->second.c_str()) * 1024 / 8;
+       }
+
        config->udpstreams.push_back(udpstream);
        return true;
 }
+
 bool parse_error_log(const ConfigLine &line, Config *config)
 {
        if (line.arguments.size() != 0) {
@@ -378,7 +398,14 @@ bool parse_config(const string &filename, Config *config)
        bool has_stats_file = fetch_config_string(lines, "stats_file", &config->stats_file);
        bool has_stats_interval = fetch_config_int(lines, "stats_interval", &config->stats_interval);
        if (has_stats_interval && !has_stats_file) {
-               log(WARNING, "'stats_interval' given, but no 'stats_file'. No statistics will be written.");
+               log(WARNING, "'stats_interval' given, but no 'stats_file'. No client statistics will be written.");
+       }
+
+       config->input_stats_interval = 60;
+       bool has_input_stats_file = fetch_config_string(lines, "input_stats_file", &config->input_stats_file);
+       bool has_input_stats_interval = fetch_config_int(lines, "input_stats_interval", &config->input_stats_interval);
+       if (has_input_stats_interval && !has_input_stats_file) {
+               log(WARNING, "'input_stats_interval' given, but no 'input_stats_file'. No input statistics will be written.");
        }
        
        fetch_config_string(lines, "access_log", &config->access_log_file);
@@ -388,6 +415,8 @@ bool parse_config(const string &filename, Config *config)
                if (line.keyword == "num_servers" ||
                    line.keyword == "stats_file" ||
                    line.keyword == "stats_interval" ||
+                   line.keyword == "input_stats_file" ||
+                   line.keyword == "input_stats_interval" ||
                    line.keyword == "access_log") {
                        // Already taken care of, above.
                } else if (line.keyword == "port") {