X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=main.cpp;h=86ba28a81cf41aef2927659375a169f16f03f434;hp=3f36f32da35ab493c5ba987dccf18b751dc6b92d;hb=e42cde17932cfbb2bf54244d46c6f9cd7215105b;hpb=4ec6a7f04455b023d3ca91d4e84a19993ec4d34e diff --git a/main.cpp b/main.cpp index 3f36f32..86ba28a 100644 --- a/main.cpp +++ b/main.cpp @@ -184,6 +184,8 @@ void create_streams(const Config &config, servers->set_mark_pool(stream_index, mark_pools[stream_config.mark_pool]); } + servers->set_pacing_rate(stream_index, stream_config.pacing_rate); + string src = stream_config.src; if (!src.empty()) { multimap::iterator input_it = inputs->find(src); @@ -212,7 +214,7 @@ void create_streams(const Config &config, 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); + int stream_index = servers->add_udpstream(udpstream_config.dst, mark_pool, udpstream_config.pacing_rate); string src = udpstream_config.src; if (!src.empty()) { @@ -401,6 +403,7 @@ start: serialize_start.tv_usec = loaded_state.serialize_start_usec(); // Deserialize the streams. + map stream_headers_for_url; // See below. for (int i = 0; i < loaded_state.streams_size(); ++i) { const StreamProto &stream = loaded_state.streams(i); @@ -423,15 +426,28 @@ start: servers->add_stream_from_serialized(stream, data_fds); deserialized_urls.insert(stream.url()); + + stream_headers_for_url.insert(make_pair(stream.url(), stream.stream_header())); } } // Deserialize the inputs. Note that we don't actually add them to any stream yet. for (int i = 0; i < loaded_state.inputs_size(); ++i) { + InputProto serialized_input = loaded_state.inputs(i); + + // Older versions did not store the stream header in the input, + // only in each stream. We need to have the stream header in the + // input as well, in case we create a new stream reusing the same input. + // Thus, we put it into place here if it's missing. + if (!serialized_input.has_stream_header() && + stream_headers_for_url.count(serialized_input.url()) != 0) { + serialized_input.set_stream_header(stream_headers_for_url[serialized_input.url()]); + } + InputWithRefcount iwr; - iwr.input = create_input(loaded_state.inputs(i)); + iwr.input = create_input(serialized_input); iwr.refcount = 0; - inputs.insert(make_pair(loaded_state.inputs(i).url(), iwr)); + inputs.insert(make_pair(serialized_input.url(), iwr)); } // Deserialize the acceptors.