author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 02 Feb 2010 00:43:10 +0200 | |
changeset 3 | 41300fa6a67c |
parent 0 | 1918ee327afb |
child 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 |
** All rights reserved. |
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtMultimedia module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
41 |
#include <QDebug> |
0 | 42 |
#include <QtMultimedia/qaudioformat.h> |
43 |
||
44 |
||
45 |
QT_BEGIN_NAMESPACE |
|
46 |
||
47 |
||
48 |
class QAudioFormatPrivate : public QSharedData |
|
49 |
{ |
|
50 |
public: |
|
51 |
QAudioFormatPrivate() |
|
52 |
{ |
|
53 |
frequency = -1; |
|
54 |
channels = -1; |
|
55 |
sampleSize = -1; |
|
56 |
byteOrder = QAudioFormat::Endian(QSysInfo::ByteOrder); |
|
57 |
sampleType = QAudioFormat::Unknown; |
|
58 |
} |
|
59 |
||
60 |
QAudioFormatPrivate(const QAudioFormatPrivate &other): |
|
61 |
QSharedData(other), |
|
62 |
codec(other.codec), |
|
63 |
byteOrder(other.byteOrder), |
|
64 |
sampleType(other.sampleType), |
|
65 |
frequency(other.frequency), |
|
66 |
channels(other.channels), |
|
67 |
sampleSize(other.sampleSize) |
|
68 |
{ |
|
69 |
} |
|
70 |
||
71 |
QAudioFormatPrivate& operator=(const QAudioFormatPrivate &other) |
|
72 |
{ |
|
73 |
codec = other.codec; |
|
74 |
byteOrder = other.byteOrder; |
|
75 |
sampleType = other.sampleType; |
|
76 |
frequency = other.frequency; |
|
77 |
channels = other.channels; |
|
78 |
sampleSize = other.sampleSize; |
|
79 |
||
80 |
return *this; |
|
81 |
} |
|
82 |
||
83 |
QString codec; |
|
84 |
QAudioFormat::Endian byteOrder; |
|
85 |
QAudioFormat::SampleType sampleType; |
|
86 |
int frequency; |
|
87 |
int channels; |
|
88 |
int sampleSize; |
|
89 |
}; |
|
90 |
||
91 |
/*! |
|
92 |
\class QAudioFormat |
|
93 |
\brief The QAudioFormat class stores audio parameter information. |
|
94 |
||
95 |
\inmodule QtMultimedia |
|
96 |
\ingroup multimedia |
|
97 |
\since 4.6 |
|
98 |
||
99 |
An audio format specifies how data in an audio stream is arranged, |
|
100 |
i.e, how the stream is to be interpreted. The encoding itself is |
|
101 |
specified by the codec() used for the stream. |
|
102 |
||
103 |
In addition to the encoding, QAudioFormat contains other |
|
104 |
parameters that further specify how the audio data is arranged. |
|
105 |
These are the frequency, the number of channels, the sample size, |
|
106 |
the sample type, and the byte order. The following table describes |
|
107 |
these in more detail. |
|
108 |
||
109 |
\table |
|
110 |
\header |
|
111 |
\o Parameter |
|
112 |
\o Description |
|
113 |
\row |
|
114 |
\o Frequency |
|
115 |
\o Samples per second of audio data in Hertz. |
|
116 |
\row |
|
117 |
\o Number of channels |
|
118 |
\o The number of audio channels (typically one for mono |
|
119 |
or two for stereo) |
|
120 |
\row |
|
121 |
\o Sample size |
|
122 |
\o How much data is stored in each sample (typically 8 |
|
123 |
or 16) |
|
124 |
\row |
|
125 |
\o Sample type |
|
126 |
\o Numerical representation of sample (typically signed integer, |
|
127 |
unsigned integer or float) |
|
128 |
\row |
|
129 |
\o Byte order |
|
130 |
\o Byte ordering of sample (typically little endian, big endian) |
|
131 |
\endtable |
|
132 |
||
133 |
You can obtain audio formats compatible with the audio device used |
|
134 |
through functions in QAudioDeviceInfo. This class also lets you |
|
135 |
query available parameter values for a device, so that you can set |
|
136 |
the parameters yourself. See the QAudioDeviceInfo class |
|
137 |
description for details. You need to know the format of the audio |
|
138 |
streams you wish to play. Qt does not set up formats for you. |
|
139 |
*/ |
|
140 |
||
141 |
/*! |
|
142 |
Construct a new audio format. |
|
143 |
||
144 |
Values are initialized as follows: |
|
145 |
\list |
|
146 |
\o frequency() = -1 |
|
147 |
\o channels() = -1 |
|
148 |
\o sampleSize() = -1 |
|
149 |
\o byteOrder() = QAudioFormat::Endian(QSysInfo::ByteOrder) |
|
150 |
\o sampleType() = QAudioFormat::Unknown |
|
151 |
\c codec() = "" |
|
152 |
\endlist |
|
153 |
*/ |
|
154 |
||
155 |
QAudioFormat::QAudioFormat(): |
|
156 |
d(new QAudioFormatPrivate) |
|
157 |
{ |
|
158 |
} |
|
159 |
||
160 |
/*! |
|
161 |
Construct a new audio format using \a other. |
|
162 |
*/ |
|
163 |
||
164 |
QAudioFormat::QAudioFormat(const QAudioFormat &other): |
|
165 |
d(other.d) |
|
166 |
{ |
|
167 |
} |
|
168 |
||
169 |
/*! |
|
170 |
Destroy this audio format. |
|
171 |
*/ |
|
172 |
||
173 |
QAudioFormat::~QAudioFormat() |
|
174 |
{ |
|
175 |
} |
|
176 |
||
177 |
/*! |
|
178 |
Assigns \a other to this QAudioFormat implementation. |
|
179 |
*/ |
|
180 |
||
181 |
QAudioFormat& QAudioFormat::operator=(const QAudioFormat &other) |
|
182 |
{ |
|
183 |
d = other.d; |
|
184 |
return *this; |
|
185 |
} |
|
186 |
||
187 |
/*! |
|
188 |
Returns true if this QAudioFormat is equal to the \a other |
|
189 |
QAudioFormat; otherwise returns false. |
|
190 |
||
191 |
All elements of QAudioFormat are used for the comparison. |
|
192 |
*/ |
|
193 |
||
194 |
bool QAudioFormat::operator==(const QAudioFormat &other) const |
|
195 |
{ |
|
196 |
return d->frequency == other.d->frequency && |
|
197 |
d->channels == other.d->channels && |
|
198 |
d->sampleSize == other.d->sampleSize && |
|
199 |
d->byteOrder == other.d->byteOrder && |
|
200 |
d->codec == other.d->codec && |
|
201 |
d->sampleType == other.d->sampleType; |
|
202 |
} |
|
203 |
||
204 |
/*! |
|
205 |
Returns true if this QAudioFormat is not equal to the \a other |
|
206 |
QAudioFormat; otherwise returns false. |
|
207 |
||
208 |
All elements of QAudioFormat are used for the comparison. |
|
209 |
*/ |
|
210 |
||
211 |
bool QAudioFormat::operator!=(const QAudioFormat& other) const |
|
212 |
{ |
|
213 |
return !(*this == other); |
|
214 |
} |
|
215 |
||
216 |
/*! |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
Returns true if all of the parameters are valid. |
0 | 218 |
*/ |
219 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
220 |
bool QAudioFormat::isValid() const |
0 | 221 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
222 |
return d->frequency != -1 && d->channels != -1 && d->sampleSize != -1 && |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
d->sampleType != QAudioFormat::Unknown && !d->codec.isEmpty(); |
0 | 224 |
} |
225 |
||
226 |
/*! |
|
227 |
Sets the frequency to \a frequency. |
|
228 |
*/ |
|
229 |
||
230 |
void QAudioFormat::setFrequency(int frequency) |
|
231 |
{ |
|
232 |
d->frequency = frequency; |
|
233 |
} |
|
234 |
||
235 |
/*! |
|
236 |
Returns the current frequency value. |
|
237 |
*/ |
|
238 |
||
239 |
int QAudioFormat::frequency() const |
|
240 |
{ |
|
241 |
return d->frequency; |
|
242 |
} |
|
243 |
||
244 |
/*! |
|
245 |
Sets the channels to \a channels. |
|
246 |
*/ |
|
247 |
||
248 |
void QAudioFormat::setChannels(int channels) |
|
249 |
{ |
|
250 |
d->channels = channels; |
|
251 |
} |
|
252 |
||
253 |
/*! |
|
254 |
Returns the current channel value. |
|
255 |
*/ |
|
256 |
||
257 |
int QAudioFormat::channels() const |
|
258 |
{ |
|
259 |
return d->channels; |
|
260 |
} |
|
261 |
||
262 |
/*! |
|
263 |
Sets the sampleSize to \a sampleSize. |
|
264 |
*/ |
|
265 |
||
266 |
void QAudioFormat::setSampleSize(int sampleSize) |
|
267 |
{ |
|
268 |
d->sampleSize = sampleSize; |
|
269 |
} |
|
270 |
||
271 |
/*! |
|
272 |
Returns the current sampleSize value. |
|
273 |
*/ |
|
274 |
||
275 |
int QAudioFormat::sampleSize() const |
|
276 |
{ |
|
277 |
return d->sampleSize; |
|
278 |
} |
|
279 |
||
280 |
/*! |
|
281 |
Sets the codec to \a codec. |
|
282 |
||
283 |
\sa QAudioDeviceInfo::supportedCodecs() |
|
284 |
*/ |
|
285 |
||
286 |
void QAudioFormat::setCodec(const QString &codec) |
|
287 |
{ |
|
288 |
d->codec = codec; |
|
289 |
} |
|
290 |
||
291 |
/*! |
|
292 |
Returns the current codec value. |
|
293 |
||
294 |
\sa QAudioDeviceInfo::supportedCodecs() |
|
295 |
*/ |
|
296 |
||
297 |
QString QAudioFormat::codec() const |
|
298 |
{ |
|
299 |
return d->codec; |
|
300 |
} |
|
301 |
||
302 |
/*! |
|
303 |
Sets the byteOrder to \a byteOrder. |
|
304 |
*/ |
|
305 |
||
306 |
void QAudioFormat::setByteOrder(QAudioFormat::Endian byteOrder) |
|
307 |
{ |
|
308 |
d->byteOrder = byteOrder; |
|
309 |
} |
|
310 |
||
311 |
/*! |
|
312 |
Returns the current byteOrder value. |
|
313 |
*/ |
|
314 |
||
315 |
QAudioFormat::Endian QAudioFormat::byteOrder() const |
|
316 |
{ |
|
317 |
return d->byteOrder; |
|
318 |
} |
|
319 |
||
320 |
/*! |
|
321 |
Sets the sampleType to \a sampleType. |
|
322 |
*/ |
|
323 |
||
324 |
void QAudioFormat::setSampleType(QAudioFormat::SampleType sampleType) |
|
325 |
{ |
|
326 |
d->sampleType = sampleType; |
|
327 |
} |
|
328 |
||
329 |
/*! |
|
330 |
Returns the current SampleType value. |
|
331 |
*/ |
|
332 |
||
333 |
QAudioFormat::SampleType QAudioFormat::sampleType() const |
|
334 |
{ |
|
335 |
return d->sampleType; |
|
336 |
} |
|
337 |
||
338 |
/*! |
|
339 |
\enum QAudioFormat::SampleType |
|
340 |
||
341 |
\value Unknown Not Set |
|
342 |
\value SignedInt samples are signed integers |
|
343 |
\value UnSignedInt samples are unsigned intergers |
|
344 |
\value Float samples are floats |
|
345 |
*/ |
|
346 |
||
347 |
/*! |
|
348 |
\enum QAudioFormat::Endian |
|
349 |
||
350 |
\value BigEndian samples are big endian byte order |
|
351 |
\value LittleEndian samples are little endian byte order |
|
352 |
*/ |
|
353 |
||
354 |
QT_END_NAMESPACE |
|
355 |