[TBT][tizen_3.0_mobile][voice-control module added] 90/107190/1
authornazib.ullah <nazib.ullah@samsung.com>
Tue, 27 Dec 2016 06:00:04 +0000 (12:00 +0600)
committernazib.ullah <nazib.ullah@samsung.com>
Tue, 27 Dec 2016 06:00:04 +0000 (12:00 +0600)
Change-Id: Ic9b39906a9f93864f4bbcf93496a906fcf04c5e0
Signed-off-by: nazib.ullah <nazib.ullah@samsung.com>
release/binary-aarch64/org.tizen.tbtcoreapp-1.0.0-aarch64.tpk
release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk
release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk
release/binary-x86_64/org.tizen.tbtcoreapp-1.0.0-x86_64.tpk
tbtcoreapp/inc/model/tbt-info.h
tbtcoreapp/inc/utils/app_module_config.h
tbtcoreapp/inc/view/tbt-voice-control-view.h [new file with mode: 0644]
tbtcoreapp/res/edje/3.0/mobile/voice_control_viewer.edc [new file with mode: 0644]
tbtcoreapp/src/model/tbt-list.c
tbtcoreapp/src/view/tbt-genlist-view.c
tbtcoreapp/src/view/tbt-voice-control-view.c [new file with mode: 0644]

index 2cb2ccdd8772348233071af09baa8bae09a53277..cb838d06e543fe6f80db6b28108cba0f040e9680 100644 (file)
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
index 1dcc4ed2963d028e8cc516b6383b103328be0cbb..13745641a52662f60048e019777fdc1c5b092acc 100644 (file)
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
index 8f0f5a95ac74ca7c8ce9e1b7073d8243b87474bd..9091b0ef46dc4f5b4ff2c4fac2e69e937aaa0f78 100644 (file)
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
index e98a3101ba28f667834ed47678e7b460e5b7b223..dde4c9f1c49e79f4dd4034fe0a665fc7091ddd80 100644 (file)
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
index fac3747e909463a427f1d1b30bb8d95978d804a8..bf1e9b5a92c628f42edcfd32a2bb56b92fa1e02c 100644 (file)
@@ -249,6 +249,8 @@ typedef enum {
 
     TBT_APP_STT_ERROR,
 
+       TBT_APP_VOICE_CONTROL,
+
     TBT_APP_IOTCON_BASIC_SERVER,
     TBT_APP_IOTCON_BASIC_CLIENT,
 
index 30f88432303e1f54104615c48ce9d51a6d42d307..419d16033ff00b2f66c947253b27cc1f1b47b297 100755 (executable)
 #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 (file)
index 0000000..848f445
--- /dev/null
@@ -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 <Evas.h>
+#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 (file)
index 0000000..828a35f
--- /dev/null
@@ -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; }
+                }
+            }
+        }
+    }
+}
index 7f3e7259db48602d97be836e0a9ad628cba99c1f..0a9606626167abe96eae32915594e466b7018489 100755 (executable)
@@ -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<br/>"
+                                       "2. Run this module then press <b>back button</b> to exit from module.<br/>"
+                                       "3. Remove <b>tbtcoreapp</b> instance from task manager by long pressing <b>home button</b>.<br/>"
+                                       "4. Slide notification panel from top and <b>Mic</b> icon.<br/>"
+                                       "5. Speak <b>\"Test pop\"</b>, while voice control panel app listening.<br/>"
+                                       "6. <b>tbtcoreapp</b> will be launched.",
+                       .result = 0
+               },
+       #endif
+#endif
+
 
 #ifdef TBT_MODULE_IOTCON
        #ifdef TBT_MODULE_APP_IOTCON_BASIC_SERVER
index 6dd1255afd2574149456d3e1bde1874b0a84ea32..010d77136c8588aec4396954fd94efb17b5fea93 100644 (file)
@@ -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 (file)
index 0000000..592e6b9
--- /dev/null
@@ -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 <Elementary.h>
+#include <voice_control.h>
+
+#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