QXmpp Version: 0.9.3
QXmppRtpChannel.h
1/*
2 * Copyright (C) 2008-2014 The QXmpp developers
3 *
4 * Author:
5 * Jeremy Lainé
6 *
7 * Source:
8 * https://github.com/qxmpp-project/qxmpp
9 *
10 * This file is a part of QXmpp library.
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 */
23
24#ifndef QXMPPRTPCHANNEL_H
25#define QXMPPRTPCHANNEL_H
26
27#include <QIODevice>
28#include <QSize>
29
30#include "QXmppJingleIq.h"
31#include "QXmppLogger.h"
32
33class QXmppCodec;
35class QXmppRtpAudioChannelPrivate;
36class QXmppRtpVideoChannelPrivate;
37
38class QXMPP_EXPORT QXmppRtpChannel
39{
40public:
41 QXmppRtpChannel();
42
44 virtual void close() = 0;
45
47 virtual QIODevice::OpenMode openMode() const = 0;
48
49 QList<QXmppJinglePayloadType> localPayloadTypes();
50 void setRemotePayloadTypes(const QList<QXmppJinglePayloadType> &remotePayloadTypes);
51
52 quint32 localSsrc() const;
53 void setLocalSsrc(quint32 ssrc);
54
55protected:
57 virtual void payloadTypesChanged() = 0;
58
59 QList<QXmppJinglePayloadType> m_incomingPayloadTypes;
60 QList<QXmppJinglePayloadType> m_outgoingPayloadTypes;
61 bool m_outgoingPayloadNumbered;
63
64private:
65 quint32 m_outgoingSsrc;
66};
67
74
75class QXMPP_EXPORT QXmppRtpAudioChannel : public QIODevice, public QXmppRtpChannel
76{
77 Q_OBJECT
78 Q_ENUMS(Tone)
79
80public:
82 enum Tone {
83 Tone_0 = 0,
98 Tone_D
99 };
100
101 QXmppRtpAudioChannel(QObject *parent = 0);
103
104 qint64 bytesAvailable() const;
105 void close();
106 bool isSequential() const;
107 QIODevice::OpenMode openMode() const;
108 QXmppJinglePayloadType payloadType() const;
109 qint64 pos() const;
110 bool seek(qint64 pos);
111
112signals:
114 void sendDatagram(const QByteArray &ba);
115
117 void logMessage(QXmppLogger::MessageType type, const QString &msg);
118
119public slots:
120 void datagramReceived(const QByteArray &ba);
121 void startTone(QXmppRtpAudioChannel::Tone tone);
122 void stopTone(QXmppRtpAudioChannel::Tone tone);
123
124protected:
126 void debug(const QString &message)
127 {
128 emit logMessage(QXmppLogger::DebugMessage, qxmpp_loggable_trace(message));
129 }
130
131 void warning(const QString &message)
132 {
133 emit logMessage(QXmppLogger::WarningMessage, qxmpp_loggable_trace(message));
134 }
135
136 void logReceived(const QString &message)
137 {
138 emit logMessage(QXmppLogger::ReceivedMessage, qxmpp_loggable_trace(message));
139 }
140
141 void logSent(const QString &message)
142 {
143 emit logMessage(QXmppLogger::SentMessage, qxmpp_loggable_trace(message));
144 }
145
146 void payloadTypesChanged();
147 qint64 readData(char * data, qint64 maxSize);
148 qint64 writeData(const char * data, qint64 maxSize);
150
151private slots:
152 void emitSignals();
153 void writeDatagram();
154
155private:
156 friend class QXmppRtpAudioChannelPrivate;
157 QXmppRtpAudioChannelPrivate * d;
158};
159
163
164class QXMPP_EXPORT QXmppVideoFrame
165{
166public:
169 Format_Invalid = 0,
170 Format_RGB32 = 3,
171 Format_RGB24 = 4,
172 Format_YUV420P = 18,
176 Format_UYVY = 20,
181 Format_YUYV = 21
186 };
187
189 QXmppVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format);
190 uchar *bits();
191 const uchar *bits() const;
192 int bytesPerLine() const;
193 int height() const;
194 bool isValid() const;
195 int mappedBytes() const;
196 PixelFormat pixelFormat() const;
197 QSize size() const;
198 int width() const;
199
200private:
201 int m_bytesPerLine;
202 QByteArray m_data;
203 int m_height;
204 int m_mappedBytes;
205 PixelFormat m_pixelFormat;
206 int m_width;
207};
208
209class QXMPP_EXPORT QXmppVideoFormat
210{
211public:
212 int frameHeight() const {
213 return m_frameSize.height();
214 }
215
216 int frameWidth() const {
217 return m_frameSize.width();
218 }
219
220 qreal frameRate() const {
221 return m_frameRate;
222 }
223
224 void setFrameRate(qreal frameRate) {
225 m_frameRate = frameRate;
226 }
227
228 QSize frameSize() const {
229 return m_frameSize;
230 }
231
232 void setFrameSize(const QSize &frameSize) {
233 m_frameSize = frameSize;
234 }
235
236 QXmppVideoFrame::PixelFormat pixelFormat() const {
237 return m_pixelFormat;
238 }
239
240 void setPixelFormat(QXmppVideoFrame::PixelFormat pixelFormat) {
241 m_pixelFormat = pixelFormat;
242 }
243
244private:
245 qreal m_frameRate;
246 QSize m_frameSize;
247 QXmppVideoFrame::PixelFormat m_pixelFormat;
248};
249
250
254
255class QXMPP_EXPORT QXmppRtpVideoChannel : public QXmppLoggable, public QXmppRtpChannel
256{
257 Q_OBJECT
258
259public:
260 QXmppRtpVideoChannel(QObject *parent = 0);
262
263 void close();
264 QIODevice::OpenMode openMode() const;
265
266 // incoming stream
267 QXmppVideoFormat decoderFormat() const;
268 QList<QXmppVideoFrame> readFrames();
269
270 // outgoing stream
271 QXmppVideoFormat encoderFormat() const;
272 void setEncoderFormat(const QXmppVideoFormat &format);
273 void writeFrame(const QXmppVideoFrame &frame);
274
275signals:
277 void sendDatagram(const QByteArray &ba);
278
279public slots:
280 void datagramReceived(const QByteArray &ba);
281
282protected:
284 void payloadTypesChanged();
286
287private:
288 friend class QXmppRtpVideoChannelPrivate;
289 QXmppRtpVideoChannelPrivate * d;
290};
291
292#endif
The QXmppJinglePayloadType class represents a payload type as specified by XEP-0167: Jingle RTP Sessi...
Definition: QXmppJingleIq.h:41
The QXmppLoggable class represents a source of logging messages.
Definition: QXmppLogger.h:112
MessageType
This enum describes a type of log message.
Definition: QXmppLogger.h:66
@ ReceivedMessage
Message received from server.
Definition: QXmppLogger.h:71
@ SentMessage
Message sent to server.
Definition: QXmppLogger.h:72
@ DebugMessage
Debugging message.
Definition: QXmppLogger.h:68
@ WarningMessage
Warning message.
Definition: QXmppLogger.h:70
The QXmppRtpAudioChannel class represents an RTP audio channel to a remote party.
Definition: QXmppRtpChannel.h:76
void logMessage(QXmppLogger::MessageType type, const QString &msg)
This signal is emitted to send logging messages.
Tone
This enum is used to describe a DTMF tone.
Definition: QXmppRtpChannel.h:82
@ Tone_C
Tone for the C key.
Definition: QXmppRtpChannel.h:97
@ Tone_6
Tone for the 6 key.
Definition: QXmppRtpChannel.h:89
@ Tone_5
Tone for the 5 key.
Definition: QXmppRtpChannel.h:88
@ Tone_4
Tone for the 4 key.
Definition: QXmppRtpChannel.h:87
@ Tone_Pound
Tone for the # key.
Definition: QXmppRtpChannel.h:94
@ Tone_B
Tone for the B key.
Definition: QXmppRtpChannel.h:96
@ Tone_Star
Tone for the * key.
Definition: QXmppRtpChannel.h:93
@ Tone_2
Tone for the 2 key.
Definition: QXmppRtpChannel.h:85
@ Tone_A
Tone for the A key.
Definition: QXmppRtpChannel.h:95
@ Tone_8
Tone for the 8 key.
Definition: QXmppRtpChannel.h:91
@ Tone_7
Tone for the 7 key.
Definition: QXmppRtpChannel.h:90
@ Tone_9
Tone for the 9 key.
Definition: QXmppRtpChannel.h:92
@ Tone_3
Tone for the 3 key.
Definition: QXmppRtpChannel.h:86
@ Tone_1
Tone for the 1 key.
Definition: QXmppRtpChannel.h:84
void sendDatagram(const QByteArray &ba)
This signal is emitted when a datagram needs to be sent.
The QXmppRtpVideoChannel class represents an RTP video channel to a remote party.
Definition: QXmppRtpChannel.h:256
void sendDatagram(const QByteArray &ba)
This signal is emitted when a datagram needs to be sent.
The QXmppVideoFrame class provides a representation of a frame of video data.
Definition: QXmppRtpChannel.h:165
PixelFormat
This enum describes a pixel format.
Definition: QXmppRtpChannel.h:168