Browse Source

fixes

pull/2703/head
Jason Dove 8 months ago
parent
commit
6b07484e72
No known key found for this signature in database
  1. 13
      ErsatzTV.Infrastructure/Streaming/Graphics/Script/ScriptElement.cs

13
ErsatzTV.Infrastructure/Streaming/Graphics/Script/ScriptElement.cs

@ -220,7 +220,7 @@ public class ScriptElement(ScriptGraphicsElement scriptElement, ILogger logger)
if (magic != EtvGraphicsMagic || version != 1) if (magic != EtvGraphicsMagic || version != 1)
{ {
// TODO: better error handling? logger.LogWarning("Invalid graphics packet received: magic {Magic}, version {Version}", magic, version);
return false; return false;
} }
@ -243,11 +243,13 @@ public class ScriptElement(ScriptGraphicsElement scriptElement, ILogger logger)
} }
break; break;
case (byte)ScriptPayloadType.Repeat: case (byte)ScriptPayloadType.Repeat:
uint repeatFrames = BinaryPrimitives.ReadUInt32BigEndian(buffer.First.Span); Span<byte> repeatBytes = stackalloc byte[4];
_repeatCount = (int)repeatFrames; buffer.Slice(0, 4).CopyTo(repeatBytes);
_repeatCount = (int)BinaryPrimitives.ReadUInt32BigEndian(repeatBytes);
break; break;
case (byte)ScriptPayloadType.Rectangles: case (byte)ScriptPayloadType.Rectangles:
// TODO: support rectangles // TODO: support rectangles
logger.LogWarning("Unsupported graphics packet type: {Type}", type);
success = false; success = false;
break; break;
} }
@ -261,6 +263,11 @@ public class ScriptElement(ScriptGraphicsElement scriptElement, ILogger logger)
{ {
_canvasBitmap.Erase(SKColors.Transparent); _canvasBitmap.Erase(SKColors.Transparent);
} }
else
{
logger.LogWarning("Unexpected zero-length payload for type {Type}", type);
success = false;
}
} }
return success; return success;

Loading…
Cancel
Save