MythTV  master
subtitlereader.h
Go to the documentation of this file.
1 #ifndef SUBTITLEREADER_H
2 #define SUBTITLEREADER_H
3 
4 #include <QMutex>
5 
6 extern "C" {
7 #include "libavcodec/avcodec.h"
8 }
9 
10 #include "libmythbase/mythchrono.h"
11 #include "libmythbase/mythdeque.h"
12 #include "textsubtitleparser.h"
13 
14 class MythPlayer;
15 
17 {
18  public:
19  AVSubtitles() = default;
21  QMutex m_lock;
22  bool m_fixPosition {false};
23 };
24 
26 {
27  public:
28  RawTextSubs(void) = default;
29 
30  QStringList m_buffers;
31  std::chrono::milliseconds m_duration {0ms};
32  QMutex m_lock;
33 };
34 
35 class SubtitleReader : public QObject
36 {
37  Q_OBJECT
38 
39  signals:
40  void TextSubtitlesUpdated();
41 
42  public:
43  SubtitleReader(MythPlayer *parent);
44  ~SubtitleReader() override;
45 
46  void EnableAVSubtitles(bool enable);
47  void EnableTextSubtitles(bool enable);
48  void EnableRawTextSubtitles(bool enable);
49 
51  bool AddAVSubtitle(AVSubtitle& subtitle, bool fix_position,
52  bool allow_forced);
53  void ClearAVSubtitles(bool force = false);
54  static void FreeAVSubtitle(AVSubtitle &sub);
55 
57  bool HasTextSubtitles(void);
58  void LoadExternalSubtitles(const QString &subtitleFileName, bool isInProgress);
59 
60  QStringList GetRawTextSubtitles(std::chrono::milliseconds &duration);
61  void AddRawTextSubtitle(const QStringList& list, std::chrono::milliseconds duration);
62  void ClearRawTextSubtitles(void);
63 
64  private:
65  MythPlayer *m_parent {nullptr};
66 
68  bool m_avSubtitlesEnabled {false};
70  bool m_textSubtitlesEnabled {false};
73 
75 };
76 
77 #endif // SUBTITLEREADER_H
TextSubtitleParser
Definition: textsubtitleparser.h:90
SubtitleReader::TextSubtitlesUpdated
void TextSubtitlesUpdated()
textsubtitleparser.h
SubtitleReader::m_parent
MythPlayer * m_parent
Definition: subtitlereader.h:65
SubtitleReader::SubtitleReader
SubtitleReader(MythPlayer *parent)
Definition: subtitlereader.cpp:8
SubtitleReader::m_textSubtitles
TextSubtitles m_textSubtitles
Definition: subtitlereader.h:69
SubtitleReader
Definition: subtitlereader.h:35
SubtitleReader::AddAVSubtitle
bool AddAVSubtitle(AVSubtitle &subtitle, bool fix_position, bool allow_forced)
Definition: subtitlereader.cpp:36
MythPlayer
Definition: mythplayer.h:84
SubtitleReader::EnableAVSubtitles
void EnableAVSubtitles(bool enable)
Definition: subtitlereader.cpp:21
force
bool force
Definition: mythcommflag.cpp:70
mythdeque.h
RawTextSubs::m_duration
std::chrono::milliseconds m_duration
Definition: subtitlereader.h:31
SubtitleReader::ClearAVSubtitles
void ClearAVSubtitles(bool force=false)
Definition: subtitlereader.cpp:92
SubtitleReader::LoadExternalSubtitles
void LoadExternalSubtitles(const QString &subtitleFileName, bool isInProgress)
Definition: subtitlereader.cpp:113
SubtitleReader::EnableTextSubtitles
void EnableTextSubtitles(bool enable)
Definition: subtitlereader.cpp:26
SubtitleReader::~SubtitleReader
~SubtitleReader() override
Definition: subtitlereader.cpp:15
AVSubtitles
Definition: subtitlereader.h:16
SubtitleReader::ClearRawTextSubtitles
void ClearRawTextSubtitles(void)
Definition: subtitlereader.cpp:152
TextSubtitles
Definition: textsubtitleparser.h:41
SubtitleReader::FreeAVSubtitle
static void FreeAVSubtitle(AVSubtitle &sub)
Definition: subtitlereader.cpp:108
RawTextSubs::m_lock
QMutex m_lock
Definition: subtitlereader.h:32
SubtitleReader::m_rawTextSubtitles
RawTextSubs m_rawTextSubtitles
Definition: subtitlereader.h:71
SubtitleReader::EnableRawTextSubtitles
void EnableRawTextSubtitles(bool enable)
Definition: subtitlereader.cpp:31
SubtitleReader::GetRawTextSubtitles
QStringList GetRawTextSubtitles(std::chrono::milliseconds &duration)
Definition: subtitlereader.cpp:129
SubtitleReader::GetAVSubtitles
AVSubtitles * GetAVSubtitles(void)
Definition: subtitlereader.h:50
RawTextSubs::RawTextSubs
RawTextSubs(void)=default
SubtitleReader::m_rawTextSubtitlesEnabled
bool m_rawTextSubtitlesEnabled
Definition: subtitlereader.h:72
SubtitleReader::m_avSubtitlesEnabled
bool m_avSubtitlesEnabled
Definition: subtitlereader.h:68
AVSubtitles::m_buffers
MythDeque< AVSubtitle > m_buffers
Definition: subtitlereader.h:20
AVSubtitles::AVSubtitles
AVSubtitles()=default
SubtitleReader::m_textSubtitlesEnabled
bool m_textSubtitlesEnabled
Definition: subtitlereader.h:70
RawTextSubs::m_buffers
QStringList m_buffers
Definition: subtitlereader.h:30
MythDeque< AVSubtitle >
AVSubtitles::m_fixPosition
bool m_fixPosition
Definition: subtitlereader.h:22
SubtitleReader::GetParser
TextSubtitleParser * GetParser(void)
Definition: subtitlereader.h:56
RawTextSubs
Definition: subtitlereader.h:25
AVSubtitles::m_lock
QMutex m_lock
Definition: subtitlereader.h:21
SubtitleReader::HasTextSubtitles
bool HasTextSubtitles(void)
Definition: subtitlereader.cpp:124
mythchrono.h
SubtitleReader::AddRawTextSubtitle
void AddRawTextSubtitle(const QStringList &list, std::chrono::milliseconds duration)
Definition: subtitlereader.cpp:141
SubtitleReader::m_externalParser
TextSubtitleParser * m_externalParser
Definition: subtitlereader.h:74
SubtitleReader::m_avSubtitles
AVSubtitles m_avSubtitles
Definition: subtitlereader.h:67