]> git.sesse.net Git - nageru/blobdiff - mux.h
Write 1.4.0 changelog.
[nageru] / mux.h
diff --git a/mux.h b/mux.h
index 83030215e86df4d3b5ae0a8adc581fdfd9d35e97..ddf97fe92a591d86ec6dbebd9614cf32fa9a0846 100644 (file)
--- a/mux.h
+++ b/mux.h
@@ -6,11 +6,12 @@
 extern "C" {
 #include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
-#include <libavformat/avio.h>
 }
 
+#include <sys/types.h>
+#include <functional>
 #include <mutex>
-#include <queue>
+#include <string>
 #include <vector>
 
 class Mux {
@@ -20,8 +21,10 @@ public:
                CODEC_NV12,  // Uncompressed 4:2:0.
        };
 
-       // Takes ownership of avctx. <keyframe_signal_receiver> can be nullptr.
-       Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const std::string &video_extradata, const AVCodecContext *audio_ctx, int time_base);
+       // Takes ownership of avctx. <write_callback> will be called every time
+       // a write has been made to the video stream (id 0), with the pts of
+       // the just-written frame. (write_callback can be nullptr.)
+       Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const std::string &video_extradata, const AVCodecParameters *audio_codecpar, int time_base, std::function<void(int64_t)> write_callback);
        ~Mux();
        void add_packet(const AVPacket &pkt, int64_t pts, int64_t dts);
 
@@ -45,6 +48,8 @@ private:
        std::vector<AVPacket *> plugged_packets;  // Protected by <mu>.
 
        AVStream *avstream_video, *avstream_audio;
+
+       std::function<void(int64_t)> write_callback;
 };
 
 #endif  // !defined(_MUX_H)