diff options
author | Max Kellermann <max@musicpd.org> | 2017-11-10 21:52:54 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-11-10 21:52:54 +0100 |
commit | fef9747fbf351bcd43259b0dc2f4fde4c93dcf6c (patch) | |
tree | c45c6e7b07f5b24b0a16628722f528c1ca40bd71 /src/output | |
parent | 13816c1c7d826fe7b4a72f604c0f11de8fce6745 (diff) |
output/shout: use MIME type instead of the encoder plugin name
This is more robust, for example it allows using the Shine encoder
plugin instead of LAME.
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/plugins/ShoutOutputPlugin.cxx | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/output/plugins/ShoutOutputPlugin.cxx b/src/output/plugins/ShoutOutputPlugin.cxx index 0b9005dc5..b30dae91d 100644 --- a/src/output/plugins/ShoutOutputPlugin.cxx +++ b/src/output/plugins/ShoutOutputPlugin.cxx @@ -25,6 +25,7 @@ #include "encoder/EncoderList.hxx" #include "util/RuntimeError.hxx" #include "util/Domain.hxx" +#include "util/StringAPI.hxx" #include "Log.hxx" #include <shout/shout.h> @@ -165,8 +166,10 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block) prepared_encoder.reset(encoder_init(*encoder_plugin, block)); + const char *const mime_type = prepared_encoder->GetMimeType(); + unsigned shout_format; - if (strcmp(encoding, "mp3") == 0 || strcmp(encoding, "lame") == 0) + if (StringIsEqual(mime_type, "audio/mpeg")) shout_format = SHOUT_FORMAT_MP3; else shout_format = SHOUT_FORMAT_OGG; @@ -175,9 +178,9 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block) value = block.GetBlockValue("protocol"); if (value != nullptr) { if (0 == strcmp(value, "shoutcast") && - 0 != strcmp(encoding, "mp3")) + !StringIsEqual(mime_type, "audio/mpeg")) throw FormatRuntimeError("you cannot stream \"%s\" to shoutcast, use mp3", - encoding); + mime_type); else if (0 == strcmp(value, "shoutcast")) protocol = SHOUT_PROTOCOL_ICY; else if (0 == strcmp(value, "icecast1")) |