obs.h 45 KB

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