From c56b0e2487bff246cb90a67c714a5a8b3ad11695 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 6 Apr 2013 13:59:38 +0200 Subject: [PATCH] Start adding scaffolds for most of the basic classes. --- cubemap.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/cubemap.cpp b/cubemap.cpp index cbdab18..2bccac3 100644 --- a/cubemap.cpp +++ b/cubemap.cpp @@ -4,11 +4,63 @@ #include #include #include +#include #include +#include +#include #include "metacube.h" +#define NUM_SERVERS 4 +#define STREAM_ID "stream" +#define STREAM_URL "http://gruessi.zrh.sesse.net:4013/" +#define BACKLOG_SIZE 1048576 + using namespace std; +struct Client { + enum State { READING_REQUEST, SENDING_HEADER, SENDING_DATA }; + State state; + + // The HTTP request, as sent by the client. If we are in READING_REQUEST, + // this might not be finished. + string client_request; + +#if 0 + // What stream we're connecting to; parsed from client_request. + // Not relevant for READING_REQUEST. + string stream_id; +#endif + + // Number of bytes we've sent of the header. Only relevant for SENDING_HEADER. + size_t header_bytes_sent; + + // Number of bytes we've sent of data. Only relevant for SENDING_DATA. + size_t bytes_sent; +}; + +struct Stream { + // The HTTP response header, plus the video stream header (if any). + string header; + + // The stream data itself, stored in a circular buffer. + char data[BACKLOG_SIZE]; + + // How many bytes contains. Can very well be larger than BACKLOG_SIZE, + // since the buffer wraps. + size_t data_size; +}; + +class Server { +public: + void add_socket(int server_sock); + void add_stream(const string &stream_id); + void set_header(const string &stream_id, const string &header); + void add_data(const string &stream_id, const char *data, size_t bytes); + +private: + map streams; +}; + class Input { public: Input(); -- 2.39.2