reference-sources.rst 61 KB

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