Example #1
0
        public void SetParameters()
        {
            if (!IsLocal)
            {
                return;
            }
            if (_card == null)
            {
                return;
            }
            ScanParameters  settings = new ScanParameters();
            TvBusinessLayer layer    = new TvBusinessLayer();

            settings.TimeOutTune              = Int32.Parse(layer.GetSetting("timeoutTune", "2").Value);
            settings.TimeOutPAT               = Int32.Parse(layer.GetSetting("timeoutPAT", "5").Value);
            settings.TimeOutCAT               = Int32.Parse(layer.GetSetting("timeoutCAT", "5").Value);
            settings.TimeOutPMT               = Int32.Parse(layer.GetSetting("timeoutPMT", "10").Value);
            settings.TimeOutSDT               = Int32.Parse(layer.GetSetting("timeoutSDT", "20").Value);
            settings.TimeOutAnalog            = Int32.Parse(layer.GetSetting("timeoutAnalog", "20").Value);
            settings.UseDefaultLnbFrequencies = (layer.GetSetting("lnbDefault", "true").Value == "true");
            settings.LnbLowFrequency          = Int32.Parse(layer.GetSetting("LnbLowFrequency", "0").Value);
            settings.LnbHighFrequency         = Int32.Parse(layer.GetSetting("LnbHighFrequency", "0").Value);
            settings.LnbSwitchFrequency       = Int32.Parse(layer.GetSetting("LnbSwitchFrequency", "0").Value);
            settings.MinimumFiles             = Int32.Parse(layer.GetSetting("timeshiftMinFiles", "6").Value);
            settings.MaximumFiles             = Int32.Parse(layer.GetSetting("timeshiftMaxFiles", "20").Value);
            settings.MaximumFileSize          = UInt32.Parse(layer.GetSetting("timeshiftMaxFileSize", "256").Value);
            settings.MaximumFileSize         *= 1000;
            settings.MaximumFileSize         *= 1000;
            _card.Parameters = settings;
        }
        /// <summary>
        /// sets the filename used for timeshifting
        /// </summary>
        /// <param name="fileName">timeshifting filename</param>
        protected override bool OnStartTimeShifting(string fileName)
        {
            if (_card.SupportsQualityControl && !IsRecording)
            {
                _card.Quality.StartPlayback();
            }
            _timeshiftFileName = fileName;
            Log.Log.WriteFile("analog:SetTimeShiftFileName:{0}", fileName);
            Log.Log.WriteFile("analog:SetTimeShiftFileName: uses .ts");
            ScanParameters parameters = _card.Parameters;

            _mpRecord.SetVideoAudioObserver(_subChannelId, this);
            _mpRecord.SetTimeShiftParams(_subChannelId, parameters.MinimumFiles, parameters.MaximumFiles,
                                         parameters.MaximumFileSize);
            _mpRecord.SetTimeShiftFileNameW(_subChannelId, fileName);

            //  Set the channel type
            if (CurrentChannel == null)
            {
                Log.Log.Error("Error, CurrentChannel is null when trying to start timeshifting");
                return(false);
            }

            // Important: this call needs to be made *before* the call to StartTimeShifting().
            _mpRecord.SetChannelType(_subChannelId, (CurrentChannel.IsTv ? 0 : 1));

            _mpRecord.StartTimeShifting(_subChannelId);
            _dateTimeShiftStarted = DateTime.Now;
            return(true);
        }
        /// <summary>
        /// Sends the diseq command.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="parameters">The scanparameters.</param>
        public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
        {
            if (m_bIsTeVii == false)
            {
                return;
            }
            Log.Log.Debug("TeVii: SendDiseqc: {0},{1}", parameters.ToString(), channel.ToString());

            //bit 0	(1)	: 0=low band, 1 = hi band
            //bit 1 (2) : 0=vertical, 1 = horizontal
            //bit 3 (4) : 0=satellite position A, 1=satellite position B
            //bit 4 (8) : 0=switch option A, 1=switch option  B
            // LNB    option  position
            // 1        A         A
            // 2        A         B
            // 3        B         A
            // 4        B         B
            int  antennaNr    = BandTypeConverter.GetAntennaNr(channel);
            bool hiBand       = BandTypeConverter.IsHiBand(channel, parameters);
            bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                                 (channel.Polarisation == Polarisation.CircularL));
            byte cmd = 0xf0;

            cmd |= (byte)(hiBand ? 1 : 0);
            cmd |= (byte)((isHorizontal) ? 2 : 0);
            cmd |= (byte)((antennaNr - 1) << 2);

            byte[] ucMessage = new byte[4];
            ucMessage[0] = 0xE0; //framing byte
            ucMessage[1] = 0x10; //address byte
            ucMessage[2] = 0x38; //command byte
            ucMessage[3] = cmd;  //data byte (port group 0)
            //byte[] ucMessage = DiSEqC_Helper.ChannelToDiSEqC(parameters, channel);
            SendDiSEqCCommand(ucMessage);
        }
        /// <summary>
        /// Sends the diseq command.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="parameters">The channels scanning parameters.</param>
        public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
        {
            if (_isGenPix == false)
            {
                return;
            }
            Log.Log.Debug("SendDiseqc: {0},{1}", parameters.ToString(), channel.ToString());

            //bit 0	(1)	: 0=low band, 1 = hi band
            //bit 1 (2) : 0=vertical, 1 = horizontal
            //bit 3 (4) : 0=satellite position A, 1=satellite position B
            //bit 4 (8) : 0=switch option A, 1=switch option  B
            // LNB    option  position
            // 1        A         A
            // 2        A         B
            // 3        B         A
            // 4        B         B
            int  antennaNr    = BandTypeConverter.GetAntennaNr(channel);
            bool hiBand       = BandTypeConverter.IsHiBand(channel, parameters);
            bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                                 (channel.Polarisation == Polarisation.CircularL));
            byte cmd = 0xf0;

            cmd |= (byte)(hiBand ? 1 : 0);
            cmd |= (byte)((isHorizontal) ? 2 : 0);
            cmd |= (byte)((antennaNr - 1) << 2);

            DISEQC_COMMAND DiseqcCommand = new DISEQC_COMMAND();

            DiseqcCommand.ucMessage[0]    = 0xE0; //framing byte
            DiseqcCommand.ucMessage[1]    = 0x10; //address byte
            DiseqcCommand.ucMessage[2]    = 0x38; //command byte
            DiseqcCommand.ucMessage[3]    = cmd;  //data byte (port group 0)
            DiseqcCommand.ucMessage[4]    = 0;    //Need not fill this up
            DiseqcCommand.ucMessage[5]    = 0;    //Need not fill this up
            DiseqcCommand.ucMessageLength = 4;    //Number of Valid bytes in the Command.

            Marshal.StructureToPtr(DiseqcCommand, _ptrDiseqc, false);
            //get the length of the structure command - usually 7 bytes.
            int len = Marshal.SizeOf(DiseqcCommand);

            string txt = "";

            for (int i = 0; i < len; ++i)
            {
                txt += String.Format("0x{0:X} ", Marshal.ReadByte(_ptrDiseqc, i));
            }
            Log.Log.Debug("GenPix: SendDiseqCommand: {0} with length {1}", txt, len);
            //set the DisEqC command to the tuner pin
            int hr = _propertySet.Set(BdaTunerExtentionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC,
                                      _ptrTempInstance, 32, _ptrDiseqc, len);

            if (hr != 0)
            {
                Log.Log.Info("GenPix: SendDiseqCommand returned: 0x{0:X} - {1}{2}", hr, HResult.GetDXErrorString(hr),
                             DsError.GetErrorText(hr));
            }
        }
Example #5
0
        public void ScanIps()
        {
            var scanner    = new IpScan();
            var parameters = new ScanParameters();

            parameters.StartIp = IPAddress.Parse("192.168.0.1");
            parameters.LastIp  = IPAddress.Parse("192.168.0.5");

            var devices = scanner.ScanIpRange(parameters);

            Assert.NotEmpty(devices);
        }
Example #6
0
        /// <summary>
        /// Determins if the tuning paramter is HiBand and if so involke the 22Khz switch.
        /// </summary>
        /// <param name="channel">tuning details for specific channel / frequency</param>
        /// <param name="parameters">holds the parameters needed for tuning channel </param>
        /// <returns></returns>
        public static bool IsHiBand(DVBSChannel channel, ScanParameters parameters)
        {
            int lof1, lof2, sw;

            GetDefaultLnbSetup(parameters, channel.BandType, out lof1, out lof2, out sw);

            if (sw == 0)
            {
                return(false);
            }
            return(channel.Frequency >= (sw * 1000));
        }
        /// <summary>
        /// scans current transponder for more channels.
        /// </summary>
        /// <param name="channel">IChannel containing the transponder tuning details.</param>
        /// <param name="settings">Scan settings</param>
        /// <returns>list of channels found</returns>
        public IChannel[] Scan(IChannel channel, ScanParameters settings)
        {
            try
            {
                if (_cardHandler.DataBaseCard.Enabled == false)
                {
                    return(new List <IChannel>().ToArray());
                }

                try
                {
                    RemoteControl.HostName = _cardHandler.DataBaseCard.ReferencedServer().HostName;
                    if (!RemoteControl.Instance.CardPresent(_cardHandler.DataBaseCard.IdCard))
                    {
                        return(new List <IChannel>().ToArray());
                    }
                    if (_cardHandler.IsLocal == false)
                    {
                        return(RemoteControl.Instance.Scan(_cardHandler.DataBaseCard.IdCard, channel));
                    }
                }
                catch (Exception)
                {
                    Log.Error("card: unable to connect to slave controller at:{0}",
                              _cardHandler.DataBaseCard.ReferencedServer().HostName);
                    return(null);
                }
                ITVScanning scanner = _cardHandler.Card.ScanningInterface;
                if (scanner == null)
                {
                    return(null);
                }
                scanner.Reset();
                List <IChannel> channelsFound = scanner.Scan(channel, settings);
                if (channelsFound == null)
                {
                    return(null);
                }
                return(channelsFound.ToArray());
            }
            catch (TvExceptionNoSignal)
            {
                //ignore
                return(null);
            }
            catch (Exception ex)
            {
                Log.Write(ex);
                return(null);
            }
        }
Example #8
0
        /// <summary>
        /// Sends the diseq command.
        /// </summary>
        /// <param name="parameters">Scan parameters</param>
        /// <param name="channel">The channel.</param>
        public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
        {
            byte  disEqcPort = (byte)BandTypeConverter.GetAntennaNr(channel);
            Int32 LNBLOFLowBand;
            Int32 LNBLOFHighBand;
            Int32 LNBLOFHiLoSW;

            BandTypeConverter.GetDefaultLnbSetup(parameters, channel.BandType, out LNBLOFLowBand, out LNBLOFHighBand,
                                                 out LNBLOFHiLoSW);
            byte turnon22Khz = BandTypeConverter.IsHiBand(channel, parameters) ? (byte)2 : (byte)1;

            SetLnbData(true, LNBLOFLowBand, LNBLOFHighBand, LNBLOFHiLoSW, turnon22Khz, disEqcPort);
            SendDiseqcCommandTest(parameters, channel);
        }
Example #9
0
 ///<summary>
 /// Constrcutor for the analog
 ///</summary>
 ///<param name="device">Tuner Device</param>
 public TvCardAnalog(DsDevice device)
     : base(device)
 {
     _parameters          = new ScanParameters();
     _mapSubChannels      = new Dictionary <int, BaseSubChannel>();
     _supportsSubChannels = true;
     _minChannel          = 0;
     _maxChannel          = 128;
     _camType             = CamType.Default;
     _conditionalAccess   = null;
     _cardType            = CardType.Analog;
     _epgGrabbing         = false;
     _configuration       = Configuration.readConfiguration(_cardId, _name, _devicePath);
     Configuration.writeConfiguration(_configuration);
 }
 ///<summary>
 /// Constrcutor for the analog
 ///</summary>
 ///<param name="device">Tuner Device</param>
 public TvCardAnalog(DsDevice device)
   : base(device)
 {
   _parameters = new ScanParameters();
   _mapSubChannels = new Dictionary<int, BaseSubChannel>();
   _supportsSubChannels = true;
   _minChannel = 0;
   _maxChannel = 128;
   _camType = CamType.Default;
   _conditionalAccess = null;
   _cardType = CardType.Analog;
   _epgGrabbing = false;
   _configuration = Configuration.readConfiguration(_cardId, _name, _devicePath);
   Configuration.writeConfiguration(_configuration);
 }
        /// <summary>
        /// Tunes to channel using custom tune method.
        /// </summary>
        /// <param name="channel">Channel</param>
        /// <param name="Parameters">ScanParameters</param>
        /// <returns>true if successful</returns>
        public bool CustomTune(IChannel channel, ScanParameters Parameters)
        {
            if (!SupportsTuningForChannel(channel))
            {
                return(false);
            }

            DVBSChannel satelliteChannel = channel as DVBSChannel;

            bool hiBand = BandTypeConverter.IsHiBand(satelliteChannel, Parameters);
            int  lof1, lof2, sw;

            BandTypeConverter.GetDefaultLnbSetup(Parameters, satelliteChannel.BandType, out lof1, out lof2, out sw);
            int lnbFrequency;

            if (hiBand)
            {
                lnbFrequency = lof2 * 1000;
            }
            else
            {
                lnbFrequency = lof1 * 1000;
            }

            Log.Log.Debug("TeVii: Start CustomTune F:{0} SR:{1} LOF:{6} P:{2} HI:{3} M:{4} FEC:{5}",
                          (int)satelliteChannel.Frequency,
                          satelliteChannel.SymbolRate * 1000,
                          Translate(satelliteChannel.Polarisation),
                          hiBand,
                          Translate(satelliteChannel.ModulationType),
                          Translate(satelliteChannel.InnerFecRate),
                          lnbFrequency
                          );

            int res = TuneTransponder(m_iDeviceIndex,
                                      (int)satelliteChannel.Frequency,
                                      satelliteChannel.SymbolRate * 1000,
                                      lnbFrequency,
                                      Translate(satelliteChannel.Polarisation),
                                      hiBand ? 1 : 0,
                                      Translate(satelliteChannel.ModulationType),
                                      Translate(satelliteChannel.InnerFecRate)
                                      );

            Log.Log.Debug("TeVii: Send CustomTune: {0}", res);
            return(res == 1);
        }
