Add Accept, Ring and HangUp event for Video and Audio.

Now you don't send data before friend accept.
This commit is contained in:
Phenom 2015-10-10 15:21:59 +02:00
parent 1a229ef817
commit 1989f366a7
16 changed files with 774 additions and 291 deletions

View File

@ -90,10 +90,10 @@ VOIPPlugin::VOIPPlugin()
mVOIPGUIHandler = new VOIPGUIHandler ; mVOIPGUIHandler = new VOIPGUIHandler ;
mVOIPNotify = new VOIPNotify ; mVOIPNotify = new VOIPNotify ;
QObject::connect(mVOIPNotify,SIGNAL(voipInvitationReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedInvitation(const RsPeerId&)),Qt::QueuedConnection) ; QObject::connect(mVOIPNotify,SIGNAL(voipInvitationReceived(const RsPeerId&,int)),mVOIPGUIHandler,SLOT(ReceivedInvitation(const RsPeerId&,int)),Qt::QueuedConnection) ;
QObject::connect(mVOIPNotify,SIGNAL(voipDataReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedVoipData(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(voipAcceptReceived(const RsPeerId&,int)),mVOIPGUIHandler,SLOT(ReceivedVoipAccept(const RsPeerId&,int)),Qt::QueuedConnection) ;
QObject::connect(mVOIPNotify,SIGNAL(voipHangUpReceived(const RsPeerId&)),mVOIPGUIHandler,SLOT(ReceivedVoipHangUp(const RsPeerId&)),Qt::QueuedConnection) ; QObject::connect(mVOIPNotify,SIGNAL(voipHangUpReceived(const RsPeerId&,int)),mVOIPGUIHandler,SLOT(ReceivedVoipHangUp(const RsPeerId&,int)),Qt::QueuedConnection) ;
QObject::connect(mVOIPNotify,SIGNAL(voipBandwidthInfoReceived(const RsPeerId&,int)),mVOIPGUIHandler,SLOT(ReceivedVoipBandwidthInfo(const RsPeerId&,int)),Qt::QueuedConnection) ; QObject::connect(mVOIPNotify,SIGNAL(voipBandwidthInfoReceived(const RsPeerId&,int)),mVOIPGUIHandler,SLOT(ReceivedVoipBandwidthInfo(const RsPeerId&,int)),Qt::QueuedConnection) ;
Q_INIT_RESOURCE(VOIP_images); Q_INIT_RESOURCE(VOIP_images);

View File

@ -25,6 +25,7 @@
#include <gui/audiodevicehelper.h> #include <gui/audiodevicehelper.h>
#include "interface/rsVOIP.h" #include "interface/rsVOIP.h"
#include "gui/SoundManager.h" #include "gui/SoundManager.h"
#include "util/HandleRichText.h" #include "util/HandleRichText.h"
#include "gui/common/StatusDefs.h" #include "gui/common/StatusDefs.h"
@ -65,6 +66,7 @@ VOIPChatWidgetHolder::VOIPChatWidgetHolder(ChatWidget *chatWidget, VOIPNotify *n
audioListenToggleButton->setAutoRaise(true) ; audioListenToggleButton->setAutoRaise(true) ;
audioListenToggleButton->setText(QString()) ; audioListenToggleButton->setText(QString()) ;
audioListenToggleButton->setToolTip(tr("Mute")); audioListenToggleButton->setToolTip(tr("Mute"));
audioListenToggleButton->setEnabled(false);
QIcon iconaudioCaptureToggleButton ; QIcon iconaudioCaptureToggleButton ;
iconaudioCaptureToggleButton.addPixmap(QPixmap(":/images/call-start.png")) ; iconaudioCaptureToggleButton.addPixmap(QPixmap(":/images/call-start.png")) ;
@ -281,6 +283,34 @@ VOIPChatWidgetHolder::VOIPChatWidgetHolder(ChatWidget *chatWidget, VOIPNotify *n
inputVideoDevice->setEchoVideoTarget(echoVideoDevice) ; inputVideoDevice->setEchoVideoTarget(echoVideoDevice) ;
inputVideoDevice->setVideoProcessor(videoProcessor) ; inputVideoDevice->setVideoProcessor(videoProcessor) ;
videoProcessor->setDisplayTarget(outputVideoDevice) ; videoProcessor->setDisplayTarget(outputVideoDevice) ;
//Ring
pbAudioRing = new QProgressBar();
pbAudioRing->setOrientation(Qt::Horizontal);
pbAudioRing->setRange(0, 99);
pbAudioRing->setTextVisible(false);
pbAudioRing->setHidden(true);
pbVideoRing = new QProgressBar();
pbVideoRing->setOrientation(Qt::Horizontal);
pbVideoRing->setRange(0, 99);
pbVideoRing->setTextVisible(false);
pbVideoRing->setHidden(true);
mChatWidget->addChatBarWidget(pbAudioRing);
mChatWidget->addChatBarWidget(pbVideoRing);
sendAudioRingTime = -1;
sendVideoRingTime = -1;
recAudioRingTime = -1;
recVideoRingTime = -1;
timerAudioRing = new QTimer(this);
timerAudioRing->setInterval(300);
timerAudioRing->setSingleShot(true);
connect(timerAudioRing, SIGNAL(timeout()), this, SLOT(timerAudioRingTimeOut()));
timerVideoRing = new QTimer(this);
timerVideoRing->setInterval(300);
timerVideoRing->setSingleShot(true);
connect(timerVideoRing, SIGNAL(timeout()), this, SLOT(timerVideoRingTimeOut()));
} }
VOIPChatWidgetHolder::~VOIPChatWidgetHolder() VOIPChatWidgetHolder::~VOIPChatWidgetHolder()
@ -290,11 +320,143 @@ VOIPChatWidgetHolder::~VOIPChatWidgetHolder()
delete inputVideoDevice ; delete inputVideoDevice ;
delete videoProcessor ; delete videoProcessor ;
deleteButtonMap();
button_map::iterator it = buttonMapTakeVideo.begin(); // stop and delete timers
while (it != buttonMapTakeVideo.end()) { timerAudioRing->stop();
it = buttonMapTakeVideo.erase(it); delete(timerAudioRing);
} timerVideoRing->stop();
delete(timerVideoRing);
}
void VOIPChatWidgetHolder::deleteButtonMap(int flags)
{
button_map::iterator it = buttonMapTakeCall.begin();
while (it != buttonMapTakeCall.end()) {
if (((it.key().left(1) == "a") && (flags & RS_VOIP_FLAGS_AUDIO_DATA))
|| ((it.key().left(1) == "v") && (flags & RS_VOIP_FLAGS_VIDEO_DATA)) ) {
QPair<RSButtonOnText*,RSButtonOnText*> pair = it.value();
delete pair.second;
delete pair.first;
if (flags & RS_VOIP_FLAGS_AUDIO_DATA) recAudioRingTime = -1;
if (flags & RS_VOIP_FLAGS_VIDEO_DATA) recVideoRingTime = -1;
it = buttonMapTakeCall.erase(it);
} else {
++it;
}
}
}
void VOIPChatWidgetHolder::addNewAudioButtonMap(const RsPeerId &peer_id)
{
if (mChatWidget) {
recAudioRingTime = 0;
timerAudioRingTimeOut();
QString buttonName = QString::fromUtf8(rsPeers->getPeerName(peer_id).c_str());
if (buttonName.isEmpty()) buttonName = QString::fromStdString(peer_id.toStdString().c_str());
if (buttonName.isEmpty()) buttonName = "VoIP";
button_map::iterator it = buttonMapTakeCall.find(QString("a").append(buttonName));
if (it == buttonMapTakeCall.end()){
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("%1 inviting you to start an audio conversation. Do you want Accept or Decline the invitation?").arg(buttonName), ChatWidget::MSGTYPE_SYSTEM);
RSButtonOnText *buttonT = mChatWidget->getNewButtonOnTextBrowser(tr("Accept Audio Call"));
buttonT->setToolTip(tr("Activate audio"));
buttonT->setStyleSheet(QString("border: 1px solid #199909;")
.append("font-size: 12pt; color: white;")
.append("min-width: 128px; min-height: 24px;")
.append("border-radius: 6px;")
.append("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.67, "
"stop: 0 #22c70d, stop: 1 #116a06);")
);
buttonT->updateImage();
connect(buttonT,SIGNAL(clicked()),this,SLOT(startAudioCapture()));
connect(buttonT,SIGNAL(mouseEnter()),this,SLOT(botMouseEnterTake()));
connect(buttonT,SIGNAL(mouseLeave()),this,SLOT(botMouseLeaveTake()));
RSButtonOnText *buttonD = mChatWidget->getNewButtonOnTextBrowser(tr("Decline Audio Call"));
buttonD->setToolTip(tr("Refuse audio call"));
buttonD->setStyleSheet(QString("border: 1px solid #199909;")
.append("font-size: 12pt; color: white;")
.append("min-width: 128px; min-height: 24px;")
.append("border-radius: 6px;")
.append("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.67, "
"stop: 0 #c7220d, stop: 1 #6a1106);")
);
buttonD->updateImage();
connect(buttonD,SIGNAL(clicked()),this,SLOT(hangupCallAudio()));
connect(buttonD,SIGNAL(mouseEnter()),this,SLOT(botMouseEnterDecline()));
connect(buttonD,SIGNAL(mouseLeave()),this,SLOT(botMouseLeaveDecline()));
buttonMapTakeCall.insert(QString("a").append(buttonName), QPair<RSButtonOnText*, RSButtonOnText*>(buttonT, buttonD));
}
//TODO make a sound for the incoming call
//soundManager->play(VOIP_SOUND_INCOMING_CALL);
if (mVOIPNotify) mVOIPNotify->notifyReceivedVoipAudioCall(peer_id);
}
}
void VOIPChatWidgetHolder::addNewVideoButtonMap(const RsPeerId &peer_id)
{
if (mChatWidget) {
recVideoRingTime = 0;
timerVideoRingTimeOut();
QString buttonName = QString::fromUtf8(rsPeers->getPeerName(peer_id).c_str());
if (buttonName.isEmpty()) buttonName = QString::fromStdString(peer_id.toStdString().c_str());
if (buttonName.isEmpty()) buttonName = "VoIP";
button_map::iterator it = buttonMapTakeCall.find(QString("v").append(buttonName));
if (it == buttonMapTakeCall.end()){
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("%1 inviting you to start a video conversation. Do you want Accept or Decline the invitation?").arg(buttonName), ChatWidget::MSGTYPE_SYSTEM);
RSButtonOnText *buttonT = mChatWidget->getNewButtonOnTextBrowser(tr("Accept Video Call"));
buttonT->setToolTip(tr("Activate camera"));
buttonT->setStyleSheet(QString("border: 1px solid #199909;")
.append("font-size: 12pt; color: white;")
.append("min-width: 128px; min-height: 24px;")
.append("border-radius: 6px;")
.append("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.67, "
"stop: 0 #22c70d, stop: 1 #116a06);")
);
buttonT->updateImage();
connect(buttonT,SIGNAL(clicked()),this,SLOT(startVideoCapture()));
connect(buttonT,SIGNAL(mouseEnter()),this,SLOT(botMouseEnterTake()));
connect(buttonT,SIGNAL(mouseLeave()),this,SLOT(botMouseLeaveTake()));
RSButtonOnText *buttonD = mChatWidget->getNewButtonOnTextBrowser(tr("Decline Video Call"));
buttonD->setToolTip(tr("Refuse video call"));
buttonD->setStyleSheet(QString("border: 1px solid #199909;")
.append("font-size: 12pt; color: white;")
.append("min-width: 128px; min-height: 24px;")
.append("border-radius: 6px;")
.append("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.67, "
"stop: 0 #c7220d, stop: 1 #6a1106);")
);
buttonD->updateImage();
connect(buttonD,SIGNAL(clicked()),this,SLOT(hangupCallVideo()));
connect(buttonD,SIGNAL(mouseEnter()),this,SLOT(botMouseEnterDecline()));
connect(buttonD,SIGNAL(mouseLeave()),this,SLOT(botMouseLeaveDecline()));
buttonMapTakeCall.insert(QString("v").append(buttonName), QPair<RSButtonOnText*, RSButtonOnText*>(buttonT, buttonD));
}
//TODO make a sound for the incoming call
// soundManager->play(VOIP_SOUND_INCOMING_CALL);
if (mVOIPNotify) mVOIPNotify->notifyReceivedVoipVideoCall(peer_id);
}
} }
bool VOIPChatWidgetHolder::eventFilter(QObject *obj, QEvent *event) bool VOIPChatWidgetHolder::eventFilter(QObject *obj, QEvent *event)
@ -314,24 +476,59 @@ bool VOIPChatWidgetHolder::eventFilter(QObject *obj, QEvent *event)
void VOIPChatWidgetHolder::hangupCall() void VOIPChatWidgetHolder::hangupCall()
{ {
hangupCallAudio();
hangupCallVideo();
hangupButton->hide();
hangupButtonFS->hide();
deleteButtonMap();
}
void VOIPChatWidgetHolder::hangupCallAudio()
{
bool atLeastOneChecked = false;
if (audioCaptureToggleButton->isChecked()) { if (audioCaptureToggleButton->isChecked()) {
audioCaptureToggleButton->setChecked(false); audioCaptureToggleButton->setChecked(false);
toggleAudioCapture(); toggleAudioCapture();
atLeastOneChecked = true;
} }
if (!atLeastOneChecked) {
//Decline button or Friend hang up
if (recAudioRingTime != -1) {
rsVOIP->sendVoipHangUpCall(mChatWidget->getChatId().toPeerId(), RS_VOIP_FLAGS_AUDIO_DATA);
deleteButtonMap(RS_VOIP_FLAGS_AUDIO_DATA);
}
sendAudioRingTime = -1;
recAudioRingTime = -1;
}
}
void VOIPChatWidgetHolder::hangupCallVideo()
{
bool atLeastOneChecked = false;
if (videoCaptureToggleButton->isChecked()) { if (videoCaptureToggleButton->isChecked()) {
videoCaptureToggleButton->setChecked(false); videoCaptureToggleButton->setChecked(false);
toggleVideoCapture(); toggleVideoCapture();
atLeastOneChecked = true;
} }
if (fullscreenToggleButton->isChecked()) { if (fullscreenToggleButton->isChecked()) {
fullscreenToggleButton->setChecked(false); fullscreenToggleButton->setChecked(false);
toggleFullScreen(); toggleFullScreen();
atLeastOneChecked = true;
} }
if (hideChatTextToggleButton->isChecked()) { if (hideChatTextToggleButton->isChecked()) {
hideChatTextToggleButton->setChecked(false); hideChatTextToggleButton->setChecked(false);
toggleHideChatText(); toggleHideChatText();
atLeastOneChecked = true;
}
if (!atLeastOneChecked) {
//Decline button or Friend hang up
if (recVideoRingTime != -1) {
rsVOIP->sendVoipHangUpCall(mChatWidget->getChatId().toPeerId(), RS_VOIP_FLAGS_VIDEO_DATA);
deleteButtonMap(RS_VOIP_FLAGS_VIDEO_DATA);
}
sendVideoRingTime = -1;
recVideoRingTime = -1;
} }
hangupButton->hide();
hangupButtonFS->hide();
} }
void VOIPChatWidgetHolder::toggleAudioListenFS() void VOIPChatWidgetHolder::toggleAudioListenFS()
@ -357,6 +554,7 @@ void VOIPChatWidgetHolder::toggleAudioListen()
void VOIPChatWidgetHolder::startAudioCapture() void VOIPChatWidgetHolder::startAudioCapture()
{ {
recAudioRingTime = -2;
audioCaptureToggleButton->setChecked(true); audioCaptureToggleButton->setChecked(true);
toggleAudioCapture(); toggleAudioCapture();
} }
@ -369,57 +567,85 @@ void VOIPChatWidgetHolder::toggleAudioCaptureFS()
void VOIPChatWidgetHolder::toggleAudioCapture() void VOIPChatWidgetHolder::toggleAudioCapture()
{ {
if (audioCaptureToggleButton->isChecked()) { if (audioCaptureToggleButton->isChecked()) {
//activate audio output if (recAudioRingTime == -1) {
audioListenToggleButton->setChecked(true); if (sendAudioRingTime == -1) {
audioListenToggleButtonFS->setChecked(true); sendAudioRingTime = 0;
audioCaptureToggleButton->setToolTip(tr("Hold Call")); timerAudioRingTimeOut();
hangupButton->show(); rsVOIP->sendVoipRinging(mChatWidget->getChatId().toPeerId(), RS_VOIP_FLAGS_AUDIO_DATA);
hangupButtonFS->show(); return; //Start Audio when accept received
}
}
if (recAudioRingTime != -1)
rsVOIP->sendVoipAcceptCall(mChatWidget->getChatId().toPeerId(), RS_VOIP_FLAGS_AUDIO_DATA);
recAudioRingTime = -1; //Stop ringing
//activate audio input //activate buttons
if (!inputAudioProcessor) { audioListenToggleButton->setEnabled(true);
inputAudioProcessor = new QtSpeex::SpeexInputProcessor(); audioListenToggleButton->setChecked(true);
if (outputAudioProcessor) { audioListenToggleButtonFS->setEnabled(true);
connect(outputAudioProcessor, SIGNAL(playingFrame(QByteArray*)), inputAudioProcessor, SLOT(addEchoFrame(QByteArray*))); audioListenToggleButtonFS->setChecked(true);
} audioCaptureToggleButton->setToolTip(tr("Hold Call"));
inputAudioProcessor->open(QIODevice::WriteOnly | QIODevice::Unbuffered); hangupButton->show();
} hangupButtonFS->show();
if (!inputAudioDevice) {
inputAudioDevice = AudioDeviceHelper::getPreferedInputDevice(); //activate audio input
} if (!inputAudioProcessor) {
connect(inputAudioProcessor, SIGNAL(networkPacketReady()), this, SLOT(sendAudioData())); inputAudioProcessor = new QtSpeex::SpeexInputProcessor();
inputAudioDevice->start(inputAudioProcessor); if (outputAudioProcessor) {
connect(outputAudioProcessor, SIGNAL(playingFrame(QByteArray*)), inputAudioProcessor, SLOT(addEchoFrame(QByteArray*)));
if (mChatWidget) { }
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("Outgoing Call is started..."), ChatWidget::MSGTYPE_SYSTEM); inputAudioProcessor->open(QIODevice::WriteOnly | QIODevice::Unbuffered);
} }
if (!inputAudioDevice) {
button_map::iterator it = buttonMapTakeVideo.begin(); inputAudioDevice = AudioDeviceHelper::getPreferedInputDevice();
while (it != buttonMapTakeVideo.end()) { }
RSButtonOnText *button = it.value(); connect(inputAudioProcessor, SIGNAL(networkPacketReady()), this, SLOT(sendAudioData()));
delete button; inputAudioDevice->start(inputAudioProcessor);
it = buttonMapTakeVideo.erase(it);
} //send system message
if (mChatWidget)
} else { mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("Outgoing Call is started..."), ChatWidget::MSGTYPE_SYSTEM);
disconnect(inputAudioProcessor, SIGNAL(networkPacketReady()), this, SLOT(sendAudioData()));
if (inputAudioDevice) { deleteButtonMap(RS_VOIP_FLAGS_AUDIO_DATA);
inputAudioDevice->stop(); } else {
} //desactivate buttons
if (mChatWidget) { audioListenToggleButton->setEnabled(false);
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("Outgoing Audio Call stopped."), ChatWidget::MSGTYPE_SYSTEM); audioListenToggleButton->setChecked(false);
} audioListenToggleButtonFS->setEnabled(false);
audioCaptureToggleButton->setToolTip(tr("Resume Call")); audioListenToggleButtonFS->setChecked(false);
hangupButton->hide(); audioCaptureToggleButton->setToolTip(tr("Resume Call"));
hangupButtonFS->hide(); if (!videoCaptureToggleButton->isChecked()) {
} hangupButton->hide();
audioCaptureToggleButtonFS->setChecked(audioCaptureToggleButton->isChecked()); hangupButtonFS->hide();
audioCaptureToggleButtonFS->setToolTip(audioCaptureToggleButton->toolTip()); }
if (recAudioRingTime <= -1){
//desactivate audio input
disconnect(inputAudioProcessor, SIGNAL(networkPacketReady()), this, SLOT(sendAudioData()));
if (inputAudioDevice) {
inputAudioDevice->stop();
}
//send system message
if (mChatWidget)
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("Outgoing Audio Call stopped."), ChatWidget::MSGTYPE_SYSTEM);
rsVOIP->sendVoipHangUpCall(mChatWidget->getChatId().toPeerId(), RS_VOIP_FLAGS_AUDIO_DATA);
}
sendAudioRingTime = -1;
recAudioRingTime = -1;
}
audioCaptureToggleButtonFS->setChecked(audioCaptureToggleButton->isChecked());
audioCaptureToggleButtonFS->setToolTip(audioCaptureToggleButton->toolTip());
} }
void VOIPChatWidgetHolder::startVideoCapture() void VOIPChatWidgetHolder::startVideoCapture()
{ {
recVideoRingTime = -2;
videoCaptureToggleButton->setChecked(true); videoCaptureToggleButton->setChecked(true);
toggleVideoCapture(); toggleVideoCapture();
} }
@ -434,31 +660,38 @@ void VOIPChatWidgetHolder::toggleVideoCapture()
{ {
if (videoCaptureToggleButton->isChecked()) if (videoCaptureToggleButton->isChecked())
{ {
if (recVideoRingTime == -1) {
if (sendVideoRingTime == -1) {
sendVideoRingTime = 0;
timerVideoRingTimeOut();
rsVOIP->sendVoipRinging(mChatWidget->getChatId().toPeerId(), RS_VOIP_FLAGS_VIDEO_DATA);
return; //Start Video when accept received
}
}
if (recVideoRingTime != -1)
rsVOIP->sendVoipAcceptCall(mChatWidget->getChatId().toPeerId(), RS_VOIP_FLAGS_VIDEO_DATA);
recVideoRingTime = -1; //Stop ringing
//activate buttons
hideChatTextToggleButton->setEnabled(true); hideChatTextToggleButton->setEnabled(true);
fullscreenToggleButton->setEnabled(true); fullscreenToggleButton->setEnabled(true);
fullscreenToggleButtonFS->setEnabled(true); fullscreenToggleButtonFS->setEnabled(true);
videoCaptureToggleButton->setToolTip(tr("Shut camera off"));
hangupButton->show(); hangupButton->show();
hangupButtonFS->show(); hangupButtonFS->show();
//activate video input //activate video input
//
videoWidget->show(); videoWidget->show();
inputVideoDevice->start() ; inputVideoDevice->start() ;
videoCaptureToggleButton->setToolTip(tr("Shut camera off")); //send system message
if (mChatWidget)
if (mChatWidget)
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime() mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("You're now sending video..."), ChatWidget::MSGTYPE_SYSTEM); , tr("You're now sending video..."), ChatWidget::MSGTYPE_SYSTEM);
button_map::iterator it = buttonMapTakeVideo.begin(); deleteButtonMap(RS_VOIP_FLAGS_VIDEO_DATA);
while (it != buttonMapTakeVideo.end()) { } else {
RSButtonOnText *button = it.value(); //desactivate buttons
delete button;
it = buttonMapTakeVideo.erase(it);
}
}
else
{
hideChatTextToggleButton->setEnabled(false); hideChatTextToggleButton->setEnabled(false);
hideChatTextToggleButton->setChecked(false); hideChatTextToggleButton->setChecked(false);
toggleHideChatText(); toggleHideChatText();
@ -467,17 +700,29 @@ void VOIPChatWidgetHolder::toggleVideoCapture()
fullscreenToggleButtonFS->setEnabled(false); fullscreenToggleButtonFS->setEnabled(false);
fullscreenToggleButtonFS->setChecked(false); fullscreenToggleButtonFS->setChecked(false);
toggleFullScreen(); toggleFullScreen();
hangupButton->hide();
hangupButtonFS->hide();
inputVideoDevice->stop() ;
videoCaptureToggleButton->setToolTip(tr("Activate camera")); videoCaptureToggleButton->setToolTip(tr("Activate camera"));
outputVideoDevice->showFrameOff(); if (!audioCaptureToggleButton->isChecked()) {
videoWidget->hide(); hangupButton->hide();
hangupButtonFS->hide();
if (mChatWidget) }
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("Video call stopped"), ChatWidget::MSGTYPE_SYSTEM); if (recVideoRingTime<=-1){
//desactivate video input
inputVideoDevice->stop() ;
outputVideoDevice->showFrameOff();
videoWidget->hide();
//send system message
if (mChatWidget)
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("Video call stopped"), ChatWidget::MSGTYPE_SYSTEM);
rsVOIP->sendVoipHangUpCall(mChatWidget->getChatId().toPeerId(), RS_VOIP_FLAGS_VIDEO_DATA);
}
sendVideoRingTime = -1;
recVideoRingTime = -1;
} }
videoCaptureToggleButtonFS->setChecked(videoCaptureToggleButton->isChecked()); videoCaptureToggleButtonFS->setChecked(videoCaptureToggleButton->isChecked());
videoCaptureToggleButtonFS->setToolTip(videoCaptureToggleButton->toolTip()); videoCaptureToggleButtonFS->setToolTip(videoCaptureToggleButton->toolTip());
@ -485,50 +730,19 @@ void VOIPChatWidgetHolder::toggleVideoCapture()
void VOIPChatWidgetHolder::addVideoData(const RsPeerId &peer_id, QByteArray* array) void VOIPChatWidgetHolder::addVideoData(const RsPeerId &peer_id, QByteArray* array)
{ {
if (!videoCaptureToggleButton->isChecked()) sendVideoRingTime = -2;//Receive Video so Accepted
{ if (!videoCaptureToggleButton->isChecked()) {
if (mChatWidget) { addNewVideoButtonMap(peer_id);
QString buttonName = QString::fromUtf8(rsPeers->getPeerName(peer_id).c_str()); return;
if (buttonName.isEmpty()) buttonName = "VoIP";//TODO maybe change all with GxsId }
button_map::iterator it = buttonMapTakeVideo.find(buttonName);
if (it == buttonMapTakeVideo.end()){
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("%1 inviting you to start a video conversation. do you want Accept or Decline the invitation?").arg(buttonName), ChatWidget::MSGTYPE_SYSTEM);
RSButtonOnText *button = mChatWidget->getNewButtonOnTextBrowser(tr("Accept Video Call"));
button->setToolTip(tr("Activate camera"));
button->setStyleSheet(QString("border: 1px solid #199909;")
.append("font-size: 12pt; color: white;")
.append("min-width: 128px; min-height: 24px;")
.append("border-radius: 6px;")
.append("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.67, "
"stop: 0 #22c70d, stop: 1 #116a06);")
); RsVOIPDataChunk chunk ;
chunk.type = RsVOIPDataChunk::RS_VOIP_DATA_TYPE_VIDEO ;
chunk.size = array->size() ;
chunk.data = array->data() ;
button->updateImage(); videoProcessor->receiveEncodedData(chunk) ;
connect(button,SIGNAL(clicked()),this,SLOT(startVideoCapture()));
connect(button,SIGNAL(mouseEnter()),this,SLOT(botMouseEnter()));
connect(button,SIGNAL(mouseLeave()),this,SLOT(botMouseLeave()));
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
{
RsVOIPDataChunk chunk ;
chunk.type = RsVOIPDataChunk::RS_VOIP_DATA_TYPE_VIDEO ;
chunk.size = array->size() ;
chunk.data = array->data() ;
videoProcessor->receiveEncodedData(chunk) ;
}
} }
void VOIPChatWidgetHolder::toggleHideChatText() void VOIPChatWidgetHolder::toggleHideChatText()
@ -602,34 +816,62 @@ void VOIPChatWidgetHolder::showNormalView()
toggleFullScreen(); toggleFullScreen();
} }
void VOIPChatWidgetHolder::botMouseEnter() void VOIPChatWidgetHolder::botMouseEnterTake()
{ {
RSButtonOnText *source = qobject_cast<RSButtonOnText *>(QObject::sender()); RSButtonOnText *source = qobject_cast<RSButtonOnText *>(QObject::sender());
if (source){ if (source){
source->setStyleSheet(QString("border: 1px solid #333333;") source->setStyleSheet(QString("border: 1px solid #333333;")
.append("font-size: 12pt; color: white;") .append("font-size: 12pt; color: white;")
.append("min-width: 128px; min-height: 24px;") .append("min-width: 128px; min-height: 24px;")
.append("border-radius: 6px;") .append("border-radius: 6px;")
.append("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.67, " .append("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.67, "
"stop: 0 #444444, stop: 1 #222222);") "stop: 0 #444444, stop: 1 #222222);")
);
);
//source->setDown(true); //source->setDown(true);
} }
} }
void VOIPChatWidgetHolder::botMouseLeave() void VOIPChatWidgetHolder::botMouseLeaveTake()
{ {
RSButtonOnText *source = qobject_cast<RSButtonOnText *>(QObject::sender()); RSButtonOnText *source = qobject_cast<RSButtonOnText *>(QObject::sender());
if (source){ if (source){
source->setStyleSheet(QString("border: 1px solid #199909;") source->setStyleSheet(QString("border: 1px solid #199909;")
.append("font-size: 12pt; color: white;") .append("font-size: 12pt; color: white;")
.append("min-width: 128px; min-height: 24px;") .append("min-width: 128px; min-height: 24px;")
.append("border-radius: 6px;") .append("border-radius: 6px;")
.append("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.67, " .append("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.67, "
"stop: 0 #22c70d, stop: 1 #116a06);") "stop: 0 #22c70d, stop: 1 #116a06);")
);
//source->setDown(false);
}
}
); void VOIPChatWidgetHolder::botMouseEnterDecline()
{
RSButtonOnText *source = qobject_cast<RSButtonOnText *>(QObject::sender());
if (source){
source->setStyleSheet(QString("border: 1px solid #333333;")
.append("font-size: 12pt; color: white;")
.append("min-width: 128px; min-height: 24px;")
.append("border-radius: 6px;")
.append("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.67, "
"stop: 0 #444444, stop: 1 #222222);")
);
//source->setDown(true);
}
}
void VOIPChatWidgetHolder::botMouseLeaveDecline()
{
RSButtonOnText *source = qobject_cast<RSButtonOnText *>(QObject::sender());
if (source){
source->setStyleSheet(QString("border: 1px solid #199909;")
.append("font-size: 12pt; color: white;")
.append("min-width: 128px; min-height: 24px;")
.append("border-radius: 6px;")
.append("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.67, "
"stop: 0 #c7220d, stop: 1 #6a1106);")
);
//source->setDown(false); //source->setDown(false);
} }
} }
@ -641,57 +883,9 @@ void VOIPChatWidgetHolder::setAcceptedBandwidth(uint32_t bytes_per_sec)
void VOIPChatWidgetHolder::addAudioData(const RsPeerId &peer_id, QByteArray* array) void VOIPChatWidgetHolder::addAudioData(const RsPeerId &peer_id, QByteArray* array)
{ {
sendAudioRingTime = -2;//Receive Audio so Accepted
if (!audioCaptureToggleButton->isChecked()) { if (!audioCaptureToggleButton->isChecked()) {
//launch an animation. Don't launch it if already animating addNewAudioButtonMap(peer_id);
if (!audioCaptureToggleButton->graphicsEffect() ||
(audioCaptureToggleButton->graphicsEffect()->inherits("QGraphicsOpacityEffect") &&
((QGraphicsOpacityEffect*)audioCaptureToggleButton->graphicsEffect())->opacity() == 1)
) {
QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(audioListenToggleButton);
audioCaptureToggleButton->setGraphicsEffect(effect);
QPropertyAnimation *anim = new QPropertyAnimation(effect, "opacity", effect);
anim->setStartValue(1);
anim->setKeyValueAt(0.5,0);
anim->setEndValue(1);
anim->setDuration(400);
anim->start();
}
if (mChatWidget) {
QString buttonName = QString::fromUtf8(rsPeers->getPeerName(peer_id).c_str());
if (buttonName.isEmpty()) buttonName = "VoIP";//TODO maybe change all with GxsId
button_map::iterator it = buttonMapTakeVideo.find(buttonName);
if (it == buttonMapTakeVideo.end()){
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("%1 inviting you to start a audio conversation. do you want Accept or Decline the invitation?").arg(buttonName), ChatWidget::MSGTYPE_SYSTEM);
RSButtonOnText *button = mChatWidget->getNewButtonOnTextBrowser(tr("Accept Call"));
button->setToolTip(tr("Activate audio"));
button->setStyleSheet(QString("border: 1px solid #199909;")
.append("font-size: 12pt; color: white;")
.append("min-width: 128px; min-height: 24px;")
.append("border-radius: 6px;")
.append("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.67, "
"stop: 0 #22c70d, stop: 1 #116a06);")
);
button->updateImage();
connect(button,SIGNAL(clicked()),this,SLOT(startAudioCapture()));
connect(button,SIGNAL(mouseEnter()),this,SLOT(botMouseEnter()));
connect(button,SIGNAL(mouseLeave()),this,SLOT(botMouseLeave()));
buttonMapTakeVideo.insert(buttonName, button);
}
}
audioCaptureToggleButton->setToolTip(tr("Answer"));
//TODO make a sound for the incoming call
// soundManager->play(VOIP_SOUND_INCOMING_CALL);
if (mVOIPNotify) mVOIPNotify->notifyReceivedVoipAudioCall(peer_id);
return; return;
} }
@ -733,7 +927,7 @@ void VOIPChatWidgetHolder::sendVideoData()
RsVOIPDataChunk chunk ; RsVOIPDataChunk chunk ;
while(inputVideoDevice && inputVideoDevice->getNextEncodedPacket(chunk)) while(inputVideoDevice && inputVideoDevice->getNextEncodedPacket(chunk))
rsVOIP->sendVoipData(mChatWidget->getChatId().toPeerId(),chunk) ; rsVOIP->sendVoipData(mChatWidget->getChatId().toPeerId(),chunk) ;
} }
void VOIPChatWidgetHolder::sendAudioData() void VOIPChatWidgetHolder::sendAudioData()
@ -743,7 +937,7 @@ void VOIPChatWidgetHolder::sendAudioData()
RsVOIPDataChunk chunk; RsVOIPDataChunk chunk;
chunk.size = qbarray.size(); chunk.size = qbarray.size();
chunk.data = (void*)qbarray.constData(); chunk.data = (void*)qbarray.constData();
chunk.type = RsVOIPDataChunk::RS_VOIP_DATA_TYPE_AUDIO ; chunk.type = RsVOIPDataChunk::RS_VOIP_DATA_TYPE_AUDIO ;
rsVOIP->sendVoipData(mChatWidget->getChatId().toPeerId(),chunk); rsVOIP->sendVoipData(mChatWidget->getChatId().toPeerId(),chunk);
} }
} }
@ -752,8 +946,8 @@ void VOIPChatWidgetHolder::updateStatus(int status)
{ {
bool enabled = (status != RS_STATUS_OFFLINE); bool enabled = (status != RS_STATUS_OFFLINE);
audioListenToggleButton->setEnabled(enabled); audioListenToggleButton->setEnabled(audioCaptureToggleButton->isChecked() && enabled);
audioListenToggleButtonFS->setEnabled(enabled); audioListenToggleButtonFS->setEnabled(audioCaptureToggleButton->isChecked() && enabled);
audioCaptureToggleButton->setEnabled(enabled); audioCaptureToggleButton->setEnabled(enabled);
audioCaptureToggleButtonFS->setEnabled(enabled); audioCaptureToggleButtonFS->setEnabled(enabled);
videoCaptureToggleButton->setEnabled(enabled); videoCaptureToggleButton->setEnabled(enabled);
@ -764,3 +958,196 @@ void VOIPChatWidgetHolder::updateStatus(int status)
hangupButton->setEnabled(enabled); hangupButton->setEnabled(enabled);
hangupButtonFS->setEnabled(enabled); hangupButtonFS->setEnabled(enabled);
} }
void VOIPChatWidgetHolder::ReceivedInvitation(const RsPeerId &peer_id, int flags)
{
switch(flags){
case RS_VOIP_FLAGS_AUDIO_DATA: {
if (audioCaptureToggleButton->isChecked()) {
if (recAudioRingTime != -1)
toggleAudioCapture();
} else {
addNewAudioButtonMap(peer_id);
}
}
break;
case RS_VOIP_FLAGS_VIDEO_DATA: {
if (videoCaptureToggleButton->isChecked()) {
if (recVideoRingTime != -1)
toggleVideoCapture();
} else {
addNewVideoButtonMap(peer_id);
}
}
break;
default:
std::cerr << "VOIPChatWidgetHolder::ReceivedInvitation(): Received unknown flags item # " << flags << ": not handled yet ! Sorry" << std::endl;
break ;
}
}
void VOIPChatWidgetHolder::ReceivedVoipHangUp(const RsPeerId &peer_id, int flags)
{
switch(flags){
case RS_VOIP_FLAGS_AUDIO_DATA | RS_VOIP_FLAGS_VIDEO_DATA: {
if (mChatWidget) {
if (videoCaptureToggleButton->isChecked() || audioCaptureToggleButton->isChecked()) {
QString peerName = QString::fromUtf8(rsPeers->getPeerName(peer_id).c_str());
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("%1 hang up. Your call is closed.").arg(peerName), ChatWidget::MSGTYPE_SYSTEM);
}
hangupCall();
}
}
break;
case RS_VOIP_FLAGS_AUDIO_DATA: {
if (mChatWidget) {
if (audioCaptureToggleButton->isChecked()) {
QString peerName = QString::fromUtf8(rsPeers->getPeerName(peer_id).c_str());
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("%1 hang up. Your audio call is closed.").arg(peerName), ChatWidget::MSGTYPE_SYSTEM);
}
hangupCallAudio();
}
}
break;
case RS_VOIP_FLAGS_VIDEO_DATA: {
if (mChatWidget) {
if (videoCaptureToggleButton->isChecked()) {
QString peerName = QString::fromUtf8(rsPeers->getPeerName(peer_id).c_str());
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("%1 hang up. Your video call is closed.").arg(peerName), ChatWidget::MSGTYPE_SYSTEM);
}
hangupCallVideo();
}
}
break;
default:
std::cerr << "VOIPChatWidgetHolder::ReceivedVoipHangUp(): Received unknown flags item # " << flags << ": not handled yet ! Sorry" << std::endl;
break ;
}
//deleteButtonMap();
}
void VOIPChatWidgetHolder::ReceivedVoipAccept(const RsPeerId &peer_id, int flags)
{
switch(flags){
case RS_VOIP_FLAGS_AUDIO_DATA: {
if (mChatWidget) {
sendAudioRingTime = -2;
QString peerName = QString::fromUtf8(rsPeers->getPeerName(peer_id).c_str());
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("%1 accepted your audio call.").arg(peerName), ChatWidget::MSGTYPE_SYSTEM);
if (audioCaptureToggleButton->isChecked())
toggleAudioCapture();
}
}
break;
case RS_VOIP_FLAGS_VIDEO_DATA: {
if (mChatWidget) {
sendVideoRingTime = -2;
QString peerName = QString::fromUtf8(rsPeers->getPeerName(peer_id).c_str());
mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("%1 accepted your video call.").arg(peerName), ChatWidget::MSGTYPE_SYSTEM);
if (videoCaptureToggleButton->isChecked())
toggleVideoCapture();
}
}
break;
default:
std::cerr << "VOIPChatWidgetHolder::ReceivedVoipHangUp(): Received unknown flags item # " << flags << ": not handled yet ! Sorry" << std::endl;
break ;
}
}
void VOIPChatWidgetHolder::timerAudioRingTimeOut()
{
//Sending or receiving (-2 connected, -1 reseted, >=0 in progress)
if (sendAudioRingTime >= 0) {
//Sending
++sendAudioRingTime;
if (sendAudioRingTime == 100) sendAudioRingTime = 0;
pbAudioRing->setValue(sendAudioRingTime);
pbAudioRing->setToolTip(tr("Waiting your friend respond your audio call."));
pbAudioRing->setVisible(true);
timerAudioRing->start();
} else if(recAudioRingTime >= 0) {
//Receiving
++recAudioRingTime;
if (recAudioRingTime == 100) recAudioRingTime = 0;
pbAudioRing->setValue(recAudioRingTime);
pbAudioRing->setToolTip(tr("Your friend is calling you for audio. Respond."));
pbAudioRing->setVisible(true);
//launch an animation. Don't launch it if already animating
if (!audioCaptureToggleButton->graphicsEffect()
|| (audioCaptureToggleButton->graphicsEffect()->inherits("QGraphicsOpacityEffect")
&& ((QGraphicsOpacityEffect*)audioCaptureToggleButton->graphicsEffect())->opacity() == 1)
) {
QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(audioListenToggleButton);
audioCaptureToggleButton->setGraphicsEffect(effect);
QPropertyAnimation *anim = new QPropertyAnimation(effect, "opacity", effect);
anim->setStartValue(1);
anim->setKeyValueAt(0.5,0);
anim->setEndValue(1);
anim->setDuration(timerAudioRing->interval());
anim->start();
}
audioCaptureToggleButton->setToolTip(tr("Answer"));
timerAudioRing->start();
} else {
//Nothing to do, reset stat
pbAudioRing->setHidden(true);
pbAudioRing->setValue(0);
pbAudioRing->setToolTip("");
audioCaptureToggleButton->setGraphicsEffect(0);
}
}
void VOIPChatWidgetHolder::timerVideoRingTimeOut()
{
//Sending or receiving (-2 connected, -1 reseted, >=0 in progress)
if (sendVideoRingTime >= 0) {
//Sending
++sendVideoRingTime;
if (sendVideoRingTime == 100) sendVideoRingTime = 0;
pbVideoRing->setValue(sendVideoRingTime);
pbVideoRing->setToolTip(tr("Waiting your friend respond your video call."));
pbVideoRing->setVisible(true);
timerVideoRing->start();
} else if(recVideoRingTime >= 0) {
//Receiving
++recVideoRingTime;
if (recVideoRingTime == 100) recVideoRingTime = 0;
pbVideoRing->setValue(recVideoRingTime);
pbVideoRing->setToolTip(tr("Your friend is calling you for video. Respond."));
pbVideoRing->setVisible(true);
//launch an animation. Don't launch it if already animating
if (!videoCaptureToggleButton->graphicsEffect()
|| (videoCaptureToggleButton->graphicsEffect()->inherits("QGraphicsOpacityEffect")
&& ((QGraphicsOpacityEffect*)videoCaptureToggleButton->graphicsEffect())->opacity() == 1)
) {
QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(audioListenToggleButton);
videoCaptureToggleButton->setGraphicsEffect(effect);
QPropertyAnimation *anim = new QPropertyAnimation(effect, "opacity", effect);
anim->setStartValue(1);
anim->setKeyValueAt(0.5,0);
anim->setEndValue(1);
anim->setDuration(timerVideoRing->interval());
anim->start();
}
videoCaptureToggleButton->setToolTip(tr("Answer"));
timerVideoRing->start();
} else {
//Nothing to do, reset stat
pbVideoRing->setHidden(true);
pbVideoRing->setValue(0);
pbVideoRing->setToolTip("");
videoCaptureToggleButton->setGraphicsEffect(0);
}
}

