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(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 { 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: */
MythPlayer::GetTeletextReader
virtual TeletextReader * GetTeletextReader(uint=0)
Definition: mythplayer.h:220
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
kSubDVB
@ kSubDVB
Definition: mythccextractorplayer.h:22
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
Context
QHash< QString, Action * > Context
Definition: action.h:77
SubtitleReader
Definition: subtitlereader.h:33
mythplayer.h
MythPlayer::GetCC708Reader
virtual CC708Reader * GetCC708Reader(uint=0)
Definition: mythplayer.h:217
PlayerFlags
PlayerFlags
Definition: mythplayer.h:79
DVBSubStuff::~DVBSubStuff
~DVBSubStuff()
Definition: mythccextractorplayer.cpp:49
MythPlayer
Definition: mythplayer.h:100
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:30
MythCCExtractorPlayer::m_cc708Info
CC708Info m_cc708Info
Definition: mythccextractorplayer.h:152
SRTStuff::~SRTStuff
virtual ~SRTStuff()
Definition: mythccextractorplayer.cpp:38
MythCCExtractorPlayer
Definition: mythccextractorplayer.h:113
MythCCExtractorPlayer::m_curTime
double m_curTime
Keeps track for decoding time to make timestamps for subtitles.
Definition: mythccextractorplayer.h:169
kSubCC608
@ kSubCC608
Definition: mythccextractorplayer.h:20
TeletextStuff::TeletextStuff
TeletextStuff()=default
MythCCExtractorPlayer::~MythCCExtractorPlayer
~MythCCExtractorPlayer() override=default
TeletextReader
Definition: teletextreader.h:76
CC608Stuff
Definition: mythccextractorplayer.h:69
MythCCExtractorPlayer::m_baseName
QString m_baseName
Definition: mythccextractorplayer.h:174
TeletextStuff
Definition: mythccextractorplayer.h:90
MythCCExtractorPlayer::Window
Keeps cc708 windows (1-8) for all streams & services (which ids are the keys).
Definition: mythccextractorplayer.h:159
DVBStreamType
QList< OneSubtitle > DVBStreamType
Subtitles in chrono order.
Definition: mythccextractorplayer.h:57
CC608Stuff::~CC608Stuff
~CC608Stuff() override
Definition: mythccextractorplayer.cpp:46
SRTWriter
Class to write SubRip files.
Definition: srtwriter.h:28
SRTStuff
Definition: mythccextractorplayer.h:60
SubtitleReaders
QHash< uint, SubtitleReader * > SubtitleReaders
Definition: mythccextractorplayer.h:110
MythPlayer::GetCC608Reader
virtual CC608Reader * GetCC608Reader(uint=0)
Definition: mythplayer.h:218
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
MythCCExtractorPlayer::m_fileName
QString m_fileName
Definition: mythccextractorplayer.h:172
MythCCExtractorPlayer::MythCCExtractorPlayer
MythCCExtractorPlayer(const MythCCExtractorPlayer &rhs)
DVBSubStuff
Definition: mythccextractorplayer.h:100
sub_types
sub_types
Definition: mythccextractorplayer.h:19
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
uint
unsigned int uint
Definition: compat.h:140
CC608Info
QHash< uint, CC608Stuff > CC608Info
Definition: mythccextractorplayer.h:76
TeletextExtractorReader
Definition: teletextextractorreader.h:17
DVBSubStuff::m_subsNum
int m_subsNum
Definition: mythccextractorplayer.h:105
MythPlayer::GetSubReader
virtual SubtitleReader * GetSubReader(uint=0)
Definition: mythplayer.h:219
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_showProgress
bool m_showProgress
Definition: mythccextractorplayer.h:171
MythCCExtractorPlayer::m_ttxInfo
TeletextInfo m_ttxInfo
Definition: mythccextractorplayer.h:153
CC608Stuff::m_reader
CC608Reader * m_reader
Definition: mythccextractorplayer.h:73
kSubTeletext
@ kSubTeletext
Definition: mythccextractorplayer.h:23
TeletextStuff::~TeletextStuff
~TeletextStuff() override
Definition: mythccextractorplayer.cpp:48
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:79
CC708Info
QHash< uint, CC708Stuff > CC708Info
Definition: mythccextractorplayer.h:86
OneSubtitle::kDefaultLength
static const int kDefaultLength
Definition: mythccextractorplayer.h:47
PlayerContext
Definition: playercontext.h:49
SRTStuff::SRTStuff
SRTStuff()=default
CC608Stuff::CC608Stuff
CC608Stuff()=default
MythCCExtractorPlayer::Window::text
QStringList text
Definition: mythccextractorplayer.h:163
CC708Stuff::CC708Stuff
CC708Stuff()=default
MythCCExtractorPlayer::m_myFramesPlayed
uint64_t m_myFramesPlayed
Definition: mythccextractorplayer.h:170
kSubCC708
@ kSubCC708
Definition: mythccextractorplayer.h:21
MythCCExtractorPlayer::m_cc708Windows
QHash< uint, WindowsOnService > m_cc708Windows
Definition: mythccextractorplayer.h:166
CC708Reader
Definition: cc708reader.h:17
CC608Reader
Definition: cc608reader.h:78
CC708Stuff::~CC708Stuff
~CC708Stuff() override
Definition: mythccextractorplayer.cpp:47
OneSubtitle::OneSubtitle
OneSubtitle()=default
DVBSubStuff::DVBSubStuff
DVBSubStuff()=default