QXmppCodec.h

    00001 /*
    00002  * Copyright (C) 2008-2011 The QXmpp developers
    00003  *
    00004  * Author:
    00005  *  Jeremy Lainé
    00006  *
    00007  * Source:
    00008  *  http://code.google.com/p/qxmpp
    00009  *
    00010  * This file is a part of QXmpp library.
    00011  *
    00012  * This library is free software; you can redistribute it and/or
    00013  * modify it under the terms of the GNU Lesser General Public
    00014  * License as published by the Free Software Foundation; either
    00015  * version 2.1 of the License, or (at your option) any later version.
    00016  *
    00017  * This library is distributed in the hope that it will be useful,
    00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00020  * Lesser General Public License for more details.
    00021  *
    00022  */
    00023
    00024 #ifndef QXMPPCODEC_H
    00025 #define QXMPPCODEC_H
    00026
    00027 #include <QtGlobal>
    00028
    00029 class QXmppRtpPacket;
    00030 class QXmppVideoFormat;
    00031 class QXmppVideoFrame;
    00032
    00037
    00038 class QXmppCodec
    00039 {
    00040 public:
    00043     virtual qint64 encode(QDataStream &input, QDataStream &output) = 0;
    00044
    00047     virtual qint64 decode(QDataStream &input, QDataStream &output) = 0;
    00048 };
    00049
    00053
    00054 class QXmppG711aCodec : public QXmppCodec
    00055 {
    00056 public:
    00057     QXmppG711aCodec(int clockrate);
    00058
    00059     qint64 encode(QDataStream &input, QDataStream &output);
    00060     qint64 decode(QDataStream &input, QDataStream &output);
    00061
    00062 private:
    00063     int m_frequency;
    00064 };
    00065
    00069
    00070 class QXmppG711uCodec : public QXmppCodec
    00071 {
    00072 public:
    00073     QXmppG711uCodec(int clockrate);
    00074
    00075     qint64 encode(QDataStream &input, QDataStream &output);
    00076     qint64 decode(QDataStream &input, QDataStream &output);
    00077
    00078 private:
    00079     int m_frequency;
    00080 };
    00081
    00082 #ifdef QXMPP_USE_SPEEX
    00083 typedef struct SpeexBits SpeexBits;
    00084
    00088
    00089 class QXmppSpeexCodec : public QXmppCodec
    00090 {
    00091 public:
    00092     QXmppSpeexCodec(int clockrate);
    00093     ~QXmppSpeexCodec();
    00094
    00095     qint64 encode(QDataStream &input, QDataStream &output);
    00096     qint64 decode(QDataStream &input, QDataStream &output);
    00097
    00098 private:
    00099     SpeexBits *encoder_bits;
    00100     void *encoder_state;
    00101     SpeexBits *decoder_bits;
    00102     void *decoder_state;
    00103     int frame_samples;
    00104 };
    00105 #endif
    00106
    00109
    00110 class QXmppVideoDecoder
    00111 {
    00112 public:
    00113     virtual QXmppVideoFormat format() const = 0;
    00114     virtual QList<QXmppVideoFrame> handlePacket(const QXmppRtpPacket &packet) = 0;
    00115     virtual bool setParameters(const QMap<QString, QString> &parameters) = 0;
    00116 };
    00117
    00118 class QXmppVideoEncoder
    00119 {
    00120 public:
    00121     virtual bool setFormat(const QXmppVideoFormat &format) = 0;
    00122     virtual QList<QByteArray> handleFrame(const QXmppVideoFrame &frame) = 0;
    00123     virtual QMap<QString, QString> parameters() const = 0;
    00124 };
    00125
    00126 #ifdef QXMPP_USE_THEORA
    00127 class QXmppTheoraDecoderPrivate;
    00128 class QXmppTheoraEncoderPrivate;
    00129
    00130 class QXmppTheoraDecoder : public QXmppVideoDecoder
    00131 {
    00132 public:
    00133     QXmppTheoraDecoder();
    00134     ~QXmppTheoraDecoder();
    00135
    00136     QXmppVideoFormat format() const;
    00137     QList<QXmppVideoFrame> handlePacket(const QXmppRtpPacket &packet);
    00138     bool setParameters(const QMap<QString, QString> &parameters);
    00139
    00140 private:
    00141     QXmppTheoraDecoderPrivate *d;
    00142 };
    00143
    00144 class QXmppTheoraEncoder : public QXmppVideoEncoder
    00145 {
    00146 public:
    00147     QXmppTheoraEncoder();
    00148     ~QXmppTheoraEncoder();
    00149
    00150     bool setFormat(const QXmppVideoFormat &format);
    00151     QList<QByteArray> handleFrame(const QXmppVideoFrame &frame);
    00152     QMap<QString, QString> parameters() const;
    00153
    00154 private:
    00155     QXmppTheoraEncoderPrivate *d;
    00156 };
    00157 #endif
    00158
    00159 #ifdef QXMPP_USE_VPX
    00160 class QXmppVpxDecoderPrivate;
    00161 class QXmppVpxEncoderPrivate;
    00162
    00163 class QXmppVpxDecoder : public QXmppVideoDecoder
    00164 {
    00165 public:
    00166     QXmppVpxDecoder();
    00167     ~QXmppVpxDecoder();
    00168
    00169     QXmppVideoFormat format() const;
    00170     QList<QXmppVideoFrame> handlePacket(const QXmppRtpPacket &packet);
    00171     bool setParameters(const QMap<QString, QString> &parameters);
    00172
    00173 private:
    00174     QXmppVpxDecoderPrivate *d;
    00175 };
    00176
    00177 class QXmppVpxEncoder : public QXmppVideoEncoder
    00178 {
    00179 public:
    00180     QXmppVpxEncoder();
    00181     ~QXmppVpxEncoder();
    00182
    00183     bool setFormat(const QXmppVideoFormat &format);
    00184     QList<QByteArray> handleFrame(const QXmppVideoFrame &frame);
    00185     QMap<QString, QString> parameters() const;
    00186
    00187 private:
    00188     QXmppVpxEncoderPrivate *d;
    00189 };
    00190 #endif
    00191
    00192 #endif

All Classes Functions Enumerations Enumerator Properties