CodeTV.GraphBuilderWDM.SubmitTuneRequest C# (CSharp) Method

SubmitTuneRequest() public method

public SubmitTuneRequest ( Channel channel ) : void
channel Channel
return void
        public override void SubmitTuneRequest(Channel channel)
        {
            if (channel is ChannelAnalogic)
            {
                ChannelAnalogic channelAnalogic = channel as ChannelAnalogic;

                int hr = 0;

                //SetCaptureResolution(this.captureFormat); // channelAnalogic.CaptureResolution);

                if (this.videoCaptureFilter != null)
                {
                    IAMAnalogVideoDecoder analogVideoDecoder = this.videoCaptureFilter as IAMAnalogVideoDecoder;
                    if (analogVideoDecoder != null)
                    {
                        AnalogVideoStandard videoStandard;
                        hr = analogVideoDecoder.get_TVFormat(out videoStandard);
                        if (videoStandard != channelAnalogic.VideoStandard)
                            hr = analogVideoDecoder.put_TVFormat(channelAnalogic.VideoStandard);
                    }
                }

                if (this.tuner != null)
                {
                    int tuningSpace = 0;
                    hr = this.tuner.get_TuningSpace(out tuningSpace);
                    if (hr < 0 || channelAnalogic.TuningSpace != tuningSpace)
                        this.tuner.put_TuningSpace(channelAnalogic.TuningSpace);

                    int countryCode = 0;
                    hr = this.tuner.get_CountryCode(out countryCode);
                    if (hr < 0 || channelAnalogic.CountryCode != countryCode)
                        this.tuner.put_CountryCode(channelAnalogic.CountryCode);

                    int connectInput = 0;
                    hr = this.tuner.get_ConnectInput(out connectInput);
                    if (hr < 0 || channelAnalogic.ConnectInput != connectInput)
                        this.tuner.put_ConnectInput(channelAnalogic.ConnectInput);

                    TunerInputType inputType = TunerInputType.Antenna;
                    hr = this.tuner.get_InputType(channelAnalogic.ConnectInput, out inputType);
                    if (hr < 0 || channelAnalogic.InputType != inputType)
                        this.tuner.put_InputType(channelAnalogic.ConnectInput, channelAnalogic.InputType);

                    AMTunerModeType mode = AMTunerModeType.Default;
                    hr = this.tuner.get_Mode(out mode);
                    if (hr < 0 || channelAnalogic.Mode != mode)
                        this.tuner.put_Mode(channelAnalogic.Mode);

                    if (channelAnalogic.Channel > 0)
                    {
                        hr = this.tuner.put_Channel(channelAnalogic.Channel, AMTunerSubChannel.Default, AMTunerSubChannel.Default);
                        DsError.ThrowExceptionForHR(hr);
                    }

                    //int plChannel;
                    //AMTunerSubChannel plVideoSubChannel;
                    //AMTunerSubChannel plAudioSubChannel;
                    //hr = this.tuner.get_Channel(out plChannel, out plVideoSubChannel, out plAudioSubChannel);

                    //if (plChannel != channelAnalogic.Channel)
                    //{
                    //    DsError.ThrowExceptionForHR(-2147024809);
                    //}
                }

                if (this.amTVAudio != null && channelAnalogic.AudioMode != TVAudioMode.None)
                {
                    TVAudioMode audioMode = TVAudioMode.Stereo;
                    hr = this.amTVAudio.get_TVAudioMode(out audioMode);
                    if (hr < 0 || channelAnalogic.AudioMode != audioMode)
                        this.amTVAudio.put_TVAudioMode(channelAnalogic.AudioMode);
                }

                if (WDMCrossbar != null)
                {
                    try
                    {
                        if (channelAnalogic.AudioSource != WDMCrossbar.GetAudioInput())
                            WDMCrossbar.SetAudioInput(channelAnalogic.AudioSource, false);
                    }
                    catch { }

                    try
                    {
                        if (channelAnalogic.VideoSource != WDMCrossbar.GetVideoInput())
                            WDMCrossbar.SetVideoInput(channelAnalogic.VideoSource, false);
                    }
                    catch { }
                }

                RunGraph();
            }

            if (useWPF)
                WpfUpdateVideoSize();
        }