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(ERR_PUBLISH_ERROR, "publishPayloadImpl called without an active frame in GstreamerJsonFactory");
11 return false;
12 }
13 if (!payload) {
14 log->error(ERR_PUBLISH_ERROR, "payload is null in GstreamerJsonFactory::publishPayloadImpl");
15 return false;
16 }
17
18 // Separate the payload block from the header block if both are present.
19 if (current_frame_has_header) current_frame << ", ";
20
21 current_frame << "\"payload\": [";
22
23 bool wrote_first = false;
24 for (const auto* pl : *payload) {
25 if (!pl) continue;
26
27 if (wrote_first) current_frame << ", ";
28 wrote_first = true;
29
30 // Each payload object is written as one JSON array of integers.
31 current_frame << "[";
32 const auto vec = pl->getPayload();
33
34 for (size_t i = 0; i < vec.size(); i++) {
35 current_frame << vec[i];
36 if (i + 1 < vec.size()) current_frame << ", ";
37 }
38 current_frame << "]";
39 }
40
41 current_frame << "]";
42
43 current_frame_has_payload = true;
44 return true;
45}
std::shared_ptr< GLogger > log
void error(int exit_code, Args &&... args) const
Shared constants and error codes for the gstreamer module.
#define ERR_PUBLISH_ERROR
Publish sequence encountered invalid state or invalid input data.
JSON streamer plugin declarations.