Skip to main content

H264Parse.h File

SimaAI H264 parse node wrapper. More...

Included Headers

#include "builder/Node.h" #include "builder/OutputSpec.h" #include <memory> #include <optional> #include <string> #include <vector>

Namespaces Index

namespacesimaai
namespaceneat
namespacenodes

Classes Index

structH264ParseOptions
classH264Parse

Description

SimaAI H264 parse node wrapper.

File Listing

The file content with the documentation metadata removed is:

1// include/nodes/sima/H264Parse.h
7#pragma once
8
9#include "builder/Node.h"
10#include "builder/OutputSpec.h"
11
12#include <memory>
13#include <optional>
14#include <string>
15#include <vector>
16
17namespace simaai::neat {
18
19// GStreamer h264parse + (optional) caps enforcement.
20//
21// Why caps enforcement is inside this node:
22// - AU/NAL alignment is often a CAPS negotiation detail (not always a property)
23// - Keeping it here avoids users sprinkling raw capsfilter strings everywhere
24// - Still prints a clean gst-launch repro string
26 // Sends SPS/PPS periodically. Commonly required for RTP/RTSP robustness.
27 // (Maps to h264parse property: config-interval)
29
30 // Optional: enforce downstream caps after h264parse via a capsfilter.
31 // This is how we express AU alignment and stream-format deterministically.
32 enum class Alignment { Auto, AU, NAL };
33 enum class StreamFormat { Auto, AVC, ByteStream };
34
37
38 // If true, we add a named capsfilter after h264parse.
39 // It will include only the fields that are not Auto.
40 bool enforce_caps = false;
41};
42
43class H264Parse final : public Node, public OutputSpecProvider {
44public:
45 explicit H264Parse(H264ParseOptions opt = {});
46 std::string kind() const override {
47 return "H264Parse";
48 }
49 NodeCapsBehavior caps_behavior() const override {
50 return opt_.enforce_caps ? NodeCapsBehavior::Static : NodeCapsBehavior::Dynamic;
51 }
52
53 std::string backend_fragment(int node_index) const override;
54 std::vector<std::string> element_names(int node_index) const override;
55 OutputSpec output_spec(const OutputSpec& input) const override;
56
57 const H264ParseOptions& options() const {
58 return opt_;
59 }
60
61private:
63};
64
65} // namespace simaai::neat
66
67namespace simaai::neat::nodes {
68
69// Fully configurable (power user).
70std::shared_ptr<simaai::neat::Node> H264Parse(simaai::neat::H264ParseOptions opt);
71
72// Convenience: old behavior (only config-interval, no enforced caps).
73inline std::shared_ptr<simaai::neat::Node> H264Parse(int config_interval = 1) {
75 opt.config_interval = config_interval;
76 opt.enforce_caps = false;
77 return H264Parse(opt);
78}
79
80// Convenience preset: “AU-aligned access units” (replaces H264ParseAu node).
81// This should be the default for demux->decode paths where AU boundaries matter.
82inline std::shared_ptr<simaai::neat::Node> H264ParseAu(int config_interval = 1) {
84 opt.config_interval = config_interval;
85 opt.enforce_caps = true;
87 // stream_format left Auto unless you know you need ByteStream/AVC.
88 return H264Parse(opt);
89}
90
91// Convenience preset: “Streaming-safe” defaults.
92// Good for RTP/RTSP publishing where late-joiners need SPS/PPS.
93inline std::shared_ptr<simaai::neat::Node> H264ParseForRtp(int config_interval = 1) {
95 opt.config_interval = config_interval; // usually 1
96 opt.enforce_caps = true;
98 // stream_format left Auto to avoid forcing an incorrect mode for some MPKs.
99 return H264Parse(opt);
100}
101
102} // namespace simaai::neat::nodes

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.1.