Merge pull request #17299 from Speenah/fix/hls-subtitle-timing

Fix fMP4 HLS subtitle timestamp map offset
This commit is contained in:
Speenah authored and GitHub committed 2026-10-13 19:43:53 +02:00
1 parent 34768404f7
commit e53a6d3e6a
5 files changed
+134 -11

No files matched your search

@@ -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;
}
}
@@ -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;
}
}
}