]> git.sesse.net Git - cubemap/blob - config.h
Refer to streams internally mostly by an index, not the stream_id.
[cubemap] / config.h
1 #ifndef _CONFIG_H
2 #define _CONFIG_H
3
4 // Various routines that deal with parsing the configuration file.
5
6 #include <stddef.h>
7 #include <string>
8 #include <vector>
9
10 struct MarkPoolConfig {
11         int from, to;
12 };
13
14 struct StreamConfig {
15         std::string url;  // As seen by the client.
16         std::string src;  // Can be empty.
17         size_t backlog_size;
18         int mark_pool;  // -1 for none.
19         enum { STREAM_ENCODING_RAW = 0, STREAM_ENCODING_METACUBE } encoding;
20 };
21
22 struct AcceptorConfig {
23         int port;
24 };
25
26 struct LogConfig {
27         enum { LOG_TYPE_FILE, LOG_TYPE_CONSOLE, LOG_TYPE_SYSLOG } type;
28         std::string filename;
29 };
30
31 struct Config {
32         bool daemonize;
33         int num_servers;
34         std::vector<MarkPoolConfig> mark_pools;
35         std::vector<StreamConfig> streams;
36         std::vector<AcceptorConfig> acceptors;
37         std::vector<LogConfig> log_destinations;
38
39         std::string stats_file;  // Empty means no stats file.
40         int stats_interval;
41
42         std::string access_log_file;  // Empty means no accses_log file.
43 };
44
45 // Parse and validate configuration. Returns false on error.
46 // <config> is taken to be empty (uninitialized) on entry.
47 bool parse_config(const std::string &filename, Config *config);
48
49 #endif  // !defined(_CONFIG_H)