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.

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