qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
avform.cpp
Go to the documentation of this file.
1 /*
2  Copyright © 2014-2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "avform.h"
21 
22 #include <cassert>
23 #include <map>
24 
25 #include <QDebug>
26 #include <QDesktopWidget>
27 #include <QScreen>
28 #include <QShowEvent>
29 
30 #include "audio/audio.h"
31 #include "audio/iaudiosettings.h"
32 #include "audio/iaudiosource.h"
33 #include "src/core/core.h"
34 #include "src/core/coreav.h"
35 #include "src/video/cameradevice.h"
36 #include "src/video/camerasource.h"
38 #include "src/video/videosurface.h"
41 #include "src/widget/translator.h"
42 
43 #ifndef ALC_ALL_DEVICES_SPECIFIER
44 #define ALC_ALL_DEVICES_SPECIFIER ALC_DEVICE_SPECIFIER
45 #endif
46 
47 AVForm::AVForm(IAudioControl& audio, CoreAV* coreAV, CameraSource& camera,
48  IAudioSettings* audioSettings, IVideoSettings* videoSettings)
49  : GenericForm(QPixmap(":/img/settings/av.png"))
50  , audio(audio)
51  , coreAV{coreAV}
52  , audioSettings{audioSettings}
53  , videoSettings{videoSettings}
54  , camVideoSurface(nullptr)
55  , camera(camera)
56 {
57  setupUi(this);
58 
59  // block all child signals during initialization
60  const RecursiveSignalBlocker signalBlocker(this);
61 
62  cbEnableTestSound->setChecked(audioSettings->getEnableTestSound());
63  cbEnableTestSound->setToolTip(tr("Play a test sound while changing the output volume."));
64 
65  connect(rescanButton, &QPushButton::clicked, this, &AVForm::rescanDevices);
66 
67  playbackSlider->setTracking(false);
68  playbackSlider->setMaximum(totalSliderSteps);
69  playbackSlider->setValue(getStepsFromValue(audioSettings->getOutVolume(),
70  audioSettings->getOutVolumeMin(),
71  audioSettings->getOutVolumeMax()));
72  playbackSlider->installEventFilter(this);
73 
74  microphoneSlider->setToolTip(tr("Use slider to set the gain of your input device ranging"
75  " from %1dB to %2dB.")
76  .arg(audio.minInputGain())
77  .arg(audio.maxInputGain()));
78  microphoneSlider->setMaximum(totalSliderSteps);
79  microphoneSlider->setTickPosition(QSlider::TicksBothSides);
80  static const int numTicks = 4;
81  microphoneSlider->setTickInterval(totalSliderSteps / numTicks);
82  microphoneSlider->setTracking(false);
83  microphoneSlider->installEventFilter(this);
84  microphoneSlider->setValue(
85  getStepsFromValue(audioSettings->getAudioInGainDecibel(),
86  audio.minInputGain(),
87  audio.maxInputGain()));
88 
89  audioThresholdSlider->setToolTip(tr("Use slider to set the activation volume for your"
90  " input device."));
91  audioThresholdSlider->setMaximum(totalSliderSteps);
92  audioThresholdSlider->setValue(getStepsFromValue(audioSettings->getAudioThreshold(),
93  audio.minInputThreshold(),
94  audio.maxInputThreshold()));
95  audioThresholdSlider->setTracking(false);
96  audioThresholdSlider->installEventFilter(this);
97 
98  volumeDisplay->setMaximum(totalSliderSteps);
99 
100  fillAudioQualityComboBox();
101 
102  eventsInit();
103 
104  for (QScreen* qScreen : QGuiApplication::screens()) {
105  connect(qScreen, &QScreen::geometryChanged, this, &AVForm::rescanDevices);
106  }
107  auto* qGUIApp = qobject_cast<QGuiApplication *>(qApp);
108  assert (qGUIApp);
109  connect(qGUIApp, &QGuiApplication::screenAdded, this, &AVForm::trackNewScreenGeometry);
110  connect(qGUIApp, &QGuiApplication::screenAdded, this, &AVForm::rescanDevices);
111  connect(qGUIApp, &QGuiApplication::screenRemoved, this, &AVForm::rescanDevices);
112  Translator::registerHandler(std::bind(&AVForm::retranslateUi, this), this);
113 }
114 
116 {
119 }
120 
121 void AVForm::hideEvent(QHideEvent* event)
122 {
123  audioSink.reset();
124  audioSrc.reset();
125 
126  if (camVideoSurface) {
127  camVideoSurface->setSource(nullptr);
129  }
130  videoDeviceList.clear();
131 
132  GenericForm::hideEvent(event);
133 }
134 
135 void AVForm::showEvent(QShowEvent* event)
136 {
140  getVideoDevices();
141 
142  if (audioSrc == nullptr) {
143  audioSrc = audio.makeSource();
144  connect(audioSrc.get(), &IAudioSource::volumeAvailable, this, &AVForm::setVolume);
145  }
146 
147  if (audioSink == nullptr) {
148  audioSink = audio.makeSink();
149  }
150 
151  GenericForm::showEvent(event);
152 }
153 
154 void AVForm::open(const QString& devName, const VideoMode& mode)
155 {
156  QRect rect = mode.toRect();
158  videoSettings->setCamVideoFPS(static_cast<float>(mode.FPS));
159  camera.setupDevice(devName, mode);
160 }
161 
162 void AVForm::trackNewScreenGeometry(QScreen* qScreen) {
163  connect(qScreen, &QScreen::geometryChanged, this, &AVForm::rescanDevices);
164 }
165 
167 {
170  getVideoDevices();
171 }
172 
173 void AVForm::setVolume(float value)
174 {
175  volumeDisplay->setValue(getStepsFromValue(value, audio.minOutputVolume(), audio.maxOutputVolume()));
176 }
177 
179 {
180  assert(0 <= index && index < videoModes.size());
181  int devIndex = videoDevCombobox->currentIndex();
182  assert(0 <= devIndex && devIndex < videoDeviceList.size());
183 
184  QString devName = videoDeviceList[devIndex].first;
185  VideoMode mode = videoModes[index];
186 
187  if (CameraDevice::isScreen(devName) && mode == VideoMode()) {
190  open(devName, mode);
191  return;
192  }
193 
194  auto onGrabbed = [devName, this](QRect region) {
195  VideoMode mode(region);
196  mode.width = mode.width / 2 * 2;
197  mode.height = mode.height / 2 * 2;
198 
199  // Needed, if the virtual screen origin is the top left corner of the primary screen
200  QRect screen = QApplication::primaryScreen()->virtualGeometry();
201  mode.x += screen.x();
202  mode.y += screen.y();
203 
206 
207  open(devName, mode);
208  };
209 
210  // note: grabber is self-managed and will destroy itself when done
211  ScreenshotGrabber* screenshotGrabber = new ScreenshotGrabber;
212 
213  connect(screenshotGrabber, &ScreenshotGrabber::regionChosen, this, onGrabbed,
214  Qt::QueuedConnection);
215  screenshotGrabber->showGrabber();
216  return;
217  }
218 
220  open(devName, mode);
221 }
222 
223 void AVForm::selectBestModes(QVector<VideoMode>& allVideoModes)
224 {
225  if (allVideoModes.isEmpty()) {
226  qCritical() << "Trying to select best mode from empty modes list";
227  return;
228  }
229 
230  // Identify the best resolutions available for the supposed XXXXp resolutions.
231  std::map<int, VideoMode> idealModes;
232  idealModes[120] = VideoMode(160, 120);
233  idealModes[240] = VideoMode(430, 240);
234  idealModes[360] = VideoMode(640, 360);
235  idealModes[480] = VideoMode(854, 480);
236  idealModes[720] = VideoMode(1280, 720);
237  idealModes[1080] = VideoMode(1920, 1080);
238  idealModes[1440] = VideoMode(2560, 1440);
239  idealModes[2160] = VideoMode(3840, 2160);
240 
241  std::map<int, int> bestModeInds;
242  for (int i = 0; i < allVideoModes.size(); ++i) {
243  VideoMode mode = allVideoModes[i];
244 
245  // PS3-Cam protection, everything above 60fps makes no sense
246  if (mode.FPS > 60)
247  continue;
248 
249  for (auto iter = idealModes.begin(); iter != idealModes.end(); ++iter) {
250  int res = iter->first;
251  VideoMode idealMode = iter->second;
252  // don't take approximately correct resolutions unless they really
253  // are close
254  if (mode.norm(idealMode) > idealMode.tolerance())
255  continue;
256 
257  if (bestModeInds.find(res) == bestModeInds.end()) {
258  bestModeInds[res] = i;
259  continue;
260  }
261 
262  int index = bestModeInds[res];
263  VideoMode best = allVideoModes[index];
264  if (mode.norm(idealMode) < best.norm(idealMode)) {
265  bestModeInds[res] = i;
266  continue;
267  }
268 
269  if (mode.norm(idealMode) == best.norm(idealMode)) {
270  // prefer higher FPS and "better" pixel formats
271  if (mode.FPS > best.FPS) {
272  bestModeInds[res] = i;
273  continue;
274  }
275 
277  if (mode.FPS >= best.FPS && better)
278  bestModeInds[res] = i;
279  }
280  }
281  }
282 
283  QVector<VideoMode> newVideoModes;
284  for (auto it = bestModeInds.rbegin(); it != bestModeInds.rend(); ++it) {
285  VideoMode mode = allVideoModes[it->second];
286 
287  if (newVideoModes.empty()) {
288  newVideoModes.push_back(mode);
289  } else {
290  int size = getModeSize(mode);
291  auto result = std::find_if(newVideoModes.cbegin(), newVideoModes.cend(),
292  [size](VideoMode mode) { return getModeSize(mode) == size; });
293 
294  if (result == newVideoModes.end())
295  newVideoModes.push_back(mode);
296  }
297  }
298  allVideoModes = newVideoModes;
299 }
300 
302 {
303  qDebug() << "selected Modes:";
304  bool previouslyBlocked = videoModescomboBox->blockSignals(true);
305  videoModescomboBox->clear();
306 
307  for (int i = 0; i < videoModes.size(); ++i) {
308  VideoMode mode = videoModes[i];
309 
310  QString str;
311  std::string pixelFormat = CameraDevice::getPixelFormatString(mode.pixel_format).toStdString();
312  qDebug("width: %d, height: %d, FPS: %f, pixel format: %s", mode.width, mode.height,
313  mode.FPS, pixelFormat.c_str());
314 
315  if (mode.height && mode.width) {
316  str += QString("%1p").arg(mode.height);
317  } else {
318  str += tr("Default resolution");
319  }
320 
321  videoModescomboBox->addItem(str);
322  }
323 
324  if (videoModes.isEmpty())
325  videoModescomboBox->addItem(tr("Default resolution"));
326 
327  videoModescomboBox->blockSignals(previouslyBlocked);
328 }
329 
331 {
332  QRect prefRes = videoSettings->getCamVideoRes();
333  float prefFPS = videoSettings->getCamVideoFPS();
334 
335  for (int i = 0; i < videoModes.size(); ++i) {
336  VideoMode mode = videoModes[i];
337  if (mode.width == prefRes.width() && mode.height == prefRes.height()
338  && (qAbs(mode.FPS - prefFPS) < 0.0001f)) {
339  return i;
340  }
341  }
342 
343  return -1;
344 }
345 
347 {
348  bool previouslyBlocked = videoModescomboBox->blockSignals(true);
349  videoModescomboBox->clear();
350 
351  for (int i = 0; i < videoModes.size(); ++i) {
352  VideoMode mode = videoModes[i];
353  std::string pixelFormat = CameraDevice::getPixelFormatString(mode.pixel_format).toStdString();
354  qDebug("%dx%d+%d,%d FPS: %f, pixel format: %s\n", mode.width, mode.height, mode.x, mode.y,
355  mode.FPS, pixelFormat.c_str());
356 
357  QString name;
358  if (mode.width && mode.height)
359  name = tr("Screen %1").arg(i + 1);
360  else
361  name = tr("Select region");
362 
363  videoModescomboBox->addItem(name);
364  }
365 
366  videoModescomboBox->blockSignals(previouslyBlocked);
367 }
368 
370 {
371  const bool previouslyBlocked = audioQualityComboBox->blockSignals(true);
372 
373  audioQualityComboBox->addItem(tr("High (64 kbps)"), 64);
374  audioQualityComboBox->addItem(tr("Medium (32 kbps)"), 32);
375  audioQualityComboBox->addItem(tr("Low (16 kbps)"), 16);
376  audioQualityComboBox->addItem(tr("Very low (8 kbps)"), 8);
377 
378  const int currentBitrate = audioSettings->getAudioBitrate();
379  const int index = audioQualityComboBox->findData(currentBitrate);
380 
381  audioQualityComboBox->setCurrentIndex(index);
382  audioQualityComboBox->blockSignals(previouslyBlocked);
383 }
384 
385 void AVForm::updateVideoModes(int curIndex)
386 {
387  if (curIndex < 0 || curIndex >= videoDeviceList.size()) {
388  qWarning() << "Invalid index:" << curIndex;
389  return;
390  }
391  QString devName = videoDeviceList[curIndex].first;
392  QVector<VideoMode> allVideoModes = CameraDevice::getVideoModes(devName);
393 
394  qDebug("available Modes:");
395  bool isScreen = CameraDevice::isScreen(devName);
396  if (isScreen) {
397  // Add extra video mode to region selection
398  allVideoModes.push_back(VideoMode());
399  videoModes = allVideoModes;
401  } else {
402  selectBestModes(allVideoModes);
403  videoModes = allVideoModes;
405  }
406 
407  int preferedIndex = searchPreferredIndex();
408  if (preferedIndex != -1) {
410  videoModescomboBox->blockSignals(true);
411  videoModescomboBox->setCurrentIndex(preferedIndex);
412  videoModescomboBox->blockSignals(false);
413  open(devName, videoModes[preferedIndex]);
414  return;
415  }
416 
417  if (isScreen) {
418  QRect rect = videoSettings->getScreenRegion();
419  VideoMode mode(rect);
420 
422  videoModescomboBox->setCurrentIndex(videoModes.size() - 1);
423  open(devName, mode);
424  return;
425  }
426 
427  // If the user hasn't set a preferred resolution yet,
428  // we'll pick the resolution in the middle of the list,
429  // and the best FPS for that resolution.
430  // If we picked the lowest resolution, the quality would be awful
431  // but if we picked the largest, FPS would be bad and thus quality bad too.
432  int mid = (videoModes.size() - 1) / 2;
433  videoModescomboBox->setCurrentIndex(mid);
434 }
435 
437 {
438  assert(0 <= index && index < videoDeviceList.size());
439 
441  QString dev = videoDeviceList[index].first;
443  bool previouslyBlocked = videoModescomboBox->blockSignals(true);
444  updateVideoModes(index);
445  videoModescomboBox->blockSignals(previouslyBlocked);
446 
448  return;
449  }
450 
451  int modeIndex = videoModescomboBox->currentIndex();
452  VideoMode mode = VideoMode();
453  if (0 <= modeIndex && modeIndex < videoModes.size()) {
454  mode = videoModes[modeIndex];
455  }
456 
457  camera.setupDevice(dev, mode);
458  if (dev == "none") {
459  coreAV->sendNoVideo();
460  }
461 }
462 
464 {
465  audioSettings->setAudioBitrate(audioQualityComboBox->currentData().toInt());
466 }
467 
469 {
470  QString settingsInDev = videoSettings->getVideoDev();
471  int videoDevIndex = 0;
473  // prevent currentIndexChanged to be fired while adding items
474  videoDevCombobox->blockSignals(true);
475  videoDevCombobox->clear();
476  for (QPair<QString, QString> device : videoDeviceList) {
477  videoDevCombobox->addItem(device.second);
478  if (device.first == settingsInDev)
479  videoDevIndex = videoDevCombobox->count() - 1;
480  }
481  videoDevCombobox->setCurrentIndex(videoDevIndex);
482  videoDevCombobox->blockSignals(false);
483  updateVideoModes(videoDevIndex);
484 }
485 
487 {
488  return qRound(mode.height / 120.0) * 120;
489 }
490 
492 {
493  QStringList deviceNames;
494  deviceNames << tr("Disabled") << audio.inDeviceNames();
495 
496  inDevCombobox->blockSignals(true);
497  inDevCombobox->clear();
498  inDevCombobox->addItems(deviceNames);
499  inDevCombobox->blockSignals(false);
500 
501  int idx = 0;
502  bool enabled = audioSettings->getAudioInDevEnabled();
503  if (enabled && deviceNames.size() > 1) {
504  QString dev = audioSettings->getInDev();
505  idx = qMax(deviceNames.indexOf(dev), 1);
506  }
507  inDevCombobox->setCurrentIndex(idx);
508 }
509 
511 {
512  QStringList deviceNames;
513  deviceNames << tr("Disabled") << audio.outDeviceNames();
514 
515  outDevCombobox->blockSignals(true);
516  outDevCombobox->clear();
517  outDevCombobox->addItems(deviceNames);
518  outDevCombobox->blockSignals(false);
519 
520  int idx = 0;
521  bool enabled = audioSettings->getAudioOutDevEnabled();
522  if (enabled && deviceNames.size() > 1) {
523  QString dev = audioSettings->getOutDev();
524  idx = qMax(deviceNames.indexOf(dev), 1);
525  }
526  outDevCombobox->setCurrentIndex(idx);
527 }
528 
530 {
531  const bool inputEnabled = deviceIndex > 0;
532  audioSettings->setAudioInDevEnabled(inputEnabled);
533 
534  QString deviceName{};
535  if (inputEnabled) {
536  deviceName = inDevCombobox->itemText(deviceIndex);
537  }
538 
539  const QString oldName = audioSettings->getInDev();
540  if (oldName != deviceName) {
541  audioSettings->setInDev(deviceName);
542  audio.reinitInput(deviceName);
543  audioSrc = audio.makeSource();
544  connect(audioSrc.get(), &IAudioSource::volumeAvailable, this, &AVForm::setVolume);
545  }
546 
547  microphoneSlider->setEnabled(inputEnabled);
548  if (!inputEnabled) {
549  volumeDisplay->setValue(volumeDisplay->minimum());
550  }
551 }
552 
554 {
555  const bool outputEnabled = deviceIndex > 0;
556  audioSettings->setAudioOutDevEnabled(outputEnabled);
557 
558  QString deviceName{};
559  if (outputEnabled) {
560  deviceName = outDevCombobox->itemText(deviceIndex);
561  }
562 
563  const QString oldName = audioSettings->getOutDev();
564 
565  if (oldName != deviceName) {
566  audioSettings->setOutDev(deviceName);
567  audio.reinitOutput(deviceName);
568  audioSink = audio.makeSink();
569  }
570 
571  playbackSlider->setEnabled(outputEnabled);
572 }
573 
575 {
576  const int settingsVolume = getValueFromSteps(sliderSteps, audioSettings->getOutVolumeMin(),
577  audioSettings->getOutVolumeMax());
578  audioSettings->setOutVolume(settingsVolume);
579 
580  if (audio.isOutputReady()) {
581  const qreal volume =
582  getValueFromSteps(sliderSteps, audio.minOutputVolume(), audio.maxOutputVolume());
583  audio.setOutputVolume(volume);
584 
585  if (cbEnableTestSound->isChecked() && audioSink) {
586  audioSink->playMono16Sound(IAudioSink::Sound::Test);
587  }
588  }
589 }
590 
592 {
593  audioSettings->setEnableTestSound(cbEnableTestSound->isChecked());
594 
595  if (cbEnableTestSound->isChecked() && audio.isOutputReady() && audioSink) {
596  audioSink->playMono16Sound(IAudioSink::Sound::Test);
597  }
598 }
599 
601 {
602  const qreal dB = getValueFromSteps(sliderSteps, audio.minInputGain(), audio.maxInputGain());
603  audioSettings->setAudioInGainDecibel(dB);
604  audio.setInputGain(dB);
605 }
606 
608 {
609  const qreal normThreshold =
610  getValueFromSteps(sliderSteps, audio.minInputThreshold(), audio.maxInputThreshold());
611  audioSettings->setAudioThreshold(normThreshold);
612  audio.setInputThreshold(normThreshold);
613 }
615 {
616  if (camVideoSurface)
617  return;
618 
619  camVideoSurface = new VideoSurface(QPixmap(), CamFrame);
620  camVideoSurface->setObjectName(QStringLiteral("CamVideoSurface"));
621  camVideoSurface->setMinimumSize(QSize(160, 120));
623  gridLayout->addWidget(camVideoSurface, 0, 0, 1, 1);
624 }
625 
627 {
628  if (!camVideoSurface)
629  return;
630 
631  QLayoutItem* child;
632  while ((child = gridLayout->takeAt(0)) != nullptr)
633  delete child;
634 
635  camVideoSurface->close();
636  delete camVideoSurface;
637  camVideoSurface = nullptr;
638 }
639 
641 {
642  Ui::AVForm::retranslateUi(this);
643 }
644 
645 int AVForm::getStepsFromValue(qreal val, qreal valMin, qreal valMax)
646 {
647  const float norm = (val - valMin) / (valMax - valMin);
648  return norm * totalSliderSteps;
649 }
650 
651 qreal AVForm::getValueFromSteps(int steps, qreal valMin, qreal valMax)
652 {
653  return (static_cast<float>(steps) / totalSliderSteps) * (valMax - valMin) + valMin;
654 }
AVForm::trackNewScreenGeometry
void trackNewScreenGeometry(QScreen *qScreen)
Definition: avform.cpp:162
IVideoSettings::setScreenRegion
virtual void setScreenRegion(const QRect &value)=0
AVForm::killVideoSurface
void killVideoSurface()
Definition: avform.cpp:626
ScreenshotGrabber
Definition: screenshotgrabber.h:36
AVForm::videoSettings
IVideoSettings * videoSettings
Definition: avform.h:101
CameraDevice::getDeviceList
static QVector< QPair< QString, QString > > getDeviceList()
Get device list with desciption.
Definition: cameradevice.cpp:343
AVForm::on_playbackSlider_valueChanged
void on_playbackSlider_valueChanged(int sliderSteps)
Definition: avform.cpp:574
AVForm::videoModes
QVector< VideoMode > videoModes
Definition: avform.h:109
AVForm::audioSink
std::unique_ptr< IAudioSink > audioSink
Definition: avform.h:104
AVForm::retranslateUi
void retranslateUi()
Definition: avform.cpp:640
AVForm::on_audioThresholdSlider_valueChanged
void on_audioThresholdSlider_valueChanged(int sliderSteps)
Definition: avform.cpp:607
recursivesignalblocker.h
VideoMode::x
int x
Definition: videomode.h:28
IVideoSettings::getCamVideoFPS
virtual float getCamVideoFPS() const =0
AVForm::camera
CameraSource & camera
Definition: avform.h:107
IVideoSettings::setCamVideoRes
virtual void setCamVideoRes(QRect newValue)=0
VideoMode::tolerance
uint32_t tolerance() const
Definition: videomode.cpp:70
AVForm::on_audioQualityComboBox_currentIndexChanged
void on_audioQualityComboBox_currentIndexChanged(int index)
Definition: avform.cpp:463
CoreAV::sendNoVideo
void sendNoVideo()
Signal to all peers that we're not sending video anymore.
Definition: coreav.cpp:704
AVForm::totalSliderSteps
const uint totalSliderSteps
Definition: avform.h:111
AVForm::selectBestModes
void selectBestModes(QVector< VideoMode > &allVideoModes)
Definition: avform.cpp:223
CameraSource
This class is a wrapper to share a camera's captured video frames.
Definition: camerasource.h:34
Translator::unregister
static void unregister(void *owner)
Unregisters all handlers of an owner.
Definition: translator.cpp:103
screenshotgrabber.h
CameraDevice::getVideoModes
static QVector< VideoMode > getVideoModes(QString devName)
Get the list of video modes for a device.
Definition: cameradevice.cpp:451
AVForm::on_inDevCombobox_currentIndexChanged
void on_inDevCombobox_currentIndexChanged(int deviceIndex)
Definition: avform.cpp:529
VideoMode::pixel_format
uint32_t pixel_format
Definition: videomode.h:30
AVForm::getValueFromSteps
qreal getValueFromSteps(int steps, qreal valMin, qreal valMax)
Definition: avform.cpp:651
VideoMode::height
int height
Displayed video resolution (NOT frame resolution).
Definition: videomode.h:27
IVideoSettings::getVideoDev
virtual QString getVideoDev() const =0
AVForm::AVForm
AVForm(IAudioControl &audio, CoreAV *coreAV, CameraSource &camera, IAudioSettings *audioSettings, IVideoSettings *videoSettings)
Definition: avform.cpp:47
AVForm::audioSettings
IAudioSettings * audioSettings
Definition: avform.h:100
AVForm::hideEvent
void hideEvent(QHideEvent *event) final
Definition: avform.cpp:121
AVForm::getVideoDevices
void getVideoDevices()
Definition: avform.cpp:468
AVForm::getStepsFromValue
int getStepsFromValue(qreal val, qreal valMin, qreal valMax)
Definition: avform.cpp:645
AVForm::getAudioOutDevices
void getAudioOutDevices()
Definition: avform.cpp:510
coreav.h
CameraSource::setupDevice
void setupDevice(const QString &deviceName, const VideoMode &mode)
Change the device and mode.
Definition: camerasource.cpp:162
AVForm::rescanDevices
void rescanDevices()
Definition: avform.cpp:166
AVForm::on_cbEnableTestSound_stateChanged
void on_cbEnableTestSound_stateChanged()
Definition: avform.cpp:591
IVideoSettings::setVideoDev
virtual void setVideoDev(const QString &deviceSpecifier)=0
AVForm::on_videoDevCombobox_currentIndexChanged
void on_videoDevCombobox_currentIndexChanged(int index)
Definition: avform.cpp:436
VideoMode::norm
uint32_t norm(const VideoMode &other) const
Definition: videomode.cpp:65
cameradevice.h
AVForm::on_outDevCombobox_currentIndexChanged
void on_outDevCombobox_currentIndexChanged(int deviceIndex)
Definition: avform.cpp:553
AVForm::fillCameraModesComboBox
void fillCameraModesComboBox()
Definition: avform.cpp:301
IVideoSettings::getScreenRegion
virtual QRect getScreenRegion() const =0
camerasource.h
AVForm::~AVForm
~AVForm() override
Definition: avform.cpp:115
AVForm::audioSrc
std::unique_ptr< IAudioSource > audioSrc
Definition: avform.h:105
CameraDevice::betterPixelFormat
static bool betterPixelFormat(uint32_t a, uint32_t b)
Compare two pixel formats.
Definition: cameradevice.cpp:498
IVideoSettings::getCamVideoRes
virtual QRect getCamVideoRes() const =0
AVForm::camVideoSurface
VideoSurface * camVideoSurface
Definition: avform.h:106
AVForm::on_microphoneSlider_valueChanged
void on_microphoneSlider_valueChanged(int sliderSteps)
Definition: avform.cpp:600
VideoMode::toRect
QRect toRect() const
Definition: videomode.cpp:54
videosurface.h
VideoSurface::setSource
void setSource(VideoSource *src)
Update source.
Definition: videosurface.cpp:78
Translator::registerHandler
static void registerHandler(const std::function< void()> &, void *owner)
Register a function to be called when the UI needs to be retranslated.
Definition: translator.cpp:93
ScreenshotGrabber::showGrabber
void showGrabber()
Definition: screenshotgrabber.cpp:78
AVForm::createVideoSurface
void createVideoSurface()
Definition: avform.cpp:614
AVForm::open
void open(const QString &devName, const VideoMode &mode)
Definition: avform.cpp:154
VideoMode::width
int width
Definition: videomode.h:27
AVForm::coreAV
CoreAV * coreAV
Definition: avform.h:99
IVideoSettings
Definition: ivideosettings.h:27
VideoMode::y
int y
Coordinates of upper-left corner.
Definition: videomode.h:28
AVForm::searchPreferredIndex
int searchPreferredIndex()
Definition: avform.cpp:330
AVForm::audio
IAudioControl & audio
Definition: avform.h:98
AVForm::fillScreenModesComboBox
void fillScreenModesComboBox()
Definition: avform.cpp:346
AVForm::fillAudioQualityComboBox
void fillAudioQualityComboBox()
Definition: avform.cpp:369
AVForm::setVolume
void setVolume(float value)
Definition: avform.cpp:173
IVideoSettings::getScreenGrabbed
virtual bool getScreenGrabbed() const =0
VideoMode
Describes a video mode supported by a device.
Definition: videomode.h:25
AVForm::on_videoModescomboBox_currentIndexChanged
void on_videoModescomboBox_currentIndexChanged(int index)
Definition: avform.cpp:178
core.h
VideoMode::FPS
float FPS
Frames per second supported by the device at this resolution.
Definition: videomode.h:29
AVForm::updateVideoModes
void updateVideoModes(int curIndex)
Definition: avform.cpp:385
AVForm::getAudioInDevices
void getAudioInDevices()
Definition: avform.cpp:491
ivideosettings.h
avform.h
translator.h
ScreenshotGrabber::regionChosen
void regionChosen(QRect region)
VideoSurface
Definition: videosurface.h:27
CameraDevice::getPixelFormatString
static QString getPixelFormatString(uint32_t pixel_format)
Get the name of the pixel format of a video mode.
Definition: cameradevice.cpp:482
RecursiveSignalBlocker
Recursively blocks all signals from an object and its children.
Definition: recursivesignalblocker.h:27
IVideoSettings::setCamVideoFPS
virtual void setCamVideoFPS(float newValue)=0
GenericForm
Definition: genericsettings.h:24
CameraDevice::isScreen
static bool isScreen(const QString &devName)
Checks if a device name specifies a display.
Definition: cameradevice.cpp:419
CoreAV
Definition: coreav.h:47
AVForm::getModeSize
static int getModeSize(VideoMode mode)
Definition: avform.cpp:486
AVForm::videoDeviceList
QVector< QPair< QString, QString > > videoDeviceList
Definition: avform.h:108
AVForm::showEvent
void showEvent(QShowEvent *event) final
Definition: avform.cpp:135
IVideoSettings::setScreenGrabbed
virtual void setScreenGrabbed(bool value)=0