X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=decklink_capture.h;h=0a9c37b0494539c3cc5c3bc3f8964793cefa6a77;hb=7188db27a931607ed0388b10b351164c37cf04ee;hp=62723bcee7c73c425bdbffbeab7ec07f1a2e03fd;hpb=6ccc929592ef239dc4d011d22facaf19d098567c;p=nageru diff --git a/decklink_capture.h b/decklink_capture.h index 62723bc..0a9c37b 100644 --- a/decklink_capture.h +++ b/decklink_capture.h @@ -14,10 +14,10 @@ class IDeckLinkDisplayMode; // TODO: Adjust CaptureInterface to be a little less bmusb-centric. // There are too many member functions here that don't really do anything. -class DeckLinkCapture : public CaptureInterface, IDeckLinkInputCallback +class DeckLinkCapture : public bmusb::CaptureInterface, IDeckLinkInputCallback { public: - DeckLinkCapture(IDeckLink *card, int card_index); + DeckLinkCapture(IDeckLink *card, int card_index); // Takes ownership of . ~DeckLinkCapture(); // IDeckLinkInputCallback. @@ -33,28 +33,34 @@ public: IDeckLinkAudioInputPacket *audio_frame) override; // CaptureInterface. - void set_video_frame_allocator(FrameAllocator *allocator) override + void set_video_frame_allocator(bmusb::FrameAllocator *allocator) override { video_frame_allocator = allocator; + if (owned_video_frame_allocator.get() != allocator) { + owned_video_frame_allocator.reset(); + } } - FrameAllocator *get_video_frame_allocator() override + bmusb::FrameAllocator *get_video_frame_allocator() override { return video_frame_allocator; } // Does not take ownership. - void set_audio_frame_allocator(FrameAllocator *allocator) override + void set_audio_frame_allocator(bmusb::FrameAllocator *allocator) override { audio_frame_allocator = allocator; + if (owned_audio_frame_allocator.get() != allocator) { + owned_audio_frame_allocator.reset(); + } } - FrameAllocator *get_audio_frame_allocator() override + bmusb::FrameAllocator *get_audio_frame_allocator() override { return audio_frame_allocator; } - void set_frame_callback(frame_callback_t callback) override + void set_frame_callback(bmusb::frame_callback_t callback) override { frame_callback = callback; } @@ -75,10 +81,24 @@ public: void start_bm_capture() override; void stop_dequeue_thread() override; - std::vector get_available_video_modes() const override { return video_modes; } + // TODO: Can the API communicate this to us somehow, for e.g. Thunderbolt cards? + bool get_disconnected() const override { return false; } + + std::map get_available_video_modes() const override { return video_modes; } void set_video_mode(uint32_t video_mode_id) override; + uint32_t get_current_video_mode() const override { return current_video_mode; } + + std::map get_available_video_inputs() const override { return video_inputs; } + void set_video_input(uint32_t video_input_id) override; + uint32_t get_current_video_input() const override { return current_video_input; } + + std::map get_available_audio_inputs() const override { return audio_inputs; } + void set_audio_input(uint32_t audio_input_id) override; + uint32_t get_current_audio_input() const override { return current_audio_input; } private: + void set_video_mode_no_restart(uint32_t video_mode_id); + std::atomic refcount{1}; bool done_init = false; std::string description; @@ -89,16 +109,27 @@ private: std::function dequeue_init_callback = nullptr; std::function dequeue_cleanup_callback = nullptr; - FrameAllocator *video_frame_allocator = nullptr; - FrameAllocator *audio_frame_allocator = nullptr; - frame_callback_t frame_callback = nullptr; + bmusb::FrameAllocator *video_frame_allocator = nullptr; + bmusb::FrameAllocator *audio_frame_allocator = nullptr; + std::unique_ptr owned_video_frame_allocator; + std::unique_ptr owned_audio_frame_allocator; + bmusb::frame_callback_t frame_callback = nullptr; + IDeckLinkConfiguration *config = nullptr; + + IDeckLink *card = nullptr; IDeckLinkInput *input = nullptr; BMDTimeValue frame_duration; BMDTimeScale time_scale; - std::vector video_modes; + std::map video_modes; BMDDisplayMode current_video_mode; + + std::map video_inputs; + BMDVideoConnection current_video_input; + + std::map audio_inputs; + BMDAudioConnection current_audio_input; }; #endif // !defined(_DECKLINK_CAPTURE_H)