public DVBSTuning() { InitializeComponent(); int hr = 0; this.tuningSpace = (IDVBSTuningSpace) new DVBSTuningSpace(); hr = this.tuningSpace.put_UniqueName("DVBS TuningSpace"); hr = this.tuningSpace.put_FriendlyName("DVBS TuningSpace"); hr = this.tuningSpace.put__NetworkType(typeof(DVBSNetworkProvider).GUID); hr = this.tuningSpace.put_SystemType(DVBSystemType.Satellite); hr = this.tuningSpace.put_LowOscillator(9750000); hr = this.tuningSpace.put_HighOscillator(10600000); ITuneRequest tr = null; hr = this.tuningSpace.CreateTuneRequest(out tr); DsError.ThrowExceptionForHR(hr); this.tuneRequest = (IDVBTuneRequest)tr; hr = this.tuneRequest.put_ONID(-1); hr = this.tuneRequest.put_TSID(-1); hr = this.tuneRequest.put_SID(-1); IDVBSLocator locator = (IDVBSLocator) new DVBSLocator(); hr = locator.put_CarrierFrequency(-1); hr = locator.put_SymbolRate(-1); hr = tr.put_Locator(locator as ILocator); }
public static ITuneRequest CreateTuneRequest(ITuningSpace ts) { int hr = 0; ITuneRequest tr = null; Guid networkType; hr = ts.CreateTuneRequest(out tr); DsError.ThrowExceptionForHR(hr); hr = ts.get__NetworkType(out networkType); if (networkType == typeof(ATSCNetworkProvider).GUID) { // I know nothing about ATSC so thoses lines are pure speculation hr = (tr as IATSCChannelTuneRequest).put_Channel(-1); IATSCLocator locator = (IATSCLocator) new ATSCLocator(); hr = locator.put_CarrierFrequency(-1); hr = tr.put_Locator(locator as ILocator); } else if (networkType == typeof(DVBTNetworkProvider).GUID) { hr = (tr as IDVBTuneRequest).put_ONID(-1); hr = (tr as IDVBTuneRequest).put_TSID(-1); hr = (tr as IDVBTuneRequest).put_SID(-1); IDVBTLocator locator = (IDVBTLocator) new DVBTLocator(); hr = locator.put_CarrierFrequency(-1); hr = tr.put_Locator(locator as ILocator); } else if (networkType == typeof(DVBSNetworkProvider).GUID) { hr = (tr as IDVBTuneRequest).put_ONID(-1); hr = (tr as IDVBTuneRequest).put_TSID(-1); hr = (tr as IDVBTuneRequest).put_SID(-1); IDVBSLocator locator = (IDVBSLocator) new DVBSLocator(); hr = locator.put_CarrierFrequency(-1); hr = locator.put_SymbolRate(-1); hr = tr.put_Locator(locator as ILocator); } return(tr); }
private void buttonCapture_Click(object sender, RoutedEventArgs e) { _extractFolder = txtTsLocation.Text; if (Directory.Exists(_extractFolder)) { if (Properties.Settings.Default.ExtractDirectory != _extractFolder) { Properties.Settings.Default.ExtractDirectory = _extractFolder; Properties.Settings.Default.Save(); } txtTsLocation.IsEnabled = false; buttonBrowse.IsEnabled = false; // List already downloaded items DirectoryInfo extractDir = new DirectoryInfo(_extractFolder); foreach (DirectoryInfo fwFolder in extractDir.EnumerateDirectories()) { FirmwareFile fwFile = new FirmwareFile(fwFolder.FullName); CompletedFiles.Add(string.Format("{0:X2}-{1:X2}-{2:X2}", fwFile.VendorId, fwFile.ModelId, fwFile.VersionId), fwFile); CompletedFileList.Add(fwFile); } timer.Interval = new TimeSpan(0, 0, 1); timer.Tick += new EventHandler(timer_Tick); timer.Start(); try { // Start BDA Capture int hr = 0; IDVBSTuningSpace tuningSpace; tuningSpace = (IDVBSTuningSpace) new DVBSTuningSpace(); hr = tuningSpace.put_UniqueName("DVBS TuningSpace"); hr = tuningSpace.put_FriendlyName("DVBS TuningSpace"); hr = tuningSpace.put__NetworkType(typeof(DVBSNetworkProvider).GUID); hr = tuningSpace.put_SystemType(DVBSystemType.Satellite); hr = tuningSpace.put_LowOscillator(9750000); hr = tuningSpace.put_HighOscillator(10600000); ITuneRequest tr = null; hr = tuningSpace.CreateTuneRequest(out tr); DsError.ThrowExceptionForHR(hr); IDVBTuneRequest tuneRequest = (IDVBTuneRequest)tr; hr = tuneRequest.put_ONID(2); hr = tuneRequest.put_TSID(2004); hr = tuneRequest.put_SID(4190); IDVBSLocator locator = (IDVBSLocator) new DVBSLocator(); hr = locator.put_CarrierFrequency(11778000); hr = locator.put_SymbolRate(27500000); hr = locator.put_Modulation(ModulationType.ModQpsk); hr = (locator as IDVBSLocator).put_SignalPolarisation(Polarisation.LinearV); hr = (locator as IDVBSLocator).put_InnerFEC(FECMethod.Viterbi); hr = (locator as IDVBSLocator).put_InnerFECRate(BinaryConvolutionCodeRate.Rate2_3); hr = (locator as IDVBSLocator).put_OuterFEC(FECMethod.Viterbi); hr = (locator as IDVBSLocator).put_OuterFECRate(BinaryConvolutionCodeRate.Rate2_3); hr = tr.put_Locator(locator as ILocator); Marshal.ReleaseComObject(locator); this.bdaGraphBuilder = new BDAGraphBuilder(); this.bdaGraphBuilder.BuildGraph(tuningSpace); this.bdaGraphBuilder.SubmitTuneRequest(tr); // We have to do this to make it actually tune! this.bdaGraphBuilder.RunGraph(); this.bdaGraphBuilder.StopGraph(); TsGrabber grabber = new TsGrabber(); grabber.Callback = new TsGrabber.ProcessBufferDelegate(ProcessBuffer); this.bdaGraphBuilder.SetUpForTs(grabber, 1); this.bdaGraphBuilder.RunGraph(); this.buttonCapture.IsEnabled = false; } catch (Exception ex) { MessageBox.Show(string.Format("Error connecting to DVB-S:\n{0}", ex), "Connection error", MessageBoxButton.OK, MessageBoxImage.Error); Close(); } } else { MessageBox.Show("Cannot find extract directory specified!"); } }
/// <summary> /// Creates the tuning space. /// </summary> protected void CreateTuningSpace() { Log.Log.WriteFile("dvbs:CreateTuningSpace()"); ITuner tuner = (ITuner)_filterNetworkProvider; SystemTuningSpaces systemTuningSpaces = new SystemTuningSpaces(); ITuningSpaceContainer container = systemTuningSpaces as ITuningSpaceContainer; if (container == null) { Log.Log.Error("CreateTuningSpace() Failed to get ITuningSpaceContainer"); return; } IEnumTuningSpaces enumTuning; ITuningSpace[] spaces = new ITuningSpace[2]; int lowOsc; int hiOsc; int lnbSwitch; if (_parameters.UseDefaultLnbFrequencies) { lowOsc = 9750; hiOsc = 10600; lnbSwitch = 11700; } else { lowOsc = _parameters.LnbLowFrequency; hiOsc = _parameters.LnbHighFrequency; lnbSwitch = _parameters.LnbSwitchFrequency; } ITuneRequest request; container.get_EnumTuningSpaces(out enumTuning); IDVBSTuningSpace tuningSpace; while (true) { int fetched; enumTuning.Next(1, spaces, out fetched); if (fetched != 1) { break; } string name; spaces[0].get_UniqueName(out name); if (name == "MediaPortal DVBS TuningSpace") { Log.Log.WriteFile("dvbs:found correct tuningspace {0}", name); _tuningSpace = (IDVBSTuningSpace)spaces[0]; tuningSpace = (IDVBSTuningSpace)_tuningSpace; tuningSpace.put_LNBSwitch(lnbSwitch * 1000); tuningSpace.put_SpectralInversion(SpectralInversion.Automatic); tuningSpace.put_LowOscillator(lowOsc * 1000); tuningSpace.put_HighOscillator(hiOsc * 1000); tuner.put_TuningSpace(tuningSpace); tuningSpace.CreateTuneRequest(out request); _tuneRequest = (IDVBTuneRequest)request; return; } Release.ComObject("ITuningSpace", spaces[0]); } Release.ComObject("IEnumTuningSpaces", enumTuning); Log.Log.WriteFile("dvbs:Create new tuningspace"); _tuningSpace = (IDVBSTuningSpace) new DVBSTuningSpace(); tuningSpace = (IDVBSTuningSpace)_tuningSpace; tuningSpace.put_UniqueName("MediaPortal DVBS TuningSpace"); tuningSpace.put_FriendlyName("MediaPortal DVBS TuningSpace"); tuningSpace.put__NetworkType(typeof(DVBSNetworkProvider).GUID); tuningSpace.put_SystemType(DVBSystemType.Satellite); tuningSpace.put_LNBSwitch(lnbSwitch * 1000); tuningSpace.put_LowOscillator(lowOsc * 1000); tuningSpace.put_HighOscillator(hiOsc * 1000); IDVBSLocator locator = (IDVBSLocator) new DVBSLocator(); locator.put_CarrierFrequency(-1); locator.put_InnerFEC(FECMethod.MethodNotSet); locator.put_InnerFECRate(BinaryConvolutionCodeRate.RateNotSet); locator.put_Modulation(ModulationType.ModNotSet); locator.put_OuterFEC(FECMethod.MethodNotSet); locator.put_OuterFECRate(BinaryConvolutionCodeRate.RateNotSet); locator.put_SymbolRate(-1); object newIndex; _tuningSpace.put_DefaultLocator(locator); container.Add(_tuningSpace, out newIndex); tuner.put_TuningSpace(_tuningSpace); Release.ComObject("TuningSpaceContainer", container); _tuningSpace.CreateTuneRequest(out request); _tuneRequest = (IDVBTuneRequest)request; }