1 | #ifndef OSD_TYPE_TELETEXT_H_ |
---|
2 | #define OSD_TYPE_TELETEXT_H_ |
---|
3 | |
---|
4 | #include <vector> |
---|
5 | #include <map> |
---|
6 | using namespace std; |
---|
7 | |
---|
8 | #include <qstring.h> |
---|
9 | #include <qrect.h> |
---|
10 | #include <qmap.h> |
---|
11 | #include <qcolor.h> |
---|
12 | #include <qmutex.h> |
---|
13 | #include <qfile.h> |
---|
14 | #include <qstring.h> |
---|
15 | #include <qtextstream.h> |
---|
16 | |
---|
17 | #include "../libs/libmythtv/teletextdecoder.h" |
---|
18 | |
---|
19 | class SRTOutputFile |
---|
20 | { |
---|
21 | public: |
---|
22 | SRTOutputFile(QString outfile); |
---|
23 | ~SRTOutputFile(void); |
---|
24 | bool Open(); |
---|
25 | void Close(); |
---|
26 | void Set_DTS(int64_t dts) { m_dts = dts; } |
---|
27 | void Set_Enable(bool enabled); |
---|
28 | bool Is_Enabled() const { return m_enabled; }; |
---|
29 | void Set_Line(QString new_line); |
---|
30 | private: |
---|
31 | QString Pts_To_Srt_Time(int64_t pts); |
---|
32 | void Output_Line(); |
---|
33 | |
---|
34 | int64_t m_dts; |
---|
35 | bool m_opened; |
---|
36 | bool m_enabled; |
---|
37 | QFile m_outfp; |
---|
38 | QTextStream m_outstream; |
---|
39 | QString m_line; |
---|
40 | int64_t m_line_dts; |
---|
41 | int m_index; |
---|
42 | }; |
---|
43 | |
---|
44 | |
---|
45 | class TTColor |
---|
46 | { |
---|
47 | public: |
---|
48 | static const uint BLACK = 0; |
---|
49 | static const uint RED = 1; |
---|
50 | static const uint GREEN = 2; |
---|
51 | static const uint YELLOW = 3; |
---|
52 | static const uint BLUE = 4; |
---|
53 | static const uint MAGENTA = 5; |
---|
54 | static const uint CYAN = 6; |
---|
55 | static const uint WHITE = 7; |
---|
56 | static const uint TRANSPARENT = 8; |
---|
57 | }; |
---|
58 | |
---|
59 | class TTKey |
---|
60 | { |
---|
61 | public: |
---|
62 | static const uint k0 = 0; |
---|
63 | static const uint k1 = 1; |
---|
64 | static const uint k2 = 2; |
---|
65 | static const uint k3 = 3; |
---|
66 | static const uint k4 = 4; |
---|
67 | static const uint k5 = 5; |
---|
68 | static const uint k6 = 6; |
---|
69 | static const uint k7 = 7; |
---|
70 | static const uint k8 = 8; |
---|
71 | static const uint k9 = 9; |
---|
72 | static const uint kNextPage = 10; |
---|
73 | static const uint kPrevPage = 11; |
---|
74 | static const uint kNextSubPage = 12; |
---|
75 | static const uint kPrevSubPage = 13; |
---|
76 | static const uint kHold = 14; |
---|
77 | static const uint kTransparent = 15; |
---|
78 | static const uint kFlofRed = 16; |
---|
79 | static const uint kFlofGreen = 17; |
---|
80 | static const uint kFlofYellow = 18; |
---|
81 | static const uint kFlofBlue = 19; |
---|
82 | static const uint kFlofWhite = 20; |
---|
83 | static const uint kRevealHidden = 21; |
---|
84 | }; |
---|
85 | |
---|
86 | #define TP_SUPPRESS_HEADER 0x01 |
---|
87 | #define TP_UPDATE_INDICATOR 0x02 |
---|
88 | #define TP_INTERRUPTED_SEQ 0x04 |
---|
89 | #define TP_INHIBIT_DISPLAY 0x08 |
---|
90 | #define TP_MAGAZINE_SERIAL 0x10 |
---|
91 | #define TP_ERASE_PAGE 0x20 |
---|
92 | #define TP_NEWSFLASH 0x40 |
---|
93 | #define TP_SUBTITLE 0x80 |
---|
94 | |
---|
95 | class TeletextSubPage |
---|
96 | { |
---|
97 | public: |
---|
98 | int pagenum; ///< the wanted page |
---|
99 | int subpagenum; ///< the wanted subpage |
---|
100 | int lang; ///< language code |
---|
101 | int flags; ///< misc flags |
---|
102 | uint8_t data[25][40]; ///< page data |
---|
103 | int flof; ///< page has FastText links |
---|
104 | int floflink[6]; ///< FastText links (FLOF) |
---|
105 | bool subtitle; ///< page is subtitle page |
---|
106 | bool active; ///< data has arrived since page last cleared |
---|
107 | }; |
---|
108 | typedef map<int, TeletextSubPage> int_to_subpage_t; |
---|
109 | |
---|
110 | class TeletextPage |
---|
111 | { |
---|
112 | public: |
---|
113 | int pagenum; |
---|
114 | int current_subpage; |
---|
115 | int_to_subpage_t subpages; |
---|
116 | }; |
---|
117 | typedef map<int, TeletextPage> int_to_page_t; |
---|
118 | |
---|
119 | #define MAGAZINE(page) (page / 256) |
---|
120 | |
---|
121 | class TeletextMagazine |
---|
122 | { |
---|
123 | public: |
---|
124 | int current_page; |
---|
125 | int current_subpage; |
---|
126 | TeletextSubPage loadingpage; |
---|
127 | int_to_page_t pages; |
---|
128 | }; |
---|
129 | |
---|
130 | class SRTTypeTeletext : public TeletextViewer |
---|
131 | { |
---|
132 | public: |
---|
133 | SRTTypeTeletext(); |
---|
134 | virtual ~SRTTypeTeletext() {} |
---|
135 | |
---|
136 | // TeletextViewer interface methods |
---|
137 | void SetPage(int page, int subpage); |
---|
138 | |
---|
139 | void Reset(void); |
---|
140 | void AddPageHeader(int page, int subpage, |
---|
141 | const uint8_t *buf, int vbimode, int lang, int flags); |
---|
142 | void AddTeletextData(int magazine, int row, |
---|
143 | const uint8_t* buf, int vbimode); |
---|
144 | void SetDisplaying(bool displaying) { m_displaying = displaying; } |
---|
145 | void Set_Output_Device(SRTOutputFile *output_device) { m_output_device = output_device; }; |
---|
146 | |
---|
147 | private: |
---|
148 | // Internal Teletext Commands |
---|
149 | void NewsFlash(void) {}; |
---|
150 | void PageUpdated(int page, int subpage); |
---|
151 | void HeaderUpdated(uint8_t *page, int lang); |
---|
152 | bool DecodeLine(const unsigned char *page, uint row, int lang, QString &line) const; |
---|
153 | |
---|
154 | const TeletextSubPage *FindSubPage(int page, int subpage, int dir=0) const |
---|
155 | { return FindSubPageInternal(page, subpage, dir); } |
---|
156 | TeletextSubPage *FindSubPage(int page, int subpage, int dir = 0) |
---|
157 | { return (TeletextSubPage*) FindSubPageInternal(page, subpage, dir); } |
---|
158 | |
---|
159 | const TeletextPage *FindPage(int page, int dir = 0) const |
---|
160 | { return (TeletextPage*) FindPageInternal(page, dir); } |
---|
161 | TeletextPage *FindPage(int page, int dir = 0) |
---|
162 | { return (TeletextPage*) FindPageInternal(page, dir); } |
---|
163 | |
---|
164 | const TeletextSubPage *FindSubPageInternal(int,int,int) const; |
---|
165 | const TeletextPage *FindPageInternal(int,int) const; |
---|
166 | |
---|
167 | private: |
---|
168 | int m_tt_colspace; |
---|
169 | int m_tt_rowspace; |
---|
170 | |
---|
171 | // last fetched page |
---|
172 | int m_fetchpage; |
---|
173 | int m_fetchsubpage; |
---|
174 | |
---|
175 | // currently displayed page: |
---|
176 | mutable int m_curpage; |
---|
177 | mutable int m_cursubpage; |
---|
178 | mutable bool m_curpage_showheader; |
---|
179 | mutable bool m_curpage_issubtitle; |
---|
180 | |
---|
181 | int m_pageinput[3]; |
---|
182 | |
---|
183 | bool m_transparent; |
---|
184 | bool m_revealHidden; |
---|
185 | |
---|
186 | bool m_displaying; |
---|
187 | bool m_changed; |
---|
188 | |
---|
189 | uint8_t m_header[40]; |
---|
190 | mutable bool m_header_changed; |
---|
191 | mutable bool m_page_changed; |
---|
192 | mutable bool m_osd_changed; |
---|
193 | SRTOutputFile *m_output_device; |
---|
194 | |
---|
195 | TeletextMagazine m_magazines[8]; |
---|
196 | unsigned char m_bitswap[256]; |
---|
197 | |
---|
198 | static const int kTeletextColumns; |
---|
199 | static const int kTeletextRows; |
---|
200 | }; |
---|
201 | |
---|
202 | |
---|
203 | |
---|
204 | #endif |
---|
205 | |
---|