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 
18 enum sub_types : std::uint8_t
19 {
24 };
25 
30 {
31  public:
33  std::chrono::milliseconds m_startTime { 0 };
35  std::chrono::milliseconds m_length { -1ms };
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 constexpr std::chrono::milliseconds kDefaultLength { 750ms };
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(PlayerContext* Context, 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) const;
129  static void IngestSubtitle(QList<OneSubtitle> &list, const OneSubtitle &content);
130 
131  enum : std::uint8_t { 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 std::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  std::chrono::milliseconds m_curTime {0ms};
170  uint64_t m_myFramesPlayed {0};
171  bool m_showProgress {false};
172  QString m_fileName;
174  QString m_baseName;
175 };
176 
177 #endif // MYTHCCEXTRACTORPLAYER_H
178 
179 /* vim: set expandtab tabstop=4 shiftwidth=4: */
MythPlayer::GetTeletextReader
virtual TeletextReader * GetTeletextReader(uint=0)
Definition: mythplayer.h:197
CC708Stuff::m_reader
CC708Reader * m_reader
Definition: mythccextractorplayer.h:83
CC608Stuff::m_subs
CC608StreamType m_subs
Definition: mythccextractorplayer.h:74
TeletextStuff::m_reader
TeletextExtractorReader * m_reader
Definition: mythccextractorplayer.h:94
CC708Stuff::m_subs
CC708StreamType m_subs
Definition: mythccextractorplayer.h:84
TeletextStuff::m_subs
TeletextStreamType m_subs
Definition: mythccextractorplayer.h:95
DVBSubStuff::m_subs
DVBStreamType m_subs
Definition: mythccextractorplayer.h:106
MythCCExtractorPlayer::m_cc608Info
CC608Info m_cc608Info
Definition: mythccextractorplayer.h:151
MythCCExtractorPlayer::WindowsOnService
QHash< uint, QMap< int, Window > > WindowsOnService
Definition: mythccextractorplayer.h:165
CC708Window
Definition: cc708window.h:194
build_compdb.content
content
Definition: build_compdb.py:38
SRTStuff::m_subsNum
QHash< int, int > m_subsNum
Definition: mythccextractorplayer.h:65
SubtitleReader
Definition: subtitlereader.h:42
mythplayer.h
MythPlayer::GetCC708Reader
virtual CC708Reader * GetCC708Reader(uint=0)
Definition: mythplayer.h:194
kSubDVB
@ kSubDVB
Definition: mythccextractorplayer.h:22
PlayerFlags
PlayerFlags
Definition: mythplayer.h:64
DVBSubStuff::~DVBSubStuff
~DVBSubStuff()
Definition: mythccextractorplayer.cpp:48
MythPlayer
Definition: mythplayer.h:83
TeletextStreamType
QHash< int, QList< OneSubtitle > > TeletextStreamType
Key is a page number, values are the subtitles in chrono order.
Definition: mythccextractorplayer.h:55
OneSubtitle
Represents one subtitle record.
Definition: mythccextractorplayer.h:29
MythCCExtractorPlayer::m_cc708Info
CC708Info m_cc708Info
Definition: mythccextractorplayer.h:152
SRTStuff::~SRTStuff
virtual ~SRTStuff()
Definition: mythccextractorplayer.cpp:37
MythCCExtractorPlayer
Definition: mythccextractorplayer.h:112
TeletextStuff::TeletextStuff
TeletextStuff()=default
TeletextReader
Definition: teletextreader.h:75
CC608Stuff
Definition: mythccextractorplayer.h:68
MythCCExtractorPlayer::m_baseName
QString m_baseName
Definition: mythccextractorplayer.h:174
TeletextStuff
Definition: mythccextractorplayer.h:89
MythCCExtractorPlayer::Window
Keeps cc708 windows (1-8) for all streams & services (which ids are the keys).
Definition: mythccextractorplayer.h:158
DVBStreamType
QList< OneSubtitle > DVBStreamType
Subtitles in chrono order.
Definition: mythccextractorplayer.h:57
CC608Stuff::~CC608Stuff
~CC608Stuff() override
Definition: mythccextractorplayer.cpp:45
SRTWriter
Class to write SubRip files.
Definition: srtwriter.h:30
SRTStuff
Definition: mythccextractorplayer.h:59
SubtitleReaders
QHash< uint, SubtitleReader * > SubtitleReaders
Definition: mythccextractorplayer.h:110
MythPlayer::GetCC608Reader
virtual CC608Reader * GetCC608Reader(uint=0)
Definition: mythplayer.h:195
CC708StreamType
QHash< int, QList< OneSubtitle > > CC708StreamType
Key is a CC service (1-63), values are the subtitles in chrono order.
Definition: mythccextractorplayer.h:53
MythCCExtractorPlayer::m_dvbsubInfo
DVBSubInfo m_dvbsubInfo
Definition: mythccextractorplayer.h:154
kSubTeletext
@ kSubTeletext
Definition: mythccextractorplayer.h:23
MythCCExtractorPlayer::m_fileName
QString m_fileName
Definition: mythccextractorplayer.h:172
DVBSubStuff
Definition: mythccextractorplayer.h:99
MConcurrent::run
void run(const QString &name, Class *object, void(Class::*fn)())
Definition: mconcurrent.h:137
kSubCC708
@ kSubCC708
Definition: mythccextractorplayer.h:21
CC608StreamType
QHash< int, QList< OneSubtitle > > CC608StreamType
Key is a CC number (1-4), values are the subtitles in chrono order.
Definition: mythccextractorplayer.h:51
OneSubtitle::m_text
QStringList m_text
Lines of text of subtitles.
Definition: mythccextractorplayer.h:39
TeletextInfo
QHash< uint, TeletextStuff > TeletextInfo
Definition: mythccextractorplayer.h:97
DVBSubInfo
QHash< uint, DVBSubStuff > DVBSubInfo
Definition: mythccextractorplayer.h:108
CC608Info
QHash< uint, CC608Stuff > CC608Info
Definition: mythccextractorplayer.h:76
TeletextExtractorReader
Definition: teletextextractorreader.h:16
DVBSubStuff::m_subsNum
int m_subsNum
Definition: mythccextractorplayer.h:105
MythPlayer::GetSubReader
virtual SubtitleReader * GetSubReader(uint=0)
Definition: mythplayer.h:196
OneSubtitle::m_img
QImage m_img
Image of subtitle.
Definition: mythccextractorplayer.h:41
MythCCExtractorPlayer::m_workingDir
QDir m_workingDir
Definition: mythccextractorplayer.h:173
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
MythCCExtractorPlayer::m_ttxInfo
TeletextInfo m_ttxInfo
Definition: mythccextractorplayer.h:153
kSubCC608
@ kSubCC608
Definition: mythccextractorplayer.h:20
CC608Stuff::m_reader
CC608Reader * m_reader
Definition: mythccextractorplayer.h:73
TeletextStuff::~TeletextStuff
~TeletextStuff() override
Definition: mythccextractorplayer.cpp:47
DVBSubStuff::m_reader
SubtitleReader * m_reader
Definition: mythccextractorplayer.h:104
SRTStuff::m_srtWriters
QHash< int, SRTWriter * > m_srtWriters
Definition: mythccextractorplayer.h:64
CC708Stuff
Definition: mythccextractorplayer.h:78
CC708Info
QHash< uint, CC708Stuff > CC708Info
Definition: mythccextractorplayer.h:86
PlayerContext
Definition: playercontext.h:49
sub_types
sub_types
Definition: mythccextractorplayer.h:18
SRTStuff::SRTStuff
SRTStuff()=default
CC608Stuff::CC608Stuff
CC608Stuff()=default
MythCCExtractorPlayer::Window::text
QStringList text
Definition: mythccextractorplayer.h:163
CC708Stuff::CC708Stuff
CC708Stuff()=default
MythCCExtractorPlayer::m_cc708Windows
QHash< uint, WindowsOnService > m_cc708Windows
Definition: mythccextractorplayer.h:166
CC708Reader
Definition: cc708reader.h:16
CC608Reader
Definition: cc608reader.h:78
CC708Stuff::~CC708Stuff
~CC708Stuff() override
Definition: mythccextractorplayer.cpp:46
DVBSubStuff::DVBSubStuff
DVBSubStuff()=default
uint
unsigned int uint
Definition: freesurround.h:24