Example #12
0
 /// <summary>
 /// Scans the specified transponder.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="settings">The settings.</param>
 /// <returns></returns>
 public override List<IChannel> Scan(IChannel channel, ScanParameters settings)
 {
   ATSCChannel atscChannel = channel as ATSCChannel;
   if (atscChannel == null)
   {
     _transportStreamStandard = TransportStreamStandard.Default;
   }
   else if (atscChannel.ModulationType == ModulationType.Mod8Vsb || atscChannel.ModulationType == ModulationType.Mod16Vsb)
   {
     _transportStreamStandard = TransportStreamStandard.Atsc;
   }
   else
   {
     _transportStreamStandard = TransportStreamStandard.Scte;
   }
   return base.Scan(channel, settings);
 }
Example #13
0
        ///<summary>
        /// Send DiseqC Command test
        ///</summary>
        ///<param name="parameters">Scan parameters</param>
        ///<param name="channel">Channel</param>
        public void SendDiseqcCommandTest(ScanParameters parameters, DVBSChannel channel)
        {
            int  antennaNr    = BandTypeConverter.GetAntennaNr(channel);
            bool hiBand       = BandTypeConverter.IsHiBand(channel, parameters);
            bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                                 (channel.Polarisation == Polarisation.CircularL));
            byte cmd = 0xf0;

            cmd |= (byte)(hiBand ? 1 : 0);
            cmd |= (byte)((isHorizontal) ? 2 : 0);
            cmd |= (byte)((antennaNr - 1) << 2);
            byte[] diseqc = new byte[4];
            diseqc[0] = 0xe0;
            diseqc[1] = 0x10;
            diseqc[2] = 0x38;
            diseqc[3] = cmd;
            SendDiSEqCCommand(diseqc);
        }
Example #14
0
        /// <summary>
        /// Scans the specified transponder.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="settings">The settings.</param>
        /// <returns></returns>
        public override List <IChannel> Scan(IChannel channel, ScanParameters settings)
        {
            ATSCChannel atscChannel = channel as ATSCChannel;

            if (atscChannel == null)
            {
                _transportStreamStandard = TransportStreamStandard.Default;
            }
            else if (atscChannel.ModulationType == ModulationType.Mod8Vsb || atscChannel.ModulationType == ModulationType.Mod16Vsb)
            {
                _transportStreamStandard = TransportStreamStandard.Atsc;
            }
            else
            {
                _transportStreamStandard = TransportStreamStandard.Scte;
            }
            return(base.Scan(channel, settings));
        }
Example #15
0
        public List <Device> ScanIpRange(ScanParameters parameters)
        {
            var devices = new List <Device>();

            var pingScan = new PingScanner();

            var ips = EnumerateIps(parameters.StartIp, parameters.LastIp);

            Parallel.ForEach(ips, (currentIp) =>
            {
                if (pingScan.CheckIp(currentIp))
                {
                    devices.Add(new Device {
                        Ip = currentIp
                    });
                }
            });

            return(devices);
        }
Example #16
0
        /// <summary>
        /// Sends the diseq command.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="parameters">The scanparameters.</param>
        public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
        {
            switch (channel.DisEqc)
            {
            case DisEqcType.Level1AA:
                Log.Log.Info("KNC:  Level1AA - SendDiSEqCCommand(0x00)");
                SendDiSEqCCommand(0x00);
                break;

            case DisEqcType.Level1AB:
                Log.Log.Info("KNC:  Level1AB - SendDiSEqCCommand(0x01)");
                SendDiSEqCCommand(0x01);
                break;

            case DisEqcType.Level1BA:
                Log.Log.Info("KNC:  Level1BA - SendDiSEqCCommand(0x0100)");
                SendDiSEqCCommand(0x0100);
                break;

            case DisEqcType.Level1BB:
                Log.Log.Info("KNC:  Level1BB - SendDiSEqCCommand(0x0101)");
                SendDiSEqCCommand(0x0101);
                break;

            case DisEqcType.SimpleA:
                Log.Log.Info("KNC:  SimpleA - SendDiSEqCCommand(0x00)");
                SendDiSEqCCommand(0x00);
                break;

            case DisEqcType.SimpleB:
                Log.Log.Info("KNC:  SimpleB - SendDiSEqCCommand(0x01)");
                SendDiSEqCCommand(0x01);
                break;

            default:
                return;
            }
        }
Example #17
0
 /// <summary>
 /// Sends the diseq command.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="parameters">The scanparameters.</param>
 public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
 {
   if (_previousChannel != null)
   {
     if (_previousChannel.Frequency == channel.Frequency &&
         _previousChannel.DisEqc == channel.DisEqc &&
         _previousChannel.Polarisation == channel.Polarisation)
     {
       Log.Log.WriteFile("TechnoTrend: already tuned to diseqc:{0}, frequency:{1}, polarisation:{2}", channel.DisEqc,
                         channel.Frequency, channel.Polarisation);
       return;
     }
   }
   _previousChannel = channel;
   int antennaNr = BandTypeConverter.GetAntennaNr(channel);
   //"01,02,03,04,05,06,07,08,09,0a,0b,cc,cc,cc,cc,cc,cc,cc,cc,cc,cc,cc,cc,cc,cc,"	
   Marshal.WriteByte(_ptrDataInstance, 0, 0xE0); //diseqc command 1. uFraming=0xe0
   Marshal.WriteByte(_ptrDataInstance, 1, 0x10); //diseqc command 1. uAddress=0x10
   Marshal.WriteByte(_ptrDataInstance, 2, 0x38); //diseqc command 1. uCommand=0x38
   //bit 0	(1)	: 0=low band, 1 = hi band
   //bit 1 (2) : 0=vertical, 1 = horizontal
   //bit 3 (4) : 0=satellite position A, 1=satellite position B
   //bit 4 (8) : 0=switch option A, 1=switch option  B
   // LNB    option  position
   // 1        A         A
   // 2        A         B
   // 3        B         A
   // 4        B         B
   bool hiBand = BandTypeConverter.IsHiBand(channel, parameters);
   Log.Log.WriteFile(
     "TechnoTrend SendDiseqcCommand() diseqc:{0}, antenna:{1} frequency:{2}, polarisation:{3} hiband:{4}",
     channel.DisEqc, antennaNr, channel.Frequency, channel.Polarisation, hiBand);
   bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                        (channel.Polarisation == Polarisation.CircularL));
   byte cmd = 0xf0;
   cmd |= (byte)(hiBand ? 1 : 0);
   cmd |= (byte)((isHorizontal) ? 2 : 0);
   cmd |= (byte)((antennaNr - 1) << 2);
   Marshal.WriteByte(_ptrDataInstance, 3, cmd);
   bdaapiSetDiSEqCMsg(m_hBdaApi, _ptrDataInstance, 4, 1, 0, (short)channel.Polarisation);
   Log.Log.Info("TechnoTrend: Diseqc Command Send");
 }
    /// <summary>
    /// Sends the diseqc command.
    /// </summary>
    /// <param name="channel">The channel.</param>
    /// <param name="parameters">The scanparameters.</param>
    public void SendDiseqcCommand(ScanParameters parameters, DVBSChannel channel)
    {
      if (_previousChannel != null)
      {
        if (_previousChannel.Frequency == channel.Frequency &&
            _previousChannel.DisEqc == channel.DisEqc &&
            _previousChannel.Polarisation == channel.Polarisation &&
            _previousChannel.Pilot == channel.Pilot &&
            _previousChannel.Rolloff == channel.Rolloff &&
            _previousChannel.InnerFecRate == channel.InnerFecRate)
        {
          _previousChannel = channel;
          Log.Log.WriteFile("FireDTV: already tuned to diseqc:{0}, frequency:{1}, polarisation:{2}",
                            channel.DisEqc, channel.Frequency, channel.Polarisation);
          return;
        }
        if (_previousChannel.DisEqc == DisEqcType.None && channel.DisEqc == DisEqcType.None)
        {
          _previousChannel = channel;
          Log.Log.WriteFile("FireDTV: already no diseqc used",
                            channel.DisEqc, channel.Frequency, channel.Polarisation);
          return;
        }
      }
      if (_previousChannel == null && channel.DisEqc == DisEqcType.None)
      {
        _previousChannel = channel;
        Log.Log.WriteFile("FireDTV: diseqc isn't used - skip it",
                          channel.DisEqc, channel.Frequency, channel.Polarisation);
        return;
      }
      _previousChannel = channel;
      int antennaNr = BandTypeConverter.GetAntennaNr(channel);

      //"01,02,03,04,05,06,07,08,09,0a,0b,cc,cc,cc,cc,cc,cc,cc,cc,cc,cc,cc,cc,cc,cc,"	

      Marshal.WriteByte(_ptrDataInstance, 0, 0xFF); //Voltage;
      Marshal.WriteByte(_ptrDataInstance, 1, 0xFF); //ContTone;
      Marshal.WriteByte(_ptrDataInstance, 2, 0xFF); //Burst;
      Marshal.WriteByte(_ptrDataInstance, 3, 0x01); //NrDiseqcCmds;

      Marshal.WriteByte(_ptrDataInstance, 4, 0x04); //diseqc command 1. length=4
      Marshal.WriteByte(_ptrDataInstance, 5, 0xE0); //diseqc command 1. uFraming=0xe0
      Marshal.WriteByte(_ptrDataInstance, 6, 0x10); //diseqc command 1. uAddress=0x10
      Marshal.WriteByte(_ptrDataInstance, 7, 0x38); //diseqc command 1. uCommand=0x38


      //bit 0	(1)	: 0=low band, 1 = hi band
      //bit 1 (2) : 0=vertical, 1 = horizontal
      //bit 3 (4) : 0=satellite position A, 1=satellite position B
      //bit 4 (8) : 0=switch option A, 1=switch option  B
      // LNB    option  position
      // 1        A         A
      // 2        A         B
      // 3        B         A
      // 4        B         B
      bool hiBand = BandTypeConverter.IsHiBand(channel, parameters);
      Log.Log.WriteFile(
        "FireDTV SendDiseqcCommand() diseqc:{0}, antenna:{1} frequency:{2},  polarisation:{3} hiband:{4}",
        channel.DisEqc, antennaNr, channel.Frequency, channel.Polarisation, hiBand);

      bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                           (channel.Polarisation == Polarisation.CircularL));
      byte cmd = 0xf0;
      cmd |= (byte)(hiBand ? 1 : 0);
      cmd |= (byte)((isHorizontal) ? 2 : 0);
      cmd |= (byte)((antennaNr - 1) << 2);
      Marshal.WriteByte(_ptrDataInstance, 8, cmd);

      Guid propertyGuid = KSPROPSETID_Firesat;
      const int propId = KSPROPERTY_FIRESAT_LNB_CONTROL;
      IKsPropertySet propertySet = _filterTuner as IKsPropertySet;
      KSPropertySupport isTypeSupported;
      if (propertySet == null)
      {
        Log.Log.WriteFile("FireDTV:SendDiseqcCommand() properySet=null");
        return;
      }

      int hr = propertySet.QuerySupported(propertyGuid, propId, out isTypeSupported);
      if (hr != 0 || (isTypeSupported & KSPropertySupport.Set) == 0)
      {
        Log.Log.WriteFile("FireDTV:SendDiseqcCommand() set is not supported {0:X} {1}", hr, (int)isTypeSupported);
        return;
      }

      string txt = "";
      for (int i = 0; i < 10; ++i)
        txt += String.Format("0x{0:X} ", Marshal.ReadByte(_ptrDataInstance, i));
      Log.Log.WriteFile("FireDTV:SendDiseq: {0}", txt);

      hr = propertySet.Set(propertyGuid, propId, _ptrDataInstance, 25, _ptrDataInstance, 25);
      if (hr != 0)
      {
        Log.Log.WriteFile("FireDTV:SendDiseqcCommand() failed:{0:X}", hr);
      }
    }
