コード例 #1
0
        ///<summary>
        /// Constructor for a capture card device.
        ///</summary>
        ///<param name="device">A crossbar device for a supported capture card.</param>
        public TvCardHDPVR(DsDevice device)
            : base(device)
        {
            // Determine what type of card this is.
            if (device.Name.Contains("Colossus"))
            {
                Match match        = Regex.Match(device.Name, @".*?(\d+)$");
                int   deviceNumber = 0;
                if (match.Success)
                {
                    deviceNumber = Convert.ToInt32(match.Groups[1].Value);
                }
                _deviceType         = "Colossus";
                _crossbarDeviceName = device.Name;
                _captureDeviceName  = "Hauppauge Colossus Capture " + deviceNumber;
                _encoderDeviceName  = "Hauppauge Colossus TS Encoder " + deviceNumber;
            }

            _mapSubChannels      = new Dictionary <Int32, BaseSubChannel>();
            _supportsSubChannels = true;
            _minChannel          = 0;
            _maxChannel          = 128;
            _camType             = CamType.Default;
            _conditionalAccess   = null;
            _cardType            = CardType.Analog;
            _epgGrabbing         = false;
            _configuration       = Configuration.readConfiguration(_cardId, _name, _devicePath);
            Configuration.writeConfiguration(_configuration);
        }
コード例 #2
0
 /// <summary>
 /// Reloads the quality control configuration
 /// </summary>
 public void ReloadCardConfiguration()
 {
     if (_qualityControl != null)
     {
         _configuration = Configuration.readConfiguration(_cardId, _name, _devicePath);
         Configuration.writeConfiguration(_configuration);
         _qualityControl.SetConfiguration(_configuration);
     }
 }
コード例 #3
0
        /// <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;
            }
        }
コード例 #4
0
 ///<summary>
 /// Constrcutor for the analog
 ///</summary>
 ///<param name="device">Tuner Device</param>
 public TvCardAnalog(DsDevice device)
     : base(device)
 {
     _parameters          = new ScanParameters();
     _mapSubChannels      = new Dictionary <int, BaseSubChannel>();
     _supportsSubChannels = true;
     _minChannel          = 0;
     _maxChannel          = 128;
     _camType             = CamType.Default;
     _conditionalAccess   = null;
     _cardType            = CardType.Analog;
     _epgGrabbing         = false;
     _configuration       = Configuration.readConfiguration(_cardId, _name, _devicePath);
     Configuration.writeConfiguration(_configuration);
 }
コード例 #5
0
        /// <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);
            }
        }