1 /* libFLAC++ - Free Lossless Audio Codec library
2 * Copyright (C) 2002 Josh Coalson
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include "FLAC++/metadata.h"
21 #include "FLAC/assert.h"
22 #include <stdlib.h> // for malloc(), free()
23 #include <string.h> // for memcpy() etc.
28 // local utility routines
32 Prototype *construct_block(::FLAC__StreamMetadata *object)
35 switch(object->type) {
36 case FLAC__METADATA_TYPE_STREAMINFO:
37 ret = new StreamInfo(object, /*copy=*/false);
39 case FLAC__METADATA_TYPE_PADDING:
40 ret = new Padding(object, /*copy=*/false);
42 case FLAC__METADATA_TYPE_APPLICATION:
43 ret = new Application(object, /*copy=*/false);
45 case FLAC__METADATA_TYPE_SEEKTABLE:
46 ret = new SeekTable(object, /*copy=*/false);
48 case FLAC__METADATA_TYPE_VORBIS_COMMENT:
49 ret = new VorbisComment(object, /*copy=*/false);
60 Prototype *clone(const Prototype *object)
62 const StreamInfo *streaminfo = dynamic_cast<const StreamInfo *>(object);
63 const Padding *padding = dynamic_cast<const Padding *>(object);
64 const Application *application = dynamic_cast<const Application *>(object);
65 const SeekTable *seektable = dynamic_cast<const SeekTable *>(object);
66 const VorbisComment *vorbiscomment = dynamic_cast<const VorbisComment *>(object);
69 return new StreamInfo(*streaminfo);
71 return new Padding(*padding);
72 else if(0 != application)
73 return new Application(*application);
74 else if(0 != seektable)
75 return new SeekTable(*seektable);
76 else if(0 != vorbiscomment)
77 return new VorbisComment(*vorbiscomment);
88 Prototype::Prototype(const Prototype &object):
89 object_(::FLAC__metadata_object_clone(object.object_)),
92 FLAC__ASSERT(object.is_valid());
95 Prototype::Prototype(const ::FLAC__StreamMetadata &object):
96 object_(::FLAC__metadata_object_clone(&object)),
101 Prototype::Prototype(const ::FLAC__StreamMetadata *object):
102 object_(::FLAC__metadata_object_clone(object)),
105 FLAC__ASSERT(0 != object);
108 Prototype::Prototype(::FLAC__StreamMetadata *object, bool copy):
109 object_(copy? ::FLAC__metadata_object_clone(object) : object),
112 FLAC__ASSERT(0 != object);
115 Prototype::~Prototype()
120 void Prototype::clear()
122 if(0 != object_ && !is_reference_)
123 FLAC__metadata_object_delete(object_);
127 void Prototype::operator=(const Prototype &object)
129 FLAC__ASSERT(object.is_valid());
131 is_reference_ = false;
132 object_ = ::FLAC__metadata_object_clone(object.object_);
135 void Prototype::operator=(const ::FLAC__StreamMetadata &object)
138 is_reference_ = false;
139 object_ = ::FLAC__metadata_object_clone(&object);
142 void Prototype::operator=(const ::FLAC__StreamMetadata *object)
144 FLAC__ASSERT(0 != object);
146 is_reference_ = false;
147 object_ = ::FLAC__metadata_object_clone(object);
150 bool Prototype::get_is_last() const
152 FLAC__ASSERT(is_valid());
153 return (bool)object_->is_last;
156 FLAC__MetadataType Prototype::get_type() const
158 FLAC__ASSERT(is_valid());
159 return object_->type;
162 unsigned Prototype::get_length() const
164 FLAC__ASSERT(is_valid());
165 return object_->length;
168 void Prototype::set_is_last(bool value)
170 FLAC__ASSERT(is_valid());
171 object_->is_last = value;
179 StreamInfo::StreamInfo():
180 Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_STREAMINFO), /*copy=*/false)
183 StreamInfo::~StreamInfo()
186 unsigned StreamInfo::get_min_blocksize() const
188 FLAC__ASSERT(is_valid());
189 return object_->data.stream_info.min_blocksize;
192 unsigned StreamInfo::get_max_blocksize() const
194 FLAC__ASSERT(is_valid());
195 return object_->data.stream_info.max_blocksize;
198 unsigned StreamInfo::get_min_framesize() const
200 FLAC__ASSERT(is_valid());
201 return object_->data.stream_info.min_framesize;
204 unsigned StreamInfo::get_max_framesize() const
206 FLAC__ASSERT(is_valid());
207 return object_->data.stream_info.max_framesize;
210 unsigned StreamInfo::get_sample_rate() const
212 FLAC__ASSERT(is_valid());
213 return object_->data.stream_info.sample_rate;
216 unsigned StreamInfo::get_channels() const
218 FLAC__ASSERT(is_valid());
219 return object_->data.stream_info.channels;
222 unsigned StreamInfo::get_bits_per_sample() const
224 FLAC__ASSERT(is_valid());
225 return object_->data.stream_info.bits_per_sample;
228 FLAC__uint64 StreamInfo::get_total_samples() const
230 FLAC__ASSERT(is_valid());
231 return object_->data.stream_info.total_samples;
234 const FLAC__byte *StreamInfo::get_md5sum() const
236 FLAC__ASSERT(is_valid());
237 return object_->data.stream_info.md5sum;
240 void StreamInfo::set_min_blocksize(unsigned value)
242 FLAC__ASSERT(is_valid());
243 FLAC__ASSERT(value >= FLAC__MIN_BLOCK_SIZE);
244 FLAC__ASSERT(value <= FLAC__MAX_BLOCK_SIZE);
245 object_->data.stream_info.min_blocksize = value;
248 void StreamInfo::set_max_blocksize(unsigned value)
250 FLAC__ASSERT(is_valid());
251 FLAC__ASSERT(value >= FLAC__MIN_BLOCK_SIZE);
252 FLAC__ASSERT(value <= FLAC__MAX_BLOCK_SIZE);
253 object_->data.stream_info.max_blocksize = value;
256 void StreamInfo::set_min_framesize(unsigned value)
258 FLAC__ASSERT(is_valid());
259 FLAC__ASSERT(value < (1u < FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN));
260 object_->data.stream_info.min_framesize = value;
263 void StreamInfo::set_max_framesize(unsigned value)
265 FLAC__ASSERT(is_valid());
266 FLAC__ASSERT(value < (1u < FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN));
267 object_->data.stream_info.max_framesize = value;
270 void StreamInfo::set_sample_rate(unsigned value)
272 FLAC__ASSERT(is_valid());
273 FLAC__ASSERT(FLAC__format_is_valid_sample_rate(value));
274 object_->data.stream_info.sample_rate = value;
277 void StreamInfo::set_channels(unsigned value)
279 FLAC__ASSERT(is_valid());
280 FLAC__ASSERT(value > 0);
281 FLAC__ASSERT(value <= FLAC__MAX_CHANNELS);
282 object_->data.stream_info.channels = value;
285 void StreamInfo::set_bits_per_sample(unsigned value)
287 FLAC__ASSERT(is_valid());
288 FLAC__ASSERT(value >= FLAC__MIN_BITS_PER_SAMPLE);
289 FLAC__ASSERT(value <= FLAC__MAX_BITS_PER_SAMPLE);
290 object_->data.stream_info.bits_per_sample = value;
293 void StreamInfo::set_total_samples(FLAC__uint64 value)
295 FLAC__ASSERT(is_valid());
296 FLAC__ASSERT(value < (1u << FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN));
297 object_->data.stream_info.total_samples = value;
300 void StreamInfo::set_md5sum(const FLAC__byte value[16])
302 FLAC__ASSERT(is_valid());
303 FLAC__ASSERT(0 != value);
304 memcpy(object_->data.stream_info.md5sum, value, 16);
313 Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING), /*copy=*/false)
319 void Padding::set_length(unsigned length)
321 FLAC__ASSERT(is_valid());
322 object_->length = length;
330 Application::Application():
331 Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION), /*copy=*/false)
334 Application::~Application()
337 const FLAC__byte *Application::get_id() const
339 FLAC__ASSERT(is_valid());
340 return object_->data.application.id;
343 const FLAC__byte *Application::get_data() const
345 FLAC__ASSERT(is_valid());
346 return object_->data.application.data;
349 void Application::set_id(const FLAC__byte value[4])
351 FLAC__ASSERT(is_valid());
352 FLAC__ASSERT(0 != value);
353 memcpy(object_->data.application.id, value, 4);
356 bool Application::set_data(const FLAC__byte *data, unsigned length)
358 FLAC__ASSERT(is_valid());
359 return (bool)::FLAC__metadata_object_application_set_data(object_, (FLAC__byte*)data, length, true);
362 bool Application::set_data(FLAC__byte *data, unsigned length, bool copy)
364 FLAC__ASSERT(is_valid());
365 return (bool)::FLAC__metadata_object_application_set_data(object_, data, length, copy);
373 SeekTable::SeekTable():
374 Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE), /*copy=*/false)
377 SeekTable::~SeekTable()
380 unsigned SeekTable::get_num_points() const
382 FLAC__ASSERT(is_valid());
383 return object_->data.seek_table.num_points;
386 ::FLAC__StreamMetadata_SeekPoint SeekTable::get_point(unsigned index) const
388 FLAC__ASSERT(is_valid());
389 FLAC__ASSERT(index < object_->data.seek_table.num_points);
390 return object_->data.seek_table.points[index];
393 void SeekTable::set_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point)
395 FLAC__ASSERT(is_valid());
396 FLAC__ASSERT(index < object_->data.seek_table.num_points);
397 ::FLAC__metadata_object_seektable_set_point(object_, index, point);
400 bool SeekTable::insert_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point)
402 FLAC__ASSERT(is_valid());
403 FLAC__ASSERT(index <= object_->data.seek_table.num_points);
404 return (bool)::FLAC__metadata_object_seektable_insert_point(object_, index, point);
407 bool SeekTable::delete_point(unsigned index)
409 FLAC__ASSERT(is_valid());
410 FLAC__ASSERT(index < object_->data.seek_table.num_points);
411 return (bool)::FLAC__metadata_object_seektable_delete_point(object_, index);
414 bool SeekTable::is_legal() const
416 FLAC__ASSERT(is_valid());
417 return (bool)::FLAC__metadata_object_seektable_is_legal(object_);
422 // VorbisComment::Entry
425 VorbisComment::Entry::Entry()
430 VorbisComment::Entry::Entry(const char *field, unsigned field_length)
433 construct(field, field_length);
436 VorbisComment::Entry::Entry(const char *field_name, const char *field_value, unsigned field_value_length)
439 construct(field_name, field_value, field_value_length);
442 VorbisComment::Entry::Entry(const Entry &entry)
444 FLAC__ASSERT(entry.is_valid());
446 construct((const char *)entry.entry_.entry, entry.entry_.length);
449 void VorbisComment::Entry::operator=(const Entry &entry)
451 FLAC__ASSERT(entry.is_valid());
453 construct((const char *)entry.entry_.entry, entry.entry_.length);
456 VorbisComment::Entry::~Entry()
461 bool VorbisComment::Entry::is_valid() const
466 unsigned VorbisComment::Entry::get_field_length() const
468 FLAC__ASSERT(is_valid());
469 return entry_.length;
472 unsigned VorbisComment::Entry::get_field_name_length() const
474 FLAC__ASSERT(is_valid());
475 return field_name_length_;
478 unsigned VorbisComment::Entry::get_field_value_length() const
480 FLAC__ASSERT(is_valid());
481 return field_value_length_;
484 ::FLAC__StreamMetadata_VorbisComment_Entry VorbisComment::Entry::get_entry() const
486 FLAC__ASSERT(is_valid());
490 const char *VorbisComment::Entry::get_field() const
492 FLAC__ASSERT(is_valid());
493 return (const char *)entry_.entry;
496 const char *VorbisComment::Entry::get_field_name() const
498 FLAC__ASSERT(is_valid());
502 const char *VorbisComment::Entry::get_field_value() const
504 FLAC__ASSERT(is_valid());
508 bool VorbisComment::Entry::set_field(const char *field, unsigned field_length)
510 FLAC__ASSERT(is_valid());
511 FLAC__ASSERT(0 != field);
515 if(0 == (entry_.entry = (FLAC__byte*)malloc(field_length))) {
519 entry_.length = field_length;
520 memcpy(entry_.entry, field, field_length);
521 (void) parse_field();
527 bool VorbisComment::Entry::set_field_name(const char *field_name)
529 FLAC__ASSERT(is_valid());
530 FLAC__ASSERT(0 != field_name);
534 if(0 == (field_name_ = strdup(field_name))) {
538 field_name_length_ = strlen(field_name_);
545 bool VorbisComment::Entry::set_field_value(const char *field_value, unsigned field_value_length)
547 FLAC__ASSERT(is_valid());
548 FLAC__ASSERT(0 != field_value);
552 if(0 == (field_value_ = (char *)malloc(field_value_length))) {
556 field_value_length_ = field_value_length;
557 memcpy(field_value_, field_value, field_value_length);
564 void VorbisComment::Entry::zero()
570 field_name_length_ = 0;
572 field_value_length_ = 0;
575 void VorbisComment::Entry::clear()
583 void VorbisComment::Entry::clear_entry()
585 if(0 != entry_.entry) {
592 void VorbisComment::Entry::clear_field_name()
594 if(0 != field_name_) {
597 field_name_length_ = 0;
601 void VorbisComment::Entry::clear_field_value()
603 if(0 != field_value_) {
606 field_value_length_ = 0;
610 void VorbisComment::Entry::construct(const char *field, unsigned field_length)
612 if(set_field(field, field_length))
616 void VorbisComment::Entry::construct(const char *field_name, const char *field_value, unsigned field_value_length)
618 if(set_field_name(field_name) && set_field_value(field_value, field_value_length))
622 void VorbisComment::Entry::compose_field()
626 if(0 == (entry_.entry = (FLAC__byte*)malloc(field_name_length_ + 1 + field_value_length_))) {
630 memcpy(entry_.entry, field_name_, field_name_length_);
631 entry_.length += field_name_length_;
632 memcpy(entry_.entry + entry_.length, "=", 1);
634 memcpy(entry_.entry + entry_.length, field_value_, field_value_length_);
635 entry_.length += field_value_length_;
640 void VorbisComment::Entry::parse_field()
645 const char *p = (const char *)memchr(entry_.entry, '=', entry_.length);
648 p = (const char *)entry_.entry + entry_.length;
650 field_name_length_ = p - (const char *)entry_.entry;
651 if(0 == (field_name_ = (char *)malloc(field_name_length_ + 1))) { // +1 for the trailing \0
655 memcpy(field_name_, entry_.entry, field_name_length_);
656 field_name_[field_name_length_] = '\0';
658 if(entry_.length - field_name_length_ == 0) {
659 field_value_length_ = 0;
660 if(0 == (field_value_ = (char *)malloc(0))) {
666 field_value_length_ = entry_.length - field_name_length_ - 1;
667 if(0 == (field_value_ = (char *)malloc(field_value_length_))) {
671 memcpy(field_value_, ++p, field_value_length_);
682 VorbisComment::VorbisComment():
683 Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT), /*copy=*/false)
686 VorbisComment::~VorbisComment()
689 unsigned VorbisComment::get_num_comments() const
691 FLAC__ASSERT(is_valid());
692 return object_->data.vorbis_comment.num_comments;
695 VorbisComment::Entry VorbisComment::get_vendor_string() const
697 FLAC__ASSERT(is_valid());
698 return Entry((const char *)object_->data.vorbis_comment.vendor_string.entry, object_->data.vorbis_comment.vendor_string.length);
701 VorbisComment::Entry VorbisComment::get_comment(unsigned index) const
703 FLAC__ASSERT(is_valid());
704 FLAC__ASSERT(index < object_->data.vorbis_comment.num_comments);
705 return Entry((const char *)object_->data.vorbis_comment.comments[index].entry, object_->data.vorbis_comment.comments[index].length);
708 bool VorbisComment::set_vendor_string(const VorbisComment::Entry &entry)
710 FLAC__ASSERT(is_valid());
711 // vendor_string is a special kind of entry
712 ::FLAC__StreamMetadata_VorbisComment_Entry vendor_string;
713 vendor_string.length = entry.get_field_name_length();
714 vendor_string.entry = (FLAC__byte*)entry.get_field_name(); // we can cheat on const-ness because we make a copy below:
715 return (bool)::FLAC__metadata_object_vorbiscomment_set_vendor_string(object_, vendor_string, /*copy=*/true);
718 bool VorbisComment::set_comment(unsigned index, const VorbisComment::Entry &entry)
720 FLAC__ASSERT(is_valid());
721 FLAC__ASSERT(index < object_->data.vorbis_comment.num_comments);
722 return (bool)::FLAC__metadata_object_vorbiscomment_set_comment(object_, index, entry.get_entry(), /*copy=*/true);
725 bool VorbisComment::insert_comment(unsigned index, const VorbisComment::Entry &entry)
727 FLAC__ASSERT(is_valid());
728 FLAC__ASSERT(index <= object_->data.vorbis_comment.num_comments);
729 return (bool)::FLAC__metadata_object_vorbiscomment_insert_comment(object_, index, entry.get_entry(), /*copy=*/true);
732 bool VorbisComment::delete_comment(unsigned index)
734 FLAC__ASSERT(is_valid());
735 FLAC__ASSERT(index < object_->data.vorbis_comment.num_comments);
736 return (bool)::FLAC__metadata_object_vorbiscomment_delete_comment(object_, index);
740 // ============================================================
744 // ============================================================
746 bool get_streaminfo(const char *filename, StreamInfo &streaminfo)
748 FLAC__ASSERT(0 != filename);
750 ::FLAC__StreamMetadata s;
752 if(::FLAC__metadata_get_streaminfo(filename, &s)) {
761 // ============================================================
765 // ============================================================
767 SimpleIterator::SimpleIterator():
768 iterator_(::FLAC__metadata_simple_iterator_new())
771 SimpleIterator::~SimpleIterator()
776 void SimpleIterator::clear()
779 FLAC__metadata_simple_iterator_delete(iterator_);
783 bool SimpleIterator::init(const char *filename, bool preserve_file_stats)
785 FLAC__ASSERT(0 != filename);
786 FLAC__ASSERT(is_valid());
787 return (bool)::FLAC__metadata_simple_iterator_init(iterator_, filename, preserve_file_stats);
790 bool SimpleIterator::is_valid() const
792 return 0 != iterator_;
795 SimpleIterator::Status SimpleIterator::status()
797 FLAC__ASSERT(is_valid());
798 return Status(::FLAC__metadata_simple_iterator_status(iterator_));
801 bool SimpleIterator::is_writable() const
803 FLAC__ASSERT(is_valid());
804 return (bool)::FLAC__metadata_simple_iterator_is_writable(iterator_);
807 bool SimpleIterator::next()
809 FLAC__ASSERT(is_valid());
810 return (bool)::FLAC__metadata_simple_iterator_next(iterator_);
813 bool SimpleIterator::prev()
815 FLAC__ASSERT(is_valid());
816 return (bool)::FLAC__metadata_simple_iterator_prev(iterator_);
819 ::FLAC__MetadataType SimpleIterator::get_block_type() const
821 FLAC__ASSERT(is_valid());
822 return ::FLAC__metadata_simple_iterator_get_block_type(iterator_);
825 Prototype *SimpleIterator::get_block()
827 FLAC__ASSERT(is_valid());
828 return local::construct_block(::FLAC__metadata_simple_iterator_get_block(iterator_));
831 bool SimpleIterator::set_block(Prototype *block, bool use_padding)
833 FLAC__ASSERT(0 != block);
834 FLAC__ASSERT(is_valid());
835 return (bool)::FLAC__metadata_simple_iterator_set_block(iterator_, block->object_, use_padding);
838 bool SimpleIterator::insert_block_after(Prototype *block, bool use_padding)
840 FLAC__ASSERT(0 != block);
841 FLAC__ASSERT(is_valid());
842 return (bool)::FLAC__metadata_simple_iterator_insert_block_after(iterator_, block->object_, use_padding);
845 bool SimpleIterator::delete_block(bool use_padding)
847 FLAC__ASSERT(is_valid());
848 return (bool)::FLAC__metadata_simple_iterator_delete_block(iterator_, use_padding);
852 // ============================================================
856 // ============================================================
859 chain_(::FLAC__metadata_chain_new())
870 FLAC__metadata_chain_delete(chain_);
874 bool Chain::is_valid() const
879 Chain::Status Chain::status()
881 FLAC__ASSERT(is_valid());
882 return Status(::FLAC__metadata_chain_status(chain_));
885 bool Chain::read(const char *filename)
887 FLAC__ASSERT(0 != filename);
888 FLAC__ASSERT(is_valid());
889 return (bool)::FLAC__metadata_chain_read(chain_, filename);
892 bool Chain::write(bool use_padding, bool preserve_file_stats)
894 FLAC__ASSERT(is_valid());
895 return (bool)::FLAC__metadata_chain_write(chain_, use_padding, preserve_file_stats);
898 void Chain::merge_padding()
900 FLAC__ASSERT(is_valid());
901 ::FLAC__metadata_chain_merge_padding(chain_);
904 void Chain::sort_padding()
906 FLAC__ASSERT(is_valid());
907 ::FLAC__metadata_chain_sort_padding(chain_);
911 Iterator::Iterator():
912 iterator_(::FLAC__metadata_iterator_new())
915 Iterator::~Iterator()
920 void Iterator::clear()
923 FLAC__metadata_iterator_delete(iterator_);
927 bool Iterator::is_valid() const
929 return 0 != iterator_;
932 void Iterator::init(Chain &chain)
934 FLAC__ASSERT(is_valid());
935 FLAC__ASSERT(chain.is_valid());
936 ::FLAC__metadata_iterator_init(iterator_, chain.chain_);
939 bool Iterator::next()
941 FLAC__ASSERT(is_valid());
942 return (bool)::FLAC__metadata_iterator_next(iterator_);
945 bool Iterator::prev()
947 FLAC__ASSERT(is_valid());
948 return (bool)::FLAC__metadata_iterator_prev(iterator_);
951 ::FLAC__MetadataType Iterator::get_block_type() const
953 FLAC__ASSERT(is_valid());
954 return ::FLAC__metadata_iterator_get_block_type(iterator_);
957 Prototype *Iterator::get_block()
959 FLAC__ASSERT(is_valid());
960 Prototype *block = local::construct_block(::FLAC__metadata_iterator_get_block(iterator_));
962 block->set_reference(true);
966 bool Iterator::set_block(Prototype *block)
968 FLAC__ASSERT(0 != block);
969 FLAC__ASSERT(is_valid());
970 bool ret = (bool)::FLAC__metadata_iterator_set_block(iterator_, block->object_);
972 block->set_reference(true);
978 bool Iterator::delete_block(bool replace_with_padding)
980 FLAC__ASSERT(is_valid());
981 return (bool)::FLAC__metadata_iterator_delete_block(iterator_, replace_with_padding);
984 bool Iterator::insert_block_before(Prototype *block)
986 FLAC__ASSERT(0 != block);
987 FLAC__ASSERT(is_valid());
988 bool ret = (bool)::FLAC__metadata_iterator_insert_block_before(iterator_, block->object_);
990 block->set_reference(true);
996 bool Iterator::insert_block_after(Prototype *block)
998 FLAC__ASSERT(0 != block);
999 FLAC__ASSERT(is_valid());
1000 bool ret = (bool)::FLAC__metadata_iterator_insert_block_after(iterator_, block->object_);
1002 block->set_reference(true);