From fef9747fbf351bcd43259b0dc2f4fde4c93dcf6c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 10 Nov 2017 21:52:54 +0100 Subject: [PATCH] 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. --- NEWS | 1 + src/output/plugins/ShoutOutputPlugin.cxx | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 9517b8345..ed689a821 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ ver 0.21 (not yet released) - pcm: support audio/L24 (RFC 3190) * output - alsa: non-blocking mode + - shout: support the Shine encoder plugin - sndio: remove support for the broken RoarAudio sndio emulation * mixer - sndio: new mixer plugin 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 @@ -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"))