foobar2000 SDK  2015-08-03
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions
file_infoabstract

#include <file_info.h>

+ Inheritance diagram for file_info:

Public Types

typedef pfc::string::comparatorCaseInsensitiveASCII field_name_comparator
 

Public Member Functions

t_size __info_add_unsafe (const char *p_name, const char *p_value)
 
t_size __info_add_unsafe_ex (const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)
 
t_size __meta_add_unsafe (const char *p_name, const char *p_value)
 
t_size __meta_add_unsafe_ex (const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)
 
void _add_tag (const file_info &otherTag)
 
void _copy_meta_single_nocheck (const file_info &p_source, t_size p_index)
 
void _set_tag (const file_info &tag)
 
bool are_meta_fields_identical (t_size p_index1, t_size p_index2) const
 
audio_chunk::spec_t audio_chunk_spec () const
 
virtual void copy (const file_info &p_source)
 
virtual void copy_info (const file_info &p_source)
 
void copy_info_single (const file_info &p_source, t_size p_index)
 
void copy_info_single_by_name (const file_info &p_source, const char *p_name)
 
void copy_info_single_by_name_ex (const file_info &p_source, const char *p_name, t_size p_name_length)
 
virtual void copy_meta (const file_info &p_source)
 
void copy_meta_single (const file_info &p_source, t_size p_index)
 
void copy_meta_single_by_name (const file_info &p_source, const char *p_name)
 
void copy_meta_single_by_name_ex (const file_info &p_source, const char *p_name, t_size p_name_length)
 
void copy_meta_single_rename (const file_info &p_source, t_size p_index, const char *p_new_name)
 
void copy_meta_single_rename_ex (const file_info &p_source, t_size p_index, const char *p_new_name, t_size p_new_name_length)
 
void from_mem (const void *memPtr, size_t memSize)
 
void from_stream (stream_reader *stream, abort_callback &abort)
 
virtual double get_length () const =0
 
virtual replaygain_info get_replaygain () const =0
 
void info_calculate_bitrate (t_filesize p_filesize, double p_length)
 
virtual const char * info_enum_name (t_size p_index) const =0
 
virtual const char * info_enum_value (t_size p_index) const =0
 
bool info_exists (const char *p_name) const
 
bool info_exists_ex (const char *p_name, t_size p_name_length) const
 
t_size info_find (const char *p_name) const
 
virtual t_size info_find_ex (const char *p_name, t_size p_name_length) const
 
const char * info_get (const char *p_name) const
 
t_int64 info_get_bitrate () const
 
t_int64 info_get_bitrate_vbr () const
 
virtual t_size info_get_count () const =0
 
unsigned info_get_decoded_bps () const
 
const char * info_get_ex (const char *p_name, t_size p_name_length) const
 
double info_get_float (const char *name) const
 
t_int64 info_get_int (const char *name) const
 
t_int64 info_get_length_samples () const
 
uint32_t info_get_wfx_chanMask () const
 
bool info_remove (const char *p_name)
 
void info_remove_all ()
 
bool info_remove_ex (const char *p_name, t_size p_name_length)
 
void info_remove_index (t_size p_index)
 
virtual void info_remove_mask (const bit_array &p_mask)=0
 
t_size info_set (const char *p_name, const char *p_value)
 
void info_set_bitrate (t_int64 val)
 
void info_set_bitrate_vbr (t_int64 val)
 
