Base class of a buffer.
Buffer is the fundamental wrapper of data and metadata trunks that flows through the pipeline. Buffer is reference based and supports copying and moving, however both copying and moving only affects the reference and never transfers the data.
Definition at line 46 of file buffer.hpp.
Data Structures | |
struct | _Latency |
Unified definition of latency for a buffer. More... | |
Public Types | |
typedef struct deepstream::Buffer::_Latency | Latency |
Unified definition of latency for a buffer. More... | |
using | FreeFunction = void(*)(void *) |
Signature of customized function for freeing data in a buffer. More... | |
Public Member Functions | |
Buffer () | |
empty buffer constructor More... | |
Buffer (size_t length, void *data=nullptr, FreeFunction=nullptr) | |
New buffer constructor. More... | |
Buffer (const std::vector< uint8_t >) | |
New Buffer constructor. More... | |
Buffer (OpaqueBuffer *buffer) | |
New buffer constructor for OpaqueBuffer. More... | |
Buffer (const Buffer &) | |
Copy constructor. More... | |
Buffer (Buffer &&) | |
Move constructor. More... | |
Buffer & | operator= (const Buffer &) |
Copy assignment. More... | |
Buffer & | operator= (Buffer &&) |
Move assignment. More... | |
virtual | ~Buffer () |
Destructor. More... | |
operator bool () const | |
If the buffer is null. More... | |
size_t | size () const |
Size of the buffer in bytes. More... | |
uint64_t | timestamp () const |
Timestamp of the buffer. More... | |
int32_t | chunkId (unsigned int batchId) const |
Chunk id of the buffer. More... | |
std::vector< Latency > | measureLatency () const |
Return latency data of the buffer. More... | |
virtual size_t | read (std::function< size_t(const void *data, size_t len)> callable) |
Read data from the buffer. More... | |
virtual size_t | write (std::function< size_t(void *data, size_t len)> callable) |
Write data to the buffer. More... | |
OpaqueBuffer * | give () |
Give up the ownership of this buffer and return the opaque buffer pointer. More... | |
virtual size_t | batchSize () |
get the batch size of the buffer, 1 for un-batched buffer More... | |
virtual Tensor * | extract (unsigned int batchId) |
create a tensor object with the buffer data More... | |
Static Public Member Functions | |
static void | wrap (Tensor *) |
wrap the tensor to a new buffer More... | |
Protected Attributes | |
OpaqueBuffer * | buffer_ |
opaque buffer pointer More... | |
std::vector< int > | chunk_ids_ = { 0 } |
chunk ids, optional More... | |
using deepstream::Buffer::FreeFunction = void(*)(void*) |
Signature of customized function for freeing data in a buffer.
Definition at line 59 of file buffer.hpp.
typedef struct deepstream::Buffer::_Latency deepstream::Buffer::Latency |
Unified definition of latency for a buffer.
deepstream::Buffer::Buffer | ( | ) |
empty buffer constructor
deepstream::Buffer::Buffer | ( | size_t | length, |
void * | data = nullptr , |
||
FreeFunction | = nullptr |
||
) |
New buffer constructor.
Create a new buffer with given size. User can choose pass a raw data pointer or request the default allocation.
[in] | length | number of bytes used by the buffer |
[in] | data | if set null, default allocation will be used, otherwise, the buffer will take and own the provided pointer. |
deepstream::Buffer::Buffer | ( | const std::vector< uint8_t > | ) |
New Buffer constructor.
Create a new buffer from a byte vector, used by python mostly
[in] | bytes | byte vector |
deepstream::Buffer::Buffer | ( | OpaqueBuffer * | buffer | ) |
New buffer constructor for OpaqueBuffer.
Create a new buffer from a OpaqueBuffer, for professionals who understands how Buffer Wrapper works
[in] | buffer | pointer to a OpaqueBuffer |
deepstream::Buffer::Buffer | ( | const Buffer & | ) |
Copy constructor.
deepstream::Buffer::Buffer | ( | Buffer && | ) |
Move constructor.
|
virtual |
Destructor.
|
virtual |
get the batch size of the buffer, 1 for un-batched buffer
int32_t deepstream::Buffer::chunkId | ( | unsigned int | batchId | ) | const |
Chunk id of the buffer.
|
virtual |
create a tensor object with the buffer data
OpaqueBuffer* deepstream::Buffer::give | ( | ) |
Give up the ownership of this buffer and return the opaque buffer pointer.
Referenced by deepstream::EnsembleRender::consume().
std::vector<Latency> deepstream::Buffer::measureLatency | ( | ) | const |
Return latency data of the buffer.
Referenced by deepstream::NvDsMeasureLatency::handleBuffer().
deepstream::Buffer::operator bool | ( | ) | const |
If the buffer is null.
|
virtual |
Read data from the buffer.
[in] | callable | callable provided by the caller to collect data |
Reimplemented in deepstream::VideoBuffer.
size_t deepstream::Buffer::size | ( | ) | const |
Size of the buffer in bytes.
uint64_t deepstream::Buffer::timestamp | ( | ) | const |
Timestamp of the buffer.
|
static |
wrap the tensor to a new buffer
|
virtual |
Write data to the buffer.
[in] | callable | callable provided by the caller to inject data |
Reimplemented in deepstream::VideoBuffer.
Referenced by deepstream::FileDataSource::read().
|
protected |
opaque buffer pointer
Definition at line 164 of file buffer.hpp.
Referenced by deepstream::DS3DBuffer::DS3DBuffer().
|
protected |
chunk ids, optional
Definition at line 166 of file buffer.hpp.