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 // TODO: (API/ABI break) split StreamedMediaChannel in CallChannel and StreamedMediaChannel
00037 
00038 class StreamedMediaChannel;
00039 
00040 typedef QList<MediaContentPtr> MediaContents;
00041 typedef QList<MediaStreamPtr> MediaStreams;
00042 
00043 class TELEPATHY_QT4_EXPORT PendingMediaStreams : public PendingOperation
00044 {
00045     Q_OBJECT
00046     Q_DISABLE_COPY(PendingMediaStreams)
00047 
00048 public:
00049     ~PendingMediaStreams();
00050 
00051     MediaStreams streams() const;
00052 
00053 private Q_SLOTS:
00054     void gotSMStreams(QDBusPendingCallWatcher *);
00055 
00056     void gotCallContent(QDBusPendingCallWatcher *watcher);
00057 
00058     void onContentRemoved(const Tp::MediaContentPtr &);
00059     void onContentReady(Tp::PendingOperation *);
00060 
00061 private:
00062     friend class StreamedMediaChannel;
00063 
00064     PendingMediaStreams(const StreamedMediaChannelPtr &channel,
00065             const ContactPtr &contact,
00066             const QList<MediaStreamType> &types);
00067     PendingMediaStreams(const StreamedMediaChannelPtr &channel,
00068             const QList<MediaStreamType> &types);
00069 
00070     struct Private;
00071     friend struct Private;
00072     Private *mPriv;
00073 };
00074 
00075 class TELEPATHY_QT4_EXPORT MediaStream : public QObject,
00076                     private ReadyObject,
00077                     public RefCounted
00078 {
00079     Q_OBJECT
00080     Q_DISABLE_COPY(MediaStream)
00081 
00082 public:
00083     enum SendingState {
00084         SendingStateNone = 0,
00085         SendingStatePendingSend = 1,
00086         SendingStateSending = 2
00087     };
00088 
00089     ~MediaStream();
00090 
00091     MediaContentPtr content() const;
00092 
00093     StreamedMediaChannelPtr channel() const;
00094 
00095     uint id() const;
00096 
00097     Contacts members() const;
00098 
00099     ContactPtr contact() const;
00100 
00101     MediaStreamState state() const;
00102     MediaStreamType type() const;
00103 
00104     SendingState localSendingState() const;
00105     SendingState remoteSendingState(const ContactPtr &contact) const;
00106 
00107     bool sending() const;
00108     bool receiving() const;
00109 
00110     bool localSendingRequested() const;
00111     bool remoteSendingRequested() const;
00112 
00113     MediaStreamDirection direction() const;
00114     MediaStreamPendingSend pendingSend() const;
00115 
00116     PendingOperation *requestSending(bool send);
00117     PendingOperation *requestReceiving(const ContactPtr &contact, bool receive);
00118 
00119     PendingOperation *requestDirection(
00120             MediaStreamDirection direction);
00121     PendingOperation *requestDirection(
00122             bool send, bool receive);
00123 
00124     PendingOperation *startDTMFTone(DTMFEvent event);
00125     PendingOperation *stopDTMFTone();
00126 
00127 Q_SIGNALS:
00128     void localSendingStateChanged(
00129             Tp::MediaStream::SendingState localSendingState);
00130     void remoteSendingStateChanged(
00131             const QHash<Tp::ContactPtr, Tp::MediaStream::SendingState> &remoteSendingStates);
00132 
00133     void membersRemoved(const Tp::Contacts &members);
00134 
00135 private Q_SLOTS:
00136     void gotSMContact(Tp::PendingOperation *op);
00137 
00138     void gotCallMainProperties(QDBusPendingCallWatcher *);
00139     void gotCallSendersContacts(Tp::PendingOperation *);
00140 
00141 private:
00142     friend class MediaContent;
00143     friend class PendingMediaStreams;
00144     friend class StreamedMediaChannel;
00145 
00146     static const Feature FeatureCore;
00147 
00148     MediaStream(const MediaContentPtr &content, const MediaStreamInfo &info);
00149     MediaStream(const MediaContentPtr &content,
00150             const QDBusObjectPath &streamPath);
00151 
00152     void gotSMDirection(uint direction, uint pendingSend);
00153     void gotSMStreamState(uint state);
00154 
00155     QDBusObjectPath callObjectPath() const;
00156 
00157     struct Private;
00158     friend struct Private;
00159     Private *mPriv;
00160 };
00161 
00162 class TELEPATHY_QT4_EXPORT PendingMediaContent : public PendingOperation
00163 {
00164     Q_OBJECT
00165     Q_DISABLE_COPY(PendingMediaContent)
00166 
00167 public:
00168     ~PendingMediaContent();
00169 
00170     MediaContentPtr content() const;
00171 
00172 private Q_SLOTS:
00173     void gotSMStream(QDBusPendingCallWatcher *watcher);
00174 
00175     void gotCallContent(QDBusPendingCallWatcher *watcher);
00176 
00177     void onContentReady(Tp::PendingOperation *op);
00178     void onContentRemoved(const Tp::MediaContentPtr &content);
00179 
00180 private:
00181     friend class StreamedMediaChannel;
00182 
00183     PendingMediaContent(const StreamedMediaChannelPtr &channel,
00184             const ContactPtr &contact,
00185             const QString &contentName,
00186             MediaStreamType type);
00187     PendingMediaContent(const StreamedMediaChannelPtr &channel,
00188             const QString &contentName,
00189             MediaStreamType type);
00190     PendingMediaContent(const StreamedMediaChannelPtr &channel,
00191             const QString &errorName,
00192             const QString &errorMessage);
00193 
00194     struct Private;
00195     friend struct Private;
00196     Private *mPriv;
00197 };
00198 
00199 class TELEPATHY_QT4_EXPORT MediaContent : public QObject,
00200                     private ReadyObject,
00201                     public RefCounted
00202 {
00203     Q_OBJECT
00204     Q_DISABLE_COPY(MediaContent)
00205 
00206 public:
00207     ~MediaContent();
00208 
00209     StreamedMediaChannelPtr channel() const;
00210 
00211     QString name() const;
00212     MediaStreamType type() const;
00213     ContactPtr creator() const;
00214 
00215     MediaStreams streams() const;
00216 
00217 Q_SIGNALS:
00218     void streamAdded(const Tp::MediaStreamPtr &stream);
00219     void streamRemoved(const Tp::MediaStreamPtr &stream);
00220 
00221 private Q_SLOTS:
00222     void onStreamReady(Tp::PendingOperation *op);
00223     void gotCreator(Tp::PendingOperation *op);
00224 
00225     void gotCallMainProperties(QDBusPendingCallWatcher *);
00226     void onCallStreamAdded(const QDBusObjectPath &);
00227     void onCallStreamRemoved(const QDBusObjectPath &);
00228 
00229 private:
00230     friend class StreamedMediaChannel;
00231     friend class PendingMediaContent;
00232     friend class PendingMediaStreams;
00233 
00234     static const Feature FeatureCore;
00235 
00236     MediaContent(const StreamedMediaChannelPtr &channel,
00237             const QString &name,
00238             const MediaStreamInfo &streamInfo);
00239     MediaContent(const StreamedMediaChannelPtr &channel,
00240             const QDBusObjectPath &contentPath);
00241 
00242     void setSMStream(const MediaStreamPtr &stream);
00243     MediaStreamPtr SMStream() const;
00244     void removeSMStream();
00245 
00246     QDBusObjectPath callObjectPath() const;
00247     PendingOperation *callRemove();
00248 
00249     struct Private;
00250     friend struct Private;
00251     Private *mPriv;
00252 };
00253 
00254 class TELEPATHY_QT4_EXPORT StreamedMediaChannel : public Channel
00255 {
00256     Q_OBJECT
00257     Q_DISABLE_COPY(StreamedMediaChannel)
00258     Q_ENUMS(StateChangeReason)
00259 
00260 public:
00261     static const Feature FeatureContents;
00262     static const Feature FeatureLocalHoldState;
00263     static const Feature FeatureStreams;
00264 
00265     enum StateChangeReason {
00266         StateChangeReasonUnknown = 0,
00267         StateChangeReasonUserRequested = 1
00268     };
00269 
00270     static StreamedMediaChannelPtr create(const ConnectionPtr &connection,
00271             const QString &objectPath, const QVariantMap &immutableProperties);
00272 
00273     virtual ~StreamedMediaChannel();
00274 
00275     bool awaitingLocalAnswer() const;
00276     bool awaitingRemoteAnswer() const;
00277 
00278     PendingOperation *acceptCall();
00279     PendingOperation *hangupCall(StateChangeReason reason,
00280             const QString &detailedReason, const QString &message);
00281 
00282     MediaContents contents() const;
00283     MediaContents contentsForType(MediaStreamType type) const;
00284 
00285     MediaStreams streams() const;
00286     MediaStreams streamsForType(
00287             MediaStreamType type) const;
00288 
00289     PendingMediaContent *requestContent(const QString &name,
00290             MediaStreamType type);
00291 
00292     PendingMediaStreams *requestStream(
00293             const ContactPtr &contact,
00294             MediaStreamType type);
00295     PendingMediaStreams *requestStreams(
00296             const ContactPtr &contact,
00297             QList<MediaStreamType> types);
00298 
00299     PendingOperation *removeContent(const MediaContentPtr &content);
00300 
00301     PendingOperation *removeStream(
00302             const MediaStreamPtr &stream);
00303     PendingOperation *removeStreams(
00304             const MediaStreams &streams);
00305 
00306     bool handlerStreamingRequired() const;
00307 
00308     LocalHoldState localHoldState() const;
00309     LocalHoldStateReason localHoldStateReason() const;
00310     PendingOperation *requestHold(bool hold);
00311 
00312 Q_SIGNALS:
00313     void contentAdded(const Tp::MediaContentPtr &content);
00314     void contentRemoved(const Tp::MediaContentPtr &content);
00315 
00316     void streamAdded(const Tp::MediaStreamPtr &stream);
00317     void streamRemoved(const Tp::MediaStreamPtr &stream);
00318     void streamDirectionChanged(const Tp::MediaStreamPtr &stream,
00319             Tp::MediaStreamDirection direction,
00320             Tp::MediaStreamPendingSend pendingSend);
00321     void streamStateChanged(const Tp::MediaStreamPtr &stream,
00322             Tp::MediaStreamState state);
00323     void streamError(const Tp::MediaStreamPtr &stream,
00324             Tp::MediaStreamError errorCode,
00325             const QString &errorMessage);
00326 
00327     void localHoldStateChanged(Tp::LocalHoldState state,
00328             Tp::LocalHoldStateReason reason);
00329 
00330 protected:
00331     StreamedMediaChannel(const ConnectionPtr &connection,
00332             const QString &objectPath, const QVariantMap &immutableProperties);
00333 
00334 private Q_SLOTS:
00335     void onContentReady(Tp::PendingOperation *op);
00336 
00337     void gotSMStreams(QDBusPendingCallWatcher *);
00338     void onSMStreamAdded(uint, uint, uint);
00339     void onSMStreamRemoved(uint);
00340     void onSMStreamDirectionChanged(uint, uint, uint);
00341     void onSMStreamStateChanged(uint streamId, uint streamState);
00342     void onSMStreamError(uint, uint, const QString &);
00343 
00344     void gotCallMainProperties(QDBusPendingCallWatcher *);
00345     void onCallContentAdded(const QDBusObjectPath &, uint);
00346     void onCallContentRemoved(const QDBusObjectPath &);
00347 
00348     void gotLocalHoldState(QDBusPendingCallWatcher *);
00349     void onLocalHoldStateChanged(uint, uint);
00350 
00351 private:
00352     friend class PendingMediaContent;
00353     friend class PendingMediaStreams;
00354 
00355     MediaContentPtr addContentForSMStream(const MediaStreamInfo &streamInfo);
00356     MediaContentPtr lookupContentBySMStreamId(uint streamId);
00357 
00358     MediaContentPtr addContentForCallObjectPath(
00359             const QDBusObjectPath &contentPath);
00360     MediaContentPtr lookupContentByCallObjectPath(
00361             const QDBusObjectPath &contentPath);
00362 
00363     struct Private;
00364     friend struct Private;
00365     Private *mPriv;
00366 };
00367 
00368 } // Tp
00369 
00370 #endif


Copyright © 2008-2010 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.3.13