summaryrefslogtreecommitdiff
path: root/libs/taglib/taglib/mpeg/xingheader.h
blob: 1ffc03ddb09755915b31c93ce21955e96a829943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/***************************************************************************
    copyright            : (C) 2003 by Ismael Orenstein
    email                : orenstein@kde.org
 ***************************************************************************/

/***************************************************************************
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Lesser General Public License version   *
 *   2.1 as published by the Free Software Foundation.                     *
 *                                                                         *
 *   This library is distributed in the hope that it will be useful, but   *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 *   Lesser General Public License for more details.                       *
 *                                                                         *
 *   You should have received a copy of the GNU Lesser General Public      *
 *   License along with this library; if not, write to the Free Software   *
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
 *   USA                                                                   *
 *                                                                         *
 *   Alternatively, this file is available under the Mozilla Public        *
 *   License Version 1.1.  You may obtain a copy of the License at         *
 *   http://www.mozilla.org/MPL/                                           *
 ***************************************************************************/

#ifndef TAGLIB_XINGHEADER_H
#define TAGLIB_XINGHEADER_H

#include "mpegheader.h"
#include "taglib_export.h"

namespace TagLib {

  class ByteVector;

  namespace MPEG {

    //! An implementation of the Xing VBR headers

    /*!
     * This is a minimalistic implementation of the Xing VBR headers.  Xing
     * headers are often added to VBR (variable bit rate) MP3 streams to make it
     * easy to compute the length and quality of a VBR stream.  Our implementation
     * is only concerned with the total size of the stream (so that we can
     * calculate the total playing time and the average bitrate).  It uses
     * <a href="http://home.pcisys.net/~melanson/codecs/mp3extensions.txt">this text</a>
     * and the XMMS sources as references.
     */

    class TAGLIB_EXPORT XingHeader
    {
    public:
      /*!
       * Parses a Xing header based on \a data.  The data must be at least 16
       * bytes long (anything longer than this is discarded).
       */
      XingHeader(const ByteVector &data);

      /*!
       * Destroy this XingHeader instance.
       */
      virtual ~XingHeader();

      /*!
       * Returns true if the data was parsed properly and if there is a valid
       * Xing header present.
       */
      bool isValid() const;

      /*!
       * Returns the total number of frames.
       */
      uint totalFrames() const;

      /*!
       * Returns the total size of stream in bytes.
       */
      uint totalSize() const;

      /*!
       * Returns the offset for the start of this Xing header, given the
       * version and channels of the frame
       */
      // BIC: rename to offset()
      static int xingHeaderOffset(TagLib::MPEG::Header::Version v,
                                  TagLib::MPEG::Header::ChannelMode c);

    private:
      XingHeader(const XingHeader &);
      XingHeader &operator=(const XingHeader &);

      void parse(const ByteVector &data);

      class XingHeaderPrivate;
      XingHeaderPrivate *d;
    };
  }
}

#endif