added toasters for incoming audio/video call to voip plugin (patch from Phenom)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8295 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
electron128 2015-05-26 15:19:57 +00:00
parent c1061a1e9d
commit cee1819b7d
28 changed files with 2699 additions and 1710 deletions

View file

@ -45,7 +45,9 @@ SOURCES = VOIPPlugin.cpp \
gui/QVideoDevice.cpp \
gui/VOIPChatWidgetHolder.cpp \
gui/VOIPGUIHandler.cpp \
gui/VOIPNotify.cpp
gui/VOIPNotify.cpp \
gui/VOIPToasterItem.cpp \
gui/VOIPToasterNotify.cpp
HEADERS = VOIPPlugin.h \
services/p3VOIP.h \
@ -60,11 +62,14 @@ HEADERS = VOIPPlugin.h \
gui/VOIPChatWidgetHolder.h \
gui/VOIPGUIHandler.h \
gui/VOIPNotify.h \
gui/VOIPToasterItem.h \
gui/VOIPToasterNotify.h \
interface/rsVOIP.h
FORMS = gui/AudioInputConfig.ui \
gui/AudioStats.ui \
gui/AudioWizard.ui
gui/AudioWizard.ui \
gui/VOIPToasterItem.ui
TARGET = VOIP

View file

@ -78,20 +78,22 @@ void VOIPPlugin::getPluginVersion(int& major, int& minor, int& build, int& svn_r
VOIPPlugin::VOIPPlugin()
{
qRegisterMetaType<RsPeerId>("RsPeerId");
mVOIP = NULL ;
mPlugInHandler = NULL;
mPeers = NULL;
config_page = NULL ;
mIcon = NULL ;
mVOIPToasterNotify = NULL ;
mVOIPGUIHandler = new VOIPGUIHandler ;
mVOIPNotify = new VOIPNotify ;
QObject::connect(mVOIPNotify,SIGNAL(voipInvitationReceived(const QString&)),mVOIPGUIHandler,SLOT(ReceivedInvitation(const QString&)),Qt::QueuedConnection) ;
QObject::connect(mVOIPNotify,SIGNAL(voipDataReceived(const QString&)),mVOIPGUIHandler,SLOT(ReceivedVoipData(const QString&)),Qt::QueuedConnection) ;
QObject::connect(mVOIPNotify,SIGNAL(voipAcceptReceived(const QString&)),mVOIPGUIHandler,SLOT(ReceivedVoipAccept(const QString&)),Qt::QueuedConnection) ;
QObject::connect(mVOIPNotify,SIGNAL(voipHangUpReceived(const QString&)),mVOIPGUIHandler,SLOT(ReceivedVoipHangUp(const QString&)),Qt::QueuedConnection) ;
QObject::connect(mVOIPNotify,SIGNAL(voipBandwidthInfoReceived(const QString&,int)),mVOIPGUIHandler,SLOT(ReceivedVoipBandwidthInfo(const QString&,int)),Qt::QueuedConnection) ;
QObject::connect(mVOIPNotify,SIGNAL(voipInvitationReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedInvitation(const RsPeerId&)),Qt::QueuedConnection) ;
QObject::connect(mVOIPNotify,SIGNAL(voipDataReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedVoipData(const RsPeerId&)),Qt::QueuedConnection) ;
QObject::connect(mVOIPNotify,SIGNAL(voipAcceptReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedVoipAccept(const RsPeerId&)),Qt::QueuedConnection) ;
QObject::connect(mVOIPNotify,SIGNAL(voipHangUpReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedVoipHangUp(const RsPeerId&)),Qt::QueuedConnection) ;
QObject::connect(mVOIPNotify,SIGNAL(voipBandwidthInfoReceived(const RsPeerId&,int)),mVOIPGUIHandler,SLOT(ReceivedVoipBandwidthInfo(const RsPeerId&,int)),Qt::QueuedConnection) ;
}
void VOIPPlugin::setInterfaces(RsPlugInInterfaces &interfaces)
@ -135,7 +137,7 @@ ChatWidgetHolder *VOIPPlugin::qt_get_chat_widget_holder(ChatWidget *chatWidget)
{
switch (chatWidget->chatType()) {
case ChatWidget::CHATTYPE_PRIVATE:
return new VOIPChatWidgetHolder(chatWidget);
return new VOIPChatWidgetHolder(chatWidget, mVOIPNotify);
case ChatWidget::CHATTYPE_UNKNOWN:
case ChatWidget::CHATTYPE_LOBBY:
case ChatWidget::CHATTYPE_DISTANT:
@ -201,3 +203,10 @@ void VOIPPlugin::qt_sound_events(SoundEvents &/*events*/) const
{
// events.addEvent(QApplication::translate("VOIP", "VOIP"), QApplication::translate("VOIP", "Incoming call"), VOIP_SOUND_INCOMING_CALL);
}
ToasterNotify *VOIPPlugin::qt_toasterNotify(){
if (!mVOIPToasterNotify) {
mVOIPToasterNotify = new VOIPToasterNotify(mVOIP, mVOIPNotify);
}
return mVOIPToasterNotify;
}

View file

@ -20,9 +20,13 @@
****************************************************************/
#pragma once
#include <retroshare/rsplugin.h>
/*VOIP*/
#include "gui/VOIPToasterNotify.h"
#include "services/p3VOIP.h"
/*libretroshare"*/
#include <retroshare/rsplugin.h>
class VOIPGUIHandler ;
class VOIPNotify ;
@ -51,6 +55,9 @@ class VOIPPlugin: public RsPlugin
virtual std::string getPluginName() const;
virtual void setInterfaces(RsPlugInInterfaces& interfaces);
//================================== RsPlugin Notify ==================================//
virtual ToasterNotify *qt_toasterNotify();
private:
mutable p3VOIP *mVOIP ;
mutable RsPluginHandler *mPlugInHandler;
@ -60,5 +67,6 @@ class VOIPPlugin: public RsPlugin
VOIPNotify *mVOIPNotify ;
VOIPGUIHandler *mVOIPGUIHandler ;
VOIPToasterNotify *mVOIPToasterNotify ;
};

View file

@ -1,46 +0,0 @@
/*
* RetroShare
* Copyright (C) 2012 RetroShare Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "CallToaster.h"
#include "gui/chat/ChatDialog.h"
#include <retroshare/rspeers.h>
CallToaster::CallToaster(const RsPeerId &peerId) : QWidget(NULL)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
this->peerId = peerId;
/* connect buttons */
connect(ui.toasterButton, SIGNAL(clicked()), SLOT(chatButtonSlot()));
connect(ui.closeButton, SIGNAL(clicked()), SLOT(hide()));
/* set informations */
ui.textLabel->setText(QString::fromUtf8(rsPeers->getPeerName(peerId).c_str()));
ui.avatarWidget->setFrameType(AvatarWidget::STATUS_FRAME);
ui.avatarWidget->setId(peerId);
}
void CallToaster::chatButtonSlot()
{
ChatDialog::chatFriend(peerId);
hide();
}

View file

@ -1,47 +0,0 @@
/*
* RetroShare
* Copyright (C) 2013 RetroShare Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef CALLTOASTER_H
#define CALLTOASTER_H
#include "ui_CallToaster.h"
/**
* Shows a toaster when friend is Calling you .
*
*
*/
class CallToaster : public QWidget
{
Q_OBJECT
public:
CallToaster(const RsPeerId &peerId);
private slots:
void chatButtonSlot();
private:
RsPeerId peerId;
/** Qt Designer generated object */
Ui::CallToaster ui;
};
#endif //MESSAGETOASTER_H

View file

@ -41,8 +41,8 @@
#define CALL_HOLD ":/images/call-hold.png"
VOIPChatWidgetHolder::VOIPChatWidgetHolder(ChatWidget *chatWidget)
: QObject(), ChatWidgetHolder(chatWidget)
VOIPChatWidgetHolder::VOIPChatWidgetHolder(ChatWidget *chatWidget, VOIPNotify *notify)
: QObject(), ChatWidgetHolder(chatWidget), mVOIPNotify(notify)
{
QIcon icon ;
icon.addPixmap(QPixmap(":/images/audio-volume-muted.png")) ;
@ -284,12 +284,11 @@ void VOIPChatWidgetHolder::toggleVideoCapture()
}
}
void VOIPChatWidgetHolder::addVideoData(const QString name, QByteArray* array)
void VOIPChatWidgetHolder::addVideoData(const RsPeerId &peer_id, QByteArray* array)
{
outputVideoProcessor->receiveEncodedData((unsigned char *)array->data(),array->size()) ;
if (!videoCaptureToggleButton->isChecked()) {
if (mChatWidget) {
QString buttonName = name;
QString buttonName = QString::fromStdString(peer_id.toStdString());
if (buttonName.isEmpty()) buttonName = "VoIP";//TODO maybe change all with GxsId
button_map::iterator it = buttonMapTakeVideo.find(buttonName);
if (it == buttonMapTakeVideo.end()){
@ -315,6 +314,13 @@ void VOIPChatWidgetHolder::addVideoData(const QString name, QByteArray* array)
buttonMapTakeVideo.insert(buttonName, button);
}
}
//TODO make a sound for the incoming call
// soundManager->play(VOIP_SOUND_INCOMING_CALL);
if (mVOIPNotify) mVOIPNotify->notifyReceivedVoipVideoCall(peer_id);
} else {
outputVideoProcessor->receiveEncodedData((unsigned char *)array->data(),array->size()) ;
}
}
@ -350,12 +356,12 @@ void VOIPChatWidgetHolder::botMouseLeave()
}
}
void VOIPChatWidgetHolder::setAcceptedBandwidth(const QString name, uint32_t bytes_per_sec)
void VOIPChatWidgetHolder::setAcceptedBandwidth(uint32_t bytes_per_sec)
{
inputVideoProcessor->setMaximumFrameRate(bytes_per_sec) ;
}
void VOIPChatWidgetHolder::addAudioData(const QString name, QByteArray* array)
void VOIPChatWidgetHolder::addAudioData(const RsPeerId &peer_id, QByteArray* array)
{
if (!audioCaptureToggleButton->isChecked()) {
//launch an animation. Don't launch it if already animating
@ -374,7 +380,7 @@ void VOIPChatWidgetHolder::addAudioData(const QString name, QByteArray* array)
}
if (mChatWidget) {
QString buttonName = name;
QString buttonName = QString::fromStdString(peer_id.toStdString());
if (buttonName.isEmpty()) buttonName = "VoIP";//TODO maybe change all with GxsId
button_map::iterator it = buttonMapTakeVideo.find(buttonName);
if (it == buttonMapTakeVideo.end()){
@ -402,11 +408,12 @@ void VOIPChatWidgetHolder::addAudioData(const QString name, QByteArray* array)
}
}
// soundManager->play(VOIP_SOUND_INCOMING_CALL);
audioCaptureToggleButton->setToolTip(tr("Answer"));
//TODO make a toaster and a sound for the incoming call
//TODO make a sound for the incoming call
// soundManager->play(VOIP_SOUND_INCOMING_CALL);
if (mVOIPNotify) mVOIPNotify->notifyReceivedVoipAudioCall(peer_id);
return;
}
@ -432,7 +439,7 @@ void VOIPChatWidgetHolder::addAudioData(const QString name, QByteArray* array)
outputAudioDevice->setBufferSize(20);
outputAudioDevice->start(outputAudioProcessor);
}
outputAudioProcessor->putNetworkPacket(name, *array);
outputAudioProcessor->putNetworkPacket(QString::fromStdString(peer_id.toStdString()), *array);
//check the input device for errors
if (inputAudioDevice && inputAudioDevice->error() != QAudio::NoError) {

View file

@ -21,6 +21,8 @@
#pragma once
#include "gui/VOIPNotify.h"
#include <QObject>
#include <QGraphicsEffect>
#include <gui/SpeexProcessor.h>
@ -42,29 +44,29 @@ class VOIPChatWidgetHolder : public QObject, public ChatWidgetHolder
Q_OBJECT
public:
VOIPChatWidgetHolder(ChatWidget *chatWidget);
VOIPChatWidgetHolder(ChatWidget *chatWidget, VOIPNotify *notify);
virtual ~VOIPChatWidgetHolder();
virtual void updateStatus(int status);
void addAudioData(const QString name, QByteArray* array) ;
void addVideoData(const QString name, QByteArray* array) ;
void setAcceptedBandwidth(const QString name, uint32_t bytes_per_sec) ;
void addAudioData(const RsPeerId &peer_id, QByteArray* array) ;
void addVideoData(const RsPeerId &peer_id, QByteArray* array) ;
void setAcceptedBandwidth(uint32_t bytes_per_sec) ;
public slots:
void sendAudioData();
void sendVideoData();
void startAudioCapture();
void startVideoCapture();
private slots:
void toggleAudioListen();
void toggleAudioCapture();
void toggleVideoCapture();
void startVideoCapture();
void startAudioCapture();
void hangupCall() ;
void botMouseEnter();
void botMouseLeave();
public slots:
void sendAudioData();
void sendVideoData();
protected:
// Audio input/output
QAudioInput* inputAudioDevice;
@ -91,5 +93,7 @@ protected:
typedef QMap<QString, RSButtonOnText*> button_map;
button_map buttonMapTakeVideo;
VOIPNotify *mVOIPNotify;
};

