FLAC  1.4.3
Free Lossless Audio Codec
metadata.h
Go to the documentation of this file.
1 /* libFLAC++ - Free Lossless Audio Codec library
2  * Copyright (C) 2002-2009 Josh Coalson
3  * Copyright (C) 2011-2023 Xiph.Org Foundation
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * - Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * - Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * - Neither the name of the Xiph.org Foundation nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef FLACPP__METADATA_H
34 #define FLACPP__METADATA_H
35 
36 #include "export.h"
37 
38 #include "FLAC/metadata.h"
39 
40 // ===============================================================
41 //
42 // Full documentation for the metadata interface can be found
43 // in the C layer in include/FLAC/metadata.h
44 //
45 // ===============================================================
46 
75 namespace FLAC {
76  namespace Metadata {
77 
78  // ============================================================
79  //
80  // Metadata objects
81  //
82  // ============================================================
83 
110  protected:
112 
119 
130  Prototype(::FLAC__StreamMetadata *object, bool copy);
131 
133 
138 
143 
146  virtual void clear();
147 
148  ::FLAC__StreamMetadata *object_;
149  public:
152  virtual ~Prototype();
153 
155 
157  inline bool operator==(const Prototype &) const;
158  inline bool operator==(const ::FLAC__StreamMetadata &) const;
159  inline bool operator==(const ::FLAC__StreamMetadata *) const;
161 
163 
164  inline bool operator!=(const Prototype &) const;
165  inline bool operator!=(const ::FLAC__StreamMetadata &) const;
166  inline bool operator!=(const ::FLAC__StreamMetadata *) const;
168 
169  friend class SimpleIterator;
170  friend class Iterator;
171 
176  inline bool is_valid() const;
177 
184  bool get_is_last() const;
185 
192 
202  uint32_t get_length() const;
203 
210  void set_is_last(bool);
211 
219  inline operator const ::FLAC__StreamMetadata *() const;
220  private:
222  Prototype();
223 
224  // These are used only by Iterator
225  bool is_reference_;
226  inline void set_reference(bool x) { is_reference_ = x; }
227  };
228 
229  // local utility routines
230 
231  namespace local {
232 
235 
236  }
237 
238 #ifdef _MSC_VER
239 // warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning)
240 #pragma warning ( disable : 4800 )
241 #endif
242 
243  inline bool Prototype::operator==(const Prototype &object) const
244  { return (bool)::FLAC__metadata_object_is_equal(object_, object.object_); }
245 
246  inline bool Prototype::operator==(const ::FLAC__StreamMetadata &object) const
247  { return (bool)::FLAC__metadata_object_is_equal(object_, &object); }
248 
249  inline bool Prototype::operator==(const ::FLAC__StreamMetadata *object) const
250  { return (bool)::FLAC__metadata_object_is_equal(object_, object); }
251 
252 #ifdef _MSC_VER
253 #pragma warning ( default : 4800 )
254 #endif
255 
256  inline bool Prototype::operator!=(const Prototype &object) const
257  { return !operator==(object); }
258 
259  inline bool Prototype::operator!=(const ::FLAC__StreamMetadata &object) const
260  { return !operator==(object); }
261 
262  inline bool Prototype::operator!=(const ::FLAC__StreamMetadata *object) const
263  { return !operator==(object); }
264 
265  inline bool Prototype::is_valid() const
266  { return 0 != object_; }
267 
268  inline Prototype::operator const ::FLAC__StreamMetadata *() const
269  { return object_; }
270 
273 
274 
279  class FLACPP_API StreamInfo : public Prototype {
280  public:
281  StreamInfo();
282 
284 
287  inline StreamInfo(const StreamInfo &object): Prototype(object) { }
288  inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { }
289  inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { }
291 
295  inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
296 
297  ~StreamInfo();
298 
300 
301  inline StreamInfo &operator=(const StreamInfo &object) { Prototype::operator=(object); return *this; }
302  inline StreamInfo &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
303  inline StreamInfo &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
305 
309  inline StreamInfo &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
310 
312 
313  inline bool operator==(const StreamInfo &object) const { return Prototype::operator==(object); }
314  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
315  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
317 
319 
320  inline bool operator!=(const StreamInfo &object) const { return Prototype::operator!=(object); }
321  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
322  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
324 
326 
327  uint32_t get_min_blocksize() const;
328  uint32_t get_max_blocksize() const;
329  uint32_t get_min_framesize() const;
330  uint32_t get_max_framesize() const;
331  uint32_t get_sample_rate() const;
332  uint32_t get_channels() const;
333  uint32_t get_bits_per_sample() const;
334  FLAC__uint64 get_total_samples() const;
335  const FLAC__byte *get_md5sum() const;
336 
337  void set_min_blocksize(uint32_t value);
338  void set_max_blocksize(uint32_t value);
339  void set_min_framesize(uint32_t value);
340  void set_max_framesize(uint32_t value);
341  void set_sample_rate(uint32_t value);
342  void set_channels(uint32_t value);
343  void set_bits_per_sample(uint32_t value);
344  void set_total_samples(FLAC__uint64 value);
345  void set_md5sum(const FLAC__byte value[16]);
347  };
348 
353  class FLACPP_API Padding : public Prototype {
354  public:
355  Padding();
356 
358 
361  inline Padding(const Padding &object): Prototype(object) { }
362  inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { }
363  inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { }
365 
369  inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
370 
373  Padding(uint32_t length);
374 
375  ~Padding();
376 
378 
379  inline Padding &operator=(const Padding &object) { Prototype::operator=(object); return *this; }
380  inline Padding &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
381  inline Padding &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
383 
387  inline Padding &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
388 
390 
391  inline bool operator==(const Padding &object) const { return Prototype::operator==(object); }
392  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
393  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
395 
397 
398  inline bool operator!=(const Padding &object) const { return Prototype::operator!=(object); }
399  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
400  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
402 
405  void set_length(uint32_t length);
406  };
407 
413  public:
414  Application();
415  //
417 
420  inline Application(const Application &object): Prototype(object) { }
421  inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { }
422  inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { }
424 
428  inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
429 
430  ~Application();
431 
433 
434  inline Application &operator=(const Application &object) { Prototype::operator=(object); return *this; }
435  inline Application &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
436  inline Application &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
438 
442  inline Application &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
443 
445 
446  inline bool operator==(const Application &object) const { return Prototype::operator==(object); }
447  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
448  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
450 
452 
453  inline bool operator!=(const Application &object) const { return Prototype::operator!=(object); }
454  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
455  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
457 
458  const FLAC__byte *get_id() const;
459  const FLAC__byte *get_data() const;
460 
461  void set_id(const FLAC__byte value[4]);
463  bool set_data(const FLAC__byte *data, uint32_t length);
464  bool set_data(FLAC__byte *data, uint32_t length, bool copy);
465  };
466 
471  class FLACPP_API SeekTable : public Prototype {
472  public:
473  SeekTable();
474 
476 
479  inline SeekTable(const SeekTable &object): Prototype(object) { }
480  inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { }
481  inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { }
483 
487  inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
488 
489  ~SeekTable();
490 
492 
493  inline SeekTable &operator=(const SeekTable &object) { Prototype::operator=(object); return *this; }
494  inline SeekTable &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
495  inline SeekTable &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
497 
501  inline SeekTable &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
502 
504 
505  inline bool operator==(const SeekTable &object) const { return Prototype::operator==(object); }
506  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
507  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
509 
511 
512  inline bool operator!=(const SeekTable &object) const { return Prototype::operator!=(object); }
513  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
514  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
516 
517  uint32_t get_num_points() const;
518  ::FLAC__StreamMetadata_SeekPoint get_point(uint32_t index) const;
519 
521  bool resize_points(uint32_t new_num_points);
522 
524  void set_point(uint32_t index, const ::FLAC__StreamMetadata_SeekPoint &point);
525 
527  bool insert_point(uint32_t index, const ::FLAC__StreamMetadata_SeekPoint &point);
528 
530  bool delete_point(uint32_t index);
531 
533  bool is_legal() const;
534 
536  bool template_append_placeholders(uint32_t num);
537 
539  bool template_append_point(FLAC__uint64 sample_number);
540 
542  bool template_append_points(FLAC__uint64 sample_numbers[], uint32_t num);
543 
545  bool template_append_spaced_points(uint32_t num, FLAC__uint64 total_samples);
546 
548  bool template_append_spaced_points_by_samples(uint32_t samples, FLAC__uint64 total_samples);
549 
551  bool template_sort(bool compact);
552  };
553 
559  public:
590  public:
591  Entry();
592 
593  Entry(const char *field, uint32_t field_length);
594  Entry(const char *field); // assumes \a field is NUL-terminated
595 
596  Entry(const char *field_name, const char *field_value, uint32_t field_value_length);
597  Entry(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated
598 
599  Entry(const Entry &entry);
600 
601  Entry &operator=(const Entry &entry);
602 
603  virtual ~Entry();
604 
605  virtual bool is_valid() const;
606 
607  uint32_t get_field_length() const;
608  uint32_t get_field_name_length() const;
609  uint32_t get_field_value_length() const;
610 
612  const char *get_field() const;
613  const char *get_field_name() const;
614  const char *get_field_value() const;
615 
616  bool set_field(const char *field, uint32_t field_length);
617  bool set_field(const char *field); // assumes \a field is NUL-terminated
618  bool set_field_name(const char *field_name);
619  bool set_field_value(const char *field_value, uint32_t field_value_length);
620  bool set_field_value(const char *field_value); // assumes \a field_value is NUL-terminated
621  protected:
622  bool is_valid_;
624  char *field_name_;
625  uint32_t field_name_length_;
626  char *field_value_;
627  uint32_t field_value_length_;
628  private:
629  void zero();
630  void clear();
631  void clear_entry();
632  void clear_field_name();
633  void clear_field_value();
634  void construct(const char *field, uint32_t field_length);
635  void construct(const char *field); // assumes \a field is NUL-terminated
636  void construct(const char *field_name, const char *field_value, uint32_t field_value_length);
637  void construct(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated
638  void compose_field();
639  void parse_field();
640  };
641 
642  VorbisComment();
643 
645 
648  inline VorbisComment(const VorbisComment &object): Prototype(object) { }
649  inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { }
650  inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { }
652 
656  inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
657 
658  ~VorbisComment();
659 
661 
662  inline VorbisComment &operator=(const VorbisComment &object) { Prototype::operator=(object); return *this; }
663  inline VorbisComment &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
664  inline VorbisComment &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
666 
670  inline VorbisComment &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
671 
673 
674  inline bool operator==(const VorbisComment &object) const { return Prototype::operator==(object); }
675  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
676  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
678 
680 
681  inline bool operator!=(const VorbisComment &object) const { return Prototype::operator!=(object); }
682  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
683  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
685 
686  uint32_t get_num_comments() const;
687  const FLAC__byte *get_vendor_string() const; // NUL-terminated UTF-8 string
688  Entry get_comment(uint32_t index) const;
689 
691  bool set_vendor_string(const FLAC__byte *string); // NUL-terminated UTF-8 string
692 
694  bool resize_comments(uint32_t new_num_comments);
695 
697  bool set_comment(uint32_t index, const Entry &entry);
698 
700  bool insert_comment(uint32_t index, const Entry &entry);
701 
703  bool append_comment(const Entry &entry);
704 
706  bool replace_comment(const Entry &entry, bool all);
707 
709  bool delete_comment(uint32_t index);
710 
712  int find_entry_from(uint32_t offset, const char *field_name);
713 
715  int remove_entry_matching(const char *field_name);
716 
718  int remove_entries_matching(const char *field_name);
719  };
720 
725  class FLACPP_API CueSheet : public Prototype {
726  public:
734  protected:
736  public:
737  Track();
738  Track(const ::FLAC__StreamMetadata_CueSheet_Track *track);
739  Track(const Track &track);
740  Track &operator=(const Track &track);
741 
742  virtual ~Track();
743 
744  virtual bool is_valid() const;
745 
746 
747  inline FLAC__uint64 get_offset() const { return object_->offset; }
748  inline FLAC__byte get_number() const { return object_->number; }
749  inline const char *get_isrc() const { return object_->isrc; }
750  inline uint32_t get_type() const { return object_->type; }
751  inline bool get_pre_emphasis() const { return object_->pre_emphasis; }
752 
753  inline FLAC__byte get_num_indices() const { return object_->num_indices; }
754  ::FLAC__StreamMetadata_CueSheet_Index get_index(uint32_t i) const;
755 
756  inline const ::FLAC__StreamMetadata_CueSheet_Track *get_track() const { return object_; }
757 
758  inline void set_offset(FLAC__uint64 value) { object_->offset = value; }
759  inline void set_number(FLAC__byte value) { object_->number = value; }
760  void set_isrc(const char value[12]);
761  void set_type(uint32_t value);
762  inline void set_pre_emphasis(bool value) { object_->pre_emphasis = value? 1 : 0; }
763 
764  void set_index(uint32_t i, const ::FLAC__StreamMetadata_CueSheet_Index &index);
765  //@@@ It's awkward but to insert/delete index points
766  //@@@ you must use the routines in the CueSheet class.
767  };
768 
769  CueSheet();
770 
772 
775  inline CueSheet(const CueSheet &object): Prototype(object) { }
776  inline CueSheet(const ::FLAC__StreamMetadata &object): Prototype(object) { }
777  inline CueSheet(const ::FLAC__StreamMetadata *object): Prototype(object) { }
779 
783  inline CueSheet(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
784 
785  ~CueSheet();
786 
788 
789  inline CueSheet &operator=(const CueSheet &object) { Prototype::operator=(object); return *this; }
790  inline CueSheet &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
791  inline CueSheet &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
793 
797  inline CueSheet &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
798 
800 
801  inline bool operator==(const CueSheet &object) const { return Prototype::operator==(object); }
802  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
803  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
805 
807 
808  inline bool operator!=(const CueSheet &object) const { return Prototype::operator!=(object); }
809  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
810  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
812 
813  const char *get_media_catalog_number() const;
814  FLAC__uint64 get_lead_in() const;
815  bool get_is_cd() const;
816 
817  uint32_t get_num_tracks() const;
818  Track get_track(uint32_t i) const;
819 
820  void set_media_catalog_number(const char value[128]);
821  void set_lead_in(FLAC__uint64 value);
822  void set_is_cd(bool value);
823 
824  void set_index(uint32_t track_num, uint32_t index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);
825 
827  bool resize_indices(uint32_t track_num, uint32_t new_num_indices);
828 
830  bool insert_index(uint32_t track_num, uint32_t index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);
831 
833  bool insert_blank_index(uint32_t track_num, uint32_t index_num);
834 
836  bool delete_index(uint32_t track_num, uint32_t index_num);
837 
839  bool resize_tracks(uint32_t new_num_tracks);
840 
842  bool set_track(uint32_t i, const Track &track);
843 
845  bool insert_track(uint32_t i, const Track &track);
846 
848  bool insert_blank_track(uint32_t i);
849 
851  bool delete_track(uint32_t i);
852 
854  bool is_legal(bool check_cd_da_subset = false, const char **violation = 0) const;
855 
857  FLAC__uint32 calculate_cddb_id() const;
858  };
859 
864  class FLACPP_API Picture : public Prototype {
865  public:
866  Picture();
867 
869 
872  inline Picture(const Picture &object): Prototype(object) { }
873  inline Picture(const ::FLAC__StreamMetadata &object): Prototype(object) { }
874  inline Picture(const ::FLAC__StreamMetadata *object): Prototype(object) { }
876 
880  inline Picture(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
881 
882  ~Picture();
883 
885 
886  inline Picture &operator=(const Picture &object) { Prototype::operator=(object); return *this; }
887  inline Picture &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
888  inline Picture &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
890 
894  inline Picture &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
895 
897 
898  inline bool operator==(const Picture &object) const { return Prototype::operator==(object); }
899  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
900  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
902 
904 
905  inline bool operator!=(const Picture &object) const { return Prototype::operator!=(object); }
906  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
907  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
909 
910  ::FLAC__StreamMetadata_Picture_Type get_type() const;
911  const char *get_mime_type() const; // NUL-terminated printable ASCII string
912  const FLAC__byte *get_description() const; // NUL-terminated UTF-8 string
913  FLAC__uint32 get_width() const;
914  FLAC__uint32 get_height() const;
915  FLAC__uint32 get_depth() const;
916  FLAC__uint32 get_colors() const;
917  FLAC__uint32 get_data_length() const;
918  const FLAC__byte *get_data() const;
919 
920  void set_type(::FLAC__StreamMetadata_Picture_Type type);
921 
923  bool set_mime_type(const char *string); // NUL-terminated printable ASCII string
924 
926  bool set_description(const FLAC__byte *string); // NUL-terminated UTF-8 string
927 
928  void set_width(FLAC__uint32 value) const;
929  void set_height(FLAC__uint32 value) const;
930  void set_depth(FLAC__uint32 value) const;
931  void set_colors(FLAC__uint32 value) const;
932 
934  bool set_data(const FLAC__byte *data, FLAC__uint32 data_length);
935 
937  bool is_legal(const char **violation);
938  };
939 
946  class FLACPP_API Unknown : public Prototype {
947  public:
948  Unknown();
949  //
951 
954  inline Unknown(const Unknown &object): Prototype(object) { }
955  inline Unknown(const ::FLAC__StreamMetadata &object): Prototype(object) { }
956  inline Unknown(const ::FLAC__StreamMetadata *object): Prototype(object) { }
958 
962  inline Unknown(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
963 
964  ~Unknown();
965 
967 
968  inline Unknown &operator=(const Unknown &object) { Prototype::operator=(object); return *this; }
969  inline Unknown &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
970  inline Unknown &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
972 
976  inline Unknown &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
977 
979 
980  inline bool operator==(const Unknown &object) const { return Prototype::operator==(object); }
981  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
982  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
984 
986 
987  inline bool operator!=(const Unknown &object) const { return Prototype::operator!=(object); }
988  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
989  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
991 
992  const FLAC__byte *get_data() const;
993 
995  bool set_data(const FLAC__byte *data, uint32_t length);
996  bool set_data(FLAC__byte *data, uint32_t length, bool copy);
997  };
998 
999  /* \} */
1000 
1001 
1014  FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo);
1015 
1016  FLACPP_API bool get_tags(const char *filename, VorbisComment *&tags);
1017  FLACPP_API bool get_tags(const char *filename, VorbisComment &tags);
1018 
1019  FLACPP_API bool get_cuesheet(const char *filename, CueSheet *&cuesheet);
1020  FLACPP_API bool get_cuesheet(const char *filename, CueSheet &cuesheet);
1021 
1022  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);
1023  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);
1024 
1025  /* \} */
1026 
1027 
1063  public:
1067  public:
1068  inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { }
1069  inline operator ::FLAC__Metadata_SimpleIteratorStatus() const { return status_; }
1070  inline const char *as_cstring() const { return ::FLAC__Metadata_SimpleIteratorStatusString[status_]; }
1071  protected:
1073  };
1074 
1075  SimpleIterator();
1076  virtual ~SimpleIterator();
1077 
1078  bool is_valid() const;
1079 
1080  bool init(const char *filename, bool read_only, bool preserve_file_stats);
1081 
1083  bool is_writable() const;
1084 
1085  bool next();
1086  bool prev();
1087  bool is_last() const;
1088 
1089  off_t get_block_offset() const;
1091  uint32_t get_block_length() const;
1092  bool get_application_id(FLAC__byte *id);
1094  bool set_block(Prototype *block, bool use_padding = true);
1095  bool insert_block_after(Prototype *block, bool use_padding = true);
1096  bool delete_block(bool use_padding = true);
1097 
1098  protected:
1100  void clear();
1101 
1102  private: // Do not use.
1104  SimpleIterator&operator=(const SimpleIterator&);
1105  };
1106 
1107  /* \} */
1108 
1109 
1153  public:
1157  public:
1158  inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { }
1159  inline operator ::FLAC__Metadata_ChainStatus() const { return status_; }
1160  inline const char *as_cstring() const { return ::FLAC__Metadata_ChainStatusString[status_]; }
1161  protected:
1163  };
1164 
1165  Chain();
1166  virtual ~Chain();
1167 
1168  friend class Iterator;
1169 
1170  bool is_valid() const;
1171 
1173 
1174  bool read(const char *filename, bool is_ogg = false);
1175  bool read(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, bool is_ogg = false);
1176 
1177  bool check_if_tempfile_needed(bool use_padding);
1178 
1179  bool write(bool use_padding = true, bool preserve_file_stats = false);
1180  bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks);
1181  bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks, ::FLAC__IOHandle temp_handle, ::FLAC__IOCallbacks temp_callbacks);
1182 
1183  void merge_padding();
1184  void sort_padding();
1185 
1186  protected:
1187  ::FLAC__Metadata_Chain *chain_;
1188  virtual void clear();
1189 
1190  private: // Do not use.
1191  Chain(const Chain&);
1192  Chain&operator=(const Chain&);
1193  };
1194 
1201  public:
1202  Iterator();
1203  virtual ~Iterator();
1204 
1205  bool is_valid() const;
1206 
1207 
1208  void init(Chain &chain);
1209 
1210  bool next();
1211  bool prev();
1212 
1215  bool set_block(Prototype *block);
1216  bool delete_block(bool replace_with_padding);
1219 
1220  protected:
1221  ::FLAC__Metadata_Iterator *iterator_;
1222  virtual void clear();
1223 
1224  private: // Do not use.
1225  Iterator(const Iterator&);
1226  Iterator&operator=(const Iterator&);
1227  };
1228 
1229  /* \} */
1230 
1231  }
1232 }
1233 
1234 #endif
This module contains #defines and symbols for exporting function calls, and providing version informa...
This module provides functions for creating and manipulating FLAC metadata blocks in memory,...
Definition: metadata.h:412
Definition: metadata.h:1156
Definition: metadata.h:1152
Definition: metadata.h:733
Definition: metadata.h:725
Definition: metadata.h:1200
Definition: metadata.h:353
Definition: metadata.h:864
Definition: metadata.h:109
Definition: metadata.h:471
Definition: metadata.h:1066
Definition: metadata.h:1062
Definition: metadata.h:279
Definition: metadata.h:946
Definition: metadata.h:589
Definition: metadata.h:558
void * FLAC__IOHandle
Definition: callback.h:89
uint32_t type
Definition: format.h:683
struct FLAC__StreamMetadata FLAC__StreamMetadata
FLAC__uint64 offset
Definition: format.h:674
FLAC__byte number
Definition: format.h:677
char isrc[13]
Definition: format.h:680
FLAC__byte num_indices
Definition: format.h:689
FLAC__MetadataType
Definition: format.h:496
uint32_t pre_emphasis
Definition: format.h:686
FLAC__StreamMetadata_Picture_Type
Definition: format.h:739
struct FLAC__Metadata_SimpleIterator FLAC__Metadata_SimpleIterator
Definition: metadata.h:308
const char *const FLAC__Metadata_SimpleIteratorStatusString[]
FLAC__Metadata_SimpleIteratorStatus
Definition: metadata.h:314
const char *const FLAC__Metadata_ChainStatusString[]
struct FLAC__Metadata_Iterator FLAC__Metadata_Iterator
Definition: metadata.h:729
struct FLAC__Metadata_Chain FLAC__Metadata_Chain
Definition: metadata.h:724
FLAC__Metadata_ChainStatus
Definition: metadata.h:731
FLAC__bool FLAC__metadata_object_is_equal(const FLAC__StreamMetadata *block1, const FLAC__StreamMetadata *block2)
#define FLACPP_API
Definition: export.h:88
bool get_tags(const char *filename, VorbisComment &tags)
See FLAC__metadata_get_tags().
bool get_streaminfo(const char *filename, StreamInfo &streaminfo)
See FLAC__metadata_get_streaminfo().
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().
bool get_cuesheet(const char *filename, CueSheet &cuesheet)
See FLAC__metadata_get_cuesheet().
bool delete_index(uint32_t track_num, uint32_t index_num)
See FLAC__metadata_object_cuesheet_track_delete_index()
Status status()
See FLAC__metadata_chain_status().
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().
bool is_valid() const
Definition: metadata.h:265
void set_length(uint32_t length)
bool resize_points(uint32_t new_num_points)
See FLAC__metadata_object_seektable_resize_points()
bool template_sort(bool compact)
See FLAC__metadata_object_seektable_template_sort()
bool delete_point(uint32_t index)
See FLAC__metadata_object_seektable_delete_point()
bool set_block(Prototype *block, bool use_padding=true)
See FLAC__metadata_simple_iterator_set_block().
bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks)
See FLAC__metadata_chain_write_with_callbacks().
bool append_comment(const Entry &entry)
See FLAC__metadata_object_vorbiscomment_append_comment()
bool operator!=(const Padding &object) const
Definition: metadata.h:398
VorbisComment & operator=(const VorbisComment &object)
Definition: metadata.h:662
bool operator==(const SeekTable &object) const
Definition: metadata.h:505
int find_entry_from(uint32_t offset, const char *field_name)
See FLAC__metadata_object_vorbiscomment_find_entry_from()
bool set_description(const FLAC__byte *string)
See FLAC__metadata_object_picture_set_description()
bool operator==(const Padding &object) const
Definition: metadata.h:391
bool operator==(const Picture &object) const
Definition: metadata.h:898
bool insert_block_after(Prototype *block, bool use_padding=true)
See FLAC__metadata_simple_iterator_insert_block_after().
bool next()
See FLAC__metadata_iterator_next().
bool check_if_tempfile_needed(bool use_padding)
See FLAC__metadata_chain_check_if_tempfile_needed().
bool write(bool use_padding=true, bool preserve_file_stats=false)
See FLAC__metadata_chain_write().
Prototype(::FLAC__StreamMetadata *object, bool copy)
bool replace_comment(const Entry &entry, bool all)
See FLAC__metadata_object_vorbiscomment_replace_comment()
bool insert_blank_index(uint32_t track_num, uint32_t index_num)
See FLAC__metadata_object_cuesheet_track_insert_blank_index()
Unknown & operator=(const Unknown &object)
Definition: metadata.h:968
Picture & operator=(const Picture &object)
Definition: metadata.h:886
Unknown(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:962
bool set_data(const FLAC__byte *data, FLAC__uint32 data_length)
See FLAC__metadata_object_picture_set_data()
::FLAC__MetadataType get_block_type() const
See FLAC__metadata_simple_iterator_get_block_type().
bool set_block(Prototype *block)
See FLAC__metadata_iterator_set_block().
StreamInfo & operator=(const StreamInfo &object)
Definition: metadata.h:301
Application(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:428
Padding(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:369
Picture(const Picture &object)
Definition: metadata.h:872
Prototype * get_block()
See FLAC__metadata_iterator_get_block().
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().
Padding(const Padding &object)
Definition: metadata.h:361
bool operator==(const Unknown &object) const
Definition: metadata.h:980
bool operator!=(const Picture &object) const
Definition: metadata.h:905
Padding & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:387
Application & operator=(const Application &object)
Definition: metadata.h:434
bool operator==(const StreamInfo &object) const
Definition: metadata.h:313
bool operator==(const VorbisComment &object) const
Definition: metadata.h:674
bool is_valid() const
Returns true iff object was properly constructed.
bool get_application_id(FLAC__byte *id)
See FLAC__metadata_simple_iterator_get_application_id().
VorbisComment(const VorbisComment &object)
Definition: metadata.h:648
Application & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:442
Unknown & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:976
bool read(const char *filename, bool is_ogg=false)
See FLAC__metadata_chain_read(), FLAC__metadata_chain_read_ogg().
::FLAC__MetadataType get_type() const
bool set_track(uint32_t i, const Track &track)
See FLAC__metadata_object_cuesheet_set_track()
bool is_valid() const
Returns true iff object was properly constructed.
uint32_t get_length() const
bool operator==(const Prototype &) const
Definition: metadata.h:243
bool is_valid() const
Returns true iff object was properly constructed.
bool template_append_spaced_points_by_samples(uint32_t samples, FLAC__uint64 total_samples)
See FLAC__metadata_object_seektable_template_append_spaced_points_by_samples()
VorbisComment(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:656
bool delete_block(bool use_padding=true)
See FLAC__metadata_simple_iterator_delete_block().
bool delete_block(bool replace_with_padding)
See FLAC__metadata_iterator_delete_block().
bool init(const char *filename, bool read_only, bool preserve_file_stats)
See FLAC__metadata_simple_iterator_init().
Unknown(const Unknown &object)
Definition: metadata.h:954
bool template_append_spaced_points(uint32_t num, FLAC__uint64 total_samples)
See FLAC__metadata_object_seektable_template_append_spaced_points()
Picture(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:880
bool is_writable() const
See FLAC__metadata_simple_iterator_is_writable().
bool insert_block_after(Prototype *block)
See FLAC__metadata_iterator_insert_block_after().
bool delete_track(uint32_t i)
See FLAC__metadata_object_cuesheet_delete_track()
virtual bool is_valid() const
Returns true iff object was properly constructed.
bool prev()
See FLAC__metadata_simple_iterator_prev().
void sort_padding()
See FLAC__metadata_chain_sort_padding().
bool resize_indices(uint32_t track_num, uint32_t new_num_indices)
See FLAC__metadata_object_cuesheet_track_resize_indices()
uint32_t get_block_length() const
See FLAC__metadata_simple_iterator_get_block_length().
FLAC__uint32 calculate_cddb_id() const
See FLAC__metadata_object_cuesheet_calculate_cddb_id()
SeekTable(const SeekTable &object)
Definition: metadata.h:479
Padding(uint32_t length)
bool insert_block_before(Prototype *block)
See FLAC__metadata_iterator_insert_block_before().
bool operator==(const Application &object) const
Definition: metadata.h:446
bool is_legal() const
See FLAC__metadata_object_seektable_is_legal()
bool resize_tracks(uint32_t new_num_tracks)
See FLAC__metadata_object_cuesheet_resize_tracks()
Prototype * construct_block(::FLAC__StreamMetadata *object)
void set_colors(FLAC__uint32 value) const
a value of 0 means true-color, i.e. 2^depth colors
bool is_legal(bool check_cd_da_subset=false, const char **violation=0) const
See FLAC__metadata_object_cuesheet_is_legal()
bool set_data(const FLAC__byte *data, uint32_t length)
This form always copies data.
bool operator!=(const SeekTable &object) const
Definition: metadata.h:512
bool template_append_point(FLAC__uint64 sample_number)
See FLAC__metadata_object_seektable_template_append_point()
VorbisComment & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:670
Status status()
See FLAC__metadata_simple_iterator_status().
::FLAC__MetadataType get_block_type() const
See FLAC__metadata_iterator_get_block_type().
Picture & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:894
uint32_t get_min_blocksize() const
bool operator!=(const Unknown &object) const
Definition: metadata.h:987
StreamInfo(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:295
bool insert_comment(uint32_t index, const Entry &entry)
See FLAC__metadata_object_vorbiscomment_insert_comment()
Prototype * get_block()
See FLAC__metadata_simple_iterator_get_block().
bool next()
See FLAC__metadata_simple_iterator_next().
FLAC__uint32 get_colors() const
a return value of 0 means true-color, i.e. 2^depth colors
void init(Chain &chain)
See FLAC__metadata_iterator_init().
StreamInfo(const StreamInfo &object)
Definition: metadata.h:287
bool operator!=(const Prototype &) const
Definition: metadata.h:256
bool insert_point(uint32_t index, const ::FLAC__StreamMetadata_SeekPoint &point)
See FLAC__metadata_object_seektable_insert_point()
bool insert_blank_track(uint32_t i)
See FLAC__metadata_object_cuesheet_insert_blank_track()
virtual bool is_valid() const
Returns true iff object was properly constructed.
SeekTable & operator=(const SeekTable &object)
Definition: metadata.h:493
CueSheet & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:797
bool is_last() const
See FLAC__metadata_simple_iterator_is_last().
Application(const Application &object)
Definition: metadata.h:420
bool operator!=(const VorbisComment &object) const
Definition: metadata.h:681
Prototype & assign_object(::FLAC__StreamMetadata *object, bool copy)
SeekTable(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:487
bool insert_index(uint32_t track_num, uint32_t index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index)
See FLAC__metadata_object_cuesheet_track_insert_index()
void set_point(uint32_t index, const ::FLAC__StreamMetadata_SeekPoint &point)
See FLAC__metadata_object_seektable_set_point()
bool operator!=(const CueSheet &object) const
Definition: metadata.h:808
bool operator==(const CueSheet &object) const
Definition: metadata.h:801
StreamInfo & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:309
bool set_comment(uint32_t index, const Entry &entry)
See FLAC__metadata_object_vorbiscomment_set_comment()
CueSheet & operator=(const CueSheet &object)
Definition: metadata.h:789
off_t get_block_offset() const
See FLAC__metadata_simple_iterator_get_block_offset().
bool template_append_points(FLAC__uint64 sample_numbers[], uint32_t num)
See FLAC__metadata_object_seektable_template_append_points()
bool set_vendor_string(const FLAC__byte *string)
See FLAC__metadata_object_vorbiscomment_set_vendor_string()
bool resize_comments(uint32_t new_num_comments)
See FLAC__metadata_object_vorbiscomment_resize_comments()
bool set_data(const FLAC__byte *data, uint32_t length)
This form always copies data.
SeekTable & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:501
CueSheet(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:783
int remove_entries_matching(const char *field_name)
See FLAC__metadata_object_vorbiscomment_remove_entries_matching()
bool prev()
See FLAC__metadata_iterator_prev().
bool operator!=(const Application &object) const
Definition: metadata.h:453
Prototype(const Prototype &)
bool template_append_placeholders(uint32_t num)
See FLAC__metadata_object_seektable_template_append_placeholders()
Prototype & operator=(const Prototype &)
Padding & operator=(const Padding &object)
Definition: metadata.h:379
bool insert_track(uint32_t i, const Track &track)
See FLAC__metadata_object_cuesheet_insert_track()
void merge_padding()
See FLAC__metadata_chain_merge_padding().
int remove_entry_matching(const char *field_name)
See FLAC__metadata_object_vorbiscomment_remove_entry_matching()
bool operator!=(const StreamInfo &object) const
Definition: metadata.h:320
bool is_legal(const char **violation)
See FLAC__metadata_object_picture_is_legal()
bool delete_comment(uint32_t index)
See FLAC__metadata_object_vorbiscomment_delete_comment()
bool set_mime_type(const char *string)
See FLAC__metadata_object_picture_set_mime_type()
CueSheet(const CueSheet &object)
Definition: metadata.h:775
Prototype * clone(const Prototype *)
Definition: callback.h:175
Definition: format.h:654
Definition: format.h:673
Definition: format.h:581
Definition: format.h:631
Definition: format.h:841

Copyright (c) 2000-2009 Josh Coalson Copyright (c) 2011-2023 Xiph.Org Foundation