Open Broadcaster Software
Free, open source software for live streaming and recording
video-io.h
Go to the documentation of this file.
1 /******************************************************************************
2  Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ******************************************************************************/
17 
18 #pragma once
19 
20 #include "media-io-defs.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 struct video_frame;
27 
28 /* Base video output component. Use this to create a video output track. */
29 
30 struct video_output;
31 typedef struct video_output video_t;
32 
35 
36  /* planar 420 format */
37  VIDEO_FORMAT_I420, /* three-plane */
38  VIDEO_FORMAT_NV12, /* two-plane, luma and packed chroma */
39 
40  /* packed 422 formats */
42  VIDEO_FORMAT_YUY2, /* YUYV */
44 
45  /* packed uncompressed formats */
49  VIDEO_FORMAT_Y800, /* grayscale */
50 
51  /* planar 4:4:4 */
53 };
54 
59 };
60 
65 };
66 
67 struct video_data {
71 };
72 
74  const char *name;
75 
81  size_t cache_size;
82 
85 };
86 
87 static inline bool format_is_yuv(enum video_format format)
88 {
89  switch (format) {
90  case VIDEO_FORMAT_I420:
91  case VIDEO_FORMAT_NV12:
92  case VIDEO_FORMAT_YVYU:
93  case VIDEO_FORMAT_YUY2:
94  case VIDEO_FORMAT_UYVY:
95  case VIDEO_FORMAT_I444:
96  return true;
97  case VIDEO_FORMAT_NONE:
98  case VIDEO_FORMAT_RGBA:
99  case VIDEO_FORMAT_BGRA:
100  case VIDEO_FORMAT_BGRX:
101  case VIDEO_FORMAT_Y800:
102  return false;
103  }
104 
105  return false;
106 }
107 
108 static inline const char *get_video_format_name(enum video_format format)
109 {
110  switch (format) {
111  case VIDEO_FORMAT_I420: return "I420";
112  case VIDEO_FORMAT_NV12: return "NV12";
113  case VIDEO_FORMAT_YVYU: return "YVYU";
114  case VIDEO_FORMAT_YUY2: return "YUY2";
115  case VIDEO_FORMAT_UYVY: return "UYVY";
116  case VIDEO_FORMAT_RGBA: return "RGBA";
117  case VIDEO_FORMAT_BGRA: return "BGRA";
118  case VIDEO_FORMAT_BGRX: return "BGRX";
119  case VIDEO_FORMAT_I444: return "I444";
120  case VIDEO_FORMAT_Y800: return "Y800";
121  case VIDEO_FORMAT_NONE:;
122  }
123 
124  return "None";
125 }
126 
127 static inline const char *get_video_colorspace_name(enum video_colorspace cs)
128 {
129  switch (cs) {
130  case VIDEO_CS_709: return "709";
131  case VIDEO_CS_601:
132  case VIDEO_CS_DEFAULT:;
133  }
134 
135  return "601";
136 }
137 
138 static inline const char *get_video_range_name(enum video_range_type range)
139 {
140  switch (range) {
141  case VIDEO_RANGE_FULL: return "Full";
142  case VIDEO_RANGE_PARTIAL:
143  case VIDEO_RANGE_DEFAULT:;
144  }
145 
146  return "Partial";
147 }
148 
155 };
156 
163 };
164 
166 
168  enum video_range_type range, float matrix[16],
169  float min_range[3], float max_range[3]);
170 
171 #define VIDEO_OUTPUT_SUCCESS 0
172 #define VIDEO_OUTPUT_INVALIDPARAM -1
173 #define VIDEO_OUTPUT_FAIL -2
174 
175 EXPORT int video_output_open(video_t **video, struct video_output_info *info);
176 EXPORT void video_output_close(video_t *video);
177 
179  const struct video_scale_info *conversion,
180  void (*callback)(void *param, struct video_data *frame),
181  void *param);
183  void (*callback)(void *param, struct video_data *frame),
184  void *param);
185 
186 EXPORT bool video_output_active(const video_t *video);
187 
189  const video_t *video);
190 EXPORT bool video_output_lock_frame(video_t *video, struct video_frame *frame,
191  int count, uint64_t timestamp);
194 EXPORT void video_output_stop(video_t *video);
195 EXPORT bool video_output_stopped(video_t *video);
196 
200 EXPORT double video_output_get_frame_rate(const video_t *video);
201 
204 
205 extern void video_output_inc_texture_encoders(video_t *video);
206 extern void video_output_dec_texture_encoders(video_t *video);
207 extern void video_output_inc_texture_frames(video_t *video);
209 
210 
211 #ifdef __cplusplus
212 }
213 #endif
Definition: video-io.h:57
uint32_t width
Definition: video-io.h:79
uint32_t height
Definition: video-io.h:160
Definition: video-io.h:56
Definition: video-io.h:153
EXPORT int video_output_open(video_t **video, struct video_output_info *info)
void video_output_inc_texture_encoders(video_t *video)
Definition: video-io.h:38
Definition: video-io.h:157
EXPORT void video_output_close(video_t *video)
void video_output_inc_texture_frames(video_t *video)
Definition: video-io.h:52
Definition: video-io.h:41
Definition: video-io.h:47
enum video_range_type range
Definition: video-io.h:84
Definition: video-io.h:34
unsigned uint32_t
Definition: vc_stdint.h:31
enum video_colorspace colorspace
Definition: video-io.h:83
video_format
Definition: video-io.h:33
uint32_t fps_den
Definition: video-io.h:78
Definition: video-io.h:63
uint32_t linesize[MAX_AV_PLANES]
Definition: video-io.h:69
const char * name
Definition: video-io.h:74
unsigned __int64 uint64_t
Definition: vc_stdint.h:33
EXPORT double video_output_get_frame_rate(const video_t *video)
Definition: video-io.h:58
unsigned char uint8_t
Definition: vc_stdint.h:27
uint64_t timestamp
Definition: video-io.h:70
EXPORT bool video_format_get_parameters(enum video_colorspace color_space, enum video_range_type range, float matrix[16], float min_range[3], float max_range[3])
video_scale_type
Definition: video-io.h:149
enum video_colorspace colorspace
Definition: video-io.h:162
EXPORT void video_output_disconnect(video_t *video, void(*callback)(void *param, struct video_data *frame), void *param)
EXPORT enum video_format video_output_get_format(const video_t *video)
EXPORT uint32_t video_output_get_width(const video_t *video)
enum video_format format
Definition: video-io.h:158
EXPORT const struct video_output_info * video_output_get_info(const video_t *video)
#define EXPORT
Definition: c99defs.h:49
EXPORT bool video_output_active(const video_t *video)
Definition: video-io.h:64
EXPORT uint64_t video_output_get_frame_time(const video_t *video)
Definition: video-io.h:48
Definition: video-io.h:154
EXPORT uint32_t video_output_get_skipped_frames(const video_t *video)
video_colorspace
Definition: video-io.h:55
Definition: video-io.h:67
Definition: video-frame.h:23
Definition: video-io.h:43
EXPORT bool video_output_stopped(video_t *video)
Definition: video-io.h:73
EXPORT enum video_format video_format_from_fourcc(uint32_t fourcc)
void video_output_dec_texture_encoders(video_t *video)
uint32_t fps_num
Definition: video-io.h:77
struct video_output video_t
Definition: video-io.h:31
EXPORT void video_output_stop(video_t *video)
enum video_format format
Definition: video-io.h:76
Definition: video-io.h:62
EXPORT bool video_output_lock_frame(video_t *video, struct video_frame *frame, int count, uint64_t timestamp)
uint8_t * data[MAX_AV_PLANES]
Definition: video-io.h:68
#define MAX_AV_PLANES
Definition: media-io-defs.h:20
void video_output_inc_texture_skipped_frames(video_t *video)
EXPORT uint32_t video_output_get_height(const video_t *video)
size_t cache_size
Definition: video-io.h:81
Definition: video-io.h:152
Definition: video-io.h:151
EXPORT void video_output_unlock_frame(video_t *video)
EXPORT uint32_t video_output_get_total_frames(const video_t *video)
uint32_t height
Definition: video-io.h:80
Definition: video-io.h:150
Definition: video-io.h:49
Definition: video-io.h:37
video_range_type
Definition: video-io.h:61
Definition: video-io.h:42
enum video_range_type range
Definition: video-io.h:161
uint32_t width
Definition: video-io.h:159
EXPORT bool video_output_connect(video_t *video, const struct video_scale_info *conversion, void(*callback)(void *param, struct video_data *frame), void *param)
Definition: video-io.h:46