rtaglib 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+
6
+
7
+ task :default => [:compile,:test,:copy]
8
+
9
+ task :compile => ["taglib.so"]
10
+
11
+ task :test => ["taglib.so"] do |t|
12
+ system %(ruby "test.rb")
13
+ end
14
+ task :copy => [:test] do |t|
15
+ system %(cp extconf.rb taglib.cxx ../ext/taglib/)
16
+ system %(cp test.rb ../test/test_taglib.rb)
17
+ end
18
+ file "taglib.so" => ["taglib.cxx","Makefile"] do |t|
19
+ system %(make)
20
+ end
21
+
22
+ file "taglib.cxx" => ["taglib.i"] do |t|
23
+ puts "Actualizando swig"
24
+ if
25
+ !system %(swig -fvirtual -Wall -c++ -o taglib.cxx -ruby taglib.i)
26
+ system %(rm *.o *.so *.cxx)
27
+ end
28
+ end
29
+
30
+ file "Makefile" => ["extconf.rb"] do |t|
31
+ system %(ruby "extconf.rb")
32
+ end
33
+
@@ -0,0 +1,6 @@
1
+ require 'mkmf'
2
+ $libs = append_library($libs, "supc++")
3
+ $CFLAGS= " -I/usr/include/taglib"
4
+ if have_library("tag")
5
+ create_makefile("taglib")
6
+ end
@@ -0,0 +1,817 @@
1
+ %module taglib
2
+ %{
3
+ #include "taglib/tlist.h"
4
+ #include "taglib/fileref.h"
5
+ #include "taglib/id3v1tag.h"
6
+ #include "taglib/id3v1genres.h"
7
+
8
+
9
+ #include "taglib/id3v2tag.h"
10
+ #include "taglib/attachedpictureframe.h"
11
+ #include "taglib/commentsframe.h"
12
+ #include <taglib/xingheader.h>
13
+
14
+ #include "taglib/apefooter.h"
15
+ #include "taglib/apetag.h"
16
+ #include "taglib/apeitem.h"
17
+
18
+ #include "taglib/mpcfile.h"
19
+ #include "taglib/mpcproperties.h"
20
+
21
+
22
+
23
+ #include "taglib/flacfile.h"
24
+ #include "taglib/flacproperties.h"
25
+
26
+ #include <taglib/oggpage.h>
27
+ #include <taglib/oggpageheader.h>
28
+ #include <taglib/oggflacfile.h>
29
+ #include <taglib/speexfile.h>
30
+ #include <taglib/speexproperties.h>
31
+
32
+
33
+
34
+ #include "taglib/vorbisfile.h"
35
+ #include "taglib/vorbisproperties.h"
36
+
37
+ #include "taglib/xiphcomment.h"
38
+ #include "taglib/mpegfile.h"
39
+
40
+
41
+ #include "taglib/trueaudiofile.h"
42
+ #include "taglib/trueaudioproperties.h"
43
+
44
+
45
+ #include "taglib/wavpackfile.h"
46
+ #include "taglib/wavpackproperties.h"
47
+
48
+ %}
49
+
50
+ %inline %{
51
+ typedef wchar_t wchar;
52
+ typedef unsigned char uchar;
53
+ typedef unsigned int uint;
54
+ typedef unsigned long ulong;
55
+ typedef std::basic_string< wchar > wstring;
56
+ typedef const char * FileName;
57
+ %}
58
+
59
+ %{
60
+ VALUE StringList2Ruby(TagLib::StringList st) {
61
+ VALUE ary=Qnil;
62
+ if(st.size()>0) {
63
+ ary=rb_ary_new2(st.size());
64
+ for(uint i=0;i<(st.size());i++) {
65
+ TagLib::String &rst=st.operator[](i);
66
+ const char* ch=rst.toCString(true);
67
+ rb_ary_push(ary, rb_tainted_str_new2(ch));
68
+ }
69
+ }
70
+ return ary;
71
+ }
72
+ %}
73
+
74
+
75
+ %define MAP_HELPERS(TYPE,FUNC)
76
+ %extend Map<TagLib::String, TYPE> {
77
+ VALUE __getitem__(TagLib::String &item) {
78
+ if($self->contains(item)) {
79
+ return FUNC($self->operator[](item));
80
+ } else {
81
+ return Qnil;
82
+ }
83
+ }
84
+ VALUE __hash__() {
85
+ uint i;
86
+ VALUE hash=rb_hash_new();
87
+ for(std::map<TagLib::String,TYPE>::const_iterator it=$self->begin(); it!=$self->end();it++) {
88
+ VALUE key=rb_tainted_str_new2(it->first.toCString(true));
89
+ VALUE ary=FUNC(it->second);
90
+ rb_hash_aset(hash,key,ary);
91
+ }
92
+ return hash;
93
+ }
94
+ }
95
+ %enddef
96
+
97
+ %define FILE_VIRTUALS()
98
+ virtual ~File();
99
+ virtual Tag * tag () const;
100
+ virtual Properties * audioProperties () const;
101
+ virtual bool save ();
102
+ %enddef
103
+
104
+ %define PROPERTIES_VIRTUALS()
105
+ virtual int length () const;
106
+ virtual int bitrate () const;
107
+ virtual int sampleRate () const;
108
+ virtual int channels () const;
109
+ %enddef
110
+
111
+ %define TAG_VIRTUALS()
112
+ %alias setTitle "title="
113
+ %alias setArtist "artist="
114
+ %alias setAlbum "album="
115
+ %alias setComment "comment="
116
+ %alias setGenre "genre="
117
+ %alias setYear "year="
118
+ %alias setTrack "track="
119
+ %alias isEmpty "empty?"
120
+ virtual ~Tag();
121
+ virtual String title() const;
122
+ virtual String artist() const;
123
+ virtual String album() const;
124
+ virtual String comment() const;
125
+ virtual String genre() const;
126
+ virtual uint year() const;
127
+ virtual uint track() ;
128
+ virtual void setTitle(const String & s);
129
+ virtual void setArtist(const String & s);
130
+ virtual void setAlbum(const String & s);
131
+ virtual void setComment(const String & s);
132
+ virtual void setGenre(const String & s);
133
+ virtual void setYear(uint i);
134
+ virtual void setTrack(uint i);
135
+ virtual bool isEmpty();
136
+ %enddef
137
+
138
+
139
+
140
+ namespace TagLib {
141
+
142
+ //rename(TagLib_File) File;
143
+
144
+
145
+ %typemap(in) TagLib::StringList & {
146
+ TagLib::StringList *sl=new TagLib::StringList();
147
+ for(long i=0;i<RARRAY_LEN($input);i++) {
148
+ SafeStringValue(RARRAY_PTR($input)[i]);
149
+ TagLib::String ntl=TagLib::String(StringValuePtr(RARRAY_PTR($input)[i]));
150
+ sl->append(ntl);
151
+ }
152
+ $1=sl;
153
+ };
154
+
155
+
156
+ %typemap(out) TagLib::StringList &{
157
+ $result=StringList2Ruby($1);
158
+ }
159
+
160
+ %typemap(out) TagLib::StringList {
161
+ $result=StringList2Ruby($1);
162
+ }
163
+
164
+ %apply TagLib::StringList & {TagLib::StringList const &};
165
+
166
+
167
+ %typemap(out) String {
168
+ $result = rb_tainted_str_new2($1.toCString(true));
169
+ };
170
+
171
+ %typemap(in) String {
172
+ $1=new TagLib::String(StringValuePtr($input));
173
+ };
174
+
175
+
176
+ %apply String {String &, const String &};
177
+
178
+ %typemap(in) ByteVector {
179
+ $1=new TagLib::ByteVector(StringValuePtr($input), RSTRING_LEN($input));
180
+ };
181
+
182
+ %typemap(out) ByteVector {
183
+ $result = rb_tainted_str_new($1.data(),$1.size());
184
+ };
185
+
186
+ %apply ByteVector {ByteVector &, const ByteVector &};
187
+
188
+ class AudioProperties {
189
+ AudioProperties(ReadStyle style);
190
+ virtual ~AudioProperties();
191
+
192
+ public:
193
+ enum ReadStyle {
194
+ Fast,Average,Accurate};
195
+ PROPERTIES_VIRTUALS()
196
+ };
197
+ class String {
198
+
199
+ enum Type {
200
+ Latin1 = 0, UTF16 = 1, UTF16BE = 2, UTF8 = 3,
201
+ UTF16LE = 4
202
+ };
203
+ public:
204
+ String();
205
+ String(const char *s, Type t=Latin1);
206
+ ~String();
207
+ const char* toCString();
208
+
209
+ };
210
+ class Tag {
211
+ protected:
212
+ Tag();
213
+ public:
214
+ TAG_VIRTUALS()
215
+ };
216
+ class ByteVector {
217
+ public:
218
+ ByteVector(const char *data, uint length);
219
+ ByteVector(const char *data);
220
+ ~ByteVector();
221
+ uint size();
222
+ const char * data () const;
223
+ %extend {
224
+ const char * __str__() {
225
+ return $self->data();
226
+ }
227
+ }
228
+ };
229
+
230
+ class File {
231
+ protected:
232
+ File(FileName file);
233
+ void setValid (bool valid);
234
+ void truncate (long length);
235
+ public:
236
+ %alias readOnly "read_only?"
237
+ %alias isWritable "writable?"
238
+ %alias isOpen "open?"
239
+ %alias isValid "valid?"
240
+
241
+ enum Position { Beginning, Current, End };
242
+ FileName name() const;
243
+ virtual ~File ();
244
+ virtual Tag * tag () const;
245
+ virtual AudioProperties * audioProperties () const;
246
+ virtual bool save ();
247
+ ByteVector readBlock (ulong length);
248
+ void writeBlock (const ByteVector &data);
249
+
250
+
251
+ %rename(find3) find(const ByteVector &pattern, long fromOffset, const ByteVector &before);
252
+ %rename(find2) find(const ByteVector &pattern, long fromOffset);
253
+ %rename(find1) find(const ByteVector &pattern);
254
+
255
+ long find(const ByteVector &pattern);
256
+ long find(const ByteVector &pattern, long fromOffset = 0);
257
+ long find(const ByteVector &pattern, long fromOffset=0, const ByteVector &before=ByteVector::null);
258
+
259
+ long rfind (const ByteVector &pattern, long fromOffset=0, const ByteVector &before=ByteVector::null);
260
+ void insert (const ByteVector &data, ulong start=0, ulong replace=0);
261
+ void removeBlock (ulong start=0, ulong length=0);
262
+ bool readOnly () const;
263
+ bool isOpen () const;
264
+ bool isValid () const;
265
+ void seek (long offset, Position p=Beginning);
266
+ void clear ();
267
+ long tell () const;
268
+ long length ();
269
+ %extend {
270
+ bool isWritable() {
271
+ return !$self->readOnly();
272
+ }
273
+ }
274
+ };
275
+
276
+
277
+
278
+
279
+ template<class T> class List {
280
+ public:
281
+ List ();
282
+ List (const List< T > &l);
283
+ virtual ~List ();
284
+ uint size () const;
285
+ bool isEmpty () const;
286
+ bool contains (const T &value) const ;
287
+ };
288
+
289
+
290
+
291
+
292
+
293
+ template<class Key, class T> class Map {
294
+ public:
295
+ %alias isEmpty "empty?"
296
+ Map();
297
+ template <class Key,class T> Map(const Map< Key, T > &m);
298
+ ~Map();
299
+ Map<Key,T>& insert( const Key&, const T &);
300
+ Map<Key,T>& clear();
301
+ uint size();
302
+ %predicate Map::isEmpty();
303
+ bool isEmpty();
304
+ %predicate Map::contains();
305
+ bool contains (const Key &key);
306
+ %extend {
307
+ uint __len__() {
308
+ return $self->size();
309
+ }
310
+ }
311
+
312
+ };
313
+ // Helpers for FieldListMap
314
+ MAP_HELPERS(TagLib::StringList,StringList2Ruby)
315
+ // Helpers for GenreMap
316
+ MAP_HELPERS(int,INT2FIX)
317
+
318
+
319
+ %template (FieldListMap) Map<TagLib::String, TagLib::StringList>;
320
+ %template (ItemListMap) Map<TagLib::String, TagLib::APE::Item>;
321
+ %template (GenreMap) Map<TagLib::String, int>;
322
+ %template (FrameListMap) Map < TagLib::ByteVector, TagLib::ID3v2::FrameList >;
323
+
324
+ %template (StringList) List< TagLib::String >;
325
+ %template (ByteVectorList) List<TagLib::ByteVector>;
326
+ %template (FrameList) List< TagLib::ID3v2::Frame * >;
327
+
328
+ typedef List<TagLib::ByteVector> ByteVectorList;
329
+ typedef List<TagLib::String> StringList;
330
+
331
+ class FileRef {
332
+ public:
333
+ static StringList defaultFileExtensions ();
334
+ %alias isNull "null?"
335
+ FileRef(FileName fileName, bool readAudioProperties = true, AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average);
336
+ ~FileRef();
337
+ Tag* tag();
338
+ AudioProperties* audioProperties();
339
+ File* file();
340
+ bool save();
341
+ bool isNull();
342
+
343
+ };
344
+
345
+
346
+ namespace APE {
347
+ typedef Map<TagLib::String,TagLib::APE::Item> ItemListMap;
348
+
349
+ %rename(TagLib_APE_Tag) Tag;
350
+ %rename(TagLib_APE_Footer) Footer;
351
+
352
+ class Footer {
353
+ public:
354
+ Footer ();
355
+ Footer (const ByteVector &data);
356
+ virtual ~Footer ();
357
+ uint version () const;
358
+ bool headerPresent () const;
359
+ bool footerPresent () const;
360
+ bool isHeader () const;
361
+ void setHeaderPresent (bool b) const;
362
+ uint itemCount () const;
363
+ void setItemCount (uint s);
364
+ uint tagSize () const;
365
+ uint completeTagSize () const;
366
+ void setTagSize (uint s);
367
+ void setData (const ByteVector &data);
368
+ ByteVector renderFooter () const;
369
+ ByteVector renderHeader () const ;
370
+ };
371
+
372
+ class Item {
373
+ public:
374
+ enum ItemTypes { Text = 0, Binary = 1, Locator = 2 };
375
+ Item ();
376
+ Item (const String &key, const String &value);
377
+ Item (const String &key, const StringList &values);
378
+ Item (const Item &item);
379
+ virtual ~Item ();
380
+ //Item & operator= (const Item &item);
381
+ String key () const;
382
+ ByteVector value () const;
383
+ void setKey (const String &key);
384
+ void setValue (const String &value);
385
+ void setValues (const StringList &values);
386
+ void appendValue (const String &value);
387
+ void appendValues (const StringList &values);
388
+ int size () const;
389
+ String toString () const;
390
+ StringList toStringList () const;
391
+ StringList values () const;
392
+ ByteVector render () const;
393
+ void parse (const ByteVector &data);
394
+ void setReadOnly (bool readOnly);
395
+ bool isReadOnly () const;
396
+ void setType (ItemTypes type);
397
+ ItemTypes type () const;
398
+ bool isEmpty () const;
399
+ };
400
+
401
+ class Tag : public TagLib::Tag {
402
+ public:
403
+ Tag();
404
+ Tag (File *file, long footerLocation);
405
+
406
+ ByteVector render();
407
+ TAG_VIRTUALS()
408
+ Footer * footer () const;
409
+ const ItemListMap & itemListMap () const;
410
+ void removeItem (const String &key);
411
+ void addValue (const String &key, const String &value, bool replace=true);
412
+ void setItem (const String &key, const Item &item);
413
+
414
+
415
+ };
416
+ };
417
+
418
+
419
+
420
+
421
+
422
+
423
+ namespace Ogg {
424
+
425
+ typedef Map<TagLib::String,TagLib::StringList> FieldListMap;
426
+
427
+ %rename(Ogg_XiphComment) XiphComment;
428
+ %rename(Ogg_Page) Page;
429
+ %rename(Ogg_PageHeader) PageHeader;
430
+ %rename(Ogg_File) File;
431
+
432
+ class PageHeader {
433
+ public:
434
+ PageHeader (TagLib::Ogg::File *file=0, long pageOffset=-1);
435
+ virtual ~PageHeader ();
436
+ bool isValid () const;
437
+ List< int > packetSizes () const;
438
+ void setPacketSizes (const List< int > &sizes);
439
+ bool firstPacketContinued () const;
440
+ void setFirstPacketContinued (bool continued);
441
+ bool lastPacketCompleted () const;
442
+ void setLastPacketCompleted (bool completed);
443
+ bool firstPageOfStream () const;
444
+ void setFirstPageOfStream (bool first);
445
+ bool lastPageOfStream () const;
446
+ void setLastPageOfStream (bool last);
447
+ long long absoluteGranularPosition () const;
448
+ void setAbsoluteGranularPosition (long long agp);
449
+ uint streamSerialNumber () const;
450
+ void setStreamSerialNumber (uint n);
451
+ int pageSequenceNumber () const;
452
+ void setPageSequenceNumber (int sequenceNumber);
453
+ int size () const;
454
+ int dataSize () const;
455
+ ByteVector render () const;
456
+ };
457
+ class Page {
458
+ public:
459
+ enum ContainsPacketFlags { DoesNotContainPacket = 0x0000, CompletePacket = 0x0001, BeginsWithPacket = 0x0002, EndsWithPacket = 0x0004 };
460
+ enum PaginationStrategy { SinglePagePerGroup, Repaginate };
461
+ Page (TagLib::Ogg::File *file, long pageOffset);
462
+ virtual ~Page ();
463
+ long fileOffset () const;
464
+ const PageHeader * header () const;
465
+ int firstPacketIndex () const;
466
+ void setFirstPacketIndex (int index);
467
+ ContainsPacketFlags containsPacket (int index) const;
468
+ uint packetCount () const;
469
+ ByteVectorList packets () const;
470
+ int size () const;
471
+ ByteVector render () const;
472
+
473
+ };
474
+ class File : public TagLib::File {
475
+ protected:
476
+ File (FileName file);
477
+ public:
478
+ virtual ~File ();
479
+ ByteVector packet (uint i);
480
+ void setPacket (uint i, const ByteVector &p);
481
+ const PageHeader * firstPageHeader ();
482
+ const PageHeader * lastPageHeader ();
483
+ virtual bool save ();
484
+ };
485
+ class XiphComment : public TagLib::Tag{
486
+ public:
487
+ XiphComment ();
488
+ XiphComment (const ByteVector &data);
489
+ TAG_VIRTUALS()
490
+ uint fieldCount ();
491
+ const FieldListMap & fieldListMap();
492
+ String vendorID ();
493
+ %ignore addField(const String &key, const String &value);
494
+ void addField (const String &key, const String &value, bool replace=true);
495
+ %ignore removeField(const String &key, const String &value);
496
+ void removeField(const String &key);
497
+ //void removeField(const String &key, const String &value);
498
+
499
+ bool contains (const String &key);
500
+ ByteVector render ();
501
+ ByteVector render (bool addFramingBit);
502
+ };
503
+ namespace FLAC {
504
+ %rename (Ogg_Flac_File) File;
505
+ class File : public TagLib::Ogg::File {
506
+ public:
507
+ File (FileName file, bool readProperties=true, TagLib::AudioProperties::ReadStyle propertiesStyle=Properties::Average);
508
+ virtual ~File ();
509
+ virtual XiphComment * tag () const;
510
+ virtual TagLib::FLAC::Properties * audioProperties () const;
511
+ virtual bool save ();
512
+ long streamLength ();
513
+ };
514
+ };
515
+ namespace Speex {
516
+ %rename (Ogg_Speex_File) File;
517
+ %rename (Ogg_Speex_Properties) Properties;
518
+ class Properties : public TagLib::AudioProperties {
519
+ public:
520
+ Properties (TagLib::Ogg::Speex::File *file, ReadStyle style=Average);
521
+ PROPERTIES_VIRTUALS()
522
+ int speexVersion () const ;
523
+ };
524
+ class File : public TagLib::Ogg::File {
525
+ public:
526
+ File (FileName file, bool readProperties=true, Properties::ReadStyle propertiesStyle=Properties::Average);
527
+ virtual ~File ();
528
+ virtual Ogg::XiphComment * tag () const;
529
+ virtual Properties * audioProperties () const;
530
+ virtual bool save ();
531
+ };
532
+ };
533
+ ;
534
+ }; // end namespace Ogg
535
+ namespace Vorbis {
536
+ %rename(Vorbis_File) File;
537
+ %rename(Vorbis_Properties) Properties;
538
+ class Properties : public TagLib::AudioProperties {
539
+ public:
540
+ Properties(TagLib::Vorbis::File *file, ReadStyle style=Average);
541
+ PROPERTIES_VIRTUALS()
542
+ int vorbisVersion () const;
543
+ int bitrateMaximum () const;
544
+ int bitrateNominal () const;
545
+ int bitrateMinimum () const;
546
+ };
547
+
548
+ class File : public TagLib::Ogg::File {
549
+ File (FileName file, bool readProperties=true, Properties::ReadStyle propertiesStyle=Properties::Average);
550
+ virtual ~File ();
551
+ virtual Ogg::XiphComment * tag () const;
552
+ virtual Properties * audioProperties () const;
553
+ virtual bool save ();
554
+ };
555
+ }
556
+ namespace ID3v1 {
557
+ typedef Map<TagLib::String,int> GenreMap;
558
+ String genre(int index);
559
+ int genreIndex(const String &name);
560
+ StringList genreList();
561
+ GenreMap genreMap();
562
+ %rename(ID3v1_Tag) Tag;
563
+ class Tag : public TagLib::Tag {
564
+ public:
565
+ Tag();
566
+ Tag(File *file, long tagOffset);
567
+ TAG_VIRTUALS()
568
+ ByteVector render() const;
569
+
570
+ };
571
+ };
572
+ namespace ID3v2 {
573
+ %rename(ID3v2_Tag) Tag;
574
+ %rename(ID3v2_Header) Header;
575
+ %rename(ID3v2_CommentsFrame) CommentsFrame;
576
+ %rename(ID3v2_FrameFactory) FrameFactory;
577
+
578
+ typedef List< Frame * >FrameList;
579
+ typedef Map < ByteVector, FrameList > FrameListMap;
580
+ class AttachedPictureFrame {
581
+ public:
582
+ enum Type {
583
+ Other = 0x00, FileIcon = 0x01, OtherFileIcon = 0x02, FrontCover = 0x03,
584
+ BackCover = 0x04, LeafletPage = 0x05, Media = 0x06, LeadArtist = 0x07,
585
+ Artist = 0x08, Conductor = 0x09, Band = 0x0A, Composer = 0x0B,
586
+ Lyricist = 0x0C, RecordingLocation = 0x0D, DuringRecording = 0x0E, DuringPerformance = 0x0F,
587
+ MovieScreenCapture = 0x10, ColouredFish = 0x11, Illustration = 0x12, BandLogo = 0x13,
588
+ PublisherLogo = 0x14
589
+ };
590
+ AttachedPictureFrame ();
591
+ AttachedPictureFrame (const ByteVector &data);
592
+ virtual ~AttachedPictureFrame ();
593
+ virtual String toString () const;
594
+ String::Type textEncoding () const;
595
+ void setTextEncoding (String::Type t);
596
+ String mimeType () const;
597
+ void setMimeType (const String &m);
598
+ Type type () const;
599
+ void setType (Type t);
600
+ String description () const;
601
+ void setDescription (const String &desc);
602
+ ByteVector picture () const;
603
+ void setPicture (const ByteVector &p);
604
+ };
605
+
606
+ class CommentsFrame {
607
+ static CommentsFrame* TagLib::ID3v2::CommentsFrame::findByDescription ( const Tag * tag, const String & d);
608
+ CommentsFrame (String::Type encoding=String::Latin1);
609
+ CommentsFrame (const ByteVector &data);
610
+ virtual ~CommentsFrame ();
611
+ virtual String toString () const;
612
+ ByteVector language () const;
613
+ String description () const;
614
+ String text () const;
615
+ void setLanguage (const ByteVector &languageCode);
616
+ void setDescription (const String &s);
617
+ virtual void setText (const String &s);
618
+ String::Type textEncoding () const;
619
+ void setTextEncoding (String::Type encoding);
620
+ };
621
+ class FrameFactory {
622
+ FrameFactory();
623
+ ~FrameFactory();
624
+ };
625
+ class Header {
626
+ Header();
627
+
628
+ };
629
+ class Tag : public TagLib::Tag {
630
+ public:
631
+ Tag();
632
+ Tag(File *file, long tagOffset, const FrameFactory* factory);
633
+ TAG_VIRTUALS()
634
+ Header *header();
635
+ };
636
+ };
637
+
638
+ namespace FLAC {
639
+ %rename(FLAC_Properties) Properties;
640
+ %rename(FLAC_File) File;
641
+ class Properties : public TagLib::AudioProperties {
642
+ public:
643
+ //Properties(TagLib::ByteVector data, long streamLength, TagLib::AudioProperties::ReadStyle style=Average);
644
+ Properties(TagLib::FLAC::File * file, ReadStyle style = Average);
645
+ virtual ~Properties();
646
+ PROPERTIES_VIRTUALS()
647
+ int sampleWidth();
648
+ };
649
+
650
+ class File : public TagLib::File {
651
+ public:
652
+ File(FileName file, bool readProperties=true, Properties::ReadStyle propertiesStyle=Properties::Average);
653
+ File(FileName file, ID3v2::FrameFactory *frameFactory, bool readProperties=true, Properties::ReadStyle propertiesStyle=Properties::Average);
654
+ FILE_VIRTUALS()
655
+ ID3v2::Tag * ID3v2Tag (bool create=false);
656
+ ID3v1::Tag * ID3v1Tag (bool create=false);
657
+ Ogg::XiphComment * xiphComment (bool create=false);
658
+ void setID3v2FrameFactory (const ID3v2::FrameFactory *factory);
659
+ ByteVector streamInfoData ();
660
+ long streamLength ();
661
+
662
+ };
663
+
664
+ };
665
+
666
+
667
+ namespace MPC {
668
+ %rename(MPC_File) File;
669
+ %rename(MPC_Properties) Properties;
670
+ class Properties : public TagLib::AudioProperties {
671
+ public:
672
+ Properties(const ByteVector &data, long streamLength, ReadStyle style=Average);
673
+ PROPERTIES_VIRTUALS()
674
+ int mpcVersion() const;
675
+ };
676
+
677
+ class File : public TagLib::File {
678
+ public:
679
+
680
+ enum TagTypes {
681
+ NoTags = 0x0000, ID3v1 = 0x0001, ID3v2 = 0x0002, APE = 0x0004, AllTags = 0xffff
682
+ };
683
+
684
+
685
+
686
+ File (FileName file, bool readProperties=true, Properties::ReadStyle propertiesStyle=Properties::Average);
687
+ FILE_VIRTUALS()
688
+ ID3v1::Tag * ID3v1Tag (bool create=false);
689
+ APE::Tag * APETag (bool create=false);
690
+ void strip (int tags=AllTags);
691
+ void remove (int tags=AllTags);
692
+ };
693
+ };
694
+
695
+ namespace TrueAudio {
696
+ %rename(TrueAudio_File) File;
697
+ %rename(TrueAudio_Properties) Properties;
698
+ class Properties : public TagLib::AudioProperties {
699
+ public:
700
+ Properties(const ByteVector &data, long streamLength, ReadStyle style=Average);
701
+ PROPERTIES_VIRTUALS()
702
+ int bitsPerSample () const;
703
+ int ttaVersion () const;
704
+ };
705
+
706
+ class File : public TagLib::File {
707
+ public:
708
+ enum TagTypes { NoTags = 0x0000, ID3v1 = 0x0001, ID3v2 = 0x0002, AllTags = 0xffff };
709
+ File (FileName file, bool readProperties=true, Properties::ReadStyle propertiesStyle=Properties::Average);
710
+ File (FileName file, ID3v2::FrameFactory *frameFactory, bool readProperties=true, Properties::ReadStyle propertiesStyle=Properties::Average);
711
+ FILE_VIRTUALS()
712
+ void setID3v2FrameFactory (const ID3v2::FrameFactory *factory);
713
+ ID3v1::Tag * ID3v1Tag (bool create=false);
714
+ ID3v2::Tag * ID3v2Tag (bool create=false);
715
+ void strip (int tags=AllTags);
716
+ };
717
+ };
718
+
719
+ namespace WavPack {
720
+ %rename(WavPack_File) File;
721
+ %rename(WavPack_Properties) Properties;
722
+ class Properties : public TagLib::AudioProperties {
723
+ public:
724
+ Properties(const ByteVector &data, long streamLength, ReadStyle style=Average);
725
+ PROPERTIES_VIRTUALS()
726
+ int bitsPerSample () const;
727
+ int version () const;
728
+ };
729
+
730
+ class File : public TagLib::File {
731
+ public:
732
+ enum TagTypes { NoTags = 0x0000, ID3v1 = 0x0001, APE = 0x0002, AllTags = 0xffff };
733
+ File (FileName file, bool readProperties=true, Properties::ReadStyle propertiesStyle=Properties::Average);
734
+ FILE_VIRTUALS()
735
+
736
+ ID3v1::Tag * ID3v1Tag (bool create=false);
737
+ APE::Tag * APETag (bool create=false);
738
+ void strip (int tags=AllTags);
739
+ };
740
+ };
741
+
742
+ namespace MPEG {
743
+ %rename(MPEG_File) File;
744
+ %rename(MPEG_Properties) Properties;
745
+ %rename(MPEG_Header) Header;
746
+
747
+ class Header {
748
+ public:
749
+ enum Version { Version1 = 0, Version2 = 1, Version2_5 = 2 };
750
+ enum ChannelMode { Stereo = 0, JointStereo = 1, DualChannel = 2, SingleChannel = 3 };
751
+ Header(const ByteVector &data);
752
+ Header(const Header &h);
753
+ virtual ~Header ();
754
+ bool isValid () const;
755
+ Version version () const;
756
+ int layer () const;
757
+ bool protectionEnabled () const;
758
+ int bitrate () const;
759
+ int sampleRate () const;
760
+ bool isPadded() const;
761
+ ChannelMode channelMode () const;
762
+ bool isCopyrighted () const;
763
+ bool isOriginal () const;
764
+ int frameLength () const;
765
+ int samplesPerFrame () const;
766
+ // Header & operator= (const Header &h);
767
+ };
768
+ class XingHeader {
769
+ public:
770
+ XingHeader (const ByteVector &data);
771
+ virtual ~XingHeader ();
772
+ bool isValid () const;
773
+ uint totalFrames () const;
774
+ uint totalSize () const;
775
+ };
776
+ class Properties : public TagLib::AudioProperties {
777
+ public:
778
+ Properties(TagLib::MPEG::File *file, ReadStyle style=Average);
779
+ PROPERTIES_VIRTUALS()
780
+ const XingHeader * xingHeader () const;
781
+ Header::Version version () const;
782
+ int layer () const;
783
+ bool protectionEnabled () const;
784
+ Header::ChannelMode channelMode () const;
785
+ bool isCopyrighted () const;
786
+ bool isOriginal () const ;
787
+ };
788
+ class File : public TagLib::File {
789
+ public:
790
+ enum TagTypes {
791
+ NoTags = 0x0000, ID3v1 = 0x0001, ID3v2 = 0x0002, APE = 0x0004,
792
+ AllTags = 0xffff};
793
+ File (FileName file, bool readProperties=true, Properties::ReadStyle propertiesStyle=Properties::Average);
794
+ File (FileName file, ID3v2::FrameFactory *frameFactory, bool readProperties=true, Properties::ReadStyle propertiesStyle=Properties::Average);
795
+ FILE_VIRTUALS();
796
+ bool save (int tags);
797
+ bool save (int tags, bool stripOthers);
798
+ ID3v2::Tag * ID3v2Tag (bool create=false);
799
+ ID3v1::Tag * ID3v1Tag (bool create=false);
800
+ APE::Tag * APETag (bool create=false);
801
+ bool strip (int tags=AllTags);
802
+ bool strip (int tags, bool freeMemory);
803
+ void setID3v2FrameFactory (const ID3v2::FrameFactory *factory);
804
+ long firstFrameOffset ();
805
+ long nextFrameOffset (long position);
806
+ long previousFrameOffset (long position);
807
+ long lastFrameOffset ();;
808
+ };
809
+ };
810
+
811
+ };
812
+
813
+
814
+
815
+
816
+
817
+