MythTV  master
mythccextractorplayer.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 
3 #ifndef MYTHCCEXTRACTORPLAYER_H
4 #define MYTHCCEXTRACTORPLAYER_H
5 
6 #include <cstdint>
7 
8 #include <QStringList>
9 #include <QImage>
10 #include <QPoint>
11 #include <QHash>
12 #include <QDir>
13 
14 #include "mythplayer.h"
15 
16 class SRTWriter;
17 
19 {
24 };
25 
30 {
31  public:
33  int64_t start_time;
35  int length;
37  bool is_text;
39  QStringList text;
41  QImage img;
43  QPoint img_shift;
44 
46  start_time(),
47  length(-1),
48  is_text(true),
49  text(),
50  img_shift(0, 0)
51  {}
52 
53  static const int kDefaultLength;
54 };
55 
57 typedef QHash<int, QList<OneSubtitle> > CC608StreamType;
59 typedef QHash<int, QList<OneSubtitle> > CC708StreamType;
61 typedef QHash<int, QList<OneSubtitle> > TeletextStreamType;
63 typedef QList<OneSubtitle> DVBStreamType;
64 
65 class SRTStuff
66 {
67  public:
68  SRTStuff() = default;
69  virtual ~SRTStuff();
70  QHash<int, SRTWriter*> srtwriters;
71  QHash<int,int> subs_num;
72 };
73 
74 class CC608Stuff : public SRTStuff
75 {
76  public:
77  CC608Stuff() : reader(nullptr) { }
78  ~CC608Stuff();
81 };
82 typedef QHash<uint, CC608Stuff> CC608Info;
83 
84 class CC708Stuff : public SRTStuff
85 {
86  public:
87  CC708Stuff() : reader(nullptr) { }
88  ~CC708Stuff();
91 };
92 typedef QHash<uint, CC708Stuff> CC708Info;
93 
95 class TeletextStuff : public SRTStuff
96 {
97  public:
98  TeletextStuff() : reader(nullptr) { }
102 };
103 typedef QHash<uint, TeletextStuff> TeletextInfo;
104 
106 {
107  public:
108  DVBSubStuff() : reader(nullptr), subs_num(0) { }
109  ~DVBSubStuff();
111  int subs_num;
113 };
114 typedef QHash<uint, DVBSubStuff> DVBSubInfo;
115 
116 typedef QHash<uint, SubtitleReader*> SubtitleReaders;
117 
119 {
120  public:
121  MythCCExtractorPlayer(PlayerFlags flags, bool showProgress,
122  const QString &fileName, const QString & destdir);
124  ~MythCCExtractorPlayer() = default;
125 
126  bool run(void);
127 
128  CC708Reader *GetCC708Reader(uint id=0) override; // MythPlayer
129  CC608Reader *GetCC608Reader(uint id=0) override; // MythPlayer
130  SubtitleReader *GetSubReader(uint id=0) override; // MythPlayer
131  TeletextReader *GetTeletextReader(uint id=0) override; // MythPlayer
132 
133  private:
134  void IngestSubtitle(QList<OneSubtitle>&, const QStringList&);
135  void IngestSubtitle(QList<OneSubtitle>&, const OneSubtitle&);
136 
137  enum { kProcessNormal = 0, kProcessFinalize = 1 };
138  void Ingest608Captions(void);
139  void Process608Captions(uint flags);
140 
141  void Ingest708Captions(void);
142  void Ingest708Caption(uint streamId, uint serviceIdx, uint windowIdx,
143  uint start_row, uint start_column,
144  const CC708Window &win,
145  const vector<CC708String*> &content);
146  void Process708Captions(uint flags);
147 
148  void IngestTeletext(void);
149  void ProcessTeletext(uint flags);
150 
151  void IngestDVBSubtitles(void);
152  void ProcessDVBSubtitles(uint flags);
153 
154  void OnGotNewFrame(void);
155 
156  protected:
161 
164  class Window
165  {
166  public:
169  QStringList text;
170  };
171  typedef QHash<uint, QMap<int, Window> > WindowsOnService;
172  QHash<uint, WindowsOnService > m_cc708_windows;
173 
175  double m_curTime;
178  QString m_fileName;
180  QString m_baseName;
181 };
182 
183 #endif // MYTHCCEXTRACTORPLAYER_H
184 
185 /* vim: set expandtab tabstop=4 shiftwidth=4: */
virtual CC708Reader * GetCC708Reader(uint=0)
Definition: mythplayer.h:295
QHash< uint, CC608Stuff > CC608Info
QHash< int, QList< OneSubtitle > > CC608StreamType
Key is a CC number (1-4), values are the subtitles in chrono order.
PlayerFlags
Definition: mythplayer.h:88
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
TeletextStreamType subs
CC608Reader * reader
QHash< int, QList< OneSubtitle > > CC708StreamType
Key is a CC service (1-63), values are the subtitles in chrono order.
SubtitleReader * reader
DVBStreamType subs
QHash< uint, DVBSubStuff > DVBSubInfo
QHash< int, int > subs_num
unsigned int uint
Definition: compat.h:140
virtual TeletextReader * GetTeletextReader(uint=0)
Definition: mythplayer.h:298
QHash< int, SRTWriter * > srtwriters
Keeps cc708 windows (1-8) for all streams & services (which ids are the keys).
CC708StreamType subs
QImage img
Image of subtitle.
Class to write SubRip files.
Definition: srtwriter.h:26
QList< OneSubtitle > DVBStreamType
Subtitles in chrono order.
QHash< uint, SubtitleReader * > SubtitleReaders
#define MTV_PUBLIC
Definition: mythtvexp.h:15
bool is_text
Is this a text subtitle.
CC708Reader * reader
QPoint img_shift
Shift of image on the screen.
QHash< uint, TeletextStuff > TeletextInfo
QHash< uint, CC708Stuff > CC708Info
QHash< uint, QMap< int, Window > > WindowsOnService
int length
Time we have to show subtitle, msec.
Represents one subtitle record.
double m_curTime
Keeps track for decoding time to make timestamps for subtitles.
virtual CC608Reader * GetCC608Reader(uint=0)
Definition: mythplayer.h:296
QHash< uint, WindowsOnService > m_cc708_windows
QHash< int, QList< OneSubtitle > > TeletextStreamType
Key is a page number, values are the subtitles in chrono order.
TeletextExtractorReader * reader
QStringList text
Lines of text of subtitles.
static const int kDefaultLength
int64_t start_time
Time we have to start showing subtitle, msec.
SRTStuff()=default
CC608StreamType subs
virtual SubtitleReader * GetSubReader(uint=0)
Definition: mythplayer.h:297