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"
20 class LiveInputWrapper;
31 Theme(const std::string &filename, const std::vector<std::string> &search_dirs, movit::ResourcePool *resource_pool, unsigned num_cards);
35 movit::EffectChain *chain;
36 std::function<void()> setup_chain;
38 // FRAME_HISTORY frames for each input, in order. Will contain duplicates
39 // for non-interlaced inputs.
40 std::vector<RefCountedFrame> input_frames;
43 Chain get_chain(unsigned num, float t, unsigned width, unsigned height, InputState input_state);
45 int get_num_channels() const { return num_channels; }
46 int map_signal(int signal_num);
47 void set_signal_mapping(int signal_num, int card_num);
48 std::string get_channel_name(unsigned channel);
49 int get_channel_signal(unsigned channel);
50 bool get_supports_set_wb(unsigned channel);
51 void set_wb(unsigned channel, double r, double g, double b);
52 std::string get_channel_color(unsigned channel);
54 std::vector<std::string> get_transition_names(float t);
56 void transition_clicked(int transition_num, float t);
57 void channel_clicked(int preview_num);
59 movit::ResourcePool *get_resource_pool() const { return resource_pool; }
61 // Should be called as part of VideoInput.new() only.
62 void register_video_input(FFmpegCapture *capture)
64 video_inputs.push_back(capture);
67 std::vector<FFmpegCapture *> get_video_inputs() const
73 // Should be called as part of HTMLInput.new() only.
74 void register_html_input(CEFCapture *capture)
76 html_inputs.push_back(capture);
79 std::vector<CEFCapture *> get_html_inputs() const
85 void register_video_signal_connection(LiveInputWrapper *live_input, FFmpegCapture *capture)
87 video_signal_connections.emplace_back(live_input, capture);
90 std::vector<std::pair<LiveInputWrapper *, FFmpegCapture *>> get_video_signal_connections() const
92 return video_signal_connections;
96 void register_html_signal_connection(LiveInputWrapper *live_input, CEFCapture *capture)
98 html_signal_connections.emplace_back(live_input, capture);
101 std::vector<std::pair<LiveInputWrapper *, CEFCapture *>> get_html_signal_connections() const
103 return html_signal_connections;
108 void register_constants();
109 void register_class(const char *class_name, const luaL_Reg *funcs);
112 lua_State *L; // Protected by <m>.
113 const InputState *input_state = nullptr; // Protected by <m>. Only set temporarily, during chain setup.
114 movit::ResourcePool *resource_pool;
119 std::map<int, int> signal_to_card_mapping; // Protected by <map_m>.
121 std::vector<FFmpegCapture *> video_inputs;
122 std::vector<std::pair<LiveInputWrapper *, FFmpegCapture *>> video_signal_connections;
124 std::vector<CEFCapture *> html_inputs;
125 std::vector<std::pair<LiveInputWrapper *, CEFCapture *>> html_signal_connections;
128 friend class LiveInputWrapper;
131 // LiveInputWrapper is a facade on top of an YCbCrInput, exposed to
132 // the Lua code. It contains a function (connect_signal()) intended
133 // to be called during chain setup, that picks out the current frame
134 // (in the form of a set of textures) from the input state given by
135 // the mixer, and communicates that state over to the actual YCbCrInput.
136 class LiveInputWrapper {
138 // Note: <override_bounce> is irrelevant for PixelFormat_8BitBGRA.
139 LiveInputWrapper(Theme *theme, movit::EffectChain *chain, bmusb::PixelFormat pixel_format, bool override_bounce, bool deinterlace);
141 void connect_signal(int signal_num); // Must be called with the theme's <m> lock held, since it accesses theme->input_state.
142 void connect_signal_raw(int signal_num, const InputState &input_state);
143 movit::Effect *get_effect() const
146 return deinterlace_effect;
147 } else if (pixel_format == bmusb::PixelFormat_8BitBGRA) {
148 return rgba_inputs[0];
150 return ycbcr_inputs[0];
155 Theme *theme; // Not owned by us.
156 bmusb::PixelFormat pixel_format;
157 movit::YCbCrFormat input_ycbcr_format;
158 std::vector<movit::YCbCrInput *> ycbcr_inputs; // Multiple ones if deinterlacing. Owned by the chain.
159 std::vector<movit::FlatInput *> rgba_inputs; // Multiple ones if deinterlacing. Owned by the chain.
160 movit::Effect *deinterlace_effect = nullptr; // Owned by the chain.
164 #endif // !defined(_THEME_H)