videodecode.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef VIDEODECODE_H
  2. #define VIDEODECODE_H
  3. #include <stdint.h>
  4. #include <semaphore.h>
  5. #define DISPLAY_LAYER 1
  6. //#define TVOUT_LAYER 3
  7. #define TVOUT_WIDTH 720
  8. #define TVOUT_HEIGHT 480
  9. #define MEMALLOC_MODULE_PATH "/tmp/dev/memalloc"
  10. #define MAX_STREAM_BUFFER_SIZE (1024*1024)
  11. #define SOFT_DECODEC 0
  12. class VideoDecode
  13. {
  14. public:
  15. VideoDecode();
  16. virtual ~VideoDecode();
  17. public:
  18. void SetVideoCallback(void (*callback)(int, void*), void *parameter);
  19. int InitVideoDecode(int x, int y, int src_width, int src_height, int dst_width, int dst_height); //初始化视频解码
  20. void UninitVideoDecode(); //释放视频解码
  21. void SetDecoderExit(bool bExit); //解码释放
  22. bool GetDecoderExit() const {return m_bDoExit;}
  23. void SetDecoderEntry(bool bEntry); //连接上后释放解码第二次及以上进入
  24. int OpenVideoLayer(int x, int y, int src_width, int src_height,int dst_width, int dst_height); //打开FB视频层
  25. void CloseVideoLayer(); //关闭FB视频层
  26. int MallocMemory(); //分配内存
  27. int FreeMemory(); //释放内存
  28. bool ShowPlayer(bool bVisible); //显示还是隐藏视频
  29. bool IsPlayerVisible() const
  30. {
  31. return m_bVisible;
  32. }
  33. int Decode(const void *data, const int length); //解码调用一桢数据
  34. int Draw();
  35. void FindNALUHead(char *data , int length);
  36. bool IsIDRFrame(char *data, int size);
  37. private:
  38. int m_VideoFD;
  39. int m_TVOutFD;
  40. int m_nSrcWidth;
  41. int m_nSrcHeight;
  42. int m_x;
  43. int m_y;
  44. int m_nDecodeFrame;
  45. int m_HeadSize;
  46. char m_HeadData[100];
  47. uint8_t *m_player;
  48. void (*m_video_callback)(int, void *);
  49. void *m_parameter;
  50. //解码完成准备显示图片
  51. bool m_bReady;
  52. //连接中去退出
  53. bool m_bDoExit;
  54. //连接中再进入
  55. bool m_bDoEntry;
  56. bool m_bVisible;
  57. bool m_bMemory;
  58. bool m_bSecondVisible;
  59. bool m_bHead;
  60. int m_mapSize;
  61. unsigned int mOldyBusAddress;
  62. //pthread_mutex_t m_VideoMutex;
  63. };
  64. #endif // VIDEODECODE_H