Added AudioOutStream, exposed Clear/ClearAsync methods. Added support for cancelTokens.
This commit is contained in:
16
src/Discord.Net.Core/Audio/AudioOutStream.cs
Normal file
16
src/Discord.Net.Core/Audio/AudioOutStream.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Discord.Audio
|
||||
{
|
||||
public abstract class AudioOutStream : Stream
|
||||
{
|
||||
public override bool CanRead => false;
|
||||
public override bool CanSeek => false;
|
||||
public override bool CanWrite => true;
|
||||
|
||||
public virtual void Clear() { }
|
||||
public virtual Task ClearAsync(CancellationToken cancelToken) { return Task.Delay(0); }
|
||||
}
|
||||
}
|
||||
@@ -22,26 +22,26 @@ namespace Discord.Audio
|
||||
/// </summary>
|
||||
/// <param name="samplesPerFrame">Samples per frame. Must be 120, 240, 480, 960, 1920 or 2880, representing 2.5, 5, 10, 20, 40 or 60 milliseconds respectively.</param>
|
||||
/// <returns></returns>
|
||||
Stream CreateOpusStream(int samplesPerFrame, int bufferMillis = 1000);
|
||||
AudioOutStream CreateOpusStream(int samplesPerFrame, int bufferMillis = 1000);
|
||||
/// <summary>
|
||||
/// Creates a new outgoing stream accepting Opus-encoded data. This is a direct stream with no internal timer.
|
||||
/// </summary>
|
||||
/// <param name="samplesPerFrame">Samples per frame. Must be 120, 240, 480, 960, 1920 or 2880, representing 2.5, 5, 10, 20, 40 or 60 milliseconds respectively.</param>
|
||||
/// <returns></returns>
|
||||
Stream CreateDirectOpusStream(int samplesPerFrame);
|
||||
AudioOutStream CreateDirectOpusStream(int samplesPerFrame);
|
||||
/// <summary>
|
||||
/// Creates a new outgoing stream accepting PCM (raw) data.
|
||||
/// </summary>
|
||||
/// <param name="samplesPerFrame">Samples per frame. Must be 120, 240, 480, 960, 1920 or 2880, representing 2.5, 5, 10, 20, 40 or 60 milliseconds respectively.</param>
|
||||
/// <param name="bitrate"></param>
|
||||
/// <returns></returns>
|
||||
Stream CreatePCMStream(int samplesPerFrame, int channels = 2, int? bitrate = null, int bufferMillis = 1000);
|
||||
AudioOutStream CreatePCMStream(int samplesPerFrame, int channels = 2, int? bitrate = null, int bufferMillis = 1000);
|
||||
/// <summary>
|
||||
/// Creates a new direct outgoing stream accepting PCM (raw) data. This is a direct stream with no internal timer.
|
||||
/// </summary>
|
||||
/// <param name="samplesPerFrame">Samples per frame. Must be 120, 240, 480, 960, 1920 or 2880, representing 2.5, 5, 10, 20, 40 or 60 milliseconds respectively.</param>
|
||||
/// <param name="bitrate"></param>
|
||||
/// <returns></returns>
|
||||
Stream CreateDirectPCMStream(int samplesPerFrame, int channels = 2, int? bitrate = null);
|
||||
AudioOutStream CreateDirectPCMStream(int samplesPerFrame, int channels = 2, int? bitrate = null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user