MirrorLink.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #include "MirrorLink.h"
  2. #include "mirrorplayer.h"
  3. MirrorLink::MirrorLink()
  4. {
  5. #ifdef USE_MIRROR
  6. m_pMirrorPlayer = new MirrorPlayer();
  7. #endif
  8. }
  9. MirrorLink::~MirrorLink()
  10. {
  11. #ifdef USE_MIRROR
  12. if(m_pMirrorPlayer)
  13. delete m_pMirrorPlayer;
  14. #endif
  15. }
  16. #ifdef USE_MIRROR
  17. bool MirrorLink::init(LinkMode linkMode)
  18. {
  19. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  20. m_pMirrorPlayer->Initialize();
  21. m_pMirrorPlayer->SetLinkstatusCallback(linkstatus_callback_func,this);
  22. m_pMirrorPlayer->SetVideoStartCallback(std::bind(&MirrorLink::onVideoStartCallback,this, std::placeholders::_1,std::placeholders::_2,std::placeholders::_3));
  23. m_pMirrorPlayer->SetVideoInfoCallback(std::bind(&MirrorLink::onVideoInfoCallback,this, std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4));
  24. return true;
  25. }
  26. bool MirrorLink::release()
  27. {
  28. if(m_pMirrorPlayer){
  29. m_pMirrorPlayer->ExitLink();
  30. delete m_pMirrorPlayer;
  31. m_pMirrorPlayer = nullptr;
  32. }
  33. return true;
  34. }
  35. bool MirrorLink::start()
  36. {
  37. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  38. if(m_pMirrorPlayer){
  39. onSdkConnectStatus(CONNECT_STATUS_CONNECTING, Phone_Android);
  40. m_pMirrorPlayer->startServer();
  41. }
  42. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  43. return true;
  44. }
  45. bool MirrorLink::stop()
  46. {
  47. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  48. if(m_pMirrorPlayer){
  49. m_pMirrorPlayer->stopServer();
  50. }
  51. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  52. return true;
  53. }
  54. bool MirrorLink::start_mirror()
  55. {
  56. return true;
  57. }
  58. bool MirrorLink::stop_mirror()
  59. {
  60. return true;
  61. }
  62. bool MirrorLink::set_background()
  63. {
  64. }
  65. bool MirrorLink::set_foreground()
  66. {
  67. }
  68. bool MirrorLink::get_audio_focus()
  69. {
  70. }
  71. bool MirrorLink::release_audio_focus()
  72. {
  73. }
  74. void MirrorLink::set_inserted(bool inserted, PhoneType phoneType)
  75. {
  76. }
  77. void MirrorLink::send_screen_size(int width, int height)
  78. {
  79. }
  80. #define DUMP_REC_FILE 0
  81. #if DUMP_REC_FILE
  82. static FILE *pfile = NULL;
  83. #endif
  84. void MirrorLink::record_audio_callback(unsigned char *data, int len)
  85. {
  86. }
  87. void MirrorLink::send_car_bluetooth(const string& name, const string& address, const string& pin)
  88. {
  89. }
  90. void MirrorLink::send_phone_bluetooth(const string& address)
  91. {
  92. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  93. }
  94. void MirrorLink::send_touch(int x, int y, TouchCode touchCode)
  95. {
  96. printf("carplay x:%d, y:%d, press:%d\r\n",x, y, touchCode);
  97. }
  98. bool MirrorLink::send_key(KeyCode keyCode)
  99. {
  100. }
  101. bool MirrorLink::send_wheel(WheelCode wheel, bool foucs)
  102. {
  103. }
  104. bool MirrorLink::open_page(AppPage appPage)
  105. {
  106. }
  107. void MirrorLink::request_status(RequestAppStatus requestAppStatus, void *reserved)
  108. {
  109. }
  110. void MirrorLink::linkstatus_callback_func(int status, void* parameter)
  111. {
  112. MirrorLink *pthis = (MirrorLink*)parameter;
  113. printf("status = %d\r\n", status);
  114. }
  115. void MirrorLink::onVideoStartCallback(bool start, int width, int height)
  116. {
  117. int offx = 0 ;//+ (mLinkConfig.screen_width - width) / 2;
  118. int offy = 0 ;//+ (mLinkConfig.screen_height - height) / 2;
  119. if(start)
  120. video_start(offx, offy, width, height);
  121. else
  122. video_stop();
  123. }
  124. void MirrorLink::onVideoInfoCallback(int width, int height, unsigned char* data, int length)
  125. {
  126. video_play(data, length);
  127. }
  128. #endif