1
0

reference-scenes.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. Scene API Reference (obs_scene_t)
  2. =================================
  3. A scene is a source which contains and renders other sources using
  4. specific transforms and/or filtering
  5. .. type:: obs_scene_t
  6. A reference-counted scene object.
  7. .. type:: obs_sceneitem_t
  8. A reference-counted scene item object.
  9. .. code:: cpp
  10. #include <obs.h>
  11. Scene Item Transform Structure (obs_transform_info)
  12. ---------------------------------------------------
  13. .. type:: struct obs_transform_info
  14. Scene item transform structure.
  15. .. member:: struct vec2 obs_transform_info.pos
  16. Position.
  17. .. member:: float obs_transform_info.rot
  18. Rotation (degrees).
  19. .. member:: struct vec2 obs_transform_info.scale
  20. Scale.
  21. .. member:: uint32_t obs_transform_info.alignment
  22. The alignment of the scene item relative to its position.
  23. Can be 0 or a bitwise OR combination of one of the following values:
  24. - **OBS_ALIGN_CENTER**
  25. - **OBS_ALIGN_LEFT**
  26. - **OBS_ALIGN_RIGHT**
  27. - **OBS_ALIGN_TOP**
  28. - **OBS_ALIGN_BOTTOM**
  29. .. member:: enum obs_bounds_type obs_transform_info.bounds_type
  30. Can be one of the following values:
  31. - **OBS_BOUNDS_NONE** - No bounding box
  32. - **OBS_BOUNDS_STRETCH** - Stretch to the bounding box without preserving aspect ratio
  33. - **OBS_BOUNDS_SCALE_INNER** - Scales with aspect ratio to inner bounding box rectangle
  34. - **OBS_BOUNDS_SCALE_OUTER** - Scales with aspect ratio to outer bounding box rectangle
  35. - **OBS_BOUNDS_SCALE_TO_WIDTH** - Scales with aspect ratio to the bounding box width
  36. - **OBS_BOUNDS_SCALE_TO_HEIGHT** - Scales with aspect ratio to the bounding box height
  37. - **OBS_BOUNDS_MAX_ONLY** - Scales with aspect ratio, but only to the size of the source maximum
  38. .. member:: uint32_t obs_transform_info.bounds_alignment
  39. The alignment of the source within the bounding box.
  40. Can be 0 or a bitwise OR combination of one of the following values:
  41. - **OBS_ALIGN_CENTER**
  42. - **OBS_ALIGN_LEFT**
  43. - **OBS_ALIGN_RIGHT**
  44. - **OBS_ALIGN_TOP**
  45. - **OBS_ALIGN_BOTTOM**
  46. .. member:: struct vec2 obs_transform_info.bounds
  47. The bounding box (if a bounding box is enabled).
  48. Scene Item Crop Structure (obs_sceneitem_crop)
  49. ----------------------------------------------
  50. .. type:: struct obs_sceneitem_crop
  51. Scene item crop structure.
  52. .. member:: int obs_sceneitem_crop.left
  53. Left crop value.
  54. .. member:: int obs_sceneitem_crop.top
  55. Top crop value.
  56. .. member:: int obs_sceneitem_crop.right
  57. Right crop value.
  58. .. member:: int obs_sceneitem_crop.bottom
  59. Bottom crop value.
  60. .. _scene_signal_reference:
  61. Scene Signals
  62. -------------
  63. **item_add** (ptr scene, ptr item)
  64. Called when a scene item has been added to the scene.
  65. **item_remove** (ptr scene, ptr item)
  66. Called when a scene item has been removed from the scen.
  67. **reorder** (ptr scene)
  68. Called when scene items have been reoredered in the scene.
  69. **item_visible** (ptr scene, ptr item, bool visible)
  70. Called when a scene item's visibility state changes.
  71. **item_select** (ptr scene, ptr item)
  72. **item_deselect** (ptr scene, ptr item)
  73. Called when a scene item has been selected/deselected.
  74. (Author's note: These should be replaced)
  75. **item_transform** (ptr scene, ptr item)
  76. Called when a scene item's transform has changed.
  77. General Scene Functions
  78. -----------------------
  79. .. function:: obs_scene_t *obs_scene_create(const char *name)
  80. :param name: Name of the scene source. If it's not unique, it will
  81. be made unique
  82. :return: A reference to a scene
  83. ---------------------
  84. .. function:: obs_scene_t *obs_scene_create_private(const char *name)
  85. :param name: Name of the scene source. Does not have to be unique,
  86. or can be *NULL*
  87. :return: A reference to a private scene
  88. ---------------------
  89. .. function:: obs_scene_t *obs_scene_duplicate(obs_scene_t *scene, const char *name, enum obs_scene_duplicate_type type)
  90. Duplicates a scene. When a scene is duplicated, its sources can be
  91. just referenced, or fully duplicated.
  92. :param name: Name of the new scene source
  93. :param type: | Type of duplication:
  94. | OBS_SCENE_DUP_REFS - Duplicates the scene, but scene items are only duplicated with references
  95. | OBS_SCENE_DUP_COPY - Duplicates the scene, and scene items are also fully duplicated when possible
  96. | OBS_SCENE_DUP_PRIVATE_REFS - Duplicates with references, but the scene is a private source
  97. | OBS_SCENE_DUP_PRIVATE_COPY - Fully duplicates scene items when possible, but the scene and duplicates sources are private sources
  98. :return: A reference to a new scene
  99. ---------------------
  100. .. function:: void obs_scene_addref(obs_scene_t *scene)
  101. void obs_scene_release(obs_scene_t *scene)
  102. Adds/releases a reference to a scene.
  103. ---------------------
  104. .. function:: obs_sceneitem_t *obs_scene_add(obs_scene_t *scene, obs_source_t *source)
  105. :return: A new scene item for a source within a scene. Does not
  106. increment the reference
  107. ---------------------
  108. .. function:: obs_source_t *obs_scene_get_source(const obs_scene_t *scene)
  109. :return: The scene's source. Does not increment the reference
  110. ---------------------
  111. .. function:: obs_scene_t *obs_scene_from_source(const obs_source_t *source)
  112. :return: The scene context, or *NULL* if not a scene. Does not
  113. increase the reference
  114. ---------------------
  115. .. function:: obs_sceneitem_t *obs_scene_find_source(obs_scene_t *scene, const char *name)
  116. :param name: The name of the source to find
  117. :return: The scene item if found, otherwise *NULL* if not found
  118. ---------------------
  119. .. function:: obs_sceneitem_t *obs_scene_find_sceneitem_by_id(obs_scene_t *scene, int64_t id)
  120. :param id: The unique numeric identifier of the scene item
  121. :return: The scene item if found, otherwise *NULL* if not found
  122. ---------------------
  123. .. function:: void obs_scene_enum_items(obs_scene_t *scene, bool (*callback)(obs_scene_t*, obs_sceneitem_t*, void*), void *param)
  124. Enumerates scene items within a scene.
  125. ---------------------
  126. .. function:: bool obs_scene_reorder_items(obs_scene_t *scene, obs_sceneitem_t * const *item_order, size_t item_order_size)
  127. Reorders items within a scene.
  128. ---------------------
  129. .. _scene_item_reference:
  130. Scene Item Functions
  131. --------------------
  132. .. function:: void obs_sceneitem_addref(obs_sceneitem_t *item)
  133. void obs_sceneitem_release(obs_sceneitem_t *item)
  134. Adds/releases a reference to a scene item.
  135. ---------------------
  136. .. function:: void obs_sceneitem_remove(obs_sceneitem_t *item)
  137. Removes the scene item from the scene.
  138. ---------------------
  139. .. function:: obs_scene_t *obs_sceneitem_get_scene(const obs_sceneitem_t *item)
  140. :return: The scene associated with the scene item. Does not
  141. increment the reference
  142. ---------------------
  143. .. function:: obs_source_t *obs_sceneitem_get_source(const obs_sceneitem_t *item)
  144. :return: The source associated with the scene item. Does not
  145. increment the reference
  146. ---------------------
  147. .. function:: void obs_sceneitem_set_pos(obs_sceneitem_t *item, const struct vec2 *pos)
  148. void obs_sceneitem_get_pos(const obs_sceneitem_t *item, struct vec2 *pos)
  149. Sets/gets the position of a scene item.
  150. ---------------------
  151. .. function:: void obs_sceneitem_set_rot(obs_sceneitem_t *item, float rot_deg)
  152. float obs_sceneitem_get_rot(const obs_sceneitem_t *item)
  153. Sets/gets the rotation of a scene item.
  154. ---------------------
  155. .. function:: void obs_sceneitem_set_scale(obs_sceneitem_t *item, const struct vec2 *scale)
  156. void obs_sceneitem_get_scale(const obs_sceneitem_t *item, struct vec2 *scale)
  157. Sets/gets the scaling of the scene item.
  158. ---------------------
  159. .. function:: void obs_sceneitem_set_alignment(obs_sceneitem_t *item, uint32_t alignment)
  160. uint32_t obs_sceneitem_get_alignment(const obs_sceneitem_t *item)
  161. Sets/gets the alignment of the scene item relative to its position.
  162. :param alignment: | Can be any bitwise OR combination of:
  163. | OBS_ALIGN_CENTER
  164. | OBS_ALIGN_LEFT
  165. | OBS_ALIGN_RIGHT
  166. | OBS_ALIGN_TOP
  167. | OBS_ALIGN_BOTTOM
  168. ---------------------
  169. .. function:: void obs_sceneitem_set_order(obs_sceneitem_t *item, enum obs_order_movement movement)
  170. Changes the scene item's order relative to the other scene items
  171. within the scene.
  172. :param movement: | Can be one of the following:
  173. | OBS_ORDER_MOVE_UP
  174. | OBS_ORDER_MOVE_DOWN
  175. | OBS_ORDER_MOVE_TOP
  176. | OBS_ORDER_MOVE_BOTTOM
  177. ---------------------
  178. .. function:: void obs_sceneitem_set_order_position(obs_sceneitem_t *item, int position)
  179. Changes the scene item's order index.
  180. ---------------------
  181. .. function:: void obs_sceneitem_set_bounds_type(obs_sceneitem_t *item, enum obs_bounds_type type)
  182. enum obs_bounds_type obs_sceneitem_get_bounds_type(const obs_sceneitem_t *item)
  183. Sets/gets the bounding box type of a scene item. Bounding boxes are
  184. used to stretch/position the source relative to a specific bounding
  185. box of a specific size.
  186. :param type: | Can be one of the following values:
  187. | OBS_BOUNDS_NONE - No bounding box
  188. | OBS_BOUNDS_STRETCH - Stretch to the bounding box without preserving aspect ratio
  189. | OBS_BOUNDS_SCALE_INNER - Scales with aspect ratio to inner bounding box rectangle
  190. | OBS_BOUNDS_SCALE_OUTER - Scales with aspect ratio to outer bounding box rectangle
  191. | OBS_BOUNDS_SCALE_TO_WIDTH - Scales with aspect ratio to the bounding box width
  192. | OBS_BOUNDS_SCALE_TO_HEIGHT - Scales with aspect ratio to the bounding box height
  193. | OBS_BOUNDS_MAX_ONLY - Scales with aspect ratio, but only to the size of the source maximum
  194. ---------------------
  195. .. function:: void obs_sceneitem_set_bounds_alignment(obs_sceneitem_t *item, uint32_t alignment)
  196. uint32_t obs_sceneitem_get_bounds_alignment(const obs_sceneitem_t *item)
  197. Sets/gets the alignment of the source within the bounding box.
  198. :param alignment: | Can be any bitwise OR combination of:
  199. | OBS_ALIGN_CENTER
  200. | OBS_ALIGN_LEFT
  201. | OBS_ALIGN_RIGHT
  202. | OBS_ALIGN_TOP
  203. | OBS_ALIGN_BOTTOM
  204. ---------------------
  205. .. function:: void obs_sceneitem_set_bounds(obs_sceneitem_t *item, const struct vec2 *bounds)
  206. void obs_sceneitem_get_bounds(const obs_sceneitem_t *item, struct vec2 *bounds)
  207. Sets/gets the bounding box width/height of the scene item.
  208. ---------------------
  209. .. function:: void obs_sceneitem_set_info(obs_sceneitem_t *item, const struct obs_transform_info *info)
  210. void obs_sceneitem_get_info(const obs_sceneitem_t *item, struct obs_transform_info *info)
  211. Sets/gets the transform information of the scene item.
  212. ---------------------
  213. .. function:: void obs_sceneitem_get_draw_transform(const obs_sceneitem_t *item, struct matrix4 *transform)
  214. Gets the transform matrix of the scene item used for drawing the
  215. source.
  216. ---------------------
  217. .. function:: void obs_sceneitem_get_box_transform(const obs_sceneitem_t *item, struct matrix4 *transform)
  218. Gets the transform matrix of the scene item used for the bouding box
  219. or edges of the scene item.
  220. ---------------------
  221. .. function:: bool obs_sceneitem_set_visible(obs_sceneitem_t *item, bool visible)
  222. bool obs_sceneitem_visible(const obs_sceneitem_t *item)
  223. Sets/gets the visibility state of the scene item.
  224. ---------------------
  225. .. function:: void obs_sceneitem_set_crop(obs_sceneitem_t *item, const struct obs_sceneitem_crop *crop)
  226. void obs_sceneitem_get_crop(const obs_sceneitem_t *item, struct obs_sceneitem_crop *crop)
  227. Sets/gets the cropping of the scene item.
  228. ---------------------
  229. .. function:: void obs_sceneitem_set_scale_filter(obs_sceneitem_t *item, enum obs_scale_type filter)
  230. enum obs_scale_type obs_sceneitem_get_scale_filter( obs_sceneitem_t *item)
  231. Sets/gets the scale filter used for the scene item.
  232. :param filter: | Can be one of the following values:
  233. | OBS_SCALE_DISABLE
  234. | OBS_SCALE_POINT
  235. | OBS_SCALE_BICUBIC
  236. | OBS_SCALE_BILINEAR
  237. | OBS_SCALE_LANCZOS
  238. ---------------------
  239. .. function:: void obs_sceneitem_defer_update_begin(obs_sceneitem_t *item)
  240. void obs_sceneitem_defer_update_end(obs_sceneitem_t *item)
  241. Allows the ability to call any one of the transform functions without
  242. updating the internal matrices until obs_sceneitem_defer_update_end
  243. has been called.
  244. ---------------------
  245. .. function:: obs_data_t *obs_sceneitem_get_private_settings(obs_sceneitem_t *item)
  246. :return: An incremented reference to the private settings of the
  247. scene item. Allows the front-end to set custom information
  248. which is saved with the scene item