Added TagLib (with AUTORS and COPYING files)
[someplayer] / src / taglib / mpeg / id3v2 / frames / attachedpictureframe.h
1 /***************************************************************************
2     copyright            : (C) 2002 - 2008 by Scott Wheeler
3     email                : wheeler@kde.org
4  ***************************************************************************/
5
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.                     *
10  *                                                                         *
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.                       *
15  *                                                                         *
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  *
19  *   USA                                                                   *
20  *                                                                         *
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  ***************************************************************************/
25
26 #ifndef TAGLIB_ATTACHEDPICTUREFRAME_H
27 #define TAGLIB_ATTACHEDPICTUREFRAME_H
28
29 #include "id3v2frame.h"
30 #include "id3v2header.h"
31 #include "taglib_export.h"
32
33 namespace TagLib {
34
35   namespace ID3v2 {
36
37     //! An ID3v2 attached picture frame implementation
38
39     /*!
40      * This is an implementation of ID3v2 attached pictures.  Pictures may be
41      * included in tags, one per APIC frame (but there may be multiple APIC
42      * frames in a single tag).  These pictures are usually in either JPEG or
43      * PNG format.
44      */
45
46     class TAGLIB_EXPORT AttachedPictureFrame : public Frame
47     {
48       friend class FrameFactory;
49
50     public:
51
52       /*!
53        * This describes the function or content of the picture.
54        */
55       enum Type {
56         //! A type not enumerated below
57         Other              = 0x00,
58         //! 32x32 PNG image that should be used as the file icon
59         FileIcon           = 0x01,
60         //! File icon of a different size or format
61         OtherFileIcon      = 0x02,
62         //! Front cover image of the album
63         FrontCover         = 0x03,
64         //! Back cover image of the album
65         BackCover          = 0x04,
66         //! Inside leaflet page of the album
67         LeafletPage        = 0x05,
68         //! Image from the album itself
69         Media              = 0x06,
70         //! Picture of the lead artist or soloist
71         LeadArtist         = 0x07,
72         //! Picture of the artist or performer
73         Artist             = 0x08,
74         //! Picture of the conductor
75         Conductor          = 0x09,
76         //! Picture of the band or orchestra
77         Band               = 0x0A,
78         //! Picture of the composer
79         Composer           = 0x0B,
80         //! Picture of the lyricist or text writer
81         Lyricist           = 0x0C,
82         //! Picture of the recording location or studio
83         RecordingLocation  = 0x0D,
84         //! Picture of the artists during recording
85         DuringRecording    = 0x0E,
86         //! Picture of the artists during performance
87         DuringPerformance  = 0x0F,
88         //! Picture from a movie or video related to the track
89         MovieScreenCapture = 0x10,
90         //! Picture of a large, coloured fish
91         ColouredFish       = 0x11,
92         //! Illustration related to the track
93         Illustration       = 0x12,
94         //! Logo of the band or performer
95         BandLogo           = 0x13,
96         //! Logo of the publisher (record company)
97         PublisherLogo      = 0x14
98       };
99
100       /*!
101        * Constructs an empty picture frame.  The description, content and text
102        * encoding should be set manually.
103        */
104       AttachedPictureFrame();
105
106       /*!
107        * Constructs an AttachedPicture frame based on \a data.
108        */
109       explicit AttachedPictureFrame(const ByteVector &data);
110
111       /*!
112        * Destroys the AttahcedPictureFrame instance.
113        */
114       virtual ~AttachedPictureFrame();
115
116       /*!
117        * Returns a string containing the description and mime-type
118        */
119       virtual String toString() const;
120
121       /*!
122        * Returns the text encoding used for the description.
123        *
124        * \see setTextEncoding()
125        * \see description()
126        */
127       String::Type textEncoding() const;
128
129       /*!
130        * Set the text encoding used for the description.
131        *
132        * \see description()
133        */
134       void setTextEncoding(String::Type t);
135
136       /*!
137        * Returns the mime type of the image.  This should in most cases be
138        * "image/png" or "image/jpeg".
139        */
140       String mimeType() const;
141
142       /*!
143        * Sets the mime type of the image.  This should in most cases be
144        * "image/png" or "image/jpeg".
145        */
146       void setMimeType(const String &m);
147
148       /*!
149        * Returns the type of the image.
150        *
151        * \see Type
152        * \see setType()
153        */
154       Type type() const;
155
156       /*!
157        * Sets the type for the image.
158        *
159        * \see Type
160        * \see type()
161        */
162       void setType(Type t);
163
164       /*!
165        * Returns a text description of the image.
166        *
167        * \see setDescription()
168        * \see textEncoding()
169        * \see setTextEncoding()
170        */
171
172       String description() const;
173
174       /*!
175        * Sets a textual description of the image to \a desc.
176        *
177        * \see description()
178        * \see textEncoding()
179        * \see setTextEncoding()
180        */
181
182       void setDescription(const String &desc);
183
184       /*!
185        * Returns the image data as a ByteVector.
186        *
187        * \note ByteVector has a data() method that returns a const char * which
188        * should make it easy to export this data to external programs.
189        *
190        * \see setPicture()
191        * \see mimeType()
192        */
193       ByteVector picture() const;
194
195       /*!
196        * Sets the image data to \a p.  \a p should be of the type specified in
197        * this frame's mime-type specification.
198        *
199        * \see picture()
200        * \see mimeType()
201        * \see setMimeType()
202        */
203       void setPicture(const ByteVector &p);
204
205     protected:
206       virtual void parseFields(const ByteVector &data);
207       virtual ByteVector renderFields() const;
208       class AttachedPictureFramePrivate;
209       AttachedPictureFramePrivate *d;
210
211     private:
212       AttachedPictureFrame(const AttachedPictureFrame &);
213       AttachedPictureFrame &operator=(const AttachedPictureFrame &);
214       AttachedPictureFrame(const ByteVector &data, Header *h);
215
216     };
217
218     //! support for ID3v2.2 PIC frames
219     class TAGLIB_EXPORT AttachedPictureFrameV22 : public AttachedPictureFrame
220     {
221     protected:
222       virtual void parseFields(const ByteVector &data);
223     private:
224       AttachedPictureFrameV22(const ByteVector &data, Header *h);
225       friend class FrameFactory;
226     };
227   }
228 }
229
230 #endif