]> git.sesse.net Git - cubemap/blobdiff - server.h
Support configurable BACKLOG_SIZE (per-stream). No support for changing across restar...
[cubemap] / server.h
index e9b74315f1b3d5fdd6227d67c2c4160ccf89be58..7910f4c9c37ffdf190245f60edf5fbce1512dc29 100644 (file)
--- 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 <data> contains. Can very well be larger than BACKLOG_SIZE,
-       // since the buffer wraps.
-       size_t data_size;
+       // How many bytes <data_fd> can hold (the buffer size).
+       size_t backlog_size;
+
+       // How many bytes this stream have received. Can very well be larger
+       // than <backlog_size>, 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: