+ 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<uint64_t> 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.
+ // This roughly mirrors suitable_starting_points, but we generally make much
+ // larger fragments (we try to get as close as possible without exceeding
+ // <hls_frag_duration> seconds by too much).
+ //
+ // We keep this list even if we don't have HLS, given that we have pts data
+ // from the input stream.
+ //
+ // NOTE: The last fragment is an in-progress fragment, which can still be
+ // extended and thus should not be output. So the last fragment output is
+ // from points N-3..N-2.
+ struct FragmentStart {
+ uint64_t byte_position;
+ double pts;
+ };
+ std::deque<FragmentStart> fragments;
+ uint64_t first_fragment_index = 0, discontinuity_counter = 0;
+
+ // HLS target duration, in seconds.
+ unsigned hls_frag_duration = 6;
+
+ // Don't advertise new HLS fragments beginning before this point after the
+ // start of the backlog, so that we're reasonably sure that we can actually
+ // serve them even if the client can't completely keep up.
+ size_t hls_backlog_margin = 0;
+
+ // HLS playlists for this stream, in the form of a HTTP response, with
+ // headers and all. These are created on-demand, re-used by clients as
+ // needed, and cleared when they are no longer valid (e.g., when new fragments
+ // are added).
+ std::shared_ptr<const std::string> hls_playlist_http10;
+ std::shared_ptr<const std::string> hls_playlist_http11_close;
+ std::shared_ptr<const std::string> hls_playlist_http11_persistent;
+