diff --git a/components/rgbd-sources/src/snapshot_source.hpp b/components/rgbd-sources/src/snapshot_source.hpp index 3ba9a7f0232632c8b95bc13074bbd5dfe9b76972..7b5b491fc723c8ea5d5dec3d42850775c66257cf 100644 --- a/components/rgbd-sources/src/snapshot_source.hpp +++ b/components/rgbd-sources/src/snapshot_source.hpp @@ -4,8 +4,8 @@ #include <loguru.hpp> -#include "ftl/rgbd/source.hpp" -#include "ftl/rgbd/snapshot.hpp" +#include <ftl/rgbd/source.hpp> +#include <ftl/rgbd/snapshot.hpp> namespace ftl { namespace rgbd { diff --git a/components/rgbd-sources/src/source.cpp b/components/rgbd-sources/src/source.cpp index 4c7379574a145004c46aaf20083484e0e8a89f81..f050a16481124529e26ba47b9171278e391fb6ed 100644 --- a/components/rgbd-sources/src/source.cpp +++ b/components/rgbd-sources/src/source.cpp @@ -6,6 +6,7 @@ #include "image.hpp" #ifdef HAVE_LIBARCHIVE +#include <ftl/rgbd/snapshot.hpp> #include "snapshot_source.hpp" #endif @@ -101,8 +102,14 @@ ftl::rgbd::detail::Source *Source::_createFileImpl(const ftl::URI &uri) { return new ImageSource(this, path); } else if (ext == "mp4") { return new StereoVideoSource(this, path); - } else if (ext == "tar") { + } else if (ext == "tar" || ext == "gz") { +#ifdef HAVE_LIBARCHIVE + ftl::rgbd::SnapshotReader reader(path); + return new ftl::rgbd::detail::SnapshotSource(this, reader, "0"); // TODO Get ID from config +#else + LOG(ERROR) << "Cannot read snapshots, libarchive not installed"; return nullptr; +#endif // HAVE_LIBARCHIVE } else { LOG(WARNING) << "Unrecognised file type: " << path; } diff --git a/components/rgbd-sources/test/source_unit.cpp b/components/rgbd-sources/test/source_unit.cpp index 553d2ecbe254a4335e9348f342ff931dec93b3c0..baea61824a5b762c08564f8f7c7c081ac5839c78 100644 --- a/components/rgbd-sources/test/source_unit.cpp +++ b/components/rgbd-sources/test/source_unit.cpp @@ -9,6 +9,12 @@ static std::string last_type = ""; namespace ftl { namespace rgbd { + +class SnapshotReader { + public: + SnapshotReader(const std::string &) {} +}; + namespace detail { class ImageSource : public ftl::rgbd::detail::Source { @@ -47,6 +53,16 @@ class NetSource : public ftl::rgbd::detail::Source { bool isReady() { return true; }; }; +class SnapshotSource : public ftl::rgbd::detail::Source { + public: + SnapshotSource(ftl::rgbd::Source *host, ftl::rgbd::SnapshotReader &r, const std::string &) : ftl::rgbd::detail::Source(host) { + last_type = "snapshot"; + } + + bool grab() { return true; }; + bool isReady() { return true; }; +}; + class RealsenseSource : public ftl::rgbd::detail::Source { public: RealsenseSource(ftl::rgbd::Source *host) : ftl::rgbd::detail::Source(host) { @@ -66,6 +82,7 @@ class RealsenseSource : public ftl::rgbd::detail::Source { // Prevent these headers... #define _FTL_RGBD_STEREOVIDEO_HPP_ #define _FTL_RGBD_NET_HPP_ +#define _FTL_RGBD_SNAPSHOT_HPP_ #define _FTL_RGBD_SNAPSHOT_SOURCE_HPP_ #define _FTL_RGBD_IMAGE_HPP_ #define _FTL_RGBD_REALSENSE_HPP_