]> git.sesse.net Git - nageru/blob - mux.h
Make it possible for file and HTTP streams to use different audio codecs.
[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 PacketDestination {
13 public:
14         virtual ~PacketDestination() {}
15         virtual void add_packet(const AVPacket &pkt, int64_t pts, int64_t dts) = 0;
16 };
17
18 class Mux : public PacketDestination {
19 public:
20         enum Codec {
21                 CODEC_H264,
22                 CODEC_NV12,  // Uncompressed 4:2:0.
23         };
24
25         // Takes ownership of avctx.
26         Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, int time_base, int bit_rate);
27         ~Mux();
28         void add_packet(const AVPacket &pkt, int64_t pts, int64_t dts) override;
29
30 private:
31         bool seen_keyframe = false;
32         AVFormatContext *avctx;
33         AVStream *avstream_video, *avstream_audio;
34 };
35
36 #endif  // !defined(_MUX_H)