msp_cmn.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /**
  2. * @file msp_cmn.h
  3. * @brief Mobile Speech Platform Common Interface Header File
  4. *
  5. * This file contains the quick common programming interface (API) declarations
  6. * of MSP. Developer can include this file in your project to build applications.
  7. * For more information, please read the developer guide.
  8. * Use of this software is subject to certain restrictions and limitations set
  9. * forth in a license agreement entered into between iFLYTEK, Co,LTD.
  10. * and the licensee of this software. Please refer to the license
  11. * agreement for license use rights and restrictions.
  12. *
  13. * Copyright (C) 1999 - 2012 by ANHUI USTC iFLYTEK, Co,LTD.
  14. * All rights reserved.
  15. *
  16. * @author Speech Dept. iFLYTEK.
  17. * @version 1.0
  18. * @date 2012/09/01
  19. *
  20. * @see
  21. *
  22. * History:
  23. * index version date author notes
  24. * 0 1.0 2012/09/01 MSC40 Create this file
  25. */
  26. #ifndef __MSP_CMN_H__
  27. #define __MSP_CMN_H__
  28. #include "msp_types.h"
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif /* C++ */
  32. //#ifdef MSP_WCHAR_SUPPORT
  33. /**
  34. * @fn Wchar2Mbytes
  35. * @brief wchar to mbytes
  36. *
  37. * User login.
  38. *
  39. * @return int MSPAPI - Return 0 in success, otherwise return error code.
  40. * @param const wchar_t* wcstr - [in] Null-terminated source string(wchar_t *).
  41. * @param char* mbstr - [in] Destination string(char *).
  42. * @param int len - [in] The maximum number of bytes that can be stored in the multibyte output string.
  43. * @see
  44. */
  45. char *Wchar2Mbytes(const wchar_t* wcstr);
  46. /**
  47. * @fn Mbytes2Wchar
  48. * @brief mbytes to wchar
  49. *
  50. * User login.
  51. *
  52. * @return int MSPAPI - Return 0 in success, otherwise return error code.
  53. * @param const char* mbstr - [in] Null-terminated source string(char *).
  54. * @param wchar_t* wcstr - [in] Destination string(wchar_t *).
  55. * @param int wlen - [in] The maximum number of multibyte characters to convert.
  56. * @see
  57. */
  58. wchar_t *Mbytes2Wchar(const char *mbstr);
  59. //#endif /*MSP_WCHAR_SUPPORT*/
  60. /**
  61. * @fn MSPLogin
  62. * @brief user login interface
  63. *
  64. * User login.
  65. *
  66. * @return int MSPAPI - Return 0 in success, otherwise return error code.
  67. * @param const char* usr - [in] user name.
  68. * @param const char* pwd - [in] password.
  69. * @param const char* params - [in] parameters when user login.
  70. * @see
  71. */
  72. int MSPAPI MSPLogin(const char* usr, const char* pwd, const char* params);
  73. typedef int (MSPAPI *Proc_MSPLogin)(const char* usr, const char* pwd, const char* params);
  74. //#ifdef MSP_WCHAR_SUPPORT
  75. int MSPAPI MSPLoginW(const wchar_t* usr, const wchar_t* pwd, const wchar_t* params);
  76. typedef int (MSPAPI *Proc_MSPLoginW)(const wchar_t* usr, const wchar_t* pwd, const wchar_t* params);
  77. //#endif/*MSP_WCHAR_SUPPORT*/
  78. /**
  79. * @fn MSPLogout
  80. * @brief user logout interface
  81. *
  82. * User logout
  83. *
  84. * @return int MSPAPI - Return 0 in success, otherwise return error code.
  85. * @see
  86. */
  87. int MSPAPI MSPLogout();
  88. typedef int (MSPAPI *Proc_MSPLogout)();
  89. //#ifdef MSP_WCHAR_SUPPORT
  90. int MSPAPI MSPLogoutW();
  91. typedef int (MSPAPI *Proc_MSPLogoutW)();
  92. //#endif/*MSP_WCHAR_SUPPORT*/
  93. /**
  94. * @fn MSPUpload
  95. * @brief Upload User Specific Data
  96. *
  97. * Upload data such as user config, custom grammar, etc.
  98. *
  99. * @return int MSPAPI - Return 0 in success, otherwise return error code.
  100. * @param const char* dataName - [in] data name, should be unique to diff other data.
  101. * @param const char* params - [in] parameters about uploading data.
  102. * @param const char* dataID - [in] id of the data to be operated.
  103. * @see
  104. */
  105. int MSPAPI MSPUpload( const char* dataName, const char* params, const char* dataID);
  106. typedef int (MSPAPI* Proc_MSPUpload)( const char* dataName, const char* params, const char* dataID);
  107. /**
  108. * @fn MSPDownload
  109. * @brief Download User Specific Data
  110. *
  111. * Download data such as user config, etc.
  112. *
  113. * @return int MSPAPI - Return 0 in success, otherwise return error code.
  114. * @param const char* params - [in] parameters about data to be downloaded.
  115. * @see
  116. */
  117. typedef int (*DownloadStatusCB)(int errorCode, long param1, const void *param2, void *userData);
  118. typedef int (*DownloadResultCB)(const void *data, long dataLen, void *userData);
  119. int MSPAPI MSPDownload(const char* dataName, const char* params, DownloadStatusCB statusCb, DownloadResultCB resultCb, void*userData);
  120. typedef int (MSPAPI* Proc_MSPDownload)(const char* dataName, const char* params, DownloadStatusCB statusCb, DownloadResultCB resultCb, void*userData);
  121. int MSPAPI MSPDownloadW(const wchar_t* wdataName, const wchar_t* wparams, DownloadStatusCB statusCb, DownloadResultCB resultCb, void*userData);
  122. typedef int (MSPAPI* Proc_MSPDownloadW) (const wchar_t* wdataName, const wchar_t* wparams, DownloadStatusCB statusCb, DownloadResultCB resultCb, void*userData);
  123. /**
  124. * @fn MSPAppendData
  125. * @brief Append Data.
  126. *
  127. * Write data to msc, such as data to be uploaded, searching text, etc.
  128. *
  129. * @return int MSPAPI - Return 0 in success, otherwise return error code.
  130. * @param void* data - [in] the data buffer pointer, data could be binary.
  131. * @param unsigned int dataLen - [in] length of data.
  132. * @param unsigned int dataStatus - [in] data status, 2: first or continuous, 4: last.
  133. * @see
  134. */
  135. int MSPAPI MSPAppendData(void* data, unsigned int dataLen, unsigned int dataStatus);
  136. typedef int (MSPAPI* Proc_MSPAppendData)(void* data, unsigned int dataLen, unsigned int dataStatus);
  137. /**
  138. * @fn MSPGetResult
  139. * @brief Get Result
  140. *
  141. * Get result of uploading, downloading or searching, etc.
  142. *
  143. * @return const char* MSPAPI - Return result of uploading, downloading or searching, etc.
  144. * @param int* rsltLen - [out] Length of result returned.
  145. * @param int* rsltStatus - [out] Status of result returned.
  146. * @param int* errorCode - [out] Return 0 in success, otherwise return error code.
  147. * @see
  148. */
  149. const char* MSPAPI MSPGetResult(unsigned int* rsltLen, int* rsltStatus, int *errorCode);
  150. typedef const char * (MSPAPI *Proc_MSPGetResult)(unsigned int* rsltLen, int* rsltStatus, int *errorCode);
  151. /**
  152. * @fn MSPSetParam
  153. * @brief set params of msc
  154. *
  155. * set param of msc
  156. *
  157. * @return int - Return 0 if success, otherwise return errcode.
  158. * @param const char* paramName - [in] param name.
  159. * @param const char* paramValue - [in] param value
  160. * @see
  161. */
  162. int MSPAPI MSPSetParam( const char* paramName, const char* paramValue );
  163. typedef int (MSPAPI *Proc_MSPSetParam)(const char* paramName, const char* paramValue);
  164. /**
  165. * @fn MSPGetParam
  166. * @brief get params of msc
  167. *
  168. * get param of msc
  169. *
  170. * @return int - Return 0 if success, otherwise return errcode.
  171. * @param const char* paramName - [in] param name.
  172. * @param const char* paramValue - [out] param value
  173. * @param const char* valueLen - [in/out] param value (buffer) length
  174. * @see
  175. */
  176. int MSPAPI MSPGetParam( const char *paramName, char *paramValue, unsigned int *valueLen );
  177. typedef int (MSPAPI *Proc_MSPGetParam)( const char *paramName, char *paramValue, unsigned int *valueLen );
  178. /**
  179. * @fn MSPUploadData
  180. * @brief Upload User Specific Data
  181. *
  182. * Upload data such as user config, custom grammar, etc.
  183. *
  184. * @return const char* MSPAPI - data id returned by Server, used for special command.
  185. * @param const char* dataName - [in] data name, should be unique to diff other data.
  186. * @param void* data - [in] the data buffer pointer, data could be binary.
  187. * @param unsigned int dataLen - [in] length of data.
  188. * @param const char* params - [in] parameters about uploading data.
  189. * @param int* errorCode - [out] Return 0 in success, otherwise return error code.
  190. * @see
  191. */
  192. const char* MSPAPI MSPUploadData(const char* dataName, void* data, unsigned int dataLen, const char* params, int* errorCode);
  193. typedef const char* (MSPAPI* Proc_MSPUploadData)(const char* dataName, void* data, unsigned int dataLen, const char* params, int* errorCode);
  194. /**
  195. * @fn MSPDownloadData
  196. * @brief Download User Specific Data
  197. *
  198. * Download data such as user config, etc.
  199. *
  200. * @return const void* MSPAPI - received data buffer pointer, data could be binary, NULL if failed or data does not exsit.
  201. * @param const char* params - [in] parameters about data to be downloaded.
  202. * @param unsigned int* dataLen - [out] length of received data.
  203. * @param int* errorCode - [out] Return 0 in success, otherwise return error code.
  204. * @see
  205. */
  206. const void* MSPAPI MSPDownloadData(const char* params, unsigned int* dataLen, int* errorCode);
  207. typedef const void* (MSPAPI* Proc_MSPDownloadData)(const char* params, unsigned int* dataLen, int* errorCode);
  208. //#ifdef MSP_WCHAR_SUPPORT
  209. const void* MSPAPI MSPDownloadDataW(const wchar_t* params, unsigned int* dataLen, int* errorCode);
  210. typedef const void* (MSPAPI* Proc_MSPDownloadDataW)(const wchar_t* params, unsigned int* dataLen, int* errorCode);
  211. //#endif/*MSP_WCHAR_SUPPORT*/
  212. /**
  213. * @fn MSPSearch
  214. * @brief Search text for result
  215. *
  216. * Search text content, and got text result
  217. *
  218. * @return const void* MSPAPI - received data buffer pointer, data could be binary, NULL if failed or data does not exsit.
  219. * @param const char* params - [in] parameters about data to be downloaded.
  220. * @param unsigned int* dataLen - [out] length of received data.
  221. * @param int* errorCode - [out] Return 0 in success, otherwise return error code.
  222. * @see
  223. */
  224. const char* MSPAPI MSPSearch(const char* params, const char* text, unsigned int* dataLen, int* errorCode);
  225. typedef const char* (MSPAPI* Proc_MSPSearch)(const char* params, const char* text, unsigned int* dataLen, int* errorCode);
  226. typedef int (*NLPSearchCB)(const char *sessionID, int errorCode, int status, const void* result, long rsltLen, void *userData);
  227. const char* MSPAPI MSPNlpSearch(const char* params, const char* text, unsigned int textLen, int *errorCode, NLPSearchCB callback, void *userData);
  228. typedef const char* (MSPAPI* Proc_MSPNlpSearch)(const char* params, const char* text, unsigned int textLen, int *errorCode, NLPSearchCB callback, void *userData);
  229. int MSPAPI MSPNlpSchCancel(const char *sessionID, const char *hints);
  230. /**
  231. * @fn MSPRegisterNotify
  232. * @brief Register a Callback
  233. *
  234. * Register a Callback
  235. *
  236. * @return int -
  237. * @param msp_status_ntf_handler statusCb - [in] notify handler
  238. * @param void *userData - [in] userData
  239. * @see
  240. */
  241. typedef void ( *msp_status_ntf_handler)( int type, int status, int param1, const void *param2, void *userData );
  242. int MSPAPI MSPRegisterNotify( msp_status_ntf_handler statusCb, void *userData );
  243. typedef const char* (MSPAPI* Proc_MSPRegisterNotify)( msp_status_ntf_handler statusCb, void *userData );
  244. /**
  245. * @fn MSPGetVersion
  246. * @brief Get version of MSC or Local Engine
  247. *
  248. * Get version of MSC or Local Engine
  249. *
  250. * @return const char * MSPAPI - Return version value if success, NULL if fail.
  251. * @param const char *verName - [in] version name, could be "msc", "aitalk", "aisound", "ivw".
  252. * @param int *errorCode - [out] Return 0 in success, otherwise return error code.
  253. * @see
  254. */
  255. const char* MSPAPI MSPGetVersion(const char *verName, int *errorCode);
  256. typedef const char* (MSPAPI * Proc_MSPGetVersion)(const char *verName, int *errorCode);
  257. #ifdef __cplusplus
  258. } /* extern "C" */
  259. #endif /* C++ */
  260. #endif /* __MSP_CMN_H__ */