// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // The hand brake instance manager. // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrake.ApplicationServices.Interop { using System; using HandBrake.ApplicationServices.Interop.Interfaces; /// /// The HandBrake Instance manager. /// Only supports scanning right now. /// public static class HandBrakeInstanceManager { private static HandBrakeInstance scanInstance; private static HandBrakeInstance encodeInstance; private static HandBrakeInstance masterInstance; /// /// Initializes static members of the class. /// static HandBrakeInstanceManager() { masterInstance = new HandBrakeInstance(); masterInstance.Initialize(2); } /// /// The init. /// public static void Init() { // Nothing to do. Triggers static constructor. } /// /// Gets the scanInstance. /// /// /// The verbosity. /// /// /// The . /// internal static IHandBrakeInstance GetScanInstance(int verbosity) { if (scanInstance != null) { scanInstance.Dispose(); scanInstance = null; } HandBrakeInstance newInstance = new HandBrakeInstance(); newInstance.Initialize(verbosity); scanInstance = newInstance; return scanInstance; } /// /// The get encode instance. /// /// /// The verbosity. /// /// /// The . /// internal static IHandBrakeInstance GetEncodeInstance(int verbosity) { if (encodeInstance != null) { encodeInstance.Dispose(); encodeInstance = null; } HandBrakeInstance newInstance = new HandBrakeInstance(); newInstance.Initialize(verbosity); encodeInstance = newInstance; return encodeInstance; } /// /// Gets the master instance. /// internal static IHandBrakeInstance MasterInstance { get { return masterInstance; } } /// /// Gets the last scan scan instance. /// internal static IHandBrakeInstance LastScanScanInstance { get { return scanInstance; } } /// /// Gets the handle. /// internal static IntPtr LastScanHandle { get { return scanInstance.Handle; } } /// /// Gets the last encode scan instance. /// internal static IHandBrakeInstance LastEncodeScanInstance { get { return encodeInstance; } } /// /// Gets the encode handle. /// internal static IntPtr LastEncodeHandle { get { return encodeInstance.Handle; } } } }