-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
namespace Tricycle.Models.Jobs | ||
{ | ||
public class SubtitleOutputStream : TranscodedOutputStream<SubtitleFormat> | ||
{ | ||
public SubtitleOutputStream() | ||
{ | ||
} | ||
|
||
public SubtitleOutputStream(SubtitleFormat format) | ||
{ | ||
Format = format; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
namespace Tricycle.Models | ||
{ | ||
public enum SubtitleFormat | ||
{ | ||
Dvb, | ||
Dvd, | ||
Pgs, | ||
Ssa, | ||
Subrip, | ||
TimedText, | ||
WebVtt | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Tricycle.Models; | ||
|
||
namespace Tricycle.Utilities.Tests | ||
{ | ||
[TestClass] | ||
public class SubtitleUtilityTests | ||
{ | ||
[TestMethod] | ||
public void TestIsSupportedByContainer() | ||
{ | ||
foreach (SubtitleFormat subtitleFormat in Enum.GetValues(typeof(SubtitleFormat))) | ||
{ | ||
var isSupported = SubtitleUtility.IsSupportedByContainer(ContainerFormat.Mkv, subtitleFormat); | ||
|
||
Assert.AreEqual(subtitleFormat != SubtitleFormat.TimedText, isSupported); | ||
|
||
isSupported = SubtitleUtility.IsSupportedByContainer(ContainerFormat.Mp4, subtitleFormat); | ||
|
||
Assert.AreEqual(subtitleFormat == SubtitleFormat.TimedText, isSupported); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using Tricycle.Models; | ||
|
||
namespace Tricycle.Utilities | ||
{ | ||
public static class SubtitleUtility | ||
{ | ||
public static bool IsSupportedByContainer(ContainerFormat containerFormat, SubtitleFormat subtitleFormat) | ||
{ | ||
switch (containerFormat) | ||
{ | ||
case ContainerFormat.Mkv: | ||
switch (subtitleFormat) | ||
{ | ||
case SubtitleFormat.Dvb: | ||
case SubtitleFormat.Dvd: | ||
case SubtitleFormat.Pgs: | ||
case SubtitleFormat.Ssa: | ||
case SubtitleFormat.Subrip: | ||
case SubtitleFormat.WebVtt: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
case ContainerFormat.Mp4: | ||
switch (subtitleFormat) | ||
{ | ||
case SubtitleFormat.TimedText: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
default: | ||
return false; | ||
} | ||
} | ||
} | ||
} |