obs.h 105 KB

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