carlife.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. #ifndef CARLIFE_H
  2. #define CARLIFE_H
  3. #include <semaphore.h>
  4. //#include <QTimer>
  5. #include "timer.h"
  6. #include<string>
  7. #include "libusb.h"
  8. using std::string;
  9. class BlueToothControl;
  10. enum PhoneOS
  11. {
  12. Unknown = 0,
  13. Android = 1,
  14. IOS = 2,
  15. WIRELESS = 3,
  16. };
  17. enum ScreenAction
  18. {
  19. ScreenPress,
  20. ScreenRelease,
  21. ScreenMove,
  22. ScreenSingleClick,
  23. ScreenDoubleClick,
  24. ScreenLongPress,
  25. };
  26. typedef enum
  27. {
  28. FAILED = -1,
  29. FAILED_EAP = -2,
  30. FAILED_UNSTART = -3,
  31. }FAILED_STATUS;
  32. //#define CARLIFE_ADB 1
  33. //#undef CARLIFE_ADB
  34. #define EAP_SIZE 100
  35. class CarLife
  36. {
  37. public:
  38. explicit CarLife();
  39. virtual ~CarLife();
  40. public:
  41. int AdbInitialize();
  42. int EapInitialize();
  43. int AOAInitialize(int idVendor);
  44. int SendHuProtocolVer();
  45. int SendHuInfo();
  46. int SendVideoInit();
  47. void VideoPause();
  48. void VideoStart();
  49. void VideoChangeRate(int fps);
  50. bool Authentication();
  51. int Install(int idVendor, char* pAddress = NULL);
  52. bool Connect(Timer* pTimer, char* pAddress = NULL);
  53. bool ChannelsStart(char* pAddress = NULL);
  54. //主动退出视频解码并且mute掉声音
  55. bool UnInitDecode();
  56. //释放了解码后第二次进入
  57. bool InitDecode();
  58. //mute掉所有声音,包括VR,TTS,Media和输入的Micphone
  59. bool AudioMute(bool bMute);
  60. void DecodeEntry(bool bEntry);
  61. void DecoderExit(bool bExit);
  62. //打开显示层
  63. bool OpenVideoLayer();
  64. //关闭显示层
  65. bool CloseVideoLayer();
  66. void ShowPlayer(bool visible);
  67. bool IsVideoLayerVisible();
  68. bool touchAction(int x, int y, int screenwidth, int screenheight,ScreenAction act);
  69. bool touchKey(int key);
  70. void SetPhoneOS(PhoneOS os); //获取是什么手机类型
  71. void SetBTHFPInComming(char *pPhoneNumber);
  72. void SetBTHFPActive();
  73. void SetBTHFPInActive();
  74. void SetBTHFPOutGoing();
  75. void SetEapLink(bool bEapLink);
  76. void SetAoaLink(bool bAoaLink);
  77. void DisconnectAoa();
  78. void setMicAudioData(unsigned char *data, int length);
  79. //注册手机断开的回调函数注册
  80. void SetSocketDisconnectCallback(void (*callback)(void*), void *parameter);
  81. //
  82. void SetMicDisconnectCallback(void (*callback)(void*), void *parameter);
  83. //cmd状态回调函数注册
  84. void SetCmdStatusCallback(void (*callback)(int ,void*), void *parameter);
  85. void SetCmdPhoneNumberCallback(void (*callback)(string, void*), void *parameter);
  86. void SetCmdMediaInfoCallback(void (*callback)(string, string, string, void*), void *parameter);
  87. //车机端是否显示问题
  88. void SetVideoCallback(void (*callback)(int, int ,int ,void*), void *parameter);
  89. void SetVideoInfoCallback(bool bControlVideo, void (*callback)(int,int,unsigned char*, int, void*), void*parameter);
  90. void SetAudioInfoCallback(void (*callback)(int,unsigned char*, int, void*), void*parameter);
  91. void SetAudioStartCallback(void (*callback)(bool,int,int,int,int, void*), void*parameter);
  92. //手机拔掉
  93. static void disconnect_callback_func();
  94. //作为盒子端从车机获取屏幕大小
  95. void GetCarScreenSize(int screenwidth, int screenheight);
  96. void SendCarBluetooth(const string& name, const string& address, const string& pin);
  97. //
  98. static void disconnect_mic_callback_func();
  99. //断开失败的处理
  100. void DisconnectHandler(char* pAddress = NULL);
  101. //cmd消息回调到这里
  102. static void cmd_status_callback_func(int status, void* parameter);
  103. static void music_status_callback_func(int status, void* parameter);
  104. static void cmd_phonenumber_callback_func(string phonenumber, void* parameter);
  105. static void cmd_mediainfo_callback_func(string song, string artist, string album, void* parameter);
  106. //车机端显示回调
  107. static void video_callback_func(int ready, int width, int height, void* parameter);
  108. static void video_info_callback_func(int width, int height, unsigned char* data, int length, void*parameter);
  109. static void music_info_callback_func(unsigned char* data, int length, void* parameter);
  110. static void music_start_callback_func(bool start, int type, int rate, int bit, int channel, void *parameter);
  111. static void tts_info_callback_func(unsigned char* data, int length, void* parameter);
  112. static void tts_start_callback_func(bool start, int type, int rate, int bit, int channel, void *parameter);
  113. static void vr_info_callback_func(unsigned char* data, int length, void* parameter);
  114. static void vr_start_callback_func(bool start, int type, int rate, int bit, int channel, void *parameter);
  115. private:
  116. //手机类型
  117. PhoneOS m_PhoneOS;
  118. int m_nScreenWidth;
  119. int m_nScreenHeight;
  120. void* m_parameter;
  121. void (*m_socket_disconnect_callback)(void*);
  122. void (*m_mic_disconnect_callback)(void*);
  123. void (*m_cmd_status_callback)(int ,void*);
  124. void (*m_music_status_callback)(int ,void*);
  125. void (*m_cmd_phonenumber_callback)(string ,void*);
  126. void (*m_cmd_mediainfo_callback)(string, string,string ,void*);
  127. void (*m_vido_callback)(int, int, int,void*);
  128. void (*m_video_info_callback)(int,int,unsigned char*, int,void*);
  129. void (*m_audio_info_callback)(int,unsigned char*, int,void*);
  130. void (*m_audio_start_callback)(bool,int,int,int,int,void*);
  131. bool m_bControlVideo;
  132. libusb_device *m_device;
  133. //视频准备好
  134. bool m_ready;
  135. bool m_bEapLink;
  136. bool m_bAoaLink;
  137. };
  138. #endif // CARLIFE_H