foobar2000 SDK  2015-08-03
Public Member Functions | Private Attributes
cue_parser::embeddedcue_metadata_manager

#include <cue_parser.h>

Public Member Functions

t_size get_cue_track_count () const
 
void get_tag (file_info &p_info) const
 
void get_track_info (unsigned p_track, file_info &p_info) const
 
bool have_cuesheet () const
 
void query_track_offsets (unsigned p_track, double &p_begin, double &p_length) const
 
unsigned remap_trackno (unsigned p_index) const
 
void set_tag (file_info const &p_info)
 
void set_track_info (unsigned p_track, file_info const &p_info)
 

Private Attributes

track_record_list m_content
 

Detailed Description

Definition at line 176 of file cue_parser.h.

Member Function Documentation

t_size embeddedcue_metadata_manager::get_cue_track_count ( ) const

Definition at line 369 of file cue_parser_embedding.cpp.

369  {
370  return m_content.get_count() - 1;
371 }
t_size get_count() const
Definition: map.h:137
void embeddedcue_metadata_manager::get_tag ( file_info p_info) const

Definition at line 145 of file cue_parser_embedding.cpp.

145  {
146  if (!have_cuesheet()) {
147  m_content.query_ptr((unsigned)0)->m_info.to_info(p_info);
148  p_info.meta_remove_field("cuesheet");
149  } else {
151  {
152  __get_tag_cue_track_list_builder e(entries);
153  m_content.enumerate(e);
154  }
155  pfc::string_formatter cuesheet;
156  cue_creator::create(cuesheet,entries);
157  entries.remove_all();
158  //parse it back to see what info got stored in the cuesheet and what needs to be stored outside cuesheet in the tags
159  cue_parser::parse_full(cuesheet,entries);
161 
162 
163 
164 
165  {
167  //1. find global infos and forward them
168  {
169  field_name_list fields;
170  { __get_tag__enum_fields_enumerator e(fields); m_content.enumerate(e);}
171  { __get_tag__filter_globals e(m_content,globals); fields.enumerate(e); }
172  }
173 
174  output.overwrite_meta(globals);
175 
176  //2. find local infos
177  {__get_tag__local_field_filter e(globals,output.m_meta); m_content.enumerate(e);}
178  }
179 
180 
181  //strip redundant titles and tracknumbers that the cuesheet already contains
182  for(cue_creator::t_entry_list::const_iterator iter = entries.first(); iter.is_valid(); ++iter) {
183  strip_redundant_track_meta(iter->m_track_number,iter->m_infos,output.m_meta,"tracknumber");
184  strip_redundant_track_meta(iter->m_track_number,iter->m_infos,output.m_meta,"title");
185  }
186 
187 
188  //add tech infos etc
189 
190  {
191  const track_record * rec = m_content.query_ptr((unsigned)0);
192  if (rec != NULL) {
193  output.set_length(rec->m_info.get_length());
194  output.set_replaygain(rec->m_info.get_replaygain());
195  output.overwrite_info(rec->m_info.m_info);
196  }
197  }
198  output.meta_set("cuesheet",cuesheet);
199  output.to_info(p_info);
200  }
201 }
replaygain_info get_replaygain() const
Definition: cue_parser.h:36
void meta_set(const char *p_name, const char *p_value)
Definition: cue_parser.h:97
void enumerate(t_callback &p_callback) const
Definition: map.h:125
void set_replaygain(const replaygain_info &p_replaygain)
Definition: cue_parser.h:37
Differences between chain_list_v2_t<> and old chain_list_t<>: Iterators pointing to removed items as...
Definition: chain_list_v2.h:26
file_info_record_helper::file_info_record m_info
Definition: cue_parser.h:169
bool is_valid() const
Definition: iterators.h:24
void overwrite_meta(const t_source &p_meta)
Definition: cue_parser.h:70
void overwrite_info(const t_source &p_info)
Definition: cue_parser.h:74
const t_storage_value * query_ptr(const _t_key &p_key) const
Definition: map.h:64
void meta_remove_field(const char *p_name)
Definition: file_info.h:156
string8_fastalloc string_formatter
Definition: string_base.h:615
void create(pfc::string_formatter &p_out, const t_entry_list &p_data)
Definition: cue_creator.cpp:44
void parse_full(const char *p_cuesheet, cue_creator::t_entry_list &p_out)
Throws exception_bad_cuesheet on failure.
Definition: cue_parser.cpp:744
static void strip_redundant_track_meta(unsigned p_tracknumber, const file_info &p_cueinfo, file_info_record::t_meta_map &p_meta, const char *p_metaname)
Definition: output.h:95
void to_info(file_info &p_info) const
Definition: cue_parser.h:118
void embeddedcue_metadata_manager::get_track_info ( unsigned  p_track,
file_info p_info 
) const

