aboutsummaryrefslogtreecommitdiff
path: root/example/example_4_callHandling/xmppClient.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-07-21 15:42:03 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-07-21 15:42:03 +0000
commita48c10970f44dc3d0e6abed54a67619fb2721431 (patch)
tree4dfba0ad94c174a5c8cbc5c3d000aa76951bb024 /example/example_4_callHandling/xmppClient.cpp
parent96c5dd3b18bc8ebc9f39a1fd23ee4c5eaf4f2bc7 (diff)
downloadqxmpp-a48c10970f44dc3d0e6abed54a67619fb2721431.tar.gz
make example actually work
Diffstat (limited to 'example/example_4_callHandling/xmppClient.cpp')
-rw-r--r--example/example_4_callHandling/xmppClient.cpp30
1 files changed, 26 insertions, 4 deletions
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 <QBuffer>
+#include <QAudioInput>
+#include <QAudioOutput>
#include <QDebug>
-#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<QXmppCall*>(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);