From 222e277c57769486800a43bc758175567231db40 Mon Sep 17 00:00:00 2001 From: Stefan Pöschel Date: Mon, 6 Feb 2017 23:56:42 +0100 Subject: PAD: insert DLS regularly while SLS transmission When a slide is transmitted, now every 50 PADs the current DLS is inserted (and thereby reread from file). Hence in the best case (AAC-LC @ 48 kHz), DLS is inserted every 1000ms; in the worst case (HE-AAC @ 32 kHz) it is inserted every 3000ms. This way a listener will get DLS much earlier after switching to a service, compared to the previous situation where the slide transmission was not interrupted for DLS insertion. Note that there still remains a delay without any PAD, between the end of a slide transmission and the start of the next one's transmission. Also note that adding a feedback channel from the audio encoder to ODR-PadEnc will make this improvement obsolete. --- src/odr-padenc.cpp | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src/odr-padenc.cpp') 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); } -- cgit v1.2.3