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 // FRAME_HISTORY frames for each input, in order. Will contain duplicates
38 // for non-interlaced inputs.
39 std::vector<RefCountedFrame> input_frames;
42 Chain get_chain(unsigned num, float t, unsigned width, unsigned height, InputState input_state);
44 int get_num_channels() const { return num_channels; }
45 int map_signal(int signal_num);
46 void set_signal_mapping(int signal_num, int card_num);
47 std::string get_channel_name(unsigned channel);
48 int get_channel_signal(unsigned channel);
49 bool get_supports_set_wb(unsigned channel);
50 void set_wb(unsigned channel, double r, double g, double b);
51 std::string get_channel_color(unsigned channel);
53 std::vector<std::string> get_transition_names(float t);
55 void transition_clicked(int transition_num, float t);
56 void channel_clicked(int preview_num);
58 movit::ResourcePool *get_resource_pool() const { return resource_pool; }
60 // Should be called as part of VideoInput.new() only.
61 void register_video_input(FFmpegCapture *capture)
63 video_inputs.push_back(capture);
66 std::vector<FFmpegCapture *> get_video_inputs() const
71 void register_signal_connection(LiveInputWrapper *live_input, FFmpegCapture *capture)
73 signal_connections.emplace_back(live_input, capture);
76 std::vector<std::pair<LiveInputWrapper *, FFmpegCapture *>> get_signal_connections() const
78 return signal_connections;
82 void register_constants();
83 void register_class(const char *class_name, const luaL_Reg *funcs);
86 lua_State *L; // Protected by <m>.
87 const InputState *input_state; // Protected by <m>. Only set temporarily, during chain setup.
88 movit::ResourcePool *resource_pool;
93 std::map<int, int> signal_to_card_mapping; // Protected by <map_m>.
95 std::vector<FFmpegCapture *> video_inputs;
96 std::vector<std::pair<LiveInputWrapper *, FFmpegCapture *>> signal_connections;
98 friend class LiveInputWrapper;
101 // LiveInputWrapper is a facade on top of an YCbCrInput, exposed to
102 // the Lua code. It contains a function (connect_signal()) intended
103 // to be called during chain setup, that picks out the current frame
104 // (in the form of a set of textures) from the input state given by
105 // the mixer, and communicates that state over to the actual YCbCrInput.
106 class LiveInputWrapper {
108 // Note: <override_bounce> is irrelevant for PixelFormat_8BitBGRA.
109 LiveInputWrapper(Theme *theme, movit::EffectChain *chain, bmusb::PixelFormat pixel_format, bool override_bounce, bool deinterlace);
111 void connect_signal(int signal_num);
112 void connect_signal_raw(int signal_num);
113 movit::Effect *get_effect() const
116 return deinterlace_effect;
117 } else if (pixel_format == bmusb::PixelFormat_8BitBGRA) {
118 return rgba_inputs[0];
120 return ycbcr_inputs[0];
125 Theme *theme; // Not owned by us.
126 bmusb::PixelFormat pixel_format;
127 movit::YCbCrFormat input_ycbcr_format;
128 std::vector<movit::YCbCrInput *> ycbcr_inputs; // Multiple ones if deinterlacing. Owned by the chain.
129 std::vector<movit::FlatInput *> rgba_inputs; // Multiple ones if deinterlacing. Owned by the chain.
130 movit::Effect *deinterlace_effect = nullptr; // Owned by the chain.
134 #endif // !defined(_THEME_H)