Use std::filesystem::path for playback path

This commit is contained in:
Georg Hagen
2025-03-02 19:51:57 +01:00
parent c2c19b6383
commit 950c66f5c8
5 changed files with 12 additions and 11 deletions

View File

@@ -57,7 +57,7 @@ namespace OpenVulkano::AR
return { nullptr, ArCreateResult::FAILED_UNKNOWN, "Unknown exception while initializing AR system." }; return { nullptr, ArCreateResult::FAILED_UNKNOWN, "Unknown exception while initializing AR system." };
} }
ArCreateResult ArSession::CreatePlayback(const std::string& recordingPath, bool autoAdvance, bool loadImages, bool loadDepth) ArCreateResult ArSession::CreatePlayback(const std::filesystem::path& recordingPath, bool autoAdvance, bool loadImages, bool loadDepth)
{ {
try try
{ {

View File

@@ -11,7 +11,6 @@
#include "ArTrackingState.hpp" #include "ArTrackingState.hpp"
#include "ArSessionMetadata.hpp" #include "ArSessionMetadata.hpp"
#include "ArRecorder.hpp" #include "ArRecorder.hpp"
#include "Math/Range.hpp"
#include "Base/Event.hpp" #include "Base/Event.hpp"
#include <memory> #include <memory>
#include <string> #include <string>
@@ -112,9 +111,11 @@ namespace OpenVulkano::AR
* Creates a playback AR session. nullptr if failed to create session for given path. * Creates a playback AR session. nullptr if failed to create session for given path.
* @param recordingPath Path to a previously recorded AR session. * @param recordingPath Path to a previously recorded AR session.
* @param autoAdvance If set to true the playback will advance based on the stored timestamps. If set to false it will only advance if a new frame is requested. * @param autoAdvance If set to true the playback will advance based on the stored timestamps. If set to false it will only advance if a new frame is requested.
* @param loadImages If set to true, image will be loaded
* @param loadDepth If set to true, depth data will be loaded
* @return ArCreateResult about the status of the AR session creation. The session pointer will always be nullptr unless the status is SUCCESS. * @return ArCreateResult about the status of the AR session creation. The session pointer will always be nullptr unless the status is SUCCESS.
*/ */
[[nodiscard]] [[deprecated]] static ArCreateResult CreatePlayback(const std::string& recordingPath, bool autoAdvance = true, bool loadImages = true, bool loadDepth = true); [[nodiscard]] static ArCreateResult CreatePlayback(const std::filesystem::path& recordingPath, bool autoAdvance = true, bool loadImages = true, bool loadDepth = true);
/** /**
* Creates a network streamed AR session. nullptr if failed to create session for given address. This will block till the connection with the remote host has been established. * Creates a network streamed AR session. nullptr if failed to create session for given address. This will block till the connection with the remote host has been established.

View File

@@ -47,9 +47,9 @@ namespace OpenVulkano::AR::Playback
size_t m_imgTotalSize = 0, m_imgReadSize = 0; size_t m_imgTotalSize = 0, m_imgReadSize = 0;
public: public:
[[deprecated]] ArPlaybackReader(const std::string& recDir) ArPlaybackReader(const std::filesystem::path& recDir)
{ {
std::string extensions = R"((_\d+|\.part\d+)?)" + std::string(TAR_EXTENSIONS_REGEX); const std::string extensions = R"((_\d+|\.part\d+)?)" + std::string(TAR_EXTENSIONS_REGEX);
m_archiveMetadata.Open(recDir, ".*meta(data)?" + extensions); m_archiveMetadata.Open(recDir, ".*meta(data)?" + extensions);
m_archiveColor.Open(recDir, ".*(color|image)" + extensions, &m_imgTotalSize); m_archiveColor.Open(recDir, ".*(color|image)" + extensions, &m_imgTotalSize);
m_archiveDepth.Open(recDir, ".*depth" + extensions); m_archiveDepth.Open(recDir, ".*depth" + extensions);

View File

@@ -14,7 +14,7 @@ using namespace std::chrono_literals;
namespace OpenVulkano::AR::Playback namespace OpenVulkano::AR::Playback
{ {
ArSessionPlayback::ArSessionPlayback(const std::string& recordingPath, bool autoAdvance, bool loadImages, bool loadDepth) ArSessionPlayback::ArSessionPlayback(const std::filesystem::path& recordingPath, const bool autoAdvance, const bool loadImages, const bool loadDepth)
: ArSession(ArSessionMetadata(recordingPath)), recordingPath(recordingPath), autoAdvance(autoAdvance) : ArSession(ArSessionMetadata(recordingPath)), recordingPath(recordingPath), autoAdvance(autoAdvance)
, loadImages(loadImages), loadDepth(loadDepth), playbackReader(recordingPath) , loadImages(loadImages), loadDepth(loadDepth), playbackReader(recordingPath)
{ {
@@ -113,7 +113,7 @@ namespace OpenVulkano::AR::Playback
OnSessionInterruptionChange(true); OnSessionInterruptionChange(true);
} }
Scene::Texture* ArSessionPlayback::MakeTexture(OpenVulkano::AR::ArFrame* frame) Scene::Texture* ArSessionPlayback::MakeTexture(ArFrame* frame)
{ {
Scene::Texture* texture; Scene::Texture* texture;
if (!m_textureCache.empty()) if (!m_textureCache.empty())

View File

@@ -15,7 +15,7 @@ namespace OpenVulkano::AR::Playback
class ArSessionPlayback final : public ArSession, public std::enable_shared_from_this<ArSessionPlayback> class ArSessionPlayback final : public ArSession, public std::enable_shared_from_this<ArSessionPlayback>
{ {
public: public:
[[deprecated]] ArSessionPlayback(const std::string& recordingPath, bool autoAdvance, bool loadImages, bool loadDepth); ArSessionPlayback(const std::filesystem::path& recordingPath, bool autoAdvance, bool loadImages, bool loadDepth);
~ArSessionPlayback() override; ~ArSessionPlayback() override;
@@ -31,7 +31,7 @@ namespace OpenVulkano::AR::Playback
[[nodiscard]] ArType GetArType() override; [[nodiscard]] ArType GetArType() override;
[[nodiscard]] [[deprecated]] const std::string& GetPlaybackPath() const { return recordingPath; } [[nodiscard]] const std::filesystem::path& GetPlaybackPath() const { return recordingPath; }
[[nodiscard]] bool IsLoadColorEnabled() const { return loadImages; } [[nodiscard]] bool IsLoadColorEnabled() const { return loadImages; }
[[nodiscard]] bool IsLoadDepthEnabled() const { return loadDepth; } [[nodiscard]] bool IsLoadDepthEnabled() const { return loadDepth; }
@@ -43,7 +43,7 @@ namespace OpenVulkano::AR::Playback
Event<double> OnPlaybackProgress; Event<double> OnPlaybackProgress;
protected: protected:
Scene::Texture* MakeTexture(OpenVulkano::AR::ArFrame* frame) override; Scene::Texture* MakeTexture(ArFrame* frame) override;
void ReturnTexture(Scene::Texture *texture) override; void ReturnTexture(Scene::Texture *texture) override;
@@ -52,7 +52,7 @@ namespace OpenVulkano::AR::Playback
Math::Timestamp lastTimestamp; Math::Timestamp lastTimestamp;
const std::string recordingPath; const std::filesystem::path recordingPath;
const bool autoAdvance, loadImages, loadDepth; const bool autoAdvance, loadImages, loadDepth;
ArPlaybackReader playbackReader; ArPlaybackReader playbackReader;
ArTrackingState m_lastTrackingState = ArTrackingState::UNKNOWN; ArTrackingState m_lastTrackingState = ArTrackingState::UNKNOWN;