Browse Source

add content_total_seconds to watermark opacity expression (#2275)

pull/2276/head
Jason Dove 3 days ago committed by GitHub
parent
commit
f9db92d5e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 1
      ErsatzTV.Core/Interfaces/Streaming/IGraphicsElement.cs
  3. 11
      ErsatzTV.Infrastructure/Streaming/GraphicsEngine.cs
  4. 2
      ErsatzTV.Infrastructure/Streaming/WatermarkElement.cs

1
CHANGELOG.md

@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- This allows specifying an expression that returns an opacity between 0.0 and 1.0
- The expression can use:
- `content_seconds` - the total number of seconds the frame is into the content
- `content_total_seconds` - the total number of seconds in the content
- `channel_seconds` - the total number of seconds the frame is from when the channel started/activated
- `time_of_day_seconds` - the total number of seconds the frame is since midnight

1
ErsatzTV.Core/Interfaces/Streaming/IGraphicsElement.cs

@ -12,6 +12,7 @@ public interface IGraphicsElement @@ -12,6 +12,7 @@ public interface IGraphicsElement
object context,
TimeSpan timeOfDay,
TimeSpan contentTime,
TimeSpan contentTotalTime,
TimeSpan channelTime,
CancellationToken cancellationToken);
}

11
ErsatzTV.Infrastructure/Streaming/GraphicsEngine.cs

@ -35,6 +35,9 @@ public class GraphicsEngine(ILogger<GraphicsEngine> logger) : IGraphicsEngine @@ -35,6 +35,9 @@ public class GraphicsEngine(ILogger<GraphicsEngine> logger) : IGraphicsEngine
try
{
// `content_total_seconds` - the total number of seconds in the content
var contentTotalTime = context.Seek + context.Duration;
while (!cancellationToken.IsCancellationRequested && frameCount < totalFrames)
{
// seconds since this specific stream started
@ -64,7 +67,13 @@ public class GraphicsEngine(ILogger<GraphicsEngine> logger) : IGraphicsEngine @@ -64,7 +67,13 @@ public class GraphicsEngine(ILogger<GraphicsEngine> logger) : IGraphicsEngine
{
if (!element.IsFailed)
{
element.Draw(ctx, frameTime.TimeOfDay, contentTime, channelTime, cancellationToken);
element.Draw(
ctx,
frameTime.TimeOfDay,
contentTime,
contentTotalTime,
channelTime,
cancellationToken);
}
}
catch (Exception ex)

2
ErsatzTV.Infrastructure/Streaming/WatermarkElement.cs

@ -121,6 +121,7 @@ public class WatermarkElement : IGraphicsElement, IDisposable @@ -121,6 +121,7 @@ public class WatermarkElement : IGraphicsElement, IDisposable
object context,
TimeSpan timeOfDay,
TimeSpan contentTime,
TimeSpan contentTotalTime,
TimeSpan channelTime,
CancellationToken cancellationToken)
{
@ -130,6 +131,7 @@ public class WatermarkElement : IGraphicsElement, IDisposable @@ -130,6 +131,7 @@ public class WatermarkElement : IGraphicsElement, IDisposable
}
_expression.Parameters["content_seconds"] = contentTime.TotalSeconds;
_expression.Parameters["content_total_seconds"] = contentTotalTime.TotalSeconds;
_expression.Parameters["channel_seconds"] = channelTime.TotalSeconds;
_expression.Parameters["time_of_day_seconds"] = timeOfDay.TotalSeconds;

Loading…
Cancel
Save