gstreamer
Loading...
Searching...
No Matches
gstreamerCSVConnection.cc
Go to the documentation of this file.
1// gstreamer
4
5// Implementation summary:
6// Manage the lifetime of the two CSV streams used by the plugin.
7
8bool GstreamerCsvFactory::openConnection() {
9 // Both streams must be open for the CSV backend to operate correctly.
10 if (ofile_true_info.is_open() && ofile_digitized.is_open()) {
11 return true;
12 }
13
14 if (!ofile_true_info.is_open()) {
15 ofile_true_info.clear();
16 ofile_true_info.open(filename_true_info(), std::ios::out | std::ios::trunc);
17
18 if (!ofile_true_info.is_open() || !ofile_true_info) {
19 log->error(ERR_CANTOPENOUTPUT, SFUNCTION_NAME, " could not open file ", filename_true_info());
20 }
21
22 log->info(1, SFUNCTION_NAME, "GstreamerCsvFactory: opened file " + filename_true_info());
23 }
24
25 if (!ofile_digitized.is_open()) {
26 ofile_digitized.clear();
27 ofile_digitized.open(filename_digitized(), std::ios::out | std::ios::trunc);
28
29 if (!ofile_digitized.is_open() || !ofile_digitized) {
30 log->error(ERR_CANTOPENOUTPUT, SFUNCTION_NAME, " could not open file ", filename_digitized());
31 }
32
33 log->info(1, SFUNCTION_NAME, "GstreamerCsvFactory: opened file " + filename_digitized());
34 }
35
36 return true;
37}
38
39bool GstreamerCsvFactory::closeConnectionImpl() {
40 // The public closeConnection() wrapper already flushes buffered events before this method runs.
41
42 if (ofile_true_info.is_open()) ofile_true_info.close();
43 if (ofile_digitized.is_open()) ofile_digitized.close();
44
45 if (ofile_true_info.is_open()) {
46 log->error(ERR_CANTCLOSEOUTPUT, SFUNCTION_NAME, " could not close file " + filename_true_info());
47 }
48 if (ofile_digitized.is_open()) {
49 log->error(ERR_CANTCLOSEOUTPUT, SFUNCTION_NAME, " could not close file " + filename_digitized());
50 }
51
52 log->info(1, SFUNCTION_NAME, "GstreamerCsvFactory: closed file " + filename_true_info());
53 log->info(1, SFUNCTION_NAME, "GstreamerCsvFactory: closed file " + filename_digitized());
54
55 return true;
56}
std::shared_ptr< GLogger > log
void info(int level, Args &&... args) const
void error(int exit_code, Args &&... args) const
CSV streamer plugin declarations.
Shared constants and error codes for the gstreamer module.
#define ERR_CANTCLOSEOUTPUT
Output medium could not be closed cleanly.
#define ERR_CANTOPENOUTPUT
Output medium could not be opened successfully.