QXmpp Version:0.3.0
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 QXmppVideoFormat;
00030 class QXmppVideoFrame;
00031 
00036 
00037 class QXmppCodec
00038 {
00039 public:
00042     virtual qint64 encode(QDataStream &input, QDataStream &output) = 0;
00043 
00046     virtual qint64 decode(QDataStream &input, QDataStream &output) = 0;
00047 };
00048 
00052 
00053 class QXmppG711aCodec : public QXmppCodec
00054 {
00055 public:
00056     QXmppG711aCodec(int clockrate);
00057 
00058     qint64 encode(QDataStream &input, QDataStream &output);
00059     qint64 decode(QDataStream &input, QDataStream &output);
00060 
00061 private:
00062     int m_frequency;
00063 };
00064 
00068 
00069 class QXmppG711uCodec : public QXmppCodec
00070 {
00071 public:
00072     QXmppG711uCodec(int clockrate);
00073 
00074     qint64 encode(QDataStream &input, QDataStream &output);
00075     qint64 decode(QDataStream &input, QDataStream &output);
00076 
00077 private:
00078     int m_frequency;
00079 };
00080 
00081 #ifdef QXMPP_USE_SPEEX
00082 typedef struct SpeexBits SpeexBits;
00083 
00087 
00088 class QXmppSpeexCodec : public QXmppCodec
00089 {
00090 public:
00091     QXmppSpeexCodec(int clockrate);
00092     ~QXmppSpeexCodec();
00093 
00094     qint64 encode(QDataStream &input, QDataStream &output);
00095     qint64 decode(QDataStream &input, QDataStream &output);
00096 
00097 private:
00098     SpeexBits *encoder_bits;
00099     void *encoder_state;
00100     SpeexBits *decoder_bits;
00101     void *decoder_state;
00102     int frame_samples;
00103 };
00104 #endif
00105 
00108 
00109 class QXmppVideoDecoder
00110 {
00111 public:
00112     virtual QXmppVideoFormat format() const = 0;
00113     virtual QList<QXmppVideoFrame> handlePacket(const QByteArray &ba) = 0;
00114     virtual bool setParameters(const QMap<QString, QString> &parameters) = 0;
00115 };
00116 
00117 class QXmppVideoEncoder
00118 {
00119 public:
00120     virtual bool setFormat(const QXmppVideoFormat &format) = 0;
00121     virtual QList<QByteArray> handleFrame(const QXmppVideoFrame &frame) = 0;
00122     virtual QMap<QString, QString> parameters() const = 0;
00123 };
00124 
00125 #ifdef QXMPP_USE_THEORA
00126 class QXmppTheoraDecoderPrivate;
00127 class QXmppTheoraEncoderPrivate;
00128 
00129 class QXmppTheoraDecoder : public QXmppVideoDecoder
00130 {
00131 public:
00132     QXmppTheoraDecoder();
00133     ~QXmppTheoraDecoder();
00134 
00135     QXmppVideoFormat format() const;
00136     QList<QXmppVideoFrame> handlePacket(const QByteArray &ba);
00137     bool setParameters(const QMap<QString, QString> &parameters);
00138 
00139 private:
00140     QXmppTheoraDecoderPrivate *d;
00141 };
00142 
00143 class QXmppTheoraEncoder : public QXmppVideoEncoder
00144 {
00145 public:
00146     QXmppTheoraEncoder();
00147     ~QXmppTheoraEncoder();
00148 
00149     bool setFormat(const QXmppVideoFormat &format);
00150     QList<QByteArray> handleFrame(const QXmppVideoFrame &frame);
00151     QMap<QString, QString> parameters() const;
00152 
00153 private:
00154     QXmppTheoraEncoderPrivate *d;
00155 };
00156 #endif
00157 
00158 #endif
 All Classes Functions Enumerations Enumerator Properties