Open Broadcaster Software
Free, open source software for live streaming and recording
obs-encoder.h
Go to the documentation of this file.
1 /******************************************************************************
2  Copyright (C) 2013-2014 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 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #define OBS_ENCODER_CAP_DEPRECATED (1<<0)
33 #define OBS_ENCODER_CAP_PASS_TEXTURE (1<<1)
34 
39 };
40 
44  size_t size;
54  bool keyframe;
56  /* ---------------------------------------------------------------- */
57  /* Internal video variables (will be parsed automatically) */
58 
59  /* DTS in microseconds */
61 
62  /* System DTS in microseconds */
64 
71  int priority;
72 
80 
82  size_t track_idx;
83 
86 };
87 
89 struct encoder_frame {
92 
95 
98 
101 };
102 
114  /* ----------------------------------------------------------------- */
115  /* Required implementation*/
116 
118  const char *id;
119 
122 
124  const char *codec;
125 
132  const char *(*get_name)(void *type_data);
133 
142  void *(*create)(obs_data_t *settings, obs_encoder_t *encoder);
143 
149  void (*destroy)(void *data);
150 
163  bool (*encode)(void *data, struct encoder_frame *frame,
164  struct encoder_packet *packet, bool *received_packet);
165 
167  size_t (*get_frame_size)(void *data);
168 
169  /* ----------------------------------------------------------------- */
170  /* Optional implementation */
171 
177  void (*get_defaults)(obs_data_t *settings);
178 
184  obs_properties_t *(*get_properties)(void *data);
185 
194  bool (*update)(void *data, obs_data_t *settings);
195 
206  bool (*get_extra_data)(void *data, uint8_t **extra_data, size_t *size);
207 
216  bool (*get_sei_data)(void *data, uint8_t **sei_data, size_t *size);
217 
224  void (*get_audio_info)(void *data, struct audio_convert_info *info);
225 
232  void (*get_video_info)(void *data, struct video_scale_info *info);
233 
234  void *type_data;
235  void (*free_type_data)(void *type_data);
236 
238 
245  void (*get_defaults2)(obs_data_t *settings, void *type_data);
246 
254  obs_properties_t *(*get_properties2)(void *data, void *type_data);
255 
256  bool (*encode_texture)(void *data, uint32_t handle, int64_t pts,
257  uint64_t lock_key, uint64_t *next_key,
258  struct encoder_packet *packet, bool *received_packet);
259 };
260 
261 EXPORT void obs_register_encoder_s(const struct obs_encoder_info *info,
262  size_t size);
263 
270 #define obs_register_encoder(info) \
271  obs_register_encoder_s(info, sizeof(struct obs_encoder_info))
272 
273 #ifdef __cplusplus
274 }
275 #endif
bool(* encode)(void *data, struct encoder_frame *frame, struct encoder_packet *packet, bool *received_packet)
Definition: obs-encoder.h:163
Definition: obs-encoder.h:38
uint32_t linesize[MAX_AV_PLANES]
Definition: obs-encoder.h:94
void(* get_defaults2)(obs_data_t *settings, void *type_data)
Definition: obs-encoder.h:245
uint8_t * data
Definition: obs-encoder.h:43
uint32_t frames
Definition: obs-encoder.h:97
Definition: video-io.h:157
size_t size
Definition: obs-encoder.h:44
size_t track_idx
Definition: obs-encoder.h:82
uint8_t * data[MAX_AV_PLANES]
Definition: obs-encoder.h:91
int64_t sys_dts_usec
Definition: obs-encoder.h:63
unsigned uint32_t
Definition: vc_stdint.h:31
bool keyframe
Definition: obs-encoder.h:54
enum obs_encoder_type type
Definition: obs-encoder.h:121
uint32_t caps
Definition: obs-encoder.h:237
int int32_t
Definition: vc_stdint.h:30
void(* get_video_info)(void *data, struct video_scale_info *info)
Definition: obs-encoder.h:232
void(* free_type_data)(void *type_data)
Definition: obs-encoder.h:235
int32_t timebase_den
Definition: obs-encoder.h:50
EXPORT void obs_register_encoder_s(const struct obs_encoder_info *info, size_t size)
enum obs_encoder_type type
Definition: obs-encoder.h:52
unsigned __int64 uint64_t
Definition: vc_stdint.h:33
Definition: audio-io.h:103
Definition: obs-encoder.h:42
unsigned char uint8_t
Definition: vc_stdint.h:27
struct obs_data obs_data_t
Definition: obs-data.h:42
struct obs_properties obs_properties_t
Definition: obs-properties.h:103
bool(* update)(void *data, obs_data_t *settings)
Definition: obs-encoder.h:194
#define EXPORT
Definition: c99defs.h:49
void(* get_defaults)(obs_data_t *settings)
Definition: obs-encoder.h:177
size_t(* get_frame_size)(void *data)
Definition: obs-encoder.h:167
int32_t timebase_num
Definition: obs-encoder.h:49
Definition: obs-internal.h:965
bool(* encode_texture)(void *data, uint32_t handle, int64_t pts, uint64_t lock_key, uint64_t *next_key, struct encoder_packet *packet, bool *received_packet)
Definition: obs-encoder.h:256
int64_t dts
Definition: obs-encoder.h:47
Definition: obs-encoder.h:113
void(* get_audio_info)(void *data, struct audio_convert_info *info)
Definition: obs-encoder.h:224
int64_t pts
Definition: obs-encoder.h:46
obs_encoder_t * encoder
Definition: obs-encoder.h:85
bool(* get_extra_data)(void *data, uint8_t **extra_data, size_t *size)
Definition: obs-encoder.h:206
int64_t pts
Definition: obs-encoder.h:100
const char * codec
Definition: obs-encoder.h:124
int priority
Definition: obs-encoder.h:71
int drop_priority
Definition: obs-encoder.h:79
#define MAX_AV_PLANES
Definition: media-io-defs.h:20
void(* destroy)(void *data)
Definition: obs-encoder.h:149
Definition: obs-encoder.h:89
obs_encoder_type
Definition: obs-encoder.h:36
int64_t dts_usec
Definition: obs-encoder.h:60
const char * id
Definition: obs-encoder.h:118
void * type_data
Definition: obs-encoder.h:234
__int64 int64_t
Definition: vc_stdint.h:32
#define bool
Definition: vc_stdbool.h:5
Definition: obs-encoder.h:37
bool(* get_sei_data)(void *data, uint8_t **sei_data, size_t *size)
Definition: obs-encoder.h:216