/// <summary> /// Applies a resolution constraint from a quality's width and height if both values are greater than zero /// </summary> /// <param name="quality">The quality to derive the width and height from.</param> public FFmpegH264VideoCommandBuilder WithSize(IQuality quality) { if (quality.Width <= 0 || quality.Height <= 0) { return(this); } commands.Add($"-s {quality.Width}x{quality.Height}"); return(this); }
/// <summary> /// Get the value definition as a quality, throwing an /// exception if it is not a quality /// </summary> public static IQuality Quality(this IBaseExchangeItem item) { IQuality quality = item.ValueDefinition as IQuality; if (quality == null) { throw new Exception("ValueDefinition is not a quality"); } return(quality); }
/// <summary> /// Builds the directshow graph for this analog tvcard /// </summary> public override void BuildGraph() { if (_cardId == 0) { GetPreloadBitAndCardId(); _configuration = Configuration.readConfiguration(_cardId, _name, _devicePath); Configuration.writeConfiguration(_configuration); } _lastSignalUpdate = DateTime.MinValue; _tunerLocked = false; Log.Log.WriteFile("HDPVR: build graph"); try { if (_graphState != GraphState.Idle) { Log.Log.WriteFile("HDPVR: graph already built!"); throw new TvException("Graph already built"); } _graphBuilder = (IFilterGraph2) new FilterGraph(); _rotEntry = new DsROTEntry(_graphBuilder); _capBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2(); _capBuilder.SetFiltergraph(_graphBuilder); AddCrossBarFilter(); AddCaptureFilter(); AddEncoderFilter(); AddTsWriterFilterToGraph(); _qualityControl = QualityControlFactory.createQualityControl(_configuration, _filterEncoder, _filterCapture, null, null); if (_qualityControl == null) { Log.Log.WriteFile("HDPVR: No quality control support found"); } _graphState = GraphState.Created; _configuration.Graph.Crossbar.Name = _crossBarDevice.Name; _configuration.Graph.Crossbar.VideoPinMap = _videoPinMap; _configuration.Graph.Crossbar.AudioPinMap = _audioPinMap; _configuration.Graph.Crossbar.VideoPinRelatedAudioMap = _videoPinRelatedAudioMap; _configuration.Graph.Crossbar.VideoOut = _videoOutPinIndex; _configuration.Graph.Crossbar.AudioOut = _audioOutPinIndex; _configuration.Graph.Capture.Name = _captureDevice.Name; _configuration.Graph.Capture.FrameRate = -1d; _configuration.Graph.Capture.ImageHeight = -1; _configuration.Graph.Capture.ImageWidth = -1; Configuration.writeConfiguration(_configuration); } catch (Exception ex) { Log.Log.Write(ex); Dispose(); _graphState = GraphState.Idle; throw; } }
/// <summary> /// Check for a quality /// </summary> /// <param name="name">Gets the value of the request quality</param> /// <returns>The value</returns> public virtual int GetQuality(string name) { IQuality currentQuality = Qualities.FirstOrDefault(qual => qual.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); if (currentQuality == null) { return(0); } return(currentQuality.Value); }
public static int GetMaxWeight(Item item) { var maxWeight = 350; IQuality quality = item as IQuality; if (quality != null && quality.Quality == ItemQuality.Exceptional) { maxWeight += 50; } return(item.IsArtifact ? 500 : maxWeight); }
/// <summary> /// Price check on teaching qualities /// </summary> /// <param name="name">The name of the quality</param> /// <param name="level">The level to teach to</param> /// <returns>the price, -1 indicates it wont be taught</returns> public int InstructionPriceCheck(string qualityName, int level) { decimal value = -1; IQuality quality = TeachableProficencies.FirstOrDefault(qual => qual.Name.Equals(qualityName, StringComparison.InvariantCultureIgnoreCase) && qual.Value > level); //If we need it in stock but don't have it it's sell price is invalid if (quality != null) { value = 5; //base price, needs to be a config TODO value *= level; } return((int)Math.Truncate(value)); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.StVal == null)) { IDPStatus stValCasted = item.As <IDPStatus>(); if ((stValCasted != null)) { this._parent.StVal = stValCasted; return; } } if ((this._parent.Q == null)) { IQuality qCasted = item.As <IQuality>(); if ((qCasted != null)) { this._parent.Q = qCasted; return; } } if ((this._parent.T == null)) { ITimeStamp tCasted = item.As <ITimeStamp>(); if ((tCasted != null)) { this._parent.T = tCasted; return; } } if ((this._parent.SubVal == null)) { IDPStatus subValCasted = item.As <IDPStatus>(); if ((subValCasted != null)) { this._parent.SubVal = subValCasted; return; } } if ((this._parent.PulseConfig == null)) { IPulseConfig pulseConfigCasted = item.As <IPulseConfig>(); if ((pulseConfigCasted != null)) { this._parent.PulseConfig = pulseConfigCasted; return; } } }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.Q == null)) { IQuality qCasted = item.As <IQuality>(); if ((qCasted != null)) { this._parent.Q = qCasted; return; } } if ((this._parent.SubQ == null)) { IQuality subQCasted = item.As <IQuality>(); if ((subQCasted != null)) { this._parent.SubQ = subQCasted; return; } } }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.Q == null)) { IQuality qCasted = item.As <IQuality>(); if ((qCasted != null)) { this._parent.Q = qCasted; return; } } if ((this._parent.T == null)) { ITimeStamp tCasted = item.As <ITimeStamp>(); if ((tCasted != null)) { this._parent.T = tCasted; return; } } }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.ValWTr == null)) { IValWithTrans valWTrCasted = item.As <IValWithTrans>(); if ((valWTrCasted != null)) { this._parent.ValWTr = valWTrCasted; return; } } if ((this._parent.T == null)) { ITimeStamp tCasted = item.As <ITimeStamp>(); if ((tCasted != null)) { this._parent.T = tCasted; return; } } if ((this._parent.Q == null)) { IQuality qCasted = item.As <IQuality>(); if ((qCasted != null)) { this._parent.Q = qCasted; return; } } if ((this._parent.SubVal == null)) { IValWithTrans subValCasted = item.As <IValWithTrans>(); if ((subValCasted != null)) { this._parent.SubVal = subValCasted; return; } } }
/// <summary> /// Removes qualities higher than the given bitrate and substitutes removed qualities with a copy quality. /// </summary> /// <param name="qualities">The quality collection to crush.</param> /// <param name="bitrateKbs">Bitrate in kb/s.</param> /// <param name="crushTolerance">A multiplier.<br/>Setting this to zero causes the set to be returned unmodified.</param> /// <returns></returns> public static IEnumerable <IQuality> CrushQualities(IEnumerable <IQuality> qualities, long bitrateKbs, double crushTolerance = 0.90) { if (crushTolerance <= 0) { return(qualities); } if (qualities == null || !qualities.Any()) { return(qualities); } IQuality defaultQuality = qualities.First(); // Crush var crushed = qualities.Where(x => x.Bitrate < bitrateKbs * crushTolerance).Distinct(); if (crushed.Count() < qualities.Count()) { if (crushed.Where(x => x.Bitrate == 0).FirstOrDefault() == null) { var copyQuality = Quality.GetCopyQuality(); copyQuality.Level = defaultQuality.Level; copyQuality.PixelFormat = defaultQuality.PixelFormat; copyQuality.Profile = defaultQuality.Profile; var newQualities = new List <IQuality>() { copyQuality }; // Add a copy quality to replace removed qualities. newQualities.AddRange(crushed); return(newQualities); } return(crushed); } return(qualities); }
/// <summary> /// Builds the directshow graph for this analog tvcard /// </summary> public override void BuildGraph() { if (_cardId == 0) { GetPreloadBitAndCardId(); _configuration = Configuration.readConfiguration(_cardId, _name, _devicePath); Configuration.writeConfiguration(_configuration); } _lastSignalUpdate = DateTime.MinValue; _tunerLocked = false; Log.Log.WriteFile("analog: build graph"); try { if (_graphState != GraphState.Idle) { Log.Log.WriteFile("analog: Graph already build"); throw new TvException("Graph already build"); } //create a new filter graph _graphBuilder = (IFilterGraph2)new FilterGraph(); _rotEntry = new DsROTEntry(_graphBuilder); _capBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); _capBuilder.SetFiltergraph(_graphBuilder); Graph graph = _configuration.Graph; _tuner = new Tuner(_device); if (!_tuner.CreateFilterInstance(graph, _graphBuilder)) { Log.Log.Error("analog: unable to add tv tuner filter"); throw new TvException("Analog: unable to add tv tuner filter"); } _minChannel = _tuner.MinChannel; _maxChannel = _tuner.MaxChannel; //add the wdm crossbar device and connect tvtuner->crossbar _crossbar = new Crossbar(); if (!_crossbar.CreateFilterInstance(graph, _graphBuilder, _tuner)) { Log.Log.Error("analog: unable to add tv crossbar filter"); throw new TvException("Analog: unable to add tv crossbar filter"); } //add the tv audio tuner device and connect it to the crossbar _tvAudio = new TvAudio(); if (!_tvAudio.CreateFilterInstance(graph, _graphBuilder, _tuner, _crossbar)) { Log.Log.Error("analog: unable to add tv audio tuner filter"); throw new TvException("Analog: unable to add tv audio tuner filter"); } //add the tv capture device and connect it to the crossbar _capture = new Capture(); if (!_capture.CreateFilterInstance(graph, _capBuilder, _graphBuilder, _tuner, _crossbar, _tvAudio)) { Log.Log.Error("analog: unable to add capture filter"); throw new TvException("Analog: unable to add capture filter"); } Configuration.writeConfiguration(_configuration); _teletext = new TeletextComponent(); if (_capture.SupportsTeletext) { if (!_teletext.CreateFilterInstance(graph, _graphBuilder, _capture)) { Log.Log.Error("analog: unable to setup teletext filters"); throw new TvException("Analog: unable to setup teletext filters"); } } Configuration.writeConfiguration(_configuration); _encoder = new Encoder(); if (!_encoder.CreateFilterInstance(_graphBuilder, _tuner, _tvAudio, _crossbar, _capture)) { Log.Log.Error("analog: unable to add encoding filter"); throw new TvException("Analog: unable to add capture filter"); } Log.Log.WriteFile("analog: Check quality control"); _qualityControl = QualityControlFactory.createQualityControl(_configuration, _encoder.VideoEncoderFilter, _capture.VideoFilter, _encoder.MultiplexerFilter, _encoder.VideoCompressorFilter); if (_qualityControl == null) { Log.Log.WriteFile("analog: No quality control support found"); //If a hauppauge analog card, set bitrate to default //As the graph is stopped, we don't need to pass in the deviceID //However, if we wish to change quality for a live graph, the deviceID must be passed in if (_tunerDevice != null && _capture.VideoFilter != null) { if (_capture.VideoCaptureName.Contains("Hauppauge")) { Hauppauge _hauppauge = new Hauppauge(_capture.VideoFilter, string.Empty); _hauppauge.SetStream(103); _hauppauge.SetAudioBitRate(384); _hauppauge.SetVideoBitRate(6000, 8000, true); int min, max; bool vbr; _hauppauge.GetVideoBitRate(out min, out max, out vbr); Log.Log.Write("Hauppauge set video parameters - Max kbps: {0}, Min kbps: {1}, VBR {2}", max, min, vbr); _hauppauge.Dispose(); _hauppauge = null; } } } if (!AddTsFileSink()) { throw new TvException("Analog: unable to add mpfilewriter"); } Log.Log.WriteFile("analog: Graph is built"); FilterGraphTools.SaveGraphFile(_graphBuilder, "analog.grf"); ReloadCardConfiguration(); _graphState = GraphState.Created; } catch (TvExceptionSWEncoderMissing ex) { Log.Log.Write(ex); Dispose(); _graphState = GraphState.Idle; throw; } catch (Exception ex) { Log.Log.Write(ex); Dispose(); _graphState = GraphState.Idle; throw new TvExceptionGraphBuildingFailed("Graph building failed", ex); } }
/// <summary> /// Creates a new observable property access proxy /// </summary> /// <param name="modelElement">The model instance element for which to create the property access proxy</param> public SourceProxy(IQuality modelElement) : base(modelElement, "source") { }
/// <summary> /// Creates a new observable property access proxy /// </summary> /// <param name="modelElement">The model instance element for which to create the property access proxy</param> public ValidityProxy(IQuality modelElement) : base(modelElement, "validity") { }
/// <summary> /// Creates a new observable property access proxy /// </summary> /// <param name="modelElement">The model instance element for which to create the property access proxy</param> public OperatorBlockedProxy(IQuality modelElement) : base(modelElement, "operatorBlocked") { }
/// <summary> /// Creates a new observable property access proxy /// </summary> /// <param name="modelElement">The model instance element for which to create the property access proxy</param> public TestProxy(IQuality modelElement) : base(modelElement, "test") { }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.InstMag == null)) { IAnalogueValue instMagCasted = item.As <IAnalogueValue>(); if ((instMagCasted != null)) { this._parent.InstMag = instMagCasted; return; } } if ((this._parent.Q == null)) { IQuality qCasted = item.As <IQuality>(); if ((qCasted != null)) { this._parent.Q = qCasted; return; } } if ((this._parent.T == null)) { ITimeStamp tCasted = item.As <ITimeStamp>(); if ((tCasted != null)) { this._parent.T = tCasted; return; } } if ((this._parent.Units == null)) { IUnits unitsCasted = item.As <IUnits>(); if ((unitsCasted != null)) { this._parent.Units = unitsCasted; return; } } if ((this._parent.SVC == null)) { IScaledValueConfig sVCCasted = item.As <IScaledValueConfig>(); if ((sVCCasted != null)) { this._parent.SVC = sVCCasted; return; } } if ((this._parent.Min == null)) { IAnalogueValue minCasted = item.As <IAnalogueValue>(); if ((minCasted != null)) { this._parent.Min = minCasted; return; } } if ((this._parent.Max == null)) { IAnalogueValue maxCasted = item.As <IAnalogueValue>(); if ((maxCasted != null)) { this._parent.Max = maxCasted; return; } } }
public Quality(IQuality iQuality) : base(iQuality) { _isOrdered = iQuality.IsOrdered; }
/// <summary> /// Builds the directshow graph for this analog tvcard /// </summary> public override void BuildGraph() { if (_cardId == 0) { GetPreloadBitAndCardId(); _configuration = Configuration.readConfiguration(_cardId, _name, _devicePath); Configuration.writeConfiguration(_configuration); } _lastSignalUpdate = DateTime.MinValue; _tunerLocked = false; Log.Log.WriteFile("HDPVR: build graph"); try { if (_graphState != GraphState.Idle) { Log.Log.WriteFile("HDPVR: graph already built!"); throw new TvException("Graph already built"); } _graphBuilder = (IFilterGraph2)new FilterGraph(); _rotEntry = new DsROTEntry(_graphBuilder); _capBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); _capBuilder.SetFiltergraph(_graphBuilder); AddCrossBarFilter(); AddCaptureFilter(); AddEncoderFilter(); AddTsWriterFilterToGraph(); _qualityControl = QualityControlFactory.createQualityControl(_configuration, _filterEncoder, _filterCapture, null, null); if (_qualityControl == null) { Log.Log.WriteFile("HDPVR: No quality control support found"); } _graphState = GraphState.Created; _configuration.Graph.Crossbar.Name = _crossBarDevice.Name; _configuration.Graph.Crossbar.VideoPinMap = _videoPinMap; _configuration.Graph.Crossbar.AudioPinMap = _audioPinMap; _configuration.Graph.Crossbar.VideoPinRelatedAudioMap = _videoPinRelatedAudioMap; _configuration.Graph.Crossbar.VideoOut = _videoOutPinIndex; _configuration.Graph.Crossbar.AudioOut = _audioOutPinIndex; _configuration.Graph.Capture.Name = _captureDevice.Name; _configuration.Graph.Capture.FrameRate = -1d; _configuration.Graph.Capture.ImageHeight = -1; _configuration.Graph.Capture.ImageWidth = -1; Configuration.writeConfiguration(_configuration); } catch (Exception ex) { Log.Log.Write(ex); Dispose(); _graphState = GraphState.Idle; throw; } }
/// <summary> /// Builds the directshow graph for this analog tvcard /// </summary> public override void BuildGraph() { if (_cardId == 0) { GetPreloadBitAndCardId(); _configuration = Configuration.readConfiguration(_cardId, _name, _devicePath); Configuration.writeConfiguration(_configuration); } _lastSignalUpdate = DateTime.MinValue; _tunerLocked = false; Log.Log.WriteFile("analog: build graph"); try { if (_graphState != GraphState.Idle) { Log.Log.WriteFile("analog: Graph already build"); throw new TvException("Graph already build"); } //create a new filter graph _graphBuilder = (IFilterGraph2) new FilterGraph(); _rotEntry = new DsROTEntry(_graphBuilder); _capBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2(); _capBuilder.SetFiltergraph(_graphBuilder); Graph graph = _configuration.Graph; _tuner = new Tuner(_device); if (!_tuner.CreateFilterInstance(graph, _graphBuilder)) { Log.Log.Error("analog: unable to add tv tuner filter"); throw new TvException("Analog: unable to add tv tuner filter"); } _minChannel = _tuner.MinChannel; _maxChannel = _tuner.MaxChannel; //add the wdm crossbar device and connect tvtuner->crossbar _crossbar = new Crossbar(); if (!_crossbar.CreateFilterInstance(graph, _graphBuilder, _tuner)) { Log.Log.Error("analog: unable to add tv crossbar filter"); throw new TvException("Analog: unable to add tv crossbar filter"); } //add the tv audio tuner device and connect it to the crossbar _tvAudio = new TvAudio(); if (!_tvAudio.CreateFilterInstance(graph, _graphBuilder, _tuner, _crossbar)) { Log.Log.Error("analog: unable to add tv audio tuner filter"); throw new TvException("Analog: unable to add tv audio tuner filter"); } //add the tv capture device and connect it to the crossbar _capture = new Capture(); if (!_capture.CreateFilterInstance(graph, _capBuilder, _graphBuilder, _tuner, _crossbar, _tvAudio)) { Log.Log.Error("analog: unable to add capture filter"); throw new TvException("Analog: unable to add capture filter"); } Configuration.writeConfiguration(_configuration); _teletext = new TeletextComponent(); if (_capture.SupportsTeletext) { if (!_teletext.CreateFilterInstance(graph, _graphBuilder, _capture)) { Log.Log.Error("analog: unable to setup teletext filters"); throw new TvException("Analog: unable to setup teletext filters"); } } Configuration.writeConfiguration(_configuration); _encoder = new Encoder(); if (!_encoder.CreateFilterInstance(_graphBuilder, _tuner, _tvAudio, _crossbar, _capture)) { Log.Log.Error("analog: unable to add encoding filter"); throw new TvException("Analog: unable to add capture filter"); } Log.Log.WriteFile("analog: Check quality control"); _qualityControl = QualityControlFactory.createQualityControl(_configuration, _encoder.VideoEncoderFilter, _capture.VideoFilter, _encoder.MultiplexerFilter, _encoder.VideoCompressorFilter); if (_qualityControl == null) { Log.Log.WriteFile("analog: No quality control support found"); //If a hauppauge analog card, set bitrate to default //As the graph is stopped, we don't need to pass in the deviceID //However, if we wish to change quality for a live graph, the deviceID must be passed in if (_tunerDevice != null && _capture.VideoFilter != null) { if (_capture.VideoCaptureName.Contains("Hauppauge")) { Hauppauge _hauppauge = new Hauppauge(_capture.VideoFilter, string.Empty); _hauppauge.SetStream(103); _hauppauge.SetAudioBitRate(384); _hauppauge.SetVideoBitRate(6000, 8000, true); int min, max; bool vbr; _hauppauge.GetVideoBitRate(out min, out max, out vbr); Log.Log.Write("Hauppauge set video parameters - Max kbps: {0}, Min kbps: {1}, VBR {2}", max, min, vbr); _hauppauge.Dispose(); _hauppauge = null; } } } if (!AddTsFileSink()) { throw new TvException("Analog: unable to add mpfilewriter"); } Log.Log.WriteFile("analog: Graph is built"); FilterGraphTools.SaveGraphFile(_graphBuilder, "analog.grf"); ReloadCardConfiguration(); _graphState = GraphState.Created; } catch (TvExceptionSWEncoderMissing ex) { Log.Log.Write(ex); Dispose(); _graphState = GraphState.Idle; throw; } catch (Exception ex) { Log.Log.Write(ex); Dispose(); _graphState = GraphState.Idle; throw new TvExceptionGraphBuildingFailed("Graph building failed", ex); } }
protected ItemBase(Item item, ISellIn sellIn, IQuality quality) { _item = item; _sellIn = sellIn; _quality = quality; }