/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

#pragma once

#include "AR/ArFrame.hpp"

#import <ARKit/ARFrame.h>

namespace OpenVulkano::AR::ArKit
{
	class ArSessionArKitInternal;

	class ArFrameArKit final : public ArFrame
	{
	public:
		ArFrameArKit(ARFrame* arKitFrame, std::shared_ptr<ArSessionArKitInternal> arSession);

		~ArFrameArKit() override;

		ArImagePlanar GetCameraImage() override;

		ArDepthImage GetDepthImage() override;

		Math::Matrix4f GetCameraViewForCurrentDeviceOrientation() override;

		Math::Matrix4f GetCameraProjection(Math::Vector2f viewportSize, float near, float far) override;

		ARFrame* GetArKitFrame() const { return m_arKitFrame; }

		bool GetCameraImageAsJpeg(const std::function<void(const char*, size_t)>& handler) override;

	private:
		ARFrame* m_arKitFrame;
		bool m_lockedColor, m_lockedDepth;
		ArImagePlanar m_colorImage;
		ArDepthImage m_depthImage;
	};
}
