~ubuntu-branches/ubuntu/utopic/psi/utopic

« back to all changes in this revision

Viewing changes to src/psimedia/psimediaprovider.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2008-2009  Barracuda Networks, Inc.
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2.1 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
17
 * 02110-1301  USA
 
18
 *
 
19
 */
 
20
 
 
21
#ifndef PSIMEDIAPROVIDER_H
 
22
#define PSIMEDIAPROVIDER_H
 
23
 
 
24
#include <QString>
 
25
#include <QList>
 
26
#include <QByteArray>
 
27
#include <QSize>
 
28
#include <QObject>
 
29
 
 
30
class QImage;
 
31
class QIODevice;
 
32
 
 
33
#ifdef QT_GUI_LIB
 
34
class QWidget;
 
35
class QPainter;
 
36
#endif
 
37
 
 
38
// since we cannot put signals/slots in Qt "interfaces", we use the following
 
39
//   defines to hint about signals/slots that derived classes should provide
 
40
#define HINT_SIGNALS protected
 
41
#define HINT_PUBLIC_SLOTS public
 
42
#define HINT_METHOD(x)
 
43
 
 
44
namespace PsiMedia {
 
45
 
 
46
class Provider;
 
47
class FeaturesContext;
 
48
class RtpSessionContext;
 
49
 
 
50
class Plugin
 
51
{
 
52
public:
 
53
        virtual ~Plugin() {}
 
54
        virtual Provider *createProvider() = 0;
 
55
};
 
56
 
 
57
class QObjectInterface
 
58
{
 
59
public:
 
60
        virtual ~QObjectInterface() {}
 
61
 
 
62
        virtual QObject *qobject() = 0;
 
63
};
 
64
 
 
65
class PDevice
 
66
{
 
67
public:
 
68
        enum Type
 
69
        {
 
70
                AudioOut,
 
71
                AudioIn,
 
72
                VideoIn
 
73
        };
 
74
 
 
75
        Type type;
 
76
        QString name;
 
77
        QString id;
 
78
};
 
79
 
 
80
class PAudioParams
 
81
{
 
82
public:
 
83
        QString codec;
 
84
        int sampleRate;
 
85
        int sampleSize;
 
86
        int channels;
 
87
 
 
88
        inline PAudioParams() :
 
89
                sampleRate(0),
 
90
                sampleSize(0),
 
91
                channels(0)
 
92
        {
 
93
        }
 
94
};
 
95
 
 
96
class PVideoParams
 
97
{
 
98
public:
 
99
        QString codec;
 
100
        QSize size;
 
101
        int fps;
 
102
 
 
103
        inline PVideoParams() :
 
104
                fps(0)
 
105
        {
 
106
        }
 
107
};
 
108
 
 
109
class PFeatures
 
110
{
 
111
public:
 
112
        QList<PDevice> audioOutputDevices;
 
113
        QList<PDevice> audioInputDevices;
 
114
        QList<PDevice> videoInputDevices;
 
115
        QList<PAudioParams> supportedAudioModes;
 
116
        QList<PVideoParams> supportedVideoModes;
 
117
};
 
118
 
 
119
class PPayloadInfo
 
120
{
 
121
public:
 
122
        class Parameter
 
123
        {
 
124
        public:
 
125
                QString name;
 
126
                QString value;
 
127
        };
 
128
 
 
129
        int id;
 
130
        QString name;
 
131
        int clockrate;
 
132
        int channels;
 
133
        int ptime;
 
134
        int maxptime;
 
135
        QList<Parameter> parameters;
 
136
 
 
137
        inline PPayloadInfo() :
 
138
                id(-1),
 
139
                clockrate(-1),
 
140
                channels(-1),
 
141
                ptime(-1),
 
142
                maxptime(-1)
 
143
        {
 
144
        }
 
145
};
 
146
 
 
147
class PRtpPacket
 
148
{
 
149
public:
 
150
        QByteArray rawValue;
 
151
        int portOffset;
 
152
 
 
153
        inline PRtpPacket() :
 
154
                portOffset(0)
 
155
        {
 
156
        }
 
157
};
 
158
 
 
159
class Provider : public QObjectInterface
 
160
{
 
161
public:
 
162
        virtual bool init(const QString &resourcePath) = 0;
 
163
        virtual QString creditName() = 0;
 
164
        virtual QString creditText() = 0;
 
165
 
 
166
        virtual FeaturesContext *createFeatures() = 0;
 
167
        virtual RtpSessionContext *createRtpSession() = 0;
 
168
};
 
169
 
 
170
class FeaturesContext : public QObjectInterface
 
171
{
 
172
public:
 
173
        enum Type
 
174
        {
 
175
                AudioOut   = 0x01,
 
176
                AudioIn    = 0x02,
 
177
                VideoIn    = 0x04,
 
178
                AudioModes = 0x08,
 
179
                VideoModes = 0x10
 
180
        };
 
181
 
 
182
        virtual void lookup(int types) = 0;
 
183
        virtual bool waitForFinished(int msecs) = 0; // -1 = no timeout
 
184
        virtual PFeatures results() const = 0;
 
185
 
 
186
HINT_SIGNALS:
 
187
        HINT_METHOD(finished())
 
188
};
 
189
 
 
190
class RtpChannelContext : public QObjectInterface
 
191
{
 
192
public:
 
193
        virtual void setEnabled(bool b) = 0;
 
194
 
 
195
        virtual int packetsAvailable() const = 0;
 
196
        virtual PRtpPacket read() = 0;
 
197
        virtual void write(const PRtpPacket &rtp) = 0;
 
198
 
 
199
HINT_SIGNALS:
 
200
        HINT_METHOD(readyRead())
 
201
        HINT_METHOD(packetsWritten(int count))
 
202
};
 
203
 
 
204
#ifdef QT_GUI_LIB
 
205
class VideoWidgetContext : public QObjectInterface
 
206
{
 
207
public:
 
208
        virtual QWidget *qwidget() = 0;
 
209
 
 
210
        // this function causes VideoWidget::videoSizeChanged() to be emitted
 
211
        virtual void setVideoSize(const QSize &size) = 0;
 
212
 
 
213
HINT_SIGNALS:
 
214
        HINT_METHOD(resized(const QSize &newSize))
 
215
 
 
216
        // listener must use a direct connection and paint during the signal
 
217
        HINT_METHOD(paintEvent(QPainter *p))
 
218
};
 
219
#endif
 
220
 
 
221
class RtpSessionContext : public QObjectInterface
 
222
{
 
223
public:
 
224
        enum Error
 
225
        {
 
226
                ErrorGeneric,
 
227
                ErrorSystem,
 
228
                ErrorCodec
 
229
        };
 
230
 
 
231
        virtual void setAudioOutputDevice(const QString &deviceId) = 0;
 
232
        virtual void setAudioInputDevice(const QString &deviceId) = 0;
 
233
        virtual void setVideoInputDevice(const QString &deviceId) = 0;
 
234
        virtual void setFileInput(const QString &fileName) = 0;
 
235
        virtual void setFileDataInput(const QByteArray &fileData) = 0;
 
236
        virtual void setFileLoopEnabled(bool enabled) = 0;
 
237
 
 
238
#ifdef QT_GUI_LIB
 
239
        virtual void setVideoOutputWidget(VideoWidgetContext *widget) = 0;
 
240
        virtual void setVideoPreviewWidget(VideoWidgetContext *widget) = 0;
 
241
#endif
 
242
 
 
243
        virtual void setRecorder(QIODevice *recordDevice) = 0;
 
244
        virtual void stopRecording() = 0;
 
245
 
 
246
        virtual void setLocalAudioPreferences(const QList<PAudioParams> &params) = 0;
 
247
        virtual void setLocalVideoPreferences(const QList<PVideoParams> &params) = 0;
 
248
 
 
249
        virtual void setMaximumSendingBitrate(int kbps) = 0;
 
250
 
 
251
        virtual void setRemoteAudioPreferences(const QList<PPayloadInfo> &info) = 0;
 
252
        virtual void setRemoteVideoPreferences(const QList<PPayloadInfo> &info) = 0;
 
253
 
 
254
        virtual void start() = 0;
 
255
        virtual void updatePreferences() = 0;
 
256
 
 
257
        virtual void transmitAudio() = 0;
 
258
        virtual void transmitVideo() = 0;
 
259
 
 
260
        virtual void pauseAudio() = 0;
 
261
        virtual void pauseVideo() = 0;
 
262
        virtual void stop() = 0;
 
263
 
 
264
        virtual QList<PPayloadInfo> localAudioPayloadInfo() const = 0;
 
265
        virtual QList<PPayloadInfo> localVideoPayloadInfo() const = 0;
 
266
        virtual QList<PPayloadInfo> remoteAudioPayloadInfo() const = 0;
 
267
        virtual QList<PPayloadInfo> remoteVideoPayloadInfo() const = 0;
 
268
 
 
269
        virtual QList<PAudioParams> audioParams() const = 0;
 
270
        virtual QList<PVideoParams> videoParams() const = 0;
 
271
 
 
272
        virtual bool canTransmitAudio() const = 0;
 
273
        virtual bool canTransmitVideo() const = 0;
 
274
 
 
275
        virtual int outputVolume() const = 0; // 0 (mute) to 100
 
276
        virtual void setOutputVolume(int level) = 0;
 
277
 
 
278
        virtual int inputVolume() const = 0; // 0 (mute) to 100
 
279
        virtual void setInputVolume(int level) = 0;
 
280
 
 
281
        virtual Error errorCode() const = 0;
 
282
 
 
283
        virtual RtpChannelContext *audioRtpChannel() = 0;
 
284
        virtual RtpChannelContext *videoRtpChannel() = 0;
 
285
 
 
286
HINT_SIGNALS:
 
287
        HINT_METHOD(started())
 
288
        HINT_METHOD(preferencesUpdated())
 
289
        HINT_METHOD(audioOutputIntensityChanged(int intensity))
 
290
        HINT_METHOD(audioInputIntensityChanged(int intensity))
 
291
        HINT_METHOD(stoppedRecording())
 
292
        HINT_METHOD(stopped())
 
293
        HINT_METHOD(finished()) // for file playback only
 
294
        HINT_METHOD(error())
 
295
};
 
296
 
 
297
}
 
298
 
 
299
Q_DECLARE_INTERFACE(PsiMedia::Plugin, "org.psi-im.psimedia.Plugin/1.0")
 
300
Q_DECLARE_INTERFACE(PsiMedia::Provider, "org.psi-im.psimedia.Provider/1.0")
 
301
Q_DECLARE_INTERFACE(PsiMedia::FeaturesContext, "org.psi-im.psimedia.FeaturesContext/1.0")
 
302
Q_DECLARE_INTERFACE(PsiMedia::RtpChannelContext, "org.psi-im.psimedia.RtpChannelContext/1.0")
 
303
Q_DECLARE_INTERFACE(PsiMedia::RtpSessionContext, "org.psi-im.psimedia.RtpSessionContext/1.0")
 
304
 
 
305
#endif