NVIDIA DeepStream SDK API Reference

9.1 Release
sources/includes/ds3d/common/impl/impl_datarender.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-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 DS3D_COMMON_IMPL_BASE_DATA_RENDER_H
19 #define DS3D_COMMON_IMPL_BASE_DATA_RENDER_H
20 
21 #include "ds3d/common/hpp/datamap.hpp"
22 #include "ds3d/common/impl/impl_dataprocess.h"
23 
24 namespace ds3d { namespace impl {
25 
38 class BaseImplDataRender : public BaseImplDataProcessor<abiDataRender> {
39 public:
41  ~BaseImplDataRender() override = default;
42 
43  ErrCode preroll_i(const abiRefDataMap* inputData) final
44  {
45  DS_ASSERT(inputData);
47  getStateSafe() == State::kRunning, ErrCode::kState, "datarender is not started");
48  GuardDataMap data(*inputData);
49  return prerollImpl(std::move(data));
50  }
51 
52  const abiRefWindow* getWindow_i() const final {
53  return _window.abiRef();
54  }
55 
56  ErrCode render_i(const abiRefDataMap* inputData, const abiOnDataCB* dataDoneCb) final
57  {
59  getStateSafe() == State::kRunning, ErrCode::kState, "datarender is not started");
60 
61  DS_ASSERT(inputData);
62  GuardDataMap inData(*inputData);
63  GuardCB<abiOnDataCB> guardDoneCb(dataDoneCb ? dataDoneCb->refCopy() : nullptr);
64  OnGuardDataCBImpl consumedCB = [guardCb = std::move(guardDoneCb), this](
65  ErrCode code, GuardDataMap data) {
66  guardCb(code, data.abiRef());
67  };
68  return renderImpl(std::move(inData), std::move(consumedCB));
69  }
70 
71  ErrCode stop_i() final {
72  _window.reset();
74  }
75 
76 protected:
77  // cplusplus virtual interface, user need to derive from
78  virtual ErrCode prerollImpl(GuardDataMap datamap) = 0;
79  virtual ErrCode renderImpl(GuardDataMap datamap, OnGuardDataCBImpl dataDoneCb) = 0;
80  void setWindow(GuardWindow window) {
81  _window = window;
82  }
83 private:
84  GuardWindow _window;
85 };
86 
87 }} // namespace ds3d::impl
88 
89 #endif // DS3D_COMMON_IMPL_BASE_DATA_RENDER_H
DS3D_FAILED_RETURN
#define DS3D_FAILED_RETURN(condition, ret, fmt,...)
Definition: sources/includes/ds3d/common/defines.h:69
ds3d::GuardRef::abiRef
ref * abiRef() const
Definition: sources/includes/ds3d/common/hpp/obj.hpp:273
ds3d::impl::BaseImplDataRender::renderImpl
virtual ErrCode renderImpl(GuardDataMap datamap, OnGuardDataCBImpl dataDoneCb)=0
ds3d::impl::BaseImplDataProcessor< abiDataRender >::OnGuardDataCBImpl
std::function< void(ErrCode, GuardDataMap)> OnGuardDataCBImpl
Definition: sources/includes/ds3d/common/impl/impl_dataprocess.h:33
ds3d::impl::BaseImplDataRender::preroll_i
ErrCode preroll_i(const abiRefDataMap *inputData) final
Definition: sources/includes/ds3d/common/impl/impl_datarender.h:43
ds3d::impl::BaseImplDataRender::getWindow_i
const abiRefWindow * getWindow_i() const final
Definition: sources/includes/ds3d/common/impl/impl_datarender.h:52
ds3d::abiRefT< abiDataMap >
DS_ASSERT
#define DS_ASSERT(...)
Definition: sources/includes/ds3d/common/defines.h:36
ds3d::ErrCode
ErrCode
Definition: sources/includes/ds3d/common/common.h:47
ds3d::impl::BaseImplDataRender::~BaseImplDataRender
~BaseImplDataRender() override=default
ds3d::GuardDataT< abiWindow >
ds3d::impl::BaseImplDataProcessor::stop_i
ErrCode stop_i() override
Definition: sources/includes/ds3d/common/impl/impl_dataprocess.h:84
ds3d::impl::BaseImplDataRender
Any custom datarender must derive from BaseImplDataRender,.
Definition: sources/includes/ds3d/common/impl/impl_datarender.h:38
ds3d::GuardRef::reset
void reset(ref *abiref=nullptr)
Definition: sources/includes/ds3d/common/hpp/obj.hpp:264
ds3d::impl::BaseImplDataRender::BaseImplDataRender
BaseImplDataRender()
Definition: sources/includes/ds3d/common/impl/impl_datarender.h:40
ds3d::impl::BaseImplDataRender::render_i
ErrCode render_i(const abiRefDataMap *inputData, const abiOnDataCB *dataDoneCb) final
Definition: sources/includes/ds3d/common/impl/impl_datarender.h:56
ds3d::impl::BaseImplDataProcessor< abiDataRender >::getStateSafe
State getStateSafe() const
Definition: sources/includes/ds3d/common/impl/impl_dataprocess.h:116
ds3d::impl::BaseImplDataProcessor
BaseProcessIF could be abiDataLoader/abiDataRender/abiDataFilter or any others abi interface that der...
Definition: sources/includes/ds3d/common/impl/impl_dataprocess.h:31
ds3d::GuardDataMap
Definition: sources/includes/ds3d/common/hpp/datamap.hpp:27
ds3d::impl::BaseImplDataRender::prerollImpl
virtual ErrCode prerollImpl(GuardDataMap datamap)=0
ds3d::impl::BaseImplDataRender::stop_i
ErrCode stop_i() final
Definition: sources/includes/ds3d/common/impl/impl_datarender.h:71
ds3d::State::kRunning
@ kRunning
ds3d
Definition: sources/includes/ds3d/common/abi_dataprocess.h:25
ds3d::abiCallBackT
Definition: sources/includes/ds3d/common/abi_obj.h:75
ds3d::ErrCode::kState
@ kState
ds3d::impl::BaseImplDataRender::setWindow
void setWindow(GuardWindow window)
Definition: sources/includes/ds3d/common/impl/impl_datarender.h:80
ds3d::GuardCB
Definition: sources/includes/ds3d/common/hpp/obj.hpp:289