/// <summary> /// checks if a received EPGChannel should be filtered from the resultlist /// </summary> /// <value></value> protected override bool FilterOutEPGChannel(EpgChannel epgChannel) { TvBusinessLayer layer = new TvBusinessLayer(); if (layer.GetSetting("generalGrapOnlyForSameTransponder", "no").Value == "yes") { DVBBaseChannel chan = epgChannel.Channel as DVBBaseChannel; Channel dbchannel = layer.GetChannelByTuningDetail(chan.NetworkId, chan.TransportId, chan.ServiceId); ATSCChannel atscchannel = new ATSCChannel(); if (dbchannel == null) { return(false); } foreach (TuningDetail detail in dbchannel.ReferringTuningDetail()) { if (detail.ChannelType == 1) { atscchannel.MajorChannel = detail.MajorChannel; atscchannel.MinorChannel = detail.MinorChannel; atscchannel.PhysicalChannel = detail.ChannelNumber; } } return(this.CurrentChannel.IsDifferentTransponder(atscchannel)); } else { return(false); } }
/// <summary> /// sets the QAM modulation for ATSC cards under XP /// </summary> public void SetXPATSCQam(ATSCChannel channel) { if (_isGenericATSC == false) { return; } KSPropertySupport supported; _propertySet.QuerySupported(guidBdaDigitalDemodulator, (int)BdaDigitalModulator.MODULATION_TYPE, out supported); if ((supported & KSPropertySupport.Set) == KSPropertySupport.Set) { Log.Log.Info("GenericATSC: Set ModulationType: {0}", channel.ModulationType); Marshal.WriteInt32(_tempValue, (Int32)channel.ModulationType); int hr = _propertySet.Set(guidBdaDigitalDemodulator, (int)BdaDigitalModulator.MODULATION_TYPE, _tempInstance, 32, _tempValue, 4); if (hr != 0) { Log.Log.Info("GenericATSC: Set returned: 0x{0:X} - {1}", hr, HResult.GetDXErrorString(hr)); } } //Below is for debug only... /* * if ((supported & KSPropertySupport.Get) == KSPropertySupport.Get) * { * Log.Log.Info("GenericATSC: Get ModulationType"); * Marshal.WriteInt32(_tempValue, (Int32)0); * hr = _propertySet.Get(guidBdaDigitalDemodulator, (int)BdaDigitalModulator.MODULATION_TYPE, _tempInstance, 32, _tempValue, 4, out length); * Log.Log.Info("GenericATSC: Get returned:{0:X} len:{1} value:{2}", hr, length, Marshal.ReadInt32(_tempValue)); * } */ }
protected override DVBBaseChannel CreateChannel(int networkid, int transportid, int serviceid, string name) { ATSCChannel channel = new ATSCChannel(); channel.NetworkId = networkid; channel.TransportId = transportid; channel.ServiceId = serviceid; channel.Name = name; return(channel); }
/// <summary> /// Check if the tuner can tune to a given channel. /// </summary> /// <param name="channel">The channel to check.</param> /// <returns><c>true</c> if the tuner can tune to the channel, otherwise <c>false</c></returns> public override bool CanTune(IChannel channel) { ATSCChannel atscChannel = channel as ATSCChannel; if (atscChannel == null) { return(false); } // We tune by physical channel and/or frequency. return(atscChannel.PhysicalChannel > 0); }
/// <summary> /// Check if the tuner can tune to a given channel. /// </summary> /// <param name="channel">The channel to check.</param> /// <returns><c>true</c> if the tuner can tune to the channel, otherwise <c>false</c></returns> public override bool CanTune(IChannel channel) { ATSCChannel atscChannel = channel as ATSCChannel; if (atscChannel == null) { return(false); } // Major channel holds the virtual channel number that we use for tuning. return(atscChannel.MajorChannel > 0); }
protected override bool BeforeTune(IChannel channel) { ATSCChannel atscChannel = channel as ATSCChannel; if (atscChannel == null) { throw new TvException("PBDA CC: received tune request for unsupported channel"); } if (_graphState == GraphState.Idle) { BuildGraph(); } return(true); }
/// <summary> /// gets the QAM modulation for ViXS ATSC cards under XP /// </summary> public ATSCChannel CheckVIXSQAM(ATSCChannel channel) { try { if (_isvixsatsc != null) { _isvixsatsc.GetViXSQam(channel); } } catch (Exception ex) { Log.Log.Write(ex); } return(channel); }
public void OnCarrierDefinition(AtscTransmissionMedium transmissionMedium, byte index, int carrierFrequency) { if (transmissionMedium != AtscTransmissionMedium.Cable) { return; } if (carrierFrequency > 1750) { // Convert from centre frequency to the analog video carrier frequency. // This is a BDA convention. PhysicalChannel channel = new PhysicalChannel(); channel.Frequency = carrierFrequency - 1750; channel.Channel = ATSCChannel.GetPhysicalChannelFromFrequency(carrierFrequency); _carrierFrequencies[index] = channel; } }
/// <summary> /// sets the QAM modulation for ViXS ATSC cards /// </summary> public void SetViXSQam(ATSCChannel channel) { KSPropertySupport supported; _propertySet.QuerySupported(guidViXSTunerExtention, (int)BdaDigitalModulator.MODULATION_TYPE, out supported); if ((supported & KSPropertySupport.Set) == KSPropertySupport.Set) { Log.Log.Debug("ViXS ATSC: Set ModulationType value: {0}", (Int32)channel.ModulationType); Marshal.WriteInt32(_tempValue, (Int32)channel.ModulationType); int hr = _propertySet.Set(guidViXSTunerExtention, (int)BdaDigitalModulator.MODULATION_TYPE, _tempValue, 4, _tempValue, 4); if (hr != 0) { Log.Log.Info("ViXS ATSC: Set returned: 0x{0:X} - {1}", hr, DsError.GetErrorText(hr)); } } }
/// <summary> /// gets the QAM modulation for ViXS ATSC cards /// </summary> public void GetViXSQam(ATSCChannel channel) { KSPropertySupport supported; _propertySet.QuerySupported(guidViXSTunerExtention, (int)BdaDigitalModulator.MODULATION_TYPE, out supported); if ((supported & KSPropertySupport.Get) == KSPropertySupport.Get) { int length; Marshal.WriteInt32(_tempValue, 0); int hr = _propertySet.Get(guidViXSTunerExtention, (int)BdaDigitalModulator.MODULATION_TYPE, _tempValue, 4, _tempValue, 4, out length); if (hr != 0) { Log.Log.Info("ViXS ATSC: Get returned:{0:X}", hr); } Log.Log.Info("ViXS ATSC: Get ModulationType returned value: {0}", Marshal.ReadInt32(_tempValue)); } }
/// <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)); }
/// <summary> /// Creates the new channel. /// </summary> /// <param name="channel">The high level tuning detail.</param> /// <param name="info">The subchannel detail.</param> /// <returns>The new channel.</returns> protected override IChannel CreateNewChannel(IChannel channel, ChannelInfo info) { ATSCChannel tuningChannel = (ATSCChannel)channel; ATSCChannel atscChannel = new ATSCChannel(); // When scanning with a CableCARD tuner and/or NIT or VCT frequency info // has been received and it looks plausible... if (tuningChannel.PhysicalChannel == 0 || (info.freq > 1750 && tuningChannel.Frequency > 0 && info.freq != tuningChannel.Frequency)) { atscChannel.PhysicalChannel = ATSCChannel.GetPhysicalChannelFromFrequency(info.freq); // Convert from centre frequency to the analog video carrier // frequency. This is a BDA convention. atscChannel.Frequency = info.freq - 1750; } else { atscChannel.PhysicalChannel = tuningChannel.PhysicalChannel; atscChannel.Frequency = tuningChannel.Frequency; } if (info.minorChannel == 0) { atscChannel.LogicalChannelNumber = info.majorChannel; } else { atscChannel.LogicalChannelNumber = (info.majorChannel * 1000) + info.minorChannel; } atscChannel.Name = info.service_name; atscChannel.Provider = info.service_provider_name; atscChannel.ModulationType = tuningChannel.ModulationType; atscChannel.MajorChannel = info.majorChannel; atscChannel.MinorChannel = info.minorChannel; atscChannel.IsTv = IsTvService(info.serviceType); atscChannel.IsRadio = IsRadioService(info.serviceType); atscChannel.NetworkId = info.networkID; atscChannel.ServiceId = info.serviceID; atscChannel.TransportId = info.transportStreamID; atscChannel.PmtPid = info.network_pmt_PID; atscChannel.FreeToAir = !info.scrambled; Log.Log.Write("atsc:Found: {0}", atscChannel); return(atscChannel); }
public void OnSourceName(AtscTransmissionMedium transmissionMedium, bool applicationType, int sourceId, string name) { if (transmissionMedium != AtscTransmissionMedium.Cable || applicationType) { return; } ATSCChannel channel = null; if (_channels.TryGetValue(sourceId, out channel)) { channel.Name = name; channel.NetworkId = sourceId; _sourcesWithoutNames.Remove(sourceId); if (_sourcesWithoutNames.Count == 0) { Log.Log.Info("DRI CC: all sources now have names, assuming NTT is complete"); OnTableComplete(MgtTableType.NttSns); } } }
/// <summary> /// Creates the new channel. /// </summary> /// <param name="channel">The high level tuning detail.</param> /// <param name="info">The subchannel detail.</param> /// <returns>The new channel.</returns> protected override IChannel CreateNewChannel(IChannel channel, ChannelInfo info) { ATSCChannel tuningChannel = (ATSCChannel)channel; ATSCChannel atscChannel = new ATSCChannel(); if (tuningChannel.PhysicalChannel == 0) // ie. digital cable CableCARD tuner scan { atscChannel.PhysicalChannel = ATSCChannel.GetPhysicalChannelFromFrequency(info.freq); atscChannel.Frequency = info.freq; } else { atscChannel.PhysicalChannel = tuningChannel.PhysicalChannel; atscChannel.Frequency = tuningChannel.Frequency; } if (info.minorChannel == 0) { atscChannel.LogicalChannelNumber = info.majorChannel; } else { atscChannel.LogicalChannelNumber = (info.majorChannel * 1000) + info.minorChannel; } atscChannel.Name = info.service_name; atscChannel.Provider = info.service_provider_name; atscChannel.ModulationType = tuningChannel.ModulationType; atscChannel.MajorChannel = info.majorChannel; atscChannel.MinorChannel = info.minorChannel; atscChannel.IsTv = IsTvService(info.serviceType); atscChannel.IsRadio = IsRadioService(info.serviceType); atscChannel.NetworkId = info.networkID; atscChannel.ServiceId = info.serviceID; atscChannel.TransportId = info.transportStreamID; atscChannel.PmtPid = info.network_pmt_PID; atscChannel.FreeToAir = !info.scrambled; Log.Log.Write("atsc:Found: {0}", atscChannel); return(atscChannel); }
/// <summary> /// Creates the new channel. /// </summary> /// <param name="channel">The high level tuning detail.</param> /// <param name="info">The subchannel detail.</param> /// <returns>The new channel.</returns> protected override IChannel CreateNewChannel(IChannel channel, ChannelInfo info) { ATSCChannel tuningChannel = (ATSCChannel)channel; ATSCChannel atscChannel = new ATSCChannel(); atscChannel.Name = info.service_name; atscChannel.LogicalChannelNumber = info.LCN; atscChannel.Provider = info.service_provider_name; atscChannel.ModulationType = tuningChannel.ModulationType; atscChannel.Frequency = tuningChannel.Frequency; atscChannel.PhysicalChannel = tuningChannel.PhysicalChannel; atscChannel.MajorChannel = info.majorChannel; atscChannel.MinorChannel = info.minorChannel; atscChannel.IsTv = IsTvService(info.serviceType); atscChannel.IsRadio = IsRadioService(info.serviceType); atscChannel.NetworkId = info.networkID; atscChannel.ServiceId = info.serviceID; atscChannel.TransportId = info.transportStreamID; atscChannel.PmtPid = info.network_pmt_PID; atscChannel.FreeToAir = !info.scrambled; Log.Log.Write("atsc:Found: {0}", atscChannel); return(atscChannel); }
/// <summary> /// check if the card are ATSC QAM capable cards. /// If so sets the QAM modulation for those specific ATSC cards. /// </summary> public ATSCChannel CheckATSCQAM(ATSCChannel channel) { try { if (channel.ModulationType == ModulationType.Mod64Qam || channel.ModulationType == ModulationType.Mod256Qam) { if (_isgenericatsc != null) { Log.Log.Info("Setting Generic ATSC modulation to {0}", channel.ModulationType); _isgenericatsc.SetXPATSCQam(channel); } if (_isvixsatsc != null) { Log.Log.Info("Setting ViXS ATSC BDA modulation to {0}", channel.ModulationType); _isvixsatsc.SetViXSQam(channel); } } } catch (Exception ex) { Log.Log.Write(ex); } return(channel); }
public void OnSvctChannelDetail(AtscTransmissionMedium transmissionMedium, int vctId, int virtualChannelNumber, bool applicationVirtualChannel, int bitstreamSelect, int pathSelect, ChannelType channelType, int sourceId, byte cdsReference, int programNumber, byte mmsReference) { if (transmissionMedium != AtscTransmissionMedium.Cable || applicationVirtualChannel || programNumber == 0 || sourceId == 0) { // Not tunable/supported. return; } ATSCChannel channel = null; if (_channels.TryGetValue(sourceId, out channel)) { Log.Log.Info("DRI CC: received repeated S-VCT channel detail for source 0x{0:x}", sourceId); return; } channel = new ATSCChannel(); _channels.Add(sourceId, channel); channel.LogicalChannelNumber = virtualChannelNumber; channel.IsTv = true; channel.IsRadio = false; channel.FreeToAir = false; channel.Frequency = _carrierFrequencies[cdsReference].Frequency; channel.MajorChannel = virtualChannelNumber; channel.MinorChannel = 0; channel.ModulationType = _modulationModes[mmsReference]; channel.NetworkId = sourceId; channel.PhysicalChannel = _carrierFrequencies[cdsReference].Channel; channel.PmtPid = 0; // TV Server will automatically lookup the correct PID from the PAT channel.Provider = "Cable"; channel.ServiceId = programNumber; channel.TransportId = 0; // We don't have these details. _sourcesWithoutNames.Add(sourceId); }
public void OnLvctChannelDetail(MgtTableType tableType, string shortName, int majorChannelNumber, int minorChannelNumber, ModulationMode modulationMode, uint carrierFrequency, int channelTsid, int programNumber, EtmLocation etmLocation, bool accessControlled, bool hidden, int pathSelect, bool outOfBand, bool hideGuide, AtscServiceType serviceType, int sourceId) { if (programNumber == 0 || outOfBand || modulationMode == ModulationMode.Analog || modulationMode == ModulationMode.PrivateDescriptor || (serviceType != AtscServiceType.Audio && serviceType != AtscServiceType.DigitalTelevision) || sourceId == 0) { // Not tunable/supported. return; } ATSCChannel channel = null; if (_channels.TryGetValue(sourceId, out channel)) { Log.Log.Info("DRI CC: received repeated L-VCT channel detail for source 0x{0:x}", sourceId); return; } channel = new ATSCChannel(); _channels.Add(sourceId, channel); carrierFrequency /= 1000; // Hz => kHz if (carrierFrequency > 1750) { // Convert from centre frequency to the analog video carrier // frequency. This is a BDA convention. channel.Frequency = carrierFrequency - 1750; } channel.PhysicalChannel = ATSCChannel.GetPhysicalChannelFromFrequency((int)carrierFrequency); switch (modulationMode) { case ModulationMode.Atsc8Vsb: channel.ModulationType = ModulationType.Mod8Vsb; break; case ModulationMode.Atsc16Vsb: channel.ModulationType = ModulationType.Mod16Vsb; break; case ModulationMode.ScteMode1: channel.ModulationType = ModulationType.Mod64Qam; break; default: channel.ModulationType = ModulationType.Mod256Qam; break; } channel.FreeToAir = !accessControlled; channel.IsTv = (serviceType == AtscServiceType.DigitalTelevision); channel.IsRadio = (serviceType == AtscServiceType.Audio); if (minorChannelNumber == 0) { channel.LogicalChannelNumber = majorChannelNumber; } else { channel.LogicalChannelNumber = (majorChannelNumber * 1000) + minorChannelNumber; } channel.Name = shortName; if (tableType == MgtTableType.TvctCurrentNext1 || tableType == MgtTableType.TvctCurrentNext0) { channel.Provider = "Terrestrial"; } else { channel.Provider = "Cable"; } channel.NetworkId = sourceId; channel.PmtPid = 0; // TV Server will automatically lookup the correct PID from the PAT channel.ServiceId = programNumber; channel.TransportId = channelTsid; }
/// <summary> /// This method will try to start the epg grabber for the channel and tuning details specified /// Epg grabbing can only be started if there is a card idle which can receive the channel specified /// </summary> /// <param name="channel">channel to grab/param> /// <param name="tuning">tuning information</param> /// <param name="card">card to use for grabbing</param> /// <returns>true if grabbing has started else false</returns> private bool GrabEpgForChannel(Channel channel, IChannel tuning, Card card) { if (channel == null) { Log.Error("Epg: invalid channel"); return(false); } if (tuning == null) { Log.Error("Epg: invalid tuning"); return(false); } if (card == null) { Log.Error("Epg: invalid card"); return(false); } if (_tvController == null) { Log.Error("Epg: invalid tvcontroller"); return(false); } if (_user == null) { Log.Error("Epg: invalid user"); return(false); } //remove following check to enable multi-card epg grabbing (still beta) if (_tvController.AllCardsIdle == false) { Log.Epg("Epg: card:{0} cards are not idle", card.IdCard); return(false); } TvResult result; //handle ATSC ATSCChannel atscChannel = tuning as ATSCChannel; if (atscChannel != null) { if (_tvController.Type(card.IdCard) == CardType.Atsc) { if (IsCardIdle(card.IdCard) == false) { Log.Epg("Epg: card:{0} atsc card is not idle", card.IdCard); return(false); //card is busy } try { IUser cardUser; if (_tvController.IsCardInUse(card.IdCard, out cardUser) == false) { _user.CardId = card.IdCard; result = RemoteControl.Instance.Tune(ref _user, tuning, channel.IdChannel); if (result == TvResult.Succeeded) { if (!_isRunning || false == _tvController.GrabEpg(this, card.IdCard)) { if (!_isRunning) { Log.Epg("Tuning finished but EpgGrabber no longer enabled"); } _tvController.StopGrabbingEpg(_user); _user.CardId = -1; Log.Epg("Epg: card:{0} could not start atsc epg grabbing", card.IdCard); return(false); } _user.CardId = card.IdCard; return(true); } _user.CardId = -1; Log.Epg("Epg: card:{0} could not tune to channel:{1}", card.IdCard, result.ToString()); return(false); } } catch (Exception ex) { Log.Write(ex); throw; } return(false); } Log.Epg("Epg: card:{0} could not tune to atsc channel:{1}", card.IdCard, tuning.ToString()); return(false); } //handle DVBC DVBCChannel dvbcChannel = tuning as DVBCChannel; if (dvbcChannel != null) { if (_tvController.Type(card.IdCard) == CardType.DvbC) { if (IsCardIdle(card.IdCard) == false) { Log.Epg("Epg: card:{0} dvbc card is not idle", card.IdCard); return(false); //card is busy } try { _user.CardId = card.IdCard; result = RemoteControl.Instance.Tune(ref _user, tuning, channel.IdChannel); if (result == TvResult.Succeeded) { if (!_isRunning || false == _tvController.GrabEpg(this, card.IdCard)) { if (!_isRunning) { Log.Epg("Tuning finished but EpgGrabber no longer enabled"); } _tvController.StopGrabbingEpg(_user); _user.CardId = -1; Log.Epg("Epg: card:{0} could not start dvbc epg grabbing", card.IdCard); return(false); } _user.CardId = card.IdCard; return(true); } _user.CardId = -1; Log.Epg("Epg: card:{0} could not tune to channel:{1}", card.IdCard, result.ToString()); return(false); } catch (Exception ex) { Log.Write(ex); throw; } //unreachable return false; } Log.Epg("Epg: card:{0} could not tune to dvbc channel:{1}", card.IdCard, tuning.ToString()); return(false); } //handle DVBS DVBSChannel dvbsChannel = tuning as DVBSChannel; if (dvbsChannel != null) { if (_tvController.Type(card.IdCard) == CardType.DvbS) { if (IsCardIdle(card.IdCard) == false) { Log.Epg("Epg: card:{0} dvbs card is not idle", card.IdCard); return(false); //card is busy } try { _user.CardId = card.IdCard; result = RemoteControl.Instance.Tune(ref _user, tuning, channel.IdChannel); if (result == TvResult.Succeeded) { if (!_isRunning || false == _tvController.GrabEpg(this, card.IdCard)) { if (!_isRunning) { Log.Epg("Tuning finished but EpgGrabber no longer enabled"); } _tvController.StopGrabbingEpg(_user); _user.CardId = -1; Log.Epg("Epg: card:{0} could not start dvbs epg grabbing", card.IdCard); return(false); } _user.CardId = card.IdCard; return(true); } _user.CardId = -1; Log.Epg("Epg: card:{0} could not tune to channel:{1}", card.IdCard, result.ToString()); return(false); } catch (Exception ex) { Log.Write(ex); throw; } //unreachable return false; } Log.Epg("Epg: card:{0} could not tune to dvbs channel:{1}", card.IdCard, tuning.ToString()); return(false); } //handle DVBT DVBTChannel dvbtChannel = tuning as DVBTChannel; if (dvbtChannel != null) { if (_tvController.Type(card.IdCard) == CardType.DvbT) { if (IsCardIdle(card.IdCard) == false) { Log.Epg("Epg: card:{0} dvbt card is not idle", card.IdCard); return(false); //card is busy } try { _user.CardId = card.IdCard; result = RemoteControl.Instance.Tune(ref _user, tuning, channel.IdChannel); if (result == TvResult.Succeeded) { if (!_isRunning || false == _tvController.GrabEpg(this, card.IdCard)) { if (!_isRunning) { Log.Epg("Tuning finished but EpgGrabber no longer enabled"); } _tvController.StopGrabbingEpg(_user); _user.CardId = -1; Log.Epg("Epg: card:{0} could not start dvbt grabbing", card.IdCard); return(false); } _user.CardId = card.IdCard; return(true); } _user.CardId = -1; Log.Epg("Epg: card:{0} could not tune to channel:{1}", card.IdCard, result.ToString()); return(false); } catch (Exception ex) { Log.Write(ex); throw; } //unreachable return false; } Log.Epg("Epg: card:{0} could not tune to dvbt channel:{1}", card.IdCard, tuning.ToString()); return(false); } //handle DVBIP DVBIPChannel dvbipChannel = tuning as DVBIPChannel; if (dvbipChannel != null) { if (_tvController.Type(card.IdCard) == CardType.DvbIP) { if (IsCardIdle(card.IdCard) == false) { Log.Epg("Epg: card:{0} dvbip card is not idle", card.IdCard); return(false); //card is busy } try { _user.CardId = card.IdCard; result = RemoteControl.Instance.Tune(ref _user, tuning, channel.IdChannel); if (result == TvResult.Succeeded) { if (!_isRunning || false == _tvController.GrabEpg(this, card.IdCard)) { if (!_isRunning) { Log.Epg("Tuning finished but EpgGrabber no longer enabled"); } _tvController.StopGrabbingEpg(_user); _user.CardId = -1; Log.Epg("Epg: card:{0} could not start dvbip grabbing", card.IdCard); return(false); } _user.CardId = card.IdCard; return(true); } else { _user.CardId = -1; Log.Epg("Epg: card:{0} could not tune to channel:{1}", card.IdCard, result.ToString()); return(false); } } catch (Exception ex) { Log.Write(ex); throw ex; } //unreachable return false; } else { Log.Epg("Epg: card:{0} could not tune to dvbip channel:{1}", card.IdCard, tuning.ToString()); } return(false); } Log.Epg("Epg: card:{0} could not tune to channel:{1}", card.IdCard, tuning.ToString()); return(false); }
/// <summary> /// This method will try to start the epg grabber for the channel and tuning details specified /// Epg grabbing can only be started if there is a card idle which can receive the channel specified /// </summary> /// <param name="channel">channel to grab/param> /// <param name="tuning">tuning information</param> /// <param name="card">card to use for grabbing</param> /// <returns>true if grabbing has started else false</returns> private bool GrabEpgForChannel(Channel channel, IChannel tuning, Card card) { if (channel == null) { Log.Error("Epg: invalid channel"); return(false); } if (tuning == null) { Log.Error("Epg: invalid tuning"); return(false); } if (card == null) { Log.Error("Epg: invalid card"); return(false); } if (_tvController == null) { Log.Error("Epg: invalid tvcontroller"); return(false); } if (_user == null) { Log.Error("Epg: invalid user"); return(false); } //remove following check to enable multi-card epg grabbing (still beta) if (_tvController.AllCardsIdle == false) { Log.Epg("Epg: card:{0} cards are not idle", Card.IdCard); return(false); } TvResult result = TvResult.UnknownError; //handle ATSC ATSCChannel atscChannel = tuning as ATSCChannel; if (atscChannel != null) { if (_tvController.Type(Card.IdCard) == CardType.Atsc) { if (IsCardIdle(Card.IdCard) == false) { Log.Epg("Epg: card:{0} atsc card is not idle", Card.IdCard); return(false); //card is busy } return(TuneEPGgrabber(channel, tuning, card, result)); } Log.Epg("Epg: card:{0} could not tune to atsc channel:{1}", Card.IdCard, tuning.ToString()); return(false); } //handle DVBC DVBCChannel dvbcChannel = tuning as DVBCChannel; if (dvbcChannel != null) { if (_tvController.Type(Card.IdCard) == CardType.DvbC) { if (IsCardIdle(Card.IdCard) == false) { Log.Epg("Epg: card:{0} dvbc card is not idle", Card.IdCard); return(false); //card is busy } return(TuneEPGgrabber(channel, tuning, card, result)); } Log.Epg("Epg: card:{0} could not tune to dvbc channel:{1}", Card.IdCard, tuning.ToString()); return(false); } //handle DVBS DVBSChannel dvbsChannel = tuning as DVBSChannel; if (dvbsChannel != null) { if (_tvController.Type(Card.IdCard) == CardType.DvbS) { if (IsCardIdle(Card.IdCard) == false) { Log.Epg("Epg: card:{0} dvbs card is not idle", Card.IdCard); return(false); //card is busy } return(TuneEPGgrabber(channel, tuning, card, result)); } Log.Epg("Epg: card:{0} could not tune to dvbs channel:{1}", Card.IdCard, tuning.ToString()); return(false); } //handle DVBT DVBTChannel dvbtChannel = tuning as DVBTChannel; if (dvbtChannel != null) { if (_tvController.Type(Card.IdCard) == CardType.DvbT) { if (IsCardIdle(Card.IdCard) == false) { Log.Epg("Epg: card:{0} dvbt card is not idle", Card.IdCard); return(false); //card is busy } return(TuneEPGgrabber(channel, tuning, card, result)); } Log.Epg("Epg: card:{0} could not tune to dvbt channel:{1}", Card.IdCard, tuning.ToString()); return(false); } //handle DVBIP DVBIPChannel dvbipChannel = tuning as DVBIPChannel; if (dvbipChannel != null) { if (_tvController.Type(Card.IdCard) == CardType.DvbIP) { if (IsCardIdle(Card.IdCard) == false) { Log.Epg("Epg: card:{0} dvbip card is not idle", Card.IdCard); return(false); //card is busy } return(TuneEPGgrabber(channel, tuning, card, result)); } else { Log.Epg("Epg: card:{0} could not tune to dvbip channel:{1}", Card.IdCard, tuning.ToString()); } return(false); } Log.Epg("Epg: card:{0} could not tune to channel:{1}", Card.IdCard, tuning.ToString()); return(false); }
private bool BeforeTune(IChannel channel) { ATSCChannel atscChannel = channel as ATSCChannel; if (atscChannel == null) { Log.Log.WriteFile("atsc:Channel is not a ATSC channel!!! {0}", channel.GetType().ToString()); return(false); } if (_graphState == GraphState.Idle) { BuildGraph(); } if (useInternalNetworkProvider) { return(true); } if (_previousChannel == null || _previousChannel.IsDifferentTransponder(atscChannel)) { Log.Log.WriteFile("atsc:using new channel tuning settings"); ITuneRequest request; int hr = _tuningSpace.CreateTuneRequest(out request); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - CreateTuneRequest"); } _tuneRequest = request; IATSCChannelTuneRequest tuneRequest = (IATSCChannelTuneRequest)_tuneRequest; ILocator locator; hr = _tuningSpace.get_DefaultLocator(out locator); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - get_DefaultLocator"); } IATSCLocator atscLocator = (IATSCLocator)locator; hr = atscLocator.put_SymbolRate(-1); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_SymbolRate"); } hr = atscLocator.put_TSID(-1); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_TSID"); } hr = atscLocator.put_CarrierFrequency((int)atscChannel.Frequency); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_CarrierFrequency"); } hr = atscLocator.put_Modulation(atscChannel.ModulationType); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_Modulation"); } hr = tuneRequest.put_Channel(atscChannel.MajorChannel); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_Channel"); } hr = tuneRequest.put_MinorChannel(atscChannel.MinorChannel); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_MinorChannel"); } hr = atscLocator.put_PhysicalChannel(atscChannel.PhysicalChannel); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_PhysicalChannel"); } hr = _tuneRequest.put_Locator(locator); if (hr != 0) { Log.Log.WriteFile("atsc: Failed - put_Locator"); } //set QAM paramters if necessary... _conditionalAccess.CheckATSCQAM(atscChannel); } else { Log.Log.WriteFile("atsc:using previous channel tuning settings"); } return(true); }
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()); }
private void DoScan() { int tvChannelsNew = 0; int radioChannelsNew = 0; int tvChannelsUpdated = 0; int radioChannelsUpdated = 0; string buttonText = mpButtonScanTv.Text; try { _isScanning = true; _stopScanning = false; mpButtonScanTv.Text = "Cancel..."; RemoteControl.Instance.EpgGrabberEnabled = false; if (_atscChannels.Count == 0) { return; } mpComboBoxFrequencies.Enabled = false; listViewStatus.Items.Clear(); TvBusinessLayer layer = new TvBusinessLayer(); Card card = layer.GetCardByDevicePath(RemoteControl.Instance.CardDevice(_cardNumber)); IUser user = new User(); user.CardId = _cardNumber; int minchan = 2; int maxchan = 69 + 1; if ((string)mpComboBoxTuningMode.SelectedItem == "Clear QAM Cable") { minchan = 1; maxchan = _atscChannels.Count + 1; } else if ((string)mpComboBoxTuningMode.SelectedItem == "Digital Cable") { minchan = 0; maxchan = 1; } for (int index = minchan; index < maxchan; ++index) { if (_stopScanning) { return; } float percent = ((float)(index)) / (maxchan - minchan); percent *= 100f; if (percent > 100f) { percent = 100f; } progressBar1.Value = (int)percent; ATSCChannel tuneChannel = new ATSCChannel(); tuneChannel.NetworkId = -1; tuneChannel.TransportId = -1; tuneChannel.ServiceId = -1; tuneChannel.MinorChannel = -1; tuneChannel.MajorChannel = -1; string line; if ((string)mpComboBoxTuningMode.SelectedItem == "Clear QAM Cable") { tuneChannel.PhysicalChannel = index; tuneChannel.Frequency = _atscChannels[index - 1].frequency; if (tuneChannel.Frequency < 10000) { continue; } tuneChannel.ModulationType = ModulationType.Mod256Qam; line = string.Format("physical channel = {0}, frequency = {1} kHz, modulation = 256 QAM", tuneChannel.PhysicalChannel, tuneChannel.Frequency); Log.Info("ATSC: scanning clear QAM cable, {0}, frequency plan = {1}", line, mpComboBoxFrequencies.SelectedItem); } else if ((string)mpComboBoxTuningMode.SelectedItem == "ATSC Digital Terrestrial") { tuneChannel.PhysicalChannel = index; tuneChannel.Frequency = -1; tuneChannel.ModulationType = ModulationType.Mod8Vsb; line = string.Format("physical channel = {0}, modulation = 8 VSB", tuneChannel.PhysicalChannel); Log.Info("ATSC: scanning ATSC over-the-air, {0}", line); } else { tuneChannel.PhysicalChannel = 0; tuneChannel.ModulationType = ModulationType.Mod256Qam; line = "out-of-band service information"; Log.Info("ATSC: scanning digital cable, {0}", line); } line += "... "; ListViewItem item = listViewStatus.Items.Add(new ListViewItem(line)); item.EnsureVisible(); if (index == minchan) { RemoteControl.Instance.Scan(ref user, tuneChannel, -1); } IChannel[] channels = RemoteControl.Instance.Scan(_cardNumber, tuneChannel); UpdateStatus(); if (channels == null || channels.Length == 0) { if (tuneChannel.PhysicalChannel > 0 && !RemoteControl.Instance.TunerLocked(_cardNumber)) { line += "no signal"; } else { line += "signal locked, no channels found"; } item.Text = line; item.ForeColor = Color.Red; continue; } int newChannels = 0; int updatedChannels = 0; for (int i = 0; i < channels.Length; ++i) { Channel dbChannel; ATSCChannel channel = (ATSCChannel)channels[i]; //No support for channel moving, or merging with existing channels here. //We do not know how ATSC works to correctly implement this. TuningDetail currentDetail = layer.GetTuningDetail(channel); if (currentDetail != null) { if (channel.IsDifferentTransponder(layer.GetTuningChannel(currentDetail))) { currentDetail = null; } } bool exists; if (currentDetail == null) { //add new channel exists = false; dbChannel = layer.AddNewChannel(channel.Name, channel.LogicalChannelNumber); dbChannel.SortOrder = 10000; if (channel.LogicalChannelNumber >= 1) { dbChannel.SortOrder = channel.LogicalChannelNumber; } } else { exists = true; dbChannel = currentDetail.ReferencedChannel(); } dbChannel.IsTv = channel.IsTv; dbChannel.IsRadio = channel.IsRadio; dbChannel.Persist(); if (dbChannel.IsTv) { layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels); } if (dbChannel.IsRadio) { layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels); } if (currentDetail == null) { layer.AddTuningDetails(dbChannel, channel); } else { //update tuning details... TuningDetail td = layer.UpdateTuningDetails(dbChannel, channel, currentDetail); td.Persist(); } if (channel.IsTv) { if (exists) { tvChannelsUpdated++; updatedChannels++; } else { tvChannelsNew++; newChannels++; } } if (channel.IsRadio) { if (exists) { radioChannelsUpdated++; updatedChannels++; } else { radioChannelsNew++; newChannels++; } } layer.MapChannelToCard(card, dbChannel, false); } line += string.Format("new = {0}, updated = {1}", newChannels, updatedChannels); item.Text = line; Log.Info("ATSC: scan result, new = {0}, updated = {1}", newChannels, updatedChannels); } } catch (Exception ex) { Log.Write(ex); } finally { IUser user = new User(); user.CardId = _cardNumber; RemoteControl.Instance.StopCard(user); RemoteControl.Instance.EpgGrabberEnabled = true; progressBar1.Value = 100; mpComboBoxTuningMode.Enabled = true; UpdateQamFrequencyFieldAvailability(); mpButtonScanTv.Text = buttonText; _isScanning = false; } listViewStatus.Items.Add( new ListViewItem(String.Format("Total radio channels, new = {0}, updated = {1}", radioChannelsNew, radioChannelsUpdated))); listViewStatus.Items.Add( new ListViewItem(String.Format("Total TV channels, new = {0} updated = {1}", tvChannelsNew, tvChannelsUpdated))); ListViewItem lastItem = listViewStatus.Items.Add(new ListViewItem("Scan done!")); lastItem.EnsureVisible(); Log.Info("ATSC: scan summary, new TV = {0}, updated TV = {1}, new radio = {2}, updated radio = {3}", tvChannelsNew, tvChannelsUpdated, radioChannelsNew, radioChannelsUpdated); }
private void importButton_Click(object sender, EventArgs e) { bool importtv = imCheckTvChannels.Checked; bool importtvgroups = imCheckTvGroups.Checked; bool importradio = imCheckRadioChannels.Checked; bool importradiogroups = imCheckRadioGroups.Checked; bool importschedules = imCheckSchedules.Checked; openFileDialog1.CheckFileExists = true; openFileDialog1.DefaultExt = "xml"; openFileDialog1.RestoreDirectory = true; openFileDialog1.Title = "Load channels, channel groups and schedules"; openFileDialog1.InitialDirectory = String.Format(@"{0}\Team MediaPortal\MediaPortal TV Server", Environment.GetFolderPath( Environment.SpecialFolder.CommonApplicationData)); openFileDialog1.FileName = "export.xml"; openFileDialog1.AddExtension = true; openFileDialog1.Multiselect = false; if (openFileDialog1.ShowDialog(this) != DialogResult.OK) { return; } NotifyForm dlg = new NotifyForm("Importing tv channels...", "This can take some time\n\nPlease be patient..."); try { dlg.Show(); dlg.WaitForDisplay(); CountryCollection collection = new CountryCollection(); TvBusinessLayer layer = new TvBusinessLayer(); bool mergeChannels = false; // every exported channel will be imported on its own. int channelCount = 0; int scheduleCount = 0; int tvChannelGroupCount = 0; int radioChannelGroupCount = 0; if (layer.Channels.Count > 0 && (importtv || importradio)) { // rtv: we could offer to set a "merge" property here so tuningdetails would be updated for existing channels. if ( MessageBox.Show( "Existing channels detected! \nIf you continue to import your old backup then all identically named channels will be treated equal - there is a risk of duplicate entries. \nDo you really want to go on?", "Channels found", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel) { return; } else { mergeChannels = true; } } XmlDocument doc = new XmlDocument(); Log.Info("TvChannels: Trying to import channels from {0}", openFileDialog1.FileName); doc.Load(openFileDialog1.FileName); XmlNodeList channelList = doc.SelectNodes("/tvserver/channels/channel"); XmlNodeList tvChannelGroupList = doc.SelectNodes("/tvserver/channelgroups/channelgroup"); XmlNodeList radioChannelGroupList = doc.SelectNodes("/tvserver/radiochannelgroups/radiochannelgroup"); XmlNodeList scheduleList = doc.SelectNodes("/tvserver/schedules/schedule"); if (channelList != null) { foreach (XmlNode nodeChannel in channelList) { try { Channel dbChannel; XmlNodeList tuningList = nodeChannel.SelectNodes("TuningDetails/tune"); XmlNodeList mappingList = nodeChannel.SelectNodes("mappings/map"); bool grabEpg = (GetNodeAttribute(nodeChannel, "GrabEpg", "True") == "True"); bool isRadio = (GetNodeAttribute(nodeChannel, "IsRadio", "False") == "True"); bool isTv = (GetNodeAttribute(nodeChannel, "IsTv", "True") == "True"); DateTime lastGrabTime = DateTime.ParseExact(GetNodeAttribute(nodeChannel, "LastGrabTime", "01.01.1900"), "yyyy-M-d H:m:s", CultureInfo.InvariantCulture); int sortOrder = Int32.Parse(GetNodeAttribute(nodeChannel, "SortOrder", "0")); int timesWatched = Int32.Parse(GetNodeAttribute(nodeChannel, "TimesWatched", "0")); DateTime totalTimeWatched = DateTime.ParseExact(GetNodeAttribute(nodeChannel, "TotalTimeWatched", "01.01.1900"), "yyyy-M-d H:m:s", CultureInfo.InvariantCulture); bool visibileInGuide = (GetNodeAttribute(nodeChannel, "VisibleInGuide", "True") == "True"); bool FreeToAir = (GetNodeAttribute(nodeChannel, "FreeToAir", "True") == "True"); string displayName = GetNodeAttribute(nodeChannel, "DisplayName", "Unkown"); // Only import TV or radio channels if the corresponding checkbox was checked if ((isTv && !importtv) || (isRadio && !importradio)) { continue; } channelCount++; // rtv: since analog allows NOT to merge channels we need to take care of this. US users e.g. have multiple stations named "Sport" with different tuningdetails. // using AddChannel would incorrectly "merge" these totally different channels. // see this: http://forum.team-mediaportal.com/1-0-rc1-svn-builds-271/importing-exported-channel-list-groups-channels-39368/ Log.Info("TvChannels: Adding {0}. channel: {1}", channelCount, displayName); IList <Channel> foundExistingChannels = layer.GetChannelsByName(displayName); if (mergeChannels && (foundExistingChannels != null && foundExistingChannels.Count > 0)) { dbChannel = foundExistingChannels[0]; } else { dbChannel = layer.AddNewChannel(displayName); } dbChannel.GrabEpg = grabEpg; dbChannel.IsRadio = isRadio; dbChannel.IsTv = isTv; dbChannel.LastGrabTime = lastGrabTime; dbChannel.SortOrder = sortOrder; dbChannel.TimesWatched = timesWatched; dbChannel.TotalTimeWatched = totalTimeWatched; dbChannel.VisibleInGuide = visibileInGuide; dbChannel.DisplayName = displayName; dbChannel.Persist(); // // chemelli: When we import channels we need to add those to the "AllChannels" group // if (isTv) { layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels); } else { layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels); } foreach (XmlNode nodeMap in mappingList) { int idCard = Int32.Parse(nodeMap.Attributes["IdCard"].Value); XmlNode nodeCard = doc.SelectSingleNode(String.Format("/tvserver/servers/server/cards/card[@IdCard={0}]", idCard)); Card dbCard = layer.GetCardByDevicePath(nodeCard.Attributes["DevicePath"].Value); if (dbCard != null) { layer.MapChannelToCard(dbCard, dbChannel, false); } } foreach (XmlNode nodeTune in tuningList) { int bandwidth = Int32.Parse(nodeTune.Attributes["Bandwidth"].Value); int channelNumber = Int32.Parse(nodeTune.Attributes["ChannelNumber"].Value); int channelType = Int32.Parse(nodeTune.Attributes["ChannelType"].Value); int countryId = Int32.Parse(nodeTune.Attributes["CountryId"].Value); int diseqc = Int32.Parse(nodeTune.Attributes["Diseqc"].Value); bool fta = (nodeTune.Attributes["FreeToAir"].Value == "True"); int frequency = Int32.Parse(nodeTune.Attributes["Frequency"].Value); int majorChannel = Int32.Parse(nodeTune.Attributes["MajorChannel"].Value); int minorChannel = Int32.Parse(nodeTune.Attributes["MinorChannel"].Value); int modulation = Int32.Parse(nodeTune.Attributes["Modulation"].Value); string name = nodeTune.Attributes["Name"].Value; int networkId = Int32.Parse(nodeTune.Attributes["NetworkId"].Value); int pmtPid = Int32.Parse(nodeTune.Attributes["PmtPid"].Value); int polarisation = Int32.Parse(nodeTune.Attributes["Polarisation"].Value); string provider = GetNodeAttribute(nodeTune, "Provider", ""); int serviceId = Int32.Parse(nodeTune.Attributes["ServiceId"].Value); int switchingFrequency = Int32.Parse(nodeTune.Attributes["SwitchingFrequency"].Value); int symbolrate = Int32.Parse(nodeTune.Attributes["Symbolrate"].Value); int transportId = Int32.Parse(nodeTune.Attributes["TransportId"].Value); int tuningSource = Int32.Parse(GetNodeAttribute(nodeTune, "TuningSource", "0")); int videoSource = Int32.Parse(GetNodeAttribute(nodeTune, "VideoSource", "0")); int audioSource = Int32.Parse(GetNodeAttribute(nodeTune, "AudioSource", "0")); bool isVCRSignal = (GetNodeAttribute(nodeChannel, "IsVCRSignal", "False") == "True"); int SatIndex = Int32.Parse(GetNodeAttribute(nodeTune, "SatIndex", "-1")); int InnerFecRate = Int32.Parse(GetNodeAttribute(nodeTune, "InnerFecRate", "-1")); int band = Int32.Parse(GetNodeAttribute(nodeTune, "Band", "0")); int pilot = Int32.Parse(GetNodeAttribute(nodeTune, "Pilot", "-1")); int rollOff = Int32.Parse(GetNodeAttribute(nodeTune, "RollOff", "-1")); string url = GetNodeAttribute(nodeTune, "Url", ""); int bitrate = Int32.Parse(GetNodeAttribute(nodeTune, "Bitrate", "0")); switch (channelType) { case 0: //AnalogChannel AnalogChannel analogChannel = new AnalogChannel(); analogChannel.ChannelNumber = channelNumber; analogChannel.Country = collection.Countries[countryId]; analogChannel.Frequency = frequency; analogChannel.IsRadio = isRadio; analogChannel.IsTv = isTv; analogChannel.Name = name; analogChannel.TunerSource = (TunerInputType)tuningSource; analogChannel.AudioSource = (AnalogChannel.AudioInputType)audioSource; analogChannel.VideoSource = (AnalogChannel.VideoInputType)videoSource; analogChannel.IsVCRSignal = isVCRSignal; layer.AddTuningDetails(dbChannel, analogChannel); Log.Info("TvChannels: Added tuning details for analog channel: {0} number: {1}", name, channelNumber); break; case 1: //ATSCChannel ATSCChannel atscChannel = new ATSCChannel(); atscChannel.MajorChannel = majorChannel; atscChannel.MinorChannel = minorChannel; atscChannel.PhysicalChannel = channelNumber; atscChannel.FreeToAir = fta; atscChannel.Frequency = frequency; atscChannel.IsRadio = isRadio; atscChannel.IsTv = isTv; atscChannel.Name = name; atscChannel.NetworkId = networkId; atscChannel.PmtPid = pmtPid; atscChannel.Provider = provider; atscChannel.ServiceId = serviceId; atscChannel.TransportId = transportId; atscChannel.ModulationType = (ModulationType)modulation; layer.AddTuningDetails(dbChannel, atscChannel); Log.Info("TvChannels: Added tuning details for ATSC channel: {0} number: {1} provider: {2}", name, channelNumber, provider); break; case 2: //DVBCChannel DVBCChannel dvbcChannel = new DVBCChannel(); dvbcChannel.ModulationType = (ModulationType)modulation; dvbcChannel.FreeToAir = fta; dvbcChannel.Frequency = frequency; dvbcChannel.IsRadio = isRadio; dvbcChannel.IsTv = isTv; dvbcChannel.Name = name; dvbcChannel.NetworkId = networkId; dvbcChannel.PmtPid = pmtPid; dvbcChannel.Provider = provider; dvbcChannel.ServiceId = serviceId; dvbcChannel.SymbolRate = symbolrate; dvbcChannel.TransportId = transportId; dvbcChannel.LogicalChannelNumber = channelNumber; layer.AddTuningDetails(dbChannel, dvbcChannel); Log.Info("TvChannels: Added tuning details for DVB-C channel: {0} provider: {1}", name, provider); break; case 3: //DVBSChannel DVBSChannel dvbsChannel = new DVBSChannel(); dvbsChannel.DisEqc = (DisEqcType)diseqc; dvbsChannel.Polarisation = (Polarisation)polarisation; dvbsChannel.SwitchingFrequency = switchingFrequency; dvbsChannel.FreeToAir = fta; dvbsChannel.Frequency = frequency; dvbsChannel.IsRadio = isRadio; dvbsChannel.IsTv = isTv; dvbsChannel.Name = name; dvbsChannel.NetworkId = networkId; dvbsChannel.PmtPid = pmtPid; dvbsChannel.Provider = provider; dvbsChannel.ServiceId = serviceId; dvbsChannel.SymbolRate = symbolrate; dvbsChannel.TransportId = transportId; dvbsChannel.SatelliteIndex = SatIndex; dvbsChannel.ModulationType = (ModulationType)modulation; dvbsChannel.InnerFecRate = (BinaryConvolutionCodeRate)InnerFecRate; dvbsChannel.BandType = (BandType)band; dvbsChannel.Pilot = (Pilot)pilot; dvbsChannel.Rolloff = (RollOff)rollOff; dvbsChannel.LogicalChannelNumber = channelNumber; layer.AddTuningDetails(dbChannel, dvbsChannel); Log.Info("TvChannels: Added tuning details for DVB-S channel: {0} provider: {1}", name, provider); break; case 4: //DVBTChannel DVBTChannel dvbtChannel = new DVBTChannel(); dvbtChannel.BandWidth = bandwidth; dvbtChannel.FreeToAir = fta; dvbtChannel.Frequency = frequency; dvbtChannel.IsRadio = isRadio; dvbtChannel.IsTv = isTv; dvbtChannel.Name = name; dvbtChannel.NetworkId = networkId; dvbtChannel.PmtPid = pmtPid; dvbtChannel.Provider = provider; dvbtChannel.ServiceId = serviceId; dvbtChannel.TransportId = transportId; dvbtChannel.LogicalChannelNumber = channelNumber; layer.AddTuningDetails(dbChannel, dvbtChannel); Log.Info("TvChannels: Added tuning details for DVB-T channel: {0} provider: {1}", name, provider); break; case 5: //Webstream layer.AddWebStreamTuningDetails(dbChannel, url, bitrate); break; case 7: //DVBIPChannel DVBIPChannel dvbipChannel = new DVBIPChannel(); dvbipChannel.FreeToAir = fta; dvbipChannel.Frequency = frequency; dvbipChannel.IsRadio = isRadio; dvbipChannel.IsTv = isTv; dvbipChannel.LogicalChannelNumber = channelNumber; dvbipChannel.Name = name; dvbipChannel.NetworkId = networkId; dvbipChannel.PmtPid = pmtPid; dvbipChannel.Provider = provider; dvbipChannel.ServiceId = serviceId; dvbipChannel.TransportId = transportId; dvbipChannel.Url = url; layer.AddTuningDetails(dbChannel, dvbipChannel); Log.Info("TvChannels: Added tuning details for DVB-IP channel: {0} provider: {1}", name, provider); break; } } } catch (Exception exc) { Log.Error("TvChannels: Failed to add channel - {0}", exc.Message); } } } if (tvChannelGroupList != null && importtvgroups) { // Import tv channel groups foreach (XmlNode nodeChannelGroup in tvChannelGroupList) { try { tvChannelGroupCount++; string groupName = nodeChannelGroup.Attributes["GroupName"].Value; int groupSortOrder = Int32.Parse(nodeChannelGroup.Attributes["SortOrder"].Value); ChannelGroup group = null; if (groupName == TvConstants.TvGroupNames.AllChannels) { group = layer.GetGroupByName(groupName) ?? new ChannelGroup(groupName, groupSortOrder); } else { group = layer.GetGroupByName(groupName, groupSortOrder) ?? new ChannelGroup(groupName, groupSortOrder); } group.Persist(); XmlNodeList mappingList = nodeChannelGroup.SelectNodes("mappings/map"); foreach (XmlNode nodeMap in mappingList) { IList <Channel> channels = layer.GetChannelsByName(nodeMap.Attributes["ChannelName"].Value); int sortOrder = Int32.Parse(GetNodeAttribute(nodeMap, "SortOrder", "9999")); if (channels != null && channels.Count > 0) { Channel channel = channels[0]; if (!channel.GroupNames.Contains(group.GroupName)) { GroupMap map = new GroupMap(group.IdGroup, channel.IdChannel, sortOrder); map.Persist(); } else { foreach (GroupMap map in channel.ReferringGroupMap()) { if (map.IdGroup == group.IdGroup) { map.SortOrder = sortOrder; map.Persist(); break; } } } } } } catch (Exception exg) { Log.Error("TvChannels: Failed to add group - {0}", exg.Message); } } } if (radioChannelGroupList != null && importradiogroups) { // Import radio channel groups foreach (XmlNode nodeChannelGroup in radioChannelGroupList) { try { radioChannelGroupCount++; string groupName = nodeChannelGroup.Attributes["GroupName"].Value; int groupSortOrder = Int32.Parse(nodeChannelGroup.Attributes["SortOrder"].Value); RadioChannelGroup group = layer.GetRadioChannelGroupByName(groupName) ?? new RadioChannelGroup(groupName, groupSortOrder); group.Persist(); XmlNodeList mappingList = nodeChannelGroup.SelectNodes("mappings/map"); foreach (XmlNode nodeMap in mappingList) { IList <Channel> channels = layer.GetChannelsByName(nodeMap.Attributes["ChannelName"].Value); int sortOrder = Int32.Parse(GetNodeAttribute(nodeMap, "SortOrder", "9999")); if (channels != null && channels.Count > 0) { Channel channel = channels[0]; if (!channel.GroupNames.Contains(group.GroupName)) { RadioGroupMap map = new RadioGroupMap(group.IdGroup, channel.IdChannel, sortOrder); map.Persist(); } else { foreach (RadioGroupMap map in channel.ReferringRadioGroupMap()) { if (map.IdGroup == group.IdGroup) { map.SortOrder = sortOrder; map.Persist(); break; } } } } } } catch (Exception exg) { Log.Error("Radio Channels: Failed to add group - {0}", exg.Message); } } } if (scheduleList != null && importschedules) { // Import schedules foreach (XmlNode nodeSchedule in scheduleList) { try { int idChannel = -1; string programName = nodeSchedule.Attributes["ProgramName"].Value; string channel = nodeSchedule.Attributes["ChannelName"].Value; if (!string.IsNullOrEmpty(channel)) { IList <Channel> channels = layer.GetChannelsByName(channel); if (channels != null && channels.Count > 0) { idChannel = channels[0].IdChannel; } } DateTime startTime = DateTime.ParseExact(nodeSchedule.Attributes["StartTime"].Value, "yyyy-M-d H:m:s", CultureInfo.InvariantCulture); DateTime endTime = DateTime.ParseExact(nodeSchedule.Attributes["EndTime"].Value, "yyyy-M-d H:m:s", CultureInfo.InvariantCulture); int scheduleType = Int32.Parse(nodeSchedule.Attributes["ScheduleType"].Value); Schedule schedule = layer.AddSchedule(idChannel, programName, startTime, endTime, scheduleType); schedule.ScheduleType = scheduleType; schedule.KeepDate = DateTime.ParseExact(nodeSchedule.Attributes["KeepDate"].Value, "yyyy-M-d H:m:s", CultureInfo.InvariantCulture); schedule.PreRecordInterval = Int32.Parse(nodeSchedule.Attributes["PreRecordInterval"].Value); schedule.PostRecordInterval = Int32.Parse(nodeSchedule.Attributes["PostRecordInterval"].Value); schedule.Priority = Int32.Parse(nodeSchedule.Attributes["Priority"].Value); schedule.Quality = Int32.Parse(nodeSchedule.Attributes["Quality"].Value); schedule.Directory = nodeSchedule.Attributes["Directory"].Value; schedule.KeepMethod = Int32.Parse(nodeSchedule.Attributes["KeepMethod"].Value); schedule.MaxAirings = Int32.Parse(nodeSchedule.Attributes["MaxAirings"].Value); schedule.RecommendedCard = Int32.Parse(nodeSchedule.Attributes["RecommendedCard"].Value); schedule.ScheduleType = Int32.Parse(nodeSchedule.Attributes["ScheduleType"].Value); schedule.Series = (GetNodeAttribute(nodeSchedule, "Series", "False") == "True"); if (idChannel > -1) { schedule.Persist(); scheduleCount++; Log.Info("TvChannels: Added schedule: {0} on channel: {1}", programName, channel); } else { Log.Info("TvChannels: Skipped schedule: {0} because the channel was unknown: {1}", programName, channel); } } catch (Exception ex) { Log.Error("TvChannels: Failed to add schedule - {0}", ex.Message); } } } dlg.Close(); Log.Info( "TvChannels: Imported {0} channels, {1} tv channel groups, {2} radio channel groups and {3} schedules", channelCount, tvChannelGroupCount, radioChannelGroupCount, scheduleCount); MessageBox.Show( String.Format("Imported {0} channels, {1} tv channel groups, {2} radio channel groups and {3} schedules", channelCount, tvChannelGroupCount, radioChannelGroupCount, scheduleCount)); } catch (Exception ex) { MessageBox.Show(this, "Error while importing:\n\n" + ex + " " + ex.StackTrace); } finally { dlg.Close(); OnSectionActivated(); } }
private bool BeforeTune(IChannel channel, ref int subChannelId, out int pmtPid) { int frequency = 0; int symbolRate = 0; int modulation = (int)eModulationTAG.QAM_64; int bandWidth = 0; LNBSelectionType lnbSelection = LNBSelectionType.Lnb0; const int lnbKhzTone = 22; const int fec = (int)FecType.Fec_Auto; int polarity = 0; SS2DisEqcType disType = SS2DisEqcType.None; int switchFreq = 0; pmtPid = 0; int satelliteIndex = 0; Log.Log.WriteFile("ss2:Tune({0})", channel); if (_epgGrabbing) { _epgGrabbing = false; if (_epgGrabberCallback != null && _epgGrabbing) { _epgGrabberCallback.OnEpgCancelled(); } } switch (_cardType) { case CardType.DvbS: DVBSChannel dvbsChannel = channel as DVBSChannel; if (dvbsChannel == null) { Log.Log.Error("Channel is not a DVBS channel!!! {0}", channel.GetType().ToString()); return(false); } if (CurrentChannel != null) { DVBSChannel oldChannels = (DVBSChannel)CurrentChannel; if (oldChannels.Equals(channel)) { //@FIX this fails for back-2-back recordings //Log.Log.WriteFile("ss2:already tuned on this channel"); //return _mapSubChannels[0]; } } frequency = (int)dvbsChannel.Frequency; symbolRate = dvbsChannel.SymbolRate; satelliteIndex = dvbsChannel.SatelliteIndex; bool hiBand = BandTypeConverter.IsHiBand(dvbsChannel, Parameters); int lof1, lof2, sw; BandTypeConverter.GetDefaultLnbSetup(Parameters, dvbsChannel.BandType, out lof1, out lof2, out sw); int lnbFrequency; if (BandTypeConverter.IsHiBand(dvbsChannel, Parameters)) { lnbFrequency = lof2 * 1000; } else { lnbFrequency = lof1 * 1000; } //0=horizontal or left, 1=vertical or right polarity = 0; if (dvbsChannel.Polarisation == Polarisation.LinearV) { polarity = 1; } if (dvbsChannel.Polarisation == Polarisation.CircularR) { polarity = 1; } Log.Log.WriteFile("ss2: Polarity:{0} {1}", dvbsChannel.Polarisation, polarity); lnbSelection = LNBSelectionType.Lnb0; if (dvbsChannel.BandType == BandType.Universal) { //only set the LNB (22,33,44) Khz tone when we use ku-band and are in hi-band switch (lnbKhzTone) { case 22: lnbSelection = LNBSelectionType.Lnb22kHz; break; } if (hiBand == false) { lnbSelection = LNBSelectionType.Lnb0; } } switch (dvbsChannel.DisEqc) { case DisEqcType.None: // none disType = SS2DisEqcType.None; break; case DisEqcType.SimpleA: // Simple A disType = SS2DisEqcType.Simple_A; break; case DisEqcType.SimpleB: // Simple B disType = SS2DisEqcType.Simple_B; break; case DisEqcType.Level1AA: // Level 1 A/A disType = SS2DisEqcType.Level_1_A_A; break; case DisEqcType.Level1BA: // Level 1 B/A disType = SS2DisEqcType.Level_1_B_A; break; case DisEqcType.Level1AB: // Level 1 A/B disType = SS2DisEqcType.Level_1_A_B; break; case DisEqcType.Level1BB: // Level 1 B/B disType = SS2DisEqcType.Level_1_B_B; break; } switchFreq = lnbFrequency / 1000; //in MHz pmtPid = dvbsChannel.PmtPid; break; case CardType.DvbT: DVBTChannel dvbtChannel = channel as DVBTChannel; if (dvbtChannel == null) { Log.Log.Error("Channel is not a DVBT channel!!! {0}", channel.GetType().ToString()); return(false); } if (CurrentChannel != null) { DVBTChannel oldChannelt = (DVBTChannel)CurrentChannel; if (oldChannelt.Equals(channel)) { //@FIX this fails for back-2-back recordings //Log.Log.WriteFile("ss2:already tuned on this channel"); //return _mapSubChannels[0]; } } frequency = (int)dvbtChannel.Frequency; bandWidth = dvbtChannel.BandWidth; pmtPid = dvbtChannel.PmtPid; break; case CardType.DvbC: DVBCChannel dvbcChannel = channel as DVBCChannel; if (dvbcChannel == null) { Log.Log.Error("Channel is not a DVBC channel!!! {0}", channel.GetType().ToString()); return(false); } if (CurrentChannel != null) { DVBCChannel oldChannelc = (DVBCChannel)CurrentChannel; if (oldChannelc.Equals(channel)) { //@FIX this fails for back-2-back recordings //Log.Log.WriteFile("ss2:already tuned on this channel"); //return _mapSubChannels[0]; } } frequency = (int)dvbcChannel.Frequency; symbolRate = dvbcChannel.SymbolRate; switch (dvbcChannel.ModulationType) { case ModulationType.Mod16Qam: modulation = (int)eModulationTAG.QAM_16; break; case ModulationType.Mod32Qam: modulation = (int)eModulationTAG.QAM_32; break; case ModulationType.Mod64Qam: modulation = (int)eModulationTAG.QAM_64; break; case ModulationType.Mod128Qam: modulation = (int)eModulationTAG.QAM_128; break; case ModulationType.Mod256Qam: modulation = (int)eModulationTAG.QAM_256; break; } pmtPid = dvbcChannel.PmtPid; break; case CardType.Atsc: ATSCChannel dvbaChannel = channel as ATSCChannel; if (dvbaChannel == null) { Log.Log.Error("Channel is not a ATSC channel!!! {0}", channel.GetType().ToString()); return(false); } if (CurrentChannel != null) { ATSCChannel oldChannela = (ATSCChannel)CurrentChannel; if (oldChannela.Equals(channel)) { //@FIX this fails for back-2-back recordings //Log.Log.WriteFile("ss2:already tuned on this channel"); //return _mapSubChannels[0]; } } //if modulation = 256QAM assume ATSC QAM for HD5000 if (dvbaChannel.ModulationType == ModulationType.Mod256Qam) { Log.Log.WriteFile("DVBGraphB2C2: ATSC Channel:{0} Frequency:{1}", dvbaChannel.PhysicalChannel, dvbaChannel.Frequency); frequency = (int)dvbaChannel.Frequency; pmtPid = dvbaChannel.PmtPid; } else { Log.Log.WriteFile("DVBGraphSkyStar2: ATSC Channel:{0}", dvbaChannel.PhysicalChannel); //#DM B2C2 SDK says ATSC is tuned by frequency. Here we work the OTA frequency by channel number# int atscfreq = 0; if (dvbaChannel.PhysicalChannel <= 6) { atscfreq = 45 + (dvbaChannel.PhysicalChannel * 6); } if (dvbaChannel.PhysicalChannel >= 7 && dvbaChannel.PhysicalChannel <= 13) { atscfreq = 177 + ((dvbaChannel.PhysicalChannel - 7) * 6); } if (dvbaChannel.PhysicalChannel >= 14) { atscfreq = 473 + ((dvbaChannel.PhysicalChannel - 14) * 6); } //#DM changed tuning parameter from physical channel to calculated frequency above. frequency = atscfreq; Log.Log.WriteFile("ss2: ATSC Frequency:{0} MHz", frequency); pmtPid = dvbaChannel.PmtPid; } break; } if (_graphState == GraphState.Idle) { BuildGraph(); } if (_mapSubChannels.ContainsKey(subChannelId) == false) { subChannelId = GetNewSubChannel(channel); } _mapSubChannels[subChannelId].CurrentChannel = channel; _mapSubChannels[subChannelId].OnBeforeTune(); if (_interfaceEpgGrabber != null) { _interfaceEpgGrabber.Reset(); } if (frequency > 13000) { frequency /= 1000; } Log.Log.WriteFile("ss2: Transponder Frequency:{0} MHz", frequency); int hr = _interfaceB2C2TunerCtrl.SetFrequency(frequency); if (hr != 0) { Log.Log.Error("ss2:SetFrequencyKHz() failed:0x{0:X}", hr); return(false); } switch (_cardType) { case CardType.DvbC: Log.Log.WriteFile("ss2: SymbolRate:{0} KS/s", symbolRate); hr = _interfaceB2C2TunerCtrl.SetSymbolRate(symbolRate); if (hr != 0) { Log.Log.Error("ss2:SetSymbolRate() failed:0x{0:X}", hr); return(false); } Log.Log.WriteFile("ss2: Modulation:{0}", ((eModulationTAG)modulation)); hr = _interfaceB2C2TunerCtrl.SetModulation(modulation); if (hr != 0) { Log.Log.Error("ss2:SetModulation() failed:0x{0:X}", hr); return(false); } break; case CardType.DvbT: Log.Log.WriteFile("ss2: GuardInterval:auto"); hr = _interfaceB2C2TunerCtrl.SetGuardInterval((int)GuardIntervalType.Interval_Auto); if (hr != 0) { Log.Log.Error("ss2:SetGuardInterval() failed:0x{0:X}", hr); return(false); } Log.Log.WriteFile("ss2: Bandwidth:{0} MHz", bandWidth); //hr = _interfaceB2C2TunerCtrl.SetBandwidth((int)dvbtChannel.BandWidth); // Set Channel Bandwidth (NOTE: Temporarily use polarity function to avoid having to // change SDK interface for SetBandwidth) // from Technisat SDK 03/2006 hr = _interfaceB2C2TunerCtrl.SetPolarity(bandWidth); if (hr != 0) { Log.Log.Error("ss2:SetBandwidth() failed:0x{0:X}", hr); return(false); } break; case CardType.DvbS: Log.Log.WriteFile("ss2: SymbolRate:{0} KS/s", symbolRate); hr = _interfaceB2C2TunerCtrl.SetSymbolRate(symbolRate); if (hr != 0) { Log.Log.Error("ss2:SetSymbolRate() failed:0x{0:X}", hr); return(false); } Log.Log.WriteFile("ss2: Fec:{0} {1}", ((FecType)fec), fec); hr = _interfaceB2C2TunerCtrl.SetFec(fec); if (hr != 0) { Log.Log.Error("ss2:SetFec() failed:0x{0:X}", hr); return(false); } hr = _interfaceB2C2TunerCtrl.SetPolarity(polarity); if (hr != 0) { Log.Log.Error("ss2:SetPolarity() failed:0x{0:X}", hr); return(false); } Log.Log.WriteFile("ss2: Lnb:{0}", lnbSelection); hr = _interfaceB2C2TunerCtrl.SetLnbKHz((int)lnbSelection); if (hr != 0) { Log.Log.Error("ss2:SetLnbKHz() failed:0x{0:X}", hr); return(false); } Log.Log.WriteFile("ss2: Diseqc:{0} {1}", disType, disType); hr = _interfaceB2C2TunerCtrl.SetDiseqc((int)disType); if (hr != 0) { Log.Log.Error("ss2:SetDiseqc() failed:0x{0:X}", hr); return(false); } Log.Log.WriteFile("ss2: LNBFrequency:{0} MHz", switchFreq); hr = _interfaceB2C2TunerCtrl.SetLnbFrequency(switchFreq); if (hr != 0) { Log.Log.Error("ss2:SetLnbFrequency() failed:0x{0:X}", hr); return(false); } if (_useDISEqCMotor) { if (satelliteIndex > 0) { DisEqcGotoPosition((byte)satelliteIndex); } } break; } return(true); }
private void DoScan() { int tvChannelsNew = 0; int radioChannelsNew = 0; int tvChannelsUpdated = 0; int radioChannelsUpdated = 0; string buttonText = mpButtonScanTv.Text; try { _isScanning = true; _stopScanning = false; mpButtonScanTv.Text = "Cancel..."; RemoteControl.Instance.EpgGrabberEnabled = false; if (_atscChannels.Count == 0) { return; } mpComboBoxFrequencies.Enabled = false; listViewStatus.Items.Clear(); TvBusinessLayer layer = new TvBusinessLayer(); Card card = layer.GetCardByDevicePath(RemoteControl.Instance.CardDevice(_cardNumber)); IUser user = new User(); user.CardId = _cardNumber; int minchan = 2; int maxchan = 69; //Check if QAM if so then the number of channels varies if (checkBoxQAM.Checked) { minchan = 0; maxchan = _atscChannels.Count; } for (int index = minchan; index < maxchan; ++index) { if (_stopScanning) { return; } float percent = ((float)(index)) / (maxchan - minchan); percent *= 100f; if (percent > 100f) { percent = 100f; } progressBar1.Value = (int)percent; ATSCChannel tuneChannel = new ATSCChannel(); tuneChannel.NetworkId = -1; tuneChannel.TransportId = -1; tuneChannel.ServiceId = -1; tuneChannel.MinorChannel = -1; tuneChannel.MajorChannel = -1; if (checkBoxQAM.Checked) { Log.WriteFile("ATSC tune: QAM checkbox selected... using Modulation 256Qam"); tuneChannel.PhysicalChannel = index + 1; tuneChannel.Frequency = _atscChannels[index].frequency; tuneChannel.ModulationType = ModulationType.Mod256Qam; } else { Log.WriteFile("ATSC tune: QAM checkbox not selected... using Modulation 8Vsb"); tuneChannel.PhysicalChannel = index; tuneChannel.Frequency = -1; tuneChannel.ModulationType = ModulationType.Mod8Vsb; } Log.WriteFile("ATSC tune: PhysicalChannel: {0} Frequency: {1} Modulation: {2}", tuneChannel.PhysicalChannel, tuneChannel.Frequency, tuneChannel.ModulationType); string line = String.Format("physical channel:{0} frequency:{1} modulation:{2}", tuneChannel.PhysicalChannel, tuneChannel.Frequency, tuneChannel.ModulationType); ListViewItem item = listViewStatus.Items.Add(new ListViewItem(line)); item.EnsureVisible(); if (index == minchan) { RemoteControl.Instance.Scan(ref user, tuneChannel, -1); } IChannel[] channels = RemoteControl.Instance.Scan(_cardNumber, tuneChannel); UpdateStatus(); /*if (channels == null || channels.Length == 0) * { * if (checkBoxQAM.Checked) * { * //try Modulation 64Qam now * tuneChannel.PhysicalChannel = index + 1; * tuneChannel.Frequency = _atscChannels[index].frequency; * tuneChannel.ModulationType = ModulationType.Mod64Qam; * line = String.Format("physical channel:{0} frequency:{1} modulation:{2}: No signal", tuneChannel.PhysicalChannel, tuneChannel.Frequency, tuneChannel.ModulationType); * item.Text = line; * channels = RemoteControl.Instance.Scan(_cardNumber, tuneChannel); * } * }*/ UpdateStatus(); if (channels == null || channels.Length == 0) { if (RemoteControl.Instance.TunerLocked(_cardNumber) == false) { line = String.Format("physical channel:{0} frequency:{1} modulation:{2}: No signal", tuneChannel.PhysicalChannel, tuneChannel.Frequency, tuneChannel.ModulationType); item.Text = line; item.ForeColor = Color.Red; continue; } line = String.Format("physical channel:{0} frequency:{1} modulation:{2}: Nothing found", tuneChannel.PhysicalChannel, tuneChannel.Frequency, tuneChannel.ModulationType); item.Text = line; item.ForeColor = Color.Red; continue; } int newChannels = 0; int updatedChannels = 0; for (int i = 0; i < channels.Length; ++i) { Channel dbChannel; ATSCChannel channel = (ATSCChannel)channels[i]; //No support for channel moving, or merging with existing channels here. //We do not know how ATSC works to correctly implement this. TuningDetail currentDetail = layer.GetTuningDetail(channel); if (currentDetail != null) { if (channel.Frequency != currentDetail.Frequency) { currentDetail = null; } } bool exists; if (currentDetail == null) { //add new channel exists = false; dbChannel = layer.AddNewChannel(channel.Name); dbChannel.SortOrder = 10000; if (channel.LogicalChannelNumber >= 1) { dbChannel.SortOrder = channel.LogicalChannelNumber; } } else { exists = true; dbChannel = currentDetail.ReferencedChannel(); } dbChannel.IsTv = channel.IsTv; dbChannel.IsRadio = channel.IsRadio; dbChannel.Persist(); if (dbChannel.IsTv) { layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels); } if (dbChannel.IsRadio) { layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels); } if (currentDetail == null) { layer.AddTuningDetails(dbChannel, channel); } else { //update tuning details... TuningDetail td = layer.UpdateTuningDetails(dbChannel, channel, currentDetail); td.Persist(); } if (channel.IsTv) { if (exists) { tvChannelsUpdated++; updatedChannels++; } else { tvChannelsNew++; newChannels++; } } if (channel.IsRadio) { if (exists) { radioChannelsUpdated++; updatedChannels++; } else { radioChannelsNew++; newChannels++; } } layer.MapChannelToCard(card, dbChannel, false); line = String.Format("physical channel:{0} frequency:{1} modulation:{2} New:{3} Updated:{4}", tuneChannel.PhysicalChannel, tuneChannel.Frequency, tuneChannel.ModulationType, newChannels, updatedChannels); item.Text = line; } } //DatabaseManager.Instance.SaveChanges(); } catch (Exception ex) { Log.Write(ex); } finally { IUser user = new User(); user.CardId = _cardNumber; RemoteControl.Instance.StopCard(user); RemoteControl.Instance.EpgGrabberEnabled = true; progressBar1.Value = 100; checkBoxQAM.Enabled = true; mpComboBoxFrequencies.Enabled = true; mpButtonScanTv.Text = buttonText; _isScanning = false; } listViewStatus.Items.Add( new ListViewItem(String.Format("Total radio channels new:{0} updated:{1}", radioChannelsNew, radioChannelsUpdated))); listViewStatus.Items.Add( new ListViewItem(String.Format("Total tv channels new:{0} updated:{1}", tvChannelsNew, tvChannelsUpdated))); ListViewItem lastItem = listViewStatus.Items.Add(new ListViewItem("Scan done...")); lastItem.EnsureVisible(); }