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 
10 #include <QtXml/QDomDocument>
11 #include <QtXml/QDomElement>
12 
13 #include "avformatdecoder.h"
14 #include "mythplayer.h"
16 #include "format.h"
17 
18 #include "mythccextractorplayer.h"
19 
20 class OneSubtitle;
21 
27 {
28  public:
29  SRTWriter(const QString &fileName) :
30  m_outFile(fileName), m_outStream(&m_outFile)
31  {
32  m_outStream.setCodec("UTF-8");
33  if (!m_outFile.open(QFile::WriteOnly))
34  {
35  LOG(VB_GENERAL, LOG_ERR, QString("Failed to create '%1'")
36  .arg(fileName));
37  }
38  else
39  {
40  LOG(VB_GENERAL, LOG_DEBUG, QString("Created '%1'")
41  .arg(fileName));
42  }
43  }
44  ~SRTWriter(void)
45  {
46  m_outFile.close();
47  }
48 
49  void AddSubtitle(const OneSubtitle &sub, int number);
50 
51  bool IsOpen(void) { return m_outFile.isOpen(); }
52  void Flush(void) { m_outStream.flush(); }
53 
54  private:
56  static QString FormatTime(uint64_t time_in_msec);
58  QFile m_outFile;
60  QTextStream m_outStream;
61 };
62 
63 #endif /* SRTWRITER_H_ */
~SRTWriter(void)
Definition: srtwriter.h:44
QTextStream m_outStream
Output stream associated with m_outFile.
Definition: srtwriter.h:60
Class to write SubRip files.
Definition: srtwriter.h:26
#define MTV_PUBLIC
Definition: mythtvexp.h:15
SRTWriter(const QString &fileName)
Definition: srtwriter.h:29
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
Represents one subtitle record.
QFile m_outFile
Output file.
Definition: srtwriter.h:58
bool IsOpen(void)
Definition: srtwriter.h:51
void Flush(void)
Definition: srtwriter.h:52