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/Object>
00031 #include <TelepathyQt4/SharedPtr>
00032 #include <TelepathyQt4/Types>
00033 
00034 namespace Tp
00035 {
00036 
00037 class StreamedMediaChannel;
00038 
00039 typedef QList<StreamedMediaStreamPtr> StreamedMediaStreams;
00040 
00041 class TELEPATHY_QT4_EXPORT PendingStreamedMediaStreams : public PendingOperation
00042 {
00043     Q_OBJECT
00044     Q_DISABLE_COPY(PendingStreamedMediaStreams)
00045 
00046 public:
00047     ~PendingStreamedMediaStreams();
00048 
00049     StreamedMediaChannelPtr channel() const;
00050 
00051     StreamedMediaStreams streams() const;
00052 
00053 private Q_SLOTS:
00054     void gotStreams(QDBusPendingCallWatcher *op);
00055 
00056     void onStreamRemoved(const Tp::StreamedMediaStreamPtr &stream);
00057     void onStreamReady(Tp::PendingOperation *op);
00058 
00059 private:
00060     friend class StreamedMediaChannel;
00061 
00062     PendingStreamedMediaStreams(const StreamedMediaChannelPtr &channel,
00063             const ContactPtr &contact,
00064             const QList<MediaStreamType> &types);
00065 
00066     struct Private;
00067     friend struct Private;
00068     Private *mPriv;
00069 };
00070 
00071 class TELEPATHY_QT4_EXPORT StreamedMediaStream : public Object, private ReadyObject
00072 {
00073     Q_OBJECT
00074     Q_DISABLE_COPY(StreamedMediaStream)
00075 
00076 public:
00077     enum SendingState {
00078         SendingStateNone = 0,
00079         SendingStatePendingSend = 1,
00080         SendingStateSending = 2
00081     };
00082 
00083     ~StreamedMediaStream();
00084 
00085     StreamedMediaChannelPtr channel() const;
00086 
00087     uint id() const;
00088 
00089     ContactPtr contact() const;
00090 
00091     MediaStreamState state() const;
00092     MediaStreamType type() const;
00093 
00094     SendingState localSendingState() const;
00095     SendingState remoteSendingState() const;
00096 
00097     bool sending() const;
00098     bool receiving() const;
00099 
00100     bool localSendingRequested() const;
00101     bool remoteSendingRequested() const;
00102 
00103     MediaStreamDirection direction() const;
00104     MediaStreamPendingSend pendingSend() const;
00105 
00106     PendingOperation *requestSending(bool send);
00107     PendingOperation *requestReceiving(bool receive);
00108 
00109     PendingOperation *requestDirection(MediaStreamDirection direction);
00110     PendingOperation *requestDirection(bool send, bool receive);
00111 
00112     PendingOperation *startDTMFTone(DTMFEvent event);
00113     PendingOperation *stopDTMFTone();
00114 
00115 Q_SIGNALS:
00116     void localSendingStateChanged(Tp::StreamedMediaStream::SendingState localSendingState);
00117     void remoteSendingStateChanged(Tp::StreamedMediaStream::SendingState remoteSendingState);
00118 
00119 private Q_SLOTS:
00120     void gotContact(Tp::PendingOperation *op);
00121 
00122 private:
00123     friend class PendingStreamedMediaStreams;
00124     friend class StreamedMediaChannel;
00125 
00126     static const Feature FeatureCore;
00127 
00128     StreamedMediaStream(const StreamedMediaChannelPtr &channel, const MediaStreamInfo &info);
00129 
00130     void gotDirection(uint direction, uint pendingSend);
00131     void gotStreamState(uint state);
00132 
00133     struct Private;
00134     friend struct Private;
00135     Private *mPriv;
00136 };
00137 
00138 class TELEPATHY_QT4_EXPORT StreamedMediaChannel : public Channel
00139 {
00140     Q_OBJECT
00141     Q_DISABLE_COPY(StreamedMediaChannel)
00142     Q_ENUMS(StateChangeReason)
00143 
00144 public:
00145     static const Feature FeatureCore;
00146     static const Feature FeatureStreams;
00147     static const Feature FeatureLocalHoldState;
00148 
00149     enum StateChangeReason {
00150         StateChangeReasonUnknown = 0,
00151         StateChangeReasonUserRequested = 1
00152     };
00153 
00154     static StreamedMediaChannelPtr create(const ConnectionPtr &connection,
00155             const QString &objectPath, const QVariantMap &immutableProperties);
00156 
00157     virtual ~StreamedMediaChannel();
00158 
00159     bool awaitingLocalAnswer() const;
00160     bool awaitingRemoteAnswer() const;
00161 
00162     PendingOperation *acceptCall();
00163     PendingOperation *hangupCall();
00164 
00165     StreamedMediaStreams streams() const;
00166     StreamedMediaStreams streamsForType(MediaStreamType type) const;
00167 
00168     PendingStreamedMediaStreams *requestStream(const ContactPtr &contact, MediaStreamType type);
00169     PendingStreamedMediaStreams *requestStreams(const ContactPtr &contact, QList<MediaStreamType> types);
00170 
00171     PendingOperation *removeStream(const StreamedMediaStreamPtr &stream);
00172     PendingOperation *removeStreams(const StreamedMediaStreams &streams);
00173 
00174     bool handlerStreamingRequired() const;
00175 
00176     LocalHoldState localHoldState() const;
00177     LocalHoldStateReason localHoldStateReason() const;
00178     PendingOperation *requestHold(bool hold);
00179 
00180 Q_SIGNALS:
00181     void streamAdded(const Tp::StreamedMediaStreamPtr &stream);
00182     void streamRemoved(const Tp::StreamedMediaStreamPtr &stream);
00183     void streamDirectionChanged(const Tp::StreamedMediaStreamPtr &stream,
00184             Tp::MediaStreamDirection direction,
00185             Tp::MediaStreamPendingSend pendingSend);
00186     void streamStateChanged(const Tp::StreamedMediaStreamPtr &stream,
00187             Tp::MediaStreamState state);
00188     void streamError(const Tp::StreamedMediaStreamPtr &stream,
00189             Tp::MediaStreamError errorCode,
00190             const QString &errorMessage);
00191 
00192     void localHoldStateChanged(Tp::LocalHoldState state,
00193             Tp::LocalHoldStateReason reason);
00194 
00195 protected:
00196     StreamedMediaChannel(const ConnectionPtr &connection,
00197             const QString &objectPath, const QVariantMap &immutableProperties,
00198             const Feature &coreFeature = StreamedMediaChannel::FeatureCore);
00199 
00200 private Q_SLOTS:
00201     void onStreamReady(Tp::PendingOperation *op);
00202 
00203     void gotStreams(QDBusPendingCallWatcher *);
00204     void onStreamAdded(uint, uint, uint);
00205     void onStreamRemoved(uint);
00206     void onStreamDirectionChanged(uint, uint, uint);
00207     void onStreamStateChanged(uint streamId, uint streamState);
00208     void onStreamError(uint, uint, const QString &);
00209 
00210     void gotLocalHoldState(QDBusPendingCallWatcher *);
00211     void onLocalHoldStateChanged(uint, uint);
00212 
00213 private:
00214     friend class PendingStreamedMediaStreams;
00215 
00216     StreamedMediaStreamPtr addStream(const MediaStreamInfo &streamInfo);
00217     StreamedMediaStreamPtr lookupStreamById(uint streamId);
00218 
00219     struct Private;
00220     friend struct Private;
00221     Private *mPriv;
00222 };
00223 
00224 } // Tp
00225 
00226 #endif


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