View File

@ -20,12 +20,16 @@
****************************************************************/ ****************************************************************/
#pragma once #pragma once
//Qt
#include "gui/VOIPNotify.h"
#include <QObject> #include <QObject>
#include <QGraphicsEffect> #include <QGraphicsEffect>
#include <QProgressBar>
#include <QTimer>
//VOIP
#include "gui/VOIPNotify.h"
#include <gui/SpeexProcessor.h> #include <gui/SpeexProcessor.h>
#include "services/rsVOIPItems.h"
//retroshare-gui
#include <gui/chat/ChatWidget.h> #include <gui/chat/ChatWidget.h>
#include <gui/common/RsButtonOnText.h> #include <gui/common/RsButtonOnText.h>
@ -52,6 +56,10 @@ public:
void addVideoData(const RsPeerId &peer_id, QByteArray* array) ; void addVideoData(const RsPeerId &peer_id, QByteArray* array) ;
void setAcceptedBandwidth(uint32_t bytes_per_sec) ; void setAcceptedBandwidth(uint32_t bytes_per_sec) ;
void ReceivedInvitation(const RsPeerId &peer_id, int flags) ;
void ReceivedVoipHangUp(const RsPeerId &peer_id, int flags) ;
void ReceivedVoipAccept(const RsPeerId &peer_id, int flags) ;
public slots: public slots:
void sendAudioData(); void sendAudioData();
void sendVideoData(); void sendVideoData();
@ -69,10 +77,19 @@ private slots:
void toggleFullScreen(); void toggleFullScreen();
void toggleFullScreenFS(); void toggleFullScreenFS();
void hangupCall() ; void hangupCall() ;
void botMouseEnter(); void hangupCallAudio() ;
void botMouseLeave(); void hangupCallVideo() ;
void botMouseEnterTake();
void botMouseLeaveTake();
void botMouseEnterDecline();
void botMouseLeaveDecline();
void timerAudioRingTimeOut();
void timerVideoRingTimeOut();
private: private:
void deleteButtonMap(int flags = RS_VOIP_FLAGS_AUDIO_DATA | RS_VOIP_FLAGS_VIDEO_DATA);
void addNewVideoButtonMap(const RsPeerId &peer_id);
void addNewAudioButtonMap(const RsPeerId &peer_id);
void replaceFullscreenWidget(); void replaceFullscreenWidget();
void showNormalView(); void showNormalView();
@ -115,8 +132,18 @@ protected:
QToolButton *hangupButtonFS ; QToolButton *hangupButtonFS ;
QFrame *toolBarFS; QFrame *toolBarFS;
typedef QMap<QString, RSButtonOnText*> button_map; typedef QMap<QString, QPair<RSButtonOnText*, RSButtonOnText*> > button_map;
button_map buttonMapTakeVideo; button_map buttonMapTakeCall;
//Waiting for peer accept
QProgressBar *pbAudioRing;
QProgressBar *pbVideoRing;
QTimer *timerAudioRing;
QTimer *timerVideoRing;
int sendAudioRingTime; //(-2 connected, -1 reseted, >=0 in progress)
int sendVideoRingTime; //(-2 connected, -1 reseted, >=0 in progress)
int recAudioRingTime; //(-2 connected, -1 reseted, >=0 in progress)
int recVideoRingTime; //(-2 connected, -1 reseted, >=0 in progress)
VOIPNotify *mVOIPNotify; VOIPNotify *mVOIPNotify;
}; };

