Skip to main content

Session.h File

Session entry point and RTSP server handle. More...

Included Headers

#include "builder/Node.h" #include "builder/NodeGroup.h" #include "pipeline/SessionOptions.h" #include "pipeline/Run.h" #include "builder/GraphPrinter.h" #include "nodes/common/Output.h" #include "nodes/common/Caps.h" #include "nodes/common/FileInput.h" #include "nodes/common/JpegDecode.h" #include "nodes/common/VideoTrackSelect.h" #include "nodes/common/Queue.h" #include "nodes/common/VideoConvert.h" #include "nodes/common/VideoScale.h" #include "nodes/io/StillImageInput.h" #include "nodes/io/Input.h" #include "nodes/io/RTSPInput.h" #include "nodes/rtp/H264Depacketize.h" #include "nodes/sima/H264DecodeSima.h" #include "nodes/sima/H264EncodeSima.h" #include "nodes/sima/H264Parse.h" #include "nodes/sima/H264Packetize.h" #include <atomic> #include <functional> #include <memory> #include <string> #include <utility> #include <vector> #include <opencv2/core/mat.hpp> #include <gst/gst.h>

Namespaces Index

namespacesimaai
namespaceneat

Classes Index

classRtspServerHandle
classSession

Build, validate, and run deterministic GStreamer pipelines. More...

structBuiltState
structGroupMeta

Description

Session entry point and RTSP server handle.

File Listing

The file content with the documentation metadata removed is:

1
6#pragma once
7
8#include "builder/Node.h"
9#include "builder/NodeGroup.h"
11#include "pipeline/Run.h"
12#include "builder/GraphPrinter.h"
14#include "nodes/common/Caps.h"
22#include "nodes/io/Input.h"
29
30#include <atomic>
31#include <functional>
32#include <memory>
33#include <string>
34#include <utility>
35#include <vector>
36
37#include <opencv2/core/mat.hpp>
38#include <gst/gst.h>
39
40namespace simaai::neat {
41
43public:
44 RtspServerHandle() = default;
46
49
51 RtspServerHandle& operator=(RtspServerHandle&&) noexcept;
52
53 const std::string& url() const {
54 return url_;
55 }
56 void stop();
57 void kill() {
58 stop();
59 }
60 bool running() const;
61
62private:
63 friend class Session;
64
65 std::string url_;
66 void* impl_ = nullptr;
67 std::shared_ptr<void> guard_;
68};
69
76class Session {
77public:
78 using TensorCallback = std::function<bool(const simaai::neat::Tensor&)>;
79
80 explicit Session(const SessionOptions& opt = {});
82 Session(const Session&) = delete;
83 Session& operator=(const Session&) = delete;
84 Session(Session&&) noexcept;
85 Session& operator=(Session&&) noexcept;
86
87 // Core: add a node (factory functions return std::shared_ptr<Node>)
88 Session& add(std::shared_ptr<Node> node);
89 Session& add(const NodeGroup& group);
90 Session& add(NodeGroup&& group);
91
92 // Explicit raw-string escape hatch (keeps "power user" obvious)
93 Session& custom(std::string fragment);
94 Session& custom(std::string fragment, InputRole role);
95
96 // Typed runner: last node must be Output().
97 void run();
98 Sample run(const cv::Mat& input, const RunOptions& opt = {});
99 Sample run(const simaai::neat::Tensor& input, const RunOptions& opt = {});
100 Run build(const cv::Mat& input, RunMode mode = RunMode::Async, const RunOptions& opt = {});
102 const RunOptions& opt = {});
103 Run build(const Sample& input, RunMode mode = RunMode::Async, const RunOptions& opt = {});
104 SessionReport validate(const ValidateOptions& opt, const cv::Mat& input) const;
105
106 // Server-style run
108
109 // Build + validate pipeline (no PLAYING). Returns machine-readable report.
110 SessionReport validate(const ValidateOptions& opt = {}) const;
111
112 // Tensor-friendly output helper (adds convert/scale/caps + Output).
114
115 // UX helpers: builder-only view and gst-launch string.
116 std::string describe(const GraphPrinter::Options& opt = {}) const;
117 std::string describe_backend(bool insert_boundaries = false) const;
118
119 // Optional external guard (for externally managed runtimes).
120 void set_guard(std::shared_ptr<void> guard);
121
122 // Output callback for source pipelines (used by run()).
124
125 // Save/load pipeline config for reproducible runs.
126 void save(const std::string& path) const;
127 static Session load(const std::string& path);
128
129 // Build pipeline once (no frames processed) and return an async runner.
130 // Push pipelines use build(input) to configure appsrc caps.
131 Run build(const RunOptions& opt = {});
132
133 const std::string& last_pipeline() const {
134 return last_pipeline_;
135 }
136
137private:
138 struct BuiltState {
139 GstElement* pipeline = nullptr;
140 GstElement* sink = nullptr;
141 std::shared_ptr<void> diag;
142 };
143 struct RunCache;
144 struct GroupMeta {
145 std::size_t start = 0;
146 std::size_t end = 0; // exclusive
147 NodeCapsBehavior caps_behavior = NodeCapsBehavior::Dynamic;
148 std::string label;
149 };
150
151 std::vector<std::shared_ptr<Node>> nodes_;
152 std::vector<GroupMeta> groups_;
153 std::string last_pipeline_;
154 std::shared_ptr<void> guard_;
155 SessionOptions opt_{};
156 TensorCallback tensor_cb_;
157 std::string last_sima_manifest_json_;
158 std::atomic<uint64_t> nodes_version_{0};
159 std::unique_ptr<BuiltState> built_;
160 std::unique_ptr<RunCache> run_cache_;
161 uint64_t built_version_ = 0;
162
163 void build_cached_source();
164};
165
166} // namespace simaai::neat

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.1.