QXmppRtpChannel.h
/*
* Copyright (C) 2008-2014 The QXmpp developers
*
* Author:
* Jeremy Lainé
*
* Source:
* https://github.com/qxmpp-project/qxmpp
*
* This file is a part of QXmpp library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
#ifndef QXMPPRTPCHANNEL_H
#define QXMPPRTPCHANNEL_H
#include <QIODevice>
#include <QSize>
#include "QXmppJingleIq.h"
#include "QXmppLogger.h"
class QXmppCodec;
class QXmppJinglePayloadType;
class QXmppRtpAudioChannelPrivate;
class QXmppRtpVideoChannelPrivate;
class QXMPP_EXPORT QXmppRtpChannel
{
public:
QXmppRtpChannel();
virtual void close() = 0;
virtual QIODevice::OpenMode openMode() const = 0;
QList<QXmppJinglePayloadType> localPayloadTypes();
void setRemotePayloadTypes(const QList<QXmppJinglePayloadType> &remotePayloadTypes);
quint32 localSsrc() const;
void setLocalSsrc(quint32 ssrc);
protected:
virtual void payloadTypesChanged() = 0;
QList<QXmppJinglePayloadType> m_incomingPayloadTypes;
QList<QXmppJinglePayloadType> m_outgoingPayloadTypes;
bool m_outgoingPayloadNumbered;
private:
quint32 m_outgoingSsrc;
};
class QXMPP_EXPORT QXmppRtpAudioChannel : public QIODevice, public QXmppRtpChannel
{
Q_OBJECT
Q_ENUMS(Tone)
public:
enum Tone {
Tone_0 = 0,
Tone_1,
Tone_2,
Tone_3,
Tone_4,
Tone_5,
Tone_6,
Tone_7,
Tone_8,
Tone_9,
Tone_Star,
Tone_Pound,
Tone_A,
Tone_B,
Tone_C,
Tone_D
};
QXmppRtpAudioChannel(QObject *parent = 0);
~QXmppRtpAudioChannel();
qint64 bytesAvailable() const;
void close();
bool isSequential() const;
QIODevice::OpenMode openMode() const;
QXmppJinglePayloadType payloadType() const;
qint64 pos() const;
bool seek(qint64 pos);
signals:
void sendDatagram(const QByteArray &ba);
void logMessage(QXmppLogger::MessageType type, const QString &msg);
public slots:
void datagramReceived(const QByteArray &ba);
void startTone(QXmppRtpAudioChannel::Tone tone);
void stopTone(QXmppRtpAudioChannel::Tone tone);
protected:
void debug(const QString &message)
{
emit logMessage(QXmppLogger::DebugMessage, qxmpp_loggable_trace(message));
}
void warning(const QString &message)
{
emit logMessage(QXmppLogger::WarningMessage, qxmpp_loggable_trace(message));
}
void logReceived(const QString &message)
{
emit logMessage(QXmppLogger::ReceivedMessage, qxmpp_loggable_trace(message));
}
void logSent(const QString &message)
{
emit logMessage(QXmppLogger::SentMessage, qxmpp_loggable_trace(message));
}
void payloadTypesChanged();
qint64 readData(char * data, qint64 maxSize);
qint64 writeData(const char * data, qint64 maxSize);
private slots:
void emitSignals();
void writeDatagram();
private:
friend class QXmppRtpAudioChannelPrivate;
QXmppRtpAudioChannelPrivate * d;
};
class QXMPP_EXPORT QXmppVideoFrame
{
public:
enum PixelFormat {
Format_Invalid = 0,
Format_RGB32 = 3,
Format_RGB24 = 4,
Format_YUV420P = 18,
Format_UYVY = 20,
Format_YUYV = 21
};
QXmppVideoFrame();
QXmppVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format);
uchar *bits();
const uchar *bits() const;
int bytesPerLine() const;
int height() const;
bool isValid() const;
int mappedBytes() const;
PixelFormat pixelFormat() const;
QSize size() const;
int width() const;
private:
int m_bytesPerLine;
QByteArray m_data;
int m_height;
int m_mappedBytes;
PixelFormat m_pixelFormat;
int m_width;
};
class QXMPP_EXPORT QXmppVideoFormat
{
public:
int frameHeight() const {
return m_frameSize.height();
}
int frameWidth() const {
return m_frameSize.width();
}
qreal frameRate() const {
return m_frameRate;
}
void setFrameRate(qreal frameRate) {
m_frameRate = frameRate;
}
QSize frameSize() const {
return m_frameSize;
}
void setFrameSize(const QSize &frameSize) {
m_frameSize = frameSize;
}
QXmppVideoFrame::PixelFormat pixelFormat() const {
return m_pixelFormat;
}
void setPixelFormat(QXmppVideoFrame::PixelFormat pixelFormat) {
m_pixelFormat = pixelFormat;
}
private:
qreal m_frameRate;
QSize m_frameSize;
QXmppVideoFrame::PixelFormat m_pixelFormat;
};
class QXMPP_EXPORT QXmppRtpVideoChannel : public QXmppLoggable, public QXmppRtpChannel
{
Q_OBJECT
public:
QXmppRtpVideoChannel(QObject *parent = 0);
~QXmppRtpVideoChannel();
void close();
QIODevice::OpenMode openMode() const;
// incoming stream
QXmppVideoFormat decoderFormat() const;
QList<QXmppVideoFrame> readFrames();
// outgoing stream
QXmppVideoFormat encoderFormat() const;
void setEncoderFormat(const QXmppVideoFormat &format);
void writeFrame(const QXmppVideoFrame &frame);
signals:
void sendDatagram(const QByteArray &ba);
public slots:
void datagramReceived(const QByteArray &ba);
protected:
void payloadTypesChanged();
private:
friend class QXmppRtpVideoChannelPrivate;
QXmppRtpVideoChannelPrivate * d;
};
#endif
QXmppRtpAudioChannel::Tone_7
Tone for the 7 key.
Definition: QXmppRtpChannel.h:90
QXmppRtpAudioChannel::Tone_6
Tone for the 6 key.
Definition: QXmppRtpChannel.h:89
QXmppLogger::WarningMessage
Warning message.
Definition: QXmppLogger.h:70
QXmppRtpAudioChannel::Tone_B
Tone for the B key.
Definition: QXmppRtpChannel.h:96
QXmppRtpAudioChannel::Tone_A
Tone for the A key.
Definition: QXmppRtpChannel.h:95
QXmppRtpAudioChannel::Tone
Tone
This enum is used to describe a DTMF tone.
Definition: QXmppRtpChannel.h:82
QXmppRtpAudioChannel::Tone_8
Tone for the 8 key.
Definition: QXmppRtpChannel.h:91
QXmppLogger::MessageType
MessageType
This enum describes a type of log message.
Definition: QXmppLogger.h:65
QXmppJinglePayloadType
The QXmppJinglePayloadType class represents a payload type as specified by XEP-0167: Jingle RTP Sessi...
Definition: QXmppJingleIq.h:40
QXmppRtpAudioChannel::Tone_1
Tone for the 1 key.
Definition: QXmppRtpChannel.h:84
QXmppLoggable
The QXmppLoggable class represents a source of logging messages.
Definition: QXmppLogger.h:111
QXmppRtpAudioChannel::Tone_3
Tone for the 3 key.
Definition: QXmppRtpChannel.h:86
QXmppRtpAudioChannel::Tone_4
Tone for the 4 key.
Definition: QXmppRtpChannel.h:87
QXmppRtpAudioChannel::Tone_5
Tone for the 5 key.
Definition: QXmppRtpChannel.h:88
QXmppRtpAudioChannel::Tone_Pound
Tone for the # key.
Definition: QXmppRtpChannel.h:94
QXmppRtpAudioChannel::Tone_9
Tone for the 9 key.
Definition: QXmppRtpChannel.h:92
QXmppRtpAudioChannel
The QXmppRtpAudioChannel class represents an RTP audio channel to a remote party. ...
Definition: QXmppRtpChannel.h:75
QXmppRtpAudioChannel::Tone_2
Tone for the 2 key.
Definition: QXmppRtpChannel.h:85
QXmppLogger::DebugMessage
Debugging message.
Definition: QXmppLogger.h:68
QXmppRtpAudioChannel::Tone_Star
Tone for the * key.
Definition: QXmppRtpChannel.h:93
QXmppVideoFrame::PixelFormat
PixelFormat
This enum describes a pixel format.
Definition: QXmppRtpChannel.h:168
QXmppLogger::ReceivedMessage
Message received from server.
Definition: QXmppLogger.h:71
QXmppRtpVideoChannel
The QXmppRtpVideoChannel class represents an RTP video channel to a remote party. ...
Definition: QXmppRtpChannel.h:255
QXmppLogger::SentMessage
Message sent to server.
Definition: QXmppLogger.h:72
QXmppVideoFrame
The QXmppVideoFrame class provides a representation of a frame of video data.
Definition: QXmppRtpChannel.h:164
QXmppRtpAudioChannel::Tone_C
Tone for the C key.
Definition: QXmppRtpChannel.h:97