protected override void SetChannel(Channel channel) { if (channel == null) { throw new ArgumentNullException("channel"); } ITuneRequest tuneRequest; int hr = tuningSpace.CreateTuneRequest(out tuneRequest); DsError.ThrowExceptionForHR(hr); IATSCChannelTuneRequest atscRequest = (IATSCChannelTuneRequest)tuneRequest; IATSCLocator locator = (IATSCLocator) new ATSCLocator(); locator.put_CarrierFrequency(channel.CarrierFrequency); locator.put_PhysicalChannel(channel.PhysicalChannel); atscRequest.put_Locator(locator); atscRequest.put_Channel(channel.MajorChannel); atscRequest.put_MinorChannel(channel.MinorChannel); hr = tuner.put_TuneRequest(atscRequest); DsError.ThrowExceptionForHR(hr); ReleaseComObject(tuneRequest); }
public void DoTests() { locator = (IATSCLocator) new ATSCLocator(); try { TestPhysicalChannel(); TestTSID(); } finally { Marshal.ReleaseComObject(locator); } }
protected virtual Channel GetCurrentChannel() { if (!channelSet || (this.State != GraphState.Running)) { return(new Channel()); } // Debug.WriteLine("null -> get_TuneRequest"); ITuneRequest request; int hr = tuner.get_TuneRequest(out request); // Debug.WriteLine(hr.ToString("X8")); DsError.ThrowExceptionForHR(hr); // Debug.WriteLine("ITuneRequest -> IATSCChannelTuneRequest"); IATSCChannelTuneRequest atscRequest = (IATSCChannelTuneRequest)request; ILocator locator; // Debug.WriteLine("null -> get_Locator"); hr = atscRequest.get_Locator(out locator); // Debug.WriteLine(hr.ToString("X8")); DsError.ThrowExceptionForHR(hr); // Debug.WriteLine("ILocator -> IATSCLocator"); IATSCLocator atscLocator = (IATSCLocator)locator; int freq, channel, major, minor; hr = atscLocator.get_CarrierFrequency(out freq); hr = atscLocator.get_PhysicalChannel(out channel); hr = atscRequest.get_Channel(out major); hr = atscRequest.get_MinorChannel(out minor); Channel known = KnownChannels.FindClosest(new Channel(-1, -1, major, minor)); if (known != null) { if ((known.MajorChannel == major) && (known.MinorChannel == minor)) { return(known); } } return(new Channel(freq, channel, major, minor)); }
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); }
protected override Channel GetChannel() { ITuneRequest request; int hr = tuner.get_TuneRequest(out request); DsError.ThrowExceptionForHR(hr); IATSCChannelTuneRequest atscRequest = (IATSCChannelTuneRequest)request; ILocator locator; atscRequest.get_Locator(out locator); IATSCLocator atscLocator = (IATSCLocator)locator; int freq, channel, major, minor; hr = atscLocator.get_CarrierFrequency(out freq); hr = atscLocator.get_PhysicalChannel(out channel); hr = atscRequest.get_Channel(out major); hr = atscRequest.get_MinorChannel(out minor); return(new Channel(freq, channel, major, minor)); }
protected virtual void SetCurrentChannel(Channel channel) { if (channel == null) { throw new ArgumentNullException("channel"); } if (this.State != GraphState.Running) { return; } ITuneRequest tuneRequest; int hr = tuningSpace.CreateTuneRequest(out tuneRequest); DsError.ThrowExceptionForHR(hr); IATSCChannelTuneRequest atscRequest = (IATSCChannelTuneRequest)tuneRequest; IATSCLocator locator = (IATSCLocator) new ATSCLocator(); locator.put_CarrierFrequency(channel.CarrierFrequency); locator.put_PhysicalChannel(channel.PhysicalChannel); atscRequest.put_Locator(locator); atscRequest.put_Channel(channel.MajorChannel); atscRequest.put_MinorChannel(channel.MinorChannel); hr = tuner.put_TuneRequest(atscRequest); DsError.ThrowExceptionForHR(hr); ReleaseComObject(tuneRequest); channelSet = true; }
/// <summary> /// Creates the tuning space. /// </summary> protected void CreateTuningSpace() { Log.Log.WriteFile("atsc: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]; ITuneRequest request; container.get_EnumTuningSpaces(out enumTuning); 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 ATSC TuningSpace") { Log.Log.WriteFile("atsc:found correct tuningspace {0}", name); _tuningSpace = (IATSCTuningSpace)spaces[0]; tuner.put_TuningSpace(_tuningSpace); _tuningSpace.CreateTuneRequest(out request); _tuneRequest = (IATSCChannelTuneRequest)request; return; } Release.ComObject("ITuningSpace", spaces[0]); } Release.ComObject("IEnumTuningSpaces", enumTuning); Log.Log.WriteFile("atsc:Create new tuningspace"); _tuningSpace = (IATSCTuningSpace) new ATSCTuningSpace(); IATSCTuningSpace tuningSpace = (IATSCTuningSpace)_tuningSpace; tuningSpace.put_UniqueName("MediaPortal ATSC TuningSpace"); tuningSpace.put_FriendlyName("MediaPortal ATSC TuningSpace"); tuningSpace.put__NetworkType(typeof(ATSCNetworkProvider).GUID); tuningSpace.put_CountryCode(0); tuningSpace.put_InputType(TunerInputType.Antenna); tuningSpace.put_MaxMinorChannel(999); //minor channels per major tuningSpace.put_MaxPhysicalChannel(158); //69 for OTA 158 for QAM tuningSpace.put_MaxChannel(99); //major channels tuningSpace.put_MinMinorChannel(0); tuningSpace.put_MinPhysicalChannel(1); //OTA 1, QAM 2 tuningSpace.put_MinChannel(1); IATSCLocator locator = (IATSCLocator) new ATSCLocator(); locator.put_CarrierFrequency(-1); locator.put_InnerFEC(FECMethod.MethodNotSet); locator.put_InnerFECRate(BinaryConvolutionCodeRate.RateNotSet); locator.put_Modulation(ModulationType.Mod8Vsb); //OTA modultation, QAM = .Mod256Qam locator.put_OuterFEC(FECMethod.MethodNotSet); locator.put_OuterFECRate(BinaryConvolutionCodeRate.RateNotSet); locator.put_PhysicalChannel(-1); locator.put_SymbolRate(-1); locator.put_TSID(-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 = (IATSCChannelTuneRequest)request; }
private bool BeforeTune(IChannel channel) { ATSCChannel atscChannel = channel as ATSCChannel; if (atscChannel == null) { Log.Log.WriteFile("atsc:Channel is not a ATSC channel!!! {0}", channel.GetType().ToString()); return(false); } if (_graphState == GraphState.Idle) { BuildGraph(); } if (useInternalNetworkProvider) { return(true); } if (_previousChannel == null || _previousChannel.IsDifferentTransponder(atscChannel)) { Log.Log.WriteFile("atsc:using new channel tuning settings"); ITuneRequest request; int hr = _tuningSpace.CreateTuneRequest(out request); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - CreateTuneRequest"); } _tuneRequest = request; IATSCChannelTuneRequest tuneRequest = (IATSCChannelTuneRequest)_tuneRequest; ILocator locator; hr = _tuningSpace.get_DefaultLocator(out locator); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - get_DefaultLocator"); } IATSCLocator atscLocator = (IATSCLocator)locator; hr = atscLocator.put_SymbolRate(-1); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_SymbolRate"); } hr = atscLocator.put_TSID(-1); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_TSID"); } hr = atscLocator.put_CarrierFrequency((int)atscChannel.Frequency); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_CarrierFrequency"); } hr = atscLocator.put_Modulation(atscChannel.ModulationType); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_Modulation"); } hr = tuneRequest.put_Channel(atscChannel.MajorChannel); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_Channel"); } hr = tuneRequest.put_MinorChannel(atscChannel.MinorChannel); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_MinorChannel"); } hr = atscLocator.put_PhysicalChannel(atscChannel.PhysicalChannel); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_PhysicalChannel"); } hr = _tuneRequest.put_Locator(locator); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_Locator"); } //set QAM paramters if necessary... _conditionalAccess.CheckATSCQAM(atscChannel); } else { Log.Log.WriteFile("atsc:using previous channel tuning settings"); } return(true); }