Fork of Tangara with customizations
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
tangara-fw/src/codecs/include/source_buffer.hpp

38 lines
762 B

/*
* 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;
auto Empty() -> 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