virtual t_size info_set_ex (const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
 
void info_set_float (const char *name, double value, unsigned precision, bool force_sign=false, const char *unit=0)
 
void info_set_int (const char *name, t_int64 value)
 
bool info_set_replaygain (const char *p_name, const char *p_value)
 
void info_set_replaygain_album_gain (float value)
 
void info_set_replaygain_album_peak (float value)
 
void info_set_replaygain_auto (const char *p_name, const char *p_value)
 
void info_set_replaygain_auto_ex (const char *p_name, t_size p_name_len, const char *p_value, t_size p_value_len)
 
bool info_set_replaygain_ex (const char *p_name, t_size p_name_len, const char *p_value, t_size p_value_len)
 
void info_set_replaygain_track_gain (float value)
 
void info_set_replaygain_track_peak (float value)
 
void info_set_wfx_chanMask (uint32_t val)
 
bool is_encoding_lossy () const
 
void merge_fallback (const file_info &fallback)
 
t_size meta_add (const char *p_name, const char *p_value)
 
t_size meta_add_ex (const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)
 
void meta_add_value (t_size p_index, const char *p_value)
 
void meta_add_value_ex (t_size p_index, const char *p_value, t_size p_value_length)
 
t_size meta_calc_total_value_count () const
 
virtual const char * meta_enum_name (t_size p_index) const =0
 
virtual const char * meta_enum_value (t_size p_index, t_size p_value_number) const =0
 
virtual t_size meta_enum_value_count (t_size p_index) const =0
 
bool meta_exists (const char *p_name) const
 
bool meta_exists_ex (const char *p_name, t_size p_name_length) const
 
t_size meta_find (const char *p_name) const
 
virtual t_size meta_find_ex (const char *p_name, t_size p_name_length) const
 
bool meta_format (const char *p_name, pfc::string_base &p_out, const char *separator=", ") const
 
void meta_format_entry (t_size index, pfc::string_base &p_out, const char *separator=", ") const
 
const char * meta_get (const char *p_name, t_size p_index) const
 
virtual t_size meta_get_count () const =0
 
t_size meta_get_count_by_name (const char *p_name) const
 
t_size meta_get_count_by_name_ex (const char *p_name, t_size p_name_length) const
 
const char * meta_get_ex (const char *p_name, t_size p_name_length, t_size p_index) const
 
void meta_insert_value (t_size p_index, t_size p_value_index, const char *p_value)
 
virtual void meta_insert_value_ex (t_size p_index, t_size p_value_index, const char *p_value, t_size p_value_length)=0
 
void meta_modify_value (t_size p_index, t_size p_value_index, const char *p_value)
 
virtual void meta_modify_value_ex (t_size p_index, t_size p_value_index, const char *p_value, t_size p_value_length)=0
 
void meta_remove_all ()
 
void meta_remove_field (const char *p_name)
 
void meta_remove_field_ex (const char *p_name, t_size p_name_length)
 
void meta_remove_index (t_size p_index)
 
virtual void meta_remove_mask (const bit_array &p_mask)=0
 
void meta_remove_value (t_size p_index, t_size p_value)
 
virtual void meta_remove_values (t_size p_index, const bit_array &p_mask)=0
 
virtual void meta_reorder (const t_size *p_order)=0
 
t_size meta_set (const char *p_name, const char *p_value)
 
virtual t_size meta_set_ex (const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
 
const file_infooperator= (const file_info &p_source)
 
void overwrite_info (const file_info &p_source)
 
void overwrite_meta (const file_info &p_source)
 
void reset ()
 
void reset_replaygain ()
 
virtual void set_length (double p_length)=0
 
virtual void set_replaygain (const replaygain_info &p_info)=0
 
void to_console () const
 
void to_formatter (pfc::string_formatter &) const
 
void to_stream (stream_writer *stream, abort_callback &abort) const
 

Static Public Member Functions

static bool field_is_person (const char *fieldName)
 
static bool field_is_title (const char *fieldName)
 
static bool field_name_equals (const char *n1, const char *n2)
 
static bool g_is_info_equal (const file_info &p_item1, const file_info &p_item2)
 
static bool g_is_meta_equal (const file_info &p_item1, const file_info &p_item2)
 
static bool g_is_meta_equal_debug (const file_info &p_item1, const file_info &p_item2)
 
static bool g_is_valid_field_name (const char *p_name, t_size p_length=pfc_infinite)
 

Protected Member Functions

 file_info ()
 
 ~file_info ()
 
void copy_info_single_by_name_nocheck (const file_info &p_source, const char *p_name)
 
void copy_info_single_by_name_nocheck_ex (const file_info &p_source, const char *p_name, t_size p_name_length)
 
void copy_info_single_nocheck (const file_info &p_source, t_size p_index)
 
void copy_meta_single_by_name_nocheck (const file_info &p_source, const char *p_name)
 
void copy_meta_single_by_name_nocheck_ex (const file_info &p_source, const char *p_name, t_size p_name_length)
 
void copy_meta_single_nocheck (const file_info &p_source, t_size p_index)
 
t_size info_set_nocheck (const char *p_name, const char *p_value)
 
virtual t_size info_set_nocheck_ex (const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
 
t_size meta_set_nocheck (const char *p_name, const char *p_value)
 
virtual t_size meta_set_nocheck_ex (const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
 

Private Member Functions

void merge (const pfc::list_base_const_t< const file_info * > &p_sources)
 

Detailed Description

Main interface class for information about some playable object.

Definition at line 73 of file file_info.h.

Member Typedef Documentation

Definition at line 249 of file file_info.h.

Constructor & Destructor Documentation

file_info::file_info ( )
inlineprotected

Definition at line 266 of file file_info.h.

266 {}
file_info::~file_info ( )
inlineprotected

Definition at line 267 of file file_info.h.

267 {}

Member Function Documentation

t_size file_info::__info_add_unsafe ( const char *  p_name,
const char *  p_value 
)
inline

Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally.

Definition at line 243 of file file_info.h.

243 {return info_set_nocheck_ex(p_name,pfc_infinite,p_value,pfc_infinite);}
virtual t_size info_set_nocheck_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
t_size file_info::__info_add_unsafe_ex ( const char *  p_name,
t_size  p_name_length,
const char *  p_value,
t_size  p_value_length 
)
inline

Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally.

Definition at line 241 of file file_info.h.

241 {return info_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length);}
virtual t_size info_set_nocheck_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
t_size file_info::__meta_add_unsafe ( const char *  p_name,
const char *  p_value 
)
inline

Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally.

Definition at line 238 of file file_info.h.

238 {return meta_set_nocheck_ex(p_name,pfc_infinite,p_value,pfc_infinite);}
virtual t_size meta_set_nocheck_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
t_size file_info::__meta_add_unsafe_ex ( const char *  p_name,
t_size  p_name_length,
const char *  p_value,
t_size  p_value_length 
)
inline

Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally.

Definition at line 236 of file file_info.h.

236 {return meta_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length);}
virtual t_size meta_set_nocheck_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
void file_info::_add_tag ( const file_info otherTag)

Definition at line 158 of file file_info_merge.cpp.

158  {
160 
161  const char * tt1 = this->info_get(_tagtype);
162  const char * tt2 = otherTag.info_get(_tagtype);
163  if (tt2) {
164  if (tt1) {
165  this->info_set(_tagtype, PFC_string_formatter() << tt1 << "|" << tt2);
166  } else {
167  this->info_set(_tagtype, tt2);
168  }
169  }
170 
171 }
const char * info_get(const char *p_name) const
Definition: file_info.h:171
t_size info_set(const char *p_name, const char *p_value)
Definition: file_info.h:167
static const char _tagtype[]
virtual void set_replaygain(const replaygain_info &p_info)=0
Sets ReplayGain information.
static replaygain_info g_merge(replaygain_info r1, replaygain_info r2)
virtual replaygain_info get_replaygain() const =0
Retrieves ReplayGain information.
void file_info::_copy_meta_single_nocheck ( const file_info p_source,
t_size  p_index 
)
inline

Definition at line 245 of file file_info.h.

245 {copy_meta_single_nocheck(p_source, p_index);}
void copy_meta_single_nocheck(const file_info &p_source, t_size p_index)
Definition: file_info.cpp:99
void file_info::_set_tag ( const file_info tag)

Definition at line 151 of file file_info_merge.cpp.

151  {
152  this->copy_meta(tag);
154  const char * tt = tag.info_get(_tagtype);
155  if (tt) this->info_set(_tagtype, tt);
156 }
virtual void copy_meta(const file_info &p_source)
Copies metadata from specified file_info object.
Definition: file_info.cpp:146
const char * info_get(const char *p_name) const
Definition: file_info.h:171
t_size info_set(const char *p_name, const char *p_value)
Definition: file_info.h:167
static const char _tagtype[]
virtual void set_replaygain(const replaygain_info &p_info)=0
Sets ReplayGain information.
static replaygain_info g_merge(replaygain_info r1, replaygain_info r2)
virtual replaygain_info get_replaygain() const =0
Retrieves ReplayGain information.
bool file_info::are_meta_fields_identical ( t_size  p_index1,
t_size  p_index2 
) const

Definition at line 363 of file file_info.cpp.

364 {
365  const t_size count = meta_enum_value_count(p_index1);
366  if (count != meta_enum_value_count(p_index2)) return false;
367  t_size n;
368  for(n=0;n<count;n++)
369  {
370  if (strcmp(meta_enum_value(p_index1,n),meta_enum_value(p_index2,n))) return false;
371  }
372  return true;
373 }
virtual t_size meta_enum_value_count(t_size p_index) const =0
Retrieves count of values in metadata entry of specified index. The value is always equal to or great...
virtual const char * meta_enum_value(t_size p_index, t_size p_value_number) const =0
Retrieves specified value from specified metadata entry. Return value is a null-terminated UTF-8 enco...
size_t t_size
Definition: int_types.h:48
audio_chunk::spec_t file_info::audio_chunk_spec ( ) const

Returns ESTIMATED audio chunk spec from what has been put in the file_info.
Provided for convenience. Do not rely on it for processing decoded data.

Definition at line 715 of file file_info.cpp.

716 {
717  audio_chunk::spec_t rv = {};
718  rv.sampleRate = (uint32_t)this->info_get_int("samplerate");
719  rv.chanCount = (uint32_t)this->info_get_int("channels");
720  rv.chanMask = (uint32_t)this->info_get_wfx_chanMask();
723  }
724  return rv;
725 }
uint32_t info_get_wfx_chanMask() const
Definition: file_info.cpp:544
static unsigned g_count_channels(unsigned p_config)
Counts channels specified by channel map.
t_int64 info_get_int(const char *name) const
Definition: file_info.cpp:193
static unsigned g_guess_channel_config(unsigned count)
Helper function; guesses default channel map for the specified channel count. Returns 0 on failure...
void file_info::copy ( const file_info p_source)
virtual

Copies entire file_info contents from specified file_info object.

Reimplemented in file_info_const_impl.

Definition at line 166 of file file_info.cpp.

167 {
168  if (&p_source != this) {
169  copy_meta(p_source);
170  copy_info(p_source);
171  set_length(p_source.get_length());
172  set_replaygain(p_source.get_replaygain());
173  }
174 }
virtual double get_length() const =0
Retrieves audio duration, in seconds. Note that the reported duration should not be assumed to be th...
virtual void copy_meta(const file_info &p_source)
Copies metadata from specified file_info object.
Definition: file_info.cpp:146
virtual void copy_info(const file_info &p_source)
Copies technical info from specified file_info object.
Definition: file_info.cpp:156
virtual void set_replaygain(const replaygain_info &p_info)=0
Sets ReplayGain information.
virtual replaygain_info get_replaygain() const =0
Retrieves ReplayGain information.
virtual void set_length(double p_length)=0
Sets audio duration, in seconds. Note that the reported duration should not be assumed to be the exa...
void file_info::copy_info ( const file_info p_source)
virtual

Copies technical info from specified file_info object.

Reimplemented in file_info_impl.

Definition at line 156 of file file_info.cpp.

157 {
158  if (&p_source != this) {
159  info_remove_all();
160  t_size n, m = p_source.info_get_count();
161  for(n=0;n<m;n++)
162  copy_info_single_nocheck(p_source,n);
163  }
164 }
void info_remove_all()
Definition: file_info.cpp:71
size_t t_size
Definition: int_types.h:48
void copy_info_single_nocheck(const file_info &p_source, t_size p_index)
Definition: file_info.cpp:141
virtual t_size info_get_count() const =0
Retrieves number of technical info entries.
void file_info::copy_info_single ( const file_info p_source,
t_size  p_index 
)

Definition at line 136 of file file_info.cpp.

137 {
138  info_set(p_source.info_enum_name(p_index),p_source.info_enum_value(p_index));
139 }
virtual const char * info_enum_value(t_size p_index) const =0
Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encode...
t_size info_set(const char *p_name, const char *p_value)
Definition: file_info.h:167
virtual const char * info_enum_name(t_size p_index) const =0
Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded...
void file_info::copy_info_single_by_name ( const file_info p_source,
const char *  p_name 
)
inline

Definition at line 185 of file file_info.h.

185 {copy_info_single_by_name_ex(p_source,p_name,pfc_infinite);}
void copy_info_single_by_name_ex(const file_info &p_source, const char *p_name, t_size p_name_length)
Definition: file_info.cpp:118
void file_info::copy_info_single_by_name_ex ( const file_info p_source,
const char *  p_name,
t_size  p_name_length 
)

Definition at line 118 of file file_info.cpp.

119 {
120  t_size index = p_source.info_find_ex(p_name,p_name_length);
121  if (index != pfc_infinite) copy_info_single(p_source,index);
122 }
size_t t_size
Definition: int_types.h:48
virtual t_size info_find_ex(const char *p_name, t_size p_name_length) const
Finds technical info entry of specified name. Returns index of found entry on success, infinite on failure.
Definition: file_info.cpp:52
void copy_info_single(const file_info &p_source, t_size p_index)
Definition: file_info.cpp:136
void file_info::copy_info_single_by_name_nocheck ( const file_info p_source,
const char *  p_name 
)
inlineprotected

Definition at line 273 of file file_info.h.

273 {copy_info_single_by_name_nocheck_ex(p_source,p_name,pfc_infinite);}
void copy_info_single_by_name_nocheck_ex(const file_info &p_source, const char *p_name, t_size p_name_length)
Definition: file_info.cpp:130
void file_info::copy_info_single_by_name_nocheck_ex ( const file_info p_source,
const char *  p_name,
t_size  p_name_length 
)
protected

Definition at line 130 of file file_info.cpp.

131 {
132  t_size index = p_source.info_find_ex(p_name,p_name_length);
133  if (index != pfc_infinite) copy_info_single_nocheck(p_source,index);
134 }
size_t t_size
Definition: int_types.h:48
void copy_info_single_nocheck(const file_info &p_source, t_size p_index)
Definition: file_info.cpp:141
virtual t_size info_find_ex(const char *p_name, t_size p_name_length) const
Finds technical info entry of specified name. Returns index of found entry on success, infinite on failure.
Definition: file_info.cpp:52
void file_info::copy_info_single_nocheck ( const file_info p_source,
t_size  p_index 
)
protected

Definition at line 141 of file file_info.cpp.

142 {
143  info_set_nocheck(p_source.info_enum_name(p_index),p_source.info_enum_value(p_index));
144 }
virtual const char * info_enum_value(t_size p_index) const =0
Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encode...
t_size info_set_nocheck(const char *p_name, const char *p_value)
Definition: file_info.h:278
virtual const char * info_enum_name(t_size p_index) const =0
Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded...
void file_info::copy_meta ( const file_info p_source)
virtual

Copies metadata from specified file_info object.

Reimplemented in file_info_impl.

Definition at line 146 of file file_info.cpp.

147 {
148  if (&p_source != this) {
149  meta_remove_all();
150  t_size n, m = p_source.meta_get_count();
151  for(n=0;n<m;n++)
152  copy_meta_single_nocheck(p_source,n);
153  }
154 }
size_t t_size
Definition: int_types.h:48
virtual t_size meta_get_count() const =0
Retrieves count of metadata entries.
void meta_remove_all()
Definition: file_info.cpp:35
void copy_meta_single_nocheck(const file_info &p_source, t_size p_index)
Definition: file_info.cpp:99
void file_info::copy_meta_single ( const file_info p_source,
t_size  p_index 
)

Definition at line 94 of file file_info.cpp.

95 {
96  copy_meta_single_rename(p_source,p_index,p_source.meta_enum_name(p_index));
97 }
void copy_meta_single_rename(const file_info &p_source, t_size p_index, const char *p_new_name)
Definition: file_info.h:189
virtual const char * meta_enum_name(t_size p_index) const =0
Retrieves the name of metadata entry of specified index. Return value is a null-terminated UTF-8 enco...
void file_info::copy_meta_single_by_name ( const file_info p_source,
const char *  p_name 
)
inline

Definition at line 184 of file file_info.h.

184 {copy_meta_single_by_name_ex(p_source,p_name,pfc_infinite);}
void copy_meta_single_by_name_ex(const file_info &p_source, const char *p_name, t_size p_name_length)
Definition: file_info.cpp:112
void file_info::copy_meta_single_by_name_ex ( const file_info p_source,
const char *  p_name,
t_size  p_name_length 
)

Definition at line 112 of file file_info.cpp.

113 {
114  t_size index = p_source.meta_find_ex(p_name,p_name_length);
115  if (index != pfc_infinite) copy_meta_single(p_source,index);
116 }
size_t t_size
Definition: int_types.h:48
void copy_meta_single(const file_info &p_source, t_size p_index)
Definition: file_info.cpp:94
virtual t_size meta_find_ex(const char *p_name, t_size p_name_length) const
Finds index of metadata entry of specified name. Returns infinite when not found. ...
Definition: file_info.cpp:8
void file_info::copy_meta_single_by_name_nocheck ( const file_info p_source,
const char *  p_name 
)
inlineprotected

Definition at line 272 of file file_info.h.

272 {copy_meta_single_by_name_nocheck_ex(p_source,p_name,pfc_infinite);}
void copy_meta_single_by_name_nocheck_ex(const file_info &p_source, const char *p_name, t_size p_name_length)
Definition: file_info.cpp:124
void file_info::copy_meta_single_by_name_nocheck_ex ( const file_info p_source,
const char *  p_name,
t_size  p_name_length 
)
protected

Definition at line 124 of file file_info.cpp.

125 {
126  t_size index = p_source.meta_find_ex(p_name,p_name_length);
127  if (index != pfc_infinite) copy_meta_single_nocheck(p_source,index);
128 }
size_t t_size
Definition: int_types.h:48
virtual t_size meta_find_ex(const char *p_name, t_size p_name_length) const
Finds index of metadata entry of specified name. Returns infinite when not found. ...
Definition: file_info.cpp:8
void copy_meta_single_nocheck(const file_info &p_source, t_size p_index)
Definition: file_info.cpp:99
void file_info::copy_meta_single_nocheck ( const file_info p_source,
t_size  p_index 
)
protected

Definition at line 99 of file file_info.cpp.

100 {
101  const char * name = p_source.meta_enum_name(p_index);
102  t_size n, m = p_source.meta_enum_value_count(p_index);
103  t_size new_index = pfc_infinite;
104  for(n=0;n<m;n++)
105  {
106  const char * value = p_source.meta_enum_value(p_index,n);
107  if (n == 0) new_index = meta_set_nocheck(name,value);
108  else meta_add_value(new_index,value);
109  }
110 }
virtual t_size meta_enum_value_count(t_size p_index) const =0
Retrieves count of values in metadata entry of specified index. The value is always equal to or great...
virtual const char * meta_enum_value(t_size p_index, t_size p_value_number) const =0
Retrieves specified value from specified metadata entry. Return value is a null-terminated UTF-8 enco...
void meta_add_value(t_size p_index, const char *p_value)
Definition: file_info.h:159
t_size meta_set_nocheck(const char *p_name, const char *p_value)
Definition: file_info.h:277
size_t t_size
Definition: int_types.h:48
virtual const char * meta_enum_name(t_size p_index) const =0
Retrieves the name of metadata entry of specified index. Return value is a null-terminated UTF-8 enco...
void file_info::copy_meta_single_rename ( const file_info p_source,
t_size  p_index,
const char *  p_new_name 
)
inline

Definition at line 189 of file file_info.h.

189 {copy_meta_single_rename_ex(p_source,p_index,p_new_name,pfc_infinite);}
void copy_meta_single_rename_ex(const file_info &p_source, t_size p_index, const char *p_new_name, t_size p_new_name_length)
Definition: file_info.cpp:302
void file_info::copy_meta_single_rename_ex ( const file_info p_source,
t_size  p_index,
const char *  p_new_name,
t_size  p_new_name_length 
)

Definition at line 302 of file file_info.cpp.

303 {
304  t_size n, m = p_source.meta_enum_value_count(p_index);
305  t_size new_index = pfc_infinite;
306  for(n=0;n<m;n++)
307  {
308  const char * value = p_source.meta_enum_value(p_index,n);
309  if (n == 0) new_index = meta_set_ex(p_new_name,p_new_name_length,value,pfc_infinite);
310  else meta_add_value(new_index,value);
311  }
312 }
virtual t_size meta_set_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
Creates a new metadata entry of specified name with specified value. If an entry of same name already...
virtual t_size meta_enum_value_count(t_size p_index) const =0
Retrieves count of values in metadata entry of specified index. The value is always equal to or great...
virtual const char * meta_enum_value(t_size p_index, t_size p_value_number) const =0
Retrieves specified value from specified metadata entry. Return value is a null-terminated UTF-8 enco...
void meta_add_value(t_size p_index, const char *p_value)
Definition: file_info.h:159
size_t t_size
Definition: int_types.h:48
bool file_info::field_is_person ( const char *  fieldName)
static

Definition at line 553 of file file_info.cpp.

553  {
554  return field_name_equals(fieldName, "artist") ||
555  field_name_equals(fieldName, "album artist") ||
556  field_name_equals(fieldName, "composer") ||
557  field_name_equals(fieldName, "performer") ||
558  field_name_equals(fieldName, "conductor") ||
559  field_name_equals(fieldName, "orchestra") ||
560  field_name_equals(fieldName, "ensemble") ||
561  field_name_equals(fieldName, "engineer");
562 }
static bool field_name_equals(const char *n1, const char *n2)
Definition: file_info.h:251
bool file_info::field_is_title ( const char *  fieldName)
static

Definition at line 564 of file file_info.cpp.

564  {
565  return field_name_equals(fieldName, "title") || field_name_equals(fieldName, "album");
566 }
static bool field_name_equals(const char *n1, const char *n2)
Definition: file_info.h:251
static bool file_info::field_name_equals ( const char *  n1,
const char *  n2 
)
inlinestatic

Definition at line 251 of file file_info.h.

251 {return field_name_comparator::compare(n1, n2) == 0;}
static int compare(T1 const &v1, T2 const &v2)
Definition: stringNew.h:181
void file_info::from_mem ( const void *  memPtr,
size_t  memSize 
)

Definition at line 672 of file file_info.cpp.

672  {
673  size_t remaining = memSize;
674  const uint8_t * walk = (const uint8_t*) memPtr;
675 
676  {
677  double len; _readFloat(len, walk, remaining);
678  this->set_length( len );
679  }
680 
681  {
682  replaygain_info rg;
683  _readFloat(rg.m_track_gain, walk, remaining );
684  _readFloat(rg.m_album_gain, walk, remaining );
685  _readFloat(rg.m_track_peak, walk, remaining );
686  _readFloat(rg.m_album_peak, walk, remaining );
687  this->set_replaygain( rg );
688  }
689 
690  {
691  this->meta_remove_all();
692  for(;;) {
693  const char * metaName = _readString( walk, remaining );
694  if (*metaName == 0) break;
695  size_t metaIndex = pfc_infinite;
696  for(;;) {
697  const char * metaValue = _readString( walk, remaining );
698  if (*metaValue == 0) break;
699  if (metaIndex == pfc_infinite) metaIndex = this->meta_add( metaName, metaValue );
700  else this->meta_add_value( metaIndex, metaName );
701  }
702  }
703  }
704  {
705  this->info_remove_all();
706  for(;;) {
707  const char * infoName = _readString( walk, remaining );
708  if (*infoName == 0) break;
709  const char * infoValue = _readString( walk, remaining );
710  this->info_set( infoName, infoValue );
711  }
712  }
713 }
float m_track_gain
Definition: file_info.h:4
t_size meta_add(const char *p_name, const char *p_value)
Definition: file_info.h:162
static void _readFloat(float_t &out, const uint8_t *&ptr, size_t &remaining)
Definition: file_info.cpp:663
float m_album_peak
Definition: file_info.h:5
void info_remove_all()
Definition: file_info.cpp:71
void meta_add_value(t_size p_index, const char *p_value)
Definition: file_info.h:159
Structure containing ReplayGain scan results from some playable object, also providing various helper...
Definition: file_info.h:2
static const char * _readString(const uint8_t *&ptr, size_t &remaining)
Definition: file_info.cpp:648
t_size info_set(const char *p_name, const char *p_value)
Definition: file_info.h:167
virtual void set_replaygain(const replaygain_info &p_info)=0
Sets ReplayGain information.
void meta_remove_all()
Definition: file_info.cpp:35
float m_album_gain
Definition: file_info.h:4
float m_track_peak
Definition: file_info.h:5
virtual void set_length(double p_length)=0
Sets audio duration, in seconds. Note that the reported duration should not be assumed to be the exa...
void file_info::from_stream ( stream_reader stream,
abort_callback abort 
)

Definition at line 612 of file file_info.cpp.

612  {
613  stream_reader_formatter<> in( *stream, abort );
614  pfc::string_formatter tempName, tempValue;
615  {
616  double len; in >> len; this->set_length( len );
617  }
618  {
619  replaygain_info rg;
620  in >> rg.m_track_gain >> rg.m_album_gain >> rg.m_track_peak >> rg.m_album_peak;
621  }
622 
623  {
624  this->meta_remove_all();
625  for(;;) {
626  in.read_string_nullterm( tempName );
627  if (tempName.length() == 0) break;
628  size_t metaIndex = pfc_infinite;
629  for(;;) {
630  in.read_string_nullterm( tempValue );
631  if (tempValue.length() == 0) break;
632  if (metaIndex == pfc_infinite) metaIndex = this->meta_add( tempName, tempValue );
633  else this->meta_add_value( metaIndex, tempValue );
634  }
635  }
636  }
637  {
638  this->info_remove_all();
639  for(;;) {
640  in.read_string_nullterm( tempName );
641  if (tempName.length() == 0) break;
642  in.read_string_nullterm( tempValue );
643  this->info_set( tempName, tempValue );
644  }
645  }
646 }
float m_track_gain
Definition: file_info.h:4
t_size meta_add(const char *p_name, const char *p_value)
Definition: file_info.h:162
float m_album_peak
Definition: file_info.h:5
void info_remove_all()
Definition: file_info.cpp:71
void meta_add_value(t_size p_index, const char *p_value)
Definition: file_info.h:159
Structure containing ReplayGain scan results from some playable object, also providing various helper...
Definition: file_info.h:2
t_size info_set(const char *p_name, const char *p_value)
Definition: file_info.h:167
void meta_remove_all()
Definition: file_info.cpp:35
float m_album_gain
Definition: file_info.h:4
float m_track_peak
Definition: file_info.h:5
virtual void set_length(double p_length)=0
Sets audio duration, in seconds. Note that the reported duration should not be assumed to be the exa...
t_size length() const
For compatibility with old conventions.
Definition: string_base.h:209
bool file_info::g_is_info_equal ( const file_info p_item1,
const file_info p_item2 
)
static

Definition at line 474 of file file_info.cpp.

474  {
475  t_size count = p_item1.info_get_count();
476  if (count != p_item2.info_get_count()) {
477  //uDebugLog() << "info count mismatch";
478  return false;
479  }
480  for(t_size n1=0; n1<count; n1++) {
481  t_size n2 = p_item2.info_find(p_item1.info_enum_name(n1));
482  if (n2 == pfc_infinite) {
483  //uDebugLog() << "item2 does not have " << p_item1.info_enum_name(n1);
484  return false;
485  }
486  if (strcmp(p_item1.info_enum_value(n1),p_item2.info_enum_value(n2)) != 0) {
487  //uDebugLog() << "value mismatch: " << p_item1.info_enum_name(n1);
488  return false;
489  }
490  }
491  return true;
492 }
virtual const char * info_enum_value(t_size p_index) const =0
Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encode...
size_t t_size
Definition: int_types.h:48
t_size info_find(const char *p_name) const
Definition: file_info.h:168
virtual const char * info_enum_name(t_size p_index) const =0
Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded...
virtual t_size info_get_count() const =0
Retrieves number of technical info entries.
bool file_info::g_is_meta_equal ( const file_info p_item1,
const file_info p_item2 
)
static

Definition at line 412 of file file_info.cpp.

412  {
413  const t_size count = p_item1.meta_get_count();
414  if (count != p_item2.meta_get_count()) {
415  //uDebugLog() << "meta count mismatch";
416  return false;
417  }
419  for(t_size n=0; n<count; n++) {
420  item2_meta_map.set(p_item2.meta_enum_name(n),n);
421  }
422  for(t_size n1=0; n1<count; n1++) {
423  t_size n2;
424  if (!item2_meta_map.query(p_item1.meta_enum_name(n1),n2)) {
425  //uDebugLog() << "item2 doesn't have " << p_item1.meta_enum_name(n1);
426  return false;
427  }
428  t_size value_count = p_item1.meta_enum_value_count(n1);
429  if (value_count != p_item2.meta_enum_value_count(n2)) {
430  //uDebugLog() << "meta value count mismatch: " << p_item1.meta_enum_name(n1) << " : " << value_count << " vs " << p_item2.meta_enum_value_count(n2);
431  return false;
432  }
433  for(t_size v = 0; v < value_count; v++) {
434  if (strcmp(p_item1.meta_enum_value(n1,v),p_item2.meta_enum_value(n2,v)) != 0) {
435  //uDebugLog() << "meta mismatch: " << p_item1.meta_enum_name(n1) << " : " << p_item1.meta_enum_value(n1,v) << " vs " << p_item2.meta_enum_value(n2,v);
436  return false;
437  }
438  }
439  }
440  return true;
441 }
Definition: map.h:16
virtual t_size meta_enum_value_count(t_size p_index) const =0
Retrieves count of values in metadata entry of specified index. The value is always equal to or great...
virtual const char * meta_enum_value(t_size p_index, t_size p_value_number) const =0
Retrieves specified value from specified metadata entry. Return value is a null-terminated UTF-8 enco...
size_t t_size
Definition: int_types.h:48
virtual t_size meta_get_count() const =0
Retrieves count of metadata entries.
void set(const _t_key &p_key, const _t_value &p_value)
Definition: map.h:22
bool query(const _t_key &p_key, _t_value &p_value) const
Definition: map.h:44
virtual const char * meta_enum_name(t_size p_index) const =0
Retrieves the name of metadata entry of specified index. Return value is a null-terminated UTF-8 enco...
bool file_info::g_is_meta_equal_debug ( const file_info p_item1,
const file_info p_item2 
)
static

Definition at line 443 of file file_info.cpp.

443  {
444  const t_size count = p_item1.meta_get_count();
445  if (count != p_item2.meta_get_count()) {
446  FB2K_DebugLog() << "meta count mismatch";
447  return false;
448  }
450  for(t_size n=0; n<count; n++) {
451  item2_meta_map.set(p_item2.meta_enum_name(n),n);
452  }
453  for(t_size n1=0; n1<count; n1++) {
454  t_size n2;
455  if (!item2_meta_map.query(p_item1.meta_enum_name(n1),n2)) {
456  FB2K_DebugLog() << "item2 doesn't have " << p_item1.meta_enum_name(n1);
457  return false;
458  }
459  t_size value_count = p_item1.meta_enum_value_count(n1);
460  if (value_count != p_item2.meta_enum_value_count(n2)) {
461  FB2K_DebugLog() << "meta value count mismatch: " << p_item1.meta_enum_name(n1) << " : " << (uint32_t)value_count << " vs " << (uint32_t)p_item2.meta_enum_value_count(n2);
462  return false;
463  }
464  for(t_size v = 0; v < value_count; v++) {
465  if (strcmp(p_item1.meta_enum_value(n1,v),p_item2.meta_enum_value(n2,v)) != 0) {
466  FB2K_DebugLog() << "meta mismatch: " << p_item1.meta_enum_name(n1) << " : " << p_item1.meta_enum_value(n1,v) << " vs " << p_item2.meta_enum_value(n2,v);
467  return false;
468  }
469  }
470  }
471  return true;
472 }
Definition: map.h:16
virtual t_size meta_enum_value_count(t_size p_index) const =0
Retrieves count of values in metadata entry of specified index. The value is always equal to or great...
virtual const char * meta_enum_value(t_size p_index, t_size p_value_number) const =0
Retrieves specified value from specified metadata entry. Return value is a null-terminated UTF-8 enco...
size_t t_size
Definition: int_types.h:48
virtual t_size meta_get_count() const =0
Retrieves count of metadata entries.
void set(const _t_key &p_key, const _t_value &p_value)
Definition: map.h:22
bool query(const _t_key &p_key, _t_value &p_value) const
Definition: map.h:44
virtual const char * meta_enum_name(t_size p_index) const =0
Retrieves the name of metadata entry of specified index. Return value is a null-terminated UTF-8 enco...
bool file_info::g_is_valid_field_name ( const char *  p_name,
t_size  p_length = pfc_infinite 
)
static

Definition at line 498 of file file_info.cpp.

498  {
499  t_size walk;
500  for(walk = 0; walk < p_length && p_name[walk] != 0; walk++) {
501  if (!is_valid_field_name_char(p_name[walk])) return false;
502  }
503  return walk > 0;
504 }
size_t t_size
Definition: int_types.h:48
static bool is_valid_field_name_char(char p_char)
Definition: file_info.cpp:494
virtual double file_info::get_length ( ) const
pure virtual

Retrieves audio duration, in seconds.
Note that the reported duration should not be assumed to be the exact length of the track -
with many popular audio formats, exact duration is impossible to determine without performing a full decode pass;
with other formats, the decoded data may be shorter than reported due to truncation other damage.

Implemented in file_info_impl, and file_info_const_impl.

virtual replaygain_info file_info::get_replaygain ( ) const
pure virtual

Retrieves ReplayGain information.

Implemented in file_info_impl, and file_info_const_impl.

void file_info::info_calculate_bitrate ( t_filesize  p_filesize,
double  p_length 
)

Definition at line 395 of file file_info.cpp.

396 {
397  if (p_filesize > 0 && p_length > 0) info_set_bitrate((unsigned)floor((double)p_filesize * 8 / (p_length * 1000) + 0.5));
398 }
void info_set_bitrate(t_int64 val)
Definition: file_info.h:206
virtual const char* file_info::info_enum_name ( t_size  p_index) const
pure virtual

Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded string.

Implemented in file_info_impl, and file_info_const_impl.

virtual const char* file_info::info_enum_value ( t_size  p_index) const
pure virtual

Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encoded string.

Implemented in file_info_impl, and file_info_const_impl.

bool file_info::info_exists ( const char *  p_name) const
inline

Definition at line 169 of file file_info.h.

169 {return info_exists_ex(p_name,pfc_infinite);}
bool info_exists_ex(const char *p_name, t_size p_name_length) const
Definition: file_info.cpp:61
bool file_info::info_exists_ex ( const char *  p_name,
t_size  p_name_length 
) const

Definition at line 61 of file file_info.cpp.

62 {
63  return info_find_ex(p_name,p_name_length) != pfc_infinite;
64 }
virtual t_size info_find_ex(const char *p_name, t_size p_name_length) const
Finds technical info entry of specified name. Returns index of found entry on success, infinite on failure.
Definition: file_info.cpp:52
t_size file_info::info_find ( const char *  p_name) const
inline

Definition at line 168 of file file_info.h.

168 {return info_find_ex(p_name,pfc_infinite);}
virtual t_size info_find_ex(const char *p_name, t_size p_name_length) const
Finds technical info entry of specified name. Returns index of found entry on success, infinite on failure.
Definition: file_info.cpp:52
t_size file_info::info_find_ex ( const char *  p_name,
t_size  p_name_length 
) const
virtual

Finds technical info entry of specified name. Returns index of found entry on success, infinite on failure.

Definition at line 52 of file file_info.cpp.

53 {
54  t_size n, m = info_get_count();
55  for(n=0;n<m;n++) {
56  if (pfc::stricmp_ascii_ex(info_enum_name(n),pfc_infinite,p_name,p_name_length) == 0) return n;
57  }
58  return pfc_infinite;
59 }
int stricmp_ascii_ex(const char *const s1, t_size const len1, const char *const s2, t_size const len2)
size_t t_size
Definition: int_types.h:48
virtual const char * info_enum_name(t_size p_index) const =0
Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded...
virtual t_size info_get_count() const =0
Retrieves number of technical info entries.
const char* file_info::info_get ( const char *  p_name) const
inline

Definition at line 171 of file file_info.h.

171 {return info_get_ex(p_name,pfc_infinite);}
const char * info_get_ex(const char *p_name, t_size p_name_length) const
Definition: file_info.cpp:186
t_int64 file_info::info_get_bitrate ( ) const
inline

Definition at line 205 of file file_info.h.

205 {return info_get_int("bitrate");}
t_int64 info_get_int(const char *name) const
Definition: file_info.cpp:193
t_int64 file_info::info_get_bitrate_vbr ( ) const
inline

Definition at line 203 of file file_info.h.

203 {return info_get_int("bitrate_dynamic");}
t_int64 info_get_int(const char *name) const
Definition: file_info.cpp:193
virtual t_size file_info::info_get_count ( ) const
pure virtual

Retrieves number of technical info entries.

Implemented in file_info_impl, and file_info_const_impl.

unsigned file_info::info_get_decoded_bps ( ) const

Definition at line 277 of file file_info.cpp.

278 {
279  t_int64 val = info_get_int("decoded_bitspersample");
280  if (is_valid_bps(val)) return (unsigned)val;
281  val = info_get_int("bitspersample");
282  if (is_valid_bps(val)) return (unsigned)val;
283  return 0;
284 
285 }
t_int64 info_get_int(const char *name) const
Definition: file_info.cpp:193
static bool is_valid_bps(t_int64 val)
Definition: file_info.cpp:272
int64_t t_int64
Definition: int_types.h:2
const char * file_info::info_get_ex ( const char *  p_name,
t_size  p_name_length 
) const

Definition at line 186 of file file_info.cpp.

187 {
188  t_size index = info_find_ex(p_name,p_name_length);
189  if (index == pfc_infinite) return 0;
190  return info_enum_value(index);
191 }
virtual const char * info_enum_value(t_size p_index) const =0
Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encode...
size_t t_size
Definition: int_types.h:48
virtual t_size info_find_ex(const char *p_name, t_size p_name_length) const
Finds technical info entry of specified name. Returns index of found entry on success, infinite on failure.
Definition: file_info.cpp:52
double file_info::info_get_float ( const char *  name) const

Definition at line 214 of file file_info.cpp.

215 {
216  const char * ptr = info_get(name);
217  if (ptr) return pfc::string_to_float(ptr);
218  else return 0;
219 }
double string_to_float(const char *src, t_size max)
const char * info_get(const char *p_name) const
Definition: file_info.h:171
t_int64 file_info::info_get_int ( const char *  name) const

Definition at line 193 of file file_info.cpp.

194 {
195  PFC_ASSERT(pfc::is_valid_utf8(name));
196  const char * val = info_get(name);
197  if (val==0) return 0;
198  return _atoi64(val);
199 }
const char * info_get(const char *p_name) const
Definition: file_info.h:171
bool is_valid_utf8(const char *param, t_size max=~0)
Definition: utf8.cpp:264
t_int64 file_info::info_get_length_samples ( ) const

Definition at line 201 of file file_info.cpp.

202 {
203  t_int64 ret = 0;
204  double len = get_length();
205  t_int64 srate = info_get_int("samplerate");
206 
207  if (srate>0 && len>0)
208  {
209  ret = audio_math::time_to_samples(len,(unsigned)srate);
210  }
211  return ret;
212 }
virtual double get_length() const =0
Retrieves audio duration, in seconds. Note that the reported duration should not be assumed to be th...
t_int64 info_get_int(const char *name) const
Definition: file_info.cpp:193
int64_t t_int64
Definition: int_types.h:2
uint32_t file_info::info_get_wfx_chanMask ( ) const

Definition at line 544 of file file_info.cpp.

544  {
545  const char * str = this->info_get("WAVEFORMATEXTENSIBLE_CHANNEL_MASK");
546  if (str == NULL) return 0;
547  if (pfc::strcmp_partial( str, "0x") != 0) return 0;
548  try {
549  return pfc::atohex<uint32_t>( str + 2, strlen(str+2) );
550  } catch(...) { return 0;}
551 }
const char * info_get(const char *p_name) const
Definition: file_info.h:171
int strcmp_partial(const char *str, const char *substr)
Definition: string_base.h:1089
bool file_info::info_remove ( const char *  p_name)
inline

Definition at line 170 of file file_info.h.

170 {return info_remove_ex(p_name,pfc_infinite);}
bool info_remove_ex(const char *p_name, t_size p_name_length)
Definition: file_info.cpp:76
void file_info::info_remove_all ( )

Definition at line 71 of file file_info.cpp.

72 {
74 }
virtual void info_remove_mask(const bit_array &p_mask)=0
Removes technical info entries indicated by specified bit mask.
bool file_info::info_remove_ex ( const char *  p_name,
t_size  p_name_length 
)

Definition at line 76 of file file_info.cpp.

77 {
78  t_size index = info_find_ex(p_name,p_name_length);
79  if (index != pfc_infinite)
80  {
81  info_remove_index(index);
82  return true;
83  }
84  else return false;
85 }
size_t t_size
Definition: int_types.h:48
virtual t_size info_find_ex(const char *p_name, t_size p_name_length) const
Finds technical info entry of specified name. Returns index of found entry on success, infinite on failure.
Definition: file_info.cpp:52
void info_remove_index(t_size p_index)
Definition: file_info.cpp:66
void file_info::info_remove_index ( t_size  p_index)

Definition at line 66 of file file_info.cpp.

67 {
69 }
virtual void info_remove_mask(const bit_array &p_mask)=0
Removes technical info entries indicated by specified bit mask.
virtual void file_info::info_remove_mask ( const bit_array p_mask)
pure virtual

Removes technical info entries indicated by specified bit mask.

Implemented in file_info_impl, and file_info_const_impl.

t_size file_info::info_set ( const char *  p_name,
const char *  p_value 
)
inline

Definition at line 167 of file file_info.h.

167 {return info_set_ex(p_name,pfc_infinite,p_value,pfc_infinite);}
virtual t_size info_set_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
Creates a new technical info entry with specified name and specified value. If an entry of the same n...
void file_info::info_set_bitrate ( t_int64  val)
inline

Definition at line 206 of file file_info.h.

206 {info_set_int("bitrate",val);}
void info_set_int(const char *name, t_int64 value)
Definition: file_info.cpp:221
void file_info::info_set_bitrate_vbr ( t_int64  val)
inline

Definition at line 204 of file file_info.h.

204 {info_set_int("bitrate_dynamic",val);}
void info_set_int(const char *name, t_int64 value)
Definition: file_info.cpp:221
virtual t_size file_info::info_set_ex ( const char *  p_name,
t_size  p_name_length,
const char *  p_value,
t_size  p_value_length 
)
pure virtual

Creates a new technical info entry with specified name and specified value. If an entry of the same name already exists, it is erased. Return value is the index of newly created entry.

Implemented in file_info_impl, and file_info_const_impl.

void file_info::info_set_float ( const char *  name,
double  value,
unsigned  precision,
bool  force_sign = false,
const char *  unit = 0 
)

Definition at line 227 of file file_info.cpp.

228 {
229  PFC_ASSERT(pfc::is_valid_utf8(name));
230  PFC_ASSERT(unit==0 || strlen(unit) <= 64);
231  char temp[128];
232  pfc::float_to_string(temp,64,value,precision,force_sign);
233  temp[63] = 0;
234  if (unit)
235  {
236  strcat_s(temp," ");
237  strcat_s(temp,unit);
238  }
239  info_set(name,temp);
240 }
t_size info_set(const char *p_name, const char *p_value)
Definition: file_info.h:167
void float_to_string(char *out, t_size out_max, double val, unsigned precision, bool b_sign)
bool is_valid_utf8(const char *param, t_size max=~0)
Definition: utf8.cpp:264
void file_info::info_set_int ( const char *  name,
t_int64  value 
)

Definition at line 221 of file file_info.cpp.

222 {
223  PFC_ASSERT(pfc::is_valid_utf8(name));
224  info_set(name,pfc::format_int(value));
225 }
t_size info_set(const char *p_name, const char *p_value)
Definition: file_info.h:167
bool is_valid_utf8(const char *param, t_size max=~0)
Definition: utf8.cpp:264
t_size file_info::info_set_nocheck ( const char *  p_name,
const char *  p_value 
)
inlineprotected

Definition at line 278 of file file_info.h.

278 {return info_set_nocheck_ex(p_name,pfc_infinite,p_value,pfc_infinite);}
virtual t_size info_set_nocheck_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
virtual t_size file_info::info_set_nocheck_ex ( const char *  p_name,
t_size  p_name_length,
const char *  p_value,
t_size  p_value_length 
)
protectedpure virtual

Implemented in file_info_impl, and file_info_const_impl.

bool file_info::info_set_replaygain ( const char *  p_name,
const char *  p_value 
)
inline

Definition at line 174 of file file_info.h.

174 {return info_set_replaygain_ex(p_name,pfc_infinite,p_value,pfc_infinite);}
bool info_set_replaygain_ex(const char *p_name, t_size p_name_len, const char *p_value, t_size p_value_len)
Definition: file_info.cpp:338
void file_info::info_set_replaygain_album_gain ( float  value)

Definition at line 243 of file file_info.cpp.

244 {
246  temp.m_album_gain = value;
247  set_replaygain(temp);
248 }
Structure containing ReplayGain scan results from some playable object, also providing various helper...
Definition: file_info.h:2
virtual void set_replaygain(const replaygain_info &p_info)=0
Sets ReplayGain information.
float m_album_gain
Definition: file_info.h:4
virtual replaygain_info get_replaygain() const =0
Retrieves ReplayGain information.
void file_info::info_set_replaygain_album_peak ( float  value)

Definition at line 250 of file file_info.cpp.

251 {
253  temp.m_album_peak = value;
254  set_replaygain(temp);
255 }
float m_album_peak
Definition: file_info.h:5
Structure containing ReplayGain scan results from some playable object, also providing various helper...
Definition: file_info.h:2
virtual void set_replaygain(const replaygain_info &p_info)=0
Sets ReplayGain information.
virtual replaygain_info get_replaygain() const =0
Retrieves ReplayGain information.
void file_info::info_set_replaygain_auto ( const char *  p_name,
const char *  p_value 
)
inline

Definition at line 176 of file file_info.h.

176 {info_set_replaygain_auto_ex(p_name,pfc_infinite,p_value,pfc_infinite);}
void info_set_replaygain_auto_ex(const char *p_name, t_size p_name_len, const char *p_value, t_size p_value_len)
Definition: file_info.cpp:349
void file_info::info_set_replaygain_auto_ex ( const char *  p_name,
t_size  p_name_len,
const char *  p_value,
t_size  p_value_len 
)

Definition at line 349 of file file_info.cpp.

350 {
351  if (!info_set_replaygain_ex(p_name,p_name_len,p_value,p_value_len))
352  info_set_ex(p_name,p_name_len,p_value,p_value_len);
353 }
virtual t_size info_set_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
Creates a new technical info entry with specified name and specified value. If an entry of the same n...
bool info_set_replaygain_ex(const char *p_name, t_size p_name_len, const char *p_value, t_size p_value_len)
Definition: file_info.cpp:338
bool file_info::info_set_replaygain_ex ( const char *  p_name,
t_size  p_name_len,
const char *  p_value,
t_size  p_value_len 
)

Definition at line 338 of file file_info.cpp.

339 {
341  if (temp.set_from_meta_ex(p_name,p_name_len,p_value,p_value_len))
342  {
343  set_replaygain(temp);
344  return true;
345  }
346  else return false;
347 }
Structure containing ReplayGain scan results from some playable object, also providing various helper...
Definition: file_info.h:2
virtual void set_replaygain(const replaygain_info &p_info)=0
Sets ReplayGain information.
bool set_from_meta_ex(const char *p_name, t_size p_name_len, const char *p_value, t_size p_value_len)
virtual replaygain_info get_replaygain() const =0
Retrieves ReplayGain information.
void file_info::info_set_replaygain_track_gain ( float  value)

Definition at line 257 of file file_info.cpp.

258 {
260  temp.m_track_gain = value;
261  set_replaygain(temp);
262 }
float m_track_gain
Definition: file_info.h:4
Structure containing ReplayGain scan results from some playable object, also providing various helper...
Definition: file_info.h:2
virtual void set_replaygain(const replaygain_info &p_info)=0
Sets ReplayGain information.
virtual replaygain_info get_replaygain() const =0
Retrieves ReplayGain information.
void file_info::info_set_replaygain_track_peak ( float  value)

Definition at line 264 of file file_info.cpp.

265 {
267  temp.m_track_peak = value;
268  set_replaygain(temp);
269 }
Structure containing ReplayGain scan results from some playable object, also providing various helper...
Definition: file_info.h:2
virtual void set_replaygain(const replaygain_info &p_info)=0
Sets ReplayGain information.
virtual replaygain_info get_replaygain() const =0
Retrieves ReplayGain information.
float m_track_peak
Definition: file_info.h:5
void file_info::info_set_wfx_chanMask ( uint32_t  val)

Definition at line 532 of file file_info.cpp.

532  {
533  switch(val) {
534  case 0:
535  case 4:
536  case 3:
537  break;
538  default:
539  info_set ("WAVEFORMATEXTENSIBLE_CHANNEL_MASK", PFC_string_formatter() << "0x" << pfc::format_hex(val) );
540  break;
541  }
542 }
t_size info_set(const char *p_name, const char *p_value)
Definition: file_info.h:167
bool file_info::is_encoding_lossy ( ) const

Definition at line 400 of file file_info.cpp.

400  {
401  const char * encoding = info_get("encoding");
402  if (encoding != NULL) {
403  if (pfc::stricmp_ascii(encoding,"lossy") == 0 /*|| pfc::stricmp_ascii(encoding,"hybrid") == 0*/) return true;
404  } else {
405  //the old way
406  //disabled: don't whine if we're not sure what we're dealing with - might be a file with info not-yet-loaded in oddball cases or a mod file
407  //if (info_get("bitspersample") == NULL) return true;
408  }
409  return false;
410 }
const char * info_get(const char *p_name) const
Definition: file_info.h:171
int stricmp_ascii(const char *s1, const char *s2)
void file_info::merge ( const pfc::list_base_const_t< const file_info * > &  p_sources)
private

Definition at line 74 of file file_info_merge.cpp.

75 {
76  t_size in_count = p_in.get_count();
77  if (in_count == 0)
78  {
80  return;
81  }
82  else if (in_count == 1)
83  {
84  const file_info * info = p_in[0];
85 
86  copy_meta(*info);
87 
89 
90  overwrite_info(*info);
91 
92  //copy_info_single_by_name(*info,"tagtype");
93 
94  return;
95  }
96 
97  merge_meta(*this,p_in);
98 
99  {
100  pfc::string8_fastalloc tagtype;
102  t_size in_ptr;
103  for(in_ptr = 0; in_ptr < in_count; in_ptr++ )
104  {
105  const file_info * info = p_in[in_ptr];
106  rg = replaygain_info::g_merge(rg, info->get_replaygain());
107  t_size field_ptr, field_max = info->info_get_count();
108  for(field_ptr = 0; field_ptr < field_max; field_ptr++ )
109  {
110  const char * field_name = info->info_enum_name(field_ptr), * field_value = info->info_enum_value(field_ptr);
111  if (*field_value)
112  {
113  if (!pfc::stricmp_ascii(field_name,"tagtype"))
114  {
115  if (!tagtype.is_empty()) tagtype += "|";
116  tagtype += field_value;
117  }
118  }
119  }
120  }
121  if (!tagtype.is_empty()) info_set("tagtype",tagtype);
122  set_replaygain(rg);
123  }
124 }
virtual void copy_meta(const file_info &p_source)
Copies metadata from specified file_info object.
Definition: file_info.cpp:146
void info(const char *p_message)
Definition: console.cpp:4
static void merge_meta(file_info &p_out, const pfc::list_base_const_t< const file_info * > &p_in)
virtual const char * info_enum_value(t_size p_index) const =0
Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encode...
Structure containing ReplayGain scan results from some playable object, also providing various helper...
Definition: file_info.h:2
Main interface class for information about some playable object.
Definition: file_info.h:73
size_t t_size
Definition: int_types.h:48
t_size info_set(const char *p_name, const char *p_value)
Definition: file_info.h:167
virtual void set_replaygain(const replaygain_info &p_info)=0
Sets ReplayGain information.
static replaygain_info g_merge(replaygain_info r1, replaygain_info r2)
void meta_remove_all()
Definition: file_info.cpp:35
int stricmp_ascii(const char *s1, const char *s2)
virtual replaygain_info get_replaygain() const =0
Retrieves ReplayGain information.
string8_t< pfc::alloc_fast_aggressive > string8_fastalloc
Definition: string_base.h:436
virtual const char * info_enum_name(t_size p_index) const =0
Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded...
virtual t_size info_get_count() const =0
Retrieves number of technical info entries.
void overwrite_info(const file_info &p_source)
void file_info::merge_fallback ( const file_info fallback)

Definition at line 134 of file file_info_merge.cpp.

134  {
135  set_replaygain( replaygain_info::g_merge(get_replaygain(), source.get_replaygain() ) );
136  if (get_length() <= 0) set_length(source.get_length());
137  t_size count = source.info_get_count();
138  for(t_size infoWalk = 0; infoWalk < count; ++infoWalk) {
139  const char * name = source.info_enum_name(infoWalk);
140  if (!info_exists(name)) __info_add_unsafe(name, source.info_enum_value(infoWalk));
141  }
142  count = source.meta_get_count();
143  for(t_size metaWalk = 0; metaWalk < count; ++metaWalk) {
144  const char * name = source.meta_enum_name(metaWalk);
145  if (!meta_exists(name)) _copy_meta_single_nocheck(source, metaWalk);
146  }
147 }
virtual double get_length() const =0
Retrieves audio duration, in seconds. Note that the reported duration should not be assumed to be th...
bool info_exists(const char *p_name) const
Definition: file_info.h:169
void _copy_meta_single_nocheck(const file_info &p_source, t_size p_index)
Definition: file_info.h:245
size_t t_size
Definition: int_types.h:48
t_size __info_add_unsafe(const char *p_name, const char *p_value)
Unsafe - does not check whether the field already exists and will result in duplicates if it does - c...
Definition: file_info.h:243
virtual void set_replaygain(const replaygain_info &p_info)=0
Sets ReplayGain information.
bool meta_exists(const char *p_name) const
Definition: file_info.h:155
static replaygain_info g_merge(replaygain_info r1, replaygain_info r2)
virtual replaygain_info get_replaygain() const =0
Retrieves ReplayGain information.
virtual void set_length(double p_length)=0
Sets audio duration, in seconds. Note that the reported duration should not be assumed to be the exa...
t_size file_info::meta_add ( const char *  p_name,
const char *  p_value 
)
inline

Definition at line 162 of file file_info.h.

162 {return meta_add_ex(p_name,pfc_infinite,p_value,pfc_infinite);}
t_size meta_add_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)
Definition: file_info.cpp:314
t_size file_info::meta_add_ex ( const char *  p_name,
t_size  p_name_length,
const char *  p_value,
t_size  p_value_length 
)

