1 /**************************************************************************
2 copyright : (C) 2005-2007 by Lukáš Lalinský
3 email : lalinsky@gmail.com
4 **************************************************************************/
5
6 /***************************************************************************
7 * This library is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU Lesser General Public License version *
9 * 2.1 as published by the Free Software Foundation. *
10 * *
11 * This library is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the Free Software *
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 * 02110-1301 USA *
20 * *
21 * Alternatively, this file is available under the Mozilla Public *
22 * License Version 1.1. You may obtain a copy of the License at *
23 * http://www.mozilla.org/MPL/ *
24 ***************************************************************************/
25
26 #include <tdebug.h>
27 #include <tstring.h>
28 #include "asfproperties.h"
29
30 using namespace TagLib;
31
32 class ASF::Properties::PropertiesPrivate
33 {
34 public:
PropertiesPrivate()35 PropertiesPrivate() :
36 length(0),
37 bitrate(0),
38 sampleRate(0),
39 channels(0),
40 bitsPerSample(0),
41 codec(ASF::Properties::Unknown),
42 encrypted(false) {}
43
44 int length;
45 int bitrate;
46 int sampleRate;
47 int channels;
48 int bitsPerSample;
49 ASF::Properties::Codec codec;
50 String codecName;
51 String codecDescription;
52 bool encrypted;
53 };
54
55 ////////////////////////////////////////////////////////////////////////////////
56 // public members
57 ////////////////////////////////////////////////////////////////////////////////
58
Properties()59 ASF::Properties::Properties() :
60 AudioProperties(AudioProperties::Average),
61 d(new PropertiesPrivate())
62 {
63 }
64
~Properties()65 ASF::Properties::~Properties()
66 {
67 delete d;
68 }
69
length() const70 int ASF::Properties::length() const
71 {
72 return lengthInSeconds();
73 }
74
lengthInSeconds() const75 int ASF::Properties::lengthInSeconds() const
76 {
77 return d->length / 1000;
78 }
79
lengthInMilliseconds() const80 int ASF::Properties::lengthInMilliseconds() const
81 {
82 return d->length;
83 }
84
bitrate() const85 int ASF::Properties::bitrate() const
86 {
87 return d->bitrate;
88 }
89
sampleRate() const90 int ASF::Properties::sampleRate() const
91 {
92 return d->sampleRate;
93 }
94
channels() const95 int ASF::Properties::channels() const
96 {
97 return d->channels;
98 }
99
bitsPerSample() const100 int ASF::Properties::bitsPerSample() const
101 {
102 return d->bitsPerSample;
103 }
104
codec() const105 ASF::Properties::Codec ASF::Properties::codec() const
106 {
107 return d->codec;
108 }
109
codecName() const110 String ASF::Properties::codecName() const
111 {
112 return d->codecName;
113 }
114
codecDescription() const115 String ASF::Properties::codecDescription() const
116 {
117 return d->codecDescription;
118 }
119
isEncrypted() const120 bool ASF::Properties::isEncrypted() const
121 {
122 return d->encrypted;
123 }
124
125 ////////////////////////////////////////////////////////////////////////////////
126 // private members
127 ////////////////////////////////////////////////////////////////////////////////
128
setLength(int)129 void ASF::Properties::setLength(int /*length*/)
130 {
131 debug("ASF::Properties::setLength() -- This method is deprecated. Do not use.");
132 }
133
setLengthInMilliseconds(int value)134 void ASF::Properties::setLengthInMilliseconds(int value)
135 {
136 d->length = value;
137 }
138
setBitrate(int value)139 void ASF::Properties::setBitrate(int value)
140 {
141 d->bitrate = value;
142 }
143
setSampleRate(int value)144 void ASF::Properties::setSampleRate(int value)
145 {
146 d->sampleRate = value;
147 }
148
setChannels(int value)149 void ASF::Properties::setChannels(int value)
150 {
151 d->channels = value;
152 }
153
setBitsPerSample(int value)154 void ASF::Properties::setBitsPerSample(int value)
155 {
156 d->bitsPerSample = value;
157 }
158
setCodec(int value)159 void ASF::Properties::setCodec(int value)
160 {
161 switch(value)
162 {
163 case 0x0160:
164 d->codec = WMA1;
165 break;
166 case 0x0161:
167 d->codec = WMA2;
168 break;
169 case 0x0162:
170 d->codec = WMA9Pro;
171 break;
172 case 0x0163:
173 d->codec = WMA9Lossless;
174 break;
175 default:
176 d->codec = Unknown;
177 break;
178 }
179 }
180
setCodecName(const String & value)181 void ASF::Properties::setCodecName(const String &value)
182 {
183 d->codecName = value;
184 }
185
setCodecDescription(const String & value)186 void ASF::Properties::setCodecDescription(const String &value)
187 {
188 d->codecDescription = value;
189 }
190
setEncrypted(bool value)191 void ASF::Properties::setEncrypted(bool value)
192 {
193 d->encrypted = value;
194 }
195