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 enum TTColor
15 {
25 };
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 using int_to_subpage_t = map<int, TeletextSubPage>;
51 
53 {
54  public:
55  int pagenum {0};
56  int current_subpage {0};
58 };
59 using int_to_page_t = map<int, TeletextPage>;
60 
62 {
63  public:
64  TeletextMagazine() = default;
65  ~TeletextMagazine() { delete lock; }
66  QMutex* lock { new QMutex };
67  int current_page {0};
68  int current_subpage {0};
69  TeletextSubPage loadingpage {};
71 };
72 
74 {
75  public:
77  virtual ~TeletextReader() = default;
78 
79  // OSD/Player methods
80  void Reset(void);
81  bool KeyPress(const QString &key);
82  QString GetPage(void);
83  void SetPage(int page, int subpage);
84  void SetSubPage(int subpage) { m_cursubpage = subpage; }
85  bool PageChanged(void) const { return m_page_changed; }
86  void SetPageChanged(bool changed) { m_page_changed = changed; }
87  void SetShowHeader(bool show) { m_curpage_showheader = show; }
88  void SetHeaderChanged(bool changed) { m_header_changed = changed; }
89  bool IsSubtitle(void) const { return m_curpage_issubtitle; }
90  void SetIsSubtitle(bool sub) { m_curpage_issubtitle = sub; }
91  bool IsTransparent(void) const { return m_transparent; }
92  bool RevealHidden(void) const { return m_revealHidden; }
93  int GetPageInput(uint num) const { return m_pageinput[num]; }
95  { return FindSubPage(m_curpage, m_cursubpage); }
96  uint8_t* GetHeader(void) { return m_header; }
97 
98  // Decoder methods
99  void AddPageHeader(int page, int subpage, const uint8_t *buf,
100  int vbimode, int lang, int flags);
101  void AddTeletextData(int magazine, int row,
102  const uint8_t* buf, int vbimode);
103 
104  protected:
105  virtual void PageUpdated(int page, int subpage);
106  virtual void HeaderUpdated(
107  int page, int subpage, uint8_t *page_ptr, int lang);
108 
109  const TeletextSubPage *FindSubPage(int page, int subpage, int dir=0) const
110  { return FindSubPageInternal(page, subpage, dir); }
111 
112  TeletextSubPage *FindSubPage(int page, int subpage, int dir = 0)
113  {
114  return const_cast<TeletextSubPage*>
115  (FindSubPageInternal(page, subpage, dir));
116  }
117 
118  const TeletextPage *FindPage(int page, int dir = 0) const
119  { return FindPageInternal(page, dir); }
120 
121  TeletextPage *FindPage(int page, int dir = 0)
122  { return const_cast<TeletextPage*>(FindPageInternal(page, dir)); }
123 
124  const TeletextSubPage *FindSubPageInternal(int page, int subpage, int direction) const;
125  const TeletextPage *FindPageInternal(int page, int direction) const;
126 
127  int m_curpage {0x100};
128  int m_cursubpage {-1};
129  bool m_curpage_showheader {true};
130  bool m_curpage_issubtitle {false};
131  int m_pageinput[3] {0};
132  bool m_transparent {false};
133  bool m_revealHidden {false};
134  uint8_t m_header[40] {0};
135  bool m_header_changed {false};
136  bool m_page_changed {false};
137  TeletextMagazine m_magazines[8] { };
138  unsigned char m_bitswap[256] {};
139  int m_fetchpage {0};
140  int m_fetchsubpage {0};
141 };
142 
143 #endif // TELETEXTREADER_H
TeletextPage * FindPage(int page, int dir=0)
bool IsTransparent(void) const
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
void SetShowHeader(bool show)
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:318
map< int, TeletextSubPage > int_to_subpage_t
bool subtitle
page is subtitle page
uint8_t * GetHeader(void)
bool PageChanged(void) const
unsigned int uint
Definition: compat.h:140
void SetPageChanged(bool changed)
void SetIsSubtitle(bool sub)
void SetSubPage(int subpage)
TTColor
const TeletextPage * FindPage(int page, int dir=0) const
map< int, TeletextPage > int_to_page_t
int_to_page_t pages
int subpagenum
the wanted subpage
int_to_subpage_t subpages
int lang
language code