/// <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);
                DVBTChannel    dvbtchannel = new DVBTChannel();
                if (dbchannel == null)
                {
                    return(false);
                }
                foreach (TuningDetail detail in dbchannel.ReferringTuningDetail())
                {
                    if (detail.ChannelType == 4)
                    {
                        dvbtchannel.Frequency = detail.Frequency;
                        dvbtchannel.BandWidth = detail.Bandwidth;
                    }
                }
                return(this.CurrentChannel.IsDifferentTransponder(dvbtchannel));
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <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);
            }
        }
Ejemplo n.º 3
0
        /// <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);
                DVBSChannel    dvbschannel = new DVBSChannel();
                if (dbchannel == null)
                {
                    return(false);
                }
                foreach (TuningDetail detail in dbchannel.ReferringTuningDetail())
                {
                    if (detail.ChannelType == 3)
                    {
                        dvbschannel.Frequency      = detail.Frequency;
                        dvbschannel.Polarisation   = (Polarisation)detail.Polarisation;
                        dvbschannel.ModulationType = (ModulationType)detail.Modulation;
                        dvbschannel.SatelliteIndex = detail.SatIndex;
                        dvbschannel.InnerFecRate   = (BinaryConvolutionCodeRate)detail.InnerFecRate;
                        dvbschannel.Pilot          = (Pilot)detail.Pilot;
                        dvbschannel.Rolloff        = (RollOff)detail.RollOff;
                        dvbschannel.DisEqc         = (DisEqcType)detail.Diseqc;
                    }
                }
                return(this.CurrentChannel.IsDifferentTransponder(dvbschannel));
            }
            else
            {
                return(false);
            }
        }
        private Channel IsInsertAllowed(EpgChannel epgChannel)
        {
            DVBBaseChannel dvbChannel = (DVBBaseChannel)epgChannel.Channel;

            //are there any epg infos for this channel?
            if (epgChannel.Programs.Count == 0)
            {
                Log.Epg("{0}: no epg infos found for channel networkid:0x{1:X} transportid:0x{2:X} serviceid:0x{3:X}",
                        _grabberName, dvbChannel.NetworkId, dvbChannel.TransportId, dvbChannel.ServiceId);
                return(null);
            }
            //do we know a channel with these tuning details?
            Channel      dbChannel    = null;
            TuningDetail tuningDetail = _layer.GetTuningDetail(dvbChannel);

            if (tuningDetail != null)
            {
                dbChannel = tuningDetail.ReferencedChannel();
            }

            if (dbChannel == null)
            {
                Log.Epg("{0}: no channel found for networkid:0x{1:X} transportid:0x{2:X} serviceid:0x{3:X}", _grabberName,
                        dvbChannel.NetworkId, dvbChannel.TransportId, dvbChannel.ServiceId);

                /*foreach (EpgProgram ei in epgChannel.Programs)
                 * {
                 * string title = "";
                 * if (ei.Text.Count > 0)
                 * {
                 *  title = ei.Text[0].Title;
                 * }
                 * Log.Epg("                   -> {0}-{1}  {2}", ei.StartTime, ei.EndTime, title);
                 * }*/
                return(null);
            }
            //should we store epg for this channel?
            if ((dbChannel.IsRadio && _storeOnlySelectedChannelsRadio) || (!dbChannel.IsRadio && _storeOnlySelectedChannels))
            {
                if (!dbChannel.GrabEpg)
                {
                    Log.Epg("{0}: channel {1} is not configured to grab epg.", _grabberName, dbChannel.DisplayName);
                    return(null);
                }
            }
            if (_checkForLastUpdate)
            {
                //is the regrab time reached?
                TimeSpan ts = DateTime.Now - dbChannel.LastGrabTime;
                if (ts.TotalMinutes < _epgReGrabAfter)
                {
                    Log.Epg("{0}: {1} not needed lastUpdate:{2}", _grabberName, dbChannel.DisplayName, dbChannel.LastGrabTime);
                    return(null);
                }
            }
            return(dbChannel);
        }
