305 Commits

Author SHA1 Message Date
Dennis Sädtler
66f47924ea libobs: Add obs_canvas_rename_source() 2025-05-06 16:07:47 -04:00
Dennis Sädtler
3d57b1fd63 libobs: Introduce Canvases
This adds a new obs_canvas object that acts as a shareable
(reference-counted) owner of views, mixes, and (optionally) scenes.

This is a step towards faciliatating multi-canvas and multi-output
features in OBS Studio.

It solves a number of complications that exist with the manual approach
of using views, such as audio mixing, source active-state tracking, and
scenes not havinga  reliable way of identifying the actual available
canvas size.
2025-04-02 12:39:46 -04:00
Dennis Sädtler
4459041e7e libobs: Add view type to view object
Allos creating additional views that act like a MAIN_VIEW instead of AUX_VIEW.
2025-04-02 12:39:46 -04:00
Dennis Sädtler
187eef7b38 libobs: Add optional reconnect callback to outputs 2025-03-17 13:30:58 -04:00
Dennis Sädtler
2de0037e40 libobs: Support format/space/range conversion in encoder GPU scaling 2025-01-29 15:01:19 -05:00
Ryan Foster
a1fbf1015f clang-format: Increase column limit from 80 to 120 2024-10-04 18:19:27 -04:00
Alex Luccisano
07d504e5c7 shared/bpm: Add BPM (Broadcast Performance Metrics)
Introduce support for delivering BPM (Broadcast
Performance Metrics) over SEI (for AVC/H.264 and
HEVC/H.265) and OBU (for AV1) unregistered messages.
Metrics being sent are the session frame counters,
per-rendition frame counters, and RFC3339-based
timestamping information to support end-to-end
latency measurement.

SEI/OBU messages are generated and sent with each IDR
frame, and the frame counters are diff-based, meaning
the counts reflect the diff between IDRs, not the running
totals.

BPM documentation is available at [1].

BPM relies on the recently introduced encoder packet timing
support and the packet callback mechanism.

BPM injection is enabled for an output by registering
the `bpm_inject()` callback via `obs_output_add_packet_callback()`
function. The callback must be unregistered using
`obs_output_remove_packet_callback()` and `bpm_destroy()`
must be used by the caller to release the BPM structures.

It is important to measure the number of frames successfully
encoded by the obs_encoder_t instances, particularly for
renditions where the encoded frame rate differs from the
canvas frame rate. The encoded_frames counter and
`obs_encoder_get_encoded_frames()` API is introduced
to measure and report this in the encoded rendition
metrics message.

[1] https://d50yg09cghihd.cloudfront.net/other/20240718-MultitrackVideoIntegrationGuide.pdf
2024-09-05 16:38:58 -04:00
Alex Luccisano
0a36ed1164 libobs: Add a packet callback mechanism
Packet callbacks are invoked in `send_interleaved()` and
are useful for any plugin to extend functionality at the
packet processing level without needing to modify code in
libobs. Closed caption support is one candidate that is
suitable for migration to a packet callback.

The packet callback also supports the new encoder packet
timing feature. This means a registered callback will have
access to both the compressed encoder packet and the associated
encoder packet timing information.
2024-09-05 16:38:58 -04:00
Alex Luccisano
6a53b8928f libobs: Add encoder packet timing support
Introduce support for the `encoder_packet_time` struct
to capture timing information for each frame, starting
from the composition of each frame, through the encoder,
to the queueing of the frame data to each output_t.

Timestamps for each of the following events are based on
`os_gettime_ns()`:

CTS: Composition time stamp (in the encoder render threads)
FER: Frame encode request
FERC: Frame encoder request completely
PIR: Packet interleave request (`send_interleaved()`)

Frame times are forwarded through encoder callbacks in the
context that runs on the relevant encoder thread, ensuring
no race conditions with accessing per encoder array happen.
All per-output processing happens on data that is owned by
the output.

