LinkBase.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. #ifndef LINKBASE_H
  2. #define LINKBASE_H
  3. #ifdef __cplusplus
  4. using namespace std;
  5. #include <string>
  6. typedef enum
  7. {
  8. Carplay,
  9. Android_Auto,
  10. Carlife,
  11. HiCar,
  12. ECLink,
  13. Mirror,
  14. Airplay,
  15. }LinkType;
  16. typedef enum
  17. {
  18. Wired,
  19. Wireless,
  20. Auto,
  21. }LinkMode;
  22. //dbus mode carlink send
  23. typedef enum
  24. {
  25. DBUS_DEVICE_ATTACHED, //usb insert
  26. DBUS_DEVICE_DEATTACHED, //usb removed
  27. DBUS_CONNECTTING, //carlink connectting
  28. DBUS_CONNECTED, //carlink connected
  29. DBUS_FOREGROUND, //carlink foreground
  30. DBUS_BACKGROUND, //carlink background
  31. DBUS_FAILED, //carlink failed
  32. DBUS_DISCONNECTED, //carlink disconnected
  33. DBUS_APP_EXIT, //phone's app exited
  34. DBUS_INTERRUPTED_BY_APP, //start connecting by interrupted (kill phone's app or connecting removed)
  35. DBUS_MUSIC_STARTED, //music start
  36. DBUS_MUSIC_STOPPED, //music stop
  37. DBUS_NAVI_STARTED, //navigation start
  38. DBUS_NAVI_STOPPED, //navigation stop
  39. DBUS_VR_STARTED, //voices start
  40. DBUS_VR_STOPPED, //voices stop
  41. DBUS_RECOGNITION_STARTED, //voices recognition start(record start)
  42. DBUS_RECOGNITION_STOPPED, //voices recognition stop(record stop)
  43. DBUS_PHONE_STARTED, //phone call start
  44. DBUS_PHONE_STOPPED, //phone call stop
  45. DBUS_NAVI_SOUND_STARTED, //navigation sound start
  46. DBUS_NAVI_SOUND_STOPPED, //navigation sound stop
  47. }DbusSend;
  48. //carlink receive or user's request
  49. typedef enum
  50. {
  51. DBUS_REQUEST_CONNECT,
  52. DBUS_REQUEST_FOREGROUND,
  53. DBUS_REQUEST_BACKGROUND,
  54. DBUS_REQUEST_EXITED,
  55. }DbusReceive;
  56. typedef enum
  57. {
  58. UnKnown,
  59. Phone_Android,
  60. Phone_IOS,
  61. }PhoneType;
  62. typedef enum
  63. {
  64. APP_NOT_RUNNING, //phone app not open
  65. APP_FOREGROUND, //carlink foreground
  66. APP_BACKGROUND, //carlink background
  67. APP_SCREENLOCKED, //phone screen locked
  68. APP_UNSCREENLOCKED, //phone screen unlocked
  69. APP_MUSIC_STARTED, //music start
  70. APP_MUSIC_STOPPED, //music stop
  71. APP_NAVI_STARTED, //navigation start
  72. APP_NAVI_STOPPED, //navigation stop
  73. APP_VR_STARTED, //voices start
  74. APP_VR_STOPPED, //voices stop
  75. APP_RECOGNITION_STARTED, //voices recognition start(record start)
  76. APP_RECOGNITION_STOPPED, //voices recognition stop(record stop)
  77. APP_PHONE_STARTED, //phone call start
  78. APP_PHONE_STOPPED, //phone call stop
  79. APP_NAVI_SOUND_STARTED, //navigation sound start
  80. APP_NAVI_SOUND_STOPPED, //navigation sound stop
  81. LAUNCH_PHONE_APP, //notify open phone's app
  82. APP_QRCODE, //qr code 's information
  83. APP_LICENSE, //license information
  84. APP_INPUTINFO, //keyboard input information
  85. APP_INPUTPOS, //keyboard input pos information
  86. APP_VRTEXT, //voices information
  87. APP_VOICE_CMD, //voices controls information
  88. APP_VERSION, //version
  89. APP_VOICE_DUCK, //duck
  90. APP_VOICE_UNDUCK, //unduck
  91. APP_PINCODE, //wireless pin code(hicar)
  92. APP_BT_CMD, //bt at cmd
  93. APP_BT_DISCONNECTED, //bt disconnect
  94. APP_CARLINK_INIT_DONE, //carlink done
  95. APP_RESERVED, //reserved
  96. }AppStatusMessage;
  97. //亿连id
  98. struct License{
  99. bool activate;
  100. int code;
  101. string msg;
  102. string ver;
  103. };
  104. struct InputInfo
  105. {
  106. int32_t inputType;
  107. int32_t imeOptions;
  108. string rawText;
  109. uint32_t minLines;
  110. uint32_t maxLines;
  111. uint32_t maxLength;
  112. };
  113. struct InputPos{
  114. int start;
  115. int stop;
  116. };
  117. enum VRTextType
  118. {
  119. VR_TEXT_FROM_UNKNOWN = 0,
  120. VR_TEXT_FROM_VR,
  121. VR_TEXT_FROM_SPEAK
  122. };
  123. struct VRTextInfo
  124. {
  125. VRTextType type;
  126. int32_t sequence;
  127. string plainText;
  128. string htmlText;
  129. };
  130. typedef enum
  131. {
  132. APP_PAGE_NAVIGATION,
  133. APP_PAGE_MUSIC,
  134. APP_PAGE_VR,
  135. APP_PAGE_NAVI_HOME,
  136. APP_PAGE_NAVI_WORK,
  137. APP_PAGE_MAIN,
  138. APP_PAGE_NAVI_GAS_STATION,
  139. APP_PAGE_CAR_PARK,
  140. APP_PAGE_4S_SHOP,
  141. }AppPage;
  142. enum CallType
  143. {
  144. CALL_TYPE_DAIL = 0, ///< ring up
  145. CALL_TYPE_HANG_UP, ///< ring off
  146. CALL_TYPE_MAX, ///< reserve
  147. };
  148. enum ConnectedStatus
  149. {
  150. CONNECT_STATUS_DEVICE_ATTACHED,
  151. CONNECT_STATUS_DEVICE_DEATTACHED,
  152. CONNECT_STATUS_CONNECTING,
  153. CONNECT_STATUS_CONNECT_FAILED,
  154. CONNECT_STATUS_CONNECT_SUCCEED,
  155. CONNECT_STATUS_DISCONNECTED,
  156. CONNECT_STATUS_APP_EXIT,
  157. CONNECT_STATUS_INTERRUPTED_BY_APP,
  158. };
  159. enum RequestAppStatus
  160. {
  161. QUERYTIME,
  162. QUERYGPS,
  163. QUERYBTSTATUS,
  164. QUERYQRCODE,
  165. QUERYINPUT,
  166. };
  167. enum AudioType
  168. {
  169. AUDIO_TYPE_MUSIC = 0x00, ///< Music audio
  170. AUDIO_TYPE_CALL = 0x01, ///< phone call audio
  171. AUDIO_TYPE_VR = 0x02, ///< VR audio
  172. AUDIO_TYPE_TTS = 0x03, ///< TTS audio
  173. AUDIO_TYPE_Rec = 0x04, ///< rec audio
  174. AUDIO_TYPE_Alert = 0x05, ///< alert audio
  175. };
  176. struct AudioInfo
  177. {
  178. uint32_t sampleRate; ///< sample rate
  179. uint32_t channel; ///< channel type
  180. uint32_t format; ///< audio format type
  181. };
  182. enum WheelCode
  183. {
  184. Wheel_Keep = 0,
  185. Wheel_Next = 1,
  186. Wheel_Previous = -1,
  187. };
  188. enum TouchCode
  189. {
  190. Touch_Up = 0,
  191. Touch_Press = 1,
  192. Touch_Move = 2,
  193. };
  194. struct WifiInfo{
  195. string ssid;
  196. string passphrase;
  197. string channel_id;
  198. };
  199. struct BlueToothInfo{
  200. string name;
  201. string addr;
  202. string pin;
  203. };
  204. struct BT_CMD{
  205. string cmd;
  206. int len;
  207. };
  208. struct DuckInfo{
  209. double inDurationSecs;
  210. double volume;
  211. };
  212. enum WifiStateAction
  213. {
  214. WIFI_STATE_CHANGED_ACTION = 0, ///<AP, STATION
  215. WIFI_P2P_STATE_CHANGED_ACTION = 1, ///< P2P
  216. };
  217. enum WifiState
  218. {
  219. WIFI_STATE_UNKNOWN = 0,
  220. WIFI_STATE_ENABLE, ///< The network is available
  221. WIFI_STATE_DISABLE, ///< Network unavailable
  222. WIFI_STATE_CONNECTED, ///< Network connected
  223. WIFI_STATE_DISCONNECTED, ///< Network disconnection
  224. };
  225. struct NetWorkInfo
  226. {
  227. int32_t state; ///<see ECWifiState
  228. string phoneIp; ///<phone ip
  229. string carIp; ///<car ip
  230. };
  231. enum KeyCode
  232. {
  233. // for driving mode
  234. KEY_HOME = 1,
  235. KEY_PHONE = 2,
  236. KEY_TALKIE = 3, ///< start talkie
  237. KEY_NAVIGATION = 4, ///< start navigation
  238. KEY_VOICE_ASSISTANT = 5, ///< start voice assistant
  239. KEY_MUSIC_PLAY = 6, ///< play music
  240. KEY_MUSIC_NEXT = 7, ///< play next music
  241. KEY_MUSIC_PREVIOUS = 8, ///< play previous music
  242. KEY_MUSIC_PAUSE = 9, ///< music pause
  243. KEY_MUSIC_STOP = 10, ///< music stop
  244. KEY_MUSIC_PLAY_PAUSE = 11, ///< music switch between pause and stop
  245. KEY_VOLUME_UP = 12, ///< increase the volume of phone
  246. KEY_VOLUME_DOWN = 13, ///< decrease the volume of phone
  247. KEY_TOPLEFT = 14, ///< click top left button
  248. KEY_TOPRIGHT = 15, ///< click top right button
  249. KEY_BOTTOMLEFT = 16, ///< click bottom left button
  250. KEY_BOTTOMRIGHT = 17, ///< click bottom right button
  251. KEY_LIGHTMODE = 18, ///< click night mode button
  252. KEY_NIGHTMODE = 19, ///light mode
  253. KEY_APP_FRONT = 20, ///< make the app of android phone switch to the foreground
  254. KEY_APP_BACK = 21, ///< it works like the function of the back button to the app of the connected phone.
  255. KEY_CAR_FOREGROUND = 22, ///it carlinks 's ui foreground
  256. KEY_CAR_BACKGROUND = 23, ///it carlinks 's ui background
  257. KEY_ENFORCE_LANDSCAPE = 24, ///< make the android phone enforce landscape.
  258. KEY_CANCEL_LANDSCAPE = 25, ///< make the android phone cancel landscape.
  259. KEY_ENFORCE_OR_CANCEL_LANDSCAPE = 26, ///< make the android phone enforce or cancel landscape.
  260. KEY_SYSTEM_HOME = 27, ///< The Android phone's HOME key
  261. KEY_SYSTEM_BACK = 28, ///< The Android phone's BACK key
  262. KEY_PICKUP_PHONE = 29, /// pick up phone
  263. KEY_HANGUP_PHONE = 30, ///hang up phone
  264. KEY_CAR_OK = 31, ///make car links 'ui enter comfirm
  265. KEY_CAR_BACK = 32, ///make car links 'ui back page
  266. KEY_MAX, ///< reserve
  267. };
  268. struct LinkConfig
  269. {
  270. int offset_x;
  271. int offset_y;
  272. int screen_width;
  273. int screen_height;
  274. bool diy_screen;
  275. bool autostart;
  276. bool encryption;
  277. bool usb_index;
  278. LinkType linkType;
  279. string version;
  280. string manufacturer;
  281. string phone_bt_mac;
  282. string car_bt_mac;
  283. string phone_wifi_mac;
  284. string car_wifi_ssid;
  285. string car_wifi_passphrase;
  286. string car_wifi_channel;
  287. };
  288. struct CarlifeConfig
  289. {
  290. int ios_link_mode;
  291. int android_link_mode;
  292. bool mic_record;
  293. };
  294. struct CarplayConfig
  295. {
  296. int screen_physical_width;
  297. int screen_physical_height;
  298. int aec_delay;
  299. int fps;
  300. string vehicle_name;
  301. string vehicle_icon_label;
  302. string vehicle_icon_path;
  303. };
  304. class LinkBase
  305. {
  306. public:
  307. LinkBase(){}
  308. virtual ~LinkBase(){}
  309. protected:
  310. virtual bool init(LinkMode linkMode) = 0;
  311. virtual bool start() = 0;
  312. virtual bool stop() = 0;
  313. virtual bool release() = 0;
  314. virtual bool start_mirror() = 0;
  315. virtual bool stop_mirror() = 0;
  316. virtual bool set_background() = 0;
  317. virtual bool set_foreground() = 0;
  318. virtual bool get_audio_focus() = 0;
  319. virtual bool release_audio_focus() = 0;
  320. virtual void set_inserted(bool inserted, PhoneType phoneType) = 0;
  321. virtual void send_screen_size(int width, int height) = 0;
  322. virtual void record_audio_callback(unsigned char *data, int len) = 0;
  323. virtual void send_car_bluetooth(const string& name, const string& address, const string& pin) = 0;
  324. virtual void send_phone_bluetooth(const string& address) = 0;
  325. virtual void send_car_wifi(WifiInfo& info) = 0;
  326. virtual void send_touch(int x, int y, TouchCode touchCode) = 0;
  327. virtual void send_multi_touch(int x1, int y1, TouchCode touchCode1, int x2, int y2, TouchCode touchCode2) = 0;
  328. virtual bool send_key(KeyCode keyCode) = 0;
  329. virtual bool send_wheel(WheelCode wheel, bool foucs) = 0;
  330. virtual bool send_night_mode(bool night) = 0;
  331. virtual bool send_right_hand_driver(bool right) = 0;
  332. virtual bool open_page(AppPage appPage) = 0;
  333. virtual void request_status(RequestAppStatus requestAppStatus, void *reserved = nullptr) = 0;
  334. virtual void send_license(const string& license) = 0;
  335. virtual void send_input_text(const string& text) = 0;
  336. virtual void send_input_selection(const int start, const int stop) = 0;
  337. virtual void send_input_action(const int acionId, const int keyCode) = 0;
  338. virtual void send_bluetooth_cmd(const string& cmd ) = 0;
  339. virtual void send_broadcast(bool enable) = 0;
  340. virtual void send_delay_record(int millisecond) = 0;
  341. virtual void send_wifi_state_changed(WifiStateAction action, WifiState state, const string& phoneIp, const string& carIp) = 0;
  342. };
  343. #endif
  344. #endif // LINKBASE_H