From c31501f0f20e4298a9bb9a999073f0832de8d6ac Mon Sep 17 00:00:00 2001 From: Fyodor Sobolev <117388856+fsobolev@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:56:26 +0300 Subject: [PATCH] Add missing MPVRenderFrameInfo --- .../Internal/MPVRenderFrameInfo.cs | 25 ++++++++++ .../Internal/MPVRenderFrameInfoFlag.cs | 50 +++++++++++++++++++ Nickvision.MPVSharp/RenderContext.cs | 7 +-- 3 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 Nickvision.MPVSharp/Internal/MPVRenderFrameInfo.cs create mode 100644 Nickvision.MPVSharp/Internal/MPVRenderFrameInfoFlag.cs diff --git a/Nickvision.MPVSharp/Internal/MPVRenderFrameInfo.cs b/Nickvision.MPVSharp/Internal/MPVRenderFrameInfo.cs new file mode 100644 index 0000000..a228f9d --- /dev/null +++ b/Nickvision.MPVSharp/Internal/MPVRenderFrameInfo.cs @@ -0,0 +1,25 @@ +namespace Nickvision.MPVSharp.Internal; + +/// +/// Information about the next video frame that will be rendered. Can be +/// retrieved with . +/// +public struct MPVRenderFrameInfo +{ + /// + /// A bitset of values (i.e. multiple flags are + /// combined with bitwise or). + /// + public ulong Flags; + /// + /// Absolute time at which the frame is supposed to be displayed. This is in + /// the same unit and base as the time returned by . For + /// frames that are redrawn, or if vsync locked video timing is used (see + /// "video-sync" option), then this can be 0. The "video-timing-offset" + /// option determines how much "headroom" the render thread gets (but a high + /// enough frame rate can reduce it anyway). will + /// normally block until the time is elapsed, unless you pass it + /// = 0. + /// + ulong TargetTime; +} \ No newline at end of file diff --git a/Nickvision.MPVSharp/Internal/MPVRenderFrameInfoFlag.cs b/Nickvision.MPVSharp/Internal/MPVRenderFrameInfoFlag.cs new file mode 100644 index 0000000..052f2dc --- /dev/null +++ b/Nickvision.MPVSharp/Internal/MPVRenderFrameInfoFlag.cs @@ -0,0 +1,50 @@ +namespace Nickvision.MPVSharp.Internal; + +/// +/// Flags used in . Each value represents a bit in it. +/// +public enum MPVRenderFrameInfoFlag +{ + /// + /// Set if there is actually a next frame. If unset, there is no next frame + /// yet, and other flags and fields that require a frame to be queued will + /// be unset. + /// This is set for _any_ kind of frame, even for redraw requests. + /// Note that when this is unset, it simply means no new frame was + /// decoded/queued yet, not necessarily that the end of the video was + /// reached. A new frame can be queued after some time. + /// If the return value of had the + /// flag set, this flag will usually be set as well, + /// unless the frame is rendered, or discarded by other asynchronous events. + /// + Present = 1 << 0, + /// + /// If set, the frame is not an actual new video frame, but a redraw request. + /// For example if the video is paused, and an option that affects video + /// rendering was changed (or any other reason), an update request can be + /// issued and this flag will be set. + /// Typically, redraw frames will not be subject to video timing. + /// + /// + /// Implies . + /// + Redraw = 1 << 1, + /// + /// If set, this is supposed to reproduce the previous frame perfectly. This + /// is usually used for certain "video-sync" options ("display-..." modes). + /// Typically the renderer will blit the video from a FBO. Unset otherwise. + /// + /// + /// Implies . + /// + Repeat = 1 << 2, + /// + /// If set, the player timing code expects that the user thread blocks on + /// vsync (by either delaying the render call, or by making a call to + /// at vsync time). + /// + /// + /// Implies . + /// + BlockVsync = 1 << 3 +} \ No newline at end of file diff --git a/Nickvision.MPVSharp/RenderContext.cs b/Nickvision.MPVSharp/RenderContext.cs index b101386..9f0edf9 100644 --- a/Nickvision.MPVSharp/RenderContext.cs +++ b/Nickvision.MPVSharp/RenderContext.cs @@ -29,7 +29,7 @@ public Func GetProcAddressFn } /// - /// Construct RenderContext + /// Constructs RenderContext /// public RenderContext(nint clientHandle) { @@ -69,8 +69,9 @@ protected virtual void Dispose(bool disposing) } /// - /// Setup OpenGL rendering + /// Setups OpenGL rendering /// + /// Callback to be called when a new frame needs to be rendered /// Thrown if unable to setup GL public void SetupGL(Action? callback) { @@ -134,7 +135,7 @@ public void SetupGL(Action? callback) /// /// Rendering area width /// Rendering area width - /// Framebuffer + /// Framebuffer object name public void RenderGL(int width, int height, int? fb = null) { if (fb == null)