summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs106
1 files changed, 71 insertions, 35 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
index 6e1fcd675..393702cb2 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
@@ -52,7 +52,6 @@ namespace HandBrakeWPF.ViewModels
{
this.Task = new EncodeTask();
this.SampleRates = new ObservableCollection<string> { "Auto", "48", "44.1", "32", "24", "22.05" };
- this.AudioBitrates = this.GetAppropiateBitrates(AudioEncoder.ffaac, Mixdown.DolbyProLogicII);
this.AudioEncoders = EnumHelper<AudioEncoder>.GetEnumList();
this.AudioMixdowns = EnumHelper<Mixdown>.GetEnumList();
this.SourceTracks = new List<Audio>();
@@ -128,6 +127,14 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// The add all remaining.
+ /// </summary>
+ public void AddAllRemaining()
+ {
+ this.AddAllRemainingTracks();
+ }
+
+ /// <summary>
/// Remove the Selected Track
/// </summary>
/// <param name="track">
@@ -139,6 +146,14 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Clear out the Audio Tracks
+ /// </summary>
+ public void Clear()
+ {
+ this.Task.AudioTracks.Clear();
+ }
+
+ /// <summary>
/// Trigger a Notify Property Changed on the Task to force various UI elements to update.
/// </summary>
public void RefreshTask()
@@ -257,7 +272,7 @@ namespace HandBrakeWPF.ViewModels
/// <summary>
/// Add all source tracks that don't currently exist on the list.
/// </summary>
- private void AddAllRemaining()
+ private void AddAllRemainingTracks()
{
foreach (Audio sourceTrack in this.SourceTracks)
{
@@ -270,6 +285,34 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Add all remaining for selected languages.
+ /// </summary>
+ public void AddAllRemainingForSelectedLanguages()
+ {
+ // Figure out the source tracks we want to add
+ List<Audio> trackList = new List<Audio>();
+ foreach (
+ string language in
+ this.UserSettingService.GetUserSetting<StringCollection>(
+ UserSettingConstants.SelectedLanguages))
+ {
+ // TODO add support for "Add only 1 per language"
+ trackList.AddRange(this.SourceTracks.Where(source => source.Language.Trim() == language));
+ }
+
+ // Add them if they are not already added.
+ foreach (Audio sourceTrack in trackList)
+ {
+ bool found = this.Task.AudioTracks.Any(audioTrack => audioTrack.ScannedTrack == sourceTrack);
+
+ if (!found)
+ {
+ this.Add(sourceTrack);
+ }
+ }
+ }
+
+ /// <summary>
/// Add the required tracks for the current preset
/// </summary>
/// <param name="preset">
@@ -342,48 +385,41 @@ namespace HandBrakeWPF.ViewModels
this.AddAllRemaining();
break;
case 2: // Add Langauges tracks for the additional languages selected, in-order.
-
- // Figure out the source tracks we want to add
- trackList.Clear();
- foreach (
- string language in
- this.UserSettingService.GetUserSetting<StringCollection>(
- UserSettingConstants.SelectedLanguages))
- {
- // TODO add support for "Add only 1 per language"
- trackList.AddRange(this.SourceTracks.Where(source => source.Language.Trim() == language));
- }
-
- // Add them if they are not already added.
- foreach (Audio sourceTrack in trackList)
- {
- bool found = this.Task.AudioTracks.Any(audioTrack => audioTrack.ScannedTrack == sourceTrack);
-
- if (!found)
- {
- this.Add(sourceTrack);
- }
- }
-
+ this.AddAllRemainingForSelectedLanguages();
break;
}
}
/// <summary>
- /// Get Appropiate Bitrates for the selected encoder and mixdown.
+ /// The get language tracks.
/// </summary>
- /// <param name="encoder">
- /// The encoder.
- /// </param>
- /// <param name="mixdown">
- /// The mixdown.
- /// </param>
/// <returns>
- /// A List of valid audio bitrates
+ /// The Users desired audio tracks
/// </returns>
- private IEnumerable<int> GetAppropiateBitrates(AudioEncoder encoder, Mixdown mixdown)
+ private List<Audio> GetLanguageTracks()
{
- return new ObservableCollection<int> { 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 640, 768 };
+ List<Audio> trackList = new List<Audio>();
+ if (this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage) == "Any")
+ {
+ // If we have Any as the preferred Language, just set the first track to all audio tracks.
+ trackList.Add(this.SourceTracks.FirstOrDefault());
+ }
+ else
+ {
+ // Otherwise, fetch the preferred language.
+ foreach (
+ Audio item in
+ this.SourceTracks.Where(
+ item =>
+ item.Language.Contains(
+ this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage))))
+ {
+ trackList.Add(item);
+ break;
+ }
+ }
+
+ return trackList;
}
#endregion