MythTV  master
srtwriter.cpp
Go to the documentation of this file.
1 #include "captions/srtwriter.h"
2 
3 // SRTWriter implementation
4 
8 void SRTWriter::AddSubtitle(const OneSubtitle &sub, int number)
9 {
10  m_outStream << number << endl;
11 
12  m_outStream << FormatTime(sub.m_startTime) << " --> ";
13  m_outStream << FormatTime(sub.m_startTime + sub.m_length) << endl;
14 
15  if (!sub.m_text.isEmpty())
16  {
17  for (const auto & text : qAsConst(sub.m_text))
18  m_outStream << text << endl;
19  m_outStream << endl;
20  }
21 }
22 
26 QString SRTWriter::FormatTime(uint64_t time_in_msec)
27 {
28  QTime time = QTime::fromMSecsSinceStartOfDay(time_in_msec);
29  return time.toString("HH:mm:ss,zzz");
30 }
QTextStream m_outStream
Output stream associated with m_outFile.
Definition: srtwriter.h:61
int64_t m_startTime
Time we have to start showing subtitle, msec.
int m_length
Time we have to show subtitle, msec.
QStringList m_text
Lines of text of subtitles.
void AddSubtitle(const OneSubtitle &sub, int number)
Adds next subtitle.
Definition: srtwriter.cpp:8
static QString FormatTime(uint64_t time_in_msec)
Formats time to format appropriate to SubRip file.
Definition: srtwriter.cpp:26
Represents one subtitle record.