VideoFrame.cpp
1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <QJsonArray>
#include <QDebug>
#include "VideoFrame.h"
VideoFrame::VideoFrame(Segment *parentSegment)
: Segment(parentSegment)
{
}
VideoFrame::VideoFrame(int id, qint64 position, Segment *parentSegment, Segment::Source source, const QString &sub)
: Segment(position, parentSegment, source),
m_id(id),
m_sub(sub)
{
m_speaker = new QVector<QString>(3);
}
VideoFrame::~VideoFrame()
{
}
void VideoFrame::read(const QJsonObject &json)
{
m_id = json["id"].toInt();
m_sub = json["sub"].toString();
m_speaker = new QVector<QString>(3);
QJsonArray spkArray = json["spk"].toArray();
for (int i(0); i < m_speaker->size(); i++) {
QString speaker = spkArray[i].toString();
while (speaker.indexOf(" ") == 0)
speaker = speaker.replace(0, 1, "");
m_speaker->replace(i, speaker);
}
Segment::read(json);
}
void VideoFrame::write(QJsonObject &json) const
{
json["id"] = m_id;
json["sub"] = m_sub;
QJsonArray spkArray;
for (int i = 0; i < m_speaker->size(); i++)
spkArray.append(m_speaker->at(i));
json["spk"] = spkArray;
Segment::write(json);
}
QString VideoFrame::display() const
{
return "Frame " + QString::number(m_id);
}
//////////////
// acessors //
//////////////
int VideoFrame::getNumber() const
{
return row() + 1;
}
QString VideoFrame::getSub() const
{
return m_sub;
}
QString VideoFrame::getSpeaker(VideoFrame::SpeakerSource source) const
{
return m_speaker->value(source);
}
///////////////
// modifiers //
///////////////
void VideoFrame::setSub(const QString &sub)
{
m_sub = sub;
}
void VideoFrame::setSpeaker(const QString &speaker, VideoFrame::SpeakerSource source)
{
m_speaker->replace(source, speaker);
}
void VideoFrame::clearSpeaker(VideoFrame::SpeakerSource source)
{
m_speaker->replace(source, "");
}