add deco setting to use watermarks during filler (#1861)

This commit is contained in:
Jason Dove
2024-08-05 13:40:24 -05:00
committed by GitHub
parent b4c168e85e
commit 2977590a14
15 changed files with 11687 additions and 9 deletions
+2
View File
@@ -37,6 +37,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- POST `/api/channels/{channelNumber}/playout/reset`
- Scan library
- POST `/api/libraries/{libraryId}/scan`
- Add Deco setting to `Use Watermark During Filler`
- This setting is turned OFF by default, meaning filler will NOT use the configured watermark unless this is manually turned on
### Fixed
- Add basic cache busting to XMLTV image URLs
@@ -10,6 +10,7 @@ public record UpdateDeco(
string Name,
DecoMode WatermarkMode,
int? WatermarkId,
bool UseWatermarkDuringFiller,
DecoMode DefaultFillerMode,
ProgramScheduleItemCollectionType DefaultFillerCollectionType,
int? DefaultFillerCollectionId,
@@ -26,6 +26,8 @@ public class UpdateDecoHandler(IDbContextFactory<TvContext> dbContextFactory)
// watermark
existing.WatermarkMode = request.WatermarkMode;
existing.WatermarkId = request.WatermarkMode is DecoMode.Override ? request.WatermarkId : null;
existing.UseWatermarkDuringFiller =
request.WatermarkMode is DecoMode.Override && request.UseWatermarkDuringFiller;
// default filler
existing.DefaultFillerMode = request.DefaultFillerMode;
@@ -9,6 +9,7 @@ public record DecoViewModel(
string Name,
DecoMode WatermarkMode,
int? WatermarkId,
bool UseWatermarkDuringFiller,
DecoMode DefaultFillerMode,
ProgramScheduleItemCollectionType DefaultFillerCollectionType,
int? DefaultFillerCollectionId,
@@ -56,6 +56,7 @@ internal static class Mapper
deco.Name,
deco.WatermarkMode,
deco.WatermarkId,
deco.UseWatermarkDuringFiller,
deco.DefaultFillerMode,
deco.DefaultFillerCollectionType,
deco.DefaultFillerCollectionId,
@@ -232,7 +232,7 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
Option<ChannelWatermark> playoutItemWatermark = Optional(playoutItemWithPath.PlayoutItem.Watermark);
bool disableWatermarks = playoutItemWithPath.PlayoutItem.DisableWatermarks;
WatermarkResult watermarkResult = GetPlayoutItemWatermark(playoutItemWithPath.PlayoutItem.Playout, now);
WatermarkResult watermarkResult = GetPlayoutItemWatermark(playoutItemWithPath.PlayoutItem, now);
switch (watermarkResult)
{
case InheritWatermark:
@@ -464,7 +464,10 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
case CustomDeadAirFallback custom:
maybeFallback = new FillerPreset
{
AllowWatermarks = false, // TODO: does this need to be configurable?
// always allow watermarks here
// deco settings will disable watermarks if appropriate
AllowWatermarks = true,
CollectionType = custom.CollectionType,
CollectionId = custom.CollectionId,
MediaItemId = custom.MediaItemId,
@@ -657,9 +660,9 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
};
}
private WatermarkResult GetPlayoutItemWatermark(Playout playout, DateTimeOffset now)
private WatermarkResult GetPlayoutItemWatermark(PlayoutItem playoutItem, DateTimeOffset now)
{
DecoEntries decoEntries = GetDecoEntries(playout, now);
DecoEntries decoEntries = GetDecoEntries(playoutItem.Playout, now);
// first, check deco template / active deco
foreach (Deco templateDeco in decoEntries.TemplateDeco)
@@ -667,8 +670,14 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
switch (templateDeco.WatermarkMode)
{
case DecoMode.Override:
_logger.LogDebug("Watermark will come from template deco (override)");
return new CustomWatermark(templateDeco.Watermark);
if (playoutItem.FillerKind is FillerKind.None || templateDeco.UseWatermarkDuringFiller)
{
_logger.LogDebug("Watermark will come from template deco (override)");
return new CustomWatermark(templateDeco.Watermark);
}
_logger.LogDebug("Watermark is disabled by template deco during filler");
return new DisableWatermark();
case DecoMode.Disable:
_logger.LogDebug("Watermark is disabled by template deco");
return new DisableWatermark();
@@ -684,8 +693,14 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
switch (playoutDeco.WatermarkMode)
{
case DecoMode.Override:
_logger.LogDebug("Watermark will come from playout deco (override)");
return new CustomWatermark(playoutDeco.Watermark);
if (playoutItem.FillerKind is FillerKind.None || playoutDeco.UseWatermarkDuringFiller)
{
_logger.LogDebug("Watermark will come from playout deco (override)");
return new CustomWatermark(playoutDeco.Watermark);
}
_logger.LogDebug("Watermark is disabled by playout deco during filler");
return new DisableWatermark();
case DecoMode.Disable:
_logger.LogDebug("Watermark is disabled by playout deco");
return new DisableWatermark();
+1
View File
@@ -12,6 +12,7 @@ public class Deco
public DecoMode WatermarkMode { get; set; }
public int? WatermarkId { get; set; }
public ChannelWatermark Watermark { get; set; }
public bool UseWatermarkDuringFiller { get; set; }
// default filler
public DecoMode DefaultFillerMode { get; set; }
@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.MySql.Migrations
{
/// <inheritdoc />
public partial class Add_Deco_UseWatermarkDuringFiller : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "UseWatermarkDuringFiller",
table: "Deco",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "UseWatermarkDuringFiller",
table: "Deco");
}
}
}
@@ -2312,6 +2312,9 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations
b.Property<string>("Name")
.HasColumnType("varchar(255)");
b.Property<bool>("UseWatermarkDuringFiller")
.HasColumnType("tinyint(1)");
b.Property<int?>("WatermarkId")
.HasColumnType("int");
@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.Sqlite.Migrations
{
/// <inheritdoc />
public partial class Add_Deco_UseWatermarkDuringFiller : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "UseWatermarkDuringFiller",
table: "Deco",
type: "INTEGER",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "UseWatermarkDuringFiller",
table: "Deco");
}
}
}
@@ -2197,6 +2197,9 @@ namespace ErsatzTV.Infrastructure.Sqlite.Migrations
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<bool>("UseWatermarkDuringFiller")
.HasColumnType("INTEGER");
b.Property<int?>("WatermarkId")
.HasColumnType("INTEGER");
+14 -1
View File
@@ -45,6 +45,12 @@
<MudSelectItem T="int?" Value="@watermark.Id">@watermark.Name</MudSelectItem>
}
</MudSelect>
<MudSwitch T="bool"
Class="mt-3"
Disabled="@(_deco.WatermarkMode != DecoMode.Override)"
@bind-Value="_deco.UseWatermarkDuringFiller"
Color="Color.Primary"
Label="Use Watermark During Filler"/>
</MudCardContent>
</MudCard>
<MudCard Class="mb-6" Style="width: 350px">
@@ -159,7 +165,12 @@
}
</MudSelect>
}
<MudSwitch T="bool" Class="mt-3" Label="Trim To Fit" @bind-Value="_deco.DefaultFillerTrimToFit" Color="Color.Primary" />
<MudSwitch T="bool"
Class="mt-3"
Disabled="@(_deco.DefaultFillerMode != DecoMode.Override)"
Label="Trim To Fit"
@bind-Value="_deco.DefaultFillerTrimToFit"
Color="Color.Primary" />
</MudCardContent>
</MudCard>
<MudCard Class="mb-6" Style="width: 350px">
@@ -344,6 +355,7 @@
DecoGroupId = deco.DecoGroupId,
WatermarkMode = deco.WatermarkMode,
WatermarkId = deco.WatermarkId,
UseWatermarkDuringFiller = deco.UseWatermarkDuringFiller,
DefaultFillerMode = deco.DefaultFillerMode,
DefaultFillerCollectionType = deco.DefaultFillerCollectionType,
@@ -389,6 +401,7 @@
_deco.Name,
_deco.WatermarkMode,
_deco.WatermarkId,
_deco.UseWatermarkDuringFiller,
_deco.DefaultFillerMode,
_deco.DefaultFillerCollectionType,
_deco.DefaultFillerCollection?.Id,
+1
View File
@@ -11,6 +11,7 @@ public class DecoEditViewModel
public string Name { get; set; }
public DecoMode WatermarkMode { get; set; }
public int? WatermarkId { get; set; }
public bool UseWatermarkDuringFiller { get; set; }
public DecoMode DefaultFillerMode { get; set; }
public ProgramScheduleItemCollectionType DefaultFillerCollectionType { get; set; }