Create LocalCast producers from source ids
This commit is contained in:
parent
c06d4cbf28
commit
3316895eb1
1 changed files with 20 additions and 0 deletions
|
|
@ -193,6 +193,12 @@ public sealed class LocalCastNativeRuntime : ILocalCastNativeRuntime
|
|||
return new LocalCastNativeProducer(this, kind, sensorIdHash, initialSequence);
|
||||
}
|
||||
|
||||
public LocalCastNativeProducer CreateProducer(LocalCastNativeSampleKind kind, string sourceId, ulong initialSequence = 0)
|
||||
{
|
||||
EnsureNotDisposed();
|
||||
return new LocalCastNativeProducer(this, kind, sourceId, initialSequence);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (handle == IntPtr.Zero)
|
||||
|
|
@ -225,6 +231,17 @@ public sealed class LocalCastNativeProducer : ILocalCastNativeProducer
|
|||
}
|
||||
}
|
||||
|
||||
internal LocalCastNativeProducer(LocalCastNativeRuntime runtime, LocalCastNativeSampleKind kind, string sourceId, ulong initialSequence)
|
||||
{
|
||||
this.runtime = runtime;
|
||||
var bytes = Encoding.UTF8.GetBytes(sourceId);
|
||||
handle = LocalCastNativeMethods.ProducerCreateForSource((uint)kind, bytes, (UIntPtr)bytes.Length, initialSequence);
|
||||
if (handle == IntPtr.Zero)
|
||||
{
|
||||
throw new InvalidOperationException("LocalCast native producer creation failed.");
|
||||
}
|
||||
}
|
||||
|
||||
public ulong NextSequence
|
||||
{
|
||||
get
|
||||
|
|
@ -321,6 +338,9 @@ internal static class LocalCastNativeMethods
|
|||
[DllImport(LibraryName, EntryPoint = "localcast_producer_create")]
|
||||
internal static extern IntPtr ProducerCreate(uint sampleKind, ulong sensorIdHash, ulong initialSequence);
|
||||
|
||||
[DllImport(LibraryName, EntryPoint = "localcast_producer_create_for_source")]
|
||||
internal static extern IntPtr ProducerCreateForSource(uint sampleKind, byte[] sourceIdBytes, UIntPtr sourceIdByteLen, ulong initialSequence);
|
||||
|
||||
[DllImport(LibraryName, EntryPoint = "localcast_producer_destroy")]
|
||||
internal static extern void ProducerDestroy(IntPtr producer);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue