reference-core.rst 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  1. OBS Core API Reference
  2. ======================
  3. .. code:: cpp
  4. #include <obs.h>
  5. .. _obs_init_shutdown_reference:
  6. Initialization, Shutdown, and Information
  7. -----------------------------------------
  8. .. function:: bool obs_startup(const char *locale, const char *module_config_path, profiler_name_store_t *store)
  9. Initializes the OBS core context.
  10. :param locale: The locale to use for modules
  11. (E.G. "en-US")
  12. :param module_config_path: Path to module config storage directory
  13. (or *NULL* if none)
  14. :param store: The profiler name store for OBS to use or NULL
  15. :return: *false* if already initialized or failed
  16. to initialize
  17. ---------------------
  18. .. function:: void obs_shutdown(void)
  19. Releases all data associated with OBS and terminates the OBS context.
  20. ---------------------
  21. .. function:: bool obs_initialized(void)
  22. :return: true if the main OBS context has been initialized
  23. ---------------------
  24. .. function:: uint32_t obs_get_version(void)
  25. :return: The current core version
  26. ---------------------
  27. .. function:: const char *obs_get_version_string(void)
  28. :return: The current core version string
  29. ---------------------
  30. .. function:: void obs_set_locale(const char *locale)
  31. Sets a new locale to use for modules. This will call
  32. :c:func:`obs_module_set_locale()` for each module with the new locale.
  33. :param locale: The locale to use for modules
  34. ---------------------
  35. .. function:: const char *obs_get_locale(void)
  36. :return: The current locale
  37. ---------------------
  38. .. function:: profiler_name_store_t *obs_get_profiler_name_store(void)
  39. :return: The profiler name store (see util/profiler.h) used by OBS,
  40. which is either a name store passed to :c:func:`obs_startup()`, an
  41. internal name store, or NULL in case :c:func:`obs_initialized()`
  42. returns false.
  43. ---------------------
  44. .. function:: int obs_reset_video(struct obs_video_info *ovi)
  45. Sets base video output base resolution/fps/format.
  46. Note: This data cannot be changed if an output is currently active.
  47. Note: The graphics module cannot be changed without fully destroying
  48. the OBS context.
  49. :param ovi: Pointer to an obs_video_info structure containing the
  50. specification of the graphics subsystem,
  51. :return: | OBS_VIDEO_SUCCESS - Success
  52. | OBS_VIDEO_NOT_SUPPORTED - The adapter lacks capabilities
  53. | OBS_VIDEO_INVALID_PARAM - A parameter is invalid
  54. | OBS_VIDEO_CURRENTLY_ACTIVE - Video is currently active
  55. | OBS_VIDEO_MODULE_NOT_FOUND - The graphics module is not found
  56. | OBS_VIDEO_FAIL - Generic failure
  57. Relevant data types used with this function:
  58. .. code:: cpp
  59. struct obs_video_info {
  60. /**
  61. * Graphics module to use (usually "libobs-opengl" or "libobs-d3d11")
  62. */
  63. const char *graphics_module;
  64. uint32_t fps_num; /**< Output FPS numerator */
  65. uint32_t fps_den; /**< Output FPS denominator */
  66. uint32_t base_width; /**< Base compositing width */
  67. uint32_t base_height; /**< Base compositing height */
  68. uint32_t output_width; /**< Output width */
  69. uint32_t output_height; /**< Output height */
  70. enum video_format output_format; /**< Output format */
  71. /** Video adapter index to use (NOTE: avoid for optimus laptops) */
  72. uint32_t adapter;
  73. /** Use shaders to convert to different color formats */
  74. bool gpu_conversion;
  75. enum video_colorspace colorspace; /**< YUV type (if YUV) */
  76. enum video_range_type range; /**< YUV range (if YUV) */
  77. enum obs_scale_type scale_type; /**< How to scale if scaling */
  78. };
  79. ---------------------
  80. .. function:: bool obs_reset_audio(const struct obs_audio_info *oai)
  81. Sets base audio output format/channels/samples/etc.
  82. Note: Cannot reset base audio if an output is currently active.
  83. :return: *true* if successful, *false* otherwise
  84. Relevant data types used with this function:
  85. .. code:: cpp
  86. struct obs_audio_info {
  87. uint32_t samples_per_sec;
  88. enum speaker_layout speakers;
  89. };
  90. ---------------------
  91. .. function:: bool obs_reset_audio2(const struct obs_audio_info2 *oai)
  92. Sets base audio output format/channels/samples/etc. Also allows the
  93. ability to set the maximum audio latency of OBS, and set whether the
  94. audio buffering is fixed or dynamically increasing.
  95. When using fixed audio buffering, OBS will automatically buffer to
  96. the maximum audio latency on startup.
  97. Maximum audio latency will clamp to the closest multiple of the audio
  98. output frames (which is typically 1024 audio frames).
  99. Note: Cannot reset base audio if an output is currently active.
  100. :return: *true* if successful, *false* otherwise
  101. Relevant data types used with this function:
  102. .. code:: cpp
  103. struct obs_audio_info2 {
  104. uint32_t samples_per_sec;
  105. enum speaker_layout speakers;
  106. uint32_t max_buffering_ms;
  107. bool fixed_buffering;
  108. };
  109. ---------------------
  110. .. function:: bool obs_get_video_info(struct obs_video_info *ovi)
  111. Gets the current video settings.
  112. :return: *false* if no video
  113. ---------------------
  114. .. function:: float obs_get_video_sdr_white_level(void)
  115. Gets the current SDR white level.
  116. :return: SDR white level, 300.f if no video
  117. ---------------------
  118. .. function:: float obs_get_video_hdr_nominal_peak_level(void)
  119. Gets the current HDR nominal peak level.
  120. :return: HDR nominal peak level, 1000.f if no video
  121. ---------------------
  122. .. function:: void obs_set_video_levels(float sdr_white_level, float hdr_nominal_peak_level)
  123. Sets the current video levels.
  124. ---------------------
  125. .. function:: bool obs_get_audio_info(struct obs_audio_info *oai)
  126. Gets the current audio settings.
  127. :return: *false* if no audio
  128. ---------------------
  129. Libobs Objects
  130. --------------
  131. .. function:: bool obs_enum_source_types(size_t idx, const char **id)
  132. Enumerates all source types (inputs, filters, transitions, etc).
  133. ---------------------
  134. .. function:: bool obs_enum_input_types(size_t idx, const char **id)
  135. Enumerates all available inputs source types.
  136. Inputs are general source inputs (such as capture sources, device sources,
  137. etc).
  138. ---------------------
  139. .. function:: bool obs_enum_filter_types(size_t idx, const char **id)
  140. Enumerates all available filter source types.
  141. Filters are sources that are used to modify the video/audio output of
  142. other sources.
  143. ---------------------
  144. .. function:: bool obs_enum_transition_types(size_t idx, const char **id)
  145. Enumerates all available transition source types.
  146. Transitions are sources used to transition between two or more other
  147. sources.
  148. ---------------------
  149. .. function:: bool obs_enum_output_types(size_t idx, const char **id)
  150. Enumerates all available output types.
  151. ---------------------
  152. .. function:: bool obs_enum_encoder_types(size_t idx, const char **id)
  153. Enumerates all available encoder types.
  154. ---------------------
  155. .. function:: bool obs_enum_service_types(size_t idx, const char **id)
  156. Enumerates all available service types.
  157. ---------------------
  158. .. function:: void obs_enum_sources(bool (*enum_proc)(void*, obs_source_t*), void *param)
  159. Enumerates all input sources.
  160. Callback function returns true to continue enumeration, or false to end
  161. enumeration.
  162. Use :c:func:`obs_source_get_ref()` or
  163. :c:func:`obs_source_get_weak_source()` if you want to retain a
  164. reference after obs_enum_sources finishes.
  165. For scripting, use :py:func:`obs_enum_sources`.
  166. ---------------------
  167. .. function:: void obs_enum_scenes(bool (*enum_proc)(void*, obs_source_t*), void *param)
  168. Enumerates all scenes. Use :c:func:`obs_scene_from_source()` if the scene is
  169. needed as an :c:type:`obs_scene_t`. The order that they are enumerated should
  170. not be relied on. If one intends to enumerate the scenes in the order
  171. presented by the OBS Studio Frontend, use :c:func:`obs_frontend_get_scenes()`.
  172. Callback function returns true to continue enumeration, or false to end
  173. enumeration.
  174. Use :c:func:`obs_source_get_ref()` or
  175. :c:func:`obs_source_get_weak_source()` if you want to retain a
  176. reference after obs_enum_scenes finishes.
  177. ---------------------
  178. .. function:: void obs_enum_outputs(bool (*enum_proc)(void*, obs_output_t*), void *param)
  179. Enumerates outputs.
  180. Callback function returns true to continue enumeration, or false to end
  181. enumeration.
  182. Use :c:func:`obs_output_get_ref()` or
  183. :c:func:`obs_output_get_weak_output()` if you want to retain a
  184. reference after obs_enum_outputs finishes.
  185. ---------------------
  186. .. function:: void obs_enum_encoders(bool (*enum_proc)(void*, obs_encoder_t*), void *param)
  187. Enumerates encoders.
  188. Callback function returns true to continue enumeration, or false to end
  189. enumeration.
  190. Use :c:func:`obs_encoder_get_ref()` or
  191. :c:func:`obs_encoder_get_weak_encoder()` if you want to retain a
  192. reference after obs_enum_encoders finishes.
  193. ---------------------
  194. .. function:: void obs_enum_canvases(bool (*enum_proc)(void*, obs_canvas_t*), void *param)
  195. Enumerates canvases.
  196. Callback function returns true to continue enumeration, or false to end
  197. enumeration.
  198. Use :c:func:`obs_canvas_get_ref()` or
  199. :c:func:`obs_canvas_get_weak_encoder()` if you want to retain a
  200. reference after obs_enum_canvases finishes.
  201. ---------------------
  202. .. function:: obs_source_t *obs_get_source_by_name(const char *name)
  203. Gets a source by its name.
  204. Increments the source reference counter, use
  205. :c:func:`obs_source_release()` to release it when complete.
  206. ---------------------
  207. .. function:: obs_source_t *obs_get_source_by_uuid(const char *uuid)
  208. Gets a source by its UUID.
  209. Increments the source reference counter, use
  210. :c:func:`obs_source_release()` to release it when complete.
  211. .. versionadded:: 29.1
  212. ---------------------
  213. .. function:: obs_source_t *obs_get_transition_by_name(const char *name)
  214. Gets a transition by its name.
  215. Increments the source reference counter, use
  216. :c:func:`obs_source_release()` to release it when complete.
  217. .. deprecated:: 31.1
  218. Use :c:func:`obs_frontend_get_transitions` from the Frontend API or :c:func:`obs_get_source_by_uuid` instead.
  219. ---------------------
  220. .. function:: obs_source_t *obs_get_transition_by_uuid(const char *uuid)
  221. Gets a transition by its UUID.
  222. Increments the source reference counter, use
  223. :c:func:`obs_source_release()` to release it when complete.
  224. .. versionadded:: 29.1
  225. .. deprecated:: 31.1
  226. Use :c:func:`obs_get_source_by_uuid` instead.
  227. ---------------------
  228. .. function:: obs_scene_t *obs_get_scene_by_name(const char *name)
  229. Gets a scene by its name.
  230. Increments the scene reference counter, use
  231. :c:func:`obs_scene_release()` to release it when complete.
  232. ---------------------
  233. .. function:: obs_output_t *obs_get_output_by_name(const char *name)
  234. Gets an output by its name.
  235. Increments the output reference counter, use
  236. :c:func:`obs_output_release()` to release it when complete.
  237. ---------------------
  238. .. function:: obs_encoder_t *obs_get_encoder_by_name(const char *name)
  239. Gets an encoder by its name.
  240. Increments the encoder reference counter, use
  241. :c:func:`obs_encoder_release()` to release it when complete.
  242. ---------------------
  243. .. function:: obs_service_t *obs_get_service_by_name(const char *name)
  244. Gets an service by its name.
  245. Increments the service reference counter, use
  246. :c:func:`obs_service_release()` to release it when complete.
  247. ---------------------
  248. .. function:: obs_canvas_t *obs_get_canvas_by_name(const char *name)
  249. Get a canvas by its name.
  250. Increments the canvas reference counter, use
  251. :c:func:`obs_canvas_release()` to release it when complete.
  252. ---------------------
  253. .. function:: obs_canvas_t *obs_get_canvas_by_uuid(const char *uuid)
  254. Get a canvas by its UUID.
  255. Increments the canvas reference counter, use
  256. :c:func:`obs_canvas_release()` to release it when complete.
  257. ---------------------
  258. .. function:: obs_data_t *obs_save_source(obs_source_t *source)
  259. :return: A new reference to a source's saved data. Use
  260. :c:func:`obs_data_release()` to release it when complete.
  261. ---------------------
  262. .. function:: obs_source_t *obs_load_source(obs_data_t *data)
  263. :return: A source created from saved data
  264. ---------------------
  265. .. function:: void obs_load_sources(obs_data_array_t *array, obs_load_source_cb cb, void *private_data)
  266. Helper function to load active sources from a data array.
  267. Relevant data types used with this function:
  268. .. code:: cpp
  269. typedef void (*obs_load_source_cb)(void *private_data, obs_source_t *source);
  270. ---------------------
  271. .. function:: obs_data_array_t *obs_save_sources(void)
  272. :return: A data array with the saved data of all active sources
  273. ---------------------
  274. .. function:: obs_data_array_t *obs_save_sources_filtered(obs_save_source_filter_cb cb, void *data)
  275. :return: A data array with the saved data of all active sources,
  276. filtered by the *cb* function
  277. Relevant data types used with this function:
  278. .. code:: cpp
  279. typedef bool (*obs_save_source_filter_cb)(void *data, obs_source_t *source);
  280. ---------------------
  281. Video, Audio, and Graphics
  282. --------------------------
  283. .. function:: void obs_enter_graphics(void)
  284. Helper function for entering the OBS graphics context.
  285. ---------------------
  286. .. function:: void obs_leave_graphics(void)
  287. Helper function for leaving the OBS graphics context.
  288. ---------------------
  289. .. function:: audio_t *obs_get_audio(void)
  290. :return: The main audio output handler for this OBS context
  291. ---------------------
  292. .. function:: video_t *obs_get_video(void)
  293. :return: The main video output handler for this OBS context
  294. ---------------------
  295. .. function:: void obs_set_output_source(uint32_t channel, obs_source_t *source)
  296. Sets the primary output source for a channel.
  297. ---------------------
  298. .. function:: obs_source_t *obs_get_output_source(uint32_t channel)
  299. Gets the primary output source for a channel and increments the reference
  300. counter for that source. Use :c:func:`obs_source_release()` to release.
  301. ---------------------
  302. .. function:: gs_effect_t *obs_get_base_effect(enum obs_base_effect effect)
  303. Returns a commonly used base effect.
  304. :param effect: | Can be one of the following values:
  305. | OBS_EFFECT_DEFAULT - RGB/YUV
  306. | OBS_EFFECT_DEFAULT_RECT - RGB/YUV (using texture_rect)
  307. | OBS_EFFECT_OPAQUE - RGB/YUV (alpha set to 1.0)
  308. | OBS_EFFECT_SOLID - RGB/YUV (solid color only)
  309. | OBS_EFFECT_BICUBIC - Bicubic downscale
  310. | OBS_EFFECT_LANCZOS - Lanczos downscale
  311. | OBS_EFFECT_BILINEAR_LOWRES - Bilinear low resolution downscale
  312. | OBS_EFFECT_PREMULTIPLIED_ALPHA - Premultiplied alpha
  313. ---------------------
  314. .. function:: void obs_render_main_texture(void)
  315. Renders the main output texture. Useful for rendering a preview pane
  316. of the main output.
  317. ---------------------
  318. .. function:: bool obs_audio_monitoring_available(void)
  319. :return: Whether audio monitoring is supported and available on the current platform
  320. ---------------------
  321. .. function:: void obs_reset_audio_monitoring(void)
  322. Resets all audio monitoring devices.
  323. .. versionadded:: 30.1
  324. ---------------------
  325. .. function:: void obs_enum_audio_monitoring_devices(obs_enum_audio_device_cb cb, void *data)
  326. Enumerates audio devices which can be used for audio monitoring.
  327. Callback function returns true to continue enumeration, or false to end
  328. enumeration.
  329. Relevant data types used with this function:
  330. .. code:: cpp
  331. typedef bool (*obs_enum_audio_device_cb)(void *data, const char *name, const char *id);
  332. ---------------------
  333. .. function:: bool obs_set_audio_monitoring_device(const char *name, const char *id)
  334. Sets the current audio device for audio monitoring.
  335. ---------------------
  336. .. function:: void obs_get_audio_monitoring_device(const char **name, const char **id)
  337. Gets the current audio device for audio monitoring.
  338. ---------------------
  339. .. function:: void obs_add_main_render_callback(void (*draw)(void *param, uint32_t cx, uint32_t cy), void *param)
  340. void obs_remove_main_render_callback(void (*draw)(void *param, uint32_t cx, uint32_t cy), void *param)
  341. Adds/removes a main rendering callback. Allows custom rendering to
  342. the main stream/recording output.
  343. For scripting (**Lua only**), use :py:func:`obs_add_main_render_callback`
  344. and :py:func:`obs_remove_main_render_callback`.
  345. ---------------------
  346. .. function:: void obs_add_main_rendered_callback(void (*rendered)(void *param), void *param)
  347. void obs_remove_main_rendered_callback(void (*rendered)(void *param), void *param)
  348. Adds/removes a main rendered callback. Allows using the result of
  349. the main stream/recording output.
  350. .. versionadded:: 29.1
  351. ---------------------
  352. .. function:: void obs_add_raw_video_callback(const struct video_scale_info *conversion, void (*callback)(void *param, struct video_data *frame), void *param)
  353. void obs_remove_raw_video_callback(void (*callback)(void *param, struct video_data *frame), void *param)
  354. Adds/removes a raw video callback. Allows the ability to obtain raw
  355. video frames without necessarily using an output.
  356. :param conversion: Specifies conversion requirements. Can be NULL.
  357. :param callback: The callback that receives raw video frames.
  358. :param param: The private data associated with the callback.
  359. ---------------------
  360. .. function:: void obs_add_raw_audio_callback(size_t mix_idx, const struct audio_convert_info *conversion, audio_output_callback_t callback, void *param)
  361. void obs_remove_raw_raw_callback(size_t track, audio_output_callback_t callback, void *param)
  362. Adds/removes a raw audio callback. Allows the ability to obtain raw
  363. audio data without necessarily using an output.
  364. :param mix_idx: Specifies audio track to get data from.
  365. :param conversion: Specifies conversion requirements. Can be NULL.
  366. :param callback: The callback that receives raw audio data.
  367. :param param: The private data associated with the callback.
  368. Primary signal/procedure handlers
  369. ---------------------------------
  370. .. function:: signal_handler_t *obs_get_signal_handler(void)
  371. :return: The primary obs signal handler. Should not be manually freed,
  372. as its lifecycle is managed by libobs.
  373. See :ref:`core_signal_handler_reference` for more information on
  374. core signals.
  375. ---------------------
  376. .. function:: proc_handler_t *obs_get_proc_handler(void)
  377. :return: The primary obs procedure handler. Should not be manually freed,
  378. as its lifecycle is managed by libobs.
  379. .. _core_signal_handler_reference:
  380. Core OBS Signals
  381. ----------------
  382. **source_create** (ptr source)
  383. Called when a source has been created.
  384. **source_destroy** (ptr source)
  385. Called when a source has been destroyed.
  386. **source_remove** (ptr source)
  387. Called when a source has been removed (:c:func:`obs_source_remove()`
  388. has been called on the source).
  389. **source_update** (ptr source)
  390. Called when a source's settings have been updated.
  391. **source_save** (ptr source)
  392. Called when a source is being saved.
  393. **source_load** (ptr source)
  394. Called when a source is being loaded.
  395. **source_activate** (ptr source)
  396. Called when a source has been activated in the main view (visible on
  397. stream/recording).
  398. **source_deactivate** (ptr source)
  399. Called when a source has been deactivated from the main view (no
  400. longer visible on stream/recording).
  401. **source_show** (ptr source)
  402. Called when a source is visible on any display and/or on the main
  403. view.
  404. **source_hide** (ptr source)
  405. Called when a source is no longer visible on any display and/or on
  406. the main view.
  407. **source_rename** (ptr source, string new_name, string prev_name)
  408. Called when a source has been renamed.
  409. **source_volume** (ptr source, in out float volume)
  410. Called when a source's volume has changed.
  411. **source_audio_activate** (ptr source)
  412. Called when a source's audio becomes active.
  413. **source_audio_deactivate** (ptr source)
  414. Called when a source's audio becomes inactive.
  415. **source_filter_add** (ptr source, ptr filter)
  416. Called when a filter is added to a source.
  417. **source_filter_remove** (ptr source, ptr filter)
  418. Called when a filter is removed from a source.
  419. **source_transition_start** (ptr source)
  420. Called when a transition has started its transition.
  421. **source_transition_video_stop** (ptr source)
  422. Called when a transition has stopped its video transitioning.
  423. **source_transition_stop** (ptr source)
  424. Called when a transition has stopped its transition.
  425. **channel_change** (int channel, in out ptr source, ptr prev_source)
  426. Called when :c:func:`obs_set_output_source()` has been called.
  427. **hotkey_layout_change** ()
  428. Called when the hotkey layout has changed.
  429. **hotkey_register** (ptr hotkey)
  430. Called when a hotkey has been registered.
  431. **hotkey_unregister** (ptr hotkey)
  432. Called when a hotkey has been unregistered.
  433. **hotkey_bindings_changed** (ptr hotkey)
  434. Called when a hotkey's bindings has changed.
  435. **canvas_create** (ptr canvas)
  436. Called when a new public canvas has been created.
  437. **canvas_remove** (ptr canvas)
  438. Called when the :c:func:`obs_canvas_remove()` function is called on a public canvas.
  439. **canvas_destroy** (ptr canvas)
  440. Called when a public canvas is about to be destroyed.
  441. **canvas_video_reset** (ptr canvas)
  442. Called when a public canvas's video mix has been reset after a call to
  443. :c:func:`obs_reset_video()` or :c:func:`obs_canvas_reset_video()`.
  444. **canvas_rename** (ptr canvas, string new_name, string prev_name)
  445. Called when a public canvas has been renamed.
  446. **video_reset** ()
  447. Called when a the main OBS video has been reset.
  448. ---------------------
  449. .. _display_reference:
  450. Displays
  451. --------
  452. .. function:: obs_display_t *obs_display_create(const struct gs_init_data *graphics_data)
  453. Adds a new window display linked to the main render pipeline. This creates
  454. a new swap chain which updates every frame.
  455. *(Important note: do not use more than one display widget within the
  456. hierarchy of the same base window; this will cause presentation
  457. stalls on macOS.)*
  458. :param graphics_data: The swap chain initialization data
  459. :return: The new display context, or NULL if failed
  460. Relevant data types used with this function:
  461. .. code:: cpp
  462. enum gs_color_format {
  463. [...]
  464. GS_RGBA,
  465. GS_BGRX,
  466. GS_BGRA,
  467. GS_RGBA16F,
  468. GS_RGBA32F,
  469. [...]
  470. };
  471. enum gs_zstencil_format {
  472. GS_ZS_NONE,
  473. GS_Z16,
  474. GS_Z24_S8,
  475. GS_Z32F,
  476. GS_Z32F_S8X24
  477. };
  478. struct gs_window {
  479. #if defined(_WIN32)
  480. void *hwnd;
  481. #elif defined(__APPLE__)
  482. __unsafe_unretained id view;
  483. #elif defined(__linux__) || defined(__FreeBSD__)
  484. uint32_t id;
  485. void *display;
  486. #endif
  487. };
  488. struct gs_init_data {
  489. struct gs_window window;
  490. uint32_t cx, cy;
  491. uint32_t num_backbuffers;
  492. enum gs_color_format format;
  493. enum gs_zstencil_format zsformat;
  494. uint32_t adapter;
  495. };
  496. ---------------------
  497. .. function:: void obs_display_destroy(obs_display_t *display)
  498. Destroys a display context.
  499. ---------------------
  500. .. function:: void obs_display_resize(obs_display_t *display, uint32_t cx, uint32_t cy)
  501. Changes the size of a display context.
  502. ---------------------
  503. .. function:: void obs_display_add_draw_callback(obs_display_t *display, void (*draw)(void *param, uint32_t cx, uint32_t cy), void *param)
  504. Adds a draw callback for a display context, which will be called
  505. whenever the display is rendered.
  506. :param display: The display context
  507. :param draw: The draw callback which is called each time a frame
  508. updates
  509. :param param: The user data to be associated with this draw callback
  510. ---------------------
  511. .. function:: void obs_display_remove_draw_callback(obs_display_t *display, void (*draw)(void *param, uint32_t cx, uint32_t cy), void *param)
  512. Removes a draw callback for a display context.
  513. ---------------------
  514. .. function:: void obs_display_set_enabled(obs_display_t *display, bool enable)
  515. Enables/disables a display context.
  516. ---------------------
  517. .. function:: bool obs_display_enabled(obs_display_t *display)
  518. :return: *true* if the display is enabled, *false* otherwise
  519. ---------------------
  520. .. function:: void obs_display_set_background_color(obs_display_t *display, uint32_t color)
  521. Sets the background (clear) color for the display context.
  522. .. _view_reference:
  523. Views
  524. ----------------
  525. .. function:: obs_view_t *obs_view_create(void)
  526. :return: A view context
  527. ---------------------
  528. .. function:: void obs_view_destroy(obs_view_t *view)
  529. Destroys a view context.
  530. ---------------------
  531. .. function:: void obs_view_render(obs_view_t *view)
  532. Renders the sources of this view context.
  533. ---------------------
  534. .. function:: video_t *obs_view_add(obs_view_t *view)
  535. Renders the sources of this view context.
  536. :return: The main video output handler for the view context
  537. ---------------------
  538. .. function:: video_t *obs_view_add2(obs_view_t *view, struct obs_video_info *ovi)
  539. Adds a view to the main render loop, with custom video settings.
  540. :return: The main video output handler for the view context
  541. ---------------------
  542. .. function:: void obs_view_remove(obs_view_t *view)
  543. Removes a view from the main render loop.
  544. ---------------------
  545. .. function:: void obs_view_set_source(obs_view_t *view, uint32_t channel, obs_source_t *source)
  546. Sets the source to be used for this view context.
  547. ---------------------
  548. .. function:: obs_source_t *obs_view_get_source(obs_view_t *view, uint32_t channel)
  549. :return: The source currently in use for this view context
  550. ---------------------
  551. .. function:: bool obs_view_get_video_info(obs_view_t *view, struct obs_video_info *ovi)
  552. Gets the video settings of the first matching mix currently in use for this view context.
  553. :return: *false* if no video
  554. .. deprecated:: 3X.X
  555. ---------------------
  556. .. function:: void obs_view_enum_video_info(obs_view_t *view, bool (*enum_proc)(void *, struct obs_video_info *), void *param)
  557. Enumerates all the video info of all mixes that use the specified mix.
  558. .. versionadded:: 30.1