X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=main.cpp;h=8d60826fb3d7a8436607446f27b572ba294bc237;hp=5ec0cb487269649c59c32dde293b3c42133ab2a7;hb=adbeb2f8972672ed1059509662d006df47762228;hpb=0ff463f4df8e085ba88f8ede735f16b140a2bf8e diff --git a/main.cpp b/main.cpp index 5ec0cb4..8d60826 100644 --- a/main.cpp +++ b/main.cpp @@ -109,29 +109,36 @@ vector create_acceptors( return acceptors; } +void create_config_input(const string &src, multimap *inputs) +{ + if (src.empty()) { + return; + } + if (inputs->count(src) != 0) { + return; + } + + InputWithRefcount iwr; + iwr.input = create_input(src); + if (iwr.input == NULL) { + log(ERROR, "did not understand URL '%s', clients will not get any data.", + src.c_str()); + return; + } + iwr.refcount = 0; + inputs->insert(make_pair(src, iwr)); +} + // Find all streams in the configuration file, and create inputs for them. void create_config_inputs(const Config &config, multimap *inputs) { for (unsigned i = 0; i < config.streams.size(); ++i) { const StreamConfig &stream_config = config.streams[i]; - if (stream_config.src.empty()) { - continue; - } - - string src = stream_config.src; - if (inputs->count(src) != 0) { - continue; - } - - InputWithRefcount iwr; - iwr.input = create_input(src); - if (iwr.input == NULL) { - log(ERROR, "did not understand URL '%s', clients will not get any data.", - src.c_str()); - continue; - } - iwr.refcount = 0; - inputs->insert(make_pair(src, iwr)); + create_config_input(stream_config.src, inputs); + } + for (unsigned i = 0; i < config.udpstreams.size(); ++i) { + const UDPStreamConfig &udpstream_config = config.udpstreams[i]; + create_config_input(udpstream_config.src, inputs); } } @@ -144,6 +151,7 @@ void create_streams(const Config &config, mark_pools.push_back(new MarkPool(mp_config.from, mp_config.to)); } + // HTTP streams. set expecting_urls = deserialized_urls; for (unsigned i = 0; i < config.streams.size(); ++i) { const StreamConfig &stream_config = config.streams[i]; @@ -174,7 +182,7 @@ void create_streams(const Config &config, } } - // Warn about any servers we've lost. + // Warn about any HTTP servers we've lost. // TODO: Make an option (delete=yes?) to actually shut down streams. for (set::const_iterator stream_it = expecting_urls.begin(); stream_it != expecting_urls.end(); @@ -184,6 +192,24 @@ void create_streams(const Config &config, "It will not be deleted, but clients will not get any new inputs.", url.c_str()); } + + // UDP streams. + for (unsigned i = 0; i < config.udpstreams.size(); ++i) { + const UDPStreamConfig &udpstream_config = config.udpstreams[i]; + MarkPool *mark_pool = NULL; + if (udpstream_config.mark_pool != -1) { + mark_pool = mark_pools[udpstream_config.mark_pool]; + } + int stream_index = servers->add_udpstream(udpstream_config.dst, mark_pool); + + string src = udpstream_config.src; + if (!src.empty()) { + multimap::iterator input_it = inputs->find(src); + assert(input_it != inputs->end()); + input_it->second.input->add_destination(stream_index); + ++input_it->second.refcount; + } + } } void open_logs(const vector &log_destinations)