Reactivate SoundEvents in VOIP.

Let some stuff for soundManager, like don't play mutli
times the same event in same moment.
For that I added lastTimePlayOccurs.
This commit is contained in:
Phenom 2015-10-12 18:25:03 +02:00
parent 86b47d818b
commit 3d32fab56f
3 changed files with 56 additions and 14 deletions

View File

@ -20,6 +20,7 @@
****************************************************************/
#include <retroshare/rsplugin.h>
#include <retroshare/rsversion.h>
#include <retroshare/rsinit.h>
#include <retroshare-gui/RsAutoUpdatePage.h>
#include <QTranslator>
#include <QApplication>
@ -213,9 +214,26 @@ QTranslator* VOIPPlugin::qt_translator(QApplication */*app*/, const QString& lan
return NULL;
}
void VOIPPlugin::qt_sound_events(SoundEvents &/*events*/) const
void VOIPPlugin::qt_sound_events(SoundEvents &events) const
{
// events.addEvent(QApplication::translate("VOIP", "VOIP"), QApplication::translate("VOIP", "Incoming call"), VOIP_SOUND_INCOMING_CALL);
QDir baseDir = QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str()) + "/sounds");
events.addEvent(QApplication::translate("VOIP", "VOIP")
, QApplication::translate("VOIP", "Incoming audio call")
, VOIP_SOUND_INCOMING_AUDIO_CALL
, QFileInfo(baseDir, "incomingcall.wav").absoluteFilePath());
events.addEvent(QApplication::translate("VOIP", "VOIP")
, QApplication::translate("VOIP", "Incoming video call")
, VOIP_SOUND_INCOMING_VIDEO_CALL
, QFileInfo(baseDir, "incomingcall.wav").absoluteFilePath());
events.addEvent(QApplication::translate("VOIP", "VOIP")
, QApplication::translate("VOIP", "Outgoing audio call")
, VOIP_SOUND_OUTGOING_AUDIO_CALL
, QFileInfo(baseDir, "outgoingcall.wav").absoluteFilePath());
events.addEvent(QApplication::translate("VOIP", "VOIP")
, QApplication::translate("VOIP", "Outgoing video call")
, VOIP_SOUND_OUTGOING_VIDEO_CALL
, QFileInfo(baseDir, "outgoingcall.wav").absoluteFilePath());
}
ToasterNotify *VOIPPlugin::qt_toasterNotify(){

View File

@ -18,23 +18,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
//C++
#include <time.h>
//Qt
#include <QIcon>
#include <QLayout>
#include <QPropertyAnimation>
#include <QToolButton>
//VOIP
#include <gui/audiodevicehelper.h>
#include "interface/rsVOIP.h"
#include "VOIPChatWidgetHolder.h"
#include "VideoProcessor.h"
#include "QVideoDevice.h"
//retroshare GUI
#include "gui/SoundManager.h"
#include "util/HandleRichText.h"
#include "gui/common/StatusDefs.h"
#include "gui/chat/ChatWidget.h"
#include "VOIPChatWidgetHolder.h"
#include "VideoProcessor.h"
#include "QVideoDevice.h"
//libretroshare
#include <retroshare/rsstatus.h>
#include <retroshare/rspeers.h>
@ -311,6 +313,8 @@ VOIPChatWidgetHolder::VOIPChatWidgetHolder(ChatWidget *chatWidget, VOIPNotify *n
timerVideoRing->setInterval(300);
timerVideoRing->setSingleShot(true);
connect(timerVideoRing, SIGNAL(timeout()), this, SLOT(timerVideoRingTimeOut()));
lastTimePlayOccurs = time(NULL);
}
VOIPChatWidgetHolder::~VOIPChatWidgetHolder()
@ -1063,6 +1067,11 @@ void VOIPChatWidgetHolder::timerAudioRingTimeOut()
pbAudioRing->setToolTip(tr("Waiting your friend respond your audio call."));
pbAudioRing->setVisible(true);
if (time(NULL) > lastTimePlayOccurs) {
soundManager->play(VOIP_SOUND_OUTGOING_AUDIO_CALL);
lastTimePlayOccurs = time(NULL) + 1;
}
timerAudioRing->start();
} else if(recAudioRingTime >= 0) {
//Receiving
@ -1088,8 +1097,10 @@ void VOIPChatWidgetHolder::timerAudioRingTimeOut()
}
audioCaptureToggleButton->setToolTip(tr("Answer"));
//TODO make a sound for the incoming call
//soundManager->play(VOIP_SOUND_INCOMING_CALL);
if (time(NULL) > lastTimePlayOccurs) {
soundManager->play(VOIP_SOUND_INCOMING_AUDIO_CALL);
lastTimePlayOccurs = time(NULL) + 1;
}
if (mVOIPNotify) mVOIPNotify->notifyReceivedVoipAudioCall(mChatWidget->getChatId().toPeerId());
@ -1114,6 +1125,11 @@ void VOIPChatWidgetHolder::timerVideoRingTimeOut()
pbVideoRing->setToolTip(tr("Waiting your friend respond your video call."));
pbVideoRing->setVisible(true);
if (time(NULL) > lastTimePlayOccurs) {
soundManager->play(VOIP_SOUND_OUTGOING_VIDEO_CALL);
lastTimePlayOccurs = time(NULL) + 1;
}
timerVideoRing->start();
} else if(recVideoRingTime >= 0) {
//Receiving
@ -1139,8 +1155,10 @@ void VOIPChatWidgetHolder::timerVideoRingTimeOut()
}
videoCaptureToggleButton->setToolTip(tr("Answer"));
//TODO make a sound for the incoming call
// soundManager->play(VOIP_SOUND_INCOMING_CALL);
if (time(NULL) > lastTimePlayOccurs) {
soundManager->play(VOIP_SOUND_INCOMING_VIDEO_CALL);
lastTimePlayOccurs = time(NULL) + 1;
}
if (mVOIPNotify) mVOIPNotify->notifyReceivedVoipVideoCall(mChatWidget->getChatId().toPeerId());

View File

@ -40,7 +40,10 @@ class QVideoInputDevice ;
class QVideoOutputDevice ;
class VideoProcessor ;
#define VOIP_SOUND_INCOMING_CALL "VOIP_incoming_call"
#define VOIP_SOUND_INCOMING_AUDIO_CALL "VOIP_incoming_audio_call"
#define VOIP_SOUND_INCOMING_VIDEO_CALL "VOIP_incoming_video_call"
#define VOIP_SOUND_OUTGOING_AUDIO_CALL "VOIP_outgoing_audio_call"
#define VOIP_SOUND_OUTGOING_VIDEO_CALL "VOIP_outgoing_video_call"
class VOIPChatWidgetHolder : public QObject, public ChatWidgetHolder
{
@ -145,6 +148,9 @@ protected:
int recAudioRingTime; //(-2 connected, -1 reseted, >=0 in progress)
int recVideoRingTime; //(-2 connected, -1 reseted, >=0 in progress)
//TODO, remove this when soundManager can manage multi events.
int lastTimePlayOccurs;
VOIPNotify *mVOIPNotify;
};