NVIDIA DeepStream SDK API Reference

9.1 Release
service-maker/sources/modules/ensemble_render/ensemble_render.hpp
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 
18 #include <iostream>
19 #include <ds3d/gst/nvds3d_gst_plugin.h>
20 #include <ds3d/common/defines.h>
21 #include <ds3d/common/hpp/datamap.hpp>
22 
23 #include "data_receiver.hpp"
24 
25 
26 namespace deepstream {
27 
29 public:
31  using namespace ds3d;
32  ErrCode c;
33  if (!_initialized) {
34  _initialized = true;
35  std::string configPath;
36  Ptr<CustomLibFactory> customlib;
37  std::string configContent;
38  receiver.getProperty("config-path", configPath);
39  std::cout << "ensemble_render plugin config-path: " << configPath << std::endl;
40  readFile(configPath, configContent);
41  config::parseComponentConfig(configContent, configPath, config);
42  c = gst::loadCustomProcessor(config, render, customlib);
43  DS_ASSERT(c == ErrCode::kGood);
44  c = render.start(config.rawContent, config.filePath);
45  DS_ASSERT(c == ErrCode::kGood);
46  }
47  }
48 
49  virtual int consume(DataReceiver& receiver, Buffer buffer) {
50  if (!_initialized) initialize(receiver);
52  ds3d::ErrCode c;
53  const ds3d::abiRefDataMap* datamap = nullptr;
54  GstBuffer* buf = buffer.give();
55  gst_buffer_unref(buf);
56  c = NvDs3D_Find1stDataMap(buf, datamap);
58  DS_ASSERT(datamap);
59  ds3d::GuardDataMap guardData(*datamap);
60  c = render.render(guardData, [](ds3d::ErrCode err, const ds3d::abiRefDataMap*) {});
62  return 1;
63  }
64 
65 private:
66  OpaqueBuffer *buffer_ = nullptr;
67  ds3d::GuardDataRender render;
69  bool _initialized = false;
70 };
71 }
OpaqueBuffer
struct _GstBuffer OpaqueBuffer
Definition: service-maker/includes/buffer.hpp:36
deepstream::DataReceiver::IDataConsumer
required interface for a data receiver
Definition: service-maker/includes/data_receiver.hpp:50
ds3d::ErrCode::kGood
@ kGood
ds3d::gst::loadCustomProcessor
ErrCode loadCustomProcessor(const config::ComponentConfig &compConfig, GuardProcess &customProcessor, Ptr< CustomLibFactory > &lib)
Definition: sources/libs/ds3d/gst/nvds3d_gst_plugin.h:82
ds3d::readFile
bool readFile(const std::string &path, std::string &context)
Definition: sources/includes/ds3d/common/func_utils.h:204
ds3d::GuardDataProcess::state
State state() const
Definition: sources/includes/ds3d/common/hpp/dataprocess.hpp:92
ds3d::abiRefT< abiDataMap >
ds3d::config::parseComponentConfig
ErrCode parseComponentConfig(const std::string &yamlComp, const std::string &path, ComponentConfig &config)
Definition: sources/includes/ds3d/common/hpp/yaml_config.hpp:57
DS_ASSERT
#define DS_ASSERT(...)
Definition: sources/includes/ds3d/common/defines.h:36
ds3d::ErrCode
ErrCode
Definition: sources/includes/ds3d/common/common.h:47
deepstream::EnsembleRender::consume
virtual int consume(DataReceiver &receiver, Buffer buffer)
Definition: service-maker/sources/modules/ensemble_render/ensemble_render.hpp:49
ds3d::GuardDataRender::render
ErrCode render(GuardDataMap datamap, abiOnDataCB::CppFunc dataDoneCB)
Definition: sources/includes/ds3d/common/hpp/datarender.hpp:73
deepstream
Definition: service-maker/includes/buffer.hpp:38
deepstream::EnsembleRender
Definition: service-maker/sources/modules/ensemble_render/ensemble_render.hpp:28
deepstream::Buffer
Base class of a buffer.
Definition: service-maker/includes/buffer.hpp:51
ds3d::Ptr
ShrdPtr< T > Ptr
Definition: sources/includes/ds3d/common/hpp/obj.hpp:37
ds3d::config::ComponentConfig
Definition: sources/includes/ds3d/common/config.h:38
ds3d::GuardDataRender
GuardDataRender is the safe access entry for abiDataRender.
Definition: sources/includes/ds3d/common/hpp/datarender.hpp:57
ds3d::GuardDataMap
Definition: sources/includes/ds3d/common/hpp/datamap.hpp:27
ds3d::State::kRunning
@ kRunning
deepstream::DataReceiver
A specific signal handler for consuming data.
Definition: service-maker/includes/data_receiver.hpp:42
ds3d
Definition: sources/includes/ds3d/common/abi_dataprocess.h:25
receiver
static deepstream::Cloud2DeviceReceiver receiver
Definition: service-maker/sources/modules/smart_recording_action/smart_recording_action.hpp:29
NvDs3D_Find1stDataMap
DS3D_EXPORT_API ds3d::ErrCode NvDs3D_Find1stDataMap(GstBuffer *buf, const ds3d::abiRefDataMap *&datamap)
deepstream::EnsembleRender::initialize
void initialize(DataReceiver &receiver)
Definition: service-maker/sources/modules/ensemble_render/ensemble_render.hpp:30
deepstream::Buffer::give
OpaqueBuffer * give()
Give up the ownership of this buffer and return the opaque buffer pointer.
GstBuffer
struct _GstBuffer GstBuffer
Definition: sources/includes/ds3d/common/idatatype.h:24