Co-authored-by: Ruwen Hahn <haruwenz@twitch.tv>
2024-09-05 16:38:58 -04:00
derrod
71d49b0ef2 docs,libobs: Remove/internalize deprecated addref functions
These have been deprecated for external users since 27.2 (early 2022)
and only two are still in use internally.
2024-08-28 19:10:27 -04:00
derrod
c422a336fc libobs: Use weak reference for paired encoders 2024-08-18 22:35:34 -07:00
derrod
2c57f4564c libobs: Switch to full reference counting for encoders
Removes the "destroy_on_stop" hack that predates refcounting.
Ensures outputs hold strong references to all their encoders.
2024-08-18 22:35:34 -07:00
Rodney
198581a475 libobs: Add source profiler 2024-08-10 23:51:39 -07:00
tt2468
e215502b62 libobs, UI: Normalize encoder group API
Modifies the encoder group API added previously to better follow the
existing libobs API naming paradigms. This also produces much more
readable code, and allows a few small benefits like only needing to
hold a reference to the encoder group, instead of every encoder.
2024-06-17 08:20:01 -07:00
tt2468
751dbdad10 libobs: Update video encoder group struct member names
Updates the struct member names of the video encoder group to be more
like what is commonly seen in OBS elsewhere.
2024-06-17 08:20:01 -07:00
John Bowers
849c1180ac libobs: Insert captions on all video tracks
We will now keep a per track list of caption data. When caption
insertion is triggered we will add that to the list for each actively
encoding video track. When doing interleaved send, we pull the data
from the caption data for the corresponding video. This ensures that
captions get copied to all video tracks.
2024-04-26 18:17:34 -07:00
Norihiro Kamae
b4a061dcd8 libobs: Remove unused variable in obs_source 2024-04-20 16:07:37 -07:00
Ruwen Hahn
5e1909d54f libobs: Track keyframe alignment for keyframe aligned encoder groups 2024-04-12 14:52:32 -07:00
Ruwen Hahn
c288d42cfd libobs: Add obs_encoder_group_keyframe_aligned_encoders
Ensures grouped encoders start on the same input frame
2024-04-12 14:52:32 -07:00
Kurt Kartaltepe
02c90207fc libobs,libobs-opengl: enable GPU encoding for OpenGL
Enable all of the previously Windows only paths for OpenGL backends that
support encode_texture2

Co-authored-by: Torge Matthies <openglfreak@googlemail.com>
2024-01-26 20:01:58 -05:00
derrod
2963959e71 libobs: Replace circlebuf with deque 2024-01-16 16:45:09 +01:00
Rodney
d96ad4ac98 libobs: Add encoder ROI functions 2024-01-11 13:36:35 +01:00
Lain
2fb7063e1a libobs: Defer media controls to video thread
To prevent sources from having to take too much extra consideration into
threading, defer the media control functions that directly affect
functionality to the video thread. Getters will still have to take
threading into account, but this should make things much more trivial
for media controls thread-wise.

(Lain note: Context: I noticed that things such as the slide show
require mutexes due to their media controls, and I felt that it was
largely unnecessary and that libobs should mitigate the threading issue
itself and keep it all in the video thread like it should be. Again, the
getters are still going to require *some* consideration into threading
but in terms of threading, for the type of stuff we're doing, querying
state is far more trivial to take into consideration.)
2024-01-07 15:59:09 -06:00
Lain
1151bc9dea libobs: Add a couple missing comments
(Lain note: This is mostly so more (yes more) can be added to this
god-forsaken structure without it getting too messy. In terms of actual
code, I need to be better about writing actual code comments. ...Meaning
that I actually need to start writing code comments.)
2024-01-07 15:59:09 -06:00
derrod
ca865f80cc libobs: Pair video encoder with all audio encoders 2023-12-05 15:36:37 -06:00
derrod
b680700bba libobs: Remove unused wait_for_video flag 2023-12-05 15:36:37 -06:00
derrod
5177a593af libobs: Remove module UI functions 2023-12-02 18:09:20 -06:00
Norihiro Kamae
fa9b7b042f libobs: Remove starting_frame_count from obs_output_t
The member variable `starting_frame_count` was set but never read.
2023-08-15 16:00:21 -07:00
jpark37
7669da1ea8 libobs: Add VIDEO_FORMAT_R10L
Support 10-bit packed format that DeckLink uses.
2023-07-29 16:41:31 -07:00
derrod
d90bfc5e0b libobs: Add obs_add_safe_module() 2023-07-21 23:22:07 +02:00
Ruwen Hahn
6cdfb0a8b9 libobs: Allow configuring frame rate divisor for encoders
This allows encoders/outputs to output at a frame rate that is lower
than the configured base frame rate
2023-07-03 09:35:06 -07:00
Norihiro Kamae
8169188f89 libobs: Define DARRAY macro types
To avoid passing `struct darray *` type, which cannot hold the type
information, this commit defines array types and uses that types on the
function parameters.
2023-07-01 00:39:13 -07:00
Ruwen Hahn
03fa9acc7f libobs: Add obs_encoder_enable_gpu_scaling
Allows rescaling resolution for GPU encoders and allows moving
rescaling for CPU encoders from CPU to GPU

