/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2016 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
#ifndef __STTP_H__
#define __STTP_H__
-#include <errno.h>
+#include <tizen.h>
#include <stdbool.h>
/**
* @brief Enumerations of error codes.
*/
typedef enum {
- STTP_ERROR_NONE = 0, /**< Successful */
- STTP_ERROR_OUT_OF_MEMORY = -ENOMEM, /**< Out of Memory */
- STTP_ERROR_IO_ERROR = -EIO, /**< I/O error */
- STTP_ERROR_INVALID_PARAMETER = -EINVAL, /**< Invalid parameter */
- STTP_ERROR_OUT_OF_NETWORK = -ENETDOWN, /**< Out of network */
- STTP_ERROR_INVALID_STATE = -0x0100031, /**< Invalid state */
- STTP_ERROR_INVALID_LANGUAGE = -0x0100032, /**< Invalid language */
- STTP_ERROR_OPERATION_FAILED = -0x0100034, /**< Operation failed */
- STTP_ERROR_NOT_SUPPORTED_FEATURE= -0x0100035 /**< Not supported feature */
-}sttp_error_e;
+ STTP_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ STTP_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */
+ STTP_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
+ STTP_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
+ STTP_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< No answer from the daemon */
+ STTP_ERROR_RECORDER_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Device or resource busy */
+ STTP_ERROR_OUT_OF_NETWORK = TIZEN_ERROR_NETWORK_DOWN, /**< Network is down */
+ STTP_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED,/**< Permission denied */
+ STTP_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< STT NOT supported */
+ STTP_ERROR_INVALID_STATE = TIZEN_ERROR_STT | 0x01, /**< Invalid state */
+ STTP_ERROR_INVALID_LANGUAGE = TIZEN_ERROR_STT | 0x02, /**< Invalid language */
+ STTP_ERROR_ENGINE_NOT_FOUND = TIZEN_ERROR_STT | 0x03, /**< No available engine */
+ STTP_ERROR_OPERATION_FAILED = TIZEN_ERROR_STT | 0x04, /**< Operation failed */
+ STTP_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_STT | 0x05, /**< Not supported feature of current engine */
+ STTP_ERROR_NO_SPEECH = TIZEN_ERROR_STT | 0x06, /**< No speech while recording */
+ STTP_ERROR_RECORDING_TIMED_OUT = TIZEN_ERROR_STT | 0x10 /**< Recording timed out */
+} sttp_error_e;
/**
* @brief Enumerations of audio type.
typedef enum {
STTP_AUDIO_TYPE_PCM_S16_LE = 0, /**< Signed 16bit audio type, Little endian */
STTP_AUDIO_TYPE_PCM_U8 /**< Unsigned 8bit audio type */
-}sttp_audio_type_e;
+} sttp_audio_type_e;
/**
* @brief Enumerations of callback event.
STTP_RESULT_EVENT_FINAL_RESULT = 0, /**< Event when the recognition full or last result is ready */
STTP_RESULT_EVENT_PARTIAL_RESULT, /**< Event when the recognition partial result is ready */
STTP_RESULT_EVENT_ERROR /**< Event when the recognition has failed */
-}sttp_result_event_e;
+} sttp_result_event_e;
/**
* @brief Enumerations of result time callback event.
STTP_RESULT_TIME_EVENT_BEGINNING = 0, /**< Event when the token is beginning type */
STTP_RESULT_TIME_EVENT_MIDDLE, /**< Event when the token is middle type */
STTP_RESULT_TIME_EVENT_END /**< Event when the token is end type */
-}sttp_result_time_event_e;
+} sttp_result_time_event_e;
/**
* @brief Enumerations of silence type.
typedef enum {
STTP_SILENCE_TYPE_NO_RECORD_TIMEOUT = 0, /**< No sound is recorded */
STTP_SILENCE_TYPE_END_OF_SPEECH_DETECTED /**< End of speech is detected */
-}sttp_silence_type_e;
+} sttp_silence_type_e;
/**
* @brief Recognition type : free form dictation and default type.
*
* @see sttpe_deinitialize()
*/
-typedef int (* sttpe_initialize)(sttpe_result_cb result_cb, sttpe_silence_detected_cb silence_cb);
+typedef int (*sttpe_initialize)(sttpe_result_cb result_cb, sttpe_silence_detected_cb silence_cb);
/**
* @brief Deinitializes the engine
*
* @see sttpe_initialize()
*/
-typedef int (* sttpe_deinitialize)(void);
+typedef int (*sttpe_deinitialize)(void);
/**
* @brief Retrieves all supported languages of the engine.
*
* @see sttpe_supported_language_cb()
*/
-typedef int (* sttpe_foreach_supported_langs)(sttpe_supported_language_cb callback, void* user_data);
+typedef int (*sttpe_foreach_supported_langs)(sttpe_supported_language_cb callback, void* user_data);
/**
* @brief Checks whether a language is valid or not.
*
* @see sttpe_foreach_supported_languages()
*/
-typedef bool (* sttpe_is_valid_language)(const char* language);
+typedef bool (*sttpe_is_valid_language)(const char* language);
/**
* @brief Gets whether the engine supports silence detection.
*
* @see sttpe_set_silence_detection()
*/
-typedef bool (* sttpe_support_silence_detection)(void);
+typedef bool (*sttpe_support_silence_detection)(void);
+
+/**
+* @brief Gets credential necessity.
+*
+* @return @c true to be needed app credential, \n @c false not to be needed app credential.
+*
+*/
+typedef bool (*sttpe_need_app_credential)(void);
/**
* @brief Gets supporting recognition type.
* @return @c true to support recognition type, \n @c false not to support recognition type.
*
*/
-typedef bool (* sttpe_support_recognition_type)(const char* type);
+typedef bool (*sttpe_support_recognition_type)(const char* type);
/**
* @brief Gets recording format of the engine.
* @retval #STTP_ERROR_NONE Successful
* @retval #STTP_ERROR_INVALID_STATE Not initialized
*/
-typedef int (* sttpe_get_recording_format)(sttp_audio_type_e* types, int* rate, int* channels);
+typedef int (*sttpe_get_recording_format)(sttp_audio_type_e* types, int* rate, int* channels);
/**
* @brief Sets silence detection option.
* @retval #STTP_ERROR_INVALID_STATE Not initialized
* @retval #STTP_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
*/
-typedef int (* sttpe_set_silence_detection)(bool value);
+typedef int (*sttpe_set_silence_detection)(bool value);
/**
* @brief Gets whether application is agreed to get engine service.
* @retval #STTP_ERROR_INVALID_STATE Not initialized
* @retval #STTP_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
*/
-typedef int (* sttpe_check_app_agreed)(const char* appid, bool* value);
+typedef int (*sttpe_check_app_agreed)(const char* appid, bool* value);
/**
* @brief Retrieves result time info in recognition callback of daemon.
*
* @see sttpe_result_time_cb()
*/
-typedef int (* sttpe_foreach_result_time)(void* time_info, sttpe_result_time_cb callback, void* user_data);
+typedef int (*sttpe_foreach_result_time)(void* time_info, sttpe_result_time_cb callback, void* user_data);
/**
* @brief Start recognition.
*
* @param[in] language A language.
* @param[in] type A recognition type. (e.g. #STTP_RECOGNITION_TYPE_FREE, #STTP_RECOGNITION_TYPE_WEB_SEARCH)
+* @parma[in] credential The app credential to allow recognition
* @param[in] user_data The user data to be passed to the callback function.
*
* @return 0 on success, otherwise a negative error value
* @retval #STTP_ERROR_INVALID_LANGUAGE Invalid language
* @retval #STTP_ERROR_OPERATION_FAILED Operation failed
* @retval #STTP_ERROR_OUT_OF_NETWORK Out of network
+* @retval #STTP_ERROR_PERMISSION_DENIED Permission denied
*
* @pre The engine is not in recognition processing.
*
* @see sttpe_stop()
* @see sttpe_cancel()
*/
-typedef int (* sttpe_start)(const char* language, const char* type, void *user_data);
+typedef int (* sttpe_start)(const char* language, const char* type, const char* credential, void *user_data);
/**
* @brief Sets recording data for speech recognition from recorder.
* @see sttpe_cancel()
* @see sttpe_stop()
*/
-typedef int (* sttpe_set_recording_data)(const void* data, unsigned int length);
+typedef int (*sttpe_set_recording_data)(const void* data, unsigned int length);
/**
* @brief Stops to set recording data.
* @see sttpe_result_cb()
* @see sttpe_cancel()
*/
-typedef int (* sttpe_stop)(void);
+typedef int (*sttpe_stop)(void);
/**
* @brief Cancels the recognition process.
* @see sttpe_start()
* @see sttpe_stop()
*/
-typedef int (* sttpe_cancel)(void);
+typedef int (*sttpe_cancel)(void);
/**
* @brief Start recognition of file.
*
* @see sttpe_cancel_file()
*/
-typedef int (* sttpe_start_file)(const char* language, const char* type, const char* filepath,
+typedef int (*sttpe_start_file)(const char* language, const char* type, const char* filepath,
sttp_audio_type_e audio_type, int sample_rate, void *user_data);
/**
*
* @see sttpe_start_file()
*/
-typedef int (* sttpe_cancel_file)(void);
+typedef int (*sttpe_cancel_file)(void);
+
+/**
+* @brief Set private data.
+* @since_tizen 3.0
+*
+* @param[in] key Key field of private data.
+* @param[in] data Data field of private data.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #STTP_ERROR_NONE Successful
+* @retval #STTP_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STTP_ERROR_OPERATION_FAILED Operation failed
+*
+* @see sttpe_get_private_data()
+*/
+typedef int (* sttpe_set_private_data)(const char* key, const char* data);
+
+/**
+* @brief Get private data.
+* @since_tizen 3.0
+*
+* @param[out] key Key field of private data.
+* @param[out] data Data field of private data.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #STTP_ERROR_NONE Successful
+* @retval #STTP_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STTP_ERROR_OPERATION_FAILED Operation failed
+*
+* @see sttpe_set_private_data()
+*/
+typedef int (* sttpe_get_private_data)(const char* key, char** data);
/**
* @brief A structure of the engine functions.
sttpe_is_valid_language is_valid_lang; /**< Check language */
sttpe_support_silence_detection support_silence; /**< Get silence detection support */
sttpe_support_recognition_type support_recognition_type; /**< Get recognition type support */
+ sttpe_need_app_credential need_app_credential; /**< Get app credential necessity*/
sttpe_get_recording_format get_audio_format; /**< Get audio format */
sttpe_foreach_result_time foreach_result_time; /**< Foreach result time */
/* Control file recognition */
sttpe_start_file start_file; /**< Start recognition */
sttpe_cancel_file cancel_file; /**< Cancel recognition */
+
+ /* Set/Get private data */
+ sttpe_set_private_data set_private_data; /**< Set private data */
+ sttpe_get_private_data get_private_data; /**< Get private data */
} sttpe_funcs_s;
/**