17 #ifndef ADTF_FILE_DEFAULT_SAMPLE
18 #define ADTF_FILE_DEFAULT_SAMPLE
27 #include <unordered_map>
53 void iterateInfo(std::function<
void(uint32_t key,
DataType type, uint64_t raw_bytes)> functor)
const override;
60 const std::unordered_map<uint32_t, std::pair<DataType, uint64_t>>&
GetInfo()
const;
71 static_assert(std::is_trivially_copyable<T>::value,
"Only trivially copyable types are allowed.");
72 _buffer.resize(
sizeof(value));
73 memcpy(_buffer.data(), &value,
sizeof(value));
84 static_assert(std::is_trivially_copyable<T>::value,
"Only trivially copyable types are allowed.");
85 if (
sizeof(T) > _buffer.size())
87 throw std::runtime_error(
"invalid sample size for requested type");
89 return *
reinterpret_cast<const T*
>(_buffer.data());
93 std::chrono::nanoseconds _time_stamp = std::chrono::nanoseconds(0);
94 uint32_t _substream_id = 0;
96 std::vector<uint8_t> _buffer;
97 std::unordered_map<uint32_t, std::pair<DataType, uint64_t>> _info;
Default Sample implementation.
Definition: default_sample.h:38
const std::unordered_map< uint32_t, std::pair< DataType, uint64_t > > & GetInfo() const
Get the additional sample information.
const T & getContent() const
Get the Content of the sample for trivially copyable types.
Definition: default_sample.h:82
uint32_t getSubStreamId() const override
Get the Sub Stream Id if set.
std::chrono::nanoseconds getTimeStamp() const override
Get the Time Stamp.
void endBufferRead() const override
Ends reading from memory buffer retruned by beginBufferRead.
void setTimeStamp(std::chrono::nanoseconds time_stamp) override
Set the Time Stamp.
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:69
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.
void setSubStreamId(uint32_t substream_id) override
Set the Sub Stream Id, if needed.
void setFlags(uint32_t flags) override
Set the Flags.
std::pair< const void *, size_t > beginBufferRead() const override
Retrieve a pointer to the memory buffer for user data and size in bytes.
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
Interface class for samples that are read from a Reader.
Definition: sample.h:72
Sample base class.
Definition: stream_item.h:55
Interface class for samples that are written.
Definition: sample.h:114
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:32