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:
62  {
63  }
64 
65  void Clear(void)
66  {
67  m_outputText = "";
68  m_outputCol = 0;
69  m_outputRow = 0;
70  m_changed = true;
71  m_output.Clear();
72  }
73 
74  QString m_outputText;
77  bool m_changed;
79 };
80 
81 class MythPlayer;
82 
84 {
85  public:
86  explicit CC608Reader(MythPlayer *parent);
87  ~CC608Reader();
88 
89  void SetTTPageNum(int page) { m_ccPageNum = page; }
90  void SetEnabled(bool enable) { m_enabled = enable; }
91  void FlushTxtBuffers(void);
92  CC608Buffer *GetOutputText(bool &changed, int &streamIdx);
93  CC608Buffer* GetOutputText(bool &changed);
94  void SetMode(int mode);
95  void ClearBuffers(bool input, bool output, int outputStreamIdx = -1);
96  void AddTextData(unsigned char *buf, int len,
97  int64_t timecode, char type) override; // CC608Input
98  void TranscodeWriteText(void (*func)
99  (void *, unsigned char *, int, int, int),
100  void * ptr);
101 
102  private:
103  int Update(unsigned char *inpos);
104  void Update608Text(vector<CC608Text*> *ccbuf,
105  int replace = 0, int scroll = 0,
106  bool scroll_prsv = false,
107  int scroll_yoff = 0, int scroll_ymax = 15,
108  int streamIdx = CC_CC1);
109  int NumInputBuffers(bool need_to_lock = true);
110 
112  bool m_enabled;
113  // Input buffers
118  TextContainer m_inputBuffers[MAXTBUFFER+1];
119  int m_ccMode;
121  // Output buffers
123 };
124 
125 #endif // CC608READER_H
Definition: cc.h:13
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
QMutex m_inputBufLock
Definition: cc608reader.h:116
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
int m_writePosition
Definition: cc608reader.h:115
void SetTTPageNum(int page)
Definition: cc608reader.h:89
QString text
Definition: cc608reader.h:22
QMutex lock
Definition: cc608reader.h:53
void clear()
CC608Buffer m_output
Definition: cc608reader.h:78
#define MTV_PUBLIC
Definition: mythtvexp.h:15
void Clear(void)
Definition: cc608reader.h:39
int m_readPosition
Definition: cc608reader.h:114
#define MAXOUTBUFFERS
Definition: cc608reader.h:13
int m_maxTextSize
Definition: cc608reader.h:117
#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:65
#define MAXTBUFFER
Definition: cc608reader.h:12
unsigned char * buffer
Definition: cc608reader.h:31
QString m_outputText
Definition: cc608reader.h:74
bool m_enabled
Definition: cc608reader.h:112
void SetEnabled(bool enable)
Definition: cc608reader.h:90
MythPlayer * m_parent
Definition: cc608reader.h:111
#define output