Skip to content

Canvases - Part One (libobs) - #11823

Merged
RytoEX merged 6 commits into
obsproject:masterfrom
amazon-contributing:rodney/multi-canvas-drifting
Apr 2, 2025
Merged

RytoEX merged 6 commits into
obsproject:masterfrom
amazon-contributing:rodney/multi-canvas-drifting

Conversation

@dsaedtler

@dsaedtler dsaedtler commented Feb 4, 2025 •

Copy link
Copy Markdown

Description

Adds canvases to libobs.

In this first iteration a canvas is a reference-counted object that contains scene sources (Scenes and Groups) and has an associated view and video mix.

Unlike views, canvases can be shared and ensure their video mixes persist across video resets. They can also be saved and loaded like sources, and solve various issues of using views (audio mixing, activation, scene rendering, etc.).

Motivation and Context

The end goal of this work is to superseede #10635 with something that is more generic and safer, and should make features that rely on rendering individual sources separately (e.g. ISO recording or virtual cam) easier to implement.

In the long term we want to deprecate views and refactor more things to be canvas-aware, to provide greater flexibility in the libobs world for multiple outputs. For instance, I would like to rework how GPU scaling for encoders works by explicitly making the created "submixes" part of and managed by a canvas. Also maybe transitions should become public sources associated with a canvas, so that they can actually be accessed and modified via the libobs API.

How Has This Been Tested?

OBS boots up and behaves normally.

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Documentation (a change to documentation pages) -->

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@WizardCM WizardCM added kind/cleanup Non-breaking change which makes code smaller or more readable area/documentation Improvements or additions to documentation kind/feature Functionality or other elements that the project doesn't currently have. labels Feb 4, 2025
@dsaedtler
dsaedtler force-pushed the rodney/multi-canvas-drifting branch from 0d9e66b to 38c060f Compare February 5, 2025 15:00

@PatTheMav PatTheMav left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finished first round of reviews. No conceptual issues from my point of view, mainly code style/architectural.

I'd prefer all conditional blocks use curly braces to clearly mark the block, but IIRC the Linux kernel style guide allows it.

Comment thread libobs/obs-canvas.c Resolved
Comment thread libobs/obs-canvas.c Resolved
Comment thread docs/sphinx/reference-canvases.rst Resolved
Comment thread docs/sphinx/reference-canvases.rst Resolved
Comment thread docs/sphinx/reference-canvases.rst Resolved
Comment thread libobs/obs-canvas.c Resolved
Comment thread libobs/obs-canvas.c Resolved
Comment thread libobs/obs-internal.h Resolved
Comment thread libobs/obs-source.c Resolved
Comment thread libobs/obs.c Resolved
@dsaedtler
dsaedtler force-pushed the rodney/multi-canvas-drifting branch from 38c060f to 63f97a8 Compare February 6, 2025 21:59

@PatTheMav PatTheMav left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a bit of testing with this code and ran into no functional changes (as intended). Scene items were always scaled and positioned correctly when canvas/output sizes changed.

@dsaedtler
dsaedtler force-pushed the rodney/multi-canvas-drifting branch from 63f97a8 to fa1ec1f Compare February 25, 2025 15:53
@dsaedtler

Copy link
Copy Markdown
Author

I made a few updates based on feedback, I'll update the docs again once there are no more libobs changes planned before merging.

@PatTheMav

Copy link
Copy Markdown
Member

I made a few updates based on feedback, I'll update the docs again once there are no more libobs changes planned before merging.

Can you close the feedback comments that were addressed by the changes? The rebase obviously introduced lots of changes unrelated to the PR in the direct comparison between commits.

@dsaedtler
dsaedtler force-pushed the rodney/multi-canvas-drifting branch from fa1ec1f to 946de86 Compare February 26, 2025 14:02
@dsaedtler

Copy link
Copy Markdown
Author

I made a few updates based on feedback, I'll update the docs again once there are no more libobs changes planned before merging.

Can you close the feedback comments that were addressed by the changes? The rebase obviously introduced lots of changes unrelated to the PR in the direct comparison between commits.

Sure, I closed a few that I would consider resolved given that they have not received further responses for now.

Today's update was just a little bugfix for an oversight when it comes to renaming private canvases. Yesterday's one just added the INVALID_VIEW enumeration you requested as well as a rename of the OBS_SOURCE_REQUIRES_CANVAS flag.

@dsaedtler
dsaedtler force-pushed the rodney/multi-canvas-drifting branch from 946de86 to 0d4a0e9 Compare February 27, 2025 16:26
@dsaedtler

Copy link
Copy Markdown
Author

Updated the docs and squashed commits where appropiate.

@RytoEX
RytoEX requested review from PatTheMav and RytoEX March 4, 2025 19:49

@RytoEX RytoEX left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just nits.

Comment thread docs/sphinx/reference-canvases.rst Resolved
Comment thread docs/sphinx/reference-canvases.rst Resolved
Comment thread docs/sphinx/reference-canvases.rst Resolved
Comment thread libobs/obs-internal.h Resolved
Comment thread libobs/obs-internal.h Resolved
Comment thread libobs/obs.h Resolved
@dsaedtler
dsaedtler force-pushed the rodney/multi-canvas-drifting branch from 0d4a0e9 to 9c55c97 Compare March 5, 2025 09:12

@PatTheMav PatTheMav left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there were just documentation changes in the last push?

@dsaedtler

dsaedtler commented Mar 5, 2025 via email

Copy link
Copy Markdown
Author

@RytoEX
RytoEX requested a review from PatTheMav March 11, 2025 21:45

@PatTheMav PatTheMav left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine. I'm not happy with some architectural details but those are either necessary due to how libobs works or necessary until later PRs are fully merged.

@RytoEX RytoEX left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor nits.

Comment thread libobs/obs-canvas.c Resolved
Comment thread libobs/obs-canvas.c Resolved
Dennis Sädtler added 4 commits April 2, 2025 18:06
Allos creating additional views that act like a MAIN_VIEW instead of AUX_VIEW.
Signals when a video reset has completed. This is mainly useful when
canvases or views are used, whose mixes will have been freed or
recreated during the reset.
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.
Dennis Sädtler added 2 commits April 2, 2025 18:06
Since scenes now can have non-unique names by being part of different
canvases, use UUIDs instead.
@dsaedtler
dsaedtler force-pushed the rodney/multi-canvas-drifting branch from 9c55c97 to 3551f1d Compare April 2, 2025 16:07
@RytoEX
RytoEX merged commit 3fc1191 into obsproject:master Apr 2, 2025
@RytoEX

RytoEX commented Apr 2, 2025

Copy link
Copy Markdown
Member

I missed it, but the docs commit could have been squashed into the commit that added the functions so that each commit had complete documentation. The docs: prefix is typically used for adding/modifying documentation as a separate effort.

@dsaedtler
dsaedtler deleted the rodney/multi-canvas-drifting branch April 2, 2025 16:44
@exeldro exeldro mentioned this pull request Apr 10, 2025
6 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation Improvements or additions to documentation kind/cleanup Non-breaking change which makes code smaller or more readable kind/feature Functionality or other elements that the project doesn't currently have.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants