Skip to main content

H264Parse.h File

H264Parse Node — parses an H.264 stream into NAL units, optionally enforcing caps. 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

Construction options for an H264Parse Node — config-interval and optional caps lock. More...

classH264Parse

H.264 stream parser Node — parses NAL units, finds keyframes, optionally locks caps. More...

Description

H264Parse Node — parses an H.264 stream into NAL units, optionally enforcing caps.

Wraps GStreamer's h264parse element and an optional capsfilter to deterministically lock the access-unit alignment and stream format. Use upstream of any H.264 decoder when the source isn't already AU-aligned, and upstream of RTP packetizers where receivers need periodic SPS/PPS injection.

File Listing

The file content with the documentation metadata removed is:

1// include/nodes/sima/H264Parse.h
12#pragma once
13
14#include "builder/Node.h"
15#include "builder/OutputSpec.h"
16
17#include <memory>
18#include <optional>
19#include <string>
20#include <vector>
21
22namespace simaai::neat {
23
24// GStreamer h264parse + (optional) caps enforcement.
25//
26// Why caps enforcement is inside this node:
27// - AU/NAL alignment is often a CAPS negotiation detail (not always a property)
28// - Keeping it here avoids users sprinkling raw capsfilter strings everywhere
29// - Still prints a clean gst-launch repro string
30
40
41 // Optional: enforce downstream caps after h264parse via a capsfilter.
42 // This is how we express AU alignment and stream-format deterministically.
44 enum class Alignment { Auto, AU, NAL };
46 enum class StreamFormat { Auto, AVC, ByteStream };
47
51
53 bool enforce_caps = false;
54};
55
61class H264Parse final : public Node, public OutputSpecProvider {
62public:
64 explicit H264Parse(H264ParseOptions opt = {});
66 std::string kind() const override {
67 return "H264Parse";
68 }
70 NodeCapsBehavior caps_behavior() const override {
71 return opt_.enforce_caps ? NodeCapsBehavior::Static : NodeCapsBehavior::Dynamic;
72 }
73
75 std::string backend_fragment(int node_index) const override;
77 std::vector<std::string> element_names(int node_index) const override;
79 OutputSpec output_spec(const OutputSpec& input) const override;
80
82 const H264ParseOptions& options() const {
83 return opt_;
84 }
85
86private:
88};
89
90} // namespace simaai::neat
91
92namespace simaai::neat::nodes {
93
95std::shared_ptr<simaai::neat::Node> H264Parse(simaai::neat::H264ParseOptions opt);
96
98inline std::shared_ptr<simaai::neat::Node> H264Parse(int config_interval = 1) {
100 opt.config_interval = config_interval;
101 opt.enforce_caps = false;
102 return H264Parse(opt);
103}
104
107inline std::shared_ptr<simaai::neat::Node> H264ParseAu(int config_interval = 1) {
109 opt.config_interval = config_interval;
110 opt.enforce_caps = true;
112 // stream_format left Auto unless you know you need ByteStream/AVC.
113 return H264Parse(opt);
114}
115
118inline std::shared_ptr<simaai::neat::Node> H264ParseForRtp(int config_interval = 1) {
120 opt.config_interval = config_interval; // usually 1
121 opt.enforce_caps = true;
123 // stream_format left Auto to avoid forcing an incorrect mode for some MPKs.
124 return H264Parse(opt);
125}
126
127} // namespace simaai::neat::nodes

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.