]> git.sesse.net Git - cubemap/blob - config.h
Respect prebuffering_bytes= on existing streams when reloading.
[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 <arpa/inet.h>
7 #include <netinet/in.h>
8 #include <stddef.h>
9 #include <string>
10 #include <vector>
11
12 struct StreamConfig {
13         std::string url;  // As seen by the client.
14         std::string src;  // Can be empty.
15         size_t backlog_size;
16         size_t prebuffering_bytes;
17         uint32_t pacing_rate;  // In bytes per second. Default is ~0U (no limit).
18         enum { STREAM_ENCODING_RAW = 0, STREAM_ENCODING_METACUBE } encoding;
19 };
20
21 struct UDPStreamConfig {
22         sockaddr_in6 dst;
23         std::string src;  // Can be empty.
24         uint32_t pacing_rate;  // In bytes per second. Default is ~0U (no limit).
25         int ttl;  // Default is -1 (use operating system default).
26         int multicast_iface_index;  // Default is -1 (use operating system default).
27 };
28
29 struct AcceptorConfig {
30         sockaddr_in6 addr;
31 };
32
33 struct LogConfig {
34         enum { LOG_TYPE_FILE, LOG_TYPE_CONSOLE, LOG_TYPE_SYSLOG } type;
35         std::string filename;
36 };
37
38 struct Config {
39         bool daemonize;
40         int num_servers;
41         std::vector<StreamConfig> streams;
42         std::vector<UDPStreamConfig> udpstreams;
43         std::vector<AcceptorConfig> acceptors;
44         std::vector<LogConfig> log_destinations;
45
46         std::string stats_file;  // Empty means no stats file.
47         int stats_interval;
48
49         std::string input_stats_file;  // Empty means no input stats file.
50         int input_stats_interval;
51
52         std::string access_log_file;  // Empty means no accses_log file.
53 };
54
55 // Parse and validate configuration. Returns false on error.
56 // <config> is taken to be empty (uninitialized) on entry.
57 bool parse_config(const std::string &filename, Config *config);
58
59 #endif  // !defined(_CONFIG_H)