Skip to content

Commit ed156aa

Browse files
author
Yucked
committed
Adding D#+ opus interop
1 parent 3039922 commit ed156aa

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

src/Interop/Enums/OpusControl.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Vysn.Voice.Interop.Enums {
2+
/// <summary>
3+
///
4+
/// </summary>
5+
public enum OpusControl {
6+
7+
}
8+
}

src/Interop/Enums/OpusError.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Vysn.Voice.Interop.Enums {
2+
/// <summary>
3+
///
4+
/// </summary>
5+
public enum OpusError {
6+
7+
}
8+
}

src/Interop/OpusInterop.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
using Vysn.Voice.Interop.Enums;
4+
5+
namespace Vysn.Voice.Interop {
6+
/// <summary>
7+
///
8+
/// </summary>
9+
public readonly struct OpusInterop {
10+
private const string NAME = "libopus";
11+
12+
[DllImport(NAME, CallingConvention = CallingConvention.Cdecl)]
13+
internal static extern IntPtr opus_encoder_create(int sampleRate, int channels, int application,
14+
out OpusError error);
15+
16+
[DllImport(NAME, CallingConvention = CallingConvention.Cdecl)]
17+
internal static extern void opus_encoder_destroy(IntPtr encoder);
18+
19+
[DllImport(NAME, CallingConvention = CallingConvention.Cdecl)]
20+
internal static extern int opus_encode(IntPtr encoder, byte[] pcm, int frameSize, IntPtr data,
21+
int maxDataBytes);
22+
23+
[DllImport(NAME, CallingConvention = CallingConvention.Cdecl)]
24+
internal static extern OpusError opus_encoder_ctl(IntPtr encoder, OpusControl request, int value);
25+
26+
[DllImport(NAME, CallingConvention = CallingConvention.Cdecl)]
27+
internal static extern IntPtr opus_decoder_create(int sampleRate, int channels, out OpusError error);
28+
29+
[DllImport(NAME, CallingConvention = CallingConvention.Cdecl)]
30+
internal static extern void opus_decoder_destroy(IntPtr decoder);
31+
}
32+
}

0 commit comments

Comments
 (0)