Browse Source

add yaml post_roll instruction (#2230)

pull/2231/head
Jason Dove 2 weeks ago committed by GitHub
parent
commit
12c88a006d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      .editorconfig
  2. 3
      CHANGELOG.md
  3. 7
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutAllHandler.cs
  4. 7
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutCountHandler.cs
  5. 7
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutDurationHandler.cs
  6. 34
      ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutPostRollHandler.cs
  7. 11
      ErsatzTV.Core/Scheduling/YamlScheduling/Models/YamlPostRollInstruction.cs
  8. 2
      ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutBuilder.cs
  9. 15
      ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutContext.cs
  10. 11
      ErsatzTV/Resources/yaml-playout.schema.json

2
.editorconfig

@ -82,7 +82,7 @@ resharper_built_in_type_reference_style_highlighting=hint @@ -82,7 +82,7 @@ resharper_built_in_type_reference_style_highlighting=hint
resharper_redundant_base_qualifier_highlighting=warning
resharper_suggest_var_or_type_built_in_types_highlighting=hint
resharper_suggest_var_or_type_elsewhere_highlighting=hint
resharper_suggest_var_or_type_simple_types_highlighting=hint
resharper_suggest_var_or_type_simple_types_highlighting=none
resharper_web_config_module_not_resolved_highlighting=warning
resharper_web_config_type_not_resolved_highlighting=warning
resharper_web_config_wrong_module_highlighting=warning

3
CHANGELOG.md

@ -15,6 +15,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -15,6 +15,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- YAML playout: add `pre_roll` instruction to enable and disable a pre-roll sequence
- With value of `true` and `sequence` property, will enable automatic pre-roll for all content in the playout to the sequence with the provided key
- With value of `false`, will disable automatic pre-roll in the playout
- YAML playout: add `post_roll` instruction to enable and disable a post-roll sequence
- With value of `true` and `sequence` property, will enable automatic post-roll for all content in the playout to the sequence with the provided key
- With value of `false`, will disable automatic post-roll in the playout
- Add YAML playout validation (using JSON Schema)
- Invalid YAML playout definitions will fail to build and will log validation failures as warnings
- `content` is fully validated

7
ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutAllHandler.cs

@ -91,6 +91,13 @@ public class YamlPlayoutAllHandler(EnumeratorCache enumeratorCache) : YamlPlayou @@ -91,6 +91,13 @@ public class YamlPlayoutAllHandler(EnumeratorCache enumeratorCache) : YamlPlayou
context.CurrentTime += itemDuration;
enumerator.MoveNext();
}
foreach (string postRollSequence in context.GetPostRollSequence())
{
context.PushFillerKind(FillerKind.PostRoll);
await executeSequence(postRollSequence);
context.PopFillerKind();
}
}
return true;

7
ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutCountHandler.cs

@ -116,6 +116,13 @@ public class YamlPlayoutCountHandler(EnumeratorCache enumeratorCache) : YamlPlay @@ -116,6 +116,13 @@ public class YamlPlayoutCountHandler(EnumeratorCache enumeratorCache) : YamlPlay
context.CurrentTime += itemDuration;
enumerator.MoveNext();
}
foreach (string postRollSequence in context.GetPostRollSequence())
{
context.PushFillerKind(FillerKind.PostRoll);
await executeSequence(postRollSequence);
context.PopFillerKind();
}
}
return true;

7
ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutDurationHandler.cs

@ -229,6 +229,13 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP @@ -229,6 +229,13 @@ public class YamlPlayoutDurationHandler(EnumeratorCache enumeratorCache) : YamlP
done = true;
}
}
foreach (string postRollSequence in context.GetPostRollSequence())
{
context.PushFillerKind(FillerKind.PostRoll);
await executeSequence(postRollSequence);
context.PopFillerKind();
}
}
if (!stopBeforeEnd)

34
ErsatzTV.Core/Scheduling/YamlScheduling/Handlers/YamlPlayoutPostRollHandler.cs

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
using ErsatzTV.Core.Scheduling.YamlScheduling.Models;
using Microsoft.Extensions.Logging;
namespace ErsatzTV.Core.Scheduling.YamlScheduling.Handlers;
public class YamlPlayoutPostRollHandler : IYamlPlayoutHandler
{
public bool Reset => false;
public Task<bool> Handle(
YamlPlayoutContext context,
YamlPlayoutInstruction instruction,
PlayoutBuildMode mode,
Func<string, Task> executeSequence,
ILogger<YamlPlayoutBuilder> logger,
CancellationToken cancellationToken)
{
if (instruction is not YamlPostRollInstruction postRoll)
{
return Task.FromResult(false);
}
if (postRoll.PostRoll && !string.IsNullOrWhiteSpace(postRoll.Sequence))
{
context.SetPostRollSequence(postRoll.Sequence);
}
else
{
context.ClearPostRollSequence();
}
return Task.FromResult(true);
}
}

