encoder/Configured: glue code to initialize PreparedEncoder

This commit is contained in:
Max Kellermann
2017-11-10 21:37:56 +01:00
parent fef9747fbf
commit 6464b4b372
6 changed files with 105 additions and 51 deletions

View File

@@ -23,15 +23,13 @@
#include "HttpdClient.hxx"
#include "output/OutputAPI.hxx"
#include "encoder/EncoderInterface.hxx"
#include "encoder/EncoderPlugin.hxx"
#include "encoder/EncoderList.hxx"
#include "encoder/Configured.hxx"
#include "net/UniqueSocketDescriptor.hxx"
#include "net/SocketAddress.hxx"
#include "net/ToString.hxx"
#include "Page.hxx"
#include "IcyMetaDataServer.hxx"
#include "event/Call.hxx"
#include "util/RuntimeError.hxx"
#include "util/Domain.hxx"
#include "util/DeleteDisposer.hxx"
#include "Log.hxx"
@@ -52,6 +50,7 @@ inline
HttpdOutput::HttpdOutput(EventLoop &_loop, const ConfigBlock &block)
:AudioOutput(FLAG_ENABLE_DISABLE|FLAG_PAUSE),
ServerSocket(_loop),
prepared_encoder(CreateConfiguredEncoder(block)),
defer_broadcast(_loop, BIND_THIS_METHOD(OnDeferredBroadcast))
{
/* read configuration */
@@ -61,12 +60,6 @@ HttpdOutput::HttpdOutput(EventLoop &_loop, const ConfigBlock &block)
unsigned port = block.GetBlockValue("port", 8000u);
const char *encoder_name =
block.GetBlockValue("encoder", "vorbis");
const auto encoder_plugin = encoder_plugin_get(encoder_name);
if (encoder_plugin == nullptr)
throw FormatRuntimeError("No such encoder: %s", encoder_name);
clients_max = block.GetBlockValue("max_clients", 0u);
/* set up bind_to_address */
@@ -77,10 +70,6 @@ HttpdOutput::HttpdOutput(EventLoop &_loop, const ConfigBlock &block)
else
AddPort(port);
/* initialize encoder */
prepared_encoder.reset(encoder_init(*encoder_plugin, block));
/* determine content type */
content_type = prepared_encoder->GetMimeType();
if (content_type == nullptr)