NVIDIA DeepStream SDK API Reference

9.1 Release
9.1/service-maker/includes/plugin.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2024-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 
23 #ifndef _DEEPSTREAM_PLUGIN_H_
24 #define _DEEPSTREAM_PLUGIN_H_
25 
36 #define DS_CUSTOM_PLUGIN_DEFINE(name, description, version, license) \
37  extern "C" void *ds_stub_define_custom_plugin(const char *, const char *, const char *, const char *); \
38  extern "C" void *gst_plugin_##name##_get_desc(void); \
39  extern "C" void *gst_plugin_##name##_get_desc(void) \
40  { \
41  return ds_stub_define_custom_plugin(#name, description, version, license); \
42  }
43 
53 #define DS_CUSTOM_FACTORY_DEFINE_PARAMS_BEGIN(param_spec) static const char* param_spec = "["
54 #define DS_CUSTOM_FACTORY_DEFINE_PARAM(name, type, brief, description, default_value) \
55 "{name: "#name", type: "#type", brief: "#brief", description: "#description", default_value: "#default_value"},"
56 #define DS_CUSTOM_FACTORY_DEFINE_PARAMS_END "]";
57 
72 #define DS_CUSTOM_FACTORY_DEFINE_FULL(factory_name, long_name, klass, description, author, signals, param_spec, \
73  object_class, ...) \
74 class object_class##Factory : public deepstream::CustomFactory { \
75 public: \
76  object_class##Factory() : \
77  CustomFactory(factory_name, gst_custom_factory_get_type(factory_name)) {} \
78  deepstream::CustomObject* createObject(const std::string& name) { \
79  return new object_class(name, factory_name, __VA_ARGS__); \
80  } \
81 }; \
82 extern "C" const FactoryMetadata get_custom_factory_info(void); \
83 extern "C" const FactoryMetadata get_custom_factory_info(void) { \
84  return {factory_name, long_name, klass, description, author, object_class::type(), signals}; \
85 } \
86 extern "C" const char* get_custom_factory_product_param_spec(); \
87 extern "C" const char* get_custom_factory_product_param_spec() { return param_spec; } \
88 extern "C" void register_component_factory(const char *name); \
89 extern "C" void register_component_factory(const char* name) { \
90  deepstream::CommonFactory& factory = \
91  deepstream::CommonFactory::getInstance(); \
92  factory.addCustomFactory(new object_class##Factory(), name); \
93 }
94 
96 #define DS_CUSTOM_FACTORY_DEFINE_WITH_PARAMS(factory_name, long_name, klass, description, author, signals, param_spec, \
97  object_class, implementation) \
98  DS_CUSTOM_FACTORY_DEFINE_FULL(factory_name, long_name, klass, description, author, signals, param_spec, object_class, new implementation)
99 
101 #define DS_CUSTOM_FACTORY_DEFINE_WITH_SIGNALS(factory_name, long_name, klass, description, author, signals, \
102  object_class, implementation) \
103  static const char* param_spec = ""; \
104  DS_CUSTOM_FACTORY_DEFINE_FULL(factory_name, long_name, klass, description, author, signals, param_spec, object_class, new implementation)
105 
107 #define DS_CUSTOM_FACTORY_DEFINE(factory_name, long_name, klass, description, author, \
108  object_class, implementation) \
109  static const char* param_spec = ""; \
110  DS_CUSTOM_FACTORY_DEFINE_FULL(factory_name, long_name, klass, description, author, "", param_spec, object_class, new implementation)
111 
112 #endif