X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=main.cpp;h=5ec0cb487269649c59c32dde293b3c42133ab2a7;hp=c89ec72ff44457352c66ebb5be638a5fbc28bc66;hb=9abb89bcf7940e2ada9d708f86a218a56334f68d;hpb=ef7f588a9b7a63ba2153cd06ce5322db4453fa16 diff --git a/main.cpp b/main.cpp index c89ec72..5ec0cb4 100644 --- a/main.cpp +++ b/main.cpp @@ -136,7 +136,7 @@ void create_config_inputs(const Config &config, multimap &deserialized_stream_ids, + const set &deserialized_urls, multimap *inputs) { for (unsigned i = 0; i < config.mark_pools.size(); ++i) { @@ -144,43 +144,45 @@ void create_streams(const Config &config, mark_pools.push_back(new MarkPool(mp_config.from, mp_config.to)); } - set expecting_stream_ids = deserialized_stream_ids; + set expecting_urls = deserialized_urls; for (unsigned i = 0; i < config.streams.size(); ++i) { const StreamConfig &stream_config = config.streams[i]; - if (deserialized_stream_ids.count(stream_config.stream_id) == 0) { - servers->add_stream(stream_config.stream_id, - stream_config.backlog_size, - Stream::Encoding(stream_config.encoding)); + int stream_index; + if (deserialized_urls.count(stream_config.url) == 0) { + stream_index = servers->add_stream(stream_config.url, + stream_config.backlog_size, + Stream::Encoding(stream_config.encoding)); } else { - servers->set_backlog_size(stream_config.stream_id, stream_config.backlog_size); - servers->set_encoding(stream_config.stream_id, + stream_index = servers->lookup_stream_by_url(stream_config.url); + assert(stream_index != -1); + servers->set_backlog_size(stream_index, stream_config.backlog_size); + servers->set_encoding(stream_index, Stream::Encoding(stream_config.encoding)); } - expecting_stream_ids.erase(stream_config.stream_id); + expecting_urls.erase(stream_config.url); if (stream_config.mark_pool != -1) { - servers->set_mark_pool(stream_config.stream_id, - mark_pools[stream_config.mark_pool]); + servers->set_mark_pool(stream_index, mark_pools[stream_config.mark_pool]); } string src = stream_config.src; if (!src.empty()) { multimap::iterator input_it = inputs->find(src); assert(input_it != inputs->end()); - input_it->second.input->add_destination(stream_config.stream_id); + input_it->second.input->add_destination(stream_index); ++input_it->second.refcount; } } // 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(); + for (set::const_iterator stream_it = expecting_urls.begin(); + stream_it != expecting_urls.end(); ++stream_it) { - string stream_id = *stream_it; + string url = *stream_it; log(WARNING, "stream '%s' disappeared from the configuration file. " "It will not be deleted, but clients will not get any new inputs.", - stream_id.c_str()); + url.c_str()); } } @@ -328,7 +330,7 @@ start: CubemapStateProto loaded_state; struct timeval serialize_start; - set deserialized_stream_ids; + set deserialized_urls; map deserialized_acceptors; multimap inputs; // multimap due to older versions without deduplication. if (state_fd != -1) { @@ -361,7 +363,7 @@ start: } servers->add_stream_from_serialized(stream, data_fds); - deserialized_stream_ids.insert(stream.stream_id()); + deserialized_urls.insert(stream.url()); } // Deserialize the inputs. Note that we don't actually add them to any stream yet. @@ -386,7 +388,7 @@ start: create_config_inputs(config, &inputs); // Find all streams in the configuration file, create them, and connect to the inputs. - create_streams(config, deserialized_stream_ids, &inputs); + create_streams(config, deserialized_urls, &inputs); vector acceptors = create_acceptors(config, &deserialized_acceptors); // Put back the existing clients. It doesn't matter which server we