View file

@ -21,31 +21,29 @@
#include <iostream>
#include <vector>
#include <list>
#include <interface/rsVOIP.h>
#include "VOIPGUIHandler.h"
#include <gui/chat/ChatDialog.h>
#include <gui/VOIPChatWidgetHolder.h>
#include "gui/chat/ChatWidget.h"
#include "gui/settings/rsharesettings.h"
void VOIPGUIHandler::ReceivedInvitation(const QString& /*peer_id*/)
void VOIPGUIHandler::ReceivedInvitation(const RsPeerId &/*peer_id*/)
{
std::cerr << "****** VOIPGUIHandler: received Invitation!" << std::endl;
}
void VOIPGUIHandler::ReceivedVoipHangUp(const QString& /*peer_id*/)
void VOIPGUIHandler::ReceivedVoipHangUp(const RsPeerId &/*peer_id*/)
{
std::cerr << "****** VOIPGUIHandler: received HangUp!" << std::endl;
}
void VOIPGUIHandler::ReceivedVoipAccept(const QString& /*peer_id*/)
void VOIPGUIHandler::ReceivedVoipAccept(const RsPeerId &/*peer_id*/)
{
std::cerr << "****** VOIPGUIHandler: received VoipAccept!" << std::endl;
}
void VOIPGUIHandler::ReceivedVoipData(const QString& qpeer_id)
void VOIPGUIHandler::ReceivedVoipData(const RsPeerId &peer_id)
{
RsPeerId peer_id(qpeer_id.toStdString()) ;
std::vector<RsVOIPDataChunk> chunks ;
if(!rsVOIP->getIncomingData(peer_id,chunks))
@ -70,9 +68,9 @@ void VOIPGUIHandler::ReceivedVoipData(const QString& qpeer_id)
QByteArray qb(reinterpret_cast<const char *>(chunks[chunkIndex].data),chunks[chunkIndex].size);
if(chunks[chunkIndex].type == RsVOIPDataChunk::RS_VOIP_DATA_TYPE_AUDIO)
acwh->addAudioData(QString::fromStdString(peer_id.toStdString()),&qb);
acwh->addAudioData(peer_id, &qb);
else if(chunks[chunkIndex].type == RsVOIPDataChunk::RS_VOIP_DATA_TYPE_VIDEO)
acwh->addVideoData(QString::fromStdString(peer_id.toStdString()),&qb);
acwh->addVideoData(peer_id, &qb);
else
std::cerr << "VOIPGUIHandler: Unknown data type received. type=" << chunks[chunkIndex].type << std::endl;
}
@ -89,13 +87,11 @@ void VOIPGUIHandler::ReceivedVoipData(const QString& qpeer_id)
}
}
void VOIPGUIHandler::ReceivedVoipBandwidthInfo(const QString& qpeer_id,int bytes_per_sec)
void VOIPGUIHandler::ReceivedVoipBandwidthInfo(const RsPeerId &peer_id, int bytes_per_sec)
{
RsPeerId peer_id(qpeer_id.toStdString()) ;
ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ;
std::cerr << "VOIPGUIHandler::received bw info for peer " << qpeer_id.toStdString() << ": " << bytes_per_sec << " Bps" << std::endl;
std::cerr << "VOIPGUIHandler::received bw info for peer " << peer_id.toStdString() << ": " << bytes_per_sec << " Bps" << std::endl;
if(!di)
{
std::cerr << "VOIPGUIHandler Error: received bandwidth info for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
@ -115,6 +111,50 @@ void VOIPGUIHandler::ReceivedVoipBandwidthInfo(const QString& qpeer_id,int bytes
VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;
if (acwh)
acwh->setAcceptedBandwidth(QString::fromStdString(peer_id.toStdString()),bytes_per_sec);
acwh->setAcceptedBandwidth(bytes_per_sec);
}
}
void VOIPGUIHandler::AnswerAudioCall(const RsPeerId &peer_id)
{
ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ;
if (di) {
ChatWidget *cw = di->getChatWidget();
if(cw) {
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList)
{
VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;
if (acwh)
acwh->startAudioCapture();
}
}
} else {
std::cerr << "VOIPGUIHandler Error: answer audio call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
}
}
void VOIPGUIHandler::AnswerVideoCall(const RsPeerId &peer_id)
{
ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ;
if (di) {
ChatWidget *cw = di->getChatWidget();
if(cw) {
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList)
{
VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;
if (acwh)
acwh->startVideoCapture();
}
}
} else {
std::cerr << "VOIPGUIHandler Error: answer video call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
}
}

