input/curl: pass IcyMetaDataParser to constructor
Allows the caller to decide whether to enable the feature.
This commit is contained in:
parent
70c4b621cf
commit
3fe5b42b2b
@ -76,7 +76,9 @@ class CurlInputStream final : public AsyncInputStream, CurlResponseHandler {
|
|||||||
std::shared_ptr<IcyMetaDataParser> icy;
|
std::shared_ptr<IcyMetaDataParser> icy;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
template<typename I>
|
||||||
CurlInputStream(EventLoop &event_loop, const char *_url,
|
CurlInputStream(EventLoop &event_loop, const char *_url,
|
||||||
|
I &&_icy,
|
||||||
Mutex &_mutex, Cond &_cond);
|
Mutex &_mutex, Cond &_cond);
|
||||||
|
|
||||||
~CurlInputStream() noexcept;
|
~CurlInputStream() noexcept;
|
||||||
@ -339,13 +341,15 @@ input_curl_finish() noexcept
|
|||||||
http_200_aliases = nullptr;
|
http_200_aliases = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename I>
|
||||||
inline
|
inline
|
||||||
CurlInputStream::CurlInputStream(EventLoop &event_loop, const char *_url,
|
CurlInputStream::CurlInputStream(EventLoop &event_loop, const char *_url,
|
||||||
|
I &&_icy,
|
||||||
Mutex &_mutex, Cond &_cond)
|
Mutex &_mutex, Cond &_cond)
|
||||||
:AsyncInputStream(event_loop, _url, _mutex, _cond,
|
:AsyncInputStream(event_loop, _url, _mutex, _cond,
|
||||||
CURL_MAX_BUFFERED,
|
CURL_MAX_BUFFERED,
|
||||||
CURL_RESUME_AT),
|
CURL_RESUME_AT),
|
||||||
icy(new IcyMetaDataParser())
|
icy(std::forward<I>(_icy))
|
||||||
{
|
{
|
||||||
request_headers.Append("Icy-Metadata: 1");
|
request_headers.Append("Icy-Metadata: 1");
|
||||||
}
|
}
|
||||||
@ -440,15 +444,18 @@ CurlInputStream::DoSeek(offset_type new_offset)
|
|||||||
inline InputStreamPtr
|
inline InputStreamPtr
|
||||||
CurlInputStream::Open(const char *url, Mutex &mutex, Cond &cond)
|
CurlInputStream::Open(const char *url, Mutex &mutex, Cond &cond)
|
||||||
{
|
{
|
||||||
|
auto icy = std::make_shared<IcyMetaDataParser>();
|
||||||
|
|
||||||
auto c = std::make_unique<CurlInputStream>((*curl_init)->GetEventLoop(),
|
auto c = std::make_unique<CurlInputStream>((*curl_init)->GetEventLoop(),
|
||||||
url, mutex, cond);
|
url,
|
||||||
|
icy,
|
||||||
|
mutex, cond);
|
||||||
|
|
||||||
BlockingCall(c->GetEventLoop(), [&c](){
|
BlockingCall(c->GetEventLoop(), [&c](){
|
||||||
c->InitEasy();
|
c->InitEasy();
|
||||||
c->StartRequest();
|
c->StartRequest();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto icy = c->icy;
|
|
||||||
return std::make_unique<IcyInputStream>(std::move(c), std::move(icy));
|
return std::make_unique<IcyInputStream>(std::move(c), std::move(icy));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user