X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fdecklink_output.h;h=d5ec41446f255639e1781aa8662b3156f9d94665;hb=HEAD;hp=29ea29c177481fbe3d3850de8e6cdbb9b79bb1fb;hpb=7188e3e948c60f78f5e2cd8756337f716de06d99;p=nageru diff --git a/nageru/decklink_output.h b/nageru/decklink_output.h index 29ea29c..d5ec414 100644 --- a/nageru/decklink_output.h +++ b/nageru/decklink_output.h @@ -7,17 +7,22 @@ #include #include #include +#include #include #include #include #include +#include #include #include "DeckLinkAPI.h" +#include "DeckLinkAPIModes.h" #include "DeckLinkAPITypes.h" #include "LinuxCOM.h" -#include "context.h" +#include + +#include "shared/context.h" #include "print_latency.h" #include "quittable_sleeper.h" #include "ref_counted_frame.h" @@ -37,9 +42,14 @@ class QSurface; class DeckLinkOutput : public IDeckLinkVideoOutputCallback { public: DeckLinkOutput(movit::ResourcePool *resource_pool, QSurface *surface, unsigned width, unsigned height, unsigned card_index); - - bool set_device(IDeckLink *output); - void start_output(uint32_t mode, int64_t base_pts); // Mode comes from get_available_video_modes(). + ~DeckLinkOutput(); + + // The IDecklinkInput argument is to work around a bug + // in the 11.7 and newer drivers against older SDKs, + // where you get a freeze if querying an IDeckLinkInput interface + // on an already-started card. + bool set_device(IDeckLink *decklink, IDeckLinkInput *input_arg); + void start_output(uint32_t mode, int64_t base_pts, bool is_master_card); // Mode comes from get_available_video_modes(). void end_output(); void send_frame(GLuint y_tex, GLuint cbcr_tex, movit::YCbCrLumaCoefficients ycbcr_coefficients, const std::vector &input_frames, int64_t pts, int64_t duration); @@ -133,14 +143,16 @@ private: std::mutex frame_queue_mutex; std::queue> pending_video_frames; // Under . std::queue> frame_freelist; // Under . - int num_frames_in_flight = 0; // Number of frames allocated but not on the freelist. Under . + std::unordered_set scheduled_frames; // Owned by the driver, so no unique_ptr. Under . + std::condition_variable frame_queues_changed; - bool playback_initiated = false, playback_started = false; + bool playback_initiated = false, playback_started = false, is_master_card = false; int64_t base_pts, frame_duration; BMDDisplayModeFlags current_mode_flags = 0; bool last_frame_had_mode_mismatch = false; movit::ResourcePool *resource_pool; + IDeckLinkInput *input = nullptr; IDeckLinkOutput *output = nullptr; BMDVideoConnection video_connection; QSurface *surface;