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 <array>
7 #include <cstdint>
8 #include <map>
9 #include <vector>
10 
11 #include <QString>
12 #include <QMutex>
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 
36 using tt_line_array = std::array<uint8_t,40>;
37 
39 {
40  public:
41  int pagenum;
42  int subpagenum;
43  int lang;
44  int flags;
45  std::array<tt_line_array,25> data;
46  int flof;
47  std::array<int,6> floflink;
48  bool subtitle;
49  bool active;
50 };
51 
52 using int_to_subpage_t = std::map<int, TeletextSubPage>;
53 
55 {
56  public:
57  int pagenum {0};
58  int current_subpage {0};
60 };
61 using int_to_page_t = std::map<int, TeletextPage>;
62 
64 {
65  public:
66  TeletextMagazine() = default;
67  ~TeletextMagazine() { delete lock; }
68  QMutex* lock { new QMutex };
69  int current_page {0};
70  int current_subpage {0};
73 };
74 
76 {
77  public:
79  virtual ~TeletextReader() = default;
80 
81  // OSD/Player methods
82  void Reset(void);
83  bool KeyPress(const QString& Key, bool& Exit);
84  QString GetPage(void);
85  void SetPage(int page, int subpage);
86  void SetSubPage(int subpage) { m_cursubpage = subpage; }
87  bool PageChanged(void) const { return m_pageChanged; }
88  void SetPageChanged(bool changed) { m_pageChanged = changed; }
90  void SetHeaderChanged(bool changed) { m_headerChanged = changed; }
91  bool IsSubtitle(void) const { return m_curpageIsSubtitle; }
92  void SetIsSubtitle(bool sub) { m_curpageIsSubtitle = sub; }
93  bool IsTransparent(void) const { return m_transparent; }
94  bool RevealHidden(void) const { return m_revealHidden; }
95  int GetPageInput(uint num) const { return m_pageinput[num]; }
97  { return FindSubPage(m_curpage, m_cursubpage); }
98  tt_line_array GetHeader(void) { return m_header; }
99 
100  // Decoder methods
101  void AddPageHeader(int page, int subpage, const uint8_t *buf,
102  int vbimode, int lang, int flags);
103  void AddTeletextData(int magazine, int row,
104  const uint8_t* buf, int vbimode);
105 
106  protected:
107  virtual void PageUpdated(int page, int subpage);
108  virtual void HeaderUpdated(
109  int page, int subpage, tt_line_array& page_ptr, int lang);
110 
111  const TeletextSubPage *FindSubPage(int page, int subpage, int dir=0) const
112  { return FindSubPageInternal(page, subpage, dir); }
113 
114  TeletextSubPage *FindSubPage(int page, int subpage, int dir = 0)
115  {
116  return const_cast<TeletextSubPage*>
117  (FindSubPageInternal(page, subpage, dir));
118  }
119 
120  const TeletextPage *FindPage(int page, int dir = 0) const
121  { return FindPageInternal(page, dir); }
122 
123  TeletextPage *FindPage(int page, int dir = 0)
124  { return const_cast<TeletextPage*>(FindPageInternal(page, dir)); }
125 
126  const TeletextSubPage *FindSubPageInternal(int page, int subpage, int direction) const;
127  const TeletextPage *FindPageInternal(int page, int direction) const;
128 
129  int m_curpage {0x100};
130  int m_cursubpage {-1};
131  bool m_curpageShowHeader {true};
132  bool m_curpageIsSubtitle {false};
133  std::array<int,3> m_pageinput {0};
134  bool m_transparent {false};
135  bool m_revealHidden {false};
137  bool m_headerChanged {false};
138  bool m_pageChanged {false};
139  std::array<TeletextMagazine,8> m_magazines {};
140  std::array<uint8_t,256> m_bitswap {};
141  int m_fetchpage {0};
142  int m_fetchsubpage {0};
143 };
144 
145 #endif // TELETEXTREADER_H
TeletextSubPage::lang
int lang
language code
Definition: teletextreader.h:43
TeletextSubPage::flof
int flof
page has FastText links
Definition: teletextreader.h:46
TeletextPage::subpages
int_to_subpage_t subpages
Definition: teletextreader.h:59
TeletextMagazine::current_subpage
int current_subpage
Definition: teletextreader.h:70
kTTColorRed
@ kTTColorRed
Definition: teletextreader.h:17
TeletextReader::GetPage
QString GetPage(void)
Definition: teletextreader.cpp:194
TeletextReader::SetHeaderChanged
void SetHeaderChanged(bool changed)
Definition: teletextreader.h:90
TeletextReader::IsSubtitle
bool IsSubtitle(void) const
Definition: teletextreader.h:91
TeletextReader::m_curpage
int m_curpage
Definition: teletextreader.h:129
TeletextReader::IsTransparent
bool IsTransparent(void) const
Definition: teletextreader.h:93
TeletextSubPage::flags
int flags
misc flags
Definition: teletextreader.h:44
kTTColorTransparent
@ kTTColorTransparent
Definition: teletextreader.h:24
TeletextSubPage::floflink
std::array< int, 6 > floflink
FastText links (FLOF)
Definition: teletextreader.h:47
TeletextReader::m_bitswap
std::array< uint8_t, 256 > m_bitswap
Definition: teletextreader.h:140
vbimode
vbimode
Definition: vbilut.h:22
TeletextPage::pagenum
int pagenum
Definition: teletextreader.h:57
kTTColorBlack
@ kTTColorBlack
Definition: teletextreader.h:16
TeletextReader::m_cursubpage
int m_cursubpage
Definition: teletextreader.h:130
TeletextSubPage::subtitle
bool subtitle
page is subtitle page
Definition: teletextreader.h:48
TeletextReader::FindSubPage
const TeletextSubPage * FindSubPage(int page, int subpage, int dir=0) const
Definition: teletextreader.h:111
TeletextMagazine::pages
int_to_page_t pages
Definition: teletextreader.h:72
TeletextMagazine::lock
QMutex * lock
Definition: teletextreader.h:68
TeletextMagazine::~TeletextMagazine
~TeletextMagazine()
Definition: teletextreader.h:67
TeletextSubPage
Definition: teletextreader.h:39
show
static void show(uint8_t *buf, int length)
Definition: ringbuffer.cpp:339
TeletextReader::m_transparent
bool m_transparent
Definition: teletextreader.h:134
TeletextReader::PageUpdated
virtual void PageUpdated(int page, int subpage)
Definition: teletextreader.cpp:508
TeletextReader::FindPageInternal
const TeletextPage * FindPageInternal(int page, int direction) const
Definition: teletextreader.cpp:531
kTTColorGreen
@ kTTColorGreen
Definition: teletextreader.h:18
TeletextReader::m_headerChanged
bool m_headerChanged
Definition: teletextreader.h:137
TeletextReader::m_header
tt_line_array m_header
Definition: teletextreader.h:136
TeletextReader::m_magazines
std::array< TeletextMagazine, 8 > m_magazines
Definition: teletextreader.h:139
TeletextMagazine::TeletextMagazine
TeletextMagazine()=default
TeletextReader
Definition: teletextreader.h:76
TeletextMagazine::current_page
int current_page
Definition: teletextreader.h:69
kTTColorWhite
@ kTTColorWhite
Definition: teletextreader.h:23
TeletextMagazine::loadingpage
TeletextSubPage loadingpage
Definition: teletextreader.h:71
TeletextReader::FindSubPage
TeletextSubPage * FindSubPage(int page, int subpage, int dir=0)
Definition: teletextreader.h:114
TeletextReader::PageChanged
bool PageChanged(void) const
Definition: teletextreader.h:87
TeletextReader::m_fetchsubpage
int m_fetchsubpage
Definition: teletextreader.h:142
TeletextReader::m_pageChanged
bool m_pageChanged
Definition: teletextreader.h:138
TeletextReader::HeaderUpdated
virtual void HeaderUpdated(int page, int subpage, tt_line_array &page_ptr, int lang)
Definition: teletextreader.cpp:517
TeletextReader::SetShowHeader
void SetShowHeader(bool show)
Definition: teletextreader.h:89
kTTColorMagenta
@ kTTColorMagenta
Definition: teletextreader.h:21
tt_line_array
std::array< uint8_t, 40 > tt_line_array
Definition: teletextreader.h:36
TeletextReader::SetPage
void SetPage(int page, int subpage)
Definition: teletextreader.cpp:253
TeletextReader::m_curpageIsSubtitle
bool m_curpageIsSubtitle
Definition: teletextreader.h:132
TeletextReader::~TeletextReader
virtual ~TeletextReader()=default
TeletextReader::RevealHidden
bool RevealHidden(void) const
Definition: teletextreader.h:94
TeletextPage::current_subpage
int current_subpage
Definition: teletextreader.h:58
uint
unsigned int uint
Definition: compat.h:141
kTTColorYellow
@ kTTColorYellow
Definition: teletextreader.h:19
TeletextReader::SetIsSubtitle
void SetIsSubtitle(bool sub)
Definition: teletextreader.h:92
TeletextReader::m_fetchpage
int m_fetchpage
Definition: teletextreader.h:141
int_to_page_t
std::map< int, TeletextPage > int_to_page_t
Definition: teletextreader.h:61
TeletextReader::AddTeletextData
void AddTeletextData(int magazine, int row, const uint8_t *buf, int vbimode)
Definition: teletextreader.cpp:398
TeletextReader::KeyPress
bool KeyPress(const QString &Key, bool &Exit)
Definition: teletextreader.cpp:25
TeletextReader::m_revealHidden
bool m_revealHidden
Definition: teletextreader.h:135
TeletextReader::SetPageChanged
void SetPageChanged(bool changed)
Definition: teletextreader.h:88
TeletextReader::m_curpageShowHeader
bool m_curpageShowHeader
Definition: teletextreader.h:131
dir
QDir dir
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1174
kTTColorCyan
@ kTTColorCyan
Definition: teletextreader.h:22
TeletextReader::m_pageinput
std::array< int, 3 > m_pageinput
Definition: teletextreader.h:133
TeletextReader::FindSubPage
TeletextSubPage * FindSubPage(void)
Definition: teletextreader.h:96
TeletextSubPage::pagenum
int pagenum
the wanted page
Definition: teletextreader.h:41
TeletextReader::Reset
void Reset(void)
Definition: teletextreader.cpp:267
TeletextSubPage::active
bool active
data has arrived since page last cleared
Definition: teletextreader.h:49
TeletextSubPage::subpagenum
int subpagenum
the wanted subpage
Definition: teletextreader.h:42
TeletextReader::AddPageHeader
void AddPageHeader(int page, int subpage, const uint8_t *buf, int vbimode, int lang, int flags)
Definition: teletextreader.cpp:300
kTTColorBlue
@ kTTColorBlue
Definition: teletextreader.h:20
TeletextReader::SetSubPage
void SetSubPage(int subpage)
Definition: teletextreader.h:86
TeletextReader::FindPage
TeletextPage * FindPage(int page, int dir=0)
Definition: teletextreader.h:123
TeletextReader::FindSubPageInternal
const TeletextSubPage * FindSubPageInternal(int page, int subpage, int direction) const
Definition: teletextreader.cpp:575
TeletextReader::FindPage
const TeletextPage * FindPage(int page, int dir=0) const
Definition: teletextreader.h:120
TTColor
TTColor
Definition: teletextreader.h:15
TeletextMagazine
Definition: teletextreader.h:64
TeletextReader::TeletextReader
TeletextReader()
Definition: teletextreader.cpp:13
TeletextReader::GetPageInput
int GetPageInput(uint num) const
Definition: teletextreader.h:95
int_to_subpage_t
std::map< int, TeletextSubPage > int_to_subpage_t
Definition: teletextreader.h:52
TeletextReader::GetHeader
tt_line_array GetHeader(void)
Definition: teletextreader.h:98
TeletextPage
Definition: teletextreader.h:55
TeletextSubPage::data
std::array< tt_line_array, 25 > data
page data
Definition: teletextreader.h:45