private bool IsPresetDisabled(Preset preset) { bool isQsvEnabled = this.userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableQuickSyncEncoding); bool isNvencEnabled = this.userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableNvencEncoder); bool isVcnEnabled = this.userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableVceEncoder); HBVideoEncoder foundEncoder = HandBrakeEncoderHelpers.GetVideoEncoder(EnumHelper <VideoEncoder> .GetShortName(preset.Task.VideoEncoder)); if (foundEncoder == null) { return(true); } if (VideoEncoderHelpers.IsQuickSync(preset.Task.VideoEncoder) && !isQsvEnabled) { return(true); } if (VideoEncoderHelpers.IsNVEnc(preset.Task.VideoEncoder) && !isNvencEnabled) { return(true); } if (VideoEncoderHelpers.IsVCN(preset.Task.VideoEncoder) && !isVcnEnabled) { return(true); } return(false); }
public void ReleaseToken(VideoEncoder encoder, Guid?unlockKey) { if (unlockKey == null) { return; } lock (this.lockObj) { if (this.totalInstances.Contains(unlockKey.Value)) { this.totalInstances.Remove(unlockKey.Value); } if (VideoEncoderHelpers.IsQuickSync(encoder)) { if (this.qsvInstances.Contains(unlockKey.Value)) { this.qsvInstances.Remove(unlockKey.Value); } } else if (VideoEncoderHelpers.IsNVEnc(encoder)) { if (this.nvencInstances.Contains(unlockKey.Value)) { this.nvencInstances.Remove(unlockKey.Value); } } else if (VideoEncoderHelpers.IsVCN(encoder)) { if (this.vceInstances.Contains(unlockKey.Value)) { this.vceInstances.Remove(unlockKey.Value); } } else if (VideoEncoderHelpers.IsMediaFoundation(encoder)) { if (this.mfInstances.Contains(unlockKey.Value)) { this.mfInstances.Remove(unlockKey.Value); } } } }
public Guid?GetToken(EncodeTask task) { lock (this.lockObj) { if (VideoEncoderHelpers.IsQuickSync(task.VideoEncoder)) { if (this.qsvInstances.Count < this.totalQsvInstances && this.TotalActiveInstances <= this.maxAllowedInstances) { this.AllocateIntelGPU(task); Guid guid = Guid.NewGuid(); this.qsvInstances.Add(guid); this.totalInstances.Add(guid); return(guid); } return(Guid.Empty); // Busy } else if (VideoEncoderHelpers.IsNVEnc(task.VideoEncoder)) { if (this.nvencInstances.Count < this.totalNvidiaInstances && this.TotalActiveInstances <= this.maxAllowedInstances) { Guid guid = Guid.NewGuid(); this.nvencInstances.Add(guid); this.totalInstances.Add(guid); return(guid); } return(Guid.Empty); // Busy } else if (VideoEncoderHelpers.IsVCN(task.VideoEncoder)) { if (this.vceInstances.Count < this.totalVceInstances && this.TotalActiveInstances <= this.maxAllowedInstances) { Guid guid = Guid.NewGuid(); this.vceInstances.Add(guid); this.totalInstances.Add(guid); return(guid); } return(Guid.Empty); // Busy } else if (VideoEncoderHelpers.IsMediaFoundation(task.VideoEncoder)) { if (this.mfInstances.Count < this.totalMfInstances && this.TotalActiveInstances <= this.maxAllowedInstances) { Guid guid = Guid.NewGuid(); this.mfInstances.Add(guid); this.totalInstances.Add(guid); return(guid); } return(Guid.Empty); // Busy } else { if (this.TotalActiveInstances <= this.maxAllowedInstances) { Guid guid = Guid.NewGuid(); this.totalInstances.Add(guid); return(guid); } else { return(Guid.Empty); // Busy } } } }
/// <summary> /// Gets a list of Video encoders OR returns the string name of an encoder depending on the input. /// </summary> /// <param name="values"> /// The values. /// </param> /// <param name="targetType"> /// The target type. /// </param> /// <param name="parameter"> /// The parameter. /// </param> /// <param name="culture"> /// The culture. /// </param> /// <returns> /// IEnumerable VideoEncoder or String encoder name. /// </returns> public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values.Count() >= 2) { IUserSettingService userSettingService = values[2] as IUserSettingService; bool isQsvEnabled = false, isVceEnabled = false, isNvencEnabled = false; if (userSettingService != null) { isQsvEnabled = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableQuickSyncEncoding); isVceEnabled = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableVceEncoder); isNvencEnabled = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableNvencEncoder); } List <VideoEncoder> allEncoders = values[0] as List <VideoEncoder>; EncodeTask task = values[1] as EncodeTask; if (task == null || allEncoders == null) { return(null); } List <VideoEncoder> returnEncoders = new List <VideoEncoder>(allEncoders); foreach (var encoder in allEncoders) { HBVideoEncoder foundEncoder = HandBrakeEncoderHelpers.GetVideoEncoder(EnumHelper <VideoEncoder> .GetShortName(encoder)); if (foundEncoder == null) { returnEncoders.Remove(encoder); continue; } if (task.OutputFormat == OutputFormat.Mp4 && !foundEncoder.SupportsMP4) { returnEncoders.Remove(encoder); } if (task.OutputFormat == OutputFormat.Mkv && !foundEncoder.SupportsMKV) { returnEncoders.Remove(encoder); } if (task.OutputFormat == OutputFormat.WebM && !foundEncoder.SupportsWebM) { returnEncoders.Remove(encoder); } if (!isQsvEnabled && VideoEncoderHelpers.IsQuickSync(encoder)) { returnEncoders.Remove(encoder); } if (!isVceEnabled && VideoEncoderHelpers.IsVCN(encoder)) { returnEncoders.Remove(encoder); } if (!isNvencEnabled && VideoEncoderHelpers.IsNVEnc(encoder)) { returnEncoders.Remove(encoder); } } return(EnumHelper <VideoEncoder> .GetEnumDisplayValuesSubset(returnEncoders)); } if (values[0].GetType() == typeof(VideoEncoder)) { return(EnumHelper <VideoEncoder> .GetDisplay((VideoEncoder)values[0])); } return(null); }