View file

@ -28,17 +28,22 @@
#pragma once
#include <interface/rsVOIP.h>
#include <stdint.h>
#include <QObject>
class VOIPGUIHandler: public QObject
{
Q_OBJECT
public:
static void AnswerAudioCall(const RsPeerId &peer_id) ;
static void AnswerVideoCall(const RsPeerId &peer_id) ;
public slots:
void ReceivedInvitation(const QString& peer_id) ;
void ReceivedVoipData(const QString& peer_id) ;
void ReceivedVoipHangUp(const QString& peer_id) ;
void ReceivedVoipAccept(const QString& peer_id) ;
void ReceivedVoipBandwidthInfo(const QString& peer_id,int) ;
void ReceivedInvitation(const RsPeerId &peer_id) ;
void ReceivedVoipData(const RsPeerId &peer_id) ;
void ReceivedVoipHangUp(const RsPeerId &peer_id) ;
void ReceivedVoipAccept(const RsPeerId &peer_id) ;
void ReceivedVoipBandwidthInfo(const RsPeerId &peer_id, int) ;
};

View file

@ -21,23 +21,33 @@
#include "VOIPNotify.h"
void VOIPNotify::notifyReceivedVoipInvite(const RsPeerId& peer_id)
{
emit voipInvitationReceived(QString::fromStdString(peer_id.toStdString())) ;
}
void VOIPNotify::notifyReceivedVoipData(const RsPeerId &peer_id)
{
emit voipDataReceived(QString::fromStdString(peer_id.toStdString())) ;
}
//Call qRegisterMetaType<RsPeerId>("RsPeerId"); to enable these SIGNALs
void VOIPNotify::notifyReceivedVoipAccept(const RsPeerId& peer_id)
{
emit voipAcceptReceived(QString::fromStdString(peer_id.toStdString())) ;
}
void VOIPNotify::notifyReceivedVoipHangUp(const RsPeerId &peer_id)
{
emit voipHangUpReceived(QString::fromStdString(peer_id.toStdString())) ;
emit voipAcceptReceived(peer_id) ;
}
void VOIPNotify::notifyReceivedVoipBandwidth(const RsPeerId &peer_id,uint32_t bytes_per_sec)
{
emit voipBandwidthInfoReceived(QString::fromStdString(peer_id.toStdString()),bytes_per_sec) ;
emit voipBandwidthInfoReceived(peer_id, bytes_per_sec) ;
}
void VOIPNotify::notifyReceivedVoipData(const RsPeerId &peer_id)
{
emit voipDataReceived(peer_id) ;
}
void VOIPNotify::notifyReceivedVoipHangUp(const RsPeerId &peer_id)
{
emit voipHangUpReceived(peer_id) ;
}
void VOIPNotify::notifyReceivedVoipInvite(const RsPeerId& peer_id)
{
emit voipInvitationReceived(peer_id) ;
}
void VOIPNotify::notifyReceivedVoipAudioCall(const RsPeerId &peer_id)
{
emit voipAudioCallReceived(peer_id) ;
}
void VOIPNotify::notifyReceivedVoipVideoCall(const RsPeerId &peer_id)
{
emit voipVideoCallReceived(peer_id) ;
}

