X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=video_encoder.h;fp=video_encoder.h;h=489d9d318c9c9650846f939c8ab82f93b295ea00;hb=90d0745245f83999e88bc50cad57be3e4a1c7439;hp=1a5c97d0310525a49873a6a9900e7ab4e5eba720;hpb=c4c5e2df2b1ef88fa20b71ae981ae6462d84b63c;p=nageru diff --git a/video_encoder.h b/video_encoder.h index 1a5c97d..489d9d3 100644 --- a/video_encoder.h +++ b/video_encoder.h @@ -10,6 +10,7 @@ #include #include +#include "mux.h" #include "ref_counted_frame.h" #include "ref_counted_gl_sync.h" @@ -17,7 +18,7 @@ class HTTPD; class QSurface; class QuickSyncEncoder; -class VideoEncoder { +class VideoEncoder : public KeyFrameSignalReceiver { public: VideoEncoder(QSurface *surface, const std::string &va_display, int width, int height, HTTPD *httpd); ~VideoEncoder(); @@ -29,12 +30,30 @@ public: // Does a cut of the disk stream immediately ("frame" is used for the filename only). void do_cut(int frame); + virtual void signal_keyframe() override { + stream_mux_writing_keyframes = true; + } + private: + void open_output_stream(); + void close_output_stream(); + 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 quicksync_encoder; QSurface *surface; std::string va_display; int width, height; HTTPD *httpd; + + std::unique_ptr stream_mux; // To HTTP. + + // While Mux object is constructing, is true, + // and the header is being collected into stream_mux_header. + bool stream_mux_writing_header; + std::string stream_mux_header; + + bool stream_mux_writing_keyframes = false; }; #endif