]> git.sesse.net Git - nageru/blobdiff - mixer.h
Delete streams when they are closed (prevents memory leak on disconnecting clients).
[nageru] / mixer.h
diff --git a/mixer.h b/mixer.h
index 961c2a6c20948d72db4ca150aa7ec8c570d8e44d..061b38243c1adca511de97f119778da3e32c85f1 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -126,6 +126,31 @@ public:
                return theme->get_channel_name(channel);
        }
 
+       int get_channel_signal(unsigned channel) const
+       {
+               return theme->get_channel_signal(channel);
+       }
+
+       int map_signal(unsigned channel)
+       {
+               return theme->map_signal(channel);
+       }
+
+       unsigned get_audio_source() const
+       {
+               return audio_source_channel;
+       }
+
+       void set_audio_source(unsigned channel)
+       {
+               audio_source_channel = channel;
+       }
+
+       void set_signal_mapping(int signal, int card)
+       {
+               return theme->set_signal_mapping(signal, card);
+       }
+
        bool get_supports_set_wb(unsigned channel) const
        {
                return theme->get_supports_set_wb(channel);
@@ -141,6 +166,11 @@ public:
                locut_cutoff_hz = cutoff_hz;
        }
 
+       void set_locut_enabled(bool enabled)
+       {
+               locut_enabled = enabled;
+       }
+
        float get_limiter_threshold_dbfs()
        {
                return limiter_threshold_dbfs;
@@ -204,10 +234,35 @@ public:
 
        void reset_meters();
 
+       unsigned get_num_cards() const { return num_cards; }
+
+       std::string get_card_description(unsigned card_index) const {
+               assert(card_index < num_cards);
+               return cards[card_index].capture->get_description();
+       }
+
+       std::map<uint32_t, VideoMode> get_available_video_modes(unsigned card_index) const {
+               assert(card_index < num_cards);
+               return cards[card_index].capture->get_available_video_modes();
+       }
+
+       uint32_t get_current_video_mode(unsigned card_index) const {
+               assert(card_index < num_cards);
+               return cards[card_index].capture->get_current_video_mode();
+       }
+
+       void set_video_mode(unsigned card_index, uint32_t mode) {
+               assert(card_index < num_cards);
+               cards[card_index].capture->set_video_mode(mode);
+       }
+
+       void start_mode_scanning(unsigned card_index);
+
 private:
+       void configure_card(unsigned card_index, const QSurfaceFormat &format, CaptureInterface *capture);
        void bm_frame(unsigned card_index, uint16_t timecode,
-               FrameAllocator::Frame video_frame, size_t video_offset, uint16_t video_format,
-               FrameAllocator::Frame audio_frame, size_t audio_offset, uint16_t audio_format);
+               FrameAllocator::Frame video_frame, size_t video_offset, VideoFormat video_format,
+               FrameAllocator::Frame audio_frame, size_t audio_offset, AudioFormat audio_format);
        void place_rectangle(movit::Effect *resample_effect, movit::Effect *padding_effect, float x0, float y0, float x1, float y1);
        void thread_func();
        void audio_thread_func();
@@ -222,8 +277,11 @@ private:
        QSurface *mixer_surface, *h264_encoder_surface;
        std::unique_ptr<movit::ResourcePool> resource_pool;
        std::unique_ptr<Theme> theme;
+       std::atomic<unsigned> audio_source_channel{0};
        std::unique_ptr<movit::EffectChain> display_chain;
        GLuint cbcr_program_num;  // Owned by <resource_pool>.
+       GLuint cbcr_vbo;  // Holds position and texcoord data.
+       GLuint cbcr_position_attribute_index, cbcr_texcoord_attribute_index;
        std::unique_ptr<H264Encoder> h264_encoder;
 
        // Effects part of <display_chain>. Owned by <display_chain>.
@@ -233,7 +291,7 @@ private:
 
        std::mutex bmusb_mutex;
        struct CaptureCard {
-               BMUSBCapture *usb;
+               CaptureInterface *capture;
                std::unique_ptr<PBOFrameAllocator> frame_allocator;
 
                // Stuff for the OpenGL context (for texture uploading).
@@ -295,8 +353,9 @@ private:
        Resampler peak_resampler;
        std::atomic<float> peak{0.0f};
 
-       StereoFilter locut;  // Default cutoff 150 Hz, 24 dB/oct.
+       StereoFilter locut;  // Default cutoff 120 Hz, 24 dB/oct.
        std::atomic<float> locut_cutoff_hz;
+       std::atomic<bool> locut_enabled{true};
 
        // First compressor; takes us up to about -12 dBFS.
        StereoCompressor level_compressor;  // Under compressor_mutex. Used to set/override gain_staging_db if <level_compressor_enabled>.
@@ -325,6 +384,12 @@ private:
        std::mutex audio_mutex;
        std::condition_variable audio_task_queue_changed;
        std::queue<AudioTask> audio_task_queue;  // Under audio_mutex.
+
+       // For mode scanning.
+       bool is_mode_scanning[MAX_CARDS]{ false };
+       std::vector<uint32_t> mode_scanlist[MAX_CARDS];
+       unsigned mode_scanlist_index[MAX_CARDS]{ 0 };
+       timespec last_mode_scan_change[MAX_CARDS];
 };
 
 extern Mixer *global_mixer;