View file

@ -28,25 +28,32 @@
#pragma once
#include <QObject>
/*libretroshare*/
#include <retroshare/rstypes.h>
#include <QObject>
class VOIPNotify: public QObject
{
Q_OBJECT
public:
void notifyReceivedVoipData(const RsPeerId& peer_id) ;
void notifyReceivedVoipInvite(const RsPeerId &peer_id) ;
void notifyReceivedVoipHangUp(const RsPeerId& peer_id) ;
void notifyReceivedVoipAccept(const RsPeerId &peer_id) ;
void notifyReceivedVoipBandwidth(const RsPeerId &peer_id,uint32_t bytes_per_sec) ;
void notifyReceivedVoipAccept(const RsPeerId &peer_id) ;
void notifyReceivedVoipBandwidth(const RsPeerId &peer_id, uint32_t bytes_per_sec) ;
void notifyReceivedVoipData(const RsPeerId &peer_id) ;
void notifyReceivedVoipHangUp(const RsPeerId &peer_id) ;
void notifyReceivedVoipInvite(const RsPeerId &peer_id) ;
void notifyReceivedVoipAudioCall(const RsPeerId &peer_id) ;
void notifyReceivedVoipVideoCall(const RsPeerId &peer_id) ;
signals:
void voipInvitationReceived(const QString&) ; // signal emitted when an invitation has been received
void voipDataReceived(const QString&) ; // signal emitted when some voip data has been received
void voipHangUpReceived(const QString& peer_id) ; // emitted when the peer closes the call (i.e. hangs up)
void voipAcceptReceived(const QString& peer_id) ; // emitted when the peer accepts the call
void voipBandwidthInfoReceived(const QString& peer_id,int bytes_per_sec) ; // emitted when measured bandwidth info is received by the peer.
void voipAcceptReceived(const RsPeerId &peer_id) ; // emitted when the peer accepts the call
void voipBandwidthInfoReceived(const RsPeerId &peer_id, int bytes_per_sec) ; // emitted when measured bandwidth info is received by the peer.
void voipDataReceived(const RsPeerId &peer_id) ; // signal emitted when some voip data has been received
void voipHangUpReceived(const RsPeerId &peer_id) ; // emitted when the peer closes the call (i.e. hangs up)
void voipInvitationReceived(const RsPeerId &peer_id) ; // signal emitted when an invitation has been received
void voipAudioCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send audio
void voipVideoCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send video
};

View file

@ -0,0 +1,107 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2015 RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
/*VOIP*/
#include "VOIPToasterItem.h"
#include "VOIPGUIHandler.h"
/*libRetroshare*/
#include <retroshare/rspeers.h>
/*Retroshare-Gui*/
#include "gui/chat/ChatDialog.h"
#include "gui/notifyqt.h"
#include "util/HandleRichText.h"
VOIPToasterItem::VOIPToasterItem(const RsPeerId &peer_id, const QString &msg, const voipToasterItem_Type type)
: QWidget(NULL), mPeerId(peer_id), mMsg(msg), mType(type)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
switch (mType){
case AudioCall:
toasterButton->setIcon(QIcon("://images/call-start.png"));
break;
case VideoCall:
toasterButton->setIcon(QIcon("://images/video-icon-on.png"));
break;
default:
ChatDialog::chatFriend(ChatId(mPeerId));
}
connect(toasterButton, SIGNAL(clicked()), SLOT(chatButtonSlot()));
connect(closeButton, SIGNAL(clicked()), SLOT(hide()));
/* set informations */
textLabel->setText(RsHtml().formatText(NULL, msg, RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_CLEANSTYLE));
toasterLabel->setText(QString::fromUtf8(rsPeers->getPeerName(mPeerId).c_str()));
avatarWidget->setFrameType(AvatarWidget::STATUS_FRAME);
avatarWidget->setId(ChatId(mPeerId));
}
VOIPToasterItem::~VOIPToasterItem()
{
}
void VOIPToasterItem::chatButtonSlot()
{
switch (mType){
case AudioCall:
VOIPGUIHandler::AnswerAudioCall(mPeerId);
break;
case VideoCall:
VOIPGUIHandler::AnswerVideoCall(mPeerId);
break;
default:
ChatDialog::chatFriend(ChatId(mPeerId));
}
hide();
}
void VOIPToasterItem::voipAcceptReceived(const RsPeerId &)
{
}
void VOIPToasterItem::voipBandwidthInfoReceived(const RsPeerId &, int )
{
}
void VOIPToasterItem::voipDataReceived(const RsPeerId &)
{
}
void VOIPToasterItem::voipHangUpReceived(const RsPeerId &)
{
}
void VOIPToasterItem::voipInvitationReceived(const RsPeerId &)
{
}
void VOIPToasterItem::voipAudioCallReceived(const RsPeerId &)
{
}
void VOIPToasterItem::voipVideoCallReceived(const RsPeerId &)
{
}

