NVIDIA DeepStream SDK API Reference

9.1 Release
sources/includes/ds3d/common/impl/impl_databridge.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_FILTER_H
19 #define DS3D_COMMON_IMPL_BASE_DATA_FILTER_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 BaseImplDataBridge : public BaseImplDataProcessor<abiDataBridge> {
39 public:
41  ~BaseImplDataBridge() override = default;
42 
44  const struct VideoBridge2dInput* inputData, const abiOnDataCB* outputDataCb,
45  const abiOnBridgeDataCB* inputDataConsumedCb) final
46  {
48  getStateSafe() == State::kRunning, ErrCode::kState, "datafilter is not started");
49 
50  DS_ASSERT(inputData);
51  GuardCB<abiOnDataCB> guardOutputCb(outputDataCb ? outputDataCb->refCopy() : nullptr);
52  OnGuardDataCBImpl outputCbImpl = [gOutputCb = std::move(guardOutputCb), this](
53  ErrCode code, GuardDataMap data) {
54  gOutputCb(code, data.abiRef());
55  };
56 
57  GuardCB<abiOnBridgeDataCB> guardConsumedCb(
58  inputDataConsumedCb ? inputDataConsumedCb->refCopy() : nullptr);
59  OnGuardBridgeDataCBImpl consumedCbImpl = [gConsumedCb = std::move(guardConsumedCb), this](
60  ErrCode code, const struct VideoBridge2dInput* data) {
61  gConsumedCb(code, data);
62  };
63  return processImpl(inputData, std::move(outputCbImpl), std::move(consumedCbImpl));
64  }
65 
66 protected:
67  // cplusplus virtual interface, user need to derive from
68  virtual ErrCode processImpl(
69  const struct VideoBridge2dInput* inputData, OnGuardDataCBImpl outputDataCb,
70  OnGuardBridgeDataCBImpl inputConsumedCb) = 0;
71 };
72 
73 }} // namespace ds3d::impl
74 
75 #endif // DS3D_COMMON_IMPL_BASE_DATA_FILTER_H
ds3d::impl::BaseImplDataProcessor< abiDataBridge >::OnGuardBridgeDataCBImpl
std::function< void(ErrCode, const struct VideoBridge2dInput *)> OnGuardBridgeDataCBImpl
Definition: sources/includes/ds3d/common/impl/impl_dataprocess.h:34
ds3d::impl::BaseImplDataBridge::processImpl
virtual ErrCode processImpl(const struct VideoBridge2dInput *inputData, OnGuardDataCBImpl outputDataCb, OnGuardBridgeDataCBImpl inputConsumedCb)=0
ds3d::impl::BaseImplDataBridge::~BaseImplDataBridge
~BaseImplDataBridge() override=default
ds3d::VideoBridge2dInput
Definition: sources/includes/ds3d/common/idatatype.h:157
DS3D_FAILED_RETURN
#define DS3D_FAILED_RETURN(condition, ret, fmt,...)
Definition: sources/includes/ds3d/common/defines.h:69
ds3d::impl::BaseImplDataBridge::process_i
ErrCode process_i(const struct VideoBridge2dInput *inputData, const abiOnDataCB *outputDataCb, const abiOnBridgeDataCB *inputDataConsumedCb) final
Definition: sources/includes/ds3d/common/impl/impl_databridge.h:43
ds3d::impl::BaseImplDataProcessor< abiDataBridge >::OnGuardDataCBImpl
std::function< void(ErrCode, GuardDataMap)> OnGuardDataCBImpl
Definition: sources/includes/ds3d/common/impl/impl_dataprocess.h:33
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::BaseImplDataProcessor< abiDataBridge >::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::impl::BaseImplDataBridge::BaseImplDataBridge
BaseImplDataBridge()
Definition: sources/includes/ds3d/common/impl/impl_databridge.h:40
ds3d::GuardDataMap
Definition: sources/includes/ds3d/common/hpp/datamap.hpp:27
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::BaseImplDataBridge
Any custom datafilter must derive from BaseImplDataBridge,.
Definition: sources/includes/ds3d/common/impl/impl_databridge.h:38
ds3d::GuardCB
Definition: sources/includes/ds3d/common/hpp/obj.hpp:289