Commit fef9747f authored by Max Kellermann's avatar Max Kellermann

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.
parent 13816c1c
...@@ -10,6 +10,7 @@ ver 0.21 (not yet released) ...@@ -10,6 +10,7 @@ ver 0.21 (not yet released)
- pcm: support audio/L24 (RFC 3190) - pcm: support audio/L24 (RFC 3190)
* output * output
- alsa: non-blocking mode - alsa: non-blocking mode
- shout: support the Shine encoder plugin
- sndio: remove support for the broken RoarAudio sndio emulation - sndio: remove support for the broken RoarAudio sndio emulation
* mixer * mixer
- sndio: new mixer plugin - sndio: new mixer plugin
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "encoder/EncoderList.hxx" #include "encoder/EncoderList.hxx"
#include "util/RuntimeError.hxx" #include "util/RuntimeError.hxx"
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "util/StringAPI.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <shout/shout.h> #include <shout/shout.h>
...@@ -165,8 +166,10 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block) ...@@ -165,8 +166,10 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block)
prepared_encoder.reset(encoder_init(*encoder_plugin, block)); prepared_encoder.reset(encoder_init(*encoder_plugin, block));
const char *const mime_type = prepared_encoder->GetMimeType();
unsigned shout_format; unsigned shout_format;
if (strcmp(encoding, "mp3") == 0 || strcmp(encoding, "lame") == 0) if (StringIsEqual(mime_type, "audio/mpeg"))
shout_format = SHOUT_FORMAT_MP3; shout_format = SHOUT_FORMAT_MP3;
else else
shout_format = SHOUT_FORMAT_OGG; shout_format = SHOUT_FORMAT_OGG;
...@@ -175,9 +178,9 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block) ...@@ -175,9 +178,9 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block)
value = block.GetBlockValue("protocol"); value = block.GetBlockValue("protocol");
if (value != nullptr) { if (value != nullptr) {
if (0 == strcmp(value, "shoutcast") && if (0 == strcmp(value, "shoutcast") &&
0 != strcmp(encoding, "mp3")) !StringIsEqual(mime_type, "audio/mpeg"))
throw FormatRuntimeError("you cannot stream \"%s\" to shoutcast, use mp3", throw FormatRuntimeError("you cannot stream \"%s\" to shoutcast, use mp3",
encoding); mime_type);
else if (0 == strcmp(value, "shoutcast")) else if (0 == strcmp(value, "shoutcast"))
protocol = SHOUT_PROTOCOL_ICY; protocol = SHOUT_PROTOCOL_ICY;
else if (0 == strcmp(value, "icecast1")) else if (0 == strcmp(value, "icecast1"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment