|
1 | 1 | using System; |
| 2 | +using System.Buffers; |
2 | 3 | using System.Collections.Generic; |
| 4 | +using System.ComponentModel; |
3 | 5 | using System.Net; |
4 | 6 | using System.Runtime.InteropServices; |
5 | 7 | using System.Threading.Tasks; |
@@ -164,7 +166,7 @@ public struct AudioFormat |
164 | 166 | public const int DEFAULT_CHANNEL_COUNT = 1; |
165 | 167 |
|
166 | 168 | public static readonly AudioFormat Empty = new AudioFormat() |
167 | | - { _isNonEmpty = false, ClockRate = DEFAULT_CLOCK_RATE, ChannelCount = DEFAULT_CHANNEL_COUNT }; |
| 169 | + { _isNonEmpty = false, ClockRate = DEFAULT_CLOCK_RATE, ChannelCount = DEFAULT_CHANNEL_COUNT }; |
168 | 170 |
|
169 | 171 | public AudioCodecsEnum Codec { get; set; } |
170 | 172 |
|
@@ -288,7 +290,7 @@ public AudioFormat(int formatID, string formatName, int clockRate, int rtpClockR |
288 | 290 | { |
289 | 291 | throw new ApplicationException($"The format name must be provided for an AudioFormat."); |
290 | 292 | } |
291 | | - else if(clockRate <= 0) |
| 293 | + else if (clockRate <= 0) |
292 | 294 | { |
293 | 295 | throw new ApplicationException($"The clock rate for an AudioFormat must be greater than 0."); |
294 | 296 | } |
@@ -329,7 +331,7 @@ public struct VideoFormat |
329 | 331 | public const int DEFAULT_CLOCK_RATE = 90000; |
330 | 332 |
|
331 | 333 | public static readonly VideoFormat Empty = new VideoFormat() |
332 | | - { _isNonEmpty = false, ClockRate = DEFAULT_CLOCK_RATE }; |
| 334 | + { _isNonEmpty = false, ClockRate = DEFAULT_CLOCK_RATE }; |
333 | 335 |
|
334 | 336 | public VideoCodecsEnum Codec { get; set; } |
335 | 337 |
|
@@ -544,6 +546,14 @@ public interface IAudioEncoder |
544 | 546 | /// <returns>A byte array containing the encoded sample.</returns> |
545 | 547 | byte[] EncodeAudio(short[] pcm, AudioFormat format); |
546 | 548 |
|
| 549 | + /// <summary> |
| 550 | + /// Encodes 16bit signed PCM samples. |
| 551 | + /// </summary> |
| 552 | + /// <param name="pcm">An array of 16 bit signed audio samples.</param> |
| 553 | + /// <param name="format">The audio format to encode the PCM sample to.</param> |
| 554 | + /// <param name="destination">A <see cref="IBufferWriter{T}"/> of <see langword="byte"/> to receieve the encoded sample.</param> |
| 555 | + void EncodeAudio(ReadOnlySpan<short> pcm, AudioFormat format, IBufferWriter<byte> destination); |
| 556 | + |
547 | 557 | /// <summary> |
548 | 558 | /// Decodes to 16bit signed PCM samples. |
549 | 559 | /// </summary> |
@@ -649,6 +659,8 @@ public interface IAudioSource |
649 | 659 | { |
650 | 660 | event EncodedSampleDelegate OnAudioSourceEncodedSample; |
651 | 661 |
|
| 662 | + event Action<uint, ReadOnlyMemory<byte>> OnAudioSourceEncodedSampleEx; |
| 663 | + |
652 | 664 | event RawAudioSampleDelegate OnAudioSourceRawSample; |
653 | 665 |
|
654 | 666 | event SourceErrorDelegate OnAudioSourceError; |
|
0 commit comments