17#ifndef ADTF_FILE_DEFAULT_SAMPLE
18#define ADTF_FILE_DEFAULT_SAMPLE
27#include <unordered_map>
54 void iterateInfo(std::function<
void(uint32_t key,
DataType type, uint64_t raw_bytes)> functor)
const override;
57 void CopyFrom(
const std::shared_ptr<const Sample>& sample)
override;
64 const std::unordered_map<uint32_t, std::pair<DataType, uint64_t>>&
GetInfo()
const;
75 static_assert(std::is_trivially_copyable<T>::value,
"Only trivially copyable types are allowed.");
77 std::memcpy(buffer, &value,
sizeof(value));
89 static_assert(std::is_trivially_copyable<T>::value,
"Only trivially copyable types are allowed.");
91 if (
sizeof(T) > buffer_size)
94 throw std::runtime_error(
"invalid sample size for requested type");
96 const auto value = *
reinterpret_cast<const T*
>(buffer);
102 std::chrono::nanoseconds _time_stamp = std::chrono::nanoseconds(0);
103 uint32_t _substream_id = 0;
105 std::variant<std::monostate, std::vector<uint8_t>, std::shared_ptr<const WriteSample>> _buffer;
106 std::unordered_map<uint32_t, std::pair<DataType, uint64_t>> _info;
Default Sample implementation.
Definition default_sample.h:39
uint32_t getSubStreamId() const override
Get the Sub Stream Id if set.
std::chrono::nanoseconds getTimeStamp() const override
Get the Time Stamp.
void CopyFrom(const std::shared_ptr< const Sample > &sample) override
void endBufferRead() const override
Ends reading from memory buffer retruned by beginBufferRead.
void setTimeStamp(std::chrono::nanoseconds time_stamp) override
Set the Time Stamp.
const std::unordered_map< uint32_t, std::pair< DataType, uint64_t > > & GetInfo() const
Get the additional sample information.
uint32_t getFlags() const override
Get the Flags.
void setContent(const T &value)
Set the Content of the sample for trivially copyable types.
Definition default_sample.h:73
void endBufferWrite() override
ends writing to the memory allocated with beginBufferWrite
void addInfo(uint32_t key, DataType type, uint64_t raw_bytes) override
Adds a additional sample information.
T getContent() const
Get the Content of the sample for trivially copyable types.
Definition default_sample.h:87
void setSubStreamId(uint32_t substream_id) override
Set the Sub Stream Id, if needed.
void setFlags(uint32_t flags) override
Set the Flags.
void iterateInfo(std::function< void(uint32_t key, DataType type, uint64_t raw_bytes)> functor) const override
iterates all additional data information (if any) by calling the functor
void * beginBufferWrite(size_t size) override
allocates the memory buffer for sample data
std::pair< const void *, size_t > beginBufferRead() const override
Retrieve a pointer to the memory buffer for user data and size in bytes.
Interface class for samples that are read from a Reader.
Definition sample.h:74
interface for copying the contents of one sample into another, probably sharing resources (such as th...
Definition sample.h:183
Sample base class.
Definition stream_item.h:55
Interface class for samples that are written.
Definition sample.h:116
namespace for ADTF File library
Definition adtf2_adtf_core_media_sample_deserializer.h:25
DataType
data type id for the adtf_file::ReadSample::addInfo call.
Definition sample.h:34