41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using System;
|
|
using Vav1Player.Decoder;
|
|
|
|
namespace Vav1Player.Video
|
|
{
|
|
/// <summary>
|
|
/// Represents a video frame with timing information
|
|
/// </summary>
|
|
public class VideoFrame : IDisposable
|
|
{
|
|
public DecodedFrame Frame { get; }
|
|
public long PresentationTimeMs { get; }
|
|
public long DecodedTimeMs { get; }
|
|
public bool IsKeyFrame { get; }
|
|
public int FrameNumber { get; }
|
|
private bool _disposed = false;
|
|
|
|
public VideoFrame(DecodedFrame frame, long presentationTimeMs, int frameNumber, bool isKeyFrame = false)
|
|
{
|
|
Frame = frame;
|
|
PresentationTimeMs = presentationTimeMs;
|
|
DecodedTimeMs = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
FrameNumber = frameNumber;
|
|
IsKeyFrame = isKeyFrame;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
if (!_disposed)
|
|
{
|
|
Frame.Release();
|
|
_disposed = true;
|
|
}
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"Frame #{FrameNumber}: {Frame.Width}x{Frame.Height}, PTS: {PresentationTimeMs}ms, Key: {IsKeyFrame}";
|
|
}
|
|
}
|
|
} |