video_player.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (c) 2019 Actions Semiconductor Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file video_player.h
  8. */
  9. #ifndef _VIDEO_PLAYER_H_
  10. #define _VIDEO_PLAYER_H_
  11. #include <stream.h>
  12. #define VIDEO_PIXEL_WIDTH CONFIG_PANEL_TIMING_VACTIVE
  13. #define VIDEO_PIXEL_HEIGHT CONFIG_PANEL_TIMING_HACTIVE
  14. typedef enum
  15. {
  16. LOCAT_TYPE_DIR,
  17. LOCAT_TYPE_PLIST,
  18. } location_type_e;
  19. typedef enum
  20. {
  21. VP_STATUS_IDLE = 0,
  22. VP_STATUS_PRELOAD,
  23. VP_STATUS_PLAYING,
  24. VP_STATUS_PAUSED,
  25. VP_STATUS_STOPED,
  26. VP_STATUS_ERROR,
  27. } vp_status_e;
  28. typedef enum
  29. {
  30. VP_PLAYMODE_NORMAL,
  31. VP_PLAYMODE_LOOPBACK,
  32. } vp_playmode_e;
  33. typedef struct
  34. {
  35. void *decode_buf;
  36. int decode_buf_size;
  37. int width;
  38. int height;
  39. int format;
  40. } video_data_t;
  41. typedef void (*vp_callback)(vp_status_e status, void *user_data, video_data_t *data);
  42. typedef void *(*vp_mem_alloc)(int size);
  43. typedef void (*vp_mem_free)(void *ptr);
  44. typedef struct {
  45. vp_callback cb;
  46. void *cb_data;
  47. bool need_decode;
  48. bool mute;
  49. char *url;
  50. vp_mem_alloc alloc;
  51. vp_mem_free free;
  52. bool preload;
  53. bool repeat;
  54. } video_init_param_t;
  55. /******************************************************************************/
  56. /*! \ingroup video_player_interface
  57. * \par Description:
  58. * 打开video播放器
  59. * \return 成功返回0, 失败返回-1
  60. *******************************************************************************/
  61. int video_player_open(video_init_param_t *init_param);
  62. /******************************************************************************/
  63. /*! \ingroup video_player_interface
  64. * \par Description:
  65. * 关闭video播放器
  66. * \return 成功返回0, 失败返回-1
  67. *******************************************************************************/
  68. int video_player_close(void);
  69. /******************************************************************************/
  70. /*! \ingroup video_player_interface
  71. * \par Description:
  72. * 开始播放
  73. * \return 成功返回0, 失败返回-1
  74. *******************************************************************************/
  75. int video_player_play(void);
  76. /******************************************************************************/
  77. /*! \ingroup video_player_interface
  78. * \par Description:
  79. * 停止播放,释放文件和音频资源
  80. * \param [in] sync 0: 发送停止命令后立即返回;1: 等待播放器停止后才返回
  81. * \return 成功返回0, 失败返回-1
  82. *******************************************************************************/
  83. int video_player_stop(bool sync, bool mem_release);
  84. /******************************************************************************/
  85. /*! \ingroup video_player_interface
  86. * \par Description:
  87. * 暂停播放
  88. * \param [in] sync 0: 发送暂停命令后立即返回;1: 等待播放器暂停后才返回
  89. * \return 成功返回0, 失败返回-1
  90. *******************************************************************************/
  91. int video_player_pause(bool sync, bool mem_release);
  92. /******************************************************************************/
  93. /*! \ingroup video_player_interface
  94. * \par Description:
  95. * 暂停后恢复播放
  96. * \return 成功返回0, 失败返回-1
  97. *******************************************************************************/
  98. int video_player_resume(void);
  99. /******************************************************************************/
  100. /*! \ingroup video_player_interface
  101. * \par Description:
  102. * seek到某个时间点,setfile后即可调用,seek后播放器进入播放状态
  103. * \param [in] ms seek到的时间点,单位毫秒
  104. * \return 成功返回0, 失败返回-1
  105. *******************************************************************************/
  106. int video_player_seek(int ms);
  107. /******************************************************************************/
  108. /*! \ingroup video_player_interface
  109. * \par Description:
  110. * 获取当前播放器状态
  111. * \param [out] st 返回当前播放器状态
  112. * \return 成功返回对应状态, 失败返回-1
  113. *******************************************************************************/
  114. vp_status_e video_player_get_status(void);
  115. /******************************************************************************/
  116. /*! \ingroup video_player_interface
  117. * \par Description:
  118. * 获取视频总时间
  119. * \return 成功返回视频总时间, 失败返回-1
  120. *******************************************************************************/
  121. int video_player_get_total_time(void);
  122. /******************************************************************************/
  123. /*! \ingroup video_player_interface
  124. * \par Description:
  125. * 获取当前播放时间
  126. * \return 成功返回当前播放时间, 失败返回-1
  127. *******************************************************************************/
  128. int video_player_get_cur_time(void);
  129. void * video_player_get_buffer(void);
  130. int video_player_mute(void);
  131. int video_player_demute(void);
  132. #endif // _VIDEO_PLAYER_H_