OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / EncodeQueue / EncodeAndQueueHandler.cs
index 6d8a2ce..f2a4eae 100644 (file)
@@ -82,9 +82,10 @@ namespace Handbrake.EncodeQueue
         /// <param name="query">The query that will be passed to the HandBrake CLI.</param>\r
         /// <param name="source">The location of the source video.</param>\r
         /// <param name="destination">The location where the encoded video will be.</param>\r
-        public void AddJob(string query, string source, string destination)\r
+        /// <param name="customJob"></param>\r
+        public void AddJob(string query, string source, string destination, bool customJob)\r
         {\r
-            Job newJob = new Job { Id = nextJobId++, Query = query, Source = source, Destination = destination };\r
+            Job newJob = new Job { Id = nextJobId++, Query = query, Source = source, Destination = destination, CustomQuery = customJob };\r
 \r
             queue.Add(newJob);\r
             WriteQueueStateToFile("hb_queue_recovery.xml");\r
@@ -306,7 +307,8 @@ namespace Handbrake.EncodeQueue
             // Run through each item on the queue\r
             while (this.Count != 0)\r
             {\r
-                string query = GetNextJob().Query;\r
+                Job encJob = GetNextJob();\r
+                string query = encJob.Query;\r
                 WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file\r
 \r
                 RunCli(query);\r
@@ -316,7 +318,7 @@ namespace Handbrake.EncodeQueue
 \r
                 hbProcess.WaitForExit();\r
 \r
-                AddCLIQueryToLog(query);\r
+                AddCLIQueryToLog(encJob);\r
                 CopyLog(LastEncode.Destination);\r
 \r
                 hbProcess.Close();\r
@@ -336,6 +338,7 @@ namespace Handbrake.EncodeQueue
                     Thread.Sleep(5000);\r
                 }\r
             }\r
+            LastEncode = new Job();\r
 \r
             if (QueueCompleted != null)\r
                 QueueCompleted(this, new EventArgs());\r
@@ -361,6 +364,8 @@ namespace Handbrake.EncodeQueue
         {\r
             try\r
             {\r
+                isEncoding = true;\r
+\r
                 string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
                 string logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs", "last_encode_log.txt");\r
                 string strCmdLine = String.Format(@" /C """"{0}"" {1} 2>""{2}"" """, handbrakeCLIPath, query, logPath);\r
@@ -376,8 +381,7 @@ namespace Handbrake.EncodeQueue
 \r
                 Process[] before = Process.GetProcesses(); // Get a list of running processes before starting.\r
                 hbProcess = Process.Start(cliStart);\r
-                processID = Main.getCliProcess(before);\r
-                isEncoding = true;\r
+                processID = Main.getCliProcess(before); \r
                 currentQuery = query;\r
                 if (hbProcess != null)\r
                     processHandle = hbProcess.MainWindowHandle; // Set the process Handle\r
@@ -414,7 +418,6 @@ namespace Handbrake.EncodeQueue
             {\r
                 MessageBox.Show("It would appear that HandBrakeCLI has not started correctly. You should take a look at the Activity log as it may indicate the reason why.\n\n   Detailed Error Information: error occured in runCli()\n\n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
-\r
         }\r
 \r
         /// <summary>\r
@@ -468,7 +471,7 @@ namespace Handbrake.EncodeQueue
         /// Append the CLI query to the start of the log file.\r
         /// </summary>\r
         /// <param name="query"></param>\r
-        private static void AddCLIQueryToLog(string query)\r
+        private static void AddCLIQueryToLog(Job encJob)\r
         {\r
             string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
             string logPath = Path.Combine(logDir, "last_encode_log.txt");\r
@@ -479,7 +482,8 @@ namespace Handbrake.EncodeQueue
 \r
             StreamWriter writer = new StreamWriter(File.Create(logPath));\r
 \r
-            writer.Write("### CLI Query: " + query + "\n\n");\r
+            writer.Write("### CLI Query: " + encJob.Query + "\n\n");\r
+            writer.Write("### User Query: " + encJob.CustomQuery + "\n\n");\r
             writer.Write("#########################################\n\n");\r
             writer.WriteLine(log);\r
             writer.Flush();\r