View file

@ -0,0 +1,61 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2015 RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#pragma once
#include "ui_VOIPToasterItem.h"
#include <QWidget>
class VOIPToasterItem : public QWidget, private Ui::VOIPToasterItem
{
Q_OBJECT
public:
typedef enum{ Accept
, BandwidthInfo
, Data
, HangUp
, Invitation
, AudioCall
, VideoCall
} voipToasterItem_Type;
VOIPToasterItem(const RsPeerId &peer_id, const QString &msg, const voipToasterItem_Type type);
~VOIPToasterItem();
private slots:
void chatButtonSlot();
void voipAcceptReceived(const RsPeerId &peer_id) ; // emitted when the peer accepts the call
void voipBandwidthInfoReceived(const RsPeerId &peer_id, int bytes_per_sec) ; // emitted when measured bandwidth info is received by the peer.
void voipDataReceived(const RsPeerId &peer_id) ; // signal emitted when some voip data has been received
void voipHangUpReceived(const RsPeerId &peer_id) ; // emitted when the peer closes the call (i.e. hangs up)
void voipInvitationReceived(const RsPeerId &peer_id) ; // signal emitted when an invitation has been received
void voipAudioCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send audio
void voipVideoCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send video
private:
RsPeerId mPeerId;
QString mMsg;
voipToasterItem_Type mType;
};

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CallToaster</class>
<widget class="QWidget" name="CallToaster">
<class>VOIPToasterItem</class>
<widget class="QWidget" name="VOIPToasterItem">
<property name="geometry">
<rect>
<x>0</x>
@ -22,27 +22,27 @@
<height>100</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="margin">
<number>0</number>
</property>
<layout class="QHBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="windowFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
<enum>QFrame::WinPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout">
<property name="margin">
<number>1</number>
<number>2</number>
</property>
<property name="spacing">
<number>1</number>
<number>2</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout">
@ -70,7 +70,7 @@
</size>
</property>
<property name="pixmap">
<pixmap>:/images/rstray3.png</pixmap>
<pixmap resource="../images.qrc">:/images/logo/logo_16.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
@ -79,13 +79,6 @@
</item>
<item>
<widget class="QLabel" name="toasterLabel">
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Name</string>
</property>
@ -119,7 +112,7 @@
</size>
</property>
<property name="icon">
<iconset>
<iconset resource="../images.qrc">
<normaloff>:/images/closenormal.png</normaloff>:/images/closenormal.png</iconset>
</property>
<property name="flat">
@ -130,24 +123,18 @@
</layout>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="2">
<widget class="AvatarWidget" name="avatarWidget">
<property name="minimumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>70</height>
</size>
<layout class="QGridLayout">
<property name="spacing">
<number>2</number>
</property>
<item row="0" column="1">
<widget class="QPushButton" name="toasterButton">
<property name="text">
<string>Show Chat</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<item row="1" column="1">
<widget class="QLabel" name="textLabel">
<property name="maximumSize">
<size>
@ -160,48 +147,18 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="toasterButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Answer</string>
</property>
<property name="icon">
<iconset resource="VOIP_images.qrc">
<normaloff>:/images/call-start-22.png</normaloff>:/images/call-start-22.png</iconset>
</property>
<property name="iconSize">
<item row="0" column="0" rowspan="2">
<widget class="AvatarWidget" name="avatarWidget">
<property name="minimumSize">
<size>
<width>22</width>
<height>22</height>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="default">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Decline</string>
</property>
<property name="icon">
<iconset resource="VOIP_images.qrc">
<normaloff>:/images/call-stop-22.png</normaloff>:/images/call-stop-22.png</iconset>
</property>
<property name="iconSize">
<property name="maximumSize">
<size>
<width>22</width>
<height>22</height>
<width>70</width>
<height>70</height>
</size>
</property>
</widget>
@ -222,7 +179,8 @@
</customwidget>
</customwidgets>
<resources>
<include location="VOIP_images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -0,0 +1,401 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2015
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
/*VOIP*/
#include "gui/VOIPToasterNotify.h"
#include "gui/VOIPToasterItem.h"
/*retroshare-gui*/
#include "gui/settings/rsharesettings.h"
#include "gui/toaster/ToasterItem.h"
/*libretroshare*/
#include "retroshare/rspeers.h"
VOIPToasterNotify::VOIPToasterNotify(RsVOIP *VOIP, VOIPNotify *notify, QObject *parent)
: ToasterNotify(parent), mVOIP(VOIP), mVOIPNotify(notify)
{
mMutex = new QMutex();
#ifdef VOIPTOASTERNOTIFY_ALL
connect(mVOIPNotify, SIGNAL(voipAcceptReceived(const RsPeerId&)), this, SLOT(voipAcceptReceived(const RsPeerId&)), Qt::QueuedConnection);
connect(mVOIPNotify, SIGNAL(voipBandwidthInfoReceived(const RsPeerId&, int)), this, SLOT(voipBandwidthInfoReceived(RsPeerId&, int)), Qt::QueuedConnection);
connect(mVOIPNotify, SIGNAL(voipDataReceived(const RsPeerId&)), this, SLOT(voipDataReceived(const RsPeerId&)), Qt::QueuedConnection);
connect(mVOIPNotify, SIGNAL(voipHangUpReceived(const RsPeerId&)), this, SLOT(voipHangUpReceived(const RsPeerId&)), Qt::QueuedConnection);
connect(mVOIPNotify, SIGNAL(voipInvitationReceived(const RsPeerId&)), this, SLOT(voipInvitationReceived(const RsPeerId&)), Qt::QueuedConnection);
#endif
connect(mVOIPNotify, SIGNAL(voipAudioCallReceived(const RsPeerId&)), this, SLOT(voipAudioCallReceived(const RsPeerId&)), Qt::QueuedConnection);
connect(mVOIPNotify, SIGNAL(voipVideoCallReceived(const RsPeerId&)), this, SLOT(voipVideoCallReceived(const RsPeerId&)), Qt::QueuedConnection);
}
VOIPToasterNotify::~VOIPToasterNotify()
{
delete(mMutex);
}
bool VOIPToasterNotify::hasSettings(QString &mainName, QMap<QString, QString> &tagAndTexts)
{
mainName = tr("VOIP");
//gAndTexts.insert("Tag" , tr("Text"));
#ifdef VOIPTOASTERNOTIFY_ALL
tagAndTexts.insert("Accept" , tr("Accept"));
tagAndTexts.insert("BandwidthInfo", tr("Bandwidth Information"));
tagAndTexts.insert("Data" , tr("Audio or Video Data"));
tagAndTexts.insert("HangUp" , tr("HangUp"));
tagAndTexts.insert("Invitation" , tr("Invitation"));
#endif
tagAndTexts.insert("AudioCall" , tr("Audio Call"));
tagAndTexts.insert("VideoCall" , tr("Video Call"));
return true;
}
bool VOIPToasterNotify::notifyEnabled(QString tag)
{
return Settings->valueFromGroup("VOIP", QString("ToasterNotifyEnable").append(tag), false).toBool();
}
void VOIPToasterNotify::setNotifyEnabled(QString tag, bool enabled)
{
Settings->setValueToGroup("VOIP", QString("ToasterNotifyEnable").append(tag), enabled);
if (!enabled) {
/* remove pending Toaster items */
mMutex->lock();
#ifdef VOIPTOASTERNOTIFY_ALL
if(tag == "Accept") mPendingToasterAccept.clear();
if(tag == "BandwidthInfo") mPendingToasterBandwidthInfo.clear();
if(tag == "Data") mPendingToasterData.clear();
if(tag == "HangUp") mPendingToasterHangUp.clear();
if(tag == "Invitation") mPendingToasterInvitation.clear();
#endif
if(tag == "AudioCall") mPendingToasterAudioCall.clear();
if(tag == "VideoCall") mPendingToasterVideoCall.clear();
mMutex->unlock();
}
}
ToasterItem *VOIPToasterNotify::toasterItem()
{
ToasterItem *toasterItem = NULL;
#ifdef VOIPTOASTERNOTIFY_ALL
if (!mPendingToasterAccept.empty() && !toasterItem) {
mMutex->lock();
ToasterItemData toasterItemData = mPendingToasterAccept.takeFirst();
VOIPToasterItem *voipToasterItem = new VOIPToasterItem(toasterItemData.mPeerId, toasterItemData.mMsg, VOIPToasterItem::Accept);
toasterItem= new ToasterItem(voipToasterItem);
connect(toasterItem, SIGNAL(toasterItemDestroyed(ToasterItem*)), this, SLOT(toasterItemDestroyedAccept(ToasterItem*)));
mToasterAccept.insert(toasterItemData.mPeerId, toasterItem);
mMutex->unlock();
}
if (!mPendingToasterBandwidthInfo.empty() && !toasterItem) {
mMutex->lock();
ToasterItemData toasterItemData = mPendingToasterBandwidthInfo.takeFirst();
VOIPToasterItem *voipToasterItem = new VOIPToasterItem(toasterItemData.mPeerId, toasterItemData.mMsg, VOIPToasterItem::BandwidthInfo);
toasterItem = new ToasterItem(voipToasterItem);
connect(toasterItem, SIGNAL(toasterItemDestroyed(ToasterItem*)), this, SLOT(toasterItemDestroyedBandwidthInfo(ToasterItem*)));
mToasterBandwidthInfo.insert(toasterItemData.mPeerId, toasterItem);
mMutex->unlock();
}
if (!mPendingToasterData.empty() && !toasterItem) {
mMutex->lock();
ToasterItemData toasterItemData = mPendingToasterData.takeFirst();
VOIPToasterItem *voipToasterItem = new VOIPToasterItem(toasterItemData.mPeerId, toasterItemData.mMsg, VOIPToasterItem::Data);
toasterItem = new ToasterItem(voipToasterItem);
toasterItem->timeToLive = 10000;
connect(toasterItem, SIGNAL(toasterItemDestroyed(ToasterItem*)), this, SLOT(toasterItemDestroyedData(ToasterItem*)));
mToasterData.insert(toasterItemData.mPeerId, toasterItem);
mMutex->unlock();
}
if (!mPendingToasterHangUp.empty() && !toasterItem) {
mMutex->lock();
ToasterItemData toasterItemData = mPendingToasterHangUp.takeFirst();
VOIPToasterItem *voipToasterItem = new VOIPToasterItem(toasterItemData.mPeerId, toasterItemData.mMsg, VOIPToasterItem::HangUp);
toasterItem = new ToasterItem(voipToasterItem);
connect(toasterItem, SIGNAL(toasterItemDestroyed(ToasterItem*)), this, SLOT(toasterItemDestroyedHangUp(ToasterItem*)));
mToasterHangUp.insert(toasterItemData.mPeerId, toasterItem);
mMutex->unlock();
}
if (!mPendingToasterInvitation.empty() && !toasterItem) {
mMutex->lock();
ToasterItemData toasterItemData = mPendingToasterInvitation.takeFirst();
VOIPToasterItem *voipToasterItem = new VOIPToasterItem(toasterItemData.mPeerId, toasterItemData.mMsg, VOIPToasterItem::Invitation);
toasterItem = new ToasterItem(voipToasterItem);
connect(toasterItem, SIGNAL(toasterItemDestroyed(ToasterItem*)), this, SLOT(toasterItemDestroyedInvitation(ToasterItem*)));
mToasterInvitation.insert(toasterItemData.mPeerId, toasterItem);
mMutex->unlock();
}
#endif
if (!mPendingToasterAudioCall.empty() && !toasterItem) {
mMutex->lock();
ToasterItemData toasterItemData = mPendingToasterAudioCall.takeFirst();
VOIPToasterItem *voipToasterItem = new VOIPToasterItem(toasterItemData.mPeerId, toasterItemData.mMsg, VOIPToasterItem::AudioCall);
toasterItem = new ToasterItem(voipToasterItem);
connect(toasterItem, SIGNAL(toasterItemDestroyed(ToasterItem*)), this, SLOT(toasterItemDestroyedAudioCall(ToasterItem*)));
mToasterAudioCall.insert(toasterItemData.mPeerId, toasterItem);
mMutex->unlock();
}
if (!mPendingToasterVideoCall.empty() && !toasterItem) {
mMutex->lock();
ToasterItemData toasterItemData = mPendingToasterVideoCall.takeFirst();
VOIPToasterItem *voipToasterItem = new VOIPToasterItem(toasterItemData.mPeerId, toasterItemData.mMsg, VOIPToasterItem::VideoCall);
toasterItem = new ToasterItem(voipToasterItem);
connect(toasterItem, SIGNAL(toasterItemDestroyed(ToasterItem*)), this, SLOT(toasterItemDestroyedVideoCall(ToasterItem*)));
mToasterVideoCall.insert(toasterItemData.mPeerId, toasterItem);
mMutex->unlock();
}
return toasterItem;
}
ToasterItem* VOIPToasterNotify::testToasterItem(QString tag)
{
ToasterItem* toaster = NULL;
RsPeerId ownId = rsPeers->getOwnId();
#ifdef VOIPTOASTERNOTIFY_ALL
if (tag == "Accept") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP Accept"), VOIPToasterItem::Accept));
if (tag == "BandwidthInfo") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP BandwidthInfo"), VOIPToasterItem::BandwidthInfo));
if (tag == "Data") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP Data"), VOIPToasterItem::Data));
if (tag == "HangUp") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP HangUp"), VOIPToasterItem::HangUp));
if (tag == "Invitation") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP Invitation"), VOIPToasterItem::Invitation));
#endif
if (tag == "AudioCall") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP Audio Call"), VOIPToasterItem::AudioCall));
if (tag == "VideoCall") toaster = new ToasterItem(new VOIPToasterItem(ownId, tr("Test VOIP Video Call"), VOIPToasterItem::VideoCall));
return toaster;
}
#ifdef VOIPTOASTERNOTIFY_ALL
void VOIPToasterNotify::voipAcceptReceived(const RsPeerId &peer_id)
{
if (peer_id.isNull()) {
return;
}
if (!notifyEnabled("Accept")) {
return;
}
mMutex->lock();
if (!mToasterAccept.contains(peer_id)){
ToasterItemData toasterItemData;
toasterItemData.mPeerId = peer_id;
toasterItemData.mMsg = tr("Accept received from this peer.");
mPendingToasterAccept.push_back(toasterItemData);
mToasterAccept.insert(peer_id, NULL);
}
mMutex->unlock();
}
void VOIPToasterNotify::voipBandwidthInfoReceived(const RsPeerId &peer_id,int bytes_per_sec)
{
if (peer_id.isNull()) {
return;
}
if (!notifyEnabled("BandwidthInfo")) {
return;
}
mMutex->lock();
if (!mToasterBandwidthInfo.contains(peer_id)){
ToasterItemData toasterItemData;
toasterItemData.mPeerId = peer_id;
toasterItemData.mMsg = tr("Bandwidth Info received from this peer:%1").arg(bytes_per_sec);
mPendingToasterBandwidthInfo.push_back(toasterItemData);
mToasterBandwidthInfo.insert(peer_id, NULL);
}
mMutex->unlock();
}
void VOIPToasterNotify::voipDataReceived(const RsPeerId &peer_id)
{
if (peer_id.isNull()) {
return;
}
if (!notifyEnabled("Data")) {
return;
}
mMutex->lock();
if (!mToasterData.contains(peer_id)){
ToasterItemData toasterItemData;
toasterItemData.mPeerId = peer_id;
toasterItemData.mMsg = tr("Audio or Video Data received from this peer.");
mPendingToasterData.push_back(toasterItemData);
mToasterData.insert(peer_id, NULL);
}
mMutex->unlock();
}
void VOIPToasterNotify::voipHangUpReceived(const RsPeerId &peer_id)
{
if (peer_id.isNull()) {
return;
}
if (!notifyEnabled("HangUp")) {
return;
}
mMutex->lock();
if (!mToasterHangUp.contains(peer_id)){
ToasterItemData toasterItemData;
toasterItemData.mPeerId = peer_id;
toasterItemData.mMsg = tr("HangUp received from this peer.");
mPendingToasterHangUp.push_back(toasterItemData);
mToasterHangUp.insert(peer_id, NULL);
}
mMutex->unlock();
}
void VOIPToasterNotify::voipInvitationReceived(const RsPeerId &peer_id)
{
if (peer_id.isNull()) {
return;
}
if (!notifyEnabled("Invitation")) {
return;
}
mMutex->lock();
if (!mToasterInvitation.contains(peer_id)){
ToasterItemData toasterItemData;
toasterItemData.mPeerId = peer_id;
toasterItemData.mMsg = tr("Invitation received from this peer.");
mPendingToasterInvitation.push_back(toasterItemData);
mToasterInvitation.insert(peer_id, NULL);
}
mMutex->unlock();
}
#endif
void VOIPToasterNotify::voipAudioCallReceived(const RsPeerId &peer_id)
{
if (peer_id.isNull()) {
return;
}
if (!notifyEnabled("AudioCall")) {
return;
}
mMutex->lock();
if (!mToasterAudioCall.contains(peer_id)){
ToasterItemData toasterItemData;
toasterItemData.mPeerId = peer_id;
toasterItemData.mMsg = tr("Audio Call received from this peer.");
mPendingToasterAudioCall.push_back(toasterItemData);
mToasterAudioCall.insert(peer_id, NULL);
}
mMutex->unlock();
}
void VOIPToasterNotify::voipVideoCallReceived(const RsPeerId &peer_id)
{
if (peer_id.isNull()) {
return;
}
if (!notifyEnabled("VideoCall")) {
return;
}
mMutex->lock();
if (!mToasterVideoCall.contains(peer_id)){
ToasterItemData toasterItemData;
toasterItemData.mPeerId = peer_id;
toasterItemData.mMsg = tr("Video Call received from this peer.");
mPendingToasterVideoCall.push_back(toasterItemData);
mToasterVideoCall.insert(peer_id, NULL);
}
mMutex->unlock();
}
#ifdef VOIPTOASTERNOTIFY_ALL
void VOIPToasterNotify::toasterItemDestroyedAccept(ToasterItem *toasterItem)
{
RsPeerId key = mToasterAccept.key(toasterItem, RsPeerId());
if (!key.isNull()) mToasterAccept.remove(key);
}
void VOIPToasterNotify::toasterItemDestroyedBandwidthInfo(ToasterItem *toasterItem)
{
RsPeerId key = mToasterBandwidthInfo.key(toasterItem, RsPeerId());
if (!key.isNull()) mToasterBandwidthInfo.remove(key);
}
void VOIPToasterNotify::toasterItemDestroyedData(ToasterItem *toasterItem)
{
RsPeerId key = mToasterData.key(toasterItem, RsPeerId());
if (!key.isNull()) mToasterData.remove(key);
}
void VOIPToasterNotify::toasterItemDestroyedHangUp(ToasterItem *toasterItem)
{
RsPeerId key = mToasterHangUp.key(toasterItem, RsPeerId());
if (!key.isNull()) mToasterHangUp.remove(key);
}
void VOIPToasterNotify::toasterItemDestroyedInvitation(ToasterItem *toasterItem)
{
RsPeerId key = mToasterInvitation.key(toasterItem, RsPeerId());
if (!key.isNull()) mToasterInvitation.remove(key);
}
#endif
void VOIPToasterNotify::toasterItemDestroyedAudioCall(ToasterItem *toasterItem)
{
RsPeerId key = mToasterAudioCall.key(toasterItem, RsPeerId());
if (!key.isNull()) mToasterAudioCall.remove(key);
}
void VOIPToasterNotify::toasterItemDestroyedVideoCall(ToasterItem *toasterItem)
{
RsPeerId key = mToasterVideoCall.key(toasterItem, RsPeerId());
if (!key.isNull()) mToasterVideoCall.remove(key);
}

