1 /***************************************************************************
2 copyright : (C) 2003 by Ismael Orenstein
3 email : orenstein@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 ***************************************************************************/
26 #include <tbytevector.h>
30 #include "xingheader.h"
32 using namespace TagLib;
34 class MPEG::XingHeader::XingHeaderPrivate
48 MPEG::XingHeader::XingHeader(const ByteVector &data)
50 d = new XingHeaderPrivate;
54 MPEG::XingHeader::~XingHeader()
59 bool MPEG::XingHeader::isValid() const
64 TagLib::uint MPEG::XingHeader::totalFrames() const
69 TagLib::uint MPEG::XingHeader::totalSize() const
74 int MPEG::XingHeader::xingHeaderOffset(TagLib::MPEG::Header::Version v,
75 TagLib::MPEG::Header::ChannelMode c)
77 if(v == MPEG::Header::Version1) {
78 if(c == MPEG::Header::SingleChannel)
84 if(c == MPEG::Header::SingleChannel)
91 void MPEG::XingHeader::parse(const ByteVector &data)
93 // Check to see if a valid Xing header is available.
95 if(!data.startsWith("Xing") && !data.startsWith("Info"))
98 // If the XingHeader doesn't contain the number of frames and the total stream
101 if(!(data[7] & 0x01)) {
102 debug("MPEG::XingHeader::parse() -- Xing header doesn't contain the total number of frames.");
106 if(!(data[7] & 0x02)) {
107 debug("MPEG::XingHeader::parse() -- Xing header doesn't contain the total stream size.");
111 d->frames = data.mid(8, 4).toUInt();
112 d->size = data.mid(12, 4).toUInt();