/*
* NatCorder
* Copyright (c) 2020 Yusuf Olokoba.
*/
namespace NatSuite.Recorders {
using System;
using System.Threading.Tasks;
using Internal;
///
/// Animated GIF image recorder.
///
public sealed class GIFRecorder : IMediaRecorder {
#region --Client API--
///
/// Image size.
///
public (int width, int height) frameSize => recorder.frameSize;
///
/// Create a GIF recorder.
///
/// Image width.
/// Image height.
/// Frame duration in seconds.
public GIFRecorder (int width, int height, float frameDuration) => this.recorder = new NativeRecorder((callback, context) => Bridge.CreateGIFRecorder(width, height, frameDuration, Utility.GetPath(@".gif"), callback, context));
///
/// Commit a video pixel buffer for encoding.
/// The pixel buffer MUST have an RGBA8888 pixel layout.
///
/// Pixel buffer containing video frame to commit.
/// Not used.
public void CommitFrame (T[] pixelBuffer, long timestamp = default) where T : struct => recorder.CommitFrame(pixelBuffer, timestamp);
///
/// Commit a video pixel buffer for encoding.
/// The pixel buffer MUST have an RGBA8888 pixel layout.
///
/// Pixel buffer in native memory to commit.
/// Not used.
public void CommitFrame (IntPtr nativeBuffer, long timestamp = default) => recorder.CommitFrame(nativeBuffer, timestamp);
///
/// This recorder does not support committing sample buffers.
///
public void CommitSamples (float[] sampleBuffer = default, long timestamp = default) { }
///
/// Finish writing and return the path to the recorded media file.
///
public Task FinishWriting () => recorder.FinishWriting();
#endregion
private readonly IMediaRecorder recorder;
}
}