NVIDIA DeepStream SDK API Reference

9.1 Release
9.1/sources/includes/nvds_utils.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __NVDS_COMMON_UTILS_H__
19 #define __NVDS_COMMON_UTILS_H__
20 
21 #ifdef __cplusplus
22 extern "C"
23 {
24 #endif
25 
26 /*
27  * Release memory allocated for gobjects
28  */
29 void free_gobjs(GKeyFile *gcfg_file, GError *error, gchar **keys, gchar *key_name);
30 
31 /*
32  * Internal function to verify if the config string value is a quoted string
33  * config key = "value"
34  * If so, strip beginning and ending quote
35  */
36 NvDsMsgApiErrorType strip_quote(char *cfg_value, const char *cfg_key, const char *log_cat);
37 
38 /*
39  *Function to open a file and search config value for a config key
40  *If found, place the result in cfg_val
41  */
42 NvDsMsgApiErrorType fetch_config_value(char *config_path, const char *cfg_key, char *cfg_val, int len, const char *log_category);
43 
44 /*
45  * Get hostname with IP address or Kubernetes pod information
46  * Returns a newly allocated string containing either:
47  * - Kubernetes: "pod-name (pod-dns)"
48  * - Regular: "hostname (IP)"
49  * Caller must free with g_free().
50  */
51 char* nvds_get_hostname_with_ip(void);
52 
53 #ifdef __cplusplus
54 }
55 
56 #include <string>
57 
58 /*
59  *Generate hash value of a string using SHA256
60  */
61 std::string generate_sha256_hash(std::string str);
62 
63 /*
64  * remove leading & trailing whitespaces from a string
65  */
66 std::string trim(std::string str);
67 
68 /*
69  * Sort string of format key=value;key1=value1
70  * ex: str = "pq=89;xyz=33;abc=123;"
71  * output = "abc=123;pq=89;xyz=33"
72  */
73 std::string sort_key_value_pairs(std::string str);
74 
75 #endif
76 
77 #endif
NvDsMsgApiErrorType
NvDsMsgApiErrorType
Defines completion codes for operations in the messaging API.
Definition: sources/includes/nvds_msgapi.h:62
fetch_config_value
NvDsMsgApiErrorType fetch_config_value(char *config_path, const char *cfg_key, char *cfg_val, int len, const char *log_category)
nvds_get_hostname_with_ip
char * nvds_get_hostname_with_ip(void)
strip_quote
NvDsMsgApiErrorType strip_quote(char *cfg_value, const char *cfg_key, const char *log_cat)
free_gobjs
void free_gobjs(GKeyFile *gcfg_file, GError *error, gchar **keys, gchar *key_name)