Example #19
0
    /// <summary>
    /// Sends the diseq command.
    /// </summary>
    /// <param name="channel">The channel.</param>
    /// <param name="parameters">The channels scanning parameters.</param>
    public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
    {
      if (_isProfRed == false)
        return;
      if (_previousChannel != null)
      {
        if (_previousChannel.Frequency == channel.Frequency &&
            _previousChannel.DisEqc == channel.DisEqc &&
            _previousChannel.Polarisation == channel.Polarisation &&
            _previousChannel.Pilot == channel.Pilot &&
            _previousChannel.Rolloff == channel.Rolloff &&
            _previousChannel.InnerFecRate == channel.InnerFecRate)
        {
          _previousChannel = channel;
          Log.Log.WriteFile("ProfRed: already tuned to diseqc:{0}, frequency:{1}, polarisation:{2}",
                            channel.DisEqc, channel.Frequency, channel.Polarisation);
          return;
        }
        if (_previousChannel.DisEqc == DisEqcType.None && channel.DisEqc == DisEqcType.None)
        {
          _previousChannel = channel;
          Log.Log.WriteFile("ProfRed: already no diseqc used",
                            channel.DisEqc, channel.Frequency, channel.Polarisation);
          return;
        }
      }
      if (_previousChannel == null && channel.DisEqc == DisEqcType.None)
      {
        _previousChannel = channel;
        Log.Log.WriteFile("ProfRed: diseqc isn't used - skip it",
                          channel.DisEqc, channel.Frequency, channel.Polarisation);
        return;
      }
      _previousChannel = channel;
      int antennaNr = BandTypeConverter.GetAntennaNr(channel);
      //hack - bypass diseqc settings for single LNB implementations
      if (antennaNr == 0)
        return;
      //end of hack

      //clear the message params before writing in order to avoid corruption of the diseqc message.
      for (int i = 0; i < 188; ++i)
      {
        Marshal.WriteByte(_ptrDiseqc, i, 0x00);
      }

      bool hiBand = BandTypeConverter.IsHiBand(channel, parameters);


      //bit 0	(1)	: 0=low band, 1 = hi band
      //bit 1 (2) : 0=vertical, 1 = horizontal
      //bit 3 (4) : 0=satellite position A, 1=satellite position B
      //bit 4 (8) : 0=switch option A, 1=switch option  B
      // LNB    option  position
      // 1        A         A
      // 2        A         B
      // 3        B         A
      // 4        B         B

      bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                           (channel.Polarisation == Polarisation.CircularL));
      byte cmd = 0xf0;
      cmd |= (byte)(hiBand ? 1 : 0);
      cmd |= (byte)((isHorizontal) ? 2 : 0);
      cmd |= (byte)((antennaNr - 1) << 2);

      const int len = 188;
      ulong diseqc = 0xE0103800; //currently committed switches only. i.e. ports 1-4
      diseqc += cmd;
      Marshal.WriteByte(_ptrDiseqc, 0, (byte)((diseqc >> 24) & 0xff)); //framing byte
      Marshal.WriteByte(_ptrDiseqc, 1, (byte)((diseqc >> 16) & 0xff)); //address byte
      Marshal.WriteByte(_ptrDiseqc, 2, (byte)((diseqc >> 8) & 0xff)); //command byte
      Marshal.WriteByte(_ptrDiseqc, 3, (byte)(diseqc & 0xff)); //data byte (port group 0)
      Marshal.WriteByte(_ptrDiseqc, 151, 4); //send_message_length
      Marshal.WriteByte(_ptrDiseqc, 161, 0); //receive_message_length

      if (antennaNr == 1) //for simple diseqc switches (i.e. 22KHz tone burst)
      {
        Marshal.WriteByte(_ptrDiseqc, 164, 2); // TONE_BURST_UNMODULATED
      }
      else
      {
        Marshal.WriteByte(_ptrDiseqc, 164, 1); // TONE_BURST_MODULATED
      }
      Marshal.WriteByte(_ptrDiseqc, 172, 3); //default for Diseqc
      Marshal.WriteByte(_ptrDiseqc, 168, 2); //RxMode.RXMODE_NOREPLY);//default
      Marshal.WriteByte(_ptrDiseqc, 180, 1); //last_message TRUE */
      string txt = "";
      for (int i = 0; i < 4; ++i)
        txt += String.Format("0x{0:X} ", Marshal.ReadByte(_ptrDiseqc, i));
      txt += String.Format("0x{0:X} ", Marshal.ReadByte(_ptrDiseqc, 151)); //send_message_length
      for (int i = 164; i < 188; i += 4)
        txt += String.Format("0x{0:X} ", Marshal.ReadInt32(_ptrDiseqc, i));
      Log.Log.WriteFile("ProfRed: SendDiseq: {0}", txt);

      int retval; //out value
      int hr = _propertySet.Get(_bdaTunerExtentionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, _ptrDiseqc,
                                len, _ptrDiseqc, len, out retval);
      Log.Log.Info("ProfRed: setdiseqc returned:{0:X}", hr);
    }
Example #20
0
 public List <IChannel> ScanNIT(IChannel channel, ScanParameters settings)
 {
     throw new NotImplementedException("DRI CC: NIT scanning not implemented");
 }
Example #21
0
 /// <summary>
 /// Sets the DVB s2 modulation.
 /// </summary>
 /// <param name="parameters">The parameters.</param>
 /// <param name="channel">The channel.</param>
 public DVBSChannel SetDVBS2Modulation(ScanParameters parameters, DVBSChannel channel)
 {
   return channel;
 }
Example #22
0
    /// <summary>
    /// Sends the diseq command.
    /// </summary>
    /// <param name="channel">The channel.</param>
    /// <param name="parameters">The scanparameters.</param>
    public bool SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
    {
      bool succeeded = true;
      if (_isHauppauge == false)
        return true;
      int antennaNr = BandTypeConverter.GetAntennaNr(channel);
      if (antennaNr == 0)
        return true;
      //clear the message params before writing in order to avoid corruption of the diseqc message.
      for (int i = 0; i < 188; ++i)
      {
        Marshal.WriteByte(_ptrDiseqc, i, 0x00);
      }
      bool hiBand = BandTypeConverter.IsHiBand(channel, parameters);
      //bit 0	(1)	: 0=low band, 1 = hi band
      //bit 1 (2) : 0=vertical, 1 = horizontal
      //bit 3 (4) : 0=satellite position A, 1=satellite position B
      //bit 4 (8) : 0=switch option A, 1=switch option  B
      // LNB    option  position
      // 1        A         A
      // 2        A         B
      // 3        B         A
      // 4        B         B
      bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                           (channel.Polarisation == Polarisation.CircularL));
      byte cmd = 0xf0;
      cmd |= (byte)(hiBand ? 1 : 0);
      cmd |= (byte)((isHorizontal) ? 2 : 0);
      cmd |= (byte)((antennaNr - 1) << 2);

      const int len = 188; //hauppauge diseqc message length
      ulong diseqc = 0xE0103800; //currently committed switches only. i.e. ports 1-4
      diseqc += cmd;

      Marshal.WriteByte(_ptrDiseqc, 0, (byte)((diseqc >> 24) & 0xff)); //framing byte
      Marshal.WriteByte(_ptrDiseqc, 1, (byte)((diseqc >> 16) & 0xff)); //address byte
      Marshal.WriteByte(_ptrDiseqc, 2, (byte)((diseqc >> 8) & 0xff)); //command byte
      Marshal.WriteByte(_ptrDiseqc, 3, (byte)(diseqc & 0xff)); //data byte (port group 0)
      Marshal.WriteInt32(_ptrDiseqc, 160, 4); //send_message_length
      Marshal.WriteInt32(_ptrDiseqc, 164, 0); //receive_message_length
      Marshal.WriteInt32(_ptrDiseqc, 168, 3); //amplitude_attenuation
      if (antennaNr == 1) //for simple diseqc switches (i.e. 22KHz tone burst)
      {
        Marshal.WriteByte(_ptrDiseqc, 172, (int)BurstModulationType.TONE_BURST_UNMODULATED);
      }
      else
      {
        Marshal.WriteByte(_ptrDiseqc, 172, (int)BurstModulationType.TONE_BURST_MODULATED);
        //default to tone_burst_modulated
      }
      Marshal.WriteByte(_ptrDiseqc, 176, (int)DisEqcVersion.DISEQC_VER_1X); //default
      Marshal.WriteByte(_ptrDiseqc, 180, (int)RxMode.RXMODE_NOREPLY); //default
      Marshal.WriteByte(_ptrDiseqc, 184, 1); //last_message TRUE */

      string txt = "";
      for (int i = 0; i < 4; ++i)
        txt += String.Format("0x{0:X} ", Marshal.ReadByte(_ptrDiseqc, i));
      for (int i = 160; i < 188; i = (i + 4))
        txt += String.Format("0x{0:X} ", Marshal.ReadInt32(_ptrDiseqc, i));
      Log.Log.Debug("Hauppauge: SendDiseq: {0}", txt);
      int hr = _propertySet.Set(BdaTunerExtentionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, _ptrDiseqc,
                                len, _ptrDiseqc, len);
      if (hr != 0)
      {
        succeeded = false;
        Log.Log.Info("Hauppauge: SendDiseq returned: 0x{0:X} - {1}", hr, DsError.GetErrorText(hr));
      }
      return succeeded;
    }
Example #23
0
        ///<summary>
        /// Scan NIT channel
        ///</summary>
        ///<param name="channel">Channel</param>
        ///<param name="settings">Scan Parameters</param>
        ///<returns>Found channels</returns>
        public List <IChannel> ScanNIT(IChannel channel, ScanParameters settings)
        {
            try
            {
                _card.IsScanning = true;
                _card.Scan(0, channel);
                _analyzer = GetAnalyzer();
                if (_analyzer == null)
                {
                    Log.Log.WriteFile("Scan: no analyzer interface available");
                    return(new List <IChannel>());
                }
                _analyzer.SetCallBack(null);
                _analyzer.ScanNIT();
                Thread.Sleep(settings.TimeOutTune * 1000);
                ResetSignalUpdate();
                Log.Log.WriteFile("ScanNIT: tuner locked:{0} signal:{1} quality:{2}", _card.IsTunerLocked, _card.SignalLevel,
                                  _card.SignalQuality);
                if (_card.IsTunerLocked || _card.SignalLevel > 0 || _card.SignalQuality > 0)
                {
                    int count;

                    _event = new ManualResetEvent(false);
                    _event.WaitOne(16000, true);
                    _event.Close();
                    List <IChannel> channelsFound = new List <IChannel>();
                    _analyzer.GetNITCount(out count);
                    for (int i = 0; i < count; ++i)
                    {
                        int    freq, pol, mod, symbolrate, bandwidth, innerfec, rollOff, chType;
                        IntPtr ptrName;
                        _analyzer.GetNITChannel((short)i, out chType, out freq, out pol, out mod, out symbolrate, out bandwidth,
                                                out innerfec, out rollOff, out ptrName);
                        string name = DvbTextConverter.Convert(ptrName, "");
                        if (chType == 0)
                        {
                            DVBSChannel ch = new DVBSChannel();
                            ch.Name      = name;
                            ch.Frequency = freq;
                            Log.Log.Debug("{0},{1},{2},{3}", freq, mod, pol, symbolrate);
                            switch (mod)
                            {
                            default:
                            case 0:
                                ch.ModulationType = ModulationType.ModNotSet;
                                break;

                            //case 1: ch.ModulationType = ModulationType.ModQpsk; break;
                            case 2:
                                ch.ModulationType = ModulationType.Mod8Psk;
                                break;

                            case 3:
                                ch.ModulationType = ModulationType.Mod16Qam;
                                break;
                            }
                            ch.SymbolRate   = symbolrate;
                            ch.InnerFecRate = (BinaryConvolutionCodeRate)innerfec;
                            ch.Polarisation = (Polarisation)pol;
                            ch.Rolloff      = (RollOff)rollOff;
                            channelsFound.Add(ch);
                        }
                        else if (chType == 1)
                        {
                            DVBCChannel ch = new DVBCChannel();
                            ch.Name           = name;
                            ch.Frequency      = freq;
                            ch.ModulationType = (ModulationType)mod;
                            ch.SymbolRate     = symbolrate;
                            channelsFound.Add(ch);
                        }
                        else if (chType == 2)
                        {
                            DVBTChannel ch = new DVBTChannel();
                            ch.Name      = name;
                            ch.Frequency = freq;
                            ch.BandWidth = bandwidth;
                            channelsFound.Add(ch);
                        }
                    }
                    _analyzer.StopNIT();
                    return(channelsFound);
                }
                else
                {
                    Log.Log.WriteFile("Scan: no signal detected");
                    return(new List <IChannel>());
                }
            }
            finally
            {
                if (_analyzer != null)
                {
                    _analyzer.StopNIT();
                }
                _card.IsScanning = false;
            }
        }
