Example #1
0
        private void PopulatePane()
        {
            EpgChannelEntry channel = (EpgChannelEntry)listBoxChannels.SelectedItem;

            if (channel == null)
            {
                return;
            }

            listViewTitles.BeginUpdate();
            listViewTitles.Items.Clear();
            foreach (EpgTitleEntry entry in channel.titles)
            {
                ListViewItem item = new ListViewItem(entry.eventId.ToString());
                if (toolStripButtonUTC.Checked == true)
                {
                    item.SubItems.Add(entry.startTime.ToString());
                }
                else
                {
                    item.SubItems.Add(entry.startTime.ToLocalTime().ToString());
                }
                item.SubItems.Add(entry.length.ToString());
                item.SubItems.Add(entry.description);
                item.SubItems.Add(entry.longDescription);
                item.SubItems.Add(entry.mjd.ToString());
                item.SubItems.Add(String.Format("0x{0:X}", entry.descriptionCrc));
                item.SubItems.Add(entry.descriptionSeek.ToString());
                item.SubItems.Add(entry.descriptionLength.ToString());
                item.SubItems.Add(String.Format("0x{0:X}", entry.longDescriptionCrc));
                item.SubItems.Add(entry.longDescriptionSeek.ToString());
                item.SubItems.Add(entry.longDescriptionLength.ToString());
                item.SubItems.Add(String.Format("0x{0:X}", entry.genreId));
                item.SubItems.Add(String.Format("0x{0:X}", entry.flags));
                item.SubItems.Add(entry.revision.ToString());
                listViewTitles.Items.Add(item);
            }

            for (int i = 0; i < listViewTitles.Columns.Count; i++)
            {
                listViewTitles.Columns[i].Width = -2;
            }

            listViewTitles.Columns[4].Width = 300;

            listViewTitles.EndUpdate();
            textBoxDescription.Text = "";
        }
Example #2
0
        public bool ParseCrossEPGDB(byte[] headersData, byte[] descriptorsData)
        {
            CultureInfo culture = CultureInfo.CreateSpecificCulture("en-EN");

            if (Encoding.ASCII.GetString(headersData, 0, 13) != "_xEPG_HEADERS")
            {
                MessageBox.Show("Invalid db header", "Error reading crossepgdb", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (headersData[13] != 0x07)
            {
                MessageBox.Show("Invalid db revision (you need crossepg 0.5.9999 or newer)", "Error reading crossepgdb", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            CreationTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            UpdateTime   = new DateTime(1970, 1, 1, 0, 0, 0, 0);

            CreationTime = CreationTime.AddSeconds(BitConverter.ToUInt32(headersData, 14));
            UpdateTime   = UpdateTime.AddSeconds(BitConverter.ToUInt32(headersData, 18));

            int channels_count = BitConverter.ToInt32(headersData, 22);
            int offset         = 26;

            for (int i = 0; i < channels_count; i++)
            {
                UInt16 nid          = BitConverter.ToUInt16(headersData, offset);
                UInt16 tsid         = BitConverter.ToUInt16(headersData, offset + 2);
                UInt16 sid          = BitConverter.ToUInt16(headersData, offset + 4);
                int    titles_count = BitConverter.ToInt32(headersData, offset + 6);
                offset += 10;
                EpgChannelEntry channel = channels.Find(delegate(EpgChannelEntry ch)
                {
                    if (ch.Nid == nid && ch.Tsid == tsid && ch.Sid == sid)
                    {
                        return(true);
                    }
                    return(false);
                });

                for (int j = 0; j < titles_count; j++)
                {
                    EpgTitleEntry title = new EpgTitleEntry();
                    title.eventId               = BitConverter.ToUInt16(headersData, offset);
                    title.mjd                   = BitConverter.ToUInt16(headersData, offset + 2);
                    title.startTime             = new DateTime(1970, 1, 1, 0, 0, 0, 0);
                    title.startTime             = title.startTime.AddSeconds(BitConverter.ToUInt32(headersData, offset + 4));
                    title.length                = BitConverter.ToUInt16(headersData, offset + 8);
                    title.genreId               = headersData[10];
                    title.flags                 = headersData[11];
                    title.descriptionCrc        = BitConverter.ToUInt32(headersData, offset + 12);
                    title.descriptionSeek       = BitConverter.ToInt32(headersData, offset + 16);
                    title.longDescriptionCrc    = BitConverter.ToUInt32(headersData, offset + 20);
                    title.longDescriptionSeek   = BitConverter.ToInt32(headersData, offset + 24);
                    title.descriptionLength     = BitConverter.ToUInt16(headersData, offset + 28);
                    title.longDescriptionLength = BitConverter.ToUInt16(headersData, offset + 30);
                    title.iso639                = Encoding.ASCII.GetString(headersData, offset + 32, 3);
                    title.revision              = headersData[35];
                    offset += 36;

                    if ((title.flags & 0x01) == 0x01)
                    {
                        title.description     = Encoding.UTF8.GetString(descriptorsData, title.descriptionSeek, title.descriptionLength);
                        title.longDescription = Encoding.UTF8.GetString(descriptorsData, title.longDescriptionSeek, title.longDescriptionLength);
                    }
                    else
                    {
                        if (culture.ThreeLetterISOLanguageName != title.iso639)
                        {
                            culture = CultureInfo.CreateSpecificCulture("en-EN");
                            CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
                            foreach (CultureInfo c in cultures)
                            {
                                if (c.ThreeLetterISOLanguageName == title.iso639)
                                {
                                    culture = c;
                                    break;
                                }
                            }
                        }
                        title.description     = Encoding.GetEncoding(culture.TextInfo.ANSICodePage).GetString(descriptorsData, title.descriptionSeek, title.descriptionLength);
                        title.longDescription = Encoding.GetEncoding(culture.TextInfo.ANSICodePage).GetString(descriptorsData, title.longDescriptionSeek, title.longDescriptionLength);
                    }

                    if (channel != null)
                    {
                        channel.titles.Add(title);
                    }
                }
            }

            return(true);
        }