LinkBase.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. #ifndef LINKBASE_H
  2. #define LINKBASE_H
  3. #endif // LINKBASE_H
  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. }DbusSend;
  46. //carlink receive or user's request
  47. typedef enum
  48. {
  49. DBUS_REQUEST_CONNECT,
  50. DBUS_REQUEST_FOREGROUND,
  51. DBUS_REQUEST_BACKGROUND,
  52. DBUS_REQUEST_EXITED,
  53. }DbusReceive;
  54. typedef enum
  55. {
  56. UnKnown,
  57. Phone_Android,
  58. Phone_IOS,
  59. }PhoneType;
  60. typedef enum
  61. {
  62. APP_NOT_RUNNING, //phone app not open
  63. APP_FOREGROUND, //carlink foreground
  64. APP_BACKGROUND, //carlink background
  65. APP_SCREENLOCKED, //phone screen locked
  66. APP_UNSCREENLOCKED, //phone screen unlocked
  67. APP_MUSIC_STARTED, //music start
  68. APP_MUSIC_STOPPED, //music stop
  69. APP_NAVI_STARTED, //navigation start
  70. APP_NAVI_STOPPED, //navigation stop
  71. APP_VR_STARTED, //voices start
  72. APP_VR_STOPPED, //voices stop
  73. APP_RECOGNITION_STARTED, //voices recognition start(record start)
  74. APP_RECOGNITION_STOPPED, //voices recognition stop(record stop)
  75. APP_PHONE_STARTED, //phone call start
  76. APP_PHONE_STOPPED, //phone call stop
  77. LAUNCH_PHONE_APP, //notify open phone's app
  78. APP_QRCODE, //qr code 's information
  79. APP_LICENSE, //license information
  80. APP_INPUTINFO, //keyboard input information
  81. APP_INPUTPOS, //keyboard input pos information
  82. APP_VRTEXT, //voices information
  83. APP_VOICE_CMD, //voices controls information
  84. APP_VERSION, //version
  85. APP_RESERVED, //reserved
  86. }AppStatusMessage;
  87. //亿连id
  88. struct License{
  89. bool activate;
  90. int code;
  91. string msg;
  92. string ver;
  93. };
  94. struct InputInfo
  95. {
  96. int32_t inputType;
  97. int32_t imeOptions;
  98. string rawText;
  99. uint32_t minLines;
  100. uint32_t maxLines;
  101. uint32_t maxLength;
  102. };
  103. struct InputPos{
  104. int start;
  105. int stop;
  106. };
  107. enum VRTextType
  108. {
  109. VR_TEXT_FROM_UNKNOWN = 0,
  110. VR_TEXT_FROM_VR,
  111. VR_TEXT_FROM_SPEAK
  112. };
  113. struct VRTextInfo
  114. {
  115. VRTextType type;
  116. int32_t sequence;
  117. string plainText;
  118. string htmlText;
  119. };
  120. typedef enum
  121. {
  122. APP_PAGE_NAVIGATION,
  123. APP_PAGE_MUSIC,
  124. APP_PAGE_VR,
  125. APP_PAGE_NAVI_HOME,
  126. APP_PAGE_NAVI_WORK,
  127. APP_PAGE_MAIN,
  128. APP_PAGE_NAVI_GAS_STATION,
  129. APP_PAGE_CAR_PARK,
  130. APP_PAGE_4S_SHOP,
  131. }AppPage;
  132. enum CallType
  133. {
  134. CALL_TYPE_DAIL = 0, ///< ring up
  135. CALL_TYPE_HANG_UP, ///< ring off
  136. CALL_TYPE_MAX, ///< reserve
  137. };
  138. enum ConnectedStatus
  139. {
  140. CONNECT_STATUS_DEVICE_ATTACHED,
  141. CONNECT_STATUS_DEVICE_DEATTACHED,
  142. CONNECT_STATUS_CONNECTING,
  143. CONNECT_STATUS_CONNECT_FAILED,
  144. CONNECT_STATUS_CONNECT_SUCCEED,
  145. CONNECT_STATUS_DISCONNECTED,
  146. CONNECT_STATUS_APP_EXIT,
  147. CONNECT_STATUS_INTERRUPTED_BY_APP,
  148. };
  149. enum RequestAppStatus
  150. {
  151. QUERYTIME,
  152. QUERYGPS,
  153. QUERYBTSTATUS,
  154. QUERYQRCODE,
  155. QUERYINPUT,
  156. };
  157. enum AudioType
  158. {
  159. AUDIO_TYPE_MUSIC = 0x00, ///< Music audio
  160. AUDIO_TYPE_CALL = 0x01, ///< phone call audio
  161. AUDIO_TYPE_VR = 0x02, ///< VR audio
  162. AUDIO_TYPE_TTS = 0x03, ///< TTS audio
  163. AUDIO_TYPE_Rec = 0x04, ///< rec audio
  164. AUDIO_TYPE_Alert = 0x05, ///< alert audio
  165. };
  166. struct AudioInfo
  167. {
  168. uint32_t sampleRate; ///< sample rate
  169. uint32_t channel; ///< channel type
  170. uint32_t format; ///< audio format type
  171. };
  172. enum WheelCode
  173. {
  174. Wheel_Keep = 0,
  175. Wheel_Next = 1,
  176. Wheel_Previous = -1,
  177. };
  178. enum TouchCode
  179. {
  180. Touch_Up = 0,
  181. Touch_Press = 1,
  182. Touch_Move = 2,
  183. };
  184. struct WifiInfo{
  185. string ssid;
  186. string passphrase;
  187. string channel_id;
  188. };
  189. struct BlueToothInfo{
  190. string name;
  191. string addr;
  192. string pin;
  193. };
  194. enum KeyCode
  195. {
  196. // for driving mode
  197. KYE_HOME = 1,
  198. KEY_PHONE = 2,
  199. KEY_TALKIE = 3, ///< start talkie
  200. KEY_NAVIGATION = 4, ///< start navigation
  201. KEY_VOICE_ASSISTANT = 5, ///< start voice assistant
  202. KEY_MUSIC_PLAY = 6, ///< play music
  203. KEY_MUSIC_NEXT = 7, ///< play next music
  204. KEY_MUSIC_PREVIOUS = 8, ///< play previous music
  205. KEY_MUSIC_PAUSE = 9, ///< music pause
  206. KEY_MUSIC_STOP = 10, ///< music stop
  207. KEY_MUSIC_PLAY_PAUSE = 11, ///< music switch between pause and stop
  208. KEY_VOLUME_UP = 12, ///< increase the volume of phone
  209. KEY_VOLUME_DOWN = 13, ///< decrease the volume of phone
  210. KEY_TOPLEFT = 14, ///< click top left button
  211. KEY_TOPRIGHT = 15, ///< click top right button
  212. KEY_BOTTOMLEFT = 16, ///< click bottom left button
  213. KEY_BOTTOMRIGHT = 17, ///< click bottom right button
  214. KEY_LIGHTMODE = 18, ///< click night mode button
  215. KEY_NIGHTMODE = 19, ///light mode
  216. KEY_APP_FRONT = 20, ///< make the app of android phone switch to the foreground
  217. KEY_APP_BACK = 21, ///< it works like the function of the back button to the app of the connected phone.
  218. KEY_CAR_FRONT = 22,
  219. KEY_CAR_BACK = 23,
  220. KEY_ENFORCE_LANDSCAPE = 24, ///< make the android phone enforce landscape.
  221. KEY_CANCEL_LANDSCAPE = 25, ///< make the android phone cancel landscape.
  222. KEY_ENFORCE_OR_CANCEL_LANDSCAPE = 26, ///< make the android phone enforce or cancel landscape.
  223. KEY_SYSTEM_HOME = 27, ///< The Android phone's HOME key
  224. KEY_SYSTEM_BACK = 28, ///< The Android phone's BACK key
  225. KEY_PICKUP_PHONE = 29, /// pick up phone
  226. KEY_HANGUP_PHONE = 30, ///hang up phone
  227. KEY_MAX, ///< reserve
  228. };
  229. struct LinkConfig
  230. {
  231. int offset_x;
  232. int offset_y;
  233. int screen_width;
  234. int screen_height;
  235. bool diy_screen;
  236. bool autostart;
  237. bool encryption;
  238. bool usb_index;
  239. LinkType linkType;
  240. string version;
  241. string manufacturer;
  242. string phone_bt_mac;
  243. string car_bt_mac;
  244. string phone_wifi_mac;
  245. string car_wifi_ssid;
  246. string car_wifi_passphrase;
  247. string car_wifi_channel;
  248. };
  249. struct CarlifeConfig
  250. {
  251. int ios_link_mode;
  252. int android_link_mode;
  253. bool mic_record;
  254. };
  255. struct CarplayConfig
  256. {
  257. int screen_physical_width;
  258. int screen_physical_height;
  259. int aec_delay;
  260. int fps;
  261. };
  262. class LinkBase
  263. {
  264. public:
  265. LinkBase(){}
  266. virtual ~LinkBase(){}
  267. protected:
  268. virtual bool init(LinkMode linkMode) = 0;
  269. virtual bool start() = 0;
  270. virtual bool stop() = 0;
  271. virtual bool release() = 0;
  272. virtual bool start_mirror() = 0;
  273. virtual bool stop_mirror() = 0;
  274. virtual bool set_background() = 0;
  275. virtual bool set_foreground() = 0;
  276. virtual bool get_audio_focus() = 0;
  277. virtual bool release_audio_focus() = 0;
  278. virtual void set_inserted(bool inserted, PhoneType phoneType) = 0;
  279. virtual void send_screen_size(int width, int height) = 0;
  280. virtual void record_audio_callback(unsigned char *data, int len) = 0;
  281. virtual void send_car_bluetooth(const string& name, const string& address, const string& pin) = 0;
  282. virtual void send_phone_bluetooth(const string& address) = 0;
  283. virtual void send_car_wifi(WifiInfo& info) = 0;
  284. virtual void send_touch(int x, int y, TouchCode TouchCode) = 0;
  285. virtual void send_multi_touch(int x1, int y1, TouchCode touchCode1, int x2, int y2, TouchCode touchCode2) = 0;
  286. virtual bool send_key(KeyCode keyCode) = 0;
  287. virtual bool send_wheel(WheelCode wheel, bool foucs) = 0;
  288. virtual bool send_night_mode(bool night) = 0;
  289. virtual bool send_right_hand_driver(bool right) = 0;
  290. virtual bool open_page(AppPage appPage) = 0;
  291. virtual void request_status(RequestAppStatus requestAppStatus, void *reserved = nullptr) = 0;
  292. virtual void send_license(const string& license) = 0;
  293. virtual void send_input_text(const string& text) = 0;
  294. virtual void send_input_selection(const int start, const int stop) = 0;
  295. virtual void send_input_action(const int acionId, const int keyCode) = 0;
  296. };