diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-08-09 11:22:08 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-08-09 11:22:08 +1000 |
| commit | 578c3737f8c07e543b90f964da0e89db1c18bb9a (patch) | |
| tree | 9463cef1108936bd25c76d17e5f0ea26a6412a36 /src/codecs/include/vorbis.hpp | |
| parent | f277bd5d0c6fdb9e2c125a2a6cc32675f87056cf (diff) | |
| download | tangara-fw-578c3737f8c07e543b90f964da0e89db1c18bb9a.tar.gz | |
Add vorbis support whilst we're here
Diffstat (limited to 'src/codecs/include/vorbis.hpp')
| -rw-r--r-- | src/codecs/include/vorbis.hpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/codecs/include/vorbis.hpp b/src/codecs/include/vorbis.hpp new file mode 100644 index 00000000..2804bb7c --- /dev/null +++ b/src/codecs/include/vorbis.hpp @@ -0,0 +1,58 @@ +/* + * Copyright 2023 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#pragma once + +#include <cstddef> +#include <cstdint> +#include <memory> +#include <optional> +#include <string> +#include <utility> + +#include "ivorbisfile.h" +#include "ogg.hpp" +#include "ogg/ogg.h" +#include "opus.h" +#include "sample.hpp" +#include "span.hpp" + +#include "codec.hpp" + +namespace codecs { + +class TremorVorbisDecoder : public ICodec { + public: + TremorVorbisDecoder(); + ~TremorVorbisDecoder(); + + /* + * Returns the output format for the next frame in the stream. MP3 streams + * may represent multiple distinct tracks, with different bitrates, and so we + * handle the stream only on a frame-by-frame basis. + */ + auto BeginStream(cpp::span<const std::byte>) -> Result<OutputFormat> override; + + /* + * Writes samples for the current frame. + */ + auto ContinueStream(cpp::span<const std::byte> input, + cpp::span<sample::Sample> output) + -> Result<OutputInfo> override; + + auto SeekStream(cpp::span<const std::byte> input, std::size_t target_sample) + -> Result<void> override; + + auto ReadCallback() -> cpp::span<const std::byte>; + auto AfterReadCallback(size_t bytes_read) -> void; + + private: + OggVorbis_File vorbis_; + cpp::span<const std::byte> input_; + size_t pos_in_input_; +}; + +} // namespace codecs |
