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_Client_streamed_media_channel_h_HEADER_GUARD_
00022 #define _TelepathyQt4_Client_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 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 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 private Q_SLOTS:
00098     void gotContact(Tp::PendingOperation *op);
00099 
00100 private:
00101     friend class PendingMediaStreams;
00102     friend class StreamedMediaChannel;
00103 
00104     static const Feature FeatureContact;
00105 
00106     MediaStream(const StreamedMediaChannelPtr &channel, uint id,
00107             uint contactHandle, MediaStreamType type,
00108             MediaStreamState state, MediaStreamDirection direction,
00109             MediaStreamPendingSend pendingSend);
00110 
00111     uint contactHandle() const;
00112     void setContact(const ContactPtr &contact);
00113     void setDirection(MediaStreamDirection direction,
00114             MediaStreamPendingSend pendingSend);
00115     void setState(MediaStreamState state);
00116 
00117     struct Private;
00118     friend struct Private;
00119     Private *mPriv;
00120 };
00121 
00122 class StreamedMediaChannel : public Channel
00123 {
00124     Q_OBJECT
00125     Q_DISABLE_COPY(StreamedMediaChannel)
00126 
00127 public:
00128     static const Feature FeatureStreams;
00129 
00130     static StreamedMediaChannelPtr create(const ConnectionPtr &connection,
00131             const QString &objectPath, const QVariantMap &immutableProperties);
00132 
00133     ~StreamedMediaChannel();
00134 
00135     MediaStreams streams() const;
00136     MediaStreams streamsForType(MediaStreamType type) const;
00137 
00138     bool awaitingLocalAnswer() const;
00139     bool awaitingRemoteAnswer() const;
00140 
00141     PendingOperation *acceptCall();
00142 
00143     PendingOperation *removeStream(const MediaStreamPtr &stream);
00144     PendingOperation *removeStreams(const MediaStreams &streams);
00145 
00146     PendingMediaStreams *requestStream(
00147             const ContactPtr &contact,
00148             MediaStreamType type);
00149     PendingMediaStreams *requestStreams(
00150             const ContactPtr &contact,
00151             QList<MediaStreamType> types);
00152 
00153     bool handlerStreamingRequired() const;
00154 
00155 Q_SIGNALS:
00156     void streamAdded(const Tp::MediaStreamPtr &stream);
00157     void streamRemoved(const Tp::MediaStreamPtr &stream);
00158     void streamDirectionChanged(const Tp::MediaStreamPtr &stream,
00159             Tp::MediaStreamDirection direction,
00160             Tp::MediaStreamPendingSend pendingSend);
00161     void streamStateChanged(const Tp::MediaStreamPtr &stream,
00162             Tp::MediaStreamState);
00163     void streamError(const Tp::MediaStreamPtr &stream,
00164             Tp::MediaStreamError errorCode,
00165             const QString &errorMessage);
00166 
00167 protected:
00168     StreamedMediaChannel(const ConnectionPtr &connection,
00169             const QString &objectPath, const QVariantMap &immutableProperties);
00170 
00171 private Q_SLOTS:
00172     void gotStreams(QDBusPendingCallWatcher *);
00173     void onStreamReady(Tp::PendingOperation *);
00174     void onStreamAdded(uint, uint, uint);
00175     void onStreamRemoved(uint);
00176     void onStreamDirectionChanged(uint, uint, uint);
00177     void onStreamStateChanged(uint, uint);
00178     void onStreamError(uint, uint, const QString &);
00179 
00180 private:
00181     friend class PendingMediaStreams;
00182 
00183     void addStream(const MediaStreamPtr &stream);
00184     MediaStreamPtr lookupStreamById(uint streamId);
00185 
00186     struct Private;
00187     friend struct Private;
00188     Private *mPriv;
00189 };
00190 
00191 } // Tp
00192 
00193 #endif


Copyright © 2009 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.1.8