View File

@ -22,28 +22,89 @@
#include <vector> #include <vector>
#include <list> #include <list>
#include "VOIPGUIHandler.h" #include "VOIPGUIHandler.h"
#include <gui/chat/ChatDialog.h>
#include <gui/VOIPChatWidgetHolder.h> #include <gui/VOIPChatWidgetHolder.h>
#include <gui/chat/ChatDialog.h>
#include "gui/chat/ChatWidget.h" #include "gui/chat/ChatWidget.h"
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
void VOIPGUIHandler::ReceivedInvitation(const RsPeerId &/*peer_id*/) void VOIPGUIHandler::ReceivedInvitation(const RsPeerId &peer_id, int flags)
{ {
std::cerr << "****** VOIPGUIHandler: received Invitation!" << std::endl; #ifdef VOIPGUIHANDLER_DEBUG
std::cerr << "****** VOIPGUIHandler: received Invitation from peer " << peer_id.toStdString() << " with flags==" << flags << std::endl;
#endif
ChatDialog *di = ChatDialog::getChat(ChatId(peer_id), Settings->getChatFlags());
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->ReceivedInvitation(peer_id, flags);
}
}
} else {
std::cerr << "VOIPGUIHandler::ReceivedInvitation() Error: received invitaion call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
}
} }
void VOIPGUIHandler::ReceivedVoipHangUp(const RsPeerId &/*peer_id*/) void VOIPGUIHandler::ReceivedVoipHangUp(const RsPeerId &peer_id, int flags)
{ {
std::cerr << "****** VOIPGUIHandler: received HangUp!" << std::endl; #ifdef VOIPGUIHANDLER_DEBUG
std::cerr << "****** VOIPGUIHandler: received HangUp from peer " << peer_id.toStdString() << " with flags==" << flags << std::endl;
#endif
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->ReceivedVoipHangUp(peer_id, flags);
}
}
} else {
std::cerr << "VOIPGUIHandler::ReceivedVoipHangUp() Error: Received hangup call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
}
} }
void VOIPGUIHandler::ReceivedVoipAccept(const RsPeerId &/*peer_id*/) void VOIPGUIHandler::ReceivedVoipAccept(const RsPeerId &peer_id, int flags)
{ {
std::cerr << "****** VOIPGUIHandler: received VoipAccept!" << std::endl; #ifdef VOIPGUIHANDLER_DEBUG
std::cerr << "****** VOIPGUIHandler: received VoipAccept from peer " << peer_id.toStdString() << " with flags==" << flags << std::endl;
#endif
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->ReceivedVoipAccept(peer_id, flags);
}
}
} else {
std::cerr << "VOIPGUIHandler::ReceivedVoipAccept() Error: Received accept call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
}
} }
void VOIPGUIHandler::ReceivedVoipData(const RsPeerId &peer_id) void VOIPGUIHandler::ReceivedVoipData(const RsPeerId &peer_id)
{ {
#ifdef VOIPGUIHANDLER_DEBUG
std::cerr << "****** VOIPGUIHandler: received VoipData from peer " << peer_id.toStdString() << std::endl;
#endif
std::vector<RsVOIPDataChunk> chunks ; std::vector<RsVOIPDataChunk> chunks ;
if(!rsVOIP->getIncomingData(peer_id,chunks)) if(!rsVOIP->getIncomingData(peer_id,chunks))
@ -72,14 +133,14 @@ void VOIPGUIHandler::ReceivedVoipData(const RsPeerId &peer_id)
else if(chunks[chunkIndex].type == RsVOIPDataChunk::RS_VOIP_DATA_TYPE_VIDEO) else if(chunks[chunkIndex].type == RsVOIPDataChunk::RS_VOIP_DATA_TYPE_VIDEO)
acwh->addVideoData(peer_id, &qb); acwh->addVideoData(peer_id, &qb);
else else
std::cerr << "VOIPGUIHandler: Unknown data type received. type=" << chunks[chunkIndex].type << std::endl; std::cerr << "VOIPGUIHandler::ReceivedVoipData(): Unknown data type received. type=" << chunks[chunkIndex].type << std::endl;
} }
break; break;
} }
} }
} }
} else { } else {
std::cerr << "VOIPGUIHandler Error: received audio data for a chat dialog that does not stand Audio (Peer id = " << peer_id.toStdString() << "!" << std::endl; std::cerr << "VOIPGUIHandler::ReceivedVoipData() Error: received data for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
} }
for(unsigned int chunkIndex=0; chunkIndex<chunks.size(); chunkIndex++){ for(unsigned int chunkIndex=0; chunkIndex<chunks.size(); chunkIndex++){
@ -89,34 +150,40 @@ void VOIPGUIHandler::ReceivedVoipData(const RsPeerId &peer_id)
void VOIPGUIHandler::ReceivedVoipBandwidthInfo(const RsPeerId &peer_id, int bytes_per_sec) void VOIPGUIHandler::ReceivedVoipBandwidthInfo(const RsPeerId &peer_id, int bytes_per_sec)
{ {
ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ; #ifdef VOIPGUIHANDLER_DEBUG
std::cerr << "VOIPGUIHandler::received bw info for peer " << peer_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;
#endif
ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ;
if(!di) 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;
return ;
}
ChatWidget *cw = di->getChatWidget(); ChatWidget *cw = di->getChatWidget();
if(!cw) if(!cw)
{ {
return ; return ;
} }
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList(); const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList) foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList)
{ {
VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ; VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;
if (acwh) if (acwh)
acwh->setAcceptedBandwidth(bytes_per_sec); acwh->setAcceptedBandwidth(bytes_per_sec);
}
} else {
std::cerr << "VOIPGUIHandler::ReceivedVoipBandwidthInfo() Error: received bandwidth info for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
} }
} }
void VOIPGUIHandler::AnswerAudioCall(const RsPeerId &peer_id) void VOIPGUIHandler::AnswerAudioCall(const RsPeerId &peer_id)
{ {
#ifdef VOIPGUIHANDLER_DEBUG
std::cerr << "VOIPGUIHandler::Answer to Audio Call for peer " << peer_id.toStdString() << std::endl;
#endif
ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ; ChatDialog *di = ChatDialog::getExistingChat(ChatId(peer_id)) ;
if (di) { if (di) {
ChatWidget *cw = di->getChatWidget(); ChatWidget *cw = di->getChatWidget();
@ -132,9 +199,8 @@ void VOIPGUIHandler::AnswerAudioCall(const RsPeerId &peer_id)
} }
} }
} else { } else {
std::cerr << "VOIPGUIHandler Error: answer audio call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl; std::cerr << "VOIPGUIHandler::AnswerAudioCall() 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) void VOIPGUIHandler::AnswerVideoCall(const RsPeerId &peer_id)
@ -154,7 +220,6 @@ void VOIPGUIHandler::AnswerVideoCall(const RsPeerId &peer_id)
} }
} }
} else { } else {
std::cerr << "VOIPGUIHandler Error: answer video call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl; std::cerr << "VOIPGUIHandler::AnswerVideoCall() Error: answer video call for a chat dialog that does not stand VOIP (Peer id = " << peer_id.toStdString() << "!" << std::endl;
} }
} }

