revert: move the encoding.xml EncoderPreset fix to its own branch
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful

It is an unrelated subsystem and ships as a separate change.
This commit is contained in:
2026-09-12 16:21:47 +10:00
parent 65af2bcbd7
commit 2f9b8888e9
2 changed files with 0 additions and 69 deletions
@@ -1,10 +1,7 @@
#pragma warning disable CA1819 // XML serialization handles collections improperly, so we need to use arrays
#nullable disable
using System;
using System.ComponentModel;
using System.Text.Json.Serialization;
using System.Xml.Serialization;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Model.Configuration;
@@ -237,24 +234,8 @@ public class EncodingOptions
/// <summary>
/// Gets or sets the encoder preset.
/// </summary>
[XmlIgnore]
public EncoderPreset EncoderPreset { get; set; }
/// <summary>
/// Gets or sets the encoder preset as it is stored in the configuration file. Files written before the preset
/// list was validated can carry an empty element, which has to read back as the default rather than throw and
/// take the rest of the configuration down with it.
/// </summary>
[JsonIgnore]
[XmlElement(nameof(EncoderPreset))]
public string EncoderPresetXml
{
get => EncoderPreset.ToString();
set => EncoderPreset = Enum.TryParse<EncoderPreset>(value, true, out var encoderPreset)
? encoderPreset
: EncoderPreset.auto;
}
/// <summary>
/// Gets or sets a value indicating whether the framerate is doubled when deinterlacing.
/// </summary>
@@ -1,50 +0,0 @@
using System.IO;
using System.Xml.Serialization;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
using Xunit;
namespace Jellyfin.Model.Tests.Configuration;
public class EncodingOptionsTests
{
[Theory]
[InlineData("<EncoderPreset></EncoderPreset>")]
[InlineData("<EncoderPreset />")]
[InlineData("<EncoderPreset> </EncoderPreset>")]
[InlineData("<EncoderPreset>notapreset</EncoderPreset>")]
public void Deserialize_UnreadableEncoderPreset_FallsBackToDefault(string encoderPresetElement)
{
var options = Deserialize($"<EncodingOptions>{encoderPresetElement}<H264Crf>21</H264Crf></EncodingOptions>");
Assert.Equal(EncoderPreset.auto, options.EncoderPreset);
// The rest of the file has to survive: a throwing preset used to discard every other encoding setting.
Assert.Equal(21, options.H264Crf);
}
[Fact]
public void Deserialize_KnownEncoderPreset_IsKept()
{
var options = Deserialize("<EncodingOptions><EncoderPreset>veryfast</EncoderPreset></EncodingOptions>");
Assert.Equal(EncoderPreset.veryfast, options.EncoderPreset);
}
[Fact]
public void Serialize_WritesTheEncoderPresetElement()
{
var serializer = new XmlSerializer(typeof(EncodingOptions));
using var writer = new StringWriter();
serializer.Serialize(writer, new EncodingOptions { EncoderPreset = EncoderPreset.slow });
Assert.Contains("<EncoderPreset>slow</EncoderPreset>", writer.ToString(), System.StringComparison.Ordinal);
}
private static EncodingOptions Deserialize(string xml)
{
var serializer = new XmlSerializer(typeof(EncodingOptions));
using var reader = new StringReader(xml);
return (EncodingOptions)serializer.Deserialize(reader)!;
}
}