X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=stream.h;h=931da2aa236e941ad72833a3af0d12cdbfac2ec2;hp=77e9d8a8f0510fe06ebcb5a11b0440d4456b79b0;hb=980ac162414c9fce62af4fdb9cfc282865b31572;hpb=20e85bd6901355cc40a6cfb4c0deb7232d9aa63f diff --git a/stream.h b/stream.h index 77e9d8a..931da2a 100644 --- a/stream.h +++ b/stream.h @@ -31,7 +31,7 @@ struct Stream { Stream(const std::string &url, size_t backlog_size, - size_t prebuffering_bytes, + uint64_t prebuffering_bytes, Encoding encoding, Encoding src_encoding, unsigned hls_frag_duration, @@ -46,6 +46,9 @@ 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(). + void set_header(const std::string &new_http_header, const std::string &new_stream_header); + // 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. @@ -88,15 +91,15 @@ struct Stream { // This is basically to force a buffer on the client, which can help // if the client expects us to be able to fill up the buffer much // faster than realtime (ie., it expects a static file). - size_t prebuffering_bytes; + uint64_t prebuffering_bytes; // How many bytes this stream have received. Can very well be larger // than , since the buffer wraps. - size_t bytes_received = 0; + uint64_t bytes_received = 0; // A list of points in the stream that is suitable to start new clients at // (after having sent the header). Empty if no such point exists yet. - std::deque suitable_starting_points; + std::deque suitable_starting_points; // A list of HLS fragment boundaries currently in the backlog; the first fragment // is between point 0 and 1, the second is between 1 and 2, and so on. @@ -111,11 +114,19 @@ struct Stream { // extended and thus should not be output. So the last fragment output is // from points N-3..N-2. struct FragmentStart { - size_t byte_position; - double pts; + uint64_t byte_position; + 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;