gstreamer
Loading...
Searching...
No Matches
gstreamerASCIIConnection.cc
Go to the documentation of this file.
1// gstreamer
4
5// Implementation summary:
6// Manage the lifetime of the text output stream used by the ASCII plugin.
7
8bool GstreamerTextFactory::openConnection() {
9 if (ofile.is_open()) {
10 // Already open for this streamer instance.
11 return true;
12 }
13
14 ofile.clear();
15
16 // Open for writing and truncate any existing file content so each run starts fresh.
17 ofile.open(filename(), std::ios::out | std::ios::trunc);
18
19 if (!ofile.is_open() || !ofile) {
20 log->error(ERR_CANTOPENOUTPUT, SFUNCTION_NAME, " could not open file ", filename());
21 }
22
23 log->info(1, SFUNCTION_NAME, "GstreamerTextFactory: opened file " + filename());
24
25 return true;
26}
27
28bool GstreamerTextFactory::closeConnectionImpl() {
29 // The public closeConnection() wrapper already flushes pending events before calling this method.
30
31 if (ofile.is_open()) ofile.close();
32 if (ofile.is_open()) { log->error(ERR_CANTCLOSEOUTPUT, SFUNCTION_NAME, " could not close file " + filename()); }
33
34 log->info(1, SFUNCTION_NAME, "GstreamerTextFactory: closed file " + filename());
35
36 return true;
37}
std::shared_ptr< GLogger > log
void info(int level, Args &&... args) const
void error(int exit_code, Args &&... args) const
ASCII 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.