2012-02-25 13:15:36 -05:00
|
|
|
#include <iostream>
|
2012-02-25 16:03:06 -05:00
|
|
|
#include <vector>
|
|
|
|
#include <list>
|
|
|
|
#include <interface/rsvoip.h>
|
2012-02-25 13:15:36 -05:00
|
|
|
#include "PluginGUIHandler.h"
|
2012-02-25 16:03:06 -05:00
|
|
|
#include <gui/chat/ChatDialog.h>
|
2014-01-01 19:56:46 -05:00
|
|
|
#include <gui/AudioChatWidgetHolder.h>
|
|
|
|
#include "gui/chat/ChatWidget.h"
|
2012-02-25 13:15:36 -05:00
|
|
|
|
2012-09-30 05:38:13 -04:00
|
|
|
void PluginGUIHandler::ReceivedInvitation(const QString& /*peer_id*/)
|
2012-02-25 13:15:36 -05:00
|
|
|
{
|
2012-02-26 15:31:16 -05:00
|
|
|
std::cerr << "****** Plugin GUI handler: received Invitation!" << std::endl;
|
2012-02-25 13:15:36 -05:00
|
|
|
}
|
|
|
|
|
2012-09-30 05:38:13 -04:00
|
|
|
void PluginGUIHandler::ReceivedVoipHangUp(const QString& /*peer_id*/)
|
2012-02-26 10:49:07 -05:00
|
|
|
{
|
|
|
|
std::cerr << "****** Plugin GUI handler: received HangUp!" << std::endl;
|
|
|
|
}
|
|
|
|
|
2012-09-30 05:38:13 -04:00
|
|
|
void PluginGUIHandler::ReceivedVoipAccept(const QString& /*peer_id*/)
|
2012-02-26 10:49:07 -05:00
|
|
|
{
|
|
|
|
std::cerr << "****** Plugin GUI handler: received VoipAccept!" << std::endl;
|
|
|
|
}
|
|
|
|
|
2012-02-25 13:15:36 -05:00
|
|
|
void PluginGUIHandler::ReceivedVoipData(const QString& peer_id)
|
|
|
|
{
|
2012-02-26 15:31:16 -05:00
|
|
|
std::cerr << "****** Plugin GUI handler: received VoipData!" << std::endl;
|
2012-02-25 16:03:06 -05:00
|
|
|
|
|
|
|
std::vector<RsVoipDataChunk> chunks ;
|
|
|
|
|
|
|
|
if(!rsVoip->getIncomingData(peer_id.toStdString(),chunks))
|
|
|
|
{
|
|
|
|
std::cerr << "PluginGUIHandler::ReceivedVoipData(): No data chunks to get. Weird!" << std::endl;
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
2014-01-01 19:56:46 -05:00
|
|
|
ChatDialog *di = ChatDialog::getExistingChat(peer_id.toStdString()) ;
|
|
|
|
if (di) {
|
|
|
|
ChatWidget *cw = di->getChatWidget();
|
|
|
|
if (cw) {
|
|
|
|
const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();
|
|
|
|
|
|
|
|
foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList) {
|
|
|
|
AudioChatWidgetHolder *acwh = dynamic_cast<AudioChatWidgetHolder*>(chatWidgetHolder) ;
|
|
|
|
|
|
|
|
if (acwh) {
|
|
|
|
for (unsigned int i = 0; i < chunks.size(); ++i) {
|
|
|
|
for (unsigned int chunkIndex=0; chunkIndex<chunks.size(); chunkIndex++){
|
|
|
|
QByteArray qb(reinterpret_cast<const char *>(chunks[chunkIndex].data),chunks[chunkIndex].size);
|
|
|
|
acwh->addAudioData(peer_id,&qb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
std::cerr << "Error: received audio data for a chat dialog that does not stand Audio (Peer id = " << peer_id.toStdString() << "!" << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(unsigned int chunkIndex=0; chunkIndex<chunks.size(); chunkIndex++){
|
|
|
|
free(chunks[chunkIndex].data);
|
|
|
|
}
|
2012-02-25 13:15:36 -05:00
|
|
|
}
|
|
|
|
|