obs.h 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260
  1. /******************************************************************************
  2. Copyright (C) 2013-2014 by Hugh 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/text-lookup.h"
  18. #include "graphics/graphics.h"
  19. #include "graphics/vec2.h"
  20. #include "graphics/vec3.h"
  21. #include "media-io/audio-io.h"
  22. #include "media-io/video-io.h"
  23. #include "callback/signal.h"
  24. #include "callback/proc.h"
  25. #include "obs-config.h"
  26. #include "obs-defs.h"
  27. #include "obs-data.h"
  28. #include "obs-ui.h"
  29. #include "obs-properties.h"
  30. #include "obs-interaction.h"
  31. struct matrix4;
  32. /* opaque types */
  33. struct obs_display;
  34. struct obs_view;
  35. struct obs_source;
  36. struct obs_scene;
  37. struct obs_scene_item;
  38. struct obs_output;
  39. struct obs_encoder;
  40. struct obs_service;
  41. struct obs_module;
  42. typedef struct obs_display obs_display_t;
  43. typedef struct obs_view obs_view_t;
  44. typedef struct obs_source obs_source_t;
  45. typedef struct obs_scene obs_scene_t;
  46. typedef struct obs_scene_item obs_sceneitem_t;
  47. typedef struct obs_output obs_output_t;
  48. typedef struct obs_encoder obs_encoder_t;
  49. typedef struct obs_service obs_service_t;
  50. typedef struct obs_module obs_module_t;
  51. #include "obs-source.h"
  52. #include "obs-encoder.h"
  53. #include "obs-output.h"
  54. #include "obs-service.h"
  55. /**
  56. * @file
  57. * @brief Main libobs header used by applications.
  58. *
  59. * @mainpage
  60. *
  61. * @section intro_sec Introduction
  62. *
  63. * This document describes the api for libobs to be used by applications as well
  64. * as @ref modules_page implementing some kind of functionality.
  65. *
  66. */
  67. #ifdef __cplusplus
  68. extern "C" {
  69. #endif
  70. /** Used for changing the order of items (for example, filters in a source,
  71. * or items in a scene) */
  72. enum obs_order_movement {
  73. OBS_ORDER_MOVE_UP,
  74. OBS_ORDER_MOVE_DOWN,
  75. OBS_ORDER_MOVE_TOP,
  76. OBS_ORDER_MOVE_BOTTOM
  77. };
  78. /**
  79. * Used with obs_source_process_filter to specify whether the filter should
  80. * render the source directly with the specified effect, or whether it should
  81. * render it to a texture
  82. */
  83. enum obs_allow_direct_render {
  84. OBS_NO_DIRECT_RENDERING,
  85. OBS_ALLOW_DIRECT_RENDERING,
  86. };
  87. /**
  88. * Used with scene items to indicate the type of bounds to use for scene items.
  89. * Mostly determines how the image will be scaled within those bounds, or
  90. * whether to use bounds at all.
  91. */
  92. enum obs_bounds_type {
  93. OBS_BOUNDS_NONE, /**< no bounds */
  94. OBS_BOUNDS_STRETCH, /**< stretch (ignores base scale) */
  95. OBS_BOUNDS_SCALE_INNER, /**< scales to inner rectangle */
  96. OBS_BOUNDS_SCALE_OUTER, /**< scales to outer rectangle */
  97. OBS_BOUNDS_SCALE_TO_WIDTH, /**< scales to the width */
  98. OBS_BOUNDS_SCALE_TO_HEIGHT, /**< scales to the height */
  99. OBS_BOUNDS_MAX_ONLY, /**< no scaling, maximum size only */
  100. };
  101. struct obs_transform_info {
  102. struct vec2 pos;
  103. float rot;
  104. struct vec2 scale;
  105. uint32_t alignment;
  106. enum obs_bounds_type bounds_type;
  107. uint32_t bounds_alignment;
  108. struct vec2 bounds;
  109. };
  110. /**
  111. * Video initialization structure
  112. */
  113. struct obs_video_info {
  114. /**
  115. * Graphics module to use (usually "libobs-opengl" or "libobs-d3d11")
  116. */
  117. const char *graphics_module;
  118. uint32_t fps_num; /**< Output FPS numerator */
  119. uint32_t fps_den; /**< Output FPS denominator */
  120. uint32_t window_width; /**< Window width */
  121. uint32_t window_height; /**< Window height */
  122. uint32_t base_width; /**< Base compositing width */
  123. uint32_t base_height; /**< Base compositing height */
  124. uint32_t output_width; /**< Output width */
  125. uint32_t output_height; /**< Output height */
  126. enum video_format output_format; /**< Output format */
  127. /** Video adapter index to use (NOTE: avoid for optimus laptops) */
  128. uint32_t adapter;
  129. struct gs_window window; /**< Window to render to */
  130. /** Use shaders to convert to different color formats */
  131. bool gpu_conversion;
  132. };
  133. /**
  134. * Sent to source filters via the filter_audio callback to allow filtering of
  135. * audio data
  136. */
  137. struct obs_audio_data {
  138. uint8_t *data[MAX_AV_PLANES];
  139. uint32_t frames;
  140. uint64_t timestamp;
  141. };
  142. /**
  143. * Source audio output structure. Used with obs_source_output_audio to output
  144. * source audio. Audio is automatically resampled and remixed as necessary.
  145. */
  146. struct obs_source_audio {
  147. const uint8_t *data[MAX_AV_PLANES];
  148. uint32_t frames;
  149. enum speaker_layout speakers;
  150. enum audio_format format;
  151. uint32_t samples_per_sec;
  152. uint64_t timestamp;
  153. };
  154. /**
  155. * Source asynchronous video output structure. Used with
  156. * obs_source_output_video to output asynchronous video. Video is buffered as
  157. * necessary to play according to timestamps. When used with audio output,
  158. * audio is synced to video as it is played.
  159. *
  160. * If a YUV format is specified, it will be automatically upsampled and
  161. * converted to RGB via shader on the graphics processor.
  162. */
  163. struct obs_source_frame {
  164. uint8_t *data[MAX_AV_PLANES];
  165. uint32_t linesize[MAX_AV_PLANES];
  166. uint32_t width;
  167. uint32_t height;
  168. uint64_t timestamp;
  169. enum video_format format;
  170. float color_matrix[16];
  171. bool full_range;
  172. float color_range_min[3];
  173. float color_range_max[3];
  174. bool flip;
  175. };
  176. /* ------------------------------------------------------------------------- */
  177. /* OBS context */
  178. /**
  179. * Initializes OBS
  180. *
  181. * @param locale The locale to use for modules
  182. */
  183. EXPORT bool obs_startup(const char *locale);
  184. /** Releases all data associated with OBS and terminates the OBS context */
  185. EXPORT void obs_shutdown(void);
  186. /** @return true if the main OBS context has been initialized */
  187. EXPORT bool obs_initialized(void);
  188. /** @return The current core version */
  189. EXPORT uint32_t obs_get_version(void);
  190. /**
  191. * Sets a new locale to use for modules. This will call obs_module_set_locale
  192. * for each module with the new locale.
  193. *
  194. * @param locale The locale to use for modules
  195. */
  196. EXPORT void obs_set_locale(const char *locale);
  197. /** @return the current locale */
  198. EXPORT const char *obs_get_locale(void);
  199. /**
  200. * Sets base video ouput base resolution/fps/format.
  201. *
  202. * @note This data cannot be changed if an output is corrently active.
  203. * @note The graphics module cannot be changed without fully destroying the
  204. * OBS context.
  205. *
  206. * @param ovi Pointer to an obs_video_info structure containing the
  207. * specification of the graphics subsystem,
  208. * @return OBS_VIDEO_SUCCESS if sucessful
  209. * OBS_VIDEO_NOT_SUPPORTED if the adapter lacks capabilities
  210. * OBS_VIDEO_INVALID_PARAM if a parameter is invalid
  211. * OBS_VIDEO_CURRENTLY_ACTIVE if video is currently active
  212. * OBS_VIDEO_MODULE_NOT_FOUND if the graphics module is not found
  213. * OBS_VIDEO_FAIL for generic failure
  214. */
  215. EXPORT int obs_reset_video(struct obs_video_info *ovi);
  216. /**
  217. * Sets base audio output format/channels/samples/etc
  218. *
  219. * @note Cannot reset base audio if an output is currently active.
  220. */
  221. EXPORT bool obs_reset_audio(struct audio_output_info *ai);
  222. /** Gets the current video settings, returns false if no video */
  223. EXPORT bool obs_get_video_info(struct obs_video_info *ovi);
  224. /** Gets the current audio settings, returns false if no audio */
  225. EXPORT bool obs_get_audio_info(struct audio_output_info *ai);
  226. /**
  227. * Opens a plugin module directly from a specific path.
  228. *
  229. * If the module already exists then the function will return successful, and
  230. * the module parameter will be given the pointer to the existing module.
  231. *
  232. * This does not initialize the module, it only loads the module image. To
  233. * initialize the module, call obs_init_module.
  234. *
  235. * @param module The pointer to the created module.
  236. * @param path Specifies the path to the module library file. If the
  237. * extension is not specified, it will use the extension
  238. * appropriate to the operating system.
  239. * @param data_path Specifies the path to the directory where the module's
  240. * data files are stored.
  241. * @returns MODULE_SUCCESS if successful
  242. * MODULE_ERROR if a generic error occurred
  243. * MODULE_FILE_NOT_FOUND if the module was not found
  244. * MODULE_MISSING_EXPORTS if required exports are missing
  245. * MODULE_INCOMPATIBLE_VER if incompatible version
  246. */
  247. EXPORT int obs_open_module(obs_module_t **module, const char *path,
  248. const char *data_path);
  249. /**
  250. * Initializes the module, which calls its obs_module_load export. If the
  251. * module is alrady loaded, then this function does nothing and returns
  252. * successful.
  253. */
  254. EXPORT bool obs_init_module(obs_module_t *module);
  255. /** Returns the module file name */
  256. EXPORT const char *obs_get_module_file_name(obs_module_t *module);
  257. /** Returns the module full name */
  258. EXPORT const char *obs_get_module_name(obs_module_t *module);
  259. /** Returns the module author(s) */
  260. EXPORT const char *obs_get_module_author(obs_module_t *module);
  261. /** Returns the module description */
  262. EXPORT const char *obs_get_module_description(obs_module_t *module);
  263. /** Returns the module binary path */
  264. EXPORT const char *obs_get_module_binary_path(obs_module_t *module);
  265. /** Returns the module data path */
  266. EXPORT const char *obs_get_module_data_path(obs_module_t *module);
  267. /**
  268. * Adds a module search path to be used with obs_find_modules. If the search
  269. * path strings contain %module%, that text will be replaced with the module
  270. * name when used.
  271. *
  272. * @param bin Specifies the module's binary directory search path.
  273. * @param data Specifies the module's data directory search path.
  274. */
  275. EXPORT void obs_add_module_path(const char *bin, const char *data);
  276. /** Automatically loads all modules from module paths (convenience function) */
  277. EXPORT void obs_load_all_modules(void);
  278. struct obs_module_info {
  279. const char *bin_path;
  280. const char *data_path;
  281. };
  282. typedef void (*obs_find_module_callback_t)(void *param,
  283. const struct obs_module_info *info);
  284. /** Finds all modules within the search paths added by obs_add_module_path. */
  285. EXPORT void obs_find_modules(obs_find_module_callback_t callback, void *param);
  286. typedef void (*obs_enum_module_callback_t)(void *param, obs_module_t *module);
  287. /** Enumerates all loaded modules */
  288. EXPORT void obs_enum_modules(obs_enum_module_callback_t callback, void *param);
  289. /** Helper function for using default module locale */
  290. EXPORT lookup_t *obs_module_load_locale(obs_module_t *module,
  291. const char *default_locale, const char *locale);
  292. /**
  293. * Returns the location of a plugin module data file.
  294. *
  295. * @note Modules should use obs_module_file function defined in obs-module.h
  296. * as a more elegant means of getting their files without having to
  297. * specify the module parameter.
  298. *
  299. * @param module The module associated with the file to locate
  300. * @param file The file to locate
  301. * @return Path string, or NULL if not found. Use bfree to free string.
  302. */
  303. EXPORT char *obs_find_module_file(obs_module_t *module, const char *file);
  304. /**
  305. * Enumerates all available inputs source types.
  306. *
  307. * Inputs are general source inputs (such as capture sources, device sources,
  308. * etc).
  309. */
  310. EXPORT bool obs_enum_input_types(size_t idx, const char **id);
  311. /**
  312. * Enumerates all available filter source types.
  313. *
  314. * Filters are sources that are used to modify the video/audio output of
  315. * other sources.
  316. */
  317. EXPORT bool obs_enum_filter_types(size_t idx, const char **id);
  318. /**
  319. * Enumerates all available transition source types.
  320. *
  321. * Transitions are sources used to transition between two or more other
  322. * sources.
  323. */
  324. EXPORT bool obs_enum_transition_types(size_t idx, const char **id);
  325. /** Enumerates all available output types. */
  326. EXPORT bool obs_enum_output_types(size_t idx, const char **id);
  327. /** Enumerates all available encoder types. */
  328. EXPORT bool obs_enum_encoder_types(size_t idx, const char **id);
  329. /** Enumerates all available service types. */
  330. EXPORT bool obs_enum_service_types(size_t idx, const char **id);
  331. /** Helper function for entering the OBS graphics context */
  332. EXPORT void obs_enter_graphics(void);
  333. /** Helper function for leaving the OBS graphics context */
  334. EXPORT void obs_leave_graphics(void);
  335. /** Gets the main audio output handler for this OBS context */
  336. EXPORT audio_t *obs_get_audio(void);
  337. /** Gets the main video output handler for this OBS context */
  338. EXPORT video_t *obs_get_video(void);
  339. /**
  340. * Adds a source to the user source list and increments the reference counter
  341. * for that source.
  342. *
  343. * The user source list is the list of sources that are accessible by a user.
  344. * Typically when a transition is active, it is not meant to be accessible by
  345. * users, so there's no reason for a user to see such a source.
  346. */
  347. EXPORT bool obs_add_source(obs_source_t *source);
  348. /** Sets the primary output source for a channel. */
  349. EXPORT void obs_set_output_source(uint32_t channel, obs_source_t *source);
  350. /**
  351. * Gets the primary output source for a channel and increments the reference
  352. * counter for that source. Use obs_source_release to release.
  353. */
  354. EXPORT obs_source_t *obs_get_output_source(uint32_t channel);
  355. /**
  356. * Enumerates user sources
  357. *
  358. * Callback function returns true to continue enumeration, or false to end
  359. * enumeration.
  360. */
  361. EXPORT void obs_enum_sources(bool (*enum_proc)(void*, obs_source_t*),
  362. void *param);
  363. /** Enumerates outputs */
  364. EXPORT void obs_enum_outputs(bool (*enum_proc)(void*, obs_output_t*),
  365. void *param);
  366. /** Enumerates encoders */
  367. EXPORT void obs_enum_encoders(bool (*enum_proc)(void*, obs_encoder_t*),
  368. void *param);
  369. /** Enumerates encoders */
  370. EXPORT void obs_enum_services(bool (*enum_proc)(void*, obs_service_t*),
  371. void *param);
  372. /**
  373. * Gets a source by its name.
  374. *
  375. * Increments the source reference counter, use obs_source_release to
  376. * release it when complete.
  377. */
  378. EXPORT obs_source_t *obs_get_source_by_name(const char *name);
  379. /** Gets an output by its name. */
  380. EXPORT obs_output_t *obs_get_output_by_name(const char *name);
  381. /** Gets an encoder by its name. */
  382. EXPORT obs_encoder_t *obs_get_encoder_by_name(const char *name);
  383. /** Gets an service by its name. */
  384. EXPORT obs_service_t *obs_get_service_by_name(const char *name);
  385. /** Returns the default effect for generic RGB/YUV drawing */
  386. EXPORT gs_effect_t *obs_get_default_effect(void);
  387. /** Returns the default effect for generic RGB/YUV drawing using texture_rect */
  388. EXPORT gs_effect_t *obs_get_default_rect_effect(void);
  389. /** Returns the solid effect for drawing solid colors */
  390. EXPORT gs_effect_t *obs_get_solid_effect(void);
  391. /** Returns the primary obs signal handler */
  392. EXPORT signal_handler_t *obs_get_signal_handler(void);
  393. /** Returns the primary obs procedure handler */
  394. EXPORT proc_handler_t *obs_get_proc_handler(void);
  395. /** Adds a draw callback to the main render context */
  396. EXPORT void obs_add_draw_callback(
  397. void (*draw)(void *param, uint32_t cx, uint32_t cy),
  398. void *param);
  399. /** Removes a draw callback to the main render context */
  400. EXPORT void obs_remove_draw_callback(
  401. void (*draw)(void *param, uint32_t cx, uint32_t cy),
  402. void *param);
  403. /** Changes the size of the main view */
  404. EXPORT void obs_resize(uint32_t cx, uint32_t cy);
  405. /** Renders the main view */
  406. EXPORT void obs_render_main_view(void);
  407. /** Sets the master user volume */
  408. EXPORT void obs_set_master_volume(float volume);
  409. /** Sets the master presentation volume */
  410. EXPORT void obs_set_present_volume(float volume);
  411. /** Gets the master user volume */
  412. EXPORT float obs_get_master_volume(void);
  413. /** Gets the master presentation volume */
  414. EXPORT float obs_get_present_volume(void);
  415. /** Saves a source to settings data */
  416. EXPORT obs_data_t *obs_save_source(obs_source_t *source);
  417. /** Loads a source from settings data */
  418. EXPORT obs_source_t *obs_load_source(obs_data_t *data);
  419. /** Loads sources from a data array */
  420. EXPORT void obs_load_sources(obs_data_array_t *array);
  421. /** Saves sources to a data array */
  422. EXPORT obs_data_array_t *obs_save_sources(void);
  423. /* ------------------------------------------------------------------------- */
  424. /* View context */
  425. /**
  426. * Creates a view context.
  427. *
  428. * A view can be used for things like separate previews, or drawing
  429. * sources separately.
  430. */
  431. EXPORT obs_view_t *obs_view_create(void);
  432. /** Destroys this view context */
  433. EXPORT void obs_view_destroy(obs_view_t *view);
  434. /** Sets the source to be used for this view context. */
  435. EXPORT void obs_view_set_source(obs_view_t *view, uint32_t channel,
  436. obs_source_t *source);
  437. /** Gets the source currently in use for this view context */
  438. EXPORT obs_source_t *obs_view_get_source(obs_view_t *view,
  439. uint32_t channel);
  440. /** Renders the sources of this view context */
  441. EXPORT void obs_view_render(obs_view_t *view);
  442. /* ------------------------------------------------------------------------- */
  443. /* Display context */
  444. /**
  445. * Adds a new window display linked to the main render pipeline. This creates
  446. * a new swap chain which updates every frame.
  447. *
  448. * @param graphics_data The swap chain initialization data.
  449. * @return The new display context, or NULL if failed.
  450. */
  451. EXPORT obs_display_t *obs_display_create(
  452. const struct gs_init_data *graphics_data);
  453. /** Destroys a display context */
  454. EXPORT void obs_display_destroy(obs_display_t *display);
  455. /** Changes the size of this display */
  456. EXPORT void obs_display_resize(obs_display_t *display, uint32_t cx,
  457. uint32_t cy);
  458. /**
  459. * Adds a draw callback for this display context
  460. *
  461. * @param display The display context.
  462. * @param draw The draw callback which is called each time a frame
  463. * updates.
  464. * @param param The user data to be associated with this draw callback.
  465. */
  466. EXPORT void obs_display_add_draw_callback(obs_display_t *display,
  467. void (*draw)(void *param, uint32_t cx, uint32_t cy),
  468. void *param);
  469. /** Removes a draw callback for this display context */
  470. EXPORT void obs_display_remove_draw_callback(obs_display_t *display,
  471. void (*draw)(void *param, uint32_t cx, uint32_t cy),
  472. void *param);
  473. /* ------------------------------------------------------------------------- */
  474. /* Sources */
  475. /** Returns the translated display name of a source */
  476. EXPORT const char *obs_source_get_display_name(enum obs_source_type type,
  477. const char *id);
  478. /**
  479. * Creates a source of the specified type with the specified settings.
  480. *
  481. * The "source" context is used for anything related to presenting
  482. * or modifying video/audio. Use obs_source_release to release it.
  483. */
  484. EXPORT obs_source_t *obs_source_create(enum obs_source_type type,
  485. const char *id, const char *name, obs_data_t *settings);
  486. /**
  487. * Adds/releases a reference to a source. When the last reference is
  488. * released, the source is destroyed.
  489. */
  490. EXPORT void obs_source_addref(obs_source_t *source);
  491. EXPORT void obs_source_release(obs_source_t *source);
  492. /** Notifies all references that the source should be released */
  493. EXPORT void obs_source_remove(obs_source_t *source);
  494. /** Returns true if the source should be released */
  495. EXPORT bool obs_source_removed(const obs_source_t *source);
  496. /**
  497. * Retrieves flags that specify what type of data the source presents/modifies.
  498. */
  499. EXPORT uint32_t obs_source_get_output_flags(const obs_source_t *source);
  500. /** Gets the default settings for a source type */
  501. EXPORT obs_data_t *obs_get_source_defaults(enum obs_source_type type,
  502. const char *id);
  503. /** Returns the property list, if any. Free with obs_properties_destroy */
  504. EXPORT obs_properties_t *obs_get_source_properties(enum obs_source_type type,
  505. const char *id);
  506. /**
  507. * Returns the properties list for a specific existing source. Free with
  508. * obs_properties_destroy
  509. */
  510. EXPORT obs_properties_t *obs_source_properties(const obs_source_t *source);
  511. /** Updates settings for this source */
  512. EXPORT void obs_source_update(obs_source_t *source, obs_data_t *settings);
  513. /** Renders a video source. */
  514. EXPORT void obs_source_video_render(obs_source_t *source);
  515. /** Gets the width of a source (if it has video) */
  516. EXPORT uint32_t obs_source_get_width(const obs_source_t *source);
  517. /** Gets the height of a source (if it has video) */
  518. EXPORT uint32_t obs_source_get_height(const obs_source_t *source);
  519. /** If the source is a filter, returns the parent source of the filter */
  520. EXPORT obs_source_t *obs_filter_get_parent(const obs_source_t *filter);
  521. /** If the source is a filter, returns the target source of the filter */
  522. EXPORT obs_source_t *obs_filter_get_target(const obs_source_t *filter);
  523. /** Adds a filter to the source (which is used whenever the source is used) */
  524. EXPORT void obs_source_filter_add(obs_source_t *source, obs_source_t *filter);
  525. /** Removes a filter from the source */
  526. EXPORT void obs_source_filter_remove(obs_source_t *source,
  527. obs_source_t *filter);
  528. /** Modifies the order of a specific filter */
  529. EXPORT void obs_source_filter_set_order(obs_source_t *source,
  530. obs_source_t *filter, enum obs_order_movement movement);
  531. /** Gets the settings string for a source */
  532. EXPORT obs_data_t *obs_source_get_settings(const obs_source_t *source);
  533. /** Gets the name of a source */
  534. EXPORT const char *obs_source_get_name(const obs_source_t *source);
  535. /** Sets the name of a source */
  536. EXPORT void obs_source_set_name(obs_source_t *source, const char *name);
  537. /** Gets the source type */
  538. EXPORT enum obs_source_type obs_source_get_type(const obs_source_t *source);
  539. /** Gets the source identifier */
  540. EXPORT const char *obs_source_get_id(const obs_source_t *source);
  541. /** Returns the signal handler for a source */
  542. EXPORT signal_handler_t *obs_source_get_signal_handler(
  543. const obs_source_t *source);
  544. /** Returns the procedure handler for a source */
  545. EXPORT proc_handler_t *obs_source_get_proc_handler(const obs_source_t *source);
  546. /** Sets the user volume for a source that has audio output */
  547. EXPORT void obs_source_set_volume(obs_source_t *source, float volume);
  548. /** Sets the presentation volume for a source */
  549. EXPORT void obs_source_set_present_volume(obs_source_t *source, float volume);
  550. /** Gets the user volume for a source that has audio output */
  551. EXPORT float obs_source_get_volume(const obs_source_t *source);
  552. /** Gets the presentation volume for a source */
  553. EXPORT float obs_source_get_present_volume(const obs_source_t *source);
  554. /** Sets the audio sync offset (in nanoseconds) for a source */
  555. EXPORT void obs_source_set_sync_offset(obs_source_t *source, int64_t offset);
  556. /** Gets the audio sync offset (in nanoseconds) for a source */
  557. EXPORT int64_t obs_source_get_sync_offset(const obs_source_t *source);
  558. /** Enumerates child sources used by this source */
  559. EXPORT void obs_source_enum_sources(obs_source_t *source,
  560. obs_source_enum_proc_t enum_callback,
  561. void *param);
  562. /** Enumerates the entire child source tree used by this source */
  563. EXPORT void obs_source_enum_tree(obs_source_t *source,
  564. obs_source_enum_proc_t enum_callback,
  565. void *param);
  566. /** Returns true if active, false if not */
  567. EXPORT bool obs_source_active(const obs_source_t *source);
  568. /**
  569. * Sometimes sources need to be told when to save their settings so they
  570. * don't have to constantly update and keep track of their settings. This will
  571. * call the source's 'save' callback if any, which will save its current
  572. * data to its settings.
  573. */
  574. EXPORT void obs_source_save(obs_source_t *source);
  575. /**
  576. * Sometimes sources need to be told when they are loading their settings
  577. * from prior saved data. This is different from a source 'update' in that
  578. * it's meant to be used after the source has been created and loaded from
  579. * somewhere (such as a saved file).
  580. */
  581. EXPORT void obs_source_load(obs_source_t *source);
  582. /** Specifies that async video frames should be played as soon as possible */
  583. #define OBS_SOURCE_UNBUFFERED (1<<0)
  584. /** Sets source flags. Note that these are different from the main output
  585. * flags. */
  586. EXPORT void obs_source_set_flags(obs_source_t *source, uint32_t flags);
  587. /** Gets source flags. */
  588. EXPORT uint32_t obs_source_get_flags(const obs_source_t *source);
  589. /* ------------------------------------------------------------------------- */
  590. /* Functions used by sources */
  591. /** Outputs asynchronous video data */
  592. EXPORT void obs_source_output_video(obs_source_t *source,
  593. const struct obs_source_frame *frame);
  594. /** Outputs audio data (always asynchronous) */
  595. EXPORT void obs_source_output_audio(obs_source_t *source,
  596. const struct obs_source_audio *audio);
  597. /** Signal an update to any currently used properties via 'update_properties' */
  598. EXPORT void obs_source_update_properties(obs_source_t *source);
  599. /** Gets the current async video frame */
  600. EXPORT struct obs_source_frame *obs_source_get_frame(obs_source_t *source);
  601. /** Releases the current async video frame */
  602. EXPORT void obs_source_release_frame(obs_source_t *source,
  603. struct obs_source_frame *frame);
  604. /** Default RGB filter handler for generic effect filters */
  605. EXPORT void obs_source_process_filter(obs_source_t *filter, gs_effect_t *effect,
  606. uint32_t width, uint32_t height, enum gs_color_format format,
  607. enum obs_allow_direct_render allow_direct);
  608. /**
  609. * Adds a child source. Must be called by parent sources on child sources
  610. * when the child is added. This ensures that the source is properly activated
  611. * if the parent is active.
  612. */
  613. EXPORT void obs_source_add_child(obs_source_t *parent, obs_source_t *child);
  614. /**
  615. * Removes a child source. Must be called by parent sources on child sources
  616. * when the child is removed. This ensures that the source is properly
  617. * deactivated if the parent is active.
  618. */
  619. EXPORT void obs_source_remove_child(obs_source_t *parent, obs_source_t *child);
  620. /** Sends a mouse down/up event to a source */
  621. EXPORT void obs_source_send_mouse_click(obs_source_t *source,
  622. const struct obs_mouse_event *event,
  623. int32_t type, bool mouse_up,
  624. uint32_t click_count);
  625. /** Sends a mouse move event to a source. */
  626. EXPORT void obs_source_send_mouse_move(obs_source_t *source,
  627. const struct obs_mouse_event *event, bool mouse_leave);
  628. /** Sends a mouse wheel event to a source */
  629. EXPORT void obs_source_send_mouse_wheel(obs_source_t *source,
  630. const struct obs_mouse_event *event, int x_delta, int y_delta);
  631. /** Sends a got-focus or lost-focus event to a source */
  632. EXPORT void obs_source_send_focus(obs_source_t *source, bool focus);
  633. /** Sends a key up/down event to a source */
  634. EXPORT void obs_source_send_key_click(obs_source_t *source,
  635. const struct obs_key_event *event, bool key_up);
  636. /** Begins transition frame. Sets all transitioning volume values to 0.0f. */
  637. EXPORT void obs_transition_begin_frame(obs_source_t *transition);
  638. /**
  639. * Adds a transitioning volume value to a source that's being transitioned.
  640. * This value is applied to all the sources within the the source.
  641. */
  642. EXPORT void obs_source_set_transition_vol(obs_source_t *source, float vol);
  643. /** Ends transition frame and applies new presentation volumes to all sources */
  644. EXPORT void obs_transition_end_frame(obs_source_t *transition);
  645. /* ------------------------------------------------------------------------- */
  646. /* Scenes */
  647. /**
  648. * Creates a scene.
  649. *
  650. * A scene is a source which is a container of other sources with specific
  651. * display oriantations. Scenes can also be used like any other source.
  652. */
  653. EXPORT obs_scene_t *obs_scene_create(const char *name);
  654. EXPORT void obs_scene_addref(obs_scene_t *scene);
  655. EXPORT void obs_scene_release(obs_scene_t *scene);
  656. /** Gets the scene's source context */
  657. EXPORT obs_source_t *obs_scene_get_source(const obs_scene_t *scene);
  658. /** Gets the scene from its source, or NULL if not a scene */
  659. EXPORT obs_scene_t *obs_scene_from_source(const obs_source_t *source);
  660. /** Determines whether a source is within a scene */
  661. EXPORT obs_sceneitem_t *obs_scene_find_source(obs_scene_t *scene,
  662. const char *name);
  663. /** Enumerates sources within a scene */
  664. EXPORT void obs_scene_enum_items(obs_scene_t *scene,
  665. bool (*callback)(obs_scene_t*, obs_sceneitem_t*, void*),
  666. void *param);
  667. /** Adds/creates a new scene item for a source */
  668. EXPORT obs_sceneitem_t *obs_scene_add(obs_scene_t *scene, obs_source_t *source);
  669. EXPORT void obs_sceneitem_addref(obs_sceneitem_t *item);
  670. EXPORT void obs_sceneitem_release(obs_sceneitem_t *item);
  671. /** Removes a scene item. */
  672. EXPORT void obs_sceneitem_remove(obs_sceneitem_t *item);
  673. /** Gets the scene parent associated with the scene item. */
  674. EXPORT obs_scene_t *obs_sceneitem_get_scene(const obs_sceneitem_t *item);
  675. /** Gets the source of a scene item. */
  676. EXPORT obs_source_t *obs_sceneitem_get_source(const obs_sceneitem_t *item);
  677. EXPORT void obs_sceneitem_select(obs_sceneitem_t *item, bool select);
  678. EXPORT bool obs_sceneitem_selected(const obs_sceneitem_t *item);
  679. /* Functions for gettings/setting specific orientation of a scene item */
  680. EXPORT void obs_sceneitem_set_pos(obs_sceneitem_t *item, const struct vec2 *pos);
  681. EXPORT void obs_sceneitem_set_rot(obs_sceneitem_t *item, float rot_deg);
  682. EXPORT void obs_sceneitem_set_scale(obs_sceneitem_t *item,
  683. const struct vec2 *scale);
  684. EXPORT void obs_sceneitem_set_alignment(obs_sceneitem_t *item,
  685. uint32_t alignment);
  686. EXPORT void obs_sceneitem_set_order(obs_sceneitem_t *item,
  687. enum obs_order_movement movement);
  688. EXPORT void obs_sceneitem_set_bounds_type(obs_sceneitem_t *item,
  689. enum obs_bounds_type type);
  690. EXPORT void obs_sceneitem_set_bounds_alignment(obs_sceneitem_t *item,
  691. uint32_t alignment);
  692. EXPORT void obs_sceneitem_set_bounds(obs_sceneitem_t *item,
  693. const struct vec2 *bounds);
  694. EXPORT void obs_sceneitem_get_pos(const obs_sceneitem_t *item,
  695. struct vec2 *pos);
  696. EXPORT float obs_sceneitem_get_rot(const obs_sceneitem_t *item);
  697. EXPORT void obs_sceneitem_get_scale(const obs_sceneitem_t *item,
  698. struct vec2 *scale);
  699. EXPORT uint32_t obs_sceneitem_get_alignment(const obs_sceneitem_t *item);
  700. EXPORT enum obs_bounds_type obs_sceneitem_get_bounds_type(
  701. const obs_sceneitem_t *item);
  702. EXPORT uint32_t obs_sceneitem_get_bounds_alignment(const obs_sceneitem_t *item);
  703. EXPORT void obs_sceneitem_get_bounds(const obs_sceneitem_t *item,
  704. struct vec2 *bounds);
  705. EXPORT void obs_sceneitem_get_info(const obs_sceneitem_t *item,
  706. struct obs_transform_info *info);
  707. EXPORT void obs_sceneitem_set_info(obs_sceneitem_t *item,
  708. const struct obs_transform_info *info);
  709. EXPORT void obs_sceneitem_get_draw_transform(const obs_sceneitem_t *item,
  710. struct matrix4 *transform);
  711. EXPORT void obs_sceneitem_get_box_transform(const obs_sceneitem_t *item,
  712. struct matrix4 *transform);
  713. /* ------------------------------------------------------------------------- */
  714. /* Outputs */
  715. EXPORT const char *obs_output_get_display_name(const char *id);
  716. /**
  717. * Creates an output.
  718. *
  719. * Outputs allow outputting to file, outputting to network, outputting to
  720. * directshow, or other custom outputs.
  721. */
  722. EXPORT obs_output_t *obs_output_create(const char *id, const char *name,
  723. obs_data_t *settings);
  724. EXPORT void obs_output_destroy(obs_output_t *output);
  725. EXPORT const char *obs_output_get_name(const obs_output_t *output);
  726. /** Starts the output. */
  727. EXPORT bool obs_output_start(obs_output_t *output);
  728. /** Stops the output. */
  729. EXPORT void obs_output_stop(obs_output_t *output);
  730. /** Returns whether the output is active */
  731. EXPORT bool obs_output_active(const obs_output_t *output);
  732. /** Gets the default settings for an output type */
  733. EXPORT obs_data_t *obs_output_defaults(const char *id);
  734. /** Returns the property list, if any. Free with obs_properties_destroy */
  735. EXPORT obs_properties_t *obs_get_output_properties(const char *id);
  736. /**
  737. * Returns the property list of an existing output, if any. Free with
  738. * obs_properties_destroy
  739. */
  740. EXPORT obs_properties_t *obs_output_properties(const obs_output_t *output);
  741. /** Updates the settings for this output context */
  742. EXPORT void obs_output_update(obs_output_t *output, obs_data_t *settings);
  743. /** Specifies whether the output can be paused */
  744. EXPORT bool obs_output_canpause(const obs_output_t *output);
  745. /** Pauses the output (if the functionality is allowed by the output */
  746. EXPORT void obs_output_pause(obs_output_t *output);
  747. /* Gets the current output settings string */
  748. EXPORT obs_data_t *obs_output_get_settings(const obs_output_t *output);
  749. /** Returns the signal handler for an output */
  750. EXPORT signal_handler_t *obs_output_get_signal_handler(
  751. const obs_output_t *output);
  752. /** Returns the procedure handler for an output */
  753. EXPORT proc_handler_t *obs_output_get_proc_handler(const obs_output_t *output);
  754. /**
  755. * Sets the current video media context associated with this output,
  756. * required for non-encoded outputs
  757. */
  758. EXPORT void obs_output_set_video(obs_output_t *output, video_t *video);
  759. /**
  760. * Sets the current audio/video media contexts associated with this output,
  761. * required for non-encoded outputs. Can be null.
  762. */
  763. EXPORT void obs_output_set_media(obs_output_t *output,
  764. video_t *video, audio_t *audio);
  765. /** Returns the video media context associated with this output */
  766. EXPORT video_t *obs_output_video(const obs_output_t *output);
  767. /** Returns the audio media context associated with this output */
  768. EXPORT audio_t *obs_output_audio(const obs_output_t *output);
  769. /**
  770. * Sets the current video encoder associated with this output,
  771. * required for encoded outputs
  772. */
  773. EXPORT void obs_output_set_video_encoder(obs_output_t *output,
  774. obs_encoder_t *encoder);
  775. /**
  776. * Sets the current audio encoder associated with this output,
  777. * required for encoded outputs
  778. */
  779. EXPORT void obs_output_set_audio_encoder(obs_output_t *output,
  780. obs_encoder_t *encoder);
  781. /** Returns the current video encoder associated with this output */
  782. EXPORT obs_encoder_t *obs_output_get_video_encoder(const obs_output_t *output);
  783. /** Returns the current audio encoder associated with this output */
  784. EXPORT obs_encoder_t *obs_output_get_audio_encoder(const obs_output_t *output);
  785. /** Sets the current service associated with this output. */
  786. EXPORT void obs_output_set_service(obs_output_t *output,
  787. obs_service_t *service);
  788. /** Gets the current service associated with this output. */
  789. EXPORT obs_service_t *obs_output_get_service(const obs_output_t *output);
  790. /**
  791. * Sets the reconnect settings. Set retry_count to 0 to disable reconnecting.
  792. */
  793. EXPORT void obs_output_set_reconnect_settings(obs_output_t *output,
  794. int retry_count, int retry_sec);
  795. EXPORT uint64_t obs_output_get_total_bytes(const obs_output_t *output);
  796. EXPORT int obs_output_get_frames_dropped(const obs_output_t *output);
  797. EXPORT int obs_output_get_total_frames(const obs_output_t *output);
  798. /**
  799. * Sets the preferred scaled resolution for this output. Set width and height
  800. * to 0 to disable scaling.
  801. *
  802. * If this output uses an encoder, it will call obs_encoder_set_scaled_size on
  803. * the encoder before the stream is started. If the encoder is already active,
  804. * then this function will trigger a warning and do nothing.
  805. */
  806. EXPORT void obs_output_set_preferred_size(obs_output_t *output, uint32_t width,
  807. uint32_t height);
  808. /** For video outputs, returns the width of the encoded image */
  809. EXPORT uint32_t obs_output_get_width(const obs_output_t *output);
  810. /** For video outputs, returns the height of the encoded image */
  811. EXPORT uint32_t obs_output_get_height(const obs_output_t *output);
  812. /* ------------------------------------------------------------------------- */
  813. /* Functions used by outputs */
  814. /** Optionally sets the video conversion info. Used only for raw output */
  815. EXPORT void obs_output_set_video_conversion(obs_output_t *output,
  816. const struct video_scale_info *conversion);
  817. /** Optionally sets the audio conversion info. Used only for raw output */
  818. EXPORT void obs_output_set_audio_conversion(obs_output_t *output,
  819. const struct audio_convert_info *conversion);
  820. /** Returns whether data capture can begin with the specified flags */
  821. EXPORT bool obs_output_can_begin_data_capture(const obs_output_t *output,
  822. uint32_t flags);
  823. /** Initializes encoders (if any) */
  824. EXPORT bool obs_output_initialize_encoders(obs_output_t *output,
  825. uint32_t flags);
  826. /**
  827. * Begins data capture from media/encoders.
  828. *
  829. * @param output Output context
  830. * @param flags Set this to 0 to use default output flags set in the
  831. * obs_output_info structure, otherwise set to a either
  832. * OBS_OUTPUT_VIDEO or OBS_OUTPUT_AUDIO to specify whether to
  833. * connect audio or video. This is useful for things like
  834. * ffmpeg which may or may not always want to use both audio
  835. * and video.
  836. * @return true if successful, false otherwise.
  837. */
  838. EXPORT bool obs_output_begin_data_capture(obs_output_t *output, uint32_t flags);
  839. /** Ends data capture from media/encoders */
  840. EXPORT void obs_output_end_data_capture(obs_output_t *output);
  841. /**
  842. * Signals that the output has stopped itself.
  843. *
  844. * @param output Output context
  845. * @param code Error code (or OBS_OUTPUT_SUCCESS if not an error)
  846. */
  847. EXPORT void obs_output_signal_stop(obs_output_t *output, int code);
  848. /* ------------------------------------------------------------------------- */
  849. /* Encoders */
  850. EXPORT const char *obs_encoder_getdisplayname(const char *id);
  851. /**
  852. * Creates a video encoder context
  853. *
  854. * @param id Video encoder ID
  855. * @param name Name to assign to this context
  856. * @param settings Settings
  857. * @return The video encoder context, or NULL if failed or not found.
  858. */
  859. EXPORT obs_encoder_t *obs_video_encoder_create(const char *id, const char *name,
  860. obs_data_t *settings);
  861. /**
  862. * Creates an audio encoder context
  863. *
  864. * @param id Audio Encoder ID
  865. * @param name Name to assign to this context
  866. * @param settings Settings
  867. * @return The video encoder context, or NULL if failed or not found.
  868. */
  869. EXPORT obs_encoder_t *obs_audio_encoder_create(const char *id, const char *name,
  870. obs_data_t *settings);
  871. /** Destroys an encoder context */
  872. EXPORT void obs_encoder_destroy(obs_encoder_t *encoder);
  873. EXPORT const char *obs_encoder_get_name(const obs_encoder_t *encoder);
  874. /** Returns the codec of the encoder */
  875. EXPORT const char *obs_encoder_get_codec(const obs_encoder_t *encoder);
  876. /**
  877. * Sets the scaled resolution for a video encoder. Set width and height to 0
  878. * to disable scaling. If the encoder is active, this function will trigger
  879. * a warning, and do nothing.
  880. */
  881. EXPORT void obs_encoder_set_scaled_size(obs_encoder_t *encoder, uint32_t width,
  882. uint32_t height);
  883. /** For video encoders, returns the width of the encoded image */
  884. EXPORT uint32_t obs_encoder_get_width(const obs_encoder_t *encoder);
  885. /** For video encoders, returns the height of the encoded image */
  886. EXPORT uint32_t obs_encoder_get_height(const obs_encoder_t *encoder);
  887. /** Gets the default settings for an encoder type */
  888. EXPORT obs_data_t *obs_encoder_defaults(const char *id);
  889. /** Returns the property list, if any. Free with obs_properties_destroy */
  890. EXPORT obs_properties_t *obs_get_encoder_properties(const char *id);
  891. /**
  892. * Returns the property list of an existing encoder, if any. Free with
  893. * obs_properties_destroy
  894. */
  895. EXPORT obs_properties_t *obs_encoder_properties(const obs_encoder_t *encoder);
  896. /**
  897. * Updates the settings of the encoder context. Usually used for changing
  898. * bitrate while active
  899. */
  900. EXPORT void obs_encoder_update(obs_encoder_t *encoder, obs_data_t *settings);
  901. /** Gets extra data (headers) associated with this context */
  902. EXPORT bool obs_encoder_get_extra_data(const obs_encoder_t *encoder,
  903. uint8_t **extra_data, size_t *size);
  904. /** Returns the current settings for this encoder */
  905. EXPORT obs_data_t *obs_encoder_get_settings(const obs_encoder_t *encoder);
  906. /** Sets the video output context to be used with this encoder */
  907. EXPORT void obs_encoder_set_video(obs_encoder_t *encoder, video_t *video);
  908. /** Sets the audio output context to be used with this encoder */
  909. EXPORT void obs_encoder_set_audio(obs_encoder_t *encoder, audio_t *audio);
  910. /**
  911. * Returns the video output context used with this encoder, or NULL if not
  912. * a video context
  913. */
  914. EXPORT video_t *obs_encoder_video(const obs_encoder_t *encoder);
  915. /**
  916. * Returns the audio output context used with this encoder, or NULL if not
  917. * a audio context
  918. */
  919. EXPORT audio_t *obs_encoder_audio(const obs_encoder_t *encoder);
  920. /** Returns true if encoder is active, false otherwise */
  921. EXPORT bool obs_encoder_active(const obs_encoder_t *encoder);
  922. /** Duplicates an encoder packet */
  923. EXPORT void obs_duplicate_encoder_packet(struct encoder_packet *dst,
  924. const struct encoder_packet *src);
  925. EXPORT void obs_free_encoder_packet(struct encoder_packet *packet);
  926. /* ------------------------------------------------------------------------- */
  927. /* Stream Services */
  928. EXPORT const char *obs_service_get_display_name(const char *id);
  929. EXPORT obs_service_t *obs_service_create(const char *id, const char *name,
  930. obs_data_t *settings);
  931. EXPORT void obs_service_destroy(obs_service_t *service);
  932. EXPORT const char *obs_service_get_name(const obs_service_t *service);
  933. /** Gets the default settings for a service */
  934. EXPORT obs_data_t *obs_service_defaults(const char *id);
  935. /** Returns the property list, if any. Free with obs_properties_destroy */
  936. EXPORT obs_properties_t *obs_get_service_properties(const char *id);
  937. /**
  938. * Returns the property list of an existing service context, if any. Free with
  939. * obs_properties_destroy
  940. */
  941. EXPORT obs_properties_t *obs_service_properties(const obs_service_t *service);
  942. /** Gets the service type */
  943. EXPORT const char *obs_service_gettype(const obs_service_t *service);
  944. /** Updates the settings of the service context */
  945. EXPORT void obs_service_update(obs_service_t *service, obs_data_t *settings);
  946. /** Returns the current settings for this service */
  947. EXPORT obs_data_t *obs_service_get_settings(const obs_service_t *service);
  948. /** Returns the URL for this service context */
  949. EXPORT const char *obs_service_get_url(const obs_service_t *service);
  950. /** Returns the stream key (if any) for this service context */
  951. EXPORT const char *obs_service_get_key(const obs_service_t *service);
  952. /** Returns the username (if any) for this service context */
  953. EXPORT const char *obs_service_get_username(const obs_service_t *service);
  954. /** Returns the password (if any) for this service context */
  955. EXPORT const char *obs_service_get_password(const obs_service_t *service);
  956. /* ------------------------------------------------------------------------- */
  957. /* Source frame allocation functions */
  958. EXPORT void obs_source_frame_init(struct obs_source_frame *frame,
  959. enum video_format format, uint32_t width, uint32_t height);
  960. static inline void obs_source_frame_free(struct obs_source_frame *frame)
  961. {
  962. if (frame) {
  963. bfree(frame->data[0]);
  964. memset(frame, 0, sizeof(*frame));
  965. }
  966. }
  967. static inline struct obs_source_frame *obs_source_frame_create(
  968. enum video_format format, uint32_t width, uint32_t height)
  969. {
  970. struct obs_source_frame *frame;
  971. frame = (struct obs_source_frame*)bzalloc(sizeof(*frame));
  972. obs_source_frame_init(frame, format, width, height);
  973. return frame;
  974. }
  975. static inline void obs_source_frame_destroy(struct obs_source_frame *frame)
  976. {
  977. if (frame) {
  978. bfree(frame->data[0]);
  979. bfree(frame);
  980. }
  981. }
  982. #ifdef __cplusplus
  983. }
  984. #endif