Obtaining Packets

When setup completes, the pool begins releasing the packets to the producer block for rendering. Subsequently, as payloads are returned from downstream because they were skipped or the consumer no longer needs them, they become available to the producer again. The order in which packets are received by the producer depends on various stream settings and is not deterministic, but the pool tries to optimize so that buffers with the least wait time until it is safe to write to them are available first.

When a packet becomes available for writing, a NvSciStreamEventType_PacketReady event is received by the producer block. The packet info is retrieved by a subsequent call. If multiple packets are available, the producer receives separate events for each of them.

After a packet becomes available, a producer application may call NvSciStreamProducerPacketGet() to obtain it. The cookie field is filled in with the cookie the producer assigned to the packet. With the packet handle, the producer application calls NvSciStreamBlockPacketFenceGet() to obtain the prefences for the packet elements. The prefence field points to the location that will be filled with the fence value indicating when the consumer indexed by queryBlockIndex is no longer using the data in the packet element’s buffer.


NvSciError
NvSciStreamProducerPacketGet(
    NvSciStreamBlock const   producer,
    NvSciStreamCookie *const cookie)

NvSciError
NvSciStreamBlockPacketFenceGet(
    NvSciStreamBlock const block,
    NvSciStreamPacket const handle,
    uint32_t const queryBlockIndex,
    uint32_t const elemIndex,
    NvSciSyncFence* const prefence
)