1 /***************************************************************************
2 copyright : (C) 2002 - 2008 by Scott Wheeler
3 email : wheeler@kde.org
4 ***************************************************************************/
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. *
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. *
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
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 ***************************************************************************/
31 #include "vorbisfile.h"
33 using namespace TagLib;
35 class Vorbis::File::FilePrivate
48 Ogg::XiphComment *comment;
49 Properties *properties;
54 * Vorbis headers can be found with one type ID byte and the string "vorbis" in
55 * an Ogg stream. 0x03 indicates the comment header.
57 static const char vorbisCommentHeaderID[] = { 0x03, 'v', 'o', 'r', 'b', 'i', 's', 0 };
60 ////////////////////////////////////////////////////////////////////////////////
62 ////////////////////////////////////////////////////////////////////////////////
64 Vorbis::File::File(FileName file, bool readProperties,
65 Properties::ReadStyle propertiesStyle) : Ogg::File(file)
68 read(readProperties, propertiesStyle);
76 Ogg::XiphComment *Vorbis::File::tag() const
81 Vorbis::Properties *Vorbis::File::audioProperties() const
86 bool Vorbis::File::save()
88 ByteVector v(vorbisCommentHeaderID);
91 d->comment = new Ogg::XiphComment;
92 v.append(d->comment->render());
96 return Ogg::File::save();
99 ////////////////////////////////////////////////////////////////////////////////
101 ////////////////////////////////////////////////////////////////////////////////
103 void Vorbis::File::read(bool readProperties, Properties::ReadStyle propertiesStyle)
105 ByteVector commentHeaderData = packet(1);
107 if(commentHeaderData.mid(0, 7) != vorbisCommentHeaderID) {
108 debug("Vorbis::File::read() - Could not find the Vorbis comment header.");
113 d->comment = new Ogg::XiphComment(commentHeaderData.mid(7));
116 d->properties = new Properties(this, propertiesStyle);