NVIDIA DeepStream SDK API Reference

9.1 Release
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_base.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2022-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 __NVDSPOSTPROCESSLIB_BASE_HPP__
19 #define __NVDSPOSTPROCESSLIB_BASE_HPP__
20 
21 #include <gst/base/gstbasetransform.h>
22 #include <gst/video/video.h>
23 
24 #include "gstnvdsbufferpool.h"
26 
28 {
29 public:
31 
33 
34  virtual ~DSPostProcessLibraryBase();
35 
36  virtual bool HandleEvent (GstEvent *event) = 0;
37 
38  virtual bool SetConfigFile (const gchar *config_file) = 0;
39 
40  /* Process Incoming Buffer */
41  virtual BufferResult ProcessBuffer(GstBuffer *inbuf) = 0;
42 
43 public:
44  /* Gstreamer dsexaple2 plugin's base class reference */
45  GstBaseTransform *m_element;
46 
48  guint m_gpuId;
49 
52 
53 };
54 
55 
57  m_element = NULL;
58  m_gpuId = 0;
59  m_cudaStream = 0;
60  m_preprocessor_support = FALSE;
61 }
62 
64  if (params){
65  m_element = params->m_element;
66  m_gpuId = params->m_gpuId;
67  m_cudaStream = params->m_cudaStream;
69  }
70  else {
71  m_element = NULL;
72  m_gpuId = 0;
73  m_cudaStream = 0;
75  }
76 }
77 
79 }
80 
81 /* Helped function to get the NvBufSurface from the GstBuffer */
83 {
84  GstMapInfo in_map_info = GST_MAP_INFO_INIT;
85  NvBufSurface *nvbuf_surface = NULL;
86 
87  /* Map the buffer contents and get the pointer to NvBufSurface. */
88  if (!gst_buffer_map (inbuf, &in_map_info, GST_MAP_READ)) {
89  printf ("%s:gst buffer map to get pointer to NvBufSurface failed", __func__);
90  return NULL;
91  }
92 
93  // Assuming that the plugin uses DS NvBufSurface data structure
94  nvbuf_surface = (NvBufSurface *) in_map_info.data;
95 
96  gst_buffer_unmap(inbuf, &in_map_info);
97  return nvbuf_surface;
98 }
99 
100 #endif
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition: sources/includes/nvbufsurftransform.h:35
IDSPostProcessLibrary
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_interface.hpp:48
NvBufSurface
Holds information about batched buffers.
Definition: sources/includes/nvbufsurface.h:597
DSPostProcessLibraryBase::m_cudaStream
cudaStream_t m_cudaStream
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_base.hpp:51
DSPostProcess_CreateParams::m_gpuId
guint m_gpuId
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_interface.hpp:33
DSPostProcessLibraryBase
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_base.hpp:27
DSPostProcessLibraryBase::m_element
GstBaseTransform * m_element
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_base.hpp:45
DSPostProcess_CreateParams::m_cudaStream
cudaStream_t m_cudaStream
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_interface.hpp:34
DSPostProcess_CreateParams::m_preprocessor_support
bool m_preprocessor_support
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_interface.hpp:35
DSPostProcessLibraryBase::~DSPostProcessLibraryBase
virtual ~DSPostProcessLibraryBase()
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_base.hpp:78
DSPostProcessLibraryBase::DSPostProcessLibraryBase
DSPostProcessLibraryBase()
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_base.hpp:56
DSPostProcess_CreateParams
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_interface.hpp:31
DSPostProcessLibraryBase::m_gpuId
guint m_gpuId
GPU ID on which we expect to execute the algorithm.
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_base.hpp:48
DSPostProcessLibraryBase::SetConfigFile
virtual bool SetConfigFile(const gchar *config_file)=0
getNvBufSurface
static NvBufSurface * getNvBufSurface(GstBuffer *inbuf)
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_base.hpp:82
DSPostProcessLibraryBase::HandleEvent
virtual bool HandleEvent(GstEvent *event)=0
DSPostProcess_CreateParams::m_element
GstBaseTransform * m_element
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_interface.hpp:32
nvdspostprocesslib_interface.hpp
DSPostProcessLibraryBase::ProcessBuffer
virtual BufferResult ProcessBuffer(GstBuffer *inbuf)=0
DSPostProcessLibraryBase::m_preprocessor_support
gboolean m_preprocessor_support
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_base.hpp:50
GstBuffer
struct _GstBuffer GstBuffer
Definition: sources/includes/ds3d/common/idatatype.h:24
BufferResult
BufferResult
Definition: sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_interface.hpp:24