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.
This commit is contained in:
Max Kellermann 2017-11-10 21:52:54 +01:00
parent 13816c1c7d
commit fef9747fbf
2 changed files with 7 additions and 3 deletions

1
NEWS
View File

@ -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

View File

@ -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"))