summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF/Services/Scan/LibScan.cs')
-rw-r--r--win/CS/HandBrakeWPF/Services/Scan/LibScan.cs83
1 files changed, 4 insertions, 79 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
index d17a5d3c9..598758073 100644
--- a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
+++ b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
@@ -26,6 +26,7 @@ namespace HandBrakeWPF.Services.Scan
using HandBrakeWPF.Services.Encode.Model;
using HandBrakeWPF.Services.Encode.Model.Models;
using HandBrakeWPF.Services.Scan.EventArgs;
+ using HandBrakeWPF.Services.Scan.Factories;
using HandBrakeWPF.Services.Scan.Interfaces;
using HandBrakeWPF.Services.Scan.Model;
using HandBrakeWPF.Utilities;
@@ -47,6 +48,7 @@ namespace HandBrakeWPF.Services.Scan
#region Private Variables
private readonly ILog log = LogService.GetLogger();
+ private TitleFactory titleFactory = new TitleFactory();
private string currentSourceScanPath;
private IHandBrakeInstance instance;
private Action<bool, Source> postScanOperation;
@@ -365,89 +367,12 @@ namespace HandBrakeWPF.Services.Scan
/// <returns>
/// The convert titles.
/// </returns>
- private static List<Title> ConvertTitles(JsonScanObject titles)
+ private List<Title> ConvertTitles(JsonScanObject titles)
{
List<Title> titleList = new List<Title>();
foreach (SourceTitle title in titles.TitleList)
{
- Title converted = new Title
- {
- TitleNumber = title.Index,
- Duration = new TimeSpan(0, title.Duration.Hours, title.Duration.Minutes, title.Duration.Seconds),
- Resolution = new Size(title.Geometry.Width, title.Geometry.Height),
- AngleCount = title.AngleCount,
- ParVal = new Size(title.Geometry.PAR.Num, title.Geometry.PAR.Den),
- AutoCropDimensions = new Cropping
- {
- Top = title.Crop[0],
- Bottom = title.Crop[1],
- Left = title.Crop[2],
- Right = title.Crop[3]
- },
- Fps = ((double)title.FrameRate.Num) / title.FrameRate.Den,
- SourceName = title.Path,
- MainTitle = titles.MainFeature == title.Index,
- Playlist = title.Type == 1 ? string.Format(" {0:d5}.MPLS", title.Playlist).Trim() : null,
- FramerateNumerator = title.FrameRate.Num,
- FramerateDenominator = title.FrameRate.Den,
- Type = title.Type
- };
-
- int currentTrack = 1;
- foreach (SourceChapter chapter in title.ChapterList)
- {
- string chapterName = !string.IsNullOrEmpty(chapter.Name) ? chapter.Name : string.Empty;
- converted.Chapters.Add(new Chapter(currentTrack, chapterName, new TimeSpan(chapter.Duration.Hours, chapter.Duration.Minutes, chapter.Duration.Seconds)));
- currentTrack++;
- }
-
- int currentAudioTrack = 1;
- foreach (SourceAudioTrack track in title.AudioList)
- {
- converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, track.Codec, track.SampleRate, track.BitRate, track.ChannelLayout));
- currentAudioTrack++;
- }
-
- int currentSubtitleTrack = 1;
- foreach (SourceSubtitleTrack track in title.SubtitleList)
- {
- SubtitleType convertedType = new SubtitleType();
-
- switch (track.Source)
- {
- case 0:
- convertedType = SubtitleType.VobSub;
- break;
- case 4:
- convertedType = SubtitleType.UTF8Sub;
- break;
- case 5:
- convertedType = SubtitleType.TX3G;
- break;
- case 6:
- convertedType = SubtitleType.SSA;
- break;
- case 1:
- convertedType = SubtitleType.SRT;
- break;
- case 2:
- convertedType = SubtitleType.CC;
- break;
- case 3:
- convertedType = SubtitleType.CC;
- break;
- case 7:
- convertedType = SubtitleType.PGS;
- break;
- }
-
- bool canBurn = HBFunctions.hb_subtitle_can_burn(track.Source) > 0;
- bool canSetForcedOnly = HBFunctions.hb_subtitle_can_force(track.Source) > 0;
-
- converted.Subtitles.Add(new Subtitle(track.Source, currentSubtitleTrack, track.Language, track.LanguageCode, convertedType, canBurn, canSetForcedOnly));
- currentSubtitleTrack++;
- }
-
+ Title converted = this.titleFactory.CreateTitle(title, titles.MainFeature);
titleList.Add(converted);
}