mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 22:38:30 +01:00
Add hearing impaired subtitle stream indicator (#7379)
Co-authored-by: Claus Vium <cvium@users.noreply.github.com>
This commit is contained in:
@@ -65,6 +65,7 @@ namespace Jellyfin.MediaEncoding.Tests.Probing
|
||||
Assert.True(res.VideoStream.IsDefault);
|
||||
Assert.False(res.VideoStream.IsExternal);
|
||||
Assert.False(res.VideoStream.IsForced);
|
||||
Assert.False(res.VideoStream.IsHearingImpaired);
|
||||
Assert.False(res.VideoStream.IsInterlaced);
|
||||
Assert.False(res.VideoStream.IsTextSubtitleStream);
|
||||
Assert.Equal(13d, res.VideoStream.Level);
|
||||
@@ -142,16 +143,19 @@ namespace Jellyfin.MediaEncoding.Tests.Probing
|
||||
Assert.Equal(MediaStreamType.Subtitle, res.MediaStreams[3].Type);
|
||||
Assert.Equal("DVDSUB", res.MediaStreams[3].Codec);
|
||||
Assert.Null(res.MediaStreams[3].Title);
|
||||
Assert.False(res.MediaStreams[3].IsHearingImpaired);
|
||||
|
||||
Assert.Equal("eng", res.MediaStreams[4].Language);
|
||||
Assert.Equal(MediaStreamType.Subtitle, res.MediaStreams[4].Type);
|
||||
Assert.Equal("mov_text", res.MediaStreams[4].Codec);
|
||||
Assert.Null(res.MediaStreams[4].Title);
|
||||
Assert.True(res.MediaStreams[4].IsHearingImpaired);
|
||||
|
||||
Assert.Equal("eng", res.MediaStreams[5].Language);
|
||||
Assert.Equal(MediaStreamType.Subtitle, res.MediaStreams[5].Type);
|
||||
Assert.Equal("mov_text", res.MediaStreams[5].Codec);
|
||||
Assert.Equal("Commentary", res.MediaStreams[5].Title);
|
||||
Assert.False(res.MediaStreams[5].IsHearingImpaired);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -206,7 +206,7 @@
|
||||
"lyrics": 0,
|
||||
"karaoke": 0,
|
||||
"forced": 0,
|
||||
"hearing_impaired": 0,
|
||||
"hearing_impaired": 1,
|
||||
"visual_impaired": 0,
|
||||
"clean_effects": 0,
|
||||
"attached_pic": 0,
|
||||
|
||||
@@ -82,6 +82,19 @@ namespace Jellyfin.Model.Tests.Entities
|
||||
Codec = null
|
||||
});
|
||||
|
||||
data.Add(
|
||||
"Title - EN - Hearing Impaired - Default - Forced - SRT",
|
||||
new MediaStream
|
||||
{
|
||||
Type = MediaStreamType.Subtitle,
|
||||
Title = "Title",
|
||||
Language = "EN",
|
||||
IsForced = true,
|
||||
IsDefault = true,
|
||||
IsHearingImpaired = true,
|
||||
Codec = "SRT"
|
||||
});
|
||||
|
||||
data.Add(
|
||||
"Title - AAC - Default - External",
|
||||
new MediaStream
|
||||
|
||||
@@ -17,12 +17,15 @@ public class ExternalPathParserTests
|
||||
{
|
||||
var englishCultureDto = new CultureDto("English", "English", "en", new[] { "eng" });
|
||||
var frenchCultureDto = new CultureDto("French", "French", "fr", new[] { "fre", "fra" });
|
||||
var hindiCultureDto = new CultureDto("Hindi", "Hindi", "hi", new[] { "hin" });
|
||||
|
||||
var localizationManager = new Mock<ILocalizationManager>(MockBehavior.Loose);
|
||||
localizationManager.Setup(lm => lm.FindLanguageInfo(It.IsRegex(@"en.*", RegexOptions.IgnoreCase)))
|
||||
.Returns(englishCultureDto);
|
||||
localizationManager.Setup(lm => lm.FindLanguageInfo(It.IsRegex(@"fr.*", RegexOptions.IgnoreCase)))
|
||||
.Returns(frenchCultureDto);
|
||||
localizationManager.Setup(lm => lm.FindLanguageInfo(It.IsRegex(@"hi.*", RegexOptions.IgnoreCase)))
|
||||
.Returns(hindiCultureDto);
|
||||
|
||||
_audioPathParser = new ExternalPathParser(new NamingOptions(), localizationManager.Object, DlnaProfileType.Audio);
|
||||
_subtitlePathParser = new ExternalPathParser(new NamingOptions(), localizationManager.Object, DlnaProfileType.Subtitle);
|
||||
@@ -89,6 +92,7 @@ public class ExternalPathParserTests
|
||||
[InlineData(".DEFAULT.FORCED", null, null, true, true)]
|
||||
[InlineData(".en", null, "eng")]
|
||||
[InlineData(".EN", null, "eng")]
|
||||
[InlineData(".hi", null, "hin")]
|
||||
[InlineData(".fr.en", "fr", "eng")]
|
||||
[InlineData(".en.fr", "en", "fre")]
|
||||
[InlineData(".title.en.fr", "title.en", "fre")]
|
||||
@@ -96,7 +100,11 @@ public class ExternalPathParserTests
|
||||
[InlineData(".Title.with.Separator", "Title.with.Separator", null)]
|
||||
[InlineData(".title.en.default.forced", "title", "eng", true, true)]
|
||||
[InlineData(".forced.default.en.title", "title", "eng", true, true)]
|
||||
public void ParseFile_ExtraTokens_ParseToValues(string tokens, string? title, string? language, bool isDefault = false, bool isForced = false)
|
||||
[InlineData(".sdh.en.title", "title", "eng", false, false, true)]
|
||||
[InlineData(".en.cc.title", "title", "eng", false, false, true)]
|
||||
[InlineData(".hi.en.title", "title", "eng", false, false, true)]
|
||||
[InlineData(".en.hi.title", "title", "eng", false, false, true)]
|
||||
public void ParseFile_ExtraTokens_ParseToValues(string tokens, string? title, string? language, bool isDefault = false, bool isForced = false, bool isHearingImpaired = false)
|
||||
{
|
||||
var path = "My.Video" + tokens + ".srt";
|
||||
|
||||
@@ -107,5 +115,6 @@ public class ExternalPathParserTests
|
||||
Assert.Equal(language, actual.Language);
|
||||
Assert.Equal(isDefault, actual.IsDefault);
|
||||
Assert.Equal(isForced, actual.IsForced);
|
||||
Assert.Equal(isHearingImpaired, actual.IsHearingImpaired);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ public class MediaInfoResolverTests
|
||||
});
|
||||
|
||||
// filename has metadata
|
||||
file = "My.Video.Title1.default.forced.en.srt";
|
||||
file = "My.Video.Title1.default.forced.sdh.en.srt";
|
||||
data.Add(
|
||||
file,
|
||||
new[]
|
||||
@@ -236,7 +236,7 @@ public class MediaInfoResolverTests
|
||||
},
|
||||
new[]
|
||||
{
|
||||
CreateMediaStream(VideoDirectoryPath + "/" + file, "eng", "Title1", 0, true, true)
|
||||
CreateMediaStream(VideoDirectoryPath + "/" + file, "eng", "Title1", 0, true, true, true)
|
||||
});
|
||||
|
||||
// single stream with metadata
|
||||
@@ -245,15 +245,15 @@ public class MediaInfoResolverTests
|
||||
file,
|
||||
new[]
|
||||
{
|
||||
CreateMediaStream(VideoDirectoryPath + "/" + file, "eng", "Title", 0, true, true)
|
||||
CreateMediaStream(VideoDirectoryPath + "/" + file, "eng", "Title", 0, true, true, true)
|
||||
},
|
||||
new[]
|
||||
{
|
||||
CreateMediaStream(VideoDirectoryPath + "/" + file, "eng", "Title", 0, true, true)
|
||||
CreateMediaStream(VideoDirectoryPath + "/" + file, "eng", "Title", 0, true, true, true)
|
||||
});
|
||||
|
||||
// stream wins for title/language, filename wins for flags when conflicting
|
||||
file = "My.Video.Title2.default.forced.en.srt";
|
||||
file = "My.Video.Title2.default.forced.sdh.en.srt";
|
||||
data.Add(
|
||||
file,
|
||||
new[]
|
||||
@@ -262,7 +262,7 @@ public class MediaInfoResolverTests
|
||||
},
|
||||
new[]
|
||||
{
|
||||
CreateMediaStream(VideoDirectoryPath + "/" + file, "fra", "Metadata", 0, true, true)
|
||||
CreateMediaStream(VideoDirectoryPath + "/" + file, "fra", "Metadata", 0, true, true, true)
|
||||
});
|
||||
|
||||
// multiple stream with metadata - filename flags ignored but other data filled in when missing from stream
|
||||
@@ -324,6 +324,7 @@ public class MediaInfoResolverTests
|
||||
Assert.Equal(expected.Path, actual.Path);
|
||||
Assert.Equal(expected.IsDefault, actual.IsDefault);
|
||||
Assert.Equal(expected.IsForced, actual.IsForced);
|
||||
Assert.Equal(expected.IsHearingImpaired, actual.IsHearingImpaired);
|
||||
Assert.Equal(expected.Language, actual.Language);
|
||||
Assert.Equal(expected.Title, actual.Title);
|
||||
}
|
||||
@@ -396,7 +397,7 @@ public class MediaInfoResolverTests
|
||||
}
|
||||
}
|
||||
|
||||
private static MediaStream CreateMediaStream(string path, string? language, string? title, int index, bool isForced = false, bool isDefault = false)
|
||||
private static MediaStream CreateMediaStream(string path, string? language, string? title, int index, bool isForced = false, bool isDefault = false, bool isHearingImpaired = false)
|
||||
{
|
||||
return new MediaStream
|
||||
{
|
||||
@@ -405,6 +406,7 @@ public class MediaInfoResolverTests
|
||||
Path = path,
|
||||
IsDefault = isDefault,
|
||||
IsForced = isForced,
|
||||
IsHearingImpaired = isHearingImpaired,
|
||||
Language = language,
|
||||
Title = title
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user