/// <summary> internal override bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest) { if (commandInterface == null) { return(false); } SatelliteFrequency frequency = tuningSpec.Frequency as SatelliteFrequency; DirectShowAPI.Pilot pilot = DsUtils.GetNativePilot(frequency.Pilot); reply = commandInterface.put_Pilot(pilot); if (reply != 0) { Logger.Instance.Write("Win7API DVB-S2 handler: Set Pilot command failed error code 0x" + reply.ToString("X")); } else { Logger.Instance.Write("Win7API DVB-S2 handler: Set Pilot command succeeded"); DirectShowAPI.RollOff rollOff = DsUtils.GetNativeRollOff(frequency.RollOff); reply = commandInterface.put_RollOff(ref rollOff); if (reply != 0) { Logger.Instance.Write("Win7API DVB-S2 handler: Set Rolloff command failed error code 0x" + reply.ToString("X")); } else { Logger.Instance.Write("Win7API DVB-S2 handler: Set Rolloff command succeeded"); } } return(reply == 0); }
private AnalysisParameters getAnalysisParameters() { AnalysisParameters analysisParameters = new AnalysisParameters(); analysisParameters.Tuners = frequencySelectionControl.Tuners; analysisParameters.ScanningFrequency = frequencySelectionControl.SelectedFrequency; if (analysisParameters.ScanningFrequency as SatelliteFrequency != null) { SatelliteFrequency satelliteFrequency = (SatelliteFrequency)analysisParameters.ScanningFrequency; satelliteFrequency.SatelliteDish = new SatelliteDish(); satelliteFrequency.SatelliteDish.LNBLowBandFrequency = frequencySelectionControl.LNBLowBandFrequency; satelliteFrequency.SatelliteDish.LNBHighBandFrequency = frequencySelectionControl.LNBHighBandFrequency; satelliteFrequency.SatelliteDish.LNBSwitchFrequency = frequencySelectionControl.LNBSwitchFrequency; satelliteFrequency.SatelliteDish.DiseqcSwitch = frequencySelectionControl.DiseqcSwitch; } analysisParameters.UseSignalPresent = frequencySelectionControl.UseSignalPresent; analysisParameters.SwitchAfterPlay = frequencySelectionControl.SwitchAfterPlay; analysisParameters.RepeatDiseqc = frequencySelectionControl.RepeatDiseqc; analysisParameters.SignalLockTimeout = (int)nudSignalLockTimeout.Value; analysisParameters.DataCollectionTimeout = (int)nudDataCollectionTimeout.Value; analysisParameters.DumpFileName = tbDumpFile.Text; return(analysisParameters); }
/// <summary> /// Initialize a new instance of the TuningSpec class for a DVB satellite frequency. /// </summary> /// <param name="satellite">The satellite to tune to.</param> /// <param name="frequency">The frequency to tune to.</param> public TuningSpec(Satellite satellite, SatelliteFrequency frequency) { this.frequency = frequency; this.satellite = satellite; symbolRate = frequency.SymbolRate; fec = frequency.FEC; signalPolarization = frequency.Polarization; modulation = frequency.Modulation; }
private DumpParameters getDumpParameters() { DumpParameters dumpParameters = new DumpParameters(); dumpParameters.Tuners = frequencySelectionControl.Tuners; dumpParameters.ScanningFrequency = frequencySelectionControl.SelectedFrequency; if (dumpParameters.ScanningFrequency as SatelliteFrequency != null) { SatelliteFrequency satelliteFrequency = (SatelliteFrequency)dumpParameters.ScanningFrequency; satelliteFrequency.SatelliteDish = new SatelliteDish(); satelliteFrequency.SatelliteDish.LNBLowBandFrequency = frequencySelectionControl.LNBLowBandFrequency; satelliteFrequency.SatelliteDish.LNBHighBandFrequency = frequencySelectionControl.LNBHighBandFrequency; satelliteFrequency.SatelliteDish.LNBSwitchFrequency = frequencySelectionControl.LNBSwitchFrequency; satelliteFrequency.SatelliteDish.DiseqcSwitch = frequencySelectionControl.DiseqcSwitch; } dumpParameters.UseSignalPresent = frequencySelectionControl.UseSignalPresent; dumpParameters.SwitchAfterPlay = frequencySelectionControl.SwitchAfterPlay; dumpParameters.RepeatDiseqc = frequencySelectionControl.RepeatDiseqc; dumpParameters.SignalLockTimeout = (int)nudSignalLockTimeout.Value; dumpParameters.DataCollectionTimeout = (int)nudDataCollectionTimeout.Value; dumpParameters.PidList = pidList; string newFilePath = string.Format("{0}\\tsdump-{1}.ts", Path.GetPathRoot(txtOutputFile.Text), DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond); try { if (before_recording_complete_script_path.Text != null) { string val = ScriptRunner.run_before_start(newFilePath, get_active_tuner_idx(), before_recording_complete_script_path.Text); //MessageBox.Show(val); if (val != null) { newFilePath = val; } } } catch (Exception e) { MessageBox.Show(e.ToString()); } dumpParameters.FileName = newFilePath; return(dumpParameters); }
internal override bool ClearDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest) { if (!dvbs2Capable) { return(true); } IBDA_DigitalDemodulator demodulator = FindDemodulator("Hauppauge", tunerFilter); if (demodulator == null) { Logger.Instance.Write("Hauppauge DVB-S2 handler: Demodulator not located"); return(false); } ModulationType modulationType = tuningSpec.NativeModulation; reply = demodulator.put_ModulationType(ref modulationType); if (reply != 0) { Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Modulation Type failed error code 0x" + reply.ToString("X")); return(false); } else { Logger.Instance.Write("Hauppauge DVB-S2 handler: Modulation type set to " + modulationType); } IntPtr commandBuffer = Marshal.AllocCoTaskMem(1024); IntPtr instanceBuffer = Marshal.AllocCoTaskMem(1024); SatelliteFrequency frequency = tuningSpec.Frequency as SatelliteFrequency; Marshal.WriteInt32(commandBuffer, (int)DirectShowAPI.Pilot.NotSet); reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_PILOT, instanceBuffer, 32, commandBuffer, 4); if (reply != 0) { Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Pilot command failed error code 0x" + reply.ToString("X")); } else { Logger.Instance.Write("Hauppauge DVB-S2 handler: Pilot set to off"); } return(reply == 0); }
private void doAnalysis(object sender, DoWorkEventArgs e) { AnalysisParameters analysisParameters = e.Argument as AnalysisParameters; pidList = null; TunerNodeType tunerNodeType; TuningSpec tuningSpec; SatelliteFrequency satelliteFrequency = analysisParameters.ScanningFrequency as SatelliteFrequency; if (satelliteFrequency != null) { tunerNodeType = TunerNodeType.Satellite; tuningSpec = new TuningSpec((Satellite)satelliteFrequency.Provider, satelliteFrequency); } else { TerrestrialFrequency terrestrialFrequency = analysisParameters.ScanningFrequency as TerrestrialFrequency; if (terrestrialFrequency != null) { tunerNodeType = TunerNodeType.Terrestrial; tuningSpec = new TuningSpec(terrestrialFrequency); } else { CableFrequency cableFrequency = analysisParameters.ScanningFrequency as CableFrequency; if (cableFrequency != null) { tunerNodeType = TunerNodeType.Cable; tuningSpec = new TuningSpec(cableFrequency); } else { AtscFrequency atscFrequency = analysisParameters.ScanningFrequency as AtscFrequency; if (atscFrequency != null) { if (atscFrequency.TunerType == TunerType.ATSC) { tunerNodeType = TunerNodeType.ATSC; } else { tunerNodeType = TunerNodeType.Cable; } tuningSpec = new TuningSpec(atscFrequency); } else { ClearQamFrequency clearQamFrequency = analysisParameters.ScanningFrequency as ClearQamFrequency; if (clearQamFrequency != null) { tunerNodeType = TunerNodeType.Cable; tuningSpec = new TuningSpec(clearQamFrequency); } else { ISDBSatelliteFrequency isdbSatelliteFrequency = analysisParameters.ScanningFrequency as ISDBSatelliteFrequency; if (isdbSatelliteFrequency != null) { tunerNodeType = TunerNodeType.ISDBS; tuningSpec = new TuningSpec((Satellite)satelliteFrequency.Provider, isdbSatelliteFrequency); } else { ISDBTerrestrialFrequency isdbTerrestrialFrequency = analysisParameters.ScanningFrequency as ISDBTerrestrialFrequency; if (isdbTerrestrialFrequency != null) { tunerNodeType = TunerNodeType.ISDBT; tuningSpec = new TuningSpec(isdbTerrestrialFrequency); } else { throw (new InvalidOperationException("Tuning frequency not recognized")); } } } } } } } Tuner currentTuner = null; bool finished = false; while (!finished) { if ((sender as BackgroundWorker).CancellationPending) { Logger.Instance.Write("Scan abandoned by user"); e.Cancel = true; resetEvent.Set(); return; } BDAGraph graph = BDAGraph.FindTuner(analysisParameters.Tuners, tunerNodeType, tuningSpec, currentTuner, analysisParameters.RepeatDiseqc, analysisParameters.SwitchAfterPlay); if (graph == null) { Logger.Instance.Write("<e> No tuner able to tune frequency " + analysisParameters.ScanningFrequency.ToString()); frequencySelectionControl.Invoke(new ShowMessage(showMessage), "No tuner able to tune frequency " + analysisParameters.ScanningFrequency.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); finished = true; } else { string tuneReply = checkTuning(graph, analysisParameters, sender as BackgroundWorker); if ((sender as BackgroundWorker).CancellationPending) { Logger.Instance.Write("Scan abandoned by user"); graph.Dispose(); e.Cancel = true; resetEvent.Set(); return; } if (tuneReply == null) { try { if (analysisParameters.DumpFileName == null || analysisParameters.DumpFileName == string.Empty) { getData(graph, analysisParameters, sender as BackgroundWorker); } else { SimulationDataProvider dataProvider = new SimulationDataProvider(analysisParameters.DumpFileName, graph.Frequency); string providerReply = dataProvider.Run(); if (providerReply != null) { Logger.Instance.Write("<e> Simulation Data Provider failed"); Logger.Instance.Write("<e> " + providerReply); frequencySelectionControl.Invoke(new ShowMessage(showMessage), "Simulation Data Provider failed." + Environment.NewLine + Environment.NewLine + providerReply, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { getData(dataProvider, analysisParameters, sender as BackgroundWorker); dataProvider.Stop(); } } } catch (IOException ex) { Logger.Instance.Write("<e> Failed to process dump file"); Logger.Instance.Write("<e> " + ex.Message); frequencySelectionControl.Invoke(new ShowMessage(showMessage), "Failed to process dump file." + Environment.NewLine + Environment.NewLine + ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } graph.Dispose(); finished = true; } else { Logger.Instance.Write("Failed to tune frequency " + analysisParameters.ScanningFrequency.ToString()); graph.Dispose(); currentTuner = graph.Tuner; } } } e.Cancel = true; resetEvent.Set(); }
internal override bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest) { if (!dvbs2Capable) { return(true); } IBDA_DigitalDemodulator demodulator = FindDemodulator("DigitalEverywhere", tunerFilter); if (demodulator == null) { Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Demodulator not located"); return(false); } ModulationType modulationType = ModulationType.ModNotSet; switch (tuningSpec.Modulation) { case Modulation.QPSK: modulationType = ModulationType.ModNbcQpsk; break; case Modulation.PSK8: modulationType = ModulationType.ModNbc8Psk; break; default: break; } if (modulationType != ModulationType.ModNotSet) { reply = demodulator.put_ModulationType(ref modulationType); if (reply != 0) { Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Set Modulation Type failed error code 0x" + reply.ToString("X")); return(false); } else { Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Modulation type changed to " + modulationType); } } else { Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Modulation type not changed"); } BinaryConvolutionCodeRate oldCodeRate; reply = demodulator.get_InnerFECRate(out oldCodeRate); if (reply != 0) { Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Get FEC Rate failed error code 0x" + reply.ToString("X")); return(false); } SatelliteFrequency satelliteFrequency = tuningSpec.Frequency as SatelliteFrequency; BinaryConvolutionCodeRate newCodeRate = oldCodeRate; if (satelliteFrequency.Pilot == DomainObjects.Pilot.Off) { newCodeRate += 64; } else { if (satelliteFrequency.Pilot == DomainObjects.Pilot.On) { newCodeRate += 128; } } switch (satelliteFrequency.RollOff) { case DomainObjects.RollOff.RollOff20: newCodeRate += 16; break; case DomainObjects.RollOff.RollOff25: newCodeRate += 32; break; case DomainObjects.RollOff.RollOff35: newCodeRate += 48; break; default: break; } if (oldCodeRate != newCodeRate) { reply = demodulator.put_InnerFECRate(newCodeRate); if (reply != 0) { Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: Set FEC Rate failed error code 0x" + reply.ToString("X")); return(false); } Logger.Instance.Write("DigitalEverywhere DVB-S2 handler: FEC Rate changed from " + oldCodeRate + " to " + newCodeRate); } return(true); }
internal override bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest) { if (!dvbs2Capable) { return(true); } IntPtr commandBuffer = Marshal.AllocCoTaskMem(commandBufferLength); for (int index = 0; index < commandBufferLength; ++index) { Marshal.WriteByte(commandBuffer, index, 0x00); } SatelliteFrequency frequency = tuningSpec.Frequency as SatelliteFrequency; switch (frequency.RollOff) { case DomainObjects.RollOff.RollOff20: Marshal.WriteInt32(commandBuffer, 0, 0); break; case DomainObjects.RollOff.RollOff25: Marshal.WriteInt32(commandBuffer, 0, 1); break; case DomainObjects.RollOff.RollOff35: Marshal.WriteInt32(commandBuffer, 0, 2); break; default: Marshal.WriteInt32(commandBuffer, 0, 0xff); break; } switch (frequency.Pilot) { case DomainObjects.Pilot.Off: Marshal.WriteInt32(commandBuffer, 4, 0); break; case DomainObjects.Pilot.On: Marshal.WriteInt32(commandBuffer, 4, 1); break; default: Marshal.WriteInt32(commandBuffer, 4, 1); break; } Marshal.WriteInt32(commandBuffer, 8, 2); // 0 = auto 1 = DVB-S 2 = DVB-S2 Marshal.WriteInt32(commandBuffer, 12, (int)tuningSpec.NativeFECRate); Marshal.WriteInt32(commandBuffer, 16, (int)ModulationType.ModBpsk); // StringBuilder commandString = new StringBuilder("TBS DVB-S2 handler: sending command 0x"); byte[] commandBytes = new byte[20]; for (int index = 0; index < 20; ++index) { int commandByte = Marshal.ReadByte(commandBuffer, index); if (commandByte < 0x10) { commandString.Append("0" + commandByte.ToString("X")); } else { commandString.Append(commandByte.ToString("X")); } } Logger.Instance.Write(commandString.ToString()); string getSet; if (useGet) { int bytesReturned; reply = propertySet.Get(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_NBC_PARAMS, commandBuffer, commandBufferLength, commandBuffer, commandBufferLength, out bytesReturned); getSet = "Get"; } else { reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_NBC_PARAMS, commandBuffer, commandBufferLength, commandBuffer, commandBufferLength); getSet = "Set"; } if (reply != 0) { Logger.Instance.Write("TBS DVB-S2 handler: " + getSet + " command failed error code 0x" + reply.ToString("X")); } else { Logger.Instance.Write("TBS DVB-S2 handler: " + getSet + " command succeeded"); } return(reply == 0); }
internal override bool SetDVBS2Parameters(TuningSpec tuningSpec, IBaseFilter tunerFilter, ITuneRequest tuneRequest) { if (!dvbs2Capable) { return(true); } IBDA_DigitalDemodulator demodulator = FindDemodulator("Hauppauge", tunerFilter); if (demodulator == null) { Logger.Instance.Write("Hauppauge DVB-S2 handler: Demodulator not located"); return(false); } ModulationType modulationType = ModulationType.ModNotSet; switch (tuningSpec.Modulation) { case Modulation.QPSK: BinaryConvolutionCodeRate codeRate; reply = demodulator.get_InnerFECRate(out codeRate); if (reply != 0) { Logger.Instance.Write("Hauppauge DVB-S2 handler: Get FEC rate failed error code 0x" + reply.ToString("X")); return(false); } if (codeRate == BinaryConvolutionCodeRate.Rate9_10) { modulationType = ModulationType.Mod32Qam; } else { if (codeRate == BinaryConvolutionCodeRate.Rate8_9) { modulationType = ModulationType.Mod16Qam; } else { modulationType = ModulationType.ModBpsk; } } break; case Modulation.PSK8: modulationType = ModulationType.ModNbc8Psk; break; default: break; } if (modulationType != ModulationType.ModNotSet) { reply = demodulator.put_ModulationType(ref modulationType); if (reply != 0) { Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Modulation Type failed error code 0x" + reply.ToString("X")); return(false); } else { Logger.Instance.Write("Hauppauge DVB-S2 handler: Modulation type changed to " + modulationType); } } else { Logger.Instance.Write("Hauppauge DVB-S2 handler: Modulation type not changed"); } IntPtr commandBuffer = Marshal.AllocCoTaskMem(1024); IntPtr instanceBuffer = Marshal.AllocCoTaskMem(1024); SatelliteFrequency frequency = tuningSpec.Frequency as SatelliteFrequency; string setting; if (frequency.SymbolRate != 30000) { Marshal.WriteInt32(commandBuffer, (int)DsUtils.GetNativePilot(frequency.Pilot)); setting = frequency.Pilot.ToString(); } else { Logger.Instance.Write("Hauppauge DVB-S2 handler: Setting pilot to off for symbol rate of 30000"); Marshal.WriteInt32(commandBuffer, (int)DirectShowAPI.Pilot.Off); setting = "Off"; } reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_PILOT, instanceBuffer, 32, commandBuffer, 4); if (reply != 0) { Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Pilot command failed error code 0x" + reply.ToString("X")); return(false); } else { Logger.Instance.Write("Hauppauge DVB-S2 handler: Pilot set to " + setting); Marshal.WriteInt32(commandBuffer, (int)DsUtils.GetNativeRollOff(frequency.RollOff)); reply = propertySet.Set(bdaTunerExtensionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_ROLL_OFF, instanceBuffer, 32, commandBuffer, 4); if (reply != 0) { Logger.Instance.Write("Hauppauge DVB-S2 handler: Set Rolloff command failed error code 0x" + reply.ToString("X")); return(false); } else { Logger.Instance.Write("Hauppauge DVB-S2 handler: Rolloff set to " + frequency.RollOff); } } return(true); }