diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-08-10 15:33:00 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-08-10 15:33:00 +1000 |
| commit | d8fc77101dcf80a3643a00b3446dca1e390ce997 (patch) | |
| tree | 9e03881f3857c7b4c6a0b6e3a062947daecc69d1 /src/codecs/include/source_buffer.hpp | |
| parent | 67caeb6e3cda44205ba8fe783274b20dc7ea216e (diff) | |
| download | tangara-fw-d8fc77101dcf80a3643a00b3446dca1e390ce997.tar.gz | |
Give codecs complete control of their input files
Diffstat (limited to 'src/codecs/include/source_buffer.hpp')
| -rw-r--r-- | src/codecs/include/source_buffer.hpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/codecs/include/source_buffer.hpp b/src/codecs/include/source_buffer.hpp new file mode 100644 index 00000000..d0d7635a --- /dev/null +++ b/src/codecs/include/source_buffer.hpp @@ -0,0 +1,37 @@ +/* + * Copyright 2023 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#pragma once + +#include <cstddef> +#include <cstdint> +#include <functional> + +#include "span.hpp" + +#include "codec.hpp" + +namespace codecs { + +class SourceBuffer { + public: + SourceBuffer(); + ~SourceBuffer(); + + auto Refill(IStream* src) -> bool; + auto AddBytes(std::function<size_t(cpp::span<std::byte>)> writer) -> void; + auto ConsumeBytes(std::function<size_t(cpp::span<std::byte>)> reader) -> void; + + SourceBuffer(const SourceBuffer&) = delete; + SourceBuffer& operator=(const SourceBuffer&) = delete; + + private: + const cpp::span<std::byte> buffer_; + size_t bytes_in_buffer_; + size_t offset_of_bytes_; +}; + +} // namespace codecs |