Example #24
0
    public List<IChannel> Scan(IChannel channel, ScanParameters settings)
    {
      try
      {
        _channels.Clear();
        _sourcesWithoutNames.Clear();

        _tuner.IsScanning = true;
        _tuner.Scan(0, channel);
        _fdcService.SubscribeStateVariables(OnTableSection);
        Thread.Sleep(1000);

        _scanStage = ScanStage.Mgt;
        _mgtParser.OnTableDetail += OnMgtTableDetail;
        _mgtParser.OnTableComplete += OnTableComplete;
        _fdcService.RequestTables(new List<byte> { 0xc7 });
        _scanEvent.Reset();
        _scanEvent.WaitOne(1000);

        _scanStage = ScanStage.Nit;
        _nitParser.Reset();
        _nitParser.OnCarrierDefinition += OnCarrierDefinition;
        _nitParser.OnModulationMode += OnModulationMode;
        _nitParser.OnTableComplete += OnTableComplete;
        _fdcService.RequestTables(new List<byte> { 0xc2 });
        _scanEvent.Reset();
        _scanEvent.WaitOne(_tuner.Parameters.TimeOutSDT * 1000);

        _scanStage = ScanStage.Vct;
        _svctParser.Reset();
        _svctParser.OnChannelDetail += OnSvctChannelDetail;
        _svctParser.OnTableComplete += OnTableComplete;
        _lvctParser.Reset();
        _lvctParser.OnChannelDetail += OnLvctChannelDetail;
        _lvctParser.OnTableComplete += OnTableComplete;
        _fdcService.RequestTables(new List<byte> { 0xc4, 0xc8, 0xc9 });
        _scanEvent.Reset();
        _scanEvent.WaitOne(_tuner.Parameters.TimeOutSDT * 1000);

        _scanStage = ScanStage.Ntt;
        _nttParser.Reset();
        _nttParser.OnSourceName += OnSourceName;
        _nttParser.OnTableComplete += OnTableComplete;
        _fdcService.RequestTables(new List<byte> { 0xc3 });
        _scanEvent.Reset();
        _scanEvent.WaitOne(_tuner.Parameters.TimeOutSDT * 1000);

        foreach (int sourceId in _sourcesWithoutNames)
        {
          Log.Log.Info("DRI CC: missing name for source 0x{0:x}", sourceId);
          ATSCChannel atscChannel = _channels[sourceId];
          if (atscChannel.MinorChannel != 0)
          {
            atscChannel.Name = string.Format("Unknown {0}-{1}", atscChannel.MajorChannel, atscChannel.MinorChannel);
          }
          else
          {
            atscChannel.Name = string.Format("Unknown {0} ({1}-{2})", atscChannel.LogicalChannelNumber, atscChannel.PhysicalChannel, atscChannel.ServiceId);
          }
        }
      }
      finally
      {
        _tuner.IsScanning = false;
        _fdcService.UnsubscribeStateVariables();
      }
      return _channels.Values.Select(x => (IChannel)x).ToList();
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="RadioWebStreamCard"/> class.
 /// </summary>
 public RadioWebStreamCard()
 {
   _name = "RadioWebStream Card (builtin)";
   _parameters = new ScanParameters();
 }
        /// <summary>
        /// Tunes to the channel specified and will start scanning for any channel
        /// </summary>
        /// <param name="channel">channel to tune to</param>
        /// <param name="settings"></param>
        /// <returns>list of channels found</returns>
        public List <IChannel> Scan(IChannel channel, ScanParameters settings)
        {
            _card.IsScanning = true;
            _card.Tune(0, channel);
            if (_card.IsTunerLocked)
            {
                if (channel.IsTv)
                {
                    if (_card.VideoFrequency == _previousFrequency)
                    {
                        return(new List <IChannel>());
                    }
                    _previousFrequency = _card.VideoFrequency;
                }

                if (channel.IsTv)
                {
                    try
                    {
                        _scanner = _card.GetChannelScanner();
                        _event   = new ManualResetEvent(false);
                        _scanner.SetCallBack(this);
                        _scanner.Start();
                        _event.WaitOne(settings.TimeOutAnalog * 1000, true);

                        IntPtr serviceName;
                        _scanner.GetChannel(out serviceName);
                        _scanner.Stop();
                        string channelName = DvbTextConverter.Convert(serviceName, "");

                        int pos = channelName.LastIndexOf("teletext", StringComparison.InvariantCultureIgnoreCase);
                        if (pos != -1)
                        {
                            channelName = channelName.Substring(0, pos);
                        }
                        //Some times channel name includes program name after :
                        pos = channelName.LastIndexOf(":");
                        if (pos != -1)
                        {
                            channelName = channelName.Substring(0, pos);
                        }
                        channelName = channelName.TrimEnd(new char[] { '\'', '\"', '´', '`' });
                        channelName = channelName.Trim();
                        if (channelName != "")
                        {
                            channel.Name = "";
                            for (int x = 0; x < channelName.Length; ++x)
                            {
                                char k = channelName[x];
                                if (k < (char)32 || k > (char)127)
                                {
                                    break;
                                }
                                channel.Name += k.ToString();
                            }
                        }
                    }
                    finally
                    {
                        if (_scanner != null)
                        {
                            _scanner.SetCallBack(null);
                            _scanner.Stop();
                        }
                        if (_event != null)
                        {
                            _event.Close();
                        }
                    }
                }
                List <IChannel> list = new List <IChannel>();
                list.Add(channel);
                _card.IsScanning = false;
                return(list);
            }
            _card.IsScanning = false;
            return(null);
        }
Example #27
0
 public List<IChannel> ScanNIT(IChannel channel, ScanParameters settings)
 {
   throw new NotImplementedException("DRI CC: NIT scanning not implemented");
 }
 /// <summary>
 /// Tunes to channels based on the list the multiplexes that make up a DVB network.
 /// This information is obtained from the DVB NIT (Network Information Table)
 /// Not applicable for Analog.
 /// </summary>
 /// <param name="channel">channel to tune to</param>
 /// <param name="settings">ScanParameters to use while tuning</param>
 /// <returns></returns>
 public List <IChannel> ScanNIT(IChannel channel, ScanParameters settings)
 {
     return(new List <IChannel>());
 }
 private async Task<string> WaitForOneADBBitmapWhileTapping(List<string> imageNames, List<Rectangle> locations, Point tapLocation, string machineName, int timeout)
 {
     bool foundOne = false;
     int selection = 0;
     int iterations = 0;
     while (!foundOne && iterations < timeout * 5)
     {
         Bitmap haystack = await ADBImageGrab(machineName);
         int len = imageNames.Count;
         for (int i =0; i< len; i++)
         {
             Bitmap needle = CommandParser.GetBmp(imageNames[i]);
             ScanParameters[] find = new ScanParameters[1];
             ScanParameters[] avoid = new ScanParameters[0];
             find[0] = new ScanParameters(needle, haystack, locations[i]);
             foundOne = Scan.Seek(find, avoid);
             if (foundOne)
             {
                 selection = i;
                 break;
             }
         }
         if (tapLocation.X >= 0)
         {
             await ADBTap(tapLocation.X, tapLocation.Y, machineName);
         }
         await Task.Delay(20); //200ms? lower due to the tap pause
         iterations++;
     }
     return imageNames[selection];
 }
 private async Task<Rectangle> WaitForADBBitmap(string name, string machineName, Rectangle location, int timeout=5)
 {
     for (int i = 0; i < timeout*5; i++)
     {
         ScanParameters[] find = new ScanParameters[1];
         ScanParameters[] avoid = new ScanParameters[0];
         Bitmap haystack = await ADBImageGrab(machineName);
         Bitmap needle = CommandParser.GetBmp(name);
         find[0] = new ScanParameters(needle, haystack, location);
         bool found = Scan.Seek(find, avoid);
         if (found)
         {
             return Scan.SearchBitmap(needle, haystack, 0.03); //hopefully NO DUPLICATE LOCATIONS!!! assuming true
         }
         await Task.Delay(40);
     }
     throw new ArithmeticException("COULD NOT FIND " + name);
 }
Example #31
0
    /// <summary>
    /// Tunes to the channel specified and will start scanning for any channel
    /// </summary>
    /// <param name="channel">channel to tune to</param>
    /// <param name="settings"></param>
    /// <returns>list of channels found</returns>
    public List<IChannel> Scan(IChannel channel, ScanParameters settings)
    {
      _card.IsScanning = true;
      _card.Tune(0, channel);
      if (_card.IsTunerLocked)
      {
        if (channel.IsTv)
        {
          if (_card.VideoFrequency == _previousFrequency)
            return new List<IChannel>();
          _previousFrequency = _card.VideoFrequency;
        }

        if (channel.IsTv)
        {
          try
          {
            _scanner = _card.GetChannelScanner();
            _event = new ManualResetEvent(false);
            _scanner.SetCallBack(this);
            _scanner.Start();
            _event.WaitOne(settings.TimeOutAnalog * 1000, true);

            IntPtr serviceName;
            _scanner.GetChannel(out serviceName);
            _scanner.Stop();
            string channelName = DvbTextConverter.Convert(serviceName, "");

            int pos = channelName.LastIndexOf("teletext", StringComparison.InvariantCultureIgnoreCase);
            if (pos != -1)
            {
              channelName = channelName.Substring(0, pos);
            }
            //Some times channel name includes program name after :
            pos = channelName.LastIndexOf(":");
            if (pos != -1)
            {
              channelName = channelName.Substring(0, pos);
            }
            channelName = channelName.TrimEnd(new char[] {'\'', '\"', '´', '`'});
            channelName = channelName.Trim();
            if (channelName != "")
            {
              channel.Name = "";
              for (int x = 0; x < channelName.Length; ++x)
              {
                char k = channelName[x];
                if (k < (char)32 || k > (char)127)
                  break;
                channel.Name += k.ToString();
              }
            }
          }
          finally
          {
            if (_scanner != null)
            {
              _scanner.SetCallBack(null);
              _scanner.Stop();
            }
            if (_event != null)
            {
              _event.Close();
            }
          }
        }
        List<IChannel> list = new List<IChannel>();
        list.Add(channel);
        _card.IsScanning = false;
        return list;
      }
      _card.IsScanning = false;
      return null;
    }
Example #32
0
 /// <summary>
 /// Sends the diseq command.
 /// </summary>
 /// <param name="parameters">Scan parameters</param>
 /// <param name="channel">The channel.</param>
 public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
 {
   byte disEqcPort = (byte)BandTypeConverter.GetAntennaNr(channel);
   Int32 LNBLOFLowBand;
   Int32 LNBLOFHighBand;
   Int32 LNBLOFHiLoSW;
   BandTypeConverter.GetDefaultLnbSetup(parameters, channel.BandType, out LNBLOFLowBand, out LNBLOFHighBand,
                                        out LNBLOFHiLoSW);
   byte turnon22Khz = BandTypeConverter.IsHiBand(channel, parameters) ? (byte)2 : (byte)1;
   SetLnbData(true, LNBLOFLowBand, LNBLOFHighBand, LNBLOFHiLoSW, turnon22Khz, disEqcPort);
   SendDiseqcCommandTest(parameters, channel);
 }
Example #33
0
        /// <summary>
        /// Sets the DVB-S2 parameters such as modulation, roll-off, pilot etc.
        /// </summary>
        /// <param name="parameters">The LNB parameters.</param>
        /// <param name="channel">The channel to tune.</param>
        /// <returns>The channel with DVB-S2 parameters set.</returns>
        public DVBSChannel SetDVBS2Modulation(ScanParameters parameters, DVBSChannel channel)
        {
            //Log.Log.WriteFile("Trying to set DVB-S2 modulation...");
            try
            {
                if (_twinhan != null)
                {
                    //DVB-S2 modulation parameters for Twinhan
                    if (channel.ModulationType == ModulationType.ModQpsk)
                    {
                        channel.ModulationType = ModulationType.Mod8Vsb;
                    }
                    if (channel.ModulationType == ModulationType.Mod8Psk)
                    {
                        channel.ModulationType = ModulationType.Mod8Vsb;
                    }
                    if (channel.ModulationType == ModulationType.Mod16Apsk)
                    {
                        channel.ModulationType = ModulationType.Mod16Vsb;
                    }
                    if (channel.ModulationType == ModulationType.Mod32Apsk)
                    {
                        channel.ModulationType = ModulationType.ModOqpsk;
                    }
                    Log.Log.WriteFile("Twinhan DVB-S2 modulation set to:{0}", channel.ModulationType);
                    Log.Log.WriteFile("Twinhan DVB-S2 Pilot set to:{0}", channel.Pilot);
                    Log.Log.WriteFile("Twinhan DVB-S2 RollOff set to:{0}", channel.Rolloff);
                    Log.Log.WriteFile("Twinhan DVB-S2 fec set to:{0}", channel.InnerFecRate);
                    return(channel);
                }
                if (_hauppauge != null)
                {
                    //Set Hauppauge pilot, roll-off settings but only if DVB-S2
                    //We assume if the modulation is set then a DVB-S2 tuning request has been requested
                    if (channel.ModulationType != ModulationType.ModNotSet)
                    {
                        //Set the alternative Hauppauge Modulation type
                        if (channel.ModulationType == ModulationType.ModQpsk)
                        {
                            if (channel.InnerFecRate == BinaryConvolutionCodeRate.Rate9_10)
                            {
                                channel.ModulationType = ModulationType.Mod32Qam;
                            }
                            channel.ModulationType = channel.InnerFecRate == BinaryConvolutionCodeRate.Rate8_9
                                         ? ModulationType.Mod16Qam
                                         : ModulationType.ModBpsk;
                        }
                        //Set the Hauppauge Modulation type

                        /*if (channel.ModulationType == ModulationType.ModQpsk)
                         * {
                         * channel.ModulationType = ModulationType.ModQpsk2;
                         * }*/
                        if (channel.ModulationType == ModulationType.Mod8Psk)
                        {
                            channel.ModulationType = ModulationType.ModNbc8Psk;
                        }
                        if (channel.SymbolRate == 30000)
                        {
                            channel.Pilot = Pilot.Off;
                        }
                        Log.Log.WriteFile("Hauppauge DVB-S2 modulation set to:{0}", channel.ModulationType);
                        Log.Log.WriteFile("Hauppauge DVB-S2 Pilot set to:{0}", channel.Pilot);
                        Log.Log.WriteFile("Hauppauge DVB-S2 RollOff set to:{0}", channel.Rolloff);
                        Log.Log.WriteFile("Hauppauge DVB-S2 fec set to:{0}", channel.InnerFecRate);
                        _hauppauge.SetDVBS2PilotRolloff(channel);
                    }
                    return(channel);
                }
                if (_profred != null)
                {
                    //Set ProfRed pilot, roll-off settings
                    if (channel.ModulationType == ModulationType.ModNotSet)
                    {
                        channel.ModulationType = ModulationType.ModNotDefined;
                    }
                    if (channel.ModulationType == ModulationType.Mod8Psk)
                    {
                        channel.ModulationType = ModulationType.ModBpsk;
                    }
                    Log.Log.WriteFile("ProfRed DVB-S2 modulation set to:{0}", channel.ModulationType);
                    Log.Log.WriteFile("ProfRed DVB-S2 Pilot set to:{0}", channel.Pilot);
                    Log.Log.WriteFile("ProfRed DVB-S2 RollOff set to:{0}", channel.Rolloff);
                    Log.Log.WriteFile("ProfRed DVB-S2 fec set to:{0}", channel.InnerFecRate);
                    //}
                    return(channel);
                }
                if (_technoTrend != null)
                {
                    //Set TechnoTrend modulation tuning settings
                    if (channel.ModulationType == ModulationType.ModQpsk)
                    {
                        channel.ModulationType = ModulationType.Mod8Vsb;
                    }
                    if (channel.ModulationType == ModulationType.Mod8Psk)
                    {
                        channel.ModulationType = ModulationType.Mod8Vsb;
                    }
                    if (channel.ModulationType == ModulationType.Mod16Apsk)
                    {
                        channel.ModulationType = ModulationType.Mod16Vsb;
                    }
                    if (channel.ModulationType == ModulationType.Mod32Apsk)
                    {
                        channel.ModulationType = ModulationType.ModOqpsk;
                    }
                    Log.Log.WriteFile("Technotrend DVB-S2 modulation set to:{0}", channel.ModulationType);
                    Log.Log.WriteFile("Technotrend DVB-S2 Pilot set to:{0}", channel.Pilot);
                    Log.Log.WriteFile("Technotrend DVB-S2 RollOff set to:{0}", channel.Rolloff);
                    Log.Log.WriteFile("Technotrend DVB-S2 fec set to:{0}", channel.InnerFecRate);
                    return(channel);
                }
                if (_knc != null)
                {
                    //Set KNC modulation tuning settings
                    if (channel.ModulationType == ModulationType.ModQpsk)
                    {
                        channel.ModulationType = ModulationType.Mod8Vsb;
                    }
                    if (channel.ModulationType == ModulationType.Mod8Psk)
                    {
                        channel.ModulationType = ModulationType.Mod8Vsb;
                    }
                    if (channel.ModulationType == ModulationType.Mod16Apsk)
                    {
                        channel.ModulationType = ModulationType.Mod16Vsb;
                    }
                    if (channel.ModulationType == ModulationType.Mod32Apsk)
                    {
                        channel.ModulationType = ModulationType.ModOqpsk;
                    }
                    Log.Log.WriteFile("KNC DVB-S2 modulation set to:{0}", channel.ModulationType);
                    Log.Log.WriteFile("KNC DVB-S2 Pilot set to:{0}", channel.Pilot);
                    Log.Log.WriteFile("KNC DVB-S2 RollOff set to:{0}", channel.Rolloff);
                    Log.Log.WriteFile("KNC DVB-S2 fec set to:{0}", channel.InnerFecRate);
                    return(channel);
                }
                if (_digitalEveryWhere != null)
                {
                    if (channel.ModulationType == ModulationType.ModQpsk)
                    {
                        channel.ModulationType = ModulationType.ModNbcQpsk;
                    }
                    if (channel.ModulationType == ModulationType.Mod8Psk)
                    {
                        channel.ModulationType = ModulationType.ModNbc8Psk;
                    }
                    //Check if DVB-S channel if not turn off Pilot & Roll-off regardless
                    if (channel.ModulationType == ModulationType.ModNotSet)
                    {
                        channel.Pilot   = Pilot.NotSet;
                        channel.Rolloff = RollOff.NotSet;
                        //Log.Log.WriteFile("DigitalEverywhere: we're tuning DVB-S, pilot & roll-off are now not set");
                    }

                    if (channel.InnerFecRate != BinaryConvolutionCodeRate.RateNotSet)
                    {
                        //Set the DigitalEverywhere binary values for Pilot & Roll-off
                        int _pilot   = 0;
                        int _rollOff = 0;
                        if (channel.Pilot == Pilot.On)
                        {
                            _pilot = 128;
                        }
                        if (channel.Pilot == Pilot.Off)
                        {
                            _pilot = 64;
                        }
                        if (channel.Rolloff == RollOff.Twenty)
                        {
                            _rollOff = 16;
                        }
                        if (channel.Rolloff == RollOff.TwentyFive)
                        {
                            _rollOff = 32;
                        }
                        if (channel.Rolloff == RollOff.ThirtyFive)
                        {
                            _rollOff = 48;
                        }
                        //The binary values get added to the current InnerFECRate - done!
                        BinaryConvolutionCodeRate r = channel.InnerFecRate + _pilot + _rollOff;
                        channel.InnerFecRate = r;
                    }
                    Log.Log.WriteFile("DigitalEverywhere DVB-S2 modulation set to:{0}", channel.ModulationType);
                    Log.Log.WriteFile("DigitalEverywhere Pilot set to:{0}", channel.Pilot);
                    Log.Log.WriteFile("DigitalEverywhere RollOff set to:{0}", channel.Rolloff);
                    Log.Log.WriteFile("DigitalEverywhere fec set to:{0}", (int)channel.InnerFecRate);
                    return(channel);
                }
            }
            catch (Exception ex)
            {
                Log.Log.Write(ex);
            }
            return(channel);
        }
Example #34
0
    /// <summary>
    /// Scans the specified transponder.
    /// </summary>
    /// <param name="channel">The channel.</param>
    /// <param name="settings">The settings.</param>
    /// <returns></returns>
    public virtual List<IChannel> Scan(IChannel channel, ScanParameters settings)
    {
      try
      {
        bool isDigitalCableScan = false;
        if (_card is TunerPbdaCableCard)
        {
          isDigitalCableScan = true;
        }
        _card.IsScanning = true;
        _card.Scan(0, channel);
        _analyzer = GetAnalyzer();
        if (_analyzer == null)
        {
          Log.Log.WriteFile("Scan: no analyzer interface available");
          return new List<IChannel>();
        }
        ResetSignalUpdate();

        // Note we don't check lock for PBDA CableCARD tuners because
        // they scan using the out of band tuner. OOB lock has already
        // been checked.
        if (_card.IsTunerLocked == false && !isDigitalCableScan)
        {
          Thread.Sleep(settings.TimeOutTune * 1000);
          ResetSignalUpdate();
        }
        Log.Log.WriteFile("Scan: tuner locked:{0} signal:{1} quality:{2}", _card.IsTunerLocked, _card.SignalLevel,
                          _card.SignalQuality);
        if (_card.IsTunerLocked || _card.SignalLevel > 0 || _card.SignalQuality > 0 || isDigitalCableScan)
        {
          try
          {
            _event = new ManualResetEvent(false);
            _analyzer.SetCallBack(this);
            _analyzer.Start(_transportStreamStandard);
            _event.WaitOne(settings.TimeOutSDT * 1000, true);

            int found = 0;
            short channelCount;
            _analyzer.GetCount(out channelCount);
            List<IChannel> channelsFound = new List<IChannel>();

            for (int i = 0; i < channelCount; ++i)
            {
              int networkId;
              int transportId;
              int serviceId;
              int majorChannel;
              int minorChannel;
              int frequency;
              short freeCAMode;
              short serviceType;
              short modulation;
              IntPtr providerName;
              IntPtr serviceName;
              int pmtPid;
              short hasVideo;
              short hasAudio;
              short hasCaDescriptor;
              int lcn;
              _analyzer.GetChannel((short)i,
                                   out networkId, out transportId, out serviceId, out majorChannel, out minorChannel,
                                   out frequency, out lcn, out freeCAMode, out serviceType, out modulation,
                                   out providerName, out serviceName,
                                   out pmtPid, out hasVideo, out hasAudio, out hasCaDescriptor);

              string name = DvbTextConverter.Convert(serviceName, "");
              Log.Log.Write("{0}) 0x{1:X} 0x{2:X} 0x{3:X} 0x{4:X} {5} type:{6:X}", i, networkId, transportId, serviceId,
                            pmtPid, name, serviceType);

              found++;
              ChannelInfo info = new ChannelInfo();
              info.networkID = networkId;
              info.transportStreamID = transportId;
              info.serviceID = serviceId;
              info.majorChannel = majorChannel;
              info.minorChannel = minorChannel;
              info.freq = frequency;
              info.LCN = lcn;
              info.serviceType = serviceType;
              info.modulation = modulation;
              info.service_provider_name = DvbTextConverter.Convert(providerName, "");
              info.service_name = DvbTextConverter.Convert(serviceName, "");
              info.scrambled = (freeCAMode != 0 || hasCaDescriptor != 0);
              info.network_pmt_PID = pmtPid;

              if (IsValidChannel(info, hasAudio, hasVideo))
              {
                if (info.service_name.Length == 0)
                {
                  SetNameForUnknownChannel(channel, info);
                }
                IChannel result = CreateNewChannel(channel, info);
                if (result != null)
                {
                  channelsFound.Add(result);
                }
              }
              else
              {
                Log.Log.Write(
                  "Found Unknown: {0} {1} type:{2} onid:{3:X} tsid:{4:X} sid:{5:X} pmt:{6:X} hasVideo:{7} hasAudio:{8}",
                  info.service_provider_name, info.service_name, info.serviceType, info.networkID,
                  info.transportStreamID, info.serviceID, info.network_pmt_PID, hasVideo, hasAudio);
              }
            }

            Log.Log.Write("Scan Got {0} from {1} channels", found, channelCount);
            return channelsFound;
          }
          finally
          {
            if (_analyzer != null)
            {
              _analyzer.SetCallBack(null);
              _analyzer.Stop();
            }
            _event.Close();
          }
        }
        else
        {
          Log.Log.WriteFile("Scan: no signal detected");
          return new List<IChannel>();
        }
      }
      finally
      {
        _card.IsScanning = false;
      }
    }
Example #35
0
        /// <summary>
        /// Scans the specified transponder.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="settings">The settings.</param>
        /// <returns></returns>
        public List <IChannel> Scan(IChannel channel, ScanParameters settings)
        {
            try
            {
                _card.IsScanning = true;
                _card.Scan(0, channel);
                _analyzer = GetAnalyzer();
                if (_analyzer == null)
                {
                    Log.Log.WriteFile("Scan: no analyzer interface available");
                    return(new List <IChannel>());
                }
                ResetSignalUpdate();
                if (_card.IsTunerLocked == false)
                {
                    Thread.Sleep(settings.TimeOutTune * 1000);
                    ResetSignalUpdate();
                }
                Log.Log.WriteFile("Scan: tuner locked:{0} signal:{1} quality:{2}", _card.IsTunerLocked, _card.SignalLevel,
                                  _card.SignalQuality);
                if (_card.IsTunerLocked || _card.SignalLevel > 0 || _card.SignalQuality > 0)
                {
                    try
                    {
                        _event = new ManualResetEvent(false);
                        _analyzer.SetCallBack(this);
                        _analyzer.Start(_enableWaitForVCT);
                        _event.WaitOne(settings.TimeOutSDT * 1000, true);

                        int   found = 0;
                        short channelCount;
                        _analyzer.GetCount(out channelCount);
                        List <IChannel> channelsFound = new List <IChannel>();

                        for (int i = 0; i < channelCount; ++i)
                        {
                            int    networkId;
                            int    transportId;
                            int    serviceId;
                            short  majorChannel;
                            short  minorChannel;
                            short  frequency;
                            short  freeCAMode;
                            short  serviceType;
                            short  modulation;
                            IntPtr providerName;
                            IntPtr serviceName;
                            short  pmtPid;
                            short  hasVideo;
                            short  hasAudio;
                            short  hasCaDescriptor;
                            short  lcn;
                            _analyzer.GetChannel((short)i,
                                                 out networkId, out transportId, out serviceId, out majorChannel, out minorChannel,
                                                 out frequency, out lcn, out freeCAMode, out serviceType, out modulation,
                                                 out providerName, out serviceName,
                                                 out pmtPid, out hasVideo, out hasAudio, out hasCaDescriptor);

                            string name = DvbTextConverter.Convert(serviceName, "");
                            Log.Log.Write("{0}) 0x{1:X} 0x{2:X} 0x{3:X} 0x{4:X} {5} type:{6:X}", i, networkId, transportId, serviceId,
                                          pmtPid, name, serviceType);

                            found++;
                            ChannelInfo info = new ChannelInfo();
                            info.networkID         = networkId;
                            info.transportStreamID = transportId;
                            info.serviceID         = serviceId;
                            info.majorChannel      = majorChannel;
                            info.minorChannel      = minorChannel;
                            info.freq                  = frequency;
                            info.LCN                   = lcn;
                            info.serviceType           = serviceType;
                            info.modulation            = modulation;
                            info.service_provider_name = DvbTextConverter.Convert(providerName, "");
                            info.service_name          = DvbTextConverter.Convert(serviceName, "");
                            info.scrambled             = (freeCAMode != 0 || hasCaDescriptor != 0);
                            info.network_pmt_PID       = pmtPid;

                            if (IsValidChannel(info, hasAudio, hasVideo))
                            {
                                if (info.service_name.Length == 0)
                                {
                                    SetNameForUnknownChannel(channel, info);
                                }
                                IChannel result = CreateNewChannel(channel, info);
                                if (result != null)
                                {
                                    channelsFound.Add(result);
                                }
                            }
                            else
                            {
                                Log.Log.Write(
                                    "Found Unknown: {0} {1} type:{2} onid:{3:X} tsid:{4:X} sid:{5:X} pmt:{6:X} hasVideo:{7} hasAudio:{8}",
                                    info.service_provider_name, info.service_name, info.serviceType, info.networkID,
                                    info.transportStreamID, info.serviceID, info.network_pmt_PID, hasVideo, hasAudio);
                            }
                        }

                        Log.Log.Write("Scan Got {0} from {1} channels", found, channelCount);
                        return(channelsFound);
                    }
                    finally
                    {
                        if (_analyzer != null)
                        {
                            _analyzer.SetCallBack(null);
                            _analyzer.Stop();
                        }
                        _event.Close();
                    }
                }
                else
                {
                    Log.Log.WriteFile("Scan: no signal detected");
                    return(new List <IChannel>());
                }
            }
            finally
            {
                _card.IsScanning = false;
            }
        }
        /// <summary>
        /// Sends the diseq command.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="parameters">The channels scanning parameters.</param>
        public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
        {
            if (_isProfRed == false)
            {
                return;
            }
            if (_previousChannel != null)
            {
                if (_previousChannel.Frequency == channel.Frequency &&
                    _previousChannel.DisEqc == channel.DisEqc &&
                    _previousChannel.Polarisation == channel.Polarisation &&
                    _previousChannel.Pilot == channel.Pilot &&
                    _previousChannel.Rolloff == channel.Rolloff &&
                    _previousChannel.InnerFecRate == channel.InnerFecRate)
                {
                    _previousChannel = channel;
                    Log.Log.WriteFile("ProfRed: already tuned to diseqc:{0}, frequency:{1}, polarisation:{2}",
                                      channel.DisEqc, channel.Frequency, channel.Polarisation);
                    return;
                }
                if (_previousChannel.DisEqc == DisEqcType.None && channel.DisEqc == DisEqcType.None)
                {
                    _previousChannel = channel;
                    Log.Log.WriteFile("ProfRed: already no diseqc used",
                                      channel.DisEqc, channel.Frequency, channel.Polarisation);
                    return;
                }
            }
            if (_previousChannel == null && channel.DisEqc == DisEqcType.None)
            {
                _previousChannel = channel;
                Log.Log.WriteFile("ProfRed: diseqc isn't used - skip it",
                                  channel.DisEqc, channel.Frequency, channel.Polarisation);
                return;
            }
            _previousChannel = channel;
            int antennaNr = BandTypeConverter.GetAntennaNr(channel);

            //hack - bypass diseqc settings for single LNB implementations
            if (antennaNr == 0)
            {
                return;
            }
            //end of hack

            //clear the message params before writing in order to avoid corruption of the diseqc message.
            for (int i = 0; i < 188; ++i)
            {
                Marshal.WriteByte(_ptrDiseqc, i, 0x00);
            }

            bool hiBand = BandTypeConverter.IsHiBand(channel, parameters);


            //bit 0	(1)	: 0=low band, 1 = hi band
            //bit 1 (2) : 0=vertical, 1 = horizontal
            //bit 3 (4) : 0=satellite position A, 1=satellite position B
            //bit 4 (8) : 0=switch option A, 1=switch option  B
            // LNB    option  position
            // 1        A         A
            // 2        A         B
            // 3        B         A
            // 4        B         B

            bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                                 (channel.Polarisation == Polarisation.CircularL));
            byte cmd = 0xf0;

            cmd |= (byte)(hiBand ? 1 : 0);
            cmd |= (byte)((isHorizontal) ? 2 : 0);
            cmd |= (byte)((antennaNr - 1) << 2);

            const int len    = 188;
            ulong     diseqc = 0xE0103800; //currently committed switches only. i.e. ports 1-4

            diseqc += cmd;
            Marshal.WriteByte(_ptrDiseqc, 0, (byte)((diseqc >> 24) & 0xff)); //framing byte
            Marshal.WriteByte(_ptrDiseqc, 1, (byte)((diseqc >> 16) & 0xff)); //address byte
            Marshal.WriteByte(_ptrDiseqc, 2, (byte)((diseqc >> 8) & 0xff));  //command byte
            Marshal.WriteByte(_ptrDiseqc, 3, (byte)(diseqc & 0xff));         //data byte (port group 0)
            Marshal.WriteByte(_ptrDiseqc, 151, 4);                           //send_message_length
            Marshal.WriteByte(_ptrDiseqc, 161, 0);                           //receive_message_length

            if (antennaNr == 1)                                              //for simple diseqc switches (i.e. 22KHz tone burst)
            {
                Marshal.WriteByte(_ptrDiseqc, 164, 2);                       // TONE_BURST_UNMODULATED
            }
            else
            {
                Marshal.WriteByte(_ptrDiseqc, 164, 1); // TONE_BURST_MODULATED
            }
            Marshal.WriteByte(_ptrDiseqc, 172, 3);     //default for Diseqc
            Marshal.WriteByte(_ptrDiseqc, 168, 2);     //RxMode.RXMODE_NOREPLY);//default
            Marshal.WriteByte(_ptrDiseqc, 180, 1);     //last_message TRUE */
            string txt = "";

            for (int i = 0; i < 4; ++i)
            {
                txt += String.Format("0x{0:X} ", Marshal.ReadByte(_ptrDiseqc, i));
            }
            txt += String.Format("0x{0:X} ", Marshal.ReadByte(_ptrDiseqc, 151)); //send_message_length
            for (int i = 164; i < 188; i += 4)
            {
                txt += String.Format("0x{0:X} ", Marshal.ReadInt32(_ptrDiseqc, i));
            }
            Log.Log.WriteFile("ProfRed: SendDiseq: {0}", txt);

            int retval; //out value
            int hr = _propertySet.Get(_bdaTunerExtentionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, _ptrDiseqc,
                                      len, _ptrDiseqc, len, out retval);

            Log.Log.Info("ProfRed: setdiseqc returned:{0:X}", hr);
        }
