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); }
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)); }
private void Config() { int hr = 0; IATSCTuningSpace ts = (IATSCTuningSpace) new ATSCTuningSpace(); ITuneRequest tr = null; hr = ts.put_MaxChannel(50); DsError.ThrowExceptionForHR(hr); hr = ts.put_MinChannel(5); DsError.ThrowExceptionForHR(hr); hr = ts.CreateTuneRequest(out tr); DsError.ThrowExceptionForHR(hr); atscChannelTR = (IATSCChannelTuneRequest)tr; Marshal.ReleaseComObject(ts); }
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; }
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); }