2012-02-15 16:17:18 -05:00
|
|
|
/* Copyright (C) 2005-2010, Thorvald Natvig <thorvald@natvig.com>
|
|
|
|
Copyright (C) 2008, Andreas Messer <andi@bupfen.de>
|
|
|
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
|
|
|
- Redistributions of source code must retain the above copyright notice,
|
|
|
|
this list of conditions and the following disclaimer.
|
|
|
|
- Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
- Neither the name of the Mumble Developers nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived from this
|
|
|
|
software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
|
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2013-10-19 20:56:34 -04:00
|
|
|
|
2012-02-15 16:17:18 -05:00
|
|
|
#include "AudioStats.h"
|
|
|
|
#include "AudioInputConfig.h"
|
2012-02-18 10:56:37 -05:00
|
|
|
#include "audiodevicehelper.h"
|
2012-02-15 16:17:18 -05:00
|
|
|
#include "AudioWizard.h"
|
2015-08-14 16:44:20 -04:00
|
|
|
#include "gui/VideoProcessor.h"
|
2015-08-07 21:40:48 -04:00
|
|
|
#include "gui/common/RSGraphWidget.h"
|
2015-08-10 22:13:50 -04:00
|
|
|
#include "util/RsProtectedTimer.h"
|
|
|
|
|
2015-05-11 15:40:07 -04:00
|
|
|
#include <interface/rsVOIP.h>
|
2012-02-15 16:17:18 -05:00
|
|
|
|
|
|
|
#define iroundf(x) ( static_cast<int>(x) )
|
|
|
|
|
|
|
|
/*void AudioInputDialog::hideEvent(QHideEvent *) {
|
|
|
|
qtTick->stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioInputDialog::showEvent(QShowEvent *) {
|
|
|
|
qtTick->start(20);
|
|
|
|
}*/
|
|
|
|
|
2015-08-07 21:40:48 -04:00
|
|
|
class voipGraphSource: public RSGraphSource
|
|
|
|
{
|
|
|
|
public:
|
2015-08-09 18:09:17 -04:00
|
|
|
voipGraphSource() : video_input(NULL) {}
|
2015-08-07 21:40:48 -04:00
|
|
|
|
2015-08-09 18:09:17 -04:00
|
|
|
void setVideoInput(const QVideoInputDevice *vid) { video_input = vid ; }
|
2015-08-07 21:40:48 -04:00
|
|
|
|
|
|
|
virtual QString displayName(int) const { return tr("Required bandwidth") ;}
|
|
|
|
|
|
|
|
virtual QString displayValue(float v) const
|
|
|
|
{
|
|
|
|
if(v < 1000)
|
|
|
|
return QString::number(v,10,2) + " B/s" ;
|
|
|
|
else if(v < 1000*1024)
|
|
|
|
return QString::number(v/1024,10,2) + " KB/s" ;
|
|
|
|
else
|
|
|
|
return QString::number(v/(1024*1024),10,2) + " MB/s" ;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void getValues(std::map<std::string,float>& vals) const
|
|
|
|
{
|
|
|
|
vals.clear() ;
|
|
|
|
|
2015-08-09 18:09:17 -04:00
|
|
|
if(video_input)
|
|
|
|
vals[std::string("bw")] = video_input->currentBandwidth() ;
|
2015-08-07 21:40:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-08-09 18:09:17 -04:00
|
|
|
const QVideoInputDevice *video_input ;
|
2015-08-07 21:40:48 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
void voipGraph::setVoipSource(voipGraphSource *gs)
|
|
|
|
{
|
|
|
|
_src = gs ;
|
|
|
|
RSGraphWidget::setSource(gs) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
voipGraph::voipGraph(QWidget *parent)
|
|
|
|
: RSGraphWidget(parent)
|
|
|
|
{
|
|
|
|
setFlags(RSGraphWidget::RSGRAPH_FLAGS_SHOW_LEGEND) ;
|
|
|
|
setFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN) ;
|
|
|
|
|
|
|
|
_src = NULL ;
|
|
|
|
}
|
|
|
|
|
2012-02-15 16:17:18 -05:00
|
|
|
/** Constructor */
|
2013-10-18 17:10:33 -04:00
|
|
|
AudioInputConfig::AudioInputConfig(QWidget * parent, Qt::WindowFlags flags)
|
2012-02-15 16:17:18 -05:00
|
|
|
: ConfigPage(parent, flags)
|
|
|
|
{
|
2015-08-14 16:44:20 -04:00
|
|
|
std::cerr << "Creating audioInputConfig object" << std::endl;
|
2014-07-13 09:57:25 -04:00
|
|
|
|
2015-08-14 16:44:20 -04:00
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
2012-02-15 16:17:18 -05:00
|
|
|
|
2015-08-14 16:44:20 -04:00
|
|
|
loaded = false;
|
2012-02-28 16:59:01 -05:00
|
|
|
|
2015-08-14 16:44:20 -04:00
|
|
|
inputAudioProcessor = NULL;
|
|
|
|
inputAudioDevice = NULL;
|
|
|
|
abSpeech = NULL;
|
|
|
|
qtTick = NULL;
|
2014-07-13 09:57:25 -04:00
|
|
|
|
2015-08-14 16:44:20 -04:00
|
|
|
// Create the video pipeline.
|
|
|
|
//
|
|
|
|
videoInput = new QVideoInputDevice(this) ;
|
|
|
|
videoInput->setEchoVideoTarget(ui.videoDisplay) ;
|
2015-08-10 22:13:50 -04:00
|
|
|
|
2015-08-14 16:44:20 -04:00
|
|
|
videoProcessor = new VideoProcessor() ;
|
|
|
|
videoProcessor->setDisplayTarget(NULL) ;
|
2015-08-10 22:13:50 -04:00
|
|
|
|
2015-08-24 21:15:33 -04:00
|
|
|
videoProcessor->setMaximumBandwidth(ui.availableBW_SB->value()) ;
|
|
|
|
|
2015-08-14 16:44:20 -04:00
|
|
|
videoInput->setVideoProcessor(videoProcessor) ;
|
2015-08-10 22:13:50 -04:00
|
|
|
|
2015-08-14 16:44:20 -04:00
|
|
|
graph_source = new voipGraphSource ;
|
|
|
|
ui.voipBwGraph->setSource(graph_source);
|
2015-08-10 22:13:50 -04:00
|
|
|
|
2015-08-14 16:44:20 -04:00
|
|
|
graph_source->setVideoInput(videoInput) ;
|
|
|
|
graph_source->setCollectionTimeLimit(1000*300) ;
|
|
|
|
graph_source->start() ;
|
|
|
|
|
|
|
|
QObject::connect(ui.showEncoded_CB,SIGNAL(toggled(bool)),this,SLOT(togglePreview(bool))) ;
|
2015-08-24 21:15:33 -04:00
|
|
|
QObject::connect(ui.availableBW_SB,SIGNAL(valueChanged(double)),this,SLOT(updateAvailableBW(double))) ;
|
2015-08-09 18:09:17 -04:00
|
|
|
}
|
|
|
|
|
2015-08-24 21:15:33 -04:00
|
|
|
void AudioInputConfig::updateAvailableBW(double r)
|
|
|
|
{
|
|
|
|
std::cerr << "Setting max bandwidth to " << r << " KB/s" << std::endl;
|
|
|
|
videoProcessor->setMaximumBandwidth((uint32_t)(r*1024)) ;
|
|
|
|
}
|
|
|
|
|
2015-08-09 18:09:17 -04:00
|
|
|
void AudioInputConfig::togglePreview(bool b)
|
|
|
|
{
|
|
|
|
if(b)
|
|
|
|
{
|
|
|
|
videoInput->setEchoVideoTarget(NULL) ;
|
2015-08-14 16:44:20 -04:00
|
|
|
videoProcessor->setDisplayTarget(ui.videoDisplay) ;
|
2015-08-09 18:09:17 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
videoInput->setEchoVideoTarget(ui.videoDisplay) ;
|
2015-08-14 16:44:20 -04:00
|
|
|
videoProcessor->setDisplayTarget(NULL) ;
|
2015-08-09 18:09:17 -04:00
|
|
|
}
|
2012-02-15 16:17:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
AudioInputConfig::~AudioInputConfig()
|
|
|
|
{
|
2015-09-02 22:14:04 -04:00
|
|
|
disconnect( qtTick, SIGNAL( timeout ( ) ), this, SLOT( on_Tick_timeout() ) );
|
|
|
|
|
2015-08-07 21:40:48 -04:00
|
|
|
graph_source->stop() ;
|
|
|
|
graph_source->setVideoInput(NULL) ;
|
|
|
|
|
2014-07-13 09:57:25 -04:00
|
|
|
std::cerr << "Deleting audioInputConfig object" << std::endl;
|
|
|
|
if(videoInput != NULL)
|
|
|
|
{
|
|
|
|
videoInput->stop() ;
|
|
|
|
delete videoInput ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inputAudioDevice) {
|
|
|
|
inputAudioDevice->stop();
|
|
|
|
delete inputAudioDevice ;
|
|
|
|
inputAudioDevice = NULL ;
|
2012-02-15 16:17:18 -05:00
|
|
|
}
|
2012-09-24 15:53:53 -04:00
|
|
|
|
2014-07-13 09:57:25 -04:00
|
|
|
if(inputAudioProcessor)
|
2012-09-24 15:53:53 -04:00
|
|
|
{
|
2014-07-13 09:57:25 -04:00
|
|
|
delete inputAudioProcessor ;
|
|
|
|
inputAudioProcessor = NULL ;
|
2012-09-24 15:53:53 -04:00
|
|
|
}
|
2012-02-15 16:17:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Loads the settings for this page */
|
|
|
|
void AudioInputConfig::load()
|
|
|
|
{
|
|
|
|
//connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(bool) ) );
|
|
|
|
//connect( ui.allowTunnelConnectionCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleTunnelConnection(bool) ) );
|
|
|
|
|
2015-08-10 22:13:50 -04:00
|
|
|
qtTick = new RsProtectedTimer(this);
|
2012-02-15 16:17:18 -05:00
|
|
|
connect( qtTick, SIGNAL( timeout ( ) ), this, SLOT( on_Tick_timeout() ) );
|
|
|
|
qtTick->start(20);
|
|
|
|
/*if (AudioInputRegistrar::qmNew) {
|
|
|
|
QList<QString> keys = AudioInputRegistrar::qmNew->keys();
|
|
|
|
foreach(QString key, keys) {
|
|
|
|
qcbSystem->addItem(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
qcbSystem->setEnabled(qcbSystem->count() > 1);*/
|
|
|
|
|
2015-05-11 15:40:07 -04:00
|
|
|
ui.qcbTransmit->addItem(tr("Continuous"), RsVOIP::AudioTransmitContinous);
|
|
|
|
ui.qcbTransmit->addItem(tr("Voice Activity"), RsVOIP::AudioTransmitVAD);
|
|
|
|
ui.qcbTransmit->addItem(tr("Push To Talk"), RsVOIP::AudioTransmitPushToTalk);
|
2012-02-15 16:17:18 -05:00
|
|
|
|
|
|
|
abSpeech = new AudioBar();
|
|
|
|
abSpeech->qcBelow = Qt::red;
|
|
|
|
abSpeech->qcInside = Qt::yellow;
|
|
|
|
abSpeech->qcAbove = Qt::green;
|
|
|
|
//abSpeech->setGeometry(9,20,50,10);
|
|
|
|
ui.qwVadLayout_2->addWidget(abSpeech,0,0,1,0);
|
|
|
|
|
|
|
|
//on_qcbPushClick_clicked(g.s.bPushClick);
|
|
|
|
//ui.on_Tick_timeout();
|
|
|
|
loadSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AudioInputConfig::loadSettings() {
|
|
|
|
/*QList<QString> keys;
|
|
|
|
|
|
|
|
if (AudioInputRegistrar::qmNew)
|
|
|
|
keys=AudioInputRegistrar::qmNew->keys();
|
|
|
|
else
|
|
|
|
keys.clear();
|
|
|
|
i=keys.indexOf(AudioInputRegistrar::current);
|
|
|
|
if (i >= 0)
|
|
|
|
loadComboBox(qcbSystem, i);
|
|
|
|
|
|
|
|
loadCheckBox(qcbExclusive, r.bExclusiveInput);*/
|
|
|
|
|
|
|
|
//qlePushClickPathOn->setText(r.qsPushClickOn);
|
|
|
|
//qlePushClickPathOff->setText(r.qsPushClickOff);
|
|
|
|
|
|
|
|
/*loadComboBox(qcbTransmit, r.atTransmit);
|
|
|
|
loadSlider(qsTransmitHold, r.iVoiceHold);
|
|
|
|
loadSlider(qsTransmitMin, iroundf(r.fVADmin * 32767.0f + 0.5f));
|
|
|
|
loadSlider(qsTransmitMax, iroundf(r.fVADmax * 32767.0f + 0.5f));
|
|
|
|
loadSlider(qsFrames, (r.iFramesPerPacket == 1) ? 1 : (r.iFramesPerPacket/2 + 1));
|
|
|
|
loadSlider(qsDoublePush, iroundf(static_cast<float>(r.uiDoublePush) / 1000.f + 0.5f));*/
|
2015-05-11 15:40:07 -04:00
|
|
|
ui.qcbTransmit->setCurrentIndex(rsVOIP->getVoipATransmit());
|
|
|
|
on_qcbTransmit_currentIndexChanged(rsVOIP->getVoipATransmit());
|
|
|
|
ui.qsTransmitHold->setValue(rsVOIP->getVoipVoiceHold());
|
|
|
|
on_qsTransmitHold_valueChanged(rsVOIP->getVoipVoiceHold());
|
|
|
|
ui.qsTransmitMin->setValue(rsVOIP->getVoipfVADmin());
|
|
|
|
ui.qsTransmitMax->setValue(rsVOIP->getVoipfVADmax());
|
|
|
|
ui.qcbEchoCancel->setChecked(rsVOIP->getVoipEchoCancel());
|
2012-02-15 16:17:18 -05:00
|
|
|
//ui.qsDoublePush->setValue(iroundf(static_cast<float>(r.uiDoublePush) / 1000.f + 0.5f));
|
|
|
|
|
|
|
|
//loadCheckBox(qcbPushClick, r.bPushClick);
|
|
|
|
//loadSlider(qsQuality, r.iQuality);
|
2015-05-11 15:40:07 -04:00
|
|
|
if (rsVOIP->getVoipiNoiseSuppress() != 0)
|
|
|
|
ui.qsNoise->setValue(-rsVOIP->getVoipiNoiseSuppress());
|
2012-02-15 16:17:18 -05:00
|
|
|
else
|
|
|
|
ui.qsNoise->setValue(14);
|
|
|
|
|
2015-05-11 15:40:07 -04:00
|
|
|
on_qsNoise_valueChanged(-rsVOIP->getVoipiNoiseSuppress());
|
2012-02-15 16:17:18 -05:00
|
|
|
|
2015-05-11 15:40:07 -04:00
|
|
|
ui.qsAmp->setValue(20000 - rsVOIP->getVoipiMinLoudness());
|
|
|
|
on_qsAmp_valueChanged(20000 - rsVOIP->getVoipiMinLoudness());
|
2012-02-15 16:17:18 -05:00
|
|
|
//loadSlider(qsIdle, r.iIdleTime);
|
|
|
|
|
|
|
|
/*int echo = 0;
|
|
|
|
if (r.bEcho)
|
|
|
|
echo = r.bEchoMulti ? 2 : 1;
|
|
|
|
|
|
|
|
loadComboBox(qcbEcho, echo);*/
|
|
|
|
connect( ui.qsTransmitHold, SIGNAL( valueChanged ( int ) ), this, SLOT( on_qsTransmitHold_valueChanged(int) ) );
|
|
|
|
connect( ui.qsNoise, SIGNAL( valueChanged ( int ) ), this, SLOT( on_qsNoise_valueChanged(int) ) );
|
|
|
|
connect( ui.qsAmp, SIGNAL( valueChanged ( int ) ), this, SLOT( on_qsAmp_valueChanged(int) ) );
|
|
|
|
connect( ui.qcbTransmit, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( on_qcbTransmit_currentIndexChanged(int) ) );
|
|
|
|
loaded = true;
|
2014-07-13 09:57:25 -04:00
|
|
|
|
|
|
|
std::cerr << "AudioInputConfig:: starting video." << std::endl;
|
|
|
|
videoInput->start() ;
|
2012-02-15 16:17:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AudioInputConfig::save(QString &/*errmsg*/) {//mainly useless beacause saving occurs in realtime
|
|
|
|
//s.iQuality = qsQuality->value();
|
2015-05-11 15:40:07 -04:00
|
|
|
rsVOIP->setVoipiNoiseSuppress((ui.qsNoise->value() == 14) ? 0 : - ui.qsNoise->value());
|
|
|
|
rsVOIP->setVoipiMinLoudness(20000 - ui.qsAmp->value());
|
|
|
|
rsVOIP->setVoipVoiceHold(ui.qsTransmitHold->value());
|
|
|
|
rsVOIP->setVoipfVADmin(ui.qsTransmitMin->value());
|
|
|
|
rsVOIP->setVoipfVADmax(ui.qsTransmitMax->value());
|
2012-02-15 16:17:18 -05:00
|
|
|
/*s.uiDoublePush = qsDoublePush->value() * 1000;*/
|
2015-05-11 15:40:07 -04:00
|
|
|
rsVOIP->setVoipATransmit(static_cast<RsVOIP::enumAudioTransmit>(ui.qcbTransmit->currentIndex() ));
|
|
|
|
rsVOIP->setVoipEchoCancel(ui.qcbEchoCancel->isChecked());
|
2012-02-15 16:17:18 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*bool AudioInputDialog::expert(bool b) {
|
|
|
|
qgbInterfaces->setVisible(b);
|
|
|
|
qgbAudio->setVisible(b);
|
|
|
|
qliFrames->setVisible(b);
|
|
|
|
qsFrames->setVisible(b);
|
|
|
|
qlFrames->setVisible(b);
|
|
|
|
qswTransmit->setVisible(b);
|
|
|
|
qliIdle->setVisible(b);
|
|
|
|
qsIdle->setVisible(b);
|
|
|
|
qlIdle->setVisible(b);
|
|
|
|
return true;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
void AudioInputConfig::on_qsTransmitHold_valueChanged(int v) {
|
|
|
|
float val = static_cast<float>(v * FRAME_SIZE);
|
|
|
|
val = val / SAMPLING_RATE;
|
|
|
|
ui.qlTransmitHold->setText(tr("%1 s").arg(val, 0, 'f', 2));
|
2015-05-11 15:40:07 -04:00
|
|
|
rsVOIP->setVoipVoiceHold(v);
|
2012-02-15 16:17:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void AudioInputConfig::on_qsNoise_valueChanged(int v) {
|
|
|
|
QPalette pal;
|
|
|
|
|
|
|
|
if (v < 15) {
|
|
|
|
ui.qlNoise->setText(tr("Off"));
|
|
|
|
pal.setColor(ui.qlNoise->foregroundRole(), Qt::red);
|
|
|
|
} else {
|
|
|
|
ui.qlNoise->setText(tr("-%1 dB").arg(v));
|
|
|
|
}
|
|
|
|
ui.qlNoise->setPalette(pal);
|
2015-05-11 15:40:07 -04:00
|
|
|
rsVOIP->setVoipiNoiseSuppress(- ui.qsNoise->value());
|
2012-02-15 16:17:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void AudioInputConfig::on_qsAmp_valueChanged(int v) {
|
|
|
|
v = 20000 - v;
|
|
|
|
float d = 20000.0f/static_cast<float>(v);
|
|
|
|
ui.qlAmp->setText(QString::fromLatin1("%1").arg(d, 0, 'f', 2));
|
2015-05-11 15:40:07 -04:00
|
|
|
rsVOIP->setVoipiMinLoudness(20000 - ui.qsAmp->value());
|
2012-02-15 16:17:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void AudioInputConfig::on_qcbEchoCancel_clicked() {
|
2015-05-11 15:40:07 -04:00
|
|
|
rsVOIP->setVoipEchoCancel(ui.qcbEchoCancel->isChecked());
|
2012-02-15 16:17:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AudioInputConfig::on_qcbTransmit_currentIndexChanged(int v) {
|
|
|
|
switch (v) {
|
|
|
|
case 0:
|
|
|
|
ui.qswTransmit->setCurrentWidget(ui.qwContinuous);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ui.qswTransmit->setCurrentWidget(ui.qwVAD);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ui.qswTransmit->setCurrentWidget(ui.qwPTT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (loaded)
|
2015-05-11 15:40:07 -04:00
|
|
|
rsVOIP->setVoipATransmit(static_cast<RsVOIP::enumAudioTransmit>(ui.qcbTransmit->currentIndex() ));
|
2012-02-15 16:17:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-02 22:14:04 -04:00
|
|
|
void AudioInputConfig::on_Tick_timeout()
|
|
|
|
{
|
|
|
|
if (!inputAudioProcessor)
|
|
|
|
{
|
2014-07-13 09:57:25 -04:00
|
|
|
inputAudioProcessor = new QtSpeex::SpeexInputProcessor();
|
|
|
|
inputAudioProcessor->open(QIODevice::WriteOnly | QIODevice::Unbuffered);
|
2012-02-15 16:17:18 -05:00
|
|
|
|
2014-07-13 09:57:25 -04:00
|
|
|
if (!inputAudioDevice) {
|
|
|
|
inputAudioDevice = AudioDeviceHelper::getPreferedInputDevice();
|
2012-02-15 16:17:18 -05:00
|
|
|
}
|
2014-07-13 09:57:25 -04:00
|
|
|
inputAudioDevice->start(inputAudioProcessor);
|
|
|
|
connect(inputAudioProcessor, SIGNAL(networkPacketReady()), this, SLOT(emptyBuffer()));
|
2012-02-15 16:17:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
abSpeech->iBelow = ui.qsTransmitMin->value();
|
|
|
|
abSpeech->iAbove = ui.qsTransmitMax->value();
|
|
|
|
if (loaded) {
|
2015-05-11 15:40:07 -04:00
|
|
|
rsVOIP->setVoipfVADmin(ui.qsTransmitMin->value());
|
|
|
|
rsVOIP->setVoipfVADmax(ui.qsTransmitMax->value());
|
2012-02-15 16:17:18 -05:00
|
|
|
}
|
|
|
|
|
2014-07-13 09:57:25 -04:00
|
|
|
abSpeech->iValue = iroundf(inputAudioProcessor->dVoiceAcivityLevel * 32767.0f + 0.5f);
|
2012-02-15 16:17:18 -05:00
|
|
|
|
|
|
|
abSpeech->update();
|
2015-08-09 18:09:17 -04:00
|
|
|
|
|
|
|
// also transmit encoded video
|
|
|
|
RsVOIPDataChunk chunk ;
|
|
|
|
|
2015-09-02 22:14:04 -04:00
|
|
|
while((!videoInput->stopped()) && videoInput->getNextEncodedPacket(chunk))
|
2015-08-09 18:09:17 -04:00
|
|
|
{
|
2015-08-14 16:44:20 -04:00
|
|
|
videoProcessor->receiveEncodedData(chunk) ;
|
2015-08-09 18:09:17 -04:00
|
|
|
chunk.clear() ;
|
|
|
|
}
|
2012-02-15 16:17:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void AudioInputConfig::emptyBuffer() {
|
2014-07-13 09:57:25 -04:00
|
|
|
while(inputAudioProcessor->hasPendingPackets()) {
|
|
|
|
inputAudioProcessor->getNetworkPacket(); //that will purge the buffer
|
2012-02-15 16:17:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioInputConfig::on_qpbAudioWizard_clicked() {
|
2012-09-25 19:08:46 -04:00
|
|
|
AudioWizard aw(this);
|
|
|
|
aw.exec();
|
2012-02-15 16:17:18 -05:00
|
|
|
loadSettings();
|
|
|
|
}
|