Definition at line 315 of file cue_parser_embedding.cpp.

315  {
316  const track_record * rec = m_content.query_ptr(p_track);
317  if (rec == NULL) throw exception_io_data();
318  rec->m_info.to_info(p_info);
319 }
file_info_record_helper::file_info_record m_info
Definition: cue_parser.h:169
const t_storage_value * query_ptr(const _t_key &p_key) const
Definition: map.h:64
void to_info(file_info &p_info) const
Definition: cue_parser.h:118
bool embeddedcue_metadata_manager::have_cuesheet ( ) const

Definition at line 335 of file cue_parser_embedding.cpp.

335  {
336  return m_content.get_count() > 1;
337 }
t_size get_count() const
Definition: map.h:137
void embeddedcue_metadata_manager::query_track_offsets ( unsigned  p_track,
double &  p_begin,
double &  p_length 
) const

Definition at line 328 of file cue_parser_embedding.cpp.

328  {
329  const track_record * rec = m_content.query_ptr(p_track);
330  if (rec == NULL) throw exception_io_data();
331  p_begin = rec->m_index_list.start();
332  p_length = rec->m_info.get_length();
333 }
t_cuesheet_index_list m_index_list
Definition: cue_parser.h:171
file_info_record_helper::file_info_record m_info
Definition: cue_parser.h:169
const t_storage_value * query_ptr(const _t_key &p_key) const
Definition: map.h:64
unsigned embeddedcue_metadata_manager::remap_trackno ( unsigned  p_index) const

Definition at line 359 of file cue_parser_embedding.cpp.

359  {
360  if (have_cuesheet()) {
361  __remap_trackno_enumerator wrapper(p_index);
362  m_content.enumerate(wrapper);
363  return wrapper.result();
364  } else {
365  return 0;
366  }
367 }
void enumerate(t_callback &p_callback) const
Definition: map.h:125
void embeddedcue_metadata_manager::set_tag ( file_info const &  p_info)

Definition at line 233 of file cue_parser_embedding.cpp.

