video-io.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. struct video_output;
  21. typedef struct video_output *video_t;
  22. enum video_format {
  23. VIDEO_FORMAT_NONE,
  24. /* planar 420 format */
  25. VIDEO_FORMAT_I420, /* three-plane */
  26. VIDEO_FORMAT_NV12, /* two-plane, luma and packed chroma */
  27. /* packed 422 formats */
  28. VIDEO_FORMAT_YVYU,
  29. VIDEO_FORMAT_YUY2, /* YUYV */
  30. VIDEO_FORMAT_UYVY,
  31. /* packed uncompressed formats */
  32. VIDEO_FORMAT_YUVX,
  33. VIDEO_FORMAT_UYVX,
  34. VIDEO_FORMAT_RGBA,
  35. VIDEO_FORMAT_BGRA,
  36. VIDEO_FORMAT_BGRX,
  37. };
  38. struct video_frame {
  39. const void *data;
  40. uint32_t row_size; /* for RGB/BGR formats and UYVX */
  41. uint64_t timestamp;
  42. };
  43. struct video_output_info {
  44. const char *name;
  45. enum video_format format;
  46. uint32_t fps_num;
  47. uint32_t fps_den;
  48. uint32_t width;
  49. uint32_t height;
  50. };
  51. struct video_convert_info {
  52. enum video_format format;
  53. uint32_t width;
  54. uint32_t height;
  55. uint32_t row_align;
  56. };
  57. #define VIDEO_OUTPUT_SUCCESS 0
  58. #define VIDEO_OUTPUT_INVALIDPARAM -1
  59. #define VIDEO_OUTPUT_FAIL -2
  60. EXPORT int video_output_open(video_t *video, struct video_output_info *info);
  61. EXPORT void video_output_close(video_t video);
  62. EXPORT void video_output_connect(video_t video,
  63. struct video_convert_info *conversion,
  64. void (*callback)(void *param, const struct video_frame *frame),
  65. void *param);
  66. EXPORT void video_output_disconnect(video_t video,
  67. void (*callback)(void *param, const struct video_frame *frame),
  68. void *param);
  69. EXPORT const struct video_output_info *video_output_getinfo(video_t video);
  70. EXPORT void video_output_frame(video_t video, struct video_frame *frame);
  71. EXPORT bool video_output_wait(video_t video);
  72. EXPORT uint64_t video_getframetime(video_t video);
  73. EXPORT uint64_t video_gettime(video_t video);
  74. EXPORT void video_output_stop(video_t video);
  75. #ifdef __cplusplus
  76. }
  77. #endif