Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

include/FLAC++/metadata.h

Go to the documentation of this file.
00001 /* libFLAC++ - Free Lossless Audio Codec library
00002  * Copyright (C) 2002  Josh Coalson
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef FLACPP__METADATA_H
00021 #define FLACPP__METADATA_H
00022 
00023 #include "FLAC/metadata.h"
00024 
00025 // ===============================================================
00026 //
00027 //  Full documentation for the metadata interface can be found
00028 //  in the C layer in include/FLAC/metadata.h
00029 //
00030 // ===============================================================
00031 
00057 namespace FLAC {
00058     namespace Metadata {
00059 
00060         // ============================================================
00061         //
00062         //  Metadata objects
00063         //
00064         // ============================================================
00065 
00090         class Prototype {
00091         protected:
00093 
00096             Prototype(const Prototype &);
00097             Prototype(const ::FLAC__StreamMetadata &);
00098             Prototype(const ::FLAC__StreamMetadata *);
00100 
00111             Prototype(::FLAC__StreamMetadata *object, bool copy);
00112 
00114 
00115             void operator=(const Prototype &);
00116             void operator=(const ::FLAC__StreamMetadata &);
00117             void operator=(const ::FLAC__StreamMetadata *);
00119 
00122             virtual void clear();
00123 
00124             ::FLAC__StreamMetadata *object_;
00125         public:
00128             virtual ~Prototype();
00129 
00131 
00132             inline bool operator==(const Prototype &) const;
00133             inline bool operator==(const ::FLAC__StreamMetadata &) const;
00134             inline bool operator==(const ::FLAC__StreamMetadata *) const;
00136 
00138 
00139             inline bool operator!=(const Prototype &) const;
00140             inline bool operator!=(const ::FLAC__StreamMetadata &) const;
00141             inline bool operator!=(const ::FLAC__StreamMetadata *) const;
00143 
00144             friend class SimpleIterator;
00145             friend class Iterator;
00146 
00151             inline bool is_valid() const;
00152 
00159             bool get_is_last() const;
00160 
00166             ::FLAC__MetadataType get_type() const;
00167 
00177             unsigned get_length() const;
00178 
00185             void set_is_last(bool);
00186         private:
00188             Prototype();
00189 
00190             // These are used only by Iterator
00191             bool is_reference_;
00192             inline void set_reference(bool x) { is_reference_ = x; }
00193         };
00194 
00195         inline bool Prototype::operator==(const Prototype &object) const
00196         { return (bool)::FLAC__metadata_object_is_equal(object_, object.object_); }
00197 
00198         inline bool Prototype::operator==(const ::FLAC__StreamMetadata &object) const
00199         { return (bool)::FLAC__metadata_object_is_equal(object_, &object); }
00200 
00201         inline bool Prototype::operator==(const ::FLAC__StreamMetadata *object) const
00202         { return (bool)::FLAC__metadata_object_is_equal(object_, object); }
00203 
00204         inline bool Prototype::operator!=(const Prototype &object) const
00205         { return !operator==(object); }
00206 
00207         inline bool Prototype::operator!=(const ::FLAC__StreamMetadata &object) const
00208         { return !operator==(object); }
00209 
00210         inline bool Prototype::operator!=(const ::FLAC__StreamMetadata *object) const
00211         { return !operator==(object); }
00212 
00213         inline bool Prototype::is_valid() const
00214         { return 0 != object_; }
00215 
00217         Prototype *clone(const Prototype *);
00218 
00219 
00223         class StreamInfo : public Prototype {
00224         public:
00225             StreamInfo();
00226 
00228 
00231             inline StreamInfo(const StreamInfo &object): Prototype(object) { }
00232             inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00233             inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00235 
00239             inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00240 
00241             ~StreamInfo();
00242 
00244 
00245             inline void operator=(const StreamInfo &object) { Prototype::operator=(object); }
00246             inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00247             inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00249 
00251 
00252             inline bool operator==(const StreamInfo &object) const { return Prototype::operator==(object); }
00253             inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00254             inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00256 
00258 
00259             inline bool operator!=(const StreamInfo &object) const { return Prototype::operator!=(object); }
00260             inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00261             inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00263 
00265 
00266             unsigned get_min_blocksize() const;
00267             unsigned get_max_blocksize() const;
00268             unsigned get_min_framesize() const;
00269             unsigned get_max_framesize() const;
00270             unsigned get_sample_rate() const;
00271             unsigned get_channels() const;
00272             unsigned get_bits_per_sample() const;
00273             FLAC__uint64 get_total_samples() const;
00274             const FLAC__byte *get_md5sum() const;
00275 
00276             void set_min_blocksize(unsigned value);
00277             void set_max_blocksize(unsigned value);
00278             void set_min_framesize(unsigned value);
00279             void set_max_framesize(unsigned value);
00280             void set_sample_rate(unsigned value);
00281             void set_channels(unsigned value);
00282             void set_bits_per_sample(unsigned value);
00283             void set_total_samples(FLAC__uint64 value);
00284             void set_md5sum(const FLAC__byte value[16]);
00286         };
00287 
00291         class Padding : public Prototype {
00292         public:
00293             Padding();
00294 
00296 
00299             inline Padding(const Padding &object): Prototype(object) { }
00300             inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00301             inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00303 
00307             inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00308 
00309             ~Padding();
00310 
00312 
00313             inline void operator=(const Padding &object) { Prototype::operator=(object); }
00314             inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00315             inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00317 
00319 
00320             inline bool operator==(const Padding &object) const { return Prototype::operator==(object); }
00321             inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00322             inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00324 
00326 
00327             inline bool operator!=(const Padding &object) const { return Prototype::operator!=(object); }
00328             inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00329             inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00331 
00332             void set_length(unsigned length);
00333         };
00334 
00338         class Application : public Prototype {
00339         public:
00340             Application();
00341             //
00343             /** Constructs a copy of the given object.  This form
00344              *  always performs a deep copy.
00345              */
00346             inline Application(const Application &object): Prototype(object) { }
00347             inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00348             inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00350 
00354             inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00355 
00356             ~Application();
00357 
00359 
00360             inline void operator=(const Application &object) { Prototype::operator=(object); }
00361             inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00362             inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00364 
00366 
00367             inline bool operator==(const Application &object) const { return Prototype::operator==(object); }
00368             inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00369             inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00371 
00373 
00374             inline bool operator!=(const Application &object) const { return Prototype::operator!=(object); }
00375             inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00376             inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00378 
00379             const FLAC__byte *get_id() const;
00380             const FLAC__byte *get_data() const;
00381 
00382             void set_id(const FLAC__byte value[4]);
00384             bool set_data(const FLAC__byte *data, unsigned length);
00385             bool set_data(FLAC__byte *data, unsigned length, bool copy);
00386         };
00387 
00391         class SeekTable : public Prototype {
00392         public:
00393             SeekTable();
00394 
00396 
00399             inline SeekTable(const SeekTable &object): Prototype(object) { }
00400             inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00401             inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00403 
00407             inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00408 
00409             ~SeekTable();
00410 
00412 
00413             inline void operator=(const SeekTable &object) { Prototype::operator=(object); }
00414             inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00415             inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00417 
00419 
00420             inline bool operator==(const SeekTable &object) const { return Prototype::operator==(object); }
00421             inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00422             inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00424 
00426 
00427             inline bool operator!=(const SeekTable &object) const { return Prototype::operator!=(object); }
00428             inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00429             inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00431 
00432             unsigned get_num_points() const;
00433             ::FLAC__StreamMetadata_SeekPoint get_point(unsigned index) const;
00434 
00436             void set_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point);
00437 
00439             bool insert_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point);
00440 
00442             bool delete_point(unsigned index);
00443 
00445             bool is_legal() const;
00446         };
00447 
00451         class VorbisComment : public Prototype {
00452         public:
00477             class Entry {
00478             public:
00479                 Entry();
00480                 Entry(const char *field, unsigned field_length);
00481                 Entry(const char *field_name, const char *field_value, unsigned field_value_length);
00482                 Entry(const Entry &entry);
00483                 void operator=(const Entry &entry);
00484 
00485                 virtual ~Entry();
00486 
00487                 virtual bool is_valid() const;
00488 
00489                 unsigned get_field_length() const;
00490                 unsigned get_field_name_length() const;
00491                 unsigned get_field_value_length() const;
00492 
00493                 ::FLAC__StreamMetadata_VorbisComment_Entry get_entry() const;
00494                 const char *get_field() const;
00495                 const char *get_field_name() const;
00496                 const char *get_field_value() const;
00497 
00498                 bool set_field(const char *field, unsigned field_length);
00499                 bool set_field_name(const char *field_name);
00500                 bool set_field_value(const char *field_value, unsigned field_value_length);
00501             protected:
00502                 bool is_valid_;
00503                 ::FLAC__StreamMetadata_VorbisComment_Entry entry_;
00504                 char *field_name_;
00505                 unsigned field_name_length_;
00506                 char *field_value_;
00507                 unsigned field_value_length_;
00508             private:
00509                 void zero();
00510                 void clear();
00511                 void clear_entry();
00512                 void clear_field_name();
00513                 void clear_field_value();
00514                 void construct(const char *field, unsigned field_length);
00515                 void construct(const char *field_name, const char *field_value, unsigned field_value_length);
00516                 void compose_field();
00517                 void parse_field();
00518             };
00519 
00520             VorbisComment();
00521 
00523 
00526             inline VorbisComment(const VorbisComment &object): Prototype(object) { }
00527             inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { }
00528             inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { }
00530 
00534             inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
00535 
00536             ~VorbisComment();
00537 
00539 
00540             inline void operator=(const VorbisComment &object) { Prototype::operator=(object); }
00541             inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
00542             inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
00544 
00546 
00547             inline bool operator==(const VorbisComment &object) const { return Prototype::operator==(object); }
00548             inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
00549             inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
00551 
00553 
00554             inline bool operator!=(const VorbisComment &object) const { return Prototype::operator!=(object); }
00555             inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
00556             inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
00558 
00559             unsigned get_num_comments() const;
00560             Entry get_vendor_string() const; // only the Entry's field name should be used
00561             Entry get_comment(unsigned index) const;
00562 
00565             bool set_vendor_string(const Entry &entry); // only the Entry's field name will be used
00566 
00568             bool set_comment(unsigned index, const Entry &entry);
00569 
00571             bool insert_comment(unsigned index, const Entry &entry);
00572 
00574             bool delete_comment(unsigned index);
00575         };
00576 
00577         /* \} */
00578 
00579 
00592 
00593         bool get_streaminfo(const char *filename, StreamInfo &streaminfo);
00594 
00595         /* \} */
00596 
00597 
00630         class SimpleIterator {
00631         public:
00632             class Status {
00633             public:
00634                 inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { }
00635                 inline operator ::FLAC__Metadata_SimpleIteratorStatus() const { return status_; }
00636                 inline const char *as_cstring() const { return ::FLAC__Metadata_SimpleIteratorStatusString[status_]; }
00637             protected:
00638                 ::FLAC__Metadata_SimpleIteratorStatus status_;
00639             };
00640 
00641             SimpleIterator();
00642             virtual ~SimpleIterator();
00643 
00644             bool init(const char *filename, bool read_only, bool preserve_file_stats);
00645 
00646             bool is_valid() const;
00647             Status status();
00648             bool is_writable() const;
00649 
00650             bool next();
00651             bool prev();
00652 
00653             ::FLAC__MetadataType get_block_type() const;
00654             Prototype *get_block();
00655             bool set_block(Prototype *block, bool use_padding = true);
00656             bool insert_block_after(Prototype *block, bool use_padding = true);
00657             bool delete_block(bool use_padding = true);
00658 
00659         protected:
00660             ::FLAC__Metadata_SimpleIterator *iterator_;
00661             void clear();
00662         };
00663 
00664         /* \} */
00665 
00666 
00707         class Chain {
00708         public:
00709             class Status {
00710             public:
00711                 inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { }
00712                 inline operator ::FLAC__Metadata_ChainStatus() const { return status_; }
00713                 inline const char *as_cstring() const { return ::FLAC__Metadata_ChainStatusString[status_]; }
00714             protected:
00715                 ::FLAC__Metadata_ChainStatus status_;
00716             };
00717 
00718             Chain();
00719             virtual ~Chain();
00720 
00721             friend class Iterator;
00722 
00723             bool is_valid() const;
00724             Status status();
00725 
00726             bool read(const char *filename);
00727             bool write(bool use_padding = true, bool preserve_file_stats = false);
00728 
00729             void merge_padding();
00730             void sort_padding();
00731 
00732         protected:
00733             ::FLAC__Metadata_Chain *chain_;
00734             virtual void clear();
00735         };
00736 
00740         class Iterator {
00741         public:
00742             Iterator();
00743             virtual ~Iterator();
00744 
00745             bool is_valid() const;
00746 
00747             void init(Chain &chain);
00748 
00749             bool next();
00750             bool prev();
00751 
00752             ::FLAC__MetadataType get_block_type() const;
00753             Prototype *get_block();
00754             bool set_block(Prototype *block);
00755             bool delete_block(bool replace_with_padding);
00756             bool insert_block_before(Prototype *block);
00757             bool insert_block_after(Prototype *block);
00758 
00759         protected:
00760             ::FLAC__Metadata_Iterator *iterator_;
00761             virtual void clear();
00762         };
00763 
00764         /* \} */
00765 
00766     };
00767 };
00768 
00769 #endif

Generated on Tue Sep 24 21:54:26 2002 for FLAC by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002