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 #define OBS_ENCODER_CAP_DYN_BITRATE (1 << 2)
35 
40 };
41 
45  size_t size;
55  bool keyframe;
57  /* ---------------------------------------------------------------- */
58  /* Internal video variables (will be parsed automatically) */
59 
60  /* DTS in microseconds */
62 
63  /* System DTS in microseconds */
65 
72  int priority;
73 
81 
83  size_t track_idx;
84 
87 };
88 
90 struct encoder_frame {
93 
96 
99 
102 };
103 
115  /* ----------------------------------------------------------------- */
116  /* Required implementation*/
117 
119  const char *id;
120 
123 
125  const char *codec;
126 
133  const char *(*get_name)(void *type_data);
134 
143  void *(*create)(obs_data_t *settings, obs_encoder_t *encoder);
144 
150  void (*destroy)(void *data);
151 
164  bool (*encode)(void *data, struct encoder_frame *frame,
165  struct encoder_packet *packet, bool *received_packet);
166 
168  size_t (*get_frame_size)(void *data);
169 
170  /* ----------------------------------------------------------------- */
171  /* Optional implementation */
172 
178  void (*get_defaults)(obs_data_t *settings);
179 
185  obs_properties_t *(*get_properties)(void *data);
186 
195  bool (*update)(void *data, obs_data_t *settings);
196 
207  bool (*get_extra_data)(void *data, uint8_t **extra_data, size_t *size);
208 
217  bool (*get_sei_data)(void *data, uint8_t **sei_data, size_t *size);
218 
225  void (*get_audio_info)(void *data, struct audio_convert_info *info);
226 
233  void (*get_video_info)(void *data, struct video_scale_info *info);
234 
235  void *type_data;
236  void (*free_type_data)(void *type_data);
237 
239 
249  void (*get_defaults2)(obs_data_t *settings, void *type_data);
250 
258  obs_properties_t *(*get_properties2)(void *data, void *type_data);
259 
260  bool (*encode_texture)(void *data, uint32_t handle, int64_t pts,
261  uint64_t lock_key, uint64_t *next_key,
262  struct encoder_packet *packet,
263  bool *received_packet);
264 };
265 
266 EXPORT void obs_register_encoder_s(const struct obs_encoder_info *info,
267  size_t size);
268 
275 #define obs_register_encoder(info) \
276  obs_register_encoder_s(info, sizeof(struct obs_encoder_info))
277 
278 #ifdef __cplusplus
279 }
280 #endif
bool(* encode)(void *data, struct encoder_frame *frame, struct encoder_packet *packet, bool *received_packet)
Definition: obs-encoder.h:164
Definition: obs-encoder.h:39
uint32_t linesize[MAX_AV_PLANES]
Definition: obs-encoder.h:95
void(* get_defaults2)(obs_data_t *settings, void *type_data)
Definition: obs-encoder.h:249
uint8_t * data
Definition: obs-encoder.h:44
uint32_t frames
Definition: obs-encoder.h:98
Definition: video-io.h:211
size_t size
Definition: obs-encoder.h:45
size_t track_idx
Definition: obs-encoder.h:83
uint8_t * data[MAX_AV_PLANES]
Definition: obs-encoder.h:92
int64_t sys_dts_usec
Definition: obs-encoder.h:64
unsigned uint32_t
Definition: vc_stdint.h:31
bool keyframe
Definition: obs-encoder.h:55
enum obs_encoder_type type
Definition: obs-encoder.h:122
uint32_t caps
Definition: obs-encoder.h:238
int int32_t
Definition: vc_stdint.h:30
void(* get_video_info)(void *data, struct video_scale_info *info)
Definition: obs-encoder.h:233
void(* free_type_data)(void *type_data)
Definition: obs-encoder.h:236
int32_t timebase_den
Definition: obs-encoder.h:51
EXPORT void obs_register_encoder_s(const struct obs_encoder_info *info, size_t size)
enum obs_encoder_type type
Definition: obs-encoder.h:53
unsigned __int64 uint64_t
Definition: vc_stdint.h:33
Definition: audio-io.h:104
Definition: obs-encoder.h:43
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:110
bool(* update)(void *data, obs_data_t *settings)
Definition: obs-encoder.h:195
#define EXPORT
Definition: c99defs.h:49
void(* get_defaults)(obs_data_t *settings)
Definition: obs-encoder.h:178
size_t(* get_frame_size)(void *data)
Definition: obs-encoder.h:168
int32_t timebase_num
Definition: obs-encoder.h:50
Definition: obs-internal.h:1000
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:260
int64_t dts
Definition: obs-encoder.h:48
Definition: obs-encoder.h:114
void(* get_audio_info)(void *data, struct audio_convert_info *info)
Definition: obs-encoder.h:225
int64_t pts
Definition: obs-encoder.h:47
obs_encoder_t * encoder
Definition: obs-encoder.h:86
bool(* get_extra_data)(void *data, uint8_t **extra_data, size_t *size)
Definition: obs-encoder.h:207
int64_t pts
Definition: obs-encoder.h:101
const char * codec
Definition: obs-encoder.h:125
int priority
Definition: obs-encoder.h:72
int drop_priority
Definition: obs-encoder.h:80
#define MAX_AV_PLANES
Definition: media-io-defs.h:20
void(* destroy)(void *data)
Definition: obs-encoder.h:150
Definition: obs-encoder.h:90
obs_encoder_type
Definition: obs-encoder.h:37
int64_t dts_usec
Definition: obs-encoder.h:61
const char * id
Definition: obs-encoder.h:119
void * type_data
Definition: obs-encoder.h:235
__int64 int64_t
Definition: vc_stdint.h:32
#define bool
Definition: vc_stdbool.h:5
Definition: obs-encoder.h:38
bool(* get_sei_data)(void *data, uint8_t **sei_data, size_t *size)
Definition: obs-encoder.h:217