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
00208 inline operator const ::FLAC__StreamMetadata *() const;
00209 private:
00211 Prototype();
00212
00213
00214 bool is_reference_;
00215 inline void set_reference(bool x) { is_reference_ = x; }
00216 };
00217
00218 #ifdef _MSC_VER
00219
00220 #pragma warning ( disable : 4800 )
00221 #endif
00222
00223 inline bool Prototype::operator==(const Prototype &object) const
00224 { return (bool)::FLAC__metadata_object_is_equal(object_, object.object_); }
00225
00226 inline bool Prototype::operator==(const ::FLAC__StreamMetadata &object) const
00227 { return (bool)::FLAC__metadata_object_is_equal(object_, &object); }
00228
00229 inline bool Prototype::operator==(const ::FLAC__StreamMetadata *object) const
00230 { return (bool)::FLAC__metadata_object_is_equal(object_, object); }
00231
00232 #ifdef _MSC_VER
00233
00234
00235 #endif
00236
00237 inline bool Prototype::operator!=(const Prototype &object) const
00238 { return !operator==(object); }
00239
00240 inline bool Prototype::operator!=(const ::FLAC__StreamMetadata &object) const
00241 { return !operator==(object); }
00242
00243 inline bool Prototype::operator!=(const ::FLAC__StreamMetadata *object) const
00244 { return !operator==(object); }
00245
00246 inline bool Prototype::is_valid() const
00247 { return 0 != object_; }
00248
00249 inline Prototype::operator const ::FLAC__StreamMetadata *() const
00250 { return object_; }
00251
00253 FLACPP_API Prototype *clone(const Prototype *);
00254
00255
00259 class FLACPP_API StreamInfo : public Prototype {
00260 public:
00261 StreamInfo();
00262
00264
00267 inline StreamInfo(const StreamInfo &object): Prototype(object) { }
00268 inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00269 inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00271
00275 inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00276
00277 ~StreamInfo();
00278
00280
00281 inline void operator=(const StreamInfo &object) { Prototype::operator=(object); }
00282 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00283 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00285
00287
00288 inline bool operator==(const StreamInfo &object) const { return Prototype::operator==(object); }
00289 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00290 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00292
00294
00295 inline bool operator!=(const StreamInfo &object) const { return Prototype::operator!=(object); }
00296 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00297 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00299
00301
00302 unsigned get_min_blocksize() const;
00303 unsigned get_max_blocksize() const;
00304 unsigned get_min_framesize() const;
00305 unsigned get_max_framesize() const;
00306 unsigned get_sample_rate() const;
00307 unsigned get_channels() const;
00308 unsigned get_bits_per_sample() const;
00309 FLAC__uint64 get_total_samples() const;
00310 const FLAC__byte *get_md5sum() const;
00311
00312 void set_min_blocksize(unsigned value);
00313 void set_max_blocksize(unsigned value);
00314 void set_min_framesize(unsigned value);
00315 void set_max_framesize(unsigned value);
00316 void set_sample_rate(unsigned value);
00317 void set_channels(unsigned value);
00318 void set_bits_per_sample(unsigned value);
00319 void set_total_samples(FLAC__uint64 value);
00320 void set_md5sum(const FLAC__byte value[16]);
00322 };
00323
00327 class FLACPP_API Padding : public Prototype {
00328 public:
00329 Padding();
00330
00332
00335 inline Padding(const Padding &object): Prototype(object) { }
00336 inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00337 inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00339
00343 inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00344
00345 ~Padding();
00346
00348
00349 inline void operator=(const Padding &object) { Prototype::operator=(object); }
00350 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00351 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00353
00355
00356 inline bool operator==(const Padding &object) const { return Prototype::operator==(object); }
00357 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00358 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00360
00362
00363 inline bool operator!=(const Padding &object) const { return Prototype::operator!=(object); }
00364 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00365 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00367
00368 void set_length(unsigned length);
00369 };
00370
00374 class FLACPP_API Application : public Prototype {
00375 public:
00376 Application();
00377
00379
00380 * always performs a deep copy.
00381 */
00382 inline Application(const Application &object): Prototype(object) { }
00383 inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00384 inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00386
00390 inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00391
00392 ~Application();
00393
00395
00396 inline void operator=(const Application &object) { Prototype::operator=(object); }
00397 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00398 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00400
00402
00403 inline bool operator==(const Application &object) const { return Prototype::operator==(object); }
00404 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00405 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00407
00409
00410 inline bool operator!=(const Application &object) const { return Prototype::operator!=(object); }
00411 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00412 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00414
00415 const FLAC__byte *get_id() const;
00416 const FLAC__byte *get_data() const;
00417
00418 void set_id(const FLAC__byte value[4]);
00420 bool set_data(const FLAC__byte *data, unsigned length);
00421 bool set_data(FLAC__byte *data, unsigned length, bool copy);
00422 };
00423
00427 class FLACPP_API SeekTable : public Prototype {
00428 public:
00429 SeekTable();
00430
00432
00435 inline SeekTable(const SeekTable &object): Prototype(object) { }
00436 inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00437 inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00439
00443 inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00444
00445 ~SeekTable();
00446
00448
00449 inline void operator=(const SeekTable &object) { Prototype::operator=(object); }
00450 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00451 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00453
00455
00456 inline bool operator==(const SeekTable &object) const { return Prototype::operator==(object); }
00457 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00458 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00460
00462
00463 inline bool operator!=(const SeekTable &object) const { return Prototype::operator!=(object); }
00464 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00465 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00467
00468 unsigned get_num_points() const;
00469 ::FLAC__StreamMetadata_SeekPoint get_point(unsigned index) const;
00470
00472 void set_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point);
00473
00475 bool insert_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point);
00476
00478 bool delete_point(unsigned index);
00479
00481 bool is_legal() const;
00482 };
00483
00487 class FLACPP_API VorbisComment : public Prototype {
00488 public:
00513 class FLACPP_API Entry {
00514 public:
00515 Entry();
00516 Entry(const char *field, unsigned field_length);
00517 Entry(const char *field_name, const char *field_value, unsigned field_value_length);
00518 Entry(const Entry &entry);
00519 void operator=(const Entry &entry);
00520
00521 virtual ~Entry();
00522
00523 virtual bool is_valid() const;
00524
00525 unsigned get_field_length() const;
00526 unsigned get_field_name_length() const;
00527 unsigned get_field_value_length() const;
00528
00529 ::FLAC__StreamMetadata_VorbisComment_Entry get_entry() const;
00530 const char *get_field() const;
00531 const char *get_field_name() const;
00532 const char *get_field_value() const;
00533
00534 bool set_field(const char *field, unsigned field_length);
00535 bool set_field_name(const char *field_name);
00536 bool set_field_value(const char *field_value, unsigned field_value_length);
00537 protected:
00538 bool is_valid_;
00539 ::FLAC__StreamMetadata_VorbisComment_Entry entry_;
00540 char *field_name_;
00541 unsigned field_name_length_;
00542 char *field_value_;
00543 unsigned field_value_length_;
00544 private:
00545 void zero();
00546 void clear();
00547 void clear_entry();
00548 void clear_field_name();
00549 void clear_field_value();
00550 void construct(const char *field, unsigned field_length);
00551 void construct(const char *field_name, const char *field_value, unsigned field_value_length);
00552 void compose_field();
00553 void parse_field();
00554 };
00555
00556 VorbisComment();
00557
00559
00562 inline VorbisComment(const VorbisComment &object): Prototype(object) { }
00563 inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00564 inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00566
00570 inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00571
00572 ~VorbisComment();
00573
00575
00576 inline void operator=(const VorbisComment &object) { Prototype::operator=(object); }
00577 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00578 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00580
00582
00583 inline bool operator==(const VorbisComment &object) const { return Prototype::operator==(object); }
00584 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00585 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00587
00589
00590 inline bool operator!=(const VorbisComment &object) const { return Prototype::operator!=(object); }
00591 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00592 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00594
00595 unsigned get_num_comments() const;
00596 Entry get_vendor_string() const;
00597 Entry get_comment(unsigned index) const;
00598
00601 bool set_vendor_string(const Entry &entry);
00602
00604 bool set_comment(unsigned index, const Entry &entry);
00605
00607 bool insert_comment(unsigned index, const Entry &entry);
00608
00610 bool delete_comment(unsigned index);
00611 };
00612
00616 class FLACPP_API CueSheet : public Prototype {
00617 public:
00624 class FLACPP_API Track {
00625 protected:
00626 ::FLAC__StreamMetadata_CueSheet_Track *object_;
00627 public:
00628 Track();
00629 Track(const ::FLAC__StreamMetadata_CueSheet_Track *track);
00630 Track(const Track &track);
00631 void operator=(const Track &track);
00632
00633 virtual ~Track();
00634
00635 virtual bool is_valid() const;
00636
00637 inline FLAC__uint64 get_offset() const { return object_->offset; }
00638 inline FLAC__byte get_number() const { return object_->number; }
00639 inline const char *get_isrc() const { return object_->isrc; }
00640 inline unsigned get_type() const { return object_->type; }
00641 inline bool get_pre_emphasis() const { return object_->pre_emphasis; }
00642
00643 inline FLAC__byte get_num_indices() const { return object_->num_indices; }
00644 ::FLAC__StreamMetadata_CueSheet_Index get_index(unsigned i) const;
00645
00646 inline const ::FLAC__StreamMetadata_CueSheet_Track *get_track() const { return object_; }
00647
00648 inline void set_offset(FLAC__uint64 value) { object_->offset = value; }
00649 inline void set_number(FLAC__byte value) { object_->number = value; }
00650 void set_isrc(const char value[12]);
00651 void set_type(unsigned value);
00652 inline void set_pre_emphasis(bool value) { object_->pre_emphasis = value? 1 : 0; }
00653
00654 void set_index(unsigned i, const ::FLAC__StreamMetadata_CueSheet_Index &index);
00655
00656
00657 };
00658
00659 CueSheet();
00660
00662
00665 inline CueSheet(const CueSheet &object): Prototype(object) { }
00666 inline CueSheet(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00667 inline CueSheet(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00669
00673 inline CueSheet(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00674
00675 ~CueSheet();
00676
00678
00679 inline void operator=(const CueSheet &object) { Prototype::operator=(object); }
00680 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00681 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00683
00685
00686 inline bool operator==(const CueSheet &object) const { return Prototype::operator==(object); }
00687 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00688 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00690
00692
00693 inline bool operator!=(const CueSheet &object) const { return Prototype::operator!=(object); }
00694 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00695 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00697
00698 const char *get_media_catalog_number() const;
00699 FLAC__uint64 get_lead_in() const;
00700 bool get_is_cd() const;
00701
00702 unsigned get_num_tracks() const;
00703 Track get_track(unsigned i) const;
00704
00705 void set_media_catalog_number(const char value[128]);
00706 void set_lead_in(FLAC__uint64 value);
00707 void set_is_cd(bool value);
00708
00709 void set_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);
00710
00712 bool insert_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);
00713
00715 bool delete_index(unsigned track_num, unsigned index_num);
00716
00718 bool set_track(unsigned i, const Track &track);
00719
00721 bool insert_track(unsigned i, const Track &track);
00722
00724 bool delete_track(unsigned i);
00725
00727 bool is_legal(bool check_cd_da_subset = false, const char **violation = 0) const;
00728 };
00729
00735 class FLACPP_API Unknown : public Prototype {
00736 public:
00737 Unknown();
00738
00740
00741 * always performs a deep copy.
00742 */
00743 inline Unknown(const Unknown &object): Prototype(object) { }
00744 inline Unknown(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00745 inline Unknown(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00747
00751 inline Unknown(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00752
00753 ~Unknown();
00754
00756
00757 inline void operator=(const Unknown &object) { Prototype::operator=(object); }
00758 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00759 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00761
00763
00764 inline bool operator==(const Unknown &object) const { return Prototype::operator==(object); }
00765 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00766 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00768
00770
00771 inline bool operator!=(const Unknown &object) const { return Prototype::operator!=(object); }
00772 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00773 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00775
00776 const FLAC__byte *get_data() const;
00777
00779 bool set_data(const FLAC__byte *data, unsigned length);
00780 bool set_data(FLAC__byte *data, unsigned length, bool copy);
00781 };
00782
00783
00784
00785
00798
00799 FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo);
00800
00802
00803
00804
00805
00806
00839 class FLACPP_API SimpleIterator {
00840 public:
00841 class FLACPP_API Status {
00842 public:
00843 inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { }
00844 inline operator ::FLAC__Metadata_SimpleIteratorStatus() const { return status_; }
00845 inline const char *as_cstring() const { return ::FLAC__Metadata_SimpleIteratorStatusString[status_]; }
00846 protected:
00847 ::FLAC__Metadata_SimpleIteratorStatus status_;
00848 };
00849
00850 SimpleIterator();
00851 virtual ~SimpleIterator();
00852
00853 bool init(const char *filename, bool read_only, bool preserve_file_stats);
00854
00855 bool is_valid() const;
00856 Status status();
00857 bool is_writable() const;
00858
00859 bool next();
00860 bool prev();
00861
00862 ::FLAC__MetadataType get_block_type() const;
00863 Prototype *get_block();
00864 bool set_block(Prototype *block, bool use_padding = true);
00865 bool insert_block_after(Prototype *block, bool use_padding = true);
00866 bool delete_block(bool use_padding = true);
00867
00868 protected:
00869 ::FLAC__Metadata_SimpleIterator *iterator_;
00870 void clear();
00871 };
00872
00873
00874
00875
00916 class FLACPP_API Chain {
00917 public:
00918 class FLACPP_API Status {
00919 public:
00920 inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { }
00921 inline operator ::FLAC__Metadata_ChainStatus() const { return status_; }
00922 inline const char *as_cstring() const { return ::FLAC__Metadata_ChainStatusString[status_]; }
00923 protected:
00924 ::FLAC__Metadata_ChainStatus status_;
00925 };
00926
00927 Chain();
00928 virtual ~Chain();
00929
00930 friend class Iterator;
00931
00932 bool is_valid() const;
00933 Status status();
00934
00935 bool read(const char *filename);
00936 bool read(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks);
00937
00938 bool check_if_tempfile_needed(bool use_padding);
00939
00940 bool write(bool use_padding = true, bool preserve_file_stats = false);
00941 bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks);
00942 bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks, ::FLAC__IOHandle temp_handle, ::FLAC__IOCallbacks temp_callbacks);
00943
00944 void merge_padding();
00945 void sort_padding();
00946
00947 protected:
00948 ::FLAC__Metadata_Chain *chain_;
00949 virtual void clear();
00950 };
00951
00955 class FLACPP_API Iterator {
00956 public:
00957 Iterator();
00958 virtual ~Iterator();
00959
00960 bool is_valid() const;
00961
00962 void init(Chain &chain);
00963
00964 bool next();
00965 bool prev();
00966
00967 ::FLAC__MetadataType get_block_type() const;
00968 Prototype *get_block();
00969 bool set_block(Prototype *block);
00970 bool delete_block(bool replace_with_padding);
00971 bool insert_block_before(Prototype *block);
00972 bool insert_block_after(Prototype *block);
00973
00974 protected:
00975 ::FLAC__Metadata_Iterator *iterator_;
00976 virtual void clear();
00977 };
00978
00979
00980
00981 };
00982 };
00983
00984 #endif