X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fmixer.h;h=61db4a5c30857b06728d8dee0810a6caf3a06df1;hb=0490c42536a845dd6d718a7c58cfb3e3ab02b1ab;hp=32a1ea476f21547137e680fb13675c80b6b42835;hpb=9b7d691b4cc5db7dbfc18c82e86c1207fcac4722;p=nageru diff --git a/nageru/mixer.h b/nageru/mixer.h index 32a1ea4..61db4a5 100644 --- a/nageru/mixer.h +++ b/nageru/mixer.h @@ -23,25 +23,27 @@ #include #include +#include #include #include "audio_mixer.h" #include "bmusb/bmusb.h" #include "defs.h" -#include "httpd.h" +#include "shared/httpd.h" #include "input_state.h" #include "libusb.h" #include "pbo_frame_allocator.h" #include "ref_counted_frame.h" -#include "ref_counted_gl_sync.h" +#include "shared/ref_counted_gl_sync.h" #include "theme.h" -#include "timebase.h" +#include "shared/timebase.h" #include "video_encoder.h" #include "ycbcr_interpretation.h" class ALSAOutput; class ChromaSubsampler; class DeckLinkOutput; +class MJPEGEncoder; class QSurface; class QSurfaceFormat; class TimecodeRenderer; @@ -249,14 +251,14 @@ public: return theme->get_channel_color(channel); } - int get_channel_signal(unsigned channel) const + int map_channel_to_signal(unsigned channel) const { - return theme->get_channel_signal(channel); + return theme->map_channel_to_signal(channel); } - int map_signal(unsigned channel) + int map_signal_to_card(int signal) { - return theme->map_signal(channel); + return theme->map_signal_to_card(signal); } unsigned get_master_clock() const @@ -287,6 +289,11 @@ public: theme->set_wb(channel, r, g, b); } + std::string format_status_line(const std::string &disk_space_left_text, double file_length_seconds) + { + return theme->format_status_line(disk_space_left_text, file_length_seconds); + } + // Note: You can also get this through the global variable global_audio_mixer. AudioMixer *get_audio_mixer() { return audio_mixer.get(); } const AudioMixer *get_audio_mixer() const { return audio_mixer.get(); } @@ -412,7 +419,7 @@ public: return httpd.get_num_connected_clients(); } - std::vector get_theme_menu() { return theme->get_theme_menu(); } + Theme::MenuEntry *get_theme_menu() { return theme->get_theme_menu(); } void theme_menu_entry_clicked(int lua_ref) { return theme->theme_menu_entry_clicked(lua_ref); } @@ -455,7 +462,7 @@ private: HTTPD httpd; unsigned num_cards, num_video_inputs, num_html_inputs = 0; - QSurface *mixer_surface, *h264_encoder_surface, *decklink_output_surface; + QSurface *mixer_surface, *h264_encoder_surface, *decklink_output_surface, *image_update_surface; std::unique_ptr resource_pool; std::unique_ptr theme; std::atomic audio_source_channel{0}; @@ -475,6 +482,7 @@ private: std::unique_ptr chroma_subsampler; std::unique_ptr v210_converter; std::unique_ptr video_encoder; + std::unique_ptr mjpeg_encoder; std::unique_ptr timecode_renderer; std::atomic display_timecode_in_stream{false}; @@ -530,12 +538,20 @@ private: std::function upload_func; // Needs to be called to actually upload the texture to OpenGL. unsigned dropped_frames = 0; // Number of dropped frames before this one. std::chrono::steady_clock::time_point received_timestamp = std::chrono::steady_clock::time_point::min(); + movit::RGBTriplet neutral_color{1.0f, 1.0f, 1.0f}; + + // Used for MJPEG encoding. (upload_func packs everything it needs + // into the functor, but would otherwise also use these.) + // width=0 or height=0 means a broken frame, ie., do not upload. + bmusb::VideoFormat video_format; + size_t y_offset, cbcr_offset; }; std::deque new_frames; std::condition_variable new_frames_changed; // Set whenever new_frames is changed. - QueueLengthPolicy queue_length_policy; // Refers to the "new_frames" queue. + std::vector new_raw_audio; + int last_timecode = -1; // Unwrapped. JitterHistory jitter_history; @@ -561,6 +577,7 @@ private: JitterHistory output_jitter_history; CaptureCard cards[MAX_VIDEO_CARDS]; // Protected by . YCbCrInterpretation ycbcr_interpretation[MAX_VIDEO_CARDS]; // Protected by . + movit::RGBTriplet last_received_neutral_color[MAX_VIDEO_CARDS]; // Used by the mixer thread only. Constructor-initialiezd. std::unique_ptr audio_mixer; // Same as global_audio_mixer (see audio_mixer.h). bool input_card_is_master_clock(unsigned card_index, unsigned master_card_index) const; struct OutputFrameInfo { @@ -570,7 +587,7 @@ private: bool is_preroll; std::chrono::steady_clock::time_point frame_timestamp; }; - OutputFrameInfo get_one_frame_from_each_card(unsigned master_card_index, bool master_card_is_output, CaptureCard::NewFrame new_frames[MAX_VIDEO_CARDS], bool has_new_frame[MAX_VIDEO_CARDS]); + OutputFrameInfo get_one_frame_from_each_card(unsigned master_card_index, bool master_card_is_output, CaptureCard::NewFrame new_frames[MAX_VIDEO_CARDS], bool has_new_frame[MAX_VIDEO_CARDS], std::vector raw_audio[MAX_VIDEO_CARDS]); InputState input_state;