X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=main.cpp;h=de3900b9ac6acc676143e9ae019099b77c9175e7;hp=278c51d67d946cb540a66fa802b20d8678f96f68;hb=92aebf172247328aa8928aa421a69854975236f4;hpb=7c55e615d7b03fc92b93701ddc3a5d2e6b7087d0
diff --git a/main.cpp b/main.cpp
index 278c51d..de3900b 100644
--- a/main.cpp
+++ b/main.cpp
@@ -197,6 +197,51 @@ vector create_inputs(const vector &config,
return inputs;
}
+void create_streams(const vector &config,
+ const set &deserialized_stream_ids,
+ map *deserialized_inputs)
+{
+ set expecting_stream_ids = deserialized_stream_ids;
+ map, MarkPool *> mark_pools;
+ for (unsigned i = 0; i < config.size(); ++i) {
+ if (config[i].keyword != "stream") {
+ continue;
+ }
+ if (config[i].arguments.size() != 1) {
+ fprintf(stderr, "ERROR: 'stream' takes exactly one argument\n");
+ exit(1);
+ }
+ string stream_id = config[i].arguments[0];
+ if (deserialized_stream_ids.count(stream_id) == 0) {
+ servers->add_stream(stream_id);
+ }
+ expecting_stream_ids.erase(stream_id);
+
+ // Set up marks, if so desired.
+ map::const_iterator mark_parm_it =
+ config[i].parameters.find("mark");
+ if (mark_parm_it != config[i].parameters.end()) {
+ MarkPool *mark_pool = parse_mark_pool(&mark_pools, mark_parm_it->second);
+ servers->set_mark_pool(stream_id, mark_pool);
+ }
+ }
+
+ // Warn about any servers we've lost.
+ // TODO: Make an option (delete=yes?) to actually shut down streams.
+ for (set::const_iterator stream_it = expecting_stream_ids.begin();
+ stream_it != expecting_stream_ids.end();
+ ++stream_it) {
+ string stream_id = *stream_it;
+ fprintf(stderr, "WARNING: stream '%s' disappeared from the configuration file.\n",
+ stream_id.c_str());
+ fprintf(stderr, " It will not be deleted, but clients will not get any new inputs.\n");
+ if (deserialized_inputs->count(stream_id) != 0) {
+ delete (*deserialized_inputs)[stream_id];
+ deserialized_inputs->erase(stream_id);
+ }
+ }
+}
+
int main(int argc, char **argv)
{
fprintf(stderr, "\nCubemap starting.\n");
@@ -247,43 +292,7 @@ int main(int argc, char **argv)
}
// Find all streams in the configuration file, and create them.
- set expecting_stream_ids = deserialized_stream_ids;
- map, MarkPool *> mark_pools;
- for (unsigned i = 0; i < config.size(); ++i) {
- if (config[i].keyword != "stream") {
- continue;
- }
- if (config[i].arguments.size() != 1) {
- fprintf(stderr, "ERROR: 'stream' takes exactly one argument\n");
- exit(1);
- }
- string stream_id = config[i].arguments[0];
- if (deserialized_stream_ids.count(stream_id) == 0) {
- servers->add_stream(stream_id);
- }
- expecting_stream_ids.erase(stream_id);
-
- // Set up marks, if so desired.
- if (config[i].parameters.count("mark")) {
- MarkPool *mark_pool = parse_mark_pool(&mark_pools, config[i].parameters["mark"]);
- servers->set_mark_pool(stream_id, mark_pool);
- }
- }
-
- // Warn about any servers we've lost.
- // TODO: Make an option (delete=yes?) to actually shut down streams.
- for (set::const_iterator stream_it = expecting_stream_ids.begin();
- stream_it != expecting_stream_ids.end();
- ++stream_it) {
- string stream_id = *stream_it;
- fprintf(stderr, "WARNING: stream '%s' disappeared from the configuration file.\n",
- stream_id.c_str());
- fprintf(stderr, " It will not be deleted, but clients will not get any new inputs.\n");
- if (deserialized_inputs.count(stream_id) != 0) {
- delete deserialized_inputs[stream_id];
- deserialized_inputs.erase(stream_id);
- }
- }
+ create_streams(config, deserialized_stream_ids, &deserialized_inputs);
// Open a new server socket if we do not already have one, or if we changed ports.
if (server_sock != -1 && port != old_port) {