reference-sources.rst 56 KB

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