gstreamer
Loading...
Searching...
No Matches
publishPayload.cc
Go to the documentation of this file.
1// gstreamer
4
5// Implementation summary:
6// Append the frame payload block to the JSON object currently being assembled.
7
8bool GstreamerJsonFactory::publishPayloadImpl(const std::vector<GIntegralPayload*>* payload) {
9 if (!is_building_frame) {
11 "publishPayloadImpl called without an active frame in GstreamerJsonFactory");
12 return false;
13 }
14 if (!payload) {
15 log->error(gstreamer::ERR_PUBLISH_ERROR, "payload is null in GstreamerJsonFactory::publishPayloadImpl");
16 return false;
17 }
18
19 // Separate the payload block from the header block if both are present.
20 if (current_frame_has_header) current_frame << ", ";
21
22 current_frame << "\"payload\": [";
23
24 bool wrote_first = false;
25 for (const auto* pl : *payload) {
26 if (!pl) continue;
27
28 if (wrote_first) current_frame << ", ";
29 wrote_first = true;
30
31 // Each payload object is written as one JSON array of integers.
32 current_frame << "[";
33 const auto vec = pl->getPayload();
34
35 for (size_t i = 0; i < vec.size(); i++) {
36 current_frame << vec[i];
37 if (i + 1 < vec.size()) current_frame << ", ";
38 }
39 current_frame << "]";
40 }
41
42 current_frame << "]";
43
44 current_frame_has_payload = true;
45 return true;
46}
std::shared_ptr< GLogger > log
Shared constants and error codes for the gstreamer module.
JSON streamer plugin declarations.
constexpr int ERR_PUBLISH_ERROR
Publish sequence encountered invalid state or invalid input data.