Definition at line 314 of file file_info.cpp.

315 {
316  t_size index = meta_find_ex(p_name,p_name_length);
317  if (index == pfc_infinite) return meta_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length);
318  else
319  {
320  meta_add_value_ex(index,p_value,p_value_length);
321  return index;
322  }
323 }
virtual t_size meta_set_nocheck_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
void meta_add_value_ex(t_size p_index, const char *p_value, t_size p_value_length)
Definition: file_info.cpp:325
size_t t_size
Definition: int_types.h:48
virtual t_size meta_find_ex(const char *p_name, t_size p_name_length) const
Finds index of metadata entry of specified name. Returns infinite when not found. ...
Definition: file_info.cpp:8
void file_info::meta_add_value ( t_size  p_index,
const char *  p_value 
)
inline

Definition at line 159 of file file_info.h.

159 {meta_add_value_ex(p_index,p_value,pfc_infinite);}
void meta_add_value_ex(t_size p_index, const char *p_value, t_size p_value_length)
Definition: file_info.cpp:325
void file_info::meta_add_value_ex ( t_size  p_index,
const char *  p_value,
t_size  p_value_length 
)

Definition at line 325 of file file_info.cpp.

326 {
327  meta_insert_value_ex(p_index,meta_enum_value_count(p_index),p_value,p_value_length);
328 }
virtual t_size meta_enum_value_count(t_size p_index) const =0
Retrieves count of values in metadata entry of specified index. The value is always equal to or great...
virtual void meta_insert_value_ex(t_size p_index, t_size p_value_index, const char *p_value, t_size p_value_length)=0
Inserts a new value into specified metadata entry.
t_size file_info::meta_calc_total_value_count ( ) const

