diff options
author | sr55 <[email protected]> | 2015-05-03 17:18:59 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-05-03 17:18:59 +0000 |
commit | 0be4e18bacefa6b7bc63731b4a004a6ff772af20 (patch) | |
tree | 405ba4add7d0086d363a44e00a6b8a7ddc1c0163 | |
parent | 6689ba81c2919ef34d85da357d4b56b90507824b (diff) |
WinGui: Some Model Re-factoring by RandomEngy
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7151 b64f7644-9d1e-0410-96f1-a4d463321fa5
25 files changed, 963 insertions, 780 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index c3995689c..bb6fef136 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -109,38 +109,38 @@ <Compile Include="Interop\Interfaces\IHandBrakeInstance.cs" />
<Compile Include="Interop\Json\Anamorphic\AnamorphicGeometry.cs" />
<Compile Include="Interop\Json\Anamorphic\DestSettings.cs" />
- <Compile Include="Interop\Json\Encode\QSV.cs" />
- <Compile Include="Interop\Json\Shared\PAR.cs" />
- <Compile Include="Interop\Json\Encode\Audio.cs" />
- <Compile Include="Interop\Json\Encode\AudioList.cs" />
- <Compile Include="Interop\Json\Encode\ChapterList.cs" />
- <Compile Include="Interop\Json\Encode\Destination.cs" />
- <Compile Include="Interop\Json\Encode\Filters.cs" />
- <Compile Include="Interop\Json\Encode\Filter.cs" />
- <Compile Include="Interop\Json\Encode\JsonEncodeObject.cs" />
- <Compile Include="Interop\Json\Encode\MetaData.cs" />
- <Compile Include="Interop\Json\Encode\Mp4Options.cs" />
- <Compile Include="Interop\Json\Encode\Range.cs" />
- <Compile Include="Interop\Json\Encode\SubtitleSearch.cs" />
- <Compile Include="Interop\Json\Encode\Source.cs" />
- <Compile Include="Interop\Json\Encode\SRT.cs" />
- <Compile Include="Interop\Json\Encode\Subtitles.cs" />
- <Compile Include="Interop\Json\Encode\SubtitleList.cs" />
- <Compile Include="Interop\Json\Encode\Video.cs" />
- <Compile Include="Interop\Factories\AnamorphicFactory.cs" />
- <Compile Include="Services\Encode\Factories\EncodeFactory.cs" />
- <Compile Include="Interop\Json\Scan\AudioTrack.cs" />
- <Compile Include="Interop\Json\Scan\ChapterTrack.cs" />
- <Compile Include="Interop\Json\Scan\Color.cs" />
- <Compile Include="Interop\Json\Scan\Duration.cs" />
- <Compile Include="Interop\Json\Scan\FrameRate.cs" />
- <Compile Include="Interop\Json\Shared\Geometry.cs" />
- <Compile Include="Interop\Json\Scan\JsonScanObject.cs" />
- <Compile Include="Interop\Json\Scan\MetaData.cs" />
- <Compile Include="Interop\Json\Scan\SubtitleTrack.cs" />
- <Compile Include="Interop\Json\Scan\SourceTitle.cs" />
- <Compile Include="Interop\Json\State\JsonState.cs" />
- <Compile Include="Interop\Json\State\Scanning.cs" />
+ <Compile Include="Interop\Json\Encode\QSV.cs" /> + <Compile Include="Interop\Json\Shared\PAR.cs" /> + <Compile Include="Interop\Json\Encode\Audio.cs" /> + <Compile Include="Interop\Json\Encode\AudioTrack.cs" /> + <Compile Include="Interop\Json\Encode\Chapter.cs" /> + <Compile Include="Interop\Json\Encode\Destination.cs" /> + <Compile Include="Interop\Json\Encode\Filters.cs" /> + <Compile Include="Interop\Json\Encode\Filter.cs" /> + <Compile Include="Interop\Json\Encode\JsonEncodeObject.cs" /> + <Compile Include="Interop\Json\Encode\Metadata.cs" /> + <Compile Include="Interop\Json\Encode\Mp4Options.cs" /> + <Compile Include="Interop\Json\Encode\Range.cs" /> + <Compile Include="Interop\Json\Encode\SubtitleSearch.cs" /> + <Compile Include="Interop\Json\Encode\Source.cs" /> + <Compile Include="Interop\Json\Encode\SRT.cs" /> + <Compile Include="Interop\Json\Encode\Subtitles.cs" /> + <Compile Include="Interop\Json\Encode\SubtitleTrack.cs" /> + <Compile Include="Interop\Json\Encode\Video.cs" /> + <Compile Include="Interop\Factories\AnamorphicFactory.cs" /> + <Compile Include="Services\Encode\Factories\EncodeFactory.cs" /> + <Compile Include="Interop\Json\Scan\SourceAudioTrack.cs" /> + <Compile Include="Interop\Json\Scan\SourceChapter.cs" /> + <Compile Include="Interop\Json\Scan\Color.cs" /> + <Compile Include="Interop\Json\Scan\Duration.cs" /> + <Compile Include="Interop\Json\Scan\FrameRate.cs" /> + <Compile Include="Interop\Json\Shared\Geometry.cs" /> + <Compile Include="Interop\Json\Scan\JsonScanObject.cs" /> + <Compile Include="Interop\Json\Scan\SourceMetadata.cs" /> + <Compile Include="Interop\Json\Scan\SourceSubtitleTrack.cs" /> + <Compile Include="Interop\Json\Scan\SourceTitle.cs" /> + <Compile Include="Interop\Json\State\JsonState.cs" /> + <Compile Include="Interop\Json\State\Scanning.cs" /> <Compile Include="Interop\Json\State\WorkDone.cs" />
<Compile Include="Interop\Json\State\Working.cs" />
<Compile Include="Interop\Model\BitrateLimits.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs b/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs index abaa0fc25..741723329 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs @@ -15,6 +15,7 @@ namespace HandBrake.ApplicationServices.Interop.Factories using HandBrake.ApplicationServices.Interop.Json.Shared;
using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrake.ApplicationServices.Interop.Model.Preview;
using HandBrake.ApplicationServices.Services.Encode.Model;
/// <summary>
@@ -51,10 +52,10 @@ namespace HandBrake.ApplicationServices.Interop.Factories {
int settingMode = (int)keepWidthOrHeight + (job.KeepDisplayAspect ? 0x04 : 0);
- // Sanatise the Geometry First.
+ // Sanitize the Geometry First.
AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry
{
- SourceGeometry = new Geometry()
+ SourceGeometry = new Geometry
{
Width = title.Resolution.Width,
Height = title.Resolution.Height,
@@ -91,5 +92,58 @@ namespace HandBrake.ApplicationServices.Interop.Factories return HandBrakeUtils.GetAnamorphicSize(anamorphicGeometry);
}
+
+ /// <summary>
+ /// Finds output geometry for the given preview settings and title.
+ /// </summary>
+ /// <param name="settings">The preview settings.</param>
+ /// <param name="title">Information on the title to consider.</param>
+ /// <returns></returns>
+ public static Geometry CreateGeometry(PreviewSettings settings, SourceVideoInfo title)
+ {
+ int settingMode = settings.KeepDisplayAspect ? 0x04 : 0;
+
+ // Sanitize the Geometry First.
+ AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry
+ {
+ SourceGeometry = new Geometry
+ {
+ Width = title.Resolution.Width,
+ Height = title.Resolution.Height,
+ PAR = new PAR { Num = title.ParVal.Width, Den = title.ParVal.Height }
+ },
+ DestSettings = new DestSettings
+ {
+ AnamorphicMode = (int)settings.Anamorphic,
+ Geometry =
+ {
+ Width = settings.Width,
+ Height = settings.Height,
+ PAR = new PAR
+ {
+ Num = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : settings.PixelAspectX,
+ Den = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Height : settings.PixelAspectY,
+ }
+ },
+ Keep = settingMode,
+ Crop = new List<int> { settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right },
+ Modulus = settings.Modulus ?? 16,
+ MaxWidth = settings.MaxWidth,
+ MaxHeight = settings.MaxHeight,
+ ItuPAR = false
+ }
+ };
+
+ if (settings.Anamorphic == Anamorphic.Custom)
+ {
+ anamorphicGeometry.DestSettings.Geometry.PAR = new PAR { Num = settings.PixelAspectX, Den = settings.PixelAspectY };
+ }
+ else
+ {
+ anamorphicGeometry.DestSettings.Geometry.PAR = new PAR { Num = title.ParVal.Width, Den = title.ParVal.Height };
+ }
+
+ return HandBrakeUtils.GetAnamorphicSize(anamorphicGeometry);
+ }
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs index 714de6547..69075a7f9 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs @@ -33,33 +33,33 @@ namespace HandBrake.ApplicationServices.Interop /// </summary>
private static List<HBVideoEncoder> videoEncoders;
- /// <summary>
- /// Video framerates in pts.
- /// </summary>
- private static List<HBRate> videoFramerates;
-
- /// <summary>
- /// List of HandBrake mixdowns.
+ /// <summary> + /// Video framerates in pts. + /// </summary> + private static List<HBRate> videoFramerates; + + /// <summary> + /// List of HandBrake mixdowns. /// </summary>
private static List<HBMixdown> mixdowns;
- /// <summary>
- /// List of HandBrake containers.
- /// </summary>
- private static List<HBContainer> containers;
-
- /// <summary>
- /// The audio bitrates.
+ /// <summary> + /// List of HandBrake containers. + /// </summary> + private static List<HBContainer> containers; + + /// <summary> + /// The audio bitrates. /// </summary>
private static List<int> audioBitrates;
- /// <summary>
- /// Audio sample rates in Hz.
- /// </summary>
- private static List<HBRate> audioSampleRates;
-
- /// <summary>
- /// Initializes static members of the HandBrakeEncoderHelpers class.
+ /// <summary> + /// Audio sample rates in Hz. + /// </summary> + private static List<HBRate> audioSampleRates; + + /// <summary> + /// Initializes static members of the HandBrakeEncoderHelpers class. /// </summary>
static HandBrakeEncoderHelpers()
{
@@ -109,13 +109,13 @@ namespace HandBrake.ApplicationServices.Interop {
videoFramerates = InteropUtilities.ToListFromIterator<hb_rate_s, HBRate>(HBFunctions.hb_video_framerate_get_next, HandBrakeUnitConversionHelpers.NativeToRate);
}
-
- return videoFramerates;
- }
- }
-
- /// <summary>
- /// Gets a list of supported mixdowns.
+ + return videoFramerates; + } + } + + /// <summary> + /// Gets a list of supported mixdowns. /// </summary>
public static List<HBMixdown> Mixdowns
{
@@ -257,12 +257,73 @@ namespace HandBrake.ApplicationServices.Interop public static HBContainer GetContainer(string shortName)
{
return Containers.SingleOrDefault(c => c.ShortName == shortName);
- }
-
- /// <summary>
- /// Determines if the given encoder is compatible with the given track.
- /// </summary>
- /// <param name="codecId">
+ } + + /// <summary> + /// Returns true if the subtitle source type can be set to forced only. + /// </summary> + /// <param name="source">The subtitle source type (SSA, VobSub, etc)</param> + /// <returns>True if the subtitle source type can be set to forced only.</returns> + public static bool SubtitleCanSetForcedOnly(int source) + { + return HBFunctions.hb_subtitle_can_force(source) > 0; + } + + /// <summary> + /// Returns true if the subtitle source type can be burned in. + /// </summary> + /// <param name="source">The subtitle source type (SSA, VobSub, etc)</param> + /// <returns>True if the subtitle source type can be burned in.</returns> + public static bool SubtitleCanBurn(int source) + { + return HBFunctions.hb_subtitle_can_burn(source) > 0; + } + + /// <summary> + /// Returns true if the subtitle type can be passed through using the given muxer. + /// </summary> + /// <param name="subtitleSourceType">The subtitle source type (SSA, VobSub, etc)</param> + /// <param name="muxer">The ID of the muxer.</param> + /// <returns>True if the subtitle type can be passed through with the given muxer.</returns> + public static bool SubtitleCanPassthrough(int subtitleSourceType, int muxer) + { + return HBFunctions.hb_subtitle_can_pass(subtitleSourceType, muxer) > 0; + } + + /// <summary> + /// Gets the subtitle source type's name. + /// </summary> + /// <param name="source">The subtitle source type (SSA, VobSub, etc).</param> + /// <returns>The name of the subtitle source.</returns> + public static string GetSubtitleSourceName(int source) + { + switch ((hb_subtitle_s_subsource)source) + { + case hb_subtitle_s_subsource.CC608SUB: + return "CC608"; + case hb_subtitle_s_subsource.CC708SUB: + return "CC708"; + case hb_subtitle_s_subsource.SRTSUB: + return "SRT"; + case hb_subtitle_s_subsource.SSASUB: + return "SSA"; + case hb_subtitle_s_subsource.TX3GSUB: + return "TX3G"; + case hb_subtitle_s_subsource.UTF8SUB: + return "UTF8"; + case hb_subtitle_s_subsource.VOBSUB: + return "VobSub"; + case hb_subtitle_s_subsource.PGSSUB: + return "PGS"; + default: + return string.Empty; + } + } + + /// <summary> + /// Determines if the given encoder is compatible with the given track. + /// </summary> + /// <param name="codecId"> /// The codec Id.
/// </param>
/// <param name="encoder">
@@ -307,13 +368,13 @@ namespace HandBrake.ApplicationServices.Interop /// </param>
/// <returns>
/// True if the encoder supports the mixdown.
- /// </returns>
- public static bool MixdownHasCodecSupport(HBMixdown mixdown, HBAudioEncoder encoder)
- {
- return HBFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint) encoder.Id) > 0;
- }
-
- /// <summary>
+ /// </returns> + public static bool MixdownHasCodecSupport(HBMixdown mixdown, HBAudioEncoder encoder) + { + return HBFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint)encoder.Id) > 0; + } + + /// <summary> /// Determines if DRC can be applied to the given track with the given encoder.
/// </summary>
/// <param name="trackNumber">
@@ -428,15 +489,15 @@ namespace HandBrake.ApplicationServices.Interop int direction = 0;
HBFunctions.hb_video_quality_get_limits((uint)encoder.Id, ref low, ref high, ref granularity, ref direction);
-
- return new VideoQualityLimits
- {
- Low = low,
- High = high,
- Granularity = granularity,
- Ascending = direction == 0
- };
- }
+ + return new VideoQualityLimits + { + Low = low, + High = high, + Granularity = granularity, + Ascending = direction == 0 + }; + } /// <summary>
/// Sanitizes an audio bitrate given the output codec, sample rate and mixdown.
@@ -475,13 +536,13 @@ namespace HandBrake.ApplicationServices.Interop /// </param>
/// <returns>
/// The default bitrate for these parameters.
- /// </returns>
- public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)
- {
- return HBFunctions.hb_audio_bitrate_get_default((uint) encoder.Id, sampleRate, mixdown.Id);
- }
-
- /// <summary>
+ /// </returns> + public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown) + { + return HBFunctions.hb_audio_bitrate_get_default((uint)encoder.Id, sampleRate, mixdown.Id); + } + + /// <summary> /// Gets limits on audio quality for a given encoder.
/// </summary>
/// <param name="encoderId">
@@ -495,15 +556,15 @@ namespace HandBrake.ApplicationServices.Interop float low = 0, high = 0, granularity = 0;
int direction = 0;
HBFunctions.hb_audio_quality_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);
-
- return new RangeLimits
- {
- Low = low,
- High = high,
- Granularity = granularity,
- Ascending = direction == 0
- };
- }
+ + return new RangeLimits + { + Low = low, + High = high, + Granularity = granularity, + Ascending = direction == 0 + }; + } /// <summary>
/// Gets limits on audio compression for a given encoder.
@@ -519,14 +580,14 @@ namespace HandBrake.ApplicationServices.Interop float low = 0, high = 0, granularity = 0;
int direction = 0;
HBFunctions.hb_audio_compression_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);
-
- return new RangeLimits
- {
- Low = low,
- High = high,
- Granularity = granularity,
- Ascending = direction == 0
- };
- }
+ + return new RangeLimits + { + Low = low, + High = high, + Granularity = granularity, + Ascending = direction == 0 + }; + } }
}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs index 9e89190cd..8aafbc02d 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs @@ -61,6 +61,11 @@ namespace HandBrake.ApplicationServices.Interop private IntPtr hbHandle;
/// <summary>
+ /// The number of previews created during scan.
+ /// </summary>
+ private int previewCount;
+
+ /// <summary>
/// The timer to poll for scan status.
/// </summary>
private Timer scanPollTimer;
@@ -120,7 +125,18 @@ namespace HandBrake.ApplicationServices.Interop {
get
{
- return this.Handle;
+ return this.hbHandle;
+ }
+ }
+
+ /// <summary>
+ /// Gets the number of previews created during scan.
+ /// </summary>
+ public int PreviewCount
+ {
+ get
+ {
+ return this.previewCount;
}
}
@@ -200,6 +216,8 @@ namespace HandBrake.ApplicationServices.Interop /// </param>
public void StartScan(string path, int previewCount, TimeSpan minDuration, int titleIndex)
{
+ this.previewCount = previewCount;
+
IntPtr pathPtr = InteropUtilities.ToUtf8PtrFromString(path);
HBFunctions.hb_scan(this.hbHandle, pathPtr, titleIndex, previewCount, 1, (ulong)(minDuration.TotalSeconds * 90000));
Marshal.FreeHGlobal(pathPtr);
@@ -237,7 +255,7 @@ namespace HandBrake.ApplicationServices.Interop /// <remarks>
/// Only incorporates sizing and aspect ratio into preview image.
/// </remarks>
- /// <param name="job">
+ /// <param name="settings">
/// The encode job to preview.
/// </param>
/// <param name="previewNumber">
@@ -247,41 +265,46 @@ namespace HandBrake.ApplicationServices.Interop /// An image with the requested preview.
/// </returns>
[HandleProcessCorruptedStateExceptions]
- public BitmapImage GetPreview(PreviewSettings job, int previewNumber)
+ public BitmapImage GetPreview(PreviewSettings settings, int previewNumber)
{
- SourceTitle title = this.Titles.TitleList.FirstOrDefault(t => t.Index == job.Title);
+ SourceTitle title = this.Titles.TitleList.FirstOrDefault(t => t.Index == settings.TitleNumber);
Validate.NotNull(title, "GetPreview: Title should not have been null. This is probably a bug.");
- // Creat the Expected Output Geometry details for libhb.
+ // Create the Expected Output Geometry details for libhb.
hb_geometry_settings_s uiGeometry = new hb_geometry_settings_s
{
- crop = new[] { job.Cropping.Top, job.Cropping.Bottom, job.Cropping.Left, job.Cropping.Right },
+ crop = new[] { settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right },
itu_par = 0,
- keep = (int)AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH + (job.KeepDisplayAspect ? 0x04 : 0), // TODO Keep Width?
- maxWidth = job.MaxWidth ?? 0,
- maxHeight = job.MaxHeight ?? 0,
- mode = (int)(hb_anamorphic_mode_t)job.Anamorphic,
- modulus = job.Modulus ?? 16,
+ keep = settings.KeepDisplayAspect ? 0x04 : 0,
+ maxWidth = settings.MaxWidth,
+ maxHeight = settings.MaxHeight,
+ mode = (int)(hb_anamorphic_mode_t)settings.Anamorphic,
+ modulus = settings.Modulus ?? 16,
geometry = new hb_geometry_s
{
- height = job.Height ?? 0,
- width = job.Width ?? 0,
- par = job.Anamorphic != Anamorphic.Custom
+ height = settings.Height,
+ width = settings.Width,
+ par = settings.Anamorphic != Anamorphic.Custom
? new hb_rational_t { den = title.Geometry.PAR.Den, num = title.Geometry.PAR.Num }
- : new hb_rational_t { den = job.PixelAspectY, num = job.PixelAspectX }
+ : new hb_rational_t { den = settings.PixelAspectY, num = settings.PixelAspectX }
}
};
- // Sanatise the input.
- Geometry resultGeometry = AnamorphicFactory.CreateGeometry(job, new SourceVideoInfo(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;
+ // Sanitize the input.
+ Geometry resultGeometry = AnamorphicFactory.CreateGeometry(
+ settings,
+ new SourceVideoInfo(
+ new Size(title.Geometry.Width, title.Geometry.Height),
+ new Size(title.Geometry.PAR.Num, title.Geometry.PAR.Den)));
+ int width = resultGeometry.Width;
int height = resultGeometry.Height;
- uiGeometry.geometry.height = resultGeometry.Height; // Prased the height now.
- int outputWidth = width;
- int outputHeight = height;
-
+ uiGeometry.geometry.width = width;
+ uiGeometry.geometry.height = height;
+ uiGeometry.geometry.par.num = settings.PixelAspectX;
+ uiGeometry.geometry.par.den = settings.PixelAspectY;
+
// Fetch the image data from LibHb
- IntPtr resultingImageStuct = HBFunctions.hb_get_preview2(this.hbHandle, job.Title, previewNumber, ref uiGeometry, 0);
+ IntPtr resultingImageStuct = HBFunctions.hb_get_preview2(this.hbHandle, settings.TitleNumber, previewNumber, ref uiGeometry, 0);
hb_image_s image = InteropUtilities.ToStructureFromPtr<hb_image_s>(resultingImageStuct);
// Copy the filled image buffer to a managed array.
@@ -292,8 +315,8 @@ namespace HandBrake.ApplicationServices.Interop byte[] managedBuffer = new byte[imageBufferSize];
Marshal.Copy(image.plane[0].data, managedBuffer, 0, imageBufferSize);
- var bitmap = new Bitmap(outputWidth, outputHeight);
- BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, outputWidth, outputHeight), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb);
+ var bitmap = new Bitmap(width, height);
+ BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb);
IntPtr ptr = bitmapData.Scan0; // Pointer to the first pixel.
for (int i = 0; i < image.height; i++)
@@ -301,7 +324,7 @@ namespace HandBrake.ApplicationServices.Interop try
{
Marshal.Copy(managedBuffer, i * stride_width, ptr, stride_width);
- ptr = IntPtr.Add(ptr, outputWidth * 4);
+ ptr = IntPtr.Add(ptr, width * 4);
}
catch (Exception exc)
{
@@ -341,6 +364,18 @@ namespace HandBrake.ApplicationServices.Interop }
/// <summary>
+ /// Determines if DRC can be applied to the given track with the given encoder.
+ /// </summary>
+ /// <param name="trackNumber">The track Number.</param>
+ /// <param name="encoder">The encoder to use for DRC.</param>
+ /// <param name="title">The title.</param>
+ /// <returns>True if DRC can be applied to the track with the given encoder.</returns>
+ public bool CanApplyDrc(int trackNumber, HBAudioEncoder encoder, int title)
+ {
+ return HBFunctions.hb_audio_can_apply_drc2(this.hbHandle, title, trackNumber, encoder.Id) > 0;
+ }
+
+ /// <summary>
/// Starts an encode with the given job.
/// </summary>
/// <param name="encodeObject">
@@ -355,7 +390,6 @@ namespace HandBrake.ApplicationServices.Interop };
string encode = JsonConvert.SerializeObject(encodeObject, Formatting.Indented, settings);
- LogHelper.LogMessage(new LogMessage(encode, LogMessageType.encodeJson, LogLevel.debug));
HBFunctions.hb_add_json(this.hbHandle, InteropUtilities.ToUtf8PtrFromString(encode));
HBFunctions.hb_start(this.hbHandle);
@@ -432,6 +466,17 @@ namespace HandBrake.ApplicationServices.Interop }
/// <summary>
+ /// Gets a value indicating whether the object is disposed.
+ /// </summary>
+ public bool IsDisposed
+ {
+ get
+ {
+ return this.disposed;
+ }
+ }
+
+ /// <summary>
/// Frees any resources associated with this object.
/// </summary>
/// <param name="disposing">
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs index 7a00bb8e9..aad5df21c 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs @@ -20,23 +20,18 @@ namespace HandBrake.ApplicationServices.Interop using HandBrake.ApplicationServices.Interop.Json.Shared;
using HandBrake.ApplicationServices.Services.Logging;
using HandBrake.ApplicationServices.Services.Logging.Model;
-
- using Newtonsoft.Json;
-
- /// <summary>
- /// HandBrake Interop Utilities
- /// </summary>
- public static class HandBrakeUtils
- {
- /// <summary>
- /// Estimated overhead in bytes for each frame in output container.
- /// </summary>
- internal const int ContainerOverheadPerFrame = 6;
-
- /// <summary>
- /// The callback for log messages from HandBrake.
- /// </summary>
- private static LoggingCallback loggingCallback;
+ + using Newtonsoft.Json; + + /// <summary> + /// HandBrake Interop Utilities + /// </summary> + public static class HandBrakeUtils + { + /// <summary> + /// The callback for log messages from HandBrake. + /// </summary> + private static LoggingCallback loggingCallback; /// <summary>
/// The callback for error messages from HandBrake.
@@ -294,25 +289,25 @@ namespace HandBrake.ApplicationServices.Interop string x264Settings = Marshal.PtrToStringAnsi(ptr);
- return x264Settings;
- }
-
- /// <summary>
- /// Gets the final size and PAR of the video, given anamorphic inputs.
- /// </summary>
- /// <param name="anamorphicGeometry">Anamorphic inputs.</param>
- /// <returns>The final size and PAR of the video.</returns>
- public static Geometry GetAnamorphicSize(AnamorphicGeometry anamorphicGeometry)
- {
- string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
- LogHelper.LogMessage(new LogMessage(encode, LogMessageType.encodeJson, LogLevel.debug));
- IntPtr json = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode));
- string result = Marshal.PtrToStringAnsi(json);
- return JsonConvert.DeserializeObject<Geometry>(result);
- }
-
- /// <summary>
- /// Sends the message logged event to any registered listeners.
+ return x264Settings; + } + + /// <summary> + /// Gets the final size and PAR of the video, given anamorphic inputs. + /// </summary> + /// <param name="anamorphicGeometry">Anamorphic inputs.</param> + /// <returns>The final size and PAR of the video.</returns> + public static Geometry GetAnamorphicSize(AnamorphicGeometry anamorphicGeometry) + { + string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); + LogHelper.LogMessage(new LogMessage(encode, LogMessageType.encodeJson, LogLevel.debug)); + IntPtr json = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode)); + string result = Marshal.PtrToStringAnsi(json); + return JsonConvert.DeserializeObject<Geometry>(result); + } + + /// <summary> + /// Sends the message logged event to any registered listeners. /// </summary>
/// <param name="message">
/// The message to send.
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Audio.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Audio.cs index 2661a8f17..4e4b61d6b 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Audio.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Audio.cs @@ -19,7 +19,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode /// <summary>
/// Gets or sets the audio list.
/// </summary>
- public List<AudioList> AudioList { get; set; }
+ public List<AudioTrack> AudioList { get; set; }
/// <summary>
/// Gets or sets the copy mask.
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioList.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioTrack.cs index 2f79ec7e6..0c628fbb0 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioList.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioTrack.cs @@ -1,77 +1,77 @@ // --------------------------------------------------------------------------------------------------------------------
-// <copyright file="AudioList.cs" company="HandBrake Project (http://handbrake.fr)">
+// <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>
-// The audio list.
+// Represents an audio track to encode.
// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Json.Encode
-{
- /// <summary>
- /// The audio list.
- /// </summary>
- public class AudioList
- {
- /// <summary>
- /// Gets or sets the bitrate.
- /// </summary>
- public int? Bitrate { get; set; }
-
- /// <summary>
- /// Gets or sets the compression level.
- /// </summary>
- public double? CompressionLevel { get; set; }
-
- /// <summary>
- /// Gets or sets the drc.
- /// </summary>
- public double DRC { get; set; }
-
- /// <summary>
- /// Gets or sets the encoder.
- /// </summary>
- public int Encoder { get; set; }
-
- /// <summary>
- /// Gets or sets the gain.
- /// </summary>
- public double Gain { get; set; }
-
- /// <summary>
- /// Gets or sets the mixdown.
- /// </summary>
- public int Mixdown { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether normalize mix level.
- /// </summary>
- public bool NormalizeMixLevel { get; set; }
-
- /// <summary>
- /// Gets or sets the quality.
- /// </summary>
- public double? Quality { get; set; }
-
- /// <summary>
- /// Gets or sets the samplerate.
- /// </summary>
- public int Samplerate { get; set; }
-
- /// <summary>
- /// Gets or sets the Name of the audio track.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Gets or sets the track.
- /// </summary>
- public int Track { get; set; }
-
- /// <summary>
- /// Gets or sets the dither method.
- /// </summary>
- public int DitherMethod { get; set; }
- }
+// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Encode +{ + /// <summary> + /// Represents an audio track to encode. + /// </summary> + public class AudioTrack + { + /// <summary> + /// Gets or sets the bitrate. + /// </summary> + public int? Bitrate { get; set; } + + /// <summary> + /// Gets or sets the compression level. + /// </summary> + public double? CompressionLevel { get; set; } + + /// <summary> + /// Gets or sets the drc. + /// </summary> + public double DRC { get; set; } + + /// <summary> + /// Gets or sets the encoder. + /// </summary> + public int Encoder { get; set; } + + /// <summary> + /// Gets or sets the gain. + /// </summary> + public double Gain { get; set; } + + /// <summary> + /// Gets or sets the mixdown. + /// </summary> + public int Mixdown { get; set; } + + /// <summary> + /// Gets or sets a value indicating whether normalize mix level. + /// </summary> + public bool NormalizeMixLevel { get; set; } + + /// <summary> + /// Gets or sets the quality. + /// </summary> + public double? Quality { get; set; } + + /// <summary> + /// Gets or sets the samplerate. + /// </summary> + public int Samplerate { get; set; } + + /// <summary> + /// Gets or sets the Name of the audio track. + /// </summary> + public string Name { get; set; } + + /// <summary> + /// Gets or sets the track. + /// </summary> + public int Track { get; set; } + + /// <summary> + /// Gets or sets the dither method. + /// </summary> + public int DitherMethod { get; set; } + } }
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/ChapterList.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Chapter.cs index d58146510..567d0e7a3 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/ChapterList.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Chapter.cs @@ -1,22 +1,22 @@ // --------------------------------------------------------------------------------------------------------------------
-// <copyright file="ChapterList.cs" company="HandBrake Project (http://handbrake.fr)">
+// <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>
-// The chapter list.
+// Represents a chapter to encode.
// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Json.Encode
-{
- /// <summary>
- /// The chapter list.
- /// </summary>
- public class ChapterList
- {
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- public string Name { get; set; }
- }
+// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Encode +{ + /// <summary> + /// Represents a chapter to encode. + /// </summary> + public class Chapter + { + /// <summary> + /// Gets or sets the name. + /// </summary> + public string Name { get; set; } + } }
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Destination.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Destination.cs index 42b3eaa40..9d22fb98a 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Destination.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Destination.cs @@ -19,7 +19,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode /// <summary>
/// Gets or sets the chapter list.
/// </summary>
- public List<ChapterList> ChapterList { get; set; }
+ public List<Chapter> ChapterList { get; set; }
/// <summary>
/// Gets or sets a value indicating whether chapter markers.
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs index 9de1b8341..68baffcb4 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs @@ -39,7 +39,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode /// <summary>
/// Gets or sets the meta data.
/// </summary>
- public MetaData Metadata { get; set; }
+ public Metadata Metadata { get; set; }
/// <summary>
/// Gets or sets the sequence id.
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/MetaData.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/MetaData.cs index 86f06b8cb..d840d5d7f 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/MetaData.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/MetaData.cs @@ -12,7 +12,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode /// <summary>
/// The meta data.
/// </summary>
- public class MetaData
+ public class Metadata
{
/// <summary>
/// Gets or sets the album artist.
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleList.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleTrack.cs index 71814c9e1..3a8aedec7 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleList.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleTrack.cs @@ -1,52 +1,49 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="SubtitleList.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 subtitle list.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Json.Encode
-{
- /// <summary>
- /// The subtitle list.
- /// </summary>
- public class SubtitleList
- {
- /// <summary>
- /// Gets or sets a value indicating whether burn.
- /// </summary>
- public bool Burn { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether default.
- /// </summary>
- public bool Default { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether force.
- /// </summary>
- public bool Forced { get; set; }
-
- /// <summary>
- /// Gets or sets the id.
- /// </summary>
- public int ID { get; set; }
-
- /// <summary>
- /// Gets or sets the offset.
- /// </summary>
- public int Offset { get; set; }
-
- /// <summary>
- /// Gets or sets the track.
- /// </summary>
- public int Track { get; set; }
-
- /// <summary>
- /// Gets or sets the srt.
- /// </summary>
- public SRT SRT { get; set; }
- }
+// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="SubtitleTrack.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> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Encode +{ + /// <summary> + /// Represents a subtitle track to encode. + /// </summary> + public class SubtitleTrack + { + /// <summary> + /// Gets or sets a value indicating whether burn. + /// </summary> + public bool Burn { get; set; } + + /// <summary> + /// Gets or sets a value indicating whether default. + /// </summary> + public bool Default { get; set; } + + /// <summary> + /// Gets or sets a value indicating whether force. + /// </summary> + public bool Forced { get; set; } + + /// <summary> + /// Gets or sets the id. + /// </summary> + public int ID { get; set; } + + /// <summary> + /// Gets or sets the offset. + /// </summary> + public int Offset { get; set; } + + /// <summary> + /// Gets or sets the track. + /// </summary> + public int Track { get; set; } + + /// <summary> + /// Gets or sets the srt. + /// </summary> + public SRT SRT { get; set; } + } }
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Subtitles.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Subtitles.cs index 5d38ba51d..13439eaa7 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Subtitles.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Subtitles.cs @@ -21,9 +21,9 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode /// </summary>
public SubtitleSearch Search { get; set; }
- /// <summary>
- /// Gets or sets the subtitle list.
- /// </summary>
- public List<SubtitleList> SubtitleList { get; set; }
- }
+ /// <summary> + /// Gets or sets the subtitle list. + /// </summary> + public List<SubtitleTrack> SubtitleList { get; set; } + } }
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceAudioTrack.cs index b0491c734..091f9a4f8 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceAudioTrack.cs @@ -1,52 +1,49 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <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>
-// The audio list.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Json.Scan
-{
- /// <summary>
- /// The audio list.
- /// </summary>
- public class AudioTrack
- {
- /// <summary>
- /// Gets or sets the bit rate.
- /// </summary>
- public int BitRate { get; set; }
-
- /// <summary>
- /// Gets or sets the channel layout.
- /// </summary>
- public int ChannelLayout { get; set; }
-
- /// <summary>
- /// Gets or sets the description.
- /// </summary>
- public string Description { get; set; }
-
- /// <summary>
- /// Gets or sets the language.
- /// </summary>
- public string Language { get; set; }
-
- /// <summary>
- /// Gets or sets the language code.
- /// </summary>
- public string LanguageCode { get; set; }
-
- /// <summary>
- /// Gets or sets the sample rate.
- /// </summary>
- public int SampleRate { get; set; }
-
- /// <summary>
- /// Gets or sets the codec.
- /// </summary>
- public int Codec { get; set; }
- }
+// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="SourceAudioTrack.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> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Scan +{ + /// <summary> + /// An audio track from the source video. + /// </summary> + public class SourceAudioTrack + { + /// <summary> + /// Gets or sets the bit rate. + /// </summary> + public int BitRate { get; set; } + + /// <summary> + /// Gets or sets the channel layout. + /// </summary> + public int ChannelLayout { get; set; } + + /// <summary> + /// Gets or sets the description. + /// </summary> + public string Description { get; set; } + + /// <summary> + /// Gets or sets the language. + /// </summary> + public string Language { get; set; } + + /// <summary> + /// Gets or sets the language code. + /// </summary> + public string LanguageCode { get; set; } + + /// <summary> + /// Gets or sets the sample rate. + /// </summary> + public int SampleRate { get; set; } + + /// <summary> + /// Gets or sets the codec. + /// </summary> + public int Codec { get; set; } + } }
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterTrack.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceChapter.cs index dc50f2dc8..fce479ff1 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceChapter.cs @@ -1,27 +1,24 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="ChapterTrack.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 chapter list.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Json.Scan
-{
- /// <summary>
- /// The chapter list.
- /// </summary>
- public class ChapterTrack
- {
- /// <summary>
- /// Gets or sets the duration.
- /// </summary>
- public Duration Duration { get; set; }
-
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- public string Name { get; set; }
- }
+// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="SourceChapter.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> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Scan +{ + /// <summary> + /// The a chapter from a video source. + /// </summary> + public class SourceChapter + { + /// <summary> + /// Gets or sets the duration. + /// </summary> + public Duration Duration { get; set; } + + /// <summary> + /// Gets or sets the name. + /// </summary> + public string Name { get; set; } + } }
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/MetaData.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceMetadata.cs index ecd26bd8f..f575dc637 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/MetaData.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceMetadata.cs @@ -1,18 +1,18 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="MetaData.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 meta data.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Json.Scan
-{
- /// <summary>
- /// The meta data.
- /// </summary>
- public class MetaData
- {
- }
+// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="SourceMetadata.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 meta data. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Scan +{ + /// <summary> + /// The meta data. + /// </summary> + public class SourceMetadata + { + } }
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleTrack.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceSubtitleTrack.cs index 247801468..3f3594a39 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceSubtitleTrack.cs @@ -1,37 +1,37 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="SubtitleTrack.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 subtitle list.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Json.Scan
-{
- /// <summary>
- /// The subtitle list.
- /// </summary>
- public class SubtitleTrack
- {
- /// <summary>
- /// Gets or sets the format.
- /// </summary>
- public int Format { get; set; }
-
- /// <summary>
- /// Gets or sets the language.
- /// </summary>
- public string Language { get; set; }
-
- /// <summary>
- /// Gets or sets the language code.
- /// </summary>
- public string LanguageCode { get; set; }
-
- /// <summary>
- /// Gets or sets the source.
- /// </summary>
- public int Source { get; set; }
- }
+// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="SourceSubtitleTrack.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 subtitle list. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Scan +{ + /// <summary> + /// The subtitle list. + /// </summary> + public class SourceSubtitleTrack + { + /// <summary> + /// Gets or sets the format. + /// </summary> + public int Format { get; set; } + + /// <summary> + /// Gets or sets the language. + /// </summary> + public string Language { get; set; } + + /// <summary> + /// Gets or sets the language code. + /// </summary> + public string LanguageCode { get; set; } + + /// <summary> + /// Gets or sets the source. + /// </summary> + public int Source { get; set; } + } }
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceTitle.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceTitle.cs index f70a15584..4947bbadb 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceTitle.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceTitle.cs @@ -23,18 +23,18 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// </summary>
public int AngleCount { get; set; }
- /// <summary>
- /// Gets or sets the audio list.
- /// </summary>
- public List<AudioTrack> AudioList { get; set; }
-
- /// <summary>
- /// Gets or sets the chapter list.
- /// </summary>
- public List<ChapterTrack> ChapterList { get; set; }
-
- /// <summary>
- /// Gets or sets the color.
+ /// <summary> + /// Gets or sets the audio list. + /// </summary> + public List<SourceAudioTrack> AudioList { get; set; } + + /// <summary> + /// Gets or sets the chapter list. + /// </summary> + public List<SourceChapter> ChapterList { get; set; } + + /// <summary> + /// Gets or sets the color. /// </summary>
public Color Color { get; set; }
@@ -68,13 +68,13 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// </summary>
public bool InterlaceDetected { get; set; }
- /// <summary>
- /// Gets or sets the meta data.
- /// </summary>
- public MetaData MetaData { get; set; }
-
- /// <summary>
- /// Gets or sets the name.
+ /// <summary> + /// Gets or sets the meta data. + /// </summary> + public SourceMetadata MetaData { get; set; } + + /// <summary> + /// Gets or sets the name. /// </summary>
public string Name { get; set; }
@@ -88,13 +88,13 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// </summary>
public int Playlist { get; set; }
- /// <summary>
- /// Gets or sets the subtitle list.
- /// </summary>
- public List<SubtitleTrack> SubtitleList { get; set; }
-
- /// <summary>
- /// Gets or sets the type.
+ /// <summary> + /// Gets or sets the subtitle list. + /// </summary> + public List<SourceSubtitleTrack> SubtitleList { get; set; } + + /// <summary> + /// Gets or sets the 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/Preview/PreviewSettings.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs index e2a07d1cc..af1a166ce 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs @@ -6,27 +6,52 @@ // The preview settings.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Interop.Model.Preview
-{
- using HandBrake.ApplicationServices.Services.Encode.Model;
-
- /// <summary>
- /// The preview settings.
- /// </summary>
- public class PreviewSettings : EncodeTask
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="PreviewSettings"/> class.
- /// </summary>
- /// <param name="task">
- /// The task.
- /// </param>
- public PreviewSettings(EncodeTask task)
- : base(task)
- {
- }
-
- // TODO flesh this out into a proper model.
- }
-}
+ +namespace HandBrake.ApplicationServices.Interop.Model.Preview +{ + using HandBrake.ApplicationServices.Interop.Model.Encoding; + using HandBrake.ApplicationServices.Services.Encode.Model; + + /// <summary> + /// The preview settings. + /// </summary> + public class PreviewSettings + { + /// <summary> + /// Initializes a new instance of the <see cref="PreviewSettings"/> class. + /// </summary> + public PreviewSettings() + { + } + + /// <summary> + /// Initializes a new instance of the <see cref="PreviewSettings"/> class. + /// </summary> + /// <param name="task">The task.</param> + public PreviewSettings(EncodeTask task) + { + } + + public Cropping Cropping { get; set; } + + public int MaxWidth { get; set; } + + public int MaxHeight { get; set; } + + public bool KeepDisplayAspect { get; set; } + + public int TitleNumber { get; set; } + + public Anamorphic Anamorphic { get; set; } + + public int? Modulus { get; set; } + + public int Width { get; set; } + + public int Height { get; set; } + + public int PixelAspectX { get; set; } + + public int PixelAspectY { get; set; } + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs index 875cdc938..54b80b28c 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs @@ -14,20 +14,24 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories using System.Linq;
using System.Runtime.InteropServices;
- using HandBrake.ApplicationServices.Interop;
- using HandBrake.ApplicationServices.Interop.HbLib;
- using HandBrake.ApplicationServices.Interop.Helpers;
- using HandBrake.ApplicationServices.Interop.Json.Encode;
- using HandBrake.ApplicationServices.Interop.Json.Shared;
- using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrake.ApplicationServices.Interop; + using HandBrake.ApplicationServices.Interop.HbLib; + using HandBrake.ApplicationServices.Interop.Helpers; + using HandBrake.ApplicationServices.Interop.Json; + using HandBrake.ApplicationServices.Interop.Json.Anamorphic; + using HandBrake.ApplicationServices.Interop.Json.Encode; + using HandBrake.ApplicationServices.Interop.Json.Shared; + using HandBrake.ApplicationServices.Interop.Model.Encoding; using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.Model;
- using HandBrake.ApplicationServices.Services.Encode.Model.Models;
- using HandBrake.ApplicationServices.Utilities;
-
-
- /// <summary>
- /// This factory takes the internal EncodeJob object and turns it into a set of JSON models
+ using HandBrake.ApplicationServices.Services.Encode.Model.Models; + using HandBrake.ApplicationServices.Utilities; + + using AudioTrack = HandBrake.ApplicationServices.Services.Encode.Model.Models.AudioTrack; + using Subtitle = HandBrake.ApplicationServices.Interop.Json.Encode.Subtitles; + + /// <summary> + /// This factory takes the internal EncodeJob object and turns it into a set of JSON models /// that can be deserialized by libhb.
/// </summary>
internal class EncodeFactory
@@ -47,23 +51,23 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories /// <param name="configuration">
/// The configuration.
/// </param>
- /// <returns>
- /// The <see cref="JsonEncodeObject"/>.
- /// </returns>
- internal static JsonEncodeObject Create(EncodeTask job, HBConfiguration configuration)
- {
- JsonEncodeObject encode = new JsonEncodeObject
- {
- SequenceID = 0,
- Audio = CreateAudio(job),
- Destination = CreateDestination(job),
- Filters = CreateFilter(job),
- PAR = CreatePAR(job),
- Metadata = CreateMetaData(job),
- Source = CreateSource(job, configuration),
- Subtitle = CreateSubtitle(job),
- Video = CreateVideo(job, configuration)
- };
+ /// <returns> + /// The <see cref="JsonEncodeObject"/>. + /// </returns> + internal static JsonEncodeObject Create(EncodeTask job, HBConfiguration configuration) + { + JsonEncodeObject encode = new JsonEncodeObject + { + SequenceID = 0, + Audio = CreateAudio(job), + Destination = CreateDestination(job), + Filters = CreateFilters(job), + PAR = CreatePAR(job), + Metadata = CreateMetadata(job), + Source = CreateSource(job, configuration), + Subtitle = CreateSubtitle(job), + Video = CreateVideo(job, configuration) + }; return encode;
}
@@ -84,36 +88,36 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories {
Range range = new Range();
switch (job.PointToPointMode)
- {
- case PointToPointMode.Chapters:
- range.Type = "chapter";
- range.End = job.EndPoint;
- range.Start = job.StartPoint;
- break;
- case PointToPointMode.Seconds:
- range.Type = "time";
- range.Start = job.StartPoint * 90000;
- range.End = (job.EndPoint - job.StartPoint) * 90000;
- break;
- case PointToPointMode.Frames:
- range.Type = "frame";
- range.Start = job.StartPoint;
- range.End = job.EndPoint;
- break;
- case PointToPointMode.Preview:
- range.Type = "preview";
- range.Start = job.PreviewEncodeStartAt;
- range.SeekPoints = configuration.PreviewScanCount;
- range.End = job.PreviewEncodeDuration * 90000;
- break;
- }
-
- Source source = new Source
- {
- Title = job.Title,
- Range = range,
- Angle = job.Angle,
- Path = job.Source,
+ { + case PointToPointMode.Chapters: + range.Type = "chapter"; + range.Start = job.StartPoint; + range.End = job.EndPoint; + break; + case PointToPointMode.Seconds: + range.Type = "time"; + range.Start = job.StartPoint * 90000; + range.End = (job.EndPoint - job.StartPoint) * 90000; + break; + case PointToPointMode.Frames: + range.Type = "frame"; + range.Start = job.StartPoint; + range.End = job.EndPoint; + break; + case PointToPointMode.Preview: + range.Type = "preview"; + range.Start = job.PreviewEncodeStartAt; + range.SeekPoints = configuration.PreviewScanCount; + range.End = job.PreviewEncodeDuration * 90000; + break; + } + + Source source = new Source + { + Title = job.Title, + Range = range, + Angle = job.Angle, + Path = job.Source, };
return source;
}
@@ -128,28 +132,28 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories /// The <see cref="Destination"/>.
/// </returns>
private static Destination CreateDestination(EncodeTask job)
- {
- Destination destination = new Destination
- {
- File = job.Destination,
- Mp4Options = new Mp4Options
- {
- IpodAtom = job.IPod5GSupport,
- Mp4Optimize = job.OptimizeMP4
- },
- ChapterMarkers = job.IncludeChapterMarkers,
- Mux = HBFunctions.hb_container_get_from_name(job.OutputFormat == OutputFormat.Mp4 ? "av_mp4" : "av_mkv"), // TODO tidy up.
- ChapterList = new List<ChapterList>()
- };
-
- if (job.IncludeChapterMarkers)
- {
- foreach (ChapterMarker item in job.ChapterNames)
- {
- ChapterList chapter = new ChapterList { Name = item.ChapterName };
- destination.ChapterList.Add(chapter);
- }
- }
+ { + Destination destination = new Destination + { + File = job.Destination, + Mp4Options = new Mp4Options + { + IpodAtom = job.IPod5GSupport, + Mp4Optimize = job.OptimizeMP4 + }, + ChapterMarkers = job.IncludeChapterMarkers, + Mux = HBFunctions.hb_container_get_from_name(job.OutputFormat == OutputFormat.Mp4 ? "av_mp4" : "av_mkv"), // TODO tidy up. + ChapterList = new List<Chapter>() + }; + + if (job.IncludeChapterMarkers) + { + foreach (ChapterMarker item in job.ChapterNames) + { + Chapter chapter = new Chapter { Name = item.ChapterName }; + destination.ChapterList.Add(chapter); + } + } return destination;
}
@@ -174,28 +178,28 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories /// <param name="job">
/// The job.
/// </param>
- /// <returns>
- /// The <see cref="HandBrake.ApplicationServices.Interop.Json.Encode.Subtitles"/>.
- /// </returns>
- private static Subtitles CreateSubtitle(EncodeTask job)
- {
- Subtitles subtitle = new Subtitles
- {
- Search =
- new SubtitleSearch
- {
- Enable = false,
- Default = false,
- Burn = false,
- Forced = false
- },
- SubtitleList = new List<SubtitleList>()
- };
-
- foreach (SubtitleTrack item in job.SubtitleTracks)
- {
- if (!item.IsSrtSubtitle)
- {
+ /// <returns> + /// The <see cref="HandBrake.ApplicationServices.Interop.Json.Encode.Subtitles"/>. + /// </returns> + private static Subtitle CreateSubtitle(EncodeTask job) + { + Subtitles subtitle = new Subtitles + { + Search = + new SubtitleSearch + { + Enable = false, + Default = false, + Burn = false, + Forced = false + }, + SubtitleList = new List<HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack>() + }; + + foreach (HandBrake.ApplicationServices.Services.Encode.Model.Models.SubtitleTrack item in job.SubtitleTracks) + { + if (!item.IsSrtSubtitle) + { // Handle Foreign Audio Search
if (item.SourceTrack.TrackNumber == 0)
{
@@ -203,19 +207,27 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories subtitle.Search.Burn = item.Burned;
subtitle.Search.Default = item.Default;
subtitle.Search.Forced = item.Forced;
- }
- else
- {
- SubtitleList track = new SubtitleList { Burn = item.Burned, Default = item.Default, Forced = item.Forced, ID = item.SourceTrack.TrackNumber, Track = (item.SourceTrack.TrackNumber - 1) };
- subtitle.SubtitleList.Add(track);
- }
- }
- else
- {
- SubtitleList track = new SubtitleList
- {
- Track = -1, // Indicates SRT
- Default = item.Default,
+ } + else + { + HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack track = new HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack + { + Burn = item.Burned, + Default = item.Default, + Forced = item.Forced, + ID = item.SourceTrack.TrackNumber, + Track = (item.SourceTrack.TrackNumber - 1) + }; + + subtitle.SubtitleList.Add(track); + } + } + else + { + HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack track = new HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack + { + Track = -1, // Indicates SRT + Default = item.Default, Offset = item.SrtOffset,
Burn = item.Burned,
SRT =
@@ -225,13 +237,13 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories Codeset = item.SrtCharCode,
Language = item.SrtLang
}
- };
-
- subtitle.SubtitleList.Add(track);
- }
- }
-
- return subtitle;
+ }; + + subtitle.SubtitleList.Add(track); + } + } + + return subtitle; }
/// <summary>
@@ -303,42 +315,42 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories /// The <see cref="Audio"/>.
/// </returns>
private static Audio CreateAudio(EncodeTask job)
- {
- Audio audio = new Audio();
-
- List<uint> copyMaskList = new List<uint>();
- if (job.AllowedPassthruOptions.AudioAllowAACPass) copyMaskList.Add(NativeConstants.HB_ACODEC_AAC_PASS);
- if (job.AllowedPassthruOptions.AudioAllowAC3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_AC3_PASS);
- if (job.AllowedPassthruOptions.AudioAllowDTSHDPass) copyMaskList.Add(NativeConstants.HB_ACODEC_DCA_HD_PASS);
+ { + Audio audio = new Audio(); + + List<uint> copyMaskList = new List<uint>(); + if (job.AllowedPassthruOptions.AudioAllowAACPass) copyMaskList.Add(NativeConstants.HB_ACODEC_AAC_PASS); + if (job.AllowedPassthruOptions.AudioAllowAC3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_AC3_PASS); + if (job.AllowedPassthruOptions.AudioAllowDTSHDPass) copyMaskList.Add(NativeConstants.HB_ACODEC_DCA_HD_PASS); if (job.AllowedPassthruOptions.AudioAllowDTSPass) copyMaskList.Add(NativeConstants.HB_ACODEC_DCA_PASS);
if (job.AllowedPassthruOptions.AudioAllowEAC3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_EAC3_PASS);
- if (job.AllowedPassthruOptions.AudioAllowFlacPass) copyMaskList.Add(NativeConstants.HB_ACODEC_FLAC_PASS);
- if (job.AllowedPassthruOptions.AudioAllowMP3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_MP3_PASS);
- if (job.AllowedPassthruOptions.AudioAllowTrueHDPass) copyMaskList.Add(NativeConstants.HB_ACODEC_TRUEHD_PASS);
- audio.CopyMask = copyMaskList.ToArray();
-
- HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(job.AllowedPassthruOptions.AudioEncoderFallback));
- audio.FallbackEncoder = audioEncoder.Id;
-
- audio.AudioList = new List<AudioList>();
- foreach (AudioTrack item in job.AudioTracks)
- {
- HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(ApplicationServices.Utilities.Converters.GetCliAudioEncoder(item.Encoder) );
- Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder);
-
- HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(ApplicationServices.Utilities.Converters.GetCliMixDown(item.MixDown));
- Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + ApplicationServices.Utilities.Converters.GetCliMixDown(item.MixDown));
-
- AudioList audioTrack = new AudioList
- {
- Track = (item.Track.HasValue ? item.Track.Value : 0) - 1,
- DRC = item.DRC,
- Encoder = encoder.Id,
- Gain = item.Gain,
- Mixdown = mixdown.Id,
- NormalizeMixLevel = false,
- Samplerate = GetSampleRateRaw(item.SampleRate),
- Name = item.TrackName,
+ if (job.AllowedPassthruOptions.AudioAllowFlacPass) copyMaskList.Add(NativeConstants.HB_ACODEC_FLAC_PASS); + if (job.AllowedPassthruOptions.AudioAllowMP3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_MP3_PASS); + if (job.AllowedPassthruOptions.AudioAllowTrueHDPass) copyMaskList.Add(NativeConstants.HB_ACODEC_TRUEHD_PASS); + audio.CopyMask = copyMaskList.ToArray(); + + HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(job.AllowedPassthruOptions.AudioEncoderFallback)); + audio.FallbackEncoder = audioEncoder.Id; + + audio.AudioList = new List<Interop.Json.Encode.AudioTrack>(); + foreach (AudioTrack item in job.AudioTracks) + { + HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(ApplicationServices.Utilities.Converters.GetCliAudioEncoder(item.Encoder)); + Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder); + + HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(ApplicationServices.Utilities.Converters.GetCliMixDown(item.MixDown)); + Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + ApplicationServices.Utilities.Converters.GetCliMixDown(item.MixDown)); + + HandBrake.ApplicationServices.Interop.Json.Encode.AudioTrack audioTrack = new HandBrake.ApplicationServices.Interop.Json.Encode.AudioTrack + { + Track = (item.Track.HasValue ? item.Track.Value : 0) - 1, + DRC = item.DRC, + Encoder = encoder.Id, + Gain = item.Gain, + Mixdown = mixdown.Id, + NormalizeMixLevel = false, + Samplerate = GetSampleRateRaw(item.SampleRate), + Name = item.TrackName, };
if (!item.IsPassthru)
@@ -352,15 +364,15 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories //if (item.EncodeRateType == AudioEncodeRateType.Compression)
//{
// audioTrack.CompressionLevel = item.Compression;
- //}
-
- //if (item.EncodeRateType == AudioEncodeRateType.Bitrate)
- // {
- audioTrack.Bitrate = item.Bitrate;
- // }
- }
-
- audio.AudioList.Add(audioTrack);
+ //} + + //if (item.EncodeRateType == AudioEncodeRateType.Bitrate) + // { + audioTrack.Bitrate = item.Bitrate; + // } + } + + audio.AudioList.Add(audioTrack); }
return audio;
@@ -394,17 +406,17 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories /// <param name="job">
/// The job.
/// </param>
- /// <returns>
- /// The <see cref="Filters"/>.
- /// </returns>
- private static Filters CreateFilter(EncodeTask job)
- {
- Filters filter = new Filters
- {
- FilterList = new List<Filter>(),
- Grayscale = job.Grayscale
- };
-
+ /// <returns> + /// The <see cref="Filters"/>. + /// </returns> + private static Filters CreateFilters(EncodeTask job) + { + Filters filter = new Filters + { + FilterList = new List<Filter>(), + Grayscale = job.Grayscale + }; + // Detelecine
if (job.Detelecine != Detelecine.Off)
{
@@ -509,21 +521,21 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories filter.FilterList.Add(filterItem);
}
- // CropScale Filter
- Filter cropScale = new Filter
- {
- ID = (int)hb_filter_ids.HB_FILTER_CROP_SCALE,
- Settings =
- string.Format(
- "{0}:{1}:{2}:{3}:{4}:{5}",
- job.Width,
- job.Height,
- job.Cropping.Top,
- job.Cropping.Bottom,
- job.Cropping.Left,
- job.Cropping.Right)
- };
- filter.FilterList.Add(cropScale);
+ // CropScale Filter + Filter cropScale = new Filter + { + ID = (int)hb_filter_ids.HB_FILTER_CROP_SCALE, + Settings = + string.Format( + "{0}:{1}:{2}:{3}:{4}:{5}", + job.Width, + job.Height, + job.Cropping.Top, + job.Cropping.Bottom, + job.Cropping.Left, + job.Cropping.Right) + }; + filter.FilterList.Add(cropScale); // Rotate
/* TODO NOT SUPPORTED YET. */
@@ -535,17 +547,17 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories /// The create meta data.
/// </summary>
/// <param name="job">
- /// The job.
- /// </param>
- /// <returns>
- /// The <see cref="Interop.Json.Encode.MetaData"/>.
- /// </returns>
- private static MetaData CreateMetaData(EncodeTask job)
- {
- MetaData metaData = new MetaData();
-
- /* TODO NOT SUPPORTED YET. */
- return metaData;
+ /// The job. + /// </param> + /// <returns> + /// The <see cref="Metadata"/>. + /// </returns> + private static Metadata CreateMetadata(EncodeTask job) + { + Metadata metaData = new Metadata(); + + /* TODO NOT SUPPORTED YET. */ + return metaData; }
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs index 0d4c6b3c2..09f52eb66 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs @@ -44,13 +44,13 @@ namespace HandBrake.ApplicationServices.Services.Scan.Interfaces /// </summary>
public interface IScan
{
- /// <summary>
- /// Scan has Started
- /// </summary>
- event EventHandler ScanStared;
-
- /// <summary>
- /// Scan has completed
+ /// <summary> + /// Scan has Started + /// </summary> + event EventHandler ScanStarted; + + /// <summary> + /// Scan has completed /// </summary>
event ScanCompletedStatus ScanCompleted;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs index 6e16fa937..5eab75520 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs @@ -102,13 +102,13 @@ namespace HandBrake.ApplicationServices.Services.Scan #region Events
- /// <summary>
- /// Scan has Started
- /// </summary>
- public event EventHandler ScanStared;
-
- /// <summary>
- /// Scan has completed
+ /// <summary> + /// Scan has Started + /// </summary> + public event EventHandler ScanStarted; + + /// <summary> + /// Scan has completed /// </summary>
public event ScanCompletedStatus ScanCompleted;
@@ -318,14 +318,14 @@ namespace HandBrake.ApplicationServices.Services.Scan HandBrakeUtils.SetDvdNav(!configuraiton.IsDvdNavDisabled);
- this.ServiceLogMessage("Starting Scan ...");
- this.instance.StartScan(sourcePath.ToString(), previewCount, minDuration, title != 0 ? title : 0);
-
- if (this.ScanStared != null)
- this.ScanStared(this, System.EventArgs.Empty);
- }
- catch (Exception exc)
- {
+ this.ServiceLogMessage("Starting Scan ..."); + this.instance.StartScan(sourcePath.ToString(), previewCount, minDuration, title != 0 ? title : 0); + + if (this.ScanStarted != null) + this.ScanStarted(this, System.EventArgs.Empty); + } + catch (Exception exc) + { this.ServiceLogMessage("Scan Failed ..." + Environment.NewLine + exc);
this.Stop();
@@ -488,28 +488,28 @@ namespace HandBrake.ApplicationServices.Services.Scan Playlist = title.Type == 1 ? string.Format(" {0:d5}.MPLS", title.Playlist).Trim() : null,
FramerateNumerator = title.FrameRate.Num,
FramerateDenominator = title.FrameRate.Den
- };
-
- int currentTrack = 1;
- foreach (ChapterTrack 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)));
+ }; + + 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 (AudioTrack track in title.AudioList)
- {
- converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, string.Empty, track.SampleRate, track.BitRate));
- currentAudioTrack++;
- }
-
- int currentSubtitleTrack = 1;
- foreach (SubtitleTrack track in title.SubtitleList)
- {
- SubtitleType convertedType = new SubtitleType();
-
+ } + + int currentAudioTrack = 1; + foreach (SourceAudioTrack track in title.AudioList) + { + converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, string.Empty, track.SampleRate, track.BitRate)); + currentAudioTrack++; + } + + int currentSubtitleTrack = 1; + foreach (SourceSubtitleTrack track in title.SubtitleList) + { + SubtitleType convertedType = new SubtitleType(); + switch (track.Source)
{
case 0:
diff --git a/win/CS/HandBrakeWPF/Commands/CancelScanCommand.cs b/win/CS/HandBrakeWPF/Commands/CancelScanCommand.cs index adc18ff2d..4bf88f35a 100644 --- a/win/CS/HandBrakeWPF/Commands/CancelScanCommand.cs +++ b/win/CS/HandBrakeWPF/Commands/CancelScanCommand.cs @@ -31,13 +31,13 @@ namespace HandBrakeWPF.Commands /// <param name="ssw">
/// The scan service wrapper.
/// </param>
- public CancelScanCommand(IScan ssw)
- {
- this.scanServiceWrapper = ssw;
- this.scanServiceWrapper.ScanStared += this.ScanServiceWrapperScanStared;
- this.scanServiceWrapper.ScanCompleted += this.ScanServiceWrapperScanCompleted;
- }
-
+ public CancelScanCommand(IScan ssw) + { + this.scanServiceWrapper = ssw; + this.scanServiceWrapper.ScanStarted += this.ScanServiceWrapperScanStared; + this.scanServiceWrapper.ScanCompleted += this.ScanServiceWrapperScanCompleted; + } + /// <summary>
/// The scan service Scan Completed Event Handler.
/// Fires CanExecuteChanged
diff --git a/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs index 008d70dcb..d369728a7 100644 --- a/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs @@ -129,13 +129,13 @@ namespace HandBrakeWPF.ViewModels protected override void OnActivate()
{
this.scanService.ScanCompleted += ScanServiceScanCompleted;
- this.encodeService.EncodeCompleted += EncodeServiceEncodeCompleted;
- this.encodeService.EncodeStatusChanged += this.EncodeServiceEncodeStatusChanged;
- this.scanService.ScanStatusChanged += this.ScanServiceScanStatusChanged;
- this.scanService.ScanStared += this.scanService_ScanStared;
- this.encodeService.EncodeStarted += this.encodeService_EncodeStarted;
- base.OnActivate();
-
+ this.encodeService.EncodeCompleted += EncodeServiceEncodeCompleted; + this.encodeService.EncodeStatusChanged += this.EncodeServiceEncodeStatusChanged; + this.scanService.ScanStatusChanged += this.ScanServiceScanStatusChanged; + this.scanService.ScanStarted += this.scanService_ScanStared; + this.encodeService.EncodeStarted += this.encodeService_EncodeStarted; + base.OnActivate(); + this.NotifyOfPropertyChange(() => this.ScanLog);
this.NotifyOfPropertyChange(() => this.EncodeLog);
}
@@ -182,13 +182,13 @@ namespace HandBrakeWPF.ViewModels protected override void OnDeactivate(bool close)
{
this.scanService.ScanCompleted -= ScanServiceScanCompleted;
- this.encodeService.EncodeCompleted -= EncodeServiceEncodeCompleted;
- this.encodeService.EncodeStatusChanged -= this.EncodeServiceEncodeStatusChanged;
- this.scanService.ScanStatusChanged -= this.ScanServiceScanStatusChanged;
- this.scanService.ScanStared -= this.scanService_ScanStared;
- this.encodeService.EncodeStarted -= this.encodeService_EncodeStarted;
-
- base.OnDeactivate(close);
+ this.encodeService.EncodeCompleted -= EncodeServiceEncodeCompleted; + this.encodeService.EncodeStatusChanged -= this.EncodeServiceEncodeStatusChanged; + this.scanService.ScanStatusChanged -= this.ScanServiceScanStatusChanged; + this.scanService.ScanStarted -= this.scanService_ScanStared; + this.encodeService.EncodeStarted -= this.encodeService_EncodeStarted; + + base.OnDeactivate(close); }
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 2dc706409..e4d20d053 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -260,13 +260,13 @@ namespace HandBrakeWPF.ViewModels this.CurrentTask = new EncodeTask();
this.CurrentTask.PropertyChanged += this.CurrentTask_PropertyChanged;
this.ScannedSource = new Source();
- this.HasSource = false;
-
- // Setup Events
- this.scanService.ScanStared += this.ScanStared;
- this.scanService.ScanCompleted += this.ScanCompleted;
- this.scanService.ScanStatusChanged += this.ScanStatusChanged;
- this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
+ this.HasSource = false; + + // Setup Events + this.scanService.ScanStarted += this.ScanStared; + this.scanService.ScanCompleted += this.ScanCompleted; + this.scanService.ScanStatusChanged += this.ScanStatusChanged; + this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted; this.queueProcessor.QueueCompleted += this.QueueCompleted;
this.queueProcessor.QueueChanged += this.QueueChanged;
this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
@@ -1220,13 +1220,13 @@ namespace HandBrakeWPF.ViewModels public void Shutdown()
{
// Shutdown Service
- this.encodeService.Stop();
-
- // Unsubscribe from Events.
- this.scanService.ScanStared -= this.ScanStared;
- this.scanService.ScanCompleted -= this.ScanCompleted;
- this.scanService.ScanStatusChanged -= this.ScanStatusChanged;
-
+ this.encodeService.Stop(); + + // Unsubscribe from Events. + this.scanService.ScanStarted -= this.ScanStared; + this.scanService.ScanCompleted -= this.ScanCompleted; + this.scanService.ScanStatusChanged -= this.ScanStatusChanged; + this.queueProcessor.QueueCompleted -= this.QueueCompleted;
this.queueProcessor.QueueChanged -= this.QueueChanged;
this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;
|