00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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/Client/Channel>
00029 #include <TelepathyQt4/Client/PendingOperation>
00030
00031 namespace Telepathy
00032 {
00033 namespace Client
00034 {
00035
00036 class StreamedMediaChannel;
00037 class MediaStream;
00038
00039 typedef QExplicitlySharedDataPointer<MediaStream> MediaStreamPtr;
00040 typedef QList<MediaStreamPtr> MediaStreams;
00041
00042 class PendingMediaStreams : public PendingOperation
00043 {
00044 Q_OBJECT
00045 Q_DISABLE_COPY(PendingMediaStreams)
00046
00047 public:
00048 ~PendingMediaStreams();
00049
00050 MediaStreams streams() const;
00051
00052 private Q_SLOTS:
00053 void gotStreams(QDBusPendingCallWatcher *);
00054 void onStreamRemoved(Telepathy::Client::MediaStreamPtr);
00055 void onStreamReady(Telepathy::Client::PendingOperation *);
00056
00057 private:
00058 friend class StreamedMediaChannel;
00059
00060 PendingMediaStreams(StreamedMediaChannel *channel,
00061 ContactPtr contact,
00062 QList<Telepathy::MediaStreamType> types,
00063 QObject *parent = 0);
00064 PendingMediaStreams(StreamedMediaChannel *channel,
00065 const MediaStreams &streams,
00066 QObject *parent = 0);
00067
00068 struct Private;
00069 friend struct Private;
00070 Private *mPriv;
00071 };
00072
00073 class MediaStream : public QObject,
00074 private ReadyObject,
00075 public QSharedData
00076 {
00077 Q_OBJECT
00078 Q_DISABLE_COPY(MediaStream)
00079
00080 public:
00081 ~MediaStream();
00082
00083 StreamedMediaChannel *channel() const;
00084 uint id() const;
00085
00086 ContactPtr contact() const;
00087 Telepathy::MediaStreamState state() const;
00088 Telepathy::MediaStreamType type() const;
00089
00090 bool sending() const;
00091 bool receiving() const;
00092 bool localSendingRequested() const;
00093 bool remoteSendingRequested() const;
00094
00095 Telepathy::MediaStreamDirection direction() const;
00096 Telepathy::MediaStreamPendingSend pendingSend() const;
00097
00098 PendingOperation *requestDirection(
00099 Telepathy::MediaStreamDirection direction);
00100 PendingOperation *requestDirection(
00101 bool send, bool receive);
00102
00103 private Q_SLOTS:
00104 void gotContact(Telepathy::Client::PendingOperation *op);
00105
00106 private:
00107 friend class PendingMediaStreams;
00108 friend class StreamedMediaChannel;
00109
00110 static const Feature FeatureContact;
00111
00112 MediaStream(StreamedMediaChannel *channel, uint id,
00113 uint contactHandle, MediaStreamType type,
00114 MediaStreamState state, MediaStreamDirection direction,
00115 MediaStreamPendingSend pendingSend);
00116
00117 uint contactHandle() const;
00118 void setContact(const ContactPtr &contact);
00119 void setDirection(Telepathy::MediaStreamDirection direction,
00120 Telepathy::MediaStreamPendingSend pendingSend);
00121 void setState(Telepathy::MediaStreamState state);
00122
00123 struct Private;
00124 friend struct Private;
00125 Private *mPriv;
00126 };
00127
00128 class StreamedMediaChannel : public Channel
00129 {
00130 Q_OBJECT
00131 Q_DISABLE_COPY(StreamedMediaChannel)
00132
00133 public:
00134 static const Feature FeatureStreams;
00135
00136 StreamedMediaChannel(Connection *connection, const QString &objectPath,
00137 const QVariantMap &immutableProperties, QObject *parent = 0);
00138 ~StreamedMediaChannel();
00139
00140 MediaStreams streams() const;
00141 MediaStreams streamsForType(Telepathy::MediaStreamType type) const;
00142
00143 bool awaitingLocalAnswer() const;
00144 bool awaitingRemoteAnswer() const;
00145
00146 PendingOperation *acceptCall();
00147
00148 PendingOperation *removeStream(const MediaStreamPtr &stream);
00149 PendingOperation *removeStreams(const MediaStreams &streams);
00150
00151 PendingMediaStreams *requestStream(
00152 const ContactPtr &contact,
00153 Telepathy::MediaStreamType type);
00154 PendingMediaStreams *requestStreams(
00155 const ContactPtr &contact,
00156 QList<Telepathy::MediaStreamType> types);
00157
00158 Q_SIGNALS:
00159 void streamAdded(const Telepathy::Client::MediaStreamPtr &stream);
00160 void streamRemoved(const Telepathy::Client::MediaStreamPtr &stream);
00161 void streamDirectionChanged(const Telepathy::Client::MediaStreamPtr &stream,
00162 Telepathy::MediaStreamDirection direction,
00163 Telepathy::MediaStreamPendingSend pendingSend);
00164 void streamStateChanged(const Telepathy::Client::MediaStreamPtr &stream,
00165 Telepathy::MediaStreamState);
00166 void streamError(const Telepathy::Client::MediaStreamPtr &stream,
00167 Telepathy::MediaStreamError errorCode,
00168 const QString &errorMessage);
00169
00170 private Q_SLOTS:
00171 void gotStreams(QDBusPendingCallWatcher *);
00172 void onStreamReady(Telepathy::Client::PendingOperation *);
00173 void onStreamAdded(uint, uint, uint);
00174 void onStreamRemoved(uint);
00175 void onStreamDirectionChanged(uint, uint, uint);
00176 void onStreamStateChanged(uint, uint);
00177 void onStreamError(uint, uint, const QString &);
00178
00179 private:
00180 friend class PendingMediaStreams;
00181
00182 void addStream(const MediaStreamPtr &stream);
00183 MediaStreamPtr lookupStreamById(uint streamId);
00184
00185 struct Private;
00186 friend struct Private;
00187 Private *mPriv;
00188 };
00189
00190 typedef QExplicitlySharedDataPointer<StreamedMediaChannel> StreamedMediaChannelPtr;
00191
00192 }
00193 }
00194
00195 #endif