diff options
author | sr55 <[email protected]> | 2013-08-22 17:02:19 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-08-22 17:02:19 +0000 |
commit | c0ad015d6ef51b4edf229d98803d35c781e8b67f (patch) | |
tree | 5e40c8b802fbbfe03c3a6b27be80dcfe44d56a72 /win/CS/HandBrake.ApplicationServices | |
parent | 88cfc4524c3bb09c1316219c1f83517b35697736 (diff) |
WinGui: Strip out legacy CLI scan code.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5732 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
14 files changed, 11 insertions, 1416 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 42952d432..d884131d0 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -95,7 +95,6 @@ <Compile Include="Factories\PlistPresetFactory.cs" />
<Compile Include="Isolation\BackgroundServiceConnector.cs" />
<Compile Include="Isolation\IsolatedEncodeService.cs" />
- <Compile Include="Isolation\IsolatedScanService.cs" />
<Compile Include="LibHb\AudioVideoHelpers.cs" />
<Compile Include="Services\Interfaces\IEncodeServiceWrapper.cs" />
<Compile Include="Services\Interfaces\IHbServiceCallback.cs" />
@@ -126,10 +125,8 @@ <Compile Include="Model\QueueTask.cs" />
<Compile Include="Model\Encoding\SubtitleType.cs" />
<Compile Include="Parsing\Audio.cs" />
- <Compile Include="Parsing\AudioHelper.cs" />
<Compile Include="Parsing\Chapter.cs" />
<Compile Include="Parsing\Source.cs" />
- <Compile Include="Parsing\Parser.cs" />
<Compile Include="Parsing\Subtitle.cs" />
<Compile Include="Parsing\Title.cs" />
<Compile Include="Properties\Resources.Designer.cs">
@@ -149,7 +146,6 @@ <Compile Include="Services\LibScan.cs" />
<Compile Include="Services\PresetService.cs" />
<Compile Include="Services\QueueProcessor.cs" />
- <Compile Include="Services\ScanService.cs" />
<Compile Include="Services\UserSettingService.cs" />
<Compile Include="ASUserSettingConstants.cs" />
<Compile Include="Utilities\AppcastReader.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs b/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs index 4044e8a61..c92946bc1 100644 --- a/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs +++ b/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs @@ -139,8 +139,6 @@ namespace HandBrake.ApplicationServices.Isolation #region Implemented Interfaces
- #region IDisposable
-
/// <summary>
/// The dispose.
/// </summary>
@@ -149,37 +147,6 @@ namespace HandBrake.ApplicationServices.Isolation this.Service.Unsubscribe();
}
- #endregion
-
- #region IHbServiceCallback
-
- /// <summary>
- /// The scan completed.
- /// </summary>
- /// <param name="eventArgs">
- /// The event args.
- /// </param>
- public virtual void ScanCompletedCallback(ScanCompletedEventArgs eventArgs)
- {
- }
-
- /// <summary>
- /// The scan progress.
- /// </summary>
- /// <param name="eventArgs">
- /// The event args.
- /// </param>
- public virtual void ScanProgressCallback(ScanProgressEventArgs eventArgs)
- {
- }
-
- /// <summary>
- /// The scan started callback.
- /// </summary>
- public virtual void ScanStartedCallback()
- {
- }
-
/// <summary>
/// The encode progress callback.
/// </summary>
@@ -208,7 +175,5 @@ namespace HandBrake.ApplicationServices.Isolation }
#endregion
-
- #endregion
}
}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedScanService.cs b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedScanService.cs deleted file mode 100644 index dcef0cc44..000000000 --- a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedScanService.cs +++ /dev/null @@ -1,216 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="IsolatedScanService.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>
-// Isolated Scan Service
-// This is an implementation of the IScan implementation that runs scans on a seperate process
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Isolation
-{
- using System;
- using System.Threading;
-
- using HandBrake.ApplicationServices.EventArgs;
- using HandBrake.ApplicationServices.Exceptions;
- using HandBrake.ApplicationServices.Parsing;
- using HandBrake.ApplicationServices.Services.Interfaces;
-
- /// <summary>
- /// Isolated Scan Service.
- /// This is an implementation of the IScan implementation that runs scans on a seperate process
- /// </summary>
- public class IsolatedScanService : BackgroundServiceConnector, IScan
- {
- #region Constants and Fields
-
- /// <summary>
- /// The post action.
- /// </summary>
- private Action<bool> postScanAction;
-
- #endregion
-
- #region Events
-
- /// <summary>
- /// The scan completed.
- /// </summary>
- public event ScanCompletedStatus ScanCompleted;
-
- /// <summary>
- /// The scan stared.
- /// </summary>
- public event EventHandler ScanStared;
-
- /// <summary>
- /// The scan status changed.
- /// </summary>
- public event ScanProgessStatus ScanStatusChanged;
-
- #endregion
-
- /// <summary>
- /// Initializes a new instance of the <see cref="IsolatedScanService"/> class.
- /// </summary>
- /// <param name="port">
- /// The port.
- /// </param>
- public IsolatedScanService(string port)
- {
- try
- {
- if (this.CanConnect())
- {
- this.Connect(port);
- }
- }
- catch (Exception exception)
- {
- throw new GeneralApplicationException("Unable to connect to scan worker process.", "Try restarting HandBrake", exception);
- }
- }
-
- #region Properties
-
- /// <summary>
- /// Gets ActivityLog.
- /// </summary>
- public string ActivityLog
- {
- get
- {
- return this.Service.ScanActivityLog;
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether IsScanning.
- /// </summary>
- public bool IsScanning
- {
- get
- {
- return this.Service.IsScanning;
- }
- }
-
- /// <summary>
- /// Gets the Souce Data.
- /// </summary>
- public Source SouceData
- {
- get
- {
- return this.Service.SouceData;
- }
- }
-
- #endregion
-
- #region Public Methods
-
- /// <summary>
- /// The scan completed callback.
- /// </summary>
- /// <param name="eventArgs">
- /// The event args.
- /// </param>
- public override void ScanCompletedCallback(ScanCompletedEventArgs eventArgs)
- {
- if (this.postScanAction != null)
- {
- this.postScanAction(true);
- }
-
- if (this.ScanCompleted != null)
- {
- ThreadPool.QueueUserWorkItem(delegate { this.ScanCompleted(this, eventArgs); });
- }
-
- base.ScanCompletedCallback(eventArgs);
- }
-
- /// <summary>
- /// The scan progress callback.
- /// </summary>
- /// <param name="eventArgs">
- /// The event args.
- /// </param>
- public override void ScanProgressCallback(ScanProgressEventArgs eventArgs)
- {
- if (this.ScanStatusChanged != null)
- {
- ThreadPool.QueueUserWorkItem(delegate { this.ScanStatusChanged(this, eventArgs); });
- }
-
- base.ScanProgressCallback(eventArgs);
- }
-
- /// <summary>
- /// The scan started callback.
- /// </summary>
- public override void ScanStartedCallback()
- {
- if (this.ScanStared != null)
- {
- ThreadPool.QueueUserWorkItem(delegate { this.ScanStared(this, EventArgs.Empty); });
- }
-
- base.ScanStartedCallback();
- }
-
- #endregion
-
- #region Implemented Interfaces
-
- #region IScan
-
- /// <summary>
- /// Take a Scan Log file, and process it as if it were from the CLI.
- /// </summary>
- /// <param name="path">
- /// The path to the log file.
- /// </param>
- public void DebugScanLog(string path)
- {
- throw new NotImplementedException("Not available in process isolation mode!");
- }
-
- /// <summary>
- /// Scan a Source Path.
- /// Title 0: scan all
- /// </summary>
- /// <param name="sourcePath">
- /// Path to the file to scan
- /// </param>
- /// <param name="title">
- /// int title number. 0 for scan all
- /// </param>
- /// <param name="previewCount">
- /// The preview Count.
- /// </param>
- /// <param name="postAction">
- /// The post Action.
- /// </param>
- public void Scan(string sourcePath, int title, int previewCount, Action<bool> postAction)
- {
- this.postScanAction = postAction;
- this.Service.ScanSource(sourcePath, title, previewCount);
- }
-
- /// <summary>
- /// Kill the scan
- /// </summary>
- public void Stop()
- {
- this.Service.StopScan();
- }
-
- #endregion
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Audio.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Audio.cs index b78ca5ad8..d925d2d3a 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Audio.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Audio.cs @@ -128,10 +128,12 @@ namespace HandBrake.ApplicationServices.Parsing {
return false;
}
+
if (ReferenceEquals(this, other))
{
return true;
}
+
return other.TrackNumber == this.TrackNumber && object.Equals(other.Language, this.Language) && object.Equals(other.LanguageCode, this.LanguageCode) && object.Equals(other.Format, this.Format);
}
@@ -148,14 +150,17 @@ namespace HandBrake.ApplicationServices.Parsing {
return false;
}
+
if (ReferenceEquals(this, obj))
{
return true;
}
+
if (obj.GetType() != typeof(Audio))
{
return false;
}
+
return Equals((Audio)obj);
}
diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/AudioHelper.cs b/win/CS/HandBrake.ApplicationServices/Parsing/AudioHelper.cs deleted file mode 100644 index 43c331337..000000000 --- a/win/CS/HandBrake.ApplicationServices/Parsing/AudioHelper.cs +++ /dev/null @@ -1,95 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="AudioHelper.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 Audio Helper Class
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Parsing
-{
- using System.Collections.Generic;
- using System.IO;
- using System.Text.RegularExpressions;
-
- /// <summary>
- /// An Audio Helper Class
- /// </summary>
- public class AudioHelper
- {
- /// <summary>
- /// Gets A Dummy Not Found Track
- /// </summary>
- public static Audio NoneFound
- {
- get
- {
- return new Audio { Description = "None Found" };
- }
- }
-
- /// <summary>
- /// Parse the CLI input to an Audio Track object
- /// </summary>
- /// <param name="output">
- /// The output.
- /// </param>
- /// <returns>
- /// An Audio Track obkect
- /// </returns>
- public static Audio Parse(StringReader output)
- {
- string audioTrack = output.ReadLine();
- Match m = Regex.Match(audioTrack, @"^ \+ ([0-9]*), ([A-Za-z0-9,\s]*) \((.*)\) \((.*)\)");
- Match track = Regex.Match(audioTrack, @"^ \+ ([0-9]*), ([A-Za-z0-9,\s]*) \((.*)\)"); // ID and Language
- Match iso639_2 = Regex.Match(audioTrack, @"iso639-2: ([a-zA-Z]*)\)");
- Match samplerate = Regex.Match(audioTrack, @"([0-9]*)Hz");
- Match bitrate = Regex.Match(audioTrack, @"([0-9]*)bps");
-
- string subformat = m.Groups[4].Value.Trim().Contains("iso639") ? null : m.Groups[4].Value;
- string samplerateVal = samplerate.Success ? samplerate.Groups[0].Value.Replace("Hz", string.Empty).Trim() : "0";
- string bitrateVal = bitrate.Success ? bitrate.Groups[0].Value.Replace("bps", string.Empty).Trim() : "0";
-
- if (track.Success)
- {
- Audio thisTrack = new Audio
- {
- TrackNumber = int.Parse(track.Groups[1].Value.Trim()),
- Language = track.Groups[2].Value,
- Format = m.Groups[3].Value,
- Description = subformat,
- SampleRate = int.Parse(samplerateVal),
- Bitrate = int.Parse(bitrateVal),
- LanguageCode = iso639_2.Value.Replace("iso639-2: ", string.Empty).Replace(")", string.Empty)
- };
- return thisTrack;
- }
-
- return null;
- }
-
- /// <summary>
- /// Pase a list of audio tracks
- /// </summary>
- /// <param name="output">
- /// The output.
- /// </param>
- /// <returns>
- /// An array of audio tracks
- /// </returns>
- public static Audio[] ParseList(StringReader output)
- {
- var tracks = new List<Audio>();
- while (true)
- {
- Audio thisTrack = Parse(output);
- if (thisTrack != null)
- tracks.Add(thisTrack);
- else
- break;
- }
- return tracks.ToArray();
- }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Chapter.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Chapter.cs index 00870552f..0b0a741a0 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Chapter.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Chapter.cs @@ -10,9 +10,7 @@ namespace HandBrake.ApplicationServices.Parsing
{
using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text.RegularExpressions;
+ using System.Globalization;
/// <summary>
/// An object representing a Chapter aosciated with a Title, in a DVD
@@ -61,69 +59,12 @@ namespace HandBrake.ApplicationServices.Parsing public TimeSpan Duration { get; set; }
/// <summary>
- /// Parse a CLI string to a Chapter object
- /// </summary>
- /// <param name="output">
- /// The output.
- /// </param>
- /// <returns>
- /// A chapter Object
- /// </returns>
- public static Chapter Parse(StringReader output)
- {
- // TODO add support for reading chapter names to the regex.
- string line = output.ReadLine();
- Match m = Regex.Match(line, @"^ \+ ([0-9]*): cells ([0-9]*)->([0-9]*), ([0-9]*) blocks, duration ([0-9]{2}:[0-9]{2}:[0-9]{2})");
- if (m.Success)
- {
- var thisChapter = new Chapter
- {
- ChapterNumber = int.Parse(m.Groups[1].Value.Trim()),
- ChapterName = string.Empty,
- Duration = TimeSpan.Parse(m.Groups[5].Value)
- };
- return thisChapter;
- }
- return null;
- }
-
- /// <summary>
- /// Prase a list of strings / chatpers
- /// </summary>
- /// <param name="output">
- /// The output.
- /// </param>
- /// <returns>
- /// An array of chapter objects
- /// </returns>
- public static Chapter[] ParseList(StringReader output)
- {
- var chapters = new List<Chapter>();
-
- // this is to read the " + chapters:" line from the buffer
- // so we can start reading the chapters themselvs
- output.ReadLine();
-
- while (true)
- {
- // Start of the chapter list for this Title
- Chapter thisChapter = Parse(output);
-
- if (thisChapter != null)
- chapters.Add(thisChapter);
- else
- break;
- }
- return chapters.ToArray();
- }
-
- /// <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 ChapterNumber.ToString();
+ return ChapterNumber.ToString(CultureInfo.InvariantCulture);
}
}
}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Parser.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Parser.cs deleted file mode 100644 index 7cb7100fc..000000000 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Parser.cs +++ /dev/null @@ -1,134 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Parser.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>
-// A delegate to handle custom events regarding data being parsed from the buffer
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Parsing
-{
- using System;
- using System.Globalization;
- using System.IO;
- using System.Text;
- using System.Text.RegularExpressions;
-
- /// <summary>
- /// A delegate to handle custom events regarding data being parsed from the buffer
- /// </summary>
- /// <param name="sender">The object which raised this delegate</param>
- /// <param name="data">The data parsed from the stream</param>
- public delegate void DataReadEventHandler(object sender, string data);
-
- /// <summary>
- /// A delegate to handle events regarding progress during DVD scanning
- /// </summary>
- /// <param name="sender">The object who's raising the event</param>
- /// <param name="currentTitle">The title number currently being processed</param>
- /// <param name="titleCount">The total number of titiles to be processed</param>
- /// <param name="percentage">Percentage complete.</param>
- public delegate void ScanProgressEventHandler(object sender, int currentTitle, int titleCount, decimal percentage);
-
- /// <summary>
- /// A delegate to handle encode progress updates // EXPERIMENTAL
- /// </summary>
- /// <param name="sender">The object which raised the event</param>
- /// <param name="currentTask">The current task being processed from the queue</param>
- /// <param name="taskCount">The total number of tasks in queue</param>
- /// <param name="percentComplete">The percentage this task is complete</param>
- /// <param name="currentFps">The current encoding fps</param>
- /// <param name="averageFps">The average encoding fps for this task</param>
- /// <param name="timeRemaining">The estimated time remaining for this task to complete</param>
- public delegate void EncodeProgressEventHandler(object sender, int currentTask, int taskCount, float percentComplete, float currentFps, float averageFps, string timeRemaining);
-
- /// <summary>
- /// A simple wrapper around a StreamReader to keep track of the entire output from a cli process
- /// </summary>
- public class Parser : StreamReader
- {
- /// <summary>
- /// The Buffer StringBuilder
- /// </summary>
- private readonly StringBuilder buffer = new StringBuilder(string.Empty);
-
- /// <summary>
- /// Initializes a new instance of the <see cref="Parser"/> class.
- /// Default constructor for this object
- /// </summary>
- /// <param name="baseStream">
- /// The stream to parse from
- /// </param>
- public Parser(Stream baseStream) : base(baseStream, Encoding.Default)
- {
- }
-
- /// <summary>
- /// Raised upon a new line being read from stdout/stderr
- /// </summary>
- public event DataReadEventHandler OnReadLine;
-
- /// <summary>
- /// Raised upon the entire stdout/stderr stream being read in a single call
- /// </summary>
- public event DataReadEventHandler OnReadToEnd;
-
- /// <summary>
- /// Raised upon the catching of a "Scanning title # of #..." in the stream
- /// </summary>
- public event ScanProgressEventHandler OnScanProgress;
-
-
- /// <summary>
- /// Gets the buffer of data that came from the CLI standard input/error
- /// </summary>
- public StringBuilder Buffer
- {
- get { return buffer; }
- }
-
- /// <summary>
- /// Read a line from standard in/err
- /// </summary>
- /// <returns>
- /// The read line
- /// </returns>
- public override string ReadLine()
- {
- string tmp = base.ReadLine();
-
- Match m = null;
- if (tmp != null && tmp.Contains("Scanning title"))
- m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)([a-z0-9 ,]*), ([0-9.]*)");
- else if (!string.IsNullOrEmpty(tmp))
- buffer.Append(tmp + Environment.NewLine);
-
- if (OnReadLine != null)
- OnReadLine(this, tmp);
-
- if (m != null)
- if (m.Success && OnScanProgress != null)
- OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), decimal.Parse(m.Groups[4].Value, CultureInfo.InvariantCulture));
-
- return tmp;
- }
-
- /// <summary>
- /// Read to the end of the input stream
- /// </summary>
- /// <returns>
- /// A string of the input data
- /// </returns>
- public override string ReadToEnd()
- {
- string tmp = base.ReadToEnd();
-
- buffer.Append(tmp + Environment.NewLine);
- if (OnReadToEnd != null)
- OnReadToEnd(this, tmp);
-
- return tmp;
- }
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Source.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Source.cs index 93aa13a0c..5f721e3a6 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Source.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Source.cs @@ -10,11 +10,8 @@ namespace HandBrake.ApplicationServices.Parsing
{
using System.Collections.Generic;
- using System.IO;
using System.Runtime.Serialization;
- using HandBrake.ApplicationServices.Services.Interfaces;
-
/// <summary>
/// An object representing a scanned DVD
/// </summary>
@@ -44,33 +41,6 @@ namespace HandBrake.ApplicationServices.Parsing public List<Title> Titles { get; set; }
/// <summary>
- /// Parse the StreamReader output into a List of Titles
- /// </summary>
- /// <param name="output">
- /// The output.
- /// </param>
- /// <param name="isDvdNavDisabled">
- /// The is Dvd Nav Disabled.
- /// </param>
- /// <returns>
- /// A DVD object which contains a list of title inforamtion
- /// </returns>
- public static Source Parse(StreamReader output, bool isDvdNavDisabled)
- {
- var thisDVD = new Source();
-
- while (!output.EndOfStream)
- {
- if ((char) output.Peek() == '+')
- thisDVD.Titles.AddRange(Title.ParseList(output.ReadToEnd(), isDvdNavDisabled));
- else
- output.ReadLine();
- }
-
- return thisDVD;
- }
-
- /// <summary>
/// Copy this Source to another Source Model
/// </summary>
/// <param name="source">
diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Subtitle.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Subtitle.cs index 0a68476f4..e40734b55 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Subtitle.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Subtitle.cs @@ -10,9 +10,6 @@ namespace HandBrake.ApplicationServices.Parsing
{
using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text.RegularExpressions;
using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.ApplicationServices.Utilities;
@@ -52,7 +49,6 @@ namespace HandBrake.ApplicationServices.Parsing this.SubtitleType = subtitleType;
}
-
/// <summary>
/// Gets or sets the track number of this Subtitle
/// </summary>
@@ -101,89 +97,6 @@ namespace HandBrake.ApplicationServices.Parsing }
/// <summary>
- /// Parse the input strings related to subtitles
- /// </summary>
- /// <param name="output">
- /// The output.
- /// </param>
- /// <returns>
- /// A Subitle object
- /// </returns>
- public static Subtitle Parse(StringReader output)
- {
- string curLine = output.ReadLine();
-
- // + 1, English (iso639-2: eng) (Text)(SSA)
- // + 1, English (iso639-2: eng) (Text)(UTF-8)
- Match m = Regex.Match(curLine, @"^ \+ ([0-9]*), ([A-Za-z, ]*) \((.*)\) \(([a-zA-Z]*)\)\(([a-zA-Z0-9\-]*)\)");
-
- if (m.Success && !curLine.Contains("HandBrake has exited."))
- {
- var thisSubtitle = new Subtitle
- {
- TrackNumber = int.Parse(m.Groups[1].Value.Trim()),
- Language = m.Groups[2].Value,
- LanguageCode = m.Groups[3].Value,
- };
-
- switch (m.Groups[5].Value)
- {
- case "VOBSUB":
- thisSubtitle.SubtitleType = SubtitleType.VobSub;
- break;
- case "SRT":
- thisSubtitle.SubtitleType = SubtitleType.SRT;
- break;
- case "CC":
- thisSubtitle.SubtitleType = SubtitleType.CC;
- break;
- case "UTF-8":
- thisSubtitle.SubtitleType = SubtitleType.UTF8Sub;
- break;
- case "TX3G":
- thisSubtitle.SubtitleType = SubtitleType.TX3G;
- break;
- case "SSA":
- thisSubtitle.SubtitleType = SubtitleType.SSA;
- break;
- case "PGS":
- thisSubtitle.SubtitleType = SubtitleType.PGS;
- break;
- default:
- thisSubtitle.SubtitleType = SubtitleType.Unknown;
- break;
- }
-
- return thisSubtitle;
- }
- return null;
- }
-
- /// <summary>
- /// Parse a list of Subtitle tracks from an input string.
- /// </summary>
- /// <param name="output">
- /// The output.
- /// </param>
- /// <returns>
- /// An array of Subtitle objects
- /// </returns>
- public static IEnumerable<Subtitle> ParseList(StringReader output)
- {
- var subtitles = new List<Subtitle>();
- while ((char)output.Peek() != '+')
- {
- Subtitle thisSubtitle = Parse(output);
-
- if (thisSubtitle != null)
- subtitles.Add(thisSubtitle);
- else
- break;
- }
- return subtitles.ToArray();
- }
-
- /// <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>
@@ -227,14 +140,17 @@ namespace HandBrake.ApplicationServices.Parsing {
return false;
}
+
if (ReferenceEquals(this, obj))
{
return true;
}
+
if (obj.GetType() != typeof(Subtitle))
{
return false;
}
+
return Equals((Subtitle)obj);
}
diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs index af5788f41..969640b20 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs @@ -11,10 +11,7 @@ namespace HandBrake.ApplicationServices.Parsing {
using System;
using System.Collections.Generic;
- using System.Globalization;
- using System.IO;
using System.Linq;
- using System.Text.RegularExpressions;
using HandBrake.Interop.Model;
@@ -115,138 +112,6 @@ namespace HandBrake.ApplicationServices.Parsing #endregion
/// <summary>
- /// Parse the Title Information
- /// </summary>
- /// <param name="output">
- /// A StringReader of output data
- /// </param>
- /// <param name="isDvdNavDisabled">
- /// The is Dvd Nav Disabled.
- /// </param>
- /// <returns>
- /// A Title Object
- /// </returns>
- public static Title Parse(StringReader output, bool isDvdNavDisabled)
- {
- var thisTitle = new Title();
- string nextLine = output.ReadLine();
-
- // Get the Title Number
- Match m = Regex.Match(nextLine, @"^\+ title ([0-9]*):");
- if (m.Success)
- thisTitle.TitleNumber = int.Parse(m.Groups[1].Value.Trim());
- nextLine = output.ReadLine();
-
- // Detect if this is the main feature
- m = Regex.Match(nextLine, @" \+ Main Feature");
- if (m.Success)
- {
- thisTitle.MainTitle = true;
- nextLine = output.ReadLine();
- }
-
- // Get the stream name for file import
- m = Regex.Match(nextLine, @"^ \+ stream:");
- if (m.Success)
- {
- thisTitle.SourceName = nextLine.Replace("+ stream:", string.Empty).Trim();
- nextLine = output.ReadLine();
- }
-
- // Playlist
- m = Regex.Match(nextLine, @"^ \+ playlist:");
- if (m.Success)
- {
- thisTitle.Playlist = nextLine.Replace("+ playlist:", string.Empty).Trim();
- nextLine = output.ReadLine();
- }
-
- // Jump over the VTS and blocks line
- m = Regex.Match(nextLine, @"^ \+ vts:");
- if (nextLine.Contains("blocks") || nextLine.Contains("+ vts "))
- {
- nextLine = output.ReadLine();
- }
-
- // Multi-Angle Support if LibDvdNav is enabled
- m = Regex.Match(nextLine, @" \+ angle\(s\) ([0-9]*)");
- if (m.Success)
- {
- string angleList = m.Value.Replace("+ angle(s) ", string.Empty).Trim();
- int angleCount;
- int.TryParse(angleList, out angleCount);
-
- thisTitle.AngleCount = angleCount;
- nextLine = output.ReadLine();
- }
-
- // Get duration for this title
- m = Regex.Match(nextLine, @"^ \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})");
- if (m.Success)
- thisTitle.Duration = TimeSpan.Parse(m.Groups[1].Value);
-
- // Get resolution, aspect ratio and FPS for this title
- m = Regex.Match(output.ReadLine(), @"^ \+ size: ([0-9]*)x([0-9]*), pixel aspect: ([0-9]*)/([0-9]*), display aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");
- if (m.Success)
- {
- thisTitle.Resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
- thisTitle.ParVal = new Size(int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value));
- thisTitle.AspectRatio = Math.Round(float.Parse(m.Groups[5].Value, CultureInfo.InvariantCulture), 2);
- thisTitle.Fps = float.Parse(m.Groups[6].Value, CultureInfo.InvariantCulture);
- }
-
- // Get autocrop region for this title
- m = Regex.Match(output.ReadLine(), @"^ \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");
- if (m.Success)
- {
- thisTitle.AutoCropDimensions = new Cropping
- {
- Top = int.Parse(m.Groups[1].Value),
- Bottom = int.Parse(m.Groups[2].Value),
- Left = int.Parse(m.Groups[3].Value),
- Right = int.Parse(m.Groups[4].Value)
- };
- }
-
- thisTitle.Chapters.AddRange(Chapter.ParseList(output));
-
- thisTitle.AudioTracks.AddRange(AudioHelper.ParseList(output));
-
- thisTitle.Subtitles.AddRange(Subtitle.ParseList(output));
-
- return thisTitle;
- }
-
- /// <summary>
- /// Return a list of parsed titles
- /// </summary>
- /// <param name="output">
- /// The Output
- /// </param>
- /// <param name="isDvdNavDisabled">
- /// The is Dvd Nav Disabled.
- /// </param>
- /// <returns>
- /// A List of titles
- /// </returns>
- public static Title[] ParseList(string output, bool isDvdNavDisabled)
- {
- var titles = new List<Title>();
- var sr = new StringReader(output);
-
- while (sr.Peek() == '+' || sr.Peek() == ' ')
- {
- // If the the character is a space, then chances are the line
- if (sr.Peek() == ' ') // If the character is a space, then chances are it's the combing detected line.
- sr.ReadLine(); // Skip over it
- else
- titles.Add(Parse(sr, isDvdNavDisabled));
- }
-
- return titles.ToArray();
- }
-
- /// <summary>
/// Calcuate the Duration
/// </summary>
/// <param name="startPoint">The Start Point (Chapters)</param>
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IHbServiceCallback.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IHbServiceCallback.cs index 1d10e3062..6f4d9a260 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IHbServiceCallback.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IHbServiceCallback.cs @@ -20,30 +20,6 @@ namespace HandBrake.ApplicationServices.Services.Interfaces public interface IHbServiceCallback
{
/// <summary>
- /// The scan progress.
- /// </summary>
- /// <param name="eventArgs">
- /// The event args.
- /// </param>
- [OperationContract(IsOneWay = true)]
- void ScanProgressCallback(ScanProgressEventArgs eventArgs);
-
- /// <summary>
- /// The scan completed.
- /// </summary>
- /// <param name="eventArgs">
- /// The event args.
- /// </param>
- [OperationContract(IsOneWay = true)]
- void ScanCompletedCallback(ScanCompletedEventArgs eventArgs);
-
- /// <summary>
- /// The scan started callback.
- /// </summary>
- [OperationContract(IsOneWay = true)]
- void ScanStartedCallback();
-
- /// <summary>
/// The encode progress callback.
/// </summary>
/// <param name="eventArgs">
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs index 60d9d0b57..9aa1f1cb7 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IServerService.cs @@ -13,7 +13,6 @@ namespace HandBrake.ApplicationServices.Services.Interfaces using System.ServiceModel;
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Parsing;
/// <summary>
/// The HandBrakeService interface.
@@ -25,33 +24,9 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// Gets the activity log.
/// </summary>
[DataMember]
- string ScanActivityLog { get; }
-
- /// <summary>
- /// Gets the activity log.
- /// </summary>
- [DataMember]
string EncodeActivityLog { get; }
/// <summary>
- /// Gets the souce data.
- /// </summary>
- Source SouceData
- {
- [OperationContract]
- get;
- }
-
- /// <summary>
- /// Gets a value indicating whether is scanning.
- /// </summary>
- bool IsScanning
- {
- [OperationContract]
- get;
- }
-
- /// <summary>
/// Gets a value indicating whether is encoding.
/// </summary>
bool IsEncoding
@@ -74,21 +49,6 @@ namespace HandBrake.ApplicationServices.Services.Interfaces void Stop();
/// <summary>
- /// The scan source.
- /// </summary>
- /// <param name="path">
- /// The path.
- /// </param>
- /// <param name="title">
- /// The title.
- /// </param>
- /// <param name="previewCount">
- /// The preview Count.
- /// </param>
- [OperationContract]
- void ScanSource(string path, int title, int previewCount);
-
- /// <summary>
/// Start and Encode
/// </summary>
/// <param name="job">
@@ -116,12 +76,6 @@ namespace HandBrake.ApplicationServices.Services.Interfaces void StopEncode();
/// <summary>
- /// Stop the scan.
- /// </summary>
- [OperationContract]
- void StopScan();
-
- /// <summary>
/// Subscribe for callbacks from the called functions
/// </summary>
/// <returns>
diff --git a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs deleted file mode 100644 index 1ad531dfe..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs +++ /dev/null @@ -1,389 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="ScanService.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>
-// Scan a Source
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services
-{
- using System;
- using System.Diagnostics;
- using System.IO;
- using System.Text;
- using System.Threading;
- using System.Windows.Forms;
-
- using HandBrake.ApplicationServices.EventArgs;
- using HandBrake.ApplicationServices.Exceptions;
- using HandBrake.ApplicationServices.Parsing;
- using HandBrake.ApplicationServices.Services.Interfaces;
- using HandBrake.ApplicationServices.Utilities;
-
- using Parser = HandBrake.ApplicationServices.Parsing.Parser;
-
- /// <summary>
- /// Scan a Source
- /// </summary>
- public class ScanService : IScan
- {
- #region Private Variables
-
- /// <summary>
- /// The User Setting Service
- /// </summary>
- private readonly IUserSettingService userSettingService;
-
- /// <summary>
- /// The Log File Header
- /// </summary>
- private readonly StringBuilder header;
-
- /// <summary>
- /// The CLI data parser
- /// </summary>
- private Parser readData;
-
- /// <summary>
- /// The Log Buffer
- /// </summary>
- private StringBuilder logBuffer;
-
- /// <summary>
- /// The Process belonging to the CLI
- /// </summary>
- private Process hbProc;
-
- /// <summary>
- /// The stop scan.
- /// </summary>
- private bool cancelScan;
-
- #endregion
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ScanService"/> class.
- /// </summary>
- /// <param name="userSettingService">
- /// The user Setting Service.
- /// </param>
- public ScanService(IUserSettingService userSettingService)
- {
- this.userSettingService = userSettingService;
- this.logBuffer = new StringBuilder();
-
- header = GeneralUtilities.CreateCliLogHeader();
- }
-
- #region Events
-
- /// <summary>
- /// Scan has Started
- /// </summary>
- public event EventHandler ScanStared;
-
- /// <summary>
- /// Scan has completed
- /// </summary>
- public event ScanCompletedStatus ScanCompleted;
-
- /// <summary>
- /// Encode process has progressed
- /// </summary>
- public event ScanProgessStatus ScanStatusChanged;
-
- #endregion
-
- #region Public Properties
-
- /// <summary>
- /// Gets a value indicating whether IsScanning.
- /// </summary>
- public bool IsScanning { get; private set; }
-
- /// <summary>
- /// Gets the Souce Data.
- /// </summary>
- public Source SouceData { get; private set; }
-
- /// <summary>
- /// Gets ActivityLog.
- /// </summary>
- public string ActivityLog
- {
- get
- {
- string noLog = "No log data available... Log data will show here after you scan a source. \n\nOpen the log file directory to get previous log files.";
- return string.IsNullOrEmpty(this.logBuffer.ToString()) ? this.header + noLog : this.header + this.logBuffer.ToString();
- }
- }
-
- #endregion
-
- #region Public Methods
-
- /// <summary>
- /// Scan a Source Path.
- /// Title 0: scan all
- /// </summary>
- /// <param name="sourcePath">
- /// Path to the file to scan
- /// </param>
- /// <param name="title">
- /// int title number. 0 for scan all
- /// </param>
- /// <param name="previewCount">
- /// The preview Count.
- /// </param>
- /// <param name="postScanAction">
- /// The post Scan Action.
- /// </param>
- public void Scan(string sourcePath, int title, int previewCount, Action<bool> postScanAction)
- {
- Thread t = new Thread(unused => this.ScanSource(sourcePath, title, previewCount, postScanAction));
- t.Start();
- }
-
- /// <summary>
- /// Kill the scan
- /// </summary>
- public void Stop()
- {
- try
- {
- // Try to clean things up as best as possible.
- if (this.readData != null)
- {
- this.readData.OnScanProgress -= this.OnScanProgress;
- }
-
- cancelScan = true;
-
- if (this.hbProc != null && !this.hbProc.HasExited)
- {
- this.hbProc.Kill();
- }
- }
- catch
- {
- // We don't really need to notify the user of any errors here.
- }
- }
-
- /// <summary>
- /// Take a Scan Log file, and process it as if it were from the CLI.
- /// </summary>
- /// <param name="path">
- /// The path to the log file.
- /// </param>
- public void DebugScanLog(string path)
- {
- try
- {
- StreamReader parseLog = new StreamReader(path);
- this.readData = new Parser(parseLog.BaseStream);
- this.SouceData = Source.Parse(this.readData, this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav));
- this.SouceData.ScanPath = path;
-
- if (this.ScanCompleted != null)
- {
- this.ScanCompleted(this, new ScanCompletedEventArgs(false, null, string.Empty));
- }
- }
- catch (Exception e)
- {
- throw new GeneralApplicationException("Debug Run Failed", string.Empty, e);
- }
- }
-
- /// <summary>
- /// Shutdown the service.
- /// </summary>
- public void Shutdown()
- {
- // Nothing to do for this implementation.
- }
-
- #endregion
-
- #region Private Methods
-
- /// <summary>
- /// Start a scan for a given source path and title
- /// </summary>
- /// <param name="sourcePath">
- /// Path to the source file
- /// </param>
- /// <param name="title">
- /// the title number to look at
- /// </param>
- /// <param name="previewCount">
- /// The preview Count.
- /// </param>
- /// <param name="postScanAction">
- /// The post Scan Action. Disables the Scan Completed Event
- /// </param>
- private void ScanSource(object sourcePath, int title, int previewCount, Action<bool> postScanAction)
- {
- try
- {
- this.IsScanning = true;
- this.cancelScan = false;
-
- if (this.ScanStared != null)
- {
- this.ScanStared(this, new EventArgs());
- }
-
- this.logBuffer = new StringBuilder();
-
- string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
- string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
- "\\HandBrake\\logs";
- string dvdInfoPath = Path.Combine(
- logDir,
- string.Format("last_scan_log{0}.txt", GeneralUtilities.ProcessId));
-
- if (!Directory.Exists(logDir))
- {
- Directory.CreateDirectory(logDir);
- }
-
- // Make we don't pick up a stale last_encode_log.txt (and that we have rights to the file)
- if (File.Exists(dvdInfoPath))
- {
- File.Delete(dvdInfoPath);
- }
-
- string extraArguments = string.Empty;
-
- if (previewCount != 10)
- {
- extraArguments += " --previews " + previewCount;
- }
-
- if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav))
- {
- extraArguments += " --no-dvdnav";
- }
-
- extraArguments += string.Format(" --min-duration={0}", this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.MinScanDuration));
-
- if (title > 0)
- {
- extraArguments += " --scan ";
- }
-
- // Quick fix for "F:\\" style paths. We need \\\\ (Escaped \ twice)
- string source = sourcePath.ToString().EndsWith("\\") ? string.Format("\"{0}\\\\\"", sourcePath.ToString().TrimEnd('\\'))
- : "\"" + sourcePath + "\"";
- string query = string.Format(@" -i {0} -t{1} {2} -v ", source, title, extraArguments);
-
- this.hbProc = new Process
- {
- StartInfo =
- {
- FileName = handbrakeCLIPath,
- Arguments = string.Format(@" -i {0} -t{1} {2} -v ", source, title, extraArguments),
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- UseShellExecute = false,
- CreateNoWindow = true
- }
- };
-
- // Start the Scan
- this.hbProc.Start();
-
- this.readData = new Parser(this.hbProc.StandardError.BaseStream);
- this.readData.OnScanProgress += this.OnScanProgress;
- this.SouceData = Source.Parse(this.readData, this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav));
- this.SouceData.ScanPath = (string)sourcePath;
-
- // Write the Buffer out to file.
- using (StreamWriter scanLog = new StreamWriter(dvdInfoPath))
- {
- // Only write the log file to disk if it's less than 50MB.
- if (this.readData.Buffer.Length < 50000000)
- {
- scanLog.WriteLine(header);
- scanLog.WriteLine(query);
- scanLog.Write(this.readData.Buffer);
-
- this.logBuffer.AppendLine(query);
- this.logBuffer.AppendLine(this.readData.Buffer.ToString());
- }
- else
- {
- throw new GeneralApplicationException(
- "The Log file has not been written to disk as it has grown above the 50MB limit", " This indicates there was a problem during the scan process.", null);
- }
- }
-
- this.IsScanning = false;
-
-
- if (postScanAction != null)
- {
- postScanAction(true);
- }
- else
- {
- if (this.ScanCompleted != null)
- {
- if (logBuffer.ToString().Contains("scan: unrecognized file type"))
- this.ScanCompleted(this, new ScanCompletedEventArgs(false, null, "Unrecognized file type."));
- else
- this.ScanCompleted(this, new ScanCompletedEventArgs(this.cancelScan, null, string.Empty));
- }
- }
- }
- catch (GeneralApplicationException)
- {
- throw;
- }
- catch (Exception exc)
- {
- this.Stop();
-
- if (postScanAction != null)
- {
- postScanAction(false);
- }
- else
- {
- if (this.ScanCompleted != null)
- {
- this.ScanCompleted(this, new ScanCompletedEventArgs(false, exc, "An Error has occured in ScanService.ScanSource()"));
- }
- }
- }
- }
-
- /// <summary>
- /// Fire an event when the scan process progresses
- /// </summary>
- /// <param name="sender">the sender</param>
- /// <param name="currentTitle">the current title being scanned</param>
- /// <param name="titleCount">the total number of titles</param>
- /// <param name="percentage">The Percentage</param>
- private void OnScanProgress(object sender, int currentTitle, int titleCount, decimal percentage)
- {
- ScanProgressEventArgs eventArgs = new ScanProgressEventArgs
- {
- CurrentTitle = currentTitle,
- Titles = titleCount,
- Percentage = percentage
- };
-
- if (this.ScanStatusChanged != null)
- {
- this.ScanStatusChanged(this, eventArgs);
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs index 22d9e22a8..4e0039c55 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs @@ -11,27 +11,21 @@ namespace HandBrake.ApplicationServices.Services {
using System;
using System.Collections.Generic;
- using System.Runtime.Serialization;
using System.ServiceModel;
using System.Threading;
- using System.Windows;
- using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.Interop;
using HandBrake.Interop.Interfaces;
using EncodeCompletedEventArgs = HandBrake.ApplicationServices.EventArgs.EncodeCompletedEventArgs;
using EncodeProgressEventArgs = HandBrake.ApplicationServices.EventArgs.EncodeProgressEventArgs;
- using ScanProgressEventArgs = HandBrake.ApplicationServices.EventArgs.ScanProgressEventArgs;
/// <summary>
/// HandBrake WCF Service
/// </summary>
- [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, IncludeExceptionDetailInFaults = true,
- ConcurrencyMode = ConcurrencyMode.Single)]
+ [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, IncludeExceptionDetailInFaults = true, ConcurrencyMode = ConcurrencyMode.Single)]
public class ServerService : IServerService
{
#region Constants and Fields
@@ -47,11 +41,6 @@ namespace HandBrake.ApplicationServices.Services private static IEncode encodeService;
/// <summary>
- /// The scan service.
- /// </summary>
- private static IScan scanService;
-
- /// <summary>
/// The host.
/// </summary>
private static ServiceHost host;
@@ -68,18 +57,6 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// Gets the activity log.
/// </summary>
- [DataMember]
- public string ActivityLog
- {
- get
- {
- return scanService.ActivityLog;
- }
- }
-
- /// <summary>
- /// Gets the activity log.
- /// </summary>
public string EncodeActivityLog { get; private set; }
/// <summary>
@@ -88,34 +65,10 @@ namespace HandBrake.ApplicationServices.Services public bool IsEncoding { get; private set; }
/// <summary>
- /// Gets a value indicating whether is scanning.
- /// </summary>
- [DataMember]
- public bool IsScanning
- {
- get
- {
- return scanService.IsScanning;
- }
- }
-
- /// <summary>
/// Gets the activity log.
/// </summary>
public string ScanActivityLog { get; private set; }
- /// <summary>
- /// Gets the souce data.
- /// </summary>
- [DataMember]
- public Source SouceData
- {
- get
- {
- return scanService.SouceData;
- }
- }
-
#endregion
#region Implemented Interfaces
@@ -133,27 +86,6 @@ namespace HandBrake.ApplicationServices.Services encodeService.ProcessLogs(destination);
}
- /// <summary>
- /// The scan source.
- /// </summary>
- /// <param name="path">
- /// The path.
- /// </param>
- /// <param name="title">
- /// The title.
- /// </param>
- /// <param name="previewCount">
- /// The preview Count.
- /// </param>
- public void ScanSource(string path, int title, int previewCount)
- {
- Console.WriteLine("Starting Source Scan for: " + path);
- scanService.ScanStared += this.ScanStaredHandler;
- scanService.ScanStatusChanged += this.ScanStatusChangedHandler;
- scanService.ScanCompleted += this.ScanCompletedHandler;
-
- scanService.Scan(path, title, previewCount, null);
- }
/// <summary>
/// Start the service
@@ -173,7 +105,6 @@ namespace HandBrake.ApplicationServices.Services // Setup the services we are going to use.
IHandBrakeInstance instance = new HandBrakeInstance();
- scanService = new LibScan(instance);
encodeService = new LibEncode(new UserSettingService(), instance); // TODO this needs wired up with castle
shutdownFlag = new ManualResetEvent(false);
@@ -221,14 +152,6 @@ namespace HandBrake.ApplicationServices.Services }
/// <summary>
- /// Stop the scan.
- /// </summary>
- public void StopScan()
- {
- scanService.Stop();
- }
-
- /// <summary>
/// The subscribe.
/// </summary>
/// <returns>
@@ -292,88 +215,6 @@ namespace HandBrake.ApplicationServices.Services #region Methods
/// <summary>
- /// The scan service scan completed event handler
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The e.
- /// </param>
- private void ScanCompletedHandler(object sender, ScanCompletedEventArgs e)
- {
- Subscribers.ForEach(
- delegate(IHbServiceCallback callback)
- {
- if (((ICommunicationObject)callback).State == CommunicationState.Opened)
- {
- Console.WriteLine("Scan Completed Callback");
- callback.ScanCompletedCallback(e);
- }
- else
- {
- Subscribers.Remove(callback);
- }
- });
-
- scanService.ScanStared -= this.ScanStaredHandler;
- scanService.ScanStatusChanged -= this.ScanStatusChangedHandler;
- scanService.ScanCompleted -= this.ScanCompletedHandler;
- }
-
- /// <summary>
- /// The scan service scan stared.
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The e.
- /// </param>
- private void ScanStaredHandler(object sender, EventArgs e)
- {
- Subscribers.ForEach(
- delegate(IHbServiceCallback callback)
- {
- if (((ICommunicationObject)callback).State == CommunicationState.Opened)
- {
- Console.WriteLine("Scan Started Callback");
- callback.ScanStartedCallback();
- }
- else
- {
- Subscribers.Remove(callback);
- }
- });
- }
-
- /// <summary>
- /// The scan service scan status changed event handler
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The e.
- /// </param>
- private void ScanStatusChangedHandler(object sender, ScanProgressEventArgs e)
- {
- Subscribers.ForEach(
- delegate(IHbServiceCallback callback)
- {
- if (((ICommunicationObject)callback).State == CommunicationState.Opened)
- {
- Console.WriteLine("Scan Changed Callback");
- callback.ScanProgressCallback(e);
- }
- else
- {
- Subscribers.Remove(callback);
- }
- });
- }
-
- /// <summary>
/// The encode service_ encode completed.
/// </summary>
/// <param name="sender">
|