reference-frontend-api.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. OBS Studio Frontend API
  2. =======================
  3. The OBS Studio frontend API is the API specific to OBS Studio itself.
  4. .. code:: cpp
  5. #include <obs-frontend-api.h>
  6. Structures/Enumerations
  7. -----------------------
  8. .. type:: enum obs_frontend_event
  9. Specifies a front-end event. Can be one of the following values:
  10. - **OBS_FRONTEND_EVENT_STREAMING_STARTING**
  11. Triggered when streaming is starting.
  12. - **OBS_FRONTEND_EVENT_STREAMING_STARTED**
  13. Triggered when streaming has successfully started.
  14. - **OBS_FRONTEND_EVENT_STREAMING_STOPPING**
  15. Triggered when streaming is stopping.
  16. - **OBS_FRONTEND_EVENT_STREAMING_STOPPED**
  17. Triggered when streaming has fully stopped.
  18. - **OBS_FRONTEND_EVENT_RECORDING_STARTING**
  19. Triggered when recording is starting.
  20. - **OBS_FRONTEND_EVENT_RECORDING_STARTED**
  21. Triggered when recording has successfully started.
  22. - **OBS_FRONTEND_EVENT_RECORDING_STOPPING**
  23. Triggered when recording is stopping.
  24. - **OBS_FRONTEND_EVENT_RECORDING_STOPPED**
  25. Triggered when recording has fully stopped.
  26. - **OBS_FRONTEND_EVENT_SCENE_CHANGED**
  27. Triggered when the current scene has changed.
  28. - **OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED**
  29. Triggered when a scenes has been added/removed/reordered by the
  30. user.
  31. - **OBS_FRONTEND_EVENT_TRANSITION_CHANGED**
  32. Triggered when the current transition has changed by the user.
  33. - **OBS_FRONTEND_EVENT_TRANSITION_DURATION_CHANGED**
  34. Triggered when the transition duration has been changed by the user.
  35. - **OBS_FRONTEND_EVENT_TRANSITION_STOPPED**
  36. Triggered when a transition has completed.
  37. - **OBS_FRONTEND_EVENT_TRANSITION_LIST_CHANGED**
  38. Triggered when the user adds/removes transitions.
  39. - **OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED**
  40. Triggered when the current scene collection has changed.
  41. - **OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED**
  42. Triggered when a scene collection has been
  43. added/removed/renamed.
  44. - **OBS_FRONTEND_EVENT_PROFILE_CHANGED**
  45. Triggered when the current profile is about to change.
  46. - **OBS_FRONTEND_EVENT_PROFILE_CHANGED**
  47. Triggered when the current profile has changed.
  48. - **OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED**
  49. Triggered when a profile has been added/removed/renamed.
  50. - **OBS_FRONTEND_EVENT_SCRIPTING_SHUTDOWN**
  51. Triggered when scripts are unloaded when exiting OBS.
  52. - **OBS_FRONTEND_EVENT_EXIT**
  53. Triggered when the program is about to exit.
  54. - **OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTING**
  55. Triggered when the replay buffer is starting.
  56. - **OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTED**
  57. Triggered when the replay buffer has successfully started.
  58. - **OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPING**
  59. Triggered when the replay buffer is stopping.
  60. - **OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPED**
  61. Triggered when the replay buffer has fully stopped.
  62. - **OBS_FRONTEND_EVENT_REPLAY_BUFFER_SAVED**
  63. Triggered when the replay buffer has been saved.
  64. - **OBS_FRONTEND_EVENT_STUDIO_MODE_ENABLED**
  65. Triggered when the user has turned on studio mode.
  66. - **OBS_FRONTEND_EVENT_STUDIO_MODE_DISABLED**
  67. Triggered when the user has turned off studio mode.
  68. - **OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED**
  69. Triggered when the current preview scene has changed in studio
  70. mode.
  71. - **OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP**
  72. Triggered when a scene collection has been completely unloaded, and
  73. the program is either about to load a new scene collection, or the
  74. program is about to exit.
  75. - **OBS_FRONTEND_EVENT_FINISHED_LOADING**
  76. Triggered when the program has finished loading.
  77. - **OBS_FRONTEND_EVENT_RECORDING_PAUSED**
  78. Triggered when the recording has been paused.
  79. - **OBS_FRONTEND_EVENT_RECORDING_UNPAUSED**
  80. Triggered when the recording has been unpaused.
  81. - **OBS_FRONTEND_EVENT_VIRTUALCAM_STARTED**
  82. Triggered when the virtual camera is started.
  83. - **OBS_FRONTEND_EVENT_VIRTUALCAM_STOPPED**
  84. Triggered when the virtual camera is stopped.
  85. - **OBS_FRONTEND_EVENT_TBAR_VALUE_CHANGED**
  86. Triggered when the transition bar is moved.
  87. - **OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGING**
  88. Triggered when the current scene collection is about to change.
  89. - **OBS_FRONTEND_EVENT_PROFILE_CHANGING**
  90. Triggered when the current profile is about to change.
  91. .. type:: struct obs_frontend_source_list
  92. - DARRAY(obs_source_t*) **sources**
  93. Example usage:
  94. .. code:: cpp
  95. struct obs_frontend_source_list scenes = {0};
  96. obs_frontend_get_scenes(&scenes);
  97. for (size_t i = 0; i < scenes.num; i++) {
  98. obs_source_t *source = scenes.sources.array[i];
  99. [...]
  100. }
  101. obs_frontend_source_list_free(&scenes);
  102. .. type:: typedef void (*obs_frontend_cb)(void *private_data)
  103. Frontend tool menu callback.
  104. .. type:: typedef void (*obs_frontend_event_cb)(enum obs_frontend_event event, void *private_data)
  105. Frontend event callback.
  106. .. type:: typedef void (*obs_frontend_save_cb)(obs_data_t *save_data, bool saving, void *private_data)
  107. Frontend save/load callback.
  108. .. type:: typedef bool (*obs_frontend_translate_ui_cb)(const char *text, const char **out)
  109. Translation callback.
  110. Functions
  111. ---------
  112. .. function:: void obs_frontend_source_list_free(struct obs_frontend_source_list *source_list)
  113. Releases sources within a source list and frees the list.
  114. :param source_list: Source list to free.
  115. ---------------------------------------
  116. .. function:: void *obs_frontend_get_main_window(void)
  117. :return: The QMainWindow pointer to the OBS Studio window.
  118. ---------------------------------------
  119. .. function:: void *obs_frontend_get_main_window_handle(void)
  120. :return: The native window handle of the OBS Studio window.
  121. ---------------------------------------
  122. .. function:: char **obs_frontend_get_scene_names(void)
  123. :return: The scene name list, ending with NULL. The list is stored
  124. within one contiguous segment of memory, so freeing the
  125. returned pointer with :c:func:`bfree()` will free the entire
  126. list.
  127. ---------------------------------------
  128. .. function:: void obs_frontend_get_scenes(struct obs_frontend_source_list *sources)
  129. :param sources: Pointer to a :c:type:`obs_frontend_source_list`
  130. structure to receive the list of
  131. reference-incremented scenes. Release with
  132. :c:func:`obs_frontend_source_list_free`.
  133. ---------------------------------------
  134. .. function:: obs_source_t *obs_frontend_get_current_scene(void)
  135. :return: A new reference to the currently active scene.
  136. ---------------------------------------
  137. .. function:: void obs_frontend_set_current_scene(obs_source_t *scene)
  138. :param scene: The scene to set as the current scene.
  139. ---------------------------------------
  140. .. function:: void obs_frontend_get_transitions(struct obs_frontend_source_list *sources)
  141. :param sources: Pointer to a :c:type:`obs_frontend_source_list`
  142. structure to receive the list of
  143. reference-incremented transitions. Release with
  144. :c:func:`obs_frontend_source_list_free`.
  145. ---------------------------------------
  146. .. function:: obs_source_t *obs_frontend_get_current_transition(void)
  147. :return: A new reference to the currently active transition.
  148. ---------------------------------------
  149. .. function:: void obs_frontend_set_current_transition(obs_source_t *transition)
  150. :param transition: The transition to set as the current transition.
  151. ---------------------------------------
  152. .. function:: int obs_frontend_get_transition_duration(void)
  153. :return: The transition duration (in milliseconds) currently set in the UI.
  154. ---------------------------------------
  155. .. function:: void obs_frontend_set_transition_duration(int duration)
  156. :param duration: Desired transition duration (in milliseconds)
  157. ---------------------------------------
  158. .. function:: char **obs_frontend_get_scene_collections(void)
  159. :return: The list of profile names, ending with NULL. The list is
  160. stored within one contiguous segment of memory, so freeing
  161. the returned pointer with :c:func:`bfree()` will free the
  162. entire list.
  163. ---------------------------------------
  164. .. function:: char *obs_frontend_get_current_scene_collection(void)
  165. :return: A new pointer to the current scene collection name. Free
  166. with :c:func:`bfree()`.
  167. ---------------------------------------
  168. .. function:: void obs_frontend_set_current_scene_collection(const char *collection)
  169. :param profile: Name of the scene collection to activate.
  170. ---------------------------------------
  171. .. function:: char **obs_frontend_get_profiles(void)
  172. :return: The list of profile names, ending with NULL. The list is
  173. stored within one contiguous segment of memory, so freeing
  174. the returned pointer with :c:func:`bfree()` will free the
  175. entire list.
  176. ---------------------------------------
  177. .. function:: char *obs_frontend_get_current_profile(void)
  178. :return: A new pointer to the current profile name. Free with
  179. :c:func:`bfree()`.
  180. ---------------------------------------
  181. .. function:: char *obs_frontend_get_current_profile_path(void)
  182. :return: A new pointer to the current profile's path on the filesystem. Free
  183. with :c:func:`bfree()`.
  184. ---------------------------------------
  185. .. function:: void obs_frontend_set_current_profile(const char *profile)
  186. :param profile: Name of the profile to activate.
  187. ---------------------------------------
  188. .. function:: bool obs_frontend_create_profile(const char *name)
  189. :param name: Name of the new profile to create (must be unique).
  190. ---------------------------------------
  191. .. function:: bool obs_frontend_duplicate_profile(const char *name)
  192. :param name: Name of the duplicate profile to create (must be unique).
  193. ---------------------------------------
  194. .. function:: void obs_frontend_delete_profile(const char *profile)
  195. :param profile: Name of the profile to delete.
  196. ---------------------------------------
  197. .. function:: void obs_frontend_add_event_callback(obs_frontend_event_cb callback, void *private_data)
  198. Adds a callback that will be called when a frontend event occurs.
  199. See :c:type:`obs_frontend_event` on what sort of events can be
  200. triggered.
  201. :param callback: Callback to use when a frontend event occurs.
  202. :param private_data: Private data associated with the callback.
  203. ---------------------------------------
  204. .. function:: void obs_frontend_remove_event_callback(obs_frontend_event_cb callback, void *private_data)
  205. Removes an event callback.
  206. :param callback: Callback to remove.
  207. :param private_data: Private data associated with the callback.
  208. ---------------------------------------
  209. .. function:: void obs_frontend_add_save_callback(obs_frontend_save_cb callback, void *private_data)
  210. Adds a callback that will be called when the current scene collection
  211. is being saved/loaded.
  212. :param callback: Callback to use when saving/loading a scene
  213. collection.
  214. :param private_data: Private data associated with the callback.
  215. ---------------------------------------
  216. .. function:: void obs_frontend_remove_save_callback(obs_frontend_save_cb callback, void *private_data)
  217. Removes a save/load callback.
  218. :param callback: Callback to remove.
  219. :param private_data: Private data associated with the callback.
  220. ---------------------------------------
  221. .. function:: void obs_frontend_add_preload_callback(obs_frontend_save_cb callback, void *private_data)
  222. Adds a callback that will be called right before a scene collection
  223. is loaded. Useful if you
  224. :param callback: Callback to use when pre-loading.
  225. :param private_data: Private data associated with the callback.
  226. ---------------------------------------
  227. .. function:: void obs_frontend_remove_preload_callback(obs_frontend_save_cb callback, void *private_data)
  228. Removes a pre-load callback.
  229. :param callback: Callback to remove.
  230. :param private_data: Private data associated with the callback.
  231. ---------------------------------------
  232. .. function:: void obs_frontend_push_ui_translation(obs_frontend_translate_ui_cb translate)
  233. Pushes a UI translation callback. This allows a front-end plugin to
  234. intercept when Qt is automatically generating translating data.
  235. Typically this is just called with obs_module_get_string.
  236. :param translate: The translation callback to use.
  237. ---------------------------------------
  238. .. function:: void obs_frontend_pop_ui_translation(void)
  239. Pops the current UI translation callback.
  240. ---------------------------------------
  241. .. function:: void obs_frontend_streaming_start(void)
  242. Starts streaming.
  243. ---------------------------------------
  244. .. function:: void obs_frontend_streaming_stop(void)
  245. Stops streaming.
  246. ---------------------------------------
  247. .. function:: bool obs_frontend_streaming_active(void)
  248. :return: *true* if streaming active, *false* otherwise.
  249. ---------------------------------------
  250. .. function:: void obs_frontend_recording_start(void)
  251. Starts recording.
  252. ---------------------------------------
  253. .. function:: void obs_frontend_recording_stop(void)
  254. Stops recording.
  255. ---------------------------------------
  256. .. function:: bool obs_frontend_recording_active(void)
  257. :return: *true* if recording active, *false* otherwise.
  258. ---------------------------------------
  259. .. function:: void obs_frontend_recording_pause(bool pause)
  260. :pause: *true* to pause recording, *false* to unpause.
  261. ---------------------------------------
  262. .. function:: bool obs_frontend_recording_paused(void)
  263. :return: *true* if recording paused, *false* otherwise.
  264. ---------------------------------------
  265. .. function:: void obs_frontend_replay_buffer_start(void)
  266. Starts replay buffer.
  267. ---------------------------------------
  268. .. function:: void obs_frontend_replay_buffer_stop(void)
  269. Stops replay buffer.
  270. ---------------------------------------
  271. .. function:: void obs_frontend_replay_buffer_save(void)
  272. Saves a replay if the replay buffer is active.
  273. ---------------------------------------
  274. .. function:: bool obs_frontend_replay_buffer_active(void)
  275. :return: *true* if replay buffer active, *false* otherwise.
  276. ---------------------------------------
  277. .. function:: void obs_frontend_open_projector(const char *type, int monitor, const char *geometry, const char *name)
  278. :param type: "Preview", "Source", "Scene", "StudioProgram", or "Multiview" (case insensitive).
  279. :param monitor: Monitor to open the projector on. If -1, opens a window.
  280. :param geometry: If *monitor* is -1, size and position of the projector window. Encoded in Base64 using Qt's geometry encoding.
  281. :param name: If *type* is "Source" or "Scene", name of the source or scene to be displayed.
  282. ---------------------------------------
  283. .. function:: void obs_frontend_save(void)
  284. Saves the current scene collection.
  285. ---------------------------------------
  286. .. function:: obs_output_t *obs_frontend_get_streaming_output(void)
  287. :return: A new reference to the current streaming output.
  288. ---------------------------------------
  289. .. function:: obs_output_t *obs_frontend_get_recording_output(void)
  290. :return: A new reference to the current srecording output.
  291. ---------------------------------------
  292. .. function:: obs_output_t *obs_frontend_get_replay_buffer_output(void)
  293. :return: A new reference to the current replay buffer output.
  294. ---------------------------------------
  295. .. function:: void obs_frontend_set_streaming_service(obs_service_t *service)
  296. Sets the current streaming service to stream with.
  297. :param service: The streaming service to set.
  298. ---------------------------------------
  299. .. function:: obs_service_t *obs_frontend_get_streaming_service(void)
  300. :return: A new reference to the current streaming service object.
  301. ---------------------------------------
  302. .. function:: void obs_frontend_save_streaming_service(void)
  303. Saves the current streaming service data.
  304. ---------------------------------------
  305. .. function:: bool obs_frontend_preview_program_mode_active(void)
  306. :return: *true* if studio mode is active, *false* otherwise.
  307. ---------------------------------------
  308. .. function:: void obs_frontend_set_preview_program_mode(bool enable)
  309. Activates/deactivates studio mode.
  310. :param enable: *true* to activate studio mode, *false* to deactivate
  311. studio mode.
  312. ---------------------------------------
  313. .. function:: void obs_frontend_preview_program_trigger_transition(void)
  314. Triggers a preview-to-program transition if studio mode is active.
  315. ---------------------------------------
  316. .. function:: obs_source_t *obs_frontend_get_current_preview_scene(void)
  317. :return: A new reference to the current preview scene if studio mode
  318. is active, or the current scene if studio mode is not
  319. active.
  320. ---------------------------------------
  321. .. function:: void obs_frontend_set_current_preview_scene(obs_source_t *scene)
  322. Sets the current preview scene in studio mode, or the currently
  323. active scene if not in studio mode.
  324. :param scene: The scene to set as the current preview.
  325. ---------------------------------------
  326. .. function:: void *obs_frontend_take_screenshot(void)
  327. Takes a screenshot of the main OBS output.
  328. ---------------------------------------
  329. .. function:: void *obs_frontend_take_source_screenshot(obs_source_t *source)
  330. Takes a screenshot of the specified source.
  331. :param source: The source to take screenshot of.
  332. ---------------------------------------
  333. .. function:: obs_output_t *obs_frontend_get_virtualcam_output(void)
  334. :return: A new reference to the current virtual camera output.
  335. ---------------------------------------
  336. .. function:: void obs_frontend_start_virtualcam(void)
  337. Starts the virtual camera.
  338. ---------------------------------------
  339. .. function:: void obs_frontend_stop_virtualcam(void)
  340. Stops the virtual camera.
  341. ---------------------------------------
  342. .. function:: bool obs_frontend_virtualcam_active(void)
  343. :return: *true* if virtual camera is active, *false* otherwise.
  344. ---------------------------------------
  345. .. function:: void obs_frontend_reset_video(void)
  346. Reloads the UI canvas and resets libobs video with latest data from profile.
  347. ---------------------------------------
  348. .. function:: void obs_frontend_release_tbar(void);
  349. Emulate a mouse button release on the transition bar and determine transition status.
  350. ---------------------------------------
  351. .. function:: void obs_frontend_set_tbar_position(int position)
  352. Set the value of the transition bar.
  353. :param position: The position to set the T-bar to, with a value in 0-1023.
  354. :type position: int
  355. ---------------------------------------
  356. .. function:: int obs_frontend_get_tbar_position(void)
  357. Get the value of the transition bar.
  358. :return: The value of the position of the T-bar to, with a value in 0-1023.
  359. :rtype: int
  360. ---------------------------------------
  361. .. function:: void *obs_frontend_open_properties(obs_source_t *source)
  362. Opens the properties window of the specified source.
  363. :param source: The source to open the properties window of.
  364. ---------------------------------------
  365. .. function:: void *obs_frontend_open_filters(obs_source_t *source)
  366. Opens the filters window of the specified source.
  367. :param source: The source to open the filters window of.
  368. ---------------------------------------
  369. .. function:: char *obs_frontend_get_current_record_output_path(void)
  370. :return: A new pointer to the current record output path. Free
  371. with :c:func:`bfree()`.