Definition at line 331 of file file_info.cpp.

332 {
333  t_size n, m = meta_get_count(), ret = 0;
334  for(n=0;n<m;n++) ret += meta_enum_value_count(n);
335  return ret;
336 }
virtual t_size meta_enum_value_count(t_size p_index) const =0
Retrieves count of values in metadata entry of specified index. The value is always equal to or great...
size_t t_size
Definition: int_types.h:48
virtual t_size meta_get_count() const =0
Retrieves count of metadata entries.
virtual const char* file_info::meta_enum_name ( t_size  p_index) const
pure virtual

Retrieves the name of metadata entry of specified index. Return value is a null-terminated UTF-8 encoded string.

Implemented in file_info_impl, and file_info_const_impl.

virtual const char* file_info::meta_enum_value ( t_size  p_index,
t_size  p_value_number 
) const
pure virtual

Retrieves specified value from specified metadata entry. Return value is a null-terminated UTF-8 encoded string.

Implemented in file_info_impl, and file_info_const_impl.

virtual t_size file_info::meta_enum_value_count ( t_size  p_index) const
pure virtual

Retrieves count of values in metadata entry of specified index. The value is always equal to or greater than 1.

Implemented in file_info_impl, and file_info_const_impl.

bool file_info::meta_exists ( const char *  p_name) const
inline

