reference-sources.rst 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782
  1. Source API Reference (obs_source_t)
  2. ===================================
  3. Sources are used to render video and/or audio on stream. Things such as
  4. capturing displays/games/audio, playing a video, showing an image, or
  5. playing audio. Sources can also be used to implement audio and video
  6. filters as well as transitions. The `libobs/obs-source.h`_ file is the
  7. dedicated header for implementing sources.
  8. .. type:: obs_source_t
  9. A reference-counted video/audio input source.
  10. .. type:: obs_weak_source_t
  11. A weak reference to an video/audio input source.
  12. .. code:: cpp
  13. #include <obs.h>
  14. Source Definition Structure (obs_source_info)
  15. ---------------------------------------------
  16. .. struct:: obs_source_info
  17. Source definition structure.
  18. .. member:: const char *obs_source_info.id
  19. Unique string identifier for the source (required).
  20. .. member:: uint32_t version
  21. Source version (optional).
  22. This is used when a source's implementation is significantly
  23. modified and the previous version is deprecated, but is kept to
  24. prevent old sources from breaking.
  25. .. member:: enum obs_source_type obs_source_info.type
  26. Type of source.
  27. - **OBS_SOURCE_TYPE_INPUT** - Video/Audio Input
  28. - **OBS_SOURCE_TYPE_FILTER** - Filter
  29. - **OBS_SOURCE_TYPE_TRANSITION** - Transition
  30. .. member:: uint32_t obs_source_info.output_flags
  31. Source output capability flags (required).
  32. (Author's note: This should be renamed to "capability_flags")
  33. A bitwise OR combination of one or more of the following values:
  34. - **OBS_SOURCE_VIDEO** - Source has video
  35. Unless SOURCE_ASYNC_VIDEO is specified, the source must include the
  36. :c:member:`obs_source_info.video_render` callback in the source
  37. definition structure.
  38. - **OBS_SOURCE_AUDIO** - Source has audio
  39. Use the :c:func:`obs_source_output_audio()` function to pass raw
  40. audio data, which will be automatically converted and uploaded. If
  41. used with OBS_SOURCE_ASYNC_VIDEO, audio will automatically be
  42. synced up to the video output based upon their mutual timestamps.
  43. - **OBS_SOURCE_ASYNC** - Video is asynchronous (use
  44. OBS_SOURCE_ASYNC_VIDEO instead to automatically combine this flag
  45. with the OBS_SOURCE_VIDEO flag).
  46. - **OBS_SOURCE_ASYNC_VIDEO** - Source passes raw video data via RAM
  47. Use the :c:func:`obs_source_output_video()` function to pass raw
  48. video data, which will be automatically drawn at a timing relative
  49. to the provided timestamp.
  50. If audio is also present on the source, the audio will
  51. automatically be synced to the video based upon their mutual
  52. timestamps.
  53. - **OBS_SOURCE_CUSTOM_DRAW** - Source uses custom graphics calls,
  54. rather than just rendering a single texture.
  55. This capability flag must be used if the source does not use
  56. :c:func:`obs_source_draw()` to render a single texture.
  57. This capability flag is an important hint to turn off a specific
  58. optimization that allows the first effect filter in the filter
  59. chain to render the source directly with that effect filter. The
  60. optimization does not work if there are custom graphics calls, and
  61. the source must be rendered to a texture first before being sent to
  62. the first filter in the filter chain.
  63. (Author's note: Ironically, not many sources render with that
  64. optimization. I should have made it so that the optimization isn't
  65. used by default, and a flag should have been used to turn on the
  66. optimization -- not turn it off).
  67. - **OBS_SOURCE_INTERACTION** - Source can be interacted with by the
  68. user.
  69. When this is used, the source will receive interaction events if
  70. these callbacks are provided:
  71. :c:member:`obs_source_info.mouse_click`,
  72. :c:member:`obs_source_info.mouse_move`,
  73. :c:member:`obs_source_info.mouse_wheel`,
  74. :c:member:`obs_source_info.focus`, and
  75. :c:member:`obs_source_info.key_click`.
  76. - **OBS_SOURCE_COMPOSITE** - Source composites child sources
  77. When used, specifies that the source composites one or more child
  78. sources. Scenes and transitions are examples of sources that
  79. contain and render child sources.
  80. Sources that render sub-sources must implement the audio_render
  81. callback in order to perform custom audio mixing of child sources.
  82. This capability flag is always set for transitions.
  83. - **OBS_SOURCE_DO_NOT_DUPLICATE** - Source should not be fully
  84. duplicated.
  85. When this is used, specifies that the source should not be fully
  86. duplicated, and should prefer to duplicate via holding references
  87. rather than full duplication.
  88. When functions such as :c:func:`obs_source_duplicate()` or
  89. :c:func:`obs_scene_duplicate()` are called, sources or child
  90. sources with this flag will never be fully duplicated, and will
  91. instead only be referenced.
  92. An example of the type of sources that should not be fully
  93. duplicated are video devices, browsers, and video/audio captures,
  94. as they will either not function correctly or will cause
  95. performance or resource issues when duplicated.
  96. - **OBS_SOURCE_DEPRECATED** - Source is deprecated and should not be
  97. used.
  98. - **OBS_SOURCE_DO_NOT_SELF_MONITOR** - Audio of this source should
  99. not allow monitoring if the current monitoring device is the same
  100. device being captured by the source.
  101. This flag is used as a hint to the back-end to prevent the source
  102. from creating an audio feedback loop. This is primarily only used
  103. with desktop audio capture sources.
  104. - **OBS_SOURCE_CAP_DISABLED** - This source type has been disabled
  105. and should not be shown as a type of source the user can add.
  106. - **OBS_SOURCE_CAP_OBSOLETE** - This source type is obsolete and
  107. should not be shown as a type of source the user can add.
  108. Identical to *OBS_SOURCE_CAP_DISABLED*. Meant to be used when a
  109. source has changed in some way (mostly defaults/properties), but
  110. you want to avoid breaking older configurations. Basically solves
  111. the problem of "I want to change the defaults of a source but I
  112. don't want to break people's configurations"
  113. - **OBS_SOURCE_CONTROLLABLE_MEDIA** - This source has media that can
  114. be controlled
  115. - **OBS_SOURCE_MONITOR_BY_DEFAULT** - Source should enable
  116. monitoring by default. Monitoring should be set by the
  117. frontend if this flag is set.
  118. - **OBS_SOURCE_CEA_708** - Source type provides cea708 data
  119. - **OBS_SOURCE_SRGB** - Source understands SRGB rendering
  120. - **OBS_SOURCE_CAP_DONT_SHOW_PROPERTIES** - Source type prefers not
  121. to have its properties shown on creation (prefers to rely on
  122. defaults first)
  123. .. member:: const char *(*obs_source_info.get_name)(void *type_data)
  124. Get the translated name of the source type.
  125. :param type_data: The type_data variable of this structure
  126. :return: The translated name of the source type
  127. .. member:: void *(*obs_source_info.create)(obs_data_t *settings, obs_source_t *source)
  128. Creates the implementation data for the source.
  129. :param settings: Settings to initialize the source with
  130. :param source: Source that this data is associated with
  131. :return: The implementation data associated with this source
  132. .. member:: void (*obs_source_info.destroy)(void *data)
  133. Destroys the implementation data for the source.
  134. Async sources must not call obs_source_output_video after returning
  135. from destroy.
  136. .. member:: uint32_t (*obs_source_info.get_width)(void *data)
  137. uint32_t (*obs_source_info.get_height)(void *data)
  138. Returns the width/height of the source. These callbacks are required
  139. if this is a video source and is synchronous.
  140. (Author's note: These should really be consolidated in to one
  141. function, not two)
  142. :return: The width/height of the video
  143. .. member:: void (*obs_source_info.get_defaults)(obs_data_t *settings)
  144. void (*obs_source_info.get_defaults2)(void *type_data, obs_data_t *settings)
  145. Sets the default settings for this source.
  146. :param settings: Default settings. Call obs_data_set_default*
  147. functions on this object to set default setting
  148. values
  149. .. member:: obs_properties_t *(*obs_source_info.get_properties)(void *data)
  150. obs_properties_t *(*obs_source_info.get_properties2)(void *data, void *type_data)
  151. Gets the property information of this source.
  152. (Optional)
  153. :return: The properties of the source
  154. .. member:: void (*obs_source_info.update)(void *data, obs_data_t *settings)
  155. Updates the settings for this source.
  156. (Optional)
  157. :param settings: New settings for this source
  158. .. member:: void (*obs_source_info.activate)(void *data)
  159. Called when the source has been activated in the main view (visible
  160. on stream/recording).
  161. (Optional)
  162. .. member:: void (*obs_source_info.deactivate)(void *data)
  163. Called when the source has been deactivated from the main view (no
  164. longer visible on stream/recording).
  165. (Optional)
  166. .. member:: void (*obs_source_info.show)(void *data)
  167. Called when the source is visible on any display and/or on the main
  168. view.
  169. (Optional)
  170. .. member:: void (*obs_source_info.hide)(void *data)
  171. Called when the source is no longer visible on any display and/or on
  172. the main view.
  173. (Optional)
  174. .. member:: void (*obs_source_info.video_tick)(void *data, float seconds)
  175. Called each video frame with the time elapsed.
  176. (Optional)
  177. :param seconds: Seconds elapsed since the last frame
  178. .. member:: void (*obs_source_info.video_render)(void *data, gs_effect_t *effect)
  179. Called when rendering the source with the graphics subsystem.
  180. If this is an input/transition source, this is called to draw the
  181. source texture with the graphics subsystem.
  182. If this is a filter source, it wraps source draw calls (for example
  183. applying a custom effect with custom parameters to a source). In
  184. this case, it's highly recommended to use the
  185. :c:func:`obs_source_process_filter_begin()` and
  186. :c:func:`obs_source_process_filter_end()` functions to automatically
  187. handle effect-based filter processing. However, you can implement
  188. custom draw handling as desired as well.
  189. If the source output capability flags do not include
  190. OBS_SOURCE_CUSTOM_DRAW, the source must use
  191. :c:func:`obs_source_draw()` to render the source's texture.
  192. :param effect: This parameter is no longer used. Instead, call
  193. :c:func:`obs_source_draw()`
  194. .. member:: struct obs_source_frame *(*obs_source_info.filter_video)(void *data, struct obs_source_frame *frame)
  195. Called to filter raw async video data. This function is only used
  196. with asynchronous video filters.
  197. :param frame: Video frame to filter
  198. :return: New video frame data. This can defer video data to
  199. be drawn later if time is needed for processing
  200. .. member:: struct obs_audio_data *(*obs_source_info.filter_audio)(void *data, struct obs_audio_data *audio)
  201. Called to filter raw audio data. This function is only used with
  202. audio filters.
  203. :param audio: Audio data to filter
  204. :return: Modified or new audio data. You can directly modify
  205. the data passed and return it, or you can defer audio
  206. data for later if time is needed for processing. If
  207. you are returning new data, that data must exist until
  208. the next call to the
  209. :c:member:`obs_source_info.filter_audio` callback or
  210. until the filter is removed/destroyed
  211. .. member:: void (*obs_source_info.enum_active_sources)(void *data, obs_source_enum_proc_t enum_callback, void *param)
  212. Called to enumerate all active sources being used within this
  213. source. If the source has children that render audio/video it must
  214. implement this callback. Only used with sources that have the
  215. OBS_SOURCE_COMPOSITE output capability flag.
  216. :param enum_callback: Enumeration callback
  217. :param param: User data to pass to callback
  218. .. member:: void (*obs_source_info.save)(void *data, obs_data_t *settings)
  219. Called when saving custom data for a source. This is a separate
  220. function because sometimes a source needs to know when it is being
  221. saved so it doesn't always have to update the current settings until
  222. a certain point.
  223. (Optional)
  224. :param settings: Settings object to save data to
  225. .. member:: void (*obs_source_info.load)(void *data, obs_data_t *settings)
  226. Called when loading custom data from saved source data. This is
  227. called after all the loading sources have actually been created,
  228. allowing the ability to reference other sources if desired.
  229. (Optional)
  230. :param settings: Settings object to load data from
  231. .. member:: void (*obs_source_info.mouse_click)(void *data, const struct obs_mouse_event *event, int32_t type, bool mouse_up, uint32_t click_count)
  232. Called when interacting with a source and a mouse-down or mouse-up
  233. occurs. Only used with sources that have the OBS_SOURCE_INTERACTION
  234. output capability flag.
  235. (Optional)
  236. :param event: Mouse event properties
  237. :param type: Mouse button pushed
  238. :param mouse_up: Mouse event type (true if mouse-up)
  239. :param click_count: Mouse click count (1 for single click, etc.)
  240. .. member:: void (*obs_source_info.mouse_move)(void *data, const struct obs_mouse_event *event, bool mouse_leave)
  241. Called when interacting with a source and a mouse-move occurs. Only
  242. used with sources that have the OBS_SOURCE_INTERACTION output
  243. capability flag.
  244. (Optional)
  245. :param event: Mouse event properties
  246. :param mouse_leave: Mouse leave state (true if mouse left source)
  247. .. member:: void (*obs_source_info.mouse_wheel)(void *data, const struct obs_mouse_event *event, int x_delta, int y_delta)
  248. Called when interacting with a source and a mouse-wheel occurs. Only
  249. used with sources that have the OBS_SOURCE_INTERACTION output
  250. capability flag.
  251. (Optional)
  252. :param event: Mouse event properties
  253. :param x_delta: Movement delta in the horizontal direction
  254. :param y_delta: Movement delta in the vertical direction
  255. .. member:: void (*obs_source_info.focus)(void *data, bool focus)
  256. Called when interacting with a source and gain focus/lost focus event
  257. occurs. Only used with sources that have the OBS_SOURCE_INTERACTION
  258. output capability flag.
  259. (Optional)
  260. :param focus: Focus state (true if focus gained)
  261. .. member:: void (*obs_source_info.key_click)(void *data, const struct obs_key_event *event, bool key_up)
  262. Called when interacting with a source and a key-up or key-down
  263. occurs. Only used with sources that have the OBS_SOURCE_INTERACTION
  264. output capability flag.
  265. (Optional)
  266. :param event: Key event properties
  267. :param focus: Key event type (true if mouse-up)
  268. .. member:: void (*obs_source_info.filter_remove)(void *data, obs_source_t *source)
  269. Called when the filter is removed from a source.
  270. (Optional)
  271. :param data: Filter data
  272. :param source: Source that the filter being removed from
  273. .. member:: void *obs_source_info.type_data
  274. void (*obs_source_info.free_type_data)(void *type_data)
  275. Private data associated with this entry. Note that this is not the
  276. same as the implementation data; this is used to differentiate
  277. between two different types if the same callbacks are used for more
  278. than one different type.
  279. .. member:: bool (*obs_source_info.audio_render)(void *data, uint64_t *ts_out, struct obs_source_audio_mix *audio_output, uint32_t mixers, size_t channels, size_t sample_rate)
  280. Called to render audio of composite sources. Only used with sources
  281. that have the OBS_SOURCE_COMPOSITE output capability flag.
  282. .. member:: void (*obs_source_info.enum_all_sources)(void *data, obs_source_enum_proc_t enum_callback, void *param)
  283. Called to enumerate all active and inactive sources being used
  284. within this source. If this callback isn't implemented,
  285. enum_active_sources will be called instead. Only used with sources
  286. that have the OBS_SOURCE_COMPOSITE output capability flag.
  287. This is typically used if a source can have inactive child sources.
  288. :param enum_callback: Enumeration callback
  289. :param param: User data to pass to callback
  290. .. member:: void (*obs_source_info.transition_start)(void *data)
  291. void (*obs_source_info.transition_stop)(void *data)
  292. Called on transition sources when the transition starts/stops.
  293. (Optional)
  294. .. member:: enum obs_icon_type obs_source_info.icon_type
  295. Icon used for the source.
  296. - **OBS_ICON_TYPE_UNKNOWN** - Unknown
  297. - **OBS_ICON_TYPE_IMAGE** - Image
  298. - **OBS_ICON_TYPE_COLOR** - Color
  299. - **OBS_ICON_TYPE_SLIDESHOW** - Slideshow
  300. - **OBS_ICON_TYPE_AUDIO_INPUT** - Audio Input
  301. - **OBS_ICON_TYPE_AUDIO_OUTPUT** - Audio Output
  302. - **OBS_ICON_TYPE_DESKTOP_CAPTURE** - Desktop Capture
  303. - **OBS_ICON_TYPE_WINDOW_CAPTURE** - Window Capture
  304. - **OBS_ICON_TYPE_GAME_CAPTURE** - Game Capture
  305. - **OBS_ICON_TYPE_CAMERA** - Camera
  306. - **OBS_ICON_TYPE_TEXT** - Text
  307. - **OBS_ICON_TYPE_MEDIA** - Media
  308. - **OBS_ICON_TYPE_BROWSER** - Browser
  309. - **OBS_ICON_TYPE_CUSTOM** - Custom (not implemented yet)
  310. .. member:: void (*obs_source_info.media_play_pause)(void *data, bool pause)
  311. Called to pause or play media.
  312. .. member:: void (*obs_source_info.media_restart)(void *data)
  313. Called to restart the media.
  314. .. member:: void (*obs_source_info.media_stop)(void *data)
  315. Called to stop the media.
  316. .. member:: void (*obs_source_info.media_next)(void *data)
  317. Called to go to the next media.
  318. .. member:: void (*obs_source_info.media_previous)(void *data)
  319. Called to go to the previous media.
  320. .. member:: int64_t (*obs_source_info.media_get_duration)(void *data)
  321. Called to get the media duration.
  322. .. member:: int64_t (*obs_source_info.media_get_time)(void *data)
  323. Called to get the current time of the media.
  324. .. member:: void (*obs_source_info.media_set_time)(void *data, int64_t miliseconds)
  325. Called to set the media time.
  326. .. member:: enum obs_media_state (*obs_source_info.media_get_state)(void *data)
  327. Called to get the state of the media.
  328. - **OBS_MEDIA_STATE_NONE** - None
  329. - **OBS_MEDIA_STATE_PLAYING** - Playing
  330. - **OBS_MEDIA_STATE_OPENING** - Opening
  331. - **OBS_MEDIA_STATE_BUFFERING** - Buffering
  332. - **OBS_MEDIA_STATE_PAUSED** - Paused
  333. - **OBS_MEDIA_STATE_STOPPED** - Stopped
  334. - **OBS_MEDIA_STATE_ENDED** - Ended
  335. - **OBS_MEDIA_STATE_ERROR** - Error
  336. .. member:: obs_missing_files_t *(*missing_files)(void *data)
  337. Called to get the missing files of the source.
  338. .. member:: enum gs_color_space (*obs_source_info.video_get_color_space)(void *data, size_t count, const enum gs_color_space *preferred_spaces)
  339. Returns the color space of the source. Assume GS_CS_SRGB if not
  340. implemented.
  341. There's an optimization an SDR source can do when rendering to HDR.
  342. Check if the active space is GS_CS_709_EXTENDED, and return
  343. GS_CS_709_EXTENDED instead of GS_CS_SRGB to avoid an redundant
  344. conversion. This optimization can only be done if the pixel shader
  345. outputs linear 709, which is why it's not performed by default.
  346. :return: The color space of the video
  347. .. _source_signal_handler_reference:
  348. Source Signals
  349. --------------
  350. **destroy** (ptr *source*)
  351. This signal is called when the source is about to be destroyed. Do
  352. not increment any references when using this signal.
  353. **remove** (ptr source)
  354. Called when the :c:func:`obs_source_remove()` function is called on
  355. the source.
  356. **update** (ptr source)
  357. Called when the source's settings have been updated.
  358. .. versionadded:: 29.0.0
  359. **save** (ptr source)
  360. Called when the source is being saved.
  361. **load** (ptr source)
  362. Called when the source is being loaded.
  363. **activate** (ptr source)
  364. Called when the source has been activated in the main view (visible
  365. on stream/recording).
  366. **deactivate** (ptr source)
  367. Called when the source has been deactivated from the main view (no
  368. longer visible on stream/recording).
  369. **show** (ptr source)
  370. Called when the source is visible on any display and/or on the main
  371. view.
  372. **hide** (ptr source)
  373. Called when the source is no longer visible on any display and/or on
  374. the main view.
  375. **mute** (ptr source, bool muted)
  376. Called when the source is muted/unmuted.
  377. **push_to_mute_changed** (ptr source, bool enabled)
  378. Called when push-to-mute has been enabled/disabled.
  379. **push_to_mute_delay** (ptr source, int delay)
  380. Called when the push-to-mute delay value has changed.
  381. **push_to_talk_changed** (ptr source, bool enabled)
  382. Called when push-to-talk has been enabled/disabled.
  383. **push_to_talk_delay** (ptr source, int delay)
  384. Called when the push-to-talk delay value has changed.
  385. **enable** (ptr source, bool enabled)
  386. Called when the source has been disabled/enabled.
  387. **rename** (ptr source, string new_name, string prev_name)
  388. Called when the source has been renamed.
  389. **volume** (ptr source, in out float volume)
  390. Called when the volume of the source has changed.
  391. **update_properties** (ptr source)
  392. Called when the properties of the source have been updated.
  393. **update_flags** (ptr source, int flags)
  394. Called when the flags of the source have been changed.
  395. **audio_sync** (ptr source, int out int offset)
  396. Called when the audio sync offset has changed.
  397. **audio_balance** (ptr source, in out float balance)
  398. Called when the audio balance has changed.
  399. **audio_mixers** (ptr source, in out int mixers)
  400. Called when the audio mixers have changed.
  401. **filter_add** (ptr source, ptr filter)
  402. Called when a filter has been added to the source.
  403. **filter_remove** (ptr source, ptr filter)
  404. Called when a filter has been removed from the source.
  405. **reorder_filters** (ptr source)
  406. Called when filters have been reordered.
  407. **transition_start** (ptr source)
  408. Called when a transition is starting.
  409. **transition_video_stop** (ptr source)
  410. Called when a transition's video transitioning has stopped.
  411. **transition_stop** (ptr source)
  412. Called when a transition has stopped.
  413. **media_started**
  414. Called when media has started.
  415. **media_ended**
  416. Called when media has ended.
  417. **media_pause**
  418. Called when media has been paused.
  419. **media_play**
  420. Called when media starts playing.
  421. **media_restart**
  422. Called when the playing of media has been restarted.
  423. **media_stopped**
  424. Called when the playing of media has been stopped.
  425. **media_next**
  426. Called when the media source switches to the next media.
  427. **media_previous**
  428. Called when the media source switches to the previous media.
  429. General Source Functions
  430. ------------------------
  431. .. function:: void obs_register_source(struct obs_source_info *info)
  432. Registers a source type. Typically used in
  433. :c:func:`obs_module_load()` or in the program's initialization phase.
  434. ---------------------
  435. .. function:: const char *obs_source_get_display_name(const char *id)
  436. Calls the :c:member:`obs_source_info.get_name` callback to get the
  437. translated display name of a source type.
  438. :param id: The source type string identifier
  439. :return: The translated display name of a source type
  440. ---------------------
  441. .. function:: obs_source_t *obs_source_create(const char *id, const char *name, obs_data_t *settings, obs_data_t *hotkey_data)
  442. Creates a source of the specified type with the specified settings.
  443. The "source" context is used for anything related to presenting
  444. or modifying video/audio. Use :c:func:`obs_source_release` to release it.
  445. :param id: The source type string identifier
  446. :param name: The desired name of the source. If this is
  447. not unique, it will be made to be unique
  448. :param settings: The settings for the source, or *NULL* if
  449. none
  450. :param hotkey_data: Saved hotkey data for the source, or *NULL*
  451. if none
  452. :return: A reference to the newly created source, or
  453. *NULL* if failed
  454. ---------------------
  455. .. function:: obs_source_t *obs_source_create_private(const char *id, const char *name, obs_data_t *settings)
  456. Creates a 'private' source which is not enumerated by
  457. :c:func:`obs_enum_sources()`, and is not saved by
  458. :c:func:`obs_save_sources()`.
  459. Author's Note: The existence of this function is a result of design
  460. flaw: the front-end should control saving/loading of sources, and
  461. functions like :c:func:`obs_enum_sources()` and
  462. :c:func:`obs_save_sources()` should not exist in the back-end.
  463. :param id: The source type string identifier
  464. :param name: The desired name of the source. For private
  465. sources, this does not have to be unique,
  466. and can additionally be *NULL* if desired
  467. :param settings: The settings for the source, or *NULL* if
  468. none
  469. :return: A reference to the newly created source, or
  470. *NULL* if failed
  471. ---------------------
  472. .. function:: obs_source_t *obs_source_duplicate(obs_source_t *source, const char *desired_name, bool create_private)
  473. Duplicates a source. If the source has the
  474. OBS_SOURCE_DO_NOT_DUPLICATE output flag set, this only returns a
  475. new reference to the same source. Either way,
  476. release with :c:func:`obs_source_release`.
  477. :param source: The source to duplicate
  478. :param desired_name: The desired name of the new source. If this is
  479. not a private source and the name is not unique,
  480. it will be made to be unique
  481. :param create_private: If *true*, the new source will be a private
  482. source if fully duplicated
  483. :return: A new source reference
  484. ---------------------
  485. .. function:: void obs_source_addref(obs_source_t *source)
  486. Adds a reference to a source.
  487. .. deprecated:: 27.2.0
  488. Use :c:func:`obs_source_get_ref()` instead.
  489. ---------------------
  490. .. function:: obs_source_t *obs_source_get_ref(obs_source_t *source)
  491. Returns an incremented reference if still valid, otherwise returns
  492. *NULL*. Use :c:func:`obs_source_release` to release it.
  493. ---------------------
  494. .. function:: void obs_source_release(obs_source_t *source)
  495. Releases a reference to a source. When the last reference is
  496. released, the source is destroyed.
  497. ---------------------
  498. .. function:: obs_weak_source_t *obs_source_get_weak_source(obs_source_t *source)
  499. obs_source_t *obs_weak_source_get_source(obs_weak_source_t *weak)
  500. These functions are used to get a weak reference from a strong source
  501. reference, or a strong source reference from a weak reference. If
  502. the source is destroyed, *obs_weak_source_get_source* will return
  503. *NULL*.
  504. ---------------------
  505. .. function:: void obs_weak_source_addref(obs_weak_source_t *weak)
  506. void obs_weak_source_release(obs_weak_source_t *weak)
  507. Adds/releases a weak reference to a source.
  508. ---------------------
  509. .. function:: void obs_source_remove(obs_source_t *source)
  510. Notifies all reference holders of the source (via
  511. :c:func:`obs_source_removed()`) that the source should be released.
  512. ---------------------
  513. .. function:: bool obs_source_removed(const obs_source_t *source)
  514. :return: *true* if the source should be released
  515. ---------------------
  516. .. function:: bool obs_source_is_hidden(obs_source_t *source)
  517. void obs_source_set_hidden(obs_source_t *source, bool hidden)
  518. Gets/sets the hidden property that determines whether it should be hidden from the user.
  519. Used when the source is still alive but should not be referenced.
  520. ---------------------
  521. .. function:: uint32_t obs_source_get_output_flags(const obs_source_t *source)
  522. uint32_t obs_get_source_output_flags(const char *id)
  523. :return: Capability flags of a source
  524. Author's Note: "Output flags" is poor wording in retrospect; this
  525. should have been named "Capability flags", and the OBS_SOURCE_*
  526. macros should really be OBS_SOURCE_CAP_* macros instead.
  527. See :c:member:`obs_source_info.output_flags` for more information.
  528. ---------------------
  529. .. function:: obs_data_t *obs_get_source_defaults(const char *id)
  530. Calls :c:member:`obs_source_info.get_defaults` to get the defaults
  531. settings of the source type.
  532. :return: The default settings for a source type
  533. ---------------------
  534. .. function:: obs_properties_t *obs_source_properties(const obs_source_t *source)
  535. obs_properties_t *obs_get_source_properties(const char *id)
  536. Use these functions to get the properties of a source or source type.
  537. Properties are optionally used (if desired) to automatically generate
  538. user interface widgets to allow users to update settings.
  539. :return: The properties list for a specific existing source. Free with
  540. :c:func:`obs_properties_destroy()`
  541. ---------------------
  542. .. function:: bool obs_source_configurable(const obs_source_t *source)
  543. bool obs_is_source_configurable(const char *id)
  544. :return: *true* if the the source has custom properties, *false*
  545. otherwise
  546. ---------------------
  547. .. function:: void obs_source_update(obs_source_t *source, obs_data_t *settings)
  548. Updates the settings for a source and calls the
  549. :c:member:`obs_source_info.update` callback of the source. If the
  550. source is a video source, the :c:member:`obs_source_info.update` will
  551. be not be called immediately; instead, it will be deferred to the
  552. video thread to prevent threading issues.
  553. ---------------------
  554. .. function:: void obs_source_reset_settings(obs_source_t *source, obs_data_t *settings)
  555. Same as :c:func:`obs_source_update`, but clears existing settings
  556. first.
  557. ---------------------
  558. .. function:: void obs_source_video_render(obs_source_t *source)
  559. Renders a video source. This will call the
  560. :c:member:`obs_source_info.video_render` callback of the source.
  561. ---------------------
  562. .. function:: uint32_t obs_source_get_width(obs_source_t *source)
  563. uint32_t obs_source_get_height(obs_source_t *source)
  564. Calls the :c:member:`obs_source_info.get_width` or
  565. :c:member:`obs_source_info.get_height` of the source to get its width
  566. and/or height.
  567. Author's Note: These functions should be consolidated in to a single
  568. function/callback rather than having a function for both width and
  569. height.
  570. :return: The width or height of the source
  571. ---------------------
  572. .. function:: enum gs_color_space obs_source_get_color_space(obs_source_t *source, size_t count, const enum gs_color_space *preferred_spaces)
  573. Calls the :c:member:`obs_source_info.video_get_color_space` of the
  574. source to get its color space. Assumes GS_CS_SRGB if not implemented.
  575. Disabled filters are skipped, and async video sources can figure out
  576. the color space for themselves.
  577. :return: The color space of the source
  578. ---------------------
  579. .. function:: bool obs_source_get_texcoords_centered(obs_source_t *source)
  580. Hints whether or not the source will blend texels.
  581. :return: Whether or not the source will blend texels
  582. ---------------------
  583. .. function:: obs_data_t *obs_source_get_settings(const obs_source_t *source)
  584. :return: The settings string for a source. The reference counter of the
  585. returned settings data is incremented, so
  586. :c:func:`obs_data_release()` must be called when the
  587. settings are no longer used
  588. ---------------------
  589. .. function:: const char *obs_source_get_name(const obs_source_t *source)
  590. :return: The name of the source
  591. ---------------------
  592. .. function:: void obs_source_set_name(obs_source_t *source, const char *name)
  593. Sets the name of a source. If the source is not private and the name
  594. is not unique, it will automatically be given a unique name.
  595. ---------------------
  596. .. function:: enum obs_source_type obs_source_get_type(const obs_source_t *source)
  597. :return: | OBS_SOURCE_TYPE_INPUT for inputs
  598. | OBS_SOURCE_TYPE_FILTER for filters
  599. | OBS_SOURCE_TYPE_TRANSITION for transitions
  600. | OBS_SOURCE_TYPE_SCENE for scenes
  601. ---------------------
  602. .. function:: bool obs_source_is_scene(const obs_source_t *source)
  603. :return: *true* if the source is a scene
  604. ---------------------
  605. .. function:: bool obs_source_is_group(const obs_source_t *source)
  606. :return: *true* if the source is a group
  607. ---------------------
  608. .. function:: const char *obs_source_get_id(const obs_source_t *source)
  609. :return: The source's type identifier string. If the source is versioned,
  610. "_vN" is appended at the end, where "N" is the source's version.
  611. ---------------------
  612. .. function:: const char *obs_source_get_unversioned_id(const obs_source_t *source)
  613. :return: The source's unversioned type identifier string.
  614. ---------------------
  615. .. function:: signal_handler_t *obs_source_get_signal_handler(const obs_source_t *source)
  616. :return: The source's signal handler. Should not be manually freed,
  617. as its lifecycle is managed by libobs.
  618. See the :ref:`source_signal_handler_reference` for more information
  619. on signals that are available for sources.
  620. ---------------------
  621. .. function:: proc_handler_t *obs_source_get_proc_handler(const obs_source_t *source)
  622. :return: The procedure handler for a source. Should not be manually freed,
  623. as its lifecycle is managed by libobs.
  624. ---------------------
  625. .. function:: void obs_source_set_volume(obs_source_t *source, float volume)
  626. float obs_source_get_volume(const obs_source_t *source)
  627. Sets/gets the user volume for a source that has audio output.
  628. ---------------------
  629. .. function:: bool obs_source_muted(const obs_source_t *source)
  630. void obs_source_set_muted(obs_source_t *source, bool muted)
  631. Sets/gets whether the source's audio is muted.
  632. ---------------------
  633. .. function:: enum speaker_layout obs_source_get_speaker_layout(obs_source_t *source)
  634. Gets the current speaker layout.
  635. ---------------------
  636. .. function:: void obs_source_set_balance_value(obs_source_t *source, float balance)
  637. float obs_source_get_balance_value(const obs_source_t *source)
  638. Sets/gets the audio balance value.
  639. ---------------------
  640. .. function:: void obs_source_set_sync_offset(obs_source_t *source, int64_t offset)
  641. int64_t obs_source_get_sync_offset(const obs_source_t *source)
  642. Sets/gets the audio sync offset (in nanoseconds) for a source.
  643. ---------------------
  644. .. function:: void obs_source_set_audio_mixers(obs_source_t *source, uint32_t mixers)
  645. uint32_t obs_source_get_audio_mixers(const obs_source_t *source)
  646. Sets/gets the audio mixer channels (i.e. audio tracks) that a source outputs to,
  647. depending on what bits are set. Audio mixers allow filtering
  648. specific using multiple audio encoders to mix different sources
  649. together depending on what mixer channel they're set to.
  650. For example, to output to mixer 1 and 3, you would perform a bitwise
  651. OR on bits 0 and 2: (1<<0) | (1<<2), or 0x5.
  652. ---------------------
  653. .. function:: void obs_source_set_monitoring_type(obs_source_t *source, enum obs_monitoring_type type)
  654. enum obs_monitoring_type obs_source_get_monitoring_type(obs_source_t *source)
  655. Sets/gets the desktop audio monitoring type.
  656. :param order: | OBS_MONITORING_TYPE_NONE - Do not monitor
  657. | OBS_MONITORING_TYPE_MONITOR_ONLY - Send to monitor device, no outputs
  658. | OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT - Send to monitor device and outputs
  659. ---------------------
  660. .. function:: void obs_source_enum_active_sources(obs_source_t *source, obs_source_enum_proc_t enum_callback, void *param)
  661. void obs_source_enum_active_tree(obs_source_t *source, obs_source_enum_proc_t enum_callback, void *param)
  662. Enumerates active child sources or source tree used by this source.
  663. Relevant data types used with this function:
  664. .. code:: cpp
  665. typedef void (*obs_source_enum_proc_t)(obs_source_t *parent,
  666. obs_source_t *child, void *param);
  667. ---------------------
  668. .. function:: bool obs_source_push_to_mute_enabled(const obs_source_t *source)
  669. void obs_source_enable_push_to_mute(obs_source_t *source, bool enabled)
  670. Sets/gets whether push-to-mute is enabled.
  671. ---------------------
  672. .. function:: uint64_t obs_source_get_push_to_mute_delay(const obs_source_t *source)
  673. void obs_source_set_push_to_mute_delay(obs_source_t *source, uint64_t delay)
  674. Sets/gets the push-to-mute delay.
  675. ---------------------
  676. .. function:: bool obs_source_push_to_talk_enabled(const obs_source_t *source)
  677. void obs_source_enable_push_to_talk(obs_source_t *source, bool enabled)
  678. Sets/gets whether push-to-talk is enabled.
  679. ---------------------
  680. .. function:: uint64_t obs_source_get_push_to_talk_delay(const obs_source_t *source)
  681. void obs_source_set_push_to_talk_delay(obs_source_t *source, uint64_t delay)
  682. Sets/gets the push-to-talk delay.
  683. ---------------------
  684. .. function:: bool obs_source_active(const obs_source_t *source)
  685. :return: *true* if active, *false* if not. A source is only
  686. considered active if it's being shown on the final mix
  687. ---------------------
  688. .. function:: bool obs_source_showing(const obs_source_t *source)
  689. :return: *true* if showing, *false* if not. A source is considered
  690. showing if it's being displayed anywhere at all, whether on
  691. a display context or on the final output
  692. ---------------------
  693. .. function:: void obs_source_inc_showing(obs_source_t *source)
  694. void obs_source_dec_showing(obs_source_t *source)
  695. Increments/decrements a source's "showing" state. Typically used
  696. when drawing a source on a display manually.
  697. ---------------------
  698. .. function:: void obs_source_set_flags(obs_source_t *source, uint32_t flags)
  699. uint32_t obs_source_get_flags(const obs_source_t *source)
  700. :param flags: OBS_SOURCE_FLAG_FORCE_MONO Forces audio to mono
  701. ---------------------
  702. .. function:: void obs_source_enum_filters(obs_source_t *source, obs_source_enum_proc_t callback, void *param)
  703. Enumerates active filters on a source.
  704. Relevant data types used with this function:
  705. .. code:: cpp
  706. typedef void (*obs_source_enum_proc_t)(obs_source_t *parent,
  707. obs_source_t *child, void *param);
  708. ---------------------
  709. .. function:: obs_source_t *obs_source_get_filter_by_name(obs_source_t *source, const char *name)
  710. :return: The desired filter, or *NULL* if not found. The reference
  711. of the filter is incremented
  712. ---------------------
  713. .. function:: void obs_source_copy_filters(obs_source_t *dst, obs_source_t *src)
  714. Copies filters from the source to the destination. If filters by the
  715. same name already exist in the destination source, the newer filters
  716. will be given unique names.
  717. ---------------------
  718. .. function:: void obs_source_copy_single_filter(obs_source_t *dst, obs_source_t *filter)
  719. Copies the filter from the source to the destination. If a filter by the
  720. same name already exists in the destination source, the newer filter
  721. will be given a unique name.
  722. ---------------------
  723. .. function:: size_t obs_source_filter_count(const obs_source_t *source)
  724. Returns the number of filters the source has.
  725. ---------------------
  726. .. function:: obs_data_array_t *obs_source_backup_filters(obs_source_t *source)
  727. void obs_source_restore_filters(obs_source_t *source, obs_data_array_t *array)
  728. Backs up and restores the current filter list and order.
  729. ---------------------
  730. .. function:: bool obs_source_enabled(const obs_source_t *source)
  731. void obs_source_set_enabled(obs_source_t *source, bool enabled)
  732. Enables/disables a source, or returns the enabled state.
  733. ---------------------
  734. .. function:: void obs_source_add_audio_capture_callback(obs_source_t *source, obs_source_audio_capture_t callback, void *param)
  735. void obs_source_remove_audio_capture_callback(obs_source_t *source, obs_source_audio_capture_t callback, void *param)
  736. Adds/removes an audio capture callback for a source. This allows the
  737. ability to get the raw audio data of a source as it comes in.
  738. Relevant data types used with this function:
  739. .. code:: cpp
  740. typedef void (*obs_source_audio_capture_t)(void *param, obs_source_t *source,
  741. const struct audio_data *audio_data, bool muted);
  742. ---------------------
  743. .. function:: void obs_source_set_deinterlace_mode(obs_source_t *source, enum obs_deinterlace_mode mode)
  744. enum obs_deinterlace_mode obs_source_get_deinterlace_mode(const obs_source_t *source)
  745. Sets/gets the deinterlace mode.
  746. :param mode: | OBS_DEINTERLACE_MODE_DISABLE - Disables deinterlacing
  747. | OBS_DEINTERLACE_MODE_DISCARD - Discard
  748. | OBS_DEINTERLACE_MODE_RETRO - Retro
  749. | OBS_DEINTERLACE_MODE_BLEND - Blend
  750. | OBS_DEINTERLACE_MODE_BLEND_2X - Blend 2x
  751. | OBS_DEINTERLACE_MODE_LINEAR - Linear
  752. | OBS_DEINTERLACE_MODE_LINEAR_2X - Linear 2x
  753. | OBS_DEINTERLACE_MODE_YADIF - Yadif
  754. | OBS_DEINTERLACE_MODE_YADIF_2X - Yadif 2x
  755. ---------------------
  756. .. function:: void obs_source_set_deinterlace_field_order(obs_source_t *source, enum obs_deinterlace_field_order order)
  757. enum obs_deinterlace_field_order obs_source_get_deinterlace_field_order(const obs_source_t *source)
  758. Sets/gets the deinterlace field order.
  759. :param order: | OBS_DEINTERLACE_FIELD_ORDER_TOP - Start from top
  760. | OBS_DEINTERLACE_FIELD_ORDER_BOTTOM - Start from bottom
  761. ---------------------
  762. .. function:: obs_data_t *obs_source_get_private_settings(obs_source_t *item)
  763. Gets private front-end settings data. This data is saved/loaded
  764. automatically. Returns an incremented reference. Use :c:func:`obs_data_release()`
  765. to release it.
  766. ---------------------
  767. .. function:: void obs_source_send_mouse_click(obs_source_t *source, const struct obs_mouse_event *event, int32_t type, bool mouse_up, uint32_t click_count)
  768. Used for interacting with sources: sends a mouse down/up event to a
  769. source.
  770. ---------------------
  771. .. function:: void obs_source_send_mouse_move(obs_source_t *source, const struct obs_mouse_event *event, bool mouse_leave)
  772. Used for interacting with sources: sends a mouse move event to a
  773. source.
  774. ---------------------
  775. .. function:: void obs_source_send_mouse_wheel(obs_source_t *source, const struct obs_mouse_event *event, int x_delta, int y_delta)
  776. Used for interacting with sources: sends a mouse wheel event to a
  777. source.
  778. ---------------------
  779. .. function:: void obs_source_send_focus(obs_source_t *source, bool focus)
  780. Used for interacting with sources: sends a got-focus or lost-focus
  781. event to a source.
  782. ---------------------
  783. .. function:: void obs_source_send_key_click(obs_source_t *source, const struct obs_key_event *event, bool key_up)
  784. Used for interacting with sources: sends a key up/down event to a
  785. source.
  786. ---------------------
  787. .. function:: enum obs_icon_type obs_source_get_icon_type(const char *id)
  788. Calls the :c:member:`obs_source_info.icon_type` to get the icon type.
  789. ---------------------
  790. .. function:: void obs_source_media_play_pause(obs_source_t *source, bool pause)
  791. Calls the :c:member:`obs_source_info.media_play_pause` to pause or play media.
  792. ---------------------
  793. .. function:: void obs_source_media_restart(obs_source_t *source)
  794. Calls the :c:member:`obs_source_info.media_restart` to restart the media.
  795. ---------------------
  796. .. function:: void obs_source_media_stop(obs_source_t *source)
  797. Calls the :c:member:`obs_source_info.media_stop` to stop the media.
  798. ---------------------
  799. .. function:: void obs_source_media_next(obs_source_t *source)
  800. Calls the :c:member:`obs_source_info.media_next` to go to the next media.
  801. ---------------------
  802. .. function:: void obs_source_media_previous(obs_source_t *source)
  803. Calls the :c:member:`obs_source_info.media_previous` to go to the previous media.
  804. ---------------------
  805. .. function:: int64_t obs_source_media_get_duration(obs_source_t *source)
  806. Calls the :c:member:`obs_source_info.media_get_duration` to
  807. get the media duration in milliseconds.
  808. ---------------------
  809. .. function:: int64_t obs_source_media_get_time(obs_source_t *source)
  810. void obs_source_media_set_time(obs_source_t *source, int64_t ms)
  811. Calls the :c:member:`obs_source_info.media_get_time` or
  812. :c:member:`obs_source_info.media_set_time` to get/set the
  813. current time (in milliseconds) of the media. Will return 0
  814. for non-media sources.
  815. ---------------------
  816. .. function:: enum obs_media_state obs_source_media_get_state(obs_source_t *source)
  817. Calls the :c:member:`obs_source_info.media_get_state` to get the state of the media.
  818. ---------------------
  819. .. function:: void obs_source_media_started(obs_source_t *source)
  820. Emits a **media_started** signal.
  821. ---------------------
  822. .. function:: void obs_source_media_ended(obs_source_t *source)
  823. Emits a **media_ended** signal.
  824. ---------------------
  825. Functions used by sources
  826. -------------------------
  827. .. function:: void obs_source_draw_set_color_matrix(const struct matrix4 *color_matrix, const struct vec3 *color_range_min, const struct vec3 *color_range_max)
  828. Helper function to set the color matrix information when drawing the
  829. source.
  830. :param color_matrix: The color matrix. Assigns to the 'color_matrix'
  831. effect variable.
  832. :param color_range_min: The minimum color range. Assigns to the
  833. 'color_range_min' effect variable. If NULL,
  834. {0.0f, 0.0f, 0.0f} is used.
  835. :param color_range_max: The maximum color range. Assigns to the
  836. 'color_range_max' effect variable. If NULL,
  837. {1.0f, 1.0f, 1.0f} is used.
  838. ---------------------
  839. .. function:: void obs_source_draw(gs_texture_t *image, int x, int y, uint32_t cx, uint32_t cy, bool flip)
  840. Helper function to draw sprites for a source (synchronous video).
  841. :param image: The sprite texture to draw. Assigns to the 'image' variable
  842. of the current effect.
  843. :param x: X position of the sprite.
  844. :param y: Y position of the sprite.
  845. :param cx: Width of the sprite. If 0, uses the texture width.
  846. :param cy: Height of the sprite. If 0, uses the texture height.
  847. :param flip: Specifies whether to flip the image vertically.
  848. ---------------------
  849. .. function:: void obs_source_output_video(obs_source_t *source, const struct obs_source_frame *frame)
  850. Outputs asynchronous video data. Set to NULL to deactivate the texture.
  851. Relevant data types used with this function:
  852. .. code:: cpp
  853. enum video_format {
  854. VIDEO_FORMAT_NONE,
  855. /* planar 4:2:0 formats */
  856. VIDEO_FORMAT_I420, /* three-plane */
  857. VIDEO_FORMAT_NV12, /* two-plane, luma and packed chroma */
  858. /* packed 4:2:2 formats */
  859. VIDEO_FORMAT_YVYU,
  860. VIDEO_FORMAT_YUY2, /* YUYV */
  861. VIDEO_FORMAT_UYVY,
  862. /* packed uncompressed formats */
  863. VIDEO_FORMAT_RGBA,
  864. VIDEO_FORMAT_BGRA,
  865. VIDEO_FORMAT_BGRX,
  866. VIDEO_FORMAT_Y800, /* grayscale */
  867. /* planar 4:4:4 */
  868. VIDEO_FORMAT_I444,
  869. /* more packed uncompressed formats */
  870. VIDEO_FORMAT_BGR3,
  871. /* planar 4:2:2 */
  872. VIDEO_FORMAT_I422,
  873. /* planar 4:2:0 with alpha */
  874. VIDEO_FORMAT_I40A,
  875. /* planar 4:2:2 with alpha */
  876. VIDEO_FORMAT_I42A,
  877. /* planar 4:4:4 with alpha */
  878. VIDEO_FORMAT_YUVA,
  879. /* packed 4:4:4 with alpha */
  880. VIDEO_FORMAT_AYUV,
  881. /* planar 4:2:0 format, 10 bpp */
  882. VIDEO_FORMAT_I010, /* three-plane */
  883. VIDEO_FORMAT_P010, /* two-plane, luma and packed chroma */
  884. /* planar 4:2:2 format, 10 bpp */
  885. VIDEO_FORMAT_I210,
  886. /* planar 4:4:4 format, 12 bpp */
  887. VIDEO_FORMAT_I412,
  888. /* planar 4:4:4:4 format, 12 bpp */
  889. VIDEO_FORMAT_YA2L,
  890. /* planar 4:2:2 format, 16 bpp */
  891. VIDEO_FORMAT_P216, /* two-plane, luma and packed chroma */
  892. /* planar 4:4:4 format, 16 bpp */
  893. VIDEO_FORMAT_P416, /* two-plane, luma and packed chroma */
  894. };
  895. struct obs_source_frame {
  896. uint8_t *data[MAX_AV_PLANES];
  897. uint32_t linesize[MAX_AV_PLANES];
  898. uint32_t width;
  899. uint32_t height;
  900. uint64_t timestamp;
  901. enum video_format format;
  902. float color_matrix[16];
  903. bool full_range;
  904. uint16_t max_luminance;
  905. float color_range_min[3];
  906. float color_range_max[3];
  907. bool flip;
  908. uint8_t flags;
  909. uint8_t trc; /* enum video_trc */
  910. };
  911. ---------------------
  912. .. function:: void obs_source_set_async_rotation(obs_source_t *source, long rotation)
  913. Allows the ability to set rotation (0, 90, 180, -90, 270) for an
  914. async video source. The rotation will be automatically applied to
  915. the source.
  916. ---------------------
  917. .. function:: void obs_source_preload_video(obs_source_t *source, const struct obs_source_frame *frame)
  918. Preloads a video frame to ensure a frame is ready for playback as
  919. soon as video playback starts.
  920. ---------------------
  921. .. function:: void obs_source_show_preloaded_video(obs_source_t *source)
  922. Shows any preloaded video frame.
  923. ---------------------
  924. .. function:: void obs_source_output_audio(obs_source_t *source, const struct obs_source_audio *audio)
  925. Outputs audio data.
  926. ---------------------
  927. .. function:: void obs_source_update_properties(obs_source_t *source)
  928. Signal an update to any currently used properties.
  929. ---------------------
  930. .. function:: bool obs_source_add_active_child(obs_source_t *parent, obs_source_t *child)
  931. Adds an active child source. Must be called by parent sources on child
  932. sources when the child is added and active. This ensures that the source is
  933. properly activated if the parent is active.
  934. :return: *true* if source can be added, *false* if it causes recursion
  935. ---------------------
  936. .. function:: void obs_source_remove_active_child(obs_source_t *parent, obs_source_t *child)
  937. Removes an active child source. Must be called by parent sources on child
  938. sources when the child is removed or inactive. This ensures that the source
  939. is properly deactivated if the parent is no longer active.
  940. ---------------------
  941. Filters
  942. -------
  943. .. function:: obs_source_t *obs_filter_get_parent(const obs_source_t *filter)
  944. If the source is a filter, returns the parent source of the filter.
  945. The parent source is the source being filtered.
  946. Only guaranteed to be valid inside of the video_render, filter_audio,
  947. filter_video, and filter_remove callbacks.
  948. ---------------------
  949. .. function:: obs_source_t *obs_filter_get_target(const obs_source_t *filter)
  950. If the source is a filter, returns the target source of the filter.
  951. The target source is the next source in the filter chain.
  952. Only guaranteed to be valid inside of the video_render, filter_audio,
  953. filter_video, and filter_remove callbacks.
  954. ---------------------
  955. .. function:: void obs_source_default_render(obs_source_t *source)
  956. Can be used by filters to directly render a non-async parent source
  957. without any filter processing.
  958. ---------------------
  959. .. function:: void obs_source_filter_add(obs_source_t *source, obs_source_t *filter)
  960. void obs_source_filter_remove(obs_source_t *source, obs_source_t *filter)
  961. Adds/removes a filter to/from a source.
  962. ---------------------
  963. .. function:: void obs_source_filter_set_order(obs_source_t *source, obs_source_t *filter, enum obs_order_movement movement)
  964. Modifies the order of a specific filter.
  965. :param movement: | Can be one of the following:
  966. | OBS_ORDER_MOVE_UP
  967. | OBS_ORDER_MOVE_DOWN
  968. | OBS_ORDER_MOVE_TOP
  969. | OBS_ORDER_MOVE_BOTTOM
  970. ---------------------
  971. Functions used by filters
  972. -------------------------
  973. .. function:: bool obs_source_process_filter_begin(obs_source_t *filter, enum gs_color_format format, enum obs_allow_direct_render allow_direct)
  974. Default RGB filter handler for generic effect filters. Processes the
  975. filter chain and renders them to texture if needed, then the filter is
  976. drawn with.
  977. After calling this, set your parameters for the effect, then call
  978. obs_source_process_filter_end to draw the filter.
  979. :return: *true* if filtering should continue, *false* if the filter
  980. is bypassed for whatever reason
  981. ---------------------
  982. .. function:: bool obs_source_process_filter_begin_with_color_space(obs_source_t *filter, enum gs_color_format format, enum gs_color_space space, enum obs_allow_direct_render allow_direct)
  983. Similar to obs_source_process_filter_begin, but also set the active
  984. color space.
  985. :return: *true* if filtering should continue, *false* if the filter
  986. is bypassed for whatever reason
  987. ---------------------
  988. .. function:: void obs_source_process_filter_end(obs_source_t *filter, gs_effect_t *effect, uint32_t width, uint32_t height)
  989. Draws the filter using the effect's "Draw" technique.
  990. Before calling this function, first call obs_source_process_filter_begin and
  991. then set the effect parameters, and then call this function to finalize the
  992. filter.
  993. ---------------------
  994. .. function:: void obs_source_process_filter_tech_end(obs_source_t *filter, gs_effect_t *effect, uint32_t width, uint32_t height, const char *tech_name)
  995. Draws the filter with a specific technique in the effect.
  996. Before calling this function, first call obs_source_process_filter_begin and
  997. then set the effect parameters, and then call this function to finalize the
  998. filter.
  999. ---------------------
  1000. .. function:: void obs_source_skip_video_filter(obs_source_t *filter)
  1001. Skips the filter if the filter is invalid and cannot be rendered.
  1002. ---------------------
  1003. .. _transitions:
  1004. Transitions
  1005. -----------
  1006. .. function:: obs_source_t *obs_transition_get_source(obs_source_t *transition, enum obs_transition_target target)
  1007. :param target: | OBS_TRANSITION_SOURCE_A - Source being transitioned from, or the current source if not transitioning
  1008. | OBS_TRANSITION_SOURCE_B - Source being transitioned to
  1009. :return: An incremented reference to the source or destination
  1010. sources of the transition. Use :c:func:`obs_source_release`
  1011. to release it.
  1012. ---------------------
  1013. .. function:: void obs_transition_clear(obs_source_t *transition)
  1014. Clears the transition.
  1015. ---------------------
  1016. .. function:: obs_source_t *obs_transition_get_active_source(obs_source_t *transition)
  1017. :return: An incremented reference to the currently active source of
  1018. the transition. Use :c:func:`obs_source_release` to release it.
  1019. ---------------------
  1020. .. function:: bool obs_transition_start(obs_source_t *transition, enum obs_transition_mode mode, uint32_t duration_ms, obs_source_t *dest)
  1021. Starts the transition with the desired destination source.
  1022. :param mode: Currently only OBS_TRANSITION_MODE_AUTO
  1023. :param duration_ms: Duration in milliseconds. If the transition has
  1024. a fixed duration set by
  1025. :c:func:`obs_transition_enable_fixed`, this
  1026. parameter will have no effect
  1027. :param dest: The destination source to transition to
  1028. ---------------------
  1029. .. function:: void obs_transition_set_size(obs_source_t *transition, uint32_t cx, uint32_t cy)
  1030. void obs_transition_get_size(const obs_source_t *transition, uint32_t *cx, uint32_t *cy)
  1031. Sets/gets the dimensions of the transition.
  1032. ---------------------
  1033. .. function:: void obs_transition_set_scale_type(obs_source_t *transition, enum obs_transition_scale_type type)
  1034. enum obs_transition_scale_type obs_transition_get_scale_type( const obs_source_t *transition)
  1035. Sets/gets the scale type for sources within the transition.
  1036. :param type: | OBS_TRANSITION_SCALE_MAX_ONLY - Scale to aspect ratio, but only to the maximum size of each source
  1037. | OBS_TRANSITION_SCALE_ASPECT - Always scale the sources, but keep aspect ratio
  1038. | OBS_TRANSITION_SCALE_STRETCH - Scale and stretch the sources to the size of the transition
  1039. ---------------------
  1040. .. function:: void obs_transition_set_alignment(obs_source_t *transition, uint32_t alignment)
  1041. uint32_t obs_transition_get_alignment(const obs_source_t *transition)
  1042. Sets/gets the alignment used to draw the two sources within
  1043. transition the transition.
  1044. :param alignment: | Can be any bitwise OR combination of:
  1045. | OBS_ALIGN_CENTER
  1046. | OBS_ALIGN_LEFT
  1047. | OBS_ALIGN_RIGHT
  1048. | OBS_ALIGN_TOP
  1049. | OBS_ALIGN_BOTTOM
  1050. ---------------------
  1051. Functions used by transitions
  1052. -----------------------------
  1053. .. function:: void obs_transition_enable_fixed(obs_source_t *transition, bool enable, uint32_t duration_ms)
  1054. bool obs_transition_fixed(obs_source_t *transition)
  1055. Sets/gets whether the transition uses a fixed duration. Useful for
  1056. certain types of transitions such as stingers. If this is set, the
  1057. *duration_ms* parameter of :c:func:`obs_transition_start()` has no
  1058. effect.
  1059. ---------------------
  1060. .. function:: float obs_transition_get_time(obs_source_t *transition)
  1061. :return: The current transition time value (0.0f..1.0f)
  1062. ---------------------
  1063. .. function:: void obs_transition_video_render(obs_source_t *transition, obs_transition_video_render_callback_t callback)
  1064. void obs_transition_video_render2(obs_source_t *transition, obs_transition_video_render_callback_t callback, gs_texture_t *placeholder_texture)
  1065. Helper function used for rendering transitions. This function will
  1066. render two distinct textures for source A and source B of the
  1067. transition, allowing the ability to blend them together with a pixel
  1068. shader in a desired manner.
  1069. The *a* and *b* parameters of *callback* are automatically rendered
  1070. textures of source A and source B, *t* is the time value
  1071. (0.0f..1.0f), *cx* and *cy* are the current dimensions of the
  1072. transition, and *data* is the implementation's private data.
  1073. The *placeholder_texture* parameter allows a callback to receive
  1074. a replacement that isn't the default transparent texture, including
  1075. NULL if the caller desires.
  1076. Relevant data types used with this function:
  1077. .. code:: cpp
  1078. typedef void (*obs_transition_video_render_callback_t)(void *data,
  1079. gs_texture_t *a, gs_texture_t *b, float t,
  1080. uint32_t cx, uint32_t cy);
  1081. ---------------------
  1082. .. function:: enum gs_color_space obs_transition_video_get_color_space(obs_source_t *transition)
  1083. Figure out the color space that encompasses both child sources.
  1084. The wider space wins.
  1085. :return: The color space of the transition
  1086. ---------------------
  1087. .. function:: bool obs_transition_audio_render(obs_source_t *transition, uint64_t *ts_out, struct obs_source_audio_mix *audio, uint32_t mixers, size_t channels, size_t sample_rate, obs_transition_audio_mix_callback_t mix_a_callback, obs_transition_audio_mix_callback_t mix_b_callback)
  1088. Helper function used for transitioning audio. Typically you'd call
  1089. this in the obs_source_info.audio_render callback with its
  1090. parameters, and use the mix_a_callback and mix_b_callback to
  1091. determine the the audio fading of source A and source B.
  1092. Relevant data types used with this function:
  1093. .. code:: cpp
  1094. typedef float (*obs_transition_audio_mix_callback_t)(void *data, float t);
  1095. ---------------------
  1096. .. function:: void obs_transition_swap_begin(obs_source_t *tr_dest, obs_source_t *tr_source)
  1097. void obs_transition_swap_end(obs_source_t *tr_dest, obs_source_t *tr_source)
  1098. Swaps two transitions. Call obs_transition_swap_begin, swap the
  1099. source, then call obs_transition_swap_end when complete. This allows
  1100. the ability to seamlessly swap two different transitions without it
  1101. affecting the output.
  1102. For example, if a transition is assigned to output channel 0, you'd
  1103. call obs_transition_swap_begin, then you'd call obs_set_output_source
  1104. with the new transition, then call
  1105. :c:func:`obs_transition_swap_begin()`.
  1106. .. ---------------------------------------------------------------------------
  1107. .. _libobs/obs-source.h: https://github.com/obsproject/obs-studio/blob/master/libobs/obs-source.h