videochannel.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #ifndef VIDEOCHANEL_H
  2. #define VIDEOCHANEL_H
  3. #include "thread.h"
  4. #include "types.h"
  5. #include "CCarLifeLibWrapper.h"
  6. #include "videodecode.h"
  7. #include <stdio.h>
  8. class VideoChannel : public Thread
  9. {
  10. public:
  11. VideoChannel();
  12. virtual ~VideoChannel();
  13. static VideoChannel *instance();
  14. //初始化视频解码参数
  15. void setVideoParam(const uint width, const uint height, const uint frameRate);
  16. //车机端显示回调注册
  17. void SetVideoCallback(void (*callback)(int,int ,int ,void*), void *parameter);
  18. void SetVideoInfoCallback(bool bControlVideo, void (*callback)(int, int ,unsigned char*, int ,void*), void *parameter);
  19. void ShowPlayer(bool bVisible);
  20. bool IsPlayerVisible() const
  21. {
  22. return m_bVisible;
  23. }
  24. uint width() const
  25. {
  26. return mParam.width;
  27. }
  28. uint height() const
  29. {
  30. return mParam.height;
  31. }
  32. uint frameRate() const
  33. {
  34. return mParam.frameRate;
  35. }
  36. bool recvData() const
  37. {
  38. return mRecvData;
  39. }
  40. void setRecvData(bool recv)
  41. {
  42. mRecvData = recv;
  43. }
  44. VideoDecode *decoder()
  45. {
  46. return m_pVideoDecode;
  47. }
  48. VideoParam GetVideoParam() const
  49. {
  50. return mParam;
  51. }
  52. protected:
  53. virtual void run(); //线程执行函数
  54. private:
  55. //数据接收回调函数
  56. static void recvData(u8 *data, u32 len); //接收视频数据
  57. static void recvHeartBeat(); //接收心跳包
  58. //视频显示通知
  59. static void video_callback_func(int ready, void* parameter);
  60. static void video_info_callback_func(int width,int height, unsigned char* data, int length, void* parameter);
  61. private:
  62. static VideoChannel *mInstance;
  63. VideoParam mParam;
  64. bool mRecvData;
  65. VideoDecode *m_pVideoDecode;
  66. bool m_bVisible;
  67. bool mbControlVideo;
  68. int m_screen_width;
  69. int m_screen_height;
  70. void (*m_video_callback)(int, int, int, void *);
  71. void (*m_video_info_callback)(int,int,unsigned char*,int,void*);
  72. void *m_parameter;
  73. };
  74. #endif // VIDEOCHANEL_H