Specifying Buffers
Once the element attributes are specified, the application can allocate buffers from NvSciBuf using the attribute lists. It creates packets using the pool object, allocates a buffer for each element of each packet, and then assigns them to their proper places in the packets.
To create a new packet, the application calls
NvSciStreamPoolPacketCreate()
. The cookie is any non-zero value
that the application chooses to look up data structures for the packet. Typically, the
cookie is either a 1-based index into an array of structures or a pointer directly to
the structure. Any events received on the pool object related to the packet references
this cookie. On success, the function returns a new handle that the application stores
in its data structure for the packet and uses whenever it needs to tell the stream to
operate on the packet.
After creating a packet, the application assigns a buffer to each element by calling
NvSciStreamPoolPacketInsertBuffer()
. The packet handle is returned
at packet creation, and the index of the element is assigned the buffer handle, which
NvSciStream duplicates. Ownership of the original remains with the caller, and once the
function returns, it may safely free the buffer.
The application calls NvSciStreamPacketComplete()
to inform NvSciStream
finished assigning buffers for a packet.
When the application finished creating all packets and assigned all buffers, it calls
the NvSciStreamBlockSetupStatusSet()
function with a value of
NvSciStreamSetup_PacketExport
to indicate completion of packet
creation.
For static pools, the number of packets is specified when the pool is created. Streaming won't start until this number of packets is created. If the application tries to create more than this number of packets, an error occurs.
NvSciError
NvSciStreamPoolPacketCreate(
NvSciStreamBlock const pool,
NvSciStreamCookie const cookie,
NvSciStreamPacket *const handle
)
NvSciError
NvSciStreamPoolPacketInsertBuffer(
NvSciStreamBlock const pool,
NvSciStreamPacket const handle,
uint32_t const index,
NvSciBufObj const bufObj
)
NvSciError
NvSciStreamPoolPacketComplete(
NvSciStreamBlock const pool,
NvSciStreamPacket const handle
)