Expose LocalCast native source hashing
This commit is contained in:
parent
f4c5988e3d
commit
924aa2f6b4
1 changed files with 18 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Aquarium.LocalCast;
|
||||
|
||||
|
|
@ -112,6 +113,20 @@ public interface ILocalCastNativeRuntime : IDisposable
|
|||
bool TryReadLatestForSensor(LocalCastNativeSampleKind kind, ulong sensorIdHash, out LocalCastNativeSampleHandle sample);
|
||||
}
|
||||
|
||||
public static class LocalCastNativeSourceId
|
||||
{
|
||||
public static ulong HashUtf8(string sourceId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sourceId))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var bytes = Encoding.UTF8.GetBytes(sourceId);
|
||||
return LocalCastNativeMethods.HashSourceId(bytes, (UIntPtr)bytes.Length);
|
||||
}
|
||||
}
|
||||
|
||||
public interface ILocalCastNativeProducer : IDisposable
|
||||
{
|
||||
ulong NextSequence { get; }
|
||||
|
|
@ -266,6 +281,9 @@ internal static class LocalCastNativeMethods
|
|||
{
|
||||
private const string LibraryName = "localcast_reservoir";
|
||||
|
||||
[DllImport(LibraryName, EntryPoint = "localcast_hash_source_id")]
|
||||
internal static extern ulong HashSourceId(byte[] bytes, UIntPtr byteLen);
|
||||
|
||||
[DllImport(LibraryName, EntryPoint = "localcast_runtime_create")]
|
||||
internal static extern IntPtr RuntimeCreate(ulong durationNs);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue