Files
OpenVulkano/openVulkanoCpp/AR/ArRecorder.hpp
2021-06-30 19:35:10 +02:00

107 lines
2.8 KiB
C++

/*
* 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 <string>
#include <filesystem>
#include <memory>
namespace openVulkanoCpp
{
class MultiPartArchiveWriter;
}
namespace openVulkanoCpp::AR
{
class ArSession;
class ArFrame;
enum class RecordingMode
{
/**
* Frames will only be saved when manually requested through ArFrame::Save()
*/
MANUAL,
/**
* Frames will only be saved when the frame is manually requested through ArSession::GetFrame()
*/
FRAME_REQUEST,
/**
* Every new frame will be stored automatically
*/
NEW_FRAME
};
class ArRecorder final
{
ArSession* m_session;
RecordingMode m_recordingMode = RecordingMode::MANUAL;
std::filesystem::path m_path;
std::unique_ptr<MultiPartArchiveWriter> m_colorWriter, m_depthWriter, m_confidenceWriter, m_metadataWriter;
bool m_recording = false, m_persistent = false;
void WriteColorImage(ArFrame* arFrame);
void WriteDepthImage(ArFrame *arFrame);
public:
ArRecorder(ArSession* session);
~ArRecorder();
void Save(ArFrame* frame);
/**
* Starts the recording of the owning AR session
*/
void Start();
/**
* Stops the recording of the owning AR session
*/
void Stop();
/**
* Sets the directory into which the AR recording should be stored.
* The path needs to be set to make the recording persistent.
* If path is changed after starting the recording, the already running recording will be moved to the new path.
* @param path The path to be used to store the recording
*/
void SetRecordingPath(const std::string& path);
/**
* Gets the current recording path
* @return Current recording dir
*/
[[nodiscard]] const std::filesystem::path& GetRecordingPath() const { return m_path; }
/**
* Checks if a path to be used for the recording has been set.
* If no path has been set the recording will be stored in a temporary location and will be deleted once the recording is stopped.
* @return True if a path has been set and the recording will persist after stopping the recording.
*/
[[nodiscard]] bool IsPersistent() const { return m_persistent; }
/**
* Checks if the recording of the AR session is running
* @return True if recording is started
*/
[[nodiscard]] bool IsRecording() const { return m_recording; }
/**
* Sets the used recording mode
* @param mode The mode that should be used to record the current session
*/
void SetRecordingMode(RecordingMode mode) { m_recordingMode = mode; }
/**
* Checks the currently used recording mode for the AR session
* @return The currently used recording mode
*/
[[nodiscard]] RecordingMode SetRecordingMode() const { return m_recordingMode; }
};
}