Definition at line 155 of file file_info.h.

155 {return meta_exists_ex(p_name,pfc_infinite);}
bool meta_exists_ex(const char *p_name, t_size p_name_length) const
Definition: file_info.cpp:18
bool file_info::meta_exists_ex ( const char *  p_name,
t_size  p_name_length 
) const

Definition at line 18 of file file_info.cpp.

19 {
20  return meta_find_ex(p_name,p_name_length) != pfc_infinite;
21 }
virtual t_size meta_find_ex(const char *p_name, t_size p_name_length) const
Finds index of metadata entry of specified name. Returns infinite when not found. ...
Definition: file_info.cpp:8
t_size file_info::meta_find ( const char *  p_name) const
inline

Definition at line 154 of file file_info.h.

154 {return meta_find_ex(p_name,pfc_infinite);}
virtual t_size meta_find_ex(const char *p_name, t_size p_name_length) const
Finds index of metadata entry of specified name. Returns infinite when not found. ...
Definition: file_info.cpp:8
t_size file_info::meta_find_ex ( const char *  p_name,
t_size  p_name_length 
) const
virtual

Finds index of metadata entry of specified name. Returns infinite when not found.

Reimplemented in file_info_const_impl.

Definition at line 8 of file file_info.cpp.

9 {
10  t_size n, m = meta_get_count();
11  for(n=0;n<m;n++)
12  {
13  if (pfc::stricmp_ascii_ex(meta_enum_name(n),pfc_infinite,p_name,p_name_length) == 0) return n;
14  }
15  return pfc_infinite;
16 }
int stricmp_ascii_ex(const char *const s1, t_size const len1, const char *const s2, t_size const len2)
size_t t_size
Definition: int_types.h:48
virtual t_size meta_get_count() const =0
Retrieves count of metadata entries.
virtual const char * meta_enum_name(t_size p_index) const =0
Retrieves the name of metadata entry of specified index. Return value is a null-terminated UTF-8 enco...
bool file_info::meta_format ( const char *  p_name,
pfc::string_base p_out,
const char *  separator = ", " 
) const