View File

@ -32,6 +32,9 @@
#include <stdint.h> #include <stdint.h>
#include <QObject> #include <QObject>
/***
#define VOIPGUIHANDLER_DEBUG 1
***/
class VOIPGUIHandler: public QObject class VOIPGUIHandler: public QObject
{ {
@ -41,9 +44,9 @@ public:
static void AnswerVideoCall(const RsPeerId &peer_id) ; static void AnswerVideoCall(const RsPeerId &peer_id) ;
public slots: public slots:
void ReceivedInvitation(const RsPeerId &peer_id) ; void ReceivedInvitation(const RsPeerId &peer_id, int flags) ;
void ReceivedVoipData(const RsPeerId &peer_id) ; void ReceivedVoipData(const RsPeerId &peer_id) ;
void ReceivedVoipHangUp(const RsPeerId &peer_id) ; void ReceivedVoipHangUp(const RsPeerId &peer_id, int flags) ;
void ReceivedVoipAccept(const RsPeerId &peer_id) ; void ReceivedVoipAccept(const RsPeerId &peer_id, int flags) ;
void ReceivedVoipBandwidthInfo(const RsPeerId &peer_id, int) ; void ReceivedVoipBandwidthInfo(const RsPeerId &peer_id, int) ;
}; };

View File

