diff options
author | Jacob Keeler <jacob.keeler@livioradio.com> | 2018-06-14 11:49:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-14 11:49:32 -0700 |
commit | 4f2f8812e766153a61e46b982513353694446eec (patch) | |
tree | 5ebee668cd52078b7d5ae0319e753f5f7641a467 /src/components/application_manager/src/commands | |
parent | 0dec6ef21fdfd752e33b0364c9e50d27c736371e (diff) | |
parent | 0a4344894d21e90116476c58d82a0c2995f9008b (diff) | |
download | sdl_core-4f2f8812e766153a61e46b982513353694446eec.tar.gz |
Merge pull request #1360 from smartdevicelink/feature/audio_file_playback_tts_chunks
Add audio file playback capabilities using TTS Chunks
Diffstat (limited to 'src/components/application_manager/src/commands')
8 files changed, 199 insertions, 14 deletions
diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc index d5767690d7..dee364cb99 100644 --- a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc +++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc @@ -92,6 +92,21 @@ void AlertManeuverRequest::Run() { // check TTSChunk parameter if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { + smart_objects::SmartObject& tts_chunks = + (*message_)[strings::msg_params][strings::tts_chunks]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse(false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for tts_chunks are not present"); + return; + } + if (0 < (*message_)[strings::msg_params][strings::tts_chunks].length()) { pending_requests_.Add(hmi_apis::FunctionID::TTS_Speak); tts_is_ok = true; diff --git a/src/components/application_manager/src/commands/mobile/alert_request.cc b/src/components/application_manager/src/commands/mobile/alert_request.cc index 3c42e43767..e0cbe9e600 100644 --- a/src/components/application_manager/src/commands/mobile/alert_request.cc +++ b/src/components/application_manager/src/commands/mobile/alert_request.cc @@ -281,6 +281,23 @@ bool AlertRequest::Validate(uint32_t app_id) { return false; } + if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { + smart_objects::SmartObject& tts_chunks = + (*message_)[strings::msg_params][strings::tts_chunks]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse(false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for tts_chunks are not present"); + return false; + } + } + return true; } diff --git a/src/components/application_manager/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/src/commands/mobile/change_registration_request.cc index f55767c723..06027a42db 100644 --- a/src/components/application_manager/src/commands/mobile/change_registration_request.cc +++ b/src/components/application_manager/src/commands/mobile/change_registration_request.cc @@ -178,6 +178,23 @@ void ChangeRegistrationRequest::Run() { return; } + if ((*message_)[strings::msg_params].keyExists(strings::tts_name)) { + smart_objects::SmartObject& tts_name = + (*message_)[strings::msg_params][strings::tts_name]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(tts_name, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse(false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for tts_name are not present"); + return; + } + } + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); const HmiInterfaces::InterfaceState vr_state = diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc index 20076ac50c..a758f04aac 100644 --- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -96,8 +96,24 @@ void PerformAudioPassThruRequest::Run() { // need set flag before sending to hmi StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); - if ((*message_)[str::msg_params].keyExists(str::initial_prompt) && - (0 < (*message_)[str::msg_params][str::initial_prompt].length())) { + if ((*message_)[str::msg_params].keyExists(str::initial_prompt)) { + smart_objects::SmartObject& initial_prompt = + (*message_)[strings::msg_params][strings::initial_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + initial_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse( + false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for initial_prompt are not present"); + return; + } + // In case TTS Speak, subscribe on notification SendSpeakRequest(); SendPerformAudioPassThruRequest(); diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc index 68940158b9..86ab0a97c0 100644 --- a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc @@ -31,6 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include <numeric> #include <string.h> #include <string> #include "application_manager/commands/mobile/perform_interaction_request.h" @@ -536,9 +537,21 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( } } + std::vector<std::string> invalid_params; if ((*message_)[strings::msg_params].keyExists(strings::help_prompt)) { - msg_params[strings::help_prompt] = + smart_objects::SmartObject& help_prompt = (*message_)[strings::msg_params][strings::help_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(help_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_WARN(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("help_prompt"); + } else { + msg_params[strings::help_prompt] = help_prompt; + } } else { if (choice_list.length() != 0) { msg_params[strings::help_prompt] = @@ -573,8 +586,20 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( } if ((*message_)[strings::msg_params].keyExists(strings::timeout_prompt)) { - msg_params[strings::timeout_prompt] = + smart_objects::SmartObject& timeout_prompt = (*message_)[strings::msg_params][strings::timeout_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + timeout_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_WARN(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("timeout_prompt"); + } else { + msg_params[strings::timeout_prompt] = timeout_prompt; + } } else { if (msg_params.keyExists(strings::help_prompt)) { msg_params[strings::timeout_prompt] = msg_params[strings::help_prompt]; @@ -582,8 +607,34 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( } if ((*message_)[strings::msg_params].keyExists(strings::initial_prompt)) { - msg_params[strings::initial_prompt] = + smart_objects::SmartObject& initial_prompt = (*message_)[strings::msg_params][strings::initial_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + initial_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_WARN(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("initial_prompt"); + } else { + msg_params[strings::initial_prompt] = initial_prompt; + } + } + + if (!invalid_params.empty()) { + const std::string params_list = + std::accumulate(std::begin(invalid_params), + std::end(invalid_params), + std::string(""), + [](std::string& first, std::string& second) { + return first.empty() ? second : first + ", " + second; + }); + const std::string info = + "One or more files needed for " + params_list + " are not present"; + SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, info.c_str()); + return; } mobile_apis::InteractionMode::eType mode = diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index 3a8a2de4ab..ff0d0d3622 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -179,7 +179,7 @@ namespace commands { RegisterAppInterfaceRequest::RegisterAppInterfaceRequest( const MessageSharedPtr& message, ApplicationManager& application_manager) : CommandRequestImpl(message, application_manager) - , result_checking_app_hmi_type_(mobile_apis::Result::INVALID_ENUM) {} + , result_code_(mobile_apis::Result::INVALID_ENUM) {} RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() {} @@ -320,7 +320,20 @@ void RegisterAppInterfaceRequest::Run() { } if (msg_params.keyExists(strings::tts_name)) { - application->set_tts_name(msg_params[strings::tts_name]); + smart_objects::SmartObject& tts_name = + (*message_)[strings::msg_params][strings::tts_name]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + tts_name, application, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_WARN(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + response_info_ = "One or more files needed for tts_name are not present"; + result_code_ = mobile_apis::Result::WARNINGS; + } + application->set_tts_name(tts_name); } if (msg_params.keyExists(strings::app_hmi_type)) { @@ -713,9 +726,9 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( } } if ((mobile_apis::Result::SUCCESS == result_code) && - (mobile_apis::Result::INVALID_ENUM != result_checking_app_hmi_type_)) { + (mobile_apis::Result::INVALID_ENUM != result_code_)) { add_info += response_info_; - result_code = result_checking_app_hmi_type_; + result_code = result_code_; } // in case application exist in resumption we need to send resumeVrgrammars @@ -1066,7 +1079,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() { "Following AppHmiTypes are not present in policy " "table:" + log; - result_checking_app_hmi_type_ = mobile_apis::Result::WARNINGS; + result_code_ = mobile_apis::Result::WARNINGS; } } // Replace AppHmiTypes in request with values allowed by policy table diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc index e811f5d154..621aa90447 100644 --- a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc @@ -31,6 +31,7 @@ */ #include <string.h> +#include <numeric> #include <algorithm> #include "application_manager/commands/mobile/set_global_properties_request.h" @@ -185,14 +186,54 @@ void SetGlobalPropertiesRequest::Run() { smart_objects::SmartObject params = smart_objects::SmartObject(smart_objects::SmartType_Map); + std::vector<std::string> invalid_params; if (is_help_prompt_present) { - app->set_help_prompt(msg_params.getElement(strings::help_prompt)); - params[strings::help_prompt] = (*app->help_prompt()); + smart_objects::SmartObject& help_prompt = + (*message_)[strings::msg_params][strings::help_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(help_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("help_prompt"); + } else { + app->set_help_prompt(help_prompt); + params[strings::help_prompt] = (*app->help_prompt()); + } } if (is_timeout_prompt_present) { - app->set_timeout_prompt(msg_params.getElement(strings::timeout_prompt)); - params[strings::timeout_prompt] = (*app->timeout_prompt()); + smart_objects::SmartObject& timeout_prompt = + (*message_)[strings::msg_params][strings::timeout_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + timeout_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("timeout_prompt"); + } else { + app->set_timeout_prompt(timeout_prompt); + params[strings::timeout_prompt] = (*app->timeout_prompt()); + } + } + + if (!invalid_params.empty()) { + std::string params_list = std::accumulate( + std::begin(invalid_params), + std::end(invalid_params), + std::string(""), + [](std::string& first, std::string& second) { + return first.empty() ? second : first + ", " + second; + }); + const std::string info = + "One or more files needed for " + params_list + " are not present"; + SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, info.c_str()); + return; } params[strings::app_id] = app->app_id(); diff --git a/src/components/application_manager/src/commands/mobile/speak_request.cc b/src/components/application_manager/src/commands/mobile/speak_request.cc index 1954cde181..6da6b482b3 100644 --- a/src/components/application_manager/src/commands/mobile/speak_request.cc +++ b/src/components/application_manager/src/commands/mobile/speak_request.cc @@ -69,6 +69,21 @@ void SpeakRequest::Run() { return; } + smart_objects::SmartObject& tts_chunks = + (*message_)[strings::msg_params][strings::tts_chunks]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse(false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for tts_chunks are not present"); + return; + } + (*message_)[strings::msg_params][strings::app_id] = app->app_id(); (*message_)[strings::msg_params][hmi_request::speak_type] = hmi_apis::Common_MethodName::SPEAK; |