Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wayland: add support for content-type protocol #10751

Merged
merged 2 commits into from
Nov 15, 2022

Conversation

Dudemanguy
Copy link
Member

@Dudemanguy Dudemanguy commented Oct 16, 2022

The content-type protocol allows mpv to send compositor a hint about the type of content being displayed on its surface so it could potentially make some sort of optimization. Fundamentally, this is pretty simple but since this requires a very new wayland-protocols version (1.27), we have to mess with the build to add a new define and add a bunch of if's in here. The protocol itself exposes 4 different types of content: none, photo, video, and game. For mpv, we of course send video by default but it is certainly common to view images/photos as well. Additionally, maybe the compositor is bugged in some way and one would like to turn this off. In light of that, a new option has also been added (wayland-content-type) that lets users control what content hint to send to the compositor. For completion's sake, game is also allowed here, but in practice there shouldn't ever be a reason to use that.

Supercedes: #10262

@Dudemanguy Dudemanguy force-pushed the wayland-content-type branch 3 times, most recently from a8e34a3 to 18a4f6f Compare October 16, 2022 05:58
@Dudemanguy Dudemanguy force-pushed the wayland-content-type branch 4 times, most recently from edf88d9 to d3cdae9 Compare November 7, 2022 23:37
@Dudemanguy
Copy link
Member Author

I've now added a commit that adds a new VOCTRL, VOCTRL_IS_IMAGE, which signals the VO if mpv's core has loaded what it considers a video file or not. The succeeding wayland commit makes use of this to implement an auto mode so it hints photo if mpv thinks it has an image and video otherwise.

video/out/wayland_common.c Outdated Show resolved Hide resolved
@Dudemanguy Dudemanguy force-pushed the wayland-content-type branch from d3cdae9 to 1d3c504 Compare November 9, 2022 00:07
@Dudemanguy
Copy link
Member Author

I changed it to VOCTRL_CONTENT_TYPE now which sends an enum that basically follows the wayland protocol. For the case of having a forced window but no actual video, it now will just send NONE.

@Dudemanguy Dudemanguy force-pushed the wayland-content-type branch 2 times, most recently from 33ed98f to bf547ef Compare November 15, 2022 16:41
mpv's core already keeps track of whether or not it thinks a track is an
image. Some VOs (i.e. wayland) would benefit from knowing if what is
currently being displayed is an image or not so add a new VOCTRL that
signals this anytime we load a new file with a VO. Additionally, let's
add a helper enum for signaling the kind of content that is being
displayed. There is now MP_CONTENT_NONE (strictly for force window being
used on a track with no image/video), MP_CONTENT_IMAGE, and
MP_CONTENT_VIDEO. See the next commit for the actual usage of this (with
wayland).
The content-type protocol allows mpv to send compositor a hint about the
type of content being displayed on its surface so it could potentially
make some sort of optimization. Fundamentally, this is pretty simple but
since this requires a very new wayland-protocols version (1.27), we have
to mess with the build to add a new define and add a bunch of if's in
here. The protocol itself exposes 4 different types of content: none,
photo, video, and game.

To do that, let's add a new option (wayland-content-type) that lets
users control what hint to send to the compossitor. Since the previous
commit adds a VOCTRL that notifies us about the content being displayed,
we can also add an auto value to this option. As you'd expect, the
compositor hint would be set to photo if mpv's core detects an image,
video for other things, and it is set to none for the special case of
forcing a window when there is not a video track. For completion's sake,
game is also allowed as a value for this option, but in practice there
shouldn't be a reason to use that.
@Dudemanguy
Copy link
Member Author

I was finally able to test this in git master of sway and the wayland debug logs look good.

@Dudemanguy Dudemanguy merged commit 6623efb into mpv-player:master Nov 15, 2022
@Dudemanguy Dudemanguy deleted the wayland-content-type branch November 15, 2022 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants