foobar2000 SDK  2015-01-14
Public Member Functions | Static Public Member Functions | Data Fields
input_raw

Public Member Functions

bool decode_can_seek ()
 
bool decode_get_dynamic_info (file_info &p_out, double &p_timestamp_delta)
 
bool decode_get_dynamic_info_track (file_info &p_out, double &p_timestamp_delta)
 
void decode_initialize (unsigned p_flags, abort_callback &p_abort)
 
void decode_on_idle (abort_callback &p_abort)
 
bool decode_run (audio_chunk &p_chunk, abort_callback &p_abort)
 
void decode_seek (double p_seconds, abort_callback &p_abort)
 
t_filestats get_file_stats (abort_callback &p_abort)
 
void get_info (file_info &p_info, abort_callback &p_abort)
 
void open (service_ptr_t< file > p_filehint, const char *p_path, t_input_open_reason p_reason, abort_callback &p_abort)
 
void retag (const file_info &p_info, abort_callback &p_abort)
 

Static Public Member Functions

static bool g_is_our_content_type (const char *p_content_type)
 
static bool g_is_our_path (const char *p_path, const char *p_extension)
 

Data Fields

pfc::array_t< t_uint8m_buffer
 
service_ptr_t< filem_file
 

Detailed Description

Definition at line 13 of file input_raw.cpp.

Member Function Documentation

bool input_raw::decode_can_seek ( )
inline

Definition at line 65 of file input_raw.cpp.

65 {return m_file->can_seek();}
service_ptr_t< file > m_file
Definition: input_raw.cpp:75
bool input_raw::decode_get_dynamic_info ( file_info p_out,
double &  p_timestamp_delta 
)
inline

Definition at line 66 of file input_raw.cpp.

66 {return false;} // deals with dynamic information such as VBR bitrates
bool input_raw::decode_get_dynamic_info_track ( file_info p_out,
double &  p_timestamp_delta 
)
inline

Definition at line 67 of file input_raw.cpp.

67 {return false;} // deals with dynamic information such as track changes in live streams
void input_raw::decode_initialize ( unsigned  p_flags,
abort_callback p_abort 
)
inline

Definition at line 38 of file input_raw.cpp.

38  {
39  m_file->reopen(p_abort);//equivalent to seek to zero, except it also works on nonseekable streams
40  }
service_ptr_t< file > m_file
Definition: input_raw.cpp:75
void input_raw::decode_on_idle ( abort_callback p_abort)
inline

Definition at line 68 of file input_raw.cpp.

68 {m_file->on_idle(p_abort);}
service_ptr_t< file > m_file
Definition: input_raw.cpp:75
bool input_raw::decode_run ( audio_chunk p_chunk,
abort_callback p_abort 
)
inline

Definition at line 41 of file input_raw.cpp.

41  {
42  enum {
43  deltaread = 1024,
44  };
46  t_size deltaread_done = m_file->read(m_buffer.get_ptr(),deltaread * raw_total_sample_width,p_abort) / raw_total_sample_width;
47  if (deltaread_done == 0) return false;//EOF
48 
50 
51  //processed successfully, no EOF
52  return true;
53  }
const t_item * get_ptr() const
Definition: array.h:213
service_ptr_t< file > m_file
Definition: input_raw.cpp:75
pfc::array_t< t_uint8 > m_buffer
Definition: input_raw.cpp:76
size_t t_size
Definition: int_types.h:48
void set_size(t_size p_size)
Definition: array.h:104
void set_data_fixedpoint(const void *ptr, t_size bytes, unsigned srate, unsigned nch, unsigned bps, unsigned channel_config)
Helper, sets chunk data to contents of specified buffer, using default win32/wav conventions for sign...
Definition: audio_chunk.h:156
static unsigned g_guess_channel_config(unsigned count)
Helper function; guesses default channel map for the specified channel count. Returns 0 on failure...
void input_raw::decode_seek ( double  p_seconds,
abort_callback p_abort 
)
inline

Definition at line 54 of file input_raw.cpp.

