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 #define OBS_ENCODER_CAP_INTERNAL (1 << 3)
36 
41 };
42 
45  uint8_t *data;
46  size_t size;
48  int64_t pts;
49  int64_t dts;
51  int32_t timebase_num;
52  int32_t timebase_den;
56  bool keyframe;
58  /* ---------------------------------------------------------------- */
59  /* Internal video variables (will be parsed automatically) */
60 
61  /* DTS in microseconds */
62  int64_t dts_usec;
63 
64  /* System DTS in microseconds */
65  int64_t sys_dts_usec;
66 
73  int priority;
74 
82 
84  size_t track_idx;
85 
88 };
89 
91 struct encoder_frame {
93  uint8_t *data[MAX_AV_PLANES];
94 
97 
99  uint32_t frames;
100 
102  int64_t pts;
103 };
104 
116  /* ----------------------------------------------------------------- */
117  /* Required implementation*/
118 
120  const char *id;
121 
124 
126  const char *codec;
127 
134  const char *(*get_name)(void *type_data);
135 
144  void *(*create)(obs_data_t *settings, obs_encoder_t *encoder);
145 
151  void (*destroy)(void *data);
152 
165  bool (*encode)(void *data, struct encoder_frame *frame,
166  struct encoder_packet *packet, bool *received_packet);
167 
169  size_t (*get_frame_size)(void *data);
170 
171  /* ----------------------------------------------------------------- */
172  /* Optional implementation */
173 
179  void (*get_defaults)(obs_data_t *settings);
180 
186  obs_properties_t *(*get_properties)(void *data);
187 
196  bool (*update)(void *data, obs_data_t *settings);
197 
208  bool (*get_extra_data)(void *data, uint8_t **extra_data, size_t *size);
209 
218  bool (*get_sei_data)(void *data, uint8_t **sei_data, size_t *size);
219 
226  void (*get_audio_info)(void *data, struct audio_convert_info *info);
227 
234  void (*get_video_info)(void *data, struct video_scale_info *info);
235 
236  void *type_data;
237  void (*free_type_data)(void *type_data);
238 
239  uint32_t caps;
240 
250  void (*get_defaults2)(obs_data_t *settings, void *type_data);
251 
259  obs_properties_t *(*get_properties2)(void *data, void *type_data);
260 
261  bool (*encode_texture)(void *data, uint32_t handle, int64_t pts,
262  uint64_t lock_key, uint64_t *next_key,
263  struct encoder_packet *packet,
264  bool *received_packet);
265 };
266 
267 EXPORT void obs_register_encoder_s(const struct obs_encoder_info *info,
268  size_t size);
269 
276 #define obs_register_encoder(info) \
277  obs_register_encoder_s(info, sizeof(struct obs_encoder_info))
278 
279 #ifdef __cplusplus
280 }
281 #endif
bool(* encode)(void *data, struct encoder_frame *frame, struct encoder_packet *packet, bool *received_packet)
Definition: obs-encoder.h:165
Definition: obs-encoder.h:40
uint32_t linesize[MAX_AV_PLANES]
Definition: obs-encoder.h:96
void(* get_defaults2)(obs_data_t *settings, void *type_data)
Definition: obs-encoder.h:250
uint8_t * data
Definition: obs-encoder.h:45
uint32_t frames
Definition: obs-encoder.h:99
Definition: video-io.h:213
size_t size
Definition: obs-encoder.h:46
size_t track_idx
Definition: obs-encoder.h:84
uint8_t * data[MAX_AV_PLANES]
Definition: obs-encoder.h:93
int64_t sys_dts_usec
Definition: obs-encoder.h:65
bool keyframe
Definition: obs-encoder.h:56
enum obs_encoder_type type
Definition: obs-encoder.h:123
uint32_t caps
Definition: obs-encoder.h:239
void(* get_video_info)(void *data, struct video_scale_info *info)
Definition: obs-encoder.h:234
void(* free_type_data)(void *type_data)
Definition: obs-encoder.h:237
int32_t timebase_den
Definition: obs-encoder.h:52
EXPORT void obs_register_encoder_s(const struct obs_encoder_info *info, size_t size)
enum obs_encoder_type type
Definition: obs-encoder.h:54
Definition: audio-io.h:104
Definition: obs-encoder.h:44
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:196
#define EXPORT
Definition: c99defs.h:37
void(* get_defaults)(obs_data_t *settings)
Definition: obs-encoder.h:179
size_t(* get_frame_size)(void *data)
Definition: obs-encoder.h:169
int32_t timebase_num
Definition: obs-encoder.h:51
Definition: obs-internal.h:1017
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:261
int64_t dts
Definition: obs-encoder.h:49
Definition: obs-encoder.h:115
void(* get_audio_info)(void *data, struct audio_convert_info *info)
Definition: obs-encoder.h:226
int64_t pts
Definition: obs-encoder.h:48
obs_encoder_t * encoder
Definition: obs-encoder.h:87
bool(* get_extra_data)(void *data, uint8_t **extra_data, size_t *size)
Definition: obs-encoder.h:208
int64_t pts
Definition: obs-encoder.h:102
const char * codec
Definition: obs-encoder.h:126
int priority
Definition: obs-encoder.h:73
int drop_priority
Definition: obs-encoder.h:81
#define MAX_AV_PLANES
Definition: media-io-defs.h:20
void(* destroy)(void *data)
Definition: obs-encoder.h:151
Definition: obs-encoder.h:91
obs_encoder_type
Definition: obs-encoder.h:38
int64_t dts_usec
Definition: obs-encoder.h:62
const char * id
Definition: obs-encoder.h:120
void * type_data
Definition: obs-encoder.h:236
Definition: obs-encoder.h:39
bool(* get_sei_data)(void *data, uint8_t **sei_data, size_t *size)
Definition: obs-encoder.h:218