//=============================================================================================================================
//
// Copyright (c) 2015-2022 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================

#pragma once

#include "easyar/types.hpp"
#include "renderer.hpp"
#include "boxrenderer.hpp"
#include <QString>
#include <QObject>

namespace easyar {

class HelloAR
{
public:
    void setMessageHandler(std::function<void(int, std::string)> func) { message_ = func; }

    void recreate_context();
    void initialize();
    void finalize();
    bool start();
    void stop();
    void render(int width, int height, int screenRotation);

    void setTrack(bool enable);
    void setHorizontalFlip(bool flip);
private:
    void loadFromImage(std::shared_ptr<easyar::ImageTracker> tracker, const std::string& path, const std::string& name);

    std::shared_ptr<easyar::DelayedCallbackScheduler> scheduler_;
    std::shared_ptr<easyar::CameraDevice> camera_;
    std::shared_ptr<easyar::ImageTracker> tracker_;
    std::shared_ptr<easyar::InputFrameThrottler> throttler_;
    std::shared_ptr<easyar::OutputFrameFork> outputFrameFork_;
    std::shared_ptr<easyar::OutputFrameBuffer> outputFrameBuffer_;
    std::shared_ptr<easyar::InputFrameToFeedbackFrameAdapter> i2FAdapter_;

    std::shared_ptr<Renderer> bgRenderer_;
    std::shared_ptr<BoxRenderer> boxRenderer_;

    float previousInputFrameIndex_{-1};

    bool track_enabled_{true};
    bool cameraHorizontalFlip_{false};
    std::function<void(int, std::string)> message_;
};

}
