IcyInputStream.hxx 2.03 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright 2003-2017 The Music Player Daemon Project
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 * http://www.musicpd.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef MPD_ICY_INPUT_STREAM_HXX
#define MPD_ICY_INPUT_STREAM_HXX

#include "ProxyInputStream.hxx"
24
#include "util/Compiler.h"
25

26 27
#include <memory>

28
struct Tag;
29
class IcyMetaDataParser;
30 31 32 33 34

/**
 * An #InputStream filter that parses Icy metadata.
 */
class IcyInputStream final : public ProxyInputStream {
35
	std::shared_ptr<IcyMetaDataParser> parser;
36 37 38 39

	/**
	 * The #Tag object ready to be requested via ReadTag().
	 */
40
	std::unique_ptr<Tag> input_tag;
41 42 43 44

	/**
	 * The #Tag object ready to be requested via ReadTag().
	 */
45
	std::unique_ptr<Tag> icy_tag;
46

47
	offset_type override_offset = 0;
48 49

public:
50 51 52 53 54 55
	/**
	 * @param _parser a IcyMetaDataParser instance which is shared
	 * with our input; it needs to be shared because our input
	 * needs to feed parameters (e.g. from the "icy-metaint"
	 * header) into it
	 */
56
	IcyInputStream(InputStreamPtr _input,
57
		       std::shared_ptr<IcyMetaDataParser> _parser) noexcept;
58
	virtual ~IcyInputStream() noexcept;
59 60 61 62

	IcyInputStream(const IcyInputStream &) = delete;
	IcyInputStream &operator=(const IcyInputStream &) = delete;

63 64
	gcc_pure
	bool IsEnabled() const noexcept;
65 66

	/* virtual methods from InputStream */
67
	void Update() noexcept override;
68
	std::unique_ptr<Tag> ReadTag() override;
69
	size_t Read(void *ptr, size_t size) override;
70 71 72
};

#endif