1 #ifndef _FAKE_CAPTURE_H
2 #define _FAKE_CAPTURE_H 1
12 class FakeCapture : public CaptureInterface
15 FakeCapture(unsigned width, unsigned height, unsigned fps, unsigned audio_frequency, int card_index);
19 void set_video_frame_allocator(FrameAllocator *allocator) override
21 video_frame_allocator = allocator;
22 if (owned_video_frame_allocator.get() != allocator) {
23 owned_video_frame_allocator.reset();
27 FrameAllocator *get_video_frame_allocator() override
29 return video_frame_allocator;
32 // Does not take ownership.
33 void set_audio_frame_allocator(FrameAllocator *allocator) override
35 audio_frame_allocator = allocator;
36 if (owned_audio_frame_allocator.get() != allocator) {
37 owned_audio_frame_allocator.reset();
41 FrameAllocator *get_audio_frame_allocator() override
43 return audio_frame_allocator;
46 void set_frame_callback(frame_callback_t callback) override
48 frame_callback = callback;
51 void set_dequeue_thread_callbacks(std::function<void()> init, std::function<void()> cleanup) override
53 dequeue_init_callback = init;
54 dequeue_cleanup_callback = cleanup;
55 has_dequeue_callbacks = true;
58 std::string get_description() const override
63 void configure_card() override;
64 void start_bm_capture() override;
65 void stop_dequeue_thread() override;
66 bool get_disconnected() const override { return false; }
68 std::map<uint32_t, VideoMode> get_available_video_modes() const override;
69 void set_video_mode(uint32_t video_mode_id) override;
70 uint32_t get_current_video_mode() const override { return 0; }
72 std::map<uint32_t, std::string> get_available_video_inputs() const override;
73 void set_video_input(uint32_t video_input_id) override;
74 uint32_t get_current_video_input() const override { return 0; }
76 std::map<uint32_t, std::string> get_available_audio_inputs() const override;
77 void set_audio_input(uint32_t audio_input_id) override;
78 uint32_t get_current_audio_input() const override { return 0; }
81 void producer_thread_func();
83 unsigned width, height, fps, audio_frequency;
86 bool has_dequeue_callbacks = false;
87 std::function<void()> dequeue_init_callback = nullptr;
88 std::function<void()> dequeue_cleanup_callback = nullptr;
90 FrameAllocator *video_frame_allocator = nullptr;
91 FrameAllocator *audio_frame_allocator = nullptr;
92 std::unique_ptr<FrameAllocator> owned_video_frame_allocator;
93 std::unique_ptr<FrameAllocator> owned_audio_frame_allocator;
94 frame_callback_t frame_callback = nullptr;
96 std::string description;
98 std::atomic<bool> producer_thread_should_quit{false};
99 std::thread producer_thread;
104 #endif // !defined(_FAKE_CAPTURE_H)