コード例 #1
0
ファイル: TvCardDVBT.cs プロジェクト: thomasr3/MediaPortal-1
 /// <summary>
 /// Builds the graph.
 /// </summary>
 public override void BuildGraph()
 {
     try
     {
         if (_graphState != GraphState.Idle)
         {
             Log.Log.Error("dvbt:Graph already built");
             throw new TvException("Graph already build");
         }
         Log.Log.WriteFile("dvbt:BuildGraph");
         _graphBuilder = (IFilterGraph2) new FilterGraph();
         _capBuilder   = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();
         _capBuilder.SetFiltergraph(_graphBuilder);
         _rotEntry = new DsROTEntry(_graphBuilder);
         AddNetworkProviderFilter(typeof(DVBTNetworkProvider).GUID);
         AddTsWriterFilterToGraph();
         if (!useInternalNetworkProvider)
         {
             CreateTuningSpace();
             AddMpeg2DemuxerToGraph();
         }
         AddAndConnectBDABoardFilters(_device);
         string graphName = _device.Name + " - DVBT Graph.grf";
         FilterGraphTools.SaveGraphFile(_graphBuilder, graphName);
         GetTunerSignalStatistics();
         _graphState = GraphState.Created;
     }
     catch (Exception ex)
     {
         Log.Log.Write(ex);
         Dispose();
         _graphState = GraphState.Idle;
         throw new TvExceptionGraphBuildingFailed("Graph building failed", ex);
     }
 }
コード例 #2
0
 public void SaveGraph(string filename)
 {
     try
     {
         FilterGraphTools.SaveGraphFile(graphBuilder, filename);
     }
     catch (COMException e)
     {
         ShowCOMException(e, "Error saving graph " + filename);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Exception saving graph " + filename);
     }
 }
