X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=server.h;h=7910f4c9c37ffdf190245f60edf5fbce1512dc29;hp=e9b74315f1b3d5fdd6227d67c2c4160ccf89be58;hb=f51b3892514540ff3f08ab052296091f3a6f7a93;hpb=51e357cb8decceaeab47332492962bc0175b0b13 diff --git a/server.h b/server.h index e9b7431..7910f4c 100644 --- a/server.h +++ b/server.h @@ -11,7 +11,6 @@ #include "thread.h" -#define BACKLOG_SIZE 1048576 #define EPOLL_MAX_EVENTS 8192 #define EPOLL_TIMEOUT_MS 20 #define MAX_CLIENT_REQUEST 16384 @@ -76,7 +75,7 @@ struct Client { }; struct Stream { - Stream(const std::string &stream_id); + Stream(const std::string &stream_id, size_t backlog_size); ~Stream(); // Serialization/deserialization. @@ -88,7 +87,7 @@ struct Stream { // The HTTP response header, plus the video stream header (if any). std::string header; - // The stream data itself, stored in a circular buffer.q + // The stream data itself, stored in a circular buffer. // // We store our data in a file, so that we can send the data to the // kernel only once (with write()). We then use sendfile() for each @@ -98,9 +97,12 @@ struct Stream { // the same data from userspace many times. int data_fd; - // How many bytes contains. Can very well be larger than BACKLOG_SIZE, - // since the buffer wraps. - size_t data_size; + // How many bytes can hold (the buffer size). + size_t backlog_size; + + // How many bytes this stream have received. Can very well be larger + // than , since the buffer wraps. + size_t bytes_received; // Clients that are in SENDING_DATA, but that we don't listen on, // because we currently don't have any data for them. @@ -152,7 +154,7 @@ public: // at the same time). CubemapStateProto serialize(); void add_client_from_serialized(const ClientProto &client); - void add_stream(const std::string &stream_id); + void add_stream(const std::string &stream_id, size_t bytes_received); void add_stream_from_serialized(const StreamProto &stream); private: