From c78b45b755f99045c34b8337471ad5c91950e3dc Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 18 Feb 2012 15:56:37 +0000 Subject: [PATCH] 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 --- plugins/VOIP/AudioInputConfig.cpp | 62 +++++++++++----------- plugins/VOIP/AudioInputConfig.h | 69 ++++++++++++------------ plugins/VOIP/AudioWizard.cpp | 28 +++++----- plugins/VOIP/SpeexProcessor.cpp | 35 +++++++------ plugins/VOIP/VOIP.pro | 2 +- plugins/VOIP/VOIPPlugin.cpp | 87 +++++++++++++++++++++++++++++++ plugins/VOIP/VOIPPlugin.h | 6 +-- plugins/VOIP/p3Voip.h | 28 ++++++++-- plugins/VOIP/rsvoip.h | 37 +++++++++++++ 9 files changed, 254 insertions(+), 100 deletions(-) create mode 100644 plugins/VOIP/VOIPPlugin.cpp create mode 100644 plugins/VOIP/rsvoip.h diff --git a/plugins/VOIP/AudioInputConfig.cpp b/plugins/VOIP/AudioInputConfig.cpp index 6b0845031..5d10ee48f 100644 --- a/plugins/VOIP/AudioInputConfig.cpp +++ b/plugins/VOIP/AudioInputConfig.cpp @@ -35,9 +35,9 @@ #include "AudioInputConfig.h" //#include "Global.h" //#include "NetworkConfig.h" -#include "rsharesettings.h" -#include "util/audiodevicehelper.h" +#include "audiodevicehelper.h" #include "AudioWizard.h" +#include "rsvoip.h" #define iroundf(x) ( static_cast(x) ) @@ -83,9 +83,9 @@ void AudioInputConfig::load() } qcbSystem->setEnabled(qcbSystem->count() > 1);*/ - ui.qcbTransmit->addItem(tr("Continuous"), RshareSettings::AudioTransmitContinous); - ui.qcbTransmit->addItem(tr("Voice Activity"), RshareSettings::AudioTransmitVAD); - ui.qcbTransmit->addItem(tr("Push To Talk"), RshareSettings::AudioTransmitPushToTalk); + ui.qcbTransmit->addItem(tr("Continuous"), RsVoip::AudioTransmitContinous); + ui.qcbTransmit->addItem(tr("Voice Activity"), RsVoip::AudioTransmitVAD); + ui.qcbTransmit->addItem(tr("Push To Talk"), RsVoip::AudioTransmitPushToTalk); abSpeech = new AudioBar(); abSpeech->qcBelow = Qt::red; @@ -125,26 +125,26 @@ void AudioInputConfig::loadSettings() { loadSlider(qsTransmitMax, iroundf(r.fVADmax * 32767.0f + 0.5f)); loadSlider(qsFrames, (r.iFramesPerPacket == 1) ? 1 : (r.iFramesPerPacket/2 + 1)); loadSlider(qsDoublePush, iroundf(static_cast(r.uiDoublePush) / 1000.f + 0.5f));*/ - ui.qcbTransmit->setCurrentIndex(Settings->getVoipATransmit()-1); - on_qcbTransmit_currentIndexChanged(Settings->getVoipATransmit()-1); - ui.qsTransmitHold->setValue(Settings->getVoipVoiceHold()); - on_qsTransmitHold_valueChanged(Settings->getVoipVoiceHold()); - ui.qsTransmitMin->setValue(Settings->getVoipfVADmin()); - ui.qsTransmitMax->setValue(Settings->getVoipfVADmax()); - ui.qcbEchoCancel->setChecked(Settings->getVoipEchoCancel()); + ui.qcbTransmit->setCurrentIndex(rsVoip->getVoipATransmit()-1); + on_qcbTransmit_currentIndexChanged(rsVoip->getVoipATransmit()-1); + 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()); //ui.qsDoublePush->setValue(iroundf(static_cast(r.uiDoublePush) / 1000.f + 0.5f)); //loadCheckBox(qcbPushClick, r.bPushClick); //loadSlider(qsQuality, r.iQuality); - if (Settings->getVoipiNoiseSuppress() != 0) - ui.qsNoise->setValue(-Settings->getVoipiNoiseSuppress()); + if (rsVoip->getVoipiNoiseSuppress() != 0) + ui.qsNoise->setValue(-rsVoip->getVoipiNoiseSuppress()); else ui.qsNoise->setValue(14); - on_qsNoise_valueChanged(-Settings->getVoipiNoiseSuppress()); + on_qsNoise_valueChanged(-rsVoip->getVoipiNoiseSuppress()); - ui.qsAmp->setValue(20000 - Settings->getVoipiMinLoudness()); - on_qsAmp_valueChanged(20000 - Settings->getVoipiMinLoudness()); + ui.qsAmp->setValue(20000 - rsVoip->getVoipiMinLoudness()); + on_qsAmp_valueChanged(20000 - rsVoip->getVoipiMinLoudness()); //loadSlider(qsIdle, r.iIdleTime); /*int echo = 0; @@ -161,14 +161,14 @@ void AudioInputConfig::loadSettings() { bool AudioInputConfig::save(QString &/*errmsg*/) {//mainly useless beacause saving occurs in realtime //s.iQuality = qsQuality->value(); - Settings->setVoipiNoiseSuppress((ui.qsNoise->value() == 14) ? 0 : - ui.qsNoise->value()); - Settings->setVoipiMinLoudness(20000 - ui.qsAmp->value()); - Settings->setVoipVoiceHold(ui.qsTransmitHold->value()); - Settings->setVoipfVADmin(ui.qsTransmitMin->value()); - Settings->setVoipfVADmax(ui.qsTransmitMax->value()); + 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()); /*s.uiDoublePush = qsDoublePush->value() * 1000;*/ - Settings->setVoipATransmit(static_cast(ui.qcbTransmit->currentIndex() + 1)); - Settings->setVoipEchoCancel(ui.qcbEchoCancel->isChecked()); + rsVoip->setVoipATransmit(static_cast(ui.qcbTransmit->currentIndex() + 1)); + rsVoip->setVoipEchoCancel(ui.qcbEchoCancel->isChecked()); return true; } @@ -191,7 +191,7 @@ void AudioInputConfig::on_qsTransmitHold_valueChanged(int v) { float val = static_cast(v * FRAME_SIZE); val = val / SAMPLING_RATE; ui.qlTransmitHold->setText(tr("%1 s").arg(val, 0, 'f', 2)); - Settings->setVoipVoiceHold(v); + rsVoip->setVoipVoiceHold(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->setPalette(pal); - Settings->setVoipiNoiseSuppress(- ui.qsNoise->value()); + rsVoip->setVoipiNoiseSuppress(- ui.qsNoise->value()); } void AudioInputConfig::on_qsAmp_valueChanged(int v) { v = 20000 - v; float d = 20000.0f/static_cast(v); 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() { - Settings->setVoipEchoCancel(ui.qcbEchoCancel->isChecked()); + rsVoip->setVoipEchoCancel(ui.qcbEchoCancel->isChecked()); } @@ -232,7 +232,7 @@ void AudioInputConfig::on_qcbTransmit_currentIndexChanged(int v) { break; } if (loaded) - Settings->setVoipATransmit(static_cast(ui.qcbTransmit->currentIndex() + 1)); + rsVoip->setVoipATransmit(static_cast(ui.qcbTransmit->currentIndex() + 1)); } @@ -251,8 +251,8 @@ void AudioInputConfig::on_Tick_timeout() { abSpeech->iBelow = ui.qsTransmitMin->value(); abSpeech->iAbove = ui.qsTransmitMax->value(); if (loaded) { - Settings->setVoipfVADmin(ui.qsTransmitMin->value()); - Settings->setVoipfVADmax(ui.qsTransmitMax->value()); + rsVoip->setVoipfVADmin(ui.qsTransmitMin->value()); + rsVoip->setVoipfVADmax(ui.qsTransmitMax->value()); } abSpeech->iValue = iroundf(inputProcessor->dVoiceAcivityLevel * 32767.0f + 0.5f); diff --git a/plugins/VOIP/AudioInputConfig.h b/plugins/VOIP/AudioInputConfig.h index 7cf98dff0..8ca757763 100644 --- a/plugins/VOIP/AudioInputConfig.h +++ b/plugins/VOIP/AudioInputConfig.h @@ -34,49 +34,54 @@ #include #include -#include "configpage.h" +#include "retroshare-gui/configpage.h" + #include "ui_AudioInputConfig.h" -#include "util/SpeexProcessor.h" +#include "SpeexProcessor.h" #include "AudioStats.h" -class AudioInputConfig : public ConfigPage { - Q_OBJECT +class AudioInputConfig : public ConfigPage +{ + Q_OBJECT - private: - Ui::AudioInput ui; - QAudioInput* inputDevice; - QtSpeex::SpeexInputProcessor* inputProcessor; - AudioBar* abSpeech; - bool loaded; + private: + Ui::AudioInput ui; + QAudioInput* inputDevice; + QtSpeex::SpeexInputProcessor* inputProcessor; + AudioBar* abSpeech; + bool loaded; - protected: - QTimer *qtTick; - /*void hideEvent(QHideEvent *event); - void showEvent(QShowEvent *event);*/ + protected: + QTimer *qtTick; + /*void hideEvent(QHideEvent *event); + void showEvent(QShowEvent *event);*/ public: - /** Default Constructor */ - AudioInputConfig(QWidget * parent = 0, Qt::WFlags flags = 0); - /** Default Destructor */ - ~AudioInputConfig(); + /** Default Constructor */ + AudioInputConfig(QWidget * parent = 0, Qt::WFlags flags = 0); + /** Default Destructor */ + ~AudioInputConfig(); - /** Saves the changes on this page */ - bool save(QString &errmsg); - /** Loads the settings for this page */ - void load(); + /** Saves the changes on this page */ + virtual bool save(QString &errmsg); + /** Loads the settings for this page */ + virtual void load(); - private slots: - void loadSettings(); - void emptyBuffer(); + virtual QPixmap iconPixmap() const { return QPixmap(":/images/talking_on.svg") ; } + virtual QString pageName() const { return tr("VOIP") ; } - void on_qsTransmitHold_valueChanged(int v); - void on_qsAmp_valueChanged(int v); - void on_qsNoise_valueChanged(int v); - void on_qcbTransmit_currentIndexChanged(int v); - void on_Tick_timeout(); - void on_qpbAudioWizard_clicked(); - void on_qcbEchoCancel_clicked(); + private slots: + void loadSettings(); + void emptyBuffer(); + + void on_qsTransmitHold_valueChanged(int v); + void on_qsAmp_valueChanged(int v); + 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 diff --git a/plugins/VOIP/AudioWizard.cpp b/plugins/VOIP/AudioWizard.cpp index 8bfe8e195..efd51d2b7 100644 --- a/plugins/VOIP/AudioWizard.cpp +++ b/plugins/VOIP/AudioWizard.cpp @@ -34,8 +34,8 @@ //#include "Settings.h" //#include "Log.h" //#include "MainWindow.h" -#include "gui/settings/rsharesettings.h" #include "audiodevicehelper.h" +#include "rsvoip.h" #define iroundf(x) ( static_cast(x) ) @@ -70,9 +70,9 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) { verticalLayout_3->addWidget(abAmplify); - if (Settings->getVoipATransmit() == RshareSettings::AudioTransmitPushToTalk) + if (rsVoip->getVoipATransmit() == RsVoip::AudioTransmitPushToTalk) qrPTT->setChecked(true); - else if (Settings->getVoipATransmit() == RshareSettings::AudioTransmitVAD) + else if (rsVoip->getVoipATransmit() == RsVoip::AudioTransmitVAD) qrVAD->setChecked(true); else qrContinuous->setChecked(true); @@ -82,13 +82,13 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) { abVAD->qcInside = Qt::yellow; abVAD->qcAbove = Qt::green; - qsTransmitMin->setValue(Settings->getVoipfVADmin()); - qsTransmitMax->setValue(Settings->getVoipfVADmax()); + qsTransmitMin->setValue(rsVoip->getVoipfVADmin()); + qsTransmitMax->setValue(rsVoip->getVoipfVADmax()); verticalLayout_6->addWidget(abVAD); // Volume - qsMaxAmp->setValue(Settings->getVoipiMinLoudness()); + qsMaxAmp->setValue(rsVoip->getVoipiMinLoudness()); setOption(QWizard::NoCancelButton, false); resize(700, 500); @@ -130,7 +130,7 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) { void AudioWizard::on_qsMaxAmp_valueChanged(int v) { - Settings->setVoipiMinLoudness(qMin(v, 30000)); + rsVoip->setVoipiMinLoudness(qMin(v, 30000)); } void AudioWizard::on_Ticker_timeout() { @@ -158,8 +158,8 @@ void AudioWizard::on_Ticker_timeout() { abVAD->iBelow = qsTransmitMin->value(); abVAD->iAbove = qsTransmitMax->value(); - Settings->setVoipfVADmin(qsTransmitMin->value()); - Settings->setVoipfVADmax(qsTransmitMax->value()); + rsVoip->setVoipfVADmin(qsTransmitMin->value()); + rsVoip->setVoipfVADmax(qsTransmitMax->value()); 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) { if (! bInit) { - Settings->setVoipfVADmax(v); + rsVoip->setVoipfVADmax(v); } } void AudioWizard::on_qsTransmitMin_valueChanged(int v) { if (! bInit) { - Settings->setVoipfVADmin(v); + rsVoip->setVoipfVADmin(v); } } void AudioWizard::on_qrVAD_clicked(bool on) { if (on) { - Settings->setVoipATransmit(RshareSettings::AudioTransmitVAD); + rsVoip->setVoipATransmit(RsVoip::AudioTransmitVAD); updateTriggerWidgets(true); bTransmitChanged = true; } @@ -234,7 +234,7 @@ void AudioWizard::on_qrVAD_clicked(bool on) { void AudioWizard::on_qrPTT_clicked(bool on) { if (on) { - Settings->setVoipATransmit(RshareSettings::AudioTransmitPushToTalk); + rsVoip->setVoipATransmit(RsVoip::AudioTransmitPushToTalk); updateTriggerWidgets(false); bTransmitChanged = true; } @@ -242,7 +242,7 @@ void AudioWizard::on_qrPTT_clicked(bool on) { void AudioWizard::on_qrContinuous_clicked(bool on) { if (on) { - Settings->setVoipATransmit(RshareSettings::AudioTransmitContinous); + rsVoip->setVoipATransmit(RsVoip::AudioTransmitContinous); updateTriggerWidgets(false); bTransmitChanged = true; } diff --git a/plugins/VOIP/SpeexProcessor.cpp b/plugins/VOIP/SpeexProcessor.cpp index ab148afe3..6fb93d9d9 100644 --- a/plugins/VOIP/SpeexProcessor.cpp +++ b/plugins/VOIP/SpeexProcessor.cpp @@ -10,7 +10,10 @@ #include #include #include -#include "gui/settings/rsharesettings.h" + +#include "rsvoip.h" + +//#include "gui/settings/rsharesettings.h" #define iroundf(x) ( static_cast(x) ) @@ -160,7 +163,7 @@ qint64 SpeexInputProcessor::writeData(const char *data, qint64 maxSize) { iArg = -60; 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); if (echo_state) { @@ -172,18 +175,18 @@ qint64 SpeexInputProcessor::writeData(const char *data, qint64 maxSize) { bResetProcessor = false; } - float v = 30000.0f / static_cast(Settings->getVoipiMinLoudness()); + float v = 30000.0f / static_cast(rsVoip->getVoipiMinLoudness()); iArg = iroundf(floorf(20.0f * log10f(v))); speex_preprocess_ctl(preprocessor, SPEEX_PREPROCESS_SET_AGC_MAX_GAIN, &iArg); speex_preprocess_ctl(preprocessor, SPEEX_PREPROCESS_GET_AGC_GAIN, &iArg); float gainValue = static_cast(iArg); - iArg = Settings->getVoipiNoiseSuppress() - iArg; + iArg = rsVoip->getVoipiNoiseSuppress() - iArg; speex_preprocess_ctl(preprocessor, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &iArg); short * psSource = psMic; - if (echo_state && Settings->getVoipEchoCancel()) { + if (echo_state && rsVoip->getVoipEchoCancel()) { speex_echo_playback(echo_state, (short*)lastEchoFrame->data()); speex_echo_capture(echo_state,psMic,psClean); psSource = psClean; @@ -207,29 +210,29 @@ qint64 SpeexInputProcessor::writeData(const char *data, qint64 maxSize) { bool bIsSpeech = false; - if (dVoiceAcivityLevel > (static_cast(Settings->getVoipfVADmax()) / 32767)) + if (dVoiceAcivityLevel > (static_cast(rsVoip->getVoipfVADmax()) / 32767)) bIsSpeech = true; - else if (dVoiceAcivityLevel > (static_cast(Settings->getVoipfVADmin()) / 32767) && bPreviousVoice) + else if (dVoiceAcivityLevel > (static_cast(rsVoip->getVoipfVADmin()) / 32767) && bPreviousVoice) bIsSpeech = true; if (! bIsSpeech) { iHoldFrames++; - if (iHoldFrames < Settings->getVoipVoiceHold()) + if (iHoldFrames < rsVoip->getVoipVoiceHold()) bIsSpeech = true; } else { iHoldFrames = 0; } - if (Settings->getVoipATransmit() == RshareSettings::AudioTransmitContinous) { + if (rsVoip->getVoipATransmit() == RsVoip::AudioTransmitContinous) { 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 = 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; }*/ @@ -241,11 +244,11 @@ qint64 SpeexInputProcessor::writeData(const char *data, qint64 maxSize) { /*if (p) { if (! bIsSpeech) - p->setTalking(Settings::Passive); + p->setTalking(RsVoip::Passive); else if (g.iTarget == 0) - p->setTalking(Settings::Talking); + p->setTalking(RsVoip::Talking); 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; //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. - 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 } else {//maybe we can do vbr for ppt and continuous vbr_on = 1; @@ -365,7 +368,7 @@ bool SpeexInputProcessor::isSequential() const { } void SpeexInputProcessor::addEchoFrame(QByteArray* echo_frame) { - if (Settings->getVoipEchoCancel() && echo_frame) { + if (rsVoip->getVoipEchoCancel() && echo_frame) { QMutexLocker l(&qmSpeex); lastEchoFrame = echo_frame; if (!echo_state) {//init echo_state diff --git a/plugins/VOIP/VOIP.pro b/plugins/VOIP/VOIP.pro index 035a23689..c5c2ade99 100644 --- a/plugins/VOIP/VOIP.pro +++ b/plugins/VOIP/VOIP.pro @@ -5,7 +5,7 @@ CONFIG += mobility QT += 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 FORMS = AudioInputConfig.ui AudioStats.ui AudioWizard.ui diff --git a/plugins/VOIP/VOIPPlugin.cpp b/plugins/VOIP/VOIPPlugin.cpp new file mode 100644 index 000000000..161607602 --- /dev/null +++ b/plugins/VOIP/VOIPPlugin.cpp @@ -0,0 +1,87 @@ +#include +#include +#include + +#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; +} + + diff --git a/plugins/VOIP/VOIPPlugin.h b/plugins/VOIP/VOIPPlugin.h index d78a40f37..5befc793f 100644 --- a/plugins/VOIP/VOIPPlugin.h +++ b/plugins/VOIP/VOIPPlugin.h @@ -14,6 +14,7 @@ class VOIPPlugin: public RsPlugin virtual MainPage *qt_page() const ; virtual QIcon *qt_icon() const ; 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; @@ -27,10 +28,9 @@ class VOIPPlugin: public RsPlugin virtual void setInterfaces(RsPlugInInterfaces& interfaces); private: - mutable p3Voip *mVoip ; + mutable p3VoipService *mVoip ; mutable RsPluginHandler *mPlugInHandler; mutable RsPeers* mPeers; - mutable MainPage* mainpage ; - mutable QIcon* mIcon ; + mutable ConfigPage *config_page ; }; diff --git a/plugins/VOIP/p3Voip.h b/plugins/VOIP/p3Voip.h index c9f6a872c..cf27aa04a 100644 --- a/plugins/VOIP/p3Voip.h +++ b/plugins/VOIP/p3Voip.h @@ -31,6 +31,8 @@ #include "serialiser/rsmsgitems.h" #include "services/p3service.h" #include "retroshare/rsmsgs.h" +#include "plugins/rspqiservice.h" +#include "rsvoip.h" //!The basic VOIP service. @@ -47,17 +49,37 @@ class p3VoipService: public RsPQIService, public RsVoip * : notifyCustomState, notifyChatStatus, notifyPeerHasNewAvatar * @see NotifyBase */ - virtual int tick(); + virtual void tick(); virtual int status(); - /*************** pqiMonitor callback ***********************/ - virtual void statusChange(const std::list &plist); + // /*************** pqiMonitor callback ***********************/ + // virtual void statusChange(const std::list &plist); /*! * public chat sent to all peers */ 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: /************* from p3Config *******************/ virtual RsSerialiser *setupSerialiser() ; diff --git a/plugins/VOIP/rsvoip.h b/plugins/VOIP/rsvoip.h new file mode 100644 index 000000000..1f75584ff --- /dev/null +++ b/plugins/VOIP/rsvoip.h @@ -0,0 +1,37 @@ +// interface class for p3Voip service +// + +#pragma once + +#include + +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 ; +};