#ifndef MUXER_H
#define MUXER_H

#include <dvb.h>
#include <mutex>
#include <boost/shared_ptr.hpp>
#include <processPipes.h>
#include <visibility.h>
#include <logger.h>

namespace P2PVR {
class DLL_PUBLIC Muxer : public RawDataClient {
	public:
		Muxer(const RawDataClientPrx & target, const std::string & cmd);
		~Muxer();

		bool NewData(const Data &, const Ice::Current &);

	private:
		DLL_PRIVATE bool ReadWaiting() const;
		DLL_PRIVATE bool ReadAvailable() const;
		DLL_PRIVATE bool ReadMuxerAndSend(int wait) const;
		const RawDataClientPrx target;
		typedef boost::shared_ptr<AdHoc::System::ProcessPipes> ProcessPipesPtr;
		ProcessPipesPtr fds;
		mutable std::mutex lock;

		static IceTray::Logging::LoggerPtr log;
};
}

#endif