Commit b886dc375aa8a6924a2f257bcfdfa896d9704d99

Authored by Erickson Silva
1 parent a370be04
Exists in master and in 1 other branch devel

Adiciona serviço 6 (rec without mixing), corrige alguns serviços e simplifica o TradutorPortGlosa.

main.cpp
... ... @@ -25,12 +25,15 @@
25 25 using namespace std;
26 26  
27 27 void serviceSRT(char* service, char* path_video, char* path_srt, char* sublanguage, char* position, char* size, char* transparency, char* id, char* client_type);
28   -void serviceOnlySRT(char* service, char* path_file, char* transparency, char* username, char* client_type);
  28 +void serviceREC(char* service, char* path_video, char* position, char* size, char* transparency, char* id, char* client_type);
  29 +
  30 +void serviceOnlySRT(char* service, char* path_file, char* sublanguage, char* transparency, char* id, char* client_type);
  31 +void serviceOnlyAudio(char* service, char* path_audio, char* transparency, char* id, char* client_type);
  32 +void serviceRECWithoutMixing(char* service, char* path_video, char* transparency, char* id, char* client_type);
  33 +void serviceText(char* service, char* path_text, char* sublanguage, char* transparency, char* id, char* client_type);
  34 +
29 35 //void serviceREC(char* path_video, char* sublanguage, char* position, char* size, char* transparency, char* username, char* rate);
30   -void serviceREC(char* service, char* path_video, char* sublanguage, char* position, char* size, char* transparency, char* id, char* client_type);
31 36 //void serviceOnlyAudio(char* path_audio, char* transparency, char* username, char* rate);
32   -void serviceOnlyAudio(char* service, char* path_audio, char* transparency, char* id, char* client_type);
33   -void serviceText(char* service, char* path_text, char* transparency, char* id, char* client_type);
34 37  
35 38 void help();
36 39 void serviceHelp(int service);
... ... @@ -63,19 +66,19 @@ int main(int argc, char* argv[]) {
63 66 }
64 67 break;
65 68 case 2:
66   - if(argc <= 8){
  69 + if(argc <= 7){
67 70 serviceHelp(2);
68 71 hasInvalid();
69 72 }else{
70   - serviceREC(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8]);
  73 + serviceREC(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7]);
