Skip to main content

Session.h File

Session — the assembly stage that takes Nodes and turns them into a runnable Run. 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
namespaceinternal
namespacepipeline_internal

Classes Index

classRtspServerHandle

Live handle for a Session running in RTSP server mode. More...

classSession

The assembly stage — turns a list of Nodes into a runnable, deterministic pipeline. More...

structBuiltState

Opaque state carried by a built (not yet running) Session. More...

structGroupMeta

Per-NodeGroup metadata captured during build. More...

Description

Session — the assembly stage that takes Nodes and turns them into a runnable Run.

Session is the central concept of the framework. It collects Nodes (or NodeGroups, which are bundles of Nodes), validates them against built-in contracts, compiles them into a deterministic GStreamer pipeline string, instantiates the pipeline, negotiates caps between adjacent elements, and returns a Run handle for push/pull execution. Model is internally a Session wrapper: the same composition, validation, and runtime machinery powers Model underneath. New users typically use Model::run(); advanced users compose their own Sessions with model.session() plus extra Nodes for input sources, custom processing, side branches, or RTSP server output.

See Also

Run for the runtime handle a built Session produces

See Also

RtspServerHandle for server-mode Sessions

See Also

"Sessions: the assembly contract" (§0.12 of the design deep dive)

File Listing

The file content with the documentation metadata removed is:

1
19#pragma once
20
21#include "builder/Node.h"
22#include "builder/NodeGroup.h"
24#include "pipeline/Run.h"
25#include "builder/GraphPrinter.h"
27#include "nodes/common/Caps.h"
35#include "nodes/io/Input.h"
42
43#include <atomic>
44#include <functional>
45#include <memory>
46#include <string>
47#include <utility>
48#include <vector>
49
50#include <opencv2/core/mat.hpp>
51#include <gst/gst.h>
52
53namespace simaai::neat {
54namespace internal {
55struct ModelAccess;
56}
57namespace pipeline_internal {
58struct InputRouteProcessor;
59}
60
75public:
77 RtspServerHandle() = default;
80
83
85 RtspServerHandle& operator=(RtspServerHandle&&) noexcept;
86
88 const std::string& url() const {
89 return url_;
90 }
92 void stop();
94 void kill() {
95 stop();
96 }
98 bool running() const;
99
100private:
101 friend class Session;
102
103 std::string url_;
104 void* impl_ = nullptr;
105 std::shared_ptr<void> guard_;
106};
107
140class Session {
141public:
144 using TensorCallback = std::function<bool(const simaai::neat::Tensor&)>;
145
147 explicit Session(const SessionOptions& opt = {});
150 Session(const Session&) = delete;
151 Session& operator=(const Session&) = delete;
152 Session(Session&&) noexcept;
153 Session& operator=(Session&&) noexcept;
154
155 // ── Core: add Nodes / NodeGroups ─────────────────────────────────────────────────────────
162 Session& add(std::shared_ptr<Node> node);
164 Session& add(const NodeGroup& group);
166 Session& add(NodeGroup&& group);
167
168 // ── Custom GStreamer escape hatch ────────────────────────────────────────────────────────
179 Session& custom(std::string fragment);
181 Session& custom(std::string fragment, InputRole role);
182
183 // ── Typed runner: last node must be Output() ────────────────────────────────────────────
192 void run();
194 TensorList run(const std::vector<cv::Mat>& inputs, const RunOptions& opt = {});
196 TensorList run(const TensorList& inputs, const RunOptions& opt = {});
198 SampleList run(const SampleList& inputs, const RunOptions& opt = {});
206 Run build(const std::vector<cv::Mat>& inputs, RunMode mode = RunMode::Async,
207 const RunOptions& opt = {});
209 Run build(const TensorList& inputs, RunMode mode = RunMode::Async, const RunOptions& opt = {});
211 Run build(const SampleList& inputs, RunMode mode = RunMode::Async, const RunOptions& opt = {});
219 SessionReport validate(const ValidateOptions& opt, const cv::Mat& input) const;
220
221 // ── Server-style run ────────────────────────────────────────────────────────────────────
233
243 SessionReport validate(const ValidateOptions& opt = {}) const;
244
245 // ── Tensor-friendly output helper ────────────────────────────────────────────────────────
255
256 // ── UX helpers ───────────────────────────────────────────────────────────────────────────
258 std::string describe(const GraphPrinter::Options& opt = {}) const;
267 std::string describe_backend(bool insert_boundaries = false) const;
268
270 void set_guard(std::shared_ptr<void> guard);
271
274
276 void save(const std::string& path) const;
278 static Session load(const std::string& path);
279
287 Run build(const RunOptions& opt = {});
288
290 const std::string& last_pipeline() const {
291 return last_pipeline_;
292 }
293
294private:
296
306 struct BuiltState {
307 GstElement* pipeline = nullptr;
308 GstElement* sink = nullptr;
309 std::shared_ptr<void> diag;
310 };
311 struct RunCache;
321 struct GroupMeta {
322 std::size_t start = 0;
323 std::size_t end = 0;
324 NodeCapsBehavior caps_behavior = NodeCapsBehavior::Dynamic;
325 std::string label;
326 };
327
328 std::vector<std::shared_ptr<Node>> nodes_;
329 std::vector<GroupMeta> groups_;
330 std::string last_pipeline_;
331 std::shared_ptr<void> guard_;
332 std::shared_ptr<void> verbose_guard_;
333 SessionOptions opt_{};
334 TensorCallback tensor_cb_;
335 std::atomic<uint64_t> nodes_version_{0};
336 std::unique_ptr<BuiltState> built_;
337 std::unique_ptr<RunCache> run_cache_;
338 uint64_t built_version_ = 0;
339 std::shared_ptr<const pipeline_internal::InputRouteProcessor> input_route_processor_;
340
341 void build_cached_source();
342};
343
344} // namespace simaai::neat

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.