X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=httpd.h;fp=httpd.h;h=e739f70dd173821a6ab34aaf5d8171a283a0582b;hb=dbadc60a477927db7a5e941b17fe1c9b808fd175;hp=e8efc030b4706d92b64e89e7ea748c056d8f7c85;hpb=72d1b1cd96eacf39732a8fc9791c7fcf4d7bf1c6;p=nageru diff --git a/httpd.h b/httpd.h index e8efc03..e739f70 100644 --- a/httpd.h +++ b/httpd.h @@ -16,8 +16,8 @@ #include #include #include +#include #include -#include struct MHD_Connection; @@ -50,6 +50,10 @@ private: static void free_stream(void *cls); + static void request_completed_thunk(void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe); + + void request_completed(struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe); + class Mux { public: Mux(AVFormatContext *avctx, int width, int height); // Takes ownership of avctx. @@ -74,15 +78,16 @@ private: static int write_packet_thunk(void *opaque, uint8_t *buf, int buf_size); int write_packet(uint8_t *buf, int buf_size); - std::unique_ptr mux; - std::mutex buffer_mutex; std::condition_variable has_buffered_data; std::deque buffered_data; // Protected by . size_t used_of_buffered_data = 0; // How many bytes of the first element of that is already used. Protected by . + + std::unique_ptr mux; // Must come last to be destroyed before buffered_data, since the destructor can write bytes. }; - std::vector streams; // Not owned. + std::mutex streams_mutex; + std::set streams; // Not owned. int width, height; std::unique_ptr file_mux; // To local disk.