diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2020-04-06 14:30:38 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2020-04-06 14:30:38 +0200 |
commit | 17591c94cf2553b8361b35846e12f72d33d8da7f (patch) | |
tree | ae97072770100d8912b04c38ab5987e665fdf6c9 /src/GSTInput.cpp | |
parent | 04f3fc5a463f324cf850ccdc49d8c7a6c47e1156 (diff) | |
download | ODR-AudioEnc-17591c94cf2553b8361b35846e12f72d33d8da7f.tar.gz ODR-AudioEnc-17591c94cf2553b8361b35846e12f72d33d8da7f.tar.bz2 ODR-AudioEnc-17591c94cf2553b8361b35846e12f72d33d8da7f.zip |
GSt: handle artist and title metadata
Diffstat (limited to 'src/GSTInput.cpp')
-rw-r--r-- | src/GSTInput.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/GSTInput.cpp b/src/GSTInput.cpp index 97bcc0f..aa46003 100644 --- a/src/GSTInput.cpp +++ b/src/GSTInput.cpp @@ -209,28 +209,42 @@ void GSTInput::process() gst_message_parse_tag(msg, &tags); //fprintf(stderr, "Got tags from element %s\n", GST_OBJECT_NAME(msg->src)); - string new_title; + struct user_data_t { + string new_artist; + string new_title; + } user_data; auto extract_title = [](const GstTagList *list, const gchar *tag, void *user_data) { GValue val = { 0, }; - auto new_title = (string*)user_data; + auto data = (user_data_t*)user_data; gst_tag_list_copy_value(&val, list, tag); - if (strcmp(tag, "title") == 0 and G_VALUE_HOLDS_STRING(&val)) { - *new_title = g_value_dup_string(&val); + if (G_VALUE_HOLDS_STRING(&val)) { + if (strcmp(tag, "title") == 0) { + data->new_title = g_value_get_string(&val); + } + else if (strcmp(tag, "artist") == 0) { + data->new_artist = g_value_get_string(&val); + } } g_value_unset(&val); }; - gst_tag_list_foreach(tags, extract_title, &new_title); + gst_tag_list_foreach(tags, extract_title, &user_data); gst_tag_list_unref(tags); + { std::lock_guard<std::mutex> lock(m_nowplaying_mutex); - m_nowplaying.useNowPlaying(new_title); + if (user_data.new_artist.empty()) { + m_nowplaying.useNowPlaying(user_data.new_title); + } + else { + m_nowplaying.useArtistTitle(user_data.new_artist, user_data.new_title); + } } break; } |