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
16class SRTWriter;
17
18enum 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
51using CC608StreamType = QHash<int, QList<OneSubtitle> >;
53using CC708StreamType = QHash<int, QList<OneSubtitle> >;
55using TeletextStreamType = QHash<int, QList<OneSubtitle> >;
57using DVBStreamType = QList<OneSubtitle>;
58
60{
61 public:
62 SRTStuff() = default;
63 virtual ~SRTStuff();
64 QHash<int, SRTWriter*> m_srtWriters;
65 QHash<int,int> m_subsNum;
66};
67
68class CC608Stuff : public SRTStuff
69{
70 public:
71 CC608Stuff() = default;
72 ~CC608Stuff() override;
73 CC608Reader *m_reader { nullptr };
75};
76using CC608Info = QHash<uint, CC608Stuff>;
77
78class CC708Stuff : public SRTStuff
79{
80 public:
81 CC708Stuff() = default;
82 ~CC708Stuff() override;
83 CC708Reader *m_reader { nullptr };
85};
86using CC708Info = QHash<uint, CC708Stuff>;
87
89class TeletextStuff : public SRTStuff
90{
91 public:
92 TeletextStuff() = default;
93 ~TeletextStuff() override;
96};
97using TeletextInfo = QHash<uint, TeletextStuff>;
98
100{
101 public:
102 DVBSubStuff() = default;
103 ~DVBSubStuff();
105 int m_subsNum { 0 };
107};
108using DVBSubInfo = QHash<uint, DVBSubStuff>;
109
110using 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: */
~CC608Stuff() override
CC608Stuff()=default
CC608StreamType m_subs
CC608Reader * m_reader
CC708Stuff()=default
CC708StreamType m_subs
CC708Reader * m_reader
~CC708Stuff() override
SubtitleReader * m_reader
DVBStreamType m_subs
DVBSubStuff()=default
Keeps cc708 windows (1-8) for all streams & services (which ids are the keys).
QHash< uint, QMap< int, Window > > WindowsOnService
~MythCCExtractorPlayer() override=default
QHash< uint, WindowsOnService > m_cc708Windows
MythCCExtractorPlayer(const MythCCExtractorPlayer &rhs)
Represents one subtitle record.
OneSubtitle()=default
QStringList m_text
Lines of text of subtitles.
QImage m_img
Image of subtitle.
QHash< int, int > m_subsNum
QHash< int, SRTWriter * > m_srtWriters
SRTStuff()=default
Class to write SubRip files.
Definition: srtwriter.h:21
TeletextStreamType m_subs
TeletextStuff()=default
TeletextExtractorReader * m_reader
unsigned int uint
Definition: freesurround.h:24
QList< OneSubtitle > DVBStreamType
Subtitles in chrono order.
QHash< uint, TeletextStuff > TeletextInfo
@ kSubTeletext
QHash< uint, SubtitleReader * > SubtitleReaders
QHash< int, QList< OneSubtitle > > CC608StreamType
Key is a CC number (1-4), values are the subtitles in chrono order.
QHash< int, QList< OneSubtitle > > TeletextStreamType
Key is a page number, values are the subtitles in chrono order.
QHash< uint, CC708Stuff > CC708Info
QHash< uint, CC608Stuff > CC608Info
QHash< int, QList< OneSubtitle > > CC708StreamType
Key is a CC service (1-63), values are the subtitles in chrono order.
QHash< uint, DVBSubStuff > DVBSubInfo
PlayerFlags
Definition: mythplayer.h:65
#define MTV_PUBLIC
Definition: mythtvexp.h:15
void run(const QString &name, Class *object, void(Class::*fn)())
Definition: mconcurrent.h:137