xref: /MusicPlayer2/MusicPlayer2/taglib/oggfile.h (revision 2661106a96494c0a7dfab38bf1ae7b9565882443)
1*2661106aSZhong Yang /***************************************************************************
2*2661106aSZhong Yang     copyright            : (C) 2002 - 2008 by Scott Wheeler
3*2661106aSZhong Yang     email                : [email protected]
4*2661106aSZhong Yang  ***************************************************************************/
5*2661106aSZhong Yang 
6*2661106aSZhong Yang /***************************************************************************
7*2661106aSZhong Yang  *   This library is free software; you can redistribute it and/or modify  *
8*2661106aSZhong Yang  *   it under the terms of the GNU Lesser General Public License version   *
9*2661106aSZhong Yang  *   2.1 as published by the Free Software Foundation.                     *
10*2661106aSZhong Yang  *                                                                         *
11*2661106aSZhong Yang  *   This library is distributed in the hope that it will be useful, but   *
12*2661106aSZhong Yang  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
13*2661106aSZhong Yang  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
14*2661106aSZhong Yang  *   Lesser General Public License for more details.                       *
15*2661106aSZhong Yang  *                                                                         *
16*2661106aSZhong Yang  *   You should have received a copy of the GNU Lesser General Public      *
17*2661106aSZhong Yang  *   License along with this library; if not, write to the Free Software   *
18*2661106aSZhong Yang  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA         *
19*2661106aSZhong Yang  *   02110-1301  USA                                                       *
20*2661106aSZhong Yang  *                                                                         *
21*2661106aSZhong Yang  *   Alternatively, this file is available under the Mozilla Public        *
22*2661106aSZhong Yang  *   License Version 1.1.  You may obtain a copy of the License at         *
23*2661106aSZhong Yang  *   http://www.mozilla.org/MPL/                                           *
24*2661106aSZhong Yang  ***************************************************************************/
25*2661106aSZhong Yang 
26*2661106aSZhong Yang #include "taglib_export.h"
27*2661106aSZhong Yang #include "tfile.h"
28*2661106aSZhong Yang #include "tbytevectorlist.h"
29*2661106aSZhong Yang 
30*2661106aSZhong Yang #ifndef TAGLIB_OGGFILE_H
31*2661106aSZhong Yang #define TAGLIB_OGGFILE_H
32*2661106aSZhong Yang 
33*2661106aSZhong Yang namespace TagLib {
34*2661106aSZhong Yang 
35*2661106aSZhong Yang   //! A namespace for the classes used by Ogg-based metadata files
36*2661106aSZhong Yang 
37*2661106aSZhong Yang   namespace Ogg {
38*2661106aSZhong Yang 
39*2661106aSZhong Yang     class PageHeader;
40*2661106aSZhong Yang 
41*2661106aSZhong Yang     //! An implementation of TagLib::File with some helpers for Ogg based formats
42*2661106aSZhong Yang 
43*2661106aSZhong Yang     /*!
44*2661106aSZhong Yang      * This is an implementation of Ogg file page and packet rendering and is of
45*2661106aSZhong Yang      * use to Ogg based formats.  While the API is small this handles the
46*2661106aSZhong Yang      * non-trivial details of breaking up an Ogg stream into packets and makes
47*2661106aSZhong Yang      * these available (via subclassing) to the codec meta data implementations.
48*2661106aSZhong Yang      */
49*2661106aSZhong Yang 
50*2661106aSZhong Yang     class TAGLIB_EXPORT File : public TagLib::File
51*2661106aSZhong Yang     {
52*2661106aSZhong Yang     public:
53*2661106aSZhong Yang       virtual ~File();
54*2661106aSZhong Yang 
55*2661106aSZhong Yang       /*!
56*2661106aSZhong Yang        * Returns the packet contents for the i-th packet (starting from zero)
57*2661106aSZhong Yang        * in the Ogg bitstream.
58*2661106aSZhong Yang        *
59*2661106aSZhong Yang        * \warning This requires reading at least the packet header for every page
60*2661106aSZhong Yang        * up to the requested page.
61*2661106aSZhong Yang        */
62*2661106aSZhong Yang       ByteVector packet(unsigned int i);
63*2661106aSZhong Yang 
64*2661106aSZhong Yang       /*!
65*2661106aSZhong Yang        * Sets the packet with index \a i to the value \a p.
66*2661106aSZhong Yang        */
67*2661106aSZhong Yang       void setPacket(unsigned int i, const ByteVector &p);
68*2661106aSZhong Yang 
69*2661106aSZhong Yang       /*!
70*2661106aSZhong Yang        * Returns a pointer to the PageHeader for the first page in the stream or
71*2661106aSZhong Yang        * null if the page could not be found.
72*2661106aSZhong Yang        */
73*2661106aSZhong Yang       const PageHeader *firstPageHeader();
74*2661106aSZhong Yang 
75*2661106aSZhong Yang       /*!
76*2661106aSZhong Yang        * Returns a pointer to the PageHeader for the last page in the stream or
77*2661106aSZhong Yang        * null if the page could not be found.
78*2661106aSZhong Yang        */
79*2661106aSZhong Yang       const PageHeader *lastPageHeader();
80*2661106aSZhong Yang 
81*2661106aSZhong Yang       virtual bool save();
82*2661106aSZhong Yang 
83*2661106aSZhong Yang     protected:
84*2661106aSZhong Yang       /*!
85*2661106aSZhong Yang        * Constructs an Ogg file from \a file.
86*2661106aSZhong Yang        *
87*2661106aSZhong Yang        * \note This constructor is protected since Ogg::File shouldn't be
88*2661106aSZhong Yang        * instantiated directly but rather should be used through the codec
89*2661106aSZhong Yang        * specific subclasses.
90*2661106aSZhong Yang        */
91*2661106aSZhong Yang       File(FileName file);
92*2661106aSZhong Yang 
93*2661106aSZhong Yang       /*!
94*2661106aSZhong Yang        * Constructs an Ogg file from \a stream.
95*2661106aSZhong Yang        *
96*2661106aSZhong Yang        * \note This constructor is protected since Ogg::File shouldn't be
97*2661106aSZhong Yang        * instantiated directly but rather should be used through the codec
98*2661106aSZhong Yang        * specific subclasses.
99*2661106aSZhong Yang        *
100*2661106aSZhong Yang        * \note TagLib will *not* take ownership of the stream, the caller is
101*2661106aSZhong Yang        * responsible for deleting it after the File object.
102*2661106aSZhong Yang        */
103*2661106aSZhong Yang       File(IOStream *stream);
104*2661106aSZhong Yang 
105*2661106aSZhong Yang     private:
106*2661106aSZhong Yang       File(const File &);
107*2661106aSZhong Yang       File &operator=(const File &);
108*2661106aSZhong Yang 
109*2661106aSZhong Yang       /*!
110*2661106aSZhong Yang        * Reads the pages from the beginning of the file until enough to compose
111*2661106aSZhong Yang        * the requested packet.
112*2661106aSZhong Yang        */
113*2661106aSZhong Yang       bool readPages(unsigned int i);
114*2661106aSZhong Yang 
115*2661106aSZhong Yang       /*!
116*2661106aSZhong Yang        * Writes the requested packet to the file.
117*2661106aSZhong Yang        */
118*2661106aSZhong Yang       void writePacket(unsigned int i, const ByteVector &packet);
119*2661106aSZhong Yang 
120*2661106aSZhong Yang       class FilePrivate;
121*2661106aSZhong Yang       FilePrivate *d;
122*2661106aSZhong Yang     };
123*2661106aSZhong Yang 
124*2661106aSZhong Yang   }
125*2661106aSZhong Yang }
126*2661106aSZhong Yang 
127*2661106aSZhong Yang #endif
128