QXmppCallManager.h

    00001 /*
    00002  * Copyright (C) 2008-2011 The QXmpp developers
    00003  *
    00004  * Author:
    00005  *  Jeremy Lainé
    00006  *
    00007  * Source:
    00008  *  http://code.google.com/p/qxmpp
    00009  *
    00010  * This file is a part of QXmpp library.
    00011  *
    00012  * This library is free software; you can redistribute it and/or
    00013  * modify it under the terms of the GNU Lesser General Public
    00014  * License as published by the Free Software Foundation; either
    00015  * version 2.1 of the License, or (at your option) any later version.
    00016  *
    00017  * This library is distributed in the hope that it will be useful,
    00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00020  * Lesser General Public License for more details.
    00021  *
    00022  */
    00023
    00024 #ifndef QXMPPCALLMANAGER_H
    00025 #define QXMPPCALLMANAGER_H
    00026
    00027 #include <QObject>
    00028 #include <QIODevice>
    00029 #include <QMetaType>
    00030
    00031 #include "QXmppClientExtension.h"
    00032 #include "QXmppLogger.h"
    00033
    00034 class QHostAddress;
    00035 class QXmppCallPrivate;
    00036 class QXmppCallManager;
    00037 class QXmppCallManagerPrivate;
    00038 class QXmppIq;
    00039 class QXmppJingleCandidate;
    00040 class QXmppJingleIq;
    00041 class QXmppJinglePayloadType;
    00042 class QXmppPresence;
    00043 class QXmppRtpAudioChannel;
    00044 class QXmppRtpVideoChannel;
    00045
    00052
    00053 class QXmppCall : public QXmppLoggable
    00054 {
    00055     Q_OBJECT
    00056     Q_ENUMS(Direction State)
    00057     Q_FLAGS(QIODevice::OpenModeFlag QIODevice::OpenMode)
    00058     Q_PROPERTY(Direction direction READ direction CONSTANT)
    00059     Q_PROPERTY(QString jid READ jid CONSTANT)
    00060     Q_PROPERTY(State state READ state NOTIFY stateChanged)
    00061     Q_PROPERTY(QIODevice::OpenMode audioMode READ audioMode NOTIFY audioModeChanged)
    00062     Q_PROPERTY(QIODevice::OpenMode videoMode READ videoMode NOTIFY videoModeChanged)
    00063
    00064 public:
    00066     enum Direction
    00067     {
    00068         IncomingDirection,
    00069         OutgoingDirection,
    00070     };
    00071
    00073     enum State
    00074     {
    00075         ConnectingState = 0,
    00076         ActiveState = 1,
    00077         DisconnectingState = 2,
    00078         FinishedState = 3,
    00079     };
    00080
    00081     ~QXmppCall();
    00082
    00083     QXmppCall::Direction direction() const;
    00084     QString jid() const;
    00085     QString sid() const;
    00086     QXmppCall::State state() const;
    00087
    00088     QXmppRtpAudioChannel *audioChannel() const;
    00089     QIODevice::OpenMode audioMode() const;
    00090     QXmppRtpVideoChannel *videoChannel() const;
    00091     QIODevice::OpenMode videoMode() const;
    00092
    00093 signals:
    00099     void connected();
    00100
    00105     void finished();
    00106
    00108     void ringing();
    00109
    00111     void stateChanged(QXmppCall::State state);
    00112
    00114     void audioModeChanged(QIODevice::OpenMode mode);
    00115
    00117     void videoModeChanged(QIODevice::OpenMode mode);
    00118
    00119 public slots:
    00120     void accept();
    00121     void hangup();
    00122     void startVideo();
    00123     void stopVideo();
    00124
    00125 private slots:
    00126     void localCandidatesChanged();
    00127     void terminated();
    00128     void updateOpenMode();
    00129
    00130 private:
    00131     QXmppCall(const QString &jid, QXmppCall::Direction direction, QXmppCallManager *parent);
    00132
    00133     QXmppCallPrivate *d;
    00134     friend class QXmppCallManager;
    00135     friend class QXmppCallManagerPrivate;
    00136     friend class QXmppCallPrivate;
    00137 };
    00138
    00159
    00160 class QXmppCallManager : public QXmppClientExtension
    00161 {
    00162     Q_OBJECT
    00163
    00164 public:
    00165     QXmppCallManager();
    00166     ~QXmppCallManager();
    00167     void setStunServer(const QHostAddress &host, quint16 port = 3478);
    00168     void setTurnServer(const QHostAddress &host, quint16 port = 3478);
    00169     void setTurnUser(const QString &user);
    00170     void setTurnPassword(const QString &password);
    00171
    00173     QStringList discoveryFeatures() const;
    00174     bool handleStanza(const QDomElement &element);
    00176
    00177 signals:
    00182     void callReceived(QXmppCall *call);
    00183
    00184     void callStarted(QXmppCall *call);
    00185
    00186 public slots:
    00187     QXmppCall *call(const QString &jid);
    00188
    00189 protected:
    00191     void setClient(QXmppClient* client);
    00193
    00194 private slots:
    00195     void _q_callDestroyed(QObject *object);
    00196     void _q_disconnected();
    00197     void _q_iqReceived(const QXmppIq &iq);
    00198     void _q_jingleIqReceived(const QXmppJingleIq &iq);
    00199     void _q_presenceReceived(const QXmppPresence &presence);
    00200
    00201 private:
    00202     QXmppCallManagerPrivate *d;
    00203     friend class QXmppCall;
    00204     friend class QXmppCallPrivate;
    00205     friend class QXmppCallManagerPrivate;
    00206 };
    00207
    00208 Q_DECLARE_METATYPE(QXmppCall::State)
    00209
    00210 #endif

All Classes Functions Enumerations Enumerator Properties