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 m_startTime { 0 };
35  int m_length { -1 };
37  bool m_isText { true };
39  QStringList m_text;
41  QImage m_img;
43  QPoint m_imgShift { 0,0 };
44 
45  OneSubtitle() = default;
46 
47  static const int kDefaultLength;
48 };
49 
51 using CC608StreamType = QHash<int, QList<OneSubtitle> >;
53 using CC708StreamType = QHash<int, QList<OneSubtitle> >;
55 using TeletextStreamType = QHash<int, QList<OneSubtitle> >;
57 using DVBStreamType = QList<OneSubtitle>;
58 
59 class SRTStuff
60 {
61  public:
62  SRTStuff() = default;
63  virtual ~SRTStuff();
64  QHash<int, SRTWriter*> m_srtWriters;
65  QHash<int,int> m_subsNum;
66 };
67 
68 class CC608Stuff : public SRTStuff
69 {
70  public:
71  CC608Stuff() = default;
72  ~CC608Stuff() override;
73  CC608Reader *m_reader { nullptr };
75 };
76 using CC608Info = QHash<uint, CC608Stuff>;
77 
78 class CC708Stuff : public SRTStuff
79 {
80  public:
81  CC708Stuff() = default;
82  ~CC708Stuff() override;
83  CC708Reader *m_reader { nullptr };
85 };
86 using CC708Info = QHash<uint, CC708Stuff>;
87 
89 class TeletextStuff : public SRTStuff
90 {
91  public:
92  TeletextStuff() = default;
93  ~TeletextStuff() override;
96 };
97 using TeletextInfo = QHash<uint, TeletextStuff>;
98 
100 {
101  public:
102  DVBSubStuff() = default;
103  ~DVBSubStuff();
104  SubtitleReader *m_reader { nullptr };
105  int m_subsNum { 0 };
107 };
108 using DVBSubInfo = QHash<uint, DVBSubStuff>;
109 
110 using SubtitleReaders = QHash<uint, SubtitleReader*>;
111 
113 {
114  public:
115  MythCCExtractorPlayer(PlayerFlags flags, bool showProgress,
116  QString fileName, const QString & destdir);
118  ~MythCCExtractorPlayer() override = default;
119 
120  bool run(void);
121 
122  CC708Reader *GetCC708Reader(uint id=0) override; // MythPlayer
123  CC608Reader *GetCC608Reader(uint id=0) override; // MythPlayer
124  SubtitleReader *GetSubReader(uint id=0) override; // MythPlayer
125  TeletextReader *GetTeletextReader(uint id=0) override; // MythPlayer
126 
127  private:
128  void IngestSubtitle(QList<OneSubtitle> &list, const QStringList &content);
129  static void IngestSubtitle(QList<OneSubtitle> &list, const OneSubtitle &content);
130 
131  enum { kProcessNormal = 0, kProcessFinalize = 1 };
132  void Ingest608Captions(void);
133  void Process608Captions(uint flags);
134 
135  void Ingest708Captions(void);
136  void Ingest708Caption(uint streamId, uint serviceIdx, uint windowIdx,
137  uint start_row, uint start_column,
138  const CC708Window &win,
139  const vector<CC708String*> &content);
140  void Process708Captions(uint flags);
141 
142  void IngestTeletext(void);
143  void ProcessTeletext(uint flags);
144 
145  void IngestDVBSubtitles(void);
146  void ProcessDVBSubtitles(uint flags);
147 
148  void OnGotNewFrame(void);
149 
150  protected:
155 
158  class Window
159  {
160  public:
161  uint row {0};
162  uint column {0};
163  QStringList text;
164  };
165  using WindowsOnService = QHash<uint, QMap<int, Window> >;
166  QHash<uint, WindowsOnService > m_cc708Windows;
167 
169  double m_curTime;
172  QString m_fileName;
174  QString m_baseName;
175 };
176 
177 #endif // MYTHCCEXTRACTORPLAYER_H
178 
179 /* vim: set expandtab tabstop=4 shiftwidth=4: */
virtual CC708Reader * GetCC708Reader(uint=0)
Definition: mythplayer.h:325
QHash< uint, WindowsOnService > m_cc708Windows
CC608Reader * m_reader
DVBStreamType m_subs
PlayerFlags
Definition: mythplayer.h:86
QHash< int, int > m_subsNum
QHash< uint, DVBSubStuff > DVBSubInfo
QHash< uint, CC608Stuff > CC608Info
CC708Stuff()=default
virtual TeletextReader * GetTeletextReader(uint=0)
Definition: mythplayer.h:328
CC608Stuff()=default
QStringList m_text
Lines of text of subtitles.
~CC708Stuff() override
Keeps cc708 windows (1-8) for all streams & services (which ids are the keys).
QHash< uint, CC708Stuff > CC708Info
Class to write SubRip files.
Definition: srtwriter.h:26
QHash< uint, QMap< int, Window > > WindowsOnService
QHash< int, QList< OneSubtitle > > CC608StreamType
Key is a CC number (1-4), values are the subtitles in chrono order.
#define MTV_PUBLIC
Definition: mythtvexp.h:15
QHash< uint, SubtitleReader * > SubtitleReaders
unsigned int uint
Definition: compat.h:140
TeletextExtractorReader * m_reader
CC708Reader * m_reader
CC708StreamType m_subs
SubtitleReader * m_reader
QHash< int, QList< OneSubtitle > > CC708StreamType
Key is a CC service (1-63), values are the subtitles in chrono order.
CC608StreamType m_subs
Represents one subtitle record.
TeletextStreamType m_subs
QHash< int, SRTWriter * > m_srtWriters
QImage m_img
Image of subtitle.
~CC608Stuff() override
QList< OneSubtitle > DVBStreamType
Subtitles in chrono order.
double m_curTime
Keeps track for decoding time to make timestamps for subtitles.
QHash< int, QList< OneSubtitle > > TeletextStreamType
Key is a page number, values are the subtitles in chrono order.
virtual CC608Reader * GetCC608Reader(uint=0)
Definition: mythplayer.h:326
TeletextStuff()=default
QHash< uint, TeletextStuff > TeletextInfo
DVBSubStuff()=default
static const int kDefaultLength
SRTStuff()=default
virtual SubtitleReader * GetSubReader(uint=0)
Definition: mythplayer.h:327