NVIDIA DeepStream SDK API Reference

7.0 Release
deepstream_app.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2018-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4  *
5  * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
6  * property and proprietary rights in and to this material, related
7  * documentation and any modifications thereto. Any use, reproduction,
8  * disclosure or distribution of this material and related documentation
9  * without an express license agreement from NVIDIA CORPORATION or
10  * its affiliates is strictly prohibited.
11  */
12 
13 #ifndef __NVGSTDS_APP_H__
14 #define __NVGSTDS_APP_H__
15 
16 #include <gst/gst.h>
17 #include <stdio.h>
18 
19 #include "deepstream_app_version.h"
20 #include "deepstream_common.h"
21 #include "deepstream_config.h"
22 #include "deepstream_osd.h"
23 #include "deepstream_segvisual.h"
24 #include "deepstream_perf.h"
25 #include "deepstream_preprocess.h"
26 #include "deepstream_primary_gie.h"
27 #include "deepstream_sinks.h"
28 #include "deepstream_sources.h"
29 #include "deepstream_streammux.h"
31 #include "deepstream_dsanalytics.h"
32 #include "deepstream_dsexample.h"
33 #include "deepstream_tracker.h"
36 #include "deepstream_c2d_msg.h"
37 #include "deepstream_image_save.h"
38 #include "gst-nvdscustommessage.h"
39 #include "gst-nvdscommonconfig.h"
40 
41 #ifdef __cplusplus
42 extern "C"
43 {
44 #endif
45 
46 typedef struct _AppCtx AppCtx;
47 
48 typedef void (*bbox_generated_callback) (AppCtx *appCtx, GstBuffer *buf,
49  NvDsBatchMeta *batch_meta, guint index);
50 typedef gboolean (*overlay_graphics_callback) (AppCtx *appCtx, GstBuffer *buf,
51  NvDsBatchMeta *batch_meta, guint index);
52 
53 typedef struct
54 {
55  guint index;
56  gulong all_bbox_buffer_probe_id;
57  gulong primary_bbox_buffer_probe_id;
59  GstElement *bin;
60  GstElement *tee;
61  GstElement *msg_conv;
69  NvDsSinkBin sink_bin;
73  AppCtx *appCtx;
75 
76 typedef struct
77 {
79  guint bus_id;
80  GstElement *pipeline;
81  NvDsSrcParentBin multi_src_bin;
83  NvDsInstanceBin demux_instance_bins[MAX_SOURCE_BINS];
84  NvDsInstanceBin common_elements;
85  GstElement *tiler_tee;
87  GstElement *demuxer;
89  AppCtx *appCtx;
90 } NvDsPipeline;
91 
92 typedef struct
93 {
94  gboolean enable_perf_measurement;
95  gint file_loop;
97  gboolean source_list_enabled;
98  guint total_num_sources;
99  guint num_source_sub_bins;
102  guint num_sink_sub_bins;
104  guint perf_measurement_interval_sec;
107  gchar *sei_uuid;
114 
115  gchar **uri_list;
116  gchar **sensor_id_list;
118  NvDsSourceConfig multi_source_config[MAX_SOURCE_BINS];
119  NvDsStreammuxConfig streammux_config;
123  NvDsPreProcessConfig secondary_preprocess_sub_bin_config[MAX_SECONDARY_PREPROCESS_BINS];
126  NvDsGieConfig secondary_gie_sub_bin_config[MAX_SECONDARY_GIE_BINS];
127  NvDsSinkSubBinConfig sink_bin_sub_bin_config[MAX_SINK_BINS];
134 
139  gchar* http_ip;
140  gchar* http_port;
143 
148 } NvDsConfig;
149 
150 typedef struct
151 {
152  gulong frame_num;
154 
155 struct _AppCtx
156 {
157  gboolean version;
158  gboolean cintr;
159  gboolean show_bbox_text;
160  gboolean seeking;
161  gboolean quit;
164  gint return_value;
165  guint index;
167 
168  GMutex app_lock;
169  GCond app_cond;
170 
181  GMutex latency_lock;
185 
189  GHashTable *sensorInfoHash;
190 };
191 
207 gboolean create_pipeline (AppCtx * appCtx,
208  bbox_generated_callback bbox_generated_post_analytics_cb,
209  bbox_generated_callback all_bbox_generated_cb,
210  perf_callback perf_cb,
211  overlay_graphics_callback overlay_graphics_cb);
212 
213 gboolean pause_pipeline (AppCtx * appCtx);
214 gboolean resume_pipeline (AppCtx * appCtx);
215 gboolean seek_pipeline (AppCtx * appCtx, glong milliseconds, gboolean seek_is_relative);
216 
217 void toggle_show_bbox_text (AppCtx * appCtx);
218 
219 void destroy_pipeline (AppCtx * appCtx);
220 void restart_pipeline (AppCtx * appCtx);
221 
222 
231 gboolean
232 parse_config_file (NvDsConfig * config, gchar * cfg_file_path);
233 
242 gboolean
243 parse_config_file_yaml (NvDsConfig * config, gchar * cfg_file_path);
244 
259 NvDsSensorInfo* get_sensor_info(AppCtx* appCtx, guint source_id);
260 
261 #ifdef __cplusplus
262 }
263 #endif
264 
265 #endif
NvDsPrimaryGieBin
Definition: deepstream_primary_gie.h:23
NvDsSegVisualBin
Definition: deepstream_segvisual.h:23
enable_perf_measurement
gboolean enable_perf_measurement(NvDsAppPerfStructInt *str, GstPad *sink_bin_pad, guint num_sources, gulong interval_sec, guint num_surfaces_per_frame, perf_callback callback)
_AppCtx::quit
gboolean quit
Definition: deepstream_audio.h:84
create_pipeline
gboolean create_pipeline(AppCtx *appCtx, bbox_generated_callback bbox_generated_post_analytics_cb, bbox_generated_callback all_bbox_generated_cb, perf_callback perf_cb, overlay_graphics_callback overlay_graphics_cb)
Create DS Anyalytics Pipeline per the appCtx configurations.
NvDsC2DContext
Definition: deepstream_c2d_msg.h:25
deepstream_tracker.h
NvDsConfig::global_gpu_id
gint global_gpu_id
To set Global GPU ID for all the componenents at once if needed This will be used in case gpu_id prop...
Definition: deepstream_app.h:147
deepstream_streammux.h
NvDsConfig::low_latency_mode
gboolean low_latency_mode
Definition: deepstream_app.h:108
_AppCtx::all_bbox_generated_cb
bbox_generated_callback all_bbox_generated_cb
Definition: deepstream_app.h:178
NvDsInstanceBin::secondary_gie_bin
NvDsSecondaryGieBin secondary_gie_bin
Definition: deepstream_app.h:66
NvDsConfig::reid_track_dir_path
gchar * reid_track_dir_path
Definition: deepstream_app.h:111
get_sensor_info
NvDsSensorInfo * get_sensor_info(AppCtx *appCtx, guint source_id)
Function to procure the NvDsSensorInfo for the source_id that was added using the nvmultiurisrcbin RE...
AppCtx
REST server application context.
Definition: nvds_appctx_server.h:46
perf_callback
void(* perf_callback)(gpointer ctx, NvDsAppPerfStruct *str)
Definition: deepstream_perf.h:52
deepstream_secondary_preprocess.h
NvDsPreProcessConfig
Definition: deepstream_preprocess.h:23
_AppCtx::ota_watch_desc
guint ota_watch_desc
Definition: deepstream_app.h:184
deepstream_dsexample.h
_AppCtx::c2d_ctx
NvDsC2DContext * c2d_ctx[MAX_MESSAGE_CONSUMERS]
Definition: deepstream_app.h:175
NvDsPipeline
Definition: deepstream_audio.h:51
deepstream_app_version.h
_AppCtx::app_lock
GMutex app_lock
Definition: deepstream_audio.h:90
NvDsSinkSubBinConfig
Definition: deepstream_sinks.h:129
MAX_SECONDARY_GIE_BINS
#define MAX_SECONDARY_GIE_BINS
Definition: deepstream_config.h:86
NvDsConfig::num_secondary_preprocess_sub_bins
guint num_secondary_preprocess_sub_bins
Definition: deepstream_app.h:101
parse_config_file
gboolean parse_config_file(NvDsConfig *config, gchar *cfg_file_path)
Function to read properties from configuration file.
_AppCtx::active_source_index
gint active_source_index
Definition: deepstream_app.h:166
_AppCtx::ota_inotify_fd
guint ota_inotify_fd
Definition: deepstream_app.h:183
NvDsConfig::segvisual_config
NvDsSegVisualConfig segvisual_config
Definition: deepstream_app.h:121
NvDsConfig::kitti_track_dir_path
gchar * kitti_track_dir_path
Definition: deepstream_app.h:110
NvDsConfig::bbox_dir_path
gchar * bbox_dir_path
Definition: deepstream_app.h:109
NvDsAppPerfStructInt
Definition: deepstream_perf.h:64
parse_config_file_yaml
gboolean parse_config_file_yaml(NvDsConfig *config, gchar *cfg_file_path)
Function to read properties from YML configuration file.
NvDsInstanceBin::dsexample_bin
NvDsDsExampleBin dsexample_bin
Definition: deepstream_app.h:72
NvDsImageSave
Definition: deepstream_image_save.h:21
NvDsDsExampleBin
Definition: deepstream_dsexample.h:40
overlay_graphics_callback
gboolean(* overlay_graphics_callback)(AppCtx *appCtx, GstBuffer *buf, NvDsBatchMeta *batch_meta, guint index)
Definition: deepstream_app.h:50
NvDsInstanceBin::dsanalytics_bin
NvDsDsAnalyticsBin dsanalytics_bin
Definition: deepstream_app.h:71
NvDsInstanceBin::demux_sink_bin
NvDsSinkBin demux_sink_bin
Definition: deepstream_app.h:70
NvDsFrameLatencyInfo
Holds information about the latency of a given frame.
Definition: nvds_latency_meta.h:83
_AppCtx::latency_info
NvDsFrameLatencyInfo * latency_info
Definition: deepstream_app.h:180
bbox_generated_callback
void(* bbox_generated_callback)(AppCtx *appCtx, GstBuffer *buf, NvDsBatchMeta *batch_meta, guint index)
Definition: deepstream_app.h:48
_AppCtx::return_value
gint return_value
Definition: deepstream_audio.h:87
_AppCtx::version
gboolean version
Definition: deepstream_audio.h:81
NvDsSegVisualConfig
Definition: deepstream_segvisual.h:33
deepstream_image_save.h
NvDsConfig::source_attr_all_config
NvDsSourceConfig source_attr_all_config
Definition: deepstream_app.h:142
NvDsDsExampleConfig
Definition: deepstream_dsexample.h:23
toggle_show_bbox_text
void toggle_show_bbox_text(AppCtx *appCtx)
NvDsPreProcessBin
Definition: deepstream_preprocess.h:34
deepstream_config.h
_AppCtx::overlay_graphics_cb
overlay_graphics_callback overlay_graphics_cb
Definition: deepstream_app.h:179
NvDsConfig::tracker_config
NvDsTrackerConfig tracker_config
Definition: deepstream_app.h:125
NvDsSinkMsgConvBrokerConfig
Definition: deepstream_sinks.h:104
NvDsInstanceBin::msg_conv
GstElement * msg_conv
Definition: deepstream_app.h:61
NvDsPipeline::tiled_display_bin
NvDsTiledDisplayBin tiled_display_bin
Definition: deepstream_app.h:86
NvDsConfig::num_secondary_gie_sub_bins
guint num_secondary_gie_sub_bins
Definition: deepstream_app.h:100
NvDsTiledDisplayBin
Definition: deepstream_tiled_display.h:24
deepstream_sinks.h
_AppCtx
Definition: deepstream_audio.h:79
NvDsConfig::extract_sei_type5_data
gboolean extract_sei_type5_data
Definition: deepstream_app.h:106
NvDsConfig::pipeline_recreate_sec
gint pipeline_recreate_sec
Definition: deepstream_app.h:96
_AppCtx::ota_handler_thread
GThread * ota_handler_thread
Definition: deepstream_app.h:182
NvDsDsAnalyticsBin
Definition: deepstream_dsanalytics.h:33
NvDsConfig::terminated_track_output_path
gchar * terminated_track_output_path
Definition: deepstream_app.h:112
deepstream_primary_gie.h
NvDsDsAnalyticsConfig
Definition: deepstream_dsanalytics.h:23
_AppCtx::perf_struct
NvDsAppPerfStructInt perf_struct
Definition: deepstream_audio.h:95
_AppCtx::person_class_id
gint person_class_id
Definition: deepstream_app.h:162
NvDsConfig::primary_gie_config
NvDsGieConfig primary_gie_config
Definition: deepstream_app.h:124
deepstream_common.h
NvDsConfig::sei_uuid
gchar * sei_uuid
Definition: deepstream_app.h:107
NvDsConfig::sensor_name_list
gchar ** sensor_name_list
Definition: deepstream_app.h:117
deepstream_osd.h
_AppCtx::pipeline
NvDsPipeline pipeline
Definition: deepstream_audio.h:93
_AppCtx::seeking
gboolean seeking
Definition: deepstream_audio.h:83
_AppCtx::sensorInfoHash
GHashTable * sensorInfoHash
Hash table to save NvDsSensorInfo obtained with REST API stream/add, remove operations The key is sou...
Definition: deepstream_app.h:189
NvDsPipeline::primary_bbox_buffer_probe_id
gulong primary_bbox_buffer_probe_id
Definition: deepstream_app.h:78
NvDsSourceConfig
Definition: deepstream_sources.h:38
_AppCtx::bbox_generated_post_analytics_cb
bbox_generated_callback bbox_generated_post_analytics_cb
Definition: deepstream_audio.h:85
NvDsPipeline::dsexample_bin
NvDsDsExampleBin dsexample_bin
Definition: deepstream_app.h:88
_NvDsBatchMeta
Holds information about a formed batch containing frames from different sources.
Definition: nvdsmeta.h:241
NvDsConfig::sensor_id_list
gchar ** sensor_id_list
Definition: deepstream_app.h:116
deepstream_c2d_msg.h
MAX_MESSAGE_CONSUMERS
#define MAX_MESSAGE_CONSUMERS
Definition: deepstream_config.h:88
NvDsConfig::http_port
gchar * http_port
Definition: deepstream_app.h:140
NvDsConfig::stream_name_display
gboolean stream_name_display
Definition: deepstream_app.h:137
NvDsConfig::dsanalytics_config
NvDsDsAnalyticsConfig dsanalytics_config
Definition: deepstream_app.h:130
NvDsPipeline::tiler_tee
GstElement * tiler_tee
Definition: deepstream_app.h:85
NvDsConfig::http_ip
gchar * http_ip
Definition: deepstream_app.h:139
destroy_pipeline
void destroy_pipeline(AppCtx *appCtx)
NvDsTiledDisplayConfig
Definition: deepstream_tiled_display.h:44
NvDsTrackerBin
Definition: deepstream_tracker.h:45
deepstream_perf.h
NvDsInstanceBin
Definition: deepstream_audio.h:39
NvDsOSDBin
Definition: deepstream_osd.h:25
NvDsInstanceBin::preprocess_bin
NvDsPreProcessBin preprocess_bin
Definition: deepstream_app.h:62
_AppCtx::instance_data
NvDsInstanceData instance_data[MAX_SOURCE_BINS]
Definition: deepstream_app.h:174
_AppCtx::app_cond
GCond app_cond
Definition: deepstream_audio.h:91
deepstream_sources.h
deepstream_secondary_gie.h
_AppCtx::latency_lock
GMutex latency_lock
Definition: deepstream_app.h:181
_AppCtx::override_config
NvDsConfig override_config
Definition: deepstream_app.h:173
NvDsStreammuxConfig
Definition: deepstream_streammux.h:23
NvDsInstanceData
Definition: deepstream_app.h:150
NvDsPipeline::demuxer
GstElement * demuxer
Definition: deepstream_app.h:87
NvDsConfig
Definition: deepstream_audio.h:62
NvDsConfig::sgie_batch_size
guint sgie_batch_size
Definition: deepstream_app.h:105
_NvDsSensorInfo
Definition: libs/gstnvdscustomhelper/gst-nvdscommonconfig.h:62
NvDsGieConfig
Definition: deepstream_gie.h:33
resume_pipeline
gboolean resume_pipeline(AppCtx *appCtx)
NvDsInstanceBin::primary_gie_bin
NvDsPrimaryGieBin primary_gie_bin
Definition: deepstream_app.h:63
deepstream_preprocess.h
_AppCtx::show_bbox_text
gboolean show_bbox_text
Definition: deepstream_app.h:159
NvDsConfig::max_batch_size
guint max_batch_size
Definition: deepstream_app.h:138
_AppCtx::car_class_id
gint car_class_id
Definition: deepstream_app.h:163
MAX_SECONDARY_PREPROCESS_BINS
#define MAX_SECONDARY_PREPROCESS_BINS
Definition: deepstream_config.h:87
NvDsSecondaryPreProcessBin
Definition: deepstream_secondary_preprocess.h:35
NvDsConfig::use_nvmultiurisrcbin
gboolean use_nvmultiurisrcbin
To support nvmultiurisrcbin.
Definition: deepstream_app.h:136
MAX_SINK_BINS
#define MAX_SINK_BINS
Definition: deepstream_config.h:85
deepstream_segvisual.h
NvDsInstanceBin::secondary_preprocess_bin
NvDsSecondaryPreProcessBin secondary_preprocess_bin
Definition: deepstream_app.h:67
NvDsConfig::image_save_config
NvDsImageSave image_save_config
Definition: deepstream_app.h:133
NvDsSrcParentBin
Definition: deepstream_sources.h:147
GstBuffer
struct _GstBuffer GstBuffer
Definition: idatatype.h:19
NvDsConfig::preprocess_config
NvDsPreProcessConfig preprocess_config
Definition: deepstream_app.h:122
NvDsConfig::dsexample_config
NvDsDsExampleConfig dsexample_config
Definition: deepstream_app.h:131
NvDsTrackerConfig
Definition: deepstream_tracker.h:25
NvDsInstanceData::frame_num
gulong frame_num
Definition: deepstream_app.h:152
NvDsMsgConsumerConfig
Definition: deepstream_c2d_msg.h:36
NvDsSecondaryGieBin
Definition: deepstream_secondary_gie.h:34
NvDsConfig::num_message_consumers
guint num_message_consumers
Definition: deepstream_app.h:103
deepstream_dsanalytics.h
MAX_SOURCE_BINS
#define MAX_SOURCE_BINS
Definition: deepstream_config.h:84
NvDsConfig::tiled_display_config
NvDsTiledDisplayConfig tiled_display_config
Definition: deepstream_app.h:129
pause_pipeline
gboolean pause_pipeline(AppCtx *appCtx)
NvDsSinkBin
Definition: deepstream_sinks.h:156
NvDsConfig::shadow_track_output_path
gchar * shadow_track_output_path
Definition: deepstream_app.h:113
deepstream_tiled_display.h
NvDsOSDConfig
Definition: deepstream_osd.h:35
restart_pipeline
void restart_pipeline(AppCtx *appCtx)
NvDsInstanceBin::osd_bin
NvDsOSDBin osd_bin
Definition: deepstream_app.h:64
NvDsInstanceBin::tracker_bin
NvDsTrackerBin tracker_bin
Definition: deepstream_app.h:68
_AppCtx::config
NvDsConfig config
Definition: deepstream_audio.h:94
_AppCtx::cintr
gboolean cintr
Definition: deepstream_audio.h:82
seek_pipeline
gboolean seek_pipeline(AppCtx *appCtx, glong milliseconds, gboolean seek_is_relative)
NvDsConfig::msg_conv_config
NvDsSinkMsgConvBrokerConfig msg_conv_config
Definition: deepstream_app.h:132
NvDsConfig::osd_config
NvDsOSDConfig osd_config
Definition: deepstream_app.h:120
NvDsConfig::source_attr_all_parsed
gboolean source_attr_all_parsed
Definition: deepstream_app.h:141
NvDsInstanceBin::segvisual_bin
NvDsSegVisualBin segvisual_bin
Definition: deepstream_app.h:65
_AppCtx::index
guint index
Definition: deepstream_audio.h:88
NvDsInstanceBin::fps_buffer_probe_id
gulong fps_buffer_probe_id
Definition: deepstream_app.h:58