예제 #1
0
        /// <summary>
        /// Gets the raw teletext page.
        /// </summary>
        /// <param name="page">pagenumber (0x100-0x899)</param>
        /// <param name="subpage">subpagenumber (0x0-0x79)</param>
        /// <returns>raw teletext page (or null if page is not found)</returns>
        public byte[] GetRawPage(int page, int subpage)
        {
            _currentPageNumber    = page;
            _currentSubPageNumber = subpage;
            if (_currentPageNumber < MIN_PAGE)
            {
                _currentPageNumber = MIN_PAGE;
            }
            if (_currentPageNumber >= MAX_PAGE)
            {
                _currentPageNumber = MAX_PAGE - 1;
            }

            if (_pageCache.SubPageExists(_currentPageNumber, _currentSubPageNumber))
            {
                byte[] byPage = _pageCache.GetPage(_currentPageNumber, _currentSubPageNumber);
                if (byPage == null)
                {
                    return(null);
                }
                _fastTextDecoder.Decode(byPage);

                if (_topTextDecoder.Decode(_pageCache, _currentPageNumber))
                {
                    AddTopTextRow24(ref byPage);
                }
                return(byPage);
            }
            return(null);
        }
예제 #2
0
 /// <summary>
 /// Decodes the toptext multi page.
 /// </summary>
 /// <param name="cache">The cache.</param>
 private void DecodeMultiPage(TeletextPageCache cache)
 {
     // multi page contains the number of subpages transmitted for each page (100-899);
     if (!cache.PageExists(TOP_MULTI_PAGE))
     {
         return;
     }
     byte[] multiPage = cache.GetPage(TOP_MULTI_PAGE, 0);
     for (int pageNr = 100; pageNr <= 899; pageNr++)
     {
         int  row  = ((pageNr - 100) / 40) + 1;
         int  col  = ((pageNr - 100) % 40) + 2;
         byte data = Hamming.Decode[multiPage[row * 42 + col]];
         if (data == NotPresent)
         {
             //page is offair
             _pageSubCount[pageNr] = 0;
         }
         else if (data == 0x0a)
         {
             //page has > 10 subpages
             _pageSubCount[pageNr] = 10; //( or more)
         }
         else
         {
             int numberOfSubPages = data - 1;
             _pageSubCount[pageNr] = numberOfSubPages;
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Decodes the additional toptext pages.
        /// </summary>
        /// <param name="cache">The cache.</param>
        private void DecodeAdditionalPages(TeletextPageCache cache)
        {
            //addditional pages carry information to display on line 24
            //
            for (int pageNr = TOP_ADDITIONAL_PAGE; pageNr < 0x1fd; ++pageNr)
            {
                if (!cache.PageExists(pageNr))
                {
                    continue;
                }
                byte[] additionalPage = cache.GetPage(pageNr, 0);
                int    lineCounter    = 0;
                while (true)
                {
                    int  row       = 1 + (lineCounter / 2);
                    int  col       = (20 * (lineCounter % 2));
                    byte magazine  = Hamming.Decode[additionalPage[row * 42 + 2 + col]];
                    byte pageTens  = Hamming.Decode[additionalPage[row * 42 + 3 + col]];
                    byte pageUnits = Hamming.Decode[additionalPage[row * 42 + 4 + col]];
                    if (magazine >= 0 && magazine <= 7)
                    {
                        if (pageTens >= 0x0 && pageTens <= 9)
                        {
                            if (pageUnits >= 0x0 && pageUnits <= 9)
                            {
                                string description = String.Empty;
                                for (int i = 1; i < 12; ++i)
                                {
                                    row = 1 + (lineCounter / 2);
                                    col = 9 + i + (20 * (lineCounter % 2));

                                    description += (char)(additionalPage[row * 42 + col] & 0x7f);
                                }
                                if (magazine == 0)
                                {
                                    magazine = 8;
                                }
                                int pageNo = magazine * 100 + pageTens * 10 + pageUnits;
                                if (pageNo >= 100 && pageNo <= 899)
                                {
                                    _pageDescription[pageNo] = description;
                                }
                            }
                        }
                    }
                    lineCounter++;
                    if (lineCounter >= 43)
                    {
                        break;
                    }
                }
            }
        }
예제 #4
0
 /// <summary>
 /// Decodes the basic toptext page.
 /// </summary>
 /// <param name="cache">The cache.</param>
 /// <returns></returns>
 private bool DecodeBasicPage(TeletextPageCache cache)
 {
     //basic toppage contains information which teletext pages are onair
     //and if onair if it has subpages or not
     //also contains the type for each page
     if (!cache.PageExists(TOP_BASIC_PAGE))
     {
         return(false);
     }
     byte[] basicPage = cache.GetPage(TOP_BASIC_PAGE, 0);
     for (int pageNr = 100; pageNr <= 899; pageNr++)
     {
         int  row  = ((pageNr - 100) / 40) + 1;
         int  col  = ((pageNr - 100) % 40) + 2;
         byte data = Hamming.Decode[basicPage[row * 42 + col]];
         if (data == ProgramInfoBlockPageMulti ||
             data == BlockPageMulti ||
             data == GroupPageMulti ||
             data == NormalPageMulti ||
             data == NormalPageMultiInfo
             )
         {
             //page is onair and has subpages
             _pageType[pageNr] = data;
         }
         if (data == ProgramInfoBlockPageSingle ||
             data == BlockPageSingle ||
             data == GroupPageSingle ||
             data == NormalPage ||
             data == NormalPageInfo)
         {
             //page is onair and has subpages
             _pageType[pageNr] = data;
         }
         if (data == NotPresent)
         {
             //page is not onair
             _pageType[pageNr]     = data;
             _pageSubCount[pageNr] = 0;
         }
     }
     return(true);
 }
예제 #5
0
    /// <summary>
    /// Decodes the additional toptext pages.
    /// </summary>
    /// <param name="cache">The cache.</param>
    private void DecodeAdditionalPages(TeletextPageCache cache)
    {
      //addditional pages carry information to display on line 24
      //
      for (int pageNr = TOP_ADDITIONAL_PAGE; pageNr < 0x1fd; ++pageNr)
      {
        if (!cache.PageExists(pageNr))
          continue;
        byte[] additionalPage = cache.GetPage(pageNr, 0);
        int lineCounter = 0;
        while (true)
        {
          int row = 1 + (lineCounter / 2);
          int col = (20 * (lineCounter % 2));
          byte magazine = Hamming.Decode[additionalPage[row * 42 + 2 + col]];
          byte pageTens = Hamming.Decode[additionalPage[row * 42 + 3 + col]];
          byte pageUnits = Hamming.Decode[additionalPage[row * 42 + 4 + col]];
          if (magazine >= 0 && magazine <= 7)
          {
            if (pageTens >= 0x0 && pageTens <= 9)
            {
              if (pageUnits >= 0x0 && pageUnits <= 9)
              {
                string description = String.Empty;
                for (int i = 1; i < 12; ++i)
                {
                  row = 1 + (lineCounter / 2);
                  col = 9 + i + (20 * (lineCounter % 2));

                  description += (char)(additionalPage[row * 42 + col] & 0x7f);
                }
                if (magazine == 0)
                  magazine = 8;
                int pageNo = magazine * 100 + pageTens * 10 + pageUnits;
                if (pageNo >= 100 && pageNo <= 899)
                {
                  _pageDescription[pageNo] = description;
                }
              }
            }
          }
          lineCounter++;
          if (lineCounter >= 43)
            break;
        }
      }
    }
예제 #6
0
 /// <summary>
 /// Decodes the toptext multi page.
 /// </summary>
 /// <param name="cache">The cache.</param>
 private void DecodeMultiPage(TeletextPageCache cache)
 {
   // multi page contains the number of subpages transmitted for each page (100-899);
   if (!cache.PageExists(TOP_MULTI_PAGE))
     return;
   byte[] multiPage = cache.GetPage(TOP_MULTI_PAGE, 0);
   for (int pageNr = 100; pageNr <= 899; pageNr++)
   {
     int row = ((pageNr - 100) / 40) + 1;
     int col = ((pageNr - 100) % 40) + 2;
     byte data = Hamming.Decode[multiPage[row * 42 + col]];
     if (data == NotPresent)
     {
       //page is offair
       _pageSubCount[pageNr] = 0;
     }
     else if (data == 0x0a)
     {
       //page has > 10 subpages
       _pageSubCount[pageNr] = 10; //( or more)
     }
     else
     {
       int numberOfSubPages = data - 1;
       _pageSubCount[pageNr] = numberOfSubPages;
     }
   }
 }
예제 #7
0
 /// <summary>
 /// Decodes the basic toptext page.
 /// </summary>
 /// <param name="cache">The cache.</param>
 /// <returns></returns>
 private bool DecodeBasicPage(TeletextPageCache cache)
 {
   //basic toppage contains information which teletext pages are onair
   //and if onair if it has subpages or not
   //also contains the type for each page
   if (!cache.PageExists(TOP_BASIC_PAGE))
     return false;
   byte[] basicPage = cache.GetPage(TOP_BASIC_PAGE, 0);
   for (int pageNr = 100; pageNr <= 899; pageNr++)
   {
     int row = ((pageNr - 100) / 40) + 1;
     int col = ((pageNr - 100) % 40) + 2;
     byte data = Hamming.Decode[basicPage[row * 42 + col]];
     if (data == ProgramInfoBlockPageMulti ||
         data == BlockPageMulti ||
         data == GroupPageMulti ||
         data == NormalPageMulti ||
         data == NormalPageMultiInfo
       )
     {
       //page is onair and has subpages
       _pageType[pageNr] = data;
     }
     if (data == ProgramInfoBlockPageSingle ||
         data == BlockPageSingle ||
         data == GroupPageSingle ||
         data == NormalPage ||
         data == NormalPageInfo)
     {
       //page is onair and has subpages
       _pageType[pageNr] = data;
     }
     if (data == NotPresent)
     {
       //page is not onair
       _pageType[pageNr] = data;
       _pageSubCount[pageNr] = 0;
     }
   }
   return true;
 }