MythTV  master
cc608reader.h
Go to the documentation of this file.
1 #ifndef CC608READER_H
2 #define CC608READER_H
3 
4 #include <cstdint>
5 
6 #include <QMutex>
7 
8 #include "cc608decoder.h"
9 
10 #include "mythtvexp.h"
11 
12 #define MAXTBUFFER 60
13 #define MAXOUTBUFFERS (16 + 1)
14 
15 class CC608Text
16 {
17  public:
18  CC608Text(const QString &T, int X, int Y) :
19  text(T), x(X), y(Y) {}
20  CC608Text(const CC608Text &other) :
21  text(other.text), x(other.x), y(other.y) {}
22  QString text;
23  int x;
24  int y;
25 };
26 
28 {
29  int timecode;
30  int len;
31  unsigned char *buffer;
32  char type;
33 };
34 
36 {
37  public:
38  ~CC608Buffer(void) { Clear(); }
39  void Clear(void)
40  {
41  lock.lock();
42  vector<CC608Text*>::iterator i = buffers.begin();
43  for (; i != buffers.end(); ++i)
44  {
45  CC608Text *cc = (*i);
46  if (cc)
47  delete cc;
48  }
49  buffers.clear();
50  lock.unlock();
51  }
52 
53  QMutex lock;
54  vector<CC608Text*> buffers;
55 };
56 
58 {
59  public:
60  CC608StateTracker() = default;
61 
62  void Clear(void)
63  {
64  m_outputText = "";
65  m_outputCol = 0;
66  m_outputRow = 0;
67  m_changed = true;
68  m_output.Clear();
69  }
70 
71  QString m_outputText;
72  int m_outputCol {0};
73  int m_outputRow {0};
74  bool m_changed {true};
76 };
77 
78 class MythPlayer;
79 
81 {
82  public:
83  explicit CC608Reader(MythPlayer *parent);
84  ~CC608Reader();
85 
86  void SetTTPageNum(int page) { m_ccPageNum = page; }
87  void SetEnabled(bool enable) { m_enabled = enable; }
88  void FlushTxtBuffers(void);
89  CC608Buffer *GetOutputText(bool &changed, int &streamIdx);
90  CC608Buffer* GetOutputText(bool &changed);
91  void SetMode(int mode);
92  void ClearBuffers(bool input, bool output, int outputStreamIdx = -1);
93  void AddTextData(unsigned char *buf, int len,
94  int64_t timecode, char type) override; // CC608Input
95  void TranscodeWriteText(void (*func)
96  (void *, unsigned char *, int, int, int),
97  void * ptr);
98 
99  private:
100  int Update(unsigned char *inpos);
101  void Update608Text(vector<CC608Text*> *ccbuf,
102  int replace = 0, int scroll = 0,
103  bool scroll_prsv = false,
104  int scroll_yoff = 0, int scroll_ymax = 15,
105  int streamIdx = CC_CC1);
106  int NumInputBuffers(bool need_to_lock = true);
107 
108  MythPlayer *m_parent {nullptr};
109  bool m_enabled {false};
110  // Input buffers
111  int m_readPosition {0};
112  int m_writePosition {0};
114  int m_maxTextSize {0};
115  TextContainer m_inputBuffers[MAXTBUFFER+1] {};
116  int m_ccMode {CC_CC1};
117  int m_ccPageNum {0x888};
118  // Output buffers
120 };
121 
122 #endif // CC608READER_H
Definition: cc.h:13
QMutex m_inputBufLock
Definition: cc608reader.h:113
CC608Text(const QString &T, int X, int Y)
Definition: cc608reader.h:18
vector< CC608Text * > buffers
Definition: cc608reader.h:54
virtual void AddTextData(unsigned char *buf, int len, int64_t timecode, char type)=0
void SetTTPageNum(int page)
Definition: cc608reader.h:86
QString text
Definition: cc608reader.h:22
QMutex lock
Definition: cc608reader.h:53
void clear()
CC608Buffer m_output
Definition: cc608reader.h:75
#define MTV_PUBLIC
Definition: mythtvexp.h:15
void Clear(void)
Definition: cc608reader.h:39
#define MAXOUTBUFFERS
Definition: cc608reader.h:13
#define CC_CC1
Definition: format.h:198
CC608Text(const CC608Text &other)
Definition: cc608reader.h:20
~CC608Buffer(void)
Definition: cc608reader.h:38
void Clear(void)
Definition: cc608reader.h:62
#define MAXTBUFFER
Definition: cc608reader.h:12
unsigned char * buffer
Definition: cc608reader.h:31
QString m_outputText
Definition: cc608reader.h:71
CC608StateTracker()=default
void SetEnabled(bool enable)
Definition: cc608reader.h:87
#define output