@ -23,9 +23,9 @@
//Call qRegisterMetaType<RsPeerId>("RsPeerId"); to enable these SIGNALs //Call qRegisterMetaType<RsPeerId>("RsPeerId"); to enable these SIGNALs
void VOIPNotify::notifyReceivedVoipAccept(const RsPeerId& peer_id) void VOIPNotify::notifyReceivedVoipAccept(const RsPeerId& peer_id, const uint32_t flags)
{ {
emit voipAcceptReceived(peer_id) ; emit voipAcceptReceived(peer_id, flags) ;
} }
void VOIPNotify::notifyReceivedVoipBandwidth(const RsPeerId &peer_id,uint32_t bytes_per_sec) void VOIPNotify::notifyReceivedVoipBandwidth(const RsPeerId &peer_id,uint32_t bytes_per_sec)
{ {
@ -35,13 +35,13 @@ void VOIPNotify::notifyReceivedVoipData(const RsPeerId &peer_id)
{ {
emit voipDataReceived(peer_id) ; emit voipDataReceived(peer_id) ;
} }
void VOIPNotify::notifyReceivedVoipHangUp(const RsPeerId &peer_id) void VOIPNotify::notifyReceivedVoipHangUp(const RsPeerId &peer_id, const uint32_t flags)
{ {
emit voipHangUpReceived(peer_id) ; emit voipHangUpReceived(peer_id, flags) ;
} }
void VOIPNotify::notifyReceivedVoipInvite(const RsPeerId& peer_id) void VOIPNotify::notifyReceivedVoipInvite(const RsPeerId& peer_id, const uint32_t flags)
{ {
emit voipInvitationReceived(peer_id) ; emit voipInvitationReceived(peer_id, flags) ;
} }
void VOIPNotify::notifyReceivedVoipAudioCall(const RsPeerId &peer_id) void VOIPNotify::notifyReceivedVoipAudioCall(const RsPeerId &peer_id)
{ {

View File

@ -38,21 +38,20 @@ class VOIPNotify: public QObject
Q_OBJECT Q_OBJECT
public: public:
void notifyReceivedVoipAccept(const RsPeerId &peer_id) ; void notifyReceivedVoipAccept(const RsPeerId &peer_id, const uint32_t flags) ;
void notifyReceivedVoipBandwidth(const RsPeerId &peer_id, uint32_t bytes_per_sec) ; void notifyReceivedVoipBandwidth(const RsPeerId &peer_id, uint32_t bytes_per_sec) ;
void notifyReceivedVoipData(const RsPeerId &peer_id) ; void notifyReceivedVoipData(const RsPeerId &peer_id) ;
void notifyReceivedVoipHangUp(const RsPeerId &peer_id) ; void notifyReceivedVoipHangUp(const RsPeerId &peer_id, const uint32_t flags) ;
void notifyReceivedVoipInvite(const RsPeerId &peer_id) ; void notifyReceivedVoipInvite(const RsPeerId &peer_id, const uint32_t flags) ;
void notifyReceivedVoipAudioCall(const RsPeerId &peer_id) ; void notifyReceivedVoipAudioCall(const RsPeerId &peer_id) ;
void notifyReceivedVoipVideoCall(const RsPeerId &peer_id) ; void notifyReceivedVoipVideoCall(const RsPeerId &peer_id) ;
signals: signals:
void voipAcceptReceived(const RsPeerId &peer_id) ; // emitted when the peer accepts the call void voipAcceptReceived(const RsPeerId &peer_id, int flags) ; // 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 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 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 voipHangUpReceived(const RsPeerId &peer_id, int flags) ; // 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 voipInvitationReceived(const RsPeerId &peer_id, int flags) ; // 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 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 void voipVideoCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send video
}; };

View File

@ -79,7 +79,8 @@ void VOIPToasterItem::chatButtonSlot()
hide(); hide();
} }
void VOIPToasterItem::voipAcceptReceived(const RsPeerId &) #ifdef VOIPTOASTERNOTIFY_ALL
void VOIPToasterItem::voipAcceptReceived(const RsPeerId &, int )
{ {
} }
@ -91,11 +92,11 @@ void VOIPToasterItem::voipDataReceived(const RsPeerId &)
{ {
} }
void VOIPToasterItem::voipHangUpReceived(const RsPeerId &) void VOIPToasterItem::voipHangUpReceived(const RsPeerId &, int )
{ {
} }
void VOIPToasterItem::voipInvitationReceived(const RsPeerId &) void VOIPToasterItem::voipInvitationReceived(const RsPeerId &, int )
{ {
} }
@ -106,4 +107,4 @@ void VOIPToasterItem::voipAudioCallReceived(const RsPeerId &)
void VOIPToasterItem::voipVideoCallReceived(const RsPeerId &) void VOIPToasterItem::voipVideoCallReceived(const RsPeerId &)
{ {
} }
#endif

