HiCarLink.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef HICARLINK_H
  2. #define HICARLINK_H
  3. #include <mutex>
  4. #include "IUserLinkPlayer.h"
  5. #ifdef USE_HICAR
  6. #define PLAYLOAD 640
  7. enum HiCarAudioStreamType {
  8. HiCar_AUDIO_STREAM_TELEPHONY = 0,
  9. HiCar_AUDIO_STREAM_VR = 2,
  10. HiCar_AUDIO_STREAM_MEDIA = 3,
  11. HiCar_AUDIO_STREAM_Alt = 4,
  12. };
  13. class HiCarLink;
  14. class BufferQueue;
  15. class HiCarLinkImpl
  16. {
  17. public:
  18. HiCarLinkImpl(HiCarLink *handle);
  19. ~HiCarLinkImpl();
  20. //int HiCarGetTypeByStreamType(int streamType);
  21. AudioType ChangeAudioType(HiCarAudioStreamType type);
  22. static int HiCarSendVHiCarEventCallBack(int type, void *data, int len, void *parameters);
  23. static int HiCarSendVideoDataCallBack(int type, void *data, int dataLen, void *parameters);
  24. static int HiCarGetAudioDataCallBack(int streamType, void *data, int dataLen, void *parameters);
  25. static int HiCarGetAudioMicDataCallBack(int streamType, void *data, int dataLen, void *parameters);
  26. static int HiCarSendVHiCarBTCallBack(int type, void *data, int dataLen, void *parameters);
  27. static int HiCarAudioFoucsCallBack(int type, void *streamType, int focus, void* parameters);
  28. private:
  29. HiCarLink *mHandle;
  30. int mHiCarState;
  31. };
  32. #endif
  33. class HiCarLink : public IUserLinkPlayer
  34. {
  35. public:
  36. HiCarLink();
  37. virtual ~HiCarLink();
  38. #ifdef USE_HICAR
  39. protected:
  40. virtual bool init(LinkMode linkMode);
  41. virtual bool release();
  42. virtual bool start();
  43. virtual bool stop();
  44. virtual bool start_mirror();
  45. virtual bool stop_mirror();
  46. virtual bool set_background();
  47. virtual bool set_foreground();
  48. virtual bool get_audio_focus();
  49. virtual bool release_audio_focus();
  50. virtual void set_inserted(bool inserted, PhoneType phoneType);
  51. virtual void send_screen_size(int width, int height);
  52. virtual void record_audio_callback(unsigned char *data, int len);
  53. virtual void send_car_bluetooth(const string& name, const string& address, const string& pin);
  54. virtual void send_phone_bluetooth(const string& address);
  55. virtual void send_car_wifi(WifiInfo& info);
  56. virtual void send_touch(int x, int y, TouchCode touchCode);
  57. virtual void send_multi_touch(int x1, int y1, TouchCode touchCode1, int x2, int y2, TouchCode touchCode2);
  58. virtual bool send_key(KeyCode keyCode);
  59. virtual bool send_wheel(WheelCode wheel, bool foucs);
  60. virtual bool send_night_mode(bool night);
  61. virtual bool send_right_hand_driver(bool right);
  62. virtual bool open_page(AppPage appPage);
  63. virtual void request_status(RequestAppStatus requestAppStatus, void *reserved = nullptr);
  64. virtual void send_license(const string& license){}
  65. virtual void send_input_text(const string& text) {}
  66. virtual void send_input_selection(const int start, const int stop){}
  67. virtual void send_input_action(const int acionId, const int keyCode){}
  68. virtual void send_bluetooth_cmd(const string& cmd);
  69. virtual void send_broadcast(bool enable);
  70. virtual void send_delay_record(int millisecond);
  71. virtual void send_wifi_state_changed(WifiStateAction action, WifiState state, const string& phoneIp, const string& carIp){}
  72. friend class HiCarLinkImpl;
  73. protected:
  74. PhoneType getPhoneType() {return mPhoneType;}
  75. private:
  76. LinkMode mLinkMode;
  77. HiCarLinkImpl* mHandle;
  78. PhoneType mPhoneType;
  79. std::mutex mMutex;
  80. BufferQueue* mRecQueue;
  81. int mRecPos;
  82. uint8_t mRecBuf[PLAYLOAD];
  83. int mLinkType;
  84. int mMillisecond;
  85. #endif
  86. };
  87. #endif // HICARLINK_H