diff options
author | sr55 <[email protected]> | 2015-03-06 22:36:10 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-03-06 22:36:10 +0000 |
commit | 27a40c0299e0545d1b92ab12a5508c5f4ffb9b8b (patch) | |
tree | c8c8591aac41588c5c4e3cf0d3fdcd1de992f5dd /win/CS | |
parent | 01eabb2d314372bb301c3468d53840994105c652 (diff) |
WinGui: Stripping out a lot of legacy abstraction code for the scan service.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6971 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS')
18 files changed, 80 insertions, 808 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index bc2f23f27..91228fdae 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -143,7 +143,6 @@ <Compile Include="Interop\Json\Encode\Video.cs" />
<Compile Include="Interop\Factories\AnamorphicFactory.cs" />
<Compile Include="Services\Encode\Factories\EncodeFactory.cs" />
- <Compile Include="Interop\Factories\ScanFactory.cs" />
<Compile Include="Interop\Json\Scan\AudioList.cs" />
<Compile Include="Interop\Json\Scan\ChapterList.cs" />
<Compile Include="Interop\Json\Scan\Color.cs" />
@@ -182,12 +181,6 @@ <Compile Include="Interop\Model\Language.cs" />
<Compile Include="Interop\Model\Preview\PreviewSettings.cs" />
<Compile Include="Interop\Model\RangeLimits.cs" />
- <Compile Include="Interop\Model\Scan\AudioTrack.cs" />
- <Compile Include="Interop\Model\Scan\Chapter.cs" />
- <Compile Include="Interop\Model\Scan\InputType.cs" />
- <Compile Include="Interop\Model\Scan\Subtitle.cs" />
- <Compile Include="Interop\Model\Scan\SubtitleSource.cs" />
- <Compile Include="Interop\Model\Scan\Title.cs" />
<Compile Include="Interop\Model\Size.cs" />
<Compile Include="Interop\Model\SourceVideoInfo.cs" />
<Compile Include="Interop\Model\VideoQualityLimits.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Factories/ScanFactory.cs b/win/CS/HandBrake.ApplicationServices/Interop/Factories/ScanFactory.cs deleted file mode 100644 index e2ac0f3cb..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Factories/ScanFactory.cs +++ /dev/null @@ -1,221 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="ScanFactory.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The scan factory.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Factories
-{
- using System;
- using System.Collections.Generic;
-
- using HandBrake.ApplicationServices.Interop.Json.Scan;
- using HandBrake.ApplicationServices.Interop.Model;
- using HandBrake.ApplicationServices.Interop.Model.Scan;
-
- /// <summary>
- /// This factory takes the JSON objects deserialized from libhb for the scan information
- /// and converts them into the internal Title objects.
- /// </summary>
- internal class ScanFactory
- {
- /// <summary>
- /// The create title set.
- /// </summary>
- /// <param name="scan">
- /// The scan.
- /// </param>
- /// <returns>
- /// The <see cref="IEnumerable"/>.
- /// </returns>
- internal static IEnumerable<Title> CreateTitleSet(JsonScanObject scan)
- {
- List<Title> titles = new List<Title>();
-
- if (scan != null)
- {
- foreach (TitleList item in scan.TitleList)
- {
- Title title = CreateTitle(item);
-
- if (title.TitleNumber == scan.MainFeature)
- {
- title.IsMainFeature = true;
- }
-
- titles.Add(title);
- }
- }
-
- return titles;
- }
-
- /// <summary>
- /// The create title.
- /// </summary>
- /// <param name="title">
- /// The title.
- /// </param>
- /// <returns>
- /// The <see cref="Title"/>.
- /// </returns>
- private static Title CreateTitle(TitleList title)
- {
- Title newTitle = new Title
- {
- TitleNumber = title.Index,
- Playlist = title.Playlist,
- Resolution = new Size(title.Geometry.Width, title.Geometry.Height),
- ParVal = new Size(title.Geometry.PAR.Num, title.Geometry.PAR.Den),
- Duration = new TimeSpan(title.Duration.Hours, title.Duration.Minutes, title.Duration.Seconds),
- AutoCropDimensions = new Cropping
- {
- Top = title.Crop[0],
- Bottom = title.Crop[1],
- Left = title.Crop[2],
- Right = title.Crop[3]
- },
- AngleCount = title.AngleCount,
- VideoCodecName = title.VideoCodec,
- Framerate = ((double)title.FrameRate.Num) / title.FrameRate.Den,
- FramerateNumerator = title.FrameRate.Num,
- FramerateDenominator = title.FrameRate.Den,
- Path = title.Path
- };
-
- switch (title.Type)
- {
- case 2:
- newTitle.InputType = InputType.Stream;
- break;
- case 0:
- newTitle.InputType = InputType.Dvd;
- break;
- case 1:
- newTitle.InputType = InputType.Bluray;
- break;
- case 3:
- newTitle.InputType = InputType.FFStream;
- break;
- }
-
- foreach (Subtitle subtitleTrack in CreateSubtitleTracks(title.SubtitleList))
- {
- newTitle.Subtitles.Add(subtitleTrack);
- }
-
- foreach (AudioTrack audioTrack in CreateAudioTracks(title.AudioList))
- {
- newTitle.AudioTracks.Add(audioTrack);
- }
-
- foreach (Chapter chapter in CreateChapters(title.ChapterList))
- {
- newTitle.Chapters.Add(chapter);
- }
-
- return newTitle;
- }
-
- /// <summary>
- /// The create subtitle tracks.
- /// </summary>
- /// <param name="subtitles">
- /// The subtitles.
- /// </param>
- /// <returns>
- /// The <see cref="IEnumerable"/>.
- /// </returns>
- private static IEnumerable<Subtitle> CreateSubtitleTracks(IEnumerable<SubtitleList> subtitles)
- {
- List<Subtitle> subtiles = new List<Subtitle>();
-
- int currentSubtitleTrack = 1;
- foreach (SubtitleList subtitle in subtitles)
- {
- Subtitle newSubtitle = new Subtitle
- {
- TrackNumber = currentSubtitleTrack,
- Language = subtitle.Language,
- LanguageCode = subtitle.LanguageCode,
- SubtitleSourceInt = subtitle.Source,
- SubtitleSource = (SubtitleSource)subtitle.Source // TODO Check correct
- };
-
- subtiles.Add(newSubtitle);
-
- currentSubtitleTrack++;
- }
-
- return subtiles;
- }
-
- /// <summary>
- /// The create audio tracks.
- /// </summary>
- /// <param name="audioTracks">
- /// The audio tracks.
- /// </param>
- /// <returns>
- /// The <see cref="IEnumerable"/>.
- /// </returns>
- private static IEnumerable<AudioTrack> CreateAudioTracks(IEnumerable<AudioList> audioTracks)
- {
- List<AudioTrack> tracks = new List<AudioTrack>();
-
- int currentAudioTrack = 1;
- foreach (AudioList track in audioTracks)
- {
- AudioTrack newAudio = new AudioTrack
- {
- TrackNumber = currentAudioTrack,
- CodecId = Convert.ToUInt32(track.Codec),
- Language = track.Language,
- LanguageCode = track.LanguageCode,
- Description = track.Description,
- ChannelLayout = (ulong)track.ChannelLayout,
- SampleRate = track.SampleRate,
- Bitrate = track.BitRate
- };
-
- tracks.Add(newAudio);
-
- currentAudioTrack++;
- }
- return tracks;
- }
-
- /// <summary>
- /// The create chapters.
- /// </summary>
- /// <param name="chapters">
- /// The chapters.
- /// </param>
- /// <returns>
- /// The <see cref="IEnumerable"/>.
- /// </returns>
- private static IEnumerable<Chapter> CreateChapters(IEnumerable<ChapterList> chapters)
- {
- List<Chapter> tracks = new List<Chapter>();
-
- int currentTrack = 1;
- foreach (ChapterList chapter in chapters)
- {
- Chapter newChapter = new Chapter
- {
- Name = chapter.Name,
- ChapterNumber = currentTrack,
- Duration = new TimeSpan(chapter.Duration.Hours, chapter.Duration.Minutes, chapter.Duration.Seconds)
- };
-
- tracks.Add(newChapter);
- currentTrack++;
- }
-
- return tracks;
- }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs index 35d278a4a..714de6547 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs @@ -1,5 +1,5 @@ // --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Encoders.cs" company="HandBrake Project (http://handbrake.fr)">
+// <copyright file="HandBrakeEncoderHelpers.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
@@ -17,7 +17,6 @@ namespace HandBrake.ApplicationServices.Interop using HandBrake.ApplicationServices.Interop.Helpers;
using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
- using HandBrake.ApplicationServices.Interop.Model.Scan;
/// <summary>
/// The encoders.
@@ -263,8 +262,8 @@ namespace HandBrake.ApplicationServices.Interop /// <summary>
/// Determines if the given encoder is compatible with the given track.
/// </summary>
- /// <param name="track">
- /// The audio track to examine.
+ /// <param name="codecId">
+ /// The codec Id.
/// </param>
/// <param name="encoder">
/// The encoder to examine.
@@ -275,9 +274,9 @@ namespace HandBrake.ApplicationServices.Interop /// <remarks>
/// Only works with passthrough encoders.
/// </remarks>
- public static bool AudioEncoderIsCompatible(AudioTrack track, HBAudioEncoder encoder)
+ public static bool AudioEncoderIsCompatible(int codecId, HBAudioEncoder encoder)
{
- return (track.CodecId & encoder.Id) > 0;
+ return (codecId & encoder.Id) > 0;
}
/// <summary>
@@ -317,8 +316,8 @@ namespace HandBrake.ApplicationServices.Interop /// <summary>
/// Determines if DRC can be applied to the given track with the given encoder.
/// </summary>
- /// <param name="track">
- /// The track to apply DRC to.
+ /// <param name="trackNumber">
+ /// The track Number.
/// </param>
/// <param name="encoder">
/// The encoder to use for DRC.
@@ -329,9 +328,9 @@ namespace HandBrake.ApplicationServices.Interop /// <returns>
/// True if DRC can be applied to the track with the given encoder.
/// </returns>
- public static bool CanApplyDrc(AudioTrack track, HBAudioEncoder encoder, int title)
+ public static bool CanApplyDrc(int trackNumber, HBAudioEncoder encoder, int title)
{
- return HBFunctions.hb_audio_can_apply_drc2(HandBrakeInstanceManager.LastScanHandle, title, track.TrackNumber, encoder.Id) > 0;
+ return HBFunctions.hb_audio_can_apply_drc2(HandBrakeInstanceManager.LastScanHandle, title, trackNumber, encoder.Id) > 0;
}
/// <summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs index 3da06d58d..719119cc0 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs @@ -32,11 +32,11 @@ namespace HandBrake.ApplicationServices.Interop using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
using HandBrake.ApplicationServices.Interop.Model.Preview;
- using HandBrake.ApplicationServices.Interop.Model.Scan;
using Newtonsoft.Json;
using Geometry = HandBrake.ApplicationServices.Interop.Json.Anamorphic.Geometry;
+ using Size = HandBrake.ApplicationServices.Interop.Model.Size;
/// <summary>
/// A wrapper for a HandBrake instance.
@@ -71,7 +71,7 @@ namespace HandBrake.ApplicationServices.Interop /// <summary>
/// The list of titles on this instance.
/// </summary>
- private List<Title> titles;
+ private JsonScanObject titles;
/// <summary>
/// The index of the default title.
@@ -125,7 +125,7 @@ namespace HandBrake.ApplicationServices.Interop /// <summary>
/// Gets the list of titles on this instance.
/// </summary>
- public List<Title> Titles
+ public JsonScanObject Titles
{
get
{
@@ -247,7 +247,7 @@ namespace HandBrake.ApplicationServices.Interop [HandleProcessCorruptedStateExceptions]
public BitmapImage GetPreview(PreviewSettings job, int previewNumber)
{
- Title title = this.Titles.FirstOrDefault(t => t.TitleNumber == job.Title);
+ TitleList title = this.Titles.TitleList.FirstOrDefault(t => t.Index == job.Title);
Validate.NotNull(title, "GetPreview: Title should not have been null. This is probably a bug.");
// Creat the Expected Output Geometry details for libhb.
@@ -265,13 +265,13 @@ namespace HandBrake.ApplicationServices.Interop height = job.Height ?? 0,
width = job.Width ?? 0,
par = job.Anamorphic != Anamorphic.Custom
- ? new hb_rational_t { den = title.ParVal.Height, num = title.ParVal.Width }
+ ? new hb_rational_t { den = title.Geometry.PAR.Den, num = title.Geometry.PAR.Num }
: new hb_rational_t { den = job.PixelAspectY, num = job.PixelAspectX }
}
};
// Sanatise the input.
- Geometry resultGeometry = AnamorphicFactory.CreateGeometry(job, new SourceVideoInfo(title.FramerateNumerator, title.FramerateDenominator, title.Resolution, title.ParVal), AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH); // TODO this keep isn't right.
+ Geometry resultGeometry = AnamorphicFactory.CreateGeometry(job, new SourceVideoInfo(null, null, new Size(title.Geometry.Width, title.Geometry.Height), new Size(title.Geometry.PAR.Num, title.Geometry.PAR.Den)), AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH); // TODO this keep isn't right.
int width = resultGeometry.Width * resultGeometry.PAR.Num / resultGeometry.PAR.Den;
int height = resultGeometry.Height;
uiGeometry.geometry.height = resultGeometry.Height; // Prased the height now.
@@ -344,11 +344,8 @@ namespace HandBrake.ApplicationServices.Interop /// <param name="encodeObject">
/// The encode Object.
/// </param>
- /// <param name="title">
- /// The title.
- /// </param>
[HandleProcessCorruptedStateExceptions]
- public void StartEncode(JsonEncodeObject encodeObject, Title title)
+ public void StartEncode(JsonEncodeObject encodeObject)
{
JsonSerializerSettings settings = new JsonSerializerSettings
{
@@ -479,21 +476,10 @@ namespace HandBrake.ApplicationServices.Interop }
else if (state != null && state.State == NativeConstants.HB_STATE_SCANDONE)
{
- this.titles = new List<Title>();
-
var jsonMsg = HBFunctions.hb_get_title_set_json(this.hbHandle);
-
string scanJson = InteropUtilities.ToStringFromUtf8Ptr(jsonMsg);
-
- JsonScanObject scanObject = JsonConvert.DeserializeObject<JsonScanObject>(scanJson);
-
- foreach (Title title in ScanFactory.CreateTitleSet(scanObject))
- {
- // Set the Main Title.
- this.featureTitle = title.IsMainFeature ? title.TitleNumber : 0;
-
- this.titles.Add(title);
- }
+ this.titles = JsonConvert.DeserializeObject<JsonScanObject>(scanJson);
+ this.featureTitle = this.titles.MainFeature;
this.scanPollTimer.Stop();
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs index 138eed367..577fbf0e6 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs @@ -16,9 +16,6 @@ namespace HandBrake.ApplicationServices.Interop using HandBrake.ApplicationServices.Interop.EventArgs;
using HandBrake.ApplicationServices.Interop.HbLib;
- using HandBrake.ApplicationServices.Interop.Model;
- using HandBrake.ApplicationServices.Interop.Model.Encoding;
- using HandBrake.ApplicationServices.Interop.Model.Scan;
/// <summary>
/// HandBrake Interop Utilities
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Interfaces/IHandBrakeInstance.cs b/win/CS/HandBrake.ApplicationServices/Interop/Interfaces/IHandBrakeInstance.cs index 48be6bc40..8230e6620 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Interfaces/IHandBrakeInstance.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Interfaces/IHandBrakeInstance.cs @@ -10,14 +10,12 @@ namespace HandBrake.ApplicationServices.Interop.Interfaces
{
using System;
- using System.Collections.Generic;
using System.Windows.Media.Imaging;
using HandBrake.ApplicationServices.Interop.EventArgs;
using HandBrake.ApplicationServices.Interop.Json.Encode;
- using HandBrake.ApplicationServices.Interop.Model;
+ using HandBrake.ApplicationServices.Interop.Json.Scan;
using HandBrake.ApplicationServices.Interop.Model.Preview;
- using HandBrake.ApplicationServices.Interop.Model.Scan;
/// <summary>
/// The Interface for HandBrakeInstance
@@ -58,7 +56,7 @@ namespace HandBrake.ApplicationServices.Interop.Interfaces /// <summary>
/// Gets the list of titles on this instance.
/// </summary>
- List<Title> Titles { get; }
+ JsonScanObject Titles { get; }
#endregion
@@ -67,7 +65,9 @@ namespace HandBrake.ApplicationServices.Interop.Interfaces /// <summary>
/// Initializes this instance.
/// </summary>
- /// <param name="verbosity">The code for the logging verbosity to use.</param>
+ /// <param name="verbosity">
+ /// The code for the logging verbosity to use.
+ /// </param>
void Initialize(int verbosity);
/// <summary>
@@ -108,10 +108,7 @@ namespace HandBrake.ApplicationServices.Interop.Interfaces /// <param name="jobToStart">
/// The job to start.
/// </param>
- /// <param name="title">
- /// The title.
- /// </param>
- void StartEncode(JsonEncodeObject jobToStart, Title title);
+ void StartEncode(JsonEncodeObject jobToStart);
/// <summary>
/// Starts a scan of the given path.
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/PAR.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/PAR.cs index bfe647ab8..2eca81fc6 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/PAR.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/PAR.cs @@ -15,12 +15,12 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan internal class PAR
{
/// <summary>
- /// Gets or sets the height.
+ /// Gets or sets the width.
/// </summary>
public int Num { get; set; }
/// <summary>
- /// Gets or sets the width.
+ /// Gets or sets the height.
/// </summary>
public int Den { get; set; }
}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/TitleList.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/TitleList.cs index b31dd4e05..f6668eb24 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/TitleList.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/TitleList.cs @@ -93,7 +93,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// <summary>
/// Gets or sets the type.
- /// HB_DVD_TYPE, HB_BD_TYPE, HB_STREAM_TYPE, HB_FF_STREAM_TYPE
+ /// HB_DVD_TYPE = 0, HB_BD_TYPE, HB_STREAM_TYPE, HB_FF_STREAM_TYPE
/// </summary>
public int Type { get; set; }
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/AudioTrack.cs deleted file mode 100644 index 527b3c4f6..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/AudioTrack.cs +++ /dev/null @@ -1,107 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="AudioTrack.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// An object represending an AudioTrack associated with a Title, in a DVD
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Model.Scan
-{
- /// <summary>
- /// An object represending an AudioTrack associated with a Title, in a DVD
- /// </summary>
- public class AudioTrack
- {
- /// <summary>
- /// Gets or sets the track number of this Audio Track
- /// </summary>
- public int TrackNumber { get; set; }
-
- /// <summary>
- /// Gets or sets the audio codec ID for this track.
- /// </summary>
- public uint CodecId { get; set; }
-
- /// <summary>
- /// Gets or sets the language (if detected) of this Audio Track
- /// </summary>
- public string Language { get; set; }
-
- /// <summary>
- /// Gets or sets the language code for this audio track.
- /// </summary>
- public string LanguageCode { get; set; }
-
- /// <summary>
- /// Gets or sets the description for this audio track.
- /// </summary>
- public string Description { get; set; }
-
- /// <summary>
- /// Gets or sets the channel layout of this Audio Track.
- /// </summary>
- public ulong ChannelLayout { get; set; }
-
- /// <summary>
- /// Gets or sets the frequency (in Hz) of this Audio Track
- /// </summary>
- public int SampleRate { get; set; }
-
- /// <summary>
- /// Gets or sets the bitrate (in bits/sec) of this Audio Track.
- /// </summary>
- public int Bitrate { get; set; }
-
- /// <summary>
- /// Gets the display string for this audio track.
- /// </summary>
- public string Display
- {
- get
- {
- return this.GetDisplayString(true);
- }
- }
-
- /// <summary>
- /// Gets the display string for this audio track (not including track number)
- /// </summary>
- public string NoTrackDisplay
- {
- get
- {
- return this.GetDisplayString(false);
- }
- }
-
- /// <summary>
- /// Override of the ToString method to make this object easier to use in the UI
- /// </summary>
- /// <returns>A string formatted as: {track #} {language} ({format}) ({sub-format})</returns>
- public override string ToString()
- {
- return this.GetDisplayString(true);
- }
-
- /// <summary>
- /// The get display string.
- /// </summary>
- /// <param name="includeTrackNumber">
- /// The include track number.
- /// </param>
- /// <returns>
- /// The <see cref="string"/>.
- /// </returns>
- private string GetDisplayString(bool includeTrackNumber)
- {
- if (includeTrackNumber)
- {
- return this.TrackNumber + " " + this.Description;
- }
-
- return this.Description;
- }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/Chapter.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/Chapter.cs deleted file mode 100644 index 720906059..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/Chapter.cs +++ /dev/null @@ -1,44 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Chapter.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// An object representing a Chapter aosciated with a Title, in a DVD
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Model.Scan
-{
- using System;
- using System.Globalization;
-
- /// <summary>
- /// An object representing a Chapter aosciated with a Title, in a DVD
- /// </summary>
- public class Chapter
- {
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Gets or sets the number of this Chapter, in regards to its parent Title
- /// </summary>
- public int ChapterNumber { get; set; }
-
- /// <summary>
- /// Gets or sets the duration of this chapter.
- /// </summary>
- public TimeSpan Duration { get; set; }
-
- /// <summary>
- /// Override of the ToString method to make this object easier to use in the UI
- /// </summary>
- /// <returns>A string formatted as: {chapter #}</returns>
- public override string ToString()
- {
- return this.ChapterNumber.ToString(CultureInfo.InvariantCulture);
- }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/InputType.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/InputType.cs deleted file mode 100644 index 4366d5a74..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/InputType.cs +++ /dev/null @@ -1,31 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="InputType.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Defines the InputType type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Model.Scan
-{
- using System.ComponentModel.DataAnnotations;
-
- /// <summary>
- /// The input type.
- /// </summary>
- public enum InputType
- {
- [Display(Name = "File")]
- Stream,
-
- [Display(Name = "DVD")]
- Dvd,
-
- [Display(Name = "Blu-ray")]
- Bluray,
-
- [Display(Name = "File")]
- FFStream
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/Subtitle.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/Subtitle.cs deleted file mode 100644 index 6f8a5b027..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/Subtitle.cs +++ /dev/null @@ -1,96 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Subtitle.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// An object that represents a subtitle associated with a Title, in a DVD
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Model.Scan
-{
- using HandBrake.ApplicationServices.Interop.HbLib;
-
- /// <summary>
- /// An object that represents a subtitle associated with a Title, in a DVD
- /// </summary>
- public class Subtitle
- {
- /// <summary>
- /// Gets or sets the track number of this Subtitle
- /// </summary>
- public int TrackNumber { get; set; }
-
- /// <summary>
- /// Gets or sets the language (if detected) of this Subtitle
- /// </summary>
- public string Language { get; set; }
-
- /// <summary>
- /// Gets or sets the Langauage Code.
- /// </summary>
- public string LanguageCode { get; set; }
-
- /// <summary>
- /// Gets or sets the subtitle source.
- /// </summary>
- public SubtitleSource SubtitleSource { get; set; }
-
- /// <summary>
- /// Gets or sets the subtitle source raw integer.
- /// </summary>
- public int SubtitleSourceInt { get; set; }
-
- /// <summary>
- /// Gets a value indicating whether the "forced only" flag can be set on this subtitle.
- /// </summary>
- public bool CanSetForcedOnly
- {
- get
- {
- return HBFunctions.hb_subtitle_can_force(this.SubtitleSourceInt) > 0;
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether this subtitle can be burned into the picture.
- /// </summary>
- public bool CanBurn
- {
- get
- {
- return HBFunctions.hb_subtitle_can_burn(this.SubtitleSourceInt) > 0;
- }
- }
-
- /// <summary>
- /// Returns true if the subtitle can be passed through using the given muxer.
- /// </summary>
- /// <param name="muxer">The muxer ID.</param>
- /// <returns>True if the subtitle can be passed through.</returns>
- public bool CanPass(int muxer)
- {
- return HBFunctions.hb_subtitle_can_pass(this.SubtitleSourceInt, muxer) > 0;
- }
-
- /// <summary>
- /// Override of the ToString method to make this object easier to use in the UI
- /// </summary>
- /// <returns>A string formatted as: {track #} {language}</returns>
- public override string ToString()
- {
- return string.Format("{0} {1} ({2})", this.TrackNumber, this.Language, this.SubtitleSource);
- }
-
- /// <summary>
- /// Gets the display.
- /// </summary>
- public string Display
- {
- get
- {
- return this.ToString();
- }
- }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/SubtitleSource.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/SubtitleSource.cs deleted file mode 100644 index d51ff4ef6..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/SubtitleSource.cs +++ /dev/null @@ -1,26 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="SubtitleSource.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Defines the SubtitleSource type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Model.Scan
-{
- /// <summary>
- /// The subtitle source.
- /// </summary>
- public enum SubtitleSource
- {
- VobSub,
- SRT,
- CC608,
- CC708,
- UTF8,
- TX3G,
- SSA,
- PGS
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/Title.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/Title.cs deleted file mode 100644 index 37013ac48..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Scan/Title.cs +++ /dev/null @@ -1,184 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Title.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// An object that represents a single Title of a DVD
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Model.Scan
-{
- using System;
- using System.Collections.Generic;
-
- using HandBrake.ApplicationServices.Interop.Model;
-
- /// <summary>
- /// An object that represents a single Title of a DVD
- /// </summary>
- public class Title
- {
- /// <summary>
- /// The audio tracks.
- /// </summary>
- private readonly List<AudioTrack> audioTracks;
-
- /// <summary>
- /// The chapters.
- /// </summary>
- private readonly List<Chapter> chapters;
-
- /// <summary>
- /// The subtitles.
- /// </summary>
- private readonly List<Subtitle> subtitles;
-
- /// <summary>
- /// Initializes a new instance of the Title class.
- /// </summary>
- public Title()
- {
- this.audioTracks = new List<AudioTrack>();
- this.chapters = new List<Chapter>();
- this.subtitles = new List<Subtitle>();
- }
-
- /// <summary>
- /// Gets or sets the input type of this title.
- /// </summary>
- public InputType InputType { get; set; }
-
- /// <summary>
- /// Gets a collection of chapters in this Title
- /// </summary>
- public List<Chapter> Chapters
- {
- get { return this.chapters; }
- }
-
- /// <summary>
- /// Gets a collection of audio tracks associated with this Title
- /// </summary>
- public List<AudioTrack> AudioTracks
- {
- get { return this.audioTracks; }
- }
-
- /// <summary>
- /// Gets a collection of subtitles associated with this Title
- /// </summary>
- public List<Subtitle> Subtitles
- {
- get { return this.subtitles; }
- }
-
- /// <summary>
- /// Gets or sets the track number of this Title (1-based).
- /// </summary>
- public int TitleNumber { get; set; }
-
- /// <summary>
- /// Gets or sets the playlist number this title came from.
- /// </summary>
- public int Playlist { get; set; }
-
- /// <summary>
- /// Gets or sets the duration of this title.
- /// </summary>
- public TimeSpan Duration { get; set; }
-
- /// <summary>
- /// Gets or sets the resolution (width/height) of this Title
- /// </summary>
- public Size Resolution { get; set; }
-
- /// <summary>
- /// Gets or sets the number of angles on the title.
- /// </summary>
- public int AngleCount { get; set; }
-
- /// <summary>
- /// Gets or sets the pixel aspect ratio.
- /// </summary>
- public Size ParVal { get; set; }
-
- /// <summary>
- /// Gets or sets the automatically detected crop region for this Title.
- /// </summary>
- public Cropping AutoCropDimensions { get; set; }
-
- /// <summary>
- /// Gets or sets the name of the video codec for this title.
- /// </summary>
- public string VideoCodecName { get; set; }
-
- /// <summary>
- /// Gets or sets the video frame rate for this title.
- /// </summary>
- public double Framerate { get; set; }
-
- /// <summary>
- /// Gets or sets the video frame rate numerator.
- /// </summary>
- public int FramerateNumerator { get; set; }
-
- /// <summary>
- /// Gets or sets the video frame rate denominator.
- /// </summary>
- public int FramerateDenominator { get; set; }
-
- /// <summary>
- /// Gets the total number of frames in this title.
- /// </summary>
- public int Frames
- {
- get
- {
- return (int)Math.Ceiling(this.Duration.TotalSeconds * this.Framerate);
- }
- }
-
- /// <summary>
- /// Gets or sets the path.
- /// </summary>
- public string Path { get; set; }
-
- /// <summary>
- /// Override of the ToString method to provide an easy way to use this object in the UI
- /// </summary>
- /// <returns>A string representing this track in the format: {title #}[ {playlist source}] (00:00:00)</returns>
- public override string ToString()
- {
- string playlistPortion = string.Empty;
- if (this.InputType == InputType.Bluray)
- {
- playlistPortion = string.Format(" {0:d5}.MPLS", this.Playlist);
- }
-
- return string.Format(
- "{0}{1} ({2:00}:{3:00}:{4:00})",
- this.TitleNumber,
- playlistPortion,
- this.Duration.Hours,
- this.Duration.Minutes,
- this.Duration.Seconds);
- }
-
- /// <summary>
- /// Gets the display string for this title.
- /// </summary>
- public string Display
- {
- get
- {
- return this.ToString();
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether is main feature.
- /// </summary>
- public bool IsMainFeature { get; set; }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/SourceVideoInfo.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/SourceVideoInfo.cs index 65ed3002b..0c6340189 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/SourceVideoInfo.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/SourceVideoInfo.cs @@ -29,7 +29,7 @@ namespace HandBrake.ApplicationServices.Interop.Model /// <param name="parVal">
/// The par val.
/// </param>
- public SourceVideoInfo(int framerateNumerator, int framerateDenominator, Size resolution, Size parVal)
+ public SourceVideoInfo(int? framerateNumerator, int? framerateDenominator, Size resolution, Size parVal)
{
this.FramerateNumerator = framerateNumerator;
this.FramerateDenominator = framerateDenominator;
@@ -40,12 +40,12 @@ namespace HandBrake.ApplicationServices.Interop.Model /// <summary>
/// Gets the framerate numerator.
/// </summary>
- public int FramerateNumerator { get; private set; }
+ public int? FramerateNumerator { get; private set; }
/// <summary>
/// Gets the framerate denominator.
/// </summary>
- public int FramerateDenominator { get; private set; }
+ public int? FramerateDenominator { get; private set; }
/// <summary>
/// Gets or sets the resolution (width/height) of this Title
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs index 64011826a..81f619b71 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs @@ -471,8 +471,8 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories else
{
// cfr or pfr flag with no rate specified implies use the title rate.
- num = title.FramerateNumerator;
- den = title.FramerateDenominator;
+ num = title.FramerateNumerator ?? 0;
+ den = title.FramerateDenominator ?? 0;
}
string framerateString = string.Format("{0}:{1}:{2}", fm, num, den); // filter_cfr, filter_vrate.num, filter_vrate.den
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs index 4fc5e3a52..0f2113ca1 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs @@ -132,7 +132,7 @@ namespace HandBrake.ApplicationServices.Services.Encode this.instance.ScanCompleted += delegate
{
// Process into internal structures.
- this.scannedSource = new Source { Titles = LibScan.ConvertTitles(this.instance.Titles, this.instance.FeatureTitle) }; // TODO work around the bad Internal API.
+ this.scannedSource = new Source { Titles = LibScan.ConvertTitles(this.instance.Titles) }; // TODO work around the bad Internal API.
this.ScanCompleted(job, this.instance);
};
@@ -218,19 +218,11 @@ namespace HandBrake.ApplicationServices.Services.Encode throw new Exception("Unable to get title for encoding. Encode Failed.");
}
- Interop.Model.Scan.Title scannedTitle = new Interop.Model.Scan.Title
- {
- Resolution = new Size(title.Resolution.Width, title.Resolution.Height),
- ParVal = new Size(title.ParVal.Width, title.ParVal.Height),
- FramerateDenominator = title.FramerateDenominator,
- FramerateNumerator = title.FramerateNumerator,
- };
-
ServiceLogMessage("Starting Encode ...");
// Get an EncodeJob object for the Interop Library
SourceVideoInfo videoInfo = new SourceVideoInfo(title.FramerateNumerator, title.FramerateDenominator, title.Resolution, title.ParVal);
- instance.StartEncode(EncodeFactory.Create(job.Task, videoInfo, job.Configuration), scannedTitle);
+ instance.StartEncode(EncodeFactory.Create(job.Task, videoInfo, job.Configuration));
// Fire the Encode Started Event
this.InvokeEncodeStarted(System.EventArgs.Empty);
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs index 903497200..09e2df18a 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs @@ -24,10 +24,11 @@ namespace HandBrake.ApplicationServices.Services.Scan using HandBrake.ApplicationServices.Utilities;
using HandBrake.ApplicationServices.Interop;
using HandBrake.ApplicationServices.Interop.EventArgs;
+ using HandBrake.ApplicationServices.Interop.HbLib;
using HandBrake.ApplicationServices.Interop.Interfaces;
+ using HandBrake.ApplicationServices.Interop.Json.Scan;
using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Preview;
- using HandBrake.ApplicationServices.Interop.Model.Scan;
using Chapter = HandBrake.ApplicationServices.Services.Scan.Model.Chapter;
using ScanProgressEventArgs = HandBrake.ApplicationServices.Interop.EventArgs.ScanProgressEventArgs;
@@ -371,7 +372,7 @@ namespace HandBrake.ApplicationServices.Services.Scan // Process into internal structures.
if (this.instance != null && this.instance.Titles != null)
{
- this.SouceData = new Source { Titles = ConvertTitles(this.instance.Titles, this.instance.FeatureTitle), ScanPath = path };
+ this.SouceData = new Source { Titles = ConvertTitles(this.instance.Titles), ScanPath = path };
}
this.IsScanning = false;
@@ -451,71 +452,87 @@ namespace HandBrake.ApplicationServices.Services.Scan /// <returns>
/// The convert titles.
/// </returns>
- internal static List<Title> ConvertTitles(IEnumerable<Interop.Model.Scan.Title> titles, int featureTitle)
+ internal static List<Title> ConvertTitles(JsonScanObject titles)
{
List<Title> titleList = new List<Title>();
- foreach (Interop.Model.Scan.Title title in titles)
+ foreach (TitleList title in titles.TitleList)
{
Title converted = new Title
{
- TitleNumber = title.TitleNumber,
- Duration = title.Duration,
- Resolution = new Size(title.Resolution.Width, title.Resolution.Height),
+ 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.ParVal.Width, title.ParVal.Height),
- AutoCropDimensions = title.AutoCropDimensions,
- Fps = title.Framerate,
+ 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 = title.TitleNumber == featureTitle,
- Playlist = title.InputType == InputType.Bluray ? string.Format(" {0:d5}.MPLS", title.Playlist).Trim() : null,
- FramerateNumerator = title.FramerateNumerator,
- FramerateDenominator = title.FramerateDenominator
+ 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
};
- foreach (Interop.Model.Scan.Chapter chapter in title.Chapters)
+ int currentTrack = 1;
+ foreach (ChapterList chapter in title.ChapterList)
{
string chapterName = !string.IsNullOrEmpty(chapter.Name) ? chapter.Name : string.Empty;
- converted.Chapters.Add(new Chapter(chapter.ChapterNumber, chapterName, chapter.Duration));
+ converted.Chapters.Add(new Chapter(currentTrack, chapterName, new TimeSpan(chapter.Duration.Hours, chapter.Duration.Minutes, chapter.Duration.Seconds)));
+ currentTrack++;
}
- foreach (AudioTrack track in title.AudioTracks)
+ int currentAudioTrack = 1;
+ foreach (AudioList track in title.AudioList)
{
- converted.AudioTracks.Add(new Audio(track.TrackNumber, track.Language, track.LanguageCode, track.Description, string.Empty, track.SampleRate, track.Bitrate));
+ converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, string.Empty, track.SampleRate, track.BitRate));
+ currentAudioTrack++;
}
- foreach (Interop.Model.Scan.Subtitle track in title.Subtitles)
+ int currentSubtitleTrack = 1;
+ foreach (SubtitleList track in title.SubtitleList)
{
SubtitleType convertedType = new SubtitleType();
- switch (track.SubtitleSource)
+ switch (track.Source)
{
- case SubtitleSource.VobSub:
+ case 0:
convertedType = SubtitleType.VobSub;
break;
- case SubtitleSource.UTF8:
+ case 4:
convertedType = SubtitleType.UTF8Sub;
break;
- case SubtitleSource.TX3G:
+ case 5:
convertedType = SubtitleType.TX3G;
break;
- case SubtitleSource.SSA:
+ case 6:
convertedType = SubtitleType.SSA;
break;
- case SubtitleSource.SRT:
+ case 1:
convertedType = SubtitleType.SRT;
break;
- case SubtitleSource.CC608:
+ case 2:
convertedType = SubtitleType.CC;
break;
- case SubtitleSource.CC708:
+ case 3:
convertedType = SubtitleType.CC;
break;
- case SubtitleSource.PGS:
+ case 7:
convertedType = SubtitleType.PGS;
break;
}
- converted.Subtitles.Add(new Subtitle(track.SubtitleSourceInt, track.TrackNumber, track.Language, track.LanguageCode, convertedType, track.CanBurn, track.CanSetForcedOnly));
+
+ 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++;
}
titleList.Add(converted);
|