diff options
| author | jacqueline <me@jacqueline.id.au> | 2022-11-21 14:46:32 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2022-11-21 14:46:32 +1100 |
| commit | 9f8cfaa7a8abd885785830e03d7c417e856b8a22 (patch) | |
| tree | 4077bb707efdcf0704287a8724d593eb05ba12c3 /src/codecs/include/codec.hpp | |
| parent | 5f7444d7956a6cc517ada1b8b96c4f9cdd408fd5 (diff) | |
| download | tangara-fw-9f8cfaa7a8abd885785830e03d7c417e856b8a22.tar.gz | |
Implement using libmad to decode
Diffstat (limited to 'src/codecs/include/codec.hpp')
| -rw-r--r-- | src/codecs/include/codec.hpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/codecs/include/codec.hpp b/src/codecs/include/codec.hpp index 5e8763a6..99e786d5 100644 --- a/src/codecs/include/codec.hpp +++ b/src/codecs/include/codec.hpp @@ -1,5 +1,6 @@ #pragma once +#include <stdint.h> #include <cstddef> #include <cstdint> @@ -7,7 +8,9 @@ namespace codecs { - enum CreateCodecError {}; + enum CreateCodecError { + UNKNOWN_EXTENSION + }; auto CreateCodecForExtension(std::string extension) -> cpp::result<std::unique_ptr<ICodec>, CreateCodecError>; @@ -17,13 +20,39 @@ namespace codecs { virtual auto CanHandleExtension(std::string extension) -> bool = 0; + struct OutputFormat { + uint8_t num_channels; + uint8_t bits_per_sample; + int sample_rate_hz; + }; + + virtual auto GetOutputFormat() -> OutputFormat = 0; + enum Error {}; + struct Result { + bool need_more_input; + /* + * For need_more_input, this is how far we got in the input buffer + * before we were unable to process more data. Any remaining data in the + * buffer should be moved to the start before the next call. + */ + std::size_t input_processed; + + bool flush_output; + /* + * For flush_output, this is how far we got in the output buffer before + * we ran out of space for samples. The caller should flush this many + * bytes downstream. + */ + std::size_t output_written; + }; + virtual auto Process( uint8_t *input, std::size_t input_len, uint8_t *output, - std::size_t output_length) -> cpp::result<size_t, Error> = 0; + std::size_t output_length) -> cpp::result<Result, Error> = 0; }; } // namespace codecs |
