1
0

reference-sources.rst 66 KB

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