MythTV  master
teletextreader.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 
3 #ifndef TELETEXTREADER_H
4 #define TELETEXTREADER_H
5 
6 #include <cstdint>
7 #include <map>
8 
9 #include <QString>
10 #include <QMutex>
11 
12 using namespace std;
13 
14 typedef enum
15 {
25 } TTColor;
26 
27 #define TP_SUPPRESS_HEADER 0x01
28 #define TP_UPDATE_INDICATOR 0x02
29 #define TP_INTERRUPTED_SEQ 0x04
30 #define TP_INHIBIT_DISPLAY 0x08
31 #define TP_MAGAZINE_SERIAL 0x10
32 #define TP_ERASE_PAGE 0x20
33 #define TP_NEWSFLASH 0x40
34 #define TP_SUBTITLE 0x80
35 
37 {
38  public:
39  int pagenum;
40  int subpagenum;
41  int lang;
42  int flags;
43  uint8_t data[25][40];
44  int flof;
45  int floflink[6];
46  bool subtitle;
47  bool active;
48 };
49 
50 typedef map<int, TeletextSubPage> int_to_subpage_t;
51 
53 {
54  public:
55  int pagenum;
58 };
59 typedef map<int, TeletextPage> int_to_page_t;
60 
62 {
63  public:
64  mutable QMutex lock;
69 };
70 
72 {
73  public:
75  virtual ~TeletextReader() = default;
76 
77  // OSD/Player methods
78  void Reset(void);
79  bool KeyPress(const QString &key);
80  QString GetPage(void);
81  void SetPage(int page, int subpage);
82  void SetSubPage(int subpage) { m_cursubpage = subpage; }
83  bool PageChanged(void) const { return m_page_changed; }
84  void SetPageChanged(bool changed) { m_page_changed = changed; }
85  void SetShowHeader(bool show) { m_curpage_showheader = show; }
86  void SetHeaderChanged(bool changed) { m_header_changed = changed; }
87  bool IsSubtitle(void) const { return m_curpage_issubtitle; }
88  void SetIsSubtitle(bool sub) { m_curpage_issubtitle = sub; }
89  bool IsTransparent(void) const { return m_transparent; }
90  bool RevealHidden(void) const { return m_revealHidden; }
91  int GetPageInput(uint num) const { return m_pageinput[num]; }
93  { return FindSubPage(m_curpage, m_cursubpage); }
94  uint8_t* GetHeader(void) { return m_header; }
95 
96  // Decoder methods
97  void AddPageHeader(int page, int subpage, const uint8_t *buf,
98  int vbimode, int lang, int flags);
99  void AddTeletextData(int magazine, int row,
100  const uint8_t* buf, int vbimode);
101 
102  protected:
103  void NewsFlash(void) {};
104  virtual void PageUpdated(int page, int subpage);
105  virtual void HeaderUpdated(
106  int page, int subpage, uint8_t *page_ptr, int lang);
107 
108  const TeletextSubPage *FindSubPage(int page, int subpage, int dir=0) const
109  { return FindSubPageInternal(page, subpage, dir); }
110 
111  TeletextSubPage *FindSubPage(int page, int subpage, int dir = 0)
112  {
113  return const_cast<TeletextSubPage*>
114  (FindSubPageInternal(page, subpage, dir));
115  }
116 
117  const TeletextPage *FindPage(int page, int dir = 0) const
118  { return FindPageInternal(page, dir); }
119 
120  TeletextPage *FindPage(int page, int dir = 0)
121  { return const_cast<TeletextPage*>(FindPageInternal(page, dir)); }
122 
123  const TeletextSubPage *FindSubPageInternal(int,int,int) const;
124  const TeletextPage *FindPageInternal(int,int) const;
125 
126  int m_curpage {0x100};
127  int m_cursubpage {-1};
128  bool m_curpage_showheader {true};
129  bool m_curpage_issubtitle {false};
130  int m_pageinput[3] {0};
131  bool m_transparent {false};
132  bool m_revealHidden {false};
133  uint8_t m_header[40] {0};
134  bool m_header_changed {false};
135  bool m_page_changed {false};
136  TeletextMagazine m_magazines[8];
137  unsigned char m_bitswap[256];
138  int m_fetchpage {0};
139  int m_fetchsubpage {0};
140 };
141 
142 #endif // TELETEXTREADER_H
TeletextPage * FindPage(int page, int dir=0)
bool IsTransparent(void) const
TeletextSubPage loadingpage
map< int, TeletextPage > int_to_page_t
vbimode
Definition: vbilut.h:20
bool IsSubtitle(void) const
void SetHeaderChanged(bool changed)
bool active
data has arrived since page last cleared
bool RevealHidden(void) const
int GetPageInput(uint num) const
unsigned int uint
Definition: compat.h:140
void SetShowHeader(bool show)
map< int, TeletextSubPage > int_to_subpage_t
TeletextSubPage * FindSubPage(int page, int subpage, int dir=0)
const TeletextSubPage * FindSubPage(int page, int subpage, int dir=0) const
int flof
page has FastText links
int pagenum
the wanted page
TeletextSubPage * FindSubPage(void)
int flags
misc flags
static void show(uint8_t *buf, int length)
Definition: ringbuffer.c:316
bool subtitle
page is subtitle page
uint8_t * GetHeader(void)
bool PageChanged(void) const
void SetPageChanged(bool changed)
void SetIsSubtitle(bool sub)
void SetSubPage(int subpage)
TTColor
void NewsFlash(void)
const TeletextPage * FindPage(int page, int dir=0) const
int_to_page_t pages
int subpagenum
the wanted subpage
int_to_subpage_t subpages
int lang
language code