Tanoda
GIFRecorder.cs
Go to the documentation of this file.
1/*
2* NatCorder
3* Copyright (c) 2020 Yusuf Olokoba.
4*/
5
6using System;
7using System.Threading.Tasks;
9
10namespace NatSuite.Recorders
11{
15 public sealed class GIFRecorder : IMediaRecorder
16 {
17 #region --Client API--
18
22 public (int width, int height) frameSize => recorder.frameSize;
23
30 public GIFRecorder(int width, int height, float frameDuration)
31 {
32 recorder = new NativeRecorder((callback, context) =>
33 Bridge.CreateGIFRecorder(width, height, frameDuration, Internal.Utility.GetPath(@".gif"), callback,
34 context));
35 }
36
43 public void CommitFrame<T>(T[] pixelBuffer, long timestamp = default) where T : struct
44 {
45 recorder.CommitFrame(pixelBuffer, timestamp);
46 }
47
54 public void CommitFrame(IntPtr nativeBuffer, long timestamp = default)
55 {
56 recorder.CommitFrame(nativeBuffer, timestamp);
57 }
58
62 public void CommitSamples(float[] sampleBuffer = default, long timestamp = default)
63 {
64 }
65
69 public Task<string> FinishWriting()
70 {
71 return recorder.FinishWriting();
72 }
73
74 #endregion
75
76 private readonly IMediaRecorder recorder;
77 }
78}
Animated GIF image recorder.
Definition: GIFRecorder.cs:16
void CommitFrame(IntPtr nativeBuffer, long timestamp=default)
Commit a video pixel buffer for encoding. The pixel buffer MUST have an RGBA8888 pixel layout.
Definition: GIFRecorder.cs:54
Task< string > FinishWriting()
Finish writing and return the path to the recorded media file.
Definition: GIFRecorder.cs:69
void CommitSamples(float[] sampleBuffer=default, long timestamp=default)
This recorder does not support committing sample buffers.
Definition: GIFRecorder.cs:62
void CommitFrame< T >(T[] pixelBuffer, long timestamp=default)
Commit a video pixel buffer for encoding. The pixel buffer MUST have an RGBA8888 pixel layout.
Definition: GIFRecorder.cs:43
A recorder capable of recording video frames, and optionally audio frames, to a media output....
Task< string > FinishWriting()
Finish writing and return the path to the recorded media file.
void CommitFrame(IntPtr nativeBuffer, long timestamp)
Commit a video pixel buffer for encoding. The pixel buffer MUST have an RGBA8888 pixel layout.