MythTV  master
srtwriter.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 #ifndef SRTWRITER_H_
3 #define SRTWRITER_H_
4 
5 #include <QStringList>
6 #include <QImage>
7 #include <QPoint>
8 #include <QHash>
9 #include <QTime>
10 
11 #include <QtXml/QDomDocument>
12 #include <QtXml/QDomElement>
13 
14 #include "avformatdecoder.h"
15 #include "mythplayer.h"
17 #include "format.h"
18 
19 #include "mythccextractorplayer.h"
20 
21 class OneSubtitle;
22 
28 {
29  public:
30  explicit SRTWriter(const QString &fileName) :
31  m_outFile(fileName), m_outStream(&m_outFile)
32  {
33  m_outStream.setCodec("UTF-8");
34  if (!m_outFile.open(QFile::WriteOnly))
35  {
36  LOG(VB_GENERAL, LOG_ERR, QString("Failed to create '%1'")
37  .arg(fileName));
38  }
39  else
40  {
41  LOG(VB_GENERAL, LOG_DEBUG, QString("Created '%1'")
42  .arg(fileName));
43  }
44  }
45  ~SRTWriter(void)
46  {
47  m_outFile.close();
48  }
49 
50  void AddSubtitle(const OneSubtitle &sub, int number);
51 
52  bool IsOpen(void) { return m_outFile.isOpen(); }
53  void Flush(void) { m_outStream.flush(); }
54 
55  private:
57  static QString FormatTime(uint64_t time_in_msec);
59  QFile m_outFile;
61  QTextStream m_outStream;
62 };
63 
64 #endif /* SRTWRITER_H_ */
~SRTWriter(void)
Definition: srtwriter.h:45
QTextStream m_outStream
Output stream associated with m_outFile.
Definition: srtwriter.h:61
Class to write SubRip files.
Definition: srtwriter.h:27
#define MTV_PUBLIC
Definition: mythtvexp.h:15
SRTWriter(const QString &fileName)
Definition: srtwriter.h:30
Represents one subtitle record.
QFile m_outFile
Output file.
Definition: srtwriter.h:59
bool IsOpen(void)
Definition: srtwriter.h:52
void Flush(void)
Definition: srtwriter.h:53
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23