View file

@ -0,0 +1,112 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2015
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#pragma once
#include "gui/VOIPNotify.h"
#include "gui/VOIPToasterItem.h"
#include "interface/rsVOIP.h"
#include "gui/common/ToasterNotify.h"
#include <QMutex>
//#define VOIPTOASTERNOTIFY_ALL //To get all notification
class VOIPToasterNotify : public ToasterNotify
{
Q_OBJECT
protected:
class ToasterItemData
{
public:
ToasterItemData() {}
public:
RsPeerId mPeerId;
QString mMsg;
};
public:
VOIPToasterNotify(RsVOIP *VOIP, VOIPNotify *notify, QObject *parent = 0);
~VOIPToasterNotify();
/// From ToasterNotify ///
virtual bool hasSettings(QString &mainName, QMap<QString,QString> &tagAndTexts);
virtual bool notifyEnabled(QString tag);
virtual void setNotifyEnabled(QString tag, bool enabled);
virtual ToasterItem *toasterItem();
virtual ToasterItem *testToasterItem(QString tag);
private slots:
#ifdef VOIPTOASTERNOTIFY_ALL
void voipAcceptReceived(const RsPeerId &peer_id) ; // emitted when the peer accepts the call
void voipBandwidthInfoReceived(const RsPeerId &peer_id, int bytes_per_sec) ; // emitted when measured bandwidth info is received by the peer.
void voipDataReceived(const RsPeerId &peer_id) ; // signal emitted when some voip data has been received
void voipHangUpReceived(const RsPeerId &peer_id) ; // emitted when the peer closes the call (i.e. hangs up)
void voipInvitationReceived(const RsPeerId &peer_id) ; // signal emitted when an invitation has been received
#endif
void voipAudioCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send audio
void voipVideoCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send video
#ifdef VOIPTOASTERNOTIFY_ALL
void toasterItemDestroyedAccept(ToasterItem *toasterItem) ;
void toasterItemDestroyedBandwidthInfo(ToasterItem *toasterItem) ;
void toasterItemDestroyedData(ToasterItem *toasterItem) ;
void toasterItemDestroyedHangUp(ToasterItem *toasterItem) ;
void toasterItemDestroyedInvitation(ToasterItem *toasterItem) ;
#endif
void toasterItemDestroyedAudioCall(ToasterItem *toasterItem) ;
void toasterItemDestroyedVideoCall(ToasterItem *toasterItem) ;
private:
RsVOIP *mVOIP;
VOIPNotify *mVOIPNotify;
// comment electron: i don't think the mutex is needed, because everything happens in the GUI thread
// (Qt signals are send to slots in the gui thread)
// i'm leaving it here to no destroy something
// note: FeedReaderFeedNotify has a similar mutex
// maybe it has historic reasons. NotifyQt still contains commented lines QMutexLocker lock(&waitingToasterMutex);
QMutex *mMutex;
#ifdef VOIPTOASTERNOTIFY_ALL
QList<ToasterItemData> mPendingToasterAccept;
QList<ToasterItemData> mPendingToasterBandwidthInfo;
QList<ToasterItemData> mPendingToasterData;
QList<ToasterItemData> mPendingToasterHangUp;
QList<ToasterItemData> mPendingToasterInvitation;
#endif
QList<ToasterItemData> mPendingToasterAudioCall;
QList<ToasterItemData> mPendingToasterVideoCall;
#ifdef VOIPTOASTERNOTIFY_ALL
QMap<RsPeerId, ToasterItem *> mToasterAccept;
QMap<RsPeerId, ToasterItem *> mToasterBandwidthInfo;
QMap<RsPeerId, ToasterItem *> mToasterData;
QMap<RsPeerId, ToasterItem *> mToasterHangUp;
QMap<RsPeerId, ToasterItem *> mToasterInvitation;
#endif
QMap<RsPeerId, ToasterItem *> mToasterAudioCall;
QMap<RsPeerId, ToasterItem *> mToasterVideoCall;
};

View file

@ -13,6 +13,7 @@ class VideoDecoder
{
public:
VideoDecoder() ;
virtual ~VideoDecoder() {}
// Gets the next image to be displayed. Once returned, the image should
// be cleared from the incoming queue.
@ -49,6 +50,7 @@ class VideoEncoder
{
public:
VideoEncoder() {}
virtual ~VideoEncoder() {}
// Takes the next image to be encoded.
//