From a48c10970f44dc3d0e6abed54a67619fb2721431 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Wed, 21 Jul 2010 15:42:03 +0000 Subject: make example actually work --- example/example_4_callHandling/xmppClient.cpp | 30 +++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'example/example_4_callHandling/xmppClient.cpp') diff --git a/example/example_4_callHandling/xmppClient.cpp b/example/example_4_callHandling/xmppClient.cpp index 7a7da11b..93bbba07 100644 --- a/example/example_4_callHandling/xmppClient.cpp +++ b/example/example_4_callHandling/xmppClient.cpp @@ -22,10 +22,11 @@ * */ -#include +#include +#include #include -#include "QXmppMessage.h" +#include "QXmppCallManager.h" #include "QXmppUtils.h" #include "xmppClient.h" @@ -53,15 +54,36 @@ void xmppClient::slotCallReceived(QXmppCall *call) check = connect(call, SIGNAL(finished()), this, SLOT(slotFinished())); Q_ASSERT(check); + + // accept call + call->accept(); } /// A call connected. void xmppClient::slotConnected() { + QXmppCall *call = qobject_cast(sender()); + Q_ASSERT(call); + qDebug() << "Call connected"; - // FIXME : show how to use QAudioInput and QAudioOutput + // prepare audio format + QAudioFormat format; + format.setFrequency(call->payloadType().clockrate()); + format.setChannels(call->payloadType().channels()); + format.setSampleSize(16); + format.setCodec("audio/pcm"); + format.setByteOrder(QAudioFormat::LittleEndian); + format.setSampleType(QAudioFormat::SignedInt); + + // initialise audio output + QAudioOutput *audioOutput = new QAudioOutput(format, this); + audioOutput->start(call); + + // initialise audio input + QAudioInput *audioInput = new QAudioInput(format, this); + audioInput->start(call); } /// A call finished. @@ -85,7 +107,7 @@ void xmppClient::slotPresenceReceived(const QXmppPresence &presence) return; // start the call and connect to the its signals - QXmppCall *call = callManager().call(recipient); + QXmppCall *call = callManager().call(presence.from()); bool check = connect(call, SIGNAL(connected()), this, SLOT(slotConnected())); Q_ASSERT(check); -- cgit v1.2.3