TelepathyQt4: streamed-media-channel.h Source File

| Home · All Classes · All Namespaces · Modules · Functions · Files

# streamed-media-channel.h

    00001 /* StreamedMedia channel client-side proxy
    00002  *
    00003  * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
    00004  * Copyright (C) 2009 Nokia Corporation
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the GNU Lesser General Public
    00008  * License as published by the Free Software Foundation; either
    00009  * version 2.1 of the License, or (at your option) any later version.
    00010  *
    00011  * This library is distributed in the hope that it will be useful,
    00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014  * Lesser General Public License for more details.
    00015  *
    00016  * You should have received a copy of the GNU Lesser General Public
    00017  * License along with this library; if not, write to the Free Software
    00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    00019  */
    00020
    00021 #ifndef _TelepathyQt4_streamed_media_channel_h_HEADER_GUARD_
    00022 #define _TelepathyQt4_streamed_media_channel_h_HEADER_GUARD_
    00023
    00024 #ifndef IN_TELEPATHY_QT4_HEADER
    00025 #error IN_TELEPATHY_QT4_HEADER
    00026 #endif
    00027
    00028 #include <TelepathyQt4/Channel>
    00029 #include <TelepathyQt4/PendingOperation>
    00030 #include <TelepathyQt4/Types>
    00031 #include <TelepathyQt4/SharedPtr>
    00032
    00033 namespace Tp
    00034 {
    00035
    00036 class StreamedMediaChannel;
    00037
    00038 typedef QList<MediaStreamPtr> MediaStreams;
    00039
    00040 class TELEPATHY_QT4_EXPORT PendingMediaStreams : public PendingOperation
    00041 {
    00042     Q_OBJECT
    00043     Q_DISABLE_COPY(PendingMediaStreams)
    00044
    00045 public:
    00046     ~PendingMediaStreams();
    00047
    00048     MediaStreams streams() const;
    00049
    00050 private Q_SLOTS:
    00051     void gotStreams(QDBusPendingCallWatcher *);
    00052     void onStreamRemoved(Tp::MediaStreamPtr);
    00053     void onStreamReady(Tp::PendingOperation *);
    00054
    00055 private:
    00056     friend class StreamedMediaChannel;
    00057
    00058     PendingMediaStreams(const StreamedMediaChannelPtr &channel,
    00059             ContactPtr contact,
    00060             QList<MediaStreamType> types);
    00061
    00062     struct Private;
    00063     friend struct Private;
    00064     Private *mPriv;
    00065 };
    00066
    00067 class TELEPATHY_QT4_EXPORT MediaStream : public QObject,
    00068                     private ReadyObject,
    00069                     public RefCounted
    00070 {
    00071     Q_OBJECT
    00072     Q_DISABLE_COPY(MediaStream)
    00073
    00074 public:
    00075     ~MediaStream();
    00076
    00077     StreamedMediaChannelPtr channel() const;
    00078     uint id() const;
    00079
    00080     ContactPtr contact() const;
    00081     MediaStreamState state() const;
    00082     MediaStreamType type() const;
    00083
    00084     bool sending() const;
    00085     bool receiving() const;
    00086     bool localSendingRequested() const;
    00087     bool remoteSendingRequested() const;
    00088
    00089     MediaStreamDirection direction() const;
    00090     MediaStreamPendingSend pendingSend() const;
    00091
    00092     PendingOperation *requestDirection(
    00093             MediaStreamDirection direction);
    00094     PendingOperation *requestDirection(
    00095             bool send, bool receive);
    00096
    00097     PendingOperation *startDTMFTone(DTMFEvent event);
    00098     PendingOperation *stopDTMFTone();
    00099
    00100 private Q_SLOTS:
    00101     void gotContact(Tp::PendingOperation *op);
    00102
    00103 private:
    00104     friend class PendingMediaStreams;
    00105     friend class StreamedMediaChannel;
    00106
    00107     static const Feature FeatureContact;
    00108
    00109     MediaStream(const StreamedMediaChannelPtr &channel, uint id,
    00110             uint contactHandle, MediaStreamType type,
    00111             MediaStreamState state, MediaStreamDirection direction,
    00112             MediaStreamPendingSend pendingSend);
    00113
    00114     uint contactHandle() const;
    00115     void setContact(const ContactPtr &contact);
    00116     void setDirection(MediaStreamDirection direction,
    00117             MediaStreamPendingSend pendingSend);
    00118     void setState(MediaStreamState state);
    00119
    00120     struct Private;
    00121     friend struct Private;
    00122     Private *mPriv;
    00123 };
    00124
    00125 class TELEPATHY_QT4_EXPORT StreamedMediaChannel : public Channel
    00126 {
    00127     Q_OBJECT
    00128     Q_DISABLE_COPY(StreamedMediaChannel)
    00129
    00130 public:
    00131     static const Feature FeatureStreams;
    00132     static const Feature FeatureLocalHoldState;
    00133
    00134     static StreamedMediaChannelPtr create(const ConnectionPtr &connection,
    00135             const QString &objectPath, const QVariantMap &immutableProperties);
    00136
    00137     virtual ~StreamedMediaChannel();
    00138
    00139     MediaStreams streams() const;
    00140     MediaStreams streamsForType(MediaStreamType type) const;
    00141
    00142     bool awaitingLocalAnswer() const;
    00143     bool awaitingRemoteAnswer() const;
    00144
    00145     PendingOperation *acceptCall();
    00146
    00147     PendingOperation *removeStream(const MediaStreamPtr &stream);
    00148     PendingOperation *removeStreams(const MediaStreams &streams);
    00149
    00150     PendingMediaStreams *requestStream(
    00151             const ContactPtr &contact,
    00152             MediaStreamType type);
    00153     PendingMediaStreams *requestStreams(
    00154             const ContactPtr &contact,
    00155             QList<MediaStreamType> types);
    00156
    00157     bool handlerStreamingRequired() const;
    00158
    00159     LocalHoldState localHoldState() const;
    00160     LocalHoldStateReason localHoldStateReason() const;
    00161     PendingOperation *requestHold(bool hold);
    00162
    00163 Q_SIGNALS:
    00164     void streamAdded(const Tp::MediaStreamPtr &stream);
    00165     void streamRemoved(const Tp::MediaStreamPtr &stream);
    00166     void streamDirectionChanged(const Tp::MediaStreamPtr &stream,
    00167             Tp::MediaStreamDirection direction,
    00168             Tp::MediaStreamPendingSend pendingSend);
    00169     void streamStateChanged(const Tp::MediaStreamPtr &stream,
    00170             Tp::MediaStreamState);
    00171     void streamError(const Tp::MediaStreamPtr &stream,
    00172             Tp::MediaStreamError errorCode,
    00173             const QString &errorMessage);
    00174
    00175     void localHoldStateChanged(Tp::LocalHoldState state,
    00176             Tp::LocalHoldStateReason reason);
    00177
    00178 protected:
    00179     StreamedMediaChannel(const ConnectionPtr &connection,
    00180             const QString &objectPath, const QVariantMap &immutableProperties);
    00181
    00182 private Q_SLOTS:
    00183     void gotStreams(QDBusPendingCallWatcher *);
    00184     void onStreamReady(Tp::PendingOperation *);
    00185     void onStreamAdded(uint, uint, uint);
    00186     void onStreamRemoved(uint);
    00187     void onStreamDirectionChanged(uint, uint, uint);
    00188     void onStreamStateChanged(uint, uint);
    00189     void onStreamError(uint, uint, const QString &);
    00190
    00191     void gotLocalHoldState(QDBusPendingCallWatcher *);
    00192     void onLocalHoldStateChanged(uint, uint);
    00193
    00194 private:
    00195     friend class PendingMediaStreams;
    00196
    00197     void addStream(const MediaStreamPtr &stream);
    00198     MediaStreamPtr lookupStreamById(uint streamId);
    00199
    00200     struct Private;
    00201     friend struct Private;
    00202     Private *mPriv;
    00203 };
    00204
    00205 } // Tp
    00206
    00207 #endif