util.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #ifndef UTIL_H
  2. #define UTIL_H
  3. #define MAXBUFSIZE 1024
  4. #define MAXPACKETAGE 32
  5. //#include "arkconfig.h"
  6. //#include "carplay.h"
  7. #include <string>
  8. using namespace std;
  9. typedef struct {
  10. int x;
  11. int y;
  12. int width;
  13. int height;
  14. } screen_pos;
  15. enum MSG_TYPE
  16. {
  17. GO_START_LINK = 1,
  18. GO_BACKGROUND,
  19. GO_FOREGROUND,
  20. GO_EXIT,
  21. GO_RESTART_LINK,
  22. GO_MUTE,
  23. GO_UNMUTE,
  24. GO_EXIT_PROCESS,
  25. };
  26. enum MSG_RECV
  27. {
  28. CMD_BACKGROUND = 10,
  29. CMD_FOREGROUND = 11,
  30. CMD_VIDEOREADY = 12,
  31. CMD_VIDEOSECOND= 13,
  32. CMD_REMOVED = 14,
  33. CMD_SUCCESS = 15,
  34. CMD_FAILED = 16,
  35. CMD_RECORD_START = 17,
  36. CMD_RECORD_END = 18,
  37. CMD_INSERTED = 19,
  38. CMD_NOTINSERTED= 20,
  39. CMD_BT_DISCONNECT = 21,
  40. CMD_CALL_PHONE = 22,
  41. CMD_CALL_PHONE_EXIT = 23,
  42. CMD_FAILED_EAP = 24,
  43. CMD_FAILED_UNSTART = 25,
  44. CMD_SOCKET_TRUST = 26,
  45. CMD_OPEN_CARLIFE = 27,
  46. CMD_VOLUME_START = 28,
  47. CMD_VOLUME_STOP = 29,
  48. CMD_SIRI_START = 24,
  49. CMD_SIRI_STOP = 25,
  50. CMD_ASSIST_AUDIO_START = 26,
  51. CMD_ASSIST_AUDIO_STOP = 27,
  52. CMD_CARLIFE_EXITED_INVOKED = 30,
  53. CMD_CARLIFE_MUSIC_STATUS = 31,
  54. CMD_MUSIC_START = 32,
  55. CMD_MUSIC_STOP = 33,
  56. CMD_NODATA = 34,
  57. CMD_VIDEOINIT = 35,
  58. CMD_RECORDER_INIT = 36,
  59. CMD_RECORDER_UNINIT = 37,
  60. CMD_START_LINK =40,
  61. CMD_BT_CALL_INCOMMING = 100,
  62. CMD_BT_CALL_OUT = 101, //
  63. CMD_BT_CALL_TERMINAL = 102,
  64. CMD_BT_CALL_ANSWER = 103, //BT来电
  65. CMD_BT_CALL_REJECT = 104, //BT拒绝接听
  66. CMD_BT_CALL_MUTE = 105, //BT挂断
  67. CMD_BT_CALL_UNMUTE = 106, //BT挂断
  68. CMD_BT_CALL_DTMF_0 = 107, //0
  69. CMD_BT_CALL_DTMF_1 = 108, //1
  70. CMD_BT_CALL_DTMF_2 = 109, //2
  71. CMD_BT_CALL_DTMF_3 = 110, //3
  72. CMD_BT_CALL_DTMF_4 = 111, //4
  73. CMD_BT_CALL_DTMF_5 = 112, //5
  74. CMD_BT_CALL_DTMF_6 = 113, //6
  75. CMD_BT_CALL_DTMF_7 = 114, //7
  76. CMD_BT_CALL_DTMF_8 = 115, //8
  77. CMD_BT_CALL_DTMF_9 = 116, //9
  78. CMD_BT_CALL_DTMF_STAR = 117, //*
  79. CMD_BT_CALL_DTMF_SHARP = 118, //#
  80. };
  81. typedef struct
  82. {
  83. int startcodeprefix_len; //! 4 for parameter sets and first slice in picture, 3 for everything else (suggested)
  84. unsigned len; //! Length of the NAL unit (Excluding the start code, which does not belong to the NALU)
  85. unsigned max_size; //! Nal Unit Buffer size
  86. int forbidden_bit; //! should be always FALSE
  87. int nal_reference_idc; //! NALU_PRIORITY_xxxx
  88. int nal_unit_type; //! NALU_TYPE_xxxx
  89. char *buf; //! contains the first byte followed by the EBSP
  90. unsigned short lost_packets; //! true, if packet loss is detected
  91. int data_offset;
  92. } NALU_t;
  93. class Util
  94. {
  95. public:
  96. Util();
  97. static void get_app(char *path);
  98. static void get_self_path_name(char *path);
  99. static bool get_deivce_type(int *device, int *vid, char *pBuffer);
  100. static void getFrameBufferFixedSize(int &width, int &height, const char* fbPath);
  101. static NALU_t * AllocNALU(int buffersize);
  102. static void FreeNALU(NALU_t *n);
  103. static int GetAnnexbNALU (NALU_t *nalu, unsigned char * Buf);
  104. static void init_var();
  105. static int open_local_socket();
  106. static int send_local_message( int inSock, const void *inMsg, size_t inLen);
  107. static void ReadBTInfo(string& addr, string& pin);
  108. static void changeOTG();
  109. };
  110. #endif // UTIL_H