11
ErsatzTV.Core/Scheduling/YamlScheduling/Models/YamlPostRollInstruction.cs

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
using YamlDotNet.Serialization;
namespace ErsatzTV.Core.Scheduling.YamlScheduling.Models;
public class YamlPostRollInstruction : YamlPlayoutInstruction
{
[YamlMember(Alias = "post_roll", ApplyNamingConventions = false)]
public bool PostRoll { get; set; }
public string Sequence { get; set; }
}

2
ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutBuilder.cs

@ -344,6 +344,7 @@ public class YamlPlayoutBuilder( @@ -344,6 +344,7 @@ public class YamlPlayoutBuilder(
YamlPlayoutWatermarkInstruction => new YamlPlayoutWatermarkHandler(channelRepository),
YamlPlayoutShuffleSequenceInstruction => new YamlPlayoutShuffleSequenceHandler(),
YamlPreRollInstruction => new YamlPlayoutPreRollHandler(),
YamlPostRollInstruction => new YamlPlayoutPostRollHandler(),
YamlPlayoutSkipItemsInstruction => new YamlPlayoutSkipItemsHandler(enumeratorCache),
YamlPlayoutSkipToItemInstruction => new YamlPlayoutSkipToItemHandler(enumeratorCache),
@ -403,6 +404,7 @@ public class YamlPlayoutBuilder( @@ -403,6 +404,7 @@ public class YamlPlayoutBuilder(
{ "pad_to_next", typeof(YamlPlayoutPadToNextInstruction) },
{ "pad_until", typeof(YamlPlayoutPadUntilInstruction) },
{ "pre_roll", typeof(YamlPreRollInstruction) },
{ "post_roll", typeof(YamlPostRollInstruction) },
{ "repeat", typeof(YamlPlayoutRepeatInstruction) },
{ "sequence", typeof(YamlPlayoutSequenceInstruction) },
{ "shuffle_sequence", typeof(YamlPlayoutShuffleSequenceInstruction) },

15
ErsatzTV.Core/Scheduling/YamlScheduling/YamlPlayoutContext.cs

@ -13,12 +13,13 @@ public class YamlPlayoutContext(Playout playout, YamlPlayoutDefinition definitio @@ -13,12 +13,13 @@ public class YamlPlayoutContext(Playout playout, YamlPlayoutDefinition definitio
};
private readonly System.Collections.Generic.HashSet<int> _visitedInstructions = [];
private readonly Stack<FillerKind> _fillerKind = new();
private int _guideGroup = guideGroup;
private bool _guideGroupLocked;
private int _instructionIndex;
private Option<int> _channelWatermarkId;
private Option<string> _preRollSequence;
private Stack<FillerKind> _fillerKind = new();
private Option<string> _postRollSequence;
public Playout Playout { get; } = playout;
@ -104,6 +105,18 @@ public class YamlPlayoutContext(Playout playout, YamlPlayoutDefinition definitio @@ -104,6 +105,18 @@ public class YamlPlayoutContext(Playout playout, YamlPlayoutDefinition definitio
public Option<string> GetPreRollSequence() => _preRollSequence;
public void SetPostRollSequence(string sequence)
{
_postRollSequence = sequence;
}
public void ClearPostRollSequence()
{
_postRollSequence = Option<string>.None;
}
public Option<string> GetPostRollSequence() => _postRollSequence;
public void PushFillerKind(FillerKind fillerKind)
{
_fillerKind.Push(fillerKind);

11
ErsatzTV/Resources/yaml-playout.schema.json

@ -40,6 +40,7 @@ @@ -40,6 +40,7 @@
{ "$ref": "#/$defs/scheduling/sequenceInstruction" },
{ "$ref": "#/$defs/control/epgGroupInstruction" },
{ "$ref": "#/$defs/control/preRollInstruction"},
{ "$ref": "#/$defs/control/postRollInstruction"},
{ "$ref": "#/$defs/control/repeatInstruction" },
{ "$ref": "#/$defs/control/shuffleSequenceInstruction" },
{ "$ref": "#/$defs/control/skipItemsInstruction" },
@ -79,6 +80,7 @@ @@ -79,6 +80,7 @@
{ "$ref": "#/$defs/scheduling/sequenceInstruction" },
{ "$ref": "#/$defs/control/epgGroupInstruction" },
{ "$ref": "#/$defs/control/preRollInstruction"},
{ "$ref": "#/$defs/control/postRollInstruction"},
{ "$ref": "#/$defs/control/repeatInstruction" },
{ "$ref": "#/$defs/control/shuffleSequenceInstruction" },
{ "$ref": "#/$defs/control/skipItemsInstruction" },
@ -298,6 +300,15 @@ @@ -298,6 +300,15 @@
"required": [ "pre_roll" ],
"additionalProperties": false
},
"postRollInstruction": {
"type": "object",
"properties": {
"post_roll": { "type": "boolean" },
"sequence": { "type": "string" }
},
"required": [ "post_roll" ],
"additionalProperties": false
},
"repeatInstruction": {
"type": "object",
"properties": {

Loading…
Cancel
Save