4 // The actual video mixer, running in its own separate background thread.
10 #include "ref_counted_gl_sync.h"
23 void start(QSurface *surface, QSurface *surface2, QSurface *surface3, QSurface *surface4);
31 void cut(Source source);
35 RefCountedGLsync ready_fence; // Asserted when the texture is done rendering.
37 // Implicitly frees the previous one if there's a new frame available.
38 bool get_display_frame(DisplayFrame *frame);
40 typedef std::function<void()> new_frame_ready_callback_t;
41 void set_frame_ready_fallback(new_frame_ready_callback_t callback);
44 void bm_frame(int card_index, uint16_t timecode,
45 FrameAllocator::Frame video_frame, size_t video_offset, uint16_t video_format,
46 FrameAllocator::Frame audio_frame, size_t audio_offset, uint16_t audio_format);
47 void place_rectangle(movit::Effect *resample_effect, movit::Effect *padding_effect, float x0, float y0, float x1, float y1);
48 void thread_func(QSurface *surface, QSurface *surface2, QSurface *surface3, QSurface *surface4);
50 Source current_source = SOURCE_INPUT1;
52 movit::ResourcePool *resource_pool;
54 std::mutex display_frame_mutex;
55 DisplayFrame current_display_frame, ready_display_frame; // protected by <frame_mutex>
56 bool has_current_display_frame = false, has_ready_display_frame = false; // protected by <frame_mutex>
58 std::mutex bmusb_mutex;
63 bool thread_initialized;
65 QOpenGLContext *context;
67 bool new_data_ready; // Whether new_frame contains anything.
68 FrameAllocator::Frame new_frame;
69 GLsync new_data_ready_fence; // Whether new_frame is ready for rendering.
70 std::condition_variable new_data_ready_changed; // Set whenever new_data_ready is changed.
72 CaptureCard cards[NUM_CARDS]; // protected by <bmusb_mutex>
74 new_frame_ready_callback_t new_frame_ready_callback;
75 bool has_new_frame_ready_callback = false;
77 std::thread mixer_thread;
81 extern Mixer *global_mixer;
83 #endif // !defined(_MIXER_H)