Definition at line 387 of file file_info.cpp.

387  {
388  p_out.reset();
389  t_size index = meta_find(p_name);
390  if (index == pfc_infinite) return false;
391  meta_format_entry(index, p_out, separator);
392  return true;
393 }
void meta_format_entry(t_size index, pfc::string_base &p_out, const char *separator=", ") const
Definition: file_info.cpp:376
size_t t_size
Definition: int_types.h:48
t_size meta_find(const char *p_name) const
Definition: file_info.h:154
void file_info::meta_format_entry ( t_size  index,
pfc::string_base p_out,
const char *  separator = ", " 
) const

Definition at line 376 of file file_info.cpp.

376  {
377  out.reset();
378  t_size val, count = meta_enum_value_count(index);
379  PFC_ASSERT( count > 0);
380  for(val=0;val<count;val++)
381  {
382  if (val > 0) out += separator;
383  out += meta_enum_value(index,val);
384  }
385 }
virtual t_size meta_enum_value_count(t_size p_index) const =0
Retrieves count of values in metadata entry of specified index. The value is always equal to or great...
virtual const char * meta_enum_value(t_size p_index, t_size p_value_number) const =0
Retrieves specified value from specified metadata entry. Return value is a null-terminated UTF-8 enco...
size_t t_size
Definition: int_types.h:48
const char* file_info::meta_get ( const char *  p_name,
t_size  p_index 
) const
inline

