video-io.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #include "media-io.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /*
  21. * Base video output component. Use this to create an video output track
  22. * for the media.
  23. */
  24. struct video_output;
  25. typedef struct video_output *video_t;
  26. enum video_format {
  27. VIDEO_FORMAT_UNKNOWN,
  28. /* planar 420 format */
  29. VIDEO_FORMAT_I420, /* three-plane */
  30. VIDEO_FORMAT_NV12, /* two-plane, lum and packed chroma */
  31. /* packed 422 formats */
  32. VIDEO_FORMAT_YVYU,
  33. VIDEO_FORMAT_YUY2, /* YUYV */
  34. VIDEO_FORMAT_UYVY,
  35. /* packed uncompressed formats */
  36. VIDEO_FORMAT_YUVX,
  37. VIDEO_FORMAT_UYVX,
  38. VIDEO_FORMAT_RGBA,
  39. VIDEO_FORMAT_BGRA,
  40. VIDEO_FORMAT_BGRX,
  41. };
  42. struct video_frame {
  43. const void *data;
  44. uint32_t row_size; /* for RGB/BGR formats and UYVX */
  45. uint64_t timestamp;
  46. };
  47. struct video_info {
  48. const char *name;
  49. enum video_format type;
  50. uint32_t fps_num; /* numerator */
  51. uint32_t fps_den; /* denominator */
  52. uint32_t width;
  53. uint32_t height;
  54. };
  55. #define VIDEO_OUTPUT_SUCCESS 0
  56. #define VIDEO_OUTPUT_INVALIDPARAM -1
  57. #define VIDEO_OUTPUT_FAIL -2
  58. EXPORT int video_output_open(video_t *video, media_t media,
  59. struct video_info *info);
  60. EXPORT const struct video_info *video_output_getinfo(video_t video);
  61. EXPORT void video_output_frame(video_t video, struct video_frame *frame);
  62. EXPORT bool video_output_wait(video_t video);
  63. EXPORT uint64_t video_getframetime(video_t video);
  64. EXPORT uint64_t video_gettime(video_t video);
  65. EXPORT void video_output_stop(video_t video);
  66. EXPORT void video_output_close(video_t video);
  67. #ifdef __cplusplus
  68. }
  69. #endif