Skip to content

Commit

Permalink
WinGui: Updated app-services library with support for auto-passthru.
Browse files Browse the repository at this point in the history
git-svn-id: svn://localhost/HandBrake/trunk@4412 b64f7644-9d1e-0410-96f1-a4d463321fa5
  • Loading branch information
sr55 committed Jan 15, 2012
1 parent 13c715f commit cd5d2bd
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
6 changes: 6 additions & 0 deletions win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs
Expand Up @@ -29,6 +29,7 @@ public EncodeTask()
this.AudioTracks = new ObservableCollection<AudioTrack>();
this.SubtitleTracks = new ObservableCollection<SubtitleTrack>();
this.ChapterNames = new ObservableCollection<ChapterMarker>();
this.AllowedPassthruOptions = new AllowedPassthru();
}

#region Source
Expand Down Expand Up @@ -262,6 +263,11 @@ public EncodeTask()
/// Gets or sets AudioEncodings.
/// </summary>
public ObservableCollection<AudioTrack> AudioTracks { get; set; }

/// <summary>
/// Gets or sets AllowedPassthruOptions.
/// </summary>
public AllowedPassthru AllowedPassthruOptions { get; set; }
#endregion

#region Subtitles
Expand Down
Expand Up @@ -602,6 +602,44 @@ private static string AudioSettingsQuery(EncodeTask task)
if (audioItems.Trim() != String.Empty)
query += " -D " + audioItems;

// Passthru Settings
if (task.AllowedPassthruOptions != null)
{
string fallbackEncoders = string.Empty;

if (task.AllowedPassthruOptions.AudioAllowAACPass)
{
fallbackEncoders += "aac";
}

if (task.AllowedPassthruOptions.AudioAllowAC3Pass)
{
fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "ac3" : ",ac3";
}

if (task.AllowedPassthruOptions.AudioAllowDTSHDPass)
{
fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "dtshd" : ",dtshd";
}

if (task.AllowedPassthruOptions.AudioAllowDTSPass)
{
fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "dts" : ",dts";
}

if (task.AllowedPassthruOptions.AudioAllowMP3Pass)
{
fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "mp3" : ",mp3";
}

if (!string.IsNullOrEmpty(fallbackEncoders))
{
query += string.Format(" --audio-copy-mask {0}", fallbackEncoders);
}

query += string.Format(" --audio-fallback {0}", Converters.GetCliAudioEncoder(task.AllowedPassthruOptions.AudioEncoderFallback));
}

return query;
}

Expand Down
Expand Up @@ -9,6 +9,7 @@ namespace HandBrake.ApplicationServices.Utilities
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;

using HandBrake.ApplicationServices.Functions;
Expand Down Expand Up @@ -100,6 +101,8 @@ public static EncodeTask Parse(string input)
Match audioSampleRates = Regex.Match(input, @"-R ([0-9a-zA-Z.,]*)"); // Auto = a-z
Match drcValues = Regex.Match(input, @"-D ([0-9.,]*)");
Match gainValues = Regex.Match(input, @"--gain=([0-9.,-]*)");
Match fallbackEncoder = Regex.Match(input, @"--audio-fallback([a-zA-Z0-9:=\s]*)");
Match allowedPassthru = Regex.Match(input, @"--audio-copy-mask([a-zA-Z0-9:,=\s]*)");

// Chapters Tab
Match chapterMarkers = Regex.Match(input, @" -m");
Expand Down Expand Up @@ -139,7 +142,7 @@ public static EncodeTask Parse(string input)
parsed.EndPoint = parsed.StartPoint;
}
}

#endregion

#region Output Settings
Expand Down Expand Up @@ -401,6 +404,23 @@ public static EncodeTask Parse(string input)

parsed.AudioTracks = allAudioTrackInfo;

if (fallbackEncoder.Success)
{
parsed.AllowedPassthruOptions.AudioEncoderFallback =
Converters.GetAudioEncoderFromCliString(fallbackEncoder.Groups[1].ToString().Trim());
}

if (allowedPassthru.Success)
{
string[] allowedEncoders = allowedPassthru.Groups[1].ToString().Trim().Split(',');

parsed.AllowedPassthruOptions.AudioAllowAACPass = allowedEncoders.Contains("aac");
parsed.AllowedPassthruOptions.AudioAllowAC3Pass = allowedEncoders.Contains("ac3");
parsed.AllowedPassthruOptions.AudioAllowDTSHDPass = allowedEncoders.Contains("dtshd");
parsed.AllowedPassthruOptions.AudioAllowDTSPass = allowedEncoders.Contains("dts");
parsed.AllowedPassthruOptions.AudioAllowMP3Pass = allowedEncoders.Contains("mp3");
}

#endregion

#region Chapters Tab
Expand All @@ -422,7 +442,7 @@ public static EncodeTask Parse(string input)
if (x264Profile.Success)
parsed.x264Profile =
Converters.Getx264ProfileFromCli(x264Profile.ToString().Replace("--x264-profile", string.Empty).Replace("=", string.Empty).Trim());

if (x264Tune.Success)
parsed.X264Tune =
Converters.Getx264TuneFromCli(x264Tune.ToString().Replace("--x264-tune", string.Empty).Replace("=", string.Empty).Trim());
Expand Down

0 comments on commit cd5d2bd

Please sign in to comment.