Example #37
0
        public List <IChannel> Scan(IChannel channel, ScanParameters settings)
        {
            try
            {
                _channels.Clear();
                _sourcesWithoutNames.Clear();

                _tuner.IsScanning = true;
                _tuner.Scan(0, channel);
                _fdcService.SubscribeStateVariables(OnTableSection);
                Thread.Sleep(1000);

                _scanStage = ScanStage.Mgt;
                _mgtParser.OnTableDetail   += OnMgtTableDetail;
                _mgtParser.OnTableComplete += OnTableComplete;
                _fdcService.RequestTables(new List <byte> {
                    0xc7
                });
                _scanEvent.Reset();
                _scanEvent.WaitOne(1000);

                _scanStage = ScanStage.Nit;
                _nitParser.Reset();
                _nitParser.OnCarrierDefinition += OnCarrierDefinition;
                _nitParser.OnModulationMode    += OnModulationMode;
                _nitParser.OnTableComplete     += OnTableComplete;
                _fdcService.RequestTables(new List <byte> {
                    0xc2
                });
                _scanEvent.Reset();
                _scanEvent.WaitOne(_tuner.Parameters.TimeOutSDT * 1000);

                _scanStage = ScanStage.Vct;
                _svctParser.Reset();
                _svctParser.OnChannelDetail += OnSvctChannelDetail;
                _svctParser.OnTableComplete += OnTableComplete;
                _lvctParser.Reset();
                _lvctParser.OnChannelDetail += OnLvctChannelDetail;
                _lvctParser.OnTableComplete += OnTableComplete;
                _fdcService.RequestTables(new List <byte> {
                    0xc4, 0xc8, 0xc9
                });
                _scanEvent.Reset();
                _scanEvent.WaitOne(_tuner.Parameters.TimeOutSDT * 1000);

                _scanStage = ScanStage.Ntt;
                _nttParser.Reset();
                _nttParser.OnSourceName    += OnSourceName;
                _nttParser.OnTableComplete += OnTableComplete;
                _fdcService.RequestTables(new List <byte> {
                    0xc3
                });
                _scanEvent.Reset();
                _scanEvent.WaitOne(_tuner.Parameters.TimeOutSDT * 1000);

                foreach (int sourceId in _sourcesWithoutNames)
                {
                    Log.Log.Info("DRI CC: missing name for source 0x{0:x}", sourceId);
                    ATSCChannel atscChannel = _channels[sourceId];
                    if (atscChannel.MinorChannel != 0)
                    {
                        atscChannel.Name = string.Format("Unknown {0}-{1}", atscChannel.MajorChannel, atscChannel.MinorChannel);
                    }
                    else
                    {
                        atscChannel.Name = string.Format("Unknown {0} ({1}-{2})", atscChannel.LogicalChannelNumber, atscChannel.PhysicalChannel, atscChannel.ServiceId);
                    }
                }
            }
            finally
            {
                _tuner.IsScanning = false;
                _fdcService.UnsubscribeStateVariables();
            }
            return(_channels.Values.Select(x => (IChannel)x).ToList());
        }
