gstreamer
Loading...
Searching...
No Matches
stream.cc
Go to the documentation of this file.
1// gstreamer
4
5bool GstreamerJsonFactory::startStreamImpl(const GFrameDataCollection* frameRunData) {
6 if (!ofile.is_open()) { log->error(ERR_CANTOPENOUTPUT, SFUNCTION_NAME, "Error: can't access ", filename()); }
7 if (!frameRunData) { log->error(ERR_PUBLISH_ERROR, "frameRunData is null in GstreamerJsonFactory::startStreamImpl"); }
8
9 ensureFileInitializedForType("stream");
10
11 is_building_frame = true;
12 current_frame.str(std::string());
13 current_frame.clear();
14 current_frame_has_header = false;
15 current_frame_has_payload = false;
16
17 current_frame << "{";
18 return true;
19}
20
21bool GstreamerJsonFactory::endStreamImpl(const GFrameDataCollection* frameRunData) {
22 if (!is_building_frame) {
23 log->error(ERR_PUBLISH_ERROR, "endStreamImpl called without an active frame in GstreamerJsonFactory");
24 return false;
25 }
26
27 // Close any missing blocks with empty placeholders.
28 if (!current_frame_has_header) {
29 if (current_frame.str().size() > 1) current_frame << ", ";
30 current_frame << "\"header\": {}";
31 }
32 if (!current_frame_has_payload) {
33 if (current_frame.str().size() > 1) current_frame << ", ";
34 current_frame << "\"payload\": []";
35 }
36
37 current_frame << "}";
38
39 writeTopLevelEntry(current_frame.str());
40
41 is_building_frame = false;
42
43 (void)frameRunData;
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
Generic publish-time error (null pointers, invalid state).
#define ERR_CANTOPENOUTPUT
Output medium could not be opened (file/device not accessible).