20 : bits_per_sample_(bits_per_sample), channels_(channels), sample_rate_(sample_rate) {
31 uint32_t frames_for_ms_calculation = *total_frames - unprocessable_frames;
34 *total_frames = unprocessable_frames;
45#ifdef USE_AUDIO_FLAC_SUPPORT
49#ifdef USE_AUDIO_MP3_SUPPORT
53#ifdef USE_AUDIO_OPUS_SUPPORT
57#ifdef USE_AUDIO_WAV_SUPPORT
68 if (content_type !=
nullptr && content_type[0] !=
'\0') {
69#ifdef USE_AUDIO_MP3_SUPPORT
70 if (strcasecmp(content_type,
"mp3") == 0 || strcasecmp(content_type,
"audio/mp3") == 0 ||
71 strcasecmp(content_type,
"audio/mpeg") == 0) {
75#ifdef USE_AUDIO_WAV_SUPPORT
76 if (strcasecmp(content_type,
"audio/wav") == 0) {
80#ifdef USE_AUDIO_FLAC_SUPPORT
81 if (strcasecmp(content_type,
"audio/flac") == 0 || strcasecmp(content_type,
"audio/x-flac") == 0) {
85#ifdef USE_AUDIO_OPUS_SUPPORT
89 if (strncasecmp(content_type,
"audio/ogg", 9) == 0 && strcasestr(content_type + 9,
"opus") !=
nullptr) {
96 if (url !=
nullptr && url[0] !=
'\0') {
97#ifdef USE_AUDIO_WAV_SUPPORT
102#ifdef USE_AUDIO_MP3_SUPPORT
107#ifdef USE_AUDIO_FLAC_SUPPORT
112#ifdef USE_AUDIO_OPUS_SUPPORT
123 size_t samples_to_scale) {
125 for (
size_t i = 0; i < samples_to_scale; i++) {
126 int32_t acc = (int32_t) audio_samples[i] * (int32_t) scale_factor;
127 output_buffer[i] = (int16_t) (acc >> 15);
uint32_t ms_sample_rate_gcd_
uint8_t get_bits_per_sample() const
uint32_t frames_to_microseconds(uint32_t frames) const
Computes the duration, in microseconds, the given amount of frames represents.
uint8_t get_channels() const
uint32_t frames_to_milliseconds_with_remainder(uint32_t *frames) const
Computes the duration, in milliseconds, the given amount of frames represents.
bool operator==(const AudioStreamInfo &rhs) const
uint32_t get_sample_rate() const
void scale_audio_samples(const int16_t *audio_samples, int16_t *output_buffer, int16_t scale_factor, size_t samples_to_scale)
Scales Q15 fixed point audio samples.
const char * audio_file_type_to_string(AudioFileType file_type)
Helper function to convert file type to a const char string.
AudioFileType detect_audio_file_type(const char *content_type, const char *url)
Detect audio file type from a Content-Type header value and/or URL extension.
bool str_endswith_ignore_case(const char *str, size_t str_len, const char *suffix, size_t suffix_len)
Case-insensitive check if string ends with suffix (no heap allocation).