Definition at line 160 of file file_info.h.

160 {return meta_get_ex(p_name,pfc_infinite,p_index);}
const char * meta_get_ex(const char *p_name, t_size p_name_length, t_size p_index) const
Definition: file_info.cpp:177
virtual t_size file_info::meta_get_count ( ) const
pure virtual

Retrieves count of metadata entries.

Implemented in file_info_impl, and file_info_const_impl.

t_size file_info::meta_get_count_by_name ( const char *  p_name) const
inline

Definition at line 161 of file file_info.h.

161 {return meta_get_count_by_name_ex(p_name,pfc_infinite);}
t_size meta_get_count_by_name_ex(const char *p_name, t_size p_name_length) const
Definition: file_info.cpp:45
t_size file_info::meta_get_count_by_name_ex ( const char *  p_name,
t_size  p_name_length 
) const

Definition at line 45 of file file_info.cpp.

46 {
47  t_size index = meta_find_ex(p_name,p_name_length);
48  if (index == pfc_infinite) return 0;
49  return meta_enum_value_count(index);
50 }
virtual t_size meta_enum_value_count(t_size p_index) const =0
Retrieves count of values in metadata entry of specified index. The value is always equal to or great...
size_t t_size
Definition: int_types.h:48
virtual t_size meta_find_ex(const char *p_name, t_size p_name_length) const
Finds index of metadata entry of specified name. Returns infinite when not found. ...
Definition: file_info.cpp:8
const char * file_info::meta_get_ex ( const char *  p_name,
t_size  p_name_length,
t_size  p_index 
) const

Definition at line 177 of file file_info.cpp.

178 {
179  t_size index = meta_find_ex(p_name,p_name_length);
180  if (index == pfc_infinite) return 0;
181  t_size max = meta_enum_value_count(index);
182  if (p_index >= max) return 0;
183  return meta_enum_value(index,p_index);
184 }
virtual t_size meta_enum_value_count(t_size p_index) const =0
Retrieves count of values in metadata entry of specified index. The value is always equal to or great...
virtual const char * meta_enum_value(t_size p_index, t_size p_value_number) const =0
Retrieves specified value from specified metadata entry. Return value is a null-terminated UTF-8 enco...
size_t t_size
Definition: int_types.h:48
virtual t_size meta_find_ex(const char *p_name, t_size p_name_length) const
Finds index of metadata entry of specified name. Returns infinite when not found. ...
Definition: file_info.cpp:8
void file_info::meta_insert_value ( t_size  p_index,
t_size  p_value_index,
const char *  p_value 
)
inline

Definition at line 158 of file file_info.h.

158 {meta_insert_value_ex(p_index,p_value_index,p_value,pfc_infinite);}
virtual void meta_insert_value_ex(t_size p_index, t_size p_value_index, const char *p_value, t_size p_value_length)=0
Inserts a new value into specified metadata entry.
virtual void file_info::meta_insert_value_ex ( t_size  p_index,
t_size  p_value_index,
const char *  p_value,
t_size  p_value_length 
)
pure virtual

Inserts a new value into specified metadata entry.

Implemented in file_info_impl, and file_info_const_impl.

void file_info::meta_modify_value ( t_size  p_index,
t_size  p_value_index,
const char *  p_value 
)
inline

Definition at line 163 of file file_info.h.

163 {meta_modify_value_ex(p_index,p_value_index,p_value,pfc_infinite);}
virtual void meta_modify_value_ex(t_size p_index, t_size p_value_index, const char *p_value, t_size p_value_length)=0
Alters specified value in specified metadata entry.
virtual void file_info::meta_modify_value_ex ( t_size  p_index,
t_size  p_value_index,
const char *  p_value,
t_size  p_value_length 
)
pure virtual

Alters specified value in specified metadata entry.

Implemented in file_info_impl, and file_info_const_impl.

void file_info::meta_remove_all ( )

Definition at line 35 of file file_info.cpp.

36 {
38 }
virtual void meta_remove_mask(const bit_array &p_mask)=0
Removes metadata entries according to specified bit mask.
void file_info::meta_remove_field ( const char *  p_name)
inline

Definition at line 156 of file file_info.h.

156 {meta_remove_field_ex(p_name,pfc_infinite);}
void meta_remove_field_ex(const char *p_name, t_size p_name_length)
Definition: file_info.cpp:23
void file_info::meta_remove_field_ex ( const char *  p_name,
t_size  p_name_length 
)

Definition at line 23 of file file_info.cpp.

24 {
25  t_size index = meta_find_ex(p_name,p_name_length);
26  if (index!=pfc_infinite) meta_remove_index(index);
27 }
size_t t_size
Definition: int_types.h:48
void meta_remove_index(t_size p_index)
Definition: file_info.cpp:30
virtual t_size meta_find_ex(const char *p_name, t_size p_name_length) const
Finds index of metadata entry of specified name. Returns infinite when not found. ...
Definition: file_info.cpp:8
void file_info::meta_remove_index ( t_size  p_index)

Definition at line 30 of file file_info.cpp.

31 {
33 }
virtual void meta_remove_mask(const bit_array &p_mask)=0
Removes metadata entries according to specified bit mask.
virtual void file_info::meta_remove_mask ( const bit_array p_mask)
pure virtual

Removes metadata entries according to specified bit mask.

Implemented in file_info_impl, and file_info_const_impl.

void file_info::meta_remove_value ( t_size  p_index,
t_size  p_value 
)

Definition at line 40 of file file_info.cpp.

