forked from gongjianbo/MyTestCode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVoicePrintSource.cpp
152 lines (137 loc) · 3.52 KB
/
VoicePrintSource.cpp
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include "VoicePrintSource.h"
#include <QDebug>
VoicePrintSource::VoicePrintSource(QObject *parent)
: LocalNode(parent)
{
}
void VoicePrintSource::appendFile(const QStringList &filelist)
{
qDebug()<<"append file"<<filelist;
}
void VoicePrintSource::editFile(const QString &filepath)
{
qDebug()<<"edit file"<<filepath;
}
void VoicePrintSource::removeFile(const QStringList &filelist)
{
qDebug()<<"remove file"<<filelist;
}
void VoicePrintSource::requestExtractProgress()
{
qDebug()<<"request extract progress";
}
void VoicePrintSource::compareRun(const QStringList &materials, const QStringList &samples, int algorithm)
{
qDebug()<<"compare run"<<materials<<samples<<algorithm;
}
void VoicePrintSource::clusterRun(const QStringList &filelist, int taskId)
{
qDebug()<<"clister run"<<filelist<<taskId;
}
void VoicePrintSource::updateExtractProgress(int extract, int unextract)
{
QByteArray data;
QDataStream stream(&data, QIODevice::ReadWrite);
stream<<extract<<unextract;
sendData(LMEType::Feature, LMEFeature::ExtractProgress, data);
}
void VoicePrintSource::updateCompareProgress(int progress)
{
QByteArray data;
QDataStream stream(&data, QIODevice::ReadWrite);
stream<<progress;
sendData(LMEType::Compare, LMETask::Progress, data);
}
void VoicePrintSource::compareResult(bool result)
{
QByteArray data;
QDataStream stream(&data, QIODevice::ReadWrite);
stream<<result;
sendData(LMEType::Compare, LMETask::Response, data);
}
void VoicePrintSource::updateClusterProgress(int progress)
{
QByteArray data;
QDataStream stream(&data, QIODevice::ReadWrite);
stream<<progress;
sendData(LMEType::Cluster, LMETask::Progress, data);
}
void VoicePrintSource::clusterResult(bool result)
{
QByteArray data;
QDataStream stream(&data, QIODevice::ReadWrite);
stream<<result;
sendData(LMEType::Cluster, LMETask::Response, data);
}
void VoicePrintSource::netDisconnected()
{
emit errorChanged();
qDebug()<<"voice print socket disconnected.";
}
void VoicePrintSource::recvData(quint8 major, quint8 minor, const QByteArray &data)
{
QDataStream stream(data);
switch(major) {
case LMEType::Feature: //特征提取
{
switch (minor) {
case LMEFeature::AppendFile:
{
QStringList filelist;
stream>>filelist;
appendFile(filelist);
}
break;
case LMEFeature::EditFile:
{
QString filepath;
stream>>filepath;
editFile(filepath);
}
break;
case LMEFeature::RemoveFile:
{
QStringList filelist;
stream>>filelist;
removeFile(filelist);
}
break;
case LMEFeature::RequestProgress:
{
requestExtractProgress();
}
break;
}
}
break;
case LMEType::Compare: //比对
{
switch (minor) {
case LMETask::Request:
{
QStringList materials;
QStringList samples;
int algorithm;
stream>>materials>>samples>>algorithm;
compareRun(materials,samples,algorithm);
}
break;
}
}
break;
case LMEType::Cluster: //聚类
{
switch (minor) {
case LMETask::Request:
{
QStringList filelist;
int taskId;
stream>>filelist>>taskId;
clusterRun(filelist,taskId);
}
break;
}
}
break;
}
}