#include "thread.h"
-#define BACKLOG_SIZE 1048576
#define EPOLL_MAX_EVENTS 8192
#define EPOLL_TIMEOUT_MS 20
#define MAX_CLIENT_REQUEST 16384
};
struct Stream {
- Stream(const std::string &stream_id);
+ Stream(const std::string &stream_id, size_t backlog_size);
~Stream();
// Serialization/deserialization.
// 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
// 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.
// 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: