5 #include <movit/flat_input.h>
6 #include <movit/ycbcr_input.h>
14 #include "bmusb/bmusb.h"
15 #include "ref_counted_frame.h"
16 #include "tweaked_inputs.h"
19 class LiveInputWrapper;
30 Theme(const std::string &filename, const std::vector<std::string> &search_dirs, movit::ResourcePool *resource_pool, unsigned num_cards);
34 movit::EffectChain *chain;
35 std::function<void()> setup_chain;
37 // May have duplicates.
38 std::vector<RefCountedFrame> input_frames;
41 Chain get_chain(unsigned num, float t, unsigned width, unsigned height, InputState input_state);
43 int get_num_channels() const { return num_channels; }
44 int map_signal(int signal_num);
45 void set_signal_mapping(int signal_num, int card_num);
46 std::string get_channel_name(unsigned channel);
47 int get_channel_signal(unsigned channel);
48 bool get_supports_set_wb(unsigned channel);
49 void set_wb(unsigned channel, double r, double g, double b);
50 std::string get_channel_color(unsigned channel);
52 std::vector<std::string> get_transition_names(float t);
54 void transition_clicked(int transition_num, float t);
55 void channel_clicked(int preview_num);
57 movit::ResourcePool *get_resource_pool() const { return resource_pool; }
59 // Should be called as part of VideoInput.new() only.
60 void register_video_input(FFmpegCapture *capture)
62 video_inputs.push_back(capture);
65 std::vector<FFmpegCapture *> get_video_inputs() const
70 void register_signal_connection(LiveInputWrapper *live_input, FFmpegCapture *capture)
72 signal_connections.emplace_back(live_input, capture);
75 std::vector<std::pair<LiveInputWrapper *, FFmpegCapture *>> get_signal_connections() const
77 return signal_connections;
81 void register_constants();
82 void register_class(const char *class_name, const luaL_Reg *funcs);
85 lua_State *L; // Protected by <m>.
86 const InputState *input_state; // Protected by <m>. Only set temporarily, during chain setup.
87 movit::ResourcePool *resource_pool;
92 std::map<int, int> signal_to_card_mapping; // Protected by <map_m>.
94 std::vector<FFmpegCapture *> video_inputs;
95 std::vector<std::pair<LiveInputWrapper *, FFmpegCapture *>> signal_connections;
97 friend class LiveInputWrapper;
100 // LiveInputWrapper is a facade on top of an YCbCrInput, exposed to
101 // the Lua code. It contains a function (connect_signal()) intended
102 // to be called during chain setup, that picks out the current frame
103 // (in the form of a set of textures) from the input state given by
104 // the mixer, and communicates that state over to the actual YCbCrInput.
105 class LiveInputWrapper {
107 // Note: <override_bounce> is irrelevant for PixelFormat_8BitBGRA.
108 LiveInputWrapper(Theme *theme, movit::EffectChain *chain, bmusb::PixelFormat pixel_format, bool override_bounce, bool deinterlace);
110 void connect_signal(int signal_num);
111 void connect_signal_raw(int signal_num);
112 movit::Effect *get_effect() const
115 return deinterlace_effect;
116 } else if (pixel_format == bmusb::PixelFormat_8BitBGRA) {
117 return rgba_inputs[0];
119 return ycbcr_inputs[0];
124 Theme *theme; // Not owned by us.
125 bmusb::PixelFormat pixel_format;
126 movit::YCbCrFormat input_ycbcr_format;
127 std::vector<movit::YCbCrInput *> ycbcr_inputs; // Multiple ones if deinterlacing. Owned by the chain.
128 std::vector<movit::FlatInput *> rgba_inputs; // Multiple ones if deinterlacing. Owned by the chain.
129 movit::Effect *deinterlace_effect = nullptr; // Owned by the chain.
133 #endif // !defined(_THEME_H)