/* libFLAC++ - Free Lossless Audio Codec library
- * Copyright (C) 2002,2003,2004 Josh Coalson
+ * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#define __STDC_LIMIT_MACROS 1 /* otherwise SIZE_MAX is not defined for c++ */
+#include "share/alloc.h"
#include "FLAC++/metadata.h"
#include "FLAC/assert.h"
#include <stdlib.h> // for malloc(), free()
case FLAC__METADATA_TYPE_CUESHEET:
ret = new CueSheet(object, /*copy=*/false);
break;
+ case FLAC__METADATA_TYPE_PICTURE:
+ ret = new Picture(object, /*copy=*/false);
+ break;
default:
ret = new Unknown(object, /*copy=*/false);
break;
return ret;
}
- };
+ }
FLACPP_API Prototype *clone(const Prototype *object)
{
const SeekTable *seektable = dynamic_cast<const SeekTable *>(object);
const VorbisComment *vorbiscomment = dynamic_cast<const VorbisComment *>(object);
const CueSheet *cuesheet = dynamic_cast<const CueSheet *>(object);
+ const Picture *picture = dynamic_cast<const Picture *>(object);
const Unknown *unknown = dynamic_cast<const Unknown *>(object);
if(0 != streaminfo)
return new VorbisComment(*vorbiscomment);
else if(0 != cuesheet)
return new CueSheet(*cuesheet);
+ else if(0 != picture)
+ return new Picture(*picture);
else if(0 != unknown)
return new Unknown(*unknown);
else {
object_ = 0;
}
- void Prototype::operator=(const Prototype &object)
+ Prototype &Prototype::operator=(const Prototype &object)
{
FLAC__ASSERT(object.is_valid());
clear();
is_reference_ = false;
object_ = ::FLAC__metadata_object_clone(object.object_);
+ return *this;
}
- void Prototype::operator=(const ::FLAC__StreamMetadata &object)
+ Prototype &Prototype::operator=(const ::FLAC__StreamMetadata &object)
{
clear();
is_reference_ = false;
object_ = ::FLAC__metadata_object_clone(&object);
+ return *this;
}
- void Prototype::operator=(const ::FLAC__StreamMetadata *object)
+ Prototype &Prototype::operator=(const ::FLAC__StreamMetadata *object)
{
FLAC__ASSERT(0 != object);
clear();
is_reference_ = false;
object_ = ::FLAC__metadata_object_clone(object);
+ return *this;
+ }
+
+ Prototype &Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy)
+ {
+ FLAC__ASSERT(0 != object);
+ clear();
+ object_ = (copy? ::FLAC__metadata_object_clone(object) : object);
+ is_reference_ = false;
+ return *this;
}
bool Prototype::get_is_last() const
void StreamInfo::set_min_framesize(unsigned value)
{
FLAC__ASSERT(is_valid());
- FLAC__ASSERT(value < (1u < FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN));
+ FLAC__ASSERT(value < (1u << FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN));
object_->data.stream_info.min_framesize = value;
}
void StreamInfo::set_max_framesize(unsigned value)
{
FLAC__ASSERT(is_valid());
- FLAC__ASSERT(value < (1u < FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN));
+ FLAC__ASSERT(value < (1u << FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN));
object_->data.stream_info.max_framesize = value;
}
void StreamInfo::set_total_samples(FLAC__uint64 value)
{
FLAC__ASSERT(is_valid());
- FLAC__ASSERT(value < (1u << FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN));
+ FLAC__ASSERT(value < (((FLAC__uint64)1) << FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN));
object_->data.stream_info.total_samples = value;
}
Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING), /*copy=*/false)
{ }
+ Padding::Padding(unsigned length):
+ Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING), /*copy=*/false)
+ {
+ set_length(length);
+ }
+
Padding::~Padding()
{ }
return object_->data.seek_table.num_points;
}
- ::FLAC__StreamMetadata_SeekPoint SeekTable::get_point(unsigned index) const
+ ::FLAC__StreamMetadata_SeekPoint SeekTable::get_point(unsigned indx) const
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(indx < object_->data.seek_table.num_points);
+ return object_->data.seek_table.points[indx];
+ }
+
+ bool SeekTable::resize_points(unsigned new_num_points)
{
FLAC__ASSERT(is_valid());
- FLAC__ASSERT(index < object_->data.seek_table.num_points);
- return object_->data.seek_table.points[index];
+ return (bool)::FLAC__metadata_object_seektable_resize_points(object_, new_num_points);
}
- void SeekTable::set_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point)
+ void SeekTable::set_point(unsigned indx, const ::FLAC__StreamMetadata_SeekPoint &point)
{
FLAC__ASSERT(is_valid());
- FLAC__ASSERT(index < object_->data.seek_table.num_points);
- ::FLAC__metadata_object_seektable_set_point(object_, index, point);
+ FLAC__ASSERT(indx < object_->data.seek_table.num_points);
+ ::FLAC__metadata_object_seektable_set_point(object_, indx, point);
}
- bool SeekTable::insert_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point)
+ bool SeekTable::insert_point(unsigned indx, const ::FLAC__StreamMetadata_SeekPoint &point)
{
FLAC__ASSERT(is_valid());
- FLAC__ASSERT(index <= object_->data.seek_table.num_points);
- return (bool)::FLAC__metadata_object_seektable_insert_point(object_, index, point);
+ FLAC__ASSERT(indx <= object_->data.seek_table.num_points);
+ return (bool)::FLAC__metadata_object_seektable_insert_point(object_, indx, point);
}
- bool SeekTable::delete_point(unsigned index)
+ bool SeekTable::delete_point(unsigned indx)
{
FLAC__ASSERT(is_valid());
- FLAC__ASSERT(index < object_->data.seek_table.num_points);
- return (bool)::FLAC__metadata_object_seektable_delete_point(object_, index);
+ FLAC__ASSERT(indx < object_->data.seek_table.num_points);
+ return (bool)::FLAC__metadata_object_seektable_delete_point(object_, indx);
}
bool SeekTable::is_legal() const
return (bool)::FLAC__metadata_object_seektable_is_legal(object_);
}
+ bool SeekTable::template_append_placeholders(unsigned num)
+ {
+ FLAC__ASSERT(is_valid());
+ return (bool)::FLAC__metadata_object_seektable_template_append_placeholders(object_, num);
+ }
+
+ bool SeekTable::template_append_point(FLAC__uint64 sample_number)
+ {
+ FLAC__ASSERT(is_valid());
+ return (bool)::FLAC__metadata_object_seektable_template_append_point(object_, sample_number);
+ }
+
+ bool SeekTable::template_append_points(FLAC__uint64 sample_numbers[], unsigned num)
+ {
+ FLAC__ASSERT(is_valid());
+ return (bool)::FLAC__metadata_object_seektable_template_append_points(object_, sample_numbers, num);
+ }
+
+ bool SeekTable::template_append_spaced_points(unsigned num, FLAC__uint64 total_samples)
+ {
+ FLAC__ASSERT(is_valid());
+ return (bool)::FLAC__metadata_object_seektable_template_append_spaced_points(object_, num, total_samples);
+ }
+
+ bool SeekTable::template_append_spaced_points_by_samples(unsigned samples, FLAC__uint64 total_samples)
+ {
+ FLAC__ASSERT(is_valid());
+ return (bool)::FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(object_, samples, total_samples);
+ }
+
+ bool SeekTable::template_sort(bool compact)
+ {
+ FLAC__ASSERT(is_valid());
+ return (bool)::FLAC__metadata_object_seektable_template_sort(object_, compact);
+ }
+
//
// VorbisComment::Entry
construct((const char *)entry.entry_.entry, entry.entry_.length);
}
- void VorbisComment::Entry::operator=(const Entry &entry)
+ VorbisComment::Entry &VorbisComment::Entry::operator=(const Entry &entry)
{
FLAC__ASSERT(entry.is_valid());
clear();
construct((const char *)entry.entry_.entry, entry.entry_.length);
+ return *this;
}
VorbisComment::Entry::~Entry()
clear_entry();
- if(0 == (entry_.entry = (FLAC__byte*)malloc(field_length+1))) {
+ if(0 == (entry_.entry = (FLAC__byte*)safe_malloc_add_2op_(field_length, /*+*/1))) {
is_valid_ = false;
}
else {
clear_field_value();
- if(0 == (field_value_ = (char *)malloc(field_value_length+1))) {
+ if(0 == (field_value_ = (char *)safe_malloc_add_2op_(field_value_length, /*+*/1))) {
is_valid_ = false;
}
else {
{
clear_entry();
- if(0 == (entry_.entry = (FLAC__byte*)malloc(field_name_length_ + 1 + field_value_length_ + 1))) {
+ if(0 == (entry_.entry = (FLAC__byte*)safe_malloc_add_4op_(field_name_length_, /*+*/1, /*+*/field_value_length_, /*+*/1))) {
is_valid_ = false;
}
else {
if(0 == p)
p = (const char *)entry_.entry + entry_.length;
- field_name_length_ = p - (const char *)entry_.entry;
- if(0 == (field_name_ = (char *)malloc(field_name_length_ + 1))) { // +1 for the trailing \0
+ field_name_length_ = (unsigned)(p - (const char *)entry_.entry);
+ if(0 == (field_name_ = (char *)safe_malloc_add_2op_(field_name_length_, /*+*/1))) { // +1 for the trailing \0
is_valid_ = false;
return;
}
if(entry_.length - field_name_length_ == 0) {
field_value_length_ = 0;
- if(0 == (field_value_ = (char *)malloc(0))) {
+ if(0 == (field_value_ = (char *)safe_malloc_(0))) {
is_valid_ = false;
return;
}
}
else {
field_value_length_ = entry_.length - field_name_length_ - 1;
- if(0 == (field_value_ = (char *)malloc(field_value_length_ + 1))) { // +1 for the trailing \0
+ if(0 == (field_value_ = (char *)safe_malloc_add_2op_(field_value_length_, /*+*/1))) { // +1 for the trailing \0
is_valid_ = false;
return;
}
return object_->data.vorbis_comment.vendor_string.entry;
}
- VorbisComment::Entry VorbisComment::get_comment(unsigned index) const
+ VorbisComment::Entry VorbisComment::get_comment(unsigned indx) const
{
FLAC__ASSERT(is_valid());
- FLAC__ASSERT(index < object_->data.vorbis_comment.num_comments);
- return Entry((const char *)object_->data.vorbis_comment.comments[index].entry, object_->data.vorbis_comment.comments[index].length);
+ FLAC__ASSERT(indx < object_->data.vorbis_comment.num_comments);
+ return Entry((const char *)object_->data.vorbis_comment.comments[indx].entry, object_->data.vorbis_comment.comments[indx].length);
}
bool VorbisComment::set_vendor_string(const FLAC__byte *string)
{
FLAC__ASSERT(is_valid());
// vendor_string is a special kind of entry
- const ::FLAC__StreamMetadata_VorbisComment_Entry vendor_string = { strlen((const char *)string), (FLAC__byte*)string }; // we can cheat on const-ness because we make a copy below:
+ const ::FLAC__StreamMetadata_VorbisComment_Entry vendor_string = { static_cast<FLAC__uint32>(strlen((const char *)string)), (FLAC__byte*)string }; // we can cheat on const-ness because we make a copy below:
return (bool)::FLAC__metadata_object_vorbiscomment_set_vendor_string(object_, vendor_string, /*copy=*/true);
}
- bool VorbisComment::set_comment(unsigned index, const VorbisComment::Entry &entry)
+ bool VorbisComment::resize_comments(unsigned new_num_comments)
{
FLAC__ASSERT(is_valid());
- FLAC__ASSERT(index < object_->data.vorbis_comment.num_comments);
- return (bool)::FLAC__metadata_object_vorbiscomment_set_comment(object_, index, entry.get_entry(), /*copy=*/true);
+ return (bool)::FLAC__metadata_object_vorbiscomment_resize_comments(object_, new_num_comments);
}
- bool VorbisComment::insert_comment(unsigned index, const VorbisComment::Entry &entry)
+ bool VorbisComment::set_comment(unsigned indx, const VorbisComment::Entry &entry)
{
FLAC__ASSERT(is_valid());
- FLAC__ASSERT(index <= object_->data.vorbis_comment.num_comments);
- return (bool)::FLAC__metadata_object_vorbiscomment_insert_comment(object_, index, entry.get_entry(), /*copy=*/true);
+ FLAC__ASSERT(indx < object_->data.vorbis_comment.num_comments);
+ return (bool)::FLAC__metadata_object_vorbiscomment_set_comment(object_, indx, entry.get_entry(), /*copy=*/true);
+ }
+
+ bool VorbisComment::insert_comment(unsigned indx, const VorbisComment::Entry &entry)
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(indx <= object_->data.vorbis_comment.num_comments);
+ return (bool)::FLAC__metadata_object_vorbiscomment_insert_comment(object_, indx, entry.get_entry(), /*copy=*/true);
}
bool VorbisComment::append_comment(const VorbisComment::Entry &entry)
return (bool)::FLAC__metadata_object_vorbiscomment_append_comment(object_, entry.get_entry(), /*copy=*/true);
}
- bool VorbisComment::delete_comment(unsigned index)
+ bool VorbisComment::replace_comment(const VorbisComment::Entry &entry, bool all)
+ {
+ FLAC__ASSERT(is_valid());
+ return (bool)::FLAC__metadata_object_vorbiscomment_replace_comment(object_, entry.get_entry(), all, /*copy=*/true);
+ }
+
+ bool VorbisComment::delete_comment(unsigned indx)
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(indx < object_->data.vorbis_comment.num_comments);
+ return (bool)::FLAC__metadata_object_vorbiscomment_delete_comment(object_, indx);
+ }
+
+ int VorbisComment::find_entry_from(unsigned offset, const char *field_name)
+ {
+ FLAC__ASSERT(is_valid());
+ return ::FLAC__metadata_object_vorbiscomment_find_entry_from(object_, offset, field_name);
+ }
+
+ int VorbisComment::remove_entry_matching(const char *field_name)
+ {
+ FLAC__ASSERT(is_valid());
+ return ::FLAC__metadata_object_vorbiscomment_remove_entry_matching(object_, field_name);
+ }
+
+ int VorbisComment::remove_entries_matching(const char *field_name)
{
FLAC__ASSERT(is_valid());
- FLAC__ASSERT(index < object_->data.vorbis_comment.num_comments);
- return (bool)::FLAC__metadata_object_vorbiscomment_delete_comment(object_, index);
+ return ::FLAC__metadata_object_vorbiscomment_remove_entries_matching(object_, field_name);
}
object_(::FLAC__metadata_object_cuesheet_track_clone(track.object_))
{ }
- void CueSheet::Track::operator=(const Track &track)
+ CueSheet::Track &CueSheet::Track::operator=(const Track &track)
{
if(0 != object_)
::FLAC__metadata_object_cuesheet_track_delete(object_);
object_ = ::FLAC__metadata_object_cuesheet_track_clone(track.object_);
+ return *this;
}
CueSheet::Track::~Track()
object_->type = value;
}
- void CueSheet::Track::set_index(unsigned i, const ::FLAC__StreamMetadata_CueSheet_Index &index)
+ void CueSheet::Track::set_index(unsigned i, const ::FLAC__StreamMetadata_CueSheet_Index &indx)
{
FLAC__ASSERT(is_valid());
FLAC__ASSERT(i < object_->num_indices);
- object_->indices[i] = index;
+ object_->indices[i] = indx;
}
object_->data.cue_sheet.is_cd = value;
}
- void CueSheet::set_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index)
+ void CueSheet::set_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &indx)
{
FLAC__ASSERT(is_valid());
FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks);
FLAC__ASSERT(index_num < object_->data.cue_sheet.tracks[track_num].num_indices);
- object_->data.cue_sheet.tracks[track_num].indices[index_num] = index;
+ object_->data.cue_sheet.tracks[track_num].indices[index_num] = indx;
}
- bool CueSheet::insert_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index)
+ bool CueSheet::resize_indices(unsigned track_num, unsigned new_num_indices)
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks);
+ return (bool)::FLAC__metadata_object_cuesheet_track_resize_indices(object_, track_num, new_num_indices);
+ }
+
+ bool CueSheet::insert_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &indx)
{
FLAC__ASSERT(is_valid());
FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks);
FLAC__ASSERT(index_num <= object_->data.cue_sheet.tracks[track_num].num_indices);
- return (bool)::FLAC__metadata_object_cuesheet_track_insert_index(object_, track_num, index_num, index);
+ return (bool)::FLAC__metadata_object_cuesheet_track_insert_index(object_, track_num, index_num, indx);
+ }
+
+ bool CueSheet::insert_blank_index(unsigned track_num, unsigned index_num)
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks);
+ FLAC__ASSERT(index_num <= object_->data.cue_sheet.tracks[track_num].num_indices);
+ return (bool)::FLAC__metadata_object_cuesheet_track_insert_blank_index(object_, track_num, index_num);
}
bool CueSheet::delete_index(unsigned track_num, unsigned index_num)
return (bool)::FLAC__metadata_object_cuesheet_track_delete_index(object_, track_num, index_num);
}
+ bool CueSheet::resize_tracks(unsigned new_num_tracks)
+ {
+ FLAC__ASSERT(is_valid());
+ return (bool)::FLAC__metadata_object_cuesheet_resize_tracks(object_, new_num_tracks);
+ }
+
bool CueSheet::set_track(unsigned i, const CueSheet::Track &track)
{
FLAC__ASSERT(is_valid());
return (bool)::FLAC__metadata_object_cuesheet_insert_track(object_, i, const_cast< ::FLAC__StreamMetadata_CueSheet_Track*>(track.get_track()), /*copy=*/true);
}
+ bool CueSheet::insert_blank_track(unsigned i)
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(i <= object_->data.cue_sheet.num_tracks);
+ return (bool)::FLAC__metadata_object_cuesheet_insert_blank_track(object_, i);
+ }
+
bool CueSheet::delete_track(unsigned i)
{
FLAC__ASSERT(is_valid());
return (bool)::FLAC__metadata_object_cuesheet_is_legal(object_, check_cd_da_subset, violation);
}
+ FLAC__uint32 CueSheet::calculate_cddb_id() const
+ {
+ FLAC__ASSERT(is_valid());
+ return ::FLAC__metadata_object_cuesheet_calculate_cddb_id(object_);
+ }
+
+
+ //
+ // Picture
+ //
+
+ Picture::Picture():
+ Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_PICTURE), /*copy=*/false)
+ { }
+
+ Picture::~Picture()
+ { }
+
+ ::FLAC__StreamMetadata_Picture_Type Picture::get_type() const
+ {
+ FLAC__ASSERT(is_valid());
+ return object_->data.picture.type;
+ }
+
+ const char *Picture::get_mime_type() const
+ {
+ FLAC__ASSERT(is_valid());
+ return object_->data.picture.mime_type;
+ }
+
+ const FLAC__byte *Picture::get_description() const
+ {
+ FLAC__ASSERT(is_valid());
+ return object_->data.picture.description;
+ }
+
+ FLAC__uint32 Picture::get_width() const
+ {
+ FLAC__ASSERT(is_valid());
+ return object_->data.picture.width;
+ }
+
+ FLAC__uint32 Picture::get_height() const
+ {
+ FLAC__ASSERT(is_valid());
+ return object_->data.picture.height;
+ }
+
+ FLAC__uint32 Picture::get_depth() const
+ {
+ FLAC__ASSERT(is_valid());
+ return object_->data.picture.depth;
+ }
+
+ FLAC__uint32 Picture::get_colors() const
+ {
+ FLAC__ASSERT(is_valid());
+ return object_->data.picture.colors;
+ }
+
+ FLAC__uint32 Picture::get_data_length() const
+ {
+ FLAC__ASSERT(is_valid());
+ return object_->data.picture.data_length;
+ }
+
+ const FLAC__byte *Picture::get_data() const
+ {
+ FLAC__ASSERT(is_valid());
+ return object_->data.picture.data;
+ }
+
+ void Picture::set_type(::FLAC__StreamMetadata_Picture_Type type)
+ {
+ FLAC__ASSERT(is_valid());
+ object_->data.picture.type = type;
+ }
+
+ bool Picture::set_mime_type(const char *string)
+ {
+ FLAC__ASSERT(is_valid());
+ // We can safely const_cast since copy=true
+ return (bool)::FLAC__metadata_object_picture_set_mime_type(object_, const_cast<char*>(string), /*copy=*/true);
+ }
+
+ bool Picture::set_description(const FLAC__byte *string)
+ {
+ FLAC__ASSERT(is_valid());
+ // We can safely const_cast since copy=true
+ return (bool)::FLAC__metadata_object_picture_set_description(object_, const_cast<FLAC__byte*>(string), /*copy=*/true);
+ }
+
+ void Picture::set_width(FLAC__uint32 value) const
+ {
+ FLAC__ASSERT(is_valid());
+ object_->data.picture.width = value;
+ }
+
+ void Picture::set_height(FLAC__uint32 value) const
+ {
+ FLAC__ASSERT(is_valid());
+ object_->data.picture.height = value;
+ }
+
+ void Picture::set_depth(FLAC__uint32 value) const
+ {
+ FLAC__ASSERT(is_valid());
+ object_->data.picture.depth = value;
+ }
+
+ void Picture::set_colors(FLAC__uint32 value) const
+ {
+ FLAC__ASSERT(is_valid());
+ object_->data.picture.colors = value;
+ }
+
+ bool Picture::set_data(const FLAC__byte *data, FLAC__uint32 data_length)
+ {
+ FLAC__ASSERT(is_valid());
+ // We can safely const_cast since copy=true
+ return (bool)::FLAC__metadata_object_picture_set_data(object_, const_cast<FLAC__byte*>(data), data_length, /*copy=*/true);
+ }
+
+ bool Picture::is_legal(const char **violation)
+ {
+ FLAC__ASSERT(is_valid());
+ return (bool)::FLAC__metadata_object_picture_is_legal(object_, violation);
+ }
+
//
// Unknown
return false;
}
+ FLACPP_API bool get_tags(const char *filename, VorbisComment &tags)
+ {
+ FLAC__ASSERT(0 != filename);
+
+ ::FLAC__StreamMetadata *object;
+
+ if(::FLAC__metadata_get_tags(filename, &object)) {
+ tags.assign(object, /*copy=*/false);
+ return true;
+ }
+ else
+ return false;
+ }
+
+ FLACPP_API bool get_cuesheet(const char *filename, CueSheet *&cuesheet)
+ {
+ FLAC__ASSERT(0 != filename);
+
+ ::FLAC__StreamMetadata *object;
+
+ cuesheet = 0;
+
+ if(::FLAC__metadata_get_cuesheet(filename, &object)) {
+ cuesheet = new CueSheet(object, /*copy=*/false);
+ return true;
+ }
+ else
+ return false;
+ }
+
+ FLACPP_API bool get_cuesheet(const char *filename, CueSheet &cuesheet)
+ {
+ FLAC__ASSERT(0 != filename);
+
+ ::FLAC__StreamMetadata *object;
+
+ if(::FLAC__metadata_get_cuesheet(filename, &object)) {
+ cuesheet.assign(object, /*copy=*/false);
+ return true;
+ }
+ else
+ return false;
+ }
+
+ FLACPP_API bool get_picture(const char *filename, Picture *&picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors)
+ {
+ FLAC__ASSERT(0 != filename);
+
+ ::FLAC__StreamMetadata *object;
+
+ picture = 0;
+
+ if(::FLAC__metadata_get_picture(filename, &object, type, mime_type, description, max_width, max_height, max_depth, max_colors)) {
+ picture = new Picture(object, /*copy=*/false);
+ return true;
+ }
+ else
+ return false;
+ }
+
+ FLACPP_API bool get_picture(const char *filename, Picture &picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors)
+ {
+ FLAC__ASSERT(0 != filename);
+
+ ::FLAC__StreamMetadata *object;
+
+ if(::FLAC__metadata_get_picture(filename, &object, type, mime_type, description, max_width, max_height, max_depth, max_colors)) {
+ picture.assign(object, /*copy=*/false);
+ return true;
+ }
+ else
+ return false;
+ }
+
// ============================================================
//
return (bool)::FLAC__metadata_simple_iterator_prev(iterator_);
}
+ //@@@@ add to tests
+ bool SimpleIterator::is_last() const
+ {
+ FLAC__ASSERT(is_valid());
+ return (bool)::FLAC__metadata_simple_iterator_is_last(iterator_);
+ }
+
+ //@@@@ add to tests
+ off_t SimpleIterator::get_block_offset() const
+ {
+ FLAC__ASSERT(is_valid());
+ return ::FLAC__metadata_simple_iterator_get_block_offset(iterator_);
+ }
+
::FLAC__MetadataType SimpleIterator::get_block_type() const
{
FLAC__ASSERT(is_valid());
return ::FLAC__metadata_simple_iterator_get_block_type(iterator_);
}
+ //@@@@ add to tests
+ unsigned SimpleIterator::get_block_length() const
+ {
+ FLAC__ASSERT(is_valid());
+ return ::FLAC__metadata_simple_iterator_get_block_length(iterator_);
+ }
+
+ //@@@@ add to tests
+ bool SimpleIterator::get_application_id(FLAC__byte *id)
+ {
+ FLAC__ASSERT(is_valid());
+ return (bool)::FLAC__metadata_simple_iterator_get_application_id(iterator_, id);
+ }
+
Prototype *SimpleIterator::get_block()
{
FLAC__ASSERT(is_valid());
return Status(::FLAC__metadata_chain_status(chain_));
}
- bool Chain::read(const char *filename)
+ bool Chain::read(const char *filename, bool is_ogg)
{
FLAC__ASSERT(0 != filename);
FLAC__ASSERT(is_valid());
- return (bool)::FLAC__metadata_chain_read(chain_, filename);
+ return is_ogg?
+ (bool)::FLAC__metadata_chain_read_ogg(chain_, filename) :
+ (bool)::FLAC__metadata_chain_read(chain_, filename)
+ ;
}
- bool Chain::read(FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks)
+ bool Chain::read(FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks, bool is_ogg)
{
FLAC__ASSERT(is_valid());
- return (bool)::FLAC__metadata_chain_read_with_callbacks(chain_, handle, callbacks);
+ return is_ogg?
+ (bool)::FLAC__metadata_chain_read_ogg_with_callbacks(chain_, handle, callbacks) :
+ (bool)::FLAC__metadata_chain_read_with_callbacks(chain_, handle, callbacks)
+ ;
}
bool Chain::check_if_tempfile_needed(bool use_padding)
return ret;
}
- };
-};
+ }
+}