Files
nvsci_samples/event_sample_app/block_info.h
svcmobrel-release a3f1b7ea33 Updating prebuilts and/or headers
2eba699906039d6615aae4967f6ea79bfe44a40a - event_sample_app/block_pool.c
f3abb0a884f0647204ad32ff51255c4712e52120 - event_sample_app/Makefile
9ee49033e077ac5c8bf458a04c91dd3dbed9633d - event_sample_app/event_loop.h
b33adce6eb1bbc7af23f6c37b6a635479e18a66a - event_sample_app/block_returnsync.c
a56041c06b6bc1d3812b72b399d7d78dd7895485 - event_sample_app/block_limiter.c
ca34c957759f7a010f0cbbbf9bedc03a2c98092b - event_sample_app/block_c2c.c
8d6d0ec3aa8e374a1d2a5fedc9dd24ff7bbdb731 - event_sample_app/block_multicast.c
a76149a2531899e35843d939f60ad8979d8cf65f - event_sample_app/block_consumer_uc1.c
9da8763e4af4b4b7278507a3ebfe2c68a7a24585 - event_sample_app/util.h
2bf7e1383d6e8913c9b0a6a8bdd48fe63d8098d0 - event_sample_app/block_producer_uc1.c
a54abf82eaa2d888e379ab4596ba68ce264e80b5 - event_sample_app/block_info.h
080a6efe263be076c7046e70e31098c2bbed0f6d - event_sample_app/block_presentsync.c
7dd10e5ea71f0c4a09bbe1f9f148f67a13ee098c - event_sample_app/util.c
bc1a6f9017b28e5707c166a658a35e6b3986fdf4 - event_sample_app/usecase1.h
317f43efc59638bf1eae8303f0c79eafb059241a - event_sample_app/block_ipc.c
40361c8f0b68f7d5207db2466ce08c19c0bf1c90 - event_sample_app/event_loop_service.c
efad113d0107e5d8f90146f3102a7c0ed22f1a35 - event_sample_app/event_loop_threads.c
2908615cebcf36330b9850c57e8745bf324867b2 - event_sample_app/block_queue.c
36ed68eca1a7800cf0d94e763c9fc352ee8cda1e - event_sample_app/block_common.c
675f75d61bd0226625a8eaaf0e503c9e976c8d61 - event_sample_app/main.c
c3b26619dd07d221e953fc5dc29a50dcb95a8b97 - rawstream/Makefile
1fbb82e2281bb2e168c87fd20903bbed898ca160 - rawstream/rawstream_cuda.c
1d96498fe3c922f143f7e50e0a32b099714060ad - rawstream/rawstream_consumer.c
d077dafc9176686f6d081026225325c2a303a60e - rawstream/rawstream_producer.c
54ae655edddda7dcabe22fbf0b27c3f617978851 - rawstream/rawstream.h
d5ffeef3c7ad2af6f6f31385db7917b5ef9a7438 - rawstream/rawstream_ipc_linux.c
81e3d6f8ff5252797a7e9e170b74df6255f54f1b - rawstream/rawstream_main.c

Change-Id: I0f4e671693eb0addfe8d0e6532cc8f240cb6c778
2025-09-19 10:10:49 -07:00

285 lines
7.5 KiB
C

