1
0

reference-outputs.rst 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041
  1. Output API Reference (obs_output_t)
  2. ===================================
  3. Outputs allow the ability to output the currently rendering audio/video.
  4. Streaming and recording are two common examples of outputs, but not the
  5. only types of outputs. Outputs can receive the raw data or receive
  6. encoded data. The `libobs/obs-output.h`_ file is the dedicated header
  7. for implementing outputs
  8. .. type:: obs_output_t
  9. A reference-counted output object.
  10. .. type:: obs_weak_output_t
  11. A weak reference to an output object.
  12. .. code:: cpp
  13. #include <obs.h>
  14. Output Definition Structure (obs_output_info)
  15. ---------------------------------------------
  16. .. struct:: obs_output_info
  17. Output definition structure.
  18. .. member:: const char *obs_output_info.id
  19. Unique string identifier for the source (required).
  20. .. member:: uint32_t obs_output_info.flags
  21. Output capability flags (required).
  22. (Author's note: This should be renamed to "capability_flags")
  23. A bitwise OR combination of one or more of the following values:
  24. - **OBS_OUTPUT_VIDEO** - Can output video.
  25. - **OBS_OUTPUT_AUDIO** - Can output audio.
  26. - **OBS_OUTPUT_AV** - Combines OBS_OUTPUT_VIDEO and OBS_OUTPUT_AUDIO.
  27. - **OBS_OUTPUT_ENCODED** - Output is encoded.
  28. When this capability flag is used, the output must have encoders
  29. assigned to it via the :c:func:`obs_output_set_video_encoder()`
  30. and/or :c:func:`obs_output_set_audio_encoder()` functions in order
  31. to be started.
  32. - **OBS_OUTPUT_SERVICE** - Output requires a service object.
  33. When this capability flag is used, the output must have a service
  34. assigned to it via the :c:func:`obs_output_set_service()` function
  35. in order to be started.
  36. This is usually used with live streaming outputs that stream to
  37. specific services.
  38. - **OBS_OUTPUT_MULTI_TRACK** - Output supports multiple audio tracks.
  39. When this capability flag is used, specifies that this output
  40. supports multiple encoded audio tracks simultaneously.
  41. - **OBS_OUTPUT_CAN_PAUSE** - Output supports pausing.
  42. When this capability flag is used, the output supports pausing.
  43. When an output is paused, raw or encoded audio/video data will be
  44. halted when paused down to the exact point to the closest video
  45. frame. Audio data will be correctly truncated down to the exact
  46. audio sample according to that video frame timing.
  47. .. member:: const char *(*obs_output_info.get_name)(void *type_data)
  48. Get the translated name of the output type.
  49. :param type_data: The type_data variable of this structure
  50. :return: The translated name of the output type
  51. .. member:: void *(*obs_output_info.create)(obs_data_t *settings, obs_output_t *output)
  52. Creates the implementation data for the output.
  53. :param settings: Settings to initialize the output with
  54. :param output: Output that this data is associated with
  55. :return: The implementation data associated with this output
  56. .. member:: void (*obs_output_info.destroy)(void *data)
  57. Destroys the implementation data for the output.
  58. .. member:: bool (*obs_output_info.start)(void *data)
  59. Starts the output. If needed, this function can spawn a thread,
  60. return *true* immediately, and then signal for failure later.
  61. :return: *true* if successful or deferring to a signal to indicate
  62. failure, *false* on failure to start
  63. .. member:: void (*obs_output_info.stop)(void *data, uint64_t ts)
  64. Requests an output to stop at a specified time. The *ts* parameter
  65. indicates when the stop should occur. Output will actually stop when
  66. either the :c:func:`obs_output_end_data_capture()` or
  67. :c:func:`obs_output_signal_stop()` functions are called. If *ts* is
  68. 0, an immediate stop was requested.
  69. :param ts: The timestamp to stop. If 0, the output should attempt to
  70. stop immediately rather than wait for any more data to
  71. process
  72. .. member:: void (*obs_output_info.raw_video)(void *data, struct video_data *frame)
  73. This is called when the output receives raw video data. Only applies
  74. to outputs that are not encoded.
  75. :param frame: The raw video frame
  76. .. member:: void (*obs_output_info.raw_audio)(void *data, struct audio_data *frames)
  77. This is called when the output receives raw audio data. Only applies
  78. to outputs that are not encoded.
  79. **This callback must be used with single-track raw outputs.**
  80. :param frames: The raw audio frames
  81. .. member:: void (*obs_output_info.raw_audio2)(void *data, size_t idx, struct audio_data *frames)
  82. This is called when the output receives raw audio data. Only applies
  83. to outputs that are not encoded.
  84. **This callback must be used with multi-track raw outputs.**
  85. :param idx: The audio track index
  86. :param frames: The raw audio frames
  87. .. member:: void (*obs_output_info.encoded_packet)(void *data, struct encoder_packet *packet)
  88. This is called when the output receives encoded video/audio data.
  89. Only applies to outputs that are encoded. Packets will always be
  90. given in monotonic timestamp order.
  91. :param packet: The video or audio packet. If NULL, an encoder error
  92. occurred, and the output should call
  93. :c:func:`obs_output_signal_stop()` with the error code
  94. **OBS_OUTPUT_ENCODE_ERROR**.
  95. .. member:: void (*obs_output_info.update)(void *data, obs_data_t *settings)
  96. Updates the settings for this output.
  97. (Optional)
  98. :param settings: New settings for this output
  99. .. member:: void (*obs_output_info.get_defaults)(obs_data_t *settings)
  100. void (*obs_output_info.get_defaults2)(void *type_data, obs_data_t *settings)
  101. Sets the default settings for this output.
  102. (Optional)
  103. :param settings: Default settings. Call obs_data_set_default*
  104. functions on this object to set default setting
  105. values
  106. .. member:: obs_properties_t *(*obs_output_info.get_properties)(void *data)
  107. obs_properties_t *(*obs_output_info.get_properties2)(void *data, void *type_data)
  108. Gets the property information of this output.
  109. (Optional)
  110. :return: The properties of the output
  111. .. member:: void (*obs_output_info.unused1)(void *data)
  112. This callback is no longer used.
  113. .. member:: uint64_t (*obs_output_info.get_total_bytes)(void *data)
  114. Returns the number of total bytes processed by this output.
  115. (Optional)
  116. :return: Total bytes processed by this output since it started
  117. .. member:: int (*obs_output_info.get_dropped_frames)(void *data)
  118. Returns the number of dropped frames.
  119. (Optional)
  120. :return: Number of dropped frames due to network congestion by this
  121. output since it started
  122. .. member:: void *obs_output_info.type_data
  123. void (*obs_output_info.free_type_data)(void *type_data)
  124. Private data associated with this entry. Note that this is not the
  125. same as the implementation data; this is used to differentiate
  126. between two different types if the same callbacks are used for more
  127. than one different type.
  128. (Optional)
  129. .. member:: float (*obs_output_info.get_congestion)(void *data)
  130. This function is used to indicate how currently congested the output
  131. is. Useful for visualizing how much data is backed up on streaming
  132. outputs.
  133. (Optional)
  134. :return: Current congestion value (0.0f..1.0f)
  135. .. member:: int (*obs_output_info.get_connect_time_ms)(void *data)
  136. This function is used to determine how many milliseconds it took to
  137. connect to its current server.
  138. (Optional)
  139. :return: Milliseconds it took to connect to its current server
  140. .. member:: const char *obs_output_info.encoded_video_codecs
  141. const char *obs_output_info.encoded_audio_codecs
  142. This variable specifies which codecs are supported by an encoded
  143. output, separated by semicolon.
  144. Required if **OBS_OUTPUT_SERVICE** flag is set, otherwise
  145. recommended.
  146. .. member:: const char *obs_output_info.protocols
  147. This variable specifies which protocols are supported by an output,
  148. separated by semicolon.
  149. Required only if **OBS_OUTPUT_SERVICE** flag is set.
  150. .. versionadded:: 29.1
  151. .. _output_signal_handler_reference:
  152. Output Signals
  153. --------------
  154. **start** (ptr output)
  155. Called when the output starts.
  156. **stop** (ptr output, int code)
  157. Called when the output stops.
  158. :Parameters: - **code** - Can be one of the following values:
  159. | OBS_OUTPUT_SUCCESS - Successfully stopped
  160. | OBS_OUTPUT_BAD_PATH - The specified path was invalid
  161. | OBS_OUTPUT_CONNECT_FAILED - Failed to connect to a server
  162. | OBS_OUTPUT_INVALID_STREAM - Invalid stream path
  163. | OBS_OUTPUT_ERROR - Generic error
  164. | OBS_OUTPUT_DISCONNECTED - Unexpectedly disconnected
  165. | OBS_OUTPUT_UNSUPPORTED - The settings, video/audio format, or codecs are unsupported by this output
  166. | OBS_OUTPUT_NO_SPACE - Ran out of disk space
  167. | OBS_OUTPUT_ENCODE_ERROR - Encoder error
  168. **pause** (ptr output)
  169. Called when the output has been paused.
  170. **unpause** (ptr output)
  171. Called when the output has been unpaused.
  172. **starting** (ptr output)
  173. Called when the output is starting.
  174. **stopping** (ptr output)
  175. Called when the output is stopping.
  176. **activate** (ptr output)
  177. Called when the output activates (starts capturing data).
  178. **deactivate** (ptr output)
  179. Called when the output deactivates (stops capturing data).
  180. **reconnect** (ptr output)
  181. Called when the output is reconnecting.
  182. **reconnect_success** (ptr output)
  183. Called when the output has successfully reconnected.
  184. General Output Functions
  185. ------------------------
  186. .. function:: void obs_register_output(struct obs_output_info *info)
  187. Registers an output type. Typically used in
  188. :c:func:`obs_module_load()` or in the program's initialization phase.
  189. ---------------------
  190. .. function:: const char *obs_output_get_display_name(const char *id)
  191. Calls the :c:member:`obs_output_info.get_name` callback to get the
  192. translated display name of an output type.
  193. :param id: The output type string identifier
  194. :return: The translated display name of an output type
  195. ---------------------
  196. .. function:: obs_output_t *obs_output_create(const char *id, const char *name, obs_data_t *settings, obs_data_t *hotkey_data)
  197. Creates an output with the specified settings.
  198. The "output" context is used for anything related to outputting the
  199. final video/audio mix (E.g. streaming or recording). Use
  200. obs_output_release to release it.
  201. :param id: The output type string identifier
  202. :param name: The desired name of the output. If this is
  203. not unique, it will be made to be unique
  204. :param settings: The settings for the output, or *NULL* if
  205. none
  206. :param hotkey_data: Saved hotkey data for the output, or *NULL*
  207. if none
  208. :return: A reference to the newly created output, or
  209. *NULL* if failed
  210. ---------------------
  211. .. function:: obs_output_t *obs_output_get_ref(obs_output_t *output)
  212. Returns an incremented reference if still valid, otherwise returns
  213. *NULL*. Release with :c:func:`obs_output_release()`.
  214. ---------------------
  215. .. function:: void obs_output_release(obs_output_t *output)
  216. Releases a reference to an output. When the last reference is
  217. released, the output is destroyed.
  218. ---------------------
  219. .. function:: obs_weak_output_t *obs_output_get_weak_output(obs_output_t *output)
  220. obs_output_t *obs_weak_output_get_output(obs_weak_output_t *weak)
  221. These functions are used to get a weak reference from a strong output
  222. reference, or a strong output reference from a weak reference. If
  223. the output is destroyed, *obs_weak_output_get_output* will return
  224. *NULL*.
  225. ---------------------
  226. .. function:: void obs_weak_output_addref(obs_weak_output_t *weak)
  227. void obs_weak_output_release(obs_weak_output_t *weak)
  228. Adds/releases a weak reference to an output.
  229. ---------------------
  230. .. function:: bool obs_weak_output_references_output(obs_weak_output_t *weak, obs_output_t *output)
  231. Compares a weak output reference with an output.
  232. :return: Whether the weak output reference ties back to the specified output
  233. ---------------------
  234. .. function:: const char *obs_output_get_name(const obs_output_t *output)
  235. :return: The name of the output
  236. ---------------------
  237. .. function:: const char *obs_output_get_id(const obs_output_t *output)
  238. :return: The output's type identifier string
  239. ---------------------
  240. .. function:: bool obs_output_start(obs_output_t *output)
  241. Starts the output.
  242. :return: *true* if output successfully started, *false* otherwise. If
  243. the output failed to start,
  244. :c:func:`obs_output_get_last_error()` may contain a specific
  245. error string related to the reason
  246. ---------------------
  247. .. function:: void obs_output_stop(obs_output_t *output)
  248. Requests the output to stop. The output will wait until all data is
  249. sent up until the time the call was made, then when the output has
  250. successfully stopped, it will send the "stop" signal. See
  251. :ref:`output_signal_handler_reference` for more information on output
  252. signals.
  253. ---------------------
  254. .. function:: void obs_output_set_delay(obs_output_t *output, uint32_t delay_sec, uint32_t flags)
  255. Sets the current output delay, in seconds (if the output supports delay)
  256. If delay is currently active, it will set the delay value, but will not
  257. affect the current delay, it will only affect the next time the output is
  258. activated.
  259. :param delay_sec: Amount to delay the output, in seconds
  260. :param flags: | Can be 0 or a combination of one of the following values:
  261. | OBS_OUTPUT_DELAY_PRESERVE - On reconnection, start where it left of on reconnection. Note however that this option will consume extra memory to continually increase delay while waiting to reconnect
  262. ---------------------
  263. .. function:: uint32_t obs_output_get_delay(const obs_output_t *output)
  264. Gets the currently set delay value, in seconds.
  265. ---------------------
  266. .. function:: uint32_t obs_output_get_active_delay(const obs_output_t *output)
  267. If delay is active, gets the currently active delay value, in
  268. seconds. The active delay can increase if the
  269. OBS_OUTPUT_DELAY_PRESERVE flag was set when setting a delay.
  270. ---------------------
  271. .. function:: void obs_output_force_stop(obs_output_t *output)
  272. Attempts to get the output to stop immediately without waiting for
  273. data to send.
  274. ---------------------
  275. .. function:: bool obs_output_active(const obs_output_t *output)
  276. :return: *true* if the output is currently active, *false* otherwise
  277. ---------------------
  278. .. function:: obs_data_t *obs_output_defaults(const char *id)
  279. :return: An incremented reference to the output's default settings.
  280. Release with :c:func:`obs_data_release()`.
  281. ---------------------
  282. .. function:: obs_properties_t *obs_output_properties(const obs_output_t *output)
  283. obs_properties_t *obs_get_output_properties(const char *id)
  284. Use these functions to get the properties of an output or output
  285. type. Properties are optionally used (if desired) to automatically
  286. generate user interface widgets to allow users to update settings.
  287. :return: The properties list for a specific existing output. Free
  288. with :c:func:`obs_properties_destroy()`
  289. ---------------------
  290. .. function:: void obs_output_update(obs_output_t *output, obs_data_t *settings)
  291. Updates the settings for this output context.
  292. ---------------------
  293. .. function:: bool obs_output_can_pause(const obs_output_t *output)
  294. :return: *true* if the output can be paused, *false* otherwise
  295. ---------------------
  296. .. function:: bool obs_output_pause(obs_output_t *output, bool pause)
  297. Pause an output (if supported by the output).
  298. :return: *true* if the output was paused successfully, *false*
  299. otherwise
  300. ---------------------
  301. .. function:: bool obs_output_paused(const obs_output_t *output)
  302. :return: *true* if the output is paused, *false* otherwise
  303. ---------------------
  304. .. function:: obs_data_t *obs_output_get_settings(const obs_output_t *output)
  305. :return: An incremented reference to the output's settings. Release with
  306. :c:func:`obs_data_release()`.
  307. ---------------------
  308. .. function:: signal_handler_t *obs_output_get_signal_handler(const obs_output_t *output)
  309. :return: The signal handler of the output. Should not be manually freed,
  310. as its lifecycle is managed by libobs.
  311. ---------------------
  312. .. function:: proc_handler_t *obs_output_get_proc_handler(const obs_output_t *output)
  313. :return: The procedure handler of the output. Should not be manually freed,
  314. as its lifecycle is managed by libobs.
  315. ---------------------
  316. .. function:: void obs_output_set_media(obs_output_t *output, video_t *video, audio_t *audio)
  317. Sets the current video/audio handlers for the output (typically
  318. :c:func:`obs_get_video()` and :c:func:`obs_get_audio()`). Only used
  319. with raw outputs so they can catch the raw video/audio frames.
  320. ---------------------
  321. .. function:: video_t *obs_output_video(const obs_output_t *output)
  322. audio_t *obs_output_audio(const obs_output_t *output)
  323. Gets the current video/audio handlers for the output.
  324. ---------------------
  325. .. function:: void obs_output_set_mixer(obs_output_t *output, size_t mixer_idx)
  326. size_t obs_output_get_mixer(const obs_output_t *output)
  327. Sets/gets the current audio mixer for non-encoded outputs. For
  328. multi-track outputs, this would be the equivalent of setting the mask
  329. only for the specified mixer index.
  330. ---------------------
  331. .. function:: void obs_output_set_mixers(obs_output_t *output, size_t mixers)
  332. size_t obs_output_get_mixers(const obs_output_t *output)
  333. Sets/gets the current audio mixers (via mask) for non-encoded
  334. multi-track outputs. If used with single-track outputs, the
  335. single-track output will use either the first set mixer track in the
  336. bitmask, or the first track if none is set in the bitmask.
  337. ---------------------
  338. .. function:: void obs_output_set_video_encoder(obs_output_t *output, obs_encoder_t *encoder)
  339. void obs_output_set_audio_encoder(obs_output_t *output, obs_encoder_t *encoder, size_t idx)
  340. Sets the video/audio encoders for an encoded output.
  341. :param encoder: The video/audio encoder
  342. :param idx: The audio encoder index if the output supports
  343. multiple audio streams at once
  344. ---------------------
  345. .. function:: obs_encoder_t *obs_output_get_video_encoder(const obs_output_t *output)
  346. obs_encoder_t *obs_output_get_audio_encoder(const obs_output_t *output, size_t idx)
  347. Gets the video/audio encoders for an encoded output.
  348. :param idx: The audio encoder index if the output supports
  349. multiple audio streams at once
  350. :return: The video/audio encoder. The reference is not
  351. incremented
  352. ---------------------
  353. .. function:: void obs_output_set_service(obs_output_t *output, obs_service_t *service)
  354. obs_service_t *obs_output_get_service(const obs_output_t *output)
  355. Sets/gets the service for outputs that require services (such as RTMP
  356. outputs). *obs_output_get_service* does not return an incremented
  357. reference.
  358. ---------------------
  359. .. function:: void obs_output_set_reconnect_settings(obs_output_t *output, int retry_count, int retry_sec);
  360. Sets the auto-reconnect settings for outputs that support it. The
  361. retry time will double on each retry to prevent overloading services.
  362. :param retry_count: Maximum retry count. Set to 0 to disable
  363. reconnecting
  364. :param retry_sec: Starting retry wait duration, in seconds
  365. ---------------------
  366. .. function:: uint64_t obs_output_get_total_bytes(const obs_output_t *output)
  367. :return: Total bytes sent/processed
  368. ---------------------
  369. .. function:: int obs_output_get_frames_dropped(const obs_output_t *output)
  370. :return: Number of frames that were dropped due to network congestion
  371. ---------------------
  372. .. function:: int obs_output_get_total_frames(const obs_output_t *output)
  373. :return: Total frames sent/processed
  374. ---------------------
  375. .. function:: void obs_output_set_preferred_size(obs_output_t *output, uint32_t width, uint32_t height)
  376. Sets the preferred scaled resolution for this output. Set width and height
  377. to 0 to disable scaling.
  378. If this output uses an encoder, it will call obs_encoder_set_scaled_size on
  379. the encoder before the stream is started. If the encoder is already active,
  380. then this function will trigger a warning and do nothing.
  381. ---------------------
  382. .. function:: uint32_t obs_output_get_width(const obs_output_t *output)
  383. uint32_t obs_output_get_height(const obs_output_t *output)
  384. :return: The width/height of the output
  385. ---------------------
  386. .. function:: void obs_output_output_caption_text1(obs_output_t *output, const char *text)
  387. void obs_output_output_caption_text2(obs_output_t *output, const char *text, double display_duration)
  388. Outputs captions from the specified text input. *text1* is the same as
  389. *text2*, except that the *display_duration* is hardcoded to 2.0 seconds.
  390. *display_duration* represents the minimum quantity of time that a given
  391. caption can be displayed for before moving onto the next caption in the
  392. queue.
  393. ---------------------
  394. .. function:: float obs_output_get_congestion(obs_output_t *output)
  395. :return: The congestion value. This value is used to visualize the
  396. current congestion of a network output. For example, if
  397. there is no congestion, the value will be 0.0f, if it's
  398. fully congested, the value will be 1.0f
  399. ---------------------
  400. .. function:: int obs_output_get_connect_time_ms(obs_output_t *output)
  401. :return: How long the output took to connect to a server, in
  402. milliseconds
  403. ---------------------
  404. .. function:: bool obs_output_reconnecting(const obs_output_t *output)
  405. :return: *true* if the output is currently reconnecting to a server,
  406. *false* otherwise
  407. ---------------------
  408. .. function:: const char *obs_output_get_supported_video_codecs(const obs_output_t *output)
  409. const char *obs_get_output_supported_video_codecs(const char *id)
  410. const char *obs_output_get_supported_audio_codecs(const obs_output_t *output)
  411. const char *obs_get_output_supported_audio_codecs(const char *id)
  412. :return: Supported video/audio codecs of an encoded output, separated
  413. by semicolon
  414. .. versionadded:: 29.1
  415. :c:func:`obs_get_output_supported_video_codecs` and
  416. :c:func:`obs_get_output_supported_audio_codecs`
  417. ---------------------
  418. .. function:: uint32_t obs_output_get_flags(const obs_output_t *output)
  419. uint32_t obs_get_output_flags(const char *id)
  420. :return: The output capability flags
  421. ---------------------
  422. .. function:: const char *obs_output_get_protocols(const obs_output_t *output)
  423. :return: Supported protocols, separated by semicolon. Always NULL if the
  424. output is not **OBS_OUTPUT_SERVICE**.
  425. .. versionadded:: 29.1
  426. ---------------------
  427. .. function:: bool obs_is_output_protocol_registered(const char *protocol)
  428. Check if one of the registered output use the given protocol.
  429. :return: A boolean showing if an output with the given
  430. protocol is registered
  431. .. versionadded:: 29.1
  432. ---------------------
  433. .. function:: bool obs_enum_output_protocols(size_t idx, char **protocol)
  434. Enumerates all registered protocol.
  435. .. versionadded:: 29.1
  436. ---------------------
  437. .. function:: void obs_enum_output_types_with_protocol(const char *protocol, void *data, bool (*enum_cb)(void *data, const char *id))
  438. Enumerates through a callback all available output types for the given protocol.
  439. :param protocol: Protocol of the outputs to enumerate
  440. :param data: Data passed to the callback
  441. :param enum_cb: Callback used when a matching output is found, the id
  442. of the output is passed to the callback
  443. :return: When all outputs are enumerated or if the callback return *false*
  444. .. versionadded:: 29.1
  445. ---------------------
  446. .. function:: void obs_output_add_packet_callback(obs_output_t *output, void (*packet_cb)(obs_output_t *output,
  447. struct encoder_packet *pkt, struct encoder_packet_time *pkt_time, void *param), void *param)
  448. Register a packet callback function for the output. The callback is invoked for each compressed
  449. packet just before sending to the service. This packet callback mechanism is the preferred method
  450. for all packet-level processing that is not required to be implemented in libobs. Any reallocation
  451. of the packet buffer, if necessary, must be done with functions in `libobs\util\bmem.h`, otherwise
  452. a memory leak may occur. Never use `memset()` to clear the packet buffer, as the buffer data is
  453. needed for subsequent callback processing.
  454. :param output: The output to register the packet_cb() function against
  455. :param packet_cb: Function pointer to the callback function
  456. :param param: Data passed to the callback
  457. :return: When the callback is added
  458. packet_cb() arguments:
  459. :param output: The output associated with the invoked callback function
  460. :param pkt: Compressed data packet (audio or video)
  461. :param pkt_time: encoder_packet_time structure associated with the data packet
  462. :param param: Data passed to the callback
  463. .. versionadded:: 31.0
  464. ---------------------
  465. .. function:: void obs_output_remove_packet_callback(obs_output_t *output, void (*packet_cb)(obs_output_t *output,
  466. struct encoder_packet *pkt, struct encoder_packet_time *pkt_time, void *param), void *param)
  467. Remove a packet callback function for the output, that had been previously registered with
  468. `obs_output_add_packet_callback()`.
  469. :param output: The output to remove the packet_cb() function against
  470. :param packet_cb: Function pointer to the callback function
  471. :param param: Data passed to the callback
  472. :return: When the callback is removed
  473. .. versionadded:: 31.0
  474. ---------------------
  475. .. function:: void obs_output_set_reconnect_callback(obs_output_t *output, bool (*reconnect_cb)(void *data, obs_output_t *output, int code), void *param)
  476. Sets a callback that can be used to decide whether or not to attempt reconnecting.
  477. Can also be used to reconfigure the output within the callback before continuing the reconnection attempts,
  478. e.g., to update the stream key after the previous one has expired.
  479. Passing in a `NULL` pointer removes the callback.
  480. :param output: The output to register the reconnect_cb() function against
  481. :param reconnect_cb: Function pointer to the callback function
  482. :param param: Data passed to the callback
  483. reconnect_cb() arguments:
  484. :param data: Data passed to the callback
  485. :param output: The output associated with the invoked callback function
  486. :param code: Error code the output was stopped with
  487. :return: Whether or not to continue attempting to reconnect
  488. .. versionadded:: 31.1
  489. Functions used by outputs
  490. -------------------------
  491. .. function:: void obs_output_set_last_error(obs_output_t *output, const char *message)
  492. const char *obs_output_get_last_error(obs_output_t *output)
  493. Sets/gets the translated error message that is presented to a user in
  494. case of disconnection, inability to connect, etc.
  495. ---------------------
  496. .. function:: void obs_output_set_video_conversion(obs_output_t *output, const struct video_scale_info *conversion)
  497. const struct video_scale_info *obs_output_get_video_conversion(obs_output_t *output)
  498. Optionally sets/gets the video conversion information. Only used by
  499. raw outputs.
  500. .. versionadded:: 29.1
  501. :c:func:`obs_output_get_video_conversion`
  502. Relevant data types used with this function:
  503. .. code:: cpp
  504. enum video_format {
  505. VIDEO_FORMAT_NONE,
  506. /* planar 4:2:0 formats */
  507. VIDEO_FORMAT_I420, /* three-plane */
  508. VIDEO_FORMAT_NV12, /* two-plane, luma and packed chroma */
  509. /* packed 4:2:2 formats */
  510. VIDEO_FORMAT_YVYU,
  511. VIDEO_FORMAT_YUY2, /* YUYV */
  512. VIDEO_FORMAT_UYVY,
  513. /* packed uncompressed formats */
  514. VIDEO_FORMAT_RGBA,
  515. VIDEO_FORMAT_BGRA,
  516. VIDEO_FORMAT_BGRX,
  517. VIDEO_FORMAT_Y800, /* grayscale */
  518. /* planar 4:4:4 */
  519. VIDEO_FORMAT_I444,
  520. /* more packed uncompressed formats */
  521. VIDEO_FORMAT_BGR3,
  522. /* planar 4:2:2 */
  523. VIDEO_FORMAT_I422,
  524. /* planar 4:2:0 with alpha */
  525. VIDEO_FORMAT_I40A,
  526. /* planar 4:2:2 with alpha */
  527. VIDEO_FORMAT_I42A,
  528. /* planar 4:4:4 with alpha */
  529. VIDEO_FORMAT_YUVA,
  530. /* packed 4:4:4 with alpha */
  531. VIDEO_FORMAT_AYUV,
  532. /* planar 4:2:0 format, 10 bpp */
  533. VIDEO_FORMAT_I010, /* three-plane */
  534. VIDEO_FORMAT_P010, /* two-plane, luma and packed chroma */
  535. /* planar 4:2:2 format, 10 bpp */
  536. VIDEO_FORMAT_I210,
  537. /* planar 4:4:4 format, 12 bpp */
  538. VIDEO_FORMAT_I412,
  539. /* planar 4:4:4:4 format, 12 bpp */
  540. VIDEO_FORMAT_YA2L,
  541. /* planar 4:2:2 format, 16 bpp */
  542. VIDEO_FORMAT_P216, /* two-plane, luma and packed chroma */
  543. /* planar 4:4:4 format, 16 bpp */
  544. VIDEO_FORMAT_P416, /* two-plane, luma and packed chroma */
  545. /* packed 4:2:2 format, 10 bpp */
  546. VIDEO_FORMAT_V210,
  547. /* packed uncompressed 10-bit format */
  548. VIDEO_FORMAT_R10L,
  549. };
  550. enum video_colorspace {
  551. VIDEO_CS_DEFAULT,
  552. VIDEO_CS_601,
  553. VIDEO_CS_709,
  554. VIDEO_CS_SRGB,
  555. VIDEO_CS_2100_PQ,
  556. VIDEO_CS_2100_HLG,
  557. };
  558. enum video_range_type {
  559. VIDEO_RANGE_DEFAULT,
  560. VIDEO_RANGE_PARTIAL,
  561. VIDEO_RANGE_FULL
  562. };
  563. struct video_scale_info {
  564. enum video_format format;
  565. uint32_t width;
  566. uint32_t height;
  567. enum video_range_type range;
  568. enum video_colorspace colorspace;
  569. };
  570. ---------------------
  571. .. function:: void obs_output_set_audio_conversion(obs_output_t *output, const struct audio_convert_info *conversion)
  572. Optionally sets the audio conversion information. Only used by raw
  573. outputs.
  574. Relevant data types used with this function:
  575. .. code:: cpp
  576. enum audio_format {
  577. AUDIO_FORMAT_UNKNOWN,
  578. AUDIO_FORMAT_U8BIT,
  579. AUDIO_FORMAT_16BIT,
  580. AUDIO_FORMAT_32BIT,
  581. AUDIO_FORMAT_FLOAT,
  582. AUDIO_FORMAT_U8BIT_PLANAR,
  583. AUDIO_FORMAT_16BIT_PLANAR,
  584. AUDIO_FORMAT_32BIT_PLANAR,
  585. AUDIO_FORMAT_FLOAT_PLANAR,
  586. };
  587. enum speaker_layout {
  588. SPEAKERS_UNKNOWN,
  589. SPEAKERS_MONO,
  590. SPEAKERS_STEREO,
  591. SPEAKERS_2POINT1,
  592. SPEAKERS_4POINT0,
  593. SPEAKERS_4POINT1,
  594. SPEAKERS_5POINT1,
  595. SPEAKERS_5POINT1_SURROUND,
  596. SPEAKERS_7POINT1,
  597. SPEAKERS_7POINT1_SURROUND,
  598. SPEAKERS_SURROUND,
  599. };
  600. struct audio_convert_info {
  601. uint32_t samples_per_sec;
  602. enum audio_format format;
  603. enum speaker_layout speakers;
  604. };
  605. ---------------------
  606. .. function:: bool obs_output_can_begin_data_capture(const obs_output_t *output, int flags)
  607. Determines whether video/audio capture (encoded or raw) is able to
  608. start. Call this before initializing any output state to ensure that
  609. the output can start.
  610. :param output: The output
  611. :param flags: Reserved. Set this to 0.
  612. :return: *true* if data capture can begin
  613. ---------------------
  614. .. function:: bool obs_output_initialize_encoders(obs_output_t *output, int flags)
  615. Initializes any encoders/services associated with the output. This
  616. must be called for encoded outputs before calling
  617. :c:func:`obs_output_begin_data_capture()`.
  618. :param output: The output
  619. :param flags: Reserved. Set this to 0.
  620. :return: *true* if successful, *false* otherwise
  621. ---------------------
  622. .. function:: bool obs_output_begin_data_capture(obs_output_t *output, int flags)
  623. Begins data capture from raw media or encoders. This is typically
  624. when the output actually activates (starts) internally. Video/audio
  625. data will start being sent to the callbacks of the output.
  626. :param output: The output
  627. :param flags: Reserved. Set this to 0.
  628. :return: *true* if successful, *false* otherwise. Typically the
  629. return value does not need to be checked if
  630. :c:func:`obs_output_can_begin_data_capture2()` was
  631. called
  632. ---------------------
  633. .. function:: void obs_output_end_data_capture(obs_output_t *output)
  634. Ends data capture of an output. This is typically when the output
  635. actually intentionally deactivates (stops). Video/audio data will
  636. stop being sent to the callbacks of the output. The output will
  637. trigger the "stop" signal with the OBS_OUTPUT_SUCCESS code to
  638. indicate that the output has stopped successfully. See
  639. :ref:`output_signal_handler_reference` for more information on output
  640. signals.
  641. ---------------------
  642. .. function:: void obs_output_signal_stop(obs_output_t *output, int code)
  643. Ends data capture of an output with an output code, indicating that
  644. the output stopped unexpectedly. This is typically used if for
  645. example the server was disconnected for some reason, or if there was
  646. an error saving to file. The output will trigger the "stop" signal
  647. with the the desired code to indicate that the output has stopped
  648. successfully. See :ref:`output_signal_handler_reference` for more
  649. information on output signals.
  650. :c:func:`obs_output_set_last_error()` may be used in conjunction with
  651. these error codes to optionally relay more detailed error information
  652. to the user
  653. :param code: | Can be one of the following values:
  654. | OBS_OUTPUT_SUCCESS - Successfully stopped
  655. | OBS_OUTPUT_BAD_PATH - The specified path was invalid
  656. | OBS_OUTPUT_CONNECT_FAILED - Failed to connect to a server
  657. | OBS_OUTPUT_INVALID_STREAM - Invalid stream path
  658. | OBS_OUTPUT_ERROR - Generic error
  659. | OBS_OUTPUT_DISCONNECTED - Unexpectedly disconnected
  660. | OBS_OUTPUT_UNSUPPORTED - The settings, video/audio format, or codecs are unsupported by this output
  661. | OBS_OUTPUT_NO_SPACE - Ran out of disk space
  662. ---------------------
  663. .. function:: uint64_t obs_output_get_pause_offset(obs_output_t *output)
  664. Returns the current pause offset of the output. Used with raw
  665. outputs to calculate system timestamps when using calculated
  666. timestamps (see FFmpeg output for an example).
  667. .. ---------------------------------------------------------------------------
  668. .. _libobs/obs-output.h: https://github.com/obsproject/obs-studio/blob/master/libobs/obs-output.h