summaryrefslogtreecommitdiffstats
path: root/win/CS
diff options
context:
space:
mode:
authorsr55 <[email protected]>2017-01-13 21:44:08 +0000
committersr55 <[email protected]>2017-01-13 21:44:08 +0000
commit4c8d30ae5f433ac80cc5c55b4853188a0df90db4 (patch)
treeb4e0dbf7f09898182b70c3e0ac5668297d5f45e0 /win/CS
parent1ff916a4f3d1031f38d5e0dfa64877f2e0407970 (diff)
WinGui: Fix an issue which prevented the GUI from parsing presets with hb_presets_read_file_json becaused it returned an unnamed list when reading plist files. It can now handle PresetList or just unnamed Json List []
Also made the parser more tolerant to casing and unset and unexpected values.
Diffstat (limited to 'win/CS')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs7
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs4
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs4
3 files changed, 11 insertions, 4 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs
index 38ebb3515..adc9bcbd6 100644
--- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs
@@ -66,7 +66,14 @@ namespace HandBrake.ApplicationServices.Interop
if (!string.IsNullOrEmpty(presetJson))
{
+ // Check to see if we have a list of presets.
+ if (presetJson.StartsWith("["))
+ {
+ presetJson = "{ \"PresetList\":" + presetJson + " } ";
+ }
+
PresetTransportContainer preset = JsonConvert.DeserializeObject<PresetTransportContainer>(presetJson);
+
return preset;
}
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
index f3b1bd56f..4a2c973c6 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
@@ -309,7 +309,7 @@ namespace HandBrakeWPF.Services.Presets.Factories
preset.Task.VideoTunes.Add(new VideoTune(item, item));
}
}
- preset.Task.Framerate = importedPreset.VideoFramerate == "auto" || string.IsNullOrEmpty(importedPreset.VideoFramerate)
+ preset.Task.Framerate = importedPreset.VideoFramerate == "auto" || importedPreset.VideoFramerate == "Same as source" || string.IsNullOrEmpty(importedPreset.VideoFramerate)
? (double?)null
: double.Parse(importedPreset.VideoFramerate, CultureInfo.InvariantCulture);
string parsedValue = importedPreset.VideoFramerateMode;
@@ -403,7 +403,7 @@ namespace HandBrakeWPF.Services.Presets.Factories
track.MixDown = HandBrakeEncoderHelpers.GetMixdown(audioTrack.AudioMixdown);
// track.AudioNormalizeMixLevel = audioTrack.AudioNormalizeMixLevel;
- track.SampleRate = audioTrack.AudioSamplerate == "auto" ? 0 : double.Parse(audioTrack.AudioSamplerate);
+ track.SampleRate = string.IsNullOrEmpty(audioTrack.AudioSamplerate) || audioTrack.AudioSamplerate.ToLower() == "auto" ? 0 : double.Parse(audioTrack.AudioSamplerate);
track.EncoderRateType = audioTrack.AudioTrackQualityEnable ? AudioEncoderRateType.Quality : AudioEncoderRateType.Bitrate;
track.Quality = audioTrack.AudioTrackQuality;
diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
index 39aab77e0..32f0b8dbd 100644
--- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
@@ -713,8 +713,8 @@ namespace HandBrakeWPF.ViewModels
HBVideoEncoder encoder = HandBrakeEncoderHelpers.VideoEncoders.FirstOrDefault(s => s.ShortName == EnumHelper<VideoEncoder>.GetShortName(this.SelectedVideoEncoder));
if (encoder != null)
{
- string preset = encoder.Presets[value];
- this.VideoPreset = new VideoPreset(preset, preset);
+ string preset = value >= 0 ? encoder.Presets[value] : null;
+ this.VideoPreset = preset != null ?new VideoPreset(preset, preset) : this.VideoPresets.FirstOrDefault();
}
this.NotifyOfPropertyChange(() => this.VideoPresetValue);