qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
avform.h
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 #pragma once
21 
22 #include <QList>
23 #include <QObject>
24 #include <QString>
25 
26 #include "genericsettings.h"
27 #include "ui_avform.h"
28 #include "src/video/videomode.h"
29 
30 #include <memory>
31 
32 class IAudioControl;
33 class IAudioSettings;
34 class IAudioSink;
35 class IAudioSource;
36 class CameraSource;
37 class CoreAV;
38 class IVideoSettings;
39 class VideoSurface;
40 class AVForm : public GenericForm, private Ui::AVForm
41 {
42  Q_OBJECT
43 public:
44  AVForm(IAudioControl& audio, CoreAV* coreAV, CameraSource& camera,
45  IAudioSettings* audioSettings, IVideoSettings* videoSettings);
46  ~AVForm() override;
47  QString getFormName() final
48  {
49  return tr("Audio/Video");
50  }
51 
52 private:
53  void getAudioInDevices();
54  void getAudioOutDevices();
55  void getVideoDevices();
56 
57  static int getModeSize(VideoMode mode);
58  void selectBestModes(QVector<VideoMode>& allVideoModes);
63 
64  void createVideoSurface();
65  void killVideoSurface();
66 
67  void retranslateUi();
68 
69 private slots:
70  // audio
71  void on_inDevCombobox_currentIndexChanged(int deviceIndex);
72  void on_outDevCombobox_currentIndexChanged(int deviceIndex);
73  void on_playbackSlider_valueChanged(int sliderSteps);
75  void on_microphoneSlider_valueChanged(int sliderSteps);
76  void on_audioThresholdSlider_valueChanged(int sliderSteps);
78 
79  // camera
82 
83  void rescanDevices();
84  void setVolume(float value);
85 
86 protected:
87  void updateVideoModes(int curIndex);
88 
89 private:
90  void hideEvent(QHideEvent* event) final;
91  void showEvent(QShowEvent* event) final;
92  void open(const QString& devName, const VideoMode& mode);
93  int getStepsFromValue(qreal val, qreal valMin, qreal valMax);
94  qreal getValueFromSteps(int steps, qreal valMin, qreal valMax);
95  void trackNewScreenGeometry(QScreen* qScreen);
96 
97 private:
98  IAudioControl& audio;
100  IAudioSettings* audioSettings;
102 
104  std::unique_ptr<IAudioSink> audioSink;
105  std::unique_ptr<IAudioSource> audioSrc;
108  QVector<QPair<QString, QString>> videoDeviceList;
109  QVector<VideoMode> videoModes;
110  uint alSource;
111  const uint totalSliderSteps = 100; // arbitrary number of steps to give slider a good "feel"
112 };
AVForm::trackNewScreenGeometry
void trackNewScreenGeometry(QScreen *qScreen)
Definition: avform.cpp:162
AVForm::killVideoSurface
void killVideoSurface()
Definition: avform.cpp:626
AVForm::getFormName
QString getFormName() final
Definition: avform.h:47
AVForm::videoSettings
IVideoSettings * videoSettings
Definition: avform.h:101
videomode.h
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
AVForm::camera
CameraSource & camera
Definition: avform.h:107
AVForm::on_audioQualityComboBox_currentIndexChanged
void on_audioQualityComboBox_currentIndexChanged(int index)
Definition: avform.cpp:463
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
AVForm::on_inDevCombobox_currentIndexChanged
void on_inDevCombobox_currentIndexChanged(int deviceIndex)
Definition: avform.cpp:529
AVForm
Definition: avform.h:40
AVForm::getValueFromSteps
qreal getValueFromSteps(int steps, qreal valMin, qreal valMax)
Definition: avform.cpp:651
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
AVForm::rescanDevices
void rescanDevices()
Definition: avform.cpp:166
AVForm::on_cbEnableTestSound_stateChanged
void on_cbEnableTestSound_stateChanged()
Definition: avform.cpp:591
genericsettings.h
AVForm::on_videoDevCombobox_currentIndexChanged
void on_videoDevCombobox_currentIndexChanged(int index)
Definition: avform.cpp:436
AVForm::on_outDevCombobox_currentIndexChanged
void on_outDevCombobox_currentIndexChanged(int deviceIndex)
Definition: avform.cpp:553
AVForm::fillCameraModesComboBox
void fillCameraModesComboBox()
Definition: avform.cpp:301
AVForm::~AVForm
~AVForm() override
Definition: avform.cpp:115
AVForm::audioSrc
std::unique_ptr< IAudioSource > audioSrc
Definition: avform.h:105
AVForm::camVideoSurface
VideoSurface * camVideoSurface
Definition: avform.h:106
AVForm::on_microphoneSlider_valueChanged
void on_microphoneSlider_valueChanged(int sliderSteps)
Definition: avform.cpp:600
AVForm::createVideoSurface
void createVideoSurface()
Definition: avform.cpp:614
AVForm::open
void open(const QString &devName, const VideoMode &mode)
Definition: avform.cpp:154
AVForm::coreAV
CoreAV * coreAV
Definition: avform.h:99
IVideoSettings
Definition: ivideosettings.h:27
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
VideoMode
Describes a video mode supported by a device.
Definition: videomode.h:25
AVForm::alSource
uint alSource
Definition: avform.h:110
AVForm::on_videoModescomboBox_currentIndexChanged
void on_videoModescomboBox_currentIndexChanged(int index)
Definition: avform.cpp:178
AVForm::updateVideoModes
void updateVideoModes(int curIndex)
Definition: avform.cpp:385
AVForm::getAudioInDevices
void getAudioInDevices()
Definition: avform.cpp:491
AVForm::subscribedToAudioIn
bool subscribedToAudioIn
Definition: avform.h:103
VideoSurface
Definition: videosurface.h:27
GenericForm
Definition: genericsettings.h:24
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