コード例 #3
0
ファイル: BaseGraph.cs プロジェクト: ewin66/media
        /// <summary>
        /// Saves the current graph to a file in the output directory.
        /// This behavior can be enabled or disabled by the appSettings OutputDebugGRF key
        /// </summary>
        public void SaveGraphFile()
        {
            bool output;

            if (bool.TryParse(ConfigurationManager.AppSettings["OutputDebugGRF"], out output))
            {
                if (output)
                {
                    if (!System.IO.Directory.Exists(AppUser.TVScannerOutputRoot))
                    {
                        System.IO.Directory.CreateDirectory(AppUser.TVScannerOutputRoot);
                    }
                    FilterGraphTools.SaveGraphFile(_graphBuilder, AppUser.TVScannerOutputRoot + this.GetType().Name + ".grf");
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Build the graph.
 /// </summary>
 public override void BuildGraph()
 {
     try
     {
         if (_graphState != GraphState.Idle)
         {
             Log.Log.Info("PBDA CC: device already initialised");
             return;
         }
         Log.Log.Info("PBDA CC: build graph");
         _graphBuilder = (IFilterGraph2) new FilterGraph();
         _capBuilder   = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();
         _capBuilder.SetFiltergraph(_graphBuilder);
         _rotEntry = new DsROTEntry(_graphBuilder);
         AddNetworkProviderFilter(typeof(ATSCNetworkProvider).GUID);
         AddTsWriterFilterToGraph();
         if (!useInternalNetworkProvider)
         {
             AddMpeg2DemuxerToGraph();
         }
         IBaseFilter lastFilter;
         AddAndConnectBDABoardFilters(_device, out lastFilter);
         _bdaCa = _filterTuner as IBDA_ConditionalAccess;
         if (_bdaCa == null)
         {
             throw new TvExceptionGraphBuildingFailed("PBDA CC: tuner filter does not implement required interface");
         }
         AddPbdaFilter(ref lastFilter);
         CompleteGraph(ref lastFilter);
         bool connected = ConnectTsWriter(_filterTuner);
         Log.Log.Debug("PBDA CC: connect OOB pin result = {0}", connected);
         CheckCableCardInfo();
         string graphName = _device.Name + " - NA Cable Graph.grf";
         FilterGraphTools.SaveGraphFile(_graphBuilder, graphName);
         GetTunerSignalStatistics();
         _graphState = GraphState.Created;
     }
     catch (Exception)
     {
         Dispose();
         throw;
     }
 }
コード例 #5
0
 public void SaveGraph(string filepath)
 {
     // Nothing to do with a DTV viewer but can be useful
     FilterGraphTools.SaveGraphFile(this.graphBuilder, filepath);
 }
コード例 #6
0
ファイル: DSGraphEditPanel.cs プロジェクト: rocee/DSGraphEdit
 /// <summary>
 /// Save the current IFilterGraph to a grf file
 /// </summary>
 /// <param name="filename"></param>
 public void SaveFilterGraph(string filename)
 {
     FilterGraphTools.SaveGraphFile(_graphBuilder, filename);
 }
コード例 #7
0
        DSStreamResultCodes InitWithVideoFile(WTVStreamingVideoRequest strq)
        {
            UsingSBEFilter = false;  // Not using stream buffer

            // Init variables
            IPin[]   pin             = new IPin[1];
            string   dPin            = string.Empty;
            string   sName           = string.Empty;
            string   dName           = string.Empty;
            string   sPin            = string.Empty;
            FileInfo fiInputFile     = new FileInfo(strq.FileName);
            string   txtOutputFNPath = fiInputFile.FullName + ".wmv";

            if (
                (fiInputFile.Extension.ToLowerInvariant().Equals(".wtv")) ||
                (fiInputFile.Extension.ToLowerInvariant().Equals(".dvr-ms"))
                )
            {
                return(DSStreamResultCodes.ErrorInvalidFileType);
            }

            int hr = 0;

            try
            {
                // Get the graphbuilder interface
                SendDebugMessage("Creating Graph Object", 0);
                IGraphBuilder graphbuilder = (IGraphBuilder)currentFilterGraph;

                // Create an ASF writer filter
                SendDebugMessage("Creating ASF Writer", 0);
                WMAsfWriter asf_filter = new WMAsfWriter();
                dc.Add(asf_filter);                            // CHECK FOR ERRORS
                currentOutputFilter = (IBaseFilter)asf_filter; // class variable
                // Add the ASF filter to the graph
                hr = graphbuilder.AddFilter((IBaseFilter)asf_filter, "WM Asf Writer");
                DsError.ThrowExceptionForHR(hr);

                // Set the filename
                SendDebugMessage("Setting filename", 0);
                IFileSinkFilter sinkFilter = (IFileSinkFilter)asf_filter;
                string          destPathFN = fiInputFile.FullName + ".wmv";
                hr = sinkFilter.SetFileName(destPathFN, null);
                DsError.ThrowExceptionForHR(hr);

                // Handy to have an ACM Wrapper filter hanging around for AVI files with MP3 audio
                SendDebugMessage("Adding ACM Wrapper", 0);
                IBaseFilter ACMFilter = FilterDefinition.AddToFilterGraph(FilterDefinitions.Other.ACMWrapperFilter, ref graphbuilder);
                dc.Add(ACMFilter);

                // Render file - then build graph
                SendDebugMessage("Rendering file", 0);
                graphbuilder.RenderFile(fiInputFile.FullName, null);
                SendDebugMessage("Saving graph", 0);
                FilterGraphTools.SaveGraphFile(graphbuilder, "C:\\ProgramData\\RemotePotato\\lastfiltergraph.grf");

                // Are both our ASF pins connected?
                IPin ASFVidInputPin = FilterGraphTools.FindPinByMediaType((IBaseFilter)asf_filter, PinDirection.Input, MediaType.Video, MediaSubType.Null);
                IPin ASFAudInputPin = FilterGraphTools.FindPinByMediaType((IBaseFilter)asf_filter, PinDirection.Input, MediaType.Audio, MediaSubType.Null);

                // Run graph [can use this also to get media type => see, e.g. dvrmstowmvhd by Babgvant]
                SendDebugMessage("Run graph for testing purposes", 0);
                IMediaControl tempControl = (IMediaControl)graphbuilder;
                IMediaEvent   tempEvent   = (IMediaEvent)graphbuilder;
                DsError.ThrowExceptionForHR(tempControl.Pause());
                EventCode pEventCode;
                hr = tempEvent.WaitForCompletion(1000, out pEventCode);

                // Get media type from vid input pin for ASF writer
                AMMediaType pmt = new AMMediaType();
                hr = ASFVidInputPin.ConnectionMediaType(pmt);

                FrameSize SourceFrameSize = null;
                if (pmt.formatType == FormatType.VideoInfo2)
                {
                    // Now graph has been run and stopped we can get the video width and height from the output pin of the main video decoder
                    VideoInfoHeader2 pvih2 = new VideoInfoHeader2();
                    Marshal.PtrToStructure(pmt.formatPtr, pvih2);
                    SourceFrameSize = new FrameSize(pvih2.BmiHeader.Width, pvih2.BmiHeader.Height);
                }
                else if (pmt.formatType == FormatType.VideoInfo)  //{05589f80-c356-11ce-bf01-00aa0055595a}
                {
                    VideoInfoHeader pvih = new VideoInfoHeader();
                    Marshal.PtrToStructure(pmt.formatPtr, pvih);
                    SourceFrameSize = new FrameSize(pvih.BmiHeader.Width, pvih.BmiHeader.Height);
                }
                else
                {
                    SourceFrameSize = new FrameSize(200, 200); // SQUARE
                }
                // Stop graph if necessary
                FilterState pFS;
                hr = tempControl.GetState(1000, out pFS);
                if (pFS != FilterState.Stopped)
                {
                    DsError.ThrowExceptionForHR(tempControl.Stop());
                }
                // Free up media type
                DsUtils.FreeAMMediaType(pmt); pmt = null;

                // (re)Configure the ASF writer with the selected WM Profile
                ConfigureASFWriter(asf_filter, strq, SourceFrameSize);

                // Release pins
                SendDebugMessage("Releasing COM objects (pins)", 0);
                // source
                Marshal.ReleaseComObject(ASFVidInputPin); ASFVidInputPin = null;
                Marshal.ReleaseComObject(ASFAudInputPin); ASFAudInputPin = null;
            }
            catch (Exception ex)
            {
                SendDebugMessageWithException(ex.Message, ex);
                return(DSStreamResultCodes.ErrorExceptionOccurred);
            }

            return(DSStreamResultCodes.OK);
        }
コード例 #8
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);
            }
        }
コード例 #9
0
ファイル: AbstractRenderer.cs プロジェクト: sandeshp/Splicer
 public void SaveToGraphFile(string fileName)
 {
     FilterGraphTools.SaveGraphFile(Graph, fileName);
 }