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 #include "dsfproperties.h"
42 #include "dsdiffproperties.h"
43 
44 #include "audioproperties.h"
45 
46 using namespace TagLib;
47 
48 // This macro is a workaround for the fact that we can't add virtual functions.
49 // Should be true virtual functions in taglib2.
50 
51 #define VIRTUAL_FUNCTION_WORKAROUND(function_name, default_value)               \
52   if(dynamic_cast<const APE::Properties*>(this))                                \
53     return dynamic_cast<const APE::Properties*>(this)->function_name();         \
54   else if(dynamic_cast<const ASF::Properties*>(this))                           \
55     return dynamic_cast<const ASF::Properties*>(this)->function_name();         \
56   else if(dynamic_cast<const FLAC::Properties*>(this))                          \
57     return dynamic_cast<const FLAC::Properties*>(this)->function_name();        \
58   else if(dynamic_cast<const MP4::Properties*>(this))                           \
59     return dynamic_cast<const MP4::Properties*>(this)->function_name();         \
60   else if(dynamic_cast<const MPC::Properties*>(this))                           \
61     return dynamic_cast<const MPC::Properties*>(this)->function_name();         \
62   else if(dynamic_cast<const MPEG::Properties*>(this))                          \
63     return dynamic_cast<const MPEG::Properties*>(this)->function_name();        \
64   else if(dynamic_cast<const Ogg::Opus::Properties*>(this))                     \
65     return dynamic_cast<const Ogg::Opus::Properties*>(this)->function_name();   \
66   else if(dynamic_cast<const Ogg::Speex::Properties*>(this))                    \
67     return dynamic_cast<const Ogg::Speex::Properties*>(this)->function_name();  \
68   else if(dynamic_cast<const TrueAudio::Properties*>(this))                     \
69     return dynamic_cast<const TrueAudio::Properties*>(this)->function_name();   \
70   else if(dynamic_cast<const RIFF::AIFF::Properties*>(this))                    \
71     return dynamic_cast<const RIFF::AIFF::Properties*>(this)->function_name();  \
72   else if(dynamic_cast<const RIFF::WAV::Properties*>(this))                     \
73     return dynamic_cast<const RIFF::WAV::Properties*>(this)->function_name();   \
74   else if(dynamic_cast<const Vorbis::Properties*>(this))                        \
75     return dynamic_cast<const Vorbis::Properties*>(this)->function_name();      \
76   else if(dynamic_cast<const WavPack::Properties*>(this))                       \
77     return dynamic_cast<const WavPack::Properties*>(this)->function_name();     \
78   else if(dynamic_cast<const DSF::Properties*>(this))                           \
79     return dynamic_cast<const DSF::Properties*>(this)->function_name();         \
80   else if(dynamic_cast<const DSDIFF::Properties*>(this))                        \
81     return dynamic_cast<const DSDIFF::Properties*>(this)->function_name();      \
82   else                                                                          \
83     return (default_value);
84 
85 class AudioProperties::AudioPropertiesPrivate
86 {
87 
88 };
89 
90 ////////////////////////////////////////////////////////////////////////////////
91 // public methods
92 ////////////////////////////////////////////////////////////////////////////////
93 
~AudioProperties()94 AudioProperties::~AudioProperties()
95 {
96 
97 }
98 
lengthInSeconds() const99 int AudioProperties::lengthInSeconds() const
100 {
101   VIRTUAL_FUNCTION_WORKAROUND(lengthInSeconds, 0)
102 }
103 
lengthInMilliseconds() const104 int AudioProperties::lengthInMilliseconds() const
105 {
106   VIRTUAL_FUNCTION_WORKAROUND(lengthInMilliseconds, 0)
107 }
108 
109 ////////////////////////////////////////////////////////////////////////////////
110 // protected methods
111 ////////////////////////////////////////////////////////////////////////////////
112 
AudioProperties(ReadStyle)113 AudioProperties::AudioProperties(ReadStyle) :
114   d(0)
115 {
116 
117 }
118