From c1599cb19601443c48c45c5ad8d1b0d40a6238bc Mon Sep 17 00:00:00 2001 From: Stefan Pöschel Date: Sun, 24 Apr 2016 22:18:56 +0200 Subject: DLS: add DL Plus support - adds support for Dynamic Label Plus to mot-encoder through a new parameter block which prepends the DLS text within the regarding file - adds an option to add DL Plus data to the VLC input ICY text of dabplus-enc --- src/VLCInput.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/VLCInput.cpp') diff --git a/src/VLCInput.cpp b/src/VLCInput.cpp index 468ef70..fc7e07f 100644 --- a/src/VLCInput.cpp +++ b/src/VLCInput.cpp @@ -337,20 +337,36 @@ ssize_t VLCInputDirect::read(uint8_t* buf, size_t length) return read; } -bool write_icy_to_file(const std::string& text, const std::string& filename) +bool write_icy_to_file(const std::string& text, const std::string& filename, bool dl_plus) { FILE* fd = fopen(filename.c_str(), "wb"); if (fd) { - int ret = fputs(text.c_str(), fd); + bool ret = true; + + // if desired, prepend DL Plus information + if (dl_plus) { + std::stringstream ss; + ss << "##### parameters { #####\n"; + ss << "DL_PLUS=1\n"; + + // if non-empty text, add PROGRAMME.NOW tag + if (!text.empty()) + ss << "DL_PLUS_TAG=33 0 " << (strlen_utf8(text.c_str()) - 1) << "\n"; // -1 ! + + ss << "##### parameters } #####\n"; + ret &= fputs(ss.str().c_str(), fd) >= 0; + } + + ret &= fputs(text.c_str(), fd) >= 0; fclose(fd); - return ret >= 0; + return ret; } return false; } -void VLCInput::write_icy_text(const std::string& filename) +void VLCInput::write_icy_text(const std::string& filename, bool dl_plus) { if (icy_text_written.valid()) { auto status = icy_text_written.wait_for(std::chrono::microseconds(1)); @@ -364,7 +380,7 @@ void VLCInput::write_icy_text(const std::string& filename) else { if (m_nowplaying_previous != m_nowplaying) { icy_text_written = std::async(std::launch::async, - std::bind(write_icy_to_file, m_nowplaying, filename)); + std::bind(write_icy_to_file, m_nowplaying, filename, dl_plus)); } -- cgit v1.2.3