|
|
|
@@ -59,7 +59,7 @@ class ShoutConfig {
|
|
|
|
|
public:
|
|
|
|
|
ShoutConfig(const ConfigBlock &block, const char *mime_type);
|
|
|
|
|
|
|
|
|
|
void Setup(shout_t *connection) const;
|
|
|
|
|
void Setup(shout_t &connection) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ShoutOutput final : AudioOutput {
|
|
|
|
@@ -229,41 +229,56 @@ ShoutOutput::Create(EventLoop &, const ConfigBlock &block)
|
|
|
|
|
return new ShoutOutput(block);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
|
ShoutConfig::Setup(shout_t *connection) const
|
|
|
|
|
static void
|
|
|
|
|
SetMeta(shout_t &connection, const char *name, const char *value)
|
|
|
|
|
{
|
|
|
|
|
if (shout_set_host(connection, host) != SHOUTERR_SUCCESS ||
|
|
|
|
|
shout_set_port(connection, port) != SHOUTERR_SUCCESS ||
|
|
|
|
|
shout_set_password(connection, passwd) != SHOUTERR_SUCCESS ||
|
|
|
|
|
shout_set_mount(connection, mount) != SHOUTERR_SUCCESS ||
|
|
|
|
|
shout_set_name(connection, name) != SHOUTERR_SUCCESS ||
|
|
|
|
|
shout_set_user(connection, user) != SHOUTERR_SUCCESS ||
|
|
|
|
|
shout_set_public(connection, is_public) != SHOUTERR_SUCCESS ||
|
|
|
|
|
shout_set_format(connection, format) != SHOUTERR_SUCCESS ||
|
|
|
|
|
shout_set_protocol(connection, protocol) != SHOUTERR_SUCCESS ||
|
|
|
|
|
#ifdef SHOUT_TLS
|
|
|
|
|
shout_set_tls(connection, tls) != SHOUTERR_SUCCESS ||
|
|
|
|
|
if (shout_set_meta(&connection, name, value) != SHOUTERR_SUCCESS)
|
|
|
|
|
throw std::runtime_error(shout_get_error(&connection));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
SetOptionalMeta(shout_t &connection, const char *name, const char *value)
|
|
|
|
|
{
|
|
|
|
|
if (value != nullptr)
|
|
|
|
|
SetMeta(connection, name, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
|
ShoutConfig::Setup(shout_t &connection) const
|
|
|
|
|
{
|
|
|
|
|
if (shout_set_host(&connection, host) != SHOUTERR_SUCCESS ||
|
|
|
|
|
shout_set_port(&connection, port) != SHOUTERR_SUCCESS ||
|
|
|
|
|
shout_set_password(&connection, passwd) != SHOUTERR_SUCCESS ||
|
|
|
|
|
shout_set_mount(&connection, mount) != SHOUTERR_SUCCESS ||
|
|
|
|
|
shout_set_user(&connection, user) != SHOUTERR_SUCCESS ||
|
|
|
|
|
shout_set_public(&connection, is_public) != SHOUTERR_SUCCESS ||
|
|
|
|
|
#ifdef SHOUT_USAGE_AUDIO
|
|
|
|
|
/* since libshout 2.4.3 */
|
|
|
|
|
shout_set_content_format(&connection, format, SHOUT_USAGE_AUDIO,
|
|
|
|
|
nullptr) != SHOUTERR_SUCCESS ||
|
|
|
|
|
#else
|
|
|
|
|
shout_set_format(&connection, format) != SHOUTERR_SUCCESS ||
|
|
|
|
|
#endif
|
|
|
|
|
shout_set_agent(connection, "MPD") != SHOUTERR_SUCCESS)
|
|
|
|
|
throw std::runtime_error(shout_get_error(connection));
|
|
|
|
|
shout_set_protocol(&connection, protocol) != SHOUTERR_SUCCESS ||
|
|
|
|
|
#ifdef SHOUT_TLS
|
|
|
|
|
shout_set_tls(&connection, tls) != SHOUTERR_SUCCESS ||
|
|
|
|
|
#endif
|
|
|
|
|
shout_set_agent(&connection, "MPD") != SHOUTERR_SUCCESS)
|
|
|
|
|
throw std::runtime_error(shout_get_error(&connection));
|
|
|
|
|
|
|
|
|
|
SetMeta(connection, SHOUT_META_NAME, name);
|
|
|
|
|
|
|
|
|
|
/* optional paramters */
|
|
|
|
|
|
|
|
|
|
if (genre != nullptr && shout_set_genre(connection, genre))
|
|
|
|
|
throw std::runtime_error(shout_get_error(connection));
|
|
|
|
|
|
|
|
|
|
if (description != nullptr &&
|
|
|
|
|
shout_set_description(connection, description))
|
|
|
|
|
throw std::runtime_error(shout_get_error(connection));
|
|
|
|
|
|
|
|
|
|
if (url != nullptr && shout_set_url(connection, url))
|
|
|
|
|
throw std::runtime_error(shout_get_error(connection));
|
|
|
|
|
SetOptionalMeta(connection, SHOUT_META_GENRE, genre);
|
|
|
|
|
SetOptionalMeta(connection, SHOUT_META_DESCRIPTION, description);
|
|
|
|
|
SetOptionalMeta(connection, SHOUT_META_URL, url);
|
|
|
|
|
|
|
|
|
|
if (quality != nullptr)
|
|
|
|
|
shout_set_audio_info(connection, SHOUT_AI_QUALITY, quality);
|
|
|
|
|
shout_set_audio_info(&connection, SHOUT_AI_QUALITY, quality);
|
|
|
|
|
|
|
|
|
|
if (bitrate != nullptr)
|
|
|
|
|
shout_set_audio_info(connection, SHOUT_AI_BITRATE, bitrate);
|
|
|
|
|
shout_set_audio_info(&connection, SHOUT_AI_BITRATE, bitrate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
@@ -274,7 +289,7 @@ ShoutOutput::Enable()
|
|
|
|
|
throw std::bad_alloc{};
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
config.Setup(shout_conn);
|
|
|
|
|
config.Setup(*shout_conn);
|
|
|
|
|
} catch (...) {
|
|
|
|
|
shout_free(shout_conn);
|
|
|
|
|
throw;
|
|
|
|
@@ -418,7 +433,7 @@ ShoutOutput::Pause()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
shout_tag_to_metadata(const Tag &tag, char *dest, size_t size)
|
|
|
|
|
shout_tag_to_metadata(const Tag &tag, char *dest, size_t size) noexcept
|
|
|
|
|
{
|
|
|
|
|
const char *artist = tag.GetValue(TAG_ARTIST);
|
|
|
|
|
const char *title = tag.GetValue(TAG_TITLE);
|
|
|
|
@@ -446,9 +461,15 @@ ShoutOutput::SendTag(const Tag &tag)
|
|
|
|
|
char song[1024];
|
|
|
|
|
shout_tag_to_metadata(tag, song, sizeof(song));
|
|
|
|
|
|
|
|
|
|
shout_metadata_add(meta, "song", song);
|
|
|
|
|
shout_metadata_add(meta, "charset", "UTF-8");
|
|
|
|
|
if (SHOUTERR_SUCCESS != shout_set_metadata(shout_conn, meta)) {
|
|
|
|
|
if (SHOUTERR_SUCCESS != shout_metadata_add(meta, "song", song) ||
|
|
|
|
|
#ifdef SHOUT_FORMAT_TEXT
|
|
|
|
|
/* since libshout 2.4.6 */
|
|
|
|
|
SHOUTERR_SUCCESS != shout_set_metadata_utf8(shout_conn, meta)
|
|
|
|
|
#else
|
|
|
|
|
SHOUTERR_SUCCESS != shout_metadata_add(meta, "charset", "UTF-8") ||
|
|
|
|
|
SHOUTERR_SUCCESS != shout_set_metadata(shout_conn, meta)
|
|
|
|
|
#endif
|
|
|
|
|
) {
|
|
|
|
|
LogWarning(shout_output_domain,
|
|
|
|
|
"error setting shout metadata");
|
|
|
|
|
}
|
|
|
|
|