obs.h 104 KB

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