rtaglib 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +84 -9
  3. data/README.txt +0 -0
  4. data/Rakefile +30 -27
  5. data/{test/data → data}/440Hz-5sec.flac +0 -0
  6. data/{test/data → data}/440Hz-5sec.mp3 +0 -0
  7. data/{test/data → data}/440Hz-5sec.mpc +0 -0
  8. data/{test/data → data}/440Hz-5sec.ogg +0 -0
  9. data/{test/data → data}/440Hz-5sec.wv +0 -0
  10. data/data/test_jason.mp3 +0 -0
  11. data/data/test_jason.ogg +0 -0
  12. data/ext/Rakefile +10 -0
  13. data/ext/tagfile/Rakefile.rb +42 -0
  14. data/ext/tagfile/rake_ext_conf.rb +29 -0
  15. data/ext/tagfile/tagfile.c +11 -7
  16. data/ext/taglib/Rakefile.rb +48 -0
  17. data/ext/taglib/rake_ext_conf.rb +33 -0
  18. data/ext/taglib/taglib-mswin32/bin/tag.dll +0 -0
  19. data/ext/taglib/taglib-mswin32/bin/tag_c.dll +0 -0
  20. data/ext/taglib/taglib-mswin32/bin/tag_cd.dll +0 -0
  21. data/ext/taglib/taglib-mswin32/bin/tagd.dll +0 -0
  22. data/ext/taglib/taglib-mswin32/bin/taglib-config +55 -0
  23. data/ext/taglib/taglib-mswin32/include/taglib/apefooter.h +173 -0
  24. data/ext/taglib/taglib-mswin32/include/taglib/apeitem.h +204 -0
  25. data/ext/taglib/taglib-mswin32/include/taglib/apetag.h +162 -0
  26. data/ext/taglib/taglib-mswin32/include/taglib/attachedpictureframe.h +220 -0
  27. data/ext/taglib/taglib-mswin32/include/taglib/audioproperties.h +110 -0
  28. data/ext/taglib/taglib-mswin32/include/taglib/commentsframe.h +168 -0
  29. data/ext/taglib/taglib-mswin32/include/taglib/fileref.h +262 -0
  30. data/ext/taglib/taglib-mswin32/include/taglib/flacfile.h +201 -0
  31. data/ext/taglib/taglib-mswin32/include/taglib/flacproperties.h +92 -0
  32. data/ext/taglib/taglib-mswin32/include/taglib/generalencapsulatedobjectframe.h +174 -0
  33. data/ext/taglib/taglib-mswin32/include/taglib/id3v1genres.h +66 -0
  34. data/ext/taglib/taglib-mswin32/include/taglib/id3v1tag.h +180 -0
  35. data/ext/taglib/taglib-mswin32/include/taglib/id3v2extendedheader.h +93 -0
  36. data/ext/taglib/taglib-mswin32/include/taglib/id3v2footer.h +82 -0
  37. data/ext/taglib/taglib-mswin32/include/taglib/id3v2frame.h +414 -0
  38. data/ext/taglib/taglib-mswin32/include/taglib/id3v2framefactory.h +167 -0
  39. data/ext/taglib/taglib-mswin32/include/taglib/id3v2header.h +175 -0
  40. data/ext/taglib/taglib-mswin32/include/taglib/id3v2synchdata.h +70 -0
  41. data/ext/taglib/taglib-mswin32/include/taglib/id3v2tag.h +300 -0
  42. data/ext/taglib/taglib-mswin32/include/taglib/mpcfile.h +175 -0
  43. data/ext/taglib/taglib-mswin32/include/taglib/mpcproperties.h +85 -0
  44. data/ext/taglib/taglib-mswin32/include/taglib/mpegfile.h +277 -0
  45. data/ext/taglib/taglib-mswin32/include/taglib/mpegheader.h +166 -0
  46. data/ext/taglib/taglib-mswin32/include/taglib/mpegproperties.h +118 -0
  47. data/ext/taglib/taglib-mswin32/include/taglib/oggfile.h +112 -0
  48. data/ext/taglib/taglib-mswin32/include/taglib/oggflacfile.h +118 -0
  49. data/ext/taglib/taglib-mswin32/include/taglib/oggpage.h +203 -0
  50. data/ext/taglib/taglib-mswin32/include/taglib/oggpageheader.h +232 -0
  51. data/ext/taglib/taglib-mswin32/include/taglib/relativevolumeframe.h +274 -0
  52. data/ext/taglib/taglib-mswin32/include/taglib/speexfile.h +99 -0
  53. data/ext/taglib/taglib-mswin32/include/taglib/speexproperties.h +89 -0
  54. data/ext/taglib/taglib-mswin32/include/taglib/tag.h +173 -0
  55. data/ext/taglib/taglib-mswin32/include/taglib/tag_c.h +288 -0
  56. data/ext/taglib/taglib-mswin32/include/taglib/taglib.h +177 -0
  57. data/ext/taglib/taglib-mswin32/include/taglib/taglib_export.h +39 -0
  58. data/ext/taglib/taglib-mswin32/include/taglib/tbytevector.h +409 -0
  59. data/ext/taglib/taglib-mswin32/include/taglib/tbytevectorlist.h +91 -0
  60. data/ext/taglib/taglib-mswin32/include/taglib/textidentificationframe.h +258 -0
  61. data/ext/taglib/taglib-mswin32/include/taglib/tfile.h +271 -0
  62. data/ext/taglib/taglib-mswin32/include/taglib/tlist.h +252 -0
  63. data/ext/taglib/taglib-mswin32/include/taglib/tlist.tcc +316 -0
  64. data/ext/taglib/taglib-mswin32/include/taglib/tmap.h +200 -0
  65. data/ext/taglib/taglib-mswin32/include/taglib/tmap.tcc +196 -0
  66. data/ext/taglib/taglib-mswin32/include/taglib/trueaudiofile.h +180 -0
  67. data/ext/taglib/taglib-mswin32/include/taglib/trueaudioproperties.h +93 -0
  68. data/ext/taglib/taglib-mswin32/include/taglib/tstring.h +456 -0
  69. data/ext/taglib/taglib-mswin32/include/taglib/tstringlist.h +115 -0
  70. data/ext/taglib/taglib-mswin32/include/taglib/uniquefileidentifierframe.h +113 -0
  71. data/ext/taglib/taglib-mswin32/include/taglib/unknownframe.h +79 -0
  72. data/ext/taglib/taglib-mswin32/include/taglib/unsynchronizedlyricsframe.h +157 -0
  73. data/ext/taglib/taglib-mswin32/include/taglib/urllinkframe.h +172 -0
  74. data/ext/taglib/taglib-mswin32/include/taglib/vorbisfile.h +118 -0
  75. data/ext/taglib/taglib-mswin32/include/taglib/vorbisproperties.h +125 -0
  76. data/ext/taglib/taglib-mswin32/include/taglib/wavpackfile.h +164 -0
  77. data/ext/taglib/taglib-mswin32/include/taglib/wavpackproperties.h +94 -0
  78. data/ext/taglib/taglib-mswin32/include/taglib/xingheader.h +100 -0
  79. data/ext/taglib/taglib-mswin32/include/taglib/xiphcomment.h +202 -0
  80. data/ext/taglib/taglib-mswin32/lib/pkgconfig/taglib_c.pc +12 -0
  81. data/ext/taglib/taglib-mswin32/lib/tag.lib +0 -0
  82. data/ext/taglib/taglib-mswin32/lib/tag_c.lib +0 -0
  83. data/ext/taglib/taglib_i386-mingw32.source +22645 -0
  84. data/ext/taglib/taglib_i386-mswin32.source +22645 -0
  85. data/ext/taglib/{taglib.cxx → taglib_x86_64-linux.source} +508 -75
  86. data/lib/TagLib.rb +3 -2
  87. data/lib/TagLib_doc.rb +1532 -1526
  88. data/lib/rtaglib_mswin32.rb +4 -0
  89. data/lib/tagfile.rb +6 -0
  90. data/swig/Doxyfile +0 -0
  91. data/swig/Rakefile +44 -19
  92. data/swig/TagLib_doc.rb +2755 -0
  93. data/swig/make_doc.rb +5 -4
  94. data/swig/process_cxx.rb +2 -2
  95. data/swig/rake_ext_conf.rb +33 -0
  96. data/swig/taglib.i +8 -5
  97. data/swig/test.rb +47 -39
  98. data/test/test_read.rb +4 -3
  99. data/test/test_taglib.rb +47 -39
  100. data/test/test_write.rb +4 -3
  101. metadata +96 -20
  102. data/ext/tagfile/extconf.rb +0 -14
  103. data/ext/taglib/extconf.rb +0 -22
  104. data/swig/extconf.rb +0 -22