/*
* SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
*
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
* property and proprietary rights in and to this material, related
* documentation and any modifications thereto. Any use, reproduction,
* disclosure or distribution of this material and related documentation
* without an express license agreement from NVIDIA CORPORATION or
* its affiliates is strictly prohibited.
*/
/*
* NvSciStream Event Loop Driven Sample App - block abstraction
*/
#ifndef _BLOCK_INFO_H
#define _BLOCK_INFO_H 1
#include <stdatomic.h>
#include <pthread.h>
#include "nvscistream.h"
/* Maximum number of consumers */
#define MAX_CONSUMERS 4
/* Maximum number of blocks */
#define MAX_BLOCKS 100
/* Maximum number of packets supported */
#define MAX_PACKETS 32
/* Maximum number of elements supported */
#define MAX_ELEMS 8
/* Memory size of endpoint inforamtion */
#define INFO_SIZE 50
/* NvSci modules for all objects */
extern NvSciSyncModule sciSyncModule;
extern NvSciBufModule sciBufModule;
/* Flag used to terminate the thread that
* was spawned to handle the late/re-attached
* consumer connections upon stream disconnect
*/
extern atomic_int streamDone;
/* Number of registered blocks for streaming */
extern int32_t numBlocks;
/* Number of active blocks */
extern uint32_t numAlive;
/* variables for synchronization */
extern pthread_mutex_t mutex;
extern pthread_cond_t cond;
/* Thread for handling late/re-attached consumer
* connections
*/
extern pthread_t dispatchThread;
/* Common options for all blocks */
typedef struct {
/* Indicate whether the producer/consumer sets endpoint info */
bool endInfo;
/* Indicate whether the producer uses yuv format */
bool yuv;
/* Indicate whether the extern event service is used */
bool useExtEventService;
/* Indicates the number of late consumers for late/re-attach usecase */
uint32_t numLateConsumer;
/* Total number of consumers */
uint32_t numConsumer;
/* Indicates c2c usecase */
bool c2cMode;
/* Indicates consumer connection is late/reattach*/
bool lateAttach;
} CommonOptions;
extern CommonOptions opts;
/* Endpoint data structure for tracking the
* IPC/C2C channels
*/
typedef struct {
/* Holds the IPC endpoint corresponding to an IPC channel */
NvSciIpcEndpoint ipcEndpoint;
/* Holds the C2C endpoint corresponding to an C2C channel */
NvSciIpcEndpoint c2cEndpoint;
/* named IPC channel */
char ipcChannel[32];
/* named IPC channel used for handsking between
* producer and late/re-attached consumer connection
*/
char ipcChannelForHandshake[32];
/* named c2c channel */
char c2cChannel[32];
/* IPC/C2C block created for handling the late/re-attached
* consumer connections*/
NvSciStreamBlock ipcBlock;
/* Queue block that is needed for c2c usecase for a c2c
* consumer late/reattach connections
*/
NvSciStreamBlock queue;
/* ReturnSync block that is needed for c2c usecase for a c2c
* consumer late/reattach connections
*/
NvSciStreamBlock returnSync;
/* Indicates the connect state of IPC channel */
bool ipcConnected;
/* Indicates the connect state of C2C channel */
bool c2cConnected;
/* Indicates the Open state of IPC channel */
bool ipcOpened;
/* Indicates the Open state of C2C channel */
bool c2cOpened;
/* QNX channel ID for communication */
int32_t chid;
/* QNX channel connection ID */
int32_t coid;
} Endpoint;
extern Endpoint ipcEP[MAX_CONSUMERS];
typedef struct {
/* The application's name for the element */
uint32_t userName;
/* Attribute list for element */
NvSciBufAttrList attrList;
} ElemAttr;
/*
* Some block types that do not require direct interaction will share a
* common private data structure and event handling functon.
*/
/* Common block private data */
typedef struct {
NvSciStreamBlock block;
int64_t waitTime;
char name[32];
void (*deleteFunc)(void*);
} BlockData;
typedef int32_t (*BlockFunc)(void* data, uint32_t wait);
/* Structure to track block info */
typedef struct {
NvSciStreamBlock handle;
void* data;
BlockFunc func;
NvSciEventNotifier* notifier;
bool isAlive;
bool retry;
} BlockEventData;
extern BlockEventData blocks[MAX_BLOCKS];
extern BlockEventData* blocksAlive[MAX_BLOCKS];
/* Create data structure for common blocks */
extern BlockData* createCommon(
char const* name,
size_t size);
/* Handle event for common block */
extern int32_t handleCommon(
void* data,
uint32_t wait);
/* Delete common block */
extern void deleteCommon(
void* data);
/*
* Functions for setting up each kind of block
*/
extern int32_t createIpcDst(
NvSciStreamBlock* ipcDst,
const char* channel,
bool useExternalEventService);
extern int32_t createIpcSrc(
NvSciStreamBlock* ipcSrc,
const char* channel,
bool useExternalEventService);
extern int32_t createIpcSrc2(
NvSciStreamBlock* ipcsrc,
NvSciIpcEndpoint endpoint,
bool useExtEventService);
extern int32_t createC2cSrc2(
NvSciStreamBlock* c2cSrc,
NvSciIpcEndpoint endpoint,
NvSciStreamBlock queue);
extern int32_t createC2cDst(
NvSciStreamBlock* c2cDst,
const char* channel,
NvSciStreamBlock pool);
extern int32_t createC2cSrc(
NvSciStreamBlock* c2cSrc,
const char* channel,
NvSciStreamBlock queue);
extern int32_t createLimiter(
NvSciStreamBlock* limiter,
uint32_t limit);
extern int32_t createPresentSync(
NvSciStreamBlock* presentSync);
extern int32_t createReturnSync(
NvSciStreamBlock* returnSync);
extern int32_t createMulticast(
NvSciStreamBlock* multicast,
uint32_t numConsumer);
extern int32_t createPool_Common(
NvSciStreamBlock* pool,
uint32_t numPacket,
bool isC2cPool);
extern int32_t createQueue(
NvSciStreamBlock* queue,
uint32_t useMailbox);
extern int32_t (*createProducer)(
NvSciStreamBlock* producer,
NvSciStreamBlock pool,
uint32_t numFrames);
extern int32_t (*createConsumer)(
NvSciStreamBlock* consumer,
NvSciStreamBlock queue,
uint32_t index,
uint32_t frames);
extern int32_t (createProducer_Usecase1)(
NvSciStreamBlock* producer,
NvSciStreamBlock pool,
uint32_t numFrames);
extern int32_t (createConsumer_Usecase1)(
NvSciStreamBlock* consumer,
NvSciStreamBlock queue,
uint32_t index,
uint32_t frames);
extern int32_t (createProducer_Usecase2)(
NvSciStreamBlock* producer,
NvSciStreamBlock pool,
uint32_t numFrames);
extern int32_t (createConsumer_Usecase2)(
NvSciStreamBlock* consumer,
NvSciStreamBlock queue,
uint32_t index,
uint32_t frames);
extern int32_t(createProducer_Usecase3)(
NvSciStreamBlock* producer,
NvSciStreamBlock pool,
uint32_t numFrames);
extern int32_t(createConsumer_Usecase3)(
NvSciStreamBlock* consumer,
NvSciStreamBlock queue,
uint32_t index,
uint32_t frames);
extern int32_t createPool_Usecase3(
NvSciStreamBlock* pool,
uint32_t numPacket,
bool isC2cPool);
extern void* handleLateConsumerThreadFunc(void*);
#endif // _BLOCK_INFO_H