1 /***************************************************************************
2 copyright : (C) 2002 - 2008 by Scott Wheeler
3 email : wheeler@kde.org
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 <tbytevector.h>
27
28 #include "aiffproperties.h"
29 #include "apeproperties.h"
30 #include "asfproperties.h"
31 #include "flacproperties.h"
32 #include "mp4properties.h"
33 #include "mpcproperties.h"
34 #include "mpegproperties.h"
35 #include "opusproperties.h"
36 #include "speexproperties.h"
37 #include "trueaudioproperties.h"
38 #include "vorbisproperties.h"
39 #include "wavproperties.h"
40 #include "wavpackproperties.h"
41
42 #include "audioproperties.h"
43
44 using namespace TagLib;
45
46 // This macro is a workaround for the fact that we can't add virtual functions.
47 // Should be true virtual functions in taglib2.
48
49 #define VIRTUAL_FUNCTION_WORKAROUND(function_name, default_value) \
50 if(dynamic_cast<const APE::Properties*>(this)) \
51 return dynamic_cast<const APE::Properties*>(this)->function_name(); \
52 else if(dynamic_cast<const ASF::Properties*>(this)) \
53 return dynamic_cast<const ASF::Properties*>(this)->function_name(); \
54 else if(dynamic_cast<const FLAC::Properties*>(this)) \
55 return dynamic_cast<const FLAC::Properties*>(this)->function_name(); \
56 else if(dynamic_cast<const MP4::Properties*>(this)) \
57 return dynamic_cast<const MP4::Properties*>(this)->function_name(); \
58 else if(dynamic_cast<const MPC::Properties*>(this)) \
59 return dynamic_cast<const MPC::Properties*>(this)->function_name(); \
60 else if(dynamic_cast<const MPEG::Properties*>(this)) \
61 return dynamic_cast<const MPEG::Properties*>(this)->function_name(); \
62 else if(dynamic_cast<const Ogg::Opus::Properties*>(this)) \
63 return dynamic_cast<const Ogg::Opus::Properties*>(this)->function_name(); \
64 else if(dynamic_cast<const Ogg::Speex::Properties*>(this)) \
65 return dynamic_cast<const Ogg::Speex::Properties*>(this)->function_name(); \
66 else if(dynamic_cast<const TrueAudio::Properties*>(this)) \
67 return dynamic_cast<const TrueAudio::Properties*>(this)->function_name(); \
68 else if(dynamic_cast<const RIFF::AIFF::Properties*>(this)) \
69 return dynamic_cast<const RIFF::AIFF::Properties*>(this)->function_name(); \
70 else if(dynamic_cast<const RIFF::WAV::Properties*>(this)) \
71 return dynamic_cast<const RIFF::WAV::Properties*>(this)->function_name(); \
72 else if(dynamic_cast<const Vorbis::Properties*>(this)) \
73 return dynamic_cast<const Vorbis::Properties*>(this)->function_name(); \
74 else if(dynamic_cast<const WavPack::Properties*>(this)) \
75 return dynamic_cast<const WavPack::Properties*>(this)->function_name(); \
76 else \
77 return (default_value);
78
79 class AudioProperties::AudioPropertiesPrivate
80 {
81
82 };
83
84 ////////////////////////////////////////////////////////////////////////////////
85 // public methods
86 ////////////////////////////////////////////////////////////////////////////////
87
~AudioProperties()88 AudioProperties::~AudioProperties()
89 {
90
91 }
92
lengthInSeconds() const93 int AudioProperties::lengthInSeconds() const
94 {
95 VIRTUAL_FUNCTION_WORKAROUND(lengthInSeconds, 0)
96 }
97
lengthInMilliseconds() const98 int AudioProperties::lengthInMilliseconds() const
99 {
100 VIRTUAL_FUNCTION_WORKAROUND(lengthInMilliseconds, 0)
101 }
102
103 ////////////////////////////////////////////////////////////////////////////////
104 // protected methods
105 ////////////////////////////////////////////////////////////////////////////////
106
AudioProperties(ReadStyle)107 AudioProperties::AudioProperties(ReadStyle) :
108 d(0)
109 {
110
111 }
112