X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=stream.h;h=9e384a9ffd141b63fee39f44c8140b29269d9020;hp=8d249c37b9852e6fc57b782193abe4ba174f56c1;hb=7ec54788f88dde7b083ba6cfd30732b32295b54a;hpb=81253bd40254831a82a3d87c3ed7f2a3524f2f57 diff --git a/stream.h b/stream.h index 8d249c3..9e384a9 100644 --- a/stream.h +++ b/stream.h @@ -46,6 +46,14 @@ struct Stream { // Changes the backlog size, restructuring the data as needed. void set_backlog_size(size_t new_size); + // You should hold the owning Server's , since it calls add_data_raw(). + // Sets unavailable to false. + void set_header(const std::string &new_http_header, const std::string &new_stream_header); + + void set_unavailable() { + unavailable = true; + } + // Mutex protecting and . // Note that if you want to hold both this and the owning server's // you will need to take before this one. @@ -53,6 +61,10 @@ struct Stream { std::string url; + // If true, the backend is not completely connected, and thus, we cannot serve + // clients (except for historic HLS fragments). + bool unavailable = true; + // The HTTP response header, without the trailing double newline. std::string http_header; @@ -112,10 +124,18 @@ struct Stream { // from points N-3..N-2. struct FragmentStart { uint64_t byte_position; - double pts; + double pts; // Unused if begins_header is true. + + // Whether the fragment started at this position is a stream header or not. + // Note that headers are stored _after_ the fragments they are headers for, + // so that they rotate out of the backlog last (and also because they are + // conveniently written then). The most current header is _not_ stored + // in the backlog; it is stored in stream_header. Only when replaced + // is it committed to the backlog and gets an entry here. + bool begins_header; }; std::deque fragments; - size_t first_fragment_index = 0, discontinuity_counter = 0; + uint64_t first_fragment_index = 0, discontinuity_counter = 0; // HLS target duration, in seconds. unsigned hls_frag_duration = 6;