00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef FLACPP__METADATA_H
00033 #define FLACPP__METADATA_H
00034
00035 #include "export.h"
00036
00037 #include "FLAC/metadata.h"
00038
00039
00040
00041
00042
00043
00044
00045
00071 namespace FLAC {
00072 namespace Metadata {
00073
00074
00075
00076
00077
00078
00079
00104 class FLACPP_API Prototype {
00105 protected:
00107
00110 Prototype(const Prototype &);
00111 Prototype(const ::FLAC__StreamMetadata &);
00112 Prototype(const ::FLAC__StreamMetadata *);
00114
00125 Prototype(::FLAC__StreamMetadata *object, bool copy);
00126
00128
00129 void operator=(const Prototype &);
00130 void operator=(const ::FLAC__StreamMetadata &);
00131 void operator=(const ::FLAC__StreamMetadata *);
00133
00136 virtual void clear();
00137
00138 ::FLAC__StreamMetadata *object_;
00139 public:
00142 virtual ~Prototype();
00143
00145
00146 inline bool operator==(const Prototype &) const;
00147 inline bool operator==(const ::FLAC__StreamMetadata &) const;
00148 inline bool operator==(const ::FLAC__StreamMetadata *) const;
00150
00152
00153 inline bool operator!=(const Prototype &) const;
00154 inline bool operator!=(const ::FLAC__StreamMetadata &) const;
00155 inline bool operator!=(const ::FLAC__StreamMetadata *) const;
00157
00158 friend class SimpleIterator;
00159 friend class Iterator;
00160
00165 inline bool is_valid() const;
00166
00173 bool get_is_last() const;
00174
00180 ::FLAC__MetadataType get_type() const;
00181
00191 unsigned get_length() const;
00192
00199 void set_is_last(bool);
00200 private:
00202 Prototype();
00203
00204
00205 bool is_reference_;
00206 inline void set_reference(bool x) { is_reference_ = x; }
00207 };
00208
00209 inline bool Prototype::operator==(const Prototype &object) const
00210 { return (bool)::FLAC__metadata_object_is_equal(object_, object.object_); }
00211
00212 inline bool Prototype::operator==(const ::FLAC__StreamMetadata &object) const
00213 { return (bool)::FLAC__metadata_object_is_equal(object_, &object); }
00214
00215 inline bool Prototype::operator==(const ::FLAC__StreamMetadata *object) const
00216 { return (bool)::FLAC__metadata_object_is_equal(object_, object); }
00217
00218 inline bool Prototype::operator!=(const Prototype &object) const
00219 { return !operator==(object); }
00220
00221 inline bool Prototype::operator!=(const ::FLAC__StreamMetadata &object) const
00222 { return !operator==(object); }
00223
00224 inline bool Prototype::operator!=(const ::FLAC__StreamMetadata *object) const
00225 { return !operator==(object); }
00226
00227 inline bool Prototype::is_valid() const
00228 { return 0 != object_; }
00229
00231 FLACPP_API Prototype *clone(const Prototype *);
00232
00233
00237 class FLACPP_API StreamInfo : public Prototype {
00238 public:
00239 StreamInfo();
00240
00242
00245 inline StreamInfo(const StreamInfo &object): Prototype(object) { }
00246 inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00247 inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00249
00253 inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00254
00255 ~StreamInfo();
00256
00258
00259 inline void operator=(const StreamInfo &object) { Prototype::operator=(object); }
00260 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00261 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00263
00265
00266 inline bool operator==(const StreamInfo &object) const { return Prototype::operator==(object); }
00267 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00268 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00270
00272
00273 inline bool operator!=(const StreamInfo &object) const { return Prototype::operator!=(object); }
00274 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00275 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00277
00279
00280 unsigned get_min_blocksize() const;
00281 unsigned get_max_blocksize() const;
00282 unsigned get_min_framesize() const;
00283 unsigned get_max_framesize() const;
00284 unsigned get_sample_rate() const;
00285 unsigned get_channels() const;
00286 unsigned get_bits_per_sample() const;
00287 FLAC__uint64 get_total_samples() const;
00288 const FLAC__byte *get_md5sum() const;
00289
00290 void set_min_blocksize(unsigned value);
00291 void set_max_blocksize(unsigned value);
00292 void set_min_framesize(unsigned value);
00293 void set_max_framesize(unsigned value);
00294 void set_sample_rate(unsigned value);
00295 void set_channels(unsigned value);
00296 void set_bits_per_sample(unsigned value);
00297 void set_total_samples(FLAC__uint64 value);
00298 void set_md5sum(const FLAC__byte value[16]);
00300 };
00301
00305 class FLACPP_API Padding : public Prototype {
00306 public:
00307 Padding();
00308
00310
00313 inline Padding(const Padding &object): Prototype(object) { }
00314 inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00315 inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00317
00321 inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00322
00323 ~Padding();
00324
00326
00327 inline void operator=(const Padding &object) { Prototype::operator=(object); }
00328 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00329 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00331
00333
00334 inline bool operator==(const Padding &object) const { return Prototype::operator==(object); }
00335 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00336 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00338
00340
00341 inline bool operator!=(const Padding &object) const { return Prototype::operator!=(object); }
00342 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00343 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00345
00346 void set_length(unsigned length);
00347 };
00348
00352 class FLACPP_API Application : public Prototype {
00353 public:
00354 Application();
00355
00357
00360 inline Application(const Application &object): Prototype(object) { }
00361 inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00362 inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00364
00368 inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00369
00370 ~Application();
00371
00373
00374 inline void operator=(const Application &object) { Prototype::operator=(object); }
00375 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00376 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00378
00380
00381 inline bool operator==(const Application &object) const { return Prototype::operator==(object); }
00382 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00383 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00385
00387
00388 inline bool operator!=(const Application &object) const { return Prototype::operator!=(object); }
00389 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00390 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00392
00393 const FLAC__byte *get_id() const;
00394 const FLAC__byte *get_data() const;
00395
00396 void set_id(const FLAC__byte value[4]);
00398 bool set_data(const FLAC__byte *data, unsigned length);
00399 bool set_data(FLAC__byte *data, unsigned length, bool copy);
00400 };
00401
00405 class FLACPP_API SeekTable : public Prototype {
00406 public:
00407 SeekTable();
00408
00410
00413 inline SeekTable(const SeekTable &object): Prototype(object) { }
00414 inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00415 inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00417
00421 inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00422
00423 ~SeekTable();
00424
00426
00427 inline void operator=(const SeekTable &object) { Prototype::operator=(object); }
00428 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00429 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00431
00433
00434 inline bool operator==(const SeekTable &object) const { return Prototype::operator==(object); }
00435 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00436 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00438
00440
00441 inline bool operator!=(const SeekTable &object) const { return Prototype::operator!=(object); }
00442 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00443 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00445
00446 unsigned get_num_points() const;
00447 ::FLAC__StreamMetadata_SeekPoint get_point(unsigned index) const;
00448
00450 void set_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point);
00451
00453 bool insert_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point);
00454
00456 bool delete_point(unsigned index);
00457
00459 bool is_legal() const;
00460 };
00461
00465 class FLACPP_API VorbisComment : public Prototype {
00466 public:
00491 class FLACPP_API Entry {
00492 public:
00493 Entry();
00494 Entry(const char *field, unsigned field_length);
00495 Entry(const char *field_name, const char *field_value, unsigned field_value_length);
00496 Entry(const Entry &entry);
00497 void operator=(const Entry &entry);
00498
00499 virtual ~Entry();
00500
00501 virtual bool is_valid() const;
00502
00503 unsigned get_field_length() const;
00504 unsigned get_field_name_length() const;
00505 unsigned get_field_value_length() const;
00506
00507 ::FLAC__StreamMetadata_VorbisComment_Entry get_entry() const;
00508 const char *get_field() const;
00509 const char *get_field_name() const;
00510 const char *get_field_value() const;
00511
00512 bool set_field(const char *field, unsigned field_length);
00513 bool set_field_name(const char *field_name);
00514 bool set_field_value(const char *field_value, unsigned field_value_length);
00515 protected:
00516 bool is_valid_;
00517 ::FLAC__StreamMetadata_VorbisComment_Entry entry_;
00518 char *field_name_;
00519 unsigned field_name_length_;
00520 char *field_value_;
00521 unsigned field_value_length_;
00522 private:
00523 void zero();
00524 void clear();
00525 void clear_entry();
00526 void clear_field_name();
00527 void clear_field_value();
00528 void construct(const char *field, unsigned field_length);
00529 void construct(const char *field_name, const char *field_value, unsigned field_value_length);
00530 void compose_field();
00531 void parse_field();
00532 };
00533
00534 VorbisComment();
00535
00537
00540 inline VorbisComment(const VorbisComment &object): Prototype(object) { }
00541 inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00542 inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00544
00548 inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00549
00550 ~VorbisComment();
00551
00553
00554 inline void operator=(const VorbisComment &object) { Prototype::operator=(object); }
00555 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00556 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00558
00560
00561 inline bool operator==(const VorbisComment &object) const { return Prototype::operator==(object); }
00562 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00563 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00565
00567
00568 inline bool operator!=(const VorbisComment &object) const { return Prototype::operator!=(object); }
00569 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00570 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00572
00573 unsigned get_num_comments() const;
00574 Entry get_vendor_string() const;
00575 Entry get_comment(unsigned index) const;
00576
00579 bool set_vendor_string(const Entry &entry);
00580
00582 bool set_comment(unsigned index, const Entry &entry);
00583
00585 bool insert_comment(unsigned index, const Entry &entry);
00586
00588 bool delete_comment(unsigned index);
00589 };
00590
00594 class FLACPP_API CueSheet : public Prototype {
00595 public:
00602 class FLACPP_API Track {
00603 protected:
00604 ::FLAC__StreamMetadata_CueSheet_Track *object_;
00605 public:
00606 Track();
00607 Track(const ::FLAC__StreamMetadata_CueSheet_Track *track);
00608 Track(const Track &track);
00609 void operator=(const Track &track);
00610
00611 virtual ~Track();
00612
00613 virtual bool is_valid() const;
00614
00615 inline FLAC__uint64 get_offset() const { return object_->offset; }
00616 inline FLAC__byte get_number() const { return object_->number; }
00617 inline const char *get_isrc() const { return object_->isrc; }
00618 inline unsigned get_type() const { return object_->type; }
00619 inline bool get_pre_emphasis() const { return object_->pre_emphasis; }
00620
00621 inline FLAC__byte get_num_indices() const { return object_->num_indices; }
00622 ::FLAC__StreamMetadata_CueSheet_Index get_index(unsigned i) const;
00623
00624 inline const ::FLAC__StreamMetadata_CueSheet_Track *get_track() const { return object_; }
00625
00626 inline void set_offset(FLAC__uint64 value) { object_->offset = value; }
00627 inline void set_number(FLAC__byte value) { object_->number = value; }
00628 void set_isrc(const char value[12]);
00629 void set_type(unsigned value);
00630 inline void set_pre_emphasis(bool value) { object_->pre_emphasis = value? 1 : 0; }
00631
00632 void set_index(unsigned i, const ::FLAC__StreamMetadata_CueSheet_Index &index);
00633
00634
00635 };
00636
00637 CueSheet();
00638
00640
00643 inline CueSheet(const CueSheet &object): Prototype(object) { }
00644 inline CueSheet(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00645 inline CueSheet(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00647
00651 inline CueSheet(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00652
00653 ~CueSheet();
00654
00656
00657 inline void operator=(const CueSheet &object) { Prototype::operator=(object); }
00658 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00659 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00661
00663
00664 inline bool operator==(const CueSheet &object) const { return Prototype::operator==(object); }
00665 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00666 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00668
00670
00671 inline bool operator!=(const CueSheet &object) const { return Prototype::operator!=(object); }
00672 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00673 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00675
00676 const char *get_media_catalog_number() const;
00677 FLAC__uint64 get_lead_in() const;
00678 bool get_is_cd() const;
00679
00680 unsigned get_num_tracks() const;
00681 Track get_track(unsigned i) const;
00682
00683 void set_media_catalog_number(const char value[128]);
00684 void set_lead_in(FLAC__uint64 value);
00685 void set_is_cd(bool value);
00686
00687 void set_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);
00688
00690 bool insert_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);
00691
00693 bool delete_index(unsigned track_num, unsigned index_num);
00694
00696 bool set_track(unsigned i, const Track &track);
00697
00699 bool insert_track(unsigned i, const Track &track);
00700
00702 bool delete_track(unsigned i);
00703
00705 bool is_legal(bool check_cd_da_subset = false, const char **violation = 0) const;
00706 };
00707
00713 class FLACPP_API Unknown : public Prototype {
00714 public:
00715 Unknown();
00716
00718
00721 inline Unknown(const Unknown &object): Prototype(object) { }
00722 inline Unknown(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00723 inline Unknown(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00725
00729 inline Unknown(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00730
00731 ~Unknown();
00732
00734
00735 inline void operator=(const Unknown &object) { Prototype::operator=(object); }
00736 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00737 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00739
00741
00742 inline bool operator==(const Unknown &object) const { return Prototype::operator==(object); }
00743 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00744 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00746
00748
00749 inline bool operator!=(const Unknown &object) const { return Prototype::operator!=(object); }
00750 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00751 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00753
00754 const FLAC__byte *get_data() const;
00755
00757 bool set_data(const FLAC__byte *data, unsigned length);
00758 bool set_data(FLAC__byte *data, unsigned length, bool copy);
00759 };
00760
00761
00762
00763
00776
00777 FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo);
00778
00779
00780
00781
00814 class FLACPP_API SimpleIterator {
00815 public:
00816 class FLACPP_API Status {
00817 public:
00818 inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { }
00819 inline operator ::FLAC__Metadata_SimpleIteratorStatus() const { return status_; }
00820 inline const char *as_cstring() const { return ::FLAC__Metadata_SimpleIteratorStatusString[status_]; }
00821 protected:
00822 ::FLAC__Metadata_SimpleIteratorStatus status_;
00823 };
00824
00825 SimpleIterator();
00826 virtual ~SimpleIterator();
00827
00828 bool init(const char *filename, bool read_only, bool preserve_file_stats);
00829
00830 bool is_valid() const;
00831 Status status();
00832 bool is_writable() const;
00833
00834 bool next();
00835 bool prev();
00836
00837 ::FLAC__MetadataType get_block_type() const;
00838 Prototype *get_block();
00839 bool set_block(Prototype *block, bool use_padding = true);
00840 bool insert_block_after(Prototype *block, bool use_padding = true);
00841 bool delete_block(bool use_padding = true);
00842
00843 protected:
00844 ::FLAC__Metadata_SimpleIterator *iterator_;
00845 void clear();
00846 };
00847
00848
00849
00850
00891 class FLACPP_API Chain {
00892 public:
00893 class FLACPP_API Status {
00894 public:
00895 inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { }
00896 inline operator ::FLAC__Metadata_ChainStatus() const { return status_; }
00897 inline const char *as_cstring() const { return ::FLAC__Metadata_ChainStatusString[status_]; }
00898 protected:
00899 ::FLAC__Metadata_ChainStatus status_;
00900 };
00901
00902 Chain();
00903 virtual ~Chain();
00904
00905 friend class Iterator;
00906
00907 bool is_valid() const;
00908 Status status();
00909
00910 bool read(const char *filename);
00911 bool write(bool use_padding = true, bool preserve_file_stats = false);
00912
00913 void merge_padding();
00914 void sort_padding();
00915
00916 protected:
00917 ::FLAC__Metadata_Chain *chain_;
00918 virtual void clear();
00919 };
00920
00924 class FLACPP_API Iterator {
00925 public:
00926 Iterator();
00927 virtual ~Iterator();
00928
00929 bool is_valid() const;
00930
00931 void init(Chain &chain);
00932
00933 bool next();
00934 bool prev();
00935
00936 ::FLAC__MetadataType get_block_type() const;
00937 Prototype *get_block();
00938 bool set_block(Prototype *block);
00939 bool delete_block(bool replace_with_padding);
00940 bool insert_block_before(Prototype *block);
00941 bool insert_block_after(Prototype *block);
00942
00943 protected:
00944 ::FLAC__Metadata_Iterator *iterator_;
00945 virtual void clear();
00946 };
00947
00948
00949
00950 };
00951 };
00952
00953 #endif