1 /***************************************************************************
2     copyright            : (C) 2006 by Lukáš Lalinský
3     email                : lalinsky@gmail.com
4 
5     copyright            : (C) 2002 - 2008 by Scott Wheeler
6     email                : wheeler@kde.org
7                            (original Vorbis implementation)
8 ***************************************************************************/
9 
10 /***************************************************************************
11  *   This library is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU Lesser General Public License version   *
13  *   2.1 as published by the Free Software Foundation.                     *
14  *                                                                         *
15  *   This library is distributed in the hope that it will be useful, but   *
16  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
18  *   Lesser General Public License for more details.                       *
19  *                                                                         *
20  *   You should have received a copy of the GNU Lesser General Public      *
21  *   License along with this library; if not, write to the Free Software   *
22  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA         *
23  *   02110-1301  USA                                                       *
24  *                                                                         *
25  *   Alternatively, this file is available under the Mozilla Public        *
26  *   License Version 1.1.  You may obtain a copy of the License at         *
27  *   http://www.mozilla.org/MPL/                                           *
28  ***************************************************************************/
29 
30 #ifndef TAGLIB_SPEEXFILE_H
31 #define TAGLIB_SPEEXFILE_H
32 
33 #include "oggfile.h"
34 #include "xiphcomment.h"
35 
36 #include "speexproperties.h"
37 
38 namespace TagLib {
39 
40   namespace Ogg {
41 
42     //! A namespace containing classes for Speex metadata
43 
44     namespace Speex {
45 
46       //! An implementation of Ogg::File with Speex specific methods
47 
48       /*!
49        * This is the central class in the Ogg Speex metadata processing collection
50        * of classes.  It's built upon Ogg::File which handles processing of the Ogg
51        * logical bitstream and breaking it down into pages which are handled by
52        * the codec implementations, in this case Speex specifically.
53        */
54 
55       class TAGLIB_EXPORT File : public Ogg::File
56       {
57       public:
58         /*!
59          * Constructs a Speex file from \a file.  If \a readProperties is true the
60          * file's audio properties will also be read.
61          *
62          * \note In the current implementation, \a propertiesStyle is ignored.
63          */
64         File(FileName file, bool readProperties = true,
65              Properties::ReadStyle propertiesStyle = Properties::Average);
66 
67         /*!
68          * Constructs a Speex file from \a stream.  If \a readProperties is true the
69          * file's audio properties will also be read.
70          *
71          * \note TagLib will *not* take ownership of the stream, the caller is
72          * responsible for deleting it after the File object.
73          *
74          * \note In the current implementation, \a propertiesStyle is ignored.
75          */
76         File(IOStream *stream, bool readProperties = true,
77              Properties::ReadStyle propertiesStyle = Properties::Average);
78 
79         /*!
80          * Destroys this instance of the File.
81          */
82         virtual ~File();
83 
84         /*!
85          * Returns the XiphComment for this file.  XiphComment implements the tag
86          * interface, so this serves as the reimplementation of
87          * TagLib::File::tag().
88          */
89         virtual Ogg::XiphComment *tag() const;
90 
91         /*!
92          * Implements the unified property interface -- export function.
93          * This forwards directly to XiphComment::properties().
94          */
95         PropertyMap properties() const;
96 
97         /*!
98          * Implements the unified tag dictionary interface -- import function.
99          * Like properties(), this is a forwarder to the file's XiphComment.
100          */
101         PropertyMap setProperties(const PropertyMap &);
102 
103         /*!
104          * Returns the Speex::Properties for this file.  If no audio properties
105          * were read then this will return a null pointer.
106          */
107         virtual Properties *audioProperties() const;
108 
109         /*!
110          * Save the file.
111          *
112          * This returns true if the save was successful.
113          */
114         virtual bool save();
115 
116         /*!
117          * Returns whether or not the given \a stream can be opened as a Speex
118          * file.
119          *
120          * \note This method is designed to do a quick check.  The result may
121          * not necessarily be correct.
122          */
123         static bool isSupported(IOStream *stream);
124 
125       private:
126         File(const File &);
127         File &operator=(const File &);
128 
129         void read(bool readProperties);
130 
131         class FilePrivate;
132         FilePrivate *d;
133       };
134     }
135   }
136 }
137 
138 #endif
139