public void RenderOutput(WebCamScreenController screenController, string input) { if (outputStreamPoller.Next(outputPacket)) { Debug.Log($"{outputPacket.Get()}"); } }
public void Ctor_ShouldInstantiatePacket_When_CalledWithNoArguments() { var packet = new StringPacket(); Assert.AreEqual(packet.ValidateAsType().code, Status.StatusCode.Internal); Assert.Throws <MediaPipeException>(() => { packet.Get(); }); Assert.AreEqual(packet.Timestamp(), Timestamp.Unset()); }
public void GetByteArray_ShouldReturnByteArray() { byte[] bytes = new byte[] { (byte)'a', (byte)'b', 0, (byte)'c' }; var packet = new StringPacket(bytes); Assert.AreEqual(packet.GetByteArray(), bytes); Assert.AreEqual(packet.Get(), "ab"); }
public void Ctor_ShouldInstantiatePacket_When_CalledWithString() { var packet = new StringPacket("test"); Assert.True(packet.ValidateAsType().ok); Assert.AreEqual(packet.Get(), "test"); Assert.AreEqual(packet.Timestamp(), Timestamp.Unset()); }
public void Ctor_ShouldInstantiatePacket_When_CalledWithByteArray() { byte[] bytes = new byte[] { (byte)'t', (byte)'e', (byte)'s', (byte)'t' }; var packet = new StringPacket(bytes); Assert.True(packet.ValidateAsType().ok); Assert.AreEqual(packet.Get(), "test"); Assert.AreEqual(packet.Timestamp(), Timestamp.Unset()); }
public string FetchNextValue() { if (!outputStreamPoller.Next(outputPacket)) { Logger.LogWarning(TAG, $"Failed to fetch next packet from {outputStreamName}"); return(null); } return(outputPacket.IsEmpty() ? null : outputPacket.Get()); }
public void Ctor_ShouldInstantiatePacket_When_CalledWithValueAndTimestamp() { var timestamp = new Timestamp(1); var packet = new StringPacket("test", timestamp); Assert.True(packet.ValidateAsType().ok); Assert.AreEqual(packet.Get(), "test"); Assert.AreEqual(packet.Timestamp(), timestamp); }
public void GetByteArray_ShouldReturnByteArray() { var bytes = new byte[] { (byte)'a', (byte)'b', 0, (byte)'c' }; using (var packet = new StringPacket(bytes)) { Assert.AreEqual(bytes, packet.GetByteArray()); Assert.AreEqual("ab", packet.Get()); } }
public void Ctor_ShouldInstantiatePacket_When_CalledWithByteArray() { var bytes = new byte[] { (byte)'t', (byte)'e', (byte)'s', (byte)'t' }; using (var packet = new StringPacket(bytes)) { Assert.True(packet.ValidateAsType().Ok()); Assert.AreEqual("test", packet.Get()); Assert.AreEqual(Timestamp.Unset(), packet.Timestamp()); } }
public void Ctor_ShouldInstantiatePacket_When_CalledWithNoArguments() { using (var packet = new StringPacket()) { #pragma warning disable IDE0058 Assert.AreEqual(Status.StatusCode.Internal, packet.ValidateAsType().Code()); Assert.Throws <MediaPipeException>(() => { packet.Get(); }); Assert.AreEqual(Timestamp.Unset(), packet.Timestamp()); #pragma warning restore IDE0058 } }
public void Ctor_ShouldInstantiatePacket_When_CalledWithStringAndTimestamp() { using (var timestamp = new Timestamp(1)) { using (var packet = new StringPacket("test", timestamp)) { Assert.True(packet.ValidateAsType().Ok()); Assert.AreEqual("test", packet.Get()); Assert.AreEqual(timestamp, packet.Timestamp()); } } }
static IntPtr OutputCallback(IntPtr graphPtr, IntPtr packetPtr) { try { var isFound = TryGetGraph(graphPtr, out var graph); if (!isFound) { return(Status.FailedPrecondition("Graph runner is not found").mpPtr); } using (var packet = new StringPacket(packetPtr, false)) { var value = packet.IsEmpty() ? null : packet.Get(); (graph as HelloWorldGraph).OnOutput.Invoke(value); } return(Status.Ok().mpPtr); } catch (Exception e) { return(Status.FailedPrecondition(e.ToString()).mpPtr); } }
public void At_ShouldReturnNewPacketWithTimestamp() { using (var timestamp = new Timestamp(1)) { var str = "str"; var packet = new StringPacket(str).At(timestamp); Assert.AreEqual(str, packet.Get()); Assert.AreEqual(timestamp, packet.Timestamp()); using (var newTimestamp = new Timestamp(2)) { var newPacket = packet.At(newTimestamp); Assert.AreEqual(str, newPacket.Get()); Assert.AreEqual(newTimestamp, newPacket.Timestamp()); } Assert.AreEqual(timestamp, packet.Timestamp()); } }