esp32-audio-player 0.1.0
Audio player engine for ESP32
Loading...
Searching...
No Matches
decoder.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
8#pragma once
9
10#include "audio_player/audio.h"
11#include "audio_player/stream.h"
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
33
34const char *codec_name(codec_id_t id);
36
40bool codec_is_audio_extension(const char *ext);
41
49
50typedef struct decoder decoder_t;
51
53codec_id_t decoder_probe(core_stream_t *s, const char *path_hint);
54
57decoder_t *decoder_open(core_stream_t *s, const char *path_hint, decoder_info_t *info, int *err);
58
62int32_t decoder_read(decoder_t *d, int32_t *out, uint32_t max_frames);
63
65int decoder_seek(decoder_t *d, uint64_t frame);
66uint64_t decoder_tell(decoder_t *d);
69
70// ---------------------------------------------------------------------------
72// ---------------------------------------------------------------------------
73typedef struct {
76 bool (*probe)(const uint8_t *head, size_t head_len, const char *ext);
78 void *(*open)(core_stream_t *s, decoder_info_t *info, int *err);
79 int32_t (*read)(void *state, int32_t *out, uint32_t max_frames);
80 int (*seek)(void *state, uint64_t frame);
81 void (*close)(void *state);
83
84#ifdef __cplusplus
85}
86#endif
Audio formats and PCM conventions.
int32_t decoder_read(decoder_t *d, int32_t *out, uint32_t max_frames)
Decode up to max_frames frames into out (interleaved Q31, info.fmt.channels).
codec_id_t codec_from_extension(const char *ext)
Extension -> codec guess ("flac" -> CODEC_FLAC). Case-insensitive, no dot.
const decoder_info_t * decoder_info(const decoder_t *d)
bool codec_is_audio_extension(const char *ext)
True if the file extension is one we list in the browser (supported or planned).
const char * codec_name(codec_id_t id)
"FLAC", "MP3", ...
void decoder_close(decoder_t *d)
uint64_t decoder_tell(decoder_t *d)
current frame
decoder_t * decoder_open(core_stream_t *s, const char *path_hint, decoder_info_t *info, int *err)
Open a decoder.
int decoder_seek(decoder_t *d, uint64_t frame)
Seek to an absolute frame (after trimming). Returns CORE_OK or error.
bool codec_is_lossless(codec_id_t id)
codec_id_t decoder_probe(core_stream_t *s, const char *path_hint)
Probe the stream (position is restored). path_hint may be NULL.
struct decoder decoder_t
Definition decoder.h:50
codec_id_t
Definition decoder.h:17
@ CODEC_FLAC
Definition decoder.h:21
@ CODEC_AIFF
Definition decoder.h:20
@ CODEC_DSF
Definition decoder.h:29
@ CODEC_OPUS
Definition decoder.h:24
@ CODEC_MP3
Definition decoder.h:22
@ CODEC_ALAC
Definition decoder.h:26
@ CODEC_AAC
Definition decoder.h:25
@ CODEC_DFF
Definition decoder.h:30
@ CODEC_VORBIS
Definition decoder.h:23
@ CODEC_WAVPACK
Definition decoder.h:27
@ CODEC_COUNT
Definition decoder.h:31
@ CODEC_UNKNOWN
Definition decoder.h:18
@ CODEC_APE
Definition decoder.h:28
@ CODEC_WAV
Definition decoder.h:19
Byte streams used by decoders and tag parsers.
struct core_stream core_stream_t
Definition stream.h:14
Definition audio.h:23
Backend interface (for implementers of src/decoders/*.c).
Definition decoder.h:73
codec_id_t id
Definition decoder.h:74
Definition decoder.h:42
uint32_t bitrate_kbps
average, 0 if unknown
Definition decoder.h:46
bool seekable
Definition decoder.h:47
uint64_t total_frames
after gapless trimming; 0 if unknown
Definition decoder.h:45
audio_format_t fmt
output PCM format (dop=true for DSD via DoP)
Definition decoder.h:44
codec_id_t codec
Definition decoder.h:43