91 lines
2.4 KiB
C++
91 lines
2.4 KiB
C++
#include "main.h"
|
|
#include "config.h"
|
|
#include <gst/gst.h>
|
|
#include <QXmppQt6/QXmppLogger.h>
|
|
#include <QXmppQt6/QXmppMessage.h>
|
|
#include <QCoreApplication>
|
|
|
|
|
|
VocaXmppClient::VocaXmppClient(QObject *parent)
|
|
: QXmppClient(parent), m_call(nullptr)
|
|
{
|
|
// Add the extension for Jingle (Voice/Video calls).
|
|
addExtension(&m_callManager);
|
|
|
|
connect(this, &QXmppClient::messageReceived, this, &VocaXmppClient::messageReceived);
|
|
connect(&m_callManager, &QXmppCallManager::callReceived, this, &VocaXmppClient::callReceived);
|
|
connect(&m_callManager, &QXmppCallManager::callStarted, this, &VocaXmppClient::callStarted);
|
|
}
|
|
|
|
VocaXmppClient::~VocaXmppClient()
|
|
{
|
|
}
|
|
|
|
void VocaXmppClient::messageReceived(const QXmppMessage &message)
|
|
{
|
|
QString from = message.from();
|
|
QString msg = message.body();
|
|
|
|
// sendPacket(QXmppMessage("", from, "Your message: " + msg));
|
|
}
|
|
|
|
void VocaXmppClient::callConnected()
|
|
{
|
|
|
|
}
|
|
|
|
int VocaXmppClient::setupPipe()
|
|
{
|
|
GstElement* wavenc = gst_element_factory_make("wavenc", "wavenc");
|
|
GstElement* sink = gst_element_factory_make("filesink", "sink");
|
|
|
|
if (!wavenc || !sink)
|
|
{
|
|
gst_printerr("Not all elements could be created\n");
|
|
}
|
|
GstElement* pipe = m_call->pipeline();
|
|
gst_bin_add_many(GST_BIN(pipe), wavenc, sink, NULL);
|
|
if (!gst_element_link_many(wavenc, sink, NULL))
|
|
{
|
|
gst_printerr("Elements could not be linked\n");
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void VocaXmppClient::callReceived(QXmppCall *call)
|
|
{
|
|
m_call = call;
|
|
connect(m_call, &QXmppCall::connected, this, &VocaXmppClient::callConnected);
|
|
connect(m_call, &QXmppCall::finished, this, &VocaXmppClient::callFinished);
|
|
//connect(m_call, &QXmppCall::audioModeChanged, this, &VocaXmppClient::audioModeChanged);
|
|
m_call->accept();
|
|
|
|
setupPipe();
|
|
}
|
|
|
|
void VocaXmppClient::callStarted(QXmppCall *call)
|
|
{
|
|
m_call = call;
|
|
}
|
|
|
|
void VocaXmppClient::callFinished()
|
|
{
|
|
disconnect(m_call, &QXmppCall::connected, this, &VocaXmppClient::callConnected);
|
|
disconnect(m_call, &QXmppCall::finished, this, &VocaXmppClient::callFinished);
|
|
//disconnect(m_call, &QXmppCall::audioModeChanged, this, &VocaXmppClient::audioModeChanged);
|
|
m_call = nullptr;
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QCoreApplication app(argc, argv);
|
|
|
|
VocaXmppClient client;
|
|
client.logger()->setLoggingType(QXmppLogger::StdoutLogging);
|
|
client.connectToServer(VOCASTI_XMPP_EMAIL, VOCASTI_XMPP_PASSWD);
|
|
|
|
return app.exec();
|
|
}
|