Browse Source

log graphics element z index (#2785)

pull/2786/head
Jason Dove 7 months ago committed by GitHub
parent
commit
4ce87feac1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      ErsatzTV.Core/Graphics/BaseGraphicsElement.cs
  2. 2
      ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElement.cs
  3. 16
      ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElementLoader.cs
  4. 8
      ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsEngine.cs
  5. 3
      ErsatzTV.Infrastructure/Streaming/Graphics/IGraphicsElement.cs
  6. 2
      ErsatzTV.Infrastructure/Streaming/Graphics/Image/ImageElement.cs
  7. 4
      ErsatzTV.Infrastructure/Streaming/Graphics/Image/WatermarkElement.cs
  8. 2
      ErsatzTV.Infrastructure/Streaming/Graphics/Motion/MotionElement.cs
  9. 2
      ErsatzTV.Infrastructure/Streaming/Graphics/Script/ScriptElement.cs
  10. 2
      ErsatzTV.Infrastructure/Streaming/Graphics/Subtitle/SubtitleElement.cs
  11. 2
      ErsatzTV.Infrastructure/Streaming/Graphics/Text/TextElement.cs

7
ErsatzTV.Core/Graphics/BaseGraphicsElement.cs

@ -1,6 +1,13 @@ @@ -1,6 +1,13 @@
using YamlDotNet.Serialization;
namespace ErsatzTV.Core.Graphics;
public class BaseGraphicsElement
{
public string Name { get; set; }
[YamlIgnore]
public string SourceFileName { get; set; }
public string DebugName() => string.IsNullOrEmpty(Name) ? SourceFileName : Name;
}

2
ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElement.cs

@ -9,6 +9,8 @@ public abstract class GraphicsElement : IGraphicsElement @@ -9,6 +9,8 @@ public abstract class GraphicsElement : IGraphicsElement
{
public abstract int ZIndex { get; }
public abstract string DebugKey { get; }
public bool IsFinished { get; set; }
public abstract Task InitializeAsync(GraphicsEngineContext context, CancellationToken cancellationToken);

16
ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElementLoader.cs

@ -281,7 +281,7 @@ public partial class GraphicsElementLoader( @@ -281,7 +281,7 @@ public partial class GraphicsElementLoader(
return result;
}
private async Task<Option<string>> GetTemplatedYaml(string fileName, Dictionary<string, object> variables)
private async Task<Option<TemplatedYaml>> GetTemplatedYaml(string fileName, Dictionary<string, object> variables)
{
string yaml = await fileSystem.File.ReadAllTextAsync(fileName);
try
@ -295,16 +295,18 @@ public partial class GraphicsElementLoader( @@ -295,16 +295,18 @@ public partial class GraphicsElementLoader(
var context = new TemplateContext { MemberRenamer = member => member.Name };
context.PushGlobal(scriptObject);
return await Template.Parse(yaml).RenderAsync(context);
return new TemplatedYaml(
fileSystem.Path.GetFileName(fileName),
await Template.Parse(yaml).RenderAsync(context));
}
catch (Exception ex)
{
logger.LogWarning(ex, "Failed to render graphics element YAML definition as scriban template");
return Option<string>.None;
return Option<TemplatedYaml>.None;
}
}
private Option<T> FromYaml<T>(string yaml)
private Option<T> FromYaml<T>(TemplatedYaml yaml) where T : BaseGraphicsElement
{
try
{
@ -318,7 +320,9 @@ public partial class GraphicsElementLoader( @@ -318,7 +320,9 @@ public partial class GraphicsElementLoader(
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.Build();
return deserializer.Deserialize<T>(yaml);
var result = deserializer.Deserialize<T>(yaml.Yaml);
result.SourceFileName = yaml.SourceFileName;
return result;
}
catch (Exception ex)
{
@ -346,4 +350,6 @@ public partial class GraphicsElementLoader( @@ -346,4 +350,6 @@ public partial class GraphicsElementLoader(
[GeneratedRegex(@"epg_entries:\s*(\d+)")]
private static partial Regex EpgEntriesRegex();
private record TemplatedYaml(string SourceFileName, string Yaml);
}

8
ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsEngine.cs

@ -99,6 +99,14 @@ public class GraphicsEngine( @@ -99,6 +99,14 @@ public class GraphicsEngine(
var prepareTasks = new List<Task<Option<PreparedElementImage>>>(elements.Count);
foreach (IGraphicsElement element in elements.OrderBy(e => e.ZIndex))
{
logger.LogDebug(
"Graphics element {Element} will draw with ZIndex {ZIndex}",
element.DebugKey,
element.ZIndex);
}
try
{
// `content_total_seconds` - the total number of seconds in the content

3
ErsatzTV.Infrastructure/Streaming/Graphics/IGraphicsElement.cs

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Streaming;
namespace ErsatzTV.Infrastructure.Streaming.Graphics;
@ -7,6 +6,8 @@ public interface IGraphicsElement @@ -7,6 +6,8 @@ public interface IGraphicsElement
{
int ZIndex { get; }
string DebugKey { get; }
bool IsFinished { get; set; }
Task InitializeAsync(GraphicsEngineContext context, CancellationToken cancellationToken);

2
ErsatzTV.Infrastructure/Streaming/Graphics/Image/ImageElement.cs

@ -13,6 +13,8 @@ public class ImageElement(ImageGraphicsElement imageGraphicsElement, ILogger log @@ -13,6 +13,8 @@ public class ImageElement(ImageGraphicsElement imageGraphicsElement, ILogger log
public override int ZIndex { get; } = imageGraphicsElement.ZIndex ?? 0;
public override string DebugKey { get; } = $"Image {imageGraphicsElement.DebugName()}";
public override async Task InitializeAsync(GraphicsEngineContext context, CancellationToken cancellationToken)
{
try

4
ErsatzTV.Infrastructure/Streaming/Graphics/Image/WatermarkElement.cs

@ -24,13 +24,17 @@ public class WatermarkElement : ImageElementBase @@ -24,13 +24,17 @@ public class WatermarkElement : ImageElementBase
_imagePath = watermarkOptions.ImagePath;
_watermark = watermarkOptions.Watermark;
ZIndex = watermarkOptions.Watermark.ZIndex;
DebugKey = $"Watermark {watermarkOptions.Watermark.Name}";
}
public bool IsValid => _imagePath != null && _watermark != null;
public override int ZIndex { get; }
public override string DebugKey { get; }
public override async Task InitializeAsync(GraphicsEngineContext context, CancellationToken cancellationToken)
{
try

2
ErsatzTV.Infrastructure/Streaming/Graphics/Motion/MotionElement.cs

@ -32,6 +32,8 @@ public class MotionElement( @@ -32,6 +32,8 @@ public class MotionElement(
public override int ZIndex { get; } = motionElement.ZIndex ?? 0;
public override string DebugKey { get; } = $"Motion {motionElement.DebugName()}";
public void Dispose()
{
GC.SuppressFinalize(this);

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

@ -29,6 +29,8 @@ public class ScriptElement(ScriptGraphicsElement scriptElement, ILogger logger) @@ -29,6 +29,8 @@ public class ScriptElement(ScriptGraphicsElement scriptElement, ILogger logger)
public override int ZIndex { get; } = scriptElement.ZIndex ?? 0;
public override string DebugKey { get; } = $"Script {scriptElement.DebugName()}";
public void Dispose()
{
logger.LogDebug(

2
ErsatzTV.Infrastructure/Streaming/Graphics/Subtitle/SubtitleElement.cs

@ -32,6 +32,8 @@ public class SubtitleElement( @@ -32,6 +32,8 @@ public class SubtitleElement(
public override int ZIndex { get; } = subtitleElement.ZIndex ?? 0;
public override string DebugKey { get; } = $"Subtitle {subtitleElement.DebugName()}";
public void Dispose()
{
GC.SuppressFinalize(this);

2
ErsatzTV.Infrastructure/Streaming/Graphics/Text/TextElement.cs

@ -23,6 +23,8 @@ public partial class TextElement( @@ -23,6 +23,8 @@ public partial class TextElement(
public override int ZIndex { get; } = textElement.ZIndex ?? 0;
public override string DebugKey { get; } = $"Text {textElement.DebugName()}";
public void Dispose()
{
GC.SuppressFinalize(this);

Loading…
Cancel
Save