Example #38
0
    /// <summary>
    /// Tunes to channel using custom tune method.
    /// </summary>
    /// <param name="channel">Channel</param>
    /// <param name="Parameters">ScanParameters</param>
    /// <returns>true if successful</returns>
    public bool CustomTune(IChannel channel, ScanParameters Parameters)
    {
      if (!SupportsTuningForChannel(channel))
        return false;

      DVBSChannel satelliteChannel = channel as DVBSChannel;

      bool hiBand = BandTypeConverter.IsHiBand(satelliteChannel, Parameters);
      int lof1, lof2, sw;
      BandTypeConverter.GetDefaultLnbSetup(Parameters, satelliteChannel.BandType, out lof1, out lof2, out sw);
      int lnbFrequency;
      if (hiBand)
        lnbFrequency = lof2 * 1000;
      else
        lnbFrequency = lof1 * 1000;

      Log.Log.Debug("TeVii: Start CustomTune F:{0} SR:{1} LOF:{6} P:{2} HI:{3} M:{4} FEC:{5}",
                    (int)satelliteChannel.Frequency,
                    satelliteChannel.SymbolRate * 1000,
                    Translate(satelliteChannel.Polarisation),
                    hiBand,
                    Translate(satelliteChannel.ModulationType),
                    Translate(satelliteChannel.InnerFecRate),
                    lnbFrequency
        );

      int res = TuneTransponder(m_iDeviceIndex,
                                (int)satelliteChannel.Frequency,
                                satelliteChannel.SymbolRate * 1000,
                                lnbFrequency,
                                Translate(satelliteChannel.Polarisation),
                                hiBand ? 1 : 0,
                                Translate(satelliteChannel.ModulationType),
                                Translate(satelliteChannel.InnerFecRate)
        );
      Log.Log.Debug("TeVii: Send CustomTune: {0}", res);
      return (res == 1);
    }
 /// <summary>
 /// Sets the DVB s2 modulation.
 /// </summary>
 /// <param name="parameters">The parameters.</param>
 /// <param name="channel">The channel.</param>
 public DVBSChannel SetDVBS2Modulation(ScanParameters parameters, DVBSChannel channel)
 {
     return(channel);
 }
 /// <summary>
 /// sends the diseqc command to the card
 /// </summary>
 /// <param name="parameters">The parameters.</param>
 /// <param name="channel">The current tv/radio channel</param>
 public bool SendDiseqcCommand(ScanParameters parameters, DVBSChannel channel)
 {
   bool succeeded = true;
   try
   {
     if (_knc != null)
     {
       _knc.SendDiseqCommand(parameters, channel);
       System.Threading.Thread.Sleep(100);
     }
     if (_digitalEveryWhere != null)
     {
       _digitalEveryWhere.SendDiseqcCommand(parameters, channel);
       System.Threading.Thread.Sleep(100);
     }
     if (_technoTrend != null)
     {
       _technoTrend.SendDiseqCommand(parameters, channel);
       System.Threading.Thread.Sleep(100);
     }
     if (_twinhan != null)
     {
       _twinhan.SendDiseqCommand(parameters, channel);
       System.Threading.Thread.Sleep(100);
     }
     if (_hauppauge != null)
     {
       succeeded = _hauppauge.SendDiseqCommand(parameters, channel);
       System.Threading.Thread.Sleep(100);
     }
     if (_genericbdas != null)
     {
       _genericbdas.SendDiseqCommand(parameters, channel);
       System.Threading.Thread.Sleep(100);
     }
     if (_conexant != null)
     {
       _conexant.SendDiseqCommand(parameters, channel);
       System.Threading.Thread.Sleep(100);
     }
     if (_profred != null)
     {
       _profred.SendDiseqCommand(parameters, channel);
       System.Threading.Thread.Sleep(100);
     }
     if (_genpix != null)
     {
       _genpix.SendDiseqCommand(parameters, channel);
       System.Threading.Thread.Sleep(100);
     }
     if (_TeVii != null)
     {
       _TeVii.SendDiseqCommand(parameters, channel);
       System.Threading.Thread.Sleep(100);
     }
   }
   catch (Exception ex)
   {
     Log.Log.Write(ex);
   }
   return succeeded;
 }
