reference-properties.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. Properties API Reference (obs_properties_t)
  2. ===========================================
  3. Properties are used to enumerate available settings for a libobs object.
  4. Typically this is used to automatically generate user interface widgets,
  5. though can be used to enumerate available and/or valid values for
  6. specific settings as well.
  7. .. type:: obs_properties_t
  8. Properties object (not reference counted).
  9. .. type:: obs_property_t
  10. A property object (not reference counted).
  11. .. code:: cpp
  12. #include <obs.h>
  13. General Functions
  14. -----------------
  15. .. function:: obs_properties_t *obs_properties_create(void)
  16. :return: A new properties object.
  17. ---------------------
  18. .. function:: obs_properties_t *obs_properties_create_param(void *param, void (*destroy)(void *param))
  19. Creates a new properties object with specific private data *param*
  20. associated with the object, and is automatically freed with the
  21. object when the properties are destroyed via the *destroy* function.
  22. :return: A new properties object.
  23. ---------------------
  24. .. function:: void obs_properties_destroy(obs_properties_t *props)
  25. ---------------------
  26. .. function:: void obs_properties_set_flags(obs_properties_t *props, uint32_t flags)
  27. uint32_t obs_properties_get_flags(obs_properties_t *props)
  28. :param flags: 0 or a bitwise OR combination of one of the following
  29. values:
  30. - OBS_PROPERTIES_DEFER_UPDATE - A hint that tells the
  31. front-end to defers updating the settings until the
  32. user has finished editing all properties rather than
  33. immediately updating any settings
  34. ---------------------
  35. .. function:: void obs_properties_set_param(obs_properties_t *props, void *param, void (*destroy)(void *param))
  36. void *obs_properties_get_param(obs_properties_t *props)
  37. Sets custom data associated with this properties object. If private
  38. data is already associated with the object, that private data will be
  39. destroyed before assigning new private data to it.
  40. ---------------------
  41. .. function:: void obs_properties_apply_settings(obs_properties_t *props, obs_data_t *settings)
  42. Applies settings to the properties by calling all the necessary
  43. modification callbacks
  44. ---------------------
  45. Property Object Functions
  46. -------------------------
  47. .. function:: obs_property_t *obs_properties_add_bool(obs_properties_t *props, const char *name, const char *description)
  48. Adds a boolean property.
  49. :param name: Setting identifier string
  50. :param description: Localized name shown to user
  51. :return: The property
  52. ---------------------
  53. .. function:: obs_property_t *obs_properties_add_int(obs_properties_t *props, const char *name, const char *description, int min, int max, int step)
  54. Adds an integer property.
  55. :param name: Setting identifier string
  56. :param description: Localized name shown to user
  57. :param min: Minimum value
  58. :param max: Maximum value
  59. :param step: Step value
  60. :return: The property
  61. ---------------------
  62. .. function:: obs_property_t *obs_properties_add_float(obs_properties_t *props, const char *name, const char *description, double min, double max, double step)
  63. :param name: Setting identifier string
  64. :param description: Localized name shown to user
  65. :param min: Minimum value
  66. :param max: Maximum value
  67. :param step: Step value
  68. :return: The property
  69. ---------------------
  70. .. function:: obs_property_t *obs_properties_add_int_slider(obs_properties_t *props, const char *name, const char *description, int min, int max, int step)
  71. :param name: Setting identifier string
  72. :param description: Localized name shown to user
  73. :param min: Minimum value
  74. :param max: Maximum value
  75. :param step: Step value
  76. :return: The property
  77. ---------------------
  78. .. function:: obs_property_t *obs_properties_add_float_slider(obs_properties_t *props, const char *name, const char *description, double min, double max, double step)
  79. :param name: Setting identifier string
  80. :param description: Localized name shown to user
  81. :param min: Minimum value
  82. :param max: Maximum value
  83. :param step: Step value
  84. :return: The property
  85. ---------------------
  86. .. function:: obs_property_t *obs_properties_add_text(obs_properties_t *props, const char *name, const char *description, enum obs_text_type type)
  87. :param name: Setting identifier string
  88. :param description: Localized name shown to user
  89. :param type: Can be one of the following values:
  90. - **OBS_TEXT_DEFAULT** - Single line of text
  91. - **OBS_TEXT_PASSWORD** - Single line of text (passworded)
  92. - **OBS_TEXT_MULTILINE** - Multi-line text
  93. :return: The property
  94. ---------------------
  95. .. function:: obs_property_t *obs_properties_add_path(obs_properties_t *props, const char *name, const char *description, enum obs_path_type type, const char *filter, const char *default_path)
  96. Adds a 'path' property. Can be a directory or a file.
  97. If target is a file path, the filters should be this format, separated by
  98. double semi-colens, and extensions separated by space::
  99. "Example types 1 and 2 (*.ex1 *.ex2);;Example type 3 (*.ex3)"
  100. :param name: Setting identifier string
  101. :param description: Localized name shown to user
  102. :param type: Can be one of the following values:
  103. - **OBS_PATH_FILE** - File (for reading)
  104. - **OBS_PATH_FILE_SAVE** - File (for writing)
  105. - **OBS_PATH_DIRECTORY** - Directory
  106. :param filter: If type is a file path, then describes the file filter
  107. that the user can browse. Items are separated via
  108. double semi-colens. If multiple file types in a
  109. filter, separate with space.
  110. :param default_path: The default path to start in, or *NULL*
  111. :return: The property
  112. ---------------------
  113. .. function:: obs_property_t *obs_properties_add_list(obs_properties_t *props, const char *name, const char *description, enum obs_combo_type type, enum obs_combo_format format)
  114. Adds an integer/string/floating point item list. This would be
  115. implemented as a combo box in user interface.
  116. :param name: Setting identifier string
  117. :param description: Localized name shown to user
  118. :param type: Can be one of the following values:
  119. - **OBS_COMBO_TYPE_EDITABLE** - Can be edited.
  120. Only used with string lists.
  121. - **OBS_COMBO_TYPE_LIST** - Not ediable.
  122. :param format: Can be one of the following values:
  123. - **OBS_COMBO_FORMAT_INT** - Integer list
  124. - **OBS_COMBO_FORMAT_FLOAT** - Floating point
  125. list
  126. - **OBS_COMBO_FORMAT_STRING** - String list
  127. :return: The property
  128. Important Related Functions:
  129. - :c:func:`obs_property_list_add_string`
  130. - :c:func:`obs_property_list_add_int`
  131. - :c:func:`obs_property_list_add_float`
  132. - :c:func:`obs_property_list_insert_string`
  133. - :c:func:`obs_property_list_insert_int`
  134. - :c:func:`obs_property_list_insert_float`
  135. - :c:func:`obs_property_list_item_remove`
  136. - :c:func:`obs_property_list_clear`
  137. ---------------------
  138. .. function:: obs_property_t *obs_properties_add_color(obs_properties_t *props, const char *name, const char *description)
  139. Adds a color property.
  140. :param name: Setting identifier string
  141. :param description: Localized name shown to user
  142. :return: The property
  143. ---------------------
  144. .. function:: obs_property_t *obs_properties_add_button(obs_properties_t *props, const char *name, const char *text, obs_property_clicked_t callback)
  145. Adds a button property. This property does not actually store any
  146. settings; it's used to implement a button in user interface if the
  147. properties are used to generate user interface.
  148. :param name: Setting identifier string
  149. :param description: Localized name shown to user
  150. :return: The property
  151. ---------------------
  152. .. function:: obs_property_t *obs_properties_add_font(obs_properties_t *props, const char *name, const char *description)
  153. Adds a font property.
  154. :param name: Setting identifier string
  155. :param description: Localized name shown to user
  156. :return: The property
  157. ---------------------
  158. .. function:: obs_property_t *obs_properties_add_editable_list(obs_properties_t *props, const char *name, const char *description, enum obs_editable_list_type type, const char *filter, const char *default_path)
  159. Adds a list in which the user can add/insert/remove items.
  160. :param name: Setting identifier string
  161. :param description: Localized name shown to user
  162. :param type: Can be one of the following values:
  163. - **OBS_EDITABLE_LIST_TYPE_STRINGS** - An
  164. editable list of strings.
  165. - **OBS_EDITABLE_LIST_TYPE_FILES** - An
  166. editable list of files.
  167. - **OBS_EDITABLE_LIST_TYPE_FILES_AND_URLS** -
  168. An editable list of files and URLs.
  169. :param filter: File filter to use if a file list
  170. :param default_path: Default path if a file list
  171. :return: The property
  172. ---------------------
  173. .. function:: obs_property_t *obs_properties_add_frame_rate(obs_properties_t *props, const char *name, const char *description)
  174. Adds a frame rate property.
  175. :param name: Setting identifier string
  176. :param description: Localized name shown to user
  177. :return: The property
  178. Important Related Functions:
  179. - :c:func:`obs_property_frame_rate_option_add`
  180. - :c:func:`obs_property_frame_rate_fps_range_add`
  181. - :c:func:`obs_property_frame_rate_option_insert`
  182. - :c:func:`obs_property_frame_rate_fps_range_insert`
  183. ---------------------
  184. Property Enumeration Functions
  185. ------------------------------
  186. .. function:: obs_property_t *obs_properties_first(obs_properties_t *props)
  187. :return: The first property in the properties object.
  188. ---------------------
  189. .. function:: obs_property_t *obs_properties_get(obs_properties_t *props, const char *property)
  190. :param property: The name of the property to get
  191. :return: A specific property or *NULL* if not found
  192. ---------------------
  193. .. function:: bool obs_property_next(obs_property_t **p)
  194. :param p: Pointer to the pointer of the next property
  195. :return: *true* if successful, *false* if no more properties
  196. ---------------------
  197. .. function:: const char * obs_property_name(obs_property_t *p)
  198. :return: The setting identifier string of the property
  199. *(Author's Note: "name" was a bad name to use here. Should have been
  200. "setting")*
  201. ---------------------
  202. .. function:: const char * obs_property_description(obs_property_t *p)
  203. :return: The actual localized display name of the property
  204. *(Author's note: This one should have been the "name")*
  205. ---------------------
  206. .. function:: const char * obs_property_long_description(obs_property_t *p)
  207. :return: A detailed description of what the setting is used for.
  208. Usually used with things like tooltips.
  209. ---------------------
  210. .. function:: enum obs_property_type obs_property_get_type(obs_property_t *p)
  211. :return: One of the following values:
  212. - OBS_PROPERTY_INVALID
  213. - OBS_PROPERTY_BOOL
  214. - OBS_PROPERTY_INT
  215. - OBS_PROPERTY_FLOAT
  216. - OBS_PROPERTY_TEXT
  217. - OBS_PROPERTY_PATH
  218. - OBS_PROPERTY_LIST
  219. - OBS_PROPERTY_COLOR
  220. - OBS_PROPERTY_BUTTON
  221. - OBS_PROPERTY_FONT
  222. - OBS_PROPERTY_EDITABLE_LIST
  223. - OBS_PROPERTY_FRAME_RATE
  224. ---------------------
  225. .. function:: bool obs_property_enabled(obs_property_t *p)
  226. ---------------------
  227. .. function:: bool obs_property_visible(obs_property_t *p)
  228. ---------------------
  229. .. function:: int obs_property_int_min(obs_property_t *p)
  230. ---------------------
  231. .. function:: int obs_property_int_max(obs_property_t *p)
  232. ---------------------
  233. .. function:: int obs_property_int_step(obs_property_t *p)
  234. ---------------------
  235. .. function:: enum obs_number_type obs_property_int_type(obs_property_t *p)
  236. ---------------------
  237. .. function:: double obs_property_float_min(obs_property_t *p)
  238. ---------------------
  239. .. function:: double obs_property_float_max(obs_property_t *p)
  240. ---------------------
  241. .. function:: double obs_property_float_step(obs_property_t *p)
  242. ---------------------
  243. .. function:: enum obs_number_type obs_property_float_type(obs_property_t *p)
  244. ---------------------
  245. .. function:: enum obs_text_type obs_property_text_type(obs_property_t *p)
  246. ---------------------
  247. .. function:: enum obs_path_type obs_property_path_type(obs_property_t *p)
  248. ---------------------
  249. .. function:: const char * obs_property_path_filter(obs_property_t *p)
  250. ---------------------
  251. .. function:: const char * obs_property_path_default_path(obs_property_t *p)
  252. ---------------------
  253. .. function:: enum obs_combo_type obs_property_list_type(obs_property_t *p)
  254. ---------------------
  255. .. function:: enum obs_combo_format obs_property_list_format(obs_property_t *p)
  256. ---------------------
  257. .. function:: bool obs_property_list_item_disabled(obs_property_t *p, size_t idx)
  258. ---------------------
  259. .. function:: size_t obs_property_list_item_count(obs_property_t *p)
  260. ---------------------
  261. .. function:: const char *obs_property_list_item_name(obs_property_t *p, size_t idx)
  262. ---------------------
  263. .. function:: const char *obs_property_list_item_string(obs_property_t *p, size_t idx)
  264. ---------------------
  265. .. function:: long long obs_property_list_item_int(obs_property_t *p, size_t idx)
  266. ---------------------
  267. .. function:: double obs_property_list_item_float(obs_property_t *p, size_t idx)
  268. ---------------------
  269. .. function:: enum obs_editable_list_type obs_property_editable_list_type(obs_property_t *p)
  270. ---------------------
  271. .. function:: const char *obs_property_editable_list_filter(obs_property_t *p)
  272. ---------------------
  273. .. function:: const char *obs_property_editable_list_default_path(obs_property_t *p)
  274. ---------------------
  275. .. function:: size_t obs_property_frame_rate_options_count(obs_property_t *p)
  276. ---------------------
  277. .. function:: const char *obs_property_frame_rate_option_name(obs_property_t *p, size_t idx)
  278. ---------------------
  279. .. function:: const char *obs_property_frame_rate_option_description( obs_property_t *p, size_t idx)
  280. ---------------------
  281. .. function:: size_t obs_property_frame_rate_fps_ranges_count(obs_property_t *p)
  282. ---------------------
  283. .. function:: struct media_frames_per_second obs_property_frame_rate_fps_range_min( obs_property_t *p, size_t idx)
  284. ---------------------
  285. .. function:: struct media_frames_per_second obs_property_frame_rate_fps_range_max( obs_property_t *p, size_t idx)
  286. ---------------------
  287. Property Modification Functions
  288. -------------------------------
  289. .. function:: void obs_property_set_modified_callback(obs_property_t *p, obs_property_modified_t modified)
  290. Allows the ability to change the properties depending on what
  291. settings are used by the user.
  292. Relevant data types used with this function:
  293. .. code:: cpp
  294. typedef bool (*obs_property_clicked_t)(obs_properties_t *props,
  295. obs_property_t *property, void *data);
  296. ---------------------
  297. .. function:: bool obs_property_modified(obs_property_t *p, obs_data_t *settings)
  298. ---------------------
  299. .. function:: bool obs_property_button_clicked(obs_property_t *p, void *obj)
  300. ---------------------
  301. .. function:: void obs_property_set_visible(obs_property_t *p, bool visible)
  302. ---------------------
  303. .. function:: void obs_property_set_enabled(obs_property_t *p, bool enabled)
  304. ---------------------
  305. .. function:: void obs_property_set_description(obs_property_t *p, const char *description)
  306. Sets the displayed localized name of the property, shown to the user.
  307. ---------------------
  308. .. function:: void obs_property_set_long_description(obs_property_t *p, const char *long_description)
  309. Sets the localized long description of the property, usually shown to
  310. a user via tooltip.
  311. ---------------------
  312. .. function:: void obs_property_int_set_limits(obs_property_t *p, int min, int max, int step)
  313. ---------------------
  314. .. function:: void obs_property_float_set_limits(obs_property_t *p, double min, double max, double step)
  315. ---------------------
  316. .. function:: void obs_property_list_clear(obs_property_t *p)
  317. ---------------------
  318. .. function:: size_t obs_property_list_add_string(obs_property_t *p, const char *name, const char *val)
  319. Adds a string to a string list.
  320. ---------------------
  321. .. function:: size_t obs_property_list_add_int(obs_property_t *p, const char *name, long long val)
  322. Adds an integer to a integer list.
  323. ---------------------
  324. .. function:: size_t obs_property_list_add_float(obs_property_t *p, const char *name, double val)
  325. Adds a floating point to a floating point list.
  326. ---------------------
  327. .. function:: void obs_property_list_insert_string(obs_property_t *p, size_t idx, const char *name, const char *val)
  328. Inserts a string in to a string list.
  329. ---------------------
  330. .. function:: void obs_property_list_insert_int(obs_property_t *p, size_t idx, const char *name, long long val)
  331. Inserts an integer in to an integer list.
  332. ---------------------
  333. .. function:: void obs_property_list_insert_float(obs_property_t *p, size_t idx, const char *name, double val)
  334. Inserts a floating point in to a floating point list.
  335. ---------------------
  336. .. function:: void obs_property_list_item_disable(obs_property_t *p, size_t idx,
  337. ---------------------
  338. .. function:: void obs_property_list_item_remove(obs_property_t *p, size_t idx)
  339. ---------------------
  340. .. function:: size_t obs_property_frame_rate_option_add(obs_property_t *p, const char *name, const char *description)
  341. ---------------------
  342. .. function:: size_t obs_property_frame_rate_fps_range_add(obs_property_t *p, struct media_frames_per_second min, struct media_frames_per_second max)
  343. ---------------------
  344. .. function:: void obs_property_frame_rate_clear(obs_property_t *p)
  345. ---------------------
  346. .. function:: void obs_property_frame_rate_options_clear(obs_property_t *p)
  347. ---------------------
  348. .. function:: void obs_property_frame_rate_fps_ranges_clear(obs_property_t *p)
  349. ---------------------
  350. .. function:: void obs_property_frame_rate_option_insert(obs_property_t *p, size_t idx, const char *name, const char *description)
  351. ---------------------
  352. .. function:: void obs_property_frame_rate_fps_range_insert(obs_property_t *p, size_t idx, struct media_frames_per_second min, struct media_frames_per_second max)