Beispiel #1
0
        private bool BeforeTune(ref int subChannelId, IChannel channel)
        {
            DVBSChannel dvbsChannel = channel as DVBSChannel;

            if (dvbsChannel == null)
            {
                Log.Log.WriteFile("Channel is not a DVBS channel!!! {0}", channel.GetType().ToString());
                return(false);
            }

            /*if (CurrentChannel != null)
             * {
             * //@FIX this fails for back-2-back recordings
             * //if (oldChannel.Equals(channel)) return _mapSubChannels[0];
             * }*/
            if (dvbsChannel.SwitchingFrequency < 10)
            {
                dvbsChannel.SwitchingFrequency = 11700000;
            }
            Log.Log.WriteFile("dvbs:  Tune:{0}", channel);
            if (_graphState == GraphState.Idle)
            {
                BuildGraph();
            }
            if (_mapSubChannels.ContainsKey(subChannelId) == false)
            {
                subChannelId = GetNewSubChannel(channel);
            }
            if (useInternalNetworkProvider)
            {
                //set the DisEqC parameters
                if (_conditionalAccess != null)
                {
                    //int hr2 = ((IMediaControl)_graphBuilder).Pause();
                    _diseqCsucceded = _conditionalAccess.SendDiseqcCommand(_parameters, dvbsChannel);
                    //hr2 = ((IMediaControl)_graphBuilder).Run();

                    //move diseqc motor to correct satellite
                    if (dvbsChannel != null && dvbsChannel.SatelliteIndex > 0 && _conditionalAccess.DiSEqCMotor != null)
                    {
                        _conditionalAccess.DiSEqCMotor.GotoPosition((byte)dvbsChannel.SatelliteIndex);
                    }
                }
                return(true);
            }

            if (_previousChannel == null || _previousChannel.IsDifferentTransponder(dvbsChannel))
            {
                //_pmtPid = -1;
                ILocator locator;
                int      lowOsc;
                int      hiOsc;
                int      lnbSwitch;
                BandTypeConverter.GetDefaultLnbSetup(Parameters, dvbsChannel.BandType, out lowOsc, out hiOsc, out lnbSwitch);
                Log.Log.Info("LNB low:{0} hi:{1} switch:{2}", lowOsc, hiOsc, lnbSwitch);
                if (lnbSwitch == 0)
                {
                    lnbSwitch = 18000;
                }
                IDVBSTuningSpace tuningSpace = (IDVBSTuningSpace)_tuningSpace;
                tuningSpace.put_LNBSwitch(lnbSwitch * 1000);
                tuningSpace.put_LowOscillator(lowOsc * 1000);
                tuningSpace.put_HighOscillator(hiOsc * 1000);
                ITuneRequest request;
                _tuningSpace.CreateTuneRequest(out request);
                _tuneRequest = (IDVBTuneRequest)request;
                _tuningSpace.get_DefaultLocator(out locator);
                IDVBSLocator    dvbsLocator = (IDVBSLocator)locator;
                IDVBTuneRequest tuneRequest = (IDVBTuneRequest)_tuneRequest;
                tuneRequest.put_ONID(dvbsChannel.NetworkId);
                tuneRequest.put_SID(dvbsChannel.ServiceId);
                tuneRequest.put_TSID(dvbsChannel.TransportId);
                locator.put_CarrierFrequency((int)dvbsChannel.Frequency);
                dvbsLocator.put_SymbolRate(dvbsChannel.SymbolRate);
                dvbsLocator.put_SignalPolarisation(dvbsChannel.Polarisation);

                // Set DVB-S2 and manufacturer specific tuning parameters here.
                //-------------------------------------------------------------------
                // Important: the original dvbsChannel object *must not* be modified
                // otherwise IsDifferentTransponder() will sometimes returns true
                // when it shouldn't. See mantis 0002979.
                //-------------------------------------------------------------------
                DVBSChannel tuneChannel = new DVBSChannel(dvbsChannel);
                if (_conditionalAccess != null)
                {
                    tuneChannel = _conditionalAccess.SetDVBS2Modulation(_parameters, tuneChannel);
                }
                dvbsLocator.put_Modulation(tuneChannel.ModulationType);
                Log.Log.WriteFile("dvbs:channel modulation is set to {0}", tuneChannel.ModulationType);
                dvbsLocator.put_InnerFECRate(tuneChannel.InnerFecRate);
                Log.Log.WriteFile("dvbs:channel FECRate is set to {0}", tuneChannel.InnerFecRate);
                _tuneRequest.put_Locator(locator);

                //set the DisEqC parameters
                if (_conditionalAccess != null)
                {
                    //int hr2 = ((IMediaControl)_graphBuilder).Pause();
                    _diseqCsucceded = _conditionalAccess.SendDiseqcCommand(_parameters, dvbsChannel);
                    //hr2 = ((IMediaControl)_graphBuilder).Run();

                    //move diseqc motor to correct satellite
                    if (dvbsChannel != null && dvbsChannel.SatelliteIndex > 0 && _conditionalAccess.DiSEqCMotor != null)
                    {
                        _conditionalAccess.DiSEqCMotor.GotoPosition((byte)dvbsChannel.SatelliteIndex);
                    }
                }
            }

            _dvbsChannel = dvbsChannel;
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Creates the tuning space.
        /// </summary>
        protected void CreateTuningSpace()
        {
            Log.Log.WriteFile("dvbs: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];
            int            lowOsc;
            int            hiOsc;
            int            lnbSwitch;

            if (_parameters.UseDefaultLnbFrequencies)
            {
                lowOsc    = 9750;
                hiOsc     = 10600;
                lnbSwitch = 11700;
            }
            else
            {
                lowOsc    = _parameters.LnbLowFrequency;
                hiOsc     = _parameters.LnbHighFrequency;
                lnbSwitch = _parameters.LnbSwitchFrequency;
            }
            ITuneRequest request;

            container.get_EnumTuningSpaces(out enumTuning);
            IDVBSTuningSpace tuningSpace;

            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 DVBS TuningSpace")
                {
                    Log.Log.WriteFile("dvbs:found correct tuningspace {0}", name);

                    _tuningSpace = (IDVBSTuningSpace)spaces[0];
                    tuningSpace  = (IDVBSTuningSpace)_tuningSpace;
                    tuningSpace.put_LNBSwitch(lnbSwitch * 1000);
                    tuningSpace.put_SpectralInversion(SpectralInversion.Automatic);
                    tuningSpace.put_LowOscillator(lowOsc * 1000);
                    tuningSpace.put_HighOscillator(hiOsc * 1000);
                    tuner.put_TuningSpace(tuningSpace);
                    tuningSpace.CreateTuneRequest(out request);
                    _tuneRequest = (IDVBTuneRequest)request;
                    return;
                }
                Release.ComObject("ITuningSpace", spaces[0]);
            }
            Release.ComObject("IEnumTuningSpaces", enumTuning);
            Log.Log.WriteFile("dvbs:Create new tuningspace");
            _tuningSpace = (IDVBSTuningSpace) new DVBSTuningSpace();
            tuningSpace  = (IDVBSTuningSpace)_tuningSpace;
            tuningSpace.put_UniqueName("MediaPortal DVBS TuningSpace");
            tuningSpace.put_FriendlyName("MediaPortal DVBS TuningSpace");
            tuningSpace.put__NetworkType(typeof(DVBSNetworkProvider).GUID);
            tuningSpace.put_SystemType(DVBSystemType.Satellite);
            tuningSpace.put_LNBSwitch(lnbSwitch * 1000);
            tuningSpace.put_LowOscillator(lowOsc * 1000);
            tuningSpace.put_HighOscillator(hiOsc * 1000);
            IDVBSLocator locator = (IDVBSLocator) new DVBSLocator();

            locator.put_CarrierFrequency(-1);
            locator.put_InnerFEC(FECMethod.MethodNotSet);
            locator.put_InnerFECRate(BinaryConvolutionCodeRate.RateNotSet);
            locator.put_Modulation(ModulationType.ModNotSet);
            locator.put_OuterFEC(FECMethod.MethodNotSet);
            locator.put_OuterFECRate(BinaryConvolutionCodeRate.RateNotSet);
            locator.put_SymbolRate(-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 = (IDVBTuneRequest)request;
        }