41 {
42  meta_remove_values(p_index,bit_array_one(p_value));
43 }
virtual void meta_remove_values(t_size p_index, const bit_array &p_mask)=0
Removes values according to specified bit mask from specified metadata entry. If all values are remov...
virtual void file_info::meta_remove_values ( t_size  p_index,
const bit_array p_mask 
)
pure virtual

Removes values according to specified bit mask from specified metadata entry. If all values are removed, entire metadata entry is removed as well.

Implemented in file_info_impl, and file_info_const_impl.

virtual void file_info::meta_reorder ( const t_size p_order)
pure virtual

Reorders metadata entries according to specified permutation.

Implemented in file_info_impl, and file_info_const_impl.

t_size file_info::meta_set ( const char *  p_name,
const char *  p_value 
)
inline

Definition at line 157 of file file_info.h.

157 {return meta_set_ex(p_name,pfc_infinite,p_value,pfc_infinite);}
virtual t_size meta_set_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
Creates a new metadata entry of specified name with specified value. If an entry of same name already...
virtual t_size file_info::meta_set_ex ( const char *  p_name,
t_size  p_name_length,
const char *  p_value,
t_size  p_value_length 
)
pure virtual

Creates a new metadata entry of specified name with specified value. If an entry of same name already exists, it is erased. Return value is the index of newly created metadata entry.

Implemented in file_info_impl, and file_info_const_impl.

t_size file_info::meta_set_nocheck ( const char *  p_name,
const char *  p_value 
)
inlineprotected

Definition at line 277 of file file_info.h.

277 {return meta_set_nocheck_ex(p_name,pfc_infinite,p_value,pfc_infinite);}
virtual t_size meta_set_nocheck_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)=0
virtual t_size file_info::meta_set_nocheck_ex ( const char *  p_name,
t_size  p_name_length,
const char *  p_value,
t_size  p_value_length 
)
protectedpure virtual

Implemented in file_info_impl, and file_info_const_impl.

const file_info& file_info::operator= ( const file_info p_source)
inline

Definition at line 229 of file file_info.h.

229 {copy(p_source);return *this;}
virtual void copy(const file_info &p_source)
Copies entire file_info contents from specified file_info object.
Definition: file_info.cpp:166
void file_info::overwrite_info ( const file_info p_source)

Definition at line 126 of file file_info_merge.cpp.

126  {
127  t_size count = p_source.info_get_count();
128  for(t_size n=0;n<count;n++) {
129  info_set(p_source.info_enum_name(n),p_source.info_enum_value(n));
130  }
131 }
virtual const char * info_enum_value(t_size p_index) const =0
Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encode...
size_t t_size
Definition: int_types.h:48
t_size info_set(const char *p_name, const char *p_value)
Definition: file_info.h:167
virtual const char * info_enum_name(t_size p_index) const =0
Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded...
virtual t_size info_get_count() const =0
Retrieves number of technical info entries.
void file_info::overwrite_meta ( const file_info p_source)

Definition at line 87 of file file_info.cpp.

87  {
88  const t_size total = p_source.meta_get_count();
89  for(t_size walk = 0; walk < total; ++walk) {
90  copy_meta_single(p_source, walk);
91  }
92 }
size_t t_size
Definition: int_types.h:48
virtual t_size meta_get_count() const =0
Retrieves count of metadata entries.
void copy_meta_single(const file_info &p_source, t_size p_index)
Definition: file_info.cpp:94
void file_info::reset ( )

Definition at line 287 of file file_info.cpp.

288 {
289  info_remove_all();
290  meta_remove_all();
291  set_length(0);
293 }
void info_remove_all()
Definition: file_info.cpp:71
void meta_remove_all()
Definition: file_info.cpp:35
void reset_replaygain()
Definition: file_info.cpp:295
virtual void set_length(double p_length)=0
Sets audio duration, in seconds. Note that the reported duration should not be assumed to be the exa...
void file_info::reset_replaygain ( )

Definition at line 295 of file file_info.cpp.

296 {
297  replaygain_info temp;
298  temp.reset();
299  set_replaygain(temp);
300 }
Structure containing ReplayGain scan results from some playable object, also providing various helper...
Definition: file_info.h:2
virtual void set_replaygain(const replaygain_info &p_info)=0
Sets ReplayGain information.
virtual void file_info::set_length ( double  p_length)
pure virtual

Sets audio duration, in seconds.
Note that the reported duration should not be assumed to be the exact length of the track -
with many popular audio formats, exact duration is impossible to determine without performing a full decode pass;
with other formats, the decoded data may be shorter than reported due to truncation other damage.

Implemented in file_info_impl, and file_info_const_impl.

virtual void file_info::set_replaygain ( const replaygain_info p_info)
pure virtual

Sets ReplayGain information.

Implemented in file_info_impl, and file_info_const_impl.

void file_info::to_console ( ) const

Definition at line 519 of file file_info.cpp.

519  {
520  FB2K_console_formatter() << "File info dump:";
521  if (get_length() > 0) FB2K_console_formatter() << "Duration: " << pfc::format_time_ex(get_length(), 6);
523  for(t_size metaWalk = 0; metaWalk < meta_get_count(); ++metaWalk) {
524  meta_format_entry(metaWalk, temp);
525  FB2K_console_formatter() << "Meta: " << meta_enum_name(metaWalk) << " = " << temp;
526  }
527  for(t_size infoWalk = 0; infoWalk < info_get_count(); ++infoWalk) {
528  FB2K_console_formatter() << "Info: " << info_enum_name(infoWalk) << " = " << info_enum_value(infoWalk);
529  }
530 }
virtual double get_length() const =0
Retrieves audio duration, in seconds. Note that the reported duration should not be assumed to be th...
virtual const char * info_enum_value(t_size p_index) const =0
Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encode...
void meta_format_entry(t_size index, pfc::string_base &p_out, const char *separator=", ") const
Definition: file_info.cpp:376
size_t t_size
Definition: int_types.h:48
virtual t_size meta_get_count() const =0
Retrieves count of metadata entries.
virtual const char * info_enum_name(t_size p_index) const =0
Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded...
virtual t_size info_get_count() const =0
Retrieves number of technical info entries.
virtual const char * meta_enum_name(t_size p_index) const =0
Retrieves the name of metadata entry of specified index. Return value is a null-terminated UTF-8 enco...
void file_info::to_formatter ( pfc::string_formatter out) const

Definition at line 506 of file file_info.cpp.

506  {
507  out << "File info dump:\n";
508  if (get_length() > 0) out<< "Duration: " << pfc::format_time_ex(get_length(), 6) << "\n";
510  for(t_size metaWalk = 0; metaWalk < meta_get_count(); ++metaWalk) {
511  meta_format_entry(metaWalk, temp);
512  out << "Meta: " << meta_enum_name(metaWalk) << " = " << temp << "\n";
513  }
514  for(t_size infoWalk = 0; infoWalk < info_get_count(); ++infoWalk) {
515  out << "Info: " << info_enum_name(infoWalk) << " = " << info_enum_value(infoWalk) << "\n";
516  }
517 }
virtual double get_length() const =0
Retrieves audio duration, in seconds. Note that the reported duration should not be assumed to be th...
virtual const char * info_enum_value(t_size p_index) const =0
Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encode...
void meta_format_entry(t_size index, pfc::string_base &p_out, const char *separator=", ") const
Definition: file_info.cpp:376
size_t t_size
Definition: int_types.h:48
virtual t_size meta_get_count() const =0
Retrieves count of metadata entries.
virtual const char * info_enum_name(t_size p_index) const =0
Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded...
virtual t_size info_get_count() const =0
Retrieves number of technical info entries.
virtual const char * meta_enum_name(t_size p_index) const =0
Retrieves the name of metadata entry of specified index. Return value is a null-terminated UTF-8 enco...
void file_info::to_stream ( stream_writer stream,
abort_callback abort 
) const

Definition at line 569 of file file_info.cpp.

569  {
570  stream_writer_formatter<> out(* stream, abort );
571 
572  out << this->get_length();
573 
574  {
575  const auto rg = this->get_replaygain();
576  out << rg.m_track_gain << rg.m_album_gain << rg.m_track_peak << rg.m_album_peak;
577  }
578 
579 
580  {
581  const uint32_t metaCount = pfc::downcast_guarded<uint32_t>( this->meta_get_count() );
582  for(uint32_t metaWalk = 0; metaWalk < metaCount; ++metaWalk) {
583  const char * name = this->meta_enum_name( metaWalk );
584  if (*name) {
585  out.write_string_nullterm( this->meta_enum_name( metaWalk ) );
586  const size_t valCount = this->meta_enum_value_count( metaWalk );
587  for(size_t valWalk = 0; valWalk < valCount; ++valWalk) {
588  const char * value = this->meta_enum_value( metaWalk, valWalk );
589  if (*value) {
590  out.write_string_nullterm( value );
591  }
592  }
593  out.write_int<char>(0);
594  }
595  }
596  out.write_int<char>(0);
597  }
598 
599  {
600  const uint32_t infoCount = pfc::downcast_guarded<uint32_t>( this->info_get_count() );
601  for(uint32_t infoWalk = 0; infoWalk < infoCount; ++infoWalk) {
602  const char * name = this->info_enum_name( infoWalk );
603  const char * value = this->info_enum_value( infoWalk );
604  if (*name && *value) {
605  out.write_string_nullterm(name); out.write_string_nullterm(value);
606  }
607  }
608  out.write_int<char>(0);
609  }
610 }
virtual double get_length() const =0
Retrieves audio duration, in seconds. Note that the reported duration should not be assumed to be th...
virtual t_size meta_enum_value_count(t_size p_index) const =0
Retrieves count of values in metadata entry of specified index. The value is always equal to or great...
virtual const char * info_enum_value(t_size p_index) const =0
Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encode...
virtual const char * meta_enum_value(t_size p_index, t_size p_value_number) const =0
Retrieves specified value from specified metadata entry. Return value is a null-terminated UTF-8 enco...
virtual t_size meta_get_count() const =0
Retrieves count of metadata entries.
virtual replaygain_info get_replaygain() const =0
Retrieves ReplayGain information.
virtual const char * info_enum_name(t_size p_index) const =0
Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded...
virtual t_size info_get_count() const =0
Retrieves number of technical info entries.
virtual const char * meta_enum_name(t_size p_index) const =0
Retrieves the name of metadata entry of specified index. Return value is a null-terminated UTF-8 enco...

The documentation for this class was generated from the following files: