Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Add missing MPVRenderFrameInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
fsobolev committed Oct 2, 2023
1 parent 5705ed3 commit c31501f
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 3 deletions.
25 changes: 25 additions & 0 deletions Nickvision.MPVSharp/Internal/MPVRenderFrameInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Nickvision.MPVSharp.Internal;

/// <summary>
/// Information about the next video frame that will be rendered. Can be
/// retrieved with <see cref="MPVRenderParamType.NextFrameInfo"/>.
/// </summary>
public struct MPVRenderFrameInfo
{
/// <summary>
/// A bitset of <see cref="MPVRenderFrameInfoFlag"/> values (i.e. multiple flags are
/// combined with bitwise or).
/// </summary>
public ulong Flags;
/// <summary>
/// Absolute time at which the frame is supposed to be displayed. This is in
/// the same unit and base as the time returned by <see cref="MPVClient.GetTimeUs"/>. 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). <see cref="MPVRenderContext.Render"/> will
/// normally block until the time is elapsed, unless you pass it
/// <see cref="MPVRenderParamType.BlockForTargetTime"/> = 0.
/// </summary>
ulong TargetTime;
}
50 changes: 50 additions & 0 deletions Nickvision.MPVSharp/Internal/MPVRenderFrameInfoFlag.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
namespace Nickvision.MPVSharp.Internal;

/// <summary>
/// Flags used in <see cref="MPVRenderFrameInfo.Flags"/>. Each value represents a bit in it.
/// </summary>
public enum MPVRenderFrameInfoFlag
{
/// <summary>
/// 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 <see cref="MPVRenderContext.Render"/> had the
/// <see cref="MPVRenderUpdateFlags.UpdateFrame"/> flag set, this flag will usually be set as well,
/// unless the frame is rendered, or discarded by other asynchronous events.
/// </summary>
Present = 1 << 0,
/// <summary>
/// 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.
/// </summary>
/// <remarks>
/// Implies <see cref="Present"/>.
/// </remarks>
Redraw = 1 << 1,
/// <summary>
/// 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.
/// </summary>
/// <remarks>
/// Implies <see cref="Present"/>.
/// </remarks>
Repeat = 1 << 2,
/// <summary>
/// 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
/// <see cref="MPVRenderContext.ReportSwap"/> at vsync time).
/// </summary>
/// <remarks>
/// Implies <see cref="Present"/>.
/// </remarks>
BlockVsync = 1 << 3
}
7 changes: 4 additions & 3 deletions Nickvision.MPVSharp/RenderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Func<string, nint> GetProcAddressFn
}

/// <summary>
/// Construct RenderContext
/// Constructs RenderContext
/// </summary>
public RenderContext(nint clientHandle)
{
Expand Down Expand Up @@ -69,8 +69,9 @@ protected virtual void Dispose(bool disposing)
}

/// <summary>
/// Setup OpenGL rendering
/// Setups OpenGL rendering
/// </summary>
/// <param name="callback">Callback to be called when a new frame needs to be rendered</param>
/// <exception cref="ClientException">Thrown if unable to setup GL</exception>
public void SetupGL(Action? callback)
{
Expand Down Expand Up @@ -134,7 +135,7 @@ public void SetupGL(Action? callback)
/// </summary>
/// <param name="width">Rendering area width</param>
/// <param name="height">Rendering area width</param>
/// <param name="fb">Framebuffer</param>
/// <param name="fb">Framebuffer object name</param>
public void RenderGL(int width, int height, int? fb = null)
{
if (fb == null)
Expand Down

0 comments on commit c31501f

Please sign in to comment.