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 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); }