NVIDIA DeepStream SDK API Reference

7.1 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;
59  GstElement *bin;
60  GstElement *tee;
61  GstElement *msg_conv;
75 
76 typedef struct
77 {
79  guint bus_id;
80  GstElement *pipeline;
83  NvDsInstanceBin demux_instance_bins[MAX_SOURCE_BINS];
85  GstElement *tiler_tee;
87  GstElement *demuxer;
90 } NvDsPipeline;
91 
92 typedef struct
93 {
95  gint file_loop;
98  gboolean dummy_payload;
108  gchar *sei_uuid;
115 
116  gchar **uri_list;
117  gchar **sensor_id_list;
119  NvDsSourceConfig multi_source_config[MAX_SOURCE_BINS];
124  NvDsPreProcessConfig secondary_preprocess_sub_bin_config[MAX_SECONDARY_PREPROCESS_BINS];
127  NvDsGieConfig secondary_gie_sub_bin_config[MAX_SECONDARY_GIE_BINS];
128  NvDsSinkSubBinConfig sink_bin_sub_bin_config[MAX_SINK_BINS];
135 
140  gchar* http_ip;
141  gchar* http_port;
144 
149 } NvDsConfig;
150 
151 typedef struct
152 {
153  gulong frame_num;
155 
156 struct _AppCtx
157 {
158  gboolean version;
159  gboolean cintr;
160  gboolean show_bbox_text;
161  gboolean seeking;
162  gboolean quit;
166  guint index;
168 
169  GMutex app_lock;
170  GCond app_cond;
171 
182  GMutex latency_lock;
186 
190  GHashTable *sensorInfoHash;
191  gboolean eos_received;
192 };
193 
209 gboolean create_pipeline (AppCtx * appCtx,
210  bbox_generated_callback bbox_generated_post_analytics_cb,
211  bbox_generated_callback all_bbox_generated_cb,
212  perf_callback perf_cb,
213  overlay_graphics_callback overlay_graphics_cb);
214 
215 gboolean pause_pipeline (AppCtx * appCtx);
216 gboolean resume_pipeline (AppCtx * appCtx);
217 gboolean seek_pipeline (AppCtx * appCtx, glong milliseconds, gboolean seek_is_relative);
218 
219 void toggle_show_bbox_text (AppCtx * appCtx);
220 
221 void destroy_pipeline (AppCtx * appCtx);
222 void restart_pipeline (AppCtx * appCtx);
223 
224 
233 gboolean
234 parse_config_file (NvDsConfig * config, gchar * cfg_file_path);
235 
244 gboolean
245 parse_config_file_yaml (NvDsConfig * config, gchar * cfg_file_path);
246 
261 NvDsSensorInfo* get_sensor_info(AppCtx* appCtx, guint source_id);
262 
263 #ifdef __cplusplus
264 }
265 #endif
266 
267 #endif
NvDsPrimaryGieBin
Definition: deepstream_primary_gie.h:23
NvDsPipeline::common_elements
NvDsInstanceBin common_elements
Definition: deepstream_app.h:84
NvDsSegVisualBin
Definition: deepstream_segvisual.h:23
NvDsPipeline::multi_src_bin
NvDsSrcParentBin multi_src_bin
Definition: deepstream_app.h:81
_AppCtx::quit
gboolean quit
Definition: deepstream_app.h:162
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.
NvDsInstanceBin::sink_bin
NvDsSinkBin sink_bin
Definition: deepstream_app.h:69
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:148
deepstream_streammux.h
NvDsConfig::low_latency_mode
gboolean low_latency_mode
Definition: deepstream_app.h:109
_AppCtx::all_bbox_generated_cb
bbox_generated_callback all_bbox_generated_cb
Definition: deepstream_app.h:179
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:112
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
NvDsConfig::enable_perf_measurement
gboolean enable_perf_measurement
Definition: deepstream_app.h:94
NvDsPreProcessConfig
Definition: deepstream_preprocess.h:23
_AppCtx::ota_watch_desc
guint ota_watch_desc
Definition: deepstream_app.h:185
_AppCtx::eos_received
gboolean eos_received
Definition: deepstream_app.h:191
deepstream_dsexample.h
_AppCtx::c2d_ctx
NvDsC2DContext * c2d_ctx[MAX_MESSAGE_CONSUMERS]
Definition: deepstream_app.h:176
NvDsConfig::num_source_sub_bins
guint num_source_sub_bins
Definition: deepstream_app.h:100
NvDsInstanceBin::appCtx
AppCtx * appCtx
Definition: deepstream_app.h:73
NvDsPipeline
Definition: deepstream_app.h:76
deepstream_app_version.h
_AppCtx::app_lock
GMutex app_lock
Definition: deepstream_app.h:169
NvDsSinkSubBinConfig
Definition: deepstream_sinks.h:130
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:102
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:167
_AppCtx::ota_inotify_fd
guint ota_inotify_fd
Definition: deepstream_app.h:184
NvDsConfig::segvisual_config
NvDsSegVisualConfig segvisual_config
Definition: deepstream_app.h:122
NvDsConfig::kitti_track_dir_path
gchar * kitti_track_dir_path
Definition: deepstream_app.h:111
NvDsConfig::bbox_dir_path
gchar * bbox_dir_path
Definition: deepstream_app.h:110
NvDsInstanceBin::bin
GstElement * bin
Definition: deepstream_app.h:59
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
NvDsPipeline::bus_id
guint bus_id
Definition: deepstream_app.h:79
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:181
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_app.h:165
_AppCtx::version
gboolean version
Definition: deepstream_app.h:158
NvDsSegVisualConfig
Definition: deepstream_segvisual.h:33
deepstream_image_save.h
NvDsConfig::source_attr_all_config
NvDsSourceConfig source_attr_all_config
Definition: deepstream_app.h:143
NvDsDsExampleConfig
Definition: deepstream_dsexample.h:23
NvDsConfig::file_loop
gint file_loop
Definition: deepstream_app.h:95
NvDsConfig::source_list_enabled
gboolean source_list_enabled
Definition: deepstream_app.h:97
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:180
NvDsConfig::tracker_config
NvDsTrackerConfig tracker_config
Definition: deepstream_app.h:126
NvDsSinkMsgConvBrokerConfig
Definition: deepstream_sinks.h:105
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:101
NvDsTiledDisplayBin
Definition: deepstream_tiled_display.h:24
deepstream_sinks.h
_AppCtx
Definition: deepstream_app.h:156
NvDsConfig::extract_sei_type5_data
gboolean extract_sei_type5_data
Definition: deepstream_app.h:107
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:183
NvDsDsAnalyticsBin
Definition: deepstream_dsanalytics.h:33
NvDsConfig::terminated_track_output_path
gchar * terminated_track_output_path
Definition: deepstream_app.h:113
deepstream_primary_gie.h
NvDsDsAnalyticsConfig
Definition: deepstream_dsanalytics.h:23
NvDsInstanceBin::index
guint index
Definition: deepstream_app.h:55
_AppCtx::perf_struct
NvDsAppPerfStructInt perf_struct
Definition: deepstream_app.h:177
_AppCtx::person_class_id
gint person_class_id
Definition: deepstream_app.h:163
NvDsConfig::primary_gie_config
NvDsGieConfig primary_gie_config
Definition: deepstream_app.h:125
deepstream_common.h
NvDsConfig::sei_uuid
gchar * sei_uuid
Definition: deepstream_app.h:108
NvDsConfig::sensor_name_list
gchar ** sensor_name_list
Definition: deepstream_app.h:118
NvDsPipeline::pipeline
GstElement * pipeline
Definition: deepstream_app.h:80
deepstream_osd.h
_AppCtx::pipeline
NvDsPipeline pipeline
Definition: deepstream_app.h:172
_AppCtx::seeking
gboolean seeking
Definition: deepstream_app.h:161
_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:190
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_app.h:178
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:244
NvDsConfig::sensor_id_list
gchar ** sensor_id_list
Definition: deepstream_app.h:117
NvDsInstanceBin::tee
GstElement * tee
Definition: deepstream_app.h:60
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:141
NvDsConfig::stream_name_display
gboolean stream_name_display
Definition: deepstream_app.h:138
NvDsConfig::dsanalytics_config
NvDsDsAnalyticsConfig dsanalytics_config
Definition: deepstream_app.h:131
NvDsPipeline::tiler_tee
GstElement * tiler_tee
Definition: deepstream_app.h:85
NvDsConfig::http_ip
gchar * http_ip
Definition: deepstream_app.h:140
destroy_pipeline
void destroy_pipeline(AppCtx *appCtx)
NvDsTiledDisplayConfig
Definition: deepstream_tiled_display.h:44
NvDsTrackerBin
Definition: deepstream_tracker.h:45
deepstream_perf.h
NvDsPipeline::appCtx
AppCtx * appCtx
Definition: deepstream_app.h:89
NvDsInstanceBin
Definition: deepstream_app.h:53
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:175
_AppCtx::app_cond
GCond app_cond
Definition: deepstream_app.h:170
deepstream_sources.h
deepstream_secondary_gie.h
_AppCtx::latency_lock
GMutex latency_lock
Definition: deepstream_app.h:182
NvDsConfig::num_sink_sub_bins
guint num_sink_sub_bins
Definition: deepstream_app.h:103
_AppCtx::override_config
NvDsConfig override_config
Definition: deepstream_app.h:174
NvDsStreammuxConfig
Definition: deepstream_streammux.h:23
NvDsInstanceData
Definition: deepstream_app.h:151
NvDsPipeline::demuxer
GstElement * demuxer
Definition: deepstream_app.h:87
NvDsConfig
Definition: deepstream_app.h:92
NvDsConfig::sgie_batch_size
guint sgie_batch_size
Definition: deepstream_app.h:106
_NvDsSensorInfo
Definition: includes/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
NvDsConfig::dummy_payload
gboolean dummy_payload
Definition: deepstream_app.h:98
_AppCtx::show_bbox_text
gboolean show_bbox_text
Definition: deepstream_app.h:160
NvDsConfig::max_batch_size
guint max_batch_size
Definition: deepstream_app.h:139
_AppCtx::car_class_id
gint car_class_id
Definition: deepstream_app.h:164
MAX_SECONDARY_PREPROCESS_BINS
#define MAX_SECONDARY_PREPROCESS_BINS
Definition: deepstream_config.h:87
NvDsSecondaryPreProcessBin
Definition: deepstream_secondary_preprocess.h:35
NvDsInstanceBin::primary_bbox_buffer_probe_id
gulong primary_bbox_buffer_probe_id
Definition: deepstream_app.h:57
NvDsConfig::use_nvmultiurisrcbin
gboolean use_nvmultiurisrcbin
To support nvmultiurisrcbin.
Definition: deepstream_app.h:137
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:134
NvDsSrcParentBin
Definition: deepstream_sources.h:157
NvDsInstanceBin::all_bbox_buffer_probe_id
gulong all_bbox_buffer_probe_id
Definition: deepstream_app.h:56
GstBuffer
struct _GstBuffer GstBuffer
Definition: idatatype.h:19
NvDsConfig::preprocess_config
NvDsPreProcessConfig preprocess_config
Definition: deepstream_app.h:123
NvDsConfig::streammux_config
NvDsStreammuxConfig streammux_config
Definition: deepstream_app.h:120
NvDsConfig::dsexample_config
NvDsDsExampleConfig dsexample_config
Definition: deepstream_app.h:132
NvDsTrackerConfig
Definition: deepstream_tracker.h:25
NvDsInstanceData::frame_num
gulong frame_num
Definition: deepstream_app.h:153
NvDsMsgConsumerConfig
Definition: deepstream_c2d_msg.h:36
NvDsConfig::perf_measurement_interval_sec
guint perf_measurement_interval_sec
Definition: deepstream_app.h:105
NvDsSecondaryGieBin
Definition: deepstream_secondary_gie.h:34
NvDsConfig::num_message_consumers
guint num_message_consumers
Definition: deepstream_app.h:104
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:130
pause_pipeline
gboolean pause_pipeline(AppCtx *appCtx)
NvDsSinkBin
Definition: deepstream_sinks.h:157
NvDsConfig::shadow_track_output_path
gchar * shadow_track_output_path
Definition: deepstream_app.h:114
deepstream_tiled_display.h
NvDsConfig::total_num_sources
guint total_num_sources
Definition: deepstream_app.h:99
NvDsOSDConfig
Definition: deepstream_osd.h:35
restart_pipeline
void restart_pipeline(AppCtx *appCtx)
NvDsInstanceBin::osd_bin
NvDsOSDBin osd_bin
Definition: deepstream_app.h:64
NvDsConfig::uri_list
gchar ** uri_list
Definition: deepstream_app.h:116
NvDsInstanceBin::tracker_bin
NvDsTrackerBin tracker_bin
Definition: deepstream_app.h:68
_AppCtx::config
NvDsConfig config
Definition: deepstream_app.h:173
_AppCtx::cintr
gboolean cintr
Definition: deepstream_app.h:159
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:133
NvDsConfig::osd_config
NvDsOSDConfig osd_config
Definition: deepstream_app.h:121
NvDsConfig::source_attr_all_parsed
gboolean source_attr_all_parsed
Definition: deepstream_app.h:142
NvDsInstanceBin::segvisual_bin
NvDsSegVisualBin segvisual_bin
Definition: deepstream_app.h:65
_AppCtx::index
guint index
Definition: deepstream_app.h:166
NvDsInstanceBin::fps_buffer_probe_id
gulong fps_buffer_probe_id
Definition: deepstream_app.h:58