Example #41
0
 /// <summary>
 /// Sends the diseq command.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="parameters">The scanparameters.</param>
 public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
 {
   switch (channel.DisEqc)
   {
     case DisEqcType.Level1AA:
       Log.Log.Info("KNC:  Level1AA - SendDiSEqCCommand(0x00)");
       SendDiSEqCCommand(0x00);
       break;
     case DisEqcType.Level1AB:
       Log.Log.Info("KNC:  Level1AB - SendDiSEqCCommand(0x01)");
       SendDiSEqCCommand(0x01);
       break;
     case DisEqcType.Level1BA:
       Log.Log.Info("KNC:  Level1BA - SendDiSEqCCommand(0x0100)");
       SendDiSEqCCommand(0x0100);
       break;
     case DisEqcType.Level1BB:
       Log.Log.Info("KNC:  Level1BB - SendDiSEqCCommand(0x0101)");
       SendDiSEqCCommand(0x0101);
       break;
     case DisEqcType.SimpleA:
       Log.Log.Info("KNC:  SimpleA - SendDiSEqCCommand(0x00)");
       SendDiSEqCCommand(0x00);
       break;
     case DisEqcType.SimpleB:
       Log.Log.Info("KNC:  SimpleB - SendDiSEqCCommand(0x01)");
       SendDiSEqCCommand(0x01);
       break;
     default:
       return;
   }
 }
    /// <summary>
    /// Sets the DVB-S2 parameters such as modulation, roll-off, pilot etc.
    /// </summary>
    /// <param name="parameters">The LNB parameters.</param>
    /// <param name="channel">The channel to tune.</param>
    /// <returns>The channel with DVB-S2 parameters set.</returns>
    public DVBSChannel SetDVBS2Modulation(ScanParameters parameters, DVBSChannel channel)
    {
      //Log.Log.WriteFile("Trying to set DVB-S2 modulation...");
      try
      {
        if (_twinhan != null)
        {
          //DVB-S2 modulation parameters for Twinhan
          if (channel.ModulationType == ModulationType.ModQpsk)
          {
            channel.ModulationType = ModulationType.Mod8Vsb;
          }
          if (channel.ModulationType == ModulationType.Mod8Psk)
          {
            channel.ModulationType = ModulationType.Mod8Vsb;
          }
          if (channel.ModulationType == ModulationType.Mod16Apsk)
          {
            channel.ModulationType = ModulationType.Mod16Vsb;
          }
          if (channel.ModulationType == ModulationType.Mod32Apsk)
          {
            channel.ModulationType = ModulationType.ModOqpsk;
          }
          Log.Log.WriteFile("Twinhan DVB-S2 modulation set to:{0}", channel.ModulationType);
          Log.Log.WriteFile("Twinhan DVB-S2 Pilot set to:{0}", channel.Pilot);
          Log.Log.WriteFile("Twinhan DVB-S2 RollOff set to:{0}", channel.Rolloff);
          Log.Log.WriteFile("Twinhan DVB-S2 fec set to:{0}", channel.InnerFecRate);
          return channel;
        }
        if (_hauppauge != null)
        {
          //Set Hauppauge pilot, roll-off settings but only if DVB-S2
          //We assume if the modulation is set then a DVB-S2 tuning request has been requested
          if (channel.ModulationType != ModulationType.ModNotSet)
          {
            //Set the alternative Hauppauge Modulation type
            if (channel.ModulationType == ModulationType.ModQpsk)
            {
              if (channel.InnerFecRate == BinaryConvolutionCodeRate.Rate9_10)
              {
                channel.ModulationType = ModulationType.Mod32Qam;
              }
              channel.ModulationType = channel.InnerFecRate == BinaryConvolutionCodeRate.Rate8_9
                                         ? ModulationType.Mod16Qam
                                         : ModulationType.ModBpsk;
            }
            //Set the Hauppauge Modulation type
            /*if (channel.ModulationType == ModulationType.ModQpsk)
            {
              channel.ModulationType = ModulationType.ModQpsk2;
            }*/
            if (channel.ModulationType == ModulationType.Mod8Psk)
            {
              channel.ModulationType = ModulationType.ModNbc8Psk;
            }
            if (channel.SymbolRate == 30000)
            {
              channel.Pilot = Pilot.Off;
            }
            Log.Log.WriteFile("Hauppauge DVB-S2 modulation set to:{0}", channel.ModulationType);
            Log.Log.WriteFile("Hauppauge DVB-S2 Pilot set to:{0}", channel.Pilot);
            Log.Log.WriteFile("Hauppauge DVB-S2 RollOff set to:{0}", channel.Rolloff);
            Log.Log.WriteFile("Hauppauge DVB-S2 fec set to:{0}", channel.InnerFecRate);
            _hauppauge.SetDVBS2PilotRolloff(channel);
          }
          return channel;
        }
        if (_profred != null)
        {
          //Set ProfRed pilot, roll-off settings
          if (channel.ModulationType == ModulationType.ModNotSet)
          {
            channel.ModulationType = ModulationType.ModNotDefined;
          }
          if (channel.ModulationType == ModulationType.Mod8Psk)
          {
            channel.ModulationType = ModulationType.ModBpsk;
          }
          Log.Log.WriteFile("ProfRed DVB-S2 modulation set to:{0}", channel.ModulationType);
          Log.Log.WriteFile("ProfRed DVB-S2 Pilot set to:{0}", channel.Pilot);
          Log.Log.WriteFile("ProfRed DVB-S2 RollOff set to:{0}", channel.Rolloff);
          Log.Log.WriteFile("ProfRed DVB-S2 fec set to:{0}", channel.InnerFecRate);
          //}
          return channel;
        }
        if (_technoTrend != null)
        {
          //Set TechnoTrend modulation tuning settings
          if (channel.ModulationType == ModulationType.ModQpsk)
          {
            channel.ModulationType = ModulationType.Mod8Vsb;
          }
          if (channel.ModulationType == ModulationType.Mod8Psk)
          {
            channel.ModulationType = ModulationType.Mod8Vsb;
          }
          if (channel.ModulationType == ModulationType.Mod16Apsk)
          {
            channel.ModulationType = ModulationType.Mod16Vsb;
          }
          if (channel.ModulationType == ModulationType.Mod32Apsk)
          {
            channel.ModulationType = ModulationType.ModOqpsk;
          }
          Log.Log.WriteFile("Technotrend DVB-S2 modulation set to:{0}", channel.ModulationType);
          Log.Log.WriteFile("Technotrend DVB-S2 Pilot set to:{0}", channel.Pilot);
          Log.Log.WriteFile("Technotrend DVB-S2 RollOff set to:{0}", channel.Rolloff);
          Log.Log.WriteFile("Technotrend DVB-S2 fec set to:{0}", channel.InnerFecRate);
          return channel;
        }
        if (_knc != null)
        {
          //Set KNC modulation tuning settings
          if (channel.ModulationType == ModulationType.ModQpsk)
          {
            channel.ModulationType = ModulationType.Mod8Vsb;
          }
          if (channel.ModulationType == ModulationType.Mod8Psk)
          {
            channel.ModulationType = ModulationType.Mod8Vsb;
          }
          if (channel.ModulationType == ModulationType.Mod16Apsk)
          {
            channel.ModulationType = ModulationType.Mod16Vsb;
          }
          if (channel.ModulationType == ModulationType.Mod32Apsk)
          {
            channel.ModulationType = ModulationType.ModOqpsk;
          }
          Log.Log.WriteFile("KNC DVB-S2 modulation set to:{0}", channel.ModulationType);
          Log.Log.WriteFile("KNC DVB-S2 Pilot set to:{0}", channel.Pilot);
          Log.Log.WriteFile("KNC DVB-S2 RollOff set to:{0}", channel.Rolloff);
          Log.Log.WriteFile("KNC DVB-S2 fec set to:{0}", channel.InnerFecRate);
          return channel;
        }
        if (_digitalEveryWhere != null)
        {
          if (channel.ModulationType == ModulationType.ModQpsk)
          {
            channel.ModulationType = ModulationType.ModNbcQpsk;
          }
          if (channel.ModulationType == ModulationType.Mod8Psk)
          {
            channel.ModulationType = ModulationType.ModNbc8Psk;
          }
          //Check if DVB-S channel if not turn off Pilot & Roll-off regardless
          if (channel.ModulationType == ModulationType.ModNotSet)
          {
            channel.Pilot = Pilot.NotSet;
            channel.Rolloff = RollOff.NotSet;
            //Log.Log.WriteFile("DigitalEverywhere: we're tuning DVB-S, pilot & roll-off are now not set");
          }

          if (channel.InnerFecRate != BinaryConvolutionCodeRate.RateNotSet)
          {
            //Set the DigitalEverywhere binary values for Pilot & Roll-off
            int _pilot = 0;
            int _rollOff = 0;
            if (channel.Pilot == Pilot.On)
              _pilot = 128;
            if (channel.Pilot == Pilot.Off)
              _pilot = 64;
            if (channel.Rolloff == RollOff.Twenty)
              _rollOff = 16;
            if (channel.Rolloff == RollOff.TwentyFive)
              _rollOff = 32;
            if (channel.Rolloff == RollOff.ThirtyFive)
              _rollOff = 48;
            //The binary values get added to the current InnerFECRate - done!
            BinaryConvolutionCodeRate r = channel.InnerFecRate + _pilot + _rollOff;
            channel.InnerFecRate = r;
          }
          Log.Log.WriteFile("DigitalEverywhere DVB-S2 modulation set to:{0}", channel.ModulationType);
          Log.Log.WriteFile("DigitalEverywhere Pilot set to:{0}", channel.Pilot);
          Log.Log.WriteFile("DigitalEverywhere RollOff set to:{0}", channel.Rolloff);
          Log.Log.WriteFile("DigitalEverywhere fec set to:{0}", (int)channel.InnerFecRate);
          return channel;
        }
      }
      catch (Exception ex)
      {
        Log.Log.Write(ex);
      }
      return channel;
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="TvCardDvbBase"/> class.
 /// </summary>
 public TvCardDvbBase(DsDevice device)
   : base(device)
 {
   matchDevicePath = true;
   _lastSignalUpdate = DateTime.MinValue;
   _mapSubChannels = new Dictionary<int, BaseSubChannel>();
   _parameters = new ScanParameters();
   _minChannel = -1;
   _maxChannel = -1;
   _supportsSubChannels = true;
   Guid networkProviderClsId = new Guid("{D7D42E5C-EB36-4aad-933B-B4C419429C98}");
   useInternalNetworkProvider = FilterGraphTools.IsThisComObjectInstalled(networkProviderClsId);
 }
Example #44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RadioWebStreamCard"/> class.
 /// </summary>
 public RadioWebStreamCard()
 {
     _name       = "RadioWebStream Card (builtin)";
     _parameters = new ScanParameters();
 }
Example #45
0
        /// <summary>
        /// Sends the diseq command.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="parameters">The scanparameters.</param>
        public bool SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
        {
            bool succeeded = true;

            if (_isHauppauge == false)
            {
                return(true);
            }
            int antennaNr = BandTypeConverter.GetAntennaNr(channel);

            if (antennaNr == 0)
            {
                return(true);
            }
            //clear the message params before writing in order to avoid corruption of the diseqc message.
            for (int i = 0; i < 188; ++i)
            {
                Marshal.WriteByte(_ptrDiseqc, i, 0x00);
            }
            bool hiBand = BandTypeConverter.IsHiBand(channel, parameters);
            //bit 0	(1)	: 0=low band, 1 = hi band
            //bit 1 (2) : 0=vertical, 1 = horizontal
            //bit 3 (4) : 0=satellite position A, 1=satellite position B
            //bit 4 (8) : 0=switch option A, 1=switch option  B
            // LNB    option  position
            // 1        A         A
            // 2        A         B
            // 3        B         A
            // 4        B         B
            bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                                 (channel.Polarisation == Polarisation.CircularL));
            byte cmd = 0xf0;

            cmd |= (byte)(hiBand ? 1 : 0);
            cmd |= (byte)((isHorizontal) ? 2 : 0);
            cmd |= (byte)((antennaNr - 1) << 2);

            const int len    = 188;        //hauppauge diseqc message length
            ulong     diseqc = 0xE0103800; //currently committed switches only. i.e. ports 1-4

            diseqc += cmd;

            Marshal.WriteByte(_ptrDiseqc, 0, (byte)((diseqc >> 24) & 0xff)); //framing byte
            Marshal.WriteByte(_ptrDiseqc, 1, (byte)((diseqc >> 16) & 0xff)); //address byte
            Marshal.WriteByte(_ptrDiseqc, 2, (byte)((diseqc >> 8) & 0xff));  //command byte
            Marshal.WriteByte(_ptrDiseqc, 3, (byte)(diseqc & 0xff));         //data byte (port group 0)
            Marshal.WriteInt32(_ptrDiseqc, 160, 4);                          //send_message_length
            Marshal.WriteInt32(_ptrDiseqc, 164, 0);                          //receive_message_length
            Marshal.WriteInt32(_ptrDiseqc, 168, 3);                          //amplitude_attenuation
            if (antennaNr == 1)                                              //for simple diseqc switches (i.e. 22KHz tone burst)
            {
                Marshal.WriteByte(_ptrDiseqc, 172, (int)BurstModulationType.TONE_BURST_UNMODULATED);
            }
            else
            {
                Marshal.WriteByte(_ptrDiseqc, 172, (int)BurstModulationType.TONE_BURST_MODULATED);
                //default to tone_burst_modulated
            }
            Marshal.WriteByte(_ptrDiseqc, 176, (int)DisEqcVersion.DISEQC_VER_1X); //default
            Marshal.WriteByte(_ptrDiseqc, 180, (int)RxMode.RXMODE_NOREPLY);       //default
            Marshal.WriteByte(_ptrDiseqc, 184, 1);                                //last_message TRUE */

            string txt = "";

            for (int i = 0; i < 4; ++i)
            {
                txt += String.Format("0x{0:X} ", Marshal.ReadByte(_ptrDiseqc, i));
            }
            for (int i = 160; i < 188; i = (i + 4))
            {
                txt += String.Format("0x{0:X} ", Marshal.ReadInt32(_ptrDiseqc, i));
            }
            Log.Log.Debug("Hauppauge: SendDiseq: {0}", txt);
            int hr = _propertySet.Set(BdaTunerExtentionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC, _ptrDiseqc,
                                      len, _ptrDiseqc, len);

            if (hr != 0)
            {
                succeeded = false;
                Log.Log.Info("Hauppauge: SendDiseq returned: 0x{0:X} - {1}", hr, DsError.GetErrorText(hr));
            }
            return(succeeded);
        }
Example #46
0
        /// <summary>
        /// sends the diseqc command to the card
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="channel">The current tv/radio channel</param>
        public bool SendDiseqcCommand(ScanParameters parameters, DVBSChannel channel)
        {
            bool succeeded = true;

            try
            {
                if (_knc != null)
                {
                    _knc.SendDiseqCommand(parameters, channel);
                    System.Threading.Thread.Sleep(100);
                }
                if (_digitalEveryWhere != null)
                {
                    _digitalEveryWhere.SendDiseqcCommand(parameters, channel);
                    System.Threading.Thread.Sleep(100);
                }
                if (_technoTrend != null)
                {
                    _technoTrend.SendDiseqCommand(parameters, channel);
                    System.Threading.Thread.Sleep(100);
                }
                if (_twinhan != null)
                {
                    _twinhan.SendDiseqCommand(parameters, channel);
                    System.Threading.Thread.Sleep(100);
                }
                if (_hauppauge != null)
                {
                    succeeded = _hauppauge.SendDiseqCommand(parameters, channel);
                    System.Threading.Thread.Sleep(100);
                }
                if (_genericbdas != null)
                {
                    _genericbdas.SendDiseqCommand(parameters, channel);
                    System.Threading.Thread.Sleep(100);
                }
                if (_conexant != null)
                {
                    _conexant.SendDiseqCommand(parameters, channel);
                    System.Threading.Thread.Sleep(100);
                }
                if (_profred != null)
                {
                    _profred.SendDiseqCommand(parameters, channel);
                    System.Threading.Thread.Sleep(100);
                }
                if (_genpix != null)
                {
                    _genpix.SendDiseqCommand(parameters, channel);
                    System.Threading.Thread.Sleep(100);
                }
                if (_TeVii != null)
                {
                    _TeVii.SendDiseqCommand(parameters, channel);
                    System.Threading.Thread.Sleep(100);
                }
            }
            catch (Exception ex)
            {
                Log.Log.Write(ex);
            }
            return(succeeded);
        }
