00001 #ifndef OSD_TYPE_TELETEXT_H_
00002 #define OSD_TYPE_TELETEXT_H_
00003
00004 #include <vector>
00005 #include <map>
00006 using namespace std;
00007
00008 #include <qstring.h>
00009 #include <qrect.h>
00010 #include <qmap.h>
00011 #include <qcolor.h>
00012 #include <qmutex.h>
00013
00014 #include "osdtypes.h"
00015 #include "teletextdecoder.h"
00016
00017 class TTFFont;
00018 class OSD;
00019 class OSDType;
00020 class OSDSurface;
00021 class OSDTypeTeletext;
00022 class TV;
00023
00024 typedef enum
00025 {
00026 kTTColorBlack = 0,
00027 kTTColorRed = 1,
00028 kTTColorGreen = 2,
00029 kTTColorYellow = 3,
00030 kTTColorBlue = 4,
00031 kTTColorMagenta = 5,
00032 kTTColorCyan = 6,
00033 kTTColorWhite = 7,
00034 kTTColorTransparent = 8,
00035 } TTColor;
00036
00037 class TTKey
00038 {
00039 public:
00040 static const uint k0 = 0;
00041 static const uint k1 = 1;
00042 static const uint k2 = 2;
00043 static const uint k3 = 3;
00044 static const uint k4 = 4;
00045 static const uint k5 = 5;
00046 static const uint k6 = 6;
00047 static const uint k7 = 7;
00048 static const uint k8 = 8;
00049 static const uint k9 = 9;
00050 static const uint kNextPage = 10;
00051 static const uint kPrevPage = 11;
00052 static const uint kNextSubPage = 12;
00053 static const uint kPrevSubPage = 13;
00054 static const uint kHold = 14;
00055 static const uint kTransparent = 15;
00056 static const uint kFlofRed = 16;
00057 static const uint kFlofGreen = 17;
00058 static const uint kFlofYellow = 18;
00059 static const uint kFlofBlue = 19;
00060 static const uint kFlofWhite = 20;
00061 static const uint kRevealHidden = 21;
00062 };
00063
00064 #define TP_SUPPRESS_HEADER 0x01
00065 #define TP_UPDATE_INDICATOR 0x02
00066 #define TP_INTERRUPTED_SEQ 0x04
00067 #define TP_INHIBIT_DISPLAY 0x08
00068 #define TP_MAGAZINE_SERIAL 0x10
00069 #define TP_ERASE_PAGE 0x20
00070 #define TP_NEWSFLASH 0x40
00071 #define TP_SUBTITLE 0x80
00072
00073 class TeletextSubPage
00074 {
00075 public:
00076 int pagenum;
00077 int subpagenum;
00078 int lang;
00079 int flags;
00080 uint8_t data[25][40];
00081 int flof;
00082 int floflink[6];
00083 bool subtitle;
00084 bool active;
00085 };
00086 typedef map<int, TeletextSubPage> int_to_subpage_t;
00087
00088 class TeletextPage
00089 {
00090 public:
00091 int pagenum;
00092 int current_subpage;
00093 int_to_subpage_t subpages;
00094 };
00095 typedef map<int, TeletextPage> int_to_page_t;
00096
00097 #define MAGAZINE(page) (page / 256)
00098
00099 class TeletextMagazine
00100 {
00101 public:
00102 mutable QMutex lock;
00103 int current_page;
00104 int current_subpage;
00105 TeletextSubPage loadingpage;
00106 int_to_page_t pages;
00107 };
00108
00109 class OSDUpdateLocker
00110 {
00111 public:
00112 OSDUpdateLocker(QMutex *lock, OSDTypeTeletext *parent);
00113 ~OSDUpdateLocker(void);
00114
00115 private:
00116 QMutex *m_lock;
00117 OSDTypeTeletext *m_parent;
00118 };
00119
00120 class OSDTypeTeletext : public OSDType, public TeletextViewer
00121 {
00122 Q_OBJECT
00123
00124 friend QColor color_tt2qt(int ttcolor);
00125 friend class OSDUpdateLocker;
00126
00127 public:
00128 OSDTypeTeletext(const QString &name, TTFFont *font,
00129 QRect displayrect, float wmult, float hmult, OSD *osd);
00130 OSDTypeTeletext(const OSDTypeTeletext &other)
00131 : OSDType(other.m_name), TeletextViewer() {}
00132 virtual ~OSDTypeTeletext() {}
00133
00134 void Reinit(float wmult, float hmult);
00135
00136
00137 void Draw(OSDSurface *surface, int fade, int maxfade, int xoff, int yoff);
00138
00139
00140 void KeyPress(uint key);
00141 void SetPage(int page, int subpage);
00142 void SetDisplaying(bool display) { m_displaying = display; };
00143
00144 void Reset(void);
00145 void AddPageHeader(int page, int subpage,
00146 const uint8_t *buf, int vbimode, int lang, int flags);
00147 void AddTeletextData(int magazine, int row,
00148 const uint8_t* buf, int vbimode);
00149
00150 private:
00151
00152 void SetForegroundColor(int color) const;
00153 void SetBackgroundColor(int color) const;
00154
00155
00156 void DrawBackground(OSDSurface *surface, int x, int y) const;
00157 void DrawRect(OSDSurface *surface, const QRect) const;
00158 void DrawCharacter(OSDSurface *surface, int x, int y,
00159 QChar ch, int doubleheight = 0) const;
00160 void DrawMosaic(OSDSurface *surface, int x, int y,
00161 int code, int doubleheight) const;
00162 void DrawLine(OSDSurface *surface, const uint8_t *page,
00163 uint row, int lang) const;
00164 void DrawHeader(OSDSurface *surface, const uint8_t *page, int lang) const;
00165 void DrawStatus(OSDSurface *surface) const;
00166 void DrawPage(OSDSurface *surface) const;
00167
00168
00169 void NewsFlash(void) {};
00170 void PageUpdated(int page, int subpage);
00171 void HeaderUpdated(uint8_t *page, int lang);
00172
00173 const TeletextSubPage *FindSubPage(int page, int subpage, int dir=0) const
00174 { return FindSubPageInternal(page, subpage, dir); }
00175 TeletextSubPage *FindSubPage(int page, int subpage, int dir = 0)
00176 { return (TeletextSubPage*) FindSubPageInternal(page, subpage, dir); }
00177
00178 const TeletextPage *FindPage(int page, int dir = 0) const
00179 { return (TeletextPage*) FindPageInternal(page, dir); }
00180 TeletextPage *FindPage(int page, int dir = 0)
00181 { return (TeletextPage*) FindPageInternal(page, dir); }
00182
00183 const TeletextSubPage *FindSubPageInternal(int,int,int) const;
00184 const TeletextPage *FindPageInternal(int,int) const;
00185
00186 private:
00187 QMutex m_lock;
00188 QRect m_displayrect;
00189 QRect m_unbiasedrect;
00190
00191 OSDTypeBox *m_box;
00192
00193 int m_tt_colspace;
00194 int m_tt_rowspace;
00195
00196
00197 int m_fetchpage;
00198 int m_fetchsubpage;
00199
00200
00201 mutable TTFFont *m_font;
00202
00203
00204 mutable uint8_t m_bgcolor_y;
00205 mutable uint8_t m_bgcolor_u;
00206 mutable uint8_t m_bgcolor_v;
00207 mutable uint8_t m_bgcolor_a;
00208
00209
00210 mutable int m_curpage;
00211 mutable int m_cursubpage;
00212 mutable bool m_curpage_showheader;
00213 mutable bool m_curpage_issubtitle;
00214
00215 int m_pageinput[3];
00216
00217 bool m_transparent;
00218 bool m_revealHidden;
00219
00220 bool m_displaying;
00221
00222 OSD *m_osd;
00223 uint8_t m_header[40];
00224 mutable bool m_header_changed;
00225 mutable bool m_page_changed;
00226 mutable bool m_osd_changed;
00227
00228 TeletextMagazine m_magazines[8];
00229 unsigned char m_bitswap[256];
00230
00231 static const QColor kColorBlack;
00232 static const QColor kColorRed;
00233 static const QColor kColorGreen;
00234 static const QColor kColorYellow;
00235 static const QColor kColorBlue;
00236 static const QColor kColorMagenta;
00237 static const QColor kColorCyan;
00238 static const QColor kColorWhite;
00239 static const int kTeletextColumns;
00240 static const int kTeletextRows;
00241 };
00242
00243 #endif
00244