Rescaling is implemented via core video mixes; encoders create
their own core mix with matching width/height/format/colorspace/
range when gpu scaling is enabled and no matching core video
mix exists
2023-06-26 13:32:25 +02:00
John Bradley
6ec0b2db11 libobs: Add support to obs-outputs for multi video encoders
This adds support in outputs to handle multiple video encoders
and their interleaving with the encoded audio.
2023-06-14 02:24:54 -07:00
Exeldro
a77789b266 libobs: Don't keep the sources mutex in tick_sources
Allow other threads to use sources while the graphics thread does
video_tick, update, activate and deactivate on sources
2023-06-10 14:20:13 -07:00
PatTheMav
2966c4030e libobs: Use static library for version string information
Switching to a static library that contains version information as
const char strings has multiple benefits:

* The version information provided externally via compiler definitions
  will fail compilation early if malformed
* An updated version string (which will happen with every commit) will
  not invalidate existing compilation units, because only the static
  library is affected by the change
* An update of the version change just requires a recompilation of the
  static library and a linker update
* An update of the version will _not_ infect the rest of the codebase
  (as it does currently, because everything includes obsconfig.h one
  way or another)
* Other modules which used the macro definition directly have been
  updated as much as possible to use the proper getter method from
  `libobs` instead (some Windows-specific modules use preprocessor
  string composition, the value has been added as a compiler definition
  directly in those cases)
* Because the impact of a version change due to a commit hash change
  is limited to the static library, ccache hit rates should be
  improved considerably
2023-05-27 16:48:24 -07:00
Lain
106c7aa61f Update copyrights/names 2023-05-20 01:31:18 -07:00
jpark37
504cc76e93 libobs: Ensure v210 preserves precision 2023-04-05 21:54:25 +02:00
Ryan Foster
bfb8fba066 Revert "libobs: Enable fast clear on Windows always"
This reverts commit c2afa58125c0005a2eb5354bf99402dab66375f7.
2023-03-27 15:24:52 -04:00
jpark37
e32c2c1427 libobs: Add callback for main texture rendered
Useful for redirecting main texture to DeckLink output for example.
2023-03-24 15:18:45 -07:00
jpark37
c2afa58125 libobs: Enable fast clear on Windows always
NVIDIA driver 527.37 fixes flickering when multiple GPUs are installed.
2023-03-20 01:41:47 -07:00
tytan652
201bcda051 libobs,docs: Add protocol in Outputs API 2023-03-19 15:29:03 +01:00
derrod
e6a7cff034 libobs: Use uthash for hotkeys and hotkey pairs 2023-03-18 10:47:50 +01:00
derrod
eff3cf134c libobs: Use uthash for hotkey name map 2023-03-18 10:47:49 +01:00
derrod
c68eeaef1d libobs: Use uthash for source objects
All sources are part of a hash table that allows a lookup by UUID.
Public sources additionally are in a hash table allowing lookup by name.
2023-03-18 10:47:49 +01:00
derrod
30519768ad libobs: Add UUIDs to obs_source objects 2023-03-12 01:11:38 +01:00
jpark37
463bf0dff5 libobs,UI: Add P216/P416 pixel formats
Will be useful for ProRes.
2023-02-21 18:48:44 +01:00
John Bradley
61284cf9ba libobs: Refactor obs-output encoded use of mixes
There was quite a bit of conflated usage of mixes (which refers
to raw audio) and encoder counts. This fully separates the two
and makes a distinct separation when iterating over mixes vs
encoders.
2023-01-18 11:54:20 -08:00
John Bradley
d70171daa6 libobs: Make internal version of remove encoder 2023-01-18 11:54:20 -08:00
Ryan Foster
19abcbcd3c Revert "libobs-d3d11: Make sure libobs knows the new adapter index"
This reverts commit e62759a3fa3d20366f80ddaa70fa58ca4f61a358.
2022-12-30 21:14:15 -08:00