summaryrefslogtreecommitdiffstats
path: root/src/metadata/m4a/mp4file.h
blob: 9e40dbc994f2d6521cf3adc9987e56e85feb3a54 (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/***************************************************************************
    copyright            : (C) 2002, 2003, 2006 by Jochen Issing
    email                : jochen.issing@isign-softart.de
 ***************************************************************************/

/***************************************************************************
 *   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., 51 Franklin Street, Fifth Floor, Boston,            *
 *   MA  02110-1301  USA                                                   *
 ***************************************************************************/

/***************************************************************************
    copyright            : (C) 2002, 2003 by Jochen Issing
    email                : jochen.issing@isign-softart.de
 ***************************************************************************/

/***************************************************************************
 *   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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  *
 *   USA                                                                   *
 ***************************************************************************/

#ifndef TAGLIB_MP4FILE_H
#define TAGLIB_MP4FILE_H

#include <tfile.h>
#include <audioproperties.h>

#include "mp4fourcc.h"

namespace TagLib {

  typedef unsigned long long ulonglong;

  class Tag;

  namespace MP4
  {
    class Mp4TagsProxy;
    class Mp4PropsProxy;

    //! An implementation of TagLib::File with mp4 itunes specific methods

    /*!
     * This implements and provides an interface for mp4 itunes files to the
     * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
     * the abstract TagLib::File API as well as providing some additional
     * information specific to mp4 itunes files. (TODO)
     */

    class File : public TagLib::File
    {
    public:
      /*!
       * Contructs an mp4 itunes file from \a file.  If \a readProperties is true the
       * file's audio properties will also be read using \a propertiesStyle.  If
       * false, \a propertiesStyle is ignored.
       */
      File(const char *file, bool readProperties = true,
           AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);

      /*!
       * Destroys this instance of the File.
       */
      virtual ~File();

      /*!
       * Returns the Tag for this file.  This will be an APE tag, an ID3v1 tag
       * or a combination of the two.
       */
      virtual TagLib::Tag *tag() const;

      /*!
       * Returns the mp4 itunes::Properties for this file.  If no audio properties
       * were read then this will return a null pointer.
       */
      virtual AudioProperties *audioProperties() const;

      /*!
       * Saves the file.
       */
      virtual bool save();

      /*!
       * This will remove all tags.
       *
       * \note This will also invalidate pointers to the tags
       * as their memory will be freed.
       * \note In order to make the removal permanent save() still needs to be called
       */
      void remove();

      /*!
       * Helper function for parsing the MP4 file - reads the size and type of the next box.
       * Returns true if read succeeded - not at EOF
       */
      bool readSizeAndType( TagLib::uint& size, MP4::Fourcc& fourcc );

      /*!
       * Helper function to read the length of an descriptor in systems manner
       */
      TagLib::uint readSystemsLen();

      /*!
       * Helper function for reading an unsigned int out of the file (big endian method)
       */
      bool readInt( TagLib::uint& toRead );

      /*!
       * Helper function for reading an unsigned short out of the file (big endian method)
       */
      bool readShort( TagLib::uint& toRead );
      
      /*!
       * Helper function for reading an unsigned long long (64bit) out of the file (big endian method)
       */
      bool readLongLong( TagLib::ulonglong& toRead );

      /*!
       *  Helper function to read a fourcc code
       */
      bool readFourcc( TagLib::MP4::Fourcc& fourcc );

      /*!
       * Function to get the tags proxy for registration of the tags boxes.
       * The proxy provides direct access to the data boxes of the certain tags - normally
       * covered by several levels of subboxes
       */
      Mp4TagsProxy* tagProxy() const;

      /*!
       * Function to get the properties proxy for registration of the properties boxes.
       * The proxy provides direct access to the needed boxes describing audio properties.
       */
      Mp4PropsProxy* propProxy() const;

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

      class FilePrivate;
      FilePrivate *d;
    };

  } // namespace MP4

} // namespace TagLib

#endif // TAGLIB_MP4FILE_H