#ifndef LCAMERA_BUFF_YUV_STIM_PRODUCER_H
#define LCAMERA_BUFF_YUV_STIM_PRODUCER_H

#include <cameraModeRequest.h>
#include <lcameraDev.h>
#include <lcameraBuffParams.h>
#include <user/stimulusProducer.h>
#include <yuvCaptureLayout.h>
#include <pixelAndColorFormatDecisions.h>
#include <memory>
#include <string>

namespace smo {
namespace stim_buff {
namespace lcamera_buff {

class YuvChannelStimulusBuffer;

class YuvStimProducer
:	public StimulusProducer
{
public:
	YuvStimProducer(
		const std::shared_ptr<device::DeviceAttachmentSpec>& deviceAttachmentSpec,
		boost::asio::io_context& ioContext,
		const std::shared_ptr<lcamera_dev::CameraSession>& deviceSession,
		const lcamera_dev::CameraIdentityRecord& resolvedIdentity,
		const LcameraBuffParsedParams& parsedParams,
		const lcamera_dev::LcameraDevConfiguredCameraMode& configuredMode);

	static bool supportsQualeIfaceApi(const std::string& qualeIfaceApi);

	bool exportsQualeIfaceApi(
		const std::string& qualeIfaceApi) const override;

	std::shared_ptr<StimulusBuffer> getOrCreateAttachedStimulusBuffer(
		const std::shared_ptr<device::DeviceAttachmentSpec>&
			deviceAttachmentSpec) override;

	void destroyAttachedStimulusBuffer(
		const std::shared_ptr<StimulusBuffer>& buffer) override;

	void start() override;
	void stop() override;

protected:
	sscl::co::ViralNonPostingInvoker<void>
		stimFrameProductionTimesliceCInd(
			sscl::SyncCancelerForAsyncWork& canceler) override;

public:
	std::shared_ptr<lcamera_dev::CameraSession> deviceSession;
	std::string resolvedCameraId;
	LcameraBuffParsedParams parsedParams;
	lcamera_dev::LcameraDevConfiguredCameraMode configuredMode;
	YuvCaptureLayoutPath layoutPath;
	YuvChromaSubsampling chromaSubsampling;
	YuvChannelBackingPlan channelBackingPlan;
};

} // namespace lcamera_buff
} // namespace stim_buff
} // namespace smo

#endif // LCAMERA_BUFF_YUV_STIM_PRODUCER_H