Example #47
0
        /// <summary>
        /// Gets the default LNB Setup depending on the type chosen.
        /// </summary>
        /// <param name="parameters">Satelliet scan parameters</param>
        /// <param name="band">LNB type i.e. Uiniversal</param>
        /// <param name="lof1">LNB low frequency</param>
        /// <param name="lof2">LNB high frequency</param>
        /// <param name="sw">LNB switch frequency</param>
        public static void GetDefaultLnbSetup(ScanParameters parameters, BandType band, out int lof1, out int lof2,
                                              out int sw)
        {
            lof1 = lof2 = sw = 0;
            if (parameters.UseDefaultLnbFrequencies == false)
            {
                lof1 = parameters.LnbLowFrequency;
                lof2 = parameters.LnbHighFrequency;
                sw   = parameters.LnbSwitchFrequency;
                return;
            }
            switch (band)
            {
            case BandType.Universal:
                lof1 = 9750;
                lof2 = 10600;
                sw   = 11700;
                break;

            case BandType.Circular:
                lof1 = 10750;
                lof2 = 0;
                sw   = 0;
                break;

            case BandType.CBand:
                lof1 = 5150;
                lof2 = 0;
                sw   = 0;
                break;

            case BandType.NaBandStackedDpKuHi:
                lof1 = 11250;
                lof2 = 14350;
                sw   = 0;
                break;

            case BandType.NaBandStackedDpKuLo:
                lof1 = 10750;
                lof2 = 13850;
                sw   = 0;
                break;

            case BandType.NaBandStackedKuHi:
                lof1 = 11250;
                lof2 = 10675;
                sw   = 0;
                break;

            case BandType.NaBandStackedKuLo:
                lof1 = 10750;
                lof2 = 10175;
                sw   = 0;
                break;

            case BandType.NaBandStackedC:
                lof1 = 5150;
                lof2 = 5750;
                sw   = 0;
                break;

            case BandType.NaLegacy:
                lof1 = 11250;
                lof2 = 0;
                sw   = 0;
                break;

            case BandType.NaCustom1:
                lof1 = 11250;
                lof2 = 11250;
                sw   = 12700;
                break;

            case BandType.NaCustom2:
                lof1 = 11250;
                lof2 = 11250;
                sw   = 12200;
                break;
            }
        }
Example #48
0
 /// <summary>
 /// Tunes to channels based on the list the multiplexes that make up a DVB network.
 /// This information is obtained from the DVB NIT (Network Information Table)
 /// Not applicable for Analog.
 /// </summary>
 /// <param name="channel">channel to tune to</param>
 /// <param name="settings">ScanParameters to use while tuning</param>
 /// <returns></returns>
 public List<IChannel> ScanNIT(IChannel channel, ScanParameters settings)
 {
   return new List<IChannel>();
 }
Example #49
0
    /// <summary>
    /// Determins if the tuning paramter is HiBand and if so involke the 22Khz switch.
    /// </summary>
    /// <param name="channel">tuning details for specific channel / frequency</param>
    /// <param name="parameters">holds the parameters needed for tuning channel </param>
    /// <returns></returns>
    public static bool IsHiBand(DVBSChannel channel, ScanParameters parameters)
    {
      int lof1, lof2, sw;
      GetDefaultLnbSetup(parameters, channel.BandType, out lof1, out lof2, out sw);

      if (sw == 0)
      {
        return false;
      }
      return channel.Frequency >= (sw * 1000);
    }
Example #50
0
    /// <summary>
    /// Sends the diseq command.
    /// </summary>
    /// <param name="channel">The channel.</param>
    /// <param name="parameters">The scanparameters.</param>
    public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
    {
      if (m_bIsTeVii == false)
        return;
      Log.Log.Debug("TeVii: SendDiseqc: {0},{1}", parameters.ToString(), channel.ToString());

      //bit 0	(1)	: 0=low band, 1 = hi band
      //bit 1 (2) : 0=vertical, 1 = horizontal
      //bit 3 (4) : 0=satellite position A, 1=satellite position B
      //bit 4 (8) : 0=switch option A, 1=switch option  B
      // LNB    option  position
      // 1        A         A
      // 2        A         B
      // 3        B         A
      // 4        B         B
      int antennaNr = BandTypeConverter.GetAntennaNr(channel);
      bool hiBand = BandTypeConverter.IsHiBand(channel, parameters);
      bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                           (channel.Polarisation == Polarisation.CircularL));
      byte cmd = 0xf0;
      cmd |= (byte)(hiBand ? 1 : 0);
      cmd |= (byte)((isHorizontal) ? 2 : 0);
      cmd |= (byte)((antennaNr - 1) << 2);

      byte[] ucMessage = new byte[4];
      ucMessage[0] = 0xE0; //framing byte
      ucMessage[1] = 0x10; //address byte
      ucMessage[2] = 0x38; //command byte
      ucMessage[3] = cmd; //data byte (port group 0)
      //byte[] ucMessage = DiSEqC_Helper.ChannelToDiSEqC(parameters, channel);
      SendDiSEqCCommand(ucMessage);
    }
Example #51
0
 ///<summary>
 /// Send DiseqC Command test
 ///</summary>
 ///<param name="parameters">Scan parameters</param>
 ///<param name="channel">Channel</param>
 public void SendDiseqcCommandTest(ScanParameters parameters, DVBSChannel channel)
 {
   int antennaNr = BandTypeConverter.GetAntennaNr(channel);
   bool hiBand = BandTypeConverter.IsHiBand(channel, parameters);
   bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                        (channel.Polarisation == Polarisation.CircularL));
   byte cmd = 0xf0;
   cmd |= (byte)(hiBand ? 1 : 0);
   cmd |= (byte)((isHorizontal) ? 2 : 0);
   cmd |= (byte)((antennaNr - 1) << 2);
   byte[] diseqc = new byte[4];
   diseqc[0] = 0xe0;
   diseqc[1] = 0x10;
   diseqc[2] = 0x38;
   diseqc[3] = cmd;
   SendDiSEqCCommand(diseqc);
 }
Example #52
0
 /// <summary>
 /// Gets the default LNB Setup depending on the type chosen.
 /// </summary>
 /// <param name="parameters">Satelliet scan parameters</param>
 /// <param name="band">LNB type i.e. Uiniversal</param>
 /// <param name="lof1">LNB low frequency</param>
 /// <param name="lof2">LNB high frequency</param>
 /// <param name="sw">LNB switch frequency</param>
 public static void GetDefaultLnbSetup(ScanParameters parameters, BandType band, out int lof1, out int lof2,
                                       out int sw)
 {
   lof1 = lof2 = sw = 0;
   if (parameters.UseDefaultLnbFrequencies == false)
   {
     lof1 = parameters.LnbLowFrequency;
     lof2 = parameters.LnbHighFrequency;
     sw = parameters.LnbSwitchFrequency;
     return;
   }
   switch (band)
   {
     case BandType.Universal:
       lof1 = 9750;
       lof2 = 10600;
       sw = 11700;
       break;
     case BandType.Circular:
       lof1 = 10750;
       lof2 = 0;
       sw = 0;
       break;
     case BandType.CBand:
       lof1 = 5150;
       lof2 = 0;
       sw = 0;
       break;
     case BandType.NaBandStackedDpKuHi:
       lof1 = 11250;
       lof2 = 14350;
       sw = 0;
       break;
     case BandType.NaBandStackedDpKuLo:
       lof1 = 10750;
       lof2 = 13850;
       sw = 0;
       break;
     case BandType.NaBandStackedKuHi:
       lof1 = 11250;
       lof2 = 10675;
       sw = 0;
       break;
     case BandType.NaBandStackedKuLo:
       lof1 = 10750;
       lof2 = 10175;
       sw = 0;
       break;
     case BandType.NaBandStackedC:
       lof1 = 5150;
       lof2 = 5750;
       sw = 0;
       break;
     case BandType.NaLegacy:
       lof1 = 11250;
       lof2 = 0;
       sw = 0;
       break;
     case BandType.NaCustom1:
       lof1 = 11250;
       lof2 = 11250;
       sw = 12700;
       break;
     case BandType.NaCustom2:
       lof1 = 11250;
       lof2 = 11250;
       sw = 12200;
       break;
   }
 }
Example #53
0
    ///<summary>
    /// Scan NIT channel
    ///</summary>
    ///<param name="channel">Channel</param>
    ///<param name="settings">Scan Parameters</param>
    ///<returns>Found channels</returns>
    public List<IChannel> ScanNIT(IChannel channel, ScanParameters settings)
    {
      try
      {
        _card.IsScanning = true;
        _card.Scan(0, channel);
        _analyzer = GetAnalyzer();
        if (_analyzer == null)
        {
          Log.Log.WriteFile("Scan: no analyzer interface available");
          return new List<IChannel>();
        }
        _analyzer.SetCallBack(null);
        _analyzer.ScanNIT();
        Thread.Sleep(settings.TimeOutTune * 1000);
        ResetSignalUpdate();
        Log.Log.WriteFile("ScanNIT: tuner locked:{0} signal:{1} quality:{2}", _card.IsTunerLocked, _card.SignalLevel,
                          _card.SignalQuality);
        if (_card.IsTunerLocked || _card.SignalLevel > 0 || _card.SignalQuality > 0)
        {
          int count;

          _event = new ManualResetEvent(false);
          _event.WaitOne(16000, true);
          _event.Close();
          List<IChannel> channelsFound = new List<IChannel>();
          _analyzer.GetNITCount(out count);
          for (int i = 0; i < count; ++i)
          {
            int freq, pol, mod, symbolrate, bandwidth, innerfec, rollOff, chType;
            IntPtr ptrName;
            _analyzer.GetNITChannel((short)i, out chType, out freq, out pol, out mod, out symbolrate, out bandwidth,
                                    out innerfec, out rollOff, out ptrName);
            string name = DvbTextConverter.Convert(ptrName, "");
            if (chType == 0)
            {
              DVBSChannel ch = new DVBSChannel();
              ch.Name = name;
              ch.Frequency = freq;
              Log.Log.Debug("{0},{1},{2},{3}", freq, mod, pol, symbolrate);
              switch (mod)
              {
                default:
                case 0:
                  ch.ModulationType = ModulationType.ModNotSet;
                  break;
                  //case 1: ch.ModulationType = ModulationType.ModQpsk; break;
                case 2:
                  ch.ModulationType = ModulationType.Mod8Psk;
                  break;
                case 3:
                  ch.ModulationType = ModulationType.Mod16Qam;
                  break;
              }
              ch.SymbolRate = symbolrate;
              ch.InnerFecRate = (BinaryConvolutionCodeRate)innerfec;
              ch.Polarisation = (Polarisation)pol;
              ch.Rolloff = (RollOff)rollOff;
              channelsFound.Add(ch);
            }
            else if (chType == 1)
            {
              DVBCChannel ch = new DVBCChannel();
              ch.Name = name;
              ch.Frequency = freq;
              ch.ModulationType = (ModulationType)mod;
              ch.SymbolRate = symbolrate;
              channelsFound.Add(ch);
            }
            else if (chType == 2)
            {
              DVBTChannel ch = new DVBTChannel();
              ch.Name = name;
              ch.Frequency = freq;
              ch.BandWidth = bandwidth;
              channelsFound.Add(ch);
            }
          }
          _analyzer.StopNIT();
          return channelsFound;
        }
        else
        {
          Log.Log.WriteFile("Scan: no signal detected");
          return new List<IChannel>();
        }
      }
      finally
      {
        if (_analyzer != null)
        {
          _analyzer.StopNIT();
        }
        _card.IsScanning = false;
      }
    }
Example #54
0
    /// <summary>
    /// Sends the diseq command.
    /// </summary>
    /// <param name="channel">The channel.</param>
    /// <param name="parameters">The channels scanning parameters.</param>
    public void SendDiseqCommand(ScanParameters parameters, DVBSChannel channel)
    {
      if (_isGenPix == false)
        return;
      Log.Log.Debug("SendDiseqc: {0},{1}", parameters.ToString(), channel.ToString());

      //bit 0	(1)	: 0=low band, 1 = hi band
      //bit 1 (2) : 0=vertical, 1 = horizontal
      //bit 3 (4) : 0=satellite position A, 1=satellite position B
      //bit 4 (8) : 0=switch option A, 1=switch option  B
      // LNB    option  position
      // 1        A         A
      // 2        A         B
      // 3        B         A
      // 4        B         B
      int antennaNr = BandTypeConverter.GetAntennaNr(channel);
      bool hiBand = BandTypeConverter.IsHiBand(channel, parameters);
      bool isHorizontal = ((channel.Polarisation == Polarisation.LinearH) ||
                           (channel.Polarisation == Polarisation.CircularL));
      byte cmd = 0xf0;
      cmd |= (byte)(hiBand ? 1 : 0);
      cmd |= (byte)((isHorizontal) ? 2 : 0);
      cmd |= (byte)((antennaNr - 1) << 2);

      DISEQC_COMMAND DiseqcCommand = new DISEQC_COMMAND();
      DiseqcCommand.ucMessage[0] = 0xE0; //framing byte
      DiseqcCommand.ucMessage[1] = 0x10; //address byte
      DiseqcCommand.ucMessage[2] = 0x38; //command byte
      DiseqcCommand.ucMessage[3] = cmd; //data byte (port group 0)
      DiseqcCommand.ucMessage[4] = 0; //Need not fill this up
      DiseqcCommand.ucMessage[5] = 0; //Need not fill this up
      DiseqcCommand.ucMessageLength = 4; //Number of Valid bytes in the Command.

      Marshal.StructureToPtr(DiseqcCommand, _ptrDiseqc, false);
      //get the length of the structure command - usually 7 bytes.
      int len = Marshal.SizeOf(DiseqcCommand);

      string txt = "";
      for (int i = 0; i < len; ++i)
        txt += String.Format("0x{0:X} ", Marshal.ReadByte(_ptrDiseqc, i));
      Log.Log.Debug("GenPix: SendDiseqCommand: {0} with length {1}", txt, len);
      //set the DisEqC command to the tuner pin
      int hr = _propertySet.Set(BdaTunerExtentionProperties, (int)BdaTunerExtension.KSPROPERTY_BDA_DISEQC,
                                _ptrTempInstance, 32, _ptrDiseqc, len);
      if (hr != 0)
      {
        Log.Log.Info("GenPix: SendDiseqCommand returned: 0x{0:X} - {1}{2}", hr, HResult.GetDXErrorString(hr),
                     DsError.GetErrorText(hr));
      }
    }