]> git.sesse.net Git - nageru/blobdiff - mux.h
Pull the Mux class out of HTTPD. (First step towards decoupling file and HTTP muxing.)
[nageru] / mux.h
diff --git a/mux.h b/mux.h
new file mode 100644 (file)
index 0000000..2aefffc
--- /dev/null
+++ b/mux.h
@@ -0,0 +1,29 @@
+#ifndef _MUX_H
+#define _MUX_H 1
+
+// Wrapper around an AVFormat mux.
+
+extern "C" {
+#include <libavcodec/avcodec.h>
+#include <libavformat/avformat.h>
+#include <libavformat/avio.h>
+}
+
+class Mux {
+public:
+       enum Codec {
+               CODEC_H264,
+               CODEC_NV12,  // Uncompressed 4:2:0.
+       };
+
+       Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, int time_base);  // Takes ownership of avctx.
+       ~Mux();
+       void add_packet(const AVPacket &pkt, int64_t pts, int64_t dts);
+
+private:
+       bool seen_keyframe = false;
+       AVFormatContext *avctx;
+       AVStream *avstream_video, *avstream_audio;
+};
+
+#endif  // !defined(_MUX_H)