blob: 1017ba1e1b12c55c4a5fa4368e7f55f0e6058b46 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="HandBrakeInstanceManager.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>
// The hand brake instance manager.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Instance
{
using System;
using HandBrake.Interop.Interop;
using HandBrake.Interop.Interop.Interfaces;
using HandBrake.Interop.Model;
using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Logging.Interfaces;
using HandBrakeWPF.Utilities;
/// <summary>
/// The HandBrake Instance manager.
/// Only supports scanning right now.
/// </summary>
public static class HandBrakeInstanceManager
{
private static IEncodeInstance encodeInstance;
private static HandBrakeInstance scanInstance;
private static HandBrakeInstance previewInstance;
private static bool noHardware;
public static void Init(bool noHardwareMode)
{
noHardware = noHardwareMode;
HandBrakeUtils.RegisterLogger();
HandBrakeUtils.EnsureGlobalInit(noHardwareMode);
}
public static IEncodeInstance GetEncodeInstance(int verbosity, HBConfiguration configuration, ILog logService, IUserSettingService userSettingService, IPortService portService)
{
if (!HandBrakeUtils.IsInitialised())
{
throw new Exception("Please call Init before Using!");
}
IEncodeInstance newInstance;
if (userSettingService.GetUserSetting<bool>(UserSettingConstants.ProcessIsolationEnabled) && Portable.IsProcessIsolationEnabled())
{
newInstance = new RemoteInstance(logService, userSettingService, portService);
}
else
{
if (encodeInstance != null && !encodeInstance.IsRemoteInstance)
{
encodeInstance.Dispose();
encodeInstance = null;
}
newInstance = new HandBrakeInstance();
HandBrakeUtils.SetDvdNav(!userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav));
encodeInstance = newInstance;
}
newInstance.Initialize(verbosity, noHardware);
return newInstance;
}
/// <summary>
/// Gets the scanInstance.
/// </summary>
/// <param name="verbosity">
/// The verbosity.
/// </param>
/// <returns>
/// The <see cref="IHandBrakeInstance"/>.
/// </returns>
public static IHandBrakeInstance GetScanInstance(int verbosity)
{
if (!HandBrakeUtils.IsInitialised())
{
throw new Exception("Please call Init before Using!");
}
if (scanInstance != null)
{
scanInstance.Dispose();
scanInstance = null;
}
HandBrakeInstance newInstance = new HandBrakeInstance();
newInstance.Initialize(verbosity, noHardware);
scanInstance = newInstance;
return scanInstance;
}
/// <summary>
/// The get encode instance.
/// </summary>
/// <param name="verbosity">
/// The verbosity.
/// </param>
/// <param name="userSettingService">
/// The user Setting Service.
/// </param>
/// <returns>
/// The <see cref="IHandBrakeInstance"/>.
/// </returns>
public static IHandBrakeInstance GetPreviewInstance(int verbosity, IUserSettingService userSettingService)
{
if (!HandBrakeUtils.IsInitialised())
{
throw new Exception("Please call Init before Using!");
}
if (previewInstance != null)
{
previewInstance.Dispose();
previewInstance = null;
}
HandBrakeInstance newInstance = new HandBrakeInstance();
newInstance.Initialize(verbosity, noHardware);
previewInstance = newInstance;
HandBrakeUtils.SetDvdNav(!userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav));
return previewInstance;
}
}
}
|