NVIDIA DeepStream SDK API Reference

9.1 Release
9.1/sources/libs/nvdsinferserver/infer_stream_manager.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 __INFER_STREAM_MANAGER_H__
19 #define __INFER_STREAM_MANAGER_H__
20 
21 #include <functional>
22 #include <queue>
23 
24 #include "infer_common.h"
25 #include "infer_utils.h"
26 
27 namespace nvdsinferserver {
28 
29 // When loop is enabled, for full frame processing only
30 //
31 class StreamManager {
32 public:
33  using StreamId = uint64_t;
34 
36  ~StreamManager() = default;
37  // wait until the streaming update from running(kRunning) to other state
39  // start a stream into waiting list, update status into kRunning
40  NvDsInferStatus startStream(StreamId id, int64_t timestamp, void* userptr);
41  // stop a stream, set it to kStopped but keep in the list
43  // update stream state into kReady
45  void notifyError(NvDsInferStatus status);
46 
47  // Information
48  // max_size; timeout_list;
49 private:
50  enum class ProgressType : int {
51  kStopped = 0,
52  kReady = 1,
53  kRunning = 2,
54  };
55 
56  struct StreamState {
57  int64_t timestamp = 0;
58  ProgressType progress = ProgressType::kReady;
59  void* reserved = nullptr;
60  };
61  using StreamList = std::unordered_map<StreamId, StreamState>;
62 
63  bool isRunning() const { return !m_Stopping; }
64  bool popDeprecatedStream();
65 
66  StreamList m_StreamList;
67  uint32_t m_MaxStreamSize = 256;
68  bool m_Stopping = false;
69  std::mutex m_Mutex;
70  std::condition_variable m_Cond;
71 };
72 
73 } // namespace nvdsinferserver
74 
75 #endif
nvdsinferserver::StreamManager::waitStream
NvDsInferStatus waitStream(StreamId id)
nvdsinferserver
This is a header file for pre-processing cuda kernels with normalization and mean subtraction require...
Definition: sources/gst-plugins/gst-nvinferserver/gstnvinferserver_impl.h:69
nvdsinferserver::StreamManager::StreamManager
StreamManager()
Definition: 9.1/sources/libs/nvdsinferserver/infer_stream_manager.h:35
nvdsinferserver::StreamManager::startStream
NvDsInferStatus startStream(StreamId id, int64_t timestamp, void *userptr)
infer_common.h
Header file of the common declarations for the nvinferserver library.
nvdsinferserver::SharedBatchArray
std::shared_ptr< BaseBatchArray > SharedBatchArray
Definition: sources/libs/nvdsinferserver/infer_common.h:80
nvdsinferserver::StreamManager::streamInferDone
NvDsInferStatus streamInferDone(StreamId id, SharedBatchArray &outTensors)
nvdsinferserver::StreamManager::StreamId
uint64_t StreamId
Definition: sources/libs/nvdsinferserver/infer_stream_manager.h:33
nvdsinferserver::StreamManager::stopStream
NvDsInferStatus stopStream(StreamId id)
nvdsinferserver::StreamManager::notifyError
void notifyError(NvDsInferStatus status)
infer_utils.h
Header file containing utility functions and classes used by the nvinferserver low level library.
nvdsinferserver::StreamManager::~StreamManager
~StreamManager()=default
NvDsInferStatus
NvDsInferStatus
Enum for the status codes returned by NvDsInferContext.
Definition: sources/includes/nvdsinfer.h:231