NVIDIA DeepStream SDK API Reference

6.4 Release
deepstream_app.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef __NVGSTDS_APP_H__
24 #define __NVGSTDS_APP_H__
25 
26 #include <gst/gst.h>
27 #include <stdio.h>
28 
29 #include "deepstream_app_version.h"
30 #include "deepstream_common.h"
31 #include "deepstream_config.h"
32 #include "deepstream_osd.h"
33 #include "deepstream_segvisual.h"
34 #include "deepstream_perf.h"
35 #include "deepstream_preprocess.h"
36 #include "deepstream_primary_gie.h"
37 #include "deepstream_sinks.h"
38 #include "deepstream_sources.h"
39 #include "deepstream_streammux.h"
41 #include "deepstream_dsanalytics.h"
42 #include "deepstream_dsexample.h"
43 #include "deepstream_tracker.h"
46 #include "deepstream_c2d_msg.h"
47 #include "deepstream_image_save.h"
48 #include "gst-nvdscustommessage.h"
49 #include "gst-nvdscommonconfig.h"
50 
51 #ifdef __cplusplus
52 extern "C"
53 {
54 #endif
55 
56 typedef struct _AppCtx AppCtx;
57 
58 typedef void (*bbox_generated_callback) (AppCtx *appCtx, GstBuffer *buf,
59  NvDsBatchMeta *batch_meta, guint index);
60 typedef gboolean (*overlay_graphics_callback) (AppCtx *appCtx, GstBuffer *buf,
61  NvDsBatchMeta *batch_meta, guint index);
62 
63 typedef struct
64 {
65  guint index;
66  gulong all_bbox_buffer_probe_id;
67  gulong primary_bbox_buffer_probe_id;
69  GstElement *bin;
70  GstElement *tee;
71  GstElement *msg_conv;
79  NvDsSinkBin sink_bin;
83  AppCtx *appCtx;
85 
86 typedef struct
87 {
89  guint bus_id;
90  GstElement *pipeline;
91  NvDsSrcParentBin multi_src_bin;
93  NvDsInstanceBin demux_instance_bins[MAX_SOURCE_BINS];
94  NvDsInstanceBin common_elements;
95  GstElement *tiler_tee;
97  GstElement *demuxer;
99  AppCtx *appCtx;
100 } NvDsPipeline;
101 
102 typedef struct
103 {
104  gboolean enable_perf_measurement;
105  gint file_loop;
107  gboolean source_list_enabled;
108  guint total_num_sources;
109  guint num_source_sub_bins;
112  guint num_sink_sub_bins;
114  guint perf_measurement_interval_sec;
121 
122  gchar **uri_list;
123  gchar **sensor_id_list;
125  NvDsSourceConfig multi_source_config[MAX_SOURCE_BINS];
126  NvDsStreammuxConfig streammux_config;
130  NvDsPreProcessConfig secondary_preprocess_sub_bin_config[MAX_SECONDARY_PREPROCESS_BINS];
133  NvDsGieConfig secondary_gie_sub_bin_config[MAX_SECONDARY_GIE_BINS];
134  NvDsSinkSubBinConfig sink_bin_sub_bin_config[MAX_SINK_BINS];
141 
146  gchar* http_ip;
147  gchar* http_port;
150 
155 } NvDsConfig;
156 
157 typedef struct
158 {
159  gulong frame_num;
161 
162 struct _AppCtx
163 {
164  gboolean version;
165  gboolean cintr;
166  gboolean show_bbox_text;
167  gboolean seeking;
168  gboolean quit;
171  gint return_value;
172  guint index;
174 
175  GMutex app_lock;
176  GCond app_cond;
177 
188  GMutex latency_lock;
192 
196  GHashTable *sensorInfoHash;
197 };
198 
214 gboolean create_pipeline (AppCtx * appCtx,
215  bbox_generated_callback bbox_generated_post_analytics_cb,
216  bbox_generated_callback all_bbox_generated_cb,
217  perf_callback perf_cb,
218  overlay_graphics_callback overlay_graphics_cb);
219 
220 gboolean pause_pipeline (AppCtx * appCtx);
221 gboolean resume_pipeline (AppCtx * appCtx);
222 gboolean seek_pipeline (AppCtx * appCtx, glong milliseconds, gboolean seek_is_relative);
223 
224 void toggle_show_bbox_text (AppCtx * appCtx);
225 
226 void destroy_pipeline (AppCtx * appCtx);
227 void restart_pipeline (AppCtx * appCtx);
228 
229 
238 gboolean
239 parse_config_file (NvDsConfig * config, gchar * cfg_file_path);
240 
249 gboolean
250 parse_config_file_yaml (NvDsConfig * config, gchar * cfg_file_path);
251 
266 NvDsSensorInfo* get_sensor_info(AppCtx* appCtx, guint source_id);
267 
268 #ifdef __cplusplus
269 }
270 #endif
271 
272 #endif
NvDsPrimaryGieBin
Definition: deepstream_primary_gie.h:33
NvDsSegVisualBin
Definition: deepstream_segvisual.h:34
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:94
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:35
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:154
deepstream_streammux.h
_AppCtx::all_bbox_generated_cb
bbox_generated_callback all_bbox_generated_cb
Definition: deepstream_app.h:185
NvDsInstanceBin::secondary_gie_bin
NvDsSecondaryGieBin secondary_gie_bin
Definition: deepstream_app.h:76
NvDsConfig::reid_track_dir_path
gchar * reid_track_dir_path
Definition: deepstream_app.h:118
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:57
perf_callback
void(* perf_callback)(gpointer ctx, NvDsAppPerfStruct *str)
Definition: deepstream_perf.h:60
deepstream_secondary_preprocess.h
NvDsPreProcessConfig
Definition: deepstream_preprocess.h:33
_AppCtx::ota_watch_desc
guint ota_watch_desc
Definition: deepstream_app.h:191
deepstream_dsexample.h
_AppCtx::c2d_ctx
NvDsC2DContext * c2d_ctx[MAX_MESSAGE_CONSUMERS]
Definition: deepstream_app.h:182
NvDsPipeline
Definition: deepstream_audio.h:61
deepstream_app_version.h
_AppCtx::app_lock
GMutex app_lock
Definition: deepstream_audio.h:100
NvDsSinkSubBinConfig
Definition: deepstream_sinks.h:137
MAX_SECONDARY_GIE_BINS
#define MAX_SECONDARY_GIE_BINS
Definition: deepstream_config.h:96
NvDsConfig::num_secondary_preprocess_sub_bins
guint num_secondary_preprocess_sub_bins
Definition: deepstream_app.h:111
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:173
_AppCtx::ota_inotify_fd
guint ota_inotify_fd
Definition: deepstream_app.h:190
NvDsConfig::segvisual_config
NvDsSegVisualConfig segvisual_config
Definition: deepstream_app.h:128
NvDsConfig::kitti_track_dir_path
gchar * kitti_track_dir_path
Definition: deepstream_app.h:117
NvDsConfig::bbox_dir_path
gchar * bbox_dir_path
Definition: deepstream_app.h:116
NvDsAppPerfStructInt
Definition: deepstream_perf.h:72
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:82
NvDsImageSave
Definition: deepstream_image_save.h:31
NvDsDsExampleBin
Definition: deepstream_dsexample.h:49
overlay_graphics_callback
gboolean(* overlay_graphics_callback)(AppCtx *appCtx, GstBuffer *buf, NvDsBatchMeta *batch_meta, guint index)
Definition: deepstream_app.h:60
NvDsInstanceBin::dsanalytics_bin
NvDsDsAnalyticsBin dsanalytics_bin
Definition: deepstream_app.h:81
NvDsInstanceBin::demux_sink_bin
NvDsSinkBin demux_sink_bin
Definition: deepstream_app.h:80
NvDsFrameLatencyInfo
Holds information about the latency of a given frame.
Definition: nvds_latency_meta.h:82
_AppCtx::latency_info
NvDsFrameLatencyInfo * latency_info
Definition: deepstream_app.h:187
bbox_generated_callback
void(* bbox_generated_callback)(AppCtx *appCtx, GstBuffer *buf, NvDsBatchMeta *batch_meta, guint index)
Definition: deepstream_app.h:58
_AppCtx::return_value
gint return_value
Definition: deepstream_audio.h:97
_AppCtx::version
gboolean version
Definition: deepstream_audio.h:91
NvDsSegVisualConfig
Definition: deepstream_segvisual.h:44
deepstream_image_save.h
NvDsConfig::source_attr_all_config
NvDsSourceConfig source_attr_all_config
Definition: deepstream_app.h:149
NvDsDsExampleConfig
Definition: deepstream_dsexample.h:33
toggle_show_bbox_text
void toggle_show_bbox_text(AppCtx *appCtx)
NvDsPreProcessBin
Definition: deepstream_preprocess.h:44
deepstream_config.h
_AppCtx::overlay_graphics_cb
overlay_graphics_callback overlay_graphics_cb
Definition: deepstream_app.h:186
NvDsConfig::tracker_config
NvDsTrackerConfig tracker_config
Definition: deepstream_app.h:132
NvDsSinkMsgConvBrokerConfig
Definition: deepstream_sinks.h:114
NvDsInstanceBin::msg_conv
GstElement * msg_conv
Definition: deepstream_app.h:71
NvDsPipeline::tiled_display_bin
NvDsTiledDisplayBin tiled_display_bin
Definition: deepstream_app.h:96
NvDsConfig::num_secondary_gie_sub_bins
guint num_secondary_gie_sub_bins
Definition: deepstream_app.h:110
NvDsTiledDisplayBin
Definition: deepstream_tiled_display.h:34
deepstream_sinks.h
_AppCtx
Definition: deepstream_audio.h:89
NvDsConfig::pipeline_recreate_sec
gint pipeline_recreate_sec
Definition: deepstream_app.h:106
_AppCtx::ota_handler_thread
GThread * ota_handler_thread
Definition: deepstream_app.h:189
NvDsDsAnalyticsBin
Definition: deepstream_dsanalytics.h:43
NvDsConfig::terminated_track_output_path
gchar * terminated_track_output_path
Definition: deepstream_app.h:119
deepstream_primary_gie.h
NvDsDsAnalyticsConfig
Definition: deepstream_dsanalytics.h:33
_AppCtx::perf_struct
NvDsAppPerfStructInt perf_struct
Definition: deepstream_audio.h:105
_AppCtx::person_class_id
gint person_class_id
Definition: deepstream_app.h:169
NvDsConfig::primary_gie_config
NvDsGieConfig primary_gie_config
Definition: deepstream_app.h:131
deepstream_common.h
NvDsConfig::sensor_name_list
gchar ** sensor_name_list
Definition: deepstream_app.h:124
deepstream_osd.h
_AppCtx::pipeline
NvDsPipeline pipeline
Definition: deepstream_audio.h:103
_AppCtx::seeking
gboolean seeking
Definition: deepstream_audio.h:93
_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:196
NvDsPipeline::primary_bbox_buffer_probe_id
gulong primary_bbox_buffer_probe_id
Definition: deepstream_app.h:88
NvDsSourceConfig
Definition: deepstream_sources.h:47
_AppCtx::bbox_generated_post_analytics_cb
bbox_generated_callback bbox_generated_post_analytics_cb
Definition: deepstream_audio.h:95
NvDsPipeline::dsexample_bin
NvDsDsExampleBin dsexample_bin
Definition: deepstream_app.h:98
_NvDsBatchMeta
Holds information about a formed batch containing frames from different sources.
Definition: nvdsmeta.h:240
NvDsConfig::sensor_id_list
gchar ** sensor_id_list
Definition: deepstream_app.h:123
deepstream_c2d_msg.h
MAX_MESSAGE_CONSUMERS
#define MAX_MESSAGE_CONSUMERS
Definition: deepstream_config.h:98
NvDsConfig::http_port
gchar * http_port
Definition: deepstream_app.h:147
NvDsConfig::stream_name_display
gboolean stream_name_display
Definition: deepstream_app.h:144
NvDsConfig::dsanalytics_config
NvDsDsAnalyticsConfig dsanalytics_config
Definition: deepstream_app.h:137
NvDsPipeline::tiler_tee
GstElement * tiler_tee
Definition: deepstream_app.h:95
NvDsConfig::http_ip
gchar * http_ip
Definition: deepstream_app.h:146
destroy_pipeline
void destroy_pipeline(AppCtx *appCtx)
NvDsTiledDisplayConfig
Definition: deepstream_tiled_display.h:54
NvDsTrackerBin
Definition: deepstream_tracker.h:54
deepstream_perf.h
NvDsInstanceBin
Definition: deepstream_audio.h:49
NvDsOSDBin
Definition: deepstream_osd.h:35
NvDsInstanceBin::preprocess_bin
NvDsPreProcessBin preprocess_bin
Definition: deepstream_app.h:72
_AppCtx::instance_data
NvDsInstanceData instance_data[MAX_SOURCE_BINS]
Definition: deepstream_app.h:181
_AppCtx::app_cond
GCond app_cond
Definition: deepstream_audio.h:101
deepstream_sources.h
deepstream_secondary_gie.h
_AppCtx::latency_lock
GMutex latency_lock
Definition: deepstream_app.h:188
_AppCtx::override_config
NvDsConfig override_config
Definition: deepstream_app.h:180
NvDsStreammuxConfig
Definition: deepstream_streammux.h:33
NvDsInstanceData
Definition: deepstream_app.h:157
NvDsPipeline::demuxer
GstElement * demuxer
Definition: deepstream_app.h:97
NvDsConfig
Definition: deepstream_audio.h:72
NvDsConfig::sgie_batch_size
guint sgie_batch_size
Definition: deepstream_app.h:115
_NvDsSensorInfo
Definition: libs/gstnvdscustomhelper/gst-nvdscommonconfig.h:73
NvDsGieConfig
Definition: deepstream_gie.h:43
resume_pipeline
gboolean resume_pipeline(AppCtx *appCtx)
NvDsInstanceBin::primary_gie_bin
NvDsPrimaryGieBin primary_gie_bin
Definition: deepstream_app.h:73
deepstream_preprocess.h
_AppCtx::show_bbox_text
gboolean show_bbox_text
Definition: deepstream_app.h:166
NvDsConfig::max_batch_size
guint max_batch_size
Definition: deepstream_app.h:145
_AppCtx::car_class_id
gint car_class_id
Definition: deepstream_app.h:170
MAX_SECONDARY_PREPROCESS_BINS
#define MAX_SECONDARY_PREPROCESS_BINS
Definition: deepstream_config.h:97
NvDsSecondaryPreProcessBin
Definition: deepstream_secondary_preprocess.h:45
NvDsConfig::use_nvmultiurisrcbin
gboolean use_nvmultiurisrcbin
To support nvmultiurisrcbin.
Definition: deepstream_app.h:143
MAX_SINK_BINS
#define MAX_SINK_BINS
Definition: deepstream_config.h:95
deepstream_segvisual.h
NvDsInstanceBin::secondary_preprocess_bin
NvDsSecondaryPreProcessBin secondary_preprocess_bin
Definition: deepstream_app.h:77
NvDsConfig::image_save_config
NvDsImageSave image_save_config
Definition: deepstream_app.h:140
NvDsSrcParentBin
Definition: deepstream_sources.h:155
GstBuffer
struct _GstBuffer GstBuffer
Definition: idatatype.h:19
NvDsConfig::preprocess_config
NvDsPreProcessConfig preprocess_config
Definition: deepstream_app.h:129
NvDsConfig::dsexample_config
NvDsDsExampleConfig dsexample_config
Definition: deepstream_app.h:138
NvDsTrackerConfig
Definition: deepstream_tracker.h:35
NvDsInstanceData::frame_num
gulong frame_num
Definition: deepstream_app.h:159
NvDsMsgConsumerConfig
Definition: deepstream_c2d_msg.h:46
NvDsSecondaryGieBin
Definition: deepstream_secondary_gie.h:44
NvDsConfig::num_message_consumers
guint num_message_consumers
Definition: deepstream_app.h:113
deepstream_dsanalytics.h
MAX_SOURCE_BINS
#define MAX_SOURCE_BINS
Definition: deepstream_config.h:94
NvDsConfig::tiled_display_config
NvDsTiledDisplayConfig tiled_display_config
Definition: deepstream_app.h:136
pause_pipeline
gboolean pause_pipeline(AppCtx *appCtx)
NvDsSinkBin
Definition: deepstream_sinks.h:164
NvDsConfig::shadow_track_output_path
gchar * shadow_track_output_path
Definition: deepstream_app.h:120
deepstream_tiled_display.h
NvDsOSDConfig
Definition: deepstream_osd.h:45
restart_pipeline
void restart_pipeline(AppCtx *appCtx)
NvDsInstanceBin::osd_bin
NvDsOSDBin osd_bin
Definition: deepstream_app.h:74
NvDsInstanceBin::tracker_bin
NvDsTrackerBin tracker_bin
Definition: deepstream_app.h:78
_AppCtx::config
NvDsConfig config
Definition: deepstream_audio.h:104
_AppCtx::cintr
gboolean cintr
Definition: deepstream_audio.h:92
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:139
NvDsConfig::osd_config
NvDsOSDConfig osd_config
Definition: deepstream_app.h:127
NvDsConfig::source_attr_all_parsed
gboolean source_attr_all_parsed
Definition: deepstream_app.h:148
NvDsInstanceBin::segvisual_bin
NvDsSegVisualBin segvisual_bin
Definition: deepstream_app.h:75
_AppCtx::index
guint index
Definition: deepstream_audio.h:98
NvDsInstanceBin::fps_buffer_probe_id
gulong fps_buffer_probe_id
Definition: deepstream_app.h:68