diff --git a/components/common/cpp/include/ftl/configuration.hpp b/components/common/cpp/include/ftl/configuration.hpp index 9010858c4a0c268c4b7603880eef79ad2d2a974d..18ce61f4c9bcfcca73a3ba05a690f18489a06f66 100644 --- a/components/common/cpp/include/ftl/configuration.hpp +++ b/components/common/cpp/include/ftl/configuration.hpp @@ -27,6 +27,8 @@ namespace config { typedef nlohmann::json json_t; +void addPath(const std::string &path); + std::optional<std::string> locateFile(const std::string &name); std::map<std::string, std::string> read_options(char ***argv, int *argc); diff --git a/components/common/cpp/src/configuration.cpp b/components/common/cpp/src/configuration.cpp index a10ba86e571c0844c931caa643aa668d0d9c2443..b849c6ff13376ee0e1046244b7880066546c7d7f 100644 --- a/components/common/cpp/src/configuration.cpp +++ b/components/common/cpp/src/configuration.cpp @@ -106,6 +106,11 @@ bool ftl::create_directory(const std::string &path) { #endif } +void ftl::config::addPath(const std::string &path) { + auto &paths = rootCFG->getConfig()["paths"]; + paths.push_back(path); +} + optional<string> ftl::config::locateFile(const string &name) { if (is_file(name)) return name; diff --git a/components/rgbd-sources/src/source.cpp b/components/rgbd-sources/src/source.cpp index b3b9e82b27a54f56bd2f0242d72ad60be6f338e4..06caebb232f64fd2b244c914cb8e01a518a2f6bc 100644 --- a/components/rgbd-sources/src/source.cpp +++ b/components/rgbd-sources/src/source.cpp @@ -92,7 +92,7 @@ ftl::rgbd::detail::Source *Source::_createFileImpl(const ftl::URI &uri) { if (eix == string::npos) { // Might be a directory if (ftl::is_directory(path)) { - return new StereoVideoSource(this); + return new StereoVideoSource(this, path); } else { return nullptr; } diff --git a/components/rgbd-sources/src/stereovideo.cpp b/components/rgbd-sources/src/stereovideo.cpp index b75380746942b3af2af1c5fca11b43afa848cf6e..86a9e10b2ba6bcd0d1ca0fd2a91e1bde2406e158 100644 --- a/components/rgbd-sources/src/stereovideo.cpp +++ b/components/rgbd-sources/src/stereovideo.cpp @@ -31,12 +31,15 @@ StereoVideoSource::~StereoVideoSource() { } void StereoVideoSource::init(const string &file) { + LOG(INFO) << "STEREOSOURCE = " << file; if (ftl::is_video(file)) { // Load video file LOG(INFO) << "Using video file..."; lsrc_ = ftl::create<LocalSource>(host_, "feed", file); - } - else if (file != "") { + } else if (ftl::is_directory(file)) { + // FIXME: This is not an ideal solution... + ftl::config::addPath(file); + auto vid = ftl::locateFile("video.mp4"); if (!vid) { LOG(FATAL) << "No video.mp4 file found in provided paths (" << file << ")";