Chris@1: Chris@1:
Chris@1:00001 /* libFLAC++ - Free Lossless Audio Codec library Chris@1: 00002 * Copyright (C) 2002,2003,2004,2005,2006,2007 Josh Coalson Chris@1: 00003 * Chris@1: 00004 * Redistribution and use in source and binary forms, with or without Chris@1: 00005 * modification, are permitted provided that the following conditions Chris@1: 00006 * are met: Chris@1: 00007 * Chris@1: 00008 * - Redistributions of source code must retain the above copyright Chris@1: 00009 * notice, this list of conditions and the following disclaimer. Chris@1: 00010 * Chris@1: 00011 * - Redistributions in binary form must reproduce the above copyright Chris@1: 00012 * notice, this list of conditions and the following disclaimer in the Chris@1: 00013 * documentation and/or other materials provided with the distribution. Chris@1: 00014 * Chris@1: 00015 * - Neither the name of the Xiph.org Foundation nor the names of its Chris@1: 00016 * contributors may be used to endorse or promote products derived from Chris@1: 00017 * this software without specific prior written permission. Chris@1: 00018 * Chris@1: 00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS Chris@1: 00020 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT Chris@1: 00021 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR Chris@1: 00022 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR Chris@1: 00023 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, Chris@1: 00024 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, Chris@1: 00025 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR Chris@1: 00026 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF Chris@1: 00027 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING Chris@1: 00028 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS Chris@1: 00029 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Chris@1: 00030 */ Chris@1: 00031 Chris@1: 00032 #ifndef FLACPP__METADATA_H Chris@1: 00033 #define FLACPP__METADATA_H Chris@1: 00034 Chris@1: 00035 #include "export.h" Chris@1: 00036 Chris@1: 00037 #include "FLAC/metadata.h" Chris@1: 00038 Chris@1: 00039 // =============================================================== Chris@1: 00040 // Chris@1: 00041 // Full documentation for the metadata interface can be found Chris@1: 00042 // in the C layer in include/FLAC/metadata.h Chris@1: 00043 // Chris@1: 00044 // =============================================================== Chris@1: 00045 Chris@1: 00074 namespace FLAC { Chris@1: 00075 namespace Metadata { Chris@1: 00076 Chris@1: 00077 // ============================================================ Chris@1: 00078 // Chris@1: 00079 // Metadata objects Chris@1: 00080 // Chris@1: 00081 // ============================================================ Chris@1: 00082 Chris@1: 00108 class FLACPP_API Prototype { Chris@1: 00109 protected: Chris@1: 00111 Chris@1: 00114 Prototype(const Prototype &); Chris@1: 00115 Prototype(const ::FLAC__StreamMetadata &); Chris@1: 00116 Prototype(const ::FLAC__StreamMetadata *); Chris@1: 00118 Chris@1: 00129 Prototype(::FLAC__StreamMetadata *object, bool copy); Chris@1: 00130 Chris@1: 00132 Chris@1: 00133 Prototype &operator=(const Prototype &); Chris@1: 00134 Prototype &operator=(const ::FLAC__StreamMetadata &); Chris@1: 00135 Prototype &operator=(const ::FLAC__StreamMetadata *); Chris@1: 00137 Chris@1: 00141 Prototype &assign_object(::FLAC__StreamMetadata *object, bool copy); Chris@1: 00142 Chris@1: 00145 virtual void clear(); Chris@1: 00146 Chris@1: 00147 ::FLAC__StreamMetadata *object_; Chris@1: 00148 public: Chris@1: 00151 virtual ~Prototype(); Chris@1: 00152 Chris@1: 00154 Chris@1: 00156 inline bool operator==(const Prototype &) const; Chris@1: 00157 inline bool operator==(const ::FLAC__StreamMetadata &) const; Chris@1: 00158 inline bool operator==(const ::FLAC__StreamMetadata *) const; Chris@1: 00160 Chris@1: 00162 Chris@1: 00163 inline bool operator!=(const Prototype &) const; Chris@1: 00164 inline bool operator!=(const ::FLAC__StreamMetadata &) const; Chris@1: 00165 inline bool operator!=(const ::FLAC__StreamMetadata *) const; Chris@1: 00167 Chris@1: 00168 friend class SimpleIterator; Chris@1: 00169 friend class Iterator; Chris@1: 00170 Chris@1: 00175 inline bool is_valid() const; Chris@1: 00176 Chris@1: 00183 bool get_is_last() const; Chris@1: 00184 Chris@1: 00190 ::FLAC__MetadataType get_type() const; Chris@1: 00191 Chris@1: 00201 unsigned get_length() const; Chris@1: 00202 Chris@1: 00209 void set_is_last(bool); Chris@1: 00210 Chris@1: 00218 inline operator const ::FLAC__StreamMetadata *() const; Chris@1: 00219 private: Chris@1: 00221 Prototype(); Chris@1: 00222 Chris@1: 00223 // These are used only by Iterator Chris@1: 00224 bool is_reference_; Chris@1: 00225 inline void set_reference(bool x) { is_reference_ = x; } Chris@1: 00226 }; Chris@1: 00227 Chris@1: 00228 #ifdef _MSC_VER Chris@1: 00229 // warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) Chris@1: 00230 #pragma warning ( disable : 4800 ) Chris@1: 00231 #endif Chris@1: 00232 Chris@1: 00233 inline bool Prototype::operator==(const Prototype &object) const Chris@1: 00234 { return (bool)::FLAC__metadata_object_is_equal(object_, object.object_); } Chris@1: 00235 Chris@1: 00236 inline bool Prototype::operator==(const ::FLAC__StreamMetadata &object) const Chris@1: 00237 { return (bool)::FLAC__metadata_object_is_equal(object_, &object); } Chris@1: 00238 Chris@1: 00239 inline bool Prototype::operator==(const ::FLAC__StreamMetadata *object) const Chris@1: 00240 { return (bool)::FLAC__metadata_object_is_equal(object_, object); } Chris@1: 00241 Chris@1: 00242 #ifdef _MSC_VER Chris@1: 00243 // @@@ how to re-enable? the following doesn't work Chris@1: 00244 // #pragma warning ( enable : 4800 ) Chris@1: 00245 #endif Chris@1: 00246 Chris@1: 00247 inline bool Prototype::operator!=(const Prototype &object) const Chris@1: 00248 { return !operator==(object); } Chris@1: 00249 Chris@1: 00250 inline bool Prototype::operator!=(const ::FLAC__StreamMetadata &object) const Chris@1: 00251 { return !operator==(object); } Chris@1: 00252 Chris@1: 00253 inline bool Prototype::operator!=(const ::FLAC__StreamMetadata *object) const Chris@1: 00254 { return !operator==(object); } Chris@1: 00255 Chris@1: 00256 inline bool Prototype::is_valid() const Chris@1: 00257 { return 0 != object_; } Chris@1: 00258 Chris@1: 00259 inline Prototype::operator const ::FLAC__StreamMetadata *() const Chris@1: 00260 { return object_; } Chris@1: 00261 Chris@1: 00263 FLACPP_API Prototype *clone(const Prototype *); Chris@1: 00264 Chris@1: 00265 Chris@1: 00270 class FLACPP_API StreamInfo : public Prototype { Chris@1: 00271 public: Chris@1: 00272 StreamInfo(); Chris@1: 00273 Chris@1: 00275 Chris@1: 00278 inline StreamInfo(const StreamInfo &object): Prototype(object) { } Chris@1: 00279 inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@1: 00280 inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@1: 00282 Chris@1: 00286 inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@1: 00287 Chris@1: 00288 ~StreamInfo(); Chris@1: 00289 Chris@1: 00291 Chris@1: 00292 inline StreamInfo &operator=(const StreamInfo &object) { Prototype::operator=(object); return *this; } Chris@1: 00293 inline StreamInfo &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@1: 00294 inline StreamInfo &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@1: 00296 Chris@1: 00300 inline StreamInfo &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@1: 00301 Chris@1: 00303 Chris@1: 00304 inline bool operator==(const StreamInfo &object) const { return Prototype::operator==(object); } Chris@1: 00305 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@1: 00306 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@1: 00308 Chris@1: 00310 Chris@1: 00311 inline bool operator!=(const StreamInfo &object) const { return Prototype::operator!=(object); } Chris@1: 00312 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@1: 00313 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@1: 00315 Chris@1: 00317 Chris@1: 00318 unsigned get_min_blocksize() const; Chris@1: 00319 unsigned get_max_blocksize() const; Chris@1: 00320 unsigned get_min_framesize() const; Chris@1: 00321 unsigned get_max_framesize() const; Chris@1: 00322 unsigned get_sample_rate() const; Chris@1: 00323 unsigned get_channels() const; Chris@1: 00324 unsigned get_bits_per_sample() const; Chris@1: 00325 FLAC__uint64 get_total_samples() const; Chris@1: 00326 const FLAC__byte *get_md5sum() const; Chris@1: 00327 Chris@1: 00328 void set_min_blocksize(unsigned value); Chris@1: 00329 void set_max_blocksize(unsigned value); Chris@1: 00330 void set_min_framesize(unsigned value); Chris@1: 00331 void set_max_framesize(unsigned value); Chris@1: 00332 void set_sample_rate(unsigned value); Chris@1: 00333 void set_channels(unsigned value); Chris@1: 00334 void set_bits_per_sample(unsigned value); Chris@1: 00335 void set_total_samples(FLAC__uint64 value); Chris@1: 00336 void set_md5sum(const FLAC__byte value[16]); Chris@1: 00338 }; Chris@1: 00339 Chris@1: 00344 class FLACPP_API Padding : public Prototype { Chris@1: 00345 public: Chris@1: 00346 Padding(); Chris@1: 00347 Chris@1: 00349 Chris@1: 00352 inline Padding(const Padding &object): Prototype(object) { } Chris@1: 00353 inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@1: 00354 inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@1: 00356 Chris@1: 00360 inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@1: 00361 Chris@1: 00362 ~Padding(); Chris@1: 00363 Chris@1: 00365 Chris@1: 00366 inline Padding &operator=(const Padding &object) { Prototype::operator=(object); return *this; } Chris@1: 00367 inline Padding &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@1: 00368 inline Padding &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@1: 00370 Chris@1: 00374 inline Padding &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@1: 00375 Chris@1: 00377 Chris@1: 00378 inline bool operator==(const Padding &object) const { return Prototype::operator==(object); } Chris@1: 00379 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@1: 00380 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@1: 00382 Chris@1: 00384 Chris@1: 00385 inline bool operator!=(const Padding &object) const { return Prototype::operator!=(object); } Chris@1: 00386 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@1: 00387 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@1: 00389 Chris@1: 00390 void set_length(unsigned length); Chris@1: 00391 }; Chris@1: 00392 Chris@1: 00397 class FLACPP_API Application : public Prototype { Chris@1: 00398 public: Chris@1: 00399 Application(); Chris@1: 00400 // Chris@1: 00402 Chris@1: 00405 inline Application(const Application &object): Prototype(object) { } Chris@1: 00406 inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@1: 00407 inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@1: 00409 Chris@1: 00413 inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@1: 00414 Chris@1: 00415 ~Application(); Chris@1: 00416 Chris@1: 00418 Chris@1: 00419 inline Application &operator=(const Application &object) { Prototype::operator=(object); return *this; } Chris@1: 00420 inline Application &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@1: 00421 inline Application &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@1: 00423 Chris@1: 00427 inline Application &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@1: 00428 Chris@1: 00430 Chris@1: 00431 inline bool operator==(const Application &object) const { return Prototype::operator==(object); } Chris@1: 00432 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@1: 00433 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@1: 00435 Chris@1: 00437 Chris@1: 00438 inline bool operator!=(const Application &object) const { return Prototype::operator!=(object); } Chris@1: 00439 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@1: 00440 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@1: 00442 Chris@1: 00443 const FLAC__byte *get_id() const; Chris@1: 00444 const FLAC__byte *get_data() const; Chris@1: 00445 Chris@1: 00446 void set_id(const FLAC__byte value[4]); Chris@1: 00448 bool set_data(const FLAC__byte *data, unsigned length); Chris@1: 00449 bool set_data(FLAC__byte *data, unsigned length, bool copy); Chris@1: 00450 }; Chris@1: 00451 Chris@1: 00456 class FLACPP_API SeekTable : public Prototype { Chris@1: 00457 public: Chris@1: 00458 SeekTable(); Chris@1: 00459 Chris@1: 00461 Chris@1: 00464 inline SeekTable(const SeekTable &object): Prototype(object) { } Chris@1: 00465 inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@1: 00466 inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@1: 00468 Chris@1: 00472 inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@1: 00473 Chris@1: 00474 ~SeekTable(); Chris@1: 00475 Chris@1: 00477 Chris@1: 00478 inline SeekTable &operator=(const SeekTable &object) { Prototype::operator=(object); return *this; } Chris@1: 00479 inline SeekTable &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@1: 00480 inline SeekTable &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@1: 00482 Chris@1: 00486 inline SeekTable &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@1: 00487 Chris@1: 00489 Chris@1: 00490 inline bool operator==(const SeekTable &object) const { return Prototype::operator==(object); } Chris@1: 00491 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@1: 00492 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@1: 00494 Chris@1: 00496 Chris@1: 00497 inline bool operator!=(const SeekTable &object) const { return Prototype::operator!=(object); } Chris@1: 00498 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@1: 00499 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@1: 00501 Chris@1: 00502 unsigned get_num_points() const; Chris@1: 00503 ::FLAC__StreamMetadata_SeekPoint get_point(unsigned index) const; Chris@1: 00504 Chris@1: 00506 void set_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point); Chris@1: 00507 Chris@1: 00509 bool insert_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point); Chris@1: 00510 Chris@1: 00512 bool delete_point(unsigned index); Chris@1: 00513 Chris@1: 00515 bool is_legal() const; Chris@1: 00516 }; Chris@1: 00517 Chris@1: 00522 class FLACPP_API VorbisComment : public Prototype { Chris@1: 00523 public: Chris@1: 00553 class FLACPP_API Entry { Chris@1: 00554 public: Chris@1: 00555 Entry(); Chris@1: 00556 Chris@1: 00557 Entry(const char *field, unsigned field_length); Chris@1: 00558 Entry(const char *field); // assumes \a field is NUL-terminated Chris@1: 00559 Chris@1: 00560 Entry(const char *field_name, const char *field_value, unsigned field_value_length); Chris@1: 00561 Entry(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated Chris@1: 00562 Chris@1: 00563 Entry(const Entry &entry); Chris@1: 00564 Chris@1: 00565 Entry &operator=(const Entry &entry); Chris@1: 00566 Chris@1: 00567 virtual ~Entry(); Chris@1: 00568 Chris@1: 00569 virtual bool is_valid() const; Chris@1: 00570 Chris@1: 00571 unsigned get_field_length() const; Chris@1: 00572 unsigned get_field_name_length() const; Chris@1: 00573 unsigned get_field_value_length() const; Chris@1: 00574 Chris@1: 00575 ::FLAC__StreamMetadata_VorbisComment_Entry get_entry() const; Chris@1: 00576 const char *get_field() const; Chris@1: 00577 const char *get_field_name() const; Chris@1: 00578 const char *get_field_value() const; Chris@1: 00579 Chris@1: 00580 bool set_field(const char *field, unsigned field_length); Chris@1: 00581 bool set_field(const char *field); // assumes \a field is NUL-terminated Chris@1: 00582 bool set_field_name(const char *field_name); Chris@1: 00583 bool set_field_value(const char *field_value, unsigned field_value_length); Chris@1: 00584 bool set_field_value(const char *field_value); // assumes \a field_value is NUL-terminated Chris@1: 00585 protected: Chris@1: 00586 bool is_valid_; Chris@1: 00587 ::FLAC__StreamMetadata_VorbisComment_Entry entry_; Chris@1: 00588 char *field_name_; Chris@1: 00589 unsigned field_name_length_; Chris@1: 00590 char *field_value_; Chris@1: 00591 unsigned field_value_length_; Chris@1: 00592 private: Chris@1: 00593 void zero(); Chris@1: 00594 void clear(); Chris@1: 00595 void clear_entry(); Chris@1: 00596 void clear_field_name(); Chris@1: 00597 void clear_field_value(); Chris@1: 00598 void construct(const char *field, unsigned field_length); Chris@1: 00599 void construct(const char *field); // assumes \a field is NUL-terminated Chris@1: 00600 void construct(const char *field_name, const char *field_value, unsigned field_value_length); Chris@1: 00601 void construct(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated Chris@1: 00602 void compose_field(); Chris@1: 00603 void parse_field(); Chris@1: 00604 }; Chris@1: 00605 Chris@1: 00606 VorbisComment(); Chris@1: 00607 Chris@1: 00609 Chris@1: 00612 inline VorbisComment(const VorbisComment &object): Prototype(object) { } Chris@1: 00613 inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@1: 00614 inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@1: 00616 Chris@1: 00620 inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@1: 00621 Chris@1: 00622 ~VorbisComment(); Chris@1: 00623 Chris@1: 00625 Chris@1: 00626 inline VorbisComment &operator=(const VorbisComment &object) { Prototype::operator=(object); return *this; } Chris@1: 00627 inline VorbisComment &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@1: 00628 inline VorbisComment &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@1: 00630 Chris@1: 00634 inline VorbisComment &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@1: 00635 Chris@1: 00637 Chris@1: 00638 inline bool operator==(const VorbisComment &object) const { return Prototype::operator==(object); } Chris@1: 00639 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@1: 00640 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@1: 00642 Chris@1: 00644 Chris@1: 00645 inline bool operator!=(const VorbisComment &object) const { return Prototype::operator!=(object); } Chris@1: 00646 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@1: 00647 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@1: 00649 Chris@1: 00650 unsigned get_num_comments() const; Chris@1: 00651 const FLAC__byte *get_vendor_string() const; // NUL-terminated UTF-8 string Chris@1: 00652 Entry get_comment(unsigned index) const; Chris@1: 00653 Chris@1: 00655 bool set_vendor_string(const FLAC__byte *string); // NUL-terminated UTF-8 string Chris@1: 00656 Chris@1: 00658 bool set_comment(unsigned index, const Entry &entry); Chris@1: 00659 Chris@1: 00661 bool insert_comment(unsigned index, const Entry &entry); Chris@1: 00662 Chris@1: 00664 bool append_comment(const Entry &entry); Chris@1: 00665 Chris@1: 00667 bool delete_comment(unsigned index); Chris@1: 00668 }; Chris@1: 00669 Chris@1: 00674 class FLACPP_API CueSheet : public Prototype { Chris@1: 00675 public: Chris@1: 00682 class FLACPP_API Track { Chris@1: 00683 protected: Chris@1: 00684 ::FLAC__StreamMetadata_CueSheet_Track *object_; Chris@1: 00685 public: Chris@1: 00686 Track(); Chris@1: 00687 Track(const ::FLAC__StreamMetadata_CueSheet_Track *track); Chris@1: 00688 Track(const Track &track); Chris@1: 00689 Track &operator=(const Track &track); Chris@1: 00690 Chris@1: 00691 virtual ~Track(); Chris@1: 00692 Chris@1: 00693 virtual bool is_valid() const; Chris@1: 00694 Chris@1: 00695 Chris@1: 00696 inline FLAC__uint64 get_offset() const { return object_->offset; } Chris@1: 00697 inline FLAC__byte get_number() const { return object_->number; } Chris@1: 00698 inline const char *get_isrc() const { return object_->isrc; } Chris@1: 00699 inline unsigned get_type() const { return object_->type; } Chris@1: 00700 inline bool get_pre_emphasis() const { return object_->pre_emphasis; } Chris@1: 00701 Chris@1: 00702 inline FLAC__byte get_num_indices() const { return object_->num_indices; } Chris@1: 00703 ::FLAC__StreamMetadata_CueSheet_Index get_index(unsigned i) const; Chris@1: 00704 Chris@1: 00705 inline const ::FLAC__StreamMetadata_CueSheet_Track *get_track() const { return object_; } Chris@1: 00706 Chris@1: 00707 inline void set_offset(FLAC__uint64 value) { object_->offset = value; } Chris@1: 00708 inline void set_number(FLAC__byte value) { object_->number = value; } Chris@1: 00709 void set_isrc(const char value[12]); Chris@1: 00710 void set_type(unsigned value); Chris@1: 00711 inline void set_pre_emphasis(bool value) { object_->pre_emphasis = value? 1 : 0; } Chris@1: 00712 Chris@1: 00713 void set_index(unsigned i, const ::FLAC__StreamMetadata_CueSheet_Index &index); Chris@1: 00714 //@@@ It's awkward but to insert/delete index points Chris@1: 00715 //@@@ you must use the routines in the CueSheet class. Chris@1: 00716 }; Chris@1: 00717 Chris@1: 00718 CueSheet(); Chris@1: 00719 Chris@1: 00721 Chris@1: 00724 inline CueSheet(const CueSheet &object): Prototype(object) { } Chris@1: 00725 inline CueSheet(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@1: 00726 inline CueSheet(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@1: 00728 Chris@1: 00732 inline CueSheet(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@1: 00733 Chris@1: 00734 ~CueSheet(); Chris@1: 00735 Chris@1: 00737 Chris@1: 00738 inline CueSheet &operator=(const CueSheet &object) { Prototype::operator=(object); return *this; } Chris@1: 00739 inline CueSheet &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@1: 00740 inline CueSheet &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@1: 00742 Chris@1: 00746 inline CueSheet &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@1: 00747 Chris@1: 00749 Chris@1: 00750 inline bool operator==(const CueSheet &object) const { return Prototype::operator==(object); } Chris@1: 00751 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@1: 00752 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@1: 00754 Chris@1: 00756 Chris@1: 00757 inline bool operator!=(const CueSheet &object) const { return Prototype::operator!=(object); } Chris@1: 00758 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@1: 00759 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@1: 00761 Chris@1: 00762 const char *get_media_catalog_number() const; Chris@1: 00763 FLAC__uint64 get_lead_in() const; Chris@1: 00764 bool get_is_cd() const; Chris@1: 00765 Chris@1: 00766 unsigned get_num_tracks() const; Chris@1: 00767 Track get_track(unsigned i) const; Chris@1: 00768 Chris@1: 00769 void set_media_catalog_number(const char value[128]); Chris@1: 00770 void set_lead_in(FLAC__uint64 value); Chris@1: 00771 void set_is_cd(bool value); Chris@1: 00772 Chris@1: 00773 void set_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index); Chris@1: 00774 Chris@1: 00776 bool insert_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index); Chris@1: 00777 Chris@1: 00779 bool delete_index(unsigned track_num, unsigned index_num); Chris@1: 00780 Chris@1: 00782 bool set_track(unsigned i, const Track &track); Chris@1: 00783 Chris@1: 00785 bool insert_track(unsigned i, const Track &track); Chris@1: 00786 Chris@1: 00788 bool delete_track(unsigned i); Chris@1: 00789 Chris@1: 00791 bool is_legal(bool check_cd_da_subset = false, const char **violation = 0) const; Chris@1: 00792 Chris@1: 00794 FLAC__uint32 calculate_cddb_id() const; Chris@1: 00795 }; Chris@1: 00796 Chris@1: 00801 class FLACPP_API Picture : public Prototype { Chris@1: 00802 public: Chris@1: 00803 Picture(); Chris@1: 00804 Chris@1: 00806 Chris@1: 00809 inline Picture(const Picture &object): Prototype(object) { } Chris@1: 00810 inline Picture(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@1: 00811 inline Picture(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@1: 00813 Chris@1: 00817 inline Picture(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@1: 00818 Chris@1: 00819 ~Picture(); Chris@1: 00820 Chris@1: 00822 Chris@1: 00823 inline Picture &operator=(const Picture &object) { Prototype::operator=(object); return *this; } Chris@1: 00824 inline Picture &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@1: 00825 inline Picture &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@1: 00827 Chris@1: 00831 inline Picture &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@1: 00832 Chris@1: 00834 Chris@1: 00835 inline bool operator==(const Picture &object) const { return Prototype::operator==(object); } Chris@1: 00836 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@1: 00837 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@1: 00839 Chris@1: 00841 Chris@1: 00842 inline bool operator!=(const Picture &object) const { return Prototype::operator!=(object); } Chris@1: 00843 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@1: 00844 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@1: 00846 Chris@1: 00847 ::FLAC__StreamMetadata_Picture_Type get_type() const; Chris@1: 00848 const char *get_mime_type() const; // NUL-terminated printable ASCII string Chris@1: 00849 const FLAC__byte *get_description() const; // NUL-terminated UTF-8 string Chris@1: 00850 FLAC__uint32 get_width() const; Chris@1: 00851 FLAC__uint32 get_height() const; Chris@1: 00852 FLAC__uint32 get_depth() const; Chris@1: 00853 FLAC__uint32 get_colors() const; Chris@1: 00854 FLAC__uint32 get_data_length() const; Chris@1: 00855 const FLAC__byte *get_data() const; Chris@1: 00856 Chris@1: 00857 void set_type(::FLAC__StreamMetadata_Picture_Type type); Chris@1: 00858 Chris@1: 00860 bool set_mime_type(const char *string); // NUL-terminated printable ASCII string Chris@1: 00861 Chris@1: 00863 bool set_description(const FLAC__byte *string); // NUL-terminated UTF-8 string Chris@1: 00864 Chris@1: 00865 void set_width(FLAC__uint32 value) const; Chris@1: 00866 void set_height(FLAC__uint32 value) const; Chris@1: 00867 void set_depth(FLAC__uint32 value) const; Chris@1: 00868 void set_colors(FLAC__uint32 value) const; Chris@1: 00869 Chris@1: 00871 bool set_data(const FLAC__byte *data, FLAC__uint32 data_length); Chris@1: 00872 }; Chris@1: 00873 Chris@1: 00880 class FLACPP_API Unknown : public Prototype { Chris@1: 00881 public: Chris@1: 00882 Unknown(); Chris@1: 00883 // Chris@1: 00885 Chris@1: 00888 inline Unknown(const Unknown &object): Prototype(object) { } Chris@1: 00889 inline Unknown(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@1: 00890 inline Unknown(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@1: 00892 Chris@1: 00896 inline Unknown(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@1: 00897 Chris@1: 00898 ~Unknown(); Chris@1: 00899 Chris@1: 00901 Chris@1: 00902 inline Unknown &operator=(const Unknown &object) { Prototype::operator=(object); return *this; } Chris@1: 00903 inline Unknown &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@1: 00904 inline Unknown &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@1: 00906 Chris@1: 00910 inline Unknown &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@1: 00911 Chris@1: 00913 Chris@1: 00914 inline bool operator==(const Unknown &object) const { return Prototype::operator==(object); } Chris@1: 00915 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@1: 00916 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@1: 00918 Chris@1: 00920 Chris@1: 00921 inline bool operator!=(const Unknown &object) const { return Prototype::operator!=(object); } Chris@1: 00922 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@1: 00923 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@1: 00925 Chris@1: 00926 const FLAC__byte *get_data() const; Chris@1: 00927 Chris@1: 00929 bool set_data(const FLAC__byte *data, unsigned length); Chris@1: 00930 bool set_data(FLAC__byte *data, unsigned length, bool copy); Chris@1: 00931 }; Chris@1: 00932 Chris@1: 00933 /* \} */ Chris@1: 00934 Chris@1: 00935 Chris@1: 00948 FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo); Chris@1: 00949 Chris@1: 00950 FLACPP_API bool get_tags(const char *filename, VorbisComment *&tags); Chris@1: 00951 FLACPP_API bool get_tags(const char *filename, VorbisComment &tags); Chris@1: 00952 Chris@1: 00953 FLACPP_API bool get_cuesheet(const char *filename, CueSheet *&cuesheet); Chris@1: 00954 FLACPP_API bool get_cuesheet(const char *filename, CueSheet &cuesheet); Chris@1: 00955 Chris@1: 00956 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); Chris@1: 00957 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); Chris@1: 00958 Chris@1: 00959 /* \} */ Chris@1: 00960 Chris@1: 00961 Chris@1: 00996 class FLACPP_API SimpleIterator { Chris@1: 00997 public: Chris@1: 01000 class FLACPP_API Status { Chris@1: 01001 public: Chris@1: 01002 inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { } Chris@1: 01003 inline operator ::FLAC__Metadata_SimpleIteratorStatus() const { return status_; } Chris@1: 01004 inline const char *as_cstring() const { return ::FLAC__Metadata_SimpleIteratorStatusString[status_]; } Chris@1: 01005 protected: Chris@1: 01006 ::FLAC__Metadata_SimpleIteratorStatus status_; Chris@1: 01007 }; Chris@1: 01008 Chris@1: 01009 SimpleIterator(); Chris@1: 01010 virtual ~SimpleIterator(); Chris@1: 01011 Chris@1: 01012 bool is_valid() const; Chris@1: 01013 Chris@1: 01014 bool init(const char *filename, bool read_only, bool preserve_file_stats); Chris@1: 01015 Chris@1: 01016 Status status(); Chris@1: 01017 bool is_writable() const; Chris@1: 01018 Chris@1: 01019 bool next(); Chris@1: 01020 bool prev(); Chris@1: 01021 bool is_last() const; Chris@1: 01022 Chris@1: 01023 off_t get_block_offset() const; Chris@1: 01024 ::FLAC__MetadataType get_block_type() const; Chris@1: 01025 unsigned get_block_length() const; Chris@1: 01026 bool get_application_id(FLAC__byte *id); Chris@1: 01027 Prototype *get_block(); Chris@1: 01028 bool set_block(Prototype *block, bool use_padding = true); Chris@1: 01029 bool insert_block_after(Prototype *block, bool use_padding = true); Chris@1: 01030 bool delete_block(bool use_padding = true); Chris@1: 01031 Chris@1: 01032 protected: Chris@1: 01033 ::FLAC__Metadata_SimpleIterator *iterator_; Chris@1: 01034 void clear(); Chris@1: 01035 }; Chris@1: 01036 Chris@1: 01037 /* \} */ Chris@1: 01038 Chris@1: 01039 Chris@1: 01082 class FLACPP_API Chain { Chris@1: 01083 public: Chris@1: 01086 class FLACPP_API Status { Chris@1: 01087 public: Chris@1: 01088 inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { } Chris@1: 01089 inline operator ::FLAC__Metadata_ChainStatus() const { return status_; } Chris@1: 01090 inline const char *as_cstring() const { return ::FLAC__Metadata_ChainStatusString[status_]; } Chris@1: 01091 protected: Chris@1: 01092 ::FLAC__Metadata_ChainStatus status_; Chris@1: 01093 }; Chris@1: 01094 Chris@1: 01095 Chain(); Chris@1: 01096 virtual ~Chain(); Chris@1: 01097 Chris@1: 01098 friend class Iterator; Chris@1: 01099 Chris@1: 01100 bool is_valid() const; Chris@1: 01101 Chris@1: 01102 Status status(); Chris@1: 01103 Chris@1: 01104 bool read(const char *filename, bool is_ogg = false); Chris@1: 01105 bool read(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, bool is_ogg = false); Chris@1: 01106 Chris@1: 01107 bool check_if_tempfile_needed(bool use_padding); Chris@1: 01108 Chris@1: 01109 bool write(bool use_padding = true, bool preserve_file_stats = false); Chris@1: 01110 bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks); Chris@1: 01111 bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks, ::FLAC__IOHandle temp_handle, ::FLAC__IOCallbacks temp_callbacks); Chris@1: 01112 Chris@1: 01113 void merge_padding(); Chris@1: 01114 void sort_padding(); Chris@1: 01115 Chris@1: 01116 protected: Chris@1: 01117 ::FLAC__Metadata_Chain *chain_; Chris@1: 01118 virtual void clear(); Chris@1: 01119 }; Chris@1: 01120 Chris@1: 01126 class FLACPP_API Iterator { Chris@1: 01127 public: Chris@1: 01128 Iterator(); Chris@1: 01129 virtual ~Iterator(); Chris@1: 01130 Chris@1: 01131 bool is_valid() const; Chris@1: 01132 Chris@1: 01133 Chris@1: 01134 void init(Chain &chain); Chris@1: 01135 Chris@1: 01136 bool next(); Chris@1: 01137 bool prev(); Chris@1: 01138 Chris@1: 01139 ::FLAC__MetadataType get_block_type() const; Chris@1: 01140 Prototype *get_block(); Chris@1: 01141 bool set_block(Prototype *block); Chris@1: 01142 bool delete_block(bool replace_with_padding); Chris@1: 01143 bool insert_block_before(Prototype *block); Chris@1: 01144 bool insert_block_after(Prototype *block); Chris@1: 01145 Chris@1: 01146 protected: Chris@1: 01147 ::FLAC__Metadata_Iterator *iterator_; Chris@1: 01148 virtual void clear(); Chris@1: 01149 }; Chris@1: 01150 Chris@1: 01151 /* \} */ Chris@1: 01152 Chris@1: 01153 } Chris@1: 01154 } Chris@1: 01155 Chris@1: 01156 #endif Chris@1: