Пример #1
0
        private void UpdateChannelListNode(ChannelListNodes nodes, params ChannelList[] channelLists)
        {
            int serviceCount = 0, programmeCount = 0;
            var sbService   = this.CreateStringBuilderDict(nodes.Service);
            var sbProgramme = this.CreateStringBuilderDict(nodes.Programme);

            foreach (var list in channelLists)
            {
                this.UpdateChannelList(sbService, sbProgramme, ref serviceCount, ref programmeCount, list.Channels);
            }
            this.ApplyStringBuilderDictToXmlNodes(nodes.Service, sbService, serviceCount);
            this.ApplyStringBuilderDictToXmlNodes(nodes.Programme, sbProgramme, programmeCount);
        }
Пример #2
0
        private void ReadServices(XmlNode node, SignalSource signalSource, int idAdjustment)
        {
            var serviceNode = node["Service"] ?? throw new FileLoadException("Missing Service XML element");
            var svcData     = SplitLines(serviceNode);

            var progNode = node["Programme"] ?? throw new FileLoadException("Missing Programme XML element");
            var progData = SplitLines(progNode);

            // remember the nodes that need to be updated when saving
            var nodes = new ChannelListNodes();

            nodes.Service   = serviceNode;
            nodes.Programme = progNode;
            this.channeListNodes[signalSource] = nodes;

            var map = new Dictionary <int, Channel>();

            for (int i = 0, c = svcData["ServiceRowId"].Length; i < c; i++)
            {
                var rowId = int.Parse(svcData["ServiceRowId"][i]);
                var chan  = new Channel(signalSource, i, rowId);
                map[rowId]             = chan;
                chan.OldProgramNr      = -1;
                chan.IsDeleted         = true;
                chan.ServiceType       = int.Parse(svcData["Type"][i]);
                chan.OriginalNetworkId = this.ParseInt(svcData["Onid"][i]);
                chan.TransportStreamId = this.ParseInt(svcData["Tsid"][i]);
                chan.ServiceId         = this.ParseInt(svcData["Sid"][i]);
                chan.Name = svcData["Name"][i];
                var muxId  = int.Parse(svcData["MuxRowId"][i]) + idAdjustment;
                var transp = this.DataRoot.Transponder[muxId];
                chan.Transponder = transp;
                if (transp != null)
                {
                    chan.FreqInMhz  = transp.FrequencyInMhz;
                    chan.SymbolRate = transp.SymbolRate;
                    chan.Polarity   = transp.Polarity;
                    if ((signalSource & SignalSource.Cable) != 0)
                    {
                        chan.ChannelOrTransponder = LookupData.Instance.GetDvbcChannelName(chan.FreqInMhz);
                    }
                    else if ((signalSource & SignalSource.Antenna) != 0)
                    {
                        chan.ChannelOrTransponder = LookupData.Instance.GetDvbtTransponder(chan.FreqInMhz).ToString();
                    }
                }

                chan.SignalSource |= LookupData.Instance.IsRadioTvOrData(chan.ServiceType);
                var att = this.ParseInt(svcData["Attribute"][i]);
                chan.Encrypted = (att & 8) != 0;

                CopyDataValues(serviceNode, svcData, i, chan.ServiceData);

                var list = this.DataRoot.GetChannelList(chan.SignalSource);
                this.DataRoot.AddChannel(list, chan);
            }

            for (int i = 0, c = progData["ServiceRowId"].Length; i < c; i++)
            {
                var rowId = int.Parse(progData["ServiceRowId"][i]);
                var chan  = map.TryGet(rowId);
                if (chan == null)
                {
                    continue;
                }
                chan.IsDeleted    = false;
                chan.OldProgramNr = int.Parse(progData["No"][i]);
                var flag = int.Parse(progData["Flag"][i]);
                chan.Favorites = (Favorites)(flag & 0x0F);

                CopyDataValues(progNode, progData, i, chan.ProgrammeData);
            }
        }
