obs.h 44.4 KB
Newer Older
J
jp9000 已提交
1
/******************************************************************************
2
    Copyright (C) 2013-2014 by Hugh Bailey <obs.jim@gmail.com>
J
jp9000 已提交
3 4 5

    This program is free software: you can redistribute it and/or modify
    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
J
jp9000 已提交
7 8 9 10 11 12 13 14 15 16 17
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

18
#pragma once
J
jp9000 已提交
19 20

#include "util/c99defs.h"
21
#include "util/bmem.h"
22
#include "util/text-lookup.h"
J
jp9000 已提交
23 24
#include "graphics/graphics.h"
#include "graphics/vec2.h"
25
#include "graphics/vec3.h"
J
jp9000 已提交
26 27
#include "media-io/audio-io.h"
#include "media-io/video-io.h"
28 29
#include "callback/signal.h"
#include "callback/proc.h"
J
jp9000 已提交
30

31
#include "obs-config.h"
32 33 34 35
#include "obs-defs.h"
#include "obs-data.h"
#include "obs-ui.h"
#include "obs-properties.h"
K
kc5nra 已提交
36
#include "obs-interaction.h"
37

38 39
struct matrix4;

J
jp9000 已提交
40 41
/* opaque types */
struct obs_display;
J
jp9000 已提交
42
struct obs_view;
J
jp9000 已提交
43 44 45 46 47 48
struct obs_source;
struct obs_scene;
struct obs_scene_item;
struct obs_output;
struct obs_encoder;
struct obs_service;
J
jp9000 已提交
49
struct obs_module;
J
jp9000 已提交
50

51 52 53 54 55 56 57 58 59
typedef struct obs_display    obs_display_t;
typedef struct obs_view       obs_view_t;
typedef struct obs_source     obs_source_t;
typedef struct obs_scene      obs_scene_t;
typedef struct obs_scene_item obs_sceneitem_t;
typedef struct obs_output     obs_output_t;
typedef struct obs_encoder    obs_encoder_t;
typedef struct obs_service    obs_service_t;
typedef struct obs_module     obs_module_t;
J
jp9000 已提交
60 61 62 63 64

#include "obs-source.h"
#include "obs-encoder.h"
#include "obs-output.h"
#include "obs-service.h"
J
jp9000 已提交
65

66
/**
J
jp9000 已提交
67
 * @file
68 69 70 71 72 73 74 75
 * @brief Main libobs header used by applications.
 *
 * @mainpage
 *
 * @section intro_sec Introduction
 *
 * This document describes the api for libobs to be used by applications as well
 * as @ref modules_page implementing some kind of functionality.
J
jp9000 已提交
76
 *
J
jp9000 已提交
77 78 79 80 81 82
 */

