]> git.sesse.net Git - nageru/blob - mux.h
Pull the Mux class out of HTTPD. (First step towards decoupling file and HTTP muxing.)
[nageru] / mux.h
1 #ifndef _MUX_H
2 #define _MUX_H 1
3
4 // Wrapper around an AVFormat mux.
5
6 extern "C" {
7 #include <libavcodec/avcodec.h>
8 #include <libavformat/avformat.h>
9 #include <libavformat/avio.h>
10 }
11
12 class Mux {
13 public:
14         enum Codec {
15                 CODEC_H264,
16                 CODEC_NV12,  // Uncompressed 4:2:0.
17         };
18
19         Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, int time_base);  // Takes ownership of avctx.
20         ~Mux();
21         void add_packet(const AVPacket &pkt, int64_t pts, int64_t dts);
22
23 private:
24         bool seen_keyframe = false;
25         AVFormatContext *avctx;
26         AVStream *avstream_video, *avstream_audio;
27 };
28
29 #endif  // !defined(_MUX_H)