Пример #3
0
        private void ReadServicesE110(XmlNode node, SignalSource signalSource, int idAdjustment)
        {
            var serviceNode = node["Service"] ?? throw new FileLoadException("Missing Service XML element");
            var svcData     = SplitLines(serviceNode);
            var dvbData     = SplitLines(serviceNode["dvb_info"]);

            // remember the nodes that need to be updated when saving
            var nodes = new ChannelListNodes();

            nodes.Service = serviceNode;
            this.channeListNodes[signalSource] = nodes;

            for (int i = 0, c = svcData["ui2_svl_rec_id"].Length; i < c; i++)
            {
                var recId = int.Parse(svcData["ui2_svl_rec_id"][i]);
                var chan  = new Channel(signalSource, i, recId);
                var no    = ParseInt(svcData["No"][i]);
                chan.OldProgramNr = (int)((uint)no >> 18);
                var nwMask = (NwMask)uint.Parse(svcData["ui4_nw_mask"][i]);
                chan.AddDebug("NW=");
                chan.AddDebug((uint)nwMask);
                chan.AddDebug("OPT=");
                chan.AddDebug(uint.Parse(svcData["ui4_nw_option_mask"][i]));
                chan.IsDeleted  = (nwMask & NwMask.NotDeletedByUserOption) == 0;
                chan.IsDeleted |= svcData["b_deleted_by_user"][i] != "1";
                chan.Hidden     = (nwMask & NwMask.Visible) == 0;
                chan.Encrypted  = (nwMask & NwMask.Encrypted) != 0;
                chan.Encrypted |= dvbData["t_free_ca_mode"][i] == "1";
                chan.Favorites  = (Favorites)((uint)(nwMask & NwMask.FavMask) >> 4);
                chan.ServiceId  = int.Parse(svcData["ui2_prog_id"][i]);
                chan.Name       = svcData["Name"][i].Replace("&amp;", "&");
                var favNumbers = svcData["aui1_custom_data"][i]?.Split(' ');
                if (favNumbers != null)
                {
                    for (int j = 0; j < 4 && j < favNumbers.Length; j++)
                    {
                        if (int.TryParse(favNumbers[j], out var favNr) && favNr > 0)
                        {
                            chan.OldFavIndex[j] = favNr;
                        }
                    }
                }
                var muxId  = int.Parse(svcData["MuxID"][i]) + idAdjustment;
                var transp = this.DataRoot.Transponder[muxId];
                chan.Transponder = transp;
                if (transp != null)
                {
                    chan.FreqInMhz         = transp.FrequencyInMhz;
                    chan.SymbolRate        = transp.SymbolRate;
                    chan.OriginalNetworkId = transp.OriginalNetworkId;
                    chan.TransportStreamId = transp.TransportStreamId;
                    chan.Polarity          = transp.Polarity;
                    chan.Satellite         = transp.Satellite?.Name;
                    chan.SatPosition       = transp.Satellite?.OrbitalPosition;

                    if ((signalSource & SignalSource.Cable) != 0)
                    {
                        chan.ChannelOrTransponder = LookupData.Instance.GetDvbcChannelName(chan.FreqInMhz);
                    }
                    if ((signalSource & SignalSource.Antenna) != 0)
                    {
                        chan.ChannelOrTransponder = LookupData.Instance.GetDvbtTransponder(chan.FreqInMhz).ToString();
                    }
                }
                else
                {
                    // this block should never be entered
                    // only DVB-C and -T (in the E-format) contain non-0 values in these fields
                    chan.OriginalNetworkId = this.ParseInt(dvbData["ui2_on_id"][i]);
                    chan.TransportStreamId = this.ParseInt(dvbData["ui2_ts_id"][i]);
                }

                chan.ServiceType = int.Parse(dvbData["ui1_sdt_service_type"][i]);
                if ((no & 0x07) == 1)
                {
                    chan.SignalSource |= SignalSource.Tv;
                }
                else if ((no & 0x07) == 2)
                {
                    chan.SignalSource |= SignalSource.Radio;
                }
                else
                {
                    chan.SignalSource |= SignalSource.Data;
                }

                CopyDataValues(serviceNode, svcData, i, chan.ServiceData);

                var list = this.DataRoot.GetChannelList(chan.SignalSource);
                chan.Source = list.ShortCaption;
                this.DataRoot.AddChannel(list, chan);
                this.mixedFavList.Channels.Add(chan);
            }
        }