summaryrefslogtreecommitdiffstats
path: root/src/dabOutput/dabOutputFifo.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-09-16 16:51:49 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-09-16 16:51:49 +0200
commit832952bb3f521e1c022d0faa8b6782f76899a770 (patch)
treec7e4a49222dd976b8423ad3276c6add715a4bd5b /src/dabOutput/dabOutputFifo.cpp
parent10c2b330c8831fe239848005cdb80efa1c222ad9 (diff)
parente0a3d294c48d234a21a1a2403cbe200ae287e82e (diff)
downloaddabmux-832952bb3f521e1c022d0faa8b6782f76899a770.tar.gz
dabmux-832952bb3f521e1c022d0faa8b6782f76899a770.tar.bz2
dabmux-832952bb3f521e1c022d0faa8b6782f76899a770.zip
Merge master of DavidLutton/ODR-DabMux into next
Diffstat (limited to 'src/dabOutput/dabOutputFifo.cpp')
-rw-r--r--src/dabOutput/dabOutputFifo.cpp54
1 files changed, 53 insertions, 1 deletions
diff --git a/src/dabOutput/dabOutputFifo.cpp b/src/dabOutput/dabOutputFifo.cpp
index 6b1c016..decd443 100644
--- a/src/dabOutput/dabOutputFifo.cpp
+++ b/src/dabOutput/dabOutputFifo.cpp
@@ -27,8 +27,61 @@
#include <cstring>
#include <fcntl.h>
#include <limits.h>
+#include <sys/types.h> // mkfifo
+#include <sys/stat.h> // mkfifo
#include "dabOutput.h"
+int DabOutputFifo::Open(const char* filename)
+{
+ char* token = strchr((char*)filename, '?');
+ if (token != NULL) {
+ *(token++) = 0;
+ char* nextPair;
+ char* key;
+ char* value;
+ // Go through all the &stuff=foo pairs
+ // Only the key "type" is supported
+ do {
+ nextPair = strchr(token, '&');
+ if (nextPair != NULL) {
+ *nextPair = 0;
+ }
+ key = token;
+ value = strchr(token, '=');
+ if (value != NULL) {
+ *(value++) = 0;
+ if (strcmp(key, "type") == 0) {
+ if (strcmp(value, "raw") == 0) {
+ this->type_ = ETI_FILE_TYPE_RAW;
+ break;
+ } else if (strcmp(value, "framed") == 0) {
+ this->type_ = ETI_FILE_TYPE_FRAMED;
+ break;
+ } else if (strcmp(value, "streamed") == 0) {
+ this->type_ = ETI_FILE_TYPE_STREAMED;
+ break;
+ } else {
+ etiLog.log(error,
+ "File type '%s' is not supported.\n", value);
+ return -1;
+ }
+ }
+ else {
+ etiLog.log(warn, "Parameter '%s' unknown\n", key);
+ }
+ }
+ } while (nextPair != NULL);
+ }
+
+ this->file_ = mkfifo(filename, 0666);
+ this->file_ = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
+ if (this->file_ == -1) {
+ perror(filename);
+ return -1;
+ }
+ return 0;
+}
+
int DabOutputFifo::Write(void* buffer, int size)
{
@@ -71,4 +124,3 @@ FIFO_WRITE_ERROR:
perror("Error while writting to file");
return -1;
}
-