Skip to main content

SimaaiGstErrors.h File

Included Headers

#include <gst/gst.h> #include <cstdarg> #include <cstdint> #include <cstdio> #include <sstream> #include <string> #include <vector>

Classes Index

structSimaaiGstErrorContext

Functions Index

const char *simaai_gst_safe (const char *s)
voidsimaai_gst_append_kv (std::ostringstream &ss, const char *key, const char *value)
voidsimaai_gst_append_kv_required (std::ostringstream &ss, const char *key, const char *value)
voidsimaai_gst_append_kv_int (std::ostringstream &ss, const char *key, std::int64_t value)
std::stringsimaai_gst_format_context (const SimaaiGstErrorContext &ctx)
std::stringsimaai_gst_format_detail (const SimaaiGstErrorContext &ctx, const char *detail)
std::stringsimaai_gst_vformat (const char *fmt, va_list ap)
std::stringsimaai_gst_format_detailf (const SimaaiGstErrorContext &ctx, const char *fmt,...)

Macro Definitions Index

#defineSIMAAI_GST_FATAL(self, domain, code, summary, detail)   ...
#defineSIMAAI_GST_WARN(self, summary, detail)   ...

Functions

simaai_gst_append_kv()

void simaai_gst_append_kv (std::ostringstream & ss, const char * key, const char * value)
inline

Definition at line 38 of file SimaaiGstErrors.h.

38inline void simaai_gst_append_kv(std::ostringstream& ss, const char* key, const char* value) {
39 if (!value || !*value)
40 return;
41 if (ss.tellp() > 0)
42 ss << ' ';
43 ss << key << "='" << value << "'";
44}

simaai_gst_append_kv_int()

void simaai_gst_append_kv_int (std::ostringstream & ss, const char * key, std::int64_t value)
inline

Definition at line 53 of file SimaaiGstErrors.h.

53inline void simaai_gst_append_kv_int(std::ostringstream& ss, const char* key, std::int64_t value) {
54 if (ss.tellp() > 0)
55 ss << ' ';
56 ss << key << '=' << value;
57}

simaai_gst_append_kv_required()

void simaai_gst_append_kv_required (std::ostringstream & ss, const char * key, const char * value)
inline

Definition at line 46 of file SimaaiGstErrors.h.

46inline void simaai_gst_append_kv_required(std::ostringstream& ss, const char* key,
47 const char* value) {
48 if (ss.tellp() > 0)
49 ss << ' ';
50 ss << key << "='" << simaai_gst_safe(value) << "'";
51}

simaai_gst_format_context()

std::string simaai_gst_format_context (const SimaaiGstErrorContext & ctx)
inline

Definition at line 59 of file SimaaiGstErrors.h.

59inline std::string simaai_gst_format_context(const SimaaiGstErrorContext& ctx) {
60 std::ostringstream ss;
61 simaai_gst_append_kv(ss, "plugin", ctx.plugin);
62 simaai_gst_append_kv(ss, "node", ctx.node);
63 simaai_gst_append_kv(ss, "config_path", ctx.config_path);
64 simaai_gst_append_kv(ss, "model_path", ctx.model_path);
65 if (ctx.graph_id >= 0)
66 simaai_gst_append_kv_int(ss, "graph_id", ctx.graph_id);
67 if (ctx.frame_id >= 0)
68 simaai_gst_append_kv_int(ss, "frame_id", ctx.frame_id);
69 simaai_gst_append_kv(ss, "stream_id", ctx.stream_id);
70 simaai_gst_append_kv(ss, "input_caps", ctx.input_caps);
71 simaai_gst_append_kv(ss, "output_caps", ctx.output_caps);
72 simaai_gst_append_kv(ss, "input_dims", ctx.input_dims);
73 simaai_gst_append_kv(ss, "output_dims", ctx.output_dims);
74 simaai_gst_append_kv(ss, "allocator", ctx.allocator);
75 simaai_gst_append_kv(ss, "dispatcher_err", ctx.dispatcher_err);
76 simaai_gst_append_kv(ss, "hint", ctx.hint);
77 simaai_gst_append_kv(ss, "manifest_version", ctx.manifest_version);
78 simaai_gst_append_kv(ss, "stage_key", ctx.stage_key);
80 ss, "source_used",
81 (ctx.source_used && *ctx.source_used) ? ctx.source_used : "infer->caps/properties/context");
82 simaai_gst_append_kv_required(ss, "missing_field",
84 : "none");
86 ss, "fallback_chain",
88 : "infer->caps/properties/context->json");
89 return ss.str();
90}

