#region add filters methods int IGraphDVBT.AddNetworkProvider() { pNetworkProvider = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(typeof(DVBTNetworkProvider).GUID)); return pGraph.AddFilter(pNetworkProvider, "Network Provider"); } int IGraphDVBT.AddTuner() { pDVBTTuner = DirectShowTools.CreateFilter(FilterCategory.BDASourceFiltersCategory, "AVerMedia 716x BDA DVBT Tuner"); return pGraph.AddFilter(pDVBTTuner, "DVBT Tuner"); } int IGraphDVBT.AddCapture() { pDigitalCapture = DirectShowTools.CreateFilter(FilterCategory.BDAReceiverComponentsCategory, "AVerMedia 716x BDA Digital Capture"); return pGraph.AddFilter(pDigitalCapture, "Digital Capture"); } int IGraphDVBT.AddMPEG2Demultiplexer() { pMPEGDemux = (IBaseFilter)new MPEG2Demultiplexer(); return pGraph.AddFilter(pMPEGDemux, "MPEG2 Demultiplexer"); } int IGraphDVBT.AddBDAMPEG2TIF() { pBDAMPEGTIF = DirectShowTools.CreateFilter(FilterCategory.LegacyAmFilterCategory, "BDA MPEG2 Transport Information Filter"); return pGraph.AddFilter(pBDAMPEGTIF, "BDA MPEG2 TIF"); } int IGraphDVBT.AddMPEG2SectAndTables() { pMPEGSectAndTables = DirectShowTools.CreateFilter(FilterCategory.LegacyAmFilterCategory, "MPEG-2 Sections and Tables"); return pGraph.AddFilter(pMPEGSectAndTables, "MPEG2 Section and Tables"); } int IGraphDVBT.AddVideoDecoder() { pVideoDecoder = DirectShowTools.CreateFilter(FilterCategory.LegacyAmFilterCategory, "Microsoft DTV-DVD Video Decoder"); return pGraph.AddFilter(pVideoDecoder, "DTV-DVD Video Decode"); } int IGraphDVBT.AddVideoRenderer() { pVideoRenderer = (IBaseFilter)new VideoMixingRenderer9(); return pGraph.AddFilter(pVideoRenderer, "Video Renderer"); } int IGraphDVBT.AddAudioDecoder() { pAudioDecoder = DirectShowTools.CreateFilter(FilterCategory.LegacyAmFilterCategory, "Microsoft DTV-DVD Audio Decoder"); return pGraph.AddFilter(pAudioDecoder, "DTV-DVD Audio Decode"); } int IGraphDVBT.AddAudioRenderer() { pAudioRenderer = DirectShowTools.CreateFilter(FilterCategory.AudioRendererCategory, "Default DirectSound Device"); return pGraph.AddFilter(pAudioRenderer, "Audio Renderer"); } #endregion
int IGraphDVBT.ConnectFilters() { int hr; IPin outPin; IPin inPin; outPin = DirectShowTools.FindPin(pNetworkProvider, new string[] { "Antenna Out" }); inPin = DirectShowTools.FindPin(pDVBTTuner, new string[] { "0" }); hr = pGraph.Connect(outPin, inPin); if (hr < 0) return hr; outPin = DirectShowTools.FindPin(pDVBTTuner, new string[] { "1" }); inPin = DirectShowTools.FindPin(pDigitalCapture, new string[] { "0" }); hr = pGraph.Connect(outPin, inPin); if (hr < 0) return hr; outPin = DirectShowTools.FindPin(pDigitalCapture, new string[] { "1" }); inPin = DirectShowTools.FindPin(pMPEGDemux, new string[] { "MPEG-2 Stream" }); hr = pGraph.Connect(outPin, inPin); if (hr < 0) return hr; outPin = DirectShowTools.FindPin(pMPEGDemux, new string[] { "001" }); inPin = DirectShowTools.FindPin(pBDAMPEGTIF, new string[] { "IB Input" }); hr = pGraph.Connect(outPin, inPin); if (hr < 0) return hr; outPin = DirectShowTools.FindPin(pMPEGDemux, new string[] { "002" }); inPin = DirectShowTools.FindPin(pMPEGSectAndTables, new string[] { "In" }); hr = pGraph.Connect(outPin, inPin); if (hr < 0) return hr; outPin = DirectShowTools.FindPin(pMPEGDemux, new string[] { "003" }); inPin = DirectShowTools.FindPin(pVideoDecoder, new string[] { "Video Input" }); hr = pGraph.Connect(outPin, inPin); if (hr < 0) return hr; outPin = DirectShowTools.FindPin(pMPEGDemux, new string[] { "007" }); inPin = DirectShowTools.FindPin(pAudioDecoder, new string[] { "In" }); hr = pGraph.Connect(outPin, inPin); if (hr < 0) return hr; outPin = DirectShowTools.FindPin(pVideoDecoder, new string[] { "Video Output 1" }); inPin = DirectShowTools.FindPin(pVideoRenderer, new string[] { "VMR Input0" }); hr = pGraph.Connect(outPin, inPin); if (hr < 0) return hr; outPin = DirectShowTools.FindPin(pAudioDecoder, new string[] { "Out" }); inPin = DirectShowTools.FindPin(pAudioRenderer, new string[] { "Audio Input pin (rendered)" }); hr = pGraph.Connect(outPin, inPin); if (hr < 0) return hr; return 0; }
int IGraphDVBT.SetNetworkProvider() { int hr; IDVBTuningSpace tuningSpace = (IDVBTuningSpace)new DVBTuningSpace(); hr = tuningSpace.put_UniqueName("DVBT TuningSpace"); if (hr < 0) return hr; hr = tuningSpace.put_FriendlyName("DVBT TuningSpace"); if (hr < 0) return hr; hr = tuningSpace.put_NetworkType("{" + typeof(DVBTNetworkProvider).GUID.ToString() + "}"); if (hr < 0) return hr; hr = tuningSpace.put_SystemType(DVBSystemType.Terrestrial); if (hr < 0) return hr; ITuneRequest tr; hr = tuningSpace.CreateTuneRequest(out tr); if (hr < 0) return hr; IDVBTuneRequest tuneRequest = (IDVBTuneRequest)tr; hr = (pNetworkProvider as ITuner).put_TuneRequest(tuneRequest); if (hr < 0) return hr; return 0; }
private int SetDVBTLocator(int frequency, out IDVBTLocator locator) { int hr = 0; // -- LOCATOR -- locator = (IDVBTLocator)new DVBTLocator(); //set frequency hr = locator.put_CarrierFrequency(frequency); /* kGz */ if (hr < 0) return hr; //Not set parameters hr = locator.put_Bandwidth(-1); /* in Mgz */ if (hr < 0) return hr; hr = locator.put_SymbolRate(-1); if (hr < 0) return hr; hr = locator.put_OtherFrequencyInUse(false); if (hr < 0) return hr; hr = locator.put_LPInnerFEC(FECMethod.MethodNotSet); if (hr < 0) return hr; hr = locator.put_LPInnerFECRate(BinaryConvolutionCodeRate.RateNotSet); if (hr < 0) return hr; hr = locator.put_HAlpha(HierarchyAlpha.HAlphaNotSet); if (hr < 0) return hr; hr = locator.put_Mode(TransmissionMode.ModeNotSet); if (hr < 0) return hr; hr = locator.put_InnerFEC(FECMethod.MethodNotSet); if (hr < 0) return hr; hr = locator.put_InnerFECRate(BinaryConvolutionCodeRate.RateNotSet); if (hr < 0) return hr; hr = locator.put_OuterFEC(FECMethod.MethodNotSet); if (hr < 0) return hr; hr = locator.put_OuterFECRate(BinaryConvolutionCodeRate.RateNotSet); if (hr < 0) return hr; hr = locator.put_Modulation(ModulationType.ModNotSet); if (hr < 0) return hr; return 0; }
public string[] SetFrequency(int frequency) { if (((IGraphDVBT)ConcreteGraph).NetworkProvider == null || ((IGraphDVBT)ConcreteGraph).TablesAndSections == null) { return null; } int hr = 0; IPAT PAT; //Table with SID IDVB_SDT SDT; IDVB_SIT SIT; int channelCount = 0; short pwVal = 0; ITuneRequest tuneRequest = null; //get tune request hr = (((IGraphDVBT)ConcreteGraph).NetworkProvider as ITuner).get_TuneRequest(out tuneRequest); if (hr < 0 || tuneRequest == null) { return null; } IDVBTuneRequest DVBtuneRequest = tuneRequest as IDVBTuneRequest; IDVBTLocator locator; //set locator with necessary frequency hr = SetDVBTLocator(frequency, out locator); if (hr < 0 || locator == null) { return null; } hr = DVBtuneRequest.put_Locator(locator); if (hr < 0) { return null; } //mediaControl.Stop(); hr = (((IGraphDVBT)ConcreteGraph).NetworkProvider as ITuner).put_TuneRequest(DVBtuneRequest); if (hr < 0) { return null; } //mediaControl.Run(); //value is channel SID IDvbSiParser parser = (IDvbSiParser)new DvbSiParser(); hr = parser.Initialize(((IGraphDVBT)ConcreteGraph).TablesAndSections as IMpeg2Data); if (hr < 0) { return null; } //get table with channels hr = parser.GetPAT(out PAT); if (hr < 0) { //DsError.ThrowExceptionForHR(hr); return null; } //get count of channels hr = PAT.GetCountOfRecords(out channelCount); if (hr < 0) { return null; } string[] channelsDVBT = new string[channelCount]; //put channels number in the list for (int i = 0; i < channelCount; i++) { PAT.GetRecordProgramNumber(i,out pwVal); channelsDVBT[i] = "Channel_" + pwVal.ToString(); } return channelsDVBT; }
/// <summary> /// Take tune request from Network Provider /// Set New SID and put tune request on the Network Provider /// </summary> /// <param name="SID">channel SID</param> public void SetDVBTChannels(int SID) { int hr = 0; ITuneRequest tuneRequest = null; //get tune request hr = (((IGraphDVBT)ConcreteGraph).NetworkProvider as ITuner).get_TuneRequest(out tuneRequest); if (tuneRequest == null) { return; } IDVBTuneRequest DVBtuneRequest = tuneRequest as IDVBTuneRequest; //set new channel hr = DVBtuneRequest.put_SID(SID); //put tune request hr = (((IGraphDVBT)ConcreteGraph).NetworkProvider as ITuner).put_TuneRequest(DVBtuneRequest); }
Source: https://habr.com/ru/post/127913/