]> git.sesse.net Git - nageru/blobdiff - nageru/ffmpeg_capture.h
Matroska hacks.
[nageru] / nageru / ffmpeg_capture.h
index 1fc8f7128f516d6b4d06431b3049256f7bbdf7f7..0823ce09bdb345d1884efc506abbd7cc9a456e35 100644 (file)
@@ -57,6 +57,7 @@ class FFmpegCapture : public bmusb::CaptureInterface
 {
 public:
        FFmpegCapture(const std::string &filename, unsigned width, unsigned height);
+       FFmpegCapture(const std::vector<std::string> &filenames, unsigned width, unsigned height);
 #ifdef HAVE_SRT
        // Takes ownership of the SRT client socket.
        FFmpegCapture(int srt_sock, const std::string &stream_id);
@@ -90,13 +91,13 @@ public:
        std::string get_filename() const
        {
                std::lock_guard<std::mutex> lock(filename_mu);
-               return filename;
+               return filenames[0];
        }
 
        void change_filename(const std::string &new_filename)
        {
                std::lock_guard<std::mutex> lock(filename_mu);
-               filename = new_filename;
+               //filename = new_filename;
                should_interrupt = true;
        }
 
@@ -159,9 +160,13 @@ public:
                        std::placeholders::_11);
        }
 
-       // FFmpegCapture-specific callback that gives the raw audio.
-       typedef std::function<void(const AVPacket *pkt, const AVRational timebase)> audio_callback_t;
-       void set_audio_callback(audio_callback_t callback)
+       // FFmpegCapture-specific callback that gives the raw audio/video.
+       typedef std::function<void(const AVPacket *pkt, const AVRational timebase)> packet_callback_t;
+       void set_video_callback(packet_callback_t callback)
+       {
+               video_callback = callback;
+       }
+       void set_audio_callback(packet_callback_t callback)
        {
                audio_callback = callback;
        }
@@ -271,7 +276,8 @@ private:
        inline unsigned frame_height(const AVFrame *frame) const;
 
        mutable std::mutex filename_mu;
-       std::string description, filename;
+       std::string description;
+       std::vector<std::string> filenames;
        int srt_sock = -1;
        uint16_t timecode = 0;
        unsigned width, height;  // 0 means keep input size.
@@ -297,7 +303,8 @@ private:
        std::unique_ptr<bmusb::FrameAllocator> owned_video_frame_allocator;
        std::unique_ptr<bmusb::FrameAllocator> owned_audio_frame_allocator;
        frame_callback_t frame_callback = nullptr;
-       audio_callback_t audio_callback = nullptr;
+       packet_callback_t video_callback = nullptr;
+       packet_callback_t audio_callback = nullptr;
 
        SwsContextWithDeleter sws_ctx;
        int sws_last_width = -1, sws_last_height = -1, sws_last_src_format = -1;