View File

@ -45,13 +45,15 @@ public:
private slots: private slots:
void chatButtonSlot(); void chatButtonSlot();
void voipAcceptReceived(const RsPeerId &peer_id) ; // emitted when the peer accepts the call #ifdef VOIPTOASTERNOTIFY_ALL
void voipAcceptReceived(const RsPeerId &peer_id, int flags) ; // 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 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 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 voipHangUpReceived(const RsPeerId &peer_id, int flags) ; // 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 voipInvitationReceived(const RsPeerId &peer_id, int flags) ; // 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 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 void voipVideoCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send video
#endif
private: private:
RsPeerId mPeerId; RsPeerId mPeerId;

View File

@ -36,11 +36,11 @@ VOIPToasterNotify::VOIPToasterNotify(RsVOIP *VOIP, VOIPNotify *notify, QObject *
mMutex = new QMutex(); mMutex = new QMutex();
#ifdef VOIPTOASTERNOTIFY_ALL #ifdef VOIPTOASTERNOTIFY_ALL
connect(mVOIPNotify, SIGNAL(voipAcceptReceived(const RsPeerId&)), this, SLOT(voipAcceptReceived(const RsPeerId&)), Qt::QueuedConnection); connect(mVOIPNotify, SIGNAL(voipAcceptReceived(const RsPeerId&, int)), this, SLOT(voipAcceptReceived(const RsPeerId&, int)), Qt::QueuedConnection);
connect(mVOIPNotify, SIGNAL(voipBandwidthInfoReceived(const RsPeerId&, int)), this, SLOT(voipBandwidthInfoReceived(RsPeerId&, int)), 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(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(voipHangUpReceived(const RsPeerId&, int)), this, SLOT(voipHangUpReceived(const RsPeerId&, int)), Qt::QueuedConnection);
connect(mVOIPNotify, SIGNAL(voipInvitationReceived(const RsPeerId&)), this, SLOT(voipInvitationReceived(const RsPeerId&)), Qt::QueuedConnection); connect(mVOIPNotify, SIGNAL(voipInvitationReceived(const RsPeerId&, int)), this, SLOT(voipInvitationReceived(const RsPeerId&, int)), Qt::QueuedConnection);
#endif #endif
connect(mVOIPNotify, SIGNAL(voipAudioCallReceived(const RsPeerId&)), this, SLOT(voipAudioCallReceived(const RsPeerId&)), Qt::QueuedConnection); 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); connect(mVOIPNotify, SIGNAL(voipVideoCallReceived(const RsPeerId&)), this, SLOT(voipVideoCallReceived(const RsPeerId&)), Qt::QueuedConnection);
@ -186,7 +186,7 @@ ToasterItem* VOIPToasterNotify::testToasterItem(QString tag)
} }
#ifdef VOIPTOASTERNOTIFY_ALL #ifdef VOIPTOASTERNOTIFY_ALL
void VOIPToasterNotify::voipAcceptReceived(const RsPeerId &peer_id) void VOIPToasterNotify::voipAcceptReceived(const RsPeerId &peer_id, int flags)
{ {
if (peer_id.isNull()) { if (peer_id.isNull()) {
return; return;
@ -258,7 +258,7 @@ void VOIPToasterNotify::voipDataReceived(const RsPeerId &peer_id)
mMutex->unlock(); mMutex->unlock();
} }
void VOIPToasterNotify::voipHangUpReceived(const RsPeerId &peer_id) void VOIPToasterNotify::voipHangUpReceived(const RsPeerId &peer_id, int flags)
{ {
if (peer_id.isNull()) { if (peer_id.isNull()) {
return; return;
@ -282,7 +282,7 @@ void VOIPToasterNotify::voipHangUpReceived(const RsPeerId &peer_id)
mMutex->unlock(); mMutex->unlock();
} }
void VOIPToasterNotify::voipInvitationReceived(const RsPeerId &peer_id) void VOIPToasterNotify::voipInvitationReceived(const RsPeerId &peer_id, int flags)
{ {
if (peer_id.isNull()) { if (peer_id.isNull()) {
return; return;

View File

@ -60,11 +60,11 @@ public:
private slots: private slots:
#ifdef VOIPTOASTERNOTIFY_ALL #ifdef VOIPTOASTERNOTIFY_ALL
void voipAcceptReceived(const RsPeerId &peer_id) ; // emitted when the peer accepts the call void voipAcceptReceived(const RsPeerId &peer_id, int flags) ; // 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 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 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 voipHangUpReceived(const RsPeerId &peer_id, int flags) ; // 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 voipInvitationReceived(const RsPeerId &peer_id, int flags) ; // signal emitted when an invitation has been received
#endif #endif
void voipAudioCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send audio 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 void voipVideoCallReceived(const RsPeerId &peer_id) ; // emitted when the peer is calling and own don't send video

View File

@ -65,9 +65,9 @@ struct RsVOIPDataChunk
class RsVOIP class RsVOIP
{ {
public: public:
virtual int sendVoipHangUpCall(const RsPeerId& peer_id) = 0; virtual int sendVoipHangUpCall(const RsPeerId& peer_id, uint32_t flags) = 0;
virtual int sendVoipRinging(const RsPeerId& peer_id) = 0; virtual int sendVoipRinging(const RsPeerId& peer_id, uint32_t flags) = 0;
virtual int sendVoipAcceptCall(const RsPeerId& peer_id) = 0; virtual int sendVoipAcceptCall(const RsPeerId& peer_id, uint32_t flags) = 0;
// Sending data. The client keeps the memory ownership and must delete it after calling this. // Sending data. The client keeps the memory ownership and must delete it after calling this.
virtual int sendVoipData(const RsPeerId& peer_id,const RsVOIPDataChunk& chunk) = 0; virtual int sendVoipData(const RsPeerId& peer_id,const RsVOIPDataChunk& chunk) = 0;

View File

@ -219,36 +219,36 @@ void p3VOIP::sendBandwidthInfo()
} }
} }
int p3VOIP::sendVoipHangUpCall(const RsPeerId &peer_id) int p3VOIP::sendVoipHangUpCall(const RsPeerId &peer_id, uint32_t flags)
{ {
RsVOIPProtocolItem *item = new RsVOIPProtocolItem ; RsVOIPProtocolItem *item = new RsVOIPProtocolItem ;
item->protocol = RsVOIPProtocolItem::VoipProtocol_Close; item->protocol = RsVOIPProtocolItem::VoipProtocol_Close;
item->flags = 0 ; item->flags = flags ;
item->PeerId(peer_id) ; item->PeerId(peer_id) ;
sendItem(item) ; sendItem(item) ;
return true ; return true ;
} }
int p3VOIP::sendVoipAcceptCall(const RsPeerId& peer_id) int p3VOIP::sendVoipAcceptCall(const RsPeerId& peer_id, uint32_t flags)
{ {
RsVOIPProtocolItem *item = new RsVOIPProtocolItem ; RsVOIPProtocolItem *item = new RsVOIPProtocolItem ;
item->protocol = RsVOIPProtocolItem::VoipProtocol_Ackn ; item->protocol = RsVOIPProtocolItem::VoipProtocol_Ackn ;
item->flags = 0 ; item->flags = flags ;
item->PeerId(peer_id) ; item->PeerId(peer_id) ;
sendItem(item) ; sendItem(item) ;
return true ; return true ;
} }
int p3VOIP::sendVoipRinging(const RsPeerId &peer_id) int p3VOIP::sendVoipRinging(const RsPeerId &peer_id, uint32_t flags)
{ {
RsVOIPProtocolItem *item = new RsVOIPProtocolItem ; RsVOIPProtocolItem *item = new RsVOIPProtocolItem ;
item->protocol = RsVOIPProtocolItem::VoipProtocol_Ring ; item->protocol = RsVOIPProtocolItem::VoipProtocol_Ring ;
item->flags = 0 ; item->flags = flags ;
item->PeerId(peer_id) ; item->PeerId(peer_id) ;
sendItem(item) ; sendItem(item) ;
@ -362,33 +362,31 @@ void p3VOIP::handleProtocol(RsVOIPProtocolItem *item)
switch(item->protocol) switch(item->protocol)
{ {
case RsVOIPProtocolItem::VoipProtocol_Ring: mNotify->notifyReceivedVoipInvite(item->PeerId()); case RsVOIPProtocolItem::VoipProtocol_Ring: mNotify->notifyReceivedVoipInvite(item->PeerId(), (uint32_t)item->flags);
#ifdef DEBUG_VOIP #ifdef DEBUG_VOIP
std::cerr << "p3VOIP::handleProtocol(): Received protocol ring item." << std::endl; std::cerr << "p3VOIP::handleProtocol(): Received protocol ring item." << std::endl;
#endif #endif
break ; break ;
case RsVOIPProtocolItem::VoipProtocol_Ackn: mNotify->notifyReceivedVoipAccept(item->PeerId()); case RsVOIPProtocolItem::VoipProtocol_Ackn: mNotify->notifyReceivedVoipAccept(item->PeerId(), (uint32_t)item->flags);
#ifdef DEBUG_VOIP #ifdef DEBUG_VOIP
std::cerr << "p3VOIP::handleProtocol(): Received protocol accept call" << std::endl; std::cerr << "p3VOIP::handleProtocol(): Received protocol accept call" << std::endl;
#endif #endif
break ; break ;
case RsVOIPProtocolItem::VoipProtocol_Close: mNotify->notifyReceivedVoipHangUp(item->PeerId()); case RsVOIPProtocolItem::VoipProtocol_Close: mNotify->notifyReceivedVoipHangUp(item->PeerId(), (uint32_t)item->flags);
#ifdef DEBUG_VOIP #ifdef DEBUG_VOIP
std::cerr << "p3VOIP::handleProtocol(): Received protocol Close call." << std::endl; std::cerr << "p3VOIP::handleProtocol(): Received protocol Close call." << std::endl;
#endif #endif
break ; break ;
case RsVOIPProtocolItem::VoipProtocol_Bandwidth: mNotify->notifyReceivedVoipBandwidth(item->PeerId(),(uint32_t)item->flags); case RsVOIPProtocolItem::VoipProtocol_Bandwidth: mNotify->notifyReceivedVoipBandwidth(item->PeerId(),(uint32_t)item->flags);
#ifdef DEBUG_VOIP #ifdef DEBUG_VOIP
std::cerr << "p3VOIP::handleProtocol(): Received protocol bandwidth. Value=" << item->flags << std::endl; std::cerr << "p3VOIP::handleProtocol(): Received protocol bandwidth. Value=" << item->flags << std::endl;
#endif #endif
break ; break ;
default: default:
#ifdef DEBUG_VOIP std::cerr << "p3VOIP::handleProtocol(): Received protocol item # " << item->protocol << ": not handled yet ! Sorry" << std::endl;
std::cerr << "p3VOIP::handleProtocol(): Received protocol item # " << item->protocol << ": not handled yet ! Sorry" << std::endl; break ;
#endif
break ;
} }
} }

View File

@ -83,9 +83,9 @@ class p3VOIP: public RsPQIService, public RsVOIP
// //
virtual bool getIncomingData(const RsPeerId& peer_id,std::vector<RsVOIPDataChunk>& chunks) ; virtual bool getIncomingData(const RsPeerId& peer_id,std::vector<RsVOIPDataChunk>& chunks) ;
virtual int sendVoipHangUpCall(const RsPeerId& peer_id) ; virtual int sendVoipHangUpCall(const RsPeerId& peer_id, uint32_t flags) ;
virtual int sendVoipRinging(const RsPeerId& peer_id) ; virtual int sendVoipRinging(const RsPeerId& peer_id, uint32_t flags) ;
virtual int sendVoipAcceptCall(const RsPeerId &peer_id) ; virtual int sendVoipAcceptCall(const RsPeerId &peer_id, uint32_t flags) ;
/***** overloaded from p3Service *****/ /***** overloaded from p3Service *****/
/*! /*!

View File

@ -71,7 +71,7 @@ std::ostream& RsVOIPProtocolItem::print(std::ostream &out, uint16_t indent)
out << "flags: " << flags << std::endl; out << "flags: " << flags << std::endl;
printIndent(out, int_Indent); printIndent(out, int_Indent);
out << "protocol: " << std::hex << protocol << std::dec << std::endl; out << "protocol: " << std::hex << (uint32_t)protocol << std::dec << std::endl;
printRsItemEnd(out, "RsVOIPProtocolItem", indent); printRsItemEnd(out, "RsVOIPProtocolItem", indent);
return out; return out;
@ -160,7 +160,7 @@ bool RsVOIPProtocolItem::serialise(void *data, uint32_t& pktsize)
offset += 8; offset += 8;
/* add mandatory parts first */ /* add mandatory parts first */
ok &= setRawUInt32(data, tlvsize, &offset, protocol); ok &= setRawUInt32(data, tlvsize, &offset, (uint32_t)protocol);
ok &= setRawUInt32(data, tlvsize, &offset, flags); ok &= setRawUInt32(data, tlvsize, &offset, flags);
if (offset != tlvsize) if (offset != tlvsize)
@ -300,7 +300,9 @@ RsVOIPProtocolItem::RsVOIPProtocolItem(void *data, uint32_t pktsize)
offset += 8; offset += 8;
/* get mandatory parts first */ /* get mandatory parts first */
ok &= getRawUInt32(data, rssize, &offset, &protocol); uint32_t uint_Protocol;
ok &= getRawUInt32(data, rssize, &offset, &uint_Protocol);
protocol = static_cast<en_Protocol>(uint_Protocol);
ok &= getRawUInt32(data, rssize, &offset, &flags); ok &= getRawUInt32(data, rssize, &offset, &flags);
if (offset != rssize) if (offset != rssize)

View File

@ -76,8 +76,8 @@ class RsVOIPItem: public RsItem
setPriorityLevel(QOS_PRIORITY_RS_VOIP) ; setPriorityLevel(QOS_PRIORITY_RS_VOIP) ;
} }
virtual ~RsVOIPItem() {}; virtual ~RsVOIPItem() {}
virtual void clear() {}; virtual void clear() {}
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) = 0 ; virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) = 0 ;
virtual bool serialise(void *data,uint32_t& size) = 0 ; // Isn't it better that items can serialise themselves ? virtual bool serialise(void *data,uint32_t& size) = 0 ; // Isn't it better that items can serialise themselves ?
@ -138,14 +138,13 @@ class RsVOIPBandwidthItem: public RsVOIPItem
uint32_t bytes_per_sec ; // bandwidth in bytes per sec. uint32_t bytes_per_sec ; // bandwidth in bytes per sec.
}; };
class RsVOIPProtocolItem: public RsVOIPItem class RsVOIPProtocolItem: public RsVOIPItem
{ {
public: public:
RsVOIPProtocolItem() :RsVOIPItem(RS_PKT_SUBTYPE_VOIP_PROTOCOL) {} RsVOIPProtocolItem() :RsVOIPItem(RS_PKT_SUBTYPE_VOIP_PROTOCOL) {}
RsVOIPProtocolItem(void *data,uint32_t size) ; RsVOIPProtocolItem(void *data,uint32_t size) ;
enum { VoipProtocol_Ring = 1, VoipProtocol_Ackn = 2, VoipProtocol_Close = 3, VoipProtocol_Bandwidth = 4 } ; typedef enum { VoipProtocol_Ring = 1, VoipProtocol_Ackn = 2, VoipProtocol_Close = 3, VoipProtocol_Bandwidth = 4 } en_Protocol;
virtual bool serialise(void *data,uint32_t& size) ; virtual bool serialise(void *data,uint32_t& size) ;
virtual uint32_t serial_size() const ; virtual uint32_t serial_size() const ;
@ -153,7 +152,7 @@ class RsVOIPProtocolItem: public RsVOIPItem
virtual ~RsVOIPProtocolItem() {} virtual ~RsVOIPProtocolItem() {}
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0); virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
uint32_t protocol ; en_Protocol protocol ;
uint32_t flags ; uint32_t flags ;
}; };