]> git.sesse.net Git - nageru/blobdiff - shared/mux.h
Make it possible for the theme to override the status line.
[nageru] / shared / mux.h
index 62cd37cf80791f061182ebf50498756948f24a78..1b9fe93216aba26c364f628cd2ce325fa187c263 100644 (file)
@@ -53,10 +53,6 @@ public:
                CODEC_NV12,  // Uncompressed 4:2:0.
                CODEC_MJPEG
        };
-       enum WithAudio {
-               WITH_AUDIO,
-               WITHOUT_AUDIO
-       };
        enum WriteStrategy {
                // add_packet() will write the packet immediately, unless plugged.
                WRITE_FOREGROUND,
@@ -68,15 +64,22 @@ public:
                // higher overhead.
                WRITE_BACKGROUND,
        };
+       enum WithSubtitles {
+               WITH_SUBTITLES,
+               WITHOUT_SUBTITLES
+       };
 
        // 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.)
        // Does not take ownership of <metrics>; elements in there, if any,
        // will be added to.
-       Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const std::string &video_extradata, const AVCodecParameters *audio_codecpar, AVColorSpace color_space, WithAudio with_audio, int time_base, std::function<void(int64_t)> write_callback, WriteStrategy write_strategy, const std::vector<MuxMetrics *> &metrics);
+       //
+       // If audio_codecpar is nullptr, there will be no audio stream.
+       Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const std::string &video_extradata, const AVCodecParameters *audio_codecpar, AVColorSpace color_space, int time_base, std::function<void(int64_t)> write_callback, WriteStrategy write_strategy, const std::vector<MuxMetrics *> &metrics, WithSubtitles with_subtitles = WITHOUT_SUBTITLES);
        ~Mux();
        void add_packet(const AVPacket &pkt, int64_t pts, int64_t dts, AVRational timebase = { 1, TIMEBASE }, int stream_index_override = -1);
+       int get_subtitle_stream_idx() const { return subtitle_stream_idx; }
 
        // As long as the mux is plugged, it will not actually write anything to disk,
        // just queue the packets. Once it is unplugged, the packets are reordered by pts
@@ -114,7 +117,8 @@ private:
        std::vector<QueuedPacket> packet_queue;
        std::condition_variable packet_queue_ready;
 
-       AVStream *avstream_video, *avstream_audio;
+       std::vector<AVStream *> streams;
+       int subtitle_stream_idx = -1;
 
        std::function<void(int64_t)> write_callback;
        std::vector<MuxMetrics *> metrics;