Late-attach/Re-attach Consumer

In a multicast stream, late consumers can connect to the stream that is already in the streaming phase. Any consumer disconnected from the stream can also re-connect, which is treated as a new late-attach consumer.

Start Streaming with Early-connected Consumers

The stream can proceed to the streaming phase, even if not all consumers are connected, by calling NvSciStreamBlockSetupStatusSet() with a value of NvSciStreamSetup_Connect on the multicast block. This API can be called multiple times when a new consumer is connected to the multicast block.

The producer and early connected consumers perform the initialization steps as usual. To ensure all consumers can use the NvSciBuf/NvSciSync objects allocated by the producer, the producer applications must allocate these objects satisfying the constraints of both early-connected and late-attach consumers.

The producer can get the total number of supported consumers by calling NvSciStreamBlockConsumerCountGet(). The producer does not need to know which consumer is connected. It just queries the NvSciSync objects and fences from all consumers as usual. A NULL NvSciSync object or an empty fence is returned if the consumer is not connected. The producer can skip those NULL objects or empty fences.

Attach Late Consumers

Upon the completion of the stream initialization with all the connected consumers, the multicast block is ready to handle new connected consumers after querying the NvSciStreamEventType_SetupComplete event. The producer can call NvSciStreamBlockSetupStatusSet() with a value of NvSciStreamSetup_Connect again to start initialization with the late-attached consumers. The early-connected consumers can continue streaming without being affected or even aware of those late-attach consumers.

The late-attached consumers perform the same initialization steps as early connected consumers.

The producer only receives NvSciStreamEventType_SignalObj event from the late-attach consumers. Because it does not know which consumer is newly connected, it needs to query the NvSciSync objects from all consumers. A NULL NvSciSync object is returned if it is not from the newly connected consumer.
  • If the retrieved sync object is NULL, then the producer can ignore it.
  • If the retrieved sync object is not NULL, then the producer should unregister the old sync object associated with this indexed consumer if any, and then register the new one.

After importing and mapping the sync objects from all late-attached consumers, the producer must call NvSciStreamBlockSetupStatusSet() with a value of NvSciStreamSetup_SignalObjImport.

Once the late-attach consumers complete all initialization steps, they can start streaming with the early-connected consumers.

Restrictions for Late-attach/Re-attach Consumer

  • Only one multicast block is allowed in the stream and must reside in the producer process.
  • No IpcSrc or IpcDst block can be connected between the producer block and the multicast block.
  • The new consumers can only be connected after all the existing consumers are in the streaming phase, not in the middle of initialization steps.
  • Late/re-attached consumers cannot send user-defined endpoint information to the producer.
  • If any late-attach consumer encounters an error or hangs during the initialization, all the late consumers that are involved in the initializations at that point must be disconnected and reconnected.