1 /******************************************************************************
2     Copyright (C) 2013-2014 by Hugh Bailey <jim@obsproject.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 "util/c99defs.h"
21 #include "util/bmem.h"
22 #include "util/profiler.h"
23 #include "util/text-lookup.h"
24 #include "graphics/graphics.h"
25 #include "graphics/vec2.h"
26 #include "graphics/vec3.h"
27 #include "media-io/audio-io.h"
28 #include "media-io/video-io.h"
29 #include "callback/signal.h"
30 #include "callback/proc.h"
31 
32 #include "obs-config.h"
33 #include "obs-defs.h"
34 #include "obs-data.h"
35 #include "obs-ui.h"
36 #include "obs-properties.h"
37 #include "obs-interaction.h"
38 
39 struct matrix4;
40 
41 /* opaque types */
42 struct obs_display;
43 struct obs_view;
44 struct obs_source;
45 struct obs_scene;
46 struct obs_scene_item;
47 struct obs_output;
48 struct obs_encoder;
49 struct obs_service;
50 struct obs_module;
51 struct obs_fader;
52 struct obs_volmeter;
53 
54 typedef struct obs_display obs_display_t;
55 typedef struct obs_view obs_view_t;
56 typedef struct obs_source obs_source_t;
57 typedef struct obs_scene obs_scene_t;
58 typedef struct obs_scene_item obs_sceneitem_t;
59 typedef struct obs_output obs_output_t;
60 typedef struct obs_encoder obs_encoder_t;
61 typedef struct obs_service obs_service_t;
62 typedef struct obs_module obs_module_t;
63 typedef struct obs_fader obs_fader_t;
64 typedef struct obs_volmeter obs_volmeter_t;
65 
66 typedef struct obs_weak_source obs_weak_source_t;
67 typedef struct obs_weak_output obs_weak_output_t;
68 typedef struct obs_weak_encoder obs_weak_encoder_t;
69 typedef struct obs_weak_service obs_weak_service_t;
70 
71 #include "obs-missing-files.h"
72 #include "obs-source.h"
73 #include "obs-encoder.h"
74 #include "obs-output.h"
75 #include "obs-service.h"
76 #include "obs-audio-controls.h"
77 #include "obs-hotkey.h"
78 
79 /**
80  * @file
81  * @brief Main libobs header used by applications.
82  *
83  * @mainpage
84  *
85  * @section intro_sec Introduction
86  *
87  * This document describes the api for libobs to be used by applications as well
88  * as @ref modules_page implementing some kind of functionality.
89  *
90  */
91 
92 #ifdef __cplusplus
93 extern "C" {
94 #endif
95 
96 /** Used for changing the order of items (for example, filters in a source,
97  * or items in a scene) */
98 enum obs_order_movement {
99 	OBS_ORDER_MOVE_UP,
100 	OBS_ORDER_MOVE_DOWN,
101 	OBS_ORDER_MOVE_TOP,
102 	OBS_ORDER_MOVE_BOTTOM,
103 };
104 
105 /**
106  * Used with obs_source_process_filter to specify whether the filter should
107  * render the source directly with the specified effect, or whether it should
108  * render it to a texture
109  */
110 enum obs_allow_direct_render {
111 	OBS_NO_DIRECT_RENDERING,
112 	OBS_ALLOW_DIRECT_RENDERING,
113 };
114 
115 enum obs_scale_type {
116 	OBS_SCALE_DISABLE,
117 	OBS_SCALE_POINT,
118 	OBS_SCALE_BICUBIC,
119 	OBS_SCALE_BILINEAR,
120 	OBS_SCALE_LANCZOS,
121 	OBS_SCALE_AREA,
122 };
123 
124 /**
125  * Used with scene items to indicate the type of bounds to use for scene items.
126  * Mostly determines how the image will be scaled within those bounds, or
127  * whether to use bounds at all.
128  */
129 enum obs_bounds_type {
130 	OBS_BOUNDS_NONE,            /**< no bounds */
131 	OBS_BOUNDS_STRETCH,         /**< stretch (ignores base scale) */
132 	OBS_BOUNDS_SCALE_INNER,     /**< scales to inner rectangle */
133 	OBS_BOUNDS_SCALE_OUTER,     /**< scales to outer rectangle */
134 	OBS_BOUNDS_SCALE_TO_WIDTH,  /**< scales to the width  */
135 	OBS_BOUNDS_SCALE_TO_HEIGHT, /**< scales to the height */
136 	OBS_BOUNDS_MAX_ONLY,        /**< no scaling, maximum size only */
137 };
138 
139 struct obs_transform_info {
140 	struct vec2 pos;
141 	float rot;
142 	struct vec2 scale;
143 	uint32_t alignment;
144 
145 	enum obs_bounds_type bounds_type;
146 	uint32_t bounds_alignment;
147 	struct vec2 bounds;
148 };
149 
150 /**
151  * Video initialization structure
152  */
153 struct obs_video_info {
154 #ifndef SWIG
155 	/**
156 	 * Graphics module to use (usually "libobs-opengl" or "libobs-d3d11")
157 	 */
158 	const char *graphics_module;
159 #endif
160 
161 	uint32_t fps_num; /**< Output FPS numerator */
162 	uint32_t fps_den; /**< Output FPS denominator */
163 
164 	uint32_t base_width;  /**< Base compositing width */
165 	uint32_t base_height; /**< Base compositing height */
166 
167 	uint32_t output_width;           /**< Output width */
168 	uint32_t output_height;          /**< Output height */
169 	enum video_format output_format; /**< Output format */
170 
171 	/** Video adapter index to use (NOTE: avoid for optimus laptops) */
172 	uint32_t adapter;
173 
174 	/** Use shaders to convert to different color formats */
175 	bool gpu_conversion;
176 
177 	enum video_colorspace colorspace; /**< YUV type (if YUV) */
178 	enum video_range_type range;      /**< YUV range (if YUV) */
179 
180 	enum obs_scale_type scale_type; /**< How to scale if scaling */
181 };
182 
183 /**
184  * Audio initialization structure
185  */
186 struct obs_audio_info {
187 	uint32_t samples_per_sec;
188 	enum speaker_layout speakers;
189 };
190 
191 /**
192  * Sent to source filters via the filter_audio callback to allow filtering of
193  * audio data
194  */
195 struct obs_audio_data {
196 	uint8_t *data[MAX_AV_PLANES];
197 	uint32_t frames;
198 	uint64_t timestamp;
199 };
200 
201 /**
202  * Source audio output structure.  Used with obs_source_output_audio to output
203  * source audio.  Audio is automatically resampled and remixed as necessary.
204  */
205 struct obs_source_audio {
206 	const uint8_t *data[MAX_AV_PLANES];
207 	uint32_t frames;
208 
209 	enum speaker_layout speakers;
210 	enum audio_format format;
211 	uint32_t samples_per_sec;
212 
213 	uint64_t timestamp;
214 };
215 
216 struct obs_source_cea_708 {
217 	const uint8_t *data;
218 	uint32_t packets;
219 	uint64_t timestamp;
220 };
221 
222 #define OBS_SOURCE_FRAME_LINEAR_ALPHA (1 << 0)
223 
224 /**
225  * Source asynchronous video output structure.  Used with
226  * obs_source_output_video to output asynchronous video.  Video is buffered as
227  * necessary to play according to timestamps.  When used with audio output,
228  * audio is synced to video as it is played.
229  *
230  * If a YUV format is specified, it will be automatically upsampled and
231  * converted to RGB via shader on the graphics processor.
232  *
233  * NOTE: Non-YUV formats will always be treated as full range with this
234  * structure!  Use obs_source_frame2 along with obs_source_output_video2
235  * instead if partial range support is desired for non-YUV video formats.
236  */
237 struct obs_source_frame {
238 	uint8_t *data[MAX_AV_PLANES];
239 	uint32_t linesize[MAX_AV_PLANES];
240 	uint32_t width;
241 	uint32_t height;
242 	uint64_t timestamp;
243 
244 	enum video_format format;
245 	float color_matrix[16];
246 	bool full_range;
247 	float color_range_min[3];
248 	float color_range_max[3];
249 	bool flip;
250 	uint8_t flags;
251 
252 	/* used internally by libobs */
253 	volatile long refs;
254 	bool prev_frame;
255 };
256 
257 struct obs_source_frame2 {
258 	uint8_t *data[MAX_AV_PLANES];
259 	uint32_t linesize[MAX_AV_PLANES];
260 	uint32_t width;
261 	uint32_t height;
262 	uint64_t timestamp;
263 
264 	enum video_format format;
265 	enum video_range_type range;
266 	float color_matrix[16];
267 	float color_range_min[3];
268 	float color_range_max[3];
269 	bool flip;
270 	uint8_t flags;
271 };
272 
273 /** Access to the argc/argv used to start OBS. What you see is what you get. */
274 struct obs_cmdline_args {
275 	int argc;
276 	char **argv;
277 };
278 
279 /* ------------------------------------------------------------------------- */
280 /* OBS context */
281 
282 /**
283  * Find a core libobs data file
284  * @param path name of the base file
285  * @return A string containing the full path to the file.
286  *          Use bfree after use.
287  */
288 EXPORT char *obs_find_data_file(const char *file);
289 
290 /**
291  * Add a path to search libobs data files in.
292  * @param path Full path to directory to look in.
293  *             The string is copied.
294  */
295 EXPORT void obs_add_data_path(const char *path);
296 
297 /**
298  * Remove a path from libobs core data paths.
299  * @param path The path to compare to currently set paths.
300  *             It does not need to be the same pointer, but
301  *             the path string must match an entry fully.
302  * @return Whether or not the path was successfully removed.
303  *         If false, the path could not be found.
304  */
305 EXPORT bool obs_remove_data_path(const char *path);
306 
307 /**
308  * Initializes OBS
309  *
310  * @param  locale              The locale to use for modules
311  * @param  module_config_path  Path to module config storage directory
312  *                             (or NULL if none)
313  * @param  store               The profiler name store for OBS to use or NULL
314  */
315 EXPORT bool obs_startup(const char *locale, const char *module_config_path,
316 			profiler_name_store_t *store);
317 
318 /** Releases all data associated with OBS and terminates the OBS context */
319 EXPORT void obs_shutdown(void);
320 
321 /** @return true if the main OBS context has been initialized */
322 EXPORT bool obs_initialized(void);
323 
324 /** @return The current core version */
325 EXPORT uint32_t obs_get_version(void);
326 
327 /** @return The current core version string */
328 EXPORT const char *obs_get_version_string(void);
329 
330 /**
331  * Sets things up for calls to obs_get_cmdline_args. Called only once at startup
332  * and safely copies argv/argc from main(). Subsequent calls do nothing.
333  *
334  * @param  argc  The count of command line arguments, from main()
335  * @param  argv  An array of command line arguments, copied from main() and ends
336  *               with NULL.
337  */
338 EXPORT void obs_set_cmdline_args(int argc, const char *const *argv);
339 
340 /**
341  * Get the argc/argv used to start OBS
342  *
343  * @return  The command line arguments used for main(). Don't modify this or
344  *          you'll mess things up for other callers.
345  */
346 EXPORT struct obs_cmdline_args obs_get_cmdline_args(void);
347 
348 /**
349  * Sets a new locale to use for modules.  This will call obs_module_set_locale
350  * for each module with the new locale.
351  *
352  * @param  locale  The locale to use for modules
353  */
354 EXPORT void obs_set_locale(const char *locale);
355 
356 /** @return the current locale */
357 EXPORT const char *obs_get_locale(void);
358 
359 /** Initialize the Windows-specific crash handler */
360 
361 #ifdef _WIN32
362 EXPORT void obs_init_win32_crash_handler(void);
363 #endif
364 
365 /**
366  * Returns the profiler name store (see util/profiler.h) used by OBS, which is
367  * either a name store passed to obs_startup, an internal name store, or NULL
368  * in case obs_initialized() returns false.
369  */
370 EXPORT profiler_name_store_t *obs_get_profiler_name_store(void);
371 
372 /**
373  * Sets base video output base resolution/fps/format.
374  *
375  * @note This data cannot be changed if an output is currently active.
376  * @note The graphics module cannot be changed without fully destroying the
377  *       OBS context.
378  *
379  * @param   ovi  Pointer to an obs_video_info structure containing the
380  *               specification of the graphics subsystem,
381  * @return       OBS_VIDEO_SUCCESS if successful
382  *               OBS_VIDEO_NOT_SUPPORTED if the adapter lacks capabilities
383  *               OBS_VIDEO_INVALID_PARAM if a parameter is invalid
384  *               OBS_VIDEO_CURRENTLY_ACTIVE if video is currently active
385  *               OBS_VIDEO_MODULE_NOT_FOUND if the graphics module is not found
386  *               OBS_VIDEO_FAIL for generic failure
387  */
388 EXPORT int obs_reset_video(struct obs_video_info *ovi);
389 
390 /**
391  * Sets base audio output format/channels/samples/etc
392  *
393  * @note Cannot reset base audio if an output is currently active.
394  */
395 EXPORT bool obs_reset_audio(const struct obs_audio_info *oai);
396 
397 /** Gets the current video settings, returns false if no video */
398 EXPORT bool obs_get_video_info(struct obs_video_info *ovi);
399 
400 /** Gets the current audio settings, returns false if no audio */
401 EXPORT bool obs_get_audio_info(struct obs_audio_info *oai);
402 
403 /**
404  * Opens a plugin module directly from a specific path.
405  *
406  * If the module already exists then the function will return successful, and
407  * the module parameter will be given the pointer to the existing module.
408  *
409  * This does not initialize the module, it only loads the module image.  To
410  * initialize the module, call obs_init_module.
411  *
412  * @param  module     The pointer to the created module.
413  * @param  path       Specifies the path to the module library file.  If the
414  *                    extension is not specified, it will use the extension
415  *                    appropriate to the operating system.
416  * @param  data_path  Specifies the path to the directory where the module's
417  *                    data files are stored.
418  * @returns           MODULE_SUCCESS if successful
419  *                    MODULE_ERROR if a generic error occurred
420  *                    MODULE_FILE_NOT_FOUND if the module was not found
421  *                    MODULE_MISSING_EXPORTS if required exports are missing
422  *                    MODULE_INCOMPATIBLE_VER if incompatible version
423  */
424 EXPORT int obs_open_module(obs_module_t **module, const char *path,
425 			   const char *data_path);
426 
427 /**
428  * Initializes the module, which calls its obs_module_load export.  If the
429  * module is already loaded, then this function does nothing and returns
430  * successful.
431  */
432 EXPORT bool obs_init_module(obs_module_t *module);
433 
434 /** Returns a module based upon its name, or NULL if not found */
435 EXPORT obs_module_t *obs_get_module(const char *name);
436 
437 /** Gets library of module */
438 EXPORT void *obs_get_module_lib(obs_module_t *module);
439 
440 /** Returns locale text from a specific module */
441 EXPORT bool obs_module_get_locale_string(const obs_module_t *mod,
442 					 const char *lookup_string,
443 					 const char **translated_string);
444 
445 EXPORT const char *obs_module_get_locale_text(const obs_module_t *mod,
446 					      const char *text);
447 
448 /** Logs loaded modules */
449 EXPORT void obs_log_loaded_modules(void);
450 
451 /** Returns the module file name */
452 EXPORT const char *obs_get_module_file_name(obs_module_t *module);
453 
454 /** Returns the module full name */
455 EXPORT const char *obs_get_module_name(obs_module_t *module);
456 
457 /** Returns the module author(s) */
458 EXPORT const char *obs_get_module_author(obs_module_t *module);
459 
460 /** Returns the module description */
461 EXPORT const char *obs_get_module_description(obs_module_t *module);
462 
463 /** Returns the module binary path */
464 EXPORT const char *obs_get_module_binary_path(obs_module_t *module);
465 
466 /** Returns the module data path */
467 EXPORT const char *obs_get_module_data_path(obs_module_t *module);
468 
469 /**
470  * Adds a module search path to be used with obs_find_modules.  If the search
471  * path strings contain %module%, that text will be replaced with the module
472  * name when used.
473  *
474  * @param  bin   Specifies the module's binary directory search path.
475  * @param  data  Specifies the module's data directory search path.
476  */
477 EXPORT void obs_add_module_path(const char *bin, const char *data);
478 
479 /** Automatically loads all modules from module paths (convenience function) */
480 EXPORT void obs_load_all_modules(void);
481 
482 /** Notifies modules that all modules have been loaded.  This function should
483  * be called after all modules have been loaded. */
484 EXPORT void obs_post_load_modules(void);
485 
486 #ifndef SWIG
487 struct obs_module_info {
488 	const char *bin_path;
489 	const char *data_path;
490 };
491 
492 typedef void (*obs_find_module_callback_t)(void *param,
493 					   const struct obs_module_info *info);
494 
495 /** Finds all modules within the search paths added by obs_add_module_path. */
496 EXPORT void obs_find_modules(obs_find_module_callback_t callback, void *param);
497 #endif
498 
499 typedef void (*obs_enum_module_callback_t)(void *param, obs_module_t *module);
500 
501 /** Enumerates all loaded modules */
502 EXPORT void obs_enum_modules(obs_enum_module_callback_t callback, void *param);
503 
504 /** Helper function for using default module locale */
505 EXPORT lookup_t *obs_module_load_locale(obs_module_t *module,
506 					const char *default_locale,
507 					const char *locale);
508 
509 /**
510  * Returns the location of a plugin module data file.
511  *
512  * @note   Modules should use obs_module_file function defined in obs-module.h
513  *         as a more elegant means of getting their files without having to
514  *         specify the module parameter.
515  *
516  * @param  module  The module associated with the file to locate
517  * @param  file    The file to locate
518  * @return         Path string, or NULL if not found.  Use bfree to free string.
519  */
520 EXPORT char *obs_find_module_file(obs_module_t *module, const char *file);
521 
522 /**
523  * Returns the path of a plugin module config file (whether it exists or not)
524  *
525  * @note   Modules should use obs_module_config_path function defined in
526  *         obs-module.h as a more elegant means of getting their files without
527  *         having to specify the module parameter.
528  *
529  * @param  module  The module associated with the path
530  * @param  file    The file to get a path to
531  * @return         Path string, or NULL if not found.  Use bfree to free string.
532  */
533 EXPORT char *obs_module_get_config_path(obs_module_t *module, const char *file);
534 
535 /** Enumerates all source types (inputs, filters, transitions, etc).  */
536 EXPORT bool obs_enum_source_types(size_t idx, const char **id);
537 
538 /**
539  * Enumerates all available inputs source types.
540  *
541  *   Inputs are general source inputs (such as capture sources, device sources,
542  * etc).
543  */
544 EXPORT bool obs_enum_input_types(size_t idx, const char **id);
545 EXPORT bool obs_enum_input_types2(size_t idx, const char **id,
546 				  const char **unversioned_id);
547 
548 EXPORT const char *obs_get_latest_input_type_id(const char *unversioned_id);
549 
550 /**
551  * Enumerates all available filter source types.
552  *
553  *   Filters are sources that are used to modify the video/audio output of
554  * other sources.
555  */
556 EXPORT bool obs_enum_filter_types(size_t idx, const char **id);
557 
558 /**
559  * Enumerates all available transition source types.
560  *
561  *   Transitions are sources used to transition between two or more other
562  * sources.
563  */
564 EXPORT bool obs_enum_transition_types(size_t idx, const char **id);
565 
566 /** Enumerates all available output types. */
567 EXPORT bool obs_enum_output_types(size_t idx, const char **id);
568 
569 /** Enumerates all available encoder types. */
570 EXPORT bool obs_enum_encoder_types(size_t idx, const char **id);
571 
572 /** Enumerates all available service types. */
573 EXPORT bool obs_enum_service_types(size_t idx, const char **id);
574 
575 /** Helper function for entering the OBS graphics context */
576 EXPORT void obs_enter_graphics(void);
577 
578 /** Helper function for leaving the OBS graphics context */
579 EXPORT void obs_leave_graphics(void);
580 
581 /** Gets the main audio output handler for this OBS context */
582 EXPORT audio_t *obs_get_audio(void);
583 
584 /** Gets the main video output handler for this OBS context */
585 EXPORT video_t *obs_get_video(void);
586 
587 /** Returns true if video is active, false otherwise */
588 EXPORT bool obs_video_active(void);
589 
590 /** Sets the primary output source for a channel. */
591 EXPORT void obs_set_output_source(uint32_t channel, obs_source_t *source);
592 
593 /**
594  * Gets the primary output source for a channel and increments the reference
595  * counter for that source.  Use obs_source_release to release.
596  */
597 EXPORT obs_source_t *obs_get_output_source(uint32_t channel);
598 
599 /**
600  * Enumerates all input sources
601  *
602  *   Callback function returns true to continue enumeration, or false to end
603  * enumeration.
604  *
605  *   Use obs_source_get_ref or obs_source_get_weak_source if you want to retain
606  * a reference after obs_enum_sources finishes
607  */
608 EXPORT void obs_enum_sources(bool (*enum_proc)(void *, obs_source_t *),
609 			     void *param);
610 
611 /** Enumerates scenes */
612 EXPORT void obs_enum_scenes(bool (*enum_proc)(void *, obs_source_t *),
613 			    void *param);
614 
615 /** Enumerates all sources (regardless of type) */
616 EXPORT void obs_enum_all_sources(bool (*enum_proc)(void *, obs_source_t *),
617 				 void *param);
618 
619 /** Enumerates outputs */
620 EXPORT void obs_enum_outputs(bool (*enum_proc)(void *, obs_output_t *),
621 			     void *param);
622 
623 /** Enumerates encoders */
624 EXPORT void obs_enum_encoders(bool (*enum_proc)(void *, obs_encoder_t *),
625 			      void *param);
626 
627 /** Enumerates encoders */
628 EXPORT void obs_enum_services(bool (*enum_proc)(void *, obs_service_t *),
629 			      void *param);
630 
631 /**
632  * Gets a source by its name.
633  *
634  *   Increments the source reference counter, use obs_source_release to
635  * release it when complete.
636  */
637 EXPORT obs_source_t *obs_get_source_by_name(const char *name);
638 
639 /** Gets an output by its name. */
640 EXPORT obs_output_t *obs_get_output_by_name(const char *name);
641 
642 /** Gets an encoder by its name. */
643 EXPORT obs_encoder_t *obs_get_encoder_by_name(const char *name);
644 
645 /** Gets an service by its name. */
646 EXPORT obs_service_t *obs_get_service_by_name(const char *name);
647 
648 enum obs_base_effect {
649 	OBS_EFFECT_DEFAULT,         /**< RGB/YUV */
650 	OBS_EFFECT_DEFAULT_RECT,    /**< RGB/YUV (using texture_rect) */
651 	OBS_EFFECT_OPAQUE,          /**< RGB/YUV (alpha set to 1.0) */
652 	OBS_EFFECT_SOLID,           /**< RGB/YUV (solid color only) */
653 	OBS_EFFECT_BICUBIC,         /**< Bicubic downscale */
654 	OBS_EFFECT_LANCZOS,         /**< Lanczos downscale */
655 	OBS_EFFECT_BILINEAR_LOWRES, /**< Bilinear low resolution downscale */
656 	OBS_EFFECT_PREMULTIPLIED_ALPHA, /**< Premultiplied alpha */
657 	OBS_EFFECT_REPEAT,              /**< RGB/YUV (repeating) */
658 	OBS_EFFECT_AREA,                /**< Area rescale */
659 };
660 
661 /** Returns a commonly used base effect */
662 EXPORT gs_effect_t *obs_get_base_effect(enum obs_base_effect effect);
663 
664 #ifndef SWIG
665 /* DEPRECATED: gets texture_rect default effect */
666 OBS_DEPRECATED
667 EXPORT gs_effect_t *obs_get_default_rect_effect(void);
668 #endif
669 
670 /** Returns the primary obs signal handler */
671 EXPORT signal_handler_t *obs_get_signal_handler(void);
672 
673 /** Returns the primary obs procedure handler */
674 EXPORT proc_handler_t *obs_get_proc_handler(void);
675 
676 #ifndef SWIG
677 /** Renders the main view */
678 OBS_DEPRECATED
679 EXPORT void obs_render_main_view(void);
680 #endif
681 
682 /** Renders the last main output texture */
683 EXPORT void obs_render_main_texture(void);
684 
685 /** Renders the last main output texture ignoring background color */
686 EXPORT void obs_render_main_texture_src_color_only(void);
687 
688 /** Returns the last main output texture.  This can return NULL if the texture
689  * is unavailable. */
690 EXPORT gs_texture_t *obs_get_main_texture(void);
691 
692 /** Sets the master user volume */
693 EXPORT void obs_set_master_volume(float volume);
694 
695 /** Gets the master user volume */
696 EXPORT float obs_get_master_volume(void);
697 
698 /** Saves a source to settings data */
699 EXPORT obs_data_t *obs_save_source(obs_source_t *source);
700 
701 /** Loads a source from settings data */
702 EXPORT obs_source_t *obs_load_source(obs_data_t *data);
703 
704 /** Send a save signal to sources */
705 EXPORT void obs_source_save(obs_source_t *source);
706 
707 /** Send a load signal to sources (soft deprecated; does not load filters) */
708 EXPORT void obs_source_load(obs_source_t *source);
709 
710 /** Send a load signal to sources */
711 EXPORT void obs_source_load2(obs_source_t *source);
712 
713 typedef void (*obs_load_source_cb)(void *private_data, obs_source_t *source);
714 
715 /** Loads sources from a data array */
716 EXPORT void obs_load_sources(obs_data_array_t *array, obs_load_source_cb cb,
717 			     void *private_data);
718 
719 /** Saves sources to a data array */
720 EXPORT obs_data_array_t *obs_save_sources(void);
721 
722 typedef bool (*obs_save_source_filter_cb)(void *data, obs_source_t *source);
723 EXPORT obs_data_array_t *obs_save_sources_filtered(obs_save_source_filter_cb cb,
724 						   void *data);
725 
726 enum obs_obj_type {
727 	OBS_OBJ_TYPE_INVALID,
728 	OBS_OBJ_TYPE_SOURCE,
729 	OBS_OBJ_TYPE_OUTPUT,
730 	OBS_OBJ_TYPE_ENCODER,
731 	OBS_OBJ_TYPE_SERVICE,
732 };
733 
734 EXPORT enum obs_obj_type obs_obj_get_type(void *obj);
735 EXPORT const char *obs_obj_get_id(void *obj);
736 EXPORT bool obs_obj_invalid(void *obj);
737 EXPORT void *obs_obj_get_data(void *obj);
738 EXPORT bool obs_obj_is_private(void *obj);
739 
740 typedef bool (*obs_enum_audio_device_cb)(void *data, const char *name,
741 					 const char *id);
742 
743 EXPORT void obs_enum_audio_monitoring_devices(obs_enum_audio_device_cb cb,
744 					      void *data);
745 
746 EXPORT bool obs_set_audio_monitoring_device(const char *name, const char *id);
747 EXPORT void obs_get_audio_monitoring_device(const char **name, const char **id);
748 
749 EXPORT void obs_add_tick_callback(void (*tick)(void *param, float seconds),
750 				  void *param);
751 EXPORT void obs_remove_tick_callback(void (*tick)(void *param, float seconds),
752 				     void *param);
753 
754 EXPORT void obs_add_main_render_callback(void (*draw)(void *param, uint32_t cx,
755 						      uint32_t cy),
756 					 void *param);
757 EXPORT void obs_remove_main_render_callback(
758 	void (*draw)(void *param, uint32_t cx, uint32_t cy), void *param);
759 
760 EXPORT void obs_add_raw_video_callback(
761 	const struct video_scale_info *conversion,
762 	void (*callback)(void *param, struct video_data *frame), void *param);
763 EXPORT void obs_remove_raw_video_callback(
764 	void (*callback)(void *param, struct video_data *frame), void *param);
765 
766 EXPORT uint64_t obs_get_video_frame_time(void);
767 
768 EXPORT double obs_get_active_fps(void);
769 EXPORT uint64_t obs_get_average_frame_time_ns(void);
770 EXPORT uint64_t obs_get_frame_interval_ns(void);
771 
772 EXPORT uint32_t obs_get_total_frames(void);
773 EXPORT uint32_t obs_get_lagged_frames(void);
774 
775 EXPORT bool obs_nv12_tex_active(void);
776 
777 EXPORT void obs_apply_private_data(obs_data_t *settings);
778 EXPORT void obs_set_private_data(obs_data_t *settings);
779 EXPORT obs_data_t *obs_get_private_data(void);
780 
781 typedef void (*obs_task_t)(void *param);
782 
783 enum obs_task_type {
784 	OBS_TASK_UI,
785 	OBS_TASK_GRAPHICS,
786 };
787 
788 EXPORT void obs_queue_task(enum obs_task_type type, obs_task_t task,
789 			   void *param, bool wait);
790 
791 typedef void (*obs_task_handler_t)(obs_task_t task, void *param, bool wait);
792 EXPORT void obs_set_ui_task_handler(obs_task_handler_t handler);
793 
794 /* ------------------------------------------------------------------------- */
795 /* View context */
796 
797 /**
798  * Creates a view context.
799  *
800  *   A view can be used for things like separate previews, or drawing
801  * sources separately.
802  */
803 EXPORT obs_view_t *obs_view_create(void);
804 
805 /** Destroys this view context */
806 EXPORT void obs_view_destroy(obs_view_t *view);
807 
808 /** Sets the source to be used for this view context. */
809 EXPORT void obs_view_set_source(obs_view_t *view, uint32_t channel,
810 				obs_source_t *source);
811 
812 /** Gets the source currently in use for this view context */
813 EXPORT obs_source_t *obs_view_get_source(obs_view_t *view, uint32_t channel);
814 
815 /** Renders the sources of this view context */
816 EXPORT void obs_view_render(obs_view_t *view);
817 
818 /* ------------------------------------------------------------------------- */
819 /* Display context */
820 
821 /**
822  * Adds a new window display linked to the main render pipeline.  This creates
823  * a new swap chain which updates every frame.
824  *
825  * @param  graphics_data  The swap chain initialization data.
826  * @return                The new display context, or NULL if failed.
827  */
828 EXPORT obs_display_t *
829 obs_display_create(const struct gs_init_data *graphics_data,
830 		   uint32_t backround_color);
831 
832 /** Destroys a display context */
833 EXPORT void obs_display_destroy(obs_display_t *display);
834 
835 /** Changes the size of this display */
836 EXPORT void obs_display_resize(obs_display_t *display, uint32_t cx,
837 			       uint32_t cy);
838 
839 /**
840  * Adds a draw callback for this display context
841  *
842  * @param  display  The display context.
843  * @param  draw     The draw callback which is called each time a frame
844  *                  updates.
845  * @param  param    The user data to be associated with this draw callback.
846  */
847 EXPORT void obs_display_add_draw_callback(obs_display_t *display,
848 					  void (*draw)(void *param, uint32_t cx,
849 						       uint32_t cy),
850 					  void *param);
851 
852 /** Removes a draw callback for this display context */
853 EXPORT void obs_display_remove_draw_callback(
854 	obs_display_t *display,
855 	void (*draw)(void *param, uint32_t cx, uint32_t cy), void *param);
856 
857 EXPORT void obs_display_set_enabled(obs_display_t *display, bool enable);
858 EXPORT bool obs_display_enabled(obs_display_t *display);
859 
860 EXPORT void obs_display_set_background_color(obs_display_t *display,
861 					     uint32_t color);
862 
863 EXPORT void obs_display_size(obs_display_t *display, uint32_t *width,
864 			     uint32_t *height);
865 
866 /* ------------------------------------------------------------------------- */
867 /* Sources */
868 
869 /** Returns the translated display name of a source */
870 EXPORT const char *obs_source_get_display_name(const char *id);
871 
872 /**
873  * Creates a source of the specified type with the specified settings.
874  *
875  *   The "source" context is used for anything related to presenting
876  * or modifying video/audio.  Use obs_source_release to release it.
877  */
878 EXPORT obs_source_t *obs_source_create(const char *id, const char *name,
879 				       obs_data_t *settings,
880 				       obs_data_t *hotkey_data);
881 
882 EXPORT obs_source_t *obs_source_create_private(const char *id, const char *name,
883 					       obs_data_t *settings);
884 
885 /* if source has OBS_SOURCE_DO_NOT_DUPLICATE output flag set, only returns a
886  * reference */
887 EXPORT obs_source_t *obs_source_duplicate(obs_source_t *source,
888 					  const char *desired_name,
889 					  bool create_private);
890 /**
891  * Adds/releases a reference to a source.  When the last reference is
892  * released, the source is destroyed.
893  */
894 EXPORT void obs_source_addref(obs_source_t *source);
895 EXPORT void obs_source_release(obs_source_t *source);
896 
897 EXPORT void obs_weak_source_addref(obs_weak_source_t *weak);
898 EXPORT void obs_weak_source_release(obs_weak_source_t *weak);
899 
900 EXPORT obs_source_t *obs_source_get_ref(obs_source_t *source);
901 EXPORT obs_weak_source_t *obs_source_get_weak_source(obs_source_t *source);
902 EXPORT obs_source_t *obs_weak_source_get_source(obs_weak_source_t *weak);
903 
904 EXPORT bool obs_weak_source_references_source(obs_weak_source_t *weak,
905 					      obs_source_t *source);
906 
907 /** Notifies all references that the source should be released */
908 EXPORT void obs_source_remove(obs_source_t *source);
909 
910 /** Returns true if the source should be released */
911 EXPORT bool obs_source_removed(const obs_source_t *source);
912 
913 /** The 'hidden' flag is not the same as a sceneitem's visibility. It is a
914   * property the determines if it can be found through searches. **/
915 /** Simply sets a 'hidden' flag when the source is still alive but shouldn't be found */
916 EXPORT void obs_source_set_hidden(obs_source_t *source, bool hidden);
917 
918 /** Returns the current 'hidden' state on the source */
919 EXPORT bool obs_source_is_hidden(obs_source_t *source);
920 
921 /** Returns capability flags of a source */
922 EXPORT uint32_t obs_source_get_output_flags(const obs_source_t *source);
923 
924 /** Returns capability flags of a source type */
925 EXPORT uint32_t obs_get_source_output_flags(const char *id);
926 
927 /** Gets the default settings for a source type */
928 EXPORT obs_data_t *obs_get_source_defaults(const char *id);
929 
930 /** Returns the property list, if any.  Free with obs_properties_destroy */
931 EXPORT obs_properties_t *obs_get_source_properties(const char *id);
932 
933 EXPORT obs_missing_files_t *
934 obs_source_get_missing_files(const obs_source_t *source);
935 
936 EXPORT void obs_source_replace_missing_file(obs_missing_file_cb cb,
937 					    obs_source_t *source,
938 					    const char *new_path, void *data);
939 
940 /** Returns whether the source has custom properties or not */
941 EXPORT bool obs_is_source_configurable(const char *id);
942 
943 EXPORT bool obs_source_configurable(const obs_source_t *source);
944 
945 /**
946  * Returns the properties list for a specific existing source.  Free with
947  * obs_properties_destroy
948  */
949 EXPORT obs_properties_t *obs_source_properties(const obs_source_t *source);
950 
951 /** Updates settings for this source */
952 EXPORT void obs_source_update(obs_source_t *source, obs_data_t *settings);
953 EXPORT void obs_source_reset_settings(obs_source_t *source,
954 				      obs_data_t *settings);
955 
956 /** Renders a video source. */
957 EXPORT void obs_source_video_render(obs_source_t *source);
958 
959 /** Gets the width of a source (if it has video) */
960 EXPORT uint32_t obs_source_get_width(obs_source_t *source);
961 
962 /** Gets the height of a source (if it has video) */
963 EXPORT uint32_t obs_source_get_height(obs_source_t *source);
964 
965 /** Hints whether or not the source will blend texels */
966 EXPORT bool obs_source_get_texcoords_centered(obs_source_t *source);
967 
968 /**
969  * If the source is a filter, returns the parent source of the filter.  Only
970  * guaranteed to be valid inside of the video_render, filter_audio,
971  * filter_video, and filter_remove callbacks.
972  */
973 EXPORT obs_source_t *obs_filter_get_parent(const obs_source_t *filter);
974 
975 /**
976  * If the source is a filter, returns the target source of the filter.  Only
977  * guaranteed to be valid inside of the video_render, filter_audio,
978  * filter_video, and filter_remove callbacks.
979  */
980 EXPORT obs_source_t *obs_filter_get_target(const obs_source_t *filter);
981 
982 /** Used to directly render a non-async source without any filter processing */
983 EXPORT void obs_source_default_render(obs_source_t *source);
984 
985 /** Adds a filter to the source (which is used whenever the source is used) */
986 EXPORT void obs_source_filter_add(obs_source_t *source, obs_source_t *filter);
987 
988 /** Removes a filter from the source */
989 EXPORT void obs_source_filter_remove(obs_source_t *source,
990 				     obs_source_t *filter);
991 
992 /** Modifies the order of a specific filter */
993 EXPORT void obs_source_filter_set_order(obs_source_t *source,
994 					obs_source_t *filter,
995 					enum obs_order_movement movement);
996 
997 /** Gets the settings string for a source */
998 EXPORT obs_data_t *obs_source_get_settings(const obs_source_t *source);
999 
1000 /** Gets the name of a source */
1001 EXPORT const char *obs_source_get_name(const obs_source_t *source);
1002 
1003 /** Sets the name of a source */
1004 EXPORT void obs_source_set_name(obs_source_t *source, const char *name);
1005 
1006 /** Gets the source type */
1007 EXPORT enum obs_source_type obs_source_get_type(const obs_source_t *source);
1008 
1009 /** Gets the source identifier */
1010 EXPORT const char *obs_source_get_id(const obs_source_t *source);
1011 EXPORT const char *obs_source_get_unversioned_id(const obs_source_t *source);
1012 
1013 /** Returns the signal handler for a source */
1014 EXPORT signal_handler_t *
1015 obs_source_get_signal_handler(const obs_source_t *source);
1016 
1017 /** Returns the procedure handler for a source */
1018 EXPORT proc_handler_t *obs_source_get_proc_handler(const obs_source_t *source);
1019 
1020 /** Sets the user volume for a source that has audio output */
1021 EXPORT void obs_source_set_volume(obs_source_t *source, float volume);
1022 
1023 /** Gets the user volume for a source that has audio output */
1024 EXPORT float obs_source_get_volume(const obs_source_t *source);
1025 
1026 /* Gets speaker layout of a source */
1027 EXPORT enum speaker_layout obs_source_get_speaker_layout(obs_source_t *source);
1028 
1029 /** Sets the balance value for a stereo audio source */
1030 EXPORT void obs_source_set_balance_value(obs_source_t *source, float balance);
1031 
1032 /** Gets the balance value for a stereo audio source */
1033 EXPORT float obs_source_get_balance_value(const obs_source_t *source);
1034 
1035 /** Sets the audio sync offset (in nanoseconds) for a source */
1036 EXPORT void obs_source_set_sync_offset(obs_source_t *source, int64_t offset);
1037 
1038 /** Gets the audio sync offset (in nanoseconds) for a source */
1039 EXPORT int64_t obs_source_get_sync_offset(const obs_source_t *source);
1040 
1041 /** Enumerates active child sources used by this source */
1042 EXPORT void obs_source_enum_active_sources(obs_source_t *source,
1043 					   obs_source_enum_proc_t enum_callback,
1044 					   void *param);
1045 
1046 /** Enumerates the entire active child source tree used by this source */
1047 EXPORT void obs_source_enum_active_tree(obs_source_t *source,
1048 					obs_source_enum_proc_t enum_callback,
1049 					void *param);
1050 
1051 EXPORT void obs_source_enum_full_tree(obs_source_t *source,
1052 				      obs_source_enum_proc_t enum_callback,
1053 				      void *param);
1054 
1055 /** Returns true if active, false if not */
1056 EXPORT bool obs_source_active(const obs_source_t *source);
1057 
1058 /**
1059  * Returns true if currently displayed somewhere (active or not), false if not
1060  */
1061 EXPORT bool obs_source_showing(const obs_source_t *source);
1062 
1063 /** Unused flag */
1064 #define OBS_SOURCE_FLAG_UNUSED_1 (1 << 0)
1065 /** Specifies to force audio to mono */
1066 #define OBS_SOURCE_FLAG_FORCE_MONO (1 << 1)
1067 
1068 /**
1069  * Sets source flags.  Note that these are different from the main output
1070  * flags.  These are generally things that can be set by the source or user,
1071  * while the output flags are more used to determine capabilities of a source.
1072  */
1073 EXPORT void obs_source_set_flags(obs_source_t *source, uint32_t flags);
1074 
1075 /** Gets source flags. */
1076 EXPORT uint32_t obs_source_get_flags(const obs_source_t *source);
1077 
1078 /**
1079  * Sets audio mixer flags.  These flags are used to specify which mixers
1080  * the source's audio should be applied to.
1081  */
1082 EXPORT void obs_source_set_audio_mixers(obs_source_t *source, uint32_t mixers);
1083 
1084 /** Gets audio mixer flags */
1085 EXPORT uint32_t obs_source_get_audio_mixers(const obs_source_t *source);
1086 
1087 /**
1088  * Increments the 'showing' reference counter to indicate that the source is
1089  * being shown somewhere.  If the reference counter was 0, will call the 'show'
1090  * callback.
1091  */
1092 EXPORT void obs_source_inc_showing(obs_source_t *source);
1093 
1094 /**
1095  * Increments the 'active' reference counter to indicate that the source is
1096  * fully active.  If the reference counter was 0, will call the 'activate'
1097  * callback.
1098  *
1099  * Unlike obs_source_inc_showing, this will cause children of this source to be
1100  * considered showing as well (currently used by transition previews to make
1101  * the stinger transition show correctly).  obs_source_inc_showing should
1102  * generally be used instead.
1103  */
1104 EXPORT void obs_source_inc_active(obs_source_t *source);
1105 
1106 /**
1107  * Decrements the 'showing' reference counter to indicate that the source is
1108  * no longer being shown somewhere.  If the reference counter is set to 0,
1109  * will call the 'hide' callback
1110  */
1111 EXPORT void obs_source_dec_showing(obs_source_t *source);
1112 
1113 /**
1114  * Decrements the 'active' reference counter to indicate that the source is no
1115  * longer fully active.  If the reference counter is set to 0, will call the
1116  * 'deactivate' callback
1117  *
1118  * Unlike obs_source_dec_showing, this will cause children of this source to be
1119  * considered not showing as well.  obs_source_dec_showing should generally be
1120  * used instead.
1121  */
1122 EXPORT void obs_source_dec_active(obs_source_t *source);
1123 
1124 /** Enumerates filters assigned to the source */
1125 EXPORT void obs_source_enum_filters(obs_source_t *source,
1126 				    obs_source_enum_proc_t callback,
1127 				    void *param);
1128 
1129 /** Gets a filter of a source by its display name. */
1130 EXPORT obs_source_t *obs_source_get_filter_by_name(obs_source_t *source,
1131 						   const char *name);
1132 
1133 /** Gets the number of filters the source has. */
1134 EXPORT size_t obs_source_filter_count(const obs_source_t *source);
1135 
1136 EXPORT void obs_source_copy_filters(obs_source_t *dst, obs_source_t *src);
1137 EXPORT void obs_source_copy_single_filter(obs_source_t *dst,
1138 					  obs_source_t *filter);
1139 
1140 EXPORT bool obs_source_enabled(const obs_source_t *source);
1141 EXPORT void obs_source_set_enabled(obs_source_t *source, bool enabled);
1142 
1143 EXPORT bool obs_source_muted(const obs_source_t *source);
1144 EXPORT void obs_source_set_muted(obs_source_t *source, bool muted);
1145 
1146 EXPORT bool obs_source_push_to_mute_enabled(obs_source_t *source);
1147 EXPORT void obs_source_enable_push_to_mute(obs_source_t *source, bool enabled);
1148 
1149 EXPORT uint64_t obs_source_get_push_to_mute_delay(obs_source_t *source);
1150 EXPORT void obs_source_set_push_to_mute_delay(obs_source_t *source,
1151 					      uint64_t delay);
1152 
1153 EXPORT bool obs_source_push_to_talk_enabled(obs_source_t *source);
1154 EXPORT void obs_source_enable_push_to_talk(obs_source_t *source, bool enabled);
1155 
1156 EXPORT uint64_t obs_source_get_push_to_talk_delay(obs_source_t *source);
1157 EXPORT void obs_source_set_push_to_talk_delay(obs_source_t *source,
1158 					      uint64_t delay);
1159 
1160 typedef void (*obs_source_audio_capture_t)(void *param, obs_source_t *source,
1161 					   const struct audio_data *audio_data,
1162 					   bool muted);
1163 
1164 EXPORT void obs_source_add_audio_capture_callback(
1165 	obs_source_t *source, obs_source_audio_capture_t callback, void *param);
1166 EXPORT void obs_source_remove_audio_capture_callback(
1167 	obs_source_t *source, obs_source_audio_capture_t callback, void *param);
1168 
1169 typedef void (*obs_source_caption_t)(void *param, obs_source_t *source,
1170 				     const struct obs_source_cea_708 *captions);
1171 
1172 EXPORT void obs_source_add_caption_callback(obs_source_t *source,
1173 					    obs_source_caption_t callback,
1174 					    void *param);
1175 EXPORT void obs_source_remove_caption_callback(obs_source_t *source,
1176 					       obs_source_caption_t callback,
1177 					       void *param);
1178 
1179 enum obs_deinterlace_mode {
1180 	OBS_DEINTERLACE_MODE_DISABLE,
1181 	OBS_DEINTERLACE_MODE_DISCARD,
1182 	OBS_DEINTERLACE_MODE_RETRO,
1183 	OBS_DEINTERLACE_MODE_BLEND,
1184 	OBS_DEINTERLACE_MODE_BLEND_2X,
1185 	OBS_DEINTERLACE_MODE_LINEAR,
1186 	OBS_DEINTERLACE_MODE_LINEAR_2X,
1187 	OBS_DEINTERLACE_MODE_YADIF,
1188 	OBS_DEINTERLACE_MODE_YADIF_2X,
1189 };
1190 
1191 enum obs_deinterlace_field_order {
1192 	OBS_DEINTERLACE_FIELD_ORDER_TOP,
1193 	OBS_DEINTERLACE_FIELD_ORDER_BOTTOM,
1194 };
1195 
1196 EXPORT void obs_source_set_deinterlace_mode(obs_source_t *source,
1197 					    enum obs_deinterlace_mode mode);
1198 EXPORT enum obs_deinterlace_mode
1199 obs_source_get_deinterlace_mode(const obs_source_t *source);
1200 EXPORT void obs_source_set_deinterlace_field_order(
1201 	obs_source_t *source, enum obs_deinterlace_field_order field_order);
1202 EXPORT enum obs_deinterlace_field_order
1203 obs_source_get_deinterlace_field_order(const obs_source_t *source);
1204 
1205 enum obs_monitoring_type {
1206 	OBS_MONITORING_TYPE_NONE,
1207 	OBS_MONITORING_TYPE_MONITOR_ONLY,
1208 	OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT,
1209 };
1210 
1211 EXPORT void obs_source_set_monitoring_type(obs_source_t *source,
1212 					   enum obs_monitoring_type type);
1213 EXPORT enum obs_monitoring_type
1214 obs_source_get_monitoring_type(const obs_source_t *source);
1215 
1216 /** Gets private front-end settings data.  This data is saved/loaded
1217  * automatically.  Returns an incremented reference. */
1218 EXPORT obs_data_t *obs_source_get_private_settings(obs_source_t *item);
1219 
1220 EXPORT obs_data_array_t *obs_source_backup_filters(obs_source_t *source);
1221 EXPORT void obs_source_restore_filters(obs_source_t *source,
1222 				       obs_data_array_t *array);
1223 
1224 /* ------------------------------------------------------------------------- */
1225 /* Functions used by sources */
1226 
1227 EXPORT void *obs_source_get_type_data(obs_source_t *source);
1228 
1229 /**
1230  * Helper function to set the color matrix information when drawing the source.
1231  *
1232  * @param  color_matrix     The color matrix.  Assigns to the 'color_matrix'
1233  *                          effect variable.
1234  * @param  color_range_min  The minimum color range.  Assigns to the
1235  *                          'color_range_min' effect variable.  If NULL,
1236  *                          {0.0f, 0.0f, 0.0f} is used.
1237  * @param  color_range_max  The maximum color range.  Assigns to the
1238  *                          'color_range_max' effect variable.  If NULL,
1239  *                          {1.0f, 1.0f, 1.0f} is used.
1240  */
1241 EXPORT void
1242 obs_source_draw_set_color_matrix(const struct matrix4 *color_matrix,
1243 				 const struct vec3 *color_range_min,
1244 				 const struct vec3 *color_range_max);
1245 
1246 /**
1247  * Helper function to draw sprites for a source (synchronous video).
1248  *
1249  * @param  image   The sprite texture to draw.  Assigns to the 'image' variable
1250  *                 of the current effect.
1251  * @param  x       X position of the sprite.
1252  * @param  y       Y position of the sprite.
1253  * @param  cx      Width of the sprite.  If 0, uses the texture width.
1254  * @param  cy      Height of the sprite.  If 0, uses the texture height.
1255  * @param  flip    Specifies whether to flip the image vertically.
1256  */
1257 EXPORT void obs_source_draw(gs_texture_t *image, int x, int y, uint32_t cx,
1258 			    uint32_t cy, bool flip);
1259 
1260 /**
1261  * Outputs asynchronous video data.  Set to NULL to deactivate the texture
1262  *
1263  * NOTE: Non-YUV formats will always be treated as full range with this
1264  * function!  Use obs_source_output_video2 instead if partial range support is
1265  * desired for non-YUV video formats.
1266  */
1267 EXPORT void obs_source_output_video(obs_source_t *source,
1268 				    const struct obs_source_frame *frame);
1269 EXPORT void obs_source_output_video2(obs_source_t *source,
1270 				     const struct obs_source_frame2 *frame);
1271 
1272 EXPORT void obs_source_set_async_rotation(obs_source_t *source, long rotation);
1273 
1274 EXPORT void obs_source_output_cea708(obs_source_t *source,
1275 				     const struct obs_source_cea_708 *captions);
1276 
1277 /**
1278  * Preloads asynchronous video data to allow instantaneous playback
1279  *
1280  * NOTE: Non-YUV formats will always be treated as full range with this
1281  * function!  Use obs_source_preload_video2 instead if partial range support is
1282  * desired for non-YUV video formats.
1283  */
1284 EXPORT void obs_source_preload_video(obs_source_t *source,
1285 				     const struct obs_source_frame *frame);
1286 EXPORT void obs_source_preload_video2(obs_source_t *source,
1287 				      const struct obs_source_frame2 *frame);
1288 
1289 /** Shows any preloaded video data */
1290 EXPORT void obs_source_show_preloaded_video(obs_source_t *source);
1291 
1292 /**
1293  * Sets current async video frame immediately
1294  *
1295  * NOTE: Non-YUV formats will always be treated as full range with this
1296  * function!  Use obs_source_preload_video2 instead if partial range support is
1297  * desired for non-YUV video formats.
1298  */
1299 EXPORT void obs_source_set_video_frame(obs_source_t *source,
1300 				       const struct obs_source_frame *frame);
1301 EXPORT void obs_source_set_video_frame2(obs_source_t *source,
1302 					const struct obs_source_frame2 *frame);
1303 
1304 /** Outputs audio data (always asynchronous) */
1305 EXPORT void obs_source_output_audio(obs_source_t *source,
1306 				    const struct obs_source_audio *audio);
1307 
1308 /** Signal an update to any currently used properties via 'update_properties' */
1309 EXPORT void obs_source_update_properties(obs_source_t *source);
1310 
1311 /** Gets the current async video frame */
1312 EXPORT struct obs_source_frame *obs_source_get_frame(obs_source_t *source);
1313 
1314 /** Releases the current async video frame */
1315 EXPORT void obs_source_release_frame(obs_source_t *source,
1316 				     struct obs_source_frame *frame);
1317 
1318 /**
1319  * Default RGB filter handler for generic effect filters.  Processes the
1320  * filter chain and renders them to texture if needed, then the filter is
1321  * drawn with
1322  *
1323  * After calling this, set your parameters for the effect, then call
1324  * obs_source_process_filter_end to draw the filter.
1325  *
1326  * Returns true if filtering should continue, false if the filter is bypassed
1327  * for whatever reason.
1328  */
1329 EXPORT bool
1330 obs_source_process_filter_begin(obs_source_t *filter,
1331 				enum gs_color_format format,
1332 				enum obs_allow_direct_render allow_direct);
1333 
1334 /**
1335  * Draws the filter.
1336  *
1337  * Before calling this function, first call obs_source_process_filter_begin and
1338  * then set the effect parameters, and then call this function to finalize the
1339  * filter.
1340  */
1341 EXPORT void obs_source_process_filter_end(obs_source_t *filter,
1342 					  gs_effect_t *effect, uint32_t width,
1343 					  uint32_t height);
1344 
1345 /**
1346  * Draws the filter with a specific technique.
1347  *
1348  * Before calling this function, first call obs_source_process_filter_begin and
1349  * then set the effect parameters, and then call this function to finalize the
1350  * filter.
1351  */
1352 EXPORT void obs_source_process_filter_tech_end(obs_source_t *filter,
1353 					       gs_effect_t *effect,
1354 					       uint32_t width, uint32_t height,
1355 					       const char *tech_name);
1356 
1357 /** Skips the filter if the filter is invalid and cannot be rendered */
1358 EXPORT void obs_source_skip_video_filter(obs_source_t *filter);
1359 
1360 /**
1361  * Adds an active child source.  Must be called by parent sources on child
1362  * sources when the child is added and active.  This ensures that the source is
1363  * properly activated if the parent is active.
1364  *
1365  * @returns true if source can be added, false if it causes recursion
1366  */
1367 EXPORT bool obs_source_add_active_child(obs_source_t *parent,
1368 					obs_source_t *child);
1369 
1370 /**
1371  * Removes an active child source.  Must be called by parent sources on child
1372  * sources when the child is removed or inactive.  This ensures that the source
1373  * is properly deactivated if the parent is no longer active.
1374  */
1375 EXPORT void obs_source_remove_active_child(obs_source_t *parent,
1376 					   obs_source_t *child);
1377 
1378 /** Sends a mouse down/up event to a source */
1379 EXPORT void obs_source_send_mouse_click(obs_source_t *source,
1380 					const struct obs_mouse_event *event,
1381 					int32_t type, bool mouse_up,
1382 					uint32_t click_count);
1383 
1384 /** Sends a mouse move event to a source. */
1385 EXPORT void obs_source_send_mouse_move(obs_source_t *source,
1386 				       const struct obs_mouse_event *event,
1387 				       bool mouse_leave);
1388 
1389 /** Sends a mouse wheel event to a source */
1390 EXPORT void obs_source_send_mouse_wheel(obs_source_t *source,
1391 					const struct obs_mouse_event *event,
1392 					int x_delta, int y_delta);
1393 
1394 /** Sends a got-focus or lost-focus event to a source */
1395 EXPORT void obs_source_send_focus(obs_source_t *source, bool focus);
1396 
1397 /** Sends a key up/down event to a source */
1398 EXPORT void obs_source_send_key_click(obs_source_t *source,
1399 				      const struct obs_key_event *event,
1400 				      bool key_up);
1401 
1402 /** Sets the default source flags. */
1403 EXPORT void obs_source_set_default_flags(obs_source_t *source, uint32_t flags);
1404 
1405 /** Gets the base width for a source (not taking in to account filtering) */
1406 EXPORT uint32_t obs_source_get_base_width(obs_source_t *source);
1407 
1408 /** Gets the base height for a source (not taking in to account filtering) */
1409 EXPORT uint32_t obs_source_get_base_height(obs_source_t *source);
1410 
1411 EXPORT bool obs_source_audio_pending(const obs_source_t *source);
1412 EXPORT uint64_t obs_source_get_audio_timestamp(const obs_source_t *source);
1413 EXPORT void obs_source_get_audio_mix(const obs_source_t *source,
1414 				     struct obs_source_audio_mix *audio);
1415 
1416 EXPORT void obs_source_set_async_unbuffered(obs_source_t *source,
1417 					    bool unbuffered);
1418 EXPORT bool obs_source_async_unbuffered(const obs_source_t *source);
1419 
1420 /** Used to decouple audio from video so that audio doesn't attempt to sync up
1421  * with video.  I.E. Audio acts independently.  Only works when in unbuffered
1422  * mode. */
1423 EXPORT void obs_source_set_async_decoupled(obs_source_t *source, bool decouple);
1424 EXPORT bool obs_source_async_decoupled(const obs_source_t *source);
1425 
1426 EXPORT void obs_source_set_audio_active(obs_source_t *source, bool show);
1427 EXPORT bool obs_source_audio_active(const obs_source_t *source);
1428 
1429 EXPORT uint32_t obs_source_get_last_obs_version(const obs_source_t *source);
1430 
1431 /** Media controls */
1432 EXPORT void obs_source_media_play_pause(obs_source_t *source, bool pause);
1433 EXPORT void obs_source_media_restart(obs_source_t *source);
1434 EXPORT void obs_source_media_stop(obs_source_t *source);
1435 EXPORT void obs_source_media_next(obs_source_t *source);
1436 EXPORT void obs_source_media_previous(obs_source_t *source);
1437 EXPORT int64_t obs_source_media_get_duration(obs_source_t *source);
1438 EXPORT int64_t obs_source_media_get_time(obs_source_t *source);
1439 EXPORT void obs_source_media_set_time(obs_source_t *source, int64_t ms);
1440 EXPORT enum obs_media_state obs_source_media_get_state(obs_source_t *source);
1441 EXPORT void obs_source_media_started(obs_source_t *source);
1442 EXPORT void obs_source_media_ended(obs_source_t *source);
1443 
1444 /* ------------------------------------------------------------------------- */
1445 /* Transition-specific functions */
1446 enum obs_transition_target {
1447 	OBS_TRANSITION_SOURCE_A,
1448 	OBS_TRANSITION_SOURCE_B,
1449 };
1450 
1451 EXPORT obs_source_t *
1452 obs_transition_get_source(obs_source_t *transition,
1453 			  enum obs_transition_target target);
1454 EXPORT void obs_transition_clear(obs_source_t *transition);
1455 
1456 EXPORT obs_source_t *obs_transition_get_active_source(obs_source_t *transition);
1457 
1458 enum obs_transition_mode {
1459 	OBS_TRANSITION_MODE_AUTO,
1460 	OBS_TRANSITION_MODE_MANUAL,
1461 };
1462 
1463 EXPORT bool obs_transition_start(obs_source_t *transition,
1464 				 enum obs_transition_mode mode,
1465 				 uint32_t duration_ms, obs_source_t *dest);
1466 
1467 EXPORT void obs_transition_set(obs_source_t *transition, obs_source_t *source);
1468 
1469 EXPORT void obs_transition_set_manual_time(obs_source_t *transition, float t);
1470 EXPORT void obs_transition_set_manual_torque(obs_source_t *transition,
1471 					     float torque, float clamp);
1472 
1473 enum obs_transition_scale_type {
1474 	OBS_TRANSITION_SCALE_MAX_ONLY,
1475 	OBS_TRANSITION_SCALE_ASPECT,
1476 	OBS_TRANSITION_SCALE_STRETCH,
1477 };
1478 
1479 EXPORT void obs_transition_set_scale_type(obs_source_t *transition,
1480 					  enum obs_transition_scale_type type);
1481 EXPORT enum obs_transition_scale_type
1482 obs_transition_get_scale_type(const obs_source_t *transition);
1483 
1484 EXPORT void obs_transition_set_alignment(obs_source_t *transition,
1485 					 uint32_t alignment);
1486 EXPORT uint32_t obs_transition_get_alignment(const obs_source_t *transition);
1487 
1488 EXPORT void obs_transition_set_size(obs_source_t *transition, uint32_t cx,
1489 				    uint32_t cy);
1490 EXPORT void obs_transition_get_size(const obs_source_t *transition,
1491 				    uint32_t *cx, uint32_t *cy);
1492 
1493 /* function used by transitions */
1494 
1495 /**
1496  * Enables fixed transitions (videos or specific types of transitions that
1497  * are of fixed duration and linearly interpolated
1498  */
1499 EXPORT void obs_transition_enable_fixed(obs_source_t *transition, bool enable,
1500 					uint32_t duration_ms);
1501 EXPORT bool obs_transition_fixed(obs_source_t *transition);
1502 
1503 typedef void (*obs_transition_video_render_callback_t)(void *data,
1504 						       gs_texture_t *a,
1505 						       gs_texture_t *b, float t,
1506 						       uint32_t cx,
1507 						       uint32_t cy);
1508 typedef float (*obs_transition_audio_mix_callback_t)(void *data, float t);
1509 
1510 EXPORT float obs_transition_get_time(obs_source_t *transition);
1511 
1512 EXPORT void obs_transition_force_stop(obs_source_t *transition);
1513 
1514 EXPORT void
1515 obs_transition_video_render(obs_source_t *transition,
1516 			    obs_transition_video_render_callback_t callback);
1517 
1518 /** Directly renders its sub-source instead of to texture.  Returns false if no
1519  * longer transitioning */
1520 EXPORT bool
1521 obs_transition_video_render_direct(obs_source_t *transition,
1522 				   enum obs_transition_target target);
1523 
1524 EXPORT bool
1525 obs_transition_audio_render(obs_source_t *transition, uint64_t *ts_out,
1526 			    struct obs_source_audio_mix *audio, uint32_t mixers,
1527 			    size_t channels, size_t sample_rate,
1528 			    obs_transition_audio_mix_callback_t mix_a_callback,
1529 			    obs_transition_audio_mix_callback_t mix_b_callback);
1530 
1531 /* swaps transition sources and textures as an optimization and to reduce
1532  * memory usage when switching between transitions */
1533 EXPORT void obs_transition_swap_begin(obs_source_t *tr_dest,
1534 				      obs_source_t *tr_source);
1535 EXPORT void obs_transition_swap_end(obs_source_t *tr_dest,
1536 				    obs_source_t *tr_source);
1537 
1538 /* ------------------------------------------------------------------------- */
1539 /* Scenes */
1540 
1541 /**
1542  * Creates a scene.
1543  *
1544  *   A scene is a source which is a container of other sources with specific
1545  * display orientations.  Scenes can also be used like any other source.
1546  */
1547 EXPORT obs_scene_t *obs_scene_create(const char *name);
1548 
1549 EXPORT obs_scene_t *obs_scene_create_private(const char *name);
1550 
1551 enum obs_scene_duplicate_type {
1552 	OBS_SCENE_DUP_REFS,         /**< Source refs only */
1553 	OBS_SCENE_DUP_COPY,         /**< Fully duplicate */
1554 	OBS_SCENE_DUP_PRIVATE_REFS, /**< Source refs only (as private) */
1555 	OBS_SCENE_DUP_PRIVATE_COPY, /**< Fully duplicate (as private) */
1556 };
1557 
1558 /**
1559  * Duplicates a scene.
1560  */
1561 EXPORT obs_scene_t *obs_scene_duplicate(obs_scene_t *scene, const char *name,
1562 					enum obs_scene_duplicate_type type);
1563 
1564 EXPORT void obs_scene_addref(obs_scene_t *scene);
1565 EXPORT void obs_scene_release(obs_scene_t *scene);
1566 
1567 /** Gets the scene's source context */
1568 EXPORT obs_source_t *obs_scene_get_source(const obs_scene_t *scene);
1569 
1570 /** Gets the scene from its source, or NULL if not a scene */
1571 EXPORT obs_scene_t *obs_scene_from_source(const obs_source_t *source);
1572 
1573 /** Determines whether a source is within a scene */
1574 EXPORT obs_sceneitem_t *obs_scene_find_source(obs_scene_t *scene,
1575 					      const char *name);
1576 
1577 EXPORT obs_sceneitem_t *obs_scene_find_source_recursive(obs_scene_t *scene,
1578 							const char *name);
1579 
1580 EXPORT obs_sceneitem_t *obs_scene_find_sceneitem_by_id(obs_scene_t *scene,
1581 						       int64_t id);
1582 
1583 /** Gets scene by name, increments the reference */
obs_get_scene_by_name(const char * name)1584 static inline obs_scene_t *obs_get_scene_by_name(const char *name)
1585 {
1586 	obs_source_t *source = obs_get_source_by_name(name);
1587 	obs_scene_t *scene = obs_scene_from_source(source);
1588 	if (!scene) {
1589 		obs_source_release(source);
1590 		return NULL;
1591 	}
1592 	return scene;
1593 }
1594 
1595 /** Enumerates sources within a scene */
1596 EXPORT void obs_scene_enum_items(obs_scene_t *scene,
1597 				 bool (*callback)(obs_scene_t *,
1598 						  obs_sceneitem_t *, void *),
1599 				 void *param);
1600 
1601 EXPORT bool obs_scene_reorder_items(obs_scene_t *scene,
1602 				    obs_sceneitem_t *const *item_order,
1603 				    size_t item_order_size);
1604 
1605 struct obs_sceneitem_order_info {
1606 	obs_sceneitem_t *group;
1607 	obs_sceneitem_t *item;
1608 };
1609 
1610 EXPORT bool
1611 obs_scene_reorder_items2(obs_scene_t *scene,
1612 			 struct obs_sceneitem_order_info *item_order,
1613 			 size_t item_order_size);
1614 
1615 EXPORT bool obs_source_is_scene(const obs_source_t *source);
1616 
1617 /** Adds/creates a new scene item for a source */
1618 EXPORT obs_sceneitem_t *obs_scene_add(obs_scene_t *scene, obs_source_t *source);
1619 
1620 typedef void (*obs_scene_atomic_update_func)(void *, obs_scene_t *scene);
1621 EXPORT void obs_scene_atomic_update(obs_scene_t *scene,
1622 				    obs_scene_atomic_update_func func,
1623 				    void *data);
1624 
1625 EXPORT void obs_sceneitem_addref(obs_sceneitem_t *item);
1626 EXPORT void obs_sceneitem_release(obs_sceneitem_t *item);
1627 
1628 /** Removes a scene item. */
1629 EXPORT void obs_sceneitem_remove(obs_sceneitem_t *item);
1630 
1631 /** Adds a scene item. */
1632 EXPORT void obs_sceneitems_add(obs_scene_t *scene, obs_data_array_t *data);
1633 
1634 /** Saves Sceneitem into an array, arr **/
1635 EXPORT void obs_sceneitem_save(obs_sceneitem_t *item, obs_data_array_t *arr);
1636 
1637 /** Set the ID of a sceneitem */
1638 EXPORT void obs_sceneitem_set_id(obs_sceneitem_t *sceneitem, int64_t id);
1639 
1640 /** Tries to find the sceneitem of the source in a given scene. Returns NULL if not found */
1641 EXPORT obs_sceneitem_t *obs_scene_sceneitem_from_source(obs_scene_t *scene,
1642 							obs_source_t *source);
1643 
1644 /** Save all the transform states for a current scene's sceneitems */
1645 EXPORT obs_data_t *obs_scene_save_transform_states(obs_scene_t *scene,
1646 						   bool all_items);
1647 
1648 /** Load all the transform states of sceneitems in that scene */
1649 EXPORT void obs_scene_load_transform_states(const char *state);
1650 
1651 /**  Gets a sceneitem's order in its scene */
1652 EXPORT int obs_sceneitem_get_order_position(obs_sceneitem_t *item);
1653 
1654 /** Gets the scene parent associated with the scene item. */
1655 EXPORT obs_scene_t *obs_sceneitem_get_scene(const obs_sceneitem_t *item);
1656 
1657 /** Gets the source of a scene item. */
1658 EXPORT obs_source_t *obs_sceneitem_get_source(const obs_sceneitem_t *item);
1659 
1660 /* FIXME: The following functions should be deprecated and replaced with a way
1661  * to specify saveable private user data. -Jim */
1662 EXPORT void obs_sceneitem_select(obs_sceneitem_t *item, bool select);
1663 EXPORT bool obs_sceneitem_selected(const obs_sceneitem_t *item);
1664 EXPORT bool obs_sceneitem_locked(const obs_sceneitem_t *item);
1665 EXPORT bool obs_sceneitem_set_locked(obs_sceneitem_t *item, bool lock);
1666 
1667 /* Functions for getting/setting specific orientation of a scene item */
1668 EXPORT void obs_sceneitem_set_pos(obs_sceneitem_t *item,
1669 				  const struct vec2 *pos);
1670 EXPORT void obs_sceneitem_set_rot(obs_sceneitem_t *item, float rot_deg);
1671 EXPORT void obs_sceneitem_set_scale(obs_sceneitem_t *item,
1672 				    const struct vec2 *scale);
1673 EXPORT void obs_sceneitem_set_alignment(obs_sceneitem_t *item,
1674 					uint32_t alignment);
1675 EXPORT void obs_sceneitem_set_order(obs_sceneitem_t *item,
1676 				    enum obs_order_movement movement);
1677 EXPORT void obs_sceneitem_set_order_position(obs_sceneitem_t *item,
1678 					     int position);
1679 EXPORT void obs_sceneitem_set_bounds_type(obs_sceneitem_t *item,
1680 					  enum obs_bounds_type type);
1681 EXPORT void obs_sceneitem_set_bounds_alignment(obs_sceneitem_t *item,
1682 					       uint32_t alignment);
1683 EXPORT void obs_sceneitem_set_bounds(obs_sceneitem_t *item,
1684 				     const struct vec2 *bounds);
1685 
1686 EXPORT int64_t obs_sceneitem_get_id(const obs_sceneitem_t *item);
1687 
1688 EXPORT void obs_sceneitem_get_pos(const obs_sceneitem_t *item,
1689 				  struct vec2 *pos);
1690 EXPORT float obs_sceneitem_get_rot(const obs_sceneitem_t *item);
1691 EXPORT void obs_sceneitem_get_scale(const obs_sceneitem_t *item,
1692 				    struct vec2 *scale);
1693 EXPORT uint32_t obs_sceneitem_get_alignment(const obs_sceneitem_t *item);
1694 
1695 EXPORT enum obs_bounds_type
1696 obs_sceneitem_get_bounds_type(const obs_sceneitem_t *item);
1697 EXPORT uint32_t obs_sceneitem_get_bounds_alignment(const obs_sceneitem_t *item);
1698 EXPORT void obs_sceneitem_get_bounds(const obs_sceneitem_t *item,
1699 				     struct vec2 *bounds);
1700 
1701 EXPORT void obs_sceneitem_get_info(const obs_sceneitem_t *item,
1702 				   struct obs_transform_info *info);
1703 EXPORT void obs_sceneitem_set_info(obs_sceneitem_t *item,
1704 				   const struct obs_transform_info *info);
1705 
1706 EXPORT void obs_sceneitem_get_draw_transform(const obs_sceneitem_t *item,
1707 					     struct matrix4 *transform);
1708 EXPORT void obs_sceneitem_get_box_transform(const obs_sceneitem_t *item,
1709 					    struct matrix4 *transform);
1710 EXPORT void obs_sceneitem_get_box_scale(const obs_sceneitem_t *item,
1711 					struct vec2 *scale);
1712 
1713 EXPORT bool obs_sceneitem_visible(const obs_sceneitem_t *item);
1714 EXPORT bool obs_sceneitem_set_visible(obs_sceneitem_t *item, bool visible);
1715 
1716 struct obs_sceneitem_crop {
1717 	int left;
1718 	int top;
1719 	int right;
1720 	int bottom;
1721 };
1722 
1723 EXPORT void obs_sceneitem_set_crop(obs_sceneitem_t *item,
1724 				   const struct obs_sceneitem_crop *crop);
1725 EXPORT void obs_sceneitem_get_crop(const obs_sceneitem_t *item,
1726 				   struct obs_sceneitem_crop *crop);
1727 
1728 EXPORT void obs_sceneitem_set_scale_filter(obs_sceneitem_t *item,
1729 					   enum obs_scale_type filter);
1730 EXPORT enum obs_scale_type
1731 obs_sceneitem_get_scale_filter(obs_sceneitem_t *item);
1732 
1733 EXPORT void obs_sceneitem_force_update_transform(obs_sceneitem_t *item);
1734 
1735 EXPORT void obs_sceneitem_defer_update_begin(obs_sceneitem_t *item);
1736 EXPORT void obs_sceneitem_defer_update_end(obs_sceneitem_t *item);
1737 
1738 /** Gets private front-end settings data.  This data is saved/loaded
1739  * automatically.  Returns an incremented reference. */
1740 EXPORT obs_data_t *obs_sceneitem_get_private_settings(obs_sceneitem_t *item);
1741 
1742 EXPORT obs_sceneitem_t *obs_scene_add_group(obs_scene_t *scene,
1743 					    const char *name);
1744 EXPORT obs_sceneitem_t *obs_scene_insert_group(obs_scene_t *scene,
1745 					       const char *name,
1746 					       obs_sceneitem_t **items,
1747 					       size_t count);
1748 
1749 EXPORT obs_sceneitem_t *obs_scene_add_group2(obs_scene_t *scene,
1750 					     const char *name, bool signal);
1751 EXPORT obs_sceneitem_t *obs_scene_insert_group2(obs_scene_t *scene,
1752 						const char *name,
1753 						obs_sceneitem_t **items,
1754 						size_t count, bool signal);
1755 
1756 EXPORT obs_sceneitem_t *obs_scene_get_group(obs_scene_t *scene,
1757 					    const char *name);
1758 
1759 EXPORT bool obs_sceneitem_is_group(obs_sceneitem_t *item);
1760 
1761 EXPORT obs_scene_t *obs_sceneitem_group_get_scene(const obs_sceneitem_t *group);
1762 
1763 EXPORT void obs_sceneitem_group_ungroup(obs_sceneitem_t *group);
1764 EXPORT void obs_sceneitem_group_ungroup2(obs_sceneitem_t *group, bool signal);
1765 
1766 EXPORT void obs_sceneitem_group_add_item(obs_sceneitem_t *group,
1767 					 obs_sceneitem_t *item);
1768 EXPORT void obs_sceneitem_group_remove_item(obs_sceneitem_t *group,
1769 					    obs_sceneitem_t *item);
1770 
1771 EXPORT obs_sceneitem_t *obs_sceneitem_get_group(obs_scene_t *scene,
1772 						obs_sceneitem_t *item);
1773 
1774 EXPORT bool obs_source_is_group(const obs_source_t *source);
1775 EXPORT bool obs_scene_is_group(const obs_scene_t *scene);
1776 
1777 EXPORT void obs_sceneitem_group_enum_items(obs_sceneitem_t *group,
1778 					   bool (*callback)(obs_scene_t *,
1779 							    obs_sceneitem_t *,
1780 							    void *),
1781 					   void *param);
1782 
1783 /** Gets the group from its source, or NULL if not a group */
1784 EXPORT obs_scene_t *obs_group_from_source(const obs_source_t *source);
1785 
1786 static inline obs_scene_t *
obs_group_or_scene_from_source(const obs_source_t * source)1787 obs_group_or_scene_from_source(const obs_source_t *source)
1788 {
1789 	obs_scene_t *s = obs_scene_from_source(source);
1790 	return s ? s : obs_group_from_source(source);
1791 }
1792 
1793 EXPORT void obs_sceneitem_defer_group_resize_begin(obs_sceneitem_t *item);
1794 EXPORT void obs_sceneitem_defer_group_resize_end(obs_sceneitem_t *item);
1795 
1796 EXPORT void obs_sceneitem_set_show_transition(obs_sceneitem_t *item,
1797 					      obs_source_t *transition);
1798 EXPORT void obs_sceneitem_set_show_transition_duration(obs_sceneitem_t *item,
1799 						       uint32_t duration_ms);
1800 EXPORT obs_source_t *obs_sceneitem_get_show_transition(obs_sceneitem_t *item);
1801 EXPORT uint32_t
1802 obs_sceneitem_get_show_transition_duration(obs_sceneitem_t *item);
1803 EXPORT void obs_sceneitem_set_hide_transition(obs_sceneitem_t *item,
1804 					      obs_source_t *transition);
1805 EXPORT void obs_sceneitem_set_hide_transition_duration(obs_sceneitem_t *item,
1806 						       uint32_t duration_ms);
1807 EXPORT obs_source_t *obs_sceneitem_get_hide_transition(obs_sceneitem_t *item);
1808 EXPORT uint32_t
1809 obs_sceneitem_get_hide_transition_duration(obs_sceneitem_t *item);
1810 EXPORT void obs_sceneitem_do_transition(obs_sceneitem_t *item, bool visible);
1811 EXPORT void obs_sceneitem_transition_load(struct obs_scene_item *item,
1812 					  obs_data_t *data, bool show);
1813 EXPORT obs_data_t *obs_sceneitem_transition_save(struct obs_scene_item *item,
1814 						 bool show);
1815 
1816 /* ------------------------------------------------------------------------- */
1817 /* Outputs */
1818 
1819 EXPORT const char *obs_output_get_display_name(const char *id);
1820 
1821 /**
1822  * Creates an output.
1823  *
1824  *   Outputs allow outputting to file, outputting to network, outputting to
1825  * directshow, or other custom outputs.
1826  */
1827 EXPORT obs_output_t *obs_output_create(const char *id, const char *name,
1828 				       obs_data_t *settings,
1829 				       obs_data_t *hotkey_data);
1830 
1831 /**
1832  * Adds/releases a reference to an output.  When the last reference is
1833  * released, the output is destroyed.
1834  */
1835 EXPORT void obs_output_addref(obs_output_t *output);
1836 EXPORT void obs_output_release(obs_output_t *output);
1837 
1838 EXPORT void obs_weak_output_addref(obs_weak_output_t *weak);
1839 EXPORT void obs_weak_output_release(obs_weak_output_t *weak);
1840 
1841 EXPORT obs_output_t *obs_output_get_ref(obs_output_t *output);
1842 EXPORT obs_weak_output_t *obs_output_get_weak_output(obs_output_t *output);
1843 EXPORT obs_output_t *obs_weak_output_get_output(obs_weak_output_t *weak);
1844 
1845 EXPORT bool obs_weak_output_references_output(obs_weak_output_t *weak,
1846 					      obs_output_t *output);
1847 
1848 EXPORT const char *obs_output_get_name(const obs_output_t *output);
1849 
1850 /** Starts the output. */
1851 EXPORT bool obs_output_start(obs_output_t *output);
1852 
1853 /** Stops the output. */
1854 EXPORT void obs_output_stop(obs_output_t *output);
1855 
1856 /**
1857  * On reconnection, start where it left of on reconnection.  Note however that
1858  * this option will consume extra memory to continually increase delay while
1859  * waiting to reconnect.
1860  */
1861 #define OBS_OUTPUT_DELAY_PRESERVE (1 << 0)
1862 
1863 /**
1864  * Sets the current output delay, in seconds (if the output supports delay).
1865  *
1866  * If delay is currently active, it will set the delay value, but will not
1867  * affect the current delay, it will only affect the next time the output is
1868  * activated.
1869  */
1870 EXPORT void obs_output_set_delay(obs_output_t *output, uint32_t delay_sec,
1871 				 uint32_t flags);
1872 
1873 /** Gets the currently set delay value, in seconds. */
1874 EXPORT uint32_t obs_output_get_delay(const obs_output_t *output);
1875 
1876 /** If delay is active, gets the currently active delay value, in seconds. */
1877 EXPORT uint32_t obs_output_get_active_delay(const obs_output_t *output);
1878 
1879 /** Forces the output to stop.  Usually only used with delay. */
1880 EXPORT void obs_output_force_stop(obs_output_t *output);
1881 
1882 /** Returns whether the output is active */
1883 EXPORT bool obs_output_active(const obs_output_t *output);
1884 
1885 /** Returns output capability flags */
1886 EXPORT uint32_t obs_output_get_flags(const obs_output_t *output);
1887 
1888 /** Returns output capability flags */
1889 EXPORT uint32_t obs_get_output_flags(const char *id);
1890 
1891 /** Gets the default settings for an output type */
1892 EXPORT obs_data_t *obs_output_defaults(const char *id);
1893 
1894 /** Returns the property list, if any.  Free with obs_properties_destroy */
1895 EXPORT obs_properties_t *obs_get_output_properties(const char *id);
1896 
1897 /**
1898  * Returns the property list of an existing output, if any.  Free with
1899  * obs_properties_destroy
1900  */
1901 EXPORT obs_properties_t *obs_output_properties(const obs_output_t *output);
1902 
1903 /** Updates the settings for this output context */
1904 EXPORT void obs_output_update(obs_output_t *output, obs_data_t *settings);
1905 
1906 /** Specifies whether the output can be paused */
1907 EXPORT bool obs_output_can_pause(const obs_output_t *output);
1908 
1909 /** Pauses the output (if the functionality is allowed by the output */
1910 EXPORT bool obs_output_pause(obs_output_t *output, bool pause);
1911 
1912 /** Returns whether output is paused */
1913 EXPORT bool obs_output_paused(const obs_output_t *output);
1914 
1915 /* Gets the current output settings string */
1916 EXPORT obs_data_t *obs_output_get_settings(const obs_output_t *output);
1917 
1918 /** Returns the signal handler for an output  */
1919 EXPORT signal_handler_t *
1920 obs_output_get_signal_handler(const obs_output_t *output);
1921 
1922 /** Returns the procedure handler for an output */
1923 EXPORT proc_handler_t *obs_output_get_proc_handler(const obs_output_t *output);
1924 
1925 /**
1926  * Sets the current audio/video media contexts associated with this output,
1927  * required for non-encoded outputs.  Can be null.
1928  */
1929 EXPORT void obs_output_set_media(obs_output_t *output, video_t *video,
1930 				 audio_t *audio);
1931 
1932 /** Returns the video media context associated with this output */
1933 EXPORT video_t *obs_output_video(const obs_output_t *output);
1934 
1935 /** Returns the audio media context associated with this output */
1936 EXPORT audio_t *obs_output_audio(const obs_output_t *output);
1937 
1938 /** Sets the current audio mixer for non-encoded outputs */
1939 EXPORT void obs_output_set_mixer(obs_output_t *output, size_t mixer_idx);
1940 
1941 /** Gets the current audio mixer for non-encoded outputs */
1942 EXPORT size_t obs_output_get_mixer(const obs_output_t *output);
1943 
1944 /** Sets the current audio mixes (mask) for a non-encoded multi-track output */
1945 EXPORT void obs_output_set_mixers(obs_output_t *output, size_t mixers);
1946 
1947 /** Gets the current audio mixes (mask) for a non-encoded multi-track output */
1948 EXPORT size_t obs_output_get_mixers(const obs_output_t *output);
1949 
1950 /**
1951  * Sets the current video encoder associated with this output,
1952  * required for encoded outputs
1953  */
1954 EXPORT void obs_output_set_video_encoder(obs_output_t *output,
1955 					 obs_encoder_t *encoder);
1956 
1957 /**
1958  * Sets the current audio encoder associated with this output,
1959  * required for encoded outputs.
1960  *
1961  * The idx parameter specifies the audio encoder index to set the encoder to.
1962  * Only used with outputs that have multiple audio outputs (RTMP typically),
1963  * otherwise the parameter is ignored.
1964  */
1965 EXPORT void obs_output_set_audio_encoder(obs_output_t *output,
1966 					 obs_encoder_t *encoder, size_t idx);
1967 
1968 /** Returns the current video encoder associated with this output */
1969 EXPORT obs_encoder_t *obs_output_get_video_encoder(const obs_output_t *output);
1970 
1971 /**
1972  * Returns the current audio encoder associated with this output
1973  *
1974  * The idx parameter specifies the audio encoder index.  Only used with
1975  * outputs that have multiple audio outputs, otherwise the parameter is
1976  * ignored.
1977  */
1978 EXPORT obs_encoder_t *obs_output_get_audio_encoder(const obs_output_t *output,
1979 						   size_t idx);
1980 
1981 /** Sets the current service associated with this output. */
1982 EXPORT void obs_output_set_service(obs_output_t *output,
1983 				   obs_service_t *service);
1984 
1985 /** Gets the current service associated with this output. */
1986 EXPORT obs_service_t *obs_output_get_service(const obs_output_t *output);
1987 
1988 /**
1989  * Sets the reconnect settings.  Set retry_count to 0 to disable reconnecting.
1990  */
1991 EXPORT void obs_output_set_reconnect_settings(obs_output_t *output,
1992 					      int retry_count, int retry_sec);
1993 
1994 EXPORT uint64_t obs_output_get_total_bytes(const obs_output_t *output);
1995 EXPORT int obs_output_get_frames_dropped(const obs_output_t *output);
1996 EXPORT int obs_output_get_total_frames(const obs_output_t *output);
1997 
1998 /**
1999  * Sets the preferred scaled resolution for this output.  Set width and height
2000  * to 0 to disable scaling.
2001  *
2002  * If this output uses an encoder, it will call obs_encoder_set_scaled_size on
2003  * the encoder before the stream is started.  If the encoder is already active,
2004  * then this function will trigger a warning and do nothing.
2005  */
2006 EXPORT void obs_output_set_preferred_size(obs_output_t *output, uint32_t width,
2007 					  uint32_t height);
2008 
2009 /** For video outputs, returns the width of the encoded image */
2010 EXPORT uint32_t obs_output_get_width(const obs_output_t *output);
2011 
2012 /** For video outputs, returns the height of the encoded image */
2013 EXPORT uint32_t obs_output_get_height(const obs_output_t *output);
2014 
2015 EXPORT const char *obs_output_get_id(const obs_output_t *output);
2016 
2017 EXPORT void obs_output_caption(obs_output_t *output,
2018 			       const struct obs_source_cea_708 *captions);
2019 
2020 EXPORT void obs_output_output_caption_text1(obs_output_t *output,
2021 					    const char *text);
2022 EXPORT void obs_output_output_caption_text2(obs_output_t *output,
2023 					    const char *text,
2024 					    double display_duration);
2025 
2026 EXPORT float obs_output_get_congestion(obs_output_t *output);
2027 EXPORT int obs_output_get_connect_time_ms(obs_output_t *output);
2028 
2029 EXPORT bool obs_output_reconnecting(const obs_output_t *output);
2030 
2031 /** Pass a string of the last output error, for UI use */
2032 EXPORT void obs_output_set_last_error(obs_output_t *output,
2033 				      const char *message);
2034 EXPORT const char *obs_output_get_last_error(obs_output_t *output);
2035 
2036 EXPORT const char *
2037 obs_output_get_supported_video_codecs(const obs_output_t *output);
2038 EXPORT const char *
2039 obs_output_get_supported_audio_codecs(const obs_output_t *output);
2040 
2041 /* ------------------------------------------------------------------------- */
2042 /* Functions used by outputs */
2043 
2044 EXPORT void *obs_output_get_type_data(obs_output_t *output);
2045 
2046 /** Optionally sets the video conversion info.  Used only for raw output */
2047 EXPORT void
2048 obs_output_set_video_conversion(obs_output_t *output,
2049 				const struct video_scale_info *conversion);
2050 
2051 /** Optionally sets the audio conversion info.  Used only for raw output */
2052 EXPORT void
2053 obs_output_set_audio_conversion(obs_output_t *output,
2054 				const struct audio_convert_info *conversion);
2055 
2056 /** Returns whether data capture can begin with the specified flags */
2057 EXPORT bool obs_output_can_begin_data_capture(const obs_output_t *output,
2058 					      uint32_t flags);
2059 
2060 /** Initializes encoders (if any) */
2061 EXPORT bool obs_output_initialize_encoders(obs_output_t *output,
2062 					   uint32_t flags);
2063 
2064 /**
2065  * Begins data capture from media/encoders.
2066  *
2067  * @param  output  Output context
2068  * @param  flags   Set this to 0 to use default output flags set in the
2069  *                 obs_output_info structure, otherwise set to a either
2070  *                 OBS_OUTPUT_VIDEO or OBS_OUTPUT_AUDIO to specify whether to
2071  *                 connect audio or video.  This is useful for things like
2072  *                 ffmpeg which may or may not always want to use both audio
2073  *                 and video.
2074  * @return         true if successful, false otherwise.
2075  */
2076 EXPORT bool obs_output_begin_data_capture(obs_output_t *output, uint32_t flags);
2077 
2078 /** Ends data capture from media/encoders */
2079 EXPORT void obs_output_end_data_capture(obs_output_t *output);
2080 
2081 /**
2082  * Signals that the output has stopped itself.
2083  *
2084  * @param  output  Output context
2085  * @param  code    Error code (or OBS_OUTPUT_SUCCESS if not an error)
2086  */
2087 EXPORT void obs_output_signal_stop(obs_output_t *output, int code);
2088 
2089 EXPORT uint64_t obs_output_get_pause_offset(obs_output_t *output);
2090 
2091 /* ------------------------------------------------------------------------- */
2092 /* Encoders */
2093 
2094 EXPORT const char *obs_encoder_get_display_name(const char *id);
2095 
2096 /**
2097  * Creates a video encoder context
2098  *
2099  * @param  id        Video encoder ID
2100  * @param  name      Name to assign to this context
2101  * @param  settings  Settings
2102  * @return           The video encoder context, or NULL if failed or not found.
2103  */
2104 EXPORT obs_encoder_t *obs_video_encoder_create(const char *id, const char *name,
2105 					       obs_data_t *settings,
2106 					       obs_data_t *hotkey_data);
2107 
2108 /**
2109  * Creates an audio encoder context
2110  *
2111  * @param  id        Audio Encoder ID
2112  * @param  name      Name to assign to this context
2113  * @param  settings  Settings
2114  * @param  mixer_idx Index of the mixer to use for this audio encoder
2115  * @return           The video encoder context, or NULL if failed or not found.
2116  */
2117 EXPORT obs_encoder_t *obs_audio_encoder_create(const char *id, const char *name,
2118 					       obs_data_t *settings,
2119 					       size_t mixer_idx,
2120 					       obs_data_t *hotkey_data);
2121 
2122 /**
2123  * Adds/releases a reference to an encoder.  When the last reference is
2124  * released, the encoder is destroyed.
2125  */
2126 EXPORT void obs_encoder_addref(obs_encoder_t *encoder);
2127 EXPORT void obs_encoder_release(obs_encoder_t *encoder);
2128 
2129 EXPORT void obs_weak_encoder_addref(obs_weak_encoder_t *weak);
2130 EXPORT void obs_weak_encoder_release(obs_weak_encoder_t *weak);
2131 
2132 EXPORT obs_encoder_t *obs_encoder_get_ref(obs_encoder_t *encoder);
2133 EXPORT obs_weak_encoder_t *obs_encoder_get_weak_encoder(obs_encoder_t *encoder);
2134 EXPORT obs_encoder_t *obs_weak_encoder_get_encoder(obs_weak_encoder_t *weak);
2135 
2136 EXPORT bool obs_weak_encoder_references_encoder(obs_weak_encoder_t *weak,
2137 						obs_encoder_t *encoder);
2138 
2139 EXPORT void obs_encoder_set_name(obs_encoder_t *encoder, const char *name);
2140 EXPORT const char *obs_encoder_get_name(const obs_encoder_t *encoder);
2141 
2142 /** Returns the codec of an encoder by the id */
2143 EXPORT const char *obs_get_encoder_codec(const char *id);
2144 
2145 /** Returns the type of an encoder by the id */
2146 EXPORT enum obs_encoder_type obs_get_encoder_type(const char *id);
2147 
2148 /** Returns the codec of the encoder */
2149 EXPORT const char *obs_encoder_get_codec(const obs_encoder_t *encoder);
2150 
2151 /** Returns the type of an encoder */
2152 EXPORT enum obs_encoder_type obs_encoder_get_type(const obs_encoder_t *encoder);
2153 
2154 /**
2155  * Sets the scaled resolution for a video encoder.  Set width and height to 0
2156  * to disable scaling.  If the encoder is active, this function will trigger
2157  * a warning, and do nothing.
2158  */
2159 EXPORT void obs_encoder_set_scaled_size(obs_encoder_t *encoder, uint32_t width,
2160 					uint32_t height);
2161 
2162 /** For video encoders, returns true if pre-encode scaling is enabled */
2163 EXPORT bool obs_encoder_scaling_enabled(const obs_encoder_t *encoder);
2164 
2165 /** For video encoders, returns the width of the encoded image */
2166 EXPORT uint32_t obs_encoder_get_width(const obs_encoder_t *encoder);
2167 
2168 /** For video encoders, returns the height of the encoded image */
2169 EXPORT uint32_t obs_encoder_get_height(const obs_encoder_t *encoder);
2170 
2171 /** For audio encoders, returns the sample rate of the audio */
2172 EXPORT uint32_t obs_encoder_get_sample_rate(const obs_encoder_t *encoder);
2173 
2174 /**
2175  * Sets the preferred video format for a video encoder.  If the encoder can use
2176  * the format specified, it will force a conversion to that format if the
2177  * obs output format does not match the preferred format.
2178  *
2179  * If the format is set to VIDEO_FORMAT_NONE, will revert to the default
2180  * functionality of converting only when absolutely necessary.
2181  */
2182 EXPORT void obs_encoder_set_preferred_video_format(obs_encoder_t *encoder,
2183 						   enum video_format format);
2184 EXPORT enum video_format
2185 obs_encoder_get_preferred_video_format(const obs_encoder_t *encoder);
2186 
2187 /** Gets the default settings for an encoder type */
2188 EXPORT obs_data_t *obs_encoder_defaults(const char *id);
2189 EXPORT obs_data_t *obs_encoder_get_defaults(const obs_encoder_t *encoder);
2190 
2191 /** Returns the property list, if any.  Free with obs_properties_destroy */
2192 EXPORT obs_properties_t *obs_get_encoder_properties(const char *id);
2193 
2194 /**
2195  * Returns the property list of an existing encoder, if any.  Free with
2196  * obs_properties_destroy
2197  */
2198 EXPORT obs_properties_t *obs_encoder_properties(const obs_encoder_t *encoder);
2199 
2200 /**
2201  * Updates the settings of the encoder context.  Usually used for changing
2202  * bitrate while active
2203  */
2204 EXPORT void obs_encoder_update(obs_encoder_t *encoder, obs_data_t *settings);
2205 
2206 /** Gets extra data (headers) associated with this context */
2207 EXPORT bool obs_encoder_get_extra_data(const obs_encoder_t *encoder,
2208 				       uint8_t **extra_data, size_t *size);
2209 
2210 /** Returns the current settings for this encoder */
2211 EXPORT obs_data_t *obs_encoder_get_settings(const obs_encoder_t *encoder);
2212 
2213 /** Sets the video output context to be used with this encoder */
2214 EXPORT void obs_encoder_set_video(obs_encoder_t *encoder, video_t *video);
2215 
2216 /** Sets the audio output context to be used with this encoder */
2217 EXPORT void obs_encoder_set_audio(obs_encoder_t *encoder, audio_t *audio);
2218 
2219 /**
2220  * Returns the video output context used with this encoder, or NULL if not
2221  * a video context
2222  */
2223 EXPORT video_t *obs_encoder_video(const obs_encoder_t *encoder);
2224 
2225 /**
2226  * Returns the audio output context used with this encoder, or NULL if not
2227  * a audio context
2228  */
2229 EXPORT audio_t *obs_encoder_audio(const obs_encoder_t *encoder);
2230 
2231 /** Returns true if encoder is active, false otherwise */
2232 EXPORT bool obs_encoder_active(const obs_encoder_t *encoder);
2233 
2234 EXPORT void *obs_encoder_get_type_data(obs_encoder_t *encoder);
2235 
2236 EXPORT const char *obs_encoder_get_id(const obs_encoder_t *encoder);
2237 
2238 EXPORT uint32_t obs_get_encoder_caps(const char *encoder_id);
2239 EXPORT uint32_t obs_encoder_get_caps(const obs_encoder_t *encoder);
2240 
2241 #ifndef SWIG
2242 /** Duplicates an encoder packet */
2243 OBS_DEPRECATED
2244 EXPORT void obs_duplicate_encoder_packet(struct encoder_packet *dst,
2245 					 const struct encoder_packet *src);
2246 
2247 OBS_DEPRECATED
2248 EXPORT void obs_free_encoder_packet(struct encoder_packet *packet);
2249 #endif
2250 
2251 EXPORT void obs_encoder_packet_ref(struct encoder_packet *dst,
2252 				   struct encoder_packet *src);
2253 EXPORT void obs_encoder_packet_release(struct encoder_packet *packet);
2254 
2255 EXPORT void *obs_encoder_create_rerouted(obs_encoder_t *encoder,
2256 					 const char *reroute_id);
2257 
2258 /** Returns whether encoder is paused */
2259 EXPORT bool obs_encoder_paused(const obs_encoder_t *output);
2260 
2261 EXPORT const char *obs_encoder_get_last_error(obs_encoder_t *encoder);
2262 EXPORT void obs_encoder_set_last_error(obs_encoder_t *encoder,
2263 				       const char *message);
2264 
2265 /* ------------------------------------------------------------------------- */
2266 /* Stream Services */
2267 
2268 EXPORT const char *obs_service_get_display_name(const char *id);
2269 
2270 EXPORT obs_service_t *obs_service_create(const char *id, const char *name,
2271 					 obs_data_t *settings,
2272 					 obs_data_t *hotkey_data);
2273 
2274 EXPORT obs_service_t *obs_service_create_private(const char *id,
2275 						 const char *name,
2276 						 obs_data_t *settings);
2277 
2278 /**
2279  * Adds/releases a reference to a service.  When the last reference is
2280  * released, the service is destroyed.
2281  */
2282 EXPORT void obs_service_addref(obs_service_t *service);
2283 EXPORT void obs_service_release(obs_service_t *service);
2284 
2285 EXPORT void obs_weak_service_addref(obs_weak_service_t *weak);
2286 EXPORT void obs_weak_service_release(obs_weak_service_t *weak);
2287 
2288 EXPORT obs_service_t *obs_service_get_ref(obs_service_t *service);
2289 EXPORT obs_weak_service_t *obs_service_get_weak_service(obs_service_t *service);
2290 EXPORT obs_service_t *obs_weak_service_get_service(obs_weak_service_t *weak);
2291 
2292 EXPORT bool obs_weak_service_references_service(obs_weak_service_t *weak,
2293 						obs_service_t *service);
2294 
2295 EXPORT const char *obs_service_get_name(const obs_service_t *service);
2296 
2297 /** Gets the default settings for a service */
2298 EXPORT obs_data_t *obs_service_defaults(const char *id);
2299 
2300 /** Returns the property list, if any.  Free with obs_properties_destroy */
2301 EXPORT obs_properties_t *obs_get_service_properties(const char *id);
2302 
2303 /**
2304  * Returns the property list of an existing service context, if any.  Free with
2305  * obs_properties_destroy
2306  */
2307 EXPORT obs_properties_t *obs_service_properties(const obs_service_t *service);
2308 
2309 /** Gets the service type */
2310 EXPORT const char *obs_service_get_type(const obs_service_t *service);
2311 
2312 /** Updates the settings of the service context */
2313 EXPORT void obs_service_update(obs_service_t *service, obs_data_t *settings);
2314 
2315 /** Returns the current settings for this service */
2316 EXPORT obs_data_t *obs_service_get_settings(const obs_service_t *service);
2317 
2318 /** Returns the URL for this service context */
2319 EXPORT const char *obs_service_get_url(const obs_service_t *service);
2320 
2321 /** Returns the stream key (if any) for this service context */
2322 EXPORT const char *obs_service_get_key(const obs_service_t *service);
2323 
2324 /** Returns the username (if any) for this service context */
2325 EXPORT const char *obs_service_get_username(const obs_service_t *service);
2326 
2327 /** Returns the password (if any) for this service context */
2328 EXPORT const char *obs_service_get_password(const obs_service_t *service);
2329 
2330 /**
2331  * Applies service-specific video encoder settings.
2332  *
2333  * @param  video_encoder_settings  Video encoder settings.  Optional.
2334  * @param  audio_encoder_settings  Audio encoder settings.  Optional.
2335  */
2336 EXPORT void
2337 obs_service_apply_encoder_settings(obs_service_t *service,
2338 				   obs_data_t *video_encoder_settings,
2339 				   obs_data_t *audio_encoder_settings);
2340 
2341 EXPORT void *obs_service_get_type_data(obs_service_t *service);
2342 
2343 EXPORT const char *obs_service_get_id(const obs_service_t *service);
2344 
2345 EXPORT void obs_service_get_supported_resolutions(
2346 	const obs_service_t *service,
2347 	struct obs_service_resolution **resolutions, size_t *count);
2348 EXPORT void obs_service_get_max_fps(const obs_service_t *service, int *fps);
2349 
2350 EXPORT void obs_service_get_max_bitrate(const obs_service_t *service,
2351 					int *video_bitrate, int *audio_bitrate);
2352 
2353 /* NOTE: This function is temporary and should be removed/replaced at a later
2354  * date. */
2355 EXPORT const char *obs_service_get_output_type(const obs_service_t *service);
2356 
2357 /* ------------------------------------------------------------------------- */
2358 /* Source frame allocation functions */
2359 EXPORT void obs_source_frame_init(struct obs_source_frame *frame,
2360 				  enum video_format format, uint32_t width,
2361 				  uint32_t height);
2362 
obs_source_frame_free(struct obs_source_frame * frame)2363 static inline void obs_source_frame_free(struct obs_source_frame *frame)
2364 {
2365 	if (frame) {
2366 		bfree(frame->data[0]);
2367 		memset(frame, 0, sizeof(*frame));
2368 	}
2369 }
2370 
2371 static inline struct obs_source_frame *
obs_source_frame_create(enum video_format format,uint32_t width,uint32_t height)2372 obs_source_frame_create(enum video_format format, uint32_t width,
2373 			uint32_t height)
2374 {
2375 	struct obs_source_frame *frame;
2376 
2377 	frame = (struct obs_source_frame *)bzalloc(sizeof(*frame));
2378 	obs_source_frame_init(frame, format, width, height);
2379 	return frame;
2380 }
2381 
obs_source_frame_destroy(struct obs_source_frame * frame)2382 static inline void obs_source_frame_destroy(struct obs_source_frame *frame)
2383 {
2384 	if (frame) {
2385 		bfree(frame->data[0]);
2386 		bfree(frame);
2387 	}
2388 }
2389 
2390 EXPORT void obs_source_frame_copy(struct obs_source_frame *dst,
2391 				  const struct obs_source_frame *src);
2392 
2393 /* ------------------------------------------------------------------------- */
2394 /* Get source icon type */
2395 EXPORT enum obs_icon_type obs_source_get_icon_type(const char *id);
2396 
2397 #ifdef __cplusplus
2398 }
2399 #endif
2400