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,203 @@
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_OGGPAGE_H
27
+ #define TAGLIB_OGGPAGE_H
28
+
29
+ #include "taglib_export.h"
30
+ #include "tbytevectorlist.h"
31
+
32
+ namespace TagLib {
33
+
34
+ namespace Ogg {
35
+
36
+ class File;
37
+ class PageHeader;
38
+
39
+ //! An implementation of Ogg pages
40
+
41
+ /*!
42
+ * This is an implementation of the pages that make up an Ogg stream.
43
+ * This handles parsing pages and breaking them down into packets and handles
44
+ * the details of packets spanning multiple pages and pages that contiain
45
+ * multiple packets.
46
+ *
47
+ * In most Xiph.org formats the comments are found in the first few packets,
48
+ * this however is a reasonably complete implementation of Ogg pages that
49
+ * could potentially be useful for non-meta data purposes.
50
+ */
51
+
52
+ class TAGLIB_EXPORT Page
53
+ {
54
+ public:
55
+ /*!
56
+ * Read an Ogg page from the \a file at the position \a pageOffset.
57
+ */
58
+ Page(File *file, long pageOffset);
59
+
60
+ virtual ~Page();
61
+
62
+ /*!
63
+ * Returns the page's position within the file (in bytes).
64
+ */
65
+ long fileOffset() const;
66
+
67
+ /*!
68
+ * Returns a pointer to the header for this page. This pointer will become
69
+ * invalid when the page is deleted.
70
+ */
71
+ const PageHeader *header() const;
72
+
73
+ /*!
74
+ * Returns the index of the first packet wholly or partially contained in
75
+ * this page.
76
+ *
77
+ * \see setFirstPacketIndex()
78
+ */
79
+ int firstPacketIndex() const;
80
+
81
+ /*!
82
+ * Sets the index of the first packet in the page.
83
+ *
84
+ * \see firstPacketIndex()
85
+ */
86
+ void setFirstPacketIndex(int index);
87
+
88
+ /*!
89
+ * When checking to see if a page contains a given packet this set of flags
90
+ * represents the possible values for that packets status in the page.
91
+ *
92
+ * \see containsPacket()
93
+ */
94
+ enum ContainsPacketFlags {
95
+ //! No part of the packet is contained in the page
96
+ DoesNotContainPacket = 0x0000,
97
+ //! The packet is wholly contained in the page
98
+ CompletePacket = 0x0001,
99
+ //! The page starts with the given packet
100
+ BeginsWithPacket = 0x0002,
101
+ //! The page ends with the given packet
102
+ EndsWithPacket = 0x0004
103
+ };
104
+
105
+ /*!
106
+ * Checks to see if the specified \a packet is contained in the current
107
+ * page.
108
+ *
109
+ * \see ContainsPacketFlags
110
+ */
111
+ ContainsPacketFlags containsPacket(int index) const;
112
+
113
+ /*!
114
+ * Returns the number of packets (whole or partial) in this page.
115
+ */
116
+ uint packetCount() const;
117
+
118
+ /*!
119
+ * Returns a list of the packets in this page.
120
+ *
121
+ * \note Either or both the first and last packets may be only partial.
122
+ * \see PageHeader::firstPacketContinued()
123
+ */
124
+ ByteVectorList packets() const;
125
+
126
+ /*!
127
+ * Returns the size of the page in bytes.
128
+ */
129
+ int size() const;
130
+
131
+ ByteVector render() const;
132
+
133
+ /*!
134
+ * Defines a strategy for pagination, or grouping pages into Ogg packets,
135
+ * for use with pagination methods.
136
+ *
137
+ * \note Yes, I'm aware that this is not a canonical "Strategy Pattern",
138
+ * the term was simply convenient.
139
+ */
140
+ enum PaginationStrategy {
141
+ /*!
142
+ * Attempt to put the specified set of packets into a single Ogg packet.
143
+ * If the sum of the packet data is greater than will fit into a single
144
+ * Ogg page -- 65280 bytes -- this will fall back to repagination using
145
+ * the recommended page sizes.
146
+ */
147
+ SinglePagePerGroup,
148
+ /*!
149
+ * Split the packet or group of packets into pages that conform to the
150
+ * sizes recommended in the Ogg standard.
151
+ */
152
+ Repaginate
153
+ };
154
+
155
+ /*!
156
+ * Pack \a packets into Ogg pages using the \a strategy for pagination.
157
+ * The page number indicater inside of the rendered packets will start
158
+ * with \a firstPage and be incremented for each page rendered.
159
+ * \a containsLastPacket should be set to true if \a packets contains the
160
+ * last page in the stream and will set the appropriate flag in the last
161
+ * rendered Ogg page's header. \a streamSerialNumber should be set to
162
+ * the serial number for this stream.
163
+ *
164
+ * \note The "absolute granule position" is currently always zeroed using
165
+ * this method as this suffices for the comment headers.
166
+ *
167
+ * \warning The pages returned by this method must be deleted by the user.
168
+ * You can use List<T>::setAutoDelete(true) to set these pages to be
169
+ * automatically deleted when this list passes out of scope.
170
+ *
171
+ * \see PaginationStrategy
172
+ * \see List::setAutoDelete()
173
+ */
174
+ static List<Page *> paginate(const ByteVectorList &packets,
175
+ PaginationStrategy strategy,
176
+ uint streamSerialNumber,
177
+ int firstPage,
178
+ bool firstPacketContinued = false,
179
+ bool lastPacketCompleted = true,
180
+ bool containsLastPacket = false);
181
+
182
+ protected:
183
+ /*!
184
+ * Creates an Ogg packet based on the data in \a packets. The page number
185
+ * for each page will be set to \a pageNumber.
186
+ */
187
+ Page(const ByteVectorList &packets,
188
+ uint streamSerialNumber,
189
+ int pageNumber,
190
+ bool firstPacketContinued = false,
191
+ bool lastPacketCompleted = true,
192
+ bool containsLastPacket = false);
193
+
194
+ private:
195
+ Page(const Page &);
196
+ Page &operator=(const Page &);
197
+
198
+ class PagePrivate;
199
+ PagePrivate *d;
200
+ };
201
+ }
202
+ }
203
+ #endif
@@ -0,0 +1,232 @@
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_OGGPAGEHEADER_H
27
+ #define TAGLIB_OGGPAGEHEADER_H
28
+
29
+ #include "tlist.h"
30
+ #include "tbytevector.h"
31
+ #include "taglib_export.h"
32
+
33
+ namespace TagLib {
34
+
35
+ namespace Ogg {
36
+
37
+ class File;
38
+
39
+ //! An implementation of the page headers associated with each Ogg::Page
40
+
41
+ /*!
42
+ * This class implements Ogg page headers which contain the information
43
+ * about Ogg pages needed to break them into packets which can be passed on
44
+ * to the codecs.
45
+ */
46
+
47
+ class TAGLIB_EXPORT PageHeader
48
+ {
49
+ public:
50
+ /*!
51
+ * Reads a PageHeader from \a file starting at \a pageOffset. The defaults
52
+ * create a page with no (and as such, invalid) data that must be set
53
+ * later.
54
+ */
55
+ PageHeader(File *file = 0, long pageOffset = -1);
56
+
57
+ /*!
58
+ * Deletes this instance of the PageHeader.
59
+ */
60
+ virtual ~PageHeader();
61
+
62
+ /*!
63
+ * Returns true if the header parsed properly and is valid.
64
+ */
65
+ bool isValid() const;
66
+
67
+ /*!
68
+ * Ogg pages contain a list of packets (which are used by the contained
69
+ * codecs). The sizes of these pages is encoded in the page header. This
70
+ * returns a list of the packet sizes in bytes.
71
+ *
72
+ * \see setPacketSizes()
73
+ */
74
+ List<int> packetSizes() const;
75
+
76
+ /*!
77
+ * Sets the sizes of the packets in this page to \a sizes. Internally this
78
+ * updates the lacing values in the header.
79
+ *
80
+ * \see packetSizes()
81
+ */
82
+ void setPacketSizes(const List<int> &sizes);
83
+
84
+ /*!
85
+ * Some packets can be <i>continued</i> across multiple pages. If the
86
+ * first packet in the current page is a continuation this will return
87
+ * true. If this is page starts with a new packet this will return false.
88
+ *
89
+ * \see lastPacketCompleted()
90
+ * \see setFirstPacketContinued()
91
+ */
92
+ bool firstPacketContinued() const;
93
+
94
+ /*!
95
+ * Sets the internal flag indicating if the first packet in this page is
96
+ * continued to \a continued.
97
+ *
98
+ * \see firstPacketContinued()
99
+ */
100
+ void setFirstPacketContinued(bool continued);
101
+
102
+ /*!
103
+ * Returns true if the last packet of this page is completely contained in
104
+ * this page.
105
+ *
106
+ * \see firstPacketContinued()
107
+ * \see setLastPacketCompleted()
108
+ */
109
+ bool lastPacketCompleted() const;
110
+
111
+ /*!
112
+ * Sets the internal flag indicating if the last packet in this page is
113
+ * complete to \a completed.
114
+ *
115
+ * \see lastPacketCompleted()
116
+ */
117
+ void setLastPacketCompleted(bool completed);
118
+
119
+ /*!
120
+ * This returns true if this is the first page of the Ogg (logical) stream.
121
+ *
122
+ * \see setFirstPageOfStream()
123
+ */
124
+ bool firstPageOfStream() const;
125
+
126
+ /*!
127
+ * Marks this page as the first page of the Ogg stream.
128
+ *
129
+ * \see firstPageOfStream()
130
+ */
131
+ void setFirstPageOfStream(bool first);
132
+
133
+ /*!
134
+ * This returns true if this is the last page of the Ogg (logical) stream.
135
+ *
136
+ * \see setLastPageOfStream()
137
+ */
138
+ bool lastPageOfStream() const;
139
+
140
+ /*!
141
+ * Marks this page as the last page of the Ogg stream.
142
+ *
143
+ * \see lastPageOfStream()
144
+ */
145
+ void setLastPageOfStream(bool last);
146
+
147
+ /*!
148
+ * A special value of containing the position of the packet to be
149
+ * interpreted by the codec. In the case of Vorbis this contains the PCM
150
+ * value and is used to calculate the length of the stream.
151
+ *
152
+ * \see setAbsoluteGranularPosition()
153
+ */
154
+ long long absoluteGranularPosition() const;
155
+
156
+ /*!
157
+ * A special value of containing the position of the packet to be
158
+ * interpreted by the codec. It is only supported here so that it may be
159
+ * coppied from one page to another.
160
+ *
161
+ * \see absoluteGranularPosition()
162
+ */
163
+ void setAbsoluteGranularPosition(long long agp);
164
+
165
+ /*!
166
+ * Every Ogg logical stream is given a random serial number which is common
167
+ * to every page in that logical stream. This returns the serial number of
168
+ * the stream associated with this packet.
169
+ *
170
+ * \see setStreamSerialNumber()
171
+ */
172
+ uint streamSerialNumber() const;
173
+
174
+ /*!
175
+ * Every Ogg logical stream is given a random serial number which is common
176
+ * to every page in that logical stream. This sets this pages serial
177
+ * number. This method should be used when adding new pages to a logical
178
+ * stream.
179
+ *
180
+ * \see streamSerialNumber()
181
+ */
182
+ void setStreamSerialNumber(uint n);
183
+
184
+ /*!
185
+ * Returns the index of the page within the Ogg stream. This helps make it
186
+ * possible to determine if pages have been lost.
187
+ *
188
+ * \see setPageSequenceNumber()
189
+ */
190
+ int pageSequenceNumber() const;
191
+
192
+ /*!
193
+ * Sets the page's position in the stream to \a sequenceNumber.
194
+ *
195
+ * \see pageSequenceNumber()
196
+ */
197
+ void setPageSequenceNumber(int sequenceNumber);
198
+
199
+ /*!
200
+ * Returns the complete header size.
201
+ */
202
+ int size() const;
203
+
204
+ /*!
205
+ * Returns the size of the data portion of the page -- i.e. the size of the
206
+ * page less the header size.
207
+ */
208
+ int dataSize() const;
209
+
210
+ /*!
211
+ * Render the page header to binary data.
212
+ *
213
+ * \note The checksum -- bytes 22 - 25 -- will be left empty and must be
214
+ * filled in when rendering the entire page.
215
+ */
216
+ ByteVector render() const;
217
+
218
+ private:
219
+ PageHeader(const PageHeader &);
220
+ PageHeader &operator=(const PageHeader &);
221
+
222
+ void read();
223
+ ByteVector lacingValues() const;
224
+
225
+ class PageHeaderPrivate;
226
+ PageHeaderPrivate *d;
227
+ };
228
+
229
+ }
230
+ }
231
+
232
+ #endif
@@ -0,0 +1,274 @@
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_RELATIVEVOLUMEFRAME_H
27
+ #define TAGLIB_RELATIVEVOLUMEFRAME_H
28
+
29
+ #include <tlist.h>
30
+ #include <id3v2frame.h>
31
+ #include "taglib_export.h"
32
+
33
+ namespace TagLib {
34
+
35
+ namespace ID3v2 {
36
+
37
+ //! An ID3v2 relative volume adjustment frame implementation
38
+
39
+ /*!
40
+ * This is an implementation of ID3v2 relative volume adjustment. The
41
+ * presence of this frame makes it possible to specify an increase in volume
42
+ * for an audio file or specific audio tracks in that file.
43
+ *
44
+ * Multiple relative volume adjustment frames may be present in the tag
45
+ * each with a unique identification and describing volume adjustment for
46
+ * different channel types.
47
+ */
48
+
49
+ class TAGLIB_EXPORT RelativeVolumeFrame : public Frame
50
+ {
51
+ friend class FrameFactory;
52
+
53
+ public:
54
+
55
+ /*!
56
+ * This indicates the type of volume adjustment that should be applied.
57
+ */
58
+ enum ChannelType {
59
+ //! A type not enumerated below
60
+ Other = 0x00,
61
+ //! The master volume for the track
62
+ MasterVolume = 0x01,
63
+ //! The front right audio channel
64
+ FrontRight = 0x02,
65
+ //! The front left audio channel
66
+ FrontLeft = 0x03,
67
+ //! The back right audio channel
68
+ BackRight = 0x04,
69
+ //! The back left audio channel
70
+ BackLeft = 0x05,
71
+ //! The front center audio channel
72
+ FrontCentre = 0x06,
73
+ //! The back center audio channel
74
+ BackCentre = 0x07,
75
+ //! The subwoofer audio channel
76
+ Subwoofer = 0x08
77
+ };
78
+
79
+ //! Struct that stores the relevant values for ID3v2 peak volume
80
+
81
+ /*!
82
+ * The peak volume is described as a series of bits that is padded to fill
83
+ * a block of bytes. These two values should always be updated in tandem.
84
+ */
85
+ struct PeakVolume
86
+ {
87
+ /*!
88
+ * Constructs an empty peak volume description.
89
+ */
90
+ PeakVolume() : bitsRepresentingPeak(0) {}
91
+ /*!
92
+ * The number of bits (in the range of 0 to 255) used to describe the
93
+ * peak volume.
94
+ */
95
+ unsigned char bitsRepresentingPeak;
96
+ /*!
97
+ * The array of bits (represented as a series of bytes) used to describe
98
+ * the peak volume.
99
+ */
100
+ ByteVector peakVolume;
101
+ };
102
+
103
+ /*!
104
+ * Constructs a RelativeVolumeFrame. The relevant data should be set
105
+ * manually.
106
+ */
107
+ RelativeVolumeFrame();
108
+
109
+ /*!
110
+ * Constructs a RelativeVolumeFrame based on the contents of \a data.
111
+ */
112
+ RelativeVolumeFrame(const ByteVector &data);
113
+
114
+ /*!
115
+ * Destroys the RelativeVolumeFrame instance.
116
+ */
117
+ virtual ~RelativeVolumeFrame();
118
+
119
+ /*!
120
+ * Returns the frame's identification.
121
+ *
122
+ * \see identification()
123
+ */
124
+ virtual String toString() const;
125
+
126
+ /*!
127
+ * Returns a list of channels with information currently in the frame.
128
+ */
129
+ List<ChannelType> channels() const;
130
+
131
+ /*!
132
+ * \deprecated Always returns master volume.
133
+ */
134
+ ChannelType channelType() const;
135
+
136
+ /*!
137
+ * \deprecated This method no longer has any effect.
138
+ */
139
+ void setChannelType(ChannelType t);
140
+
141
+ /*
142
+ * There was a terrible API goof here, and while this can't be changed to
143
+ * the way it appears below for binary compaibility reasons, let's at
144
+ * least pretend that it looks clean.
145
+ */
146
+
147
+ #ifdef DOXYGEN
148
+
149
+ /*!
150
+ * Returns the relative volume adjustment "index". As indicated by the
151
+ * ID3v2 standard this is a 16-bit signed integer that reflects the
152
+ * decibils of adjustment when divided by 512.
153
+ *
154
+ * This defaults to returning the value for the master volume channel if
155
+ * available and returns 0 if the specified channel does not exist.
156
+ *
157
+ * \see setVolumeAdjustmentIndex()
158
+ * \see volumeAjustment()
159
+ */
160
+ short volumeAdjustmentIndex(ChannelType type = MasterVolume) const;
161
+
162
+ /*!
163
+ * Set the volume adjustment to \a index. As indicated by the ID3v2
164
+ * standard this is a 16-bit signed integer that reflects the decibils of
165
+ * adjustment when divided by 512.
166
+ *
167
+ * By default this sets the value for the master volume.
168
+ *
169
+ * \see volumeAdjustmentIndex()
170
+ * \see setVolumeAjustment()
171
+ */
172
+ void setVolumeAdjustmentIndex(short index, ChannelType type = MasterVolume);
173
+
174
+ /*!
175
+ * Returns the relative volume adjustment in decibels.
176
+ *
177
+ * \note Because this is actually stored internally as an "index" to this
178
+ * value the value returned by this method may not be identical to the
179
+ * value set using setVolumeAdjustment().
180
+ *
181
+ * This defaults to returning the value for the master volume channel if
182
+ * available and returns 0 if the specified channel does not exist.
183
+ *
184
+ * \see setVolumeAdjustment()
185
+ * \see volumeAdjustmentIndex()
186
+ */
187
+ float volumeAdjustment(ChannelType type = MasterVolume) const;
188
+
189
+ /*!
190
+ * Set the relative volume adjustment in decibels to \a adjustment.
191
+ *
192
+ * By default this sets the value for the master volume.
193
+ *
194
+ * \note Because this is actually stored internally as an "index" to this
195
+ * value the value set by this method may not be identical to the one
196
+ * returned by volumeAdjustment().
197
+ *
198
+ * \see setVolumeAdjustment()
199
+ * \see volumeAdjustmentIndex()
200
+ */
201
+ void setVolumeAdjustment(float adjustment, ChannelType type = MasterVolume);
202
+
203
+ /*!
204
+ * Returns the peak volume (represented as a length and a string of bits).
205
+ *
206
+ * This defaults to returning the value for the master volume channel if
207
+ * available and returns 0 if the specified channel does not exist.
208
+ *
209
+ * \see setPeakVolume()
210
+ */
211
+ PeakVolume peakVolume(ChannelType type = MasterVolume) const;
212
+
213
+ /*!
214
+ * Sets the peak volume to \a peak.
215
+ *
216
+ * By default this sets the value for the master volume.
217
+ *
218
+ * \see peakVolume()
219
+ */
220
+ void setPeakVolume(const PeakVolume &peak, ChannelType type = MasterVolume);
221
+
222
+ #else
223
+
224
+ // BIC: Combine each of the following pairs of functions (or maybe just
225
+ // rework this junk altogether).
226
+
227
+ short volumeAdjustmentIndex(ChannelType type) const;
228
+ short volumeAdjustmentIndex() const;
229
+
230
+ void setVolumeAdjustmentIndex(short index, ChannelType type);
231
+ void setVolumeAdjustmentIndex(short index);
232
+
233
+ float volumeAdjustment(ChannelType type) const;
234
+ float volumeAdjustment() const;
235
+
236
+ void setVolumeAdjustment(float adjustment, ChannelType type);
237
+ void setVolumeAdjustment(float adjustment);
238
+
239
+ PeakVolume peakVolume(ChannelType type) const;
240
+ PeakVolume peakVolume() const;
241
+
242
+ void setPeakVolume(const PeakVolume &peak, ChannelType type);
243
+ void setPeakVolume(const PeakVolume &peak);
244
+
245
+ #endif
246
+
247
+ /*!
248
+ * Returns the identification for this frame.
249
+ */
250
+ String identification() const;
251
+
252
+ /*!
253
+ * Sets the identification of the frame to \a s. The string
254
+ * is used to identify the situation and/or device where this
255
+ * adjustment should apply.
256
+ */
257
+ void setIdentification(const String &s);
258
+
259
+ protected:
260
+ virtual void parseFields(const ByteVector &data);
261
+ virtual ByteVector renderFields() const;
262
+
263
+ private:
264
+ RelativeVolumeFrame(const ByteVector &data, Header *h);
265
+ RelativeVolumeFrame(const RelativeVolumeFrame &);
266
+ RelativeVolumeFrame &operator=(const RelativeVolumeFrame &);
267
+
268
+ class RelativeVolumeFramePrivate;
269
+ RelativeVolumeFramePrivate *d;
270
+ };
271
+
272
+ }
273
+ }
274
+ #endif