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


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