mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-12-14 10:05:44 +00:00
26 lines
767 B
C#
26 lines
767 B
C#
using FFMpegCore.Pipes;
|
|
|
|
namespace FFMpegCore.Extend;
|
|
|
|
public class PcmAudioSampleWrapper : IAudioSample
|
|
{
|
|
//This could actually be short or int, but copies would be inefficient.
|
|
//Handling bytes lets the user decide on the conversion, and abstract the library
|
|
//from handling shorts, unsigned shorts, integers, unsigned integers and floats.
|
|
private readonly byte[] _sample;
|
|
|
|
public PcmAudioSampleWrapper(byte[] sample)
|
|
{
|
|
_sample = sample;
|
|
}
|
|
|
|
public void Serialize(Stream stream)
|
|
{
|
|
stream.Write(_sample, 0, _sample.Length);
|
|
}
|
|
|
|
public async Task SerializeAsync(Stream stream, CancellationToken token)
|
|
{
|
|
await stream.WriteAsync(_sample, 0, _sample.Length, token).ConfigureAwait(false);
|
|
}
|
|
}
|