From 9eb3a90df3681586b58146b47eea7f3848c348a0 Mon Sep 17 00:00:00 2001 From: Naveen Bobbili Date: Mon, 25 Feb 2019 17:24:29 -0800 Subject: Refactored VSHL into vshl-core and vshl-capabilities. vshl-core: This API is responsible for request arbitration. Verbs exposed are 1. startListening 2. cancelListening 3. subscribe 4. enumerateVoiceAgents 5. setDefaultVoiceAgent Used by applications to subscribe to dialog, connection and auth states of underlying low level voiceagent bindings. Used by applications to trigger voice recognition routine of the underlying low level voiceagent binding. vshl-capabilities: This API exposes publish and subscribe methods for all the speech framework domains/capabilities. For eg. navigation, phonecontrol etc. This API is used by apps and low level voice agent binding to subscribe and publish these capability messages whenever applicable. The code for this is agl-service-voice-high-capabilities repository. This specific commit is for vshl-core API. Change-Id: I1101db19b57ee918482a178843641b088508ac5d Signed-off-by: Naveen Bobbili --- src/plugins/core/VRRequestProcessor.h | 19 +++++++++--------- src/plugins/core/VRRequestProcessorImpl.cpp | 19 +++++++++--------- src/plugins/core/include/VRAgentsObserver.h | 17 ++++++++-------- src/plugins/core/include/VRRequest.h | 21 ++++++++++---------- .../core/include/VRRequestProcessorDelegate.h | 23 +++++++++++----------- src/plugins/core/src/VRAgentsObserverImpl.cpp | 15 +++++++------- src/plugins/core/src/VRRequestImpl.cpp | 19 +++++++++--------- .../core/src/VRRequestProcessorDelegateImpl.cpp | 23 +++++++++++----------- src/plugins/core/test/VRRequestProcessorTest.cpp | 9 ++++----- src/plugins/core/test/VRRequestTest.cpp | 9 ++++----- 10 files changed, 82 insertions(+), 92 deletions(-) (limited to 'src/plugins/core') diff --git a/src/plugins/core/VRRequestProcessor.h b/src/plugins/core/VRRequestProcessor.h index c349a19..97e277a 100644 --- a/src/plugins/core/VRRequestProcessor.h +++ b/src/plugins/core/VRRequestProcessor.h @@ -25,8 +25,7 @@ #include "interfaces/voiceagents/IVoiceAgentsChangeObserver.h" using namespace std; - -namespace vshl { +namespace vshlcore { namespace core { /* * This class is the entry point for all the voice recognition request @@ -36,8 +35,8 @@ class VRRequestProcessor { public: // Create a VRRequestProcessor. static unique_ptr create( - shared_ptr logger, - shared_ptr delegate); + shared_ptr logger, + shared_ptr delegate); // Triggers a voiceagent to start listening to user speech input. // Returns the request ID. If start fails, then empty request ID @@ -48,7 +47,7 @@ public: void cancel(); // Returns the voiceagents observer that belongs to the core module. - shared_ptr getVoiceAgentsChangeObserver() const; + shared_ptr getVoiceAgentsChangeObserver() const; // Destructor ~VRRequestProcessor(); @@ -56,17 +55,17 @@ public: private: // Constructor VRRequestProcessor( - shared_ptr logger, - shared_ptr delegate); + shared_ptr logger, + shared_ptr delegate); // Voiceagents observer - shared_ptr mVoiceAgentsChangeObserver; + shared_ptr mVoiceAgentsChangeObserver; // Request Processor Delegate - shared_ptr mDelegate; + shared_ptr mDelegate; // Logger - shared_ptr mLogger; + shared_ptr mLogger; }; } // namespace core diff --git a/src/plugins/core/VRRequestProcessorImpl.cpp b/src/plugins/core/VRRequestProcessorImpl.cpp index 7441a7d..c07f745 100644 --- a/src/plugins/core/VRRequestProcessorImpl.cpp +++ b/src/plugins/core/VRRequestProcessorImpl.cpp @@ -16,23 +16,22 @@ #include "core/include/VRAgentsObserver.h" -static string TAG = "vshl::core::VRRequestProcessor"; +static string TAG = "vshlcore::core::VRRequestProcessor"; -using Level = vshl::utilities::logging::Logger::Level; - -namespace vshl { +using Level = vshlcore::utilities::logging::Logger::Level; +namespace vshlcore { namespace core { // Create a VRRequestProcessor. unique_ptr VRRequestProcessor::create( - shared_ptr logger, - shared_ptr delegate) { + shared_ptr logger, + shared_ptr delegate) { auto processor = std::unique_ptr(new VRRequestProcessor(logger, delegate)); return processor; } VRRequestProcessor::VRRequestProcessor( - shared_ptr logger, - shared_ptr delegate) : + shared_ptr logger, + shared_ptr delegate) : mLogger(logger), mDelegate(delegate) { mVoiceAgentsChangeObserver = VRAgentsObserver::create(mDelegate); @@ -46,7 +45,7 @@ string VRRequestProcessor::startListening() { // Currently start is simply going to send the request to // the default voice agent as the wake word detection is not // enabled. - shared_ptr defaultVA = mDelegate->getDefaultVoiceAgent(); + shared_ptr defaultVA = mDelegate->getDefaultVoiceAgent(); if (!defaultVA) { mLogger->log(Level::ERROR, TAG, "Failed to start. No default voiceagent found."); return ""; @@ -63,7 +62,7 @@ void VRRequestProcessor::cancel() { mDelegate->cancelAllRequests(); } -shared_ptr VRRequestProcessor::getVoiceAgentsChangeObserver() +shared_ptr VRRequestProcessor::getVoiceAgentsChangeObserver() const { return mVoiceAgentsChangeObserver; } diff --git a/src/plugins/core/include/VRAgentsObserver.h b/src/plugins/core/include/VRAgentsObserver.h index d4c0c7b..ce1bd43 100644 --- a/src/plugins/core/include/VRAgentsObserver.h +++ b/src/plugins/core/include/VRAgentsObserver.h @@ -22,15 +22,14 @@ #include "utilities/logging/Logger.h" using namespace std; - -namespace vshl { +namespace vshlcore { namespace core { /* * This class will observe the changes to the voiceagents data and transfers * the actual handling responsibility to its delegate. */ class VRAgentsObserver - : public vshl::common::interfaces::IVoiceAgentsChangeObserver { + : public vshlcore::common::interfaces::IVoiceAgentsChangeObserver { public: // Create a VRAgentsObserver. static shared_ptr @@ -40,18 +39,18 @@ public: protected: void OnDefaultVoiceAgentChanged( - shared_ptr defaultVoiceAgent) + shared_ptr defaultVoiceAgent) override; void OnVoiceAgentAdded( - shared_ptr voiceAgent) override; + shared_ptr voiceAgent) override; void OnVoiceAgentRemoved( - shared_ptr voiceAgent) override; + shared_ptr voiceAgent) override; void OnVoiceAgentActiveWakeWordChanged( - shared_ptr voiceAgent) override; + shared_ptr voiceAgent) override; void OnVoiceAgentActivated( - shared_ptr voiceAgent) override; + shared_ptr voiceAgent) override; void OnVoiceAgentDeactivated( - shared_ptr voiceAgent) override; + shared_ptr voiceAgent) override; private: // Constructor diff --git a/src/plugins/core/include/VRRequest.h b/src/plugins/core/include/VRRequest.h index 522ec78..8b9e842 100644 --- a/src/plugins/core/include/VRRequest.h +++ b/src/plugins/core/include/VRRequest.h @@ -22,8 +22,7 @@ #include "interfaces/voiceagents/IVoiceAgent.h" using namespace std; - -namespace vshl { +namespace vshlcore { namespace core { /* * This class implements the notion of a Voice Recognition Request. @@ -37,10 +36,10 @@ public: // Create a VRRequest. static unique_ptr create( - shared_ptr logger, - shared_ptr afbApi, + shared_ptr logger, + shared_ptr afbApi, string requestId, - shared_ptr voiceAgent); + shared_ptr voiceAgent); // Destructor ~VRRequest(); @@ -56,22 +55,22 @@ public: private: // Constructor VRRequest( - shared_ptr logger, - shared_ptr afbApi, + shared_ptr logger, + shared_ptr afbApi, const string requestId, - shared_ptr voiceAgent); + shared_ptr voiceAgent); // Binding API reference. - shared_ptr mApi; + shared_ptr mApi; // Voice agent associated with this request - shared_ptr mVoiceAgent; + shared_ptr mVoiceAgent; // Request ID string mRequestId; // Logger - shared_ptr mLogger; + shared_ptr mLogger; }; } // namespace core diff --git a/src/plugins/core/include/VRRequestProcessorDelegate.h b/src/plugins/core/include/VRRequestProcessorDelegate.h index 94b7304..2c36d38 100644 --- a/src/plugins/core/include/VRRequestProcessorDelegate.h +++ b/src/plugins/core/include/VRRequestProcessorDelegate.h @@ -25,8 +25,7 @@ #include "utilities/uuid/UUIDGeneration.h" using namespace std; - -namespace vshl { +namespace vshlcore { namespace core { /* * This is a delegate for VRRequestProcessor actions. @@ -39,22 +38,22 @@ class VRRequestProcessorDelegate { public: // create method static shared_ptr create( - shared_ptr logger, - shared_ptr afbApi); + shared_ptr logger, + shared_ptr afbApi); // Destructor ~VRRequestProcessorDelegate(); // Set default voiceagent - void setDefaultVoiceAgent(shared_ptr voiceAgent); + void setDefaultVoiceAgent(shared_ptr voiceAgent); // Get the default voiceagent - shared_ptr getDefaultVoiceAgent() const; + shared_ptr getDefaultVoiceAgent() const; // Add new request to the list and start processing it. // New request is created and startListening on the // voiceagent is called. - string startRequestForVoiceAgent(shared_ptr voiceAgent); + string startRequestForVoiceAgent(shared_ptr voiceAgent); // Cancel all requests void cancelAllRequests(); @@ -66,20 +65,20 @@ public: private: // Constructor VRRequestProcessorDelegate( - shared_ptr logger, - shared_ptr afbApi); + shared_ptr logger, + shared_ptr afbApi); // Binding API reference - shared_ptr mApi; + shared_ptr mApi; // Default voiceagent - shared_ptr mDefaultVoiceAgent; + shared_ptr mDefaultVoiceAgent; // A map of voiceagent IDs and their respective VR Request objects. unordered_map> mVRRequests; // Logger - shared_ptr mLogger; + shared_ptr mLogger; }; } // namespace core diff --git a/src/plugins/core/src/VRAgentsObserverImpl.cpp b/src/plugins/core/src/VRAgentsObserverImpl.cpp index 7ee4a7e..b44a9a0 100644 --- a/src/plugins/core/src/VRAgentsObserverImpl.cpp +++ b/src/plugins/core/src/VRAgentsObserverImpl.cpp @@ -13,8 +13,7 @@ * permissions and limitations under the License. */ #include "core/include/VRAgentsObserver.h" - -namespace vshl { +namespace vshlcore { namespace core { shared_ptr VRAgentsObserver::create(weak_ptr delegate) { @@ -29,26 +28,26 @@ VRAgentsObserver::VRAgentsObserver(weak_ptr delegate VRAgentsObserver::~VRAgentsObserver() { } -void VRAgentsObserver::OnDefaultVoiceAgentChanged(shared_ptr defaultVoiceAgent) { +void VRAgentsObserver::OnDefaultVoiceAgentChanged(shared_ptr defaultVoiceAgent) { if (auto delegate = mWeakDelegate.lock()) { delegate->setDefaultVoiceAgent(defaultVoiceAgent); } } -void VRAgentsObserver::OnVoiceAgentAdded(shared_ptr voiceAgent) { +void VRAgentsObserver::OnVoiceAgentAdded(shared_ptr voiceAgent) { } -void VRAgentsObserver::OnVoiceAgentRemoved(shared_ptr voiceAgent) { +void VRAgentsObserver::OnVoiceAgentRemoved(shared_ptr voiceAgent) { } -void VRAgentsObserver::OnVoiceAgentActiveWakeWordChanged(shared_ptr voiceAgent) { +void VRAgentsObserver::OnVoiceAgentActiveWakeWordChanged(shared_ptr voiceAgent) { // Not Implemented } -void VRAgentsObserver::OnVoiceAgentActivated(shared_ptr voiceAgent) { +void VRAgentsObserver::OnVoiceAgentActivated(shared_ptr voiceAgent) { } -void VRAgentsObserver::OnVoiceAgentDeactivated(shared_ptr voiceAgent) { +void VRAgentsObserver::OnVoiceAgentDeactivated(shared_ptr voiceAgent) { } } // namespace core } // namespace vshl diff --git a/src/plugins/core/src/VRRequestImpl.cpp b/src/plugins/core/src/VRRequestImpl.cpp index 00adf96..63302d8 100644 --- a/src/plugins/core/src/VRRequestImpl.cpp +++ b/src/plugins/core/src/VRRequestImpl.cpp @@ -24,21 +24,20 @@ break; \ } -static string TAG = "vshl::core::VRRequest"; +static string TAG = "vshlcore::core::VRRequest"; -using Level = vshl::common::interfaces::ILogger::Level; - -namespace vshl { +using Level = vshlcore::common::interfaces::ILogger::Level; +namespace vshlcore { namespace core { string VRRequest::VA_VERB_STARTLISTENING = "startListening"; string VRRequest::VA_VERB_CANCEL = "cancel"; unique_ptr VRRequest::create( - shared_ptr logger, - shared_ptr afbApi, + shared_ptr logger, + shared_ptr afbApi, const string requestId, - shared_ptr voiceAgent) { + shared_ptr voiceAgent) { if (logger == nullptr) { return nullptr; } @@ -53,10 +52,10 @@ unique_ptr VRRequest::create( } VRRequest::VRRequest( - shared_ptr logger, - shared_ptr afbApi, + shared_ptr logger, + shared_ptr afbApi, string requestId, - shared_ptr voiceAgent) : + shared_ptr voiceAgent) : mApi(afbApi), mRequestId(requestId), mVoiceAgent(voiceAgent), diff --git a/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp b/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp index e20b22e..78ef10a 100644 --- a/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp +++ b/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp @@ -14,22 +14,21 @@ */ #include "core/include/VRRequestProcessorDelegate.h" -static string TAG = "vshl::core::VRRequestProcessorDelegate"; +static string TAG = "vshlcore::core::VRRequestProcessorDelegate"; -using Level = vshl::common::interfaces::ILogger::Level; - -namespace vshl { +using Level = vshlcore::common::interfaces::ILogger::Level; +namespace vshlcore { namespace core { shared_ptr VRRequestProcessorDelegate::create( - shared_ptr logger, - shared_ptr afbApi) { + shared_ptr logger, + shared_ptr afbApi) { auto delegate = std::shared_ptr(new VRRequestProcessorDelegate(logger, afbApi)); return delegate; } VRRequestProcessorDelegate::VRRequestProcessorDelegate( - shared_ptr logger, - shared_ptr afbApi) : + shared_ptr logger, + shared_ptr afbApi) : mApi(afbApi), mLogger(logger) { } @@ -39,14 +38,14 @@ VRRequestProcessorDelegate::~VRRequestProcessorDelegate() { } string VRRequestProcessorDelegate::startRequestForVoiceAgent( - shared_ptr voiceAgent) { + shared_ptr voiceAgent) { if (!mApi) { mLogger->log(Level::ERROR, TAG, "Failed to startRequestForVoiceAgent: " + voiceAgent->getId() + ", No API."); return ""; } // Generate a new request ID. - string newReqId = vshl::utilities::uuid::generateUUID(); + string newReqId = vshlcore::utilities::uuid::generateUUID(); // Create a new request and start listening. shared_ptr newRequest = VRRequest::create(mLogger, mApi, newReqId, voiceAgent); @@ -81,11 +80,11 @@ unordered_map> VRRequestProcessorDelegate::getAllR return mVRRequests; } -void VRRequestProcessorDelegate::setDefaultVoiceAgent(shared_ptr voiceAgent) { +void VRRequestProcessorDelegate::setDefaultVoiceAgent(shared_ptr voiceAgent) { mDefaultVoiceAgent = voiceAgent; } -shared_ptr VRRequestProcessorDelegate::getDefaultVoiceAgent() const { +shared_ptr VRRequestProcessorDelegate::getDefaultVoiceAgent() const { return mDefaultVoiceAgent; } diff --git a/src/plugins/core/test/VRRequestProcessorTest.cpp b/src/plugins/core/test/VRRequestProcessorTest.cpp index c1a37df..caa62b8 100644 --- a/src/plugins/core/test/VRRequestProcessorTest.cpp +++ b/src/plugins/core/test/VRRequestProcessorTest.cpp @@ -22,11 +22,10 @@ #include "test/common/ConsoleLogger.h" #include "test/mocks/AFBApiMock.h" -using namespace vshl::core; -using namespace vshl::voiceagents; -using namespace vshl::test::common; - -namespace vshl { +using namespace vshlcore::core; +using namespace vshlcore::voiceagents; +using namespace vshlcore::test::common; +namespace vshlcore { namespace test { class VRRequestProcessorTest : public ::testing::Test { diff --git a/src/plugins/core/test/VRRequestTest.cpp b/src/plugins/core/test/VRRequestTest.cpp index b1cd0a6..a7bb3db 100644 --- a/src/plugins/core/test/VRRequestTest.cpp +++ b/src/plugins/core/test/VRRequestTest.cpp @@ -22,11 +22,10 @@ #include "test/common/ConsoleLogger.h" #include "test/mocks/AFBApiMock.h" -using namespace vshl::core; -using namespace vshl::voiceagents; -using namespace vshl::test::common; - -namespace vshl { +using namespace vshlcore::core; +using namespace vshlcore::voiceagents; +using namespace vshlcore::test::common; +namespace vshlcore { namespace test { class VRRequestTest : public ::testing::Test { -- cgit 1.2.3-korg