mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
saved current work on VOIP plugin. Not working yet.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4958 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5679a30e67
commit
c78b45b755
@ -35,9 +35,9 @@
|
|||||||
#include "AudioInputConfig.h"
|
#include "AudioInputConfig.h"
|
||||||
//#include "Global.h"
|
//#include "Global.h"
|
||||||
//#include "NetworkConfig.h"
|
//#include "NetworkConfig.h"
|
||||||
#include "rsharesettings.h"
|
#include "audiodevicehelper.h"
|
||||||
#include "util/audiodevicehelper.h"
|
|
||||||
#include "AudioWizard.h"
|
#include "AudioWizard.h"
|
||||||
|
#include "rsvoip.h"
|
||||||
|
|
||||||
#define iroundf(x) ( static_cast<int>(x) )
|
#define iroundf(x) ( static_cast<int>(x) )
|
||||||
|
|
||||||
@ -83,9 +83,9 @@ void AudioInputConfig::load()
|
|||||||
}
|
}
|
||||||
qcbSystem->setEnabled(qcbSystem->count() > 1);*/
|
qcbSystem->setEnabled(qcbSystem->count() > 1);*/
|
||||||
|
|
||||||
ui.qcbTransmit->addItem(tr("Continuous"), RshareSettings::AudioTransmitContinous);
|
ui.qcbTransmit->addItem(tr("Continuous"), RsVoip::AudioTransmitContinous);
|
||||||
ui.qcbTransmit->addItem(tr("Voice Activity"), RshareSettings::AudioTransmitVAD);
|
ui.qcbTransmit->addItem(tr("Voice Activity"), RsVoip::AudioTransmitVAD);
|
||||||
ui.qcbTransmit->addItem(tr("Push To Talk"), RshareSettings::AudioTransmitPushToTalk);
|
ui.qcbTransmit->addItem(tr("Push To Talk"), RsVoip::AudioTransmitPushToTalk);
|
||||||
|
|
||||||
abSpeech = new AudioBar();
|
abSpeech = new AudioBar();
|
||||||
abSpeech->qcBelow = Qt::red;
|
abSpeech->qcBelow = Qt::red;
|
||||||
@ -125,26 +125,26 @@ void AudioInputConfig::loadSettings() {
|
|||||||
loadSlider(qsTransmitMax, iroundf(r.fVADmax * 32767.0f + 0.5f));
|
loadSlider(qsTransmitMax, iroundf(r.fVADmax * 32767.0f + 0.5f));
|
||||||
loadSlider(qsFrames, (r.iFramesPerPacket == 1) ? 1 : (r.iFramesPerPacket/2 + 1));
|
loadSlider(qsFrames, (r.iFramesPerPacket == 1) ? 1 : (r.iFramesPerPacket/2 + 1));
|
||||||
loadSlider(qsDoublePush, iroundf(static_cast<float>(r.uiDoublePush) / 1000.f + 0.5f));*/
|
loadSlider(qsDoublePush, iroundf(static_cast<float>(r.uiDoublePush) / 1000.f + 0.5f));*/
|
||||||
ui.qcbTransmit->setCurrentIndex(Settings->getVoipATransmit()-1);
|
ui.qcbTransmit->setCurrentIndex(rsVoip->getVoipATransmit()-1);
|
||||||
on_qcbTransmit_currentIndexChanged(Settings->getVoipATransmit()-1);
|
on_qcbTransmit_currentIndexChanged(rsVoip->getVoipATransmit()-1);
|
||||||
ui.qsTransmitHold->setValue(Settings->getVoipVoiceHold());
|
ui.qsTransmitHold->setValue(rsVoip->getVoipVoiceHold());
|
||||||
on_qsTransmitHold_valueChanged(Settings->getVoipVoiceHold());
|
on_qsTransmitHold_valueChanged(rsVoip->getVoipVoiceHold());
|
||||||
ui.qsTransmitMin->setValue(Settings->getVoipfVADmin());
|
ui.qsTransmitMin->setValue(rsVoip->getVoipfVADmin());
|
||||||
ui.qsTransmitMax->setValue(Settings->getVoipfVADmax());
|
ui.qsTransmitMax->setValue(rsVoip->getVoipfVADmax());
|
||||||
ui.qcbEchoCancel->setChecked(Settings->getVoipEchoCancel());
|
ui.qcbEchoCancel->setChecked(rsVoip->getVoipEchoCancel());
|
||||||
//ui.qsDoublePush->setValue(iroundf(static_cast<float>(r.uiDoublePush) / 1000.f + 0.5f));
|
//ui.qsDoublePush->setValue(iroundf(static_cast<float>(r.uiDoublePush) / 1000.f + 0.5f));
|
||||||
|
|
||||||
//loadCheckBox(qcbPushClick, r.bPushClick);
|
//loadCheckBox(qcbPushClick, r.bPushClick);
|
||||||
//loadSlider(qsQuality, r.iQuality);
|
//loadSlider(qsQuality, r.iQuality);
|
||||||
if (Settings->getVoipiNoiseSuppress() != 0)
|
if (rsVoip->getVoipiNoiseSuppress() != 0)
|
||||||
ui.qsNoise->setValue(-Settings->getVoipiNoiseSuppress());
|
ui.qsNoise->setValue(-rsVoip->getVoipiNoiseSuppress());
|
||||||
else
|
else
|
||||||
ui.qsNoise->setValue(14);
|
ui.qsNoise->setValue(14);
|
||||||
|
|
||||||
on_qsNoise_valueChanged(-Settings->getVoipiNoiseSuppress());
|
on_qsNoise_valueChanged(-rsVoip->getVoipiNoiseSuppress());
|
||||||
|
|
||||||
ui.qsAmp->setValue(20000 - Settings->getVoipiMinLoudness());
|
ui.qsAmp->setValue(20000 - rsVoip->getVoipiMinLoudness());
|
||||||
on_qsAmp_valueChanged(20000 - Settings->getVoipiMinLoudness());
|
on_qsAmp_valueChanged(20000 - rsVoip->getVoipiMinLoudness());
|
||||||
//loadSlider(qsIdle, r.iIdleTime);
|
//loadSlider(qsIdle, r.iIdleTime);
|
||||||
|
|
||||||
/*int echo = 0;
|
/*int echo = 0;
|
||||||
@ -161,14 +161,14 @@ void AudioInputConfig::loadSettings() {
|
|||||||
|
|
||||||
bool AudioInputConfig::save(QString &/*errmsg*/) {//mainly useless beacause saving occurs in realtime
|
bool AudioInputConfig::save(QString &/*errmsg*/) {//mainly useless beacause saving occurs in realtime
|
||||||
//s.iQuality = qsQuality->value();
|
//s.iQuality = qsQuality->value();
|
||||||
Settings->setVoipiNoiseSuppress((ui.qsNoise->value() == 14) ? 0 : - ui.qsNoise->value());
|
rsVoip->setVoipiNoiseSuppress((ui.qsNoise->value() == 14) ? 0 : - ui.qsNoise->value());
|
||||||
Settings->setVoipiMinLoudness(20000 - ui.qsAmp->value());
|
rsVoip->setVoipiMinLoudness(20000 - ui.qsAmp->value());
|
||||||
Settings->setVoipVoiceHold(ui.qsTransmitHold->value());
|
rsVoip->setVoipVoiceHold(ui.qsTransmitHold->value());
|
||||||
Settings->setVoipfVADmin(ui.qsTransmitMin->value());
|
rsVoip->setVoipfVADmin(ui.qsTransmitMin->value());
|
||||||
Settings->setVoipfVADmax(ui.qsTransmitMax->value());
|
rsVoip->setVoipfVADmax(ui.qsTransmitMax->value());
|
||||||
/*s.uiDoublePush = qsDoublePush->value() * 1000;*/
|
/*s.uiDoublePush = qsDoublePush->value() * 1000;*/
|
||||||
Settings->setVoipATransmit(static_cast<RshareSettings::enumAudioTransmit>(ui.qcbTransmit->currentIndex() + 1));
|
rsVoip->setVoipATransmit(static_cast<RsVoip::enumAudioTransmit>(ui.qcbTransmit->currentIndex() + 1));
|
||||||
Settings->setVoipEchoCancel(ui.qcbEchoCancel->isChecked());
|
rsVoip->setVoipEchoCancel(ui.qcbEchoCancel->isChecked());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ void AudioInputConfig::on_qsTransmitHold_valueChanged(int v) {
|
|||||||
float val = static_cast<float>(v * FRAME_SIZE);
|
float val = static_cast<float>(v * FRAME_SIZE);
|
||||||
val = val / SAMPLING_RATE;
|
val = val / SAMPLING_RATE;
|
||||||
ui.qlTransmitHold->setText(tr("%1 s").arg(val, 0, 'f', 2));
|
ui.qlTransmitHold->setText(tr("%1 s").arg(val, 0, 'f', 2));
|
||||||
Settings->setVoipVoiceHold(v);
|
rsVoip->setVoipVoiceHold(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioInputConfig::on_qsNoise_valueChanged(int v) {
|
void AudioInputConfig::on_qsNoise_valueChanged(int v) {
|
||||||
@ -204,18 +204,18 @@ void AudioInputConfig::on_qsNoise_valueChanged(int v) {
|
|||||||
ui.qlNoise->setText(tr("-%1 dB").arg(v));
|
ui.qlNoise->setText(tr("-%1 dB").arg(v));
|
||||||
}
|
}
|
||||||
ui.qlNoise->setPalette(pal);
|
ui.qlNoise->setPalette(pal);
|
||||||
Settings->setVoipiNoiseSuppress(- ui.qsNoise->value());
|
rsVoip->setVoipiNoiseSuppress(- ui.qsNoise->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioInputConfig::on_qsAmp_valueChanged(int v) {
|
void AudioInputConfig::on_qsAmp_valueChanged(int v) {
|
||||||
v = 20000 - v;
|
v = 20000 - v;
|
||||||
float d = 20000.0f/static_cast<float>(v);
|
float d = 20000.0f/static_cast<float>(v);
|
||||||
ui.qlAmp->setText(QString::fromLatin1("%1").arg(d, 0, 'f', 2));
|
ui.qlAmp->setText(QString::fromLatin1("%1").arg(d, 0, 'f', 2));
|
||||||
Settings->setVoipiMinLoudness(20000 - ui.qsAmp->value());
|
rsVoip->setVoipiMinLoudness(20000 - ui.qsAmp->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioInputConfig::on_qcbEchoCancel_clicked() {
|
void AudioInputConfig::on_qcbEchoCancel_clicked() {
|
||||||
Settings->setVoipEchoCancel(ui.qcbEchoCancel->isChecked());
|
rsVoip->setVoipEchoCancel(ui.qcbEchoCancel->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ void AudioInputConfig::on_qcbTransmit_currentIndexChanged(int v) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (loaded)
|
if (loaded)
|
||||||
Settings->setVoipATransmit(static_cast<RshareSettings::enumAudioTransmit>(ui.qcbTransmit->currentIndex() + 1));
|
rsVoip->setVoipATransmit(static_cast<RsVoip::enumAudioTransmit>(ui.qcbTransmit->currentIndex() + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -251,8 +251,8 @@ void AudioInputConfig::on_Tick_timeout() {
|
|||||||
abSpeech->iBelow = ui.qsTransmitMin->value();
|
abSpeech->iBelow = ui.qsTransmitMin->value();
|
||||||
abSpeech->iAbove = ui.qsTransmitMax->value();
|
abSpeech->iAbove = ui.qsTransmitMax->value();
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
Settings->setVoipfVADmin(ui.qsTransmitMin->value());
|
rsVoip->setVoipfVADmin(ui.qsTransmitMin->value());
|
||||||
Settings->setVoipfVADmax(ui.qsTransmitMax->value());
|
rsVoip->setVoipfVADmax(ui.qsTransmitMax->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
abSpeech->iValue = iroundf(inputProcessor->dVoiceAcivityLevel * 32767.0f + 0.5f);
|
abSpeech->iValue = iroundf(inputProcessor->dVoiceAcivityLevel * 32767.0f + 0.5f);
|
||||||
|
@ -34,49 +34,54 @@
|
|||||||
#include <QAudioInput>
|
#include <QAudioInput>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "configpage.h"
|
#include "retroshare-gui/configpage.h"
|
||||||
|
|
||||||
#include "ui_AudioInputConfig.h"
|
#include "ui_AudioInputConfig.h"
|
||||||
#include "util/SpeexProcessor.h"
|
#include "SpeexProcessor.h"
|
||||||
#include "AudioStats.h"
|
#include "AudioStats.h"
|
||||||
|
|
||||||
class AudioInputConfig : public ConfigPage {
|
class AudioInputConfig : public ConfigPage
|
||||||
Q_OBJECT
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::AudioInput ui;
|
Ui::AudioInput ui;
|
||||||
QAudioInput* inputDevice;
|
QAudioInput* inputDevice;
|
||||||
QtSpeex::SpeexInputProcessor* inputProcessor;
|
QtSpeex::SpeexInputProcessor* inputProcessor;
|
||||||
AudioBar* abSpeech;
|
AudioBar* abSpeech;
|
||||||
bool loaded;
|
bool loaded;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QTimer *qtTick;
|
QTimer *qtTick;
|
||||||
/*void hideEvent(QHideEvent *event);
|
/*void hideEvent(QHideEvent *event);
|
||||||
void showEvent(QShowEvent *event);*/
|
void showEvent(QShowEvent *event);*/
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Default Constructor */
|
/** Default Constructor */
|
||||||
AudioInputConfig(QWidget * parent = 0, Qt::WFlags flags = 0);
|
AudioInputConfig(QWidget * parent = 0, Qt::WFlags flags = 0);
|
||||||
/** Default Destructor */
|
/** Default Destructor */
|
||||||
~AudioInputConfig();
|
~AudioInputConfig();
|
||||||
|
|
||||||
/** Saves the changes on this page */
|
/** Saves the changes on this page */
|
||||||
bool save(QString &errmsg);
|
virtual bool save(QString &errmsg);
|
||||||
/** Loads the settings for this page */
|
/** Loads the settings for this page */
|
||||||
void load();
|
virtual void load();
|
||||||
|
|
||||||
private slots:
|
virtual QPixmap iconPixmap() const { return QPixmap(":/images/talking_on.svg") ; }
|
||||||
void loadSettings();
|
virtual QString pageName() const { return tr("VOIP") ; }
|
||||||
void emptyBuffer();
|
|
||||||
|
|
||||||
void on_qsTransmitHold_valueChanged(int v);
|
private slots:
|
||||||
void on_qsAmp_valueChanged(int v);
|
void loadSettings();
|
||||||
void on_qsNoise_valueChanged(int v);
|
void emptyBuffer();
|
||||||
void on_qcbTransmit_currentIndexChanged(int v);
|
|
||||||
void on_Tick_timeout();
|
void on_qsTransmitHold_valueChanged(int v);
|
||||||
void on_qpbAudioWizard_clicked();
|
void on_qsAmp_valueChanged(int v);
|
||||||
void on_qcbEchoCancel_clicked();
|
void on_qsNoise_valueChanged(int v);
|
||||||
|
void on_qcbTransmit_currentIndexChanged(int v);
|
||||||
|
void on_Tick_timeout();
|
||||||
|
void on_qpbAudioWizard_clicked();
|
||||||
|
void on_qcbEchoCancel_clicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -34,8 +34,8 @@
|
|||||||
//#include "Settings.h"
|
//#include "Settings.h"
|
||||||
//#include "Log.h"
|
//#include "Log.h"
|
||||||
//#include "MainWindow.h"
|
//#include "MainWindow.h"
|
||||||
#include "gui/settings/rsharesettings.h"
|
|
||||||
#include "audiodevicehelper.h"
|
#include "audiodevicehelper.h"
|
||||||
|
#include "rsvoip.h"
|
||||||
|
|
||||||
#define iroundf(x) ( static_cast<int>(x) )
|
#define iroundf(x) ( static_cast<int>(x) )
|
||||||
|
|
||||||
@ -70,9 +70,9 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
|
|||||||
|
|
||||||
verticalLayout_3->addWidget(abAmplify);
|
verticalLayout_3->addWidget(abAmplify);
|
||||||
|
|
||||||
if (Settings->getVoipATransmit() == RshareSettings::AudioTransmitPushToTalk)
|
if (rsVoip->getVoipATransmit() == RsVoip::AudioTransmitPushToTalk)
|
||||||
qrPTT->setChecked(true);
|
qrPTT->setChecked(true);
|
||||||
else if (Settings->getVoipATransmit() == RshareSettings::AudioTransmitVAD)
|
else if (rsVoip->getVoipATransmit() == RsVoip::AudioTransmitVAD)
|
||||||
qrVAD->setChecked(true);
|
qrVAD->setChecked(true);
|
||||||
else
|
else
|
||||||
qrContinuous->setChecked(true);
|
qrContinuous->setChecked(true);
|
||||||
@ -82,13 +82,13 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
|
|||||||
abVAD->qcInside = Qt::yellow;
|
abVAD->qcInside = Qt::yellow;
|
||||||
abVAD->qcAbove = Qt::green;
|
abVAD->qcAbove = Qt::green;
|
||||||
|
|
||||||
qsTransmitMin->setValue(Settings->getVoipfVADmin());
|
qsTransmitMin->setValue(rsVoip->getVoipfVADmin());
|
||||||
qsTransmitMax->setValue(Settings->getVoipfVADmax());
|
qsTransmitMax->setValue(rsVoip->getVoipfVADmax());
|
||||||
|
|
||||||
verticalLayout_6->addWidget(abVAD);
|
verticalLayout_6->addWidget(abVAD);
|
||||||
|
|
||||||
// Volume
|
// Volume
|
||||||
qsMaxAmp->setValue(Settings->getVoipiMinLoudness());
|
qsMaxAmp->setValue(rsVoip->getVoipiMinLoudness());
|
||||||
|
|
||||||
setOption(QWizard::NoCancelButton, false);
|
setOption(QWizard::NoCancelButton, false);
|
||||||
resize(700, 500);
|
resize(700, 500);
|
||||||
@ -130,7 +130,7 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
|
|||||||
|
|
||||||
|
|
||||||
void AudioWizard::on_qsMaxAmp_valueChanged(int v) {
|
void AudioWizard::on_qsMaxAmp_valueChanged(int v) {
|
||||||
Settings->setVoipiMinLoudness(qMin(v, 30000));
|
rsVoip->setVoipiMinLoudness(qMin(v, 30000));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioWizard::on_Ticker_timeout() {
|
void AudioWizard::on_Ticker_timeout() {
|
||||||
@ -158,8 +158,8 @@ void AudioWizard::on_Ticker_timeout() {
|
|||||||
|
|
||||||
abVAD->iBelow = qsTransmitMin->value();
|
abVAD->iBelow = qsTransmitMin->value();
|
||||||
abVAD->iAbove = qsTransmitMax->value();
|
abVAD->iAbove = qsTransmitMax->value();
|
||||||
Settings->setVoipfVADmin(qsTransmitMin->value());
|
rsVoip->setVoipfVADmin(qsTransmitMin->value());
|
||||||
Settings->setVoipfVADmax(qsTransmitMax->value());
|
rsVoip->setVoipfVADmax(qsTransmitMax->value());
|
||||||
|
|
||||||
abVAD->iValue = iroundf(inputProcessor->dVoiceAcivityLevel * 32767.0f + 0.5f);
|
abVAD->iValue = iroundf(inputProcessor->dVoiceAcivityLevel * 32767.0f + 0.5f);
|
||||||
|
|
||||||
@ -214,19 +214,19 @@ void AudioWizard::on_playEcho_timeout() {
|
|||||||
|
|
||||||
void AudioWizard::on_qsTransmitMax_valueChanged(int v) {
|
void AudioWizard::on_qsTransmitMax_valueChanged(int v) {
|
||||||
if (! bInit) {
|
if (! bInit) {
|
||||||
Settings->setVoipfVADmax(v);
|
rsVoip->setVoipfVADmax(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioWizard::on_qsTransmitMin_valueChanged(int v) {
|
void AudioWizard::on_qsTransmitMin_valueChanged(int v) {
|
||||||
if (! bInit) {
|
if (! bInit) {
|
||||||
Settings->setVoipfVADmin(v);
|
rsVoip->setVoipfVADmin(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioWizard::on_qrVAD_clicked(bool on) {
|
void AudioWizard::on_qrVAD_clicked(bool on) {
|
||||||
if (on) {
|
if (on) {
|
||||||
Settings->setVoipATransmit(RshareSettings::AudioTransmitVAD);
|
rsVoip->setVoipATransmit(RsVoip::AudioTransmitVAD);
|
||||||
updateTriggerWidgets(true);
|
updateTriggerWidgets(true);
|
||||||
bTransmitChanged = true;
|
bTransmitChanged = true;
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ void AudioWizard::on_qrVAD_clicked(bool on) {
|
|||||||
|
|
||||||
void AudioWizard::on_qrPTT_clicked(bool on) {
|
void AudioWizard::on_qrPTT_clicked(bool on) {
|
||||||
if (on) {
|
if (on) {
|
||||||
Settings->setVoipATransmit(RshareSettings::AudioTransmitPushToTalk);
|
rsVoip->setVoipATransmit(RsVoip::AudioTransmitPushToTalk);
|
||||||
updateTriggerWidgets(false);
|
updateTriggerWidgets(false);
|
||||||
bTransmitChanged = true;
|
bTransmitChanged = true;
|
||||||
}
|
}
|
||||||
@ -242,7 +242,7 @@ void AudioWizard::on_qrPTT_clicked(bool on) {
|
|||||||
|
|
||||||
void AudioWizard::on_qrContinuous_clicked(bool on) {
|
void AudioWizard::on_qrContinuous_clicked(bool on) {
|
||||||
if (on) {
|
if (on) {
|
||||||
Settings->setVoipATransmit(RshareSettings::AudioTransmitContinous);
|
rsVoip->setVoipATransmit(RsVoip::AudioTransmitContinous);
|
||||||
updateTriggerWidgets(false);
|
updateTriggerWidgets(false);
|
||||||
bTransmitChanged = true;
|
bTransmitChanged = true;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,10 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include "gui/settings/rsharesettings.h"
|
|
||||||
|
#include "rsvoip.h"
|
||||||
|
|
||||||
|
//#include "gui/settings/rsharesettings.h"
|
||||||
|
|
||||||
#define iroundf(x) ( static_cast<int>(x) )
|
#define iroundf(x) ( static_cast<int>(x) )
|
||||||
|
|
||||||
@ -160,7 +163,7 @@ qint64 SpeexInputProcessor::writeData(const char *data, qint64 maxSize) {
|
|||||||
iArg = -60;
|
iArg = -60;
|
||||||
speex_preprocess_ctl(preprocessor, SPEEX_PREPROCESS_SET_AGC_DECREMENT, &iArg);
|
speex_preprocess_ctl(preprocessor, SPEEX_PREPROCESS_SET_AGC_DECREMENT, &iArg);
|
||||||
|
|
||||||
iArg = Settings->getVoipiNoiseSuppress();
|
iArg = rsVoip->getVoipiNoiseSuppress();
|
||||||
speex_preprocess_ctl(preprocessor, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &iArg);
|
speex_preprocess_ctl(preprocessor, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &iArg);
|
||||||
|
|
||||||
if (echo_state) {
|
if (echo_state) {
|
||||||
@ -172,18 +175,18 @@ qint64 SpeexInputProcessor::writeData(const char *data, qint64 maxSize) {
|
|||||||
bResetProcessor = false;
|
bResetProcessor = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float v = 30000.0f / static_cast<float>(Settings->getVoipiMinLoudness());
|
float v = 30000.0f / static_cast<float>(rsVoip->getVoipiMinLoudness());
|
||||||
|
|
||||||
iArg = iroundf(floorf(20.0f * log10f(v)));
|
iArg = iroundf(floorf(20.0f * log10f(v)));
|
||||||
speex_preprocess_ctl(preprocessor, SPEEX_PREPROCESS_SET_AGC_MAX_GAIN, &iArg);
|
speex_preprocess_ctl(preprocessor, SPEEX_PREPROCESS_SET_AGC_MAX_GAIN, &iArg);
|
||||||
|
|
||||||
speex_preprocess_ctl(preprocessor, SPEEX_PREPROCESS_GET_AGC_GAIN, &iArg);
|
speex_preprocess_ctl(preprocessor, SPEEX_PREPROCESS_GET_AGC_GAIN, &iArg);
|
||||||
float gainValue = static_cast<float>(iArg);
|
float gainValue = static_cast<float>(iArg);
|
||||||
iArg = Settings->getVoipiNoiseSuppress() - iArg;
|
iArg = rsVoip->getVoipiNoiseSuppress() - iArg;
|
||||||
speex_preprocess_ctl(preprocessor, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &iArg);
|
speex_preprocess_ctl(preprocessor, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &iArg);
|
||||||
|
|
||||||
short * psSource = psMic;
|
short * psSource = psMic;
|
||||||
if (echo_state && Settings->getVoipEchoCancel()) {
|
if (echo_state && rsVoip->getVoipEchoCancel()) {
|
||||||
speex_echo_playback(echo_state, (short*)lastEchoFrame->data());
|
speex_echo_playback(echo_state, (short*)lastEchoFrame->data());
|
||||||
speex_echo_capture(echo_state,psMic,psClean);
|
speex_echo_capture(echo_state,psMic,psClean);
|
||||||
psSource = psClean;
|
psSource = psClean;
|
||||||
@ -207,29 +210,29 @@ qint64 SpeexInputProcessor::writeData(const char *data, qint64 maxSize) {
|
|||||||
|
|
||||||
bool bIsSpeech = false;
|
bool bIsSpeech = false;
|
||||||
|
|
||||||
if (dVoiceAcivityLevel > (static_cast<float>(Settings->getVoipfVADmax()) / 32767))
|
if (dVoiceAcivityLevel > (static_cast<float>(rsVoip->getVoipfVADmax()) / 32767))
|
||||||
bIsSpeech = true;
|
bIsSpeech = true;
|
||||||
else if (dVoiceAcivityLevel > (static_cast<float>(Settings->getVoipfVADmin()) / 32767) && bPreviousVoice)
|
else if (dVoiceAcivityLevel > (static_cast<float>(rsVoip->getVoipfVADmin()) / 32767) && bPreviousVoice)
|
||||||
bIsSpeech = true;
|
bIsSpeech = true;
|
||||||
|
|
||||||
if (! bIsSpeech) {
|
if (! bIsSpeech) {
|
||||||
iHoldFrames++;
|
iHoldFrames++;
|
||||||
if (iHoldFrames < Settings->getVoipVoiceHold())
|
if (iHoldFrames < rsVoip->getVoipVoiceHold())
|
||||||
bIsSpeech = true;
|
bIsSpeech = true;
|
||||||
} else {
|
} else {
|
||||||
iHoldFrames = 0;
|
iHoldFrames = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Settings->getVoipATransmit() == RshareSettings::AudioTransmitContinous) {
|
if (rsVoip->getVoipATransmit() == RsVoip::AudioTransmitContinous) {
|
||||||
bIsSpeech = true;
|
bIsSpeech = true;
|
||||||
}
|
}
|
||||||
else if (Settings->getVoipATransmit() == RshareSettings::AudioTransmitPushToTalk)
|
else if (rsVoip->getVoipATransmit() == RsVoip::AudioTransmitPushToTalk)
|
||||||
bIsSpeech = false;//g.s.uiDoublePush && ((g.uiDoublePush < g.s.uiDoublePush) || (g.tDoublePush.elapsed() < g.s.uiDoublePush));
|
bIsSpeech = false;//g.s.uiDoublePush && ((g.uiDoublePush < g.s.uiDoublePush) || (g.tDoublePush.elapsed() < g.s.uiDoublePush));
|
||||||
|
|
||||||
//bIsSpeech = bIsSpeech || (g.iPushToTalk > 0);
|
//bIsSpeech = bIsSpeech || (g.iPushToTalk > 0);
|
||||||
|
|
||||||
/*if (g.s.bMute || ((g.s.lmLoopMode != Settings::Local) && p && (p->bMute || p->bSuppress)) || g.bPushToMute || (g.iTarget < 0)) {
|
/*if (g.s.bMute || ((g.s.lmLoopMode != RsVoip::Local) && p && (p->bMute || p->bSuppress)) || g.bPushToMute || (g.iTarget < 0)) {
|
||||||
bIsSpeech = false;
|
bIsSpeech = false;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@ -241,11 +244,11 @@ qint64 SpeexInputProcessor::writeData(const char *data, qint64 maxSize) {
|
|||||||
|
|
||||||
/*if (p) {
|
/*if (p) {
|
||||||
if (! bIsSpeech)
|
if (! bIsSpeech)
|
||||||
p->setTalking(Settings::Passive);
|
p->setTalking(RsVoip::Passive);
|
||||||
else if (g.iTarget == 0)
|
else if (g.iTarget == 0)
|
||||||
p->setTalking(Settings::Talking);
|
p->setTalking(RsVoip::Talking);
|
||||||
else
|
else
|
||||||
p->setTalking(Settings::Shouting);
|
p->setTalking(RsVoip::Shouting);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
@ -266,7 +269,7 @@ qint64 SpeexInputProcessor::writeData(const char *data, qint64 maxSize) {
|
|||||||
int vbr_on=0;
|
int vbr_on=0;
|
||||||
//just use fixed bitrate for now
|
//just use fixed bitrate for now
|
||||||
//encryption of VBR-encoded speech may not ensure complete privacy, as phrases can still be identified, at least in a controlled setting with a small dictionary of phrases, by analysing the pattern of variation of the bit rate.
|
//encryption of VBR-encoded speech may not ensure complete privacy, as phrases can still be identified, at least in a controlled setting with a small dictionary of phrases, by analysing the pattern of variation of the bit rate.
|
||||||
if (Settings->getVoipATransmit() == RshareSettings::AudioTransmitVAD) {//maybe we can do fixer bitrate when voice detection is active
|
if (rsVoip->getVoipATransmit() == RsVoip::AudioTransmitVAD) {//maybe we can do fixer bitrate when voice detection is active
|
||||||
vbr_on = 1;//test it on for all modes
|
vbr_on = 1;//test it on for all modes
|
||||||
} else {//maybe we can do vbr for ppt and continuous
|
} else {//maybe we can do vbr for ppt and continuous
|
||||||
vbr_on = 1;
|
vbr_on = 1;
|
||||||
@ -365,7 +368,7 @@ bool SpeexInputProcessor::isSequential() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpeexInputProcessor::addEchoFrame(QByteArray* echo_frame) {
|
void SpeexInputProcessor::addEchoFrame(QByteArray* echo_frame) {
|
||||||
if (Settings->getVoipEchoCancel() && echo_frame) {
|
if (rsVoip->getVoipEchoCancel() && echo_frame) {
|
||||||
QMutexLocker l(&qmSpeex);
|
QMutexLocker l(&qmSpeex);
|
||||||
lastEchoFrame = echo_frame;
|
lastEchoFrame = echo_frame;
|
||||||
if (!echo_state) {//init echo_state
|
if (!echo_state) {//init echo_state
|
||||||
|
@ -5,7 +5,7 @@ CONFIG += mobility
|
|||||||
QT += multimedia
|
QT += multimedia
|
||||||
MOBILITY = multimedia
|
MOBILITY = multimedia
|
||||||
|
|
||||||
SOURCES = AudioInputConfig.cpp AudioStats.cpp AudioWizard.cpp SpeexProcessor.cpp audiodevicehelper.cpp
|
SOURCES = VOIPPlugin.cpp AudioInputConfig.cpp AudioStats.cpp AudioWizard.cpp SpeexProcessor.cpp audiodevicehelper.cpp
|
||||||
HEADERS = AudioInputConfig.h AudioStats.h AudioWizard.h SpeexProcessor.h audiodevicehelper.h
|
HEADERS = AudioInputConfig.h AudioStats.h AudioWizard.h SpeexProcessor.h audiodevicehelper.h
|
||||||
FORMS = AudioInputConfig.ui AudioStats.ui AudioWizard.ui
|
FORMS = AudioInputConfig.ui AudioStats.ui AudioWizard.ui
|
||||||
|
|
||||||
|
87
plugins/VOIP/VOIPPlugin.cpp
Normal file
87
plugins/VOIP/VOIPPlugin.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
#include <retroshare/rsplugin.h>
|
||||||
|
#include <QTranslator>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
#include "VOIPPlugin.h"
|
||||||
|
#include "AudioInputConfig.h"
|
||||||
|
|
||||||
|
//static void *inited = new VOIPPlugin() ;
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
void *RETROSHARE_PLUGIN_provide()
|
||||||
|
{
|
||||||
|
static VOIPPlugin *p = new VOIPPlugin() ;
|
||||||
|
|
||||||
|
return (void*)p ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOIPPlugin::getPluginVersion(int& major,int& minor,int& svn_rev) const
|
||||||
|
{
|
||||||
|
major = 5 ;
|
||||||
|
minor = 1 ;
|
||||||
|
svn_rev = 4350 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOIPPlugin::VOIPPlugin()
|
||||||
|
{
|
||||||
|
mVoip = NULL ;
|
||||||
|
mPlugInHandler = NULL;
|
||||||
|
mPeers = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOIPPlugin::setInterfaces(RsPlugInInterfaces &interfaces)
|
||||||
|
{
|
||||||
|
mPeers = interfaces.mPeers;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigPage *VOIPPlugin::qt_config_page() const
|
||||||
|
{
|
||||||
|
if(config_page == NULL)
|
||||||
|
config_page = new AudioInputConfig() ;
|
||||||
|
|
||||||
|
return config_page ;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsPQIService *VOIPPlugin::rs_pqi_service() const
|
||||||
|
{
|
||||||
|
if(mVoip == NULL)
|
||||||
|
{
|
||||||
|
mVoip = new p3VoipService(/*mPlugInHandler*/) ; // , 3600 * 24 * 30 * 6); // 6 Months
|
||||||
|
rsVoip = mVoip ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mVoip ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOIPPlugin::setPlugInHandler(RsPluginHandler *pgHandler)
|
||||||
|
{
|
||||||
|
mPlugInHandler = pgHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string VOIPPlugin::getShortPluginDescription() const
|
||||||
|
{
|
||||||
|
return QApplication::translate("VOIP", "This plugin provides voice communication between friends in RetroShare.").toUtf8().constData();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string VOIPPlugin::getPluginName() const
|
||||||
|
{
|
||||||
|
return QApplication::translate("VOIPPlugin", "VOIP").toUtf8().constData();
|
||||||
|
}
|
||||||
|
|
||||||
|
QTranslator* VOIPPlugin::qt_translator(QApplication *app, const QString& languageCode) const
|
||||||
|
{
|
||||||
|
if (languageCode == "en") {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTranslator* translator = new QTranslator(app);
|
||||||
|
if (translator->load(":/lang/VOIP_" + languageCode + ".qm")) {
|
||||||
|
return translator;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(translator);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -14,6 +14,7 @@ class VOIPPlugin: public RsPlugin
|
|||||||
virtual MainPage *qt_page() const ;
|
virtual MainPage *qt_page() const ;
|
||||||
virtual QIcon *qt_icon() const ;
|
virtual QIcon *qt_icon() const ;
|
||||||
virtual uint16_t rs_service_id() const { return RS_SERVICE_TYPE_VOIP ; }
|
virtual uint16_t rs_service_id() const { return RS_SERVICE_TYPE_VOIP ; }
|
||||||
|
virtual ConfigPage *qt_config_page() const ;
|
||||||
|
|
||||||
virtual QTranslator *qt_translator(QApplication *app, const QString& languageCode) const;
|
virtual QTranslator *qt_translator(QApplication *app, const QString& languageCode) const;
|
||||||
|
|
||||||
@ -27,10 +28,9 @@ class VOIPPlugin: public RsPlugin
|
|||||||
virtual void setInterfaces(RsPlugInInterfaces& interfaces);
|
virtual void setInterfaces(RsPlugInInterfaces& interfaces);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable p3Voip *mVoip ;
|
mutable p3VoipService *mVoip ;
|
||||||
mutable RsPluginHandler *mPlugInHandler;
|
mutable RsPluginHandler *mPlugInHandler;
|
||||||
mutable RsPeers* mPeers;
|
mutable RsPeers* mPeers;
|
||||||
mutable MainPage* mainpage ;
|
mutable ConfigPage *config_page ;
|
||||||
mutable QIcon* mIcon ;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
#include "serialiser/rsmsgitems.h"
|
#include "serialiser/rsmsgitems.h"
|
||||||
#include "services/p3service.h"
|
#include "services/p3service.h"
|
||||||
#include "retroshare/rsmsgs.h"
|
#include "retroshare/rsmsgs.h"
|
||||||
|
#include "plugins/rspqiservice.h"
|
||||||
|
#include "rsvoip.h"
|
||||||
|
|
||||||
//!The basic VOIP service.
|
//!The basic VOIP service.
|
||||||
|
|
||||||
@ -47,17 +49,37 @@ class p3VoipService: public RsPQIService, public RsVoip
|
|||||||
* : notifyCustomState, notifyChatStatus, notifyPeerHasNewAvatar
|
* : notifyCustomState, notifyChatStatus, notifyPeerHasNewAvatar
|
||||||
* @see NotifyBase
|
* @see NotifyBase
|
||||||
*/
|
*/
|
||||||
virtual int tick();
|
virtual void tick();
|
||||||
virtual int status();
|
virtual int status();
|
||||||
|
|
||||||
/*************** pqiMonitor callback ***********************/
|
// /*************** pqiMonitor callback ***********************/
|
||||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
// virtual void statusChange(const std::list<pqipeer> &plist);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* public chat sent to all peers
|
* public chat sent to all peers
|
||||||
*/
|
*/
|
||||||
int sendVoipData(const void *data,uint32_t size);
|
int sendVoipData(const void *data,uint32_t size);
|
||||||
|
|
||||||
|
// config values
|
||||||
|
|
||||||
|
virtual int getVoipATransmit() const ;
|
||||||
|
virtual void setVoipATransmit(int) const ;
|
||||||
|
|
||||||
|
virtual int getVoipVoiceHold() const ;
|
||||||
|
virtual void setVoipVoiceHold(int) const ;
|
||||||
|
|
||||||
|
virtual int getVoipfVADmin() const ;
|
||||||
|
virtual void setVoipfVADmin(int) const ;
|
||||||
|
|
||||||
|
virtual int getVoipfVADmax() const ;
|
||||||
|
virtual void setVoipfVADmax(int) const ;
|
||||||
|
virtual int getVoipiNoiseSuppress() const ;
|
||||||
|
virtual void setVoipiNoiseSuppress(int) const ;
|
||||||
|
virtual int getVoipiMinLoudness() const ;
|
||||||
|
virtual void setVoipiMinLoudness(int) const ;
|
||||||
|
virtual bool getVoipEchoCancel() const ;
|
||||||
|
virtual void setVoipEchoCancel(bool) const ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/************* from p3Config *******************/
|
/************* from p3Config *******************/
|
||||||
virtual RsSerialiser *setupSerialiser() ;
|
virtual RsSerialiser *setupSerialiser() ;
|
||||||
|
37
plugins/VOIP/rsvoip.h
Normal file
37
plugins/VOIP/rsvoip.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// interface class for p3Voip service
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
class RsVoip ;
|
||||||
|
extern RsVoip *rsVoip;
|
||||||
|
|
||||||
|
class RsVoip
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual int sendVoipData(const void *data,uint32_t size) = 0;
|
||||||
|
|
||||||
|
typedef enum { AudioTransmitContinous = 0, AudioTransmitVAD = 1, AudioTransmitPushToTalk = 2 } enumAudioTransmit ;
|
||||||
|
|
||||||
|
// Config stuff
|
||||||
|
|
||||||
|
virtual int getVoipATransmit() const = 0 ;
|
||||||
|
virtual void setVoipATransmit(int) const = 0 ;
|
||||||
|
|
||||||
|
virtual int getVoipVoiceHold() const = 0 ;
|
||||||
|
virtual void setVoipVoiceHold(int) const = 0 ;
|
||||||
|
|
||||||
|
virtual int getVoipfVADmin() const = 0 ;
|
||||||
|
virtual void setVoipfVADmin(int) const = 0 ;
|
||||||
|
|
||||||
|
virtual int getVoipfVADmax() const = 0 ;
|
||||||
|
virtual void setVoipfVADmax(int) const = 0 ;
|
||||||
|
virtual int getVoipiNoiseSuppress() const = 0 ;
|
||||||
|
virtual void setVoipiNoiseSuppress(int) const = 0 ;
|
||||||
|
virtual int getVoipiMinLoudness() const = 0 ;
|
||||||
|
virtual void setVoipiMinLoudness(int) const = 0 ;
|
||||||
|
virtual bool getVoipEchoCancel() const = 0 ;
|
||||||
|
virtual void setVoipEchoCancel(bool) const = 0 ;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user