]> git.sesse.net Git - cubemap/blobdiff - server.cpp
Keep the HLS backlog even if the stream header changes.
[cubemap] / server.cpp
index 5c1f31bef451300f5cdf335261a7c9fd2aaedbae..4773b479b92047b0be10f87095e14605799e4db1 100644 (file)
@@ -458,26 +458,7 @@ void Server::set_header(int stream_index, const string &http_header, const strin
 {
        lock_guard<mutex> lock(mu);
        assert(stream_index >= 0 && stream_index < ssize_t(streams.size()));
 {
        lock_guard<mutex> lock(mu);
        assert(stream_index >= 0 && stream_index < ssize_t(streams.size()));
-       Stream *stream = streams[stream_index].get();
-       stream->http_header = http_header;
-
-       if (stream_header != stream->stream_header) {
-               // We cannot start at any of the older starting points anymore,
-               // since they'd get the wrong header for the stream (not to mention
-               // that a changed header probably means the stream restarted,
-               // which means any client starting on the old one would probably
-               // stop playing properly at the change point). Next block
-               // should be a suitable starting point (if not, something is
-               // pretty strange), so it will fill up again soon enough.
-               stream->suitable_starting_points.clear();
-
-               if (!stream->fragments.empty()) {
-                       stream->fragments.clear();
-                       ++stream->discontinuity_counter;
-                       stream->clear_hls_playlist_cache();
-               }
-       }
-       stream->stream_header = stream_header;
+       streams[stream_index]->set_header(http_header, stream_header);
 }
        
 void Server::set_pacing_rate(int stream_index, uint32_t pacing_rate)
 }
        
 void Server::set_pacing_rate(int stream_index, uint32_t pacing_rate)
@@ -1116,9 +1097,6 @@ int Server::parse_request(Client *client)
        }
 
        Stream *stream = client->stream;
        }
 
        Stream *stream = client->stream;
-       if (stream->http_header.empty()) {
-               return 503;  // Service unavailable.
-       }
 
        if (client->serving_hls_playlist) {
                if (stream->encoding == Stream::STREAM_ENCODING_METACUBE) {
 
        if (client->serving_hls_playlist) {
                if (stream->encoding == Stream::STREAM_ENCODING_METACUBE) {
@@ -1130,6 +1108,10 @@ int Server::parse_request(Client *client)
        }
 
        if (client->stream_pos_end == Client::STREAM_POS_NO_END) {
        }
 
        if (client->stream_pos_end == Client::STREAM_POS_NO_END) {
+               if (stream->http_header.empty()) {
+                       return 503;  // Service unavailable.
+               }
+
                // This stream won't end, so we don't have a content-length,
                // and can just as well tell the client it's Connection: close
                // (otherwise, we'd have to implement chunking TE for no good reason).
                // This stream won't end, so we don't have a content-length,
                // and can just as well tell the client it's Connection: close
                // (otherwise, we'd have to implement chunking TE for no good reason).