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
TeletextSubPage::lang
int lang
language code
Definition: teletextreader.h:41
TeletextSubPage::flof
int flof
page has FastText links
Definition: teletextreader.h:44
TeletextPage::subpages
int_to_subpage_t subpages
Definition: teletextreader.h:57
kTTColorRed
@ kTTColorRed
Definition: teletextreader.h:17
TeletextReader::SetHeaderChanged
void SetHeaderChanged(bool changed)
Definition: teletextreader.h:88
TeletextReader::IsSubtitle
bool IsSubtitle(void) const
Definition: teletextreader.h:89
TeletextReader::IsTransparent
bool IsTransparent(void) const
Definition: teletextreader.h:91
TeletextSubPage::flags
int flags
misc flags
Definition: teletextreader.h:42
kTTColorTransparent
@ kTTColorTransparent
Definition: teletextreader.h:24
vbimode
vbimode
Definition: vbilut.h:21
kTTColorBlack
@ kTTColorBlack
Definition: teletextreader.h:16
TeletextSubPage::subtitle
bool subtitle
page is subtitle page
Definition: teletextreader.h:46
TeletextReader::FindSubPage
const TeletextSubPage * FindSubPage(int page, int subpage, int dir=0) const
Definition: teletextreader.h:109
TeletextMagazine::pages
int_to_page_t pages
Definition: teletextreader.h:70
TeletextMagazine::~TeletextMagazine
~TeletextMagazine()
Definition: teletextreader.h:65
TeletextSubPage
Definition: teletextreader.h:36
show
static void show(uint8_t *buf, int length)
Definition: ringbuffer.cpp:319
kTTColorGreen
@ kTTColorGreen
Definition: teletextreader.h:18
TeletextReader
Definition: teletextreader.h:73
kTTColorWhite
@ kTTColorWhite
Definition: teletextreader.h:23
TeletextReader::FindSubPage
TeletextSubPage * FindSubPage(int page, int subpage, int dir=0)
Definition: teletextreader.h:112
TeletextReader::PageChanged
bool PageChanged(void) const
Definition: teletextreader.h:85
int_to_subpage_t
map< int, TeletextSubPage > int_to_subpage_t
Definition: teletextreader.h:50
TeletextReader::SetShowHeader
void SetShowHeader(bool show)
Definition: teletextreader.h:87
kTTColorMagenta
@ kTTColorMagenta
Definition: teletextreader.h:21
TeletextReader::RevealHidden
bool RevealHidden(void) const
Definition: teletextreader.h:92
uint
unsigned int uint
Definition: compat.h:140
kTTColorYellow
@ kTTColorYellow
Definition: teletextreader.h:19
TeletextReader::SetIsSubtitle
void SetIsSubtitle(bool sub)
Definition: teletextreader.h:90
TeletextReader::SetPageChanged
void SetPageChanged(bool changed)
Definition: teletextreader.h:86
dir
QDir dir
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1171
kTTColorCyan
@ kTTColorCyan
Definition: teletextreader.h:22
TeletextReader::FindSubPage
TeletextSubPage * FindSubPage(void)
Definition: teletextreader.h:94
int_to_page_t
map< int, TeletextPage > int_to_page_t
Definition: teletextreader.h:59
TeletextSubPage::pagenum
int pagenum
the wanted page
Definition: teletextreader.h:39
TeletextSubPage::active
bool active
data has arrived since page last cleared
Definition: teletextreader.h:47
TeletextSubPage::subpagenum
int subpagenum
the wanted subpage
Definition: teletextreader.h:40
kTTColorBlue
@ kTTColorBlue
Definition: teletextreader.h:20
TeletextReader::SetSubPage
void SetSubPage(int subpage)
Definition: teletextreader.h:84
TeletextReader::FindPage
TeletextPage * FindPage(int page, int dir=0)
Definition: teletextreader.h:121
TeletextReader::FindPage
const TeletextPage * FindPage(int page, int dir=0) const
Definition: teletextreader.h:118
TTColor
TTColor
Definition: teletextreader.h:14
TeletextMagazine
Definition: teletextreader.h:61
TeletextReader::GetHeader
uint8_t * GetHeader(void)
Definition: teletextreader.h:96
TeletextReader::GetPageInput
int GetPageInput(uint num) const
Definition: teletextreader.h:93
TeletextPage
Definition: teletextreader.h:52