X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=shared%2Fmux.h;h=1b9fe93216aba26c364f628cd2ce325fa187c263;hb=66c4fc7370e321fa5725e56685e5c5bb84bd6990;hp=c6b4c7e49420b316c44fbf827abf4b8954d04dbb;hpb=b2313d869262960aa3bcaaf3f45f2a3b90d1fc18;p=nageru diff --git a/shared/mux.h b/shared/mux.h index c6b4c7e..1b9fe93 100644 --- a/shared/mux.h +++ b/shared/mux.h @@ -64,6 +64,10 @@ public: // higher overhead. WRITE_BACKGROUND, }; + enum WithSubtitles { + WITH_SUBTITLES, + WITHOUT_SUBTITLES + }; // Takes ownership of avctx. will be called every time // a write has been made to the video stream (id 0), with the pts of @@ -72,9 +76,10 @@ public: // will be added to. // // 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 write_callback, WriteStrategy write_strategy, const std::vector &metrics); + 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 write_callback, WriteStrategy write_strategy, const std::vector &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 @@ -112,7 +117,8 @@ private: std::vector packet_queue; std::condition_variable packet_queue_ready; - AVStream *avstream_video, *avstream_audio; + std::vector streams; + int subtitle_stream_idx = -1; std::function write_callback; std::vector metrics;