21 : bits_per_sample_(bits_per_sample), channels_(channels), sample_rate_(sample_rate) {
32 uint32_t frames_for_ms_calculation = *total_frames - unprocessable_frames;
35 *total_frames = unprocessable_frames;
46#ifdef USE_AUDIO_FLAC_SUPPORT
50#ifdef USE_AUDIO_MP3_SUPPORT
54#ifdef USE_AUDIO_OPUS_SUPPORT
67 if (content_type !=
nullptr && content_type[0] !=
'\0') {
68#ifdef USE_AUDIO_MP3_SUPPORT
69 if (strcasecmp(content_type,
"mp3") == 0 || strcasecmp(content_type,
"audio/mp3") == 0 ||
70 strcasecmp(content_type,
"audio/mpeg") == 0) {
74 if (strcasecmp(content_type,
"audio/wav") == 0) {
77#ifdef USE_AUDIO_FLAC_SUPPORT
78 if (strcasecmp(content_type,
"audio/flac") == 0 || strcasecmp(content_type,
"audio/x-flac") == 0) {
82#ifdef USE_AUDIO_OPUS_SUPPORT
86 if (strncasecmp(content_type,
"audio/ogg", 9) == 0 && strcasestr(content_type + 9,
"opus") !=
nullptr) {
93 if (url !=
nullptr && url[0] !=
'\0') {
97#ifdef USE_AUDIO_MP3_SUPPORT
102#ifdef USE_AUDIO_FLAC_SUPPORT
107#ifdef USE_AUDIO_OPUS_SUPPORT
118 size_t samples_to_scale) {
120 for (
size_t i = 0; i < samples_to_scale; i++) {
121 int32_t acc = (int32_t) audio_samples[i] * (int32_t) scale_factor;
122 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.
Providing packet encoding functions for exchanging data with a remote host.
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).