From 428d5c9649ed97fd2adaf33037c263fa6466b8ef Mon Sep 17 00:00:00 2001 From: Avi Saranga Date: Mon, 23 Jul 2018 17:20:03 -0700 Subject: [PATCH] handle setStoragePath a bit different --- .../objects/TelmateFrameGrabberImpl.cpp | 2 +- .../objects/TelmateFrameGrabberOpenCVImpl.cpp | 21 +++++++++++++++---- .../objects/TelmateFrameGrabberOpenCVImpl.hpp | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/module/src/server/implementation/objects/TelmateFrameGrabberImpl.cpp b/module/src/server/implementation/objects/TelmateFrameGrabberImpl.cpp index 6bd8779..d9b8a30 100644 --- a/module/src/server/implementation/objects/TelmateFrameGrabberImpl.cpp +++ b/module/src/server/implementation/objects/TelmateFrameGrabberImpl.cpp @@ -57,7 +57,7 @@ std::string TelmateFrameGrabberImpl::getStoragePath () void TelmateFrameGrabberImpl::setStoragePath (const std::string &path) { - pTelmateFrameGrabberOpenCVImpl->storagePath = path; + pTelmateFrameGrabberOpenCVImpl->setStoragePath(path); } void TelmateFrameGrabberImpl::setWebRtcEpName (const std::string &epName) diff --git a/module/src/server/implementation/objects/TelmateFrameGrabberOpenCVImpl.cpp b/module/src/server/implementation/objects/TelmateFrameGrabberOpenCVImpl.cpp index 6e38e3c..caffed1 100644 --- a/module/src/server/implementation/objects/TelmateFrameGrabberOpenCVImpl.cpp +++ b/module/src/server/implementation/objects/TelmateFrameGrabberOpenCVImpl.cpp @@ -103,10 +103,6 @@ void TelmateFrameGrabberOpenCVImpl::queueHandler() { while (this->thrLoop) { - if(this->storagePath.empty()) { - boost::this_thread::sleep_for(boost::chrono::milliseconds(50)); - continue; - } this->frameQueue->pop(ptrVf); // blocks params.clear(); // clear the vector since the last iteration. this->lastQueueTimeStamp = this->getCurrentTimestampLong(); @@ -168,6 +164,23 @@ void TelmateFrameGrabberOpenCVImpl::queueHandler() { } +/* This function provides the ability to update the storage path for + * snapshot storage per endpoint + */ +void TelmateFrameGrabberOpenCVImpl::setStoragePath(std::string storagePath) { + + this->storagePath = storagePath; + + this->storagePathSubdir = this->storagePath + "/frames_" + this->getCurrentTimestampString(); + boost::filesystem::path dir(this->storagePathSubdir.c_str()); + if (!boost::filesystem::create_directories(dir)) { + GST_ERROR("%s create_directories() failed for: %s", this->epName.c_str(), + this->storagePathSubdir.c_str()); + } + + GST_INFO("Storage path has been updated to %s for %s", this->storagePath.c_str(), this->epName.c_str()); +} + std::string TelmateFrameGrabberOpenCVImpl::getCurrentTimestampString() { struct timeval tp; long int ms; diff --git a/module/src/server/implementation/objects/TelmateFrameGrabberOpenCVImpl.hpp b/module/src/server/implementation/objects/TelmateFrameGrabberOpenCVImpl.hpp index fd60d59..ce7e334 100644 --- a/module/src/server/implementation/objects/TelmateFrameGrabberOpenCVImpl.hpp +++ b/module/src/server/implementation/objects/TelmateFrameGrabberOpenCVImpl.hpp @@ -62,7 +62,7 @@ class TelmateFrameGrabberOpenCVImpl : public virtual OpenCVProcess { std::string storagePath; std::string epName; int outputFormat; // 0x0=JPEG 0x1=PNG - + void setStoragePath(std::string storagePath); protected: