QXmpp Version:0.3.0
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 QXmppRtpAudioChannel;
00043 class QXmppRtpVideoChannel;
00044 
00051 
00052 class QXmppCall : public QXmppLoggable
00053 {
00054     Q_OBJECT
00055     Q_ENUMS(Direction State)
00056     Q_FLAGS(QIODevice::OpenModeFlag QIODevice::OpenMode)
00057     Q_PROPERTY(Direction direction READ direction CONSTANT)
00058     Q_PROPERTY(QString jid READ jid CONSTANT)
00059     Q_PROPERTY(State state READ state NOTIFY stateChanged)
00060     Q_PROPERTY(QIODevice::OpenMode audioMode READ audioMode NOTIFY audioModeChanged)
00061     Q_PROPERTY(QIODevice::OpenMode videoMode READ videoMode NOTIFY videoModeChanged)
00062 
00063 public:
00065     enum Direction
00066     {
00067         IncomingDirection, 
00068         OutgoingDirection, 
00069     };
00070 
00072     enum State
00073     {
00074         ConnectingState = 0,    
00075         ActiveState = 1,        
00076         DisconnectingState = 2, 
00077         FinishedState = 3,      
00078     };
00079 
00080     ~QXmppCall();
00081 
00082     QXmppCall::Direction direction() const;
00083     QString jid() const;
00084     QString sid() const;
00085     QXmppCall::State state() const;
00086 
00087     QXmppRtpAudioChannel *audioChannel() const;
00088     QIODevice::OpenMode audioMode() const;
00089     QXmppRtpVideoChannel *videoChannel() const;
00090     QIODevice::OpenMode videoMode() const;
00091 
00092 signals:
00098     void connected();
00099 
00104     void finished();
00105 
00107     void ringing();
00108 
00110     void stateChanged(QXmppCall::State state);
00111 
00113     void audioModeChanged(QIODevice::OpenMode mode);
00114 
00116     void videoModeChanged(QIODevice::OpenMode mode);
00117 
00118 public slots:
00119     void accept();
00120     void hangup();
00121     void startVideo();
00122     void stopVideo();
00123 
00124 private slots:
00125     void localCandidatesChanged();
00126     void terminated();
00127     void updateOpenMode();
00128 
00129 private:
00130     QXmppCall(const QString &jid, QXmppCall::Direction direction, QXmppCallManager *parent);
00131 
00132     QXmppCallPrivate *d;
00133     friend class QXmppCallManager;
00134     friend class QXmppCallManagerPrivate;
00135     friend class QXmppCallPrivate;
00136 };
00137 
00158 
00159 class QXmppCallManager : public QXmppClientExtension
00160 {
00161     Q_OBJECT
00162 
00163 public:
00164     QXmppCallManager();
00165     ~QXmppCallManager();
00166     void setStunServer(const QHostAddress &host, quint16 port = 3478);
00167     void setTurnServer(const QHostAddress &host, quint16 port = 3478);
00168     void setTurnUser(const QString &user);
00169     void setTurnPassword(const QString &password);
00170 
00172     QStringList discoveryFeatures() const;
00173     bool handleStanza(const QDomElement &element);
00175 
00176 signals:
00181     void callReceived(QXmppCall *call);
00182 
00183     void callStarted(QXmppCall *call);
00184 
00185 public slots:
00186     QXmppCall *call(const QString &jid);
00187 
00188 protected:
00190     void setClient(QXmppClient* client);
00192 
00193 private slots:
00194     void callDestroyed(QObject *object);
00195     void iqReceived(const QXmppIq &iq);
00196     void jingleIqReceived(const QXmppJingleIq &iq);
00197 
00198 private:
00199     QXmppCallManagerPrivate *d;
00200     friend class QXmppCall;
00201     friend class QXmppCallPrivate;
00202     friend class QXmppCallManagerPrivate;
00203 };
00204 
00205 Q_DECLARE_METATYPE(QXmppCall::State)
00206 
00207 #endif
 All Classes Functions Enumerations Enumerator Properties