233  {
235 
236  {
237  track_record & track0 = m_content.find_or_add((unsigned)0);
238  track0.m_info.from_info(p_info);
239  track0.m_info.m_info.set("cue_embedded","no");
240  }
241 
242 
243 
244  const char * cuesheet = p_info.meta_get("cuesheet",0);
245  if (cuesheet == NULL) {
246  return;
247  }
248 
249  //processing order
250  //1. cuesheet content
251  //2. overwrite with global metadata from the tag
252  //3. overwrite with local metadata from the tag
253 
254  {
256  try {
257  cue_parser::parse_full(cuesheet,entries);
258  } catch(exception_io_data const & e) {
259  console::complain("Attempting to embed an invalid cuesheet", e.what());
260  return;
261  }
262 
263  {
264  const double length = p_info.get_length();
265  for(cue_creator::t_entry_list::const_iterator iter = entries.first(); iter.is_valid(); ++iter ) {
266  if (iter->m_index_list.start() > length) {
267  console::info("Invalid cuesheet - index outside allowed range");
268  return;
269  }
270  }
271  }
272 
273  for(cue_creator::t_entry_list::const_iterator iter = entries.first(); iter.is_valid(); ) {
275  ++next;
276  track_record & entry = m_content.find_or_add(iter->m_track_number);
277  entry.m_file = iter->m_file;
278  entry.m_flags = iter->m_flags;
279  entry.m_index_list = iter->m_index_list;
280  entry.m_info.from_info(iter->m_infos);
281  entry.m_info.from_info_overwrite_info(p_info);
282  entry.m_info.m_info.set("cue_embedded","yes");
283  double begin = entry.m_index_list.start(), end = next.is_valid() ? next->m_index_list.start() : p_info.get_length();
284  if (end <= begin) throw exception_io_data();
285  entry.m_info.set_length(end - begin);
286  iter = next;
287  }
288  }
289 
290  for(t_size metawalk = 0, metacount = p_info.meta_get_count(); metawalk < metacount; ++metawalk) {
291  const char * name = p_info.meta_enum_name(metawalk);
292  const t_size valuecount = p_info.meta_enum_value_count(metawalk);
293  if (valuecount > 0 && !is_reserved_meta_entry(name) && is_global_meta_entry(name)) {
294  __set_tag_global_field_relay relay(p_info,metawalk);
295  m_content.enumerate(relay);
296  }
297  }
298 
299  {
300  pfc::string8_fastalloc namebuffer;
301  for(t_size metawalk = 0, metacount = p_info.meta_get_count(); metawalk < metacount; ++metawalk) {
302  const char * name = p_info.meta_enum_name(metawalk);
303  const t_size valuecount = p_info.meta_enum_value_count(metawalk);
304  unsigned trackno;
305  if (valuecount > 0 && !is_reserved_meta_entry(name) && resolve_cue_meta_name(name,namebuffer,trackno)) {
306  track_record * rec = m_content.query_ptr(trackno);
307  if (rec != NULL) {
308  rec->m_info.transfer_meta_entry(namebuffer,p_info,metawalk);
309  }
310  }
311  }
312  }
313 }
void enumerate(t_callback &p_callback) const
Definition: map.h:125
t_cuesheet_index_list m_index_list
Definition: cue_parser.h:171
void from_info(const file_info &p_info)
Definition: cue_parser.h:111
static bool is_global_meta_entry(const char *p_name)
void info(const char *p_message)
Definition: console.cpp:4
void remove_all()
Definition: map.h:139
Differences between chain_list_v2_t<> and old chain_list_t<>: Iterators pointing to removed items as...
Definition: chain_list_v2.h:26
file_info_record_helper::file_info_record m_info
Definition: cue_parser.h:169
bool is_valid() const
Definition: iterators.h:24
void complain(const char *what, const char *msg)
Definition: console.cpp:21
void transfer_meta_entry(const char *p_name, const file_info &p_info, t_size p_index)
Definition: cue_parser.h:84
t_storage_value & find_or_add(_t_key const &p_key)
Definition: map.h:29
const t_storage_value * query_ptr(const _t_key &p_key) const
Definition: map.h:64
size_t t_size
Definition: int_types.h:48
static bool resolve_cue_meta_name(const char *p_name, pfc::string_base &p_outname, unsigned &p_tracknumber)
void from_info_overwrite_info(const file_info &p_info)
Definition: cue_parser.h:47
void set(const _t_key &p_key, const _t_value &p_value)
Definition: map.h:22
static bool is_reserved_meta_entry(const char *p_name)
void parse_full(const char *p_cuesheet, cue_creator::t_entry_list &p_out)
Throws exception_bad_cuesheet on failure.
Definition: cue_parser.cpp:744
string8_t< pfc::alloc_fast_aggressive > string8_fastalloc
Definition: string_base.h:436
void embeddedcue_metadata_manager::set_track_info ( unsigned  p_track,
file_info const &  p_info 
)

Definition at line 321 of file cue_parser_embedding.cpp.

321  {
322  track_record * rec = m_content.query_ptr(p_track);
323  if (rec == NULL) throw exception_io_data();
324  rec->m_info.from_info_set_meta(p_info);
325  rec->m_info.set_replaygain(p_info.get_replaygain());
326 }
void set_replaygain(const replaygain_info &p_replaygain)
Definition: cue_parser.h:37
file_info_record_helper::file_info_record m_info
Definition: cue_parser.h:169
const t_storage_value * query_ptr(const _t_key &p_key) const
Definition: map.h:64
void from_info_set_meta(const file_info &p_info)
Definition: cue_parser.h:106

Field Documentation

track_record_list cue_parser::embeddedcue_metadata_manager::m_content
private

Definition at line 188 of file cue_parser.h.


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