- // Open a new server socket if we do not already have one, or if we changed ports.
- if (server_sock != -1 && port != old_port) {
- fprintf(stderr, "NOTE: Port changed from %d to %d; opening new socket.\n", old_port, port);
- close(server_sock);
- server_sock = -1;
- }
- if (server_sock == -1) {
- server_sock = create_server_socket(port);
- }
-
- // See if the user wants stats.
- string stats_file = fetch_config_string(config, "stats_file", PARAMETER_OPTIONAL);
- int stats_interval = fetch_config_int(config, "stats_interval", 1, INT_MAX, PARAMETER_OPTIONAL, -1);
- if (stats_interval != -1 && stats_file.empty()) {
- fprintf(stderr, "WARNING: 'stats_interval' given, but no 'stats_file'. No statistics will be written.\n");
- }
- StatsThread *stats_thread = NULL;
- if (!stats_file.empty()) {
- stats_thread = new StatsThread(stats_file, stats_interval);
- }
-
- servers->run();
-
- AcceptorThread acceptor_thread(server_sock);
- acceptor_thread.run();
-
- // Find all streams in the configuration file, and create inputs for them.
- vector<Input *> inputs;
- for (unsigned i = 0; i < config.size(); ++i) {
- if (config[i].keyword != "stream") {
- continue;
- }
- assert(config[i].arguments.size() == 1);
- string stream_id = config[i].arguments[0];
-
- if (config[i].parameters.count("src") == 0) {
- fprintf(stderr, "WARNING: stream '%s' has no src= attribute, clients will not get any data.\n",
- stream_id.c_str());
- continue;
- }