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