1 // Copyright (c) 2006-2008 Andreas Kloeckner
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 // IN THE SOFTWARE.
20 
21 
22 
23 
24 #include <taglib/apetag.h>
25 #include <taglib/mpcfile.h>
26 #include <taglib/flacfile.h>
27 #include <taglib/xiphcomment.h>
28 #include <taglib/oggflacfile.h>
29 #include <taglib/vorbisfile.h>
30 #include <taglib/apefooter.h>
31 #include <taglib/apeitem.h>
32 #include <taglib/id3v1tag.h>
33 #include <taglib/id3v2tag.h>
34 
35 #include "common.hpp"
36 
37 
38 
39 
40 namespace
41 {
42   // -------------------------------------------------------------
43   // FLAC
44   // -------------------------------------------------------------
45   MF_OL(ID3v1Tag, 0, 1);
46   MF_OL(ID3v2Tag, 0, 1);
47   MF_OL(xiphComment, 0, 1);
48 
49   // -------------------------------------------------------------
50   // Ogg
51   // -------------------------------------------------------------
52   MF_OL(addField, 2, 3);
53   MF_OL(removeField, 1, 2);
54   MF_OL(render, 0, 1);
55 
56   // -------------------------------------------------------------
57   // APE
58   // -------------------------------------------------------------
59   MF_OL(addValue, 2, 3);
60 
61   // -------------------------------------------------------------
62   // MPC
63   // -------------------------------------------------------------
64   MF_OL(remove, 0, 1);
65   //MF_OL(ID3v1Tag, 0, 1);
66   MF_OL(APETag, 0, 1);
67 }
68 
69 
70 
71 
72 
exposeRest()73 void exposeRest()
74 {
75   // -------------------------------------------------------------
76   // Ogg
77   // -------------------------------------------------------------
78   exposeMap<String, StringList>("ogg_FieldListMap");
79 
80   {
81     typedef Ogg::XiphComment cl;
82     class_<cl, bases<Tag>, boost::noncopyable>
83       ("ogg_XiphComment", init<optional<const ByteVector &> >())
84       .DEF_SIMPLE_METHOD(fieldCount)
85       .def("fieldListMap", &cl::fieldListMap,
86            return_internal_reference<>())
87       .DEF_SIMPLE_METHOD(vendorID)
88       .DEF_OVERLOADED_METHOD(addField, void (cl::*)(const String &, const String &, bool))
89       .DEF_OVERLOADED_METHOD(removeField, void (cl::*)(const String &, const String &))
90       .DEF_OVERLOADED_METHOD(removeField, void (cl::*)(const String &, const String &))
91       .DEF_OVERLOADED_METHOD(render, ByteVector (cl::*)(bool) const)
92       ;
93   }
94 
95   {
96     typedef Ogg::File cl;
97     class_<cl, bases<File>, boost::noncopyable>
98       ("ogg_File", no_init)
99       .DEF_SIMPLE_METHOD(packet)
100       .DEF_SIMPLE_METHOD(setPacket)
101       // MISSING: page headers
102       ;
103   }
104 
105   {
106     typedef Ogg::FLAC::File cl;
107     class_<cl, bases<Ogg::File>, boost::noncopyable>
108       ("ogg_flac_File", init<const char *, optional<bool, AudioProperties::ReadStyle> >())
109       ;
110   }
111 
112   {
113     typedef Ogg::Vorbis::File cl;
114     class_<cl, bases<Ogg::File>, boost::noncopyable>
115       ("ogg_vorbis_File", init<const char *, optional<bool, AudioProperties::ReadStyle> >())
116       ;
117   }
118 
119   // -------------------------------------------------------------
120   // APE
121   // -------------------------------------------------------------
122   {
123     typedef APE::Footer cl;
124     class_<cl, boost::noncopyable>(
125       "ape_Footer", init<optional<const ByteVector &> >())
126       .DEF_SIMPLE_METHOD(version)
127       .DEF_SIMPLE_METHOD(headerPresent)
128       .DEF_SIMPLE_METHOD(footerPresent)
129       .DEF_SIMPLE_METHOD(isHeader)
130       .DEF_SIMPLE_METHOD(setHeaderPresent)
131       .DEF_SIMPLE_METHOD(itemCount)
132       .DEF_SIMPLE_METHOD(setItemCount)
133       .DEF_SIMPLE_METHOD(tagSize)
134       .DEF_SIMPLE_METHOD(completeTagSize)
135       .DEF_SIMPLE_METHOD(setTagSize)
136       .DEF_SIMPLE_METHOD(setData)
137       .DEF_SIMPLE_METHOD(renderFooter)
138       .DEF_SIMPLE_METHOD(renderHeader)
139       ;
140   }
141 
142   {
143     typedef APE::Item scope;
144     enum_<scope::ItemTypes>("ape_ItemTypes")
145       .ENUM_VALUE(Text)
146       .ENUM_VALUE(Binary)
147       .ENUM_VALUE(Locator)
148       ;
149   }
150 
151   {
152     typedef APE::Item cl;
153     class_<cl>("ape_Item")
154       .def(init<const String &, const String &>())
155       .def(init<const String &, const StringList &>())
156       .def(init<const cl &>())
157       .DEF_SIMPLE_METHOD(key)
158       .DEF_SIMPLE_METHOD(value)
159       .DEF_SIMPLE_METHOD(size)
160       .DEF_SIMPLE_METHOD(toString)
161       .DEF_SIMPLE_METHOD(toStringList)
162       .DEF_SIMPLE_METHOD(render)
163       .DEF_SIMPLE_METHOD(parse)
164       .DEF_SIMPLE_METHOD(setReadOnly)
165       .DEF_SIMPLE_METHOD(isReadOnly)
166       .DEF_SIMPLE_METHOD(setType)
167       .DEF_SIMPLE_METHOD(type)
168       .DEF_SIMPLE_METHOD(isEmpty)
169       ;
170   }
171 
172   exposeMap<const String, APE::Item>("ape_ItemListMap");
173 
174   {
175     typedef APE::Tag cl;
176     class_<cl, bases<Tag>, boost::noncopyable>("ape_Tag")
177       .def(init<File *, long>())
178       .def("footer", &cl::footer, return_internal_reference<>())
179       .def("itemListMap", &cl::itemListMap, return_internal_reference<>())
180       .DEF_SIMPLE_METHOD(removeItem)
181       .DEF_OVERLOADED_METHOD(addValue, void (cl::*)(const String &, const String &,bool))
182       .DEF_SIMPLE_METHOD(setItem)
183       ;
184   }
185 
186   // -------------------------------------------------------------
187   // FLAC
188   // -------------------------------------------------------------
189   {
190     typedef FLAC::File cl;
191     class_<cl, boost::noncopyable, bases<File> >("flac_File",
192                                    init<const char *, optional<bool, AudioProperties::ReadStyle> >())
193       .def(init<const char *, ID3v2::FrameFactory *, optional<bool, AudioProperties::ReadStyle> >())
194       .def("ID3v1Tag",
195            (ID3v1::Tag *(FLAC::File::*)(bool))
196            &FLAC::File::ID3v1Tag,
197            ID3v1Tag_overloads()[return_internal_reference<>()])
198       .def("ID3v2Tag",
199            (ID3v2::Tag *(FLAC::File::*)(bool))
200            &FLAC::File::ID3v2Tag,
201            ID3v2Tag_overloads()[return_internal_reference<>()])
202       .def("xiphComment",
203            (Ogg::XiphComment *(FLAC::File::*)(bool))
204            &FLAC::File::xiphComment,
205            xiphComment_overloads()[return_internal_reference<>()])
206       .DEF_SIMPLE_METHOD(setID3v2FrameFactory)
207       .DEF_SIMPLE_METHOD(streamInfoData)
208       .DEF_SIMPLE_METHOD(streamLength)
209       ;
210   }
211 
212   // -------------------------------------------------------------
213   // MPC
214   // -------------------------------------------------------------
215   enum_<MPC::File::TagTypes>("mpc_TagTypes")
216     .value("NoTags", MPC::File::NoTags)
217     .value("ID3v1", MPC::File::ID3v1)
218     .value("ID3v2", MPC::File::ID3v2)
219     .value("APE", MPC::File::APE)
220     .value("AllTags", MPC::File::AllTags)
221     ;
222 
223   {
224     typedef MPC::File cl;
225     class_<MPC::File, bases<File>, boost::noncopyable>
226       ("mpc_File", init<const char *, optional<bool, AudioProperties::ReadStyle> >())
227       .def("ID3v1Tag",
228            (ID3v1::Tag *(cl::*)(bool))
229            &cl::ID3v1Tag,
230            ID3v1Tag_overloads()[return_internal_reference<>()])
231       .def("APETag",
232            (APE::Tag *(cl::*)(bool))
233            &cl::APETag,
234            APETag_overloads()[return_internal_reference<>()])
235       .def("remove",
236            (void (cl::*)(int))
237            &cl::remove,
238            remove_overloads())
239       ;
240   }
241 }
242 
243 
244 
245 
246 // EMACS-FORMAT-TAG
247 //
248 // Local Variables:
249 // mode: C++
250 // eval: (c-set-style "stroustrup")
251 // eval: (c-set-offset 'access-label -2)
252 // eval: (c-set-offset 'inclass '++)
253 // c-basic-offset: 2
254 // tab-width: 8
255 // End:
256