#include <stdint.h>
+#include <atomic>
#include <condition_variable>
#include <memory>
#include <mutex>
#include "x264.h"
}
-class HTTPD;
+class Mux;
class X264Encoder {
public:
- X264Encoder(HTTPD *httpd); // Does not take ownership.
+ X264Encoder(Mux *httpd); // Does not take ownership.
+
+ // Called after the last frame. Will block; once this returns,
+ // the last data is flushed.
~X264Encoder();
// <data> is taken to be raw NV12 data of WIDTHxHEIGHT resolution.
// Does not block.
void add_frame(int64_t pts, const uint8_t *data);
- // Called after the last frame. Will block; once this returns,
- // the last data is flushed.
- void end_encoding();
-
private:
struct QueuedFrame {
int64_t pts;
// pool.
std::unique_ptr<uint8_t[]> frame_pool;
- HTTPD *httpd = nullptr;
+ Mux *mux = nullptr;
std::thread encoder_thread;
+ std::atomic<bool> should_quit{false};
x264_t *x264;
// Protects everything below it.