aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/odr-padenc.cpp36
-rw-r--r--src/pad_common.cpp13
-rw-r--r--src/pad_common.h3
3 files changed, 34 insertions, 18 deletions
diff --git a/src/odr-padenc.cpp b/src/odr-padenc.cpp
index c96ca7a..b77cc04 100644
--- a/src/odr-padenc.cpp
+++ b/src/odr-padenc.cpp
@@ -200,7 +200,7 @@ class History {
};
-int encodeFile(int output_fd, const std::string& fname, int fidx, bool raw_slides);
+int encodeFile(const std::string& fname, int fidx, bool raw_slides);
uint8_vector_t createMotHeader(
size_t blobsize,
@@ -216,7 +216,7 @@ DATA_GROUP* packMscDG(MSCDG* msc);
struct DL_STATE;
void prepend_dl_dgs(const DL_STATE& dl_state, uint8_t charset);
-void writeDLS(int output_fd, const std::string& dls_file, uint8_t charset, bool raw_dls, bool remove_dls);
+void writeDLS(const std::string& dls_file, uint8_t charset, bool raw_dls, bool remove_dls);
// MOT Slideshow related
@@ -332,6 +332,7 @@ void MOTHeader::AddExtension(int param_id, const uint8_t* data_field, size_t dat
// DLS related
static const size_t DLS_SEG_LEN_PREFIX = 2;
static const size_t DLS_SEG_LEN_CHAR_MAX = 16;
+static const int DLS_REPETITION_WHILE_SLS = 50;
enum {
DLS_CMD_REMOVE_LABEL = 0b0001,
DLS_CMD_DL_PLUS = 0b0010
@@ -687,8 +688,10 @@ int main(int argc, char *argv[])
// if ATM no slides, transmit at least DLS
if (slides_to_transmit.empty()) {
- if (not dls_file.empty())
- writeDLS(output_fd, dls_file, charset, raw_dls, remove_dls);
+ if (not dls_file.empty()) {
+ writeDLS(dls_file, charset, raw_dls, remove_dls);
+ pad_packetizer->WriteAllPADs(output_fd);
+ }
sleep(sleepdelay);
} else {
@@ -700,7 +703,7 @@ int main(int argc, char *argv[])
it != slides_to_transmit.cend();
++it) {
- ret = encodeFile(output_fd, it->filepath, it->fidx, raw_slides);
+ ret = encodeFile(it->filepath, it->fidx, raw_slides);
if (ret != 1)
fprintf(stderr, "ODR-PadEnc Error: cannot encode file '%s'\n", it->filepath.c_str());
@@ -711,9 +714,18 @@ int main(int argc, char *argv[])
}
}
- // Always retransmit DLS after each slide, we want it to be updated frequently
+ // while flushing, insert DLS after a certain PAD amout
+ while (pad_packetizer->QueueFilled()) {
+ if (not dls_file.empty())
+ writeDLS(dls_file, charset, raw_dls, remove_dls);
+
+ pad_packetizer->WriteAllPADs(output_fd, DLS_REPETITION_WHILE_SLS);
+ }
+
+ // after the slide, output a last DLS
if (not dls_file.empty())
- writeDLS(output_fd, dls_file, charset, raw_dls, remove_dls);
+ writeDLS(dls_file, charset, raw_dls, remove_dls);
+ pad_packetizer->WriteAllPADs(output_fd);
sleep(sleepdelay);
}
@@ -722,7 +734,8 @@ int main(int argc, char *argv[])
}
} else { // only DLS
// Always retransmit DLS, we want it to be updated frequently
- writeDLS(output_fd, dls_file, charset, raw_dls, remove_dls);
+ writeDLS(dls_file, charset, raw_dls, remove_dls);
+ pad_packetizer->WriteAllPADs(output_fd);
sleep(sleepdelay);
}
@@ -837,7 +850,7 @@ size_t resizeImage(MagickWand* m_wand, unsigned char** blob, const std::string&
}
#endif
-int encodeFile(int output_fd, const std::string& fname, int fidx, bool raw_slides)
+int encodeFile(const std::string& fname, int fidx, bool raw_slides)
{
int ret = 0;
int nseg, lastseglen, i, last, curseglen;
@@ -1060,8 +1073,6 @@ int encodeFile(int output_fd, const std::string& fname, int fidx, bool raw_slide
pad_packetizer->AddDG(mscdg, false);
}
- pad_packetizer->WriteAllPADs(output_fd);
-
ret = 1;
}
@@ -1400,7 +1411,7 @@ void parse_dl_params(std::ifstream &dls_fstream, DL_STATE &dl_state) {
}
-void writeDLS(int output_fd, const std::string& dls_file, uint8_t charset, bool raw_dls, bool remove_dls)
+void writeDLS(const std::string& dls_file, uint8_t charset, bool raw_dls, bool remove_dls)
{
std::ifstream dls_fstream(dls_file);
if (!dls_fstream.is_open()) {
@@ -1493,7 +1504,6 @@ void writeDLS(int output_fd, const std::string& dls_file, uint8_t charset, bool
prepend_dl_dgs(dl_state, charset);
if (remove_label_dg)
pad_packetizer->AddDG(remove_label_dg, true);
- pad_packetizer->WriteAllPADs(output_fd);
}
diff --git a/src/pad_common.cpp b/src/pad_common.cpp
index 450b122..7cc422d 100644
--- a/src/pad_common.cpp
+++ b/src/pad_common.cpp
@@ -99,11 +99,15 @@ PADPacketizer::~PADPacketizer() {
}
void PADPacketizer::AddDG(DATA_GROUP* dg, bool prepend) {
- queue.insert(prepend ? queue.begin() : queue.end(), dg);
+ queue.insert(prepend ? queue.begin() : queue.end(), dg);
}
void PADPacketizer::AddDGs(const std::vector<DATA_GROUP*>& dgs, bool prepend) {
- queue.insert(prepend ? queue.begin() : queue.end(), dgs.cbegin(), dgs.cend());
+ queue.insert(prepend ? queue.begin() : queue.end(), dgs.cbegin(), dgs.cend());
+}
+
+bool PADPacketizer::QueueFilled() {
+ return !queue.empty();
}
pad_t* PADPacketizer::GetPAD() {
@@ -127,8 +131,9 @@ pad_t* PADPacketizer::GetPAD() {
return FlushPAD();
}
-void PADPacketizer::WriteAllPADs(int output_fd) {
- for (;;) {
+void PADPacketizer::WriteAllPADs(int output_fd, int limit) {
+ // output a limited amount of PADs (-1 = no limit)
+ for (int i = 0; i != limit; i++) {
pad_t* pad = GetPAD();
// if only F-PAD present, abort
diff --git a/src/pad_common.h b/src/pad_common.h
index c997d83..c3ee01d 100644
--- a/src/pad_common.h
+++ b/src/pad_common.h
@@ -105,9 +105,10 @@ public:
void AddDG(DATA_GROUP* dg, bool prepend);
void AddDGs(const std::vector<DATA_GROUP*>& dgs, bool prepend);
+ bool QueueFilled();
pad_t* GetPAD();
// will be removed, when pull (instead of push) approach is implemented!
- void WriteAllPADs(int output_fd);
+ void WriteAllPADs(int output_fd, int limit = -1);
};