MythTV
master
libs
libmythtv
captions
srtwriter.cpp
Go to the documentation of this file.
1
#include "
captions/srtwriter.h
"
2
3
#if QT_VERSION < QT_VERSION_CHECK(5,14,0)
4
#define QT_ENDL endl
5
#else
6
#define QT_ENDL Qt::endl
7
#endif
8
9
// SRTWriter implementation
10
14
void
SRTWriter::AddSubtitle
(
const
OneSubtitle
&sub,
int
number)
15
{
16
m_outStream
<< number <<
QT_ENDL
;
17
18
m_outStream
<<
FormatTime
(sub.
m_startTime
) <<
" --> "
;
19
m_outStream
<<
FormatTime
(sub.
m_startTime
+ sub.
m_length
) <<
QT_ENDL
;
20
21
if
(!sub.
m_text
.isEmpty())
22
{
23
for
(
const
auto
& text : qAsConst(sub.
m_text
))
24
m_outStream
<< text <<
QT_ENDL
;
25
m_outStream
<<
QT_ENDL
;
26
}
27
}
28
32
QString
SRTWriter::FormatTime
(uint64_t time_in_msec)
33
{
34
QTime time = QTime::fromMSecsSinceStartOfDay(time_in_msec);
35
return
time.toString(
"HH:mm:ss,zzz"
);
36
}
OneSubtitle
Represents one subtitle record.
Definition:
mythccextractorplayer.h:29
SRTWriter::AddSubtitle
void AddSubtitle(const OneSubtitle &sub, int number)
Adds next subtitle.
Definition:
srtwriter.cpp:14
srtwriter.h
OneSubtitle::m_length
int m_length
Time we have to show subtitle, msec.
Definition:
mythccextractorplayer.h:35
SRTWriter::m_outStream
QTextStream m_outStream
Output stream associated with m_outFile.
Definition:
srtwriter.h:61
SRTWriter::FormatTime
static QString FormatTime(uint64_t time_in_msec)
Formats time to format appropriate to SubRip file.
Definition:
srtwriter.cpp:32
OneSubtitle::m_text
QStringList m_text
Lines of text of subtitles.
Definition:
mythccextractorplayer.h:39
QT_ENDL
#define QT_ENDL
Definition:
srtwriter.cpp:6
OneSubtitle::m_startTime
int64_t m_startTime
Time we have to start showing subtitle, msec.
Definition:
mythccextractorplayer.h:33
Generated on Mon Jan 18 2021 03:17:03 for MythTV by
1.8.17