1*600f14f4SXin Li /* libFLAC++ - Free Lossless Audio Codec library 2*600f14f4SXin Li * Copyright (C) 2002-2009 Josh Coalson 3*600f14f4SXin Li * Copyright (C) 2011-2023 Xiph.Org Foundation 4*600f14f4SXin Li * 5*600f14f4SXin Li * Redistribution and use in source and binary forms, with or without 6*600f14f4SXin Li * modification, are permitted provided that the following conditions 7*600f14f4SXin Li * are met: 8*600f14f4SXin Li * 9*600f14f4SXin Li * - Redistributions of source code must retain the above copyright 10*600f14f4SXin Li * notice, this list of conditions and the following disclaimer. 11*600f14f4SXin Li * 12*600f14f4SXin Li * - Redistributions in binary form must reproduce the above copyright 13*600f14f4SXin Li * notice, this list of conditions and the following disclaimer in the 14*600f14f4SXin Li * documentation and/or other materials provided with the distribution. 15*600f14f4SXin Li * 16*600f14f4SXin Li * - Neither the name of the Xiph.org Foundation nor the names of its 17*600f14f4SXin Li * contributors may be used to endorse or promote products derived from 18*600f14f4SXin Li * this software without specific prior written permission. 19*600f14f4SXin Li * 20*600f14f4SXin Li * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21*600f14f4SXin Li * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22*600f14f4SXin Li * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23*600f14f4SXin Li * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24*600f14f4SXin Li * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25*600f14f4SXin Li * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26*600f14f4SXin Li * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27*600f14f4SXin Li * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28*600f14f4SXin Li * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29*600f14f4SXin Li * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30*600f14f4SXin Li * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31*600f14f4SXin Li */ 32*600f14f4SXin Li 33*600f14f4SXin Li #ifndef FLACPP__METADATA_H 34*600f14f4SXin Li #define FLACPP__METADATA_H 35*600f14f4SXin Li 36*600f14f4SXin Li #include "export.h" 37*600f14f4SXin Li 38*600f14f4SXin Li #include "FLAC/metadata.h" 39*600f14f4SXin Li 40*600f14f4SXin Li // =============================================================== 41*600f14f4SXin Li // 42*600f14f4SXin Li // Full documentation for the metadata interface can be found 43*600f14f4SXin Li // in the C layer in include/FLAC/metadata.h 44*600f14f4SXin Li // 45*600f14f4SXin Li // =============================================================== 46*600f14f4SXin Li 47*600f14f4SXin Li /** \file include/FLAC++/metadata.h 48*600f14f4SXin Li * 49*600f14f4SXin Li * \brief 50*600f14f4SXin Li * This module provides classes for creating and manipulating FLAC 51*600f14f4SXin Li * metadata blocks in memory, and three progressively more powerful 52*600f14f4SXin Li * interfaces for traversing and editing metadata in FLAC files. 53*600f14f4SXin Li * 54*600f14f4SXin Li * See the detailed documentation for each interface in the 55*600f14f4SXin Li * \link flacpp_metadata metadata \endlink module. 56*600f14f4SXin Li */ 57*600f14f4SXin Li 58*600f14f4SXin Li /** \defgroup flacpp_metadata FLAC++/metadata.h: metadata interfaces 59*600f14f4SXin Li * \ingroup flacpp 60*600f14f4SXin Li * 61*600f14f4SXin Li * \brief 62*600f14f4SXin Li * This module provides classes for creating and manipulating FLAC 63*600f14f4SXin Li * metadata blocks in memory, and three progressively more powerful 64*600f14f4SXin Li * interfaces for traversing and editing metadata in FLAC files. 65*600f14f4SXin Li * 66*600f14f4SXin Li * The behavior closely mimics the C layer interface; be sure to read 67*600f14f4SXin Li * the detailed description of the 68*600f14f4SXin Li * \link flac_metadata C metadata module \endlink. Note that like the 69*600f14f4SXin Li * C layer, currently only the Chain interface (level 2) supports Ogg 70*600f14f4SXin Li * FLAC files, and it is read-only i.e. no writing back changed 71*600f14f4SXin Li * metadata to file. 72*600f14f4SXin Li */ 73*600f14f4SXin Li 74*600f14f4SXin Li 75*600f14f4SXin Li namespace FLAC { 76*600f14f4SXin Li namespace Metadata { 77*600f14f4SXin Li 78*600f14f4SXin Li // ============================================================ 79*600f14f4SXin Li // 80*600f14f4SXin Li // Metadata objects 81*600f14f4SXin Li // 82*600f14f4SXin Li // ============================================================ 83*600f14f4SXin Li 84*600f14f4SXin Li /** \defgroup flacpp_metadata_object FLAC++/metadata.h: metadata object classes 85*600f14f4SXin Li * \ingroup flacpp_metadata 86*600f14f4SXin Li * 87*600f14f4SXin Li * This module contains classes representing FLAC metadata 88*600f14f4SXin Li * blocks in memory. 89*600f14f4SXin Li * 90*600f14f4SXin Li * The behavior closely mimics the C layer interface; be 91*600f14f4SXin Li * sure to read the detailed description of the 92*600f14f4SXin Li * \link flac_metadata_object C metadata object module \endlink. 93*600f14f4SXin Li * 94*600f14f4SXin Li * Any time a metadata object is constructed or assigned, you 95*600f14f4SXin Li * should check is_valid() to make sure the underlying 96*600f14f4SXin Li * ::FLAC__StreamMetadata object was able to be created. 97*600f14f4SXin Li * 98*600f14f4SXin Li * \warning 99*600f14f4SXin Li * When the get_*() methods of any metadata object method 100*600f14f4SXin Li * return you a const pointer, DO NOT disobey and write into it. 101*600f14f4SXin Li * Always use the set_*() methods. 102*600f14f4SXin Li * 103*600f14f4SXin Li * \{ 104*600f14f4SXin Li */ 105*600f14f4SXin Li 106*600f14f4SXin Li /** Base class for all metadata block types. 107*600f14f4SXin Li * See the \link flacpp_metadata_object overview \endlink for more. 108*600f14f4SXin Li */ 109*600f14f4SXin Li class FLACPP_API Prototype { 110*600f14f4SXin Li protected: 111*600f14f4SXin Li //@{ 112*600f14f4SXin Li /** Constructs a copy of the given object. This form 113*600f14f4SXin Li * always performs a deep copy. 114*600f14f4SXin Li */ 115*600f14f4SXin Li Prototype(const Prototype &); 116*600f14f4SXin Li Prototype(const ::FLAC__StreamMetadata &); 117*600f14f4SXin Li Prototype(const ::FLAC__StreamMetadata *); 118*600f14f4SXin Li //@} 119*600f14f4SXin Li 120*600f14f4SXin Li /** Constructs an object with copy control. When \a copy 121*600f14f4SXin Li * is \c true, behaves identically to 122*600f14f4SXin Li * FLAC::Metadata::Prototype::Prototype(const ::FLAC__StreamMetadata *object). 123*600f14f4SXin Li * When \a copy is \c false, the instance takes ownership of 124*600f14f4SXin Li * the pointer and the ::FLAC__StreamMetadata object will 125*600f14f4SXin Li * be freed by the destructor. 126*600f14f4SXin Li * 127*600f14f4SXin Li * \assert 128*600f14f4SXin Li * \code object != NULL \endcode 129*600f14f4SXin Li */ 130*600f14f4SXin Li Prototype(::FLAC__StreamMetadata *object, bool copy); 131*600f14f4SXin Li 132*600f14f4SXin Li //@{ 133*600f14f4SXin Li /** Assign from another object. Always performs a deep copy. */ 134*600f14f4SXin Li Prototype &operator=(const Prototype &); 135*600f14f4SXin Li Prototype &operator=(const ::FLAC__StreamMetadata &); 136*600f14f4SXin Li Prototype &operator=(const ::FLAC__StreamMetadata *); 137*600f14f4SXin Li //@} 138*600f14f4SXin Li 139*600f14f4SXin Li /** Assigns an object with copy control. See 140*600f14f4SXin Li * Prototype(::FLAC__StreamMetadata *object, bool copy). 141*600f14f4SXin Li */ 142*600f14f4SXin Li Prototype &assign_object(::FLAC__StreamMetadata *object, bool copy); 143*600f14f4SXin Li 144*600f14f4SXin Li /** Deletes the underlying ::FLAC__StreamMetadata object. 145*600f14f4SXin Li */ 146*600f14f4SXin Li virtual void clear(); 147*600f14f4SXin Li 148*600f14f4SXin Li ::FLAC__StreamMetadata *object_; 149*600f14f4SXin Li public: 150*600f14f4SXin Li /** Deletes the underlying ::FLAC__StreamMetadata object. 151*600f14f4SXin Li */ 152*600f14f4SXin Li virtual ~Prototype(); 153*600f14f4SXin Li 154*600f14f4SXin Li //@{ 155*600f14f4SXin Li /** Check for equality, performing a deep compare by following pointers. 156*600f14f4SXin Li */ 157*600f14f4SXin Li inline bool operator==(const Prototype &) const; 158*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata &) const; 159*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata *) const; 160*600f14f4SXin Li //@} 161*600f14f4SXin Li 162*600f14f4SXin Li //@{ 163*600f14f4SXin Li /** Check for inequality, performing a deep compare by following pointers. */ 164*600f14f4SXin Li inline bool operator!=(const Prototype &) const; 165*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata &) const; 166*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata *) const; 167*600f14f4SXin Li //@} 168*600f14f4SXin Li 169*600f14f4SXin Li friend class SimpleIterator; 170*600f14f4SXin Li friend class Iterator; 171*600f14f4SXin Li 172*600f14f4SXin Li /** Returns \c true if the object was correctly constructed 173*600f14f4SXin Li * (i.e. the underlying ::FLAC__StreamMetadata object was 174*600f14f4SXin Li * properly allocated), else \c false. 175*600f14f4SXin Li */ 176*600f14f4SXin Li inline bool is_valid() const; 177*600f14f4SXin Li 178*600f14f4SXin Li /** Returns \c true if this block is the last block in a 179*600f14f4SXin Li * stream, else \c false. 180*600f14f4SXin Li * 181*600f14f4SXin Li * \assert 182*600f14f4SXin Li * \code is_valid() \endcode 183*600f14f4SXin Li */ 184*600f14f4SXin Li bool get_is_last() const; 185*600f14f4SXin Li 186*600f14f4SXin Li /** Returns the type of the block. 187*600f14f4SXin Li * 188*600f14f4SXin Li * \assert 189*600f14f4SXin Li * \code is_valid() \endcode 190*600f14f4SXin Li */ 191*600f14f4SXin Li ::FLAC__MetadataType get_type() const; 192*600f14f4SXin Li 193*600f14f4SXin Li /** Returns the stream length of the metadata block. 194*600f14f4SXin Li * 195*600f14f4SXin Li * \note 196*600f14f4SXin Li * The length does not include the metadata block header, 197*600f14f4SXin Li * per spec. 198*600f14f4SXin Li * 199*600f14f4SXin Li * \assert 200*600f14f4SXin Li * \code is_valid() \endcode 201*600f14f4SXin Li */ 202*600f14f4SXin Li uint32_t get_length() const; 203*600f14f4SXin Li 204*600f14f4SXin Li /** Sets the "is_last" flag for the block. When using the iterators 205*600f14f4SXin Li * it is not necessary to set this flag; they will do it for you. 206*600f14f4SXin Li * 207*600f14f4SXin Li * \assert 208*600f14f4SXin Li * \code is_valid() \endcode 209*600f14f4SXin Li */ 210*600f14f4SXin Li void set_is_last(bool); 211*600f14f4SXin Li 212*600f14f4SXin Li /** Returns a pointer to the underlying ::FLAC__StreamMetadata 213*600f14f4SXin Li * object. This can be useful for plugging any holes between 214*600f14f4SXin Li * the C++ and C interfaces. 215*600f14f4SXin Li * 216*600f14f4SXin Li * \assert 217*600f14f4SXin Li * \code is_valid() \endcode 218*600f14f4SXin Li */ 219*600f14f4SXin Li inline operator const ::FLAC__StreamMetadata *() const; 220*600f14f4SXin Li private: 221*600f14f4SXin Li /** Private and undefined so you can't use it. */ 222*600f14f4SXin Li Prototype(); 223*600f14f4SXin Li 224*600f14f4SXin Li // These are used only by Iterator 225*600f14f4SXin Li bool is_reference_; set_reference(bool x)226*600f14f4SXin Li inline void set_reference(bool x) { is_reference_ = x; } 227*600f14f4SXin Li }; 228*600f14f4SXin Li 229*600f14f4SXin Li // local utility routines 230*600f14f4SXin Li 231*600f14f4SXin Li namespace local { 232*600f14f4SXin Li 233*600f14f4SXin Li /** Construct a new object of the type provided in object->type and return it. */ 234*600f14f4SXin Li Prototype *construct_block(::FLAC__StreamMetadata *object); 235*600f14f4SXin Li 236*600f14f4SXin Li } 237*600f14f4SXin Li 238*600f14f4SXin Li #ifdef _MSC_VER 239*600f14f4SXin Li // warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) 240*600f14f4SXin Li #pragma warning ( disable : 4800 ) 241*600f14f4SXin Li #endif 242*600f14f4SXin Li 243*600f14f4SXin Li inline bool Prototype::operator==(const Prototype &object) const 244*600f14f4SXin Li { return (bool)::FLAC__metadata_object_is_equal(object_, object.object_); } 245*600f14f4SXin Li 246*600f14f4SXin Li inline bool Prototype::operator==(const ::FLAC__StreamMetadata &object) const 247*600f14f4SXin Li { return (bool)::FLAC__metadata_object_is_equal(object_, &object); } 248*600f14f4SXin Li 249*600f14f4SXin Li inline bool Prototype::operator==(const ::FLAC__StreamMetadata *object) const 250*600f14f4SXin Li { return (bool)::FLAC__metadata_object_is_equal(object_, object); } 251*600f14f4SXin Li 252*600f14f4SXin Li #ifdef _MSC_VER 253*600f14f4SXin Li #pragma warning ( default : 4800 ) 254*600f14f4SXin Li #endif 255*600f14f4SXin Li 256*600f14f4SXin Li inline bool Prototype::operator!=(const Prototype &object) const 257*600f14f4SXin Li { return !operator==(object); } 258*600f14f4SXin Li 259*600f14f4SXin Li inline bool Prototype::operator!=(const ::FLAC__StreamMetadata &object) const 260*600f14f4SXin Li { return !operator==(object); } 261*600f14f4SXin Li 262*600f14f4SXin Li inline bool Prototype::operator!=(const ::FLAC__StreamMetadata *object) const 263*600f14f4SXin Li { return !operator==(object); } 264*600f14f4SXin Li is_valid()265*600f14f4SXin Li inline bool Prototype::is_valid() const 266*600f14f4SXin Li { return 0 != object_; } 267*600f14f4SXin Li 268*600f14f4SXin Li inline Prototype::operator const ::FLAC__StreamMetadata *() const 269*600f14f4SXin Li { return object_; } 270*600f14f4SXin Li 271*600f14f4SXin Li /** Create a deep copy of an object and return it. */ 272*600f14f4SXin Li FLACPP_API Prototype *clone(const Prototype *); 273*600f14f4SXin Li 274*600f14f4SXin Li 275*600f14f4SXin Li /** STREAMINFO metadata block. 276*600f14f4SXin Li * See the \link flacpp_metadata_object overview \endlink for more, 277*600f14f4SXin Li * and the <A HREF="https://xiph.org/flac/format.html#metadata_block_streaminfo">format specification</A>. 278*600f14f4SXin Li */ 279*600f14f4SXin Li class FLACPP_API StreamInfo : public Prototype { 280*600f14f4SXin Li public: 281*600f14f4SXin Li StreamInfo(); 282*600f14f4SXin Li 283*600f14f4SXin Li //@{ 284*600f14f4SXin Li /** Constructs a copy of the given object. This form 285*600f14f4SXin Li * always performs a deep copy. 286*600f14f4SXin Li */ StreamInfo(const StreamInfo & object)287*600f14f4SXin Li inline StreamInfo(const StreamInfo &object): Prototype(object) { } StreamInfo(const::FLAC__StreamMetadata & object)288*600f14f4SXin Li inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { } StreamInfo(const::FLAC__StreamMetadata * object)289*600f14f4SXin Li inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { } 290*600f14f4SXin Li //@} 291*600f14f4SXin Li 292*600f14f4SXin Li /** Constructs an object with copy control. See 293*600f14f4SXin Li * Prototype(::FLAC__StreamMetadata *object, bool copy). 294*600f14f4SXin Li */ StreamInfo(::FLAC__StreamMetadata * object,bool copy)295*600f14f4SXin Li inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 296*600f14f4SXin Li 297*600f14f4SXin Li ~StreamInfo(); 298*600f14f4SXin Li 299*600f14f4SXin Li //@{ 300*600f14f4SXin Li /** Assign from another object. Always performs a deep copy. */ 301*600f14f4SXin Li inline StreamInfo &operator=(const StreamInfo &object) { Prototype::operator=(object); return *this; } 302*600f14f4SXin Li inline StreamInfo &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 303*600f14f4SXin Li inline StreamInfo &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 304*600f14f4SXin Li //@} 305*600f14f4SXin Li 306*600f14f4SXin Li /** Assigns an object with copy control. See 307*600f14f4SXin Li * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). 308*600f14f4SXin Li */ assign(::FLAC__StreamMetadata * object,bool copy)309*600f14f4SXin Li inline StreamInfo &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 310*600f14f4SXin Li 311*600f14f4SXin Li //@{ 312*600f14f4SXin Li /** Check for equality, performing a deep compare by following pointers. */ 313*600f14f4SXin Li inline bool operator==(const StreamInfo &object) const { return Prototype::operator==(object); } 314*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 315*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 316*600f14f4SXin Li //@} 317*600f14f4SXin Li 318*600f14f4SXin Li //@{ 319*600f14f4SXin Li /** Check for inequality, performing a deep compare by following pointers. */ 320*600f14f4SXin Li inline bool operator!=(const StreamInfo &object) const { return Prototype::operator!=(object); } 321*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 322*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 323*600f14f4SXin Li //@} 324*600f14f4SXin Li 325*600f14f4SXin Li //@{ 326*600f14f4SXin Li /** See <A HREF="https://xiph.org/flac/format.html#metadata_block_streaminfo">format specification</A>. */ 327*600f14f4SXin Li uint32_t get_min_blocksize() const; 328*600f14f4SXin Li uint32_t get_max_blocksize() const; 329*600f14f4SXin Li uint32_t get_min_framesize() const; 330*600f14f4SXin Li uint32_t get_max_framesize() const; 331*600f14f4SXin Li uint32_t get_sample_rate() const; 332*600f14f4SXin Li uint32_t get_channels() const; 333*600f14f4SXin Li uint32_t get_bits_per_sample() const; 334*600f14f4SXin Li FLAC__uint64 get_total_samples() const; 335*600f14f4SXin Li const FLAC__byte *get_md5sum() const; 336*600f14f4SXin Li 337*600f14f4SXin Li void set_min_blocksize(uint32_t value); 338*600f14f4SXin Li void set_max_blocksize(uint32_t value); 339*600f14f4SXin Li void set_min_framesize(uint32_t value); 340*600f14f4SXin Li void set_max_framesize(uint32_t value); 341*600f14f4SXin Li void set_sample_rate(uint32_t value); 342*600f14f4SXin Li void set_channels(uint32_t value); 343*600f14f4SXin Li void set_bits_per_sample(uint32_t value); 344*600f14f4SXin Li void set_total_samples(FLAC__uint64 value); 345*600f14f4SXin Li void set_md5sum(const FLAC__byte value[16]); 346*600f14f4SXin Li //@} 347*600f14f4SXin Li }; 348*600f14f4SXin Li 349*600f14f4SXin Li /** PADDING metadata block. 350*600f14f4SXin Li * See the \link flacpp_metadata_object overview \endlink for more, 351*600f14f4SXin Li * and the <A HREF="https://xiph.org/flac/format.html#metadata_block_padding">format specification</A>. 352*600f14f4SXin Li */ 353*600f14f4SXin Li class FLACPP_API Padding : public Prototype { 354*600f14f4SXin Li public: 355*600f14f4SXin Li Padding(); 356*600f14f4SXin Li 357*600f14f4SXin Li //@{ 358*600f14f4SXin Li /** Constructs a copy of the given object. This form 359*600f14f4SXin Li * always performs a deep copy. 360*600f14f4SXin Li */ Padding(const Padding & object)361*600f14f4SXin Li inline Padding(const Padding &object): Prototype(object) { } Padding(const::FLAC__StreamMetadata & object)362*600f14f4SXin Li inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { } Padding(const::FLAC__StreamMetadata * object)363*600f14f4SXin Li inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { } 364*600f14f4SXin Li //@} 365*600f14f4SXin Li 366*600f14f4SXin Li /** Constructs an object with copy control. See 367*600f14f4SXin Li * Prototype(::FLAC__StreamMetadata *object, bool copy). 368*600f14f4SXin Li */ Padding(::FLAC__StreamMetadata * object,bool copy)369*600f14f4SXin Li inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 370*600f14f4SXin Li 371*600f14f4SXin Li /** Constructs an object with the given length. 372*600f14f4SXin Li */ 373*600f14f4SXin Li Padding(uint32_t length); 374*600f14f4SXin Li 375*600f14f4SXin Li ~Padding(); 376*600f14f4SXin Li 377*600f14f4SXin Li //@{ 378*600f14f4SXin Li /** Assign from another object. Always performs a deep copy. */ 379*600f14f4SXin Li inline Padding &operator=(const Padding &object) { Prototype::operator=(object); return *this; } 380*600f14f4SXin Li inline Padding &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 381*600f14f4SXin Li inline Padding &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 382*600f14f4SXin Li //@} 383*600f14f4SXin Li 384*600f14f4SXin Li /** Assigns an object with copy control. See 385*600f14f4SXin Li * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). 386*600f14f4SXin Li */ assign(::FLAC__StreamMetadata * object,bool copy)387*600f14f4SXin Li inline Padding &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 388*600f14f4SXin Li 389*600f14f4SXin Li //@{ 390*600f14f4SXin Li /** Check for equality, performing a deep compare by following pointers. */ 391*600f14f4SXin Li inline bool operator==(const Padding &object) const { return Prototype::operator==(object); } 392*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 393*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 394*600f14f4SXin Li //@} 395*600f14f4SXin Li 396*600f14f4SXin Li //@{ 397*600f14f4SXin Li /** Check for inequality, performing a deep compare by following pointers. */ 398*600f14f4SXin Li inline bool operator!=(const Padding &object) const { return Prototype::operator!=(object); } 399*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 400*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 401*600f14f4SXin Li //@} 402*600f14f4SXin Li 403*600f14f4SXin Li /** Sets the length in bytes of the padding block. 404*600f14f4SXin Li */ 405*600f14f4SXin Li void set_length(uint32_t length); 406*600f14f4SXin Li }; 407*600f14f4SXin Li 408*600f14f4SXin Li /** APPLICATION metadata block. 409*600f14f4SXin Li * See the \link flacpp_metadata_object overview \endlink for more, 410*600f14f4SXin Li * and the <A HREF="https://xiph.org/flac/format.html#metadata_block_application">format specification</A>. 411*600f14f4SXin Li */ 412*600f14f4SXin Li class FLACPP_API Application : public Prototype { 413*600f14f4SXin Li public: 414*600f14f4SXin Li Application(); 415*600f14f4SXin Li // 416*600f14f4SXin Li //@{ 417*600f14f4SXin Li /** Constructs a copy of the given object. This form 418*600f14f4SXin Li * always performs a deep copy. 419*600f14f4SXin Li */ Application(const Application & object)420*600f14f4SXin Li inline Application(const Application &object): Prototype(object) { } Application(const::FLAC__StreamMetadata & object)421*600f14f4SXin Li inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { } Application(const::FLAC__StreamMetadata * object)422*600f14f4SXin Li inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { } 423*600f14f4SXin Li //@} 424*600f14f4SXin Li 425*600f14f4SXin Li /** Constructs an object with copy control. See 426*600f14f4SXin Li * Prototype(::FLAC__StreamMetadata *object, bool copy). 427*600f14f4SXin Li */ Application(::FLAC__StreamMetadata * object,bool copy)428*600f14f4SXin Li inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 429*600f14f4SXin Li 430*600f14f4SXin Li ~Application(); 431*600f14f4SXin Li 432*600f14f4SXin Li //@{ 433*600f14f4SXin Li /** Assign from another object. Always performs a deep copy. */ 434*600f14f4SXin Li inline Application &operator=(const Application &object) { Prototype::operator=(object); return *this; } 435*600f14f4SXin Li inline Application &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 436*600f14f4SXin Li inline Application &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 437*600f14f4SXin Li //@} 438*600f14f4SXin Li 439*600f14f4SXin Li /** Assigns an object with copy control. See 440*600f14f4SXin Li * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). 441*600f14f4SXin Li */ assign(::FLAC__StreamMetadata * object,bool copy)442*600f14f4SXin Li inline Application &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 443*600f14f4SXin Li 444*600f14f4SXin Li //@{ 445*600f14f4SXin Li /** Check for equality, performing a deep compare by following pointers. */ 446*600f14f4SXin Li inline bool operator==(const Application &object) const { return Prototype::operator==(object); } 447*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 448*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 449*600f14f4SXin Li //@} 450*600f14f4SXin Li 451*600f14f4SXin Li //@{ 452*600f14f4SXin Li /** Check for inequality, performing a deep compare by following pointers. */ 453*600f14f4SXin Li inline bool operator!=(const Application &object) const { return Prototype::operator!=(object); } 454*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 455*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 456*600f14f4SXin Li //@} 457*600f14f4SXin Li 458*600f14f4SXin Li const FLAC__byte *get_id() const; 459*600f14f4SXin Li const FLAC__byte *get_data() const; 460*600f14f4SXin Li 461*600f14f4SXin Li void set_id(const FLAC__byte value[4]); 462*600f14f4SXin Li //! This form always copies \a data 463*600f14f4SXin Li bool set_data(const FLAC__byte *data, uint32_t length); 464*600f14f4SXin Li bool set_data(FLAC__byte *data, uint32_t length, bool copy); 465*600f14f4SXin Li }; 466*600f14f4SXin Li 467*600f14f4SXin Li /** SEEKTABLE metadata block. 468*600f14f4SXin Li * See the \link flacpp_metadata_object overview \endlink for more, 469*600f14f4SXin Li * and the <A HREF="https://xiph.org/flac/format.html#metadata_block_seektable">format specification</A>. 470*600f14f4SXin Li */ 471*600f14f4SXin Li class FLACPP_API SeekTable : public Prototype { 472*600f14f4SXin Li public: 473*600f14f4SXin Li SeekTable(); 474*600f14f4SXin Li 475*600f14f4SXin Li //@{ 476*600f14f4SXin Li /** Constructs a copy of the given object. This form 477*600f14f4SXin Li * always performs a deep copy. 478*600f14f4SXin Li */ SeekTable(const SeekTable & object)479*600f14f4SXin Li inline SeekTable(const SeekTable &object): Prototype(object) { } SeekTable(const::FLAC__StreamMetadata & object)480*600f14f4SXin Li inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { } SeekTable(const::FLAC__StreamMetadata * object)481*600f14f4SXin Li inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { } 482*600f14f4SXin Li //@} 483*600f14f4SXin Li 484*600f14f4SXin Li /** Constructs an object with copy control. See 485*600f14f4SXin Li * Prototype(::FLAC__StreamMetadata *object, bool copy). 486*600f14f4SXin Li */ SeekTable(::FLAC__StreamMetadata * object,bool copy)487*600f14f4SXin Li inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 488*600f14f4SXin Li 489*600f14f4SXin Li ~SeekTable(); 490*600f14f4SXin Li 491*600f14f4SXin Li //@{ 492*600f14f4SXin Li /** Assign from another object. Always performs a deep copy. */ 493*600f14f4SXin Li inline SeekTable &operator=(const SeekTable &object) { Prototype::operator=(object); return *this; } 494*600f14f4SXin Li inline SeekTable &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 495*600f14f4SXin Li inline SeekTable &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 496*600f14f4SXin Li //@} 497*600f14f4SXin Li 498*600f14f4SXin Li /** Assigns an object with copy control. See 499*600f14f4SXin Li * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). 500*600f14f4SXin Li */ assign(::FLAC__StreamMetadata * object,bool copy)501*600f14f4SXin Li inline SeekTable &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 502*600f14f4SXin Li 503*600f14f4SXin Li //@{ 504*600f14f4SXin Li /** Check for equality, performing a deep compare by following pointers. */ 505*600f14f4SXin Li inline bool operator==(const SeekTable &object) const { return Prototype::operator==(object); } 506*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 507*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 508*600f14f4SXin Li //@} 509*600f14f4SXin Li 510*600f14f4SXin Li //@{ 511*600f14f4SXin Li /** Check for inequality, performing a deep compare by following pointers. */ 512*600f14f4SXin Li inline bool operator!=(const SeekTable &object) const { return Prototype::operator!=(object); } 513*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 514*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 515*600f14f4SXin Li //@} 516*600f14f4SXin Li 517*600f14f4SXin Li uint32_t get_num_points() const; 518*600f14f4SXin Li ::FLAC__StreamMetadata_SeekPoint get_point(uint32_t index) const; 519*600f14f4SXin Li 520*600f14f4SXin Li //! See FLAC__metadata_object_seektable_resize_points() 521*600f14f4SXin Li bool resize_points(uint32_t new_num_points); 522*600f14f4SXin Li 523*600f14f4SXin Li //! See FLAC__metadata_object_seektable_set_point() 524*600f14f4SXin Li void set_point(uint32_t index, const ::FLAC__StreamMetadata_SeekPoint &point); 525*600f14f4SXin Li 526*600f14f4SXin Li //! See FLAC__metadata_object_seektable_insert_point() 527*600f14f4SXin Li bool insert_point(uint32_t index, const ::FLAC__StreamMetadata_SeekPoint &point); 528*600f14f4SXin Li 529*600f14f4SXin Li //! See FLAC__metadata_object_seektable_delete_point() 530*600f14f4SXin Li bool delete_point(uint32_t index); 531*600f14f4SXin Li 532*600f14f4SXin Li //! See FLAC__metadata_object_seektable_is_legal() 533*600f14f4SXin Li bool is_legal() const; 534*600f14f4SXin Li 535*600f14f4SXin Li //! See FLAC__metadata_object_seektable_template_append_placeholders() 536*600f14f4SXin Li bool template_append_placeholders(uint32_t num); 537*600f14f4SXin Li 538*600f14f4SXin Li //! See FLAC__metadata_object_seektable_template_append_point() 539*600f14f4SXin Li bool template_append_point(FLAC__uint64 sample_number); 540*600f14f4SXin Li 541*600f14f4SXin Li //! See FLAC__metadata_object_seektable_template_append_points() 542*600f14f4SXin Li bool template_append_points(FLAC__uint64 sample_numbers[], uint32_t num); 543*600f14f4SXin Li 544*600f14f4SXin Li //! See FLAC__metadata_object_seektable_template_append_spaced_points() 545*600f14f4SXin Li bool template_append_spaced_points(uint32_t num, FLAC__uint64 total_samples); 546*600f14f4SXin Li 547*600f14f4SXin Li //! See FLAC__metadata_object_seektable_template_append_spaced_points_by_samples() 548*600f14f4SXin Li bool template_append_spaced_points_by_samples(uint32_t samples, FLAC__uint64 total_samples); 549*600f14f4SXin Li 550*600f14f4SXin Li //! See FLAC__metadata_object_seektable_template_sort() 551*600f14f4SXin Li bool template_sort(bool compact); 552*600f14f4SXin Li }; 553*600f14f4SXin Li 554*600f14f4SXin Li /** VORBIS_COMMENT metadata block. 555*600f14f4SXin Li * See the \link flacpp_metadata_object overview \endlink for more, 556*600f14f4SXin Li * and the <A HREF="https://xiph.org/flac/format.html#metadata_block_vorbis_comment">format specification</A>. 557*600f14f4SXin Li */ 558*600f14f4SXin Li class FLACPP_API VorbisComment : public Prototype { 559*600f14f4SXin Li public: 560*600f14f4SXin Li /** Convenience class for encapsulating Vorbis comment 561*600f14f4SXin Li * entries. An entry is a vendor string or a comment 562*600f14f4SXin Li * field. In the case of a vendor string, the field 563*600f14f4SXin Li * name is undefined; only the field value is relevant. 564*600f14f4SXin Li * 565*600f14f4SXin Li * A \a field as used in the methods refers to an 566*600f14f4SXin Li * entire 'NAME=VALUE' string; for convenience the 567*600f14f4SXin Li * string is NUL-terminated. A length field is 568*600f14f4SXin Li * required in the unlikely event that the value 569*600f14f4SXin Li * contains contain embedded NULs. 570*600f14f4SXin Li * 571*600f14f4SXin Li * A \a field_name is what is on the left side of the 572*600f14f4SXin Li * first '=' in the \a field. By definition it is ASCII 573*600f14f4SXin Li * and so is NUL-terminated and does not require a 574*600f14f4SXin Li * length to describe it. \a field_name is undefined 575*600f14f4SXin Li * for a vendor string entry. 576*600f14f4SXin Li * 577*600f14f4SXin Li * A \a field_value is what is on the right side of the 578*600f14f4SXin Li * first '=' in the \a field. By definition, this may 579*600f14f4SXin Li * contain embedded NULs and so a \a field_value_length 580*600f14f4SXin Li * is required to describe it. However in practice, 581*600f14f4SXin Li * embedded NULs are not known to be used, so it is 582*600f14f4SXin Li * generally safe to treat field values as NUL- 583*600f14f4SXin Li * terminated UTF-8 strings. 584*600f14f4SXin Li * 585*600f14f4SXin Li * Always check is_valid() after the constructor or operator= 586*600f14f4SXin Li * to make sure memory was properly allocated and that the 587*600f14f4SXin Li * Entry conforms to the Vorbis comment specification. 588*600f14f4SXin Li */ 589*600f14f4SXin Li class FLACPP_API Entry { 590*600f14f4SXin Li public: 591*600f14f4SXin Li Entry(); 592*600f14f4SXin Li 593*600f14f4SXin Li Entry(const char *field, uint32_t field_length); 594*600f14f4SXin Li Entry(const char *field); // assumes \a field is NUL-terminated 595*600f14f4SXin Li 596*600f14f4SXin Li Entry(const char *field_name, const char *field_value, uint32_t field_value_length); 597*600f14f4SXin Li Entry(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated 598*600f14f4SXin Li 599*600f14f4SXin Li Entry(const Entry &entry); 600*600f14f4SXin Li 601*600f14f4SXin Li Entry &operator=(const Entry &entry); 602*600f14f4SXin Li 603*600f14f4SXin Li virtual ~Entry(); 604*600f14f4SXin Li 605*600f14f4SXin Li virtual bool is_valid() const; ///< Returns \c true iff object was properly constructed. 606*600f14f4SXin Li 607*600f14f4SXin Li uint32_t get_field_length() const; 608*600f14f4SXin Li uint32_t get_field_name_length() const; 609*600f14f4SXin Li uint32_t get_field_value_length() const; 610*600f14f4SXin Li 611*600f14f4SXin Li ::FLAC__StreamMetadata_VorbisComment_Entry get_entry() const; 612*600f14f4SXin Li const char *get_field() const; 613*600f14f4SXin Li const char *get_field_name() const; 614*600f14f4SXin Li const char *get_field_value() const; 615*600f14f4SXin Li 616*600f14f4SXin Li bool set_field(const char *field, uint32_t field_length); 617*600f14f4SXin Li bool set_field(const char *field); // assumes \a field is NUL-terminated 618*600f14f4SXin Li bool set_field_name(const char *field_name); 619*600f14f4SXin Li bool set_field_value(const char *field_value, uint32_t field_value_length); 620*600f14f4SXin Li bool set_field_value(const char *field_value); // assumes \a field_value is NUL-terminated 621*600f14f4SXin Li protected: 622*600f14f4SXin Li bool is_valid_; 623*600f14f4SXin Li ::FLAC__StreamMetadata_VorbisComment_Entry entry_; 624*600f14f4SXin Li char *field_name_; 625*600f14f4SXin Li uint32_t field_name_length_; 626*600f14f4SXin Li char *field_value_; 627*600f14f4SXin Li uint32_t field_value_length_; 628*600f14f4SXin Li private: 629*600f14f4SXin Li void zero(); 630*600f14f4SXin Li void clear(); 631*600f14f4SXin Li void clear_entry(); 632*600f14f4SXin Li void clear_field_name(); 633*600f14f4SXin Li void clear_field_value(); 634*600f14f4SXin Li void construct(const char *field, uint32_t field_length); 635*600f14f4SXin Li void construct(const char *field); // assumes \a field is NUL-terminated 636*600f14f4SXin Li void construct(const char *field_name, const char *field_value, uint32_t field_value_length); 637*600f14f4SXin Li void construct(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated 638*600f14f4SXin Li void compose_field(); 639*600f14f4SXin Li void parse_field(); 640*600f14f4SXin Li }; 641*600f14f4SXin Li 642*600f14f4SXin Li VorbisComment(); 643*600f14f4SXin Li 644*600f14f4SXin Li //@{ 645*600f14f4SXin Li /** Constructs a copy of the given object. This form 646*600f14f4SXin Li * always performs a deep copy. 647*600f14f4SXin Li */ VorbisComment(const VorbisComment & object)648*600f14f4SXin Li inline VorbisComment(const VorbisComment &object): Prototype(object) { } VorbisComment(const::FLAC__StreamMetadata & object)649*600f14f4SXin Li inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { } VorbisComment(const::FLAC__StreamMetadata * object)650*600f14f4SXin Li inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { } 651*600f14f4SXin Li //@} 652*600f14f4SXin Li 653*600f14f4SXin Li /** Constructs an object with copy control. See 654*600f14f4SXin Li * Prototype(::FLAC__StreamMetadata *object, bool copy). 655*600f14f4SXin Li */ VorbisComment(::FLAC__StreamMetadata * object,bool copy)656*600f14f4SXin Li inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 657*600f14f4SXin Li 658*600f14f4SXin Li ~VorbisComment(); 659*600f14f4SXin Li 660*600f14f4SXin Li //@{ 661*600f14f4SXin Li /** Assign from another object. Always performs a deep copy. */ 662*600f14f4SXin Li inline VorbisComment &operator=(const VorbisComment &object) { Prototype::operator=(object); return *this; } 663*600f14f4SXin Li inline VorbisComment &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 664*600f14f4SXin Li inline VorbisComment &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 665*600f14f4SXin Li //@} 666*600f14f4SXin Li 667*600f14f4SXin Li /** Assigns an object with copy control. See 668*600f14f4SXin Li * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). 669*600f14f4SXin Li */ assign(::FLAC__StreamMetadata * object,bool copy)670*600f14f4SXin Li inline VorbisComment &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 671*600f14f4SXin Li 672*600f14f4SXin Li //@{ 673*600f14f4SXin Li /** Check for equality, performing a deep compare by following pointers. */ 674*600f14f4SXin Li inline bool operator==(const VorbisComment &object) const { return Prototype::operator==(object); } 675*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 676*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 677*600f14f4SXin Li //@} 678*600f14f4SXin Li 679*600f14f4SXin Li //@{ 680*600f14f4SXin Li /** Check for inequality, performing a deep compare by following pointers. */ 681*600f14f4SXin Li inline bool operator!=(const VorbisComment &object) const { return Prototype::operator!=(object); } 682*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 683*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 684*600f14f4SXin Li //@} 685*600f14f4SXin Li 686*600f14f4SXin Li uint32_t get_num_comments() const; 687*600f14f4SXin Li const FLAC__byte *get_vendor_string() const; // NUL-terminated UTF-8 string 688*600f14f4SXin Li Entry get_comment(uint32_t index) const; 689*600f14f4SXin Li 690*600f14f4SXin Li //! See FLAC__metadata_object_vorbiscomment_set_vendor_string() 691*600f14f4SXin Li bool set_vendor_string(const FLAC__byte *string); // NUL-terminated UTF-8 string 692*600f14f4SXin Li 693*600f14f4SXin Li //! See FLAC__metadata_object_vorbiscomment_resize_comments() 694*600f14f4SXin Li bool resize_comments(uint32_t new_num_comments); 695*600f14f4SXin Li 696*600f14f4SXin Li //! See FLAC__metadata_object_vorbiscomment_set_comment() 697*600f14f4SXin Li bool set_comment(uint32_t index, const Entry &entry); 698*600f14f4SXin Li 699*600f14f4SXin Li //! See FLAC__metadata_object_vorbiscomment_insert_comment() 700*600f14f4SXin Li bool insert_comment(uint32_t index, const Entry &entry); 701*600f14f4SXin Li 702*600f14f4SXin Li //! See FLAC__metadata_object_vorbiscomment_append_comment() 703*600f14f4SXin Li bool append_comment(const Entry &entry); 704*600f14f4SXin Li 705*600f14f4SXin Li //! See FLAC__metadata_object_vorbiscomment_replace_comment() 706*600f14f4SXin Li bool replace_comment(const Entry &entry, bool all); 707*600f14f4SXin Li 708*600f14f4SXin Li //! See FLAC__metadata_object_vorbiscomment_delete_comment() 709*600f14f4SXin Li bool delete_comment(uint32_t index); 710*600f14f4SXin Li 711*600f14f4SXin Li //! See FLAC__metadata_object_vorbiscomment_find_entry_from() 712*600f14f4SXin Li int find_entry_from(uint32_t offset, const char *field_name); 713*600f14f4SXin Li 714*600f14f4SXin Li //! See FLAC__metadata_object_vorbiscomment_remove_entry_matching() 715*600f14f4SXin Li int remove_entry_matching(const char *field_name); 716*600f14f4SXin Li 717*600f14f4SXin Li //! See FLAC__metadata_object_vorbiscomment_remove_entries_matching() 718*600f14f4SXin Li int remove_entries_matching(const char *field_name); 719*600f14f4SXin Li }; 720*600f14f4SXin Li 721*600f14f4SXin Li /** CUESHEET metadata block. 722*600f14f4SXin Li * See the \link flacpp_metadata_object overview \endlink for more, 723*600f14f4SXin Li * and the <A HREF="https://xiph.org/flac/format.html#metadata_block_cuesheet">format specification</A>. 724*600f14f4SXin Li */ 725*600f14f4SXin Li class FLACPP_API CueSheet : public Prototype { 726*600f14f4SXin Li public: 727*600f14f4SXin Li /** Convenience class for encapsulating a cue sheet 728*600f14f4SXin Li * track. 729*600f14f4SXin Li * 730*600f14f4SXin Li * Always check is_valid() after the constructor or operator= 731*600f14f4SXin Li * to make sure memory was properly allocated. 732*600f14f4SXin Li */ 733*600f14f4SXin Li class FLACPP_API Track { 734*600f14f4SXin Li protected: 735*600f14f4SXin Li ::FLAC__StreamMetadata_CueSheet_Track *object_; 736*600f14f4SXin Li public: 737*600f14f4SXin Li Track(); 738*600f14f4SXin Li Track(const ::FLAC__StreamMetadata_CueSheet_Track *track); 739*600f14f4SXin Li Track(const Track &track); 740*600f14f4SXin Li Track &operator=(const Track &track); 741*600f14f4SXin Li 742*600f14f4SXin Li virtual ~Track(); 743*600f14f4SXin Li 744*600f14f4SXin Li virtual bool is_valid() const; ///< Returns \c true iff object was properly constructed. 745*600f14f4SXin Li 746*600f14f4SXin Li get_offset()747*600f14f4SXin Li inline FLAC__uint64 get_offset() const { return object_->offset; } get_number()748*600f14f4SXin Li inline FLAC__byte get_number() const { return object_->number; } get_isrc()749*600f14f4SXin Li inline const char *get_isrc() const { return object_->isrc; } get_type()750*600f14f4SXin Li inline uint32_t get_type() const { return object_->type; } get_pre_emphasis()751*600f14f4SXin Li inline bool get_pre_emphasis() const { return object_->pre_emphasis; } 752*600f14f4SXin Li get_num_indices()753*600f14f4SXin Li inline FLAC__byte get_num_indices() const { return object_->num_indices; } 754*600f14f4SXin Li ::FLAC__StreamMetadata_CueSheet_Index get_index(uint32_t i) const; 755*600f14f4SXin Li get_track()756*600f14f4SXin Li inline const ::FLAC__StreamMetadata_CueSheet_Track *get_track() const { return object_; } 757*600f14f4SXin Li set_offset(FLAC__uint64 value)758*600f14f4SXin Li inline void set_offset(FLAC__uint64 value) { object_->offset = value; } set_number(FLAC__byte value)759*600f14f4SXin Li inline void set_number(FLAC__byte value) { object_->number = value; } 760*600f14f4SXin Li void set_isrc(const char value[12]); 761*600f14f4SXin Li void set_type(uint32_t value); set_pre_emphasis(bool value)762*600f14f4SXin Li inline void set_pre_emphasis(bool value) { object_->pre_emphasis = value? 1 : 0; } 763*600f14f4SXin Li 764*600f14f4SXin Li void set_index(uint32_t i, const ::FLAC__StreamMetadata_CueSheet_Index &index); 765*600f14f4SXin Li //@@@ It's awkward but to insert/delete index points 766*600f14f4SXin Li //@@@ you must use the routines in the CueSheet class. 767*600f14f4SXin Li }; 768*600f14f4SXin Li 769*600f14f4SXin Li CueSheet(); 770*600f14f4SXin Li 771*600f14f4SXin Li //@{ 772*600f14f4SXin Li /** Constructs a copy of the given object. This form 773*600f14f4SXin Li * always performs a deep copy. 774*600f14f4SXin Li */ CueSheet(const CueSheet & object)775*600f14f4SXin Li inline CueSheet(const CueSheet &object): Prototype(object) { } CueSheet(const::FLAC__StreamMetadata & object)776*600f14f4SXin Li inline CueSheet(const ::FLAC__StreamMetadata &object): Prototype(object) { } CueSheet(const::FLAC__StreamMetadata * object)777*600f14f4SXin Li inline CueSheet(const ::FLAC__StreamMetadata *object): Prototype(object) { } 778*600f14f4SXin Li //@} 779*600f14f4SXin Li 780*600f14f4SXin Li /** Constructs an object with copy control. See 781*600f14f4SXin Li * Prototype(::FLAC__StreamMetadata *object, bool copy). 782*600f14f4SXin Li */ CueSheet(::FLAC__StreamMetadata * object,bool copy)783*600f14f4SXin Li inline CueSheet(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 784*600f14f4SXin Li 785*600f14f4SXin Li ~CueSheet(); 786*600f14f4SXin Li 787*600f14f4SXin Li //@{ 788*600f14f4SXin Li /** Assign from another object. Always performs a deep copy. */ 789*600f14f4SXin Li inline CueSheet &operator=(const CueSheet &object) { Prototype::operator=(object); return *this; } 790*600f14f4SXin Li inline CueSheet &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 791*600f14f4SXin Li inline CueSheet &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 792*600f14f4SXin Li //@} 793*600f14f4SXin Li 794*600f14f4SXin Li /** Assigns an object with copy control. See 795*600f14f4SXin Li * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). 796*600f14f4SXin Li */ assign(::FLAC__StreamMetadata * object,bool copy)797*600f14f4SXin Li inline CueSheet &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 798*600f14f4SXin Li 799*600f14f4SXin Li //@{ 800*600f14f4SXin Li /** Check for equality, performing a deep compare by following pointers. */ 801*600f14f4SXin Li inline bool operator==(const CueSheet &object) const { return Prototype::operator==(object); } 802*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 803*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 804*600f14f4SXin Li //@} 805*600f14f4SXin Li 806*600f14f4SXin Li //@{ 807*600f14f4SXin Li /** Check for inequality, performing a deep compare by following pointers. */ 808*600f14f4SXin Li inline bool operator!=(const CueSheet &object) const { return Prototype::operator!=(object); } 809*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 810*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 811*600f14f4SXin Li //@} 812*600f14f4SXin Li 813*600f14f4SXin Li const char *get_media_catalog_number() const; 814*600f14f4SXin Li FLAC__uint64 get_lead_in() const; 815*600f14f4SXin Li bool get_is_cd() const; 816*600f14f4SXin Li 817*600f14f4SXin Li uint32_t get_num_tracks() const; 818*600f14f4SXin Li Track get_track(uint32_t i) const; 819*600f14f4SXin Li 820*600f14f4SXin Li void set_media_catalog_number(const char value[128]); 821*600f14f4SXin Li void set_lead_in(FLAC__uint64 value); 822*600f14f4SXin Li void set_is_cd(bool value); 823*600f14f4SXin Li 824*600f14f4SXin Li void set_index(uint32_t track_num, uint32_t index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index); 825*600f14f4SXin Li 826*600f14f4SXin Li //! See FLAC__metadata_object_cuesheet_track_resize_indices() 827*600f14f4SXin Li bool resize_indices(uint32_t track_num, uint32_t new_num_indices); 828*600f14f4SXin Li 829*600f14f4SXin Li //! See FLAC__metadata_object_cuesheet_track_insert_index() 830*600f14f4SXin Li bool insert_index(uint32_t track_num, uint32_t index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index); 831*600f14f4SXin Li 832*600f14f4SXin Li //! See FLAC__metadata_object_cuesheet_track_insert_blank_index() 833*600f14f4SXin Li bool insert_blank_index(uint32_t track_num, uint32_t index_num); 834*600f14f4SXin Li 835*600f14f4SXin Li //! See FLAC__metadata_object_cuesheet_track_delete_index() 836*600f14f4SXin Li bool delete_index(uint32_t track_num, uint32_t index_num); 837*600f14f4SXin Li 838*600f14f4SXin Li //! See FLAC__metadata_object_cuesheet_resize_tracks() 839*600f14f4SXin Li bool resize_tracks(uint32_t new_num_tracks); 840*600f14f4SXin Li 841*600f14f4SXin Li //! See FLAC__metadata_object_cuesheet_set_track() 842*600f14f4SXin Li bool set_track(uint32_t i, const Track &track); 843*600f14f4SXin Li 844*600f14f4SXin Li //! See FLAC__metadata_object_cuesheet_insert_track() 845*600f14f4SXin Li bool insert_track(uint32_t i, const Track &track); 846*600f14f4SXin Li 847*600f14f4SXin Li //! See FLAC__metadata_object_cuesheet_insert_blank_track() 848*600f14f4SXin Li bool insert_blank_track(uint32_t i); 849*600f14f4SXin Li 850*600f14f4SXin Li //! See FLAC__metadata_object_cuesheet_delete_track() 851*600f14f4SXin Li bool delete_track(uint32_t i); 852*600f14f4SXin Li 853*600f14f4SXin Li //! See FLAC__metadata_object_cuesheet_is_legal() 854*600f14f4SXin Li bool is_legal(bool check_cd_da_subset = false, const char **violation = 0) const; 855*600f14f4SXin Li 856*600f14f4SXin Li //! See FLAC__metadata_object_cuesheet_calculate_cddb_id() 857*600f14f4SXin Li FLAC__uint32 calculate_cddb_id() const; 858*600f14f4SXin Li }; 859*600f14f4SXin Li 860*600f14f4SXin Li /** PICTURE metadata block. 861*600f14f4SXin Li * See the \link flacpp_metadata_object overview \endlink for more, 862*600f14f4SXin Li * and the <A HREF="https://xiph.org/flac/format.html#metadata_block_picture">format specification</A>. 863*600f14f4SXin Li */ 864*600f14f4SXin Li class FLACPP_API Picture : public Prototype { 865*600f14f4SXin Li public: 866*600f14f4SXin Li Picture(); 867*600f14f4SXin Li 868*600f14f4SXin Li //@{ 869*600f14f4SXin Li /** Constructs a copy of the given object. This form 870*600f14f4SXin Li * always performs a deep copy. 871*600f14f4SXin Li */ Picture(const Picture & object)872*600f14f4SXin Li inline Picture(const Picture &object): Prototype(object) { } Picture(const::FLAC__StreamMetadata & object)873*600f14f4SXin Li inline Picture(const ::FLAC__StreamMetadata &object): Prototype(object) { } Picture(const::FLAC__StreamMetadata * object)874*600f14f4SXin Li inline Picture(const ::FLAC__StreamMetadata *object): Prototype(object) { } 875*600f14f4SXin Li //@} 876*600f14f4SXin Li 877*600f14f4SXin Li /** Constructs an object with copy control. See 878*600f14f4SXin Li * Prototype(::FLAC__StreamMetadata *object, bool copy). 879*600f14f4SXin Li */ Picture(::FLAC__StreamMetadata * object,bool copy)880*600f14f4SXin Li inline Picture(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 881*600f14f4SXin Li 882*600f14f4SXin Li ~Picture(); 883*600f14f4SXin Li 884*600f14f4SXin Li //@{ 885*600f14f4SXin Li /** Assign from another object. Always performs a deep copy. */ 886*600f14f4SXin Li inline Picture &operator=(const Picture &object) { Prototype::operator=(object); return *this; } 887*600f14f4SXin Li inline Picture &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 888*600f14f4SXin Li inline Picture &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 889*600f14f4SXin Li //@} 890*600f14f4SXin Li 891*600f14f4SXin Li /** Assigns an object with copy control. See 892*600f14f4SXin Li * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). 893*600f14f4SXin Li */ assign(::FLAC__StreamMetadata * object,bool copy)894*600f14f4SXin Li inline Picture &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 895*600f14f4SXin Li 896*600f14f4SXin Li //@{ 897*600f14f4SXin Li /** Check for equality, performing a deep compare by following pointers. */ 898*600f14f4SXin Li inline bool operator==(const Picture &object) const { return Prototype::operator==(object); } 899*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 900*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 901*600f14f4SXin Li //@} 902*600f14f4SXin Li 903*600f14f4SXin Li //@{ 904*600f14f4SXin Li /** Check for inequality, performing a deep compare by following pointers. */ 905*600f14f4SXin Li inline bool operator!=(const Picture &object) const { return Prototype::operator!=(object); } 906*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 907*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 908*600f14f4SXin Li //@} 909*600f14f4SXin Li 910*600f14f4SXin Li ::FLAC__StreamMetadata_Picture_Type get_type() const; 911*600f14f4SXin Li const char *get_mime_type() const; // NUL-terminated printable ASCII string 912*600f14f4SXin Li const FLAC__byte *get_description() const; // NUL-terminated UTF-8 string 913*600f14f4SXin Li FLAC__uint32 get_width() const; 914*600f14f4SXin Li FLAC__uint32 get_height() const; 915*600f14f4SXin Li FLAC__uint32 get_depth() const; 916*600f14f4SXin Li FLAC__uint32 get_colors() const; ///< a return value of \c 0 means true-color, i.e. 2^depth colors 917*600f14f4SXin Li FLAC__uint32 get_data_length() const; 918*600f14f4SXin Li const FLAC__byte *get_data() const; 919*600f14f4SXin Li 920*600f14f4SXin Li void set_type(::FLAC__StreamMetadata_Picture_Type type); 921*600f14f4SXin Li 922*600f14f4SXin Li //! See FLAC__metadata_object_picture_set_mime_type() 923*600f14f4SXin Li bool set_mime_type(const char *string); // NUL-terminated printable ASCII string 924*600f14f4SXin Li 925*600f14f4SXin Li //! See FLAC__metadata_object_picture_set_description() 926*600f14f4SXin Li bool set_description(const FLAC__byte *string); // NUL-terminated UTF-8 string 927*600f14f4SXin Li 928*600f14f4SXin Li void set_width(FLAC__uint32 value) const; 929*600f14f4SXin Li void set_height(FLAC__uint32 value) const; 930*600f14f4SXin Li void set_depth(FLAC__uint32 value) const; 931*600f14f4SXin Li void set_colors(FLAC__uint32 value) const; ///< a value of \c 0 means true-color, i.e. 2^depth colors 932*600f14f4SXin Li 933*600f14f4SXin Li //! See FLAC__metadata_object_picture_set_data() 934*600f14f4SXin Li bool set_data(const FLAC__byte *data, FLAC__uint32 data_length); 935*600f14f4SXin Li 936*600f14f4SXin Li //! See FLAC__metadata_object_picture_is_legal() 937*600f14f4SXin Li bool is_legal(const char **violation); 938*600f14f4SXin Li }; 939*600f14f4SXin Li 940*600f14f4SXin Li /** Opaque metadata block for storing unknown types. 941*600f14f4SXin Li * This should not be used unless you know what you are doing; 942*600f14f4SXin Li * it is currently used only internally to support forward 943*600f14f4SXin Li * compatibility of metadata blocks. 944*600f14f4SXin Li * See the \link flacpp_metadata_object overview \endlink for more, 945*600f14f4SXin Li */ 946*600f14f4SXin Li class FLACPP_API Unknown : public Prototype { 947*600f14f4SXin Li public: 948*600f14f4SXin Li Unknown(); 949*600f14f4SXin Li // 950*600f14f4SXin Li //@{ 951*600f14f4SXin Li /** Constructs a copy of the given object. This form 952*600f14f4SXin Li * always performs a deep copy. 953*600f14f4SXin Li */ Unknown(const Unknown & object)954*600f14f4SXin Li inline Unknown(const Unknown &object): Prototype(object) { } Unknown(const::FLAC__StreamMetadata & object)955*600f14f4SXin Li inline Unknown(const ::FLAC__StreamMetadata &object): Prototype(object) { } Unknown(const::FLAC__StreamMetadata * object)956*600f14f4SXin Li inline Unknown(const ::FLAC__StreamMetadata *object): Prototype(object) { } 957*600f14f4SXin Li //@} 958*600f14f4SXin Li 959*600f14f4SXin Li /** Constructs an object with copy control. See 960*600f14f4SXin Li * Prototype(::FLAC__StreamMetadata *object, bool copy). 961*600f14f4SXin Li */ Unknown(::FLAC__StreamMetadata * object,bool copy)962*600f14f4SXin Li inline Unknown(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } 963*600f14f4SXin Li 964*600f14f4SXin Li ~Unknown(); 965*600f14f4SXin Li 966*600f14f4SXin Li //@{ 967*600f14f4SXin Li /** Assign from another object. Always performs a deep copy. */ 968*600f14f4SXin Li inline Unknown &operator=(const Unknown &object) { Prototype::operator=(object); return *this; } 969*600f14f4SXin Li inline Unknown &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } 970*600f14f4SXin Li inline Unknown &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } 971*600f14f4SXin Li //@} 972*600f14f4SXin Li 973*600f14f4SXin Li /** Assigns an object with copy control. See 974*600f14f4SXin Li * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). 975*600f14f4SXin Li */ assign(::FLAC__StreamMetadata * object,bool copy)976*600f14f4SXin Li inline Unknown &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } 977*600f14f4SXin Li 978*600f14f4SXin Li //@{ 979*600f14f4SXin Li /** Check for equality, performing a deep compare by following pointers. */ 980*600f14f4SXin Li inline bool operator==(const Unknown &object) const { return Prototype::operator==(object); } 981*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } 982*600f14f4SXin Li inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } 983*600f14f4SXin Li //@} 984*600f14f4SXin Li 985*600f14f4SXin Li //@{ 986*600f14f4SXin Li /** Check for inequality, performing a deep compare by following pointers. */ 987*600f14f4SXin Li inline bool operator!=(const Unknown &object) const { return Prototype::operator!=(object); } 988*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } 989*600f14f4SXin Li inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } 990*600f14f4SXin Li //@} 991*600f14f4SXin Li 992*600f14f4SXin Li const FLAC__byte *get_data() const; 993*600f14f4SXin Li 994*600f14f4SXin Li //! This form always copies \a data 995*600f14f4SXin Li bool set_data(const FLAC__byte *data, uint32_t length); 996*600f14f4SXin Li bool set_data(FLAC__byte *data, uint32_t length, bool copy); 997*600f14f4SXin Li }; 998*600f14f4SXin Li 999*600f14f4SXin Li /* \} */ 1000*600f14f4SXin Li 1001*600f14f4SXin Li 1002*600f14f4SXin Li /** \defgroup flacpp_metadata_level0 FLAC++/metadata.h: metadata level 0 interface 1003*600f14f4SXin Li * \ingroup flacpp_metadata 1004*600f14f4SXin Li * 1005*600f14f4SXin Li * \brief 1006*600f14f4SXin Li * Level 0 metadata iterators. 1007*600f14f4SXin Li * 1008*600f14f4SXin Li * See the \link flac_metadata_level0 C layer equivalent \endlink 1009*600f14f4SXin Li * for more. 1010*600f14f4SXin Li * 1011*600f14f4SXin Li * \{ 1012*600f14f4SXin Li */ 1013*600f14f4SXin Li 1014*600f14f4SXin Li FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo); ///< See FLAC__metadata_get_streaminfo(). 1015*600f14f4SXin Li 1016*600f14f4SXin Li FLACPP_API bool get_tags(const char *filename, VorbisComment *&tags); ///< See FLAC__metadata_get_tags(). 1017*600f14f4SXin Li FLACPP_API bool get_tags(const char *filename, VorbisComment &tags); ///< See FLAC__metadata_get_tags(). 1018*600f14f4SXin Li 1019*600f14f4SXin Li FLACPP_API bool get_cuesheet(const char *filename, CueSheet *&cuesheet); ///< See FLAC__metadata_get_cuesheet(). 1020*600f14f4SXin Li FLACPP_API bool get_cuesheet(const char *filename, CueSheet &cuesheet); ///< See FLAC__metadata_get_cuesheet(). 1021*600f14f4SXin Li 1022*600f14f4SXin Li FLACPP_API bool get_picture(const char *filename, Picture *&picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors); ///< See FLAC__metadata_get_picture(). 1023*600f14f4SXin Li FLACPP_API bool get_picture(const char *filename, Picture &picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors); ///< See FLAC__metadata_get_picture(). 1024*600f14f4SXin Li 1025*600f14f4SXin Li /* \} */ 1026*600f14f4SXin Li 1027*600f14f4SXin Li 1028*600f14f4SXin Li /** \defgroup flacpp_metadata_level1 FLAC++/metadata.h: metadata level 1 interface 1029*600f14f4SXin Li * \ingroup flacpp_metadata 1030*600f14f4SXin Li * 1031*600f14f4SXin Li * \brief 1032*600f14f4SXin Li * Level 1 metadata iterator. 1033*600f14f4SXin Li * 1034*600f14f4SXin Li * The flow through the iterator in the C++ layer is similar 1035*600f14f4SXin Li * to the C layer: 1036*600f14f4SXin Li * - Create a SimpleIterator instance 1037*600f14f4SXin Li * - Check SimpleIterator::is_valid() 1038*600f14f4SXin Li * - Call SimpleIterator::init() and check the return 1039*600f14f4SXin Li * - Traverse and/or edit. Edits are written to file 1040*600f14f4SXin Li * immediately. 1041*600f14f4SXin Li * - Destroy the SimpleIterator instance 1042*600f14f4SXin Li * 1043*600f14f4SXin Li * The ownership of pointers in the C++ layer follows that in 1044*600f14f4SXin Li * the C layer, i.e. 1045*600f14f4SXin Li * - The objects returned by get_block() are yours to 1046*600f14f4SXin Li * modify, but changes are not reflected in the FLAC file 1047*600f14f4SXin Li * until you call set_block(). The objects are also 1048*600f14f4SXin Li * yours to delete; they are not automatically deleted 1049*600f14f4SXin Li * when passed to set_block() or insert_block_after(). 1050*600f14f4SXin Li * 1051*600f14f4SXin Li * See the \link flac_metadata_level1 C layer equivalent \endlink 1052*600f14f4SXin Li * for more. 1053*600f14f4SXin Li * 1054*600f14f4SXin Li * \{ 1055*600f14f4SXin Li */ 1056*600f14f4SXin Li 1057*600f14f4SXin Li /** This class is a wrapper around the FLAC__metadata_simple_iterator 1058*600f14f4SXin Li * structures and methods; see the 1059*600f14f4SXin Li * \link flacpp_metadata_level1 usage guide \endlink and 1060*600f14f4SXin Li * ::FLAC__Metadata_SimpleIterator. 1061*600f14f4SXin Li */ 1062*600f14f4SXin Li class FLACPP_API SimpleIterator { 1063*600f14f4SXin Li public: 1064*600f14f4SXin Li /** This class is a wrapper around FLAC__Metadata_SimpleIteratorStatus. 1065*600f14f4SXin Li */ 1066*600f14f4SXin Li class FLACPP_API Status { 1067*600f14f4SXin Li public: Status(::FLAC__Metadata_SimpleIteratorStatus status)1068*600f14f4SXin Li inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { } FLAC__Metadata_SimpleIteratorStatus()1069*600f14f4SXin Li inline operator ::FLAC__Metadata_SimpleIteratorStatus() const { return status_; } as_cstring()1070*600f14f4SXin Li inline const char *as_cstring() const { return ::FLAC__Metadata_SimpleIteratorStatusString[status_]; } 1071*600f14f4SXin Li protected: 1072*600f14f4SXin Li ::FLAC__Metadata_SimpleIteratorStatus status_; 1073*600f14f4SXin Li }; 1074*600f14f4SXin Li 1075*600f14f4SXin Li SimpleIterator(); 1076*600f14f4SXin Li virtual ~SimpleIterator(); 1077*600f14f4SXin Li 1078*600f14f4SXin Li bool is_valid() const; ///< Returns \c true iff object was properly constructed. 1079*600f14f4SXin Li 1080*600f14f4SXin Li bool init(const char *filename, bool read_only, bool preserve_file_stats); ///< See FLAC__metadata_simple_iterator_init(). 1081*600f14f4SXin Li 1082*600f14f4SXin Li Status status(); ///< See FLAC__metadata_simple_iterator_status(). 1083*600f14f4SXin Li bool is_writable() const; ///< See FLAC__metadata_simple_iterator_is_writable(). 1084*600f14f4SXin Li 1085*600f14f4SXin Li bool next(); ///< See FLAC__metadata_simple_iterator_next(). 1086*600f14f4SXin Li bool prev(); ///< See FLAC__metadata_simple_iterator_prev(). 1087*600f14f4SXin Li bool is_last() const; ///< See FLAC__metadata_simple_iterator_is_last(). 1088*600f14f4SXin Li 1089*600f14f4SXin Li off_t get_block_offset() const; ///< See FLAC__metadata_simple_iterator_get_block_offset(). 1090*600f14f4SXin Li ::FLAC__MetadataType get_block_type() const; ///< See FLAC__metadata_simple_iterator_get_block_type(). 1091*600f14f4SXin Li uint32_t get_block_length() const; ///< See FLAC__metadata_simple_iterator_get_block_length(). 1092*600f14f4SXin Li bool get_application_id(FLAC__byte *id); ///< See FLAC__metadata_simple_iterator_get_application_id(). 1093*600f14f4SXin Li Prototype *get_block(); ///< See FLAC__metadata_simple_iterator_get_block(). 1094*600f14f4SXin Li bool set_block(Prototype *block, bool use_padding = true); ///< See FLAC__metadata_simple_iterator_set_block(). 1095*600f14f4SXin Li bool insert_block_after(Prototype *block, bool use_padding = true); ///< See FLAC__metadata_simple_iterator_insert_block_after(). 1096*600f14f4SXin Li bool delete_block(bool use_padding = true); ///< See FLAC__metadata_simple_iterator_delete_block(). 1097*600f14f4SXin Li 1098*600f14f4SXin Li protected: 1099*600f14f4SXin Li ::FLAC__Metadata_SimpleIterator *iterator_; 1100*600f14f4SXin Li void clear(); 1101*600f14f4SXin Li 1102*600f14f4SXin Li private: // Do not use. 1103*600f14f4SXin Li SimpleIterator(const SimpleIterator&); 1104*600f14f4SXin Li SimpleIterator&operator=(const SimpleIterator&); 1105*600f14f4SXin Li }; 1106*600f14f4SXin Li 1107*600f14f4SXin Li /* \} */ 1108*600f14f4SXin Li 1109*600f14f4SXin Li 1110*600f14f4SXin Li /** \defgroup flacpp_metadata_level2 FLAC++/metadata.h: metadata level 2 interface 1111*600f14f4SXin Li * \ingroup flacpp_metadata 1112*600f14f4SXin Li * 1113*600f14f4SXin Li * \brief 1114*600f14f4SXin Li * Level 2 metadata iterator. 1115*600f14f4SXin Li * 1116*600f14f4SXin Li * The flow through the iterator in the C++ layer is similar 1117*600f14f4SXin Li * to the C layer: 1118*600f14f4SXin Li * - Create a Chain instance 1119*600f14f4SXin Li * - Check Chain::is_valid() 1120*600f14f4SXin Li * - Call Chain::read() and check the return 1121*600f14f4SXin Li * - Traverse and/or edit with an Iterator or with 1122*600f14f4SXin Li * Chain::merge_padding() or Chain::sort_padding() 1123*600f14f4SXin Li * - Write changes back to FLAC file with Chain::write() 1124*600f14f4SXin Li * - Destroy the Chain instance 1125*600f14f4SXin Li * 1126*600f14f4SXin Li * The ownership of pointers in the C++ layer is slightly 1127*600f14f4SXin Li * different than in the C layer, i.e. 1128*600f14f4SXin Li * - The objects returned by Iterator::get_block() are NOT 1129*600f14f4SXin Li * owned by the iterator and should be deleted by the 1130*600f14f4SXin Li * caller when finished, BUT, when you modify the block, 1131*600f14f4SXin Li * it will directly edit what's in the chain and you do 1132*600f14f4SXin Li * not need to call Iterator::set_block(). However the 1133*600f14f4SXin Li * changes will not be reflected in the FLAC file until 1134*600f14f4SXin Li * the chain is written with Chain::write(). 1135*600f14f4SXin Li * - When you pass an object to Iterator::set_block(), 1136*600f14f4SXin Li * Iterator::insert_block_before(), or 1137*600f14f4SXin Li * Iterator::insert_block_after(), the iterator takes 1138*600f14f4SXin Li * ownership of the block and it will be deleted by the 1139*600f14f4SXin Li * chain. 1140*600f14f4SXin Li * 1141*600f14f4SXin Li * See the \link flac_metadata_level2 C layer equivalent \endlink 1142*600f14f4SXin Li * for more. 1143*600f14f4SXin Li * 1144*600f14f4SXin Li * \{ 1145*600f14f4SXin Li */ 1146*600f14f4SXin Li 1147*600f14f4SXin Li /** This class is a wrapper around the FLAC__metadata_chain 1148*600f14f4SXin Li * structures and methods; see the 1149*600f14f4SXin Li * \link flacpp_metadata_level2 usage guide \endlink and 1150*600f14f4SXin Li * ::FLAC__Metadata_Chain. 1151*600f14f4SXin Li */ 1152*600f14f4SXin Li class FLACPP_API Chain { 1153*600f14f4SXin Li public: 1154*600f14f4SXin Li /** This class is a wrapper around FLAC__Metadata_ChainStatus. 1155*600f14f4SXin Li */ 1156*600f14f4SXin Li class FLACPP_API Status { 1157*600f14f4SXin Li public: Status(::FLAC__Metadata_ChainStatus status)1158*600f14f4SXin Li inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { } FLAC__Metadata_ChainStatus()1159*600f14f4SXin Li inline operator ::FLAC__Metadata_ChainStatus() const { return status_; } as_cstring()1160*600f14f4SXin Li inline const char *as_cstring() const { return ::FLAC__Metadata_ChainStatusString[status_]; } 1161*600f14f4SXin Li protected: 1162*600f14f4SXin Li ::FLAC__Metadata_ChainStatus status_; 1163*600f14f4SXin Li }; 1164*600f14f4SXin Li 1165*600f14f4SXin Li Chain(); 1166*600f14f4SXin Li virtual ~Chain(); 1167*600f14f4SXin Li 1168*600f14f4SXin Li friend class Iterator; 1169*600f14f4SXin Li 1170*600f14f4SXin Li bool is_valid() const; ///< Returns \c true iff object was properly constructed. 1171*600f14f4SXin Li 1172*600f14f4SXin Li Status status(); ///< See FLAC__metadata_chain_status(). 1173*600f14f4SXin Li 1174*600f14f4SXin Li bool read(const char *filename, bool is_ogg = false); ///< See FLAC__metadata_chain_read(), FLAC__metadata_chain_read_ogg(). 1175*600f14f4SXin Li bool read(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, bool is_ogg = false); ///< See FLAC__metadata_chain_read_with_callbacks(), FLAC__metadata_chain_read_ogg_with_callbacks(). 1176*600f14f4SXin Li 1177*600f14f4SXin Li bool check_if_tempfile_needed(bool use_padding); ///< See FLAC__metadata_chain_check_if_tempfile_needed(). 1178*600f14f4SXin Li 1179*600f14f4SXin Li bool write(bool use_padding = true, bool preserve_file_stats = false); ///< See FLAC__metadata_chain_write(). 1180*600f14f4SXin Li bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks); ///< See FLAC__metadata_chain_write_with_callbacks(). 1181*600f14f4SXin Li bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks, ::FLAC__IOHandle temp_handle, ::FLAC__IOCallbacks temp_callbacks); ///< See FLAC__metadata_chain_write_with_callbacks_and_tempfile(). 1182*600f14f4SXin Li 1183*600f14f4SXin Li void merge_padding(); ///< See FLAC__metadata_chain_merge_padding(). 1184*600f14f4SXin Li void sort_padding(); ///< See FLAC__metadata_chain_sort_padding(). 1185*600f14f4SXin Li 1186*600f14f4SXin Li protected: 1187*600f14f4SXin Li ::FLAC__Metadata_Chain *chain_; 1188*600f14f4SXin Li virtual void clear(); 1189*600f14f4SXin Li 1190*600f14f4SXin Li private: // Do not use. 1191*600f14f4SXin Li Chain(const Chain&); 1192*600f14f4SXin Li Chain&operator=(const Chain&); 1193*600f14f4SXin Li }; 1194*600f14f4SXin Li 1195*600f14f4SXin Li /** This class is a wrapper around the FLAC__metadata_iterator 1196*600f14f4SXin Li * structures and methods; see the 1197*600f14f4SXin Li * \link flacpp_metadata_level2 usage guide \endlink and 1198*600f14f4SXin Li * ::FLAC__Metadata_Iterator. 1199*600f14f4SXin Li */ 1200*600f14f4SXin Li class FLACPP_API Iterator { 1201*600f14f4SXin Li public: 1202*600f14f4SXin Li Iterator(); 1203*600f14f4SXin Li virtual ~Iterator(); 1204*600f14f4SXin Li 1205*600f14f4SXin Li bool is_valid() const; ///< Returns \c true iff object was properly constructed. 1206*600f14f4SXin Li 1207*600f14f4SXin Li 1208*600f14f4SXin Li void init(Chain &chain); ///< See FLAC__metadata_iterator_init(). 1209*600f14f4SXin Li 1210*600f14f4SXin Li bool next(); ///< See FLAC__metadata_iterator_next(). 1211*600f14f4SXin Li bool prev(); ///< See FLAC__metadata_iterator_prev(). 1212*600f14f4SXin Li 1213*600f14f4SXin Li ::FLAC__MetadataType get_block_type() const; ///< See FLAC__metadata_iterator_get_block_type(). 1214*600f14f4SXin Li Prototype *get_block(); ///< See FLAC__metadata_iterator_get_block(). 1215*600f14f4SXin Li bool set_block(Prototype *block); ///< See FLAC__metadata_iterator_set_block(). 1216*600f14f4SXin Li bool delete_block(bool replace_with_padding); ///< See FLAC__metadata_iterator_delete_block(). 1217*600f14f4SXin Li bool insert_block_before(Prototype *block); ///< See FLAC__metadata_iterator_insert_block_before(). 1218*600f14f4SXin Li bool insert_block_after(Prototype *block); ///< See FLAC__metadata_iterator_insert_block_after(). 1219*600f14f4SXin Li 1220*600f14f4SXin Li protected: 1221*600f14f4SXin Li ::FLAC__Metadata_Iterator *iterator_; 1222*600f14f4SXin Li virtual void clear(); 1223*600f14f4SXin Li 1224*600f14f4SXin Li private: // Do not use. 1225*600f14f4SXin Li Iterator(const Iterator&); 1226*600f14f4SXin Li Iterator&operator=(const Iterator&); 1227*600f14f4SXin Li }; 1228*600f14f4SXin Li 1229*600f14f4SXin Li /* \} */ 1230*600f14f4SXin Li 1231*600f14f4SXin Li } 1232*600f14f4SXin Li } 1233*600f14f4SXin Li 1234*600f14f4SXin Li #endif 1235