From c0788a90a0d6e047488980a2ad5bb4f9cf108682 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Thu, 5 Sep 2019 11:15:58 +0200 Subject: Take BufferManagement setting into account --- src/ConfigParser.cpp | 11 +++++++++++ src/DabMultiplexer.cpp | 12 ++++++++++-- src/MuxElements.h | 9 +++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index 3142bb3..b1e785a 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -1021,6 +1021,17 @@ static void setup_subchannel_from_ptree(shared_ptr& subchan, } } + const string bufferManagement = pt.get("buffer-management", "prebuffering"); + if (bufferManagement == "prebuffering") { + subchan->bufferManagement = BufferManagement::Prebuffering; + } + else if (bufferManagement == "timestamped") { + subchan->bufferManagement = BufferManagement::Timestamped; + } + else { + throw runtime_error("Subchannel with uid " + subchanuid + " has invalid buffer-management !"); + } + subchan->startAddress = 0; dabProtection* protection = &subchan->protection; diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index 498e9e0..6b887bd 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -581,8 +581,16 @@ void DabMultiplexer::mux_frame(std::vector >& outputs edi::TagESTn& tag = edi_subchannelToTag[subchannel.get()]; int sizeSubchannel = subchannel->getSizeByte(); - int result = subchannel->input->readFrame( - &etiFrame[index], sizeSubchannel); + int result = -1; + switch (subchannel->bufferManagement) { + case BufferManagement::Prebuffering: + result = subchannel->input->readFrame(&etiFrame[index], sizeSubchannel); + break; + case BufferManagement::Timestamped: + // no need to check enableTist because we always increment the timestamp + result = subchannel->input->readFrame(&etiFrame[index], sizeSubchannel, edi_time + m_tist_offset, timestamp); + break; + } if (result < 0) { etiLog.log(info, diff --git a/src/MuxElements.h b/src/MuxElements.h index ec79fdd..f691093 100644 --- a/src/MuxElements.h +++ b/src/MuxElements.h @@ -338,6 +338,14 @@ struct dabProtection { }; }; +enum class BufferManagement { + // Use a buffer in the input that doesn't consider timestamps + Prebuffering, + + // Buffer incoming data until a given timestamp is reached + Timestamped, +}; + class DabSubchannel { public: @@ -359,6 +367,7 @@ public: std::string uid; std::string inputUri; + BufferManagement bufferManagement = BufferManagement::Prebuffering; std::shared_ptr input; unsigned char id = 0; subchannel_type_t type = subchannel_type_t::DABAudio; -- cgit v1.2.3