00001
00002
00003 #ifndef TELETEXTREADER_H
00004 #define TELETEXTREADER_H
00005
00006 #include <stdint.h>
00007 #include <map>
00008
00009 #include <QString>
00010 #include <QMutex>
00011
00012 using namespace std;
00013
00014 typedef enum
00015 {
00016 kTTColorBlack = 0,
00017 kTTColorRed = 1,
00018 kTTColorGreen = 2,
00019 kTTColorYellow = 3,
00020 kTTColorBlue = 4,
00021 kTTColorMagenta = 5,
00022 kTTColorCyan = 6,
00023 kTTColorWhite = 7,
00024 kTTColorTransparent = 8,
00025 } TTColor;
00026
00027 #define TP_SUPPRESS_HEADER 0x01
00028 #define TP_UPDATE_INDICATOR 0x02
00029 #define TP_INTERRUPTED_SEQ 0x04
00030 #define TP_INHIBIT_DISPLAY 0x08
00031 #define TP_MAGAZINE_SERIAL 0x10
00032 #define TP_ERASE_PAGE 0x20
00033 #define TP_NEWSFLASH 0x40
00034 #define TP_SUBTITLE 0x80
00035
00036 class TeletextSubPage
00037 {
00038 public:
00039 int pagenum;
00040 int subpagenum;
00041 int lang;
00042 int flags;
00043 uint8_t data[25][40];
00044 int flof;
00045 int floflink[6];
00046 bool subtitle;
00047 bool active;
00048 };
00049
00050 typedef map<int, TeletextSubPage> int_to_subpage_t;
00051
00052 class TeletextPage
00053 {
00054 public:
00055 int pagenum;
00056 int current_subpage;
00057 int_to_subpage_t subpages;
00058 };
00059 typedef map<int, TeletextPage> int_to_page_t;
00060
00061 class TeletextMagazine
00062 {
00063 public:
00064 mutable QMutex lock;
00065 int current_page;
00066 int current_subpage;
00067 TeletextSubPage loadingpage;
00068 int_to_page_t pages;
00069 };
00070
00071 class TeletextReader
00072 {
00073 public:
00074 TeletextReader();
00075 virtual ~TeletextReader();
00076
00077
00078 void Reset(void);
00079 bool KeyPress(const QString &key);
00080 QString GetPage(void);
00081 void SetPage(int page, int subpage);
00082 void SetSubPage(int subpage) { m_cursubpage = subpage; }
00083 bool PageChanged(void) const { return m_page_changed; }
00084 void SetPageChanged(bool changed) { m_page_changed = changed; }
00085 void SetShowHeader(bool show) { m_curpage_showheader = show; }
00086 void SetHeaderChanged(bool changed) { m_header_changed = changed; }
00087 bool IsSubtitle(void) const { return m_curpage_issubtitle; }
00088 void SetIsSubtitle(bool sub) { m_curpage_issubtitle = sub; }
00089 bool IsTransparent(void) const { return m_transparent; }
00090 bool RevealHidden(void) const { return m_revealHidden; }
00091 int GetPageInput(uint num) const { return m_pageinput[num]; }
00092 TeletextSubPage* FindSubPage(void)
00093 { return FindSubPage(m_curpage, m_cursubpage); }
00094 uint8_t* GetHeader(void) { return m_header; }
00095
00096
00097 void AddPageHeader(int page, int subpage, const uint8_t *buf,
00098 int vbimode, int lang, int flags);
00099 void AddTeletextData(int magazine, int row,
00100 const uint8_t* buf, int vbimode);
00101
00102 protected:
00103 void NewsFlash(void) {};
00104 virtual void PageUpdated(int page, int subpage);
00105 virtual void HeaderUpdated(
00106 int page, int subpage, uint8_t *page_ptr, int lang);
00107
00108 const TeletextSubPage *FindSubPage(int page, int subpage, int dir=0) const
00109 { return FindSubPageInternal(page, subpage, dir); }
00110
00111 TeletextSubPage *FindSubPage(int page, int subpage, int dir = 0)
00112 {
00113 return const_cast<TeletextSubPage*>
00114 (FindSubPageInternal(page, subpage, dir));
00115 }
00116
00117 const TeletextPage *FindPage(int page, int dir = 0) const
00118 { return FindPageInternal(page, dir); }
00119
00120 TeletextPage *FindPage(int page, int dir = 0)
00121 { return const_cast<TeletextPage*>(FindPageInternal(page, dir)); }
00122
00123 const TeletextSubPage *FindSubPageInternal(int,int,int) const;
00124 const TeletextPage *FindPageInternal(int,int) const;
00125
00126 int m_curpage;
00127 int m_cursubpage;
00128 bool m_curpage_showheader;
00129 bool m_curpage_issubtitle;
00130 int m_pageinput[3];
00131 bool m_transparent;
00132 bool m_revealHidden;
00133 uint8_t m_header[40];
00134 bool m_header_changed;
00135 bool m_page_changed;
00136 TeletextMagazine m_magazines[8];
00137 unsigned char m_bitswap[256];
00138 int m_fetchpage;
00139 int m_fetchsubpage;
00140 };
00141
00142 #endif // TELETEXTREADER_H