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
14enum TTColor : std::uint8_t
15{
25};
26
27static constexpr uint8_t TP_SUPPRESS_HEADER { 0x01 };
28static constexpr uint8_t TP_UPDATE_INDICATOR { 0x02 };
29static constexpr uint8_t TP_INTERRUPTED_SEQ { 0x04 };
30static constexpr uint8_t TP_INHIBIT_DISPLAY { 0x08 };
31static constexpr uint8_t TP_MAGAZINE_SERIAL { 0x10 };
32static constexpr uint8_t TP_ERASE_PAGE { 0x20 };
33static constexpr uint8_t TP_NEWSFLASH { 0x40 };
34static constexpr uint8_t TP_SUBTITLE { 0x80 };
35
36using tt_line_array = std::array<uint8_t,40>;
37
39{
40 public:
41 int pagenum;
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
52using int_to_subpage_t = std::map<int, TeletextSubPage>;
53
55{
56 public:
57 int pagenum {0};
60};
61using 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};
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]; }
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};
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};
143};
144
145#endif // TELETEXTREADER_H
TeletextMagazine()=default
TeletextSubPage loadingpage
int_to_page_t pages
int_to_subpage_t subpages
TeletextSubPage * FindSubPage(int page, int subpage, int dir=0)
void SetShowHeader(bool show)
virtual ~TeletextReader()=default
bool IsSubtitle(void) const
bool RevealHidden(void) const
std::array< uint8_t, 256 > m_bitswap
void SetHeaderChanged(bool changed)
void AddTeletextData(int magazine, int row, const uint8_t *buf, int vbimode)
virtual void HeaderUpdated(int page, int subpage, tt_line_array &page_ptr, int lang)
void AddPageHeader(int page, int subpage, const uint8_t *buf, int vbimode, int lang, int flags)
const TeletextPage * FindPage(int page, int dir=0) const
virtual void PageUpdated(int page, int subpage)
std::array< TeletextMagazine, 8 > m_magazines
TeletextSubPage * FindSubPage(void)
TeletextPage * FindPage(int page, int dir=0)
void SetPage(int page, int subpage)
tt_line_array GetHeader(void)
const TeletextSubPage * FindSubPage(int page, int subpage, int dir=0) const
void SetSubPage(int subpage)
bool PageChanged(void) const
bool KeyPress(const QString &Key, bool &Exit)
int GetPageInput(uint num) const
tt_line_array m_header
QString GetPage(void)
void SetIsSubtitle(bool sub)
const TeletextSubPage * FindSubPageInternal(int page, int subpage, int direction) const
const TeletextPage * FindPageInternal(int page, int direction) const
std::array< int, 3 > m_pageinput
void SetPageChanged(bool changed)
bool IsTransparent(void) const
int subpagenum
the wanted subpage
int flags
misc flags
int pagenum
the wanted page
int lang
language code
int flof
page has FastText links
std::array< int, 6 > floflink
FastText links (FLOF)
bool active
data has arrived since page last cleared
bool subtitle
page is subtitle page
std::array< tt_line_array, 25 > data
page data
unsigned int uint
Definition: freesurround.h:24
static void show(uint8_t *buf, int length)
Definition: ringbuffer.cpp:341
static constexpr uint8_t TP_INHIBIT_DISPLAY
TTColor
@ kTTColorRed
@ kTTColorWhite
@ kTTColorGreen
@ kTTColorYellow
@ kTTColorMagenta
@ kTTColorBlue
@ kTTColorTransparent
@ kTTColorBlack
@ kTTColorCyan
static constexpr uint8_t TP_NEWSFLASH
static constexpr uint8_t TP_SUBTITLE
static constexpr uint8_t TP_ERASE_PAGE
std::array< uint8_t, 40 > tt_line_array
static constexpr uint8_t TP_INTERRUPTED_SEQ
static constexpr uint8_t TP_MAGAZINE_SERIAL
std::map< int, TeletextPage > int_to_page_t
std::map< int, TeletextSubPage > int_to_subpage_t
static constexpr uint8_t TP_SUPPRESS_HEADER
static constexpr uint8_t TP_UPDATE_INDICATOR
vbimode
Definition: vbilut.h:22