-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeepstream_app.h
263 lines (237 loc) · 8.04 KB
/
deepstream_app.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/*
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef __NVGSTDS_APP_H__
#define __NVGSTDS_APP_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include <gst/gst.h>
#include <stdio.h>
#include "deepstream_app_version.h"
#include "deepstream_common.h"
#include "deepstream_config.h"
#include "deepstream_osd.h"
#include "deepstream_segvisual.h"
#include "deepstream_perf.h"
#include "deepstream_preprocess.h"
#include "deepstream_primary_gie.h"
#include "deepstream_sinks.h"
#include "deepstream_sources.h"
#include "deepstream_streammux.h"
#include "deepstream_tiled_display.h"
#include "deepstream_dsanalytics.h"
#include "deepstream_dsexample.h"
#include "deepstream_tracker.h"
#include "deepstream_secondary_gie.h"
#include "deepstream_secondary_preprocess.h"
#include "deepstream_c2d_msg.h"
#include "deepstream_image_save.h"
#include "gst-nvdscustommessage.h"
#include "gst-nvdscommonconfig.h"
typedef struct _AppCtx AppCtx;
typedef void (*bbox_generated_callback) (AppCtx *appCtx, GstBuffer *buf,
NvDsBatchMeta *batch_meta, guint index);
typedef gboolean (*overlay_graphics_callback) (AppCtx *appCtx, GstBuffer *buf,
NvDsBatchMeta *batch_meta, guint index);
typedef struct
{
guint index;
gulong all_bbox_buffer_probe_id;
gulong primary_bbox_buffer_probe_id;
gulong fps_buffer_probe_id;
GstElement *bin;
GstElement *tee;
GstElement *msg_conv;
NvDsPreProcessBin preprocess_bin;
NvDsPrimaryGieBin primary_gie_bin;
NvDsOSDBin osd_bin;
NvDsSegVisualBin segvisual_bin;
NvDsSecondaryGieBin secondary_gie_bin;
NvDsSecondaryPreProcessBin secondary_preprocess_bin;
NvDsTrackerBin tracker_bin;
NvDsSinkBin sink_bin;
NvDsSinkBin demux_sink_bin;
NvDsDsAnalyticsBin dsanalytics_bin;
NvDsDsExampleBin dsexample_bin;
AppCtx *appCtx;
} NvDsInstanceBin;
typedef struct
{
gulong primary_bbox_buffer_probe_id;
guint bus_id;
GstElement *pipeline;
NvDsSrcParentBin multi_src_bin;
NvDsInstanceBin instance_bins[MAX_SOURCE_BINS];
NvDsInstanceBin demux_instance_bins[MAX_SOURCE_BINS];
NvDsInstanceBin common_elements;
GstElement *tiler_tee;
NvDsTiledDisplayBin tiled_display_bin;
GstElement *demuxer;
NvDsDsExampleBin dsexample_bin;
AppCtx *appCtx;
} NvDsPipeline;
typedef struct
{
gboolean enable_perf_measurement;
gint file_loop;
gint pipeline_recreate_sec;
gboolean source_list_enabled;
guint total_num_sources;
guint num_source_sub_bins;
guint num_secondary_gie_sub_bins;
guint num_secondary_preprocess_sub_bins;
guint num_sink_sub_bins;
guint num_message_consumers;
guint perf_measurement_interval_sec;
guint sgie_batch_size;
gchar *bbox_dir_path;
gchar *kitti_track_dir_path;
gchar *reid_track_dir_path;
gchar **uri_list;
gchar **sensor_id_list;
NvDsSourceConfig multi_source_config[MAX_SOURCE_BINS];
NvDsStreammuxConfig streammux_config;
NvDsOSDConfig osd_config;
NvDsSegVisualConfig segvisual_config;
NvDsPreProcessConfig preprocess_config;
NvDsPreProcessConfig secondary_preprocess_sub_bin_config[MAX_SECONDARY_PREPROCESS_BINS];
NvDsGieConfig primary_gie_config;
NvDsTrackerConfig tracker_config;
NvDsGieConfig secondary_gie_sub_bin_config[MAX_SECONDARY_GIE_BINS];
NvDsSinkSubBinConfig sink_bin_sub_bin_config[MAX_SINK_BINS];
NvDsMsgConsumerConfig message_consumer_config[MAX_MESSAGE_CONSUMERS];
NvDsTiledDisplayConfig tiled_display_config;
NvDsDsAnalyticsConfig dsanalytics_config;
NvDsDsExampleConfig dsexample_config;
NvDsSinkMsgConvBrokerConfig msg_conv_config;
NvDsImageSave image_save_config;
/** To support nvmultiurisrcbin */
gboolean use_nvmultiurisrcbin;
guint max_batch_size;
gchar* http_ip;
gchar* http_port;
gboolean source_attr_all_parsed;
NvDsSourceConfig source_attr_all_config;
} NvDsConfig;
typedef struct
{
gulong frame_num;
} NvDsInstanceData;
struct _AppCtx
{
gboolean version;
gboolean cintr;
gboolean show_bbox_text;
gboolean seeking;
gboolean quit;
gint person_class_id;
gint car_class_id;
gint return_value;
guint index;
gint active_source_index;
GMutex app_lock;
GCond app_cond;
NvDsPipeline pipeline;
NvDsConfig config;
NvDsConfig override_config;
NvDsInstanceData instance_data[MAX_SOURCE_BINS];
NvDsC2DContext *c2d_ctx[MAX_MESSAGE_CONSUMERS];
NvDsAppPerfStructInt perf_struct;
bbox_generated_callback bbox_generated_post_analytics_cb;
bbox_generated_callback all_bbox_generated_cb;
overlay_graphics_callback overlay_graphics_cb;
NvDsFrameLatencyInfo *latency_info;
GMutex latency_lock;
GThread *ota_handler_thread;
guint ota_inotify_fd;
guint ota_watch_desc;
/** Hash table to save NvDsSensorInfo
* obtained with REST API stream/add, remove operations
* The key is souce_id */
GHashTable *sensorInfoHash;
};
/**
* @brief Create DS Anyalytics Pipeline per the appCtx
* configurations
* @param appCtx [IN/OUT] The application context
* providing the config info and where the
* pipeline resources are maintained
* @param bbox_generated_post_analytics_cb [IN] This callback
* shall be triggered after analytics
* (PGIE, Tracker or the last SGIE appearing
* in the pipeline)
* More info: create_common_elements()
* @param all_bbox_generated_cb [IN]
* @param perf_cb [IN]
* @param overlay_graphics_cb [IN]
*/
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);
gboolean pause_pipeline (AppCtx * appCtx);
gboolean resume_pipeline (AppCtx * appCtx);
gboolean seek_pipeline (AppCtx * appCtx, glong milliseconds, gboolean seek_is_relative);
void toggle_show_bbox_text (AppCtx * appCtx);
void destroy_pipeline (AppCtx * appCtx);
void restart_pipeline (AppCtx * appCtx);
/**
* Function to read properties from configuration file.
*
* @param[in] config pointer to @ref NvDsConfig
* @param[in] cfg_file_path path of configuration file.
*
* @return true if parsed successfully.
*/
gboolean
parse_config_file (NvDsConfig * config, gchar * cfg_file_path);
/**
* Function to read properties from YML configuration file.
*
* @param[in] config pointer to @ref NvDsConfig
* @param[in] cfg_file_path path of configuration file.
*
* @return true if parsed successfully.
*/
gboolean
parse_config_file_yaml (NvDsConfig * config, gchar * cfg_file_path);
/**
* Function to procure the NvDsSensorInfo for the source_id
* that was added using the nvmultiurisrcbin REST API
*
* @param[in] appCtx [IN/OUT] The application context
* providing the config info and where the
* pipeline resources are maintained
* @param[in] source_id [IN] The unique source_id found in NvDsFrameMeta
*
* @return [transfer-floating] The NvDsSensorInfo for the source_id
* that was added using the nvmultiurisrcbin REST API.
* Please note that the returned pointer
* will be valid only until the stream is removed.
*/
NvDsSensorInfo* get_sensor_info(AppCtx* appCtx, guint source_id);
#ifdef __cplusplus
}
#endif
#endif