]> git.sesse.net Git - nageru/blobdiff - nageru/glwidget.cpp
IWYU-fix nageru/*.cpp.
[nageru] / nageru / glwidget.cpp
index 10d39cb97c7ff30fb4bdc94bdd3a6493bf63938b..d649c3daeb8ba489e8801d3d8ccf77b44e61d402 100644 (file)
@@ -2,7 +2,9 @@
 
 #include <assert.h>
 #include <bmusb/bmusb.h>
+#include <math.h>
 #include <movit/effect_chain.h>
+#include <movit/image_format.h>
 #include <movit/resource_pool.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <map>
 #include <mutex>
 #include <utility>
+#include <vector>
+
+#include <QAction>
+#include <QActionGroup>
+#include <QGL>
+#include <QInputDialog>
+#include <QLineEdit>
+#include <QList>
+#include <QObject>
+#include <QVariant>
 
 #include "audio_mixer.h"
 #include "shared/context.h"
 #include "context_menus.h"
-#include "flags.h"
 #include "mainwindow.h"
 #include "mixer.h"
 #include "shared/ref_counted_gl_sync.h"
+#include "shared/shared_defs.h"
+#include "ycbcr_interpretation.h"
 
 class QMouseEvent;
 
@@ -72,7 +85,7 @@ void GLWidget::grab_white_balance(unsigned channel, unsigned x, unsigned y)
 {
        // Set the white balance to neutral for the grab. It's probably going to
        // flicker a bit, but hopefully this display is not live anyway.
-       global_mixer->set_wb(output, 0.5, 0.5, 0.5);
+       global_mixer->set_wb(output, 1.0, 1.0, 1.0);
        global_mixer->wait_for_next_frame();
 
        // Mark that the next paintGL() should grab the given pixel.
@@ -88,7 +101,7 @@ void GLWidget::initializeGL()
 {
        static once_flag flag;
        call_once(flag, [this]{
-               global_mixer = new Mixer(QGLFormat::toSurfaceFormat(format()), global_flags.num_cards);
+               global_mixer = new Mixer(QGLFormat::toSurfaceFormat(format()));
                global_audio_mixer = global_mixer->get_audio_mixer();
                global_mainwindow->mixer_created(global_mixer);
                global_mixer->start();
@@ -174,7 +187,7 @@ void GLWidget::show_context_menu(const QPoint &pos)
                show_live_context_menu(pos);
        }
        if (output >= Mixer::OUTPUT_INPUT0) {
-               int signal_num = global_mixer->get_channel_signal(output);
+               int signal_num = global_mixer->map_channel_to_signal(output);
                if (signal_num != -1) {
                        show_preview_context_menu(signal_num, pos);
                }
@@ -227,12 +240,13 @@ void GLWidget::show_preview_context_menu(unsigned signal_num, const QPoint &pos)
        QMenu mode_submenu;
        QActionGroup mode_group(&mode_submenu);
 
-       unsigned num_cards = global_mixer->get_num_cards();
-       unsigned current_card = global_mixer->map_signal(signal_num);
+       unsigned current_card = global_mixer->map_signal_to_card(signal_num);
        bool is_ffmpeg = global_mixer->card_is_ffmpeg(current_card);
 
-       if (!is_ffmpeg) {  // FFmpeg inputs are not connected to any card; they're locked to a given input and have a given Y'CbCr interpretatio and have a given Y'CbCr interpretationn.
-               for (unsigned card_index = 0; card_index < num_cards; ++card_index) {
+       if (!is_ffmpeg) {  // FFmpeg inputs are not connected to any card; they're locked to a given input and have a given Y'CbCr interpretatio and have a given Y'CbCr interpretation.
+               for (unsigned card_index = 0; card_index < MAX_VIDEO_CARDS; ++card_index) {
+                       if (!global_mixer->card_is_active(card_index)) continue;
+                       if (global_mixer->card_is_cef(card_index) || global_mixer->card_is_ffmpeg(card_index)) continue;
                        QString description(QString::fromStdString(global_mixer->get_card_description(card_index)));
                        QAction *action = new QAction(description, &card_group);
                        action->setCheckable(true);
@@ -292,10 +306,8 @@ void GLWidget::show_preview_context_menu(unsigned signal_num, const QPoint &pos)
        if (is_ffmpeg) {
                // Add a menu to change the source URL if we're an FFmpeg card.
                // (The theme can still override.)
-               if (global_mixer->card_is_ffmpeg(current_card)) {
-                       change_url_action = new QAction("Change source filename/URL…", &menu);
-                       menu.addAction(change_url_action);
-               }
+               change_url_action = new QAction("Change source filename/URL…", &menu);
+               menu.addAction(change_url_action);
        } else {
                // Add a submenu for selecting video input, with an action for each input.
                std::map<uint32_t, string> video_inputs = global_mixer->get_available_video_inputs(current_card);
@@ -379,7 +391,7 @@ void GLWidget::show_preview_context_menu(unsigned signal_num, const QPoint &pos)
        // And a master clock selector.
        QAction *master_clock_action = new QAction("Use as master clock", &menu);
        master_clock_action->setCheckable(true);
-       if (global_mixer->get_output_card_index() != -1) {
+       if (global_mixer->get_output_card_index() != -1 && global_mixer->get_output_card_is_master()) {
                master_clock_action->setChecked(false);
                master_clock_action->setEnabled(false);
        } else if (global_mixer->get_master_clock() == signal_num) {