video-io.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /******************************************************************************
  2. Copyright (C) 2013 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include "../util/c99defs.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /* Base video output component. Use this to create an video output track. */
  20. #define MAX_VIDEO_PLANES 8
  21. struct video_output;
  22. typedef struct video_output *video_t;
  23. enum video_format {
  24. VIDEO_FORMAT_NONE,
  25. /* planar 420 format */
  26. VIDEO_FORMAT_I420, /* three-plane */
  27. VIDEO_FORMAT_NV12, /* two-plane, luma and packed chroma */
  28. /* packed 422 formats */
  29. VIDEO_FORMAT_YVYU,
  30. VIDEO_FORMAT_YUY2, /* YUYV */
  31. VIDEO_FORMAT_UYVY,
  32. /* packed uncompressed formats */
  33. VIDEO_FORMAT_YUVX,
  34. VIDEO_FORMAT_UYVX,
  35. VIDEO_FORMAT_RGBA,
  36. VIDEO_FORMAT_BGRA,
  37. VIDEO_FORMAT_BGRX,
  38. };
  39. struct video_frame {
  40. const uint8_t *data[MAX_VIDEO_PLANES];
  41. uint32_t row_size[MAX_VIDEO_PLANES];
  42. uint64_t timestamp;
  43. };
  44. struct video_output_info {
  45. const char *name;
  46. enum video_format format;
  47. uint32_t fps_num;
  48. uint32_t fps_den;
  49. uint32_t width;
  50. uint32_t height;
  51. };
  52. struct video_convert_info {
  53. enum video_format format;
  54. uint32_t width;
  55. uint32_t height;
  56. uint32_t row_align;
  57. };
  58. #define VIDEO_OUTPUT_SUCCESS 0
  59. #define VIDEO_OUTPUT_INVALIDPARAM -1
  60. #define VIDEO_OUTPUT_FAIL -2
  61. EXPORT int video_output_open(video_t *video, struct video_output_info *info);
  62. EXPORT void video_output_close(video_t video);
  63. EXPORT void video_output_connect(video_t video,
  64. struct video_convert_info *conversion,
  65. void (*callback)(void *param, const struct video_frame *frame),
  66. void *param);
  67. EXPORT void video_output_disconnect(video_t video,
  68. void (*callback)(void *param, const struct video_frame *frame),
  69. void *param);
  70. EXPORT const struct video_output_info *video_output_getinfo(video_t video);
  71. EXPORT void video_output_frame(video_t video, struct video_frame *frame);
  72. EXPORT bool video_output_wait(video_t video);
  73. EXPORT uint64_t video_getframetime(video_t video);
  74. EXPORT uint64_t video_gettime(video_t video);
  75. EXPORT void video_output_stop(video_t video);
  76. #ifdef __cplusplus
  77. }
  78. #endif