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) {
10 log->error(
12 "publishPayloadImpl called without an active frame in GstreamerJsonFactory");
13 return false;
14 }
15 if (!payload) {
16 log->error(gstreamer::ERR_PUBLISH_ERROR, "payload is null in GstreamerJsonFactory::publishPayloadImpl");
17 return false;
18 }
19
20 // Separate the payload block from the header block if both are present.
21 if (current_frame_has_header) current_frame << ", ";
22
23 current_frame << "\"payload\": [";
24
25 bool wrote_first = false;
26 for (const auto* pl : *payload) {
27 if (!pl) continue;
28
29 if (wrote_first) current_frame << ", ";
30 wrote_first = true;
31
32 // Each payload object is written as one JSON array of integers.
33 current_frame << "[";
34 const auto vec = pl->getPayload();
35
36 for (size_t i = 0; i < vec.size(); i++) {
37 current_frame << vec[i];
38 if (i + 1 < vec.size()) current_frame << ", ";
39 }
40 current_frame << "]";
41 }
42
43 current_frame << "]";
44
45 current_frame_has_payload = true;
46 return true;
47}
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.