54  {
55  m_file->ensure_seekable();//throw exceptions if someone called decode_seek() despite of our input having reported itself as nonseekable.
56  // IMPORTANT: convert time to sample offset with proper rounding! audio_math::time_to_samples does this properly for you.
58 
59  // get_size_ex fails (throws exceptions) if size is not known (where get_size would return filesize_invalid). Should never fail on seekable streams (if it does it's not our problem anymore).
60  t_filesize max = m_file->get_size_ex(p_abort);
61  if (target > max) target = max;//clip seek-past-eof attempts to legal range (next decode_run() call will just signal EOF).
62 
63  m_file->seek(target,p_abort);
64  }
service_ptr_t< file > m_file
Definition: input_raw.cpp:75
t_uint64 t_filesize
Type used for file size related variables.
Definition: filesystem.h:8
t_uint64 time_to_samples(double p_time, t_uint32 p_sample_rate)
Definition: audio_sample.h:33
static bool input_raw::g_is_our_content_type ( const char *  p_content_type)
inlinestatic

Definition at line 72 of file input_raw.cpp.

72 {return false;} // match against supported mime types here
static bool input_raw::g_is_our_path ( const char *  p_path,
const char *  p_extension 
)
inlinestatic

Definition at line 73 of file input_raw.cpp.

73 {return stricmp_utf8(p_extension,"raw") == 0;}
int SHARED_EXPORT stricmp_utf8(const char *p1, const char *p2)
t_filestats input_raw::get_file_stats ( abort_callback p_abort)
inline

Definition at line 36 of file input_raw.cpp.

36 {return m_file->get_stats(p_abort);}
service_ptr_t< file > m_file
Definition: input_raw.cpp:75
void input_raw::get_info ( file_info p_info,
abort_callback p_abort 
)
inline

Definition at line 21 of file input_raw.cpp.

21  {
22  t_filesize size = m_file->get_size(p_abort);
23  //note that the file size is not always known, for an example, live streams and alike have no defined size and filesize_invalid is returned
24  if (size != filesize_invalid) {
25  //file size is known, let's set length
27  }
28  //note that the values below should be based on contents of the file itself, NOT on user-configurable variables for an example. To report info that changes independently from file contents, use get_dynamic_info/get_dynamic_info_track instead.
29  p_info.info_set_int("samplerate",raw_sample_rate);
30  p_info.info_set_int("channels",raw_channels);
31  p_info.info_set_int("bitspersample",raw_bits_per_sample);
32  p_info.info_set("encoding","lossless");
33  p_info.info_set_bitrate((raw_bits_per_sample * raw_channels * raw_sample_rate + 500 /* rounding for bps to kbps*/ ) / 1000 /* bps to kbps */);
34 
35  }
void info_set_bitrate(t_int64 val)
Definition: file_info.h:206
static const t_filesize filesize_invalid
Invalid/unknown file size constant. Also see: t_filesize.
Definition: filesystem.h:16
service_ptr_t< file > m_file
Definition: input_raw.cpp:75
void info_set_int(const char *name, t_int64 value)
Definition: file_info.cpp:221
double samples_to_time(t_uint64 p_samples, t_uint32 p_sample_rate)
Definition: audio_sample.h:37
t_size info_set(const char *p_name, const char *p_value)
Definition: file_info.h:167
t_uint64 t_filesize
Type used for file size related variables.
Definition: filesystem.h:8
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 input_raw::open ( service_ptr_t< file p_filehint,
const char *  p_path,
t_input_open_reason  p_reason,
abort_callback p_abort 
)
inline

Definition at line 15 of file input_raw.cpp.

15  {
16  if (p_reason == input_open_info_write) throw exception_io_unsupported_format();//our input does not support retagging.
17  m_file = p_filehint;//p_filehint may be null, hence next line
18  input_open_file_helper(m_file,p_path,p_reason,p_abort);//if m_file is null, opens file with appropriate privileges for our operation (read/write for writing tags, read-only otherwise).
19  }
service_ptr_t< file > m_file
Definition: input_raw.cpp:75
void input_open_file_helper(service_ptr_t< file > &p_file, const char *p_path, t_input_open_reason p_reason, abort_callback &p_abort)
Helper function for input implementation use; ensures that file is open with relevant access mode...
Definition: input.cpp:231
void input_raw::retag ( const file_info p_info,
abort_callback p_abort 
)
inline

Definition at line 70 of file input_raw.cpp.

70 {throw exception_io_unsupported_format();}

Field Documentation

pfc::array_t<t_uint8> input_raw::m_buffer

Definition at line 76 of file input_raw.cpp.

service_ptr_t<file> input_raw::m_file

Definition at line 75 of file input_raw.cpp.


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