simaai_gst_format_detail()

std::string simaai_gst_format_detail (const SimaaiGstErrorContext & ctx, const char * detail)
inline

Definition at line 92 of file SimaaiGstErrors.h.

92inline std::string simaai_gst_format_detail(const SimaaiGstErrorContext& ctx, const char* detail) {
93 std::ostringstream ss;
94 std::string base = simaai_gst_format_context(ctx);
95 if (!base.empty())
96 ss << base;
97 if (detail && *detail) {
98 simaai_gst_append_kv(ss, "detail", detail);
99 }
100 return ss.str();
101}

simaai_gst_format_detailf()

std::string simaai_gst_format_detailf (const SimaaiGstErrorContext & ctx, const char * fmt, ...)
inline

Definition at line 117 of file SimaaiGstErrors.h.

117inline std::string simaai_gst_format_detailf(const SimaaiGstErrorContext& ctx, const char* fmt,
118 ...) {
119 va_list ap;
120 va_start(ap, fmt);
121 std::string detail = simaai_gst_vformat(fmt, ap);
122 va_end(ap);
123 return simaai_gst_format_detail(ctx, detail.c_str());
124}

simaai_gst_safe()

const char* simaai_gst_safe (const char * s)
inline

Definition at line 34 of file SimaaiGstErrors.h.

34inline const char* simaai_gst_safe(const char* s) {
35 return s ? s : "";
36}

simaai_gst_vformat()

std::string simaai_gst_vformat (const char * fmt, va_list ap)
inline

Definition at line 103 of file SimaaiGstErrors.h.

103inline std::string simaai_gst_vformat(const char* fmt, va_list ap) {
104 if (!fmt || !*fmt)
105 return {};
106 va_list ap_copy;
107 va_copy(ap_copy, ap);
108 const int needed = std::vsnprintf(nullptr, 0, fmt, ap_copy);
109 va_end(ap_copy);
110 if (needed <= 0)
111 return {};
112 std::vector<char> buf(static_cast<size_t>(needed) + 1, '\0');
113 std::vsnprintf(buf.data(), buf.size(), fmt, ap);
114 return std::string(buf.data());
115}

Macro Definitions

SIMAAI_GST_FATAL

#define SIMAAI_GST_FATAL(self, domain, code, summary, detail)   ...
Value
do { \ GST_ERROR_OBJECT((self), "%s", (summary)); \ gst_element_message_full(GST_ELEMENT(self), GST_MESSAGE_ERROR, (domain), (code), \ g_strdup(summary), g_strdup((detail) ? (detail) : ""), __FILE__, \ G_STRFUNC, __LINE__); \ } while (0)

Definition at line 126 of file SimaaiGstErrors.h.

126#define SIMAAI_GST_FATAL(self, domain, code, summary, detail) \

SIMAAI_GST_WARN

#define SIMAAI_GST_WARN(self, summary, detail)   ...
Value
do { \ if ((detail) && *(detail)) { \ GST_WARNING_OBJECT((self), "%s | %s", (summary), (detail)); \ } else { \ GST_WARNING_OBJECT((self), "%s", (summary)); \ } \ } while (0)

Definition at line 134 of file SimaaiGstErrors.h.

134#define SIMAAI_GST_WARN(self, summary, detail) \

File Listing

The file content with the documentation metadata removed is:

1#pragma once
2
3#include <gst/gst.h>
4
5#include <cstdarg>
6#include <cstdint>
7#include <cstdio>
8#include <sstream>
9#include <string>
10#include <vector>
11
13 const char* plugin = nullptr;
14 const char* node = nullptr;
15 const char* config_path = nullptr;
16 const char* model_path = nullptr;
17 int graph_id = -1;
18 std::int64_t frame_id = -1;
19 const char* stream_id = nullptr;
20 const char* input_caps = nullptr;
21 const char* output_caps = nullptr;
22 const char* input_dims = nullptr;
23 const char* output_dims = nullptr;
24 const char* allocator = nullptr;
25 const char* dispatcher_err = nullptr;
26 const char* hint = nullptr;
27 const char* manifest_version = nullptr;
28 const char* stage_key = nullptr;
29 const char* source_used = nullptr;
30 const char* missing_field = nullptr;
31 const char* fallback_chain = nullptr;
32};
33
34inline const char* simaai_gst_safe(const char* s) {
35 return s ? s : "";
36}
37
38inline void simaai_gst_append_kv(std::ostringstream& ss, const char* key, const char* value) {
39 if (!value || !*value)
40 return;
41 if (ss.tellp() > 0)
42 ss << ' ';
43 ss << key << "='" << value << "'";
44}
45
46inline void simaai_gst_append_kv_required(std::ostringstream& ss, const char* key,
47 const char* value) {
48 if (ss.tellp() > 0)
49 ss << ' ';
50 ss << key << "='" << simaai_gst_safe(value) << "'";
51}
52
53inline void simaai_gst_append_kv_int(std::ostringstream& ss, const char* key, std::int64_t value) {
54 if (ss.tellp() > 0)
55 ss << ' ';
56 ss << key << '=' << value;
57}
58
59inline std::string simaai_gst_format_context(const SimaaiGstErrorContext& ctx) {
60 std::ostringstream ss;
61 simaai_gst_append_kv(ss, "plugin", ctx.plugin);
62 simaai_gst_append_kv(ss, "node", ctx.node);
63 simaai_gst_append_kv(ss, "config_path", ctx.config_path);
64 simaai_gst_append_kv(ss, "model_path", ctx.model_path);
65 if (ctx.graph_id >= 0)
66 simaai_gst_append_kv_int(ss, "graph_id", ctx.graph_id);
67 if (ctx.frame_id >= 0)
68 simaai_gst_append_kv_int(ss, "frame_id", ctx.frame_id);
69 simaai_gst_append_kv(ss, "stream_id", ctx.stream_id);
70 simaai_gst_append_kv(ss, "input_caps", ctx.input_caps);
71 simaai_gst_append_kv(ss, "output_caps", ctx.output_caps);
72 simaai_gst_append_kv(ss, "input_dims", ctx.input_dims);
73 simaai_gst_append_kv(ss, "output_dims", ctx.output_dims);
74 simaai_gst_append_kv(ss, "allocator", ctx.allocator);
75 simaai_gst_append_kv(ss, "dispatcher_err", ctx.dispatcher_err);
76 simaai_gst_append_kv(ss, "hint", ctx.hint);
77 simaai_gst_append_kv(ss, "manifest_version", ctx.manifest_version);
78 simaai_gst_append_kv(ss, "stage_key", ctx.stage_key);
80 ss, "source_used",
81 (ctx.source_used && *ctx.source_used) ? ctx.source_used : "infer->caps/properties/context");
82 simaai_gst_append_kv_required(ss, "missing_field",
84 : "none");
86 ss, "fallback_chain",
88 : "infer->caps/properties/context->json");
89 return ss.str();
90}
91
92inline std::string simaai_gst_format_detail(const SimaaiGstErrorContext& ctx, const char* detail) {
93 std::ostringstream ss;
94 std::string base = simaai_gst_format_context(ctx);
95 if (!base.empty())
96 ss << base;
97 if (detail && *detail) {
98 simaai_gst_append_kv(ss, "detail", detail);
99 }
100 return ss.str();
101}
102
103inline std::string simaai_gst_vformat(const char* fmt, va_list ap) {
104 if (!fmt || !*fmt)
105 return {};
106 va_list ap_copy;
107 va_copy(ap_copy, ap);
108 const int needed = std::vsnprintf(nullptr, 0, fmt, ap_copy);
109 va_end(ap_copy);
110 if (needed <= 0)
111 return {};
112 std::vector<char> buf(static_cast<size_t>(needed) + 1, '\0');
113 std::vsnprintf(buf.data(), buf.size(), fmt, ap);
114 return std::string(buf.data());
115}
116
117inline std::string simaai_gst_format_detailf(const SimaaiGstErrorContext& ctx, const char* fmt,
118 ...) {
119 va_list ap;
120 va_start(ap, fmt);
121 std::string detail = simaai_gst_vformat(fmt, ap);
122 va_end(ap);
123 return simaai_gst_format_detail(ctx, detail.c_str());
124}
125
126#define SIMAAI_GST_FATAL(self, domain, code, summary, detail) \
127 do { \
128 GST_ERROR_OBJECT((self), "%s", (summary)); \
129 gst_element_message_full(GST_ELEMENT(self), GST_MESSAGE_ERROR, (domain), (code), \
130 g_strdup(summary), g_strdup((detail) ? (detail) : ""), __FILE__, \
131 G_STRFUNC, __LINE__); \
132 } while (0)
133
134#define SIMAAI_GST_WARN(self, summary, detail) \
135 do { \
136 if ((detail) && *(detail)) { \
137 GST_WARNING_OBJECT((self), "%s | %s", (summary), (detail)); \
138 } else { \
139 GST_WARNING_OBJECT((self), "%s", (summary)); \
140 } \
141 } while (0)

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.1.