FLAC
1.3.0
|
00001 /* libFLAC++ - Free Lossless Audio Codec library 00002 * Copyright (C) 2002-2009 Josh Coalson 00003 * Copyright (C) 2011-2013 Xiph.Org Foundation 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 00009 * - Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * 00012 * - Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * 00016 * - Neither the name of the Xiph.org Foundation nor the names of its 00017 * contributors may be used to endorse or promote products derived from 00018 * this software without specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00021 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00022 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00023 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 00024 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00026 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00027 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00028 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00029 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 */ 00032 00033 #ifndef FLACPP__METADATA_H 00034 #define FLACPP__METADATA_H 00035 00036 #include "export.h" 00037 00038 #include "FLAC/metadata.h" 00039 00040 // =============================================================== 00041 // 00042 // Full documentation for the metadata interface can be found 00043 // in the C layer in include/FLAC/metadata.h 00044 // 00045 // =============================================================== 00046 00075 namespace FLAC { 00076 namespace Metadata { 00077 00078 // ============================================================ 00079 // 00080 // Metadata objects 00081 // 00082 // ============================================================ 00083 00109 class FLACPP_API Prototype { 00110 protected: 00112 00115 Prototype(const Prototype &); 00116 Prototype(const ::FLAC__StreamMetadata &); 00117 Prototype(const ::FLAC__StreamMetadata *); 00119 00130 Prototype(::FLAC__StreamMetadata *object, bool copy); 00131 00133 00134 Prototype &operator=(const Prototype &); 00135 Prototype &operator=(const ::FLAC__StreamMetadata &); 00136 Prototype &operator=(const ::FLAC__StreamMetadata *); 00138 00142 Prototype &assign_object(::FLAC__StreamMetadata *object, bool copy); 00143 00146 virtual void clear(); 00147 00148 ::FLAC__StreamMetadata *object_; 00149 public: 00152 virtual ~Prototype(); 00153 00155 00157 inline bool operator==(const Prototype &) const; 00158 inline bool operator==(const ::FLAC__StreamMetadata &) const; 00159 inline bool operator==(const ::FLAC__StreamMetadata *) const; 00161 00163 00164 inline bool operator!=(const Prototype &) const; 00165 inline bool operator!=(const ::FLAC__StreamMetadata &) const; 00166 inline bool operator!=(const ::FLAC__StreamMetadata *) const; 00168 00169 friend class SimpleIterator; 00170 friend class Iterator; 00171 00176 inline bool is_valid() const; 00177 00184 bool get_is_last() const; 00185 00191 ::FLAC__MetadataType get_type() const; 00192 00202 unsigned get_length() const; 00203 00210 void set_is_last(bool); 00211 00219 inline operator const ::FLAC__StreamMetadata *() const; 00220 private: 00222 Prototype(); 00223 00224 // These are used only by Iterator 00225 bool is_reference_; 00226 inline void set_reference(bool x) { is_reference_ = x; } 00227 }; 00228 00229 #ifdef _MSC_VER 00230 // warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) 00231 #pragma warning ( disable : 4800 ) 00232 #endif 00233 00234 inline bool Prototype::operator==(const Prototype &object) const 00235 { return (bool)::FLAC__metadata_object_is_equal(object_, object.object_); } 00236 00237 inline bool Prototype::operator==(const ::FLAC__StreamMetadata &object) const 00238 { return (bool)::FLAC__metadata_object_is_equal(object_, &object); } 00239 00240 inline bool Prototype::operator==(const ::FLAC__StreamMetadata *object) const 00241 { return (bool)::FLAC__metadata_object_is_equal(object_, object); } 00242 00243 #ifdef _MSC_VER 00244 // @@@ how to re-enable? the following doesn't work 00245 // #pragma warning ( enable : 4800 ) 00246 #endif 00247 00248 inline bool Prototype::operator!=(const Prototype &object) const 00249 { return !operator==(object); } 00250 00251 inline bool Prototype::operator!=(const ::FLAC__StreamMetadata &object) const 00252 { return !operator==(object); } 00253 00254 inline bool Prototype::operator!=(const ::FLAC__StreamMetadata *object) const 00255 { return !operator==(object); } 00256 00257 inline bool Prototype::is_valid() const 00258 { return 0 != object_; } 00259 00260 inline Prototype::operator const ::FLAC__StreamMetadata *() const 00261 { return object_; } 00262 00264 FLACPP_API Prototype *clone(const Prototype *); 00265 00266 00271 class FLACPP_API StreamInfo : public Prototype { 00272 public: 00273 StreamInfo(); 00274 00276 00279 inline StreamInfo(const StreamInfo &object): Prototype(object) { } 00280 inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { } 00281 inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { } 00283 00287 inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 00288 00289 ~StreamInfo(); 00290 00292 00293 inline StreamInfo &operator=(const StreamInfo &object) { Prototype::operator=(object); return *this; } 00294 inline StreamInfo &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 00295 inline StreamInfo &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 00297 00301 inline StreamInfo &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 00302 00304 00305 inline bool operator==(const StreamInfo &object) const { return Prototype::operator==(object); } 00306 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 00307 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 00309 00311 00312 inline bool operator!=(const StreamInfo &object) const { return Prototype::operator!=(object); } 00313 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 00314 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 00316 00318 00319 unsigned get_min_blocksize() const; 00320 unsigned get_max_blocksize() const; 00321 unsigned get_min_framesize() const; 00322 unsigned get_max_framesize() const; 00323 unsigned get_sample_rate() const; 00324 unsigned get_channels() const; 00325 unsigned get_bits_per_sample() const; 00326 FLAC__uint64 get_total_samples() const; 00327 const FLAC__byte *get_md5sum() const; 00328 00329 void set_min_blocksize(unsigned value); 00330 void set_max_blocksize(unsigned value); 00331 void set_min_framesize(unsigned value); 00332 void set_max_framesize(unsigned value); 00333 void set_sample_rate(unsigned value); 00334 void set_channels(unsigned value); 00335 void set_bits_per_sample(unsigned value); 00336 void set_total_samples(FLAC__uint64 value); 00337 void set_md5sum(const FLAC__byte value[16]); 00339 }; 00340 00345 class FLACPP_API Padding : public Prototype { 00346 public: 00347 Padding(); 00348 00350 00353 inline Padding(const Padding &object): Prototype(object) { } 00354 inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { } 00355 inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { } 00357 00361 inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 00362 00365 Padding(unsigned length); 00366 00367 ~Padding(); 00368 00370 00371 inline Padding &operator=(const Padding &object) { Prototype::operator=(object); return *this; } 00372 inline Padding &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 00373 inline Padding &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 00375 00379 inline Padding &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 00380 00382 00383 inline bool operator==(const Padding &object) const { return Prototype::operator==(object); } 00384 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 00385 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 00387 00389 00390 inline bool operator!=(const Padding &object) const { return Prototype::operator!=(object); } 00391 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 00392 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 00394 00397 void set_length(unsigned length); 00398 }; 00399 00404 class FLACPP_API Application : public Prototype { 00405 public: 00406 Application(); 00407 // 00409 00412 inline Application(const Application &object): Prototype(object) { } 00413 inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { } 00414 inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { } 00416 00420 inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 00421 00422 ~Application(); 00423 00425 00426 inline Application &operator=(const Application &object) { Prototype::operator=(object); return *this; } 00427 inline Application &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 00428 inline Application &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 00430 00434 inline Application &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 00435 00437 00438 inline bool operator==(const Application &object) const { return Prototype::operator==(object); } 00439 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 00440 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 00442 00444 00445 inline bool operator!=(const Application &object) const { return Prototype::operator!=(object); } 00446 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 00447 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 00449 00450 const FLAC__byte *get_id() const; 00451 const FLAC__byte *get_data() const; 00452 00453 void set_id(const FLAC__byte value[4]); 00455 bool set_data(const FLAC__byte *data, unsigned length); 00456 bool set_data(FLAC__byte *data, unsigned length, bool copy); 00457 }; 00458 00463 class FLACPP_API SeekTable : public Prototype { 00464 public: 00465 SeekTable(); 00466 00468 00471 inline SeekTable(const SeekTable &object): Prototype(object) { } 00472 inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { } 00473 inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { } 00475 00479 inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 00480 00481 ~SeekTable(); 00482 00484 00485 inline SeekTable &operator=(const SeekTable &object) { Prototype::operator=(object); return *this; } 00486 inline SeekTable &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 00487 inline SeekTable &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 00489 00493 inline SeekTable &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 00494 00496 00497 inline bool operator==(const SeekTable &object) const { return Prototype::operator==(object); } 00498 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 00499 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 00501 00503 00504 inline bool operator!=(const SeekTable &object) const { return Prototype::operator!=(object); } 00505 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 00506 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 00508 00509 unsigned get_num_points() const; 00510 ::FLAC__StreamMetadata_SeekPoint get_point(unsigned index) const; 00511 00513 bool resize_points(unsigned new_num_points); 00514 00516 void set_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point); 00517 00519 bool insert_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point); 00520 00522 bool delete_point(unsigned index); 00523 00525 bool is_legal() const; 00526 00528 bool template_append_placeholders(unsigned num); 00529 00531 bool template_append_point(FLAC__uint64 sample_number); 00532 00534 bool template_append_points(FLAC__uint64 sample_numbers[], unsigned num); 00535 00537 bool template_append_spaced_points(unsigned num, FLAC__uint64 total_samples); 00538 00540 bool template_append_spaced_points_by_samples(unsigned samples, FLAC__uint64 total_samples); 00541 00543 bool template_sort(bool compact); 00544 }; 00545 00550 class FLACPP_API VorbisComment : public Prototype { 00551 public: 00581 class FLACPP_API Entry { 00582 public: 00583 Entry(); 00584 00585 Entry(const char *field, unsigned field_length); 00586 Entry(const char *field); // assumes \a field is NUL-terminated 00587 00588 Entry(const char *field_name, const char *field_value, unsigned field_value_length); 00589 Entry(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated 00590 00591 Entry(const Entry &entry); 00592 00593 Entry &operator=(const Entry &entry); 00594 00595 virtual ~Entry(); 00596 00597 virtual bool is_valid() const; 00598 00599 unsigned get_field_length() const; 00600 unsigned get_field_name_length() const; 00601 unsigned get_field_value_length() const; 00602 00603 ::FLAC__StreamMetadata_VorbisComment_Entry get_entry() const; 00604 const char *get_field() const; 00605 const char *get_field_name() const; 00606 const char *get_field_value() const; 00607 00608 bool set_field(const char *field, unsigned field_length); 00609 bool set_field(const char *field); // assumes \a field is NUL-terminated 00610 bool set_field_name(const char *field_name); 00611 bool set_field_value(const char *field_value, unsigned field_value_length); 00612 bool set_field_value(const char *field_value); // assumes \a field_value is NUL-terminated 00613 protected: 00614 bool is_valid_; 00615 ::FLAC__StreamMetadata_VorbisComment_Entry entry_; 00616 char *field_name_; 00617 unsigned field_name_length_; 00618 char *field_value_; 00619 unsigned field_value_length_; 00620 private: 00621 void zero(); 00622 void clear(); 00623 void clear_entry(); 00624 void clear_field_name(); 00625 void clear_field_value(); 00626 void construct(const char *field, unsigned field_length); 00627 void construct(const char *field); // assumes \a field is NUL-terminated 00628 void construct(const char *field_name, const char *field_value, unsigned field_value_length); 00629 void construct(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated 00630 void compose_field(); 00631 void parse_field(); 00632 }; 00633 00634 VorbisComment(); 00635 00637 00640 inline VorbisComment(const VorbisComment &object): Prototype(object) { } 00641 inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { } 00642 inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { } 00644 00648 inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 00649 00650 ~VorbisComment(); 00651 00653 00654 inline VorbisComment &operator=(const VorbisComment &object) { Prototype::operator=(object); return *this; } 00655 inline VorbisComment &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 00656 inline VorbisComment &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 00658 00662 inline VorbisComment &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 00663 00665 00666 inline bool operator==(const VorbisComment &object) const { return Prototype::operator==(object); } 00667 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 00668 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 00670 00672 00673 inline bool operator!=(const VorbisComment &object) const { return Prototype::operator!=(object); } 00674 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 00675 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 00677 00678 unsigned get_num_comments() const; 00679 const FLAC__byte *get_vendor_string() const; // NUL-terminated UTF-8 string 00680 Entry get_comment(unsigned index) const; 00681 00683 bool set_vendor_string(const FLAC__byte *string); // NUL-terminated UTF-8 string 00684 00686 bool resize_comments(unsigned new_num_comments); 00687 00689 bool set_comment(unsigned index, const Entry &entry); 00690 00692 bool insert_comment(unsigned index, const Entry &entry); 00693 00695 bool append_comment(const Entry &entry); 00696 00698 bool replace_comment(const Entry &entry, bool all); 00699 00701 bool delete_comment(unsigned index); 00702 00704 int find_entry_from(unsigned offset, const char *field_name); 00705 00707 int remove_entry_matching(const char *field_name); 00708 00710 int remove_entries_matching(const char *field_name); 00711 }; 00712 00717 class FLACPP_API CueSheet : public Prototype { 00718 public: 00725 class FLACPP_API Track { 00726 protected: 00727 ::FLAC__StreamMetadata_CueSheet_Track *object_; 00728 public: 00729 Track(); 00730 Track(const ::FLAC__StreamMetadata_CueSheet_Track *track); 00731 Track(const Track &track); 00732 Track &operator=(const Track &track); 00733 00734 virtual ~Track(); 00735 00736 virtual bool is_valid() const; 00737 00738 00739 inline FLAC__uint64 get_offset() const { return object_->offset; } 00740 inline FLAC__byte get_number() const { return object_->number; } 00741 inline const char *get_isrc() const { return object_->isrc; } 00742 inline unsigned get_type() const { return object_->type; } 00743 inline bool get_pre_emphasis() const { return object_->pre_emphasis; } 00744 00745 inline FLAC__byte get_num_indices() const { return object_->num_indices; } 00746 ::FLAC__StreamMetadata_CueSheet_Index get_index(unsigned i) const; 00747 00748 inline const ::FLAC__StreamMetadata_CueSheet_Track *get_track() const { return object_; } 00749 00750 inline void set_offset(FLAC__uint64 value) { object_->offset = value; } 00751 inline void set_number(FLAC__byte value) { object_->number = value; } 00752 void set_isrc(const char value[12]); 00753 void set_type(unsigned value); 00754 inline void set_pre_emphasis(bool value) { object_->pre_emphasis = value? 1 : 0; } 00755 00756 void set_index(unsigned i, const ::FLAC__StreamMetadata_CueSheet_Index &index); 00757 //@@@ It's awkward but to insert/delete index points 00758 //@@@ you must use the routines in the CueSheet class. 00759 }; 00760 00761 CueSheet(); 00762 00764 00767 inline CueSheet(const CueSheet &object): Prototype(object) { } 00768 inline CueSheet(const ::FLAC__StreamMetadata &object): Prototype(object) { } 00769 inline CueSheet(const ::FLAC__StreamMetadata *object): Prototype(object) { } 00771 00775 inline CueSheet(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 00776 00777 ~CueSheet(); 00778 00780 00781 inline CueSheet &operator=(const CueSheet &object) { Prototype::operator=(object); return *this; } 00782 inline CueSheet &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 00783 inline CueSheet &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 00785 00789 inline CueSheet &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 00790 00792 00793 inline bool operator==(const CueSheet &object) const { return Prototype::operator==(object); } 00794 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 00795 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 00797 00799 00800 inline bool operator!=(const CueSheet &object) const { return Prototype::operator!=(object); } 00801 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 00802 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 00804 00805 const char *get_media_catalog_number() const; 00806 FLAC__uint64 get_lead_in() const; 00807 bool get_is_cd() const; 00808 00809 unsigned get_num_tracks() const; 00810 Track get_track(unsigned i) const; 00811 00812 void set_media_catalog_number(const char value[128]); 00813 void set_lead_in(FLAC__uint64 value); 00814 void set_is_cd(bool value); 00815 00816 void set_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index); 00817 00819 bool resize_indices(unsigned track_num, unsigned new_num_indices); 00820 00822 bool insert_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index); 00823 00825 bool insert_blank_index(unsigned track_num, unsigned index_num); 00826 00828 bool delete_index(unsigned track_num, unsigned index_num); 00829 00831 bool resize_tracks(unsigned new_num_tracks); 00832 00834 bool set_track(unsigned i, const Track &track); 00835 00837 bool insert_track(unsigned i, const Track &track); 00838 00840 bool insert_blank_track(unsigned i); 00841 00843 bool delete_track(unsigned i); 00844 00846 bool is_legal(bool check_cd_da_subset = false, const char **violation = 0) const; 00847 00849 FLAC__uint32 calculate_cddb_id() const; 00850 }; 00851 00856 class FLACPP_API Picture : public Prototype { 00857 public: 00858 Picture(); 00859 00861 00864 inline Picture(const Picture &object): Prototype(object) { } 00865 inline Picture(const ::FLAC__StreamMetadata &object): Prototype(object) { } 00866 inline Picture(const ::FLAC__StreamMetadata *object): Prototype(object) { } 00868 00872 inline Picture(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 00873 00874 ~Picture(); 00875 00877 00878 inline Picture &operator=(const Picture &object) { Prototype::operator=(object); return *this; } 00879 inline Picture &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 00880 inline Picture &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 00882 00886 inline Picture &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 00887 00889 00890 inline bool operator==(const Picture &object) const { return Prototype::operator==(object); } 00891 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 00892 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 00894 00896 00897 inline bool operator!=(const Picture &object) const { return Prototype::operator!=(object); } 00898 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 00899 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 00901 00902 ::FLAC__StreamMetadata_Picture_Type get_type() const; 00903 const char *get_mime_type() const; // NUL-terminated printable ASCII string 00904 const FLAC__byte *get_description() const; // NUL-terminated UTF-8 string 00905 FLAC__uint32 get_width() const; 00906 FLAC__uint32 get_height() const; 00907 FLAC__uint32 get_depth() const; 00908 FLAC__uint32 get_colors() const; 00909 FLAC__uint32 get_data_length() const; 00910 const FLAC__byte *get_data() const; 00911 00912 void set_type(::FLAC__StreamMetadata_Picture_Type type); 00913 00915 bool set_mime_type(const char *string); // NUL-terminated printable ASCII string 00916 00918 bool set_description(const FLAC__byte *string); // NUL-terminated UTF-8 string 00919 00920 void set_width(FLAC__uint32 value) const; 00921 void set_height(FLAC__uint32 value) const; 00922 void set_depth(FLAC__uint32 value) const; 00923 void set_colors(FLAC__uint32 value) const; 00924 00926 bool set_data(const FLAC__byte *data, FLAC__uint32 data_length); 00927 00929 bool is_legal(const char **violation); 00930 }; 00931 00938 class FLACPP_API Unknown : public Prototype { 00939 public: 00940 Unknown(); 00941 // 00943 00946 inline Unknown(const Unknown &object): Prototype(object) { } 00947 inline Unknown(const ::FLAC__StreamMetadata &object): Prototype(object) { } 00948 inline Unknown(const ::FLAC__StreamMetadata *object): Prototype(object) { } 00950 00954 inline Unknown(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 00955 00956 ~Unknown(); 00957 00959 00960 inline Unknown &operator=(const Unknown &object) { Prototype::operator=(object); return *this; } 00961 inline Unknown &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 00962 inline Unknown &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 00964 00968 inline Unknown &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 00969 00971 00972 inline bool operator==(const Unknown &object) const { return Prototype::operator==(object); } 00973 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 00974 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 00976 00978 00979 inline bool operator!=(const Unknown &object) const { return Prototype::operator!=(object); } 00980 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 00981 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 00983 00984 const FLAC__byte *get_data() const; 00985 00987 bool set_data(const FLAC__byte *data, unsigned length); 00988 bool set_data(FLAC__byte *data, unsigned length, bool copy); 00989 }; 00990 00991 /* \} */ 00992 00993 01006 FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo); 01007 01008 FLACPP_API bool get_tags(const char *filename, VorbisComment *&tags); 01009 FLACPP_API bool get_tags(const char *filename, VorbisComment &tags); 01010 01011 FLACPP_API bool get_cuesheet(const char *filename, CueSheet *&cuesheet); 01012 FLACPP_API bool get_cuesheet(const char *filename, CueSheet &cuesheet); 01013 01014 FLACPP_API bool get_picture(const char *filename, Picture *&picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors); 01015 FLACPP_API bool get_picture(const char *filename, Picture &picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors); 01016 01017 /* \} */ 01018 01019 01054 class FLACPP_API SimpleIterator { 01055 public: 01058 class FLACPP_API Status { 01059 public: 01060 inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { } 01061 inline operator ::FLAC__Metadata_SimpleIteratorStatus() const { return status_; } 01062 inline const char *as_cstring() const { return ::FLAC__Metadata_SimpleIteratorStatusString[status_]; } 01063 protected: 01064 ::FLAC__Metadata_SimpleIteratorStatus status_; 01065 }; 01066 01067 SimpleIterator(); 01068 virtual ~SimpleIterator(); 01069 01070 bool is_valid() const; 01071 01072 bool init(const char *filename, bool read_only, bool preserve_file_stats); 01073 01074 Status status(); 01075 bool is_writable() const; 01076 01077 bool next(); 01078 bool prev(); 01079 bool is_last() const; 01080 01081 off_t get_block_offset() const; 01082 ::FLAC__MetadataType get_block_type() const; 01083 unsigned get_block_length() const; 01084 bool get_application_id(FLAC__byte *id); 01085 Prototype *get_block(); 01086 bool set_block(Prototype *block, bool use_padding = true); 01087 bool insert_block_after(Prototype *block, bool use_padding = true); 01088 bool delete_block(bool use_padding = true); 01089 01090 protected: 01091 ::FLAC__Metadata_SimpleIterator *iterator_; 01092 void clear(); 01093 }; 01094 01095 /* \} */ 01096 01097 01140 class FLACPP_API Chain { 01141 public: 01144 class FLACPP_API Status { 01145 public: 01146 inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { } 01147 inline operator ::FLAC__Metadata_ChainStatus() const { return status_; } 01148 inline const char *as_cstring() const { return ::FLAC__Metadata_ChainStatusString[status_]; } 01149 protected: 01150 ::FLAC__Metadata_ChainStatus status_; 01151 }; 01152 01153 Chain(); 01154 virtual ~Chain(); 01155 01156 friend class Iterator; 01157 01158 bool is_valid() const; 01159 01160 Status status(); 01161 01162 bool read(const char *filename, bool is_ogg = false); 01163 bool read(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, bool is_ogg = false); 01164 01165 bool check_if_tempfile_needed(bool use_padding); 01166 01167 bool write(bool use_padding = true, bool preserve_file_stats = false); 01168 bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks); 01169 bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks, ::FLAC__IOHandle temp_handle, ::FLAC__IOCallbacks temp_callbacks); 01170 01171 void merge_padding(); 01172 void sort_padding(); 01173 01174 protected: 01175 ::FLAC__Metadata_Chain *chain_; 01176 virtual void clear(); 01177 }; 01178 01184 class FLACPP_API Iterator { 01185 public: 01186 Iterator(); 01187 virtual ~Iterator(); 01188 01189 bool is_valid() const; 01190 01191 01192 void init(Chain &chain); 01193 01194 bool next(); 01195 bool prev(); 01196 01197 ::FLAC__MetadataType get_block_type() const; 01198 Prototype *get_block(); 01199 bool set_block(Prototype *block); 01200 bool delete_block(bool replace_with_padding); 01201 bool insert_block_before(Prototype *block); 01202 bool insert_block_after(Prototype *block); 01203 01204 protected: 01205 ::FLAC__Metadata_Iterator *iterator_; 01206 virtual void clear(); 01207 }; 01208 01209 /* \} */ 01210 01211 } 01212 } 01213 01214 #endif