X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Ftheme.h;h=7fe0e8585a2b0993a359d362d6db95b08951d5ba;hb=HEAD;hp=2be6689f794b1f57cb47aa986b4789621f088032;hpb=0490c42536a845dd6d718a7c58cfb3e3ab02b1ab;p=nageru diff --git a/nageru/theme.h b/nageru/theme.h index 2be6689..2c6021e 100644 --- a/nageru/theme.h +++ b/nageru/theme.h @@ -5,23 +5,26 @@ #include #include #include -#include +#include #include #include +#include #include #include #include +#include #include #include "bmusb/bmusb.h" -#include "defs.h" #include "ref_counted_frame.h" +#include "shared/shared_defs.h" #include "tweaked_inputs.h" class Scene; class CEFCapture; class FFmpegCapture; class LiveInputWrapper; +class QSurface; struct InputState; namespace movit { @@ -49,6 +52,8 @@ enum EffectType { MULTIPLY_EFFECT, MIX_EFFECT, LIFT_GAMMA_GAIN_EFFECT, + BLUR_EFFECT, + UNSHARP_MASK_EFFECT, NO_EFFECT_TYPE }; @@ -78,13 +83,14 @@ struct InputStateInfo { unsigned last_width[MAX_VIDEO_CARDS], last_height[MAX_VIDEO_CARDS]; bool last_interlaced[MAX_VIDEO_CARDS], last_has_signal[MAX_VIDEO_CARDS], last_is_connected[MAX_VIDEO_CARDS]; unsigned last_frame_rate_nom[MAX_VIDEO_CARDS], last_frame_rate_den[MAX_VIDEO_CARDS]; + bmusb::PixelFormat last_pixel_format[MAX_VIDEO_CARDS]; bool has_last_subtitle[MAX_VIDEO_CARDS]; std::string last_subtitle[MAX_VIDEO_CARDS]; }; class Theme { public: - Theme(const std::string &filename, const std::vector &search_dirs, movit::ResourcePool *resource_pool, unsigned num_cards); + Theme(const std::string &filename, const std::vector &search_dirs, movit::ResourcePool *resource_pool, QSurface *surface); ~Theme(); struct Chain { @@ -105,11 +111,11 @@ public: int map_channel_to_signal(unsigned channel); bool get_supports_set_wb(unsigned channel); void set_wb(unsigned channel, float r, float g, float b); - void set_wb_for_signal(int signal, float r, float g, float b); - movit::RGBTriplet get_white_balance_for_signal(int signal); + void set_wb_for_card(int card_idx, float r, float g, float b); + movit::RGBTriplet get_white_balance_for_card(int card_idx); std::string get_channel_color(unsigned channel); - std::unordered_map white_balance_for_signal; + std::unordered_map white_balance_for_card; std::vector get_transition_names(float t); @@ -191,6 +197,11 @@ public: std::string format_status_line(const std::string &disk_space_left_text, double file_length_seconds); + // Signal that the given card is going away and will not be replaced + // with a fake capture card, so remove all connections to it so that + // they don't automatically come back on the next frame. + void remove_card(unsigned card_index); + private: void register_globals(); void register_class(const char *class_name, const luaL_Reg *funcs, EffectType effect_type = NO_EFFECT_TYPE); @@ -205,7 +216,6 @@ private: const InputState *input_state = nullptr; // Protected by . Only set temporarily, during chain setup. movit::ResourcePool *resource_pool; int num_channels = -1; - unsigned num_cards; bool startup_finished = false; std::mutex map_m; @@ -235,6 +245,11 @@ private: std::map channel_signals; // Set using Nageru.set_channel_signal(). Protected by . std::map channel_supports_wb; // Set using Nageru.set_supports_wb(). Protected by . + // Used to construct OpenGL contexts for VideoInputs. Needs to be available + // during the entire lifetime of Theme, since they may be created basically + // at any time. + const QSurface *surface; + friend class LiveInputWrapper; friend class Scene; friend int ThemeMenu_set(lua_State *L); @@ -242,6 +257,7 @@ private: friend int Nageru_set_num_channels(lua_State *L); friend int Nageru_set_channel_signal(lua_State *L); friend int Nageru_set_supports_wb(lua_State *L); + friend int VideoInput_new(lua_State* L); }; // LiveInputWrapper is a facade on top of an YCbCrInput, exposed to @@ -255,7 +271,7 @@ public: LiveInputWrapper(Theme *theme, movit::EffectChain *chain, bmusb::PixelFormat pixel_format, bool override_bounce, bool deinterlace, bool user_connectable); bool connect_signal(int signal_num); // Must be called with the theme's lock held, since it accesses theme->input_state. Returns false on error. - void connect_signal_raw(int signal_num, const InputState &input_state); + void connect_card(int signal_num, const InputState &input_state); movit::Effect *get_effect() const { if (deinterlace) {