#ifdef __cplusplus
extern "C" {
#endif

J
jp9000 已提交
83
/** Used for changing the order of items (for example, filters in a source,
J
jp9000 已提交
84
 * or items in a scene) */
J
jp9000 已提交
85 86 87 88 89
enum obs_order_movement {
	OBS_ORDER_MOVE_UP,
	OBS_ORDER_MOVE_DOWN,
	OBS_ORDER_MOVE_TOP,
	OBS_ORDER_MOVE_BOTTOM
J
jp9000 已提交
90 91
};

J
jp9000 已提交
92 93 94 95 96
/**
 * Used with obs_source_process_filter to specify whether the filter should
 * render the source directly with the specified effect, or whether it should
 * render it to a texture
 */
97 98 99
enum obs_allow_direct_render {
	OBS_NO_DIRECT_RENDERING,
	OBS_ALLOW_DIRECT_RENDERING,
100 101
};

102 103 104 105 106 107 108
/**
 * Used with scene items to indicate the type of bounds to use for scene items.
 * Mostly determines how the image will be scaled within those bounds, or
 * whether to use bounds at all.
 */
enum obs_bounds_type {
	OBS_BOUNDS_NONE,            /**< no bounds */
J
jp9000 已提交
109
	OBS_BOUNDS_STRETCH,         /**< stretch (ignores base scale) */
110 111 112 113
	OBS_BOUNDS_SCALE_INNER,     /**< scales to inner rectangle */
	OBS_BOUNDS_SCALE_OUTER,     /**< scales to outer rectangle */
	OBS_BOUNDS_SCALE_TO_WIDTH,  /**< scales to the width  */
	OBS_BOUNDS_SCALE_TO_HEIGHT, /**< scales to the height */
J
jp9000 已提交
114
	OBS_BOUNDS_MAX_ONLY,        /**< no scaling, maximum size only */
115 116
};

117
struct obs_transform_info {
118 119 120 121 122 123 124 125 126 127
	struct vec2          pos;
	float                rot;
	struct vec2          scale;
	uint32_t             alignment;

	enum obs_bounds_type bounds_type;
	uint32_t             bounds_alignment;
	struct vec2          bounds;
};

J
jp9000 已提交
128 129 130
/**
 * Video initialization structure
 */
131
struct obs_video_info {
J
jp9000 已提交
132
	/**
133
	 * Graphics module to use (usually "libobs-opengl" or "libobs-d3d11")
J
jp9000 已提交
134
	 */
135
	const char          *graphics_module;
136

J
jp9000 已提交
137 138
	uint32_t            fps_num;       /**< Output FPS numerator */
	uint32_t            fps_den;       /**< Output FPS denominator */
139

J
jp9000 已提交
140 141
	uint32_t            window_width;  /**< Window width */
	uint32_t            window_height; /**< Window height */
142

J
jp9000 已提交
143 144
	uint32_t            base_width;    /**< Base compositing width */
	uint32_t            base_height;   /**< Base compositing height */
145

J
jp9000 已提交
146 147 148
	uint32_t            output_width;  /**< Output width */
	uint32_t            output_height; /**< Output height */
	enum video_format   output_format; /**< Output format */
149

J
jp9000 已提交
150
	/** Video adapter index to use (NOTE: avoid for optimus laptops) */
151
	uint32_t            adapter;
152

J
jp9000 已提交
153
	struct gs_window    window;        /**< Window to render to */
J
jp9000 已提交
154 155 156

	/** Use shaders to convert to different color formats */
	bool                gpu_conversion;
157 158
};

J
jp9000 已提交
159 160 161 162
/**
 * Sent to source filters via the filter_audio callback to allow filtering of
 * audio data
 */
163
struct obs_audio_data {
J
jp9000 已提交
164
	uint8_t             *data[MAX_AV_PLANES];
165 166 167 168
	uint32_t            frames;
	uint64_t            timestamp;
};

J
jp9000 已提交
169 170 171 172
/**
 * Source audio output structure.  Used with obs_source_output_audio to output
 * source audio.  Audio is automatically resampled and remixed as necessary.
 */
173
struct obs_source_audio {
J
jp9000 已提交
174
	const uint8_t       *data[MAX_AV_PLANES];
J
jp9000 已提交
175
	uint32_t            frames;
176

J
jp9000 已提交
177
	enum speaker_layout speakers;
178
	enum audio_format   format;
J
jp9000 已提交
179
	uint32_t            samples_per_sec;
180

J
jp9000 已提交
181
	uint64_t            timestamp;
182 183
};

J
jp9000 已提交
184 185 186 187 188 189 190 191 192
/**
 * Source asynchronous video output structure.  Used with
 * obs_source_output_video to output asynchronous video.  Video is buffered as
 * necessary to play according to timestamps.  When used with audio output,
 * audio is synced to video as it is played.
 *
 * If a YUV format is specified, it will be automatically upsampled and
 * converted to RGB via shader on the graphics processor.
 */
193
struct obs_source_frame {
J
jp9000 已提交
194 195
	uint8_t             *data[MAX_AV_PLANES];
	uint32_t            linesize[MAX_AV_PLANES];
J
jp9000 已提交
196 197 198 199
	uint32_t            width;
	uint32_t            height;
	uint64_t            timestamp;

200
	enum video_format   format;
201
	float               color_matrix[16];
202 203 204
	bool                full_range;
	float               color_range_min[3];
	float               color_range_max[3];
J
jp9000 已提交
205
	bool                flip;
206 207
};

J
jp9000 已提交
208 209 210
/* ------------------------------------------------------------------------- */
/* OBS context */

211 212 213 214 215 216
/**
 * Initializes OBS
 *
 * @param  locale  The locale to use for modules
 */
EXPORT bool obs_startup(const char *locale);
J
jp9000 已提交
217 218

/** Releases all data associated with OBS and terminates the OBS context */
219
EXPORT void obs_shutdown(void);
J
jp9000 已提交
220

221 222 223
/** @return true if the main OBS context has been initialized */
EXPORT bool obs_initialized(void);

224 225 226
/** @return The current core version */
EXPORT uint32_t obs_get_version(void);

227 228 229 230 231 232 233 234 235 236 237
/**
 * Sets a new locale to use for modules.  This will call obs_module_set_locale
 * for each module with the new locale.
 *
 * @param  locale  The locale to use for modules
 */
EXPORT void obs_set_locale(const char *locale);

/** @return the current locale */
EXPORT const char *obs_get_locale(void);

J
jp9000 已提交
238
/**
239
 * Sets base video ouput base resolution/fps/format.
J
jp9000 已提交
240
 *
241 242 243 244 245 246 247 248 249 250 251 252
 * @note This data cannot be changed if an output is corrently active.
 * @note The graphics module cannot be changed without fully destroying the
 *       OBS context.
 *
 * @param   ovi  Pointer to an obs_video_info structure containing the
 *               specification of the graphics subsystem,
 * @return       OBS_VIDEO_SUCCESS if sucessful
 *               OBS_VIDEO_NOT_SUPPORTED if the adapter lacks capabilities
 *               OBS_VIDEO_INVALID_PARAM if a parameter is invalid
 *               OBS_VIDEO_CURRENTLY_ACTIVE if video is currently active
 *               OBS_VIDEO_MODULE_NOT_FOUND if the graphics module is not found
 *               OBS_VIDEO_FAIL for generic failure
J
jp9000 已提交
253
 */
254
EXPORT int obs_reset_video(struct obs_video_info *ovi);
255

J
jp9000 已提交
256 257 258
/**
 * Sets base audio output format/channels/samples/etc
 *
J
jp9000 已提交
259
 * @note Cannot reset base audio if an output is currently active.
J
jp9000 已提交
260
 */
J
jp9000 已提交
261
EXPORT bool obs_reset_audio(struct audio_output_info *ai);
J
jp9000 已提交
262

J
jp9000 已提交
263
/** Gets the current video settings, returns false if no video */
264 265
EXPORT bool obs_get_video_info(struct obs_video_info *ovi);

J
jp9000 已提交
266
/** Gets the current audio settings, returns false if no audio */
J
jp9000 已提交
267
EXPORT bool obs_get_audio_info(struct audio_output_info *ai);
268

J
jp9000 已提交
269
/**
J
jp9000 已提交
270
 * Opens a plugin module directly from a specific path.
J
jp9000 已提交
271
 *
J
jp9000 已提交
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
 * If the module already exists then the function will return successful, and
 * the module parameter will be given the pointer to the existing module.
 *
 * This does not initialize the module, it only loads the module image.  To
 * initialize the module, call obs_init_module.
 *
 * @param  module     The pointer to the created module.
 * @param  path       Specifies the path to the module library file.  If the
 *                    extension is not specified, it will use the extension
 *                    appropriate to the operating system.
 * @param  data_path  Specifies the path to the directory where the module's
 *                    data files are stored.
 * @returns           MODULE_SUCCESS if successful
 *                    MODULE_ERROR if a generic error occurred
 *                    MODULE_FILE_NOT_FOUND if the module was not found
 *                    MODULE_MISSING_EXPORTS if required exports are missing
 *                    MODULE_INCOMPATIBLE_VER if incompatible version
J
jp9000 已提交
289
 */
290
EXPORT int obs_open_module(obs_module_t **module, const char *path,
J
jp9000 已提交
291 292 293 294 295 296 297
		const char *data_path);

/**
 * Initializes the module, which calls its obs_module_load export.  If the
 * module is alrady loaded, then this function does nothing and returns
 * successful.
 */
298
EXPORT bool obs_init_module(obs_module_t *module);
J
jp9000 已提交
299

300
/** Returns the module file name */
301
EXPORT const char *obs_get_module_file_name(obs_module_t *module);
302 303

/** Returns the module full name */
304
EXPORT const char *obs_get_module_name(obs_module_t *module);
305 306

/** Returns the module author(s) */
307
EXPORT const char *obs_get_module_author(obs_module_t *module);
308 309

/** Returns the module description */
310
EXPORT const char *obs_get_module_description(obs_module_t *module);
311

312
/** Returns the module binary path */
313
EXPORT const char *obs_get_module_binary_path(obs_module_t *module);
314 315

/** Returns the module data path */
316
EXPORT const char *obs_get_module_data_path(obs_module_t *module);
317

J
jp9000 已提交
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
/**
 * Adds a module search path to be used with obs_find_modules.  If the search
 * path strings contain %module%, that text will be replaced with the module
 * name when used.
 *
 * @param  bin   Specifies the module's binary directory search path.
 * @param  data  Specifies the module's data directory search path.
 */
EXPORT void obs_add_module_path(const char *bin, const char *data);

/** Automatically loads all modules from module paths (convenience function) */
EXPORT void obs_load_all_modules(void);

struct obs_module_info {
	const char *bin_path;
	const char *data_path;
};

typedef void (*obs_find_module_callback_t)(void *param,
		const struct obs_module_info *info);

/** Finds all modules within the search paths added by obs_add_module_path. */
EXPORT void obs_find_modules(obs_find_module_callback_t callback, void *param);

342
typedef void (*obs_enum_module_callback_t)(void *param, obs_module_t *module);
J
jp9000 已提交
343 344 345

/** Enumerates all loaded modules */
EXPORT void obs_enum_modules(obs_enum_module_callback_t callback, void *param);
J
jp9000 已提交
346

347
/** Helper function for using default module locale */
348
EXPORT lookup_t *obs_module_load_locale(obs_module_t *module,
349 350
		const char *default_locale, const char *locale);

J
jp9000 已提交
351 352 353 354 355 356 357 358 359 360 361
/**
 * Returns the location of a plugin module data file.
 *
 * @note   Modules should use obs_module_file function defined in obs-module.h
 *         as a more elegant means of getting their files without having to
 *         specify the module parameter.
 *
 * @param  module  The module associated with the file to locate
 * @param  file    The file to locate
 * @return         Path string, or NULL if not found.  Use bfree to free string.
 */
362
EXPORT char *obs_find_module_file(obs_module_t *module, const char *file);
J
jp9000 已提交
363

J
jp9000 已提交
364
/**
365
 * Enumerates all available inputs source types.
J
jp9000 已提交
366 367 368 369
 *
 *   Inputs are general source inputs (such as capture sources, device sources,
 * etc).
 */
370
EXPORT bool obs_enum_input_types(size_t idx, const char **id);
371

J
jp9000 已提交
372
/**
373
 * Enumerates all available filter source types.
J
jp9000 已提交
374 375 376 377
 *
 *   Filters are sources that are used to modify the video/audio output of
 * other sources.
 */
378
EXPORT bool obs_enum_filter_types(size_t idx, const char **id);
379

J
jp9000 已提交
380
/**
381
 * Enumerates all available transition source types.
J
jp9000 已提交
382 383 384 385
 *
 *   Transitions are sources used to transition between two or more other
 * sources.
 */
386
EXPORT bool obs_enum_transition_types(size_t idx, const char **id);
387

388
/** Enumerates all available output types. */
389
EXPORT bool obs_enum_output_types(size_t idx, const char **id);
J
jp9000 已提交
390

391 392 393 394 395 396
/** Enumerates all available encoder types. */
EXPORT bool obs_enum_encoder_types(size_t idx, const char **id);

/** Enumerates all available service types. */
EXPORT bool obs_enum_service_types(size_t idx, const char **id);

J
jp9000 已提交
397 398 399 400 401
/** Helper function for entering the OBS graphics context */
EXPORT void obs_enter_graphics(void);

/** Helper function for leaving the OBS graphics context */
EXPORT void obs_leave_graphics(void);
402

403
/** Gets the main audio output handler for this OBS context */
404
EXPORT audio_t *obs_get_audio(void);
405 406

/** Gets the main video output handler for this OBS context */
407
EXPORT video_t *obs_get_video(void);
J
jp9000 已提交
408 409

/**
410 411
 * Adds a source to the user source list and increments the reference counter
 * for that source.
J
jp9000 已提交
412
 *
413 414 415
 *   The user source list is the list of sources that are accessible by a user.
 * Typically when a transition is active, it is not meant to be accessible by
 * users, so there's no reason for a user to see such a source.
J
jp9000 已提交
416
 */
417
EXPORT bool obs_add_source(obs_source_t *source);
418

419
/** Sets the primary output source for a channel. */
420
EXPORT void obs_set_output_source(uint32_t channel, obs_source_t *source);
421 422 423 424 425

/**
 * Gets the primary output source for a channel and increments the reference
 * counter for that source.  Use obs_source_release to release.
 */
426
EXPORT obs_source_t *obs_get_output_source(uint32_t channel);
J
jp9000 已提交
427

428 429 430 431 432 433
/**
 * Enumerates user sources
 *
 *   Callback function returns true to continue enumeration, or false to end
 * enumeration.
 */
434
EXPORT void obs_enum_sources(bool (*enum_proc)(void*, obs_source_t*),
435 436 437
		void *param);

/** Enumerates outputs */
438
EXPORT void obs_enum_outputs(bool (*enum_proc)(void*, obs_output_t*),
439 440 441
		void *param);

/** Enumerates encoders */
442
EXPORT void obs_enum_encoders(bool (*enum_proc)(void*, obs_encoder_t*),
443 444
		void *param);

445
/** Enumerates encoders */
446
EXPORT void obs_enum_services(bool (*enum_proc)(void*, obs_service_t*),
447 448
		void *param);

449 450 451 452 453 454
/**
 * Gets a source by its name.
 *
 *   Increments the source reference counter, use obs_source_release to
 * release it when complete.
 */
455
EXPORT obs_source_t *obs_get_source_by_name(const char *name);
456

457
/** Gets an output by its name. */
458
EXPORT obs_output_t *obs_get_output_by_name(const char *name);
459 460

/** Gets an encoder by its name. */
461
EXPORT obs_encoder_t *obs_get_encoder_by_name(const char *name);
462 463

/** Gets an service by its name. */
464
EXPORT obs_service_t *obs_get_service_by_name(const char *name);
465

466
/** Returns the default effect for generic RGB/YUV drawing */
467
EXPORT gs_effect_t *obs_get_default_effect(void);
468

P
Palana 已提交
469 470 471
/** Returns the default effect for generic RGB/YUV drawing using texture_rect */
EXPORT gs_effect_t *obs_get_default_rect_effect(void);

472
/** Returns the solid effect for drawing solid colors */
473
EXPORT gs_effect_t *obs_get_solid_effect(void);
474

475
/** Returns the primary obs signal handler */
476
EXPORT signal_handler_t *obs_get_signal_handler(void);
477 478

/** Returns the primary obs procedure handler */
479
EXPORT proc_handler_t *obs_get_proc_handler(void);
480

481 482 483 484 485 486 487 488 489 490
/** Adds a draw callback to the main render context */
EXPORT void obs_add_draw_callback(
		void (*draw)(void *param, uint32_t cx, uint32_t cy),
		void *param);

/** Removes a draw callback to the main render context */
EXPORT void obs_remove_draw_callback(
		void (*draw)(void *param, uint32_t cx, uint32_t cy),
		void *param);

J
jp9000 已提交
491
/** Changes the size of the main view */
492 493
EXPORT void obs_resize(uint32_t cx, uint32_t cy);

J
jp9000 已提交
494 495
/** Renders the main view */
EXPORT void obs_render_main_view(void);
496

J
jp9000 已提交
497 498 499 500 501 502 503 504 505 506 507
/** Sets the master user volume */
EXPORT void obs_set_master_volume(float volume);

/** Sets the master presentation volume */
EXPORT void obs_set_present_volume(float volume);

/** Gets the master user volume */
EXPORT float obs_get_master_volume(void);

/** Gets the master presentation volume */
EXPORT float obs_get_present_volume(void);
508 509

/** Saves a source to settings data */
510
EXPORT obs_data_t *obs_save_source(obs_source_t *source);
511 512

/** Loads a source from settings data */
513
EXPORT obs_source_t *obs_load_source(obs_data_t *data);
J
jp9000 已提交
514

515
/** Loads sources from a data array */
516
EXPORT void obs_load_sources(obs_data_array_t *array);
517 518

/** Saves sources to a data array */
519
EXPORT obs_data_array_t *obs_save_sources(void);
520

521 522

/* ------------------------------------------------------------------------- */
J
jp9000 已提交
523
/* View context */
524 525

/**
J
jp9000 已提交
526
 * Creates a view context.
527
 *
J
jp9000 已提交
528
 *   A view can be used for things like separate previews, or drawing
529 530
 * sources separately.
 */
531
EXPORT obs_view_t *obs_view_create(void);
532

J
jp9000 已提交
533
/** Destroys this view context */
534
EXPORT void obs_view_destroy(obs_view_t *view);
535

J
jp9000 已提交
536
/** Sets the source to be used for this view context. */
537 538
EXPORT void obs_view_set_source(obs_view_t *view, uint32_t channel,
		obs_source_t *source);
539

J
jp9000 已提交
540
/** Gets the source currently in use for this view context */
541
EXPORT obs_source_t *obs_view_get_source(obs_view_t *view,
542 543
		uint32_t channel);

J
jp9000 已提交
544
/** Renders the sources of this view context */
545
EXPORT void obs_view_render(obs_view_t *view);
546

J
jp9000 已提交
547 548 549 550 551

/* ------------------------------------------------------------------------- */
/* Display context */

/**
552 553
 * Adds a new window display linked to the main render pipeline.  This creates
 * a new swap chain which updates every frame.
J
jp9000 已提交
554
 *
555 556
 * @param  graphics_data  The swap chain initialization data.
 * @return                The new display context, or NULL if failed.
J
jp9000 已提交
557
 */
558 559
EXPORT obs_display_t *obs_display_create(
		const struct gs_init_data *graphics_data);
560 561

/** Destroys a display context */
562
EXPORT void obs_display_destroy(obs_display_t *display);
563

564
/** Changes the size of this display */
565 566
EXPORT void obs_display_resize(obs_display_t *display, uint32_t cx,
		uint32_t cy);
567 568 569 570 571 572 573 574 575

/**
 * Adds a draw callback for this display context
 *
 * @param  display  The display context.
 * @param  draw     The draw callback which is called each time a frame
 *                  updates.
 * @param  param    The user data to be associated with this draw callback.
 */
576
EXPORT void obs_display_add_draw_callback(obs_display_t *display,
577 578 579 580
		void (*draw)(void *param, uint32_t cx, uint32_t cy),
		void *param);

/** Removes a draw callback for this display context */
581
EXPORT void obs_display_remove_draw_callback(obs_display_t *display,
582 583
		void (*draw)(void *param, uint32_t cx, uint32_t cy),
		void *param);
J
jp9000 已提交
584 585 586 587 588


/* ------------------------------------------------------------------------- */
/* Sources */

J
jp9000 已提交
589
/** Returns the translated display name of a source */
590
EXPORT const char *obs_source_get_display_name(enum obs_source_type type,
591
		const char *id);
592

J
jp9000 已提交
593 594 595 596
/**
 * Creates a source of the specified type with the specified settings.
 *
 *   The "source" context is used for anything related to presenting
597
 * or modifying video/audio.  Use obs_source_release to release it.
J
jp9000 已提交
598
 */
599 600
EXPORT obs_source_t *obs_source_create(enum obs_source_type type,
		const char *id, const char *name, obs_data_t *settings);
601 602 603 604 605

/**
 * Adds/releases a reference to a source.  When the last reference is
 * released, the source is destroyed.
 */
606 607
EXPORT void obs_source_addref(obs_source_t *source);
EXPORT void obs_source_release(obs_source_t *source);
608

P
Palana 已提交
609
/** Notifies all references that the source should be released */
610
EXPORT void obs_source_remove(obs_source_t *source);
611 612

/** Returns true if the source should be released */
613
EXPORT bool obs_source_removed(const obs_source_t *source);
614

J
jp9000 已提交
615 616 617
/**
 * Retrieves flags that specify what type of data the source presents/modifies.
 */
618
EXPORT uint32_t obs_source_get_output_flags(const obs_source_t *source);
619

J
jp9000 已提交
620
/** Gets the default settings for a source type */
621
EXPORT obs_data_t *obs_get_source_defaults(enum obs_source_type type,
J
jp9000 已提交
622 623
		const char *id);

J
jp9000 已提交
624
/** Returns the property list, if any.  Free with obs_properties_destroy */
625
EXPORT obs_properties_t *obs_get_source_properties(enum obs_source_type type,
626
		const char *id);
J
jp9000 已提交
627

628 629 630 631
/**
 * Returns the properties list for a specific existing source.  Free with
 * obs_properties_destroy
 */
632
EXPORT obs_properties_t *obs_source_properties(const obs_source_t *source);
633

634
/** Updates settings for this source */
635
EXPORT void obs_source_update(obs_source_t *source, obs_data_t *settings);
636

J
jp9000 已提交
637
/** Renders a video source. */
638
EXPORT void obs_source_video_render(obs_source_t *source);
639

J
jp9000 已提交
640
/** Gets the width of a source (if it has video) */
641
EXPORT uint32_t obs_source_get_width(const obs_source_t *source);
642

J
jp9000 已提交
643
/** Gets the height of a source (if it has video) */
644
EXPORT uint32_t obs_source_get_height(const obs_source_t *source);
645

646
/** If the source is a filter, returns the parent source of the filter */
647
EXPORT obs_source_t *obs_filter_get_parent(const obs_source_t *filter);
648

J
jp9000 已提交
649
/** If the source is a filter, returns the target source of the filter */
650
EXPORT obs_source_t *obs_filter_get_target(const obs_source_t *filter);
651

J
jp9000 已提交
652
/** Adds a filter to the source (which is used whenever the source is used) */
653
EXPORT void obs_source_filter_add(obs_source_t *source, obs_source_t *filter);
654

J
jp9000 已提交
655
/** Removes a filter from the source */
656 657
EXPORT void obs_source_filter_remove(obs_source_t *source,
		obs_source_t *filter);
658

J
jp9000 已提交
659
/** Modifies the order of a specific filter */
660 661
EXPORT void obs_source_filter_set_order(obs_source_t *source,
		obs_source_t *filter, enum obs_order_movement movement);
J
jp9000 已提交
662 663

/** Gets the settings string for a source */
664
EXPORT obs_data_t *obs_source_get_settings(const obs_source_t *source);
665 666

/** Gets the name of a source */
667
EXPORT const char *obs_source_get_name(const obs_source_t *source);
668 669

/** Sets the name of a source */
670
EXPORT void obs_source_set_name(obs_source_t *source, const char *name);
671

J
jp9000 已提交
672
/** Gets the source type */
673
EXPORT enum obs_source_type obs_source_get_type(const obs_source_t *source);
J
jp9000 已提交
674 675

/** Gets the source identifier */
676
EXPORT const char *obs_source_get_id(const obs_source_t *source);
J
jp9000 已提交
677

678
/** Returns the signal handler for a source */
679 680
EXPORT signal_handler_t *obs_source_get_signal_handler(
		const obs_source_t *source);
681 682

/** Returns the procedure handler for a source */
683
EXPORT proc_handler_t *obs_source_get_proc_handler(const obs_source_t *source);
684

J
jp9000 已提交
685
/** Sets the user volume for a source that has audio output */
686
EXPORT void obs_source_set_volume(obs_source_t *source, float volume);
J
jp9000 已提交
687

J
jp9000 已提交
688
/** Sets the presentation volume for a source */
689
EXPORT void obs_source_set_present_volume(obs_source_t *source, float volume);
J
jp9000 已提交
690 691

/** Gets the user volume for a source that has audio output */
692
EXPORT float obs_source_get_volume(const obs_source_t *source);
J
jp9000 已提交
693

J
jp9000 已提交
694
/** Gets the presentation volume for a source */
695
EXPORT float obs_source_get_present_volume(const obs_source_t *source);
J
jp9000 已提交
696

J
jp9000 已提交
697
/** Sets the audio sync offset (in nanoseconds) for a source */
698
EXPORT void obs_source_set_sync_offset(obs_source_t *source, int64_t offset);
J
jp9000 已提交
699 700

/** Gets the audio sync offset (in nanoseconds) for a source */
701
EXPORT int64_t obs_source_get_sync_offset(const obs_source_t *source);
J
jp9000 已提交
702

703
/** Enumerates child sources used by this source */
704
EXPORT void obs_source_enum_sources(obs_source_t *source,
705 706 707 708
		obs_source_enum_proc_t enum_callback,
		void *param);

/** Enumerates the entire child source tree used by this source */
709
EXPORT void obs_source_enum_tree(obs_source_t *source,
710 711 712
		obs_source_enum_proc_t enum_callback,
		void *param);

713
/** Returns true if active, false if not */
714
EXPORT bool obs_source_active(const obs_source_t *source);
715

716 717 718 719 720 721
/**
 * Sometimes sources need to be told when to save their settings so they
 * don't have to constantly update and keep track of their settings.  This will
 * call the source's 'save' callback if any, which will save its current
 * data to its settings.
 */
722
EXPORT void obs_source_save(obs_source_t *source);
723 724 725 726 727 728 729

/**
 * Sometimes sources need to be told when they are loading their settings
 * from prior saved data.  This is different from a source 'update' in that
 * it's meant to be used after the source has been created and loaded from
 * somewhere (such as a saved file).
 */
730
EXPORT void obs_source_load(obs_source_t *source);
731

J
jp9000 已提交
732 733 734 735 736 737 738 739 740 741
/** Specifies that async video frames should be played as soon as possible */
#define OBS_SOURCE_UNBUFFERED (1<<0)

/** Sets source flags.  Note that these are different from the main output
 * flags. */
EXPORT void obs_source_set_flags(obs_source_t *source, uint32_t flags);

/** Gets source flags. */
EXPORT uint32_t obs_source_get_flags(const obs_source_t *source);

J
jp9000 已提交
742 743 744
/* ------------------------------------------------------------------------- */
/* Functions used by sources */

J
jp9000 已提交
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775
/**
 * Helper function to set the color matrix information when drawing the source.
 *
 * @param  color_matrix     The color matrix.  Assigns to the 'color_matrix'
 *                          effect variable.
 * @param  color_range_min  The minimum color range.  Assigns to the
 *                          'color_range_min' effect variable.  If NULL,
 *                          {0.0f, 0.0f, 0.0f} is used.
 * @param  color_range_max  The maximum color range.  Assigns to the
 *                          'color_range_max' effect variable.  If NULL,
 *                          {1.0f, 1.0f, 1.0f} is used.
 */
EXPORT void obs_source_draw_set_color_matrix(
		const struct matrix4 *color_matrix,
		const struct vec3 *color_range_min,
		const struct vec3 *color_range_max);

/**
 * Helper function to draw sprites for a source (synchronous video).
 *
 * @param  image   The sprite texture to draw.  Assigns to the 'image' variable
 *                 of the current effect.
 * @param  x       X position of the sprite.
 * @param  y       Y position of the sprite.
 * @param  cx      Width of the sprite.  If 0, uses the texture width.
 * @param  cy      Height of the sprite.  If 0, uses the texture height.
 * @param  flip    Specifies whether to flip the image vertically.
 */
EXPORT void obs_source_draw(gs_texture_t *image, int x, int y,
		uint32_t cx, uint32_t cy, bool flip);

J
jp9000 已提交
776
/** Outputs asynchronous video data */
777
EXPORT void obs_source_output_video(obs_source_t *source,
778
		const struct obs_source_frame *frame);
779

J
jp9000 已提交
780
/** Outputs audio data (always asynchronous) */
781
EXPORT void obs_source_output_audio(obs_source_t *source,
782
		const struct obs_source_audio *audio);
783

784 785 786
/** Signal an update to any currently used properties via 'update_properties' */
EXPORT void obs_source_update_properties(obs_source_t *source);

787
/** Gets the current async video frame */
788
EXPORT struct obs_source_frame *obs_source_get_frame(obs_source_t *source);
789

J
jp9000 已提交
790
/** Releases the current async video frame */
791
EXPORT void obs_source_release_frame(obs_source_t *source,
792
		struct obs_source_frame *frame);
J
jp9000 已提交
793

794
/** Default RGB filter handler for generic effect filters */
795
EXPORT void obs_source_process_filter(obs_source_t *filter, gs_effect_t *effect,
J
jp9000 已提交
796
		uint32_t width, uint32_t height, enum gs_color_format format,
797
		enum obs_allow_direct_render allow_direct);
798

799 800 801 802 803
/**
 * Adds a child source.  Must be called by parent sources on child sources
 * when the child is added.  This ensures that the source is properly activated
 * if the parent is active.
 */
804
EXPORT void obs_source_add_child(obs_source_t *parent, obs_source_t *child);
805 806 807 808 809 810

/**
 * Removes a child source.  Must be called by parent sources on child sources
 * when the child is removed.  This ensures that the source is properly
 * deactivated if the parent is active.
 */
811
EXPORT void obs_source_remove_child(obs_source_t *parent, obs_source_t *child);
812

K
kc5nra 已提交
813
/** Sends a mouse down/up event to a source */
814
EXPORT void obs_source_send_mouse_click(obs_source_t *source,
K
kc5nra 已提交
815 816 817 818 819
		const struct obs_mouse_event *event,
		int32_t type, bool mouse_up,
		uint32_t click_count);

/** Sends a mouse move event to a source. */
820
EXPORT void obs_source_send_mouse_move(obs_source_t *source,
K
kc5nra 已提交
821 822 823
		const struct obs_mouse_event *event, bool mouse_leave);

/** Sends a mouse wheel event to a source */
824
EXPORT void obs_source_send_mouse_wheel(obs_source_t *source,
K
kc5nra 已提交
825 826 827
		const struct obs_mouse_event *event, int x_delta, int y_delta);

/** Sends a got-focus or lost-focus event to a source */
828
EXPORT void obs_source_send_focus(obs_source_t *source, bool focus);
K
kc5nra 已提交
829 830

/** Sends a key up/down event to a source */
831
EXPORT void obs_source_send_key_click(obs_source_t *source,
K
kc5nra 已提交
832 833
		const struct obs_key_event *event, bool key_up);

J
jp9000 已提交
834
/** Begins transition frame.  Sets all transitioning volume values to 0.0f. */
835
EXPORT void obs_transition_begin_frame(obs_source_t *transition);
J
jp9000 已提交
836 837 838 839 840

/**
 * Adds a transitioning volume value to a source that's being transitioned.
 * This value is applied to all the sources within the the source.
 */
841
EXPORT void obs_source_set_transition_vol(obs_source_t *source, float vol);
J
jp9000 已提交
842 843

/** Ends transition frame and applies new presentation volumes to all sources */
844
EXPORT void obs_transition_end_frame(obs_source_t *transition);
J
jp9000 已提交
845

J
jp9000 已提交
846 847 848 849 850 851 852 853 854 855

/* ------------------------------------------------------------------------- */
/* Scenes */

/**
 * Creates a scene.
 *
 *   A scene is a source which is a container of other sources with specific
 * display oriantations.  Scenes can also be used like any other source.
 */
856
EXPORT obs_scene_t *obs_scene_create(const char *name);
857

858 859
EXPORT void        obs_scene_addref(obs_scene_t *scene);
EXPORT void        obs_scene_release(obs_scene_t *scene);
860

J
jp9000 已提交
861
/** Gets the scene's source context */
862
EXPORT obs_source_t *obs_scene_get_source(const obs_scene_t *scene);
J
jp9000 已提交
863

864
/** Gets the scene from its source, or NULL if not a scene */
865
EXPORT obs_scene_t *obs_scene_from_source(const obs_source_t *source);
866

867
/** Determines whether a source is within a scene */
868
EXPORT obs_sceneitem_t *obs_scene_find_source(obs_scene_t *scene,
869 870 871
		const char *name);

/** Enumerates sources within a scene */
872 873
EXPORT void obs_scene_enum_items(obs_scene_t *scene,
		bool (*callback)(obs_scene_t*, obs_sceneitem_t*, void*),
874 875
		void *param);

J
jp9000 已提交
876
/** Adds/creates a new scene item for a source */
877
EXPORT obs_sceneitem_t *obs_scene_add(obs_scene_t *scene, obs_source_t *source);
J
jp9000 已提交
878

879 880
EXPORT void obs_sceneitem_addref(obs_sceneitem_t *item);
EXPORT void obs_sceneitem_release(obs_sceneitem_t *item);
881

J
jp9000 已提交
882
/** Removes a scene item. */
883
EXPORT void obs_sceneitem_remove(obs_sceneitem_t *item);
J
jp9000 已提交
884 885

/** Gets the scene parent associated with the scene item. */
886
EXPORT obs_scene_t *obs_sceneitem_get_scene(const obs_sceneitem_t *item);
J
jp9000 已提交
887

J
jp9000 已提交
888
/** Gets the source of a scene item. */
889
EXPORT obs_source_t *obs_sceneitem_get_source(const obs_sceneitem_t *item);
J
jp9000 已提交
890

891
EXPORT void obs_sceneitem_select(obs_sceneitem_t *item, bool select);
892
EXPORT bool obs_sceneitem_selected(const obs_sceneitem_t *item);
893 894

/* Functions for gettings/setting specific orientation of a scene item */
895 896 897
EXPORT void obs_sceneitem_set_pos(obs_sceneitem_t *item, const struct vec2 *pos);
EXPORT void obs_sceneitem_set_rot(obs_sceneitem_t *item, float rot_deg);
EXPORT void obs_sceneitem_set_scale(obs_sceneitem_t *item,
898
		const struct vec2 *scale);
899
EXPORT void obs_sceneitem_set_alignment(obs_sceneitem_t *item,
900
		uint32_t alignment);
901
EXPORT void obs_sceneitem_set_order(obs_sceneitem_t *item,
J
jp9000 已提交
902
		enum obs_order_movement movement);
J
jp9000 已提交
903

904
EXPORT void obs_sceneitem_set_bounds_type(obs_sceneitem_t *item,
905
		enum obs_bounds_type type);
906
EXPORT void obs_sceneitem_set_bounds_alignment(obs_sceneitem_t *item,
907
		uint32_t alignment);
908
EXPORT void obs_sceneitem_set_bounds(obs_sceneitem_t *item,
909 910
		const struct vec2 *bounds);

911 912 913 914 915 916
EXPORT void  obs_sceneitem_get_pos(const obs_sceneitem_t *item,
		struct vec2 *pos);
EXPORT float obs_sceneitem_get_rot(const obs_sceneitem_t *item);
EXPORT void  obs_sceneitem_get_scale(const obs_sceneitem_t *item,
		struct vec2 *scale);
EXPORT uint32_t obs_sceneitem_get_alignment(const obs_sceneitem_t *item);
917

918
EXPORT enum obs_bounds_type obs_sceneitem_get_bounds_type(
919 920 921
		const obs_sceneitem_t *item);
EXPORT uint32_t obs_sceneitem_get_bounds_alignment(const obs_sceneitem_t *item);
EXPORT void obs_sceneitem_get_bounds(const obs_sceneitem_t *item,
922
		struct vec2 *bounds);
923

924
EXPORT void obs_sceneitem_get_info(const obs_sceneitem_t *item,
925
		struct obs_transform_info *info);
926
EXPORT void obs_sceneitem_set_info(obs_sceneitem_t *item,
927
		const struct obs_transform_info *info);
928

929
EXPORT void obs_sceneitem_get_draw_transform(const obs_sceneitem_t *item,
930
		struct matrix4 *transform);
931
EXPORT void obs_sceneitem_get_box_transform(const obs_sceneitem_t *item,
932
		struct matrix4 *transform);
J
jp9000 已提交
933 934 935 936 937


/* ------------------------------------------------------------------------- */
/* Outputs */

938
EXPORT const char *obs_output_get_display_name(const char *id);
939

J
jp9000 已提交
940 941 942 943 944 945
/**
 * Creates an output.
 *
 *   Outputs allow outputting to file, outputting to network, outputting to
 * directshow, or other custom outputs.
 */
946 947 948
EXPORT obs_output_t *obs_output_create(const char *id, const char *name,
		obs_data_t *settings);
EXPORT void obs_output_destroy(obs_output_t *output);
949

950
EXPORT const char *obs_output_get_name(const obs_output_t *output);
J
jp9000 已提交
951

J
jp9000 已提交
952
/** Starts the output. */
953
EXPORT bool obs_output_start(obs_output_t *output);
954

J
jp9000 已提交
955
/** Stops the output. */
956
EXPORT void obs_output_stop(obs_output_t *output);
957

958
/** Returns whether the output is active */
959
EXPORT bool obs_output_active(const obs_output_t *output);
960

J
jp9000 已提交
961
/** Gets the default settings for an output type */
962
EXPORT obs_data_t *obs_output_defaults(const char *id);
J
jp9000 已提交
963

J
jp9000 已提交
964
/** Returns the property list, if any.  Free with obs_properties_destroy */
965
EXPORT obs_properties_t *obs_get_output_properties(const char *id);
966 967 968 969 970

/**
 * Returns the property list of an existing output, if any.  Free with
 * obs_properties_destroy
 */
971
EXPORT obs_properties_t *obs_output_properties(const obs_output_t *output);
J
jp9000 已提交
972

973
/** Updates the settings for this output context */
974
EXPORT void obs_output_update(obs_output_t *output, obs_data_t *settings);
975

J
jp9000 已提交
976
/** Specifies whether the output can be paused */
977
EXPORT bool obs_output_canpause(const obs_output_t *output);
978

J
jp9000 已提交
979
/** Pauses the output (if the functionality is allowed by the output */
980
EXPORT void obs_output_pause(obs_output_t *output);
J
jp9000 已提交
981 982

/* Gets the current output settings string */
983
EXPORT obs_data_t *obs_output_get_settings(const obs_output_t *output);
J
jp9000 已提交
984

985
/** Returns the signal handler for an output  */
986 987
EXPORT signal_handler_t *obs_output_get_signal_handler(
		const obs_output_t *output);
988 989

/** Returns the procedure handler for an output */
990
EXPORT proc_handler_t *obs_output_get_proc_handler(const obs_output_t *output);
991

J
jp9000 已提交
992 993 994 995
/**
 * Sets the current video media context associated with this output,
 * required for non-encoded outputs
 */
996
EXPORT void obs_output_set_video(obs_output_t *output, video_t *video);
J
jp9000 已提交
997 998 999 1000 1001

/**
 * Sets the current audio/video media contexts associated with this output,
 * required for non-encoded outputs.  Can be null.
 */
1002 1003
EXPORT void obs_output_set_media(obs_output_t *output,
		video_t *video, audio_t *audio);
J
jp9000 已提交
1004 1005

/** Returns the video media context associated with this output */
1006
EXPORT video_t *obs_output_video(const obs_output_t *output);
J
jp9000 已提交
1007 1008

/** Returns the audio media context associated with this output */
1009
EXPORT audio_t *obs_output_audio(const obs_output_t *output);
J
jp9000 已提交
1010 1011 1012 1013 1014

/**
 * Sets the current video encoder associated with this output,
 * required for encoded outputs
 */
1015 1016
EXPORT void obs_output_set_video_encoder(obs_output_t *output,
		obs_encoder_t *encoder);
J
jp9000 已提交
1017 1018 1019 1020 1021

/**
 * Sets the current audio encoder associated with this output,
 * required for encoded outputs
 */
1022 1023
EXPORT void obs_output_set_audio_encoder(obs_output_t *output,
		obs_encoder_t *encoder);
J
jp9000 已提交
1024 1025

/** Returns the current video encoder associated with this output */
1026
EXPORT obs_encoder_t *obs_output_get_video_encoder(const obs_output_t *output);
J
jp9000 已提交
1027 1028

/** Returns the current audio encoder associated with this output */
1029
EXPORT obs_encoder_t *obs_output_get_audio_encoder(const obs_output_t *output);
J
jp9000 已提交
1030

1031
/** Sets the current service associated with this output. */
1032 1033
EXPORT void obs_output_set_service(obs_output_t *output,
		obs_service_t *service);
1034 1035

/** Gets the current service associated with this output. */
1036
EXPORT obs_service_t *obs_output_get_service(const obs_output_t *output);
1037

J
jp9000 已提交
1038 1039 1040
/**
 * Sets the reconnect settings.  Set retry_count to 0 to disable reconnecting.
 */
1041
EXPORT void obs_output_set_reconnect_settings(obs_output_t *output,
J
jp9000 已提交
1042 1043
		int retry_count, int retry_sec);

1044 1045 1046
EXPORT uint64_t obs_output_get_total_bytes(const obs_output_t *output);
EXPORT int obs_output_get_frames_dropped(const obs_output_t *output);
EXPORT int obs_output_get_total_frames(const obs_output_t *output);
J
jp9000 已提交
1047

1048 1049 1050 1051 1052 1053 1054 1055
/**
 * Sets the preferred scaled resolution for this output.  Set width and height
 * to 0 to disable scaling.
 *
 * If this output uses an encoder, it will call obs_encoder_set_scaled_size on
 * the encoder before the stream is started.  If the encoder is already active,
 * then this function will trigger a warning and do nothing.
 */
1056
EXPORT void obs_output_set_preferred_size(obs_output_t *output, uint32_t width,
1057 1058 1059
		uint32_t height);

/** For video outputs, returns the width of the encoded image */
1060
EXPORT uint32_t obs_output_get_width(const obs_output_t *output);
1061 1062

/** For video outputs, returns the height of the encoded image */
1063
EXPORT uint32_t obs_output_get_height(const obs_output_t *output);
1064

J
jp9000 已提交
1065 1066 1067 1068
/* ------------------------------------------------------------------------- */
/* Functions used by outputs */

/** Optionally sets the video conversion info.  Used only for raw output */
1069
EXPORT void obs_output_set_video_conversion(obs_output_t *output,
J
jp9000 已提交
1070 1071 1072
		const struct video_scale_info *conversion);

/** Optionally sets the audio conversion info.  Used only for raw output */
1073
EXPORT void obs_output_set_audio_conversion(obs_output_t *output,
J
jp9000 已提交
1074 1075
		const struct audio_convert_info *conversion);

1076
/** Returns whether data capture can begin with the specified flags */
1077
EXPORT bool obs_output_can_begin_data_capture(const obs_output_t *output,
1078 1079
		uint32_t flags);

1080
/** Initializes encoders (if any) */
1081 1082
EXPORT bool obs_output_initialize_encoders(obs_output_t *output,
		uint32_t flags);
1083

J
jp9000 已提交
1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095
/**
 * Begins data capture from media/encoders.
 *
 * @param  output  Output context
 * @param  flags   Set this to 0 to use default output flags set in the
 *                 obs_output_info structure, otherwise set to a either
 *                 OBS_OUTPUT_VIDEO or OBS_OUTPUT_AUDIO to specify whether to
 *                 connect audio or video.  This is useful for things like
 *                 ffmpeg which may or may not always want to use both audio
 *                 and video.
 * @return         true if successful, false otherwise.
 */
1096
EXPORT bool obs_output_begin_data_capture(obs_output_t *output, uint32_t flags);
J
jp9000 已提交
1097 1098

/** Ends data capture from media/encoders */
1099
EXPORT void obs_output_end_data_capture(obs_output_t *output);
J
jp9000 已提交
1100

1101 1102 1103 1104 1105 1106
/**
 * Signals that the output has stopped itself.
 *
 * @param  output  Output context
 * @param  code    Error code (or OBS_OUTPUT_SUCCESS if not an error)
 */
1107
EXPORT void obs_output_signal_stop(obs_output_t *output, int code);
1108

1109

1110
/* ------------------------------------------------------------------------- */
J
jp9000 已提交
1111
/* Encoders */
1112

1113
EXPORT const char *obs_encoder_getdisplayname(const char *id);
1114

1115 1116 1117 1118 1119 1120 1121 1122
/**
 * Creates a video encoder context
 *
 * @param  id        Video encoder ID
 * @param  name      Name to assign to this context
 * @param  settings  Settings
 * @return           The video encoder context, or NULL if failed or not found.
 */
1123 1124
EXPORT obs_encoder_t *obs_video_encoder_create(const char *id, const char *name,
		obs_data_t *settings);
1125

1126 1127 1128 1129 1130 1131 1132 1133
/**
 * Creates an audio encoder context
 *
 * @param  id        Audio Encoder ID
 * @param  name      Name to assign to this context
 * @param  settings  Settings
 * @return           The video encoder context, or NULL if failed or not found.
 */
1134 1135
EXPORT obs_encoder_t *obs_audio_encoder_create(const char *id, const char *name,
		obs_data_t *settings);
J
jp9000 已提交
1136

1137
/** Destroys an encoder context */
1138
EXPORT void obs_encoder_destroy(obs_encoder_t *encoder);
1139

1140
EXPORT const char *obs_encoder_get_name(const obs_encoder_t *encoder);
J
jp9000 已提交
1141

1142
/** Returns the codec of the encoder */
1143
EXPORT const char *obs_encoder_get_codec(const obs_encoder_t *encoder);
1144

1145 1146 1147 1148 1149
/**
 * Sets the scaled resolution for a video encoder.  Set width and height to 0
 * to disable scaling.  If the encoder is active, this function will trigger
 * a warning, and do nothing.
 */
1150
EXPORT void obs_encoder_set_scaled_size(obs_encoder_t *encoder, uint32_t width,
1151 1152 1153
		uint32_t height);

/** For video encoders, returns the width of the encoded image */
1154
EXPORT uint32_t obs_encoder_get_width(const obs_encoder_t *encoder);
1155 1156

/** For video encoders, returns the height of the encoded image */
1157
EXPORT uint32_t obs_encoder_get_height(const obs_encoder_t *encoder);
1158

J
jp9000 已提交
1159
/** Gets the default settings for an encoder type */
1160
EXPORT obs_data_t *obs_encoder_defaults(const char *id);
J
jp9000 已提交
1161

J
jp9000 已提交
1162
/** Returns the property list, if any.  Free with obs_properties_destroy */
1163
EXPORT obs_properties_t *obs_get_encoder_properties(const char *id);
1164 1165 1166 1167 1168

/**
 * Returns the property list of an existing encoder, if any.  Free with
 * obs_properties_destroy
 */
1169
EXPORT obs_properties_t *obs_encoder_properties(const obs_encoder_t *encoder);
J
jp9000 已提交
1170

1171 1172 1173 1174
/**
 * Updates the settings of the encoder context.  Usually used for changing
 * bitrate while active
 */
1175
EXPORT void obs_encoder_update(obs_encoder_t *encoder, obs_data_t *settings);
1176

1177
/** Gets extra data (headers) associated with this context */
1178
EXPORT bool obs_encoder_get_extra_data(const obs_encoder_t *encoder,
J
jp9000 已提交
1179
		uint8_t **extra_data, size_t *size);
1180

1181
/** Returns the current settings for this encoder */
1182
EXPORT obs_data_t *obs_encoder_get_settings(const obs_encoder_t *encoder);
1183

1184
/** Sets the video output context to be used with this encoder */
1185
EXPORT void obs_encoder_set_video(obs_encoder_t *encoder, video_t *video);
1186 1187

/** Sets the audio output context to be used with this encoder */
1188
EXPORT void obs_encoder_set_audio(obs_encoder_t *encoder, audio_t *audio);
1189

1190 1191 1192 1193
/**
 * Returns the video output context used with this encoder, or NULL if not
 * a video context
 */
1194
EXPORT video_t *obs_encoder_video(const obs_encoder_t *encoder);
1195 1196 1197 1198 1199

/**
 * Returns the audio output context used with this encoder, or NULL if not
 * a audio context
 */
1200
EXPORT audio_t *obs_encoder_audio(const obs_encoder_t *encoder);
1201

1202
/** Returns true if encoder is active, false otherwise */
1203
EXPORT bool obs_encoder_active(const obs_encoder_t *encoder);
1204

1205 1206 1207 1208 1209 1210
/** Duplicates an encoder packet */
EXPORT void obs_duplicate_encoder_packet(struct encoder_packet *dst,
		const struct encoder_packet *src);

EXPORT void obs_free_encoder_packet(struct encoder_packet *packet);

1211

1212 1213
/* ------------------------------------------------------------------------- */
/* Stream Services */
1214

1215
EXPORT const char *obs_service_get_display_name(const char *id);
1216

1217 1218 1219
EXPORT obs_service_t *obs_service_create(const char *id, const char *name,
		obs_data_t *settings);
EXPORT void obs_service_destroy(obs_service_t *service);
1220

1221
EXPORT const char *obs_service_get_name(const obs_service_t *service);
1222

1223
/** Gets the default settings for a service */
1224
EXPORT obs_data_t *obs_service_defaults(const char *id);
1225 1226

/** Returns the property list, if any.  Free with obs_properties_destroy */
1227
EXPORT obs_properties_t *obs_get_service_properties(const char *id);
1228 1229 1230 1231 1232

/**
 * Returns the property list of an existing service context, if any.  Free with
 * obs_properties_destroy
 */
1233
EXPORT obs_properties_t *obs_service_properties(const obs_service_t *service);
1234

1235
/** Gets the service type */
1236
EXPORT const char *obs_service_gettype(const obs_service_t *service);
1237 1238

/** Updates the settings of the service context */
1239
EXPORT void obs_service_update(obs_service_t *service, obs_data_t *settings);
1240 1241

/** Returns the current settings for this service */
1242
EXPORT obs_data_t *obs_service_get_settings(const obs_service_t *service);
1243

1244
/** Returns the URL for this service context */
1245
EXPORT const char *obs_service_get_url(const obs_service_t *service);
1246 1247

/** Returns the stream key (if any) for this service context */
1248
EXPORT const char *obs_service_get_key(const obs_service_t *service);
1249 1250

/** Returns the username (if any) for this service context */
1251
EXPORT const char *obs_service_get_username(const obs_service_t *service);
1252 1253

/** Returns the password (if any) for this service context */
1254
EXPORT const char *obs_service_get_password(const obs_service_t *service);
1255

1256

1257 1258
/* ------------------------------------------------------------------------- */
/* Source frame allocation functions */
1259
EXPORT void obs_source_frame_init(struct obs_source_frame *frame,
1260 1261
		enum video_format format, uint32_t width, uint32_t height);

1262
static inline void obs_source_frame_free(struct obs_source_frame *frame)
1263 1264 1265
{
	if (frame) {
		bfree(frame->data[0]);
1266
		memset(frame, 0, sizeof(*frame));
1267 1268 1269
	}
}

1270
static inline struct obs_source_frame *obs_source_frame_create(
1271 1272
		enum video_format format, uint32_t width, uint32_t height)
{
1273
	struct obs_source_frame *frame;
1274

1275 1276
	frame = (struct obs_source_frame*)bzalloc(sizeof(*frame));
	obs_source_frame_init(frame, format, width, height);
1277 1278 1279
	return frame;
}

1280
static inline void obs_source_frame_destroy(struct obs_source_frame *frame)
1281 1282 1283 1284 1285 1286 1287 1288
{
	if (frame) {
		bfree(frame->data[0]);
		bfree(frame);
	}
}


J
jp9000 已提交
1289 1290 1291
#ifdef __cplusplus
}
#endif