Skip to main content

GraphMetadata.h File

Stream metadata helpers for graph samples. More...

Included Headers

#include "graph/Graph.h" #include "pipeline/SessionOptions.h" #include <cstdint> #include <string> #include <unordered_map>

Namespaces Index

namespacesimaai
namespaceneat
namespacegraph

Classes Index

structStreamMetadataDefaults

Defaults applied to a Sample by the StreamMetadata stage. More...

Description

Stream metadata helpers for graph samples.

File Listing

The file content with the documentation metadata removed is:

1
6#pragma once
7
8#include "graph/Graph.h"
10
11#include <cstdint>
12#include <string>
13#include <unordered_map>
14
15namespace simaai::neat::graph {
16
29 std::string stream_id;
30 std::string caps_string;
31 std::string stream_label;
32 std::string port_name;
33 std::string media_type;
34 std::string format;
35 std::string payload_tag;
36 bool fill_stream_id = true;
37 bool fill_input_seq = true;
38 bool fill_orig_input_seq = true;
39};
40
53inline void ensure_stream_metadata(Sample& sample, const StreamMetadataDefaults& defaults,
54 std::unordered_map<std::string, int64_t>* next_seq = nullptr) {
55 if (sample.stream_id.empty() && defaults.fill_stream_id) {
56 if (!defaults.stream_id.empty()) {
57 sample.stream_id = defaults.stream_id;
58 } else {
59 sample.stream_id = "stream0";
60 }
61 }
62
63 if (defaults.fill_input_seq && sample.input_seq < 0) {
64 if (sample.orig_input_seq >= 0) {
65 sample.input_seq = sample.orig_input_seq;
66 } else if (next_seq) {
67 auto& next = (*next_seq)[sample.stream_id];
68 sample.input_seq = next++;
69 } else {
70 sample.input_seq = 0;
71 }
72 }
73
74 if (defaults.fill_orig_input_seq && sample.orig_input_seq < 0) {
75 sample.orig_input_seq = sample.input_seq;
76 }
77
78 if (sample.caps_string.empty() && !defaults.caps_string.empty()) {
79 sample.caps_string = defaults.caps_string;
80 }
81 if (sample.stream_label.empty()) {
82 if (!defaults.stream_label.empty()) {
83 sample.stream_label = defaults.stream_label;
84 } else if (!defaults.port_name.empty()) {
85 sample.stream_label = defaults.port_name;
86 }
87 }
88 if (sample.port_name.empty() && !defaults.port_name.empty()) {
89 sample.port_name = defaults.port_name;
90 }
91 if (sample.media_type.empty() && !defaults.media_type.empty()) {
92 sample.media_type = defaults.media_type;
93 }
94 if (sample.format.empty() && !defaults.format.empty()) {
95 sample.format = defaults.format;
96 }
97 if (sample.payload_tag.empty() && !defaults.payload_tag.empty()) {
98 sample.payload_tag = defaults.payload_tag;
99 }
100}
101
102} // namespace simaai::neat::graph

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.