QXmpp  Version:1.2.0
QXmppCallManager.h
1 /*
2  * Copyright (C) 2008-2020 The QXmpp developers
3  *
4  * Author:
5  * Jeremy LainĂ©
6  *
7  * Source:
8  * https://github.com/qxmpp-project/qxmpp
9  *
10  * This file is a part of QXmpp library.
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  */
23 
24 #ifndef QXMPPCALLMANAGER_H
25 #define QXMPPCALLMANAGER_H
26 
27 #include "QXmppClientExtension.h"
28 #include "QXmppLogger.h"
29 
30 #include <QIODevice>
31 #include <QMetaType>
32 #include <QObject>
33 
34 class QHostAddress;
35 class QXmppCallPrivate;
36 class QXmppCallManager;
37 class QXmppCallManagerPrivate;
38 class QXmppIq;
40 class QXmppJingleIq;
42 class QXmppPresence;
45 
52 
53 class QXMPP_EXPORT QXmppCall : public QXmppLoggable
54 {
55  Q_OBJECT
56  Q_FLAGS(QIODevice::OpenModeFlag QIODevice::OpenMode)
57  Q_PROPERTY(Direction direction READ direction CONSTANT)
58  Q_PROPERTY(QString jid READ jid CONSTANT)
59  Q_PROPERTY(State state READ state NOTIFY stateChanged)
60  Q_PROPERTY(QIODevice::OpenMode audioMode READ audioMode NOTIFY audioModeChanged)
61  Q_PROPERTY(QIODevice::OpenMode videoMode READ videoMode NOTIFY videoModeChanged)
62 
63 public:
65  enum Direction {
67  OutgoingDirection
68  };
69  Q_ENUM(Direction)
70 
71 
72  enum State {
73  ConnectingState = 0,
74  ActiveState = 1,
75  DisconnectingState = 2,
76  FinishedState = 3
77  };
78  Q_ENUM(State)
79 
80  ~QXmppCall() override;
81 
82  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
84  QXmppCall::Direction direction() const;
86  QString jid() const;
92  QXmppCall::State state() const;
93 
94  QString sid() const;
95 
96  QXmppRtpAudioChannel *audioChannel() const;
97  QXmppRtpVideoChannel *videoChannel() const;
98 
99  // documentation needs to be here, see https://stackoverflow.com/questions/49192523/
101  QIODevice::OpenMode audioMode() const;
103  QIODevice::OpenMode videoMode() const;
104 
105 signals:
111  void connected();
112 
117  void finished();
118 
120  void ringing();
121 
123  void stateChanged(QXmppCall::State state);
124 
126  void audioModeChanged(QIODevice::OpenMode mode);
127 
129  void videoModeChanged(QIODevice::OpenMode mode);
130 
131 public slots:
132  void accept();
133  void hangup();
134  void startVideo();
135  void stopVideo();
136 
137 private slots:
138  void localCandidatesChanged();
139  void terminated();
140  void updateOpenMode();
141 
142 private:
143  QXmppCall(const QString &jid, QXmppCall::Direction direction, QXmppCallManager *parent);
144 
145  QXmppCallPrivate *d;
146  friend class QXmppCallManager;
147  friend class QXmppCallManagerPrivate;
148  friend class QXmppCallPrivate;
149 };
150 
171 
172 class QXMPP_EXPORT QXmppCallManager : public QXmppClientExtension
173 {
174  Q_OBJECT
175 
176 public:
178  ~QXmppCallManager() override;
179  void setStunServer(const QHostAddress &host, quint16 port = 3478);
180  void setTurnServer(const QHostAddress &host, quint16 port = 3478);
181  void setTurnUser(const QString &user);
182  void setTurnPassword(const QString &password);
183 
185  QStringList discoveryFeatures() const override;
186  bool handleStanza(const QDomElement &element) override;
188 
189 signals:
194  void callReceived(QXmppCall *call);
195 
197  void callStarted(QXmppCall *call);
198 
199 public slots:
200  QXmppCall *call(const QString &jid);
201 
202 protected:
204  void setClient(QXmppClient *client) override;
206 
207 private slots:
208  void _q_callDestroyed(QObject *object);
209  void _q_disconnected();
210  void _q_iqReceived(const QXmppIq &iq);
211  void _q_jingleIqReceived(const QXmppJingleIq &iq);
212  void _q_presenceReceived(const QXmppPresence &presence);
213 
214 private:
215  QXmppCallManagerPrivate *d;
216  friend class QXmppCall;
217  friend class QXmppCallPrivate;
218  friend class QXmppCallManagerPrivate;
219 };
220 
221 Q_DECLARE_METATYPE(QXmppCall::State)
222 
223 #endif
QXmppCall::IncomingDirection
The call is incoming.
Definition: QXmppCallManager.h:66
QXmppJinglePayloadType
The QXmppJinglePayloadType class represents a payload type as specified by XEP-0167: Jingle RTP Sessi...
Definition: QXmppJingleIq.h:40
QXmppPresence
The QXmppPresence class represents an XMPP presence stanza.
Definition: QXmppPresence.h:35
QXmppJingleIq
The QXmppJingleIq class represents an IQ used for initiating media sessions as specified by XEP-0166:...
Definition: QXmppJingleIq.h:153
QXmppJingleCandidate
The QXmppJingleCandidate class represents a transport candidate as specified by XEP-0176: Jingle ICE-...
Definition: QXmppJingleIq.h:84
QXmppRtpVideoChannel
The QXmppRtpVideoChannel class represents an RTP video channel to a remote party.
Definition: QXmppRtpChannel.h:267
QXmppClientExtension
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:47
QXmppClientExtension::setClient
virtual void setClient(QXmppClient *client)
Definition: QXmppClientExtension.cpp:79
QXmppCall::State
State
This enum is used to describe the state of a call.
Definition: QXmppCallManager.h:72
QXmppClientExtension::discoveryFeatures
virtual QStringList discoveryFeatures() const
Definition: QXmppClientExtension.cpp:54
QXmppIq
The QXmppIq class is the base class for all IQs.
Definition: QXmppIq.h:41
QXmppClient
The QXmppClient class is the main class for using QXmpp.
Definition: QXmppClient.h:94
QXmppLoggable
The QXmppLoggable class represents a source of logging messages.
Definition: QXmppLogger.h:123
QXmppCall::Direction
Direction
This enum is used to describe the direction of a call.
Definition: QXmppCallManager.h:65
QXmppCallManager
The QXmppCallManager class provides support for making and receiving voice calls.
Definition: QXmppCallManager.h:172
QXmppClientExtension::handleStanza
virtual bool handleStanza(const QDomElement &stanza)=0
You need to implement this method to process incoming XMPP stanzas.
QXmppCall
The QXmppCall class represents a Voice-Over-IP call to a remote party.
Definition: QXmppCallManager.h:53
QXmppRtpAudioChannel
The QXmppRtpAudioChannel class represents an RTP audio channel to a remote party.
Definition: QXmppRtpChannel.h:75