57using std::logic_error;
58using std::ostringstream;
77audio_desc::operator string()
const
96 for (
int i = 0; i < old->
ch_count; i++) {
103 timestamp = old->timestamp;
107audio_frame2::operator bool()
const
129 throw std::logic_error(
130 "Trying to append frame with different parameters!");
133 for (
size_t i = 0; i <
channels.size(); i++) {
171 unique_ptr<char []> new_data(
new char[length]);
194 for (
size_t i = 0; i <
channels.size(); i++) {
271 throw logic_error(
"Unknown sample count for compressed audio!");
303 for (
size_t i = 0; i < ret.
channels.size(); i++) {
307 frame.get_data_len(i));
319 vector<channel> new_channels(
channels.size());
321 for (
size_t i = 0; i <
channels.size(); i++) {
323 new_channels[i] = {unique_ptr<char []>(
new char[new_size]), new_size, new_size, {}};
326 for (
size_t i = 0; i <
channels.size(); i++) {
344 vector<channel> new_channels(
channels.size());
345 for (
size_t i = 0; i <
channels.size(); i++) {
348 + new_sample_rate_num *
desc.
bps / 100 / new_sample_rate_den;
349 new_channels[i] = {unique_ptr<char []>(
new char[new_size]), new_size, new_size, {}};
352 auto [ret, remainder] = resampler_state.
resample(*
this, new_channels, new_sample_rate_num, new_sample_rate_den);
358 return {ret, std::move(remainder)};
363 auto [ret, remainder] =
resample_fake(resampler_state, new_sample_rate, 1);
367 if (remainder.get_data_len() > 0) {
struct video_frame * frame
This file contains definition of some common audio types.
std::tuple< bool, audio_frame2 > resample(audio_frame2 &a, std::vector< audio_frame2::channel > &out, int new_sample_rate_num, int new_sample_rate_den)
void change_bps(int new_bps)
void resize(int channel, size_t len)
char * get_data(int channel)
bool has_same_prop_as(audio_frame2 const &frame) const
void set_fec_params(int channel, fec_desc const &)
std::vector< channel > channels
void init(int nr_channels, audio_codec_t codec, int bps, int sample_rate)
Initializes audio_frame2 for use. If already initialized, data are dropped.
void set_duration(double duration)
audio_codec_t get_codec() const
int get_channel_count() const
bool resample(audio_frame2_resampler &resampler_state, int new_sample_rate)
int64_t get_timestamp() const
void replace(int channel, size_t offset, const char *data, size_t length)
replaces portion of data of specified channel. If the size of the channel is not sufficient,...
fec_desc const & get_fec_params(int channel) const
struct audio_desc desc
desc.ch_count not set, use channels.size() instead
std::tuple< bool, audio_frame2 > resample_fake(audio_frame2_resampler &resampler_state, int new_sample_rate_num, int new_sample_rate_den)
@ resamples to new sample rate while keeping nominal sample rate intact
void set_timestamp(int64_t ts)
size_t get_data_len(int channel) const
double get_duration() const
int get_sample_rate() const
static audio_frame2 copy_with_bps_change(audio_frame2 const &frame, int new_bps)
size_t get_data_len() const
double duration
for compressed formats where this cannot be directly determined from samples/sample_rate
void append(audio_frame2 const &frame)
int get_sample_count() const
static __device__ const float offset
#define LOG_LEVEL_WARNING
less severe errors
steady_clock::duration duration
bool operator==(audio_desc const &) const
struct used to comunicate with audio capture/playback device
struct fec_desc fec_params
@ TIMESTAMP_VALID
timestamp set by source (in 90 kHz clock)
void demux_channel(char *out, char *in, int bps, int in_len, int in_stream_channels, int pos_in_stream)