Ejemplo n.º 5
0
        private void ImportEpgPrograms(EpgChannel epgChannel)
        {
            if (!this.IsArgusTVConnectionInitialized)
            {
                InitializeArgusTVConnection(null);
            }
            if (this.IsArgusTVConnectionInitialized)
            {
                TvDatabase.TvBusinessLayer layer = new TvDatabase.TvBusinessLayer();
                bool epgSyncOn = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncOn, false.ToString()).Value);
                if (epgSyncOn)
                {
                    DVBBaseChannel dvbChannel = epgChannel.Channel as DVBBaseChannel;
                    if (dvbChannel != null)
                    {
                        TvDatabase.Channel mpChannel = layer.GetChannelByTuningDetail(dvbChannel.NetworkId, dvbChannel.TransportId, dvbChannel.ServiceId);
                        if (mpChannel != null)
                        {
                            Log.Debug("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms(): received {0} programs on {1}", epgChannel.Programs.Count, mpChannel.DisplayName);

                            bool   epgSyncAutoCreateChannels          = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncAutoCreateChannels, false.ToString()).Value);
                            bool   epgSyncAutoCreateChannelsWithGroup = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncAutoCreateChannelsWithGroup, false.ToString()).Value);
                            string epgLanguages = layer.GetSetting("epgLanguages").Value;

                            Channel channel = EnsureChannelForDvbEpg(mpChannel, epgSyncAutoCreateChannels, epgSyncAutoCreateChannelsWithGroup);
                            if (channel != null)
                            {
                                EnsureGuideChannelForDvbEpg(channel, mpChannel);

                                List <GuideProgram> guidePrograms = new List <GuideProgram>();

                                foreach (EpgProgram epgProgram in epgChannel.Programs)
                                {
                                    string title;
                                    string description;
                                    string genre;
                                    int    starRating;
                                    string classification;
                                    int    parentalRating;
                                    GetProgramInfoForLanguage(epgProgram.Text, epgLanguages, out title, out description, out genre,
                                                              out starRating, out classification, out parentalRating);

                                    if (!String.IsNullOrEmpty(title))
                                    {
                                        GuideProgram guideProgram = new GuideProgram();
                                        guideProgram.GuideChannelId = channel.GuideChannelId.Value;
                                        guideProgram.StartTime      = epgProgram.StartTime;
                                        guideProgram.StopTime       = epgProgram.EndTime;
                                        guideProgram.StartTimeUtc   = epgProgram.StartTime.ToUniversalTime();
                                        guideProgram.StopTime       = epgProgram.EndTime;
                                        guideProgram.StopTimeUtc    = epgProgram.EndTime.ToUniversalTime();
                                        guideProgram.Title          = title;
                                        guideProgram.Description    = description;
                                        guideProgram.Category       = genre;
                                        guideProgram.Rating         = classification;
                                        guideProgram.StarRating     = starRating / 7.0;
                                        guidePrograms.Add(guideProgram);
                                    }
                                }

                                _dvbEpgThread.ImportProgramsAsync(guidePrograms);
                            }
                            else
                            {
                                Log.Info("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms() failed to ensure channel.");
                            }
                        }
                        else
                        {
                            Log.Info("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms() failed to find MP channel.");
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Instructs the cam/ci module to use hardware filter and only send the pids listed in pids to the pc
        /// </summary>
        /// <param name="subChannel">The sub channel id</param>
        /// <param name="channel">The current tv/radio channel.</param>
        /// <param name="pids">The pids.</param>
        /// <remarks>when the pids array is empty, pid filtering is disabled and all pids are received</remarks>
        public void SendPids(int subChannel, DVBBaseChannel channel, List <ushort> pids)
        {
            try
            {
                List <ushort> HwPids = new List <ushort>();

                _mapSubChannels[subChannel].HwPids = pids;

                Dictionary <int, ConditionalAccessContext> .Enumerator enSubch = _mapSubChannels.GetEnumerator();
                while (enSubch.MoveNext())
                {
                    List <ushort> enPid = enSubch.Current.Value.HwPids;
                    if (enPid != null)
                    {
                        for (int i = 0; i < enPid.Count; ++i)
                        {
                            if (!HwPids.Contains(enPid[i]))
                            {
                                HwPids.Add(enPid[i]);
                            }
                        }
                    }
                }

                if (_digitalEveryWhere != null)
                {
                    bool isDvbc = ((channel as DVBCChannel) != null);
                    bool isDvbt = ((channel as DVBTChannel) != null);
                    bool isDvbs = ((channel as DVBSChannel) != null);
                    bool isAtsc = ((channel as ATSCChannel) != null);

                    // It is not ideal to have to enable hardware PID filtering because
                    // doing so can limit the number of channels that can be viewed/recorded
                    // simultaneously. However, it does seem that there is a need for filtering
                    // on transponders with high data rates. Problems have been observed with
                    // transponders on Thor 5/6, Intelsat 10-02 (0.8W) if the filter is not enabled:
                    //   Symbol Rate: 27500, Modulation: 8 PSK, FEC rate: 5/6, Pilot: On, Roll-Off: 0.35
                    //   Symbol Rate: 30000, Modulation: 8 PSK, FEC rate: 3/4, Pilot: On, Roll-Off: 0.35
                    if (pids.Count != 0 && isDvbs &&
                        (((DVBSChannel)channel).ModulationType == ModulationType.Mod8Psk ||
                         ((DVBSChannel)channel).ModulationType == ModulationType.Mod16Apsk ||
                         ((DVBSChannel)channel).ModulationType == ModulationType.Mod32Apsk)
                        )
                    {
                        for (int i = 0; i < HwPids.Count; ++i)
                        {
                            Log.Log.Info("FireDTV: HW Filtered Pid : 0x{0:X}", HwPids[i]);
                        }
                        _digitalEveryWhere.SetHardwarePidFiltering(isDvbc, isDvbt, true, isAtsc, HwPids);
                    }
                    else
                    {
                        pids.Clear();
                        Log.Log.Info("FireDTV: HW Filtering disabled.");
                        _digitalEveryWhere.SetHardwarePidFiltering(isDvbc, isDvbt, isDvbs, isAtsc, pids);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Log.Write(ex);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Sends the PMT to the CI module
        /// </summary>
        /// <param name="subChannel">The sub channel.</param>
        /// <param name="channel">channel on which we are tuned</param>
        /// <param name="PMT">byte array containing the PMT</param>
        /// <param name="pmtLength">length of the pmt array</param>
        /// <param name="audioPid">pid of the current audio stream</param>
        /// <returns></returns>
        public bool SendPMT(int subChannel, DVBBaseChannel channel, byte[] PMT, int pmtLength, int audioPid)
        {
            try
            {
                if (!_useCam)
                {
                    return(true);
                }
                if (channel.FreeToAir)
                {
                    return(true); //no need to descramble this one...
                }
                AddSubChannel(subChannel, channel);
                ConditionalAccessContext context = _mapSubChannels[subChannel];
                context.CamType = _CamType;
                context.Channel = channel;
                if (_CamType == CamType.Astoncrypt2)
                {
                    int newLength;
                    context.PMT       = PatchPMT_AstonCrypt2(PMT, pmtLength, out newLength);
                    context.PMTLength = newLength;
                }
                else
                {
                    context.PMT       = PMT;
                    context.PMTLength = pmtLength;
                }
                context.AudioPid  = audioPid;
                context.ServiceId = channel.ServiceId;

                if (_winTvCiModule != null)
                {
                    int hr = _winTvCiModule.SendPMT(PMT, pmtLength);
                    if (hr != 0)
                    {
                        Log.Log.Info("Conditional Access:  sendPMT to WinTVCI failed");
                        return(false);
                    }
                    Log.Log.Info("Conditional Access:  sendPMT to WinTVCI succeeded");
                    return(true);
                }
                if (_knc != null)
                {
                    ChannelInfo info = new ChannelInfo();
                    info.DecodePmt(PMT);
                    int    caPmtLen;
                    byte[] caPmt = info.caPMT.CaPmtStruct(out caPmtLen);
                    return(_knc.SendPMT(caPmt, caPmtLen));
                }
                if (_DigitalDevices != null)
                {
                    return(_DigitalDevices.SendServiceIdToCam(channel.ServiceId));
                }
                if (_digitalEveryWhere != null)
                {
                    return(_digitalEveryWhere.SendPMTToFireDTV(_mapSubChannels));
                }
                if (_technoTrend != null)
                {
                    return(_technoTrend.DescrambleMultiple(_mapSubChannels));
                    // return _technoTrend.SendPMT(PMT, pmtLength);
                }
                if (_twinhan != null)
                {
                    ChannelInfo info = new ChannelInfo();
                    info.DecodePmt(PMT);

                    int    caPmtLen;
                    byte[] caPmt = info.caPMT.CaPmtStruct(out caPmtLen);
                    return(_twinhan.SendPMT(caPmt, caPmtLen));
                }
            }
            catch (Exception ex)
            {
                Log.Log.Write(ex);
            }
            return(true);
        }
Ejemplo n.º 8
0
        public static bool IsUserOnSameChannel(IChannel tuningDetail, TvBusinessLayer layer, DVBBaseChannel userDVBchannel)
        {
            bool isUserOnSameChannel = false;

            if (userDVBchannel != null)
            {
                var currentDVBchannel = tuningDetail as DVBBaseChannel;
                if (currentDVBchannel != null)
                {
                    TuningDetail currentDVBtuningDetail = layer.GetTuningDetail(currentDVBchannel);
                    TuningDetail userDVBtuningDetail    = layer.GetTuningDetail(userDVBchannel);
                    isUserOnSameChannel = (currentDVBtuningDetail != null && currentDVBtuningDetail.IdChannel == userDVBtuningDetail.IdChannel);
                }
            }
            return(isUserOnSameChannel);
        }