71 74 }
72 75 break;
73 76 case 3:
74   - if(argc <= 5){
  77 + if(argc <= 6){
75 78 serviceHelp(3);
76 79 hasInvalid();
77 80 }else{
78   - serviceText(argv[1], argv[2], argv[3], argv[4], argv[5]);
  81 + serviceText(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
79 82 }
80 83 break;
81 84 case 4:
... ... @@ -83,7 +86,7 @@ int main(int argc, char* argv[]) {
83 86 serviceHelp(4);
84 87 hasInvalid();
85 88 }else{
86   - serviceOnlySRT(argv[1], argv[2], argv[3], argv[4], argv[5]);
  89 + serviceOnlySRT(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
87 90 }
88 91 break;
89 92 case 5:
... ... @@ -94,6 +97,14 @@ int main(int argc, char* argv[]) {
94 97 serviceOnlyAudio(argv[1], argv[2], argv[3], argv[4], argv[5]);
95 98 }
96 99 break;
  100 + case 6:
  101 + if(argc <= 5){
  102 + serviceHelp(6);
  103 + hasInvalid();
  104 + }else{
  105 + serviceRECWithoutMixing(argv[1], argv[2], argv[3], argv[4], argv[5]);
  106 + }
  107 + break;
97 108 default:
98 109 cout << "\nFAIL VLibras: Serviço inválido! Tente --help" << endl;
99 110 hasInvalid();
... ... @@ -142,14 +153,14 @@ void serviceSRT(char* service, char* path_video, char* path_srt, char* sublangua
142 153 delete service_srt;
143 154 }
144 155  
145   -void serviceREC(char* service, char* path_video, char* sublanguage, char* position, char* size,
  156 +void serviceREC(char* service, char* path_video, char* position, char* size,
146 157 char* transparency, char* id, char* client_type){
147 158  
148 159 setPathContents(client_type);
149 160  
150 161 ServiceWindowGenerationFromRec * service_rec;
151   - service_rec = new ServiceWindowGenerationFromRec(path_video, (int) atoi(sublanguage),
152   - (int) atoi(position), (int) atoi(size), (int) atoi(transparency), id, client_type, (int) atoi(service));
  162 + service_rec = new ServiceWindowGenerationFromRec(path_video, (int) atoi(position),
  163 + (int) atoi(size), (int) atoi(transparency), id, client_type, (int) atoi(service));
153 164  
154 165 try{
155 166 service_rec->initialize();
... ... @@ -164,12 +175,21 @@ void serviceREC(char* service, char* path_video, char* sublanguage, char* positi
164 175 delete service_rec;
165 176 }
166 177  
167   -void serviceText(char* service, char* path_text, char* transparency, char* id, char* client_type){
  178 +void serviceRECWithoutMixing(char* service, char* path_video, char* transparency, char* id, char* client_type){
  179 +
  180 + char* position = new char[1];
  181 + char* size = new char[1];
  182 + strcpy(position, "0");
  183 + strcpy(size, "0");
  184 + serviceREC(service, path_video, position, size, transparency, id, client_type);
  185 +}
  186 +
  187 +void serviceText(char* service, char* path_text, char* sublanguage, char* transparency, char* id, char* client_type){
168 188  
169 189 setPathContents(client_type);
170 190  
171 191 ServiceWindowGenerationFromText *service_text;
172   - service_text = new ServiceWindowGenerationFromText(path_text, (int) atoi(transparency), id, client_type);
  192 + service_text = new ServiceWindowGenerationFromText(path_text, (int) atoi(sublanguage), (int) atoi(transparency), id, client_type);
173 193  
174 194 try{
175 195 service_text->initialize();
... ... @@ -185,12 +205,12 @@ void serviceText(char* service, char* path_text, char* transparency, char* id, c
185 205 delete service_text;
186 206 }
187 207  
188   -void serviceOnlySRT(char* service, char* path_file, char* transparency, char* id, char* client_type){
  208 +void serviceOnlySRT(char* service, char* path_file, char* sublanguage, char* transparency, char* id, char* client_type){
189 209  
190 210 setPathContents(client_type);
191 211  
192 212 ServiceWindowGenerationFromSRT * service_srt;
193   - service_srt = new ServiceWindowGenerationFromSRT(path_file, (int) atoi(transparency), id, client_type, (int) atoi(service));
  213 + service_srt = new ServiceWindowGenerationFromSRT(path_file, (int) atoi(sublanguage), (int) atoi(transparency), id, client_type, (int) atoi(service));
194 214 try{
195 215 service_srt->initialize();
196 216 }catch(ServiceException ex){
... ... @@ -203,27 +223,15 @@ void serviceOnlySRT(char* service, char* path_file, char* transparency, char* id
203 223 usleep(100000); //100ms
204 224 }
205 225 delete service_srt;
206   -
207 226 }
208 227  
209 228 void serviceOnlyAudio(char* service, char* path_audio, char* transparency, char* id, char* client_type){
210 229  
211   - setPathContents(client_type);
212   -
213   - ServiceWindowGenerationFromRec * service_rec;
214   - service_rec = new ServiceWindowGenerationFromRec(path_audio, 0, 0, 0, (int) atoi(transparency), id, client_type, (int) atoi(service));
215   -
216   - try{
217   - service_rec->initialize();
218   - }catch(ServiceException ex){
219   - fail(ex.getMessage());
220   - hasFailed();
221   - return;
222   - }
223   - while(!service_rec->isFinished()){
224   - sleep(2);
225   - }
226   - delete service_rec;
  230 + char* position = new char[1];
  231 + char* size = new char[1];
  232 + strcpy(position, "0");
  233 + strcpy(size, "0");
  234 + serviceREC(service, path_audio, position, size, transparency, id, client_type);
227 235 }
228 236  
229 237 /*void serviceREC(char* path_video, char* sublanguage,
... ... @@ -307,25 +315,29 @@ void serviceHelp(int service){
307 315 switch(service){
308 316 case 1:
309 317 cout << "\nService Type: Video with Subtitles\n"
310   - << "./vlibras INPUT_VIDEO INPUT_SRT LANGUAGE(1: Portuguese, 2:Glosa) POSITION(1: Top_Left, 2: Top_Right, 3: Bottom_Right, 4: Bottom_Left) "
  318 + << "./vlibras 1 INPUT_VIDEO INPUT_SRT LANGUAGE(1: Portuguese, 2:Glosa) POSITION(1: Top_Left, 2: Top_Right, 3: Bottom_Right, 4: Bottom_Left) "
311 319 << "SIZE(1: Small, 2: Medium, 3: Large) TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";
312 320 break;
313 321 case 2:
314 322 cout << "\nService Type: Video Recognize\n"
315   - << "./vlibras INPUT_VIDEO LANGUAGE(1: Portuguese, 2:Glosa) POSITION(1: Top_Left, 2: Top_Right, 3: Bottom_Right, 4: Bottom_Left) "
  323 + << "./vlibras 2 INPUT_VIDEO POSITION(1: Top_Left, 2: Top_Right, 3: Bottom_Right, 4: Bottom_Left) "
316 324 << "SIZE(1: Small, 2: Medium, 3: Large) TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";
317 325 break;
318 326 case 3:
319 327 cout << "\nService Type: Text\n"
320   - << "./vlibras INPUT_TEXT_FILE TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";
  328 + << "./vlibras 3 INPUT_TEXT_FILE LANGUAGE(1: Portuguese, 2:Glosa) TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";
321 329 break;
322 330 case 4:
323 331 cout << "\nService Type: Subtitles only\n"
324   - << "./vlibras INPUT_SRT TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";
  332 + << "./vlibras 4 INPUT_SRT LANGUAGE(1: Portuguese, 2:Glosa) TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";
325 333 break;
326 334 case 5:
327 335 cout << "\nService Type: Audio Recognize\n"
328   - << "./vlibras INPUT_AUDIO TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";
  336 + << "./vlibras 5 INPUT_AUDIO TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";
  337 + break;
  338 + case 6:
  339 + cout << "\nService Type: Video Recognize Without Mixing\n"
  340 + << "./vlibras 6 INPUT_VIDEO TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";
329 341 break;
330 342 }
331 343 }
... ... @@ -341,6 +353,7 @@ void help() {
341 353 << "3 Text - requires INPUT_TEXT_FILE\n"
342 354 << "4 Subtitles only (SRT) - requires INPUT_SRT\n"
343 355 << "5 Audio Recognize - requires INPUT_AUDIO\n"
  356 + << "6 Video Recognize without mixing - requires INPUT_VIDEO\n"
344 357 << "\nSERVICES PARAMETERS:\n"
345 358 << "Video with subtitles:\n"
346 359 << " [INPUT_VIDEO] [INPUT_SRT] [LANGUAGE] [POSITION] [SIZE] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"
... ...
recognize/src/recognize.cpp
... ... @@ -369,7 +369,9 @@ void Recognize::notifyListeners(char* text, int64_t pts) {
369 369 //cout << "NOTIFY: " << text << endl;
370 370  
371 371 for(list<RecognizeListener*>::iterator it = listeners->begin(); it != listeners->end(); it++){
372   - (*it)->notifyTextRecognized((unsigned char*) text, calcula_pts(pts));
  372 + //(*it)->notifyTextRecognized((unsigned char*) text, calcula_pts(pts));
  373 + (*it)->notifyTextRecognized((unsigned char*) text, pts);
  374 +
373 375 }
374 376  
375 377 }
... ...
servico/src/include/serviceWindowGenerationFromRec.h
... ... @@ -7,6 +7,7 @@
7 7  
8 8 #define SERVICE_TYPE_REC 2
9 9 #define SERVICE_TYPE_REC_ONLY_AUDIO 5
  10 +#define SERVICE_TYPE_REC_UNMIXED 6
10 11  
11 12 class ServiceWindowGenerationFromRec : public ServiceWindowGeneration, public RecognizeListener, public ListenerTradutor, public ListenerRenderer, public Thread {
12 13  
... ... @@ -19,15 +20,15 @@ private:
19 20 void setPathContents();
20 21 bool isRunning();
21 22 public:
22   - ServiceWindowGenerationFromRec(char* pathVideo, int sublanguage, int position, int size,
23   - int transparency, char* id, int serviceType, char* rate);
24   - ServiceWindowGenerationFromRec(char* pathVideo, int sublanguage, int pos, int size,
  23 + ServiceWindowGenerationFromRec(char* pathVideo, int position, int size,
  24 + int transparency, char* id, char* client, int serviceType, char* rate);
  25 + ServiceWindowGenerationFromRec(char* pathVideo, int pos, int size,
25 26 int transp, char* id, char* client, int serviceType);
26 27 ~ServiceWindowGenerationFromRec();
27 28  
28 29 void notifyTextRecognized(unsigned char* text, int64_t pts);
29 30 void notifyEndOfRenderization();
30   - void notifyTranslation(vector<string>* glosas);
  31 + void notifyTranslation(char* glosa);
31 32 void notifyTranslator(unsigned char* text);
32 33 void notifyEnd(int sentences_size);
33 34  
... ...
servico/src/include/serviceWindowGenerationFromSRT.h
... ... @@ -26,13 +26,14 @@ public:
26 26 ServiceWindowGenerationFromSRT(char* pathVideo, char* pathSRT, int sublanguage, int pos,
27 27 int size, int transp, char* id, char* client, int serviceType);
28 28 //construtor de serviço de somente legenda
29   - ServiceWindowGenerationFromSRT(char* pathSRT, int transparency, char* id, char* client, int serviceType);
  29 + ServiceWindowGenerationFromSRT(char* pathSRT, int sublanguage, int transparency, char* id, char* client, int serviceType);
30 30 ~ServiceWindowGenerationFromSRT();
31 31  
32 32 void notifySubtitle(unsigned char* subtitle, int64_t pts);
33 33 void notifyEndOfRenderization();
34   - void notifyTranslation(vector<string>* glosas);
  34 + void notifyTranslation(char* glosas);
35 35 void notifyTranslator(unsigned char* text);
  36 + void notifyRenderer(string glosa);
36 37 void notifyEnd(int sub_size);
37 38  
38 39 void initialize();
... ...
servico/src/include/serviceWindowGenerationFromText.h
... ... @@ -18,13 +18,14 @@ private:
18 18 void setPathContents();
19 19 bool isRunning();
20 20 public:
21   - ServiceWindowGenerationFromText(char* pathFile, int transparency, char* id, char* client);
  21 + ServiceWindowGenerationFromText(char* pathFile, int sublanguage, int transparency, char* id, char* client);
22 22 ~ServiceWindowGenerationFromText();
23 23  
24 24 void notifyLine(unsigned char* line);
25 25 void notifyEndOfRenderization();
26   - void notifyTranslation(vector<string>* glosas);
  26 + void notifyTranslation(char* glosa);
27 27 void notifyTranslator(unsigned char* text);
  28 + void notifyRenderer(string glosa);
28 29 void notifyEnd(int line_size);
29 30  
30 31 void initialize();
... ...
servico/src/serviceWindowGenerationFromRec.cpp
1 1 #include "serviceWindowGenerationFromRec.h"
2 2  
3 3 ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec(
4   - char* pathVideo, int sublanguage, int pos, int size, int transp, char* id, int serviceType, char* rate){
  4 + char* pathVideo, int pos, int size, int transp, char* id, char* client, int serviceType, char* rate){
5 5  
6 6 this->path_input = pathVideo;
7   - this->sub_language = sublanguage;
8 7 this->position = pos;
9 8 this->size = size;
10 9 this->transparency = transp;
11 10 this->user_id = id;
  11 + this->client_type = client;
12 12 this->service_type = serviceType;
13 13 numero_legendas = INT_MAX;
14 14 legendas_enviadas = 0;
... ... @@ -21,10 +21,9 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec(
21 21 }
22 22  
23 23 ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec(
24   - char* pathVideo, int sublanguage, int pos, int size, int transp, char* id, char* client, int serviceType){
  24 + char* pathVideo, int pos, int size, int transp, char* id, char* client, int serviceType){
25 25  
26 26 this->path_input = pathVideo;
27   - this->sub_language = sublanguage;
28 27 this->position = pos;
29 28 this->size = size;
30 29 this->transparency = transp;
... ... @@ -117,23 +116,12 @@ void ServiceWindowGenerationFromRec::notifyTextRecognized(unsigned char* text, i
117 116 notifyTranslator(text);
118 117 }
119 118  
120   -void ServiceWindowGenerationFromRec::notifyTranslation(vector<string> * glosas) {
121   - string glosa = "";
122   - int64_t pts_notificado;
123   - for (int i = 0; i < glosas->size(); i++) {
124   - locale loc;
125   - string glosa_lower = "";
126   - for (int k = 0; k < glosas->at(i).length(); k++){
127   - glosa_lower += std::tolower(glosas->at(i).at(k), loc);
128   - }
129   - glosa += glosa_lower;
130   - glosa += " ";
131   - pts_notificado = vetor_pts->front();
132   - }
  119 +void ServiceWindowGenerationFromRec::notifyTranslation(char* glosa) {
  120 + string sGlosa(reinterpret_cast<char*>(glosa));
133 121 while(renderer->isSending())
134 122 usleep(10000);
135 123 try{
136   - renderer->receiveGlosa(glosa, pts_notificado);
  124 + renderer->receiveGlosa(sGlosa, vetor_pts->front());
137 125 legendas_enviadas++;
138 126 }catch(lavidlib::RuntimeException &ex){
139 127 throw ServiceException(ex.getMessage().c_str());
... ... @@ -142,8 +130,8 @@ void ServiceWindowGenerationFromRec::notifyTranslation(vector&lt;string&gt; * glosas)
142 130 }
143 131  
144 132 void ServiceWindowGenerationFromRec::notifyEndOfRenderization() {
  133 + mixer = new Mixer();
145 134 if(this->service_type == SERVICE_TYPE_REC){
146   - mixer = new Mixer();
147 135 mixer->initialize(this->path_input, this->path_libras, this->position, this->size,
148 136 this->transparency, this->user_id, this->path_uploads, this->path_contents);
149 137 }
... ...
servico/src/serviceWindowGenerationFromSRT.cpp
... ... @@ -5,7 +5,7 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo,
5 5  
6 6 this->path_input = pathVideo;
7 7 this->path_srt = pathSRT;
8   - this-> sub_language = sublanguage;
  8 + this->sub_language = sublanguage;
9 9 this->position = pos;
10 10 this->size = size;
11 11 this->transparency = transp;
... ... @@ -15,7 +15,6 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo,
15 15 numero_legendas = INT_MAX;
16 16 legendas_enviadas = 0;
17 17 vetor_pts = new vector<int64_t >();
18   - tradutor = new TradutorPortGlosa();
19 18 extrator_factory = new ExtratorFactory();
20 19 try{
21 20 setPathContents();
... ... @@ -27,8 +26,9 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo,
27 26 DPRINTF("Done!\n");
28 27 }
29 28  
30   -ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, int transp, char* id, char* client, int serviceType) {
  29 +ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, int sublanguage, int transp, char* id, char* client, int serviceType) {
31 30 this->path_srt = pathSRT;
  31 + this->sub_language = sublanguage;
32 32 this->transparency = transp;
33 33 this->user_id = id;
34 34 this->client_type = client;
... ... @@ -36,7 +36,6 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, in
36 36 numero_legendas = INT_MAX;
37 37 legendas_enviadas = 0;
38 38 vetor_pts = new vector<int64_t >();
39   - tradutor = new TradutorPortGlosa();
40 39 extrator_factory = new ExtratorFactory();
41 40 try{
42 41 setPathContents();
... ... @@ -50,7 +49,7 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, in
50 49  
51 50 ServiceWindowGenerationFromSRT::~ServiceWindowGenerationFromSRT() {
52 51 free(vetor_pts);
53   - if (mixer) delete mixer;
  52 + if (this->mixer) delete mixer;
54 53 if (tradutor) delete tradutor;
55 54 if (renderer) delete renderer;
56 55 if (extratorSRT)delete extratorSRT;
... ... @@ -119,36 +118,34 @@ void ServiceWindowGenerationFromSRT::notifyTranslator(unsigned char* subtitle) {
119 118  
120 119 void ServiceWindowGenerationFromSRT::notifySubtitle(unsigned char *subtitle, int64_t pts){
121 120 addPTS(pts);
122   - notifyTranslator(subtitle);
123   -}
124   -
125   -void ServiceWindowGenerationFromSRT::notifyTranslation(vector<string> * glosas) {
126   - string glosa = "";
127   - int64_t pts_notificado;
128   - for (int i = 0; i < glosas->size(); i++) {
129   - locale loc;
130   - string glosa_lower = "";
131   - for (int k = 0; k < glosas->at(i).length(); k++){
132   - glosa_lower += std::tolower(glosas->at(i).at(k), loc);
133   - }
134   - glosa += glosa_lower;
135   - glosa += " ";
136   - pts_notificado = vetor_pts->front();
137   - }
  121 + if (sub_language == 1)
  122 + notifyTranslator(subtitle);
  123 + else{
  124 + string glosa(reinterpret_cast<char*>(subtitle));
  125 + notifyRenderer(glosa);
  126 + }
  127 +}
  128 +
  129 +void ServiceWindowGenerationFromSRT::notifyTranslation(char* glosa) {
  130 + string sGlosa(glosa);
  131 + notifyRenderer(sGlosa);
  132 +}
  133 +
  134 +void ServiceWindowGenerationFromSRT::notifyRenderer(string glosa) {
138 135 while(renderer->isSending())
139 136 usleep(10000);
140 137 try{
141   - renderer->receiveGlosa(glosa, pts_notificado);
  138 + renderer->receiveGlosa(glosa, vetor_pts->front());
142 139 legendas_enviadas++;
143 140 }catch(lavidlib::RuntimeException &ex){
144 141 throw ServiceException(ex.getMessage().c_str());
145 142 }
146   - vetor_pts->erase(vetor_pts->begin());
  143 + vetor_pts->erase(vetor_pts->begin());
147 144 }
148 145  
149 146 void ServiceWindowGenerationFromSRT::notifyEndOfRenderization() {
  147 + mixer = new Mixer();
150 148 if(this->service_type == SERVICE_TYPE_SRT){
151   - mixer = new Mixer();
152 149 mixer->initialize(this->path_input, this->path_libras, this->position, this->size,
153 150 this->transparency, this->user_id, this->path_uploads, this->path_contents);
154 151 }
... ... @@ -175,11 +172,14 @@ void ServiceWindowGenerationFromSRT::initialize() {
175 172 extratorSRT->addListener(this);
176 173 extratorSRT->setFilePath(path_srt);
177 174  
178   - tradutor->addListener(this);
  175 + tradutor = new TradutorPortGlosa();
  176 + if (this->sub_language == 1) {
  177 + tradutor->addListener(this);
  178 + }
179 179  
180 180 renderer = new Renderer(this->path_libras ,this->user_id);
181 181 renderer->addListener(this);
182   -
  182 +
183 183 try{
184 184 renderer->Start();
185 185 extratorSRT->initialize();
... ...
servico/src/serviceWindowGenerationFromText.cpp
1 1 #include "serviceWindowGenerationFromText.h"
2 2  
3   -ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile, int transp, char* id, char* client) {
  3 +ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile, int sublanguage, int transp, char* id, char* client) {
4 4 this->path_input = pathFile;
5 5 this->transparency = transp;
  6 + this->sub_language = sublanguage;
6 7 this->user_id = id;
7 8 client_type = client;
8 9 running = true;
9 10 finish = false;
10 11 numero_legendas = INT_MAX;
11 12 legendas_enviadas = 0;
12   - tradutor = new TradutorPortGlosa();
13 13 extrator_factory = new ExtratorFactory();
14 14 try{
15 15 setPathContents();
... ... @@ -72,24 +72,23 @@ void ServiceWindowGenerationFromText::notifyTranslator(unsigned char* text) {
72 72 tradutor->traduz(text);
73 73 }
74 74  
75   -void ServiceWindowGenerationFromText::notifyLine(unsigned char* line) {
76   - notifyTranslator(line);
  75 +void ServiceWindowGenerationFromText::notifyLine(unsigned char* line){
  76 + if (sub_language == 1)
  77 + notifyTranslator(line);
  78 + else{
  79 + string glosa(reinterpret_cast<char*>(line));
  80 + notifyRenderer(glosa);
  81 + }
77 82 }
78 83  
79   -void ServiceWindowGenerationFromText::notifyTranslation(vector<string> * glosas) {
80   - string glosa = "";
81   - for (int i = 0; i < glosas->size(); i++) {
82   - locale loc;
83   - string glosa_lower = "";
84   - for (int k = 0; k < glosas->at(i).length(); k++){
85   - glosa_lower += std::tolower(glosas->at(i).at(k), loc);
86   - }
87   - glosa += glosa_lower;
88   - glosa += " ";
89   - }
90   - while(renderer->isSending()){ // aguarda o renderizador processar a glosa anterior
  84 +void ServiceWindowGenerationFromText::notifyTranslation(char* glosa) {
  85 + string sGlosa(glosa);
  86 + notifyRenderer(sGlosa);
  87 +}
  88 +
  89 +void ServiceWindowGenerationFromText::notifyRenderer(string glosa) {
  90 + while(renderer->isSending())
91 91 usleep(10000);
92   - }
93 92 try{
94 93 renderer->receiveGlosa(glosa, (int64_t) -1);
95 94 legendas_enviadas++;
... ... @@ -122,7 +121,10 @@ void ServiceWindowGenerationFromText::initialize() {
122 121 extratorTXT->addListener(this);
123 122 extratorTXT->setFilePath(path_input);
124 123  
125   - tradutor->addListener(this);
  124 + tradutor = new TradutorPortGlosa();
  125 + if (this->sub_language == 1) {
  126 + tradutor->addListener(this);
  127 + }
126 128  
127 129 renderer = new Renderer(this->path_libras, this->user_id);
128 130 renderer->addListener(this);
... ...
tradutor/src/include/listenerTradutor.h
... ... @@ -18,7 +18,7 @@ namespace Tradutor {
18 18 //virtual ~OuvinteTradutor();
19 19  
20 20 // Metodo que vai ser chamado quando chegar a traducao
21   - virtual void notifyTranslation(std::vector<std::string> * glosas) = 0;
  21 + virtual void notifyTranslation(char* glosa) = 0;
22 22 };
23 23  
24 24 }
... ...
tradutor/src/include/tradutorPortGlosa.h
... ... @@ -31,8 +31,7 @@ namespace Tradutor {
31 31 public:
32 32 TradutorPortGlosa();
33 33 virtual ~TradutorPortGlosa();
34   - std::vector<std::string> * portuguesToGlosaVector(const char * input);
35   - std::vector<std::string> * portuguesToGlosaVectorSplit(char * pGlosa);
  34 + char* portuguesToGlosaVector(const char * input);
36 35  
37 36 // Adiciona
38 37 void addListener(ListenerTradutor * listener);
... ... @@ -45,7 +44,7 @@ namespace Tradutor {
45 44  
46 45  
47 46 private:
48   - void notifyListeners(std::vector<std::string> * traducao);
  47 + void notifyListeners(char* traducao);
49 48  
50 49 std::list<ListenerTradutor*> * listeners;
51 50 PyTradutor * pyTradutor;
... ...
tradutor/src/tradutorPortGlosa.cpp
... ... @@ -48,7 +48,7 @@ namespace Tradutor {
48 48 }
49 49  
50 50  
51   - void TradutorPortGlosa::notifyListeners(vector<string> * traducao) {
  51 + void TradutorPortGlosa::notifyListeners(char* traducao) {
52 52 for (list<ListenerTradutor*>::iterator i = listeners->begin() ; i != listeners->end() ; i++){
53 53 (*i)->notifyTranslation(traducao);
54 54 }
... ... @@ -73,10 +73,8 @@ namespace Tradutor {
73 73  
74 74 void TradutorPortGlosa::traduz(unsigned char * texto) {
75 75  
76   - vector<string> * vGlosa = portuguesToGlosaVector((const char *)texto);
77   - if (vGlosa->size() > 0)
78   - notifyListeners(vGlosa);
79   - free(vGlosa);
  76 + char* glosa = portuguesToGlosaVector((const char *)texto);
  77 + notifyListeners(glosa);
80 78 }
81 79  
82 80  
... ... @@ -87,42 +85,10 @@ namespace Tradutor {
87 85 * @param input texto de entrada
88 86 * @return vetor de string contendo os tokens em glosa traduzidos.
89 87 **/
90   - vector<string> * TradutorPortGlosa::portuguesToGlosaVector(const char * input) {
91   - char * sGlosa;
92   - vector<string> * vGlosa;
  88 + char* TradutorPortGlosa::portuguesToGlosaVector(const char * input) {
  89 + char * glosa;
93 90 // Faz a tradução de portugues para glosa
94   - sGlosa = pyTradutor->convertStringToGlosa(input);
95   - // Cria vetor de string contendo os tokens da glosa já traduzidos
96   - vGlosa = portuguesToGlosaVectorSplit(sGlosa);
97   - return vGlosa;
98   - }
99   -
100   - /**
101   - * Faz split de uma string (char * sGlosa) para um vector<string> contendo os
102   - * tokens da glosa
103   - *
104   - * @param sGlosa string de glosa
105   - * @return vetor de string contendo os tokens em glosa.
106   - **/
107   - vector<string> * TradutorPortGlosa::portuguesToGlosaVectorSplit(char * sGlosa) {
108   -
109   - //printf("[INFO] Glosa: %s\n", sGlosa);
110   -
111   - vector<string> * vGlosa = new vector<string>();
112   - string str(reinterpret_cast<char*>(sGlosa));
113   -
114   - int cutAt;
115   - while((cutAt = str.find_first_of(" ")) != str.npos){
116   - if(cutAt > 0){
117   - vGlosa->push_back(str.substr(0,cutAt));
118   - }
119   - str = str.substr(cutAt+1);
120   - }
121   -
122   - if(str.length() > 0) {
123   - vGlosa->push_back(str);
124   - }
125   -
126   - return vGlosa;
  91 + glosa = pyTradutor->convertStringToGlosa(input);
  92 + return glosa;
127 93 }
128 94 }
... ...