aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSpeenah <speenah@pm.me>2026-10-13 13:43:53 -0400
committerGitHub <noreply@github.com>2026-10-13 19:43:53 +0200
commite53a6d3e6ae29cb05c55c7b8edf2d237a1f75c16 (patch)
treedbb20b5519d0ba5954dfc02b03473c849d0eff1e /tests
parent34768404f7df0bd881ec853c8e5eb4489891688d (diff)
Merge pull request #17299 from Speenah/fix/hls-subtitle-timing
Fix fMP4 HLS subtitle timestamp map offset
Diffstat (limited to 'tests')
-rw-r--r--tests/Jellyfin.Api.Tests/Controllers/SubtitleControllerTests.cs40
-rw-r--r--tests/Jellyfin.Api.Tests/Helpers/DynamicHlsHelperTests.cs26
2 files changed, 66 insertions, 0 deletions
diff --git a/tests/Jellyfin.Api.Tests/Controllers/SubtitleControllerTests.cs b/tests/Jellyfin.Api.Tests/Controllers/SubtitleControllerTests.cs
index 77321f0b05..36b4e7156e 100644
--- a/tests/Jellyfin.Api.Tests/Controllers/SubtitleControllerTests.cs
+++ b/tests/Jellyfin.Api.Tests/Controllers/SubtitleControllerTests.cs
@@ -134,4 +134,44 @@ public class SubtitleControllerTests
fileSystem.Object,
NullLogger<SubtitleController>.Instance);
}
+
+ [Theory]
+ [MemberData(nameof(GetVttTimestampMap_Success_TestData))]
+ public static void GetVttTimestampMap_Success(long mpegTimestamp, string expected)
+ {
+ Assert.Equal(expected, SubtitleController.GetVttTimestampMap(mpegTimestamp));
+ }
+
+ public static TheoryData<long, string> GetVttTimestampMap_Success_TestData()
+ {
+ var data = new TheoryData<long, string>();
+ data.Add(900000, "X-TIMESTAMP-MAP=MPEGTS:900000,LOCAL:00:00:00.000");
+ data.Add(0, "X-TIMESTAMP-MAP=MPEGTS:0,LOCAL:00:00:00.000");
+ return data;
+ }
+
+ [Theory]
+ [MemberData(nameof(GetSubtitleSegmentUrl_Success_TestData))]
+ public static void GetSubtitleSegmentUrl_Success(long positionTicks, long endPositionTicks, string accessToken, long vttTimestampMapMpegts, string expected)
+ {
+ Assert.Equal(expected, SubtitleController.GetSubtitleSegmentUrl(positionTicks, endPositionTicks, accessToken, vttTimestampMapMpegts));
+ }
+
+ public static TheoryData<long, long, string, long, string> GetSubtitleSegmentUrl_Success_TestData()
+ {
+ var data = new TheoryData<long, long, string, long, string>();
+ data.Add(
+ 0,
+ 300000000,
+ "abc123",
+ 0,
+ "stream.vtt?CopyTimestamps=true&AddVttTimeMap=true&StartPositionTicks=0&EndPositionTicks=300000000&ApiKey=abc123&VttTimestampMapMpegts=0");
+ data.Add(
+ 300000000,
+ 600000000,
+ "abc123",
+ 900000,
+ "stream.vtt?CopyTimestamps=true&AddVttTimeMap=true&StartPositionTicks=300000000&EndPositionTicks=600000000&ApiKey=abc123&VttTimestampMapMpegts=900000");
+ return data;
+ }
}
diff --git a/tests/Jellyfin.Api.Tests/Helpers/DynamicHlsHelperTests.cs b/tests/Jellyfin.Api.Tests/Helpers/DynamicHlsHelperTests.cs
new file mode 100644
index 0000000000..d17ce0f896
--- /dev/null
+++ b/tests/Jellyfin.Api.Tests/Helpers/DynamicHlsHelperTests.cs
@@ -0,0 +1,26 @@
+using Jellyfin.Api.Helpers;
+using Xunit;
+
+namespace Jellyfin.Api.Tests.Helpers
+{
+ public static class DynamicHlsHelperTests
+ {
+ [Theory]
+ [MemberData(nameof(GetVttTimestampMapMpegts_Success_TestData))]
+ public static void GetVttTimestampMapMpegts_Success(string? segmentContainer, long expected)
+ {
+ Assert.Equal(expected, DynamicHlsHelper.GetVttTimestampMapMpegts(segmentContainer));
+ }
+
+ public static TheoryData<string?, long> GetVttTimestampMapMpegts_Success_TestData()
+ {
+ var data = new TheoryData<string?, long>();
+ data.Add(null, 900000);
+ data.Add(string.Empty, 900000);
+ data.Add("ts", 900000);
+ data.Add("mp4", 0);
+ data.Add("MP4", 0);
+ return data;
+ }
+ }
+}