QXmpp  Version:0.4.92
 All Classes Functions Enumerations Enumerator Properties Groups
QXmppCodec.h
1 /*
2  * Copyright (C) 2008-2011 The QXmpp developers
3  *
4  * Author:
5  * Jeremy LainĂ©
6  *
7  * Source:
8  * http://code.google.com/p/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 QXMPPCODEC_H
25 #define QXMPPCODEC_H
26 
27 #include <QtGlobal>
28 
29 #include "QXmppGlobal.h"
30 
31 class QXmppRtpPacket;
32 class QXmppVideoFormat;
33 class QXmppVideoFrame;
34 
39 
40 class QXMPP_EXPORT QXmppCodec
41 {
42 public:
43  virtual ~QXmppCodec();
44 
47  virtual qint64 encode(QDataStream &input, QDataStream &output) = 0;
48 
51  virtual qint64 decode(QDataStream &input, QDataStream &output) = 0;
52 };
53 
57 
58 class QXmppG711aCodec : public QXmppCodec
59 {
60 public:
61  QXmppG711aCodec(int clockrate);
62 
63  qint64 encode(QDataStream &input, QDataStream &output);
64  qint64 decode(QDataStream &input, QDataStream &output);
65 
66 private:
67  int m_frequency;
68 };
69 
73 
74 class QXmppG711uCodec : public QXmppCodec
75 {
76 public:
77  QXmppG711uCodec(int clockrate);
78 
79  qint64 encode(QDataStream &input, QDataStream &output);
80  qint64 decode(QDataStream &input, QDataStream &output);
81 
82 private:
83  int m_frequency;
84 };
85 
86 #ifdef QXMPP_USE_SPEEX
87 typedef struct SpeexBits SpeexBits;
88 
92 
93 class QXMPP_EXPORT QXmppSpeexCodec : public QXmppCodec
94 {
95 public:
96  QXmppSpeexCodec(int clockrate);
97  ~QXmppSpeexCodec();
98 
99  qint64 encode(QDataStream &input, QDataStream &output);
100  qint64 decode(QDataStream &input, QDataStream &output);
101 
102 private:
103  SpeexBits *encoder_bits;
104  void *encoder_state;
105  SpeexBits *decoder_bits;
106  void *decoder_state;
107  int frame_samples;
108 };
109 #endif
110 
113 
114 class QXMPP_EXPORT QXmppVideoDecoder
115 {
116 public:
117  virtual ~QXmppVideoDecoder();
118 
120  virtual QXmppVideoFormat format() const = 0;
121 
123  virtual QList<QXmppVideoFrame> handlePacket(const QXmppRtpPacket &packet) = 0;
124 
126  virtual bool setParameters(const QMap<QString, QString> &parameters) = 0;
127 };
128 
131 
132 class QXMPP_EXPORT QXmppVideoEncoder
133 {
134 public:
135  virtual ~QXmppVideoEncoder();
136 
138  virtual bool setFormat(const QXmppVideoFormat &format) = 0;
139 
141  virtual QList<QByteArray> handleFrame(const QXmppVideoFrame &frame) = 0;
142 
144  virtual QMap<QString, QString> parameters() const = 0;
145 };
146 
147 #ifdef QXMPP_USE_THEORA
148 class QXmppTheoraDecoderPrivate;
149 class QXmppTheoraEncoderPrivate;
150 
151 class QXMPP_EXPORT QXmppTheoraDecoder : public QXmppVideoDecoder
152 {
153 public:
154  QXmppTheoraDecoder();
155  ~QXmppTheoraDecoder();
156 
157  QXmppVideoFormat format() const;
158  QList<QXmppVideoFrame> handlePacket(const QXmppRtpPacket &packet);
159  bool setParameters(const QMap<QString, QString> &parameters);
160 
161 private:
162  QXmppTheoraDecoderPrivate *d;
163 };
164 
165 class QXMPP_EXPORT QXmppTheoraEncoder : public QXmppVideoEncoder
166 {
167 public:
168  QXmppTheoraEncoder();
169  ~QXmppTheoraEncoder();
170 
171  bool setFormat(const QXmppVideoFormat &format);
172  QList<QByteArray> handleFrame(const QXmppVideoFrame &frame);
173  QMap<QString, QString> parameters() const;
174 
175 private:
176  QXmppTheoraEncoderPrivate *d;
177 };
178 #endif
179 
180 #ifdef QXMPP_USE_VPX
181 class QXmppVpxDecoderPrivate;
182 class QXmppVpxEncoderPrivate;
183 
184 class QXMPP_EXPORT QXmppVpxDecoder : public QXmppVideoDecoder
185 {
186 public:
187  QXmppVpxDecoder();
188  ~QXmppVpxDecoder();
189 
190  QXmppVideoFormat format() const;
191  QList<QXmppVideoFrame> handlePacket(const QXmppRtpPacket &packet);
192  bool setParameters(const QMap<QString, QString> &parameters);
193 
194 private:
195  QXmppVpxDecoderPrivate *d;
196 };
197 
198 class QXMPP_EXPORT QXmppVpxEncoder : public QXmppVideoEncoder
199 {
200 public:
201  QXmppVpxEncoder();
202  ~QXmppVpxEncoder();
203 
204  bool setFormat(const QXmppVideoFormat &format);
205  QList<QByteArray> handleFrame(const QXmppVideoFrame &frame);
206  QMap<QString, QString> parameters() const;
207 
208 private:
209  QXmppVpxEncoderPrivate *d;
210 };
211 #endif
212 
213 #endif