@@ -0,0 +1,167 @@
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_ID3V2FRAMEFACTORY_H
27
+ #define TAGLIB_ID3V2FRAMEFACTORY_H
28
+
29
+ #include "taglib_export.h"
30
+ #include "tbytevector.h"
31
+ #include "id3v2frame.h"
32
+ #include "id3v2header.h"
33
+
34
+ namespace TagLib {
35
+
36
+ namespace ID3v2 {
37
+
38
+ class TAGLIB_EXPORT TextIdentificationFrame;
39
+
40
+ //! A factory for creating ID3v2 frames during parsing
41
+
42
+ /*!
43
+ * This factory abstracts away the frame creation process and instantiates
44
+ * the appropriate ID3v2::Frame subclasses based on the contents of the
45
+ * data.
46
+ *
47
+ * Reimplementing this factory is the key to adding support for frame types
48
+ * not directly supported by TagLib to your application. To do so you would
49
+ * subclass this factory reimplement createFrame(). Then by setting your
50
+ * factory to be the default factory in ID3v2::Tag constructor or with
51
+ * MPEG::File::setID3v2FrameFactory() you can implement behavior that will
52
+ * allow for new ID3v2::Frame subclasses (also provided by you) to be used.
53
+ *
54
+ * This implements both <i>abstract factory</i> and <i>singleton</i> patterns
55
+ * of which more information is available on the web and in software design
56
+ * textbooks (Notably <i>Design Patters</i>).
57
+ *
58
+ * \note You do not need to use this factory to create new frames to add to
59
+ * an ID3v2::Tag. You can instantiate frame subclasses directly (with new)
60
+ * and add them to a tag using ID3v2::Tag::addFrame()
61
+ *
62
+ * \see ID3v2::Tag::addFrame()
63
+ */
64
+
65
+ class TAGLIB_EXPORT FrameFactory
66
+ {
67
+ public:
68
+ static FrameFactory *instance();
69
+ /*!
70
+ * Create a frame based on \a data. \a synchSafeInts should only be set
71
+ * false if we are parsing an old tag (v2.3 or older) that does not support
72
+ * synchsafe ints.
73
+ *
74
+ * \deprecated Please use the method below that accepts a ID3v2::Header
75
+ * instance in new code.
76
+ */
77
+ Frame *createFrame(const ByteVector &data, bool synchSafeInts) const;
78
+
79
+ /*!
80
+ * Create a frame based on \a data. \a version should indicate the ID3v2
81
+ * version of the tag. As ID3v2.4 is the most current version of the
82
+ * standard 4 is the default.
83
+ *
84
+ * \deprecated Please use the method below that accepts a ID3v2::Header
85
+ * instance in new code.
86
+ */
87
+ Frame *createFrame(const ByteVector &data, uint version = 4) const;
88
+
89
+ /*!
90
+ * Create a frame based on \a data. \a tagHeader should be a valid
91
+ * ID3v2::Header instance.
92
+ */
93
+ // BIC: make virtual
94
+ Frame *createFrame(const ByteVector &data, Header *tagHeader) const;
95
+
96
+ /*!
97
+ * Returns the default text encoding for text frames. If setTextEncoding()
98
+ * has not been explicitly called this will only be used for new text
99
+ * frames. However, if this value has been set explicitly all frames will be
100
+ * converted to this type (unless it's explitly set differently for the
101
+ * individual frame) when being rendered.
102
+ *
103
+ * \see setDefaultTextEncoding()
104
+ */
105
+ String::Type defaultTextEncoding() const;
106
+
107
+ /*!
108
+ * Set the default text encoding for all text frames that are created to
109
+ * \a encoding. If no value is set the frames with either default to the
110
+ * encoding type that was parsed and new frames default to Latin1.
111
+ *
112
+ * Valid string types for ID3v2 tags are Latin1, UTF8, UTF16 and UTF16BE.
113
+ *
114
+ * \see defaultTextEncoding()
115
+ */
116
+ void setDefaultTextEncoding(String::Type encoding);
117
+
118
+ protected:
119
+ /*!
120
+ * Constructs a frame factory. Because this is a singleton this method is
121
+ * protected, but may be used for subclasses.
122
+ */
123
+ FrameFactory();
124
+
125
+ /*!
126
+ * Destroys the frame factory. In most cases this will never be called (as
127
+ * is typical of singletons).
128
+ */
129
+ virtual ~FrameFactory();
130
+
131
+ /*!
132
+ * This method checks for compliance to the current ID3v2 standard (2.4)
133
+ * and does nothing in the common case. However if a frame is found that
134
+ * is not compatible with the current standard, this method either updates
135
+ * the frame or indicates that it should be discarded.
136
+ *
137
+ * This method with return true (with or without changes to the frame) if
138
+ * this frame should be kept or false if it should be discarded.
139
+ *
140
+ * See the id3v2.4.0-changes.txt document for further information.
141
+ */
142
+ virtual bool updateFrame(Frame::Header *header) const;
143
+
144
+ private:
145
+ FrameFactory(const FrameFactory &);
146
+ FrameFactory &operator=(const FrameFactory &);
147
+
148
+ /*!
149
+ * This method is used internally to convert a frame from ID \a from to ID
150
+ * \a to. If the frame matches the \a from pattern and converts the frame
151
+ * ID in the \a header or simply does nothing if the frame ID does not match.
152
+ */
153
+ void convertFrame(const char *from, const char *to,
154
+ Frame::Header *header) const;
155
+
156
+ void updateGenre(TextIdentificationFrame *frame) const;
157
+
158
+ static FrameFactory *factory;
159
+
160
+ class FrameFactoryPrivate;
161
+ FrameFactoryPrivate *d;
162
+ };
163
+
164
+ }
165
+ }
166
+
167
+ #endif
@@ -0,0 +1,175 @@
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_ID3V2HEADER_H
27
+ #define TAGLIB_ID3V2HEADER_H
28
+
29
+ #include "tbytevector.h"
30
+ #include "taglib_export.h"
31
+
32
+ namespace TagLib {
33
+
34
+ namespace ID3v2 {
35
+
36
+ //! An implementation of ID3v2 headers
37
+
38
+ /*!
39
+ * This class implements ID3v2 headers. It attempts to follow, both
40
+ * semantically and programatically, the structure specified in
41
+ * the ID3v2 standard. The API is based on the properties of ID3v2 headers
42
+ * specified there. If any of the terms used in this documentation are
43
+ * unclear please check the specification in the linked section.
44
+ * (Structure, <a href="id3v2-structure.html#3.1">3.1</a>)
45
+ */
46
+
47
+ class TAGLIB_EXPORT Header
48
+ {
49
+ public:
50
+ /*!
51
+ * Constructs an empty ID3v2 header.
52
+ */
53
+ Header();
54
+
55
+ /*!
56
+ * Constructs an ID3v2 header based on \a data. parse() is called
57
+ * immediately.
58
+ */
59
+ Header(const ByteVector &data);
60
+
61
+ /*!
62
+ * Destroys the header.
63
+ */
64
+ virtual ~Header();
65
+
66
+ /*!
67
+ * Returns the major version number. (Note: This is the 4, not the 2 in
68
+ * ID3v2.4.0. The 2 is implied.)
69
+ */
70
+ uint majorVersion() const;
71
+
72
+ /*!
73
+ * Set the the major version number to \a version. (Note: This is
74
+ * the 4, not the 2 in ID3v2.4.0. The 2 is implied.)
75
+ * \see majorVersion()
76
+ *
77
+ * \note This is used by the internal parser; this will not change the
78
+ * version which is written and in general should not be called by API
79
+ * users.
80
+ */
81
+ void setMajorVersion(uint version);
82
+
83
+ /*!
84
+ * Returns the revision number. (Note: This is the 0, not the 4 in
85
+ * ID3v2.4.0. The 2 is implied.)
86
+ */
87
+ uint revisionNumber() const;
88
+
89
+ /*!
90
+ * Returns true if unsynchronisation has been applied to all frames.
91
+ */
92
+ bool unsynchronisation() const;
93
+
94
+ /*!
95
+ * Returns true if an extended header is present in the tag.
96
+ */
97
+ bool extendedHeader() const;
98
+
99
+ /*!
100
+ * Returns true if the experimental indicator flag is set.
101
+ */
102
+ bool experimentalIndicator() const;
103
+
104
+ /*!
105
+ * Returns true if a footer is present in the tag.
106
+ */
107
+ bool footerPresent() const;
108
+ /*!
109
+ * Returns the tag size in bytes. This is the size of the frame content.
110
+ * The size of the \e entire tag will be this plus the header size (10
111
+ * bytes) and, if present, the footer size (potentially another 10 bytes).
112
+ *
113
+ * \note This is the value as read from the header to which TagLib attempts
114
+ * to provide an API to; it was not a design decision on the part of TagLib
115
+ * to not include the mentioned portions of the tag in the \e size.
116
+ *
117
+ * \see completeTagSize()
118
+ */
119
+ uint tagSize() const;
120
+
121
+ /*!
122
+ * Returns the tag size, including the header and, if present, the footer
123
+ * size.
124
+ *
125
+ * \see tagSize()
126
+ */
127
+ uint completeTagSize() const;
128
+
129
+ /*!
130
+ * Set the tag size to \a s.
131
+ * \see tagSize()
132
+ */
133
+ void setTagSize(uint s);
134
+
135
+ /*!
136
+ * Returns the size of the header. Presently this is always 10 bytes.
137
+ */
138
+ static uint size();
139
+
140
+ /*!
141
+ * Returns the string used to identify and ID3v2 tag inside of a file.
142
+ * Presently this is always "ID3".
143
+ */
144
+ static ByteVector fileIdentifier();
145
+
146
+ /*!
147
+ * Sets the data that will be used as the header. 10 bytes, starting from
148
+ * the beginning of \a data are used.
149
+ */
150
+ void setData(const ByteVector &data);
151
+
152
+ /*!
153
+ * Renders the Header back to binary format.
154
+ */
155
+ ByteVector render() const;
156
+
157
+ protected:
158
+ /*!
159
+ * Called by setData() to parse the header data. It makes this information
160
+ * available through the public API.
161
+ */
162
+ void parse(const ByteVector &data);
163
+
164
+ private:
165
+ Header(const Header &);
166
+ Header &operator=(const Header &);
167
+
168
+ class HeaderPrivate;
169
+ HeaderPrivate *d;
170
+ };
171
+
172
+ }
173
+ }
174
+
175
+ #endif
@@ -0,0 +1,70 @@
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_ID3V2SYNCHDATA_H
27
+ #define TAGLIB_ID3V2SYNCHDATA_H
28
+
29
+ #include "tbytevector.h"
30
+ #include "taglib.h"
31
+
32
+ namespace TagLib {
33
+
34
+ namespace ID3v2 {
35
+
36
+ //! A few functions for ID3v2 synch safe integer conversion
37
+
38
+ /*!
39
+ * In the ID3v2.4 standard most integer values are encoded as "synch safe"
40
+ * integers which are encoded in such a way that they will not give false
41
+ * MPEG syncs and confuse MPEG decoders. This namespace provides some
42
+ * methods for converting to and from these values to ByteVectors for
43
+ * things rendering and parsing ID3v2 data.
44
+ */
45
+
46
+ namespace SynchData
47
+ {
48
+ /*!
49
+ * This returns the unsigned integer value of \a data where \a data is a
50
+ * ByteVector that contains a \e synchsafe integer (Structure,
51
+ * <a href="id3v2-structure.html#6.2">6.2</a>). The default \a length of
52
+ * 4 is used if another value is not specified.
53
+ */
54
+ TAGLIB_EXPORT uint toUInt(const ByteVector &data);
55
+
56
+ /*!
57
+ * Returns a 4 byte (32 bit) synchsafe integer based on \a value.
58
+ */
59
+ TAGLIB_EXPORT ByteVector fromUInt(uint value);
60
+
61
+ /*!
62
+ * Convert the data from unsynchronized data to its original format.
63
+ */
64
+ TAGLIB_EXPORT ByteVector decode(const ByteVector &input);
65
+ }
66
+
67
+ }
68
+ }
69
+
70
+ #endif
@@ -0,0 +1,300 @@
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_ID3V2TAG_H
27
+ #define TAGLIB_ID3V2TAG_H
28
+
29
+ #include "tag.h"
30
+ #include "tbytevector.h"
31
+ #include "tstring.h"
32
+ #include "tlist.h"
33
+ #include "tmap.h"
34
+ #include "taglib_export.h"
35
+
36
+ #include "id3v2framefactory.h"
37
+
38
+ namespace TagLib {
39
+
40
+ class File;
41
+
42
+ //! An ID3v2 implementation
43
+
44
+ /*!
45
+ * This is a relatively complete and flexible framework for working with ID3v2
46
+ * tags.
47
+ *
48
+ * \see ID3v2::Tag
49
+ */
50
+
51
+ namespace ID3v2 {
52
+
53
+ class Header;
54
+ class ExtendedHeader;
55
+ class Footer;
56
+
57
+ typedef List<Frame *> FrameList;
58
+ typedef Map<ByteVector, FrameList> FrameListMap;
59
+
60
+ //! The main class in the ID3v2 implementation
61
+
62
+ /*!
63
+ * This is the main class in the ID3v2 implementation. It serves two
64
+ * functions. This first, as is obvious from the public API, is to provide a
65
+ * container for the other ID3v2 related classes. In addition, through the
66
+ * read() and parse() protected methods, it provides the most basic level of
67
+ * parsing. In these methods the ID3v2 tag is extracted from the file and
68
+ * split into data components.
69
+ *
70
+ * ID3v2 tags have several parts, TagLib attempts to provide an interface
71
+ * for them all. header(), footer() and extendedHeader() corespond to those
72
+ * data structures in the ID3v2 standard and the APIs for the classes that
73
+ * they return attempt to reflect this.
74
+ *
75
+ * Also ID3v2 tags are built up from a list of frames, which are in turn
76
+ * have a header and a list of fields. TagLib provides two ways of accessing
77
+ * the list of frames that are in a given ID3v2 tag. The first is simply
78
+ * via the frameList() method. This is just a list of pointers to the frames.
79
+ * The second is a map from the frame type -- i.e. "COMM" for comments -- and
80
+ * a list of frames of that type. (In some cases ID3v2 allows for multiple
81
+ * frames of the same type, hence this being a map to a list rather than just
82
+ * a map to an individual frame.)
83
+ *
84
+ * More information on the structure of frames can be found in the ID3v2::Frame
85
+ * class.
86
+ *
87
+ * read() and parse() pass binary data to the other ID3v2 class structures,
88
+ * they do not handle parsing of flags or fields, for instace. Those are
89
+ * handled by similar functions within those classes.
90
+ *
91
+ * \note All pointers to data structures within the tag will become invalid
92
+ * when the tag is destroyed.
93
+ *
94
+ * \warning Dealing with the nasty details of ID3v2 is not for the faint of
95
+ * heart and should not be done without much meditation on the spec. It's
96
+ * rather long, but if you're planning on messing with this class and others
97
+ * that deal with the details of ID3v2 (rather than the nice, safe, abstract
98
+ * TagLib::Tag and friends), it's worth your time to familiarize yourself
99
+ * with said spec (which is distrubuted with the TagLib sources). TagLib
100
+ * tries to do most of the work, but with a little luck, you can still
101
+ * convince it to generate invalid ID3v2 tags. The APIs for ID3v2 assume a
102
+ * working knowledge of ID3v2 structure. You're been warned.
103
+ */
104
+
105
+ class TAGLIB_EXPORT Tag : public TagLib::Tag
106
+ {
107
+ public:
108
+ /*!
109
+ * Constructs an empty ID3v2 tag.
110
+ *
111
+ * \note You must create at least one frame for this tag to be valid.
112
+ */
113
+ Tag();
114
+
115
+ /*!
116
+ * Constructs an ID3v2 tag read from \a file starting at \a tagOffset.
117
+ * \a factory specifies which FrameFactory will be used for the
118
+ * construction of new frames.
119
+ *
120
+ * \note You should be able to ignore the \a factory parameter in almost
121
+ * all situations. You would want to specify your own FrameFactory
122
+ * subclass in the case that you are extending TagLib to support additional
123
+ * frame types, which would be incorperated into your factory.
124
+ *
125
+ * \see FrameFactory
126
+ */
127
+ Tag(File *file, long tagOffset,
128
+ const FrameFactory *factory = FrameFactory::instance());
129
+
130
+ /*!
131
+ * Destroys this Tag instance.
132
+ */
133
+ virtual ~Tag();
134
+
135
+ // Reimplementations.
136
+
137
+ virtual String title() const;
138
+ virtual String artist() const;
139
+ virtual String album() const;
140
+ virtual String comment() const;
141
+ virtual String genre() const;
142
+ virtual uint year() const;
143
+ virtual uint track() const;
144
+
145
+ virtual void setTitle(const String &s);
146
+ virtual void setArtist(const String &s);
147
+ virtual void setAlbum(const String &s);
148
+ virtual void setComment(const String &s);
149
+ virtual void setGenre(const String &s);
150
+ virtual void setYear(uint i);
151
+ virtual void setTrack(uint i);
152
+
153
+ virtual bool isEmpty() const;
154
+
155
+ /*!
156
+ * Returns a pointer to the tag's header.
157
+ */
158
+ Header *header() const;
159
+
160
+ /*!
161
+ * Returns a pointer to the tag's extended header or null if there is no
162
+ * extended header.
163
+ */
164
+ ExtendedHeader *extendedHeader() const;
165
+
166
+ /*!
167
+ * Returns a pointer to the tag's footer or null if there is no footer.
168
+ *
169
+ * \deprecated I don't see any reason to keep this around since there's
170
+ * nothing useful to be retrieved from the footer, but well, again, I'm
171
+ * prone to change my mind, so this gets to stay around until near a
172
+ * release.
173
+ */
174
+ Footer *footer() const;
175
+
176
+ /*!
177
+ * Returns a reference to the frame list map. This is an FrameListMap of
178
+ * all of the frames in the tag.
179
+ *
180
+ * This is the most convenient structure for accessing the tag's frames.
181
+ * Many frame types allow multiple instances of the same frame type so this
182
+ * is a map of lists. In most cases however there will only be a single
183
+ * frame of a certain type.
184
+ *
185
+ * Let's say for instance that you wanted to access the frame for total
186
+ * beats per minute -- the TBPM frame.
187
+ *
188
+ * \code
189
+ * TagLib::MPEG::File f("foo.mp3");
190
+ *
191
+ * // Check to make sure that it has an ID3v2 tag
192
+ *
193
+ * if(f.ID3v2Tag()) {
194
+ *
195
+ * // Get the list of frames for a specific frame type
196
+ *
197
+ * TagLib::ID3v2::FrameList l = f.ID3v2Tag()->frameListMap()["TBPM"];
198
+ *
199
+ * if(!l.isEmpty())
200
+ * std::cout << l.front()->toString() << std::endl;
201
+ * }
202
+ *
203
+ * \endcode
204
+ *
205
+ * \warning You should not modify this data structure directly, instead
206
+ * use addFrame() and removeFrame().
207
+ *
208
+ * \see frameList()
209
+ */
210
+ const FrameListMap &frameListMap() const;
211
+
212
+ /*!
213
+ * Returns a reference to the frame list. This is an FrameList of all of
214
+ * the frames in the tag in the order that they were parsed.
215
+ *
216
+ * This can be useful if for example you want iterate over the tag's frames
217
+ * in the order that they occur in the tag.
218
+ *
219
+ * \warning You should not modify this data structure directly, instead
220
+ * use addFrame() and removeFrame().
221
+ */
222
+ const FrameList &frameList() const;
223
+
224
+ /*!
225
+ * Returns the frame list for frames with the id \a frameID or an empty
226
+ * list if there are no frames of that type. This is just a convenience
227
+ * and is equivalent to:
228
+ *
229
+ * \code
230
+ * frameListMap()[frameID];
231
+ * \endcode
232
+ *
233
+ * \see frameListMap()
234
+ */
235
+ const FrameList &frameList(const ByteVector &frameID) const;
236
+
237
+ /*!
238
+ * Add a frame to the tag. At this point the tag takes ownership of
239
+ * the frame and will handle freeing its memory.
240
+ *
241
+ * \note Using this method will invalidate any pointers on the list
242
+ * returned by frameList()
243
+ */
244
+ void addFrame(Frame *frame);
245
+
246
+ /*!
247
+ * Remove a frame from the tag. If \a del is true the frame's memory
248
+ * will be freed; if it is false, it must be deleted by the user.
249
+ *
250
+ * \note Using this method will invalidate any pointers on the list
251
+ * returned by frameList()
252
+ */
253
+ void removeFrame(Frame *frame, bool del = true);
254
+
255
+ /*!
256
+ * Remove all frames of type \a id from the tag and free their memory.
257
+ *
258
+ * \note Using this method will invalidate any pointers on the list
259
+ * returned by frameList()
260
+ */
261
+ void removeFrames(const ByteVector &id);
262
+
263
+ /*!
264
+ * Render the tag back to binary data, suitable to be written to disk.
265
+ */
266
+ ByteVector render() const;
267
+
268
+ protected:
269
+ /*!
270
+ * Reads data from the file specified in the constructor. It does basic
271
+ * parsing of the data in the largest chunks. It partitions the tag into
272
+ * the Header, the body of the tag (which contains the ExtendedHeader and
273
+ * frames) and Footer.
274
+ */
275
+ void read();
276
+
277
+ /*!
278
+ * This is called by read to parse the body of the tag. It determines if an
279
+ * extended header exists and adds frames to the FrameListMap.
280
+ */
281
+ void parse(const ByteVector &data);
282
+
283
+ /*!
284
+ * Sets the value of the text frame with the Frame ID \a id to \a value.
285
+ * If the frame does not exist, it is created.
286
+ */
287
+ void setTextFrame(const ByteVector &id, const String &value);
288
+
289
+ private:
290
+ Tag(const Tag &);
291
+ Tag &operator=(const Tag &);
292
+
293
+ class TagPrivate;
294
+ TagPrivate *d;
295
+ };
296
+
297
+ }
298
+ }
299
+
300
+ #endif