aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/utils.h b/src/utils.h
index ca77a53..2f6b639 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -1,8 +1,9 @@
#pragma once
-#include <math.h>
-#include <stdint.h>
-#include <stddef.h>
+#include <string>
+#include <cmath>
+#include <cstdint>
+#include <cstddef>
#define NUMOF(l) (sizeof(l) / sizeof(*l))
@@ -15,3 +16,41 @@ const char* level(int channel, int peak);
size_t strlen_utf8(const char *s);
+struct ICY_TEXT_t {
+ std::string artist;
+ std::string title;
+ std::string now_playing;
+
+ operator bool() const {
+ return not (artist.empty() and title.empty() and now_playing.empty());
+ }
+
+ bool operator==(const ICY_TEXT_t& other) const {
+ return
+ artist == other.artist and
+ title == other.title and
+ now_playing == other.now_playing;
+ }
+ bool operator!=(const ICY_TEXT_t& other) const {
+ return !(*this == other);
+ }
+ void useArtistTitle(const std::string& artist, const std::string& title) {
+ this->artist = artist;
+ this->title = title;
+ now_playing = "";
+ }
+ void useNowPlaying(const std::string& now_playing) {
+ artist = "";
+ title = "";
+ this->now_playing = now_playing;
+ }
+};
+
+/*! Write the corresponding text to a file readable by ODR-PadEnc, 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
+ * make a copy.
+ *
+ * \return false on failure
+ */
+bool write_icy_to_file(const ICY_TEXT_t text, const std::string& filename, bool dl_plus);