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     PendingOperation *callRemove();
00246 
00247     struct Private;
00248     friend struct Private;
00249     Private *mPriv;
00250 };
00251 
00252 class TELEPATHY_QT4_EXPORT StreamedMediaChannel : public Channel
00253 {
00254     Q_OBJECT
00255     Q_DISABLE_COPY(StreamedMediaChannel)
00256     Q_ENUMS(StateChangeReason)
00257 
00258 public:
00259     static const Feature FeatureContents;
00260     static const Feature FeatureLocalHoldState;
00261     static const Feature FeatureStreams;
00262 
00263     enum StateChangeReason {
00264         StateChangeReasonUnknown = 0,
00265         StateChangeReasonUserRequested = 1
00266     };
00267 
00268     static StreamedMediaChannelPtr create(const ConnectionPtr &connection,
00269             const QString &objectPath, const QVariantMap &immutableProperties);
00270 
00271     virtual ~StreamedMediaChannel();
00272 
00273     bool awaitingLocalAnswer() const;
00274     bool awaitingRemoteAnswer() const;
00275 
00276     PendingOperation *acceptCall();
00277     PendingOperation *hangupCall(StateChangeReason reason,
00278             const QString &detailedReason, const QString &message);
00279 
00280     MediaContents contents() const;
00281     MediaContents contentsForType(MediaStreamType type) const;
00282 
00283     TELEPATHY_QT4_DEPRECATED MediaStreams streams() const;
00284     TELEPATHY_QT4_DEPRECATED MediaStreams streamsForType(
00285             MediaStreamType type) const;
00286 
00287     PendingMediaContent *requestContent(const QString &name,
00288             MediaStreamType type);
00289 
00290     TELEPATHY_QT4_DEPRECATED PendingMediaStreams *requestStream(
00291             const ContactPtr &contact,
00292             MediaStreamType type);
00293     TELEPATHY_QT4_DEPRECATED PendingMediaStreams *requestStreams(
00294             const ContactPtr &contact,
00295             QList<MediaStreamType> types);
00296 
00297     PendingOperation *removeContent(const MediaContentPtr &content);
00298 
00299     TELEPATHY_QT4_DEPRECATED PendingOperation *removeStream(
00300             const MediaStreamPtr &stream);
00301     TELEPATHY_QT4_DEPRECATED PendingOperation *removeStreams(
00302             const MediaStreams &streams);
00303 
00304     bool handlerStreamingRequired() const;
00305 
00306     LocalHoldState localHoldState() const;
00307     LocalHoldStateReason localHoldStateReason() const;
00308     PendingOperation *requestHold(bool hold);
00309 
00310 Q_SIGNALS:
00311     void contentAdded(const Tp::MediaContentPtr &content);
00312     void contentRemoved(const Tp::MediaContentPtr &content);
00313 
00314     void streamAdded(const Tp::MediaStreamPtr &stream);
00315     void streamRemoved(const Tp::MediaStreamPtr &stream);
00316     void streamDirectionChanged(const Tp::MediaStreamPtr &stream,
00317             Tp::MediaStreamDirection direction,
00318             Tp::MediaStreamPendingSend pendingSend);
00319     void streamStateChanged(const Tp::MediaStreamPtr &stream,
00320             Tp::MediaStreamState state);
00321     void streamError(const Tp::MediaStreamPtr &stream,
00322             Tp::MediaStreamError errorCode,
00323             const QString &errorMessage);
00324 
00325     void localHoldStateChanged(Tp::LocalHoldState state,
00326             Tp::LocalHoldStateReason reason);
00327 
00328 protected:
00329     StreamedMediaChannel(const ConnectionPtr &connection,
00330             const QString &objectPath, const QVariantMap &immutableProperties);
00331 
00332 private Q_SLOTS:
00333     void onContentReady(Tp::PendingOperation *op);
00334 
00335     void gotSMStreams(QDBusPendingCallWatcher *);
00336     void onSMStreamAdded(uint, uint, uint);
00337     void onSMStreamRemoved(uint);
00338     void onSMStreamDirectionChanged(uint, uint, uint);
00339     void onSMStreamStateChanged(uint streamId, uint streamState);
00340     void onSMStreamError(uint, uint, const QString &);
00341 
00342     void gotCallMainProperties(QDBusPendingCallWatcher *);
00343     void onCallContentAdded(const QDBusObjectPath &, uint);
00344     void onCallContentRemoved(const QDBusObjectPath &);
00345 
00346     void gotLocalHoldState(QDBusPendingCallWatcher *);
00347     void onLocalHoldStateChanged(uint, uint);
00348 
00349 private:
00350     friend class PendingMediaContent;
00351     friend class PendingMediaStreams;
00352 
00353     MediaContentPtr addContentForSMStream(const MediaStreamInfo &streamInfo);
00354     MediaContentPtr lookupContentBySMStreamId(uint streamId);
00355 
00356     MediaContentPtr addContentForCallObjectPath(
00357             const QDBusObjectPath &contentPath);
00358     MediaContentPtr lookupContentByCallObjectPath(
00359             const QDBusObjectPath &contentPath);
00360 
00361     struct Private;
00362     friend struct Private;
00363     Private *mPriv;
00364 };
00365 
00366 } // Tp
00367 
00368 #endif


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