00001
00002
00003 #ifndef MYTHCCEXTRACTORPLAYER_H
00004 #define MYTHCCEXTRACTORPLAYER_H
00005
00006 #include <stdint.h>
00007
00008 #include <QStringList>
00009 #include <QImage>
00010 #include <QPoint>
00011 #include <QHash>
00012
00013 #include "mythplayer.h"
00014
00015 class SRTWriter;
00016
00017 enum sub_types
00018 {
00019 kSubCC608,
00020 kSubCC708,
00021 kSubDVB,
00022 kSubTeletext,
00023 };
00024
00028 class MTV_PUBLIC OneSubtitle
00029 {
00030 public:
00032 int64_t start_time;
00034 int length;
00036 bool is_text;
00038 QStringList text;
00040 QImage img;
00042 QPoint img_shift;
00043
00044 OneSubtitle() :
00045 start_time(),
00046 length(-1),
00047 is_text(true),
00048 text(),
00049 img_shift(0, 0)
00050 {}
00051
00052 static const int kDefaultLength;
00053 };
00054
00056 typedef QHash<int, QList<OneSubtitle> > CC608StreamType;
00058 typedef QHash<int, QList<OneSubtitle> > CC708StreamType;
00060 typedef QHash<int, QList<OneSubtitle> > TeletextStreamType;
00062 typedef QList<OneSubtitle> DVBStreamType;
00063
00064 class SRTStuff
00065 {
00066 public:
00067 SRTStuff() {}
00068 virtual ~SRTStuff();
00069 QHash<int, SRTWriter*> srtwriters;
00070 QHash<int,int> subs_num;
00071 };
00072
00073 class CC608Stuff : public SRTStuff
00074 {
00075 public:
00076 CC608Stuff() : reader(NULL) { }
00077 ~CC608Stuff();
00078 CC608Reader *reader;
00079 CC608StreamType subs;
00080 };
00081 typedef QHash<uint, CC608Stuff> CC608Info;
00082
00083 class CC708Stuff : public SRTStuff
00084 {
00085 public:
00086 CC708Stuff() : reader(NULL) { }
00087 ~CC708Stuff();
00088 CC708Reader *reader;
00089 CC708StreamType subs;
00090 };
00091 typedef QHash<uint, CC708Stuff> CC708Info;
00092
00093 class TeletextExtractorReader;
00094 class TeletextStuff : public SRTStuff
00095 {
00096 public:
00097 TeletextStuff() : reader(NULL) { }
00098 ~TeletextStuff();
00099 TeletextExtractorReader *reader;
00100 TeletextStreamType subs;
00101 };
00102 typedef QHash<uint, TeletextStuff> TeletextInfo;
00103
00104 class DVBSubStuff
00105 {
00106 public:
00107 DVBSubStuff() : reader(NULL), subs_num(0) { }
00108 ~DVBSubStuff();
00109 SubtitleReader *reader;
00110 int subs_num;
00111 DVBStreamType subs;
00112 };
00113 typedef QHash<uint, DVBSubStuff> DVBSubInfo;
00114
00115 typedef QHash<uint, SubtitleReader*> SubtitleReaders;
00116
00117 class MTV_PUBLIC MythCCExtractorPlayer : public MythPlayer
00118 {
00119 public:
00120 MythCCExtractorPlayer(PlayerFlags flags, bool showProgress,
00121 const QString &fileName);
00122 ~MythCCExtractorPlayer() {}
00123
00124 bool run(void);
00125
00126 virtual CC708Reader *GetCC708Reader(uint id=0);
00127 virtual CC608Reader *GetCC608Reader(uint id=0);
00128 virtual SubtitleReader *GetSubReader(uint id=0);
00129 virtual TeletextReader *GetTeletextReader(uint id=0);
00130
00131 private:
00132 void IngestSubtitle(QList<OneSubtitle>&, const QStringList&);
00133 void IngestSubtitle(QList<OneSubtitle>&, const OneSubtitle&);
00134
00135 enum { kProcessNormal = 0, kProcessFinalize = 1 };
00136 void Ingest608Captions(void);
00137 void Process608Captions(uint flags);
00138
00139 void Ingest708Captions(void);
00140 void Ingest708Caption(uint streamId, uint serviceIdx, uint windowIdx,
00141 uint start_row, uint start_column,
00142 const CC708Window &win,
00143 const vector<CC708String*> &content);
00144 void Process708Captions(uint flags);
00145
00146 void IngestTeletext(void);
00147 void ProcessTeletext(void);
00148
00149 void IngestDVBSubtitles(void);
00150 void ProcessDVBSubtitles(uint flags);
00151
00152 void OnGotNewFrame(void);
00153
00154 protected:
00155 CC608Info m_cc608_info;
00156 CC708Info m_cc708_info;
00157 TeletextInfo m_ttx_info;
00158 DVBSubInfo m_dvbsub_info;
00159
00162 class Window
00163 {
00164 public:
00165 uint row;
00166 uint column;
00167 QStringList text;
00168 };
00169 typedef QHash<uint, QMap<int, Window> > WindowsOnService;
00170 QHash<uint, WindowsOnService > m_cc708_windows;
00171
00173 double m_curTime;
00174 uint64_t m_myFramesPlayed;
00175 bool m_showProgress;
00176 QString m_fileName;
00177 QDir m_workingDir;
00178 QString m_baseName;
00179 };
00180
00181 #endif // MYTHCCEXTRACTORPLAYER_H
00182
00183