From: nazib.ullah Date: Tue, 27 Dec 2016 06:00:04 +0000 (+0600) Subject: [TBT][tizen_3.0_mobile][voice-control module added] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=946dd95a5063accc03955b726dffbc042e68e21d;p=test%2Ftct%2Fnative%2Fbehavior.git [TBT][tizen_3.0_mobile][voice-control module added] Change-Id: Ic9b39906a9f93864f4bbcf93496a906fcf04c5e0 Signed-off-by: nazib.ullah --- diff --git a/release/binary-aarch64/org.tizen.tbtcoreapp-1.0.0-aarch64.tpk b/release/binary-aarch64/org.tizen.tbtcoreapp-1.0.0-aarch64.tpk index 2cb2ccd..cb838d0 100644 Binary files a/release/binary-aarch64/org.tizen.tbtcoreapp-1.0.0-aarch64.tpk and b/release/binary-aarch64/org.tizen.tbtcoreapp-1.0.0-aarch64.tpk differ diff --git a/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk b/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk index 1dcc4ed..1374564 100644 Binary files a/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk and b/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk differ diff --git a/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk b/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk index 8f0f5a9..9091b0e 100644 Binary files a/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk and b/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk differ diff --git a/release/binary-x86_64/org.tizen.tbtcoreapp-1.0.0-x86_64.tpk b/release/binary-x86_64/org.tizen.tbtcoreapp-1.0.0-x86_64.tpk index e98a310..dde4c9f 100644 Binary files a/release/binary-x86_64/org.tizen.tbtcoreapp-1.0.0-x86_64.tpk and b/release/binary-x86_64/org.tizen.tbtcoreapp-1.0.0-x86_64.tpk differ diff --git a/tbtcoreapp/inc/model/tbt-info.h b/tbtcoreapp/inc/model/tbt-info.h index fac3747..bf1e9b5 100644 --- a/tbtcoreapp/inc/model/tbt-info.h +++ b/tbtcoreapp/inc/model/tbt-info.h @@ -249,6 +249,8 @@ typedef enum { TBT_APP_STT_ERROR, + TBT_APP_VOICE_CONTROL, + TBT_APP_IOTCON_BASIC_SERVER, TBT_APP_IOTCON_BASIC_CLIENT, diff --git a/tbtcoreapp/inc/utils/app_module_config.h b/tbtcoreapp/inc/utils/app_module_config.h index 30f8843..419d160 100755 --- a/tbtcoreapp/inc/utils/app_module_config.h +++ b/tbtcoreapp/inc/utils/app_module_config.h @@ -244,6 +244,8 @@ #define TBT_MODULE_STT #define TBT_MODULE_APP_STT #define TBT_MODULE_APP_STT_ERROR +#define TBT_MODULE_VOICE_CONTROL +#define TBT_MODULE_APP_VOICE_CONTROL #define TBT_MODULE_IOTCON #define TBT_MODULE_APP_IOTCON_BASIC_SERVER diff --git a/tbtcoreapp/inc/view/tbt-voice-control-view.h b/tbtcoreapp/inc/view/tbt-voice-control-view.h new file mode 100644 index 0000000..848f445 --- /dev/null +++ b/tbtcoreapp/inc/view/tbt-voice-control-view.h @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *******************************************************************************/ +/** + * @file tbt-voice-control-view.h + * @brief covers voice control apis + * @since_tizen 3.0 + * @author A. B. M. Nazibullah (nazib.ullah@samsung.com) + * @date December, 2016 + * @bug + * @credit + * + */ + +#ifndef __TBT_VOICE_CONTROL_VIEW_H__ +#define __TBT_VOICE_CONTROL_VIEW_H__ + +#include "utils/app_module_config.h" +#ifdef TBT_MODULE_VOICE_CONTROL + +#include +#include "model/tbt-list.h" + + +/** + * @typedef voice_control_viewer_view + * @since_tizen 2.3 + * @brief A voice_control viewer view handle. + */ +typedef struct _voice_control_view voice_control_view; + +/** + * @brief Create voice_control camera view + * @since_tizen 2.3 + * @param[in] navi Parent naviframe + * @param[in] custom structute to hold tbt application information + * @param[in] item of the main tbt menu + * @return Pointer of voice_control on success, otherwise NULL + */ +voice_control_view *voice_control_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item); + +#endif +#endif // __TBT_VOICE_CONTROL_VIEW_H__ diff --git a/tbtcoreapp/res/edje/3.0/mobile/voice_control_viewer.edc b/tbtcoreapp/res/edje/3.0/mobile/voice_control_viewer.edc new file mode 100644 index 0000000..828a35f --- /dev/null +++ b/tbtcoreapp/res/edje/3.0/mobile/voice_control_viewer.edc @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define TEXT_HEIGHT 0.08 + +collections +{ + base_scale: 1.8; + group + { + name: "voice_control_viewer"; + parts{ + part{ + name: "label"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 0.0; } + rel2 {relative: 1.0 TEXT_HEIGHT; } + } + } + } + } +} diff --git a/tbtcoreapp/src/model/tbt-list.c b/tbtcoreapp/src/model/tbt-list.c index 7f3e725..0a96066 100755 --- a/tbtcoreapp/src/model/tbt-list.c +++ b/tbtcoreapp/src/model/tbt-list.c @@ -2421,6 +2421,24 @@ static tbt_info tbtapps[] = #endif #endif +#ifdef TBT_MODULE_VOICE_CONTROL + #ifdef TBT_MODULE_APP_VOICE_CONTROL + { + .name = "Voice Control", + .parent = "TTS/STT", + .apptype = TBT_APP_VOICE_CONTROL, + .icon_name = "dummy", + .info = "1. Make sure Internet is connected
" + "2. Run this module then press back button to exit from module.
" + "3. Remove tbtcoreapp instance from task manager by long pressing home button.
" + "4. Slide notification panel from top and Mic icon.
" + "5. Speak \"Test pop\", while voice control panel app listening.
" + "6. tbtcoreapp will be launched.", + .result = 0 + }, + #endif +#endif + #ifdef TBT_MODULE_IOTCON #ifdef TBT_MODULE_APP_IOTCON_BASIC_SERVER diff --git a/tbtcoreapp/src/view/tbt-genlist-view.c b/tbtcoreapp/src/view/tbt-genlist-view.c index 6dd1255..010d771 100644 --- a/tbtcoreapp/src/view/tbt-genlist-view.c +++ b/tbtcoreapp/src/view/tbt-genlist-view.c @@ -96,6 +96,7 @@ #include "view/tbt-d2d-view.h" #include "view/tbt-tts-view.h" #include "view/tbt-stt-view.h" +#include "view/tbt-voice-control-view.h" #include "view/tbt-iotcon-view.h" #include "view/tbt-ui-viewmgr-view.h" #include "view/tbt-dali-view.h" @@ -1142,6 +1143,13 @@ static void _gl_item_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void stt_view_add(view->navi, info, it); break; #endif + #ifdef TBT_MODULE_VOICE_CONTROL + #ifdef TBT_MODULE_APP_VOICE_CONTROL + case TBT_APP_VOICE_CONTROL: + voice_control_view_add(view->navi, info, it); + break; + #endif + #endif #ifdef TBT_MODULE_IOTCON #ifdef TBT_MODULE_APP_IOTCON_BASIC_SERVER case TBT_APP_IOTCON_BASIC_SERVER: diff --git a/tbtcoreapp/src/view/tbt-voice-control-view.c b/tbtcoreapp/src/view/tbt-voice-control-view.c new file mode 100644 index 0000000..592e6b9 --- /dev/null +++ b/tbtcoreapp/src/view/tbt-voice-control-view.c @@ -0,0 +1,265 @@ +/******************************************************************************* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ +/** + * @file tbt-voice-control-view.c + * @brief covers voice-control apis + * + * @author A. B. M. Nazibullah + * @date December, 2016 + * @bug + * @credit + * + */ + +#include "utils/app_module_config.h" +#ifdef TBT_MODULE_VOICE_CONTROL + +#include +#include + +#include "utils/logger.h" +#include "utils/config.h" +#include "utils/ui-utils.h" +#include "view/tbt-voice-control-view.h" +#include "view/tbt-common-view.h" + +struct _voice_control_view +{ + common_view* view; + Evas_Object *voice_control_label; +}; + +static void _app_destroy_cb(void* this); +static char* get_vc_error(vc_error_e err); +static void _vc_state_changed_cb(vc_state_e previous, vc_state_e current, void* user_data); +static void _vc_service_state_changed_cb(vc_service_state_e previous, vc_service_state_e current, void* user_data); +static void start_voice_control(void* data); + +/** + * @function voice_control_view_add + * @since_tizen 2.3 + * @description Voice control View Add + * @parameter Evas_Object*: Evas Object Pointer, tbt_info*: Tbt Info Pointer, Elm_Object_Item*: Elm Object Item Pointer + * @return voice_control_view* + */ +voice_control_view *voice_control_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item) +{ + RETVM_IF(NULL == navi, NULL, "navi is null"); + + voice_control_view *this = NULL; + this = calloc(1, sizeof(voice_control_view)); + RETVM_IF(!this, NULL, "calloc failed"); + this->view = calloc(1, sizeof(common_view)); + RETVM_IF(!this->view, NULL, "calloc failed"); + + tbt_info->layout_group = "voice_control_viewer"; + tbt_info->layout_file = get_edje_path("voice_control_viewer.edj"); + + common_view_add(navi, tbt_info, item, this->view, _app_destroy_cb, this); + + RETVM_IF(NULL == this->view, NULL, "navi is null"); + + this->voice_control_label = ui_utils_label_add(this->view->layout, "Voice control"); + ui_utils_label_set_text(this->voice_control_label, "Voice control", "left"); + elm_object_part_content_set(this->view->layout, "label", this->voice_control_label); + + start_voice_control(this); + + return this; +} + +static void start_voice_control(void* data) +{ + DBG("start_voice_control"); + voice_control_view *this = (voice_control_view*)data; + RETM_IF(NULL == this, "view is NULL"); + + int ret; + ret = vc_initialize(); + RETM_IF(ret != VC_ERROR_NONE, "vc_initialize() = %s.", get_vc_error(ret)); + + vc_state_e state; + ret= vc_get_state(&state); + RETM_IF(ret != VC_ERROR_NONE, "vc_get_state = %d.", state); + ret = vc_set_state_changed_cb(_vc_state_changed_cb, this); + RETM_IF(ret != VC_ERROR_NONE, "_vc_state_changed_cb() = %s.", get_vc_error(ret)); + ret = vc_set_service_state_changed_cb(_vc_service_state_changed_cb, this); + RETM_IF(ret != VC_ERROR_NONE, "vc_set_service_state_changed_cb() = %s.", get_vc_error(ret)); + + ret = vc_prepare(); + RETM_IF(ret != VC_ERROR_NONE, "vc_prepare() = %s.", get_vc_error(ret)); +} + +static void _vc_state_changed_cb(vc_state_e previous, vc_state_e current, void* user_data) +{ + DBG("_vc_state_changed_cb() previous : %d current : %d", previous, current); + voice_control_view *this = (voice_control_view*)user_data; + RETM_IF(NULL == this, "view is NULL"); + int ret; + char* language; + switch(current) + { + case VC_STATE_NONE: + DBG("VC_STATE_NONE"); + break; + case VC_STATE_INITIALIZED: + DBG("VC_STATE_INITIALIZED"); + ret = vc_unset_state_changed_cb(); + DBG("vc_unset_state_changed_cb() = %s",get_vc_error(ret)); + ret = vc_unset_service_state_changed_cb(); + DBG("vc_unset_service_state_changed_cb() = %s",get_vc_error(ret)); + break; + case VC_STATE_READY: + DBG("VC_STATE_READY"); + ret = vc_get_current_language(&language); + RETM_IF(ret != VC_ERROR_NONE, "vc_get_current_language() = %s.",language); + ret = vc_set_invocation_name("Test"); + RETM_IF(ret != VC_ERROR_NONE, "vc_set_invocation_name() = %s.", get_vc_error(ret)); + + vc_cmd_h vc_command; + ret = vc_cmd_create(&vc_command); + RETM_IF(ret != VC_ERROR_NONE, "vc_cmd_create() = %s.", get_vc_error(ret)); + ret = vc_cmd_set_type(vc_command, VC_COMMAND_TYPE_BACKGROUND); + RETM_IF(ret != VC_ERROR_NONE, "vc_cmd_set_type() = %s.", get_vc_error(ret)); + ret = vc_cmd_set_command(vc_command, "pop"); + RETM_IF(ret != VC_ERROR_NONE, "vc_cmd_set_command() = %s.", get_vc_error(ret)); + + vc_cmd_list_h vc_cmd_list; + ret = vc_cmd_list_create(&vc_cmd_list); + RETM_IF(ret != VC_ERROR_NONE, "vc_cmd_list_create() = %s.", get_vc_error(ret)); + ret = vc_cmd_list_add(vc_cmd_list, vc_command); + RETM_IF(ret != VC_ERROR_NONE, "vc_cmd_list_add() = %s.", get_vc_error(ret)); + ret = vc_set_command_list(vc_cmd_list, VC_COMMAND_TYPE_BACKGROUND); + RETM_IF(ret != VC_ERROR_NONE, "vc_set_command_list() = %s.", get_vc_error(ret)); + + ret = vc_unprepare(); + break; + } +} + + +static void _vc_service_state_changed_cb(vc_service_state_e previous, vc_service_state_e current, void* user_data) +{ + DBG("_vc_service_state_changed_cb"); + switch(current) + { + case VC_SERVICE_STATE_NONE: + DBG("VC_SERVICE_STATE_NONE"); + break; + case VC_SERVICE_STATE_READY: + DBG("VC_SERVICE_STATE_READY"); + break; + case VC_SERVICE_STATE_RECORDING: + DBG("VC_SERVICE_STATE_RECORDING"); + break; + case VC_SERVICE_STATE_PROCESSING: + DBG("VC_SERVICE_STATE_PROCESSING"); + break; + } +} +/** + * @function _app_destroy_cb + * @since_tizen 2.3 + * @description App Destroy Cb + * @parameter void*: Void Pointer + * @return static void + */ +static void _app_destroy_cb(void* this) +{ + RETM_IF(NULL == this, "data is NULL"); + + int ret; + voice_control_view *view = NULL; + view = (voice_control_view*)this; + RETM_IF(NULL == view, "view is NULL"); + + ret = vc_deinitialize(); + DBG("vc_deinitialize() = %s",get_vc_error(ret)); + + SAFE_DELETE(view->view); + SAFE_DELETE(view); +} + +static char* get_vc_error(vc_error_e err) +{ + char* err_msg; + switch (err) { + case VC_ERROR_NONE: + err_msg = "VC_ERROR_NONE"; + break; + case VC_ERROR_OUT_OF_MEMORY: + err_msg = "VC_ERROR_OUT_OF_MEMORY"; + break; + case VC_ERROR_IO_ERROR: + err_msg = "VC_ERROR_IO_ERROR"; + break; + case VC_ERROR_INVALID_PARAMETER: + err_msg = "VC_ERROR_INVALID_PARAMETER"; + break; + case VC_ERROR_TIMED_OUT: + err_msg = "VC_ERROR_TIMED_OUT"; + break; + case VC_ERROR_RECORDER_BUSY: + err_msg = "VC_ERROR_RECORDER_BUSY"; + break; + case VC_ERROR_PERMISSION_DENIED: + err_msg = "VC_ERROR_PERMISSION_DENIED"; + break; + case VC_ERROR_NOT_SUPPORTED: + err_msg = "VC_ERROR_NOT_SUPPORTED"; + break; + case VC_ERROR_INVALID_STATE: + err_msg = "VC_ERROR_INVALID_STATE"; + break; + case VC_ERROR_INVALID_LANGUAGE: + err_msg = "VC_ERROR_INVALID_LANGUAGE"; + break; + case VC_ERROR_ENGINE_NOT_FOUND: + err_msg = "VC_ERROR_ENGINE_NOT_FOUND"; + break; + case VC_ERROR_OPERATION_FAILED: + err_msg = "VC_ERROR_OPERATION_FAILED"; + break; + case VC_ERROR_OPERATION_REJECTED: + err_msg = "VC_ERROR_OPERATION_REJECTED"; + break; + case VC_ERROR_ITERATION_END: + err_msg = "VC_ERROR_ITERATION_END"; + break; + case VC_ERROR_EMPTY: + err_msg = "VC_ERROR_EMPTY"; + break; + case VC_ERROR_SERVICE_RESET: + err_msg = "VC_ERROR_SERVICE_RESET"; + break; + case VC_ERROR_IN_PROGRESS_TO_READY: + err_msg = "VC_ERROR_IN_PROGRESS_TO_READY"; + break; + case VC_ERROR_IN_PROGRESS_TO_RECORDING: + err_msg = "VC_ERROR_IN_PROGRESS_TO_RECORDING"; + break; + case VC_ERROR_IN_PROGRESS_TO_PROCESSING: + err_msg = "VC_ERROR_IN_PROGRESS_TO_PROCESSING"; + break; + default: + err_msg = "UNKNOWN_ERROR"; + break; + + } + return err_msg; +} + +#endif