diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-07-30 19:39:05 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-07-30 19:39:05 +0200 |
commit | 9b6fe48ffc63832125b519e7f839650a16d79804 (patch) | |
tree | 752092ec1273276789626f157abca75952d66c56 /src/VLCInput.cpp | |
parent | 19caa87a466e02e53e91a97f1084d860b02de9eb (diff) | |
parent | 5f2817a40d509e9dc172a161ac1a3efb66b8e7b8 (diff) | |
download | fdk-aac-dabplus-9b6fe48ffc63832125b519e7f839650a16d79804.tar.gz fdk-aac-dabplus-9b6fe48ffc63832125b519e7f839650a16d79804.tar.bz2 fdk-aac-dabplus-9b6fe48ffc63832125b519e7f839650a16d79804.zip |
Merge 'gh/next' into next
Diffstat (limited to 'src/VLCInput.cpp')
-rw-r--r-- | src/VLCInput.cpp | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/src/VLCInput.cpp b/src/VLCInput.cpp index 9f0aa65..0ce4f00 100644 --- a/src/VLCInput.cpp +++ b/src/VLCInput.cpp @@ -324,17 +324,34 @@ ssize_t VLCInput::m_read(uint8_t* buf, size_t length) break; } - char* nowplaying_sz = libvlc_media_get_meta(media, libvlc_meta_NowPlaying); - if (nowplaying_sz) { - std::lock_guard<std::mutex> lock(m_nowplaying_mutex); - m_nowplaying = nowplaying_sz; + // handle meta data + char* artist_sz = libvlc_media_get_meta(media, libvlc_meta_Artist); + char* title_sz = libvlc_media_get_meta(media, libvlc_meta_Title); - free(nowplaying_sz); + if (artist_sz && title_sz) { + // use Artist and Title + std::lock_guard<std::mutex> lock(m_nowplaying_mutex); + m_nowplaying.useArtistTitle(artist_sz, title_sz); + } else { + // try fallback to NowPlaying + char* nowplaying_sz = libvlc_media_get_meta(media, libvlc_meta_NowPlaying); + if (nowplaying_sz) { + std::lock_guard<std::mutex> lock(m_nowplaying_mutex); + m_nowplaying.useNowPlaying(nowplaying_sz); + free(nowplaying_sz); + } } + + if (artist_sz) + free(artist_sz); + if (title_sz) + free(title_sz); } return err; } +const std::string VLCInput::ICY_TEXT_SEPARATOR = " - "; + /*! Write the corresponding text to a file readable by mot-encoder, with optional * DL+ information. The text is passed as a copy because we actually use the * m_nowplaying variable which is also accessed in another thread, so better @@ -342,11 +359,12 @@ ssize_t VLCInput::m_read(uint8_t* buf, size_t length) * * \return false on failure */ -bool write_icy_to_file(const std::string text, const std::string& filename, bool dl_plus) +bool write_icy_to_file(const ICY_TEXT_T text, const std::string& filename, bool dl_plus) { FILE* fd = fopen(filename.c_str(), "wb"); if (fd) { bool ret = true; + bool artist_title_used = !text.artist.empty() && !text.title.empty(); // if desired, prepend DL Plus information if (dl_plus) { @@ -354,15 +372,32 @@ bool write_icy_to_file(const std::string text, const std::string& filename, bool 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 ! + // if non-empty text, add tag + if (artist_title_used) { + size_t artist_len = strlen_utf8(text.artist.c_str()); + size_t title_start = artist_len + strlen_utf8(VLCInput::ICY_TEXT_SEPARATOR.c_str()); + + // ITEM.ARTIST + ss << "DL_PLUS_TAG=4 0 " << (artist_len - 1) << "\n"; // -1 ! + + // ITEM.TITLE + ss << "DL_PLUS_TAG=1 " << title_start << " " << (strlen_utf8(text.title.c_str()) - 1) << "\n"; // -1 ! + } else if (!text.now_playing.empty()) { + // PROGRAMME.NOW + ss << "DL_PLUS_TAG=33 0 " << (strlen_utf8(text.now_playing.c_str()) - 1) << "\n"; // -1 ! + } ss << "##### parameters } #####\n"; ret &= fputs(ss.str().c_str(), fd) >= 0; } - ret &= fputs(text.c_str(), fd) >= 0; + if (artist_title_used) { + ret &= fputs(text.artist.c_str(), fd) >= 0; + ret &= fputs(VLCInput::ICY_TEXT_SEPARATOR.c_str(), fd) >= 0; + ret &= fputs(text.title.c_str(), fd) >= 0; + } else { + ret &= fputs(text.now_playing.c_str(), fd) >= 0; + } fclose(fd); return ret; |