Commit 23dddcacb96326a92a256dd0181bbd08d3040941

Authored by Wesnydy Ribeiro
1 parent b5cf8f1c
Exists in master and in 1 other branch devel

Atualização (VLibras-Box)

@@ -24,7 +24,8 @@ INCLUDES= \ @@ -24,7 +24,8 @@ INCLUDES= \
24 #-I libs/jthread/include -I libs/jcommon/include -I libs/jsocket/include -Wall 24 #-I libs/jthread/include -I libs/jcommon/include -I libs/jsocket/include -Wall
25 25
26 utilObjs= \ 26 utilObjs= \
27 - logger.o 27 + logger.o \
  28 + property.o
28 29
29 tradutorObjs = \ 30 tradutorObjs = \
30 pyTradutor.o \ 31 pyTradutor.o \
@@ -16,22 +16,27 @@ @@ -16,22 +16,27 @@
16 #include "serviceWindowGenerationFromREC.h" 16 #include "serviceWindowGenerationFromREC.h"
17 #include "serviceWindowGenerationFromText.h" 17 #include "serviceWindowGenerationFromText.h"
18 #include "serviceException.h" 18 #include "serviceException.h"
  19 +#include "property.h"
19 20
20 #include <sys/time.h> 21 #include <sys/time.h>
21 #include <stdlib.h> 22 #include <stdlib.h>
22 23
  24 +#define BLOQUEANTE 1
  25 +#define NAO_BLOQUEANTE 2
  26 +#define BOTH 3
  27 +
23 using namespace std; 28 using namespace std;
24 29
25 -void serviceCC();  
26 -void serviceSRT(char* path_in, char* path_srt, char* sublanguage, char* position, char* size, char* transparency, char* username);  
27 -void serviceOnlySRT(char* path_file, char* transparency, char* username);  
28 -void serviceREC(char* path_video, char* sublanguage, char* position, char* size, char* transparency, char* username, char* rate);  
29 -void serviceREC(char* path_video, char* sublanguage, char* position, char* size, char* transparency, char* username);  
30 -void serviceOnlyAudio(char* path_audio, char* transparency, char* username, char* rate);  
31 -void serviceOnlyAudio(char* path_audio, char* transparency, char* username);  
32 -void serviceText(char* path_text, char* transparency, char* username, char* client_type); 30 +void serviceSRT(char* service, char* path_video, char* path_srt, char* sublanguage, char* position, char* size, char* transparency, char* id, char* client_type);
  31 +void serviceOnlySRT(char* service, char* path_file, char* transparency, char* username, char* client_type);
  32 +//void serviceREC(char* path_video, char* sublanguage, char* position, char* size, char* transparency, char* username, char* rate);
  33 +void serviceREC(char* service, char* path_video, char* sublanguage, char* position, char* size, char* transparency, char* id, char* client_type);
  34 +//void serviceOnlyAudio(char* path_audio, char* transparency, char* username, char* rate);
  35 +void serviceOnlyAudio(char* service, char* path_audio, char* transparency, char* id, char* client_type);
  36 +void serviceText(char* service, char* path_text, char* transparency, char* id, char* client_type);
33 37
34 void help(); 38 void help();
  39 +void serviceHelp(int service);
35 void fail(string msg); 40 void fail(string msg);
36 void hasFailed(); 41 void hasFailed();
37 void hasInvalid(); 42 void hasInvalid();
@@ -47,74 +52,98 @@ int main(int argc, char* argv[]) { @@ -47,74 +52,98 @@ int main(int argc, char* argv[]) {
47 gettimeofday(&tv1, NULL); 52 gettimeofday(&tv1, NULL);
48 t1 = (double)(tv1.tv_sec) + (double)(tv1.tv_usec)/ 1000000.00; 53 t1 = (double)(tv1.tv_sec) + (double)(tv1.tv_usec)/ 1000000.00;
49 54
  55 + /*try{
  56 + PropertyHandler* reader = new PropertyHandler();
  57 + service-type = reader->getAttributeValue("SERVICE-TYPE");
  58 + }catch(RuntimeException &ex){
  59 + return; // escrever log aki
  60 + }*/
50 61
51 - printf("\n################## VLIBRAS : LAVID ##################\n\n");  
52 - DDPRINTF("Service Type: %s\n", argv[1]); 62 + //Util::Logger::Instance()->writeInfoLog("/home/wesnydy/.vlibras-conf/service/log-vbox", "VBox OK!");
53 63
54 - switch((int) atoi(argv[1])){  
55 - case 1:  
56 - serviceCC();  
57 - hasInvalid();  
58 - break;  
59 - case 2:  
60 - if(argc <= 8){  
61 - cout << "\nParametros inválidos. Tente novamente.\nService Type SRT: ./vlibras 2 INPUT_VIDEO INPUT_SRT LANGUAGE{1=Portuguese, 2=Glosa} POSITION{1=Top Left, 2=Top Right, 3=Bottom Right, 4=Bottom Left} SIZE{1=Small, 2=Medium, 3=Large} TRANSPARENCY{0=Opaque, 1=Transparent} ID" << endl;  
62 - help();  
63 - hasInvalid(); 64 + printf("\n################## VLIBRAS : LAVID ##################\n\n");
  65 +
  66 + if(argc >= 2) {
  67 +
  68 + DDPRINTF("Service Type: %s\n", argv[1]);
  69 +
  70 + switch((int) atoi(argv[1])){
  71 +
  72 + case 1:
  73 + //printf("[INFO] Serviço em manutenção!!!\n");
  74 + //exit(0);
  75 + if(argc < 9){
  76 + serviceHelp(1);
  77 + hasInvalid();
  78 + break;
  79 + }
  80 + if(argc == 9)
  81 + serviceSRT(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], "user");
  82 + else
  83 + serviceSRT(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9]);
  84 +
64 break; 85 break;
65 - }  
66 - serviceSRT(argv[2], argv[3], argv[4], argv[5],  
67 - argv[6], argv[7], argv[8]);  
68 - break;  
69 - case 3:  
70 - if(argc <= 7){  
71 - cout << "\nParametros inválidos. Tente novamente.\nService Type REC: ./vlibras 3 INPUT_VIDEO LANGUAGE{1=Portuguese, 2=Glosa} POSITION{1=Top Left, 2=Top Right, 3=Bottom Right, 4=Bottom Left} SIZE{1=Small, 2=Medium, 3=Large} TRANSPARENCY{0=Opaque, 1=Transparent} ID" << endl;  
72 - help();  
73 - hasInvalid(); 86 + case 2:
  87 + printf("[INFO] Serviço em manutenção!!!\n");
  88 + exit(0);
  89 + if(argc < 7){
  90 + serviceHelp(2);
  91 + hasInvalid();
  92 + break;
  93 + }
  94 + if(argc == 7)
  95 + serviceREC(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], "user");
  96 + else
  97 + serviceREC(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8]);
74 break; 98 break;
75 - }  
76 - if (argc == 8)  
77 - serviceREC(argv[2], argv[3], argv[4], argv[5],  
78 - argv[6], argv[7]);  
79 - else  
80 - serviceREC(argv[2], argv[3], argv[4], argv[5],  
81 - argv[6], argv[7], argv[8]);  
82 - break;  
83 - case 4:  
84 - if(argc <= 5){  
85 - cout << "\nParametros inválidos. Tente novamente.\nService Type Text: ./vlibras 4 INPUT_TEXT_FILE TRANSPARENCY{0=Opaque, 1=Transparent} ID CLIENT_TYPE{Desktop, Web}" << endl;  
86 - help();  
87 - hasInvalid();  
88 - break;  
89 - }  
90 - serviceText(argv[2], argv[3], argv[4], argv[5]);  
91 - break;  
92 - case 5:  
93 - if(argc <= 4){  
94 - cout << "\nParametros inválidos. Tente novamente.\nService Type SRT Only: ./vlibras 5 INPUT_SRT TRANSPARENCY{0=Opaque, 1=Transparent} ID" << endl;  
95 - help();  
96 - hasInvalid(); 99 + case 3:
  100 + //printf("[INFO] Serviço em manutenção!!!\n");
  101 + //exit(0);
  102 + if(argc < 5){
  103 + serviceHelp(3);
  104 + hasInvalid();
  105 + break;
  106 + }
  107 + if(argc == 5){
  108 + serviceText(argv[1], argv[2], argv[3], argv[4], "user");
  109 + }
  110 + serviceText(argv[1], argv[2], argv[3], argv[4], argv[5]);
  111 + break;
  112 + case 4:
  113 + printf("[INFO] Serviço em manutenção!!!\n");
  114 + exit(0);
  115 + if(argc < 5){
  116 + serviceHelp(4);
  117 + hasInvalid();
  118 + break;
  119 + }
  120 + if(argc == 5 )
  121 + serviceOnlySRT(argv[1], argv[2], argv[3], argv[4], "user");
  122 + else
  123 + serviceOnlySRT(argv[1], argv[2], argv[3], argv[4], argv[5]);
  124 + break;
  125 + case 5:
  126 + printf("[INFO] Serviço em manutenção!!!\n");
  127 + exit(0);
  128 + if(argc < 5){
  129 + serviceHelp(5);
  130 + hasInvalid();
  131 + break;
  132 + }
  133 + if (argc == 5)
  134 + serviceOnlyAudio(argv[1], argv[2], argv[3], argv[4], "user");
  135 + else
  136 + serviceOnlyAudio(argv[1], argv[2], argv[3], argv[4], argv[5]);
97 break; 137 break;
98 - }  
99 - serviceOnlySRT(argv[2], argv[3], argv[4]);  
100 - break;  
101 - case 6:  
102 - if(argc <= 4){  
103 - cout << "\nParametros inválidos. Tente novamente.\nService Type REC: ./vlibras 6 INPUT_AUDIO TRANSPARENCY{0=Opaque, 1=Transparent} ID" << endl;  
104 - help();  
105 - hasInvalid(); 138 + default:
  139 + cout << "\nServiço inválido. Tente novamente." << endl;
  140 + help();
  141 + hasInvalid();
106 break; 142 break;
107 - }  
108 - if (argc == 6)  
109 - serviceOnlyAudio(argv[2], argv[3], argv[4], argv[5]);  
110 - else  
111 - serviceOnlyAudio(argv[2], argv[3], argv[4]);  
112 - break;  
113 - default:  
114 - cout << "\nServiço inválido. Tente novamente." << endl;  
115 - help();  
116 - hasInvalid();  
117 - break; 143 + }
  144 + }else{
  145 + help();
  146 + hasInvalid();
118 } 147 }
119 148
120 if(isFailed) 149 if(isFailed)
@@ -131,69 +160,33 @@ int main(int argc, char* argv[]) { @@ -131,69 +160,33 @@ int main(int argc, char* argv[]) {
131 160
132 } 161 }
133 162
134 -void serviceCC(){  
135 -  
136 - cout << "\n--> Serviço não disponível.\n" << endl;  
137 - /**  
138 - cout << "\nSERVICE CLOSED CAPTION\n" << endl;  
139 - filename = createFileToResponse((char*)argv[6]); // FIXME: [6] é transparency  
140 -  
141 - char* input_file = argv[2];  
142 - int position = (int) atoi(argv[4]);  
143 - int size = (int) atoi(argv[5]);  
144 - int transparency = (int) atoi(argv[6]); 163 +void serviceSRT(char* service, char* path_video, char* path_srt, char* sublanguage, char* position,
  164 + char* size, char* transparency, char* id, char* client_type){
145 165
146 - ServiceWindowGenerationFromCC *service;  
147 - service = new ServiceWindowGenerationFromCC(  
148 - input_file,position,size, transparency, 1);  
149 -  
150 - service->initialize();  
151 -  
152 - while(service->isRunning()){  
153 - sleep(5);  
154 - }  
155 -  
156 - char* id = (char*) argv[7];  
157 - updateRequestStatus(filename.c_str(), id, "true");  
158 - **/  
159 -}  
160 -  
161 -void serviceREC(char* path_video, char* sublanguage,  
162 - char* position, char* size, char* transparency, char* id, char* rate){  
163 -  
164 - ServiceWindowGenerationFromREC * service_rec;  
165 - service_rec = new ServiceWindowGenerationFromREC(  
166 - path_video,  
167 - (int) atoi(sublanguage),  
168 - (int) atoi(position),  
169 - (int) atoi(size),  
170 - (int) atoi(transparency),  
171 - id, 3, rate); 166 + ServiceWindowGenerationFromSRT * service_srt;
  167 + service_srt = new ServiceWindowGenerationFromSRT(path_video, path_srt, (int) atoi(sublanguage),
  168 + (int) atoi(position), (int) atoi(size), (int) atoi(transparency), id, client_type, (int) atoi(service));
172 169
173 try{ 170 try{
174 - service_rec->initialize(); 171 + service_srt->initialize();
175 }catch(ServiceException ex){ 172 }catch(ServiceException ex){
176 fail(ex.getMessage()); 173 fail(ex.getMessage());
177 hasFailed(); 174 hasFailed();
178 return; 175 return;
179 - }  
180 - while(!service_rec->isFinished()){  
181 - sleep(2); 176 + }
  177 + while(!service_srt->isFinished()){
  178 + sleep(5);
182 } 179 }
183 - delete service_rec; 180 +
  181 + delete service_srt;
184 } 182 }
185 183
186 -void serviceREC(char* path_video, char* sublanguage,  
187 - char* position, char* size, char* transparency, char* id){ 184 +void serviceREC(char* service, char* path_video, char* sublanguage, char* position, char* size,
  185 + char* transparency, char* id, char* client_type){
188 186
189 ServiceWindowGenerationFromREC * service_rec; 187 ServiceWindowGenerationFromREC * service_rec;
190 - service_rec = new ServiceWindowGenerationFromREC(  
191 - path_video,  
192 - (int) atoi(sublanguage),  
193 - (int) atoi(position),  
194 - (int) atoi(size),  
195 - (int) atoi(transparency),  
196 - id, 3); 188 + service_rec = new ServiceWindowGenerationFromREC(path_video, (int) atoi(sublanguage),
  189 + (int) atoi(position), (int) atoi(size), (int) atoi(transparency), id, client_type, (int) atoi(service));
197 190
198 try{ 191 try{
199 service_rec->initialize(); 192 service_rec->initialize();
@@ -208,73 +201,29 @@ void serviceREC(char* path_video, char* sublanguage, @@ -208,73 +201,29 @@ void serviceREC(char* path_video, char* sublanguage,
208 delete service_rec; 201 delete service_rec;
209 } 202 }
210 203
211 -void serviceSRT(char* path_in, char* path_srt, char* sublanguage,  
212 - char* position, char* size, char* transparency, char* id){ 204 +void serviceText(char* service, char* path_text, char* transparency, char* id, char* client_type){
213 205
214 -  
215 - ServiceWindowGenerationFromSRT * service_srt;  
216 - service_srt = new ServiceWindowGenerationFromSRT(  
217 - path_in, path_srt, (int) atoi(sublanguage),  
218 - (int) atoi(position), (int) atoi(size),  
219 - (int) atoi(transparency), id, 2);  
220 -  
221 - try{  
222 - service_srt->initialize();  
223 - }catch(ServiceException ex){  
224 - fail(ex.getMessage());  
225 - hasFailed();  
226 - return;  
227 - }  
228 - while(!service_srt->isFinished()){  
229 - sleep(5);  
230 - }  
231 -  
232 - delete service_srt;  
233 -  
234 -} 206 + ServiceWindowGenerationFromText *service_text;
  207 + service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), (int) atoi(service), client_type);
235 208
236 -void serviceText(char* path_text, char* transparency, char* id, char* client_type){  
237 -  
238 - if (strcmp(client_type, (char*)"WEB") == 0) {  
239 - ServiceWindowGenerationFromText *service_text;  
240 - service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, client_type);  
241 - try{  
242 - service_text->initialize();  
243 - }catch(ServiceException ex){  
244 - fail(ex.getMessage());  
245 - hasFailed();  
246 - return;  
247 - }  
248 -  
249 - while (!service_text->isFinished()) {  
250 - usleep(100000); //100ms  
251 - }  
252 - delete service_text;  
253 -  
254 - } else {  
255 -  
256 - ServiceWindowGenerationFromText *service_text;  
257 - service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, (char*)"IOS");  
258 - try{  
259 - service_text->initialize();  
260 - }catch(ServiceException ex){  
261 - fail(ex.getMessage());  
262 - hasFailed();  
263 - return;  
264 - } 209 + try{
  210 + service_text->initialize();
  211 + }catch(ServiceException ex){
  212 + fail(ex.getMessage());
  213 + hasFailed();
  214 + return;
  215 + }
265 216
266 - while (!service_text->isFinished()) {  
267 - usleep(100000); //100ms  
268 - }  
269 - delete service_text;  
270 - }  
271 - 217 + while (!service_text->isFinished()) {
  218 + usleep(100000); //100ms
  219 + }
  220 + delete service_text;
272 } 221 }
273 222
274 -void serviceOnlySRT(char* path_file, char* transparency, char* id){ 223 +void serviceOnlySRT(char* service, char* path_file, char* transparency, char* id, char* client_type){
275 224
276 ServiceWindowGenerationFromSRT * service_srt; 225 ServiceWindowGenerationFromSRT * service_srt;
277 - service_srt = new ServiceWindowGenerationFromSRT(path_file, (int) atoi(transparency), id, 5); 226 + service_srt = new ServiceWindowGenerationFromSRT(path_file, (int) atoi(transparency), id, client_type, (int) atoi(service));
278 try{ 227 try{
279 service_srt->initialize(); 228 service_srt->initialize();
280 }catch(ServiceException ex){ 229 }catch(ServiceException ex){
@@ -290,16 +239,35 @@ void serviceOnlySRT(char* path_file, char* transparency, char* id){ @@ -290,16 +239,35 @@ void serviceOnlySRT(char* path_file, char* transparency, char* id){
290 239
291 } 240 }
292 241
293 -void serviceOnlyAudio(char* path_audio, char* transparency, char* id, char* rate){ 242 +void serviceOnlyAudio(char* service, char* path_audio, char* transparency, char* id, char* client_type){
  243 +
  244 + ServiceWindowGenerationFromREC * service_rec;
  245 + service_rec = new ServiceWindowGenerationFromREC(path_audio, 0, 0, 0, (int) atoi(transparency), id, client_type, (int) atoi(service));
  246 +
  247 + try{
  248 + service_rec->initialize();
  249 + }catch(ServiceException ex){
  250 + fail(ex.getMessage());
  251 + hasFailed();
  252 + return;
  253 + }
  254 + while(!service_rec->isFinished()){
  255 + sleep(2);
  256 + }
  257 + delete service_rec;
  258 +}
  259 +
  260 +/*void serviceREC(char* path_video, char* sublanguage,
  261 + char* position, char* size, char* transparency, char* id, char* rate){
294 262
295 ServiceWindowGenerationFromREC * service_rec; 263 ServiceWindowGenerationFromREC * service_rec;
296 service_rec = new ServiceWindowGenerationFromREC( 264 service_rec = new ServiceWindowGenerationFromREC(
297 - path_audio,  
298 - 0,  
299 - 0,  
300 - 0, 265 + path_video,
  266 + (int) atoi(sublanguage),
  267 + (int) atoi(position),
  268 + (int) atoi(size),
301 (int) atoi(transparency), 269 (int) atoi(transparency),
302 - id, 6, rate); 270 + id, 2, rate);
303 271
304 try{ 272 try{
305 service_rec->initialize(); 273 service_rec->initialize();
@@ -312,9 +280,9 @@ void serviceOnlyAudio(char* path_audio, char* transparency, char* id, char* rate @@ -312,9 +280,9 @@ void serviceOnlyAudio(char* path_audio, char* transparency, char* id, char* rate
312 sleep(2); 280 sleep(2);
313 } 281 }
314 delete service_rec; 282 delete service_rec;
315 -} 283 +}*/
316 284
317 -void serviceOnlyAudio(char* path_audio, char* transparency, char* id){ 285 +/*void serviceOnlyAudio(char* path_audio, char* transparency, char* id, char* rate){
318 286
319 ServiceWindowGenerationFromREC * service_rec; 287 ServiceWindowGenerationFromREC * service_rec;
320 service_rec = new ServiceWindowGenerationFromREC( 288 service_rec = new ServiceWindowGenerationFromREC(
@@ -323,7 +291,7 @@ void serviceOnlyAudio(char* path_audio, char* transparency, char* id){ @@ -323,7 +291,7 @@ void serviceOnlyAudio(char* path_audio, char* transparency, char* id){
323 0, 291 0,
324 0, 292 0,
325 (int) atoi(transparency), 293 (int) atoi(transparency),
326 - id, 6); 294 + id, 5, rate);
327 295
328 try{ 296 try{
329 service_rec->initialize(); 297 service_rec->initialize();
@@ -336,7 +304,7 @@ void serviceOnlyAudio(char* path_audio, char* transparency, char* id){ @@ -336,7 +304,7 @@ void serviceOnlyAudio(char* path_audio, char* transparency, char* id){
336 sleep(2); 304 sleep(2);
337 } 305 }
338 delete service_rec; 306 delete service_rec;
339 -} 307 +}*/
340 308
341 void fail(string msg){ 309 void fail(string msg){
342 printf("\n"); 310 printf("\n");
@@ -352,45 +320,65 @@ void hasInvalid(){ @@ -352,45 +320,65 @@ void hasInvalid(){
352 isInvalid = true; 320 isInvalid = true;
353 } 321 }
354 322
  323 +void serviceHelp(int service){
  324 + cout << "\nParâmetros inválidos! Tente novamente.\n";
  325 + switch(service){
  326 + case 1:
  327 + cout << "\nService Type: Video with Subtitles\n"
  328 + << "./vlibras INPUT_VIDEO INPUT_SRT LANGUAGE(1: Portuguese, 2:Glosa) POSITION(1: Top_Left, 2: Top_Right, 3: Bottom_Right, 4: Bottom_Left) "
  329 + << "SIZE(1: Small, 2: Medium, 3: Large) TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";
  330 + break;
  331 + case 2:
  332 + cout << "\nService Type: Video Recognize\n"
  333 + << "./vlibras INPUT_VIDEO LANGUAGE(1: Portuguese, 2:Glosa) POSITION(1: Top_Left, 2: Top_Right, 3: Bottom_Right, 4: Bottom_Left) "
  334 + << "SIZE(1: Small, 2: Medium, 3: Large) TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";
  335 + break;
  336 + case 3:
  337 + cout << "\nService Type: Text\n"
  338 + << "./vlibras INPUT_TEXT_FILE TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";
  339 + break;
  340 + case 4:
  341 + cout << "\nService Type: Subtitles only\n"
  342 + << "./vlibras INPUT_SRT TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";
  343 + break;
  344 + case 5:
  345 + cout << "\nService Type: Audio Recognize\n"
  346 + << "./vlibras INPUT_AUDIO TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";
  347 + break;
  348 + }
  349 +}
355 350
356 //Help do programa, explicando todos os parâmetros existentes... 351 //Help do programa, explicando todos os parâmetros existentes...
357 void help() { 352 void help() {
358 - cout <<"\n##################################################################################\n"  
359 - <<"# SERVICE_TYPE: 1 - means Closed Caption - doesn't use INPUT_SRT #\n"  
360 - <<"# 2 - means With Subtitles (SRT) - requires INPUT_SRT #\n"  
361 - <<"# 3 - means Recognize - requires INPUT_VIDEO #\n"  
362 - <<"# 4 - means Text - requires INPUT_FILE_TEXT #\n"  
363 - <<"# 5 - means Subtitles ONLY (SRT) - requires INPUT_SRT #\n"  
364 - <<"# 6 - means Audio - requires INPUT_AUDIO #\n"  
365 - <<"####################################################################################\n\n"  
366 - /*<<"# INPUT_VIDEO: Path of the video file #\n"  
367 - <<"#----------------------------------------------------------------------------------#\n"  
368 - <<"# INPUT_SRT: Path of the SRT file (only for SERVICE_TYPE = 2) #\n"  
369 - <<"#----------------------------------------------------------------------------------#\n"  
370 - <<"# INPUT_FILE_TEXT: Path of the text file (doesn't use INPUT_VIDEO and INPUT_SRT) #\n"  
371 - <<"#----------------------------------------------------------------------------------#\n"  
372 - <<"# INPUT_AUDIO: Path of the audio file" #\n  
373 - <<"#----------------------------------------------------------------------------------#\n"  
374 - <<"# LANGUAGE: 1 - means Portuguese #\n"  
375 - <<"# 2 - means Glosa #\n"  
376 - <<"#----------------------------------------------------------------------------------#\n"  
377 - <<"# POSITION: 1 - means TOP_LEFT #\n"  
378 - <<"# 2 - means TOP_RIGHT #\n"  
379 - <<"# 3 - means BOTTOM_RIGHT #\n"  
380 - <<"# 4 - means BOTTOM_LEFT #\n"  
381 - <<"#----------------------------------------------------------------------------------#\n"  
382 - <<"# SIZE: 1 - means SMALL #\n"  
383 - <<"# 2 - means MEDIUM #\n"  
384 - <<"# 3 - means LARGE #\n"  
385 - <<"#----------------------------------------------------------------------------------#\n"  
386 - <<"# TRANSPARENCY: 0 - means that the Background is Opaque #\n"  
387 - <<"# 1 - means that the Background is Transparent #\n"  
388 - <<"#----------------------------------------------------------------------------------#\n"  
389 - <<"# CLIENT TYPE: DESKTOP #\n"  
390 - <<"# WEB #\n"  
391 - <<"#----------------------------------------------------------------------------------#\n"  
392 - <<"# ID: relative to the unique ID on the Database #\n"  
393 - <<"####################################################################################\n"*/;  
394 -  
395 -}  
396 353
  354 + cout << endl
  355 + << "Usage Summary: vlibras [SERVICE] [INPUT] ... [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"
  356 + << "\nSERVICE:\n"
  357 + << "1 Video with Subtitles (SRT) - requires INPUT_VIDEO and INPUT_SRT\n"
  358 + << "2 Video Recognize - requires INPUT_VIDEO\n"
  359 + << "3 Text - requires INPUT_TEXT_FILE\n"
  360 + << "4 Subtitles only (SRT) - requires INPUT_SRT\n"
  361 + << "5 Audio Recognize - requires INPUT_AUDIO\n"
  362 + << "\nSERVICES PARAMETERS:\n"
  363 + << "Video with subtitles:\n"
  364 + << " [INPUT_VIDEO] [INPUT_SRT] [LANGUAGE] [POSITION] [SIZE] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"
  365 + << "Video Recognize:\n"
  366 + << " [INPUT_VIDEO] [LANGUAGE] [POSITION] [SIZE] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"
  367 + << "Text:\n"
  368 + << " [INPUT_TEXT_FILE] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"
  369 + << "Subtitles only:\n"
  370 + << " [INPUT_SRT] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"
  371 + << "Audio Recognize\n"
  372 + << " [INPUT_AUDIO] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"
  373 + << "\nPARAMETERS:\n"
  374 + << "INPUT_VIDEO Path of the video file\n"
  375 + << "INPUT_SRT Path of the subtitle file\n"
  376 + << "INPUT_TEXT_FILE Path of the text file\n"
  377 + << "INPUT_AUDIO Path of the audio file\n"
  378 + << "LANGUAGE 1 - means Portuguese, 2 - means Glosa\n"
  379 + << "POSITION 1 - means Top_Left, 2 - means Top_Right, 3 - means Bottom_Right, 4 - means Bottom_Left\n"
  380 + << "SIZE 1 - means Small, 2 - means Medium, 3 - means Large\n"
  381 + << "TRANSPARENCY 0 - means that the background is opaque , 1 - means that the background is transparent\n"
  382 + << "ID Relative to the unique ID on the Database\n"
  383 + << "CLIENT_TYPE web - necessary only for web clients, others clients can ignore this parameter\n";
  384 +}
397 \ No newline at end of file 385 \ No newline at end of file
mixer/src/Mixer.cpp
@@ -24,10 +24,11 @@ Mixer::~Mixer() { @@ -24,10 +24,11 @@ Mixer::~Mixer() {
24 24
25 /*Faz a chamada ffmpeg no terminal.*/ 25 /*Faz a chamada ffmpeg no terminal.*/
26 26
27 -void Mixer::initialize(string mainVideo, string slVideo, int positionSecondaryVideo, int sizeSecondaryVideo, int transparency, char* _id){ 27 +void Mixer::initialize(string mainVideo, string slVideo, int positionSecondaryVideo, int sizeSecondaryVideo, int transparency, char* _id, char* client_type){
28 28
29 DDPRINTF("[AGUARDE] Mixando...\n") 29 DDPRINTF("[AGUARDE] Mixando...\n")
30 30
  31 + client = client_type;
31 stringstream ss; 32 stringstream ss;
32 ss << _id; 33 ss << _id;
33 ss >> user_id; 34 ss >> user_id;
@@ -42,7 +43,6 @@ void Mixer::initialize(string mainVideo, string slVideo, int positionSecondaryVi @@ -42,7 +43,6 @@ void Mixer::initialize(string mainVideo, string slVideo, int positionSecondaryVi
42 this->setTransparency(transparency); 43 this->setTransparency(transparency);
43 this->setPathFinal(); 44 this->setPathFinal();
44 this->mixVideos(); 45 this->mixVideos();
45 -  
46 } 46 }
47 47
48 void Mixer::mixVideos () { 48 void Mixer::mixVideos () {
@@ -146,8 +146,24 @@ void Mixer::mixVideos () { @@ -146,8 +146,24 @@ void Mixer::mixVideos () {
146 } 146 }
147 147
148 void Mixer::setPathFinal(){ 148 void Mixer::setPathFinal(){
149 - pathFinal = PATH_API;  
150 - pathFinal.append(user_id).append(".mp4"); 149 +
  150 + char* final_path = new char[256];
  151 +
  152 + if(strcmp(client, (char*)WEB_USER) == 0){
  153 + pathFinal = PATH_API;
  154 + pathFinal.append(user_id).append(".mp4");
  155 + }else{
  156 + try{
  157 + PropertyHandler* reader = new PropertyHandler("vlibras_user/.vlibras-conf/configuration/params-vbox.conf");
  158 + strcpy(final_path, reader->getAttributeValue("STORAGE"));
  159 + stringstream ss;
  160 + ss << final_path;
  161 + ss >> pathFinal;
  162 + pathFinal.append("/").append(user_id).append(".mp4");
  163 + }catch(RuntimeException &ex){
  164 + printf("%s\n", ex.getMessage().c_str());
  165 + }
  166 + }
151 } 167 }
152 168
153 /*Ajusta o FPS do vídeo principal para 45 se preciso...*/ 169 /*Ajusta o FPS do vídeo principal para 45 se preciso...*/
@@ -314,11 +330,16 @@ void Mixer::setMainVideo(string mainVideo){ @@ -314,11 +330,16 @@ void Mixer::setMainVideo(string mainVideo){
314 } 330 }
315 //ajeitar isso depois 331 //ajeitar isso depois
316 string nameOfMainVideo = mainVideo.substr(0, dotPosition); 332 string nameOfMainVideo = mainVideo.substr(0, dotPosition);
317 - this->temporaryTextFile = "vlibras_user/vlibras-api/uploads/";  
318 - temporaryTextFile.append(this->user_id).append("/tamanho.txt");  
319 - 333 + char* final_path = new char[256];
  334 +
  335 + if(strcmp(client, (char*)WEB_USER) == 0){
  336 + this->temporaryTextFile = "vlibras_user/vlibras-api/uploads/";
  337 + temporaryTextFile.append(this->user_id).append("/tamanho.txt");
  338 + }else{
  339 + this->temporaryTextFile = "vlibras_user/.vlibras-conf/contents/";
  340 + temporaryTextFile.append("tamanho.txt");
  341 + }
320 //printf("##########temporaryTextFile: %s\n", temporaryTextFile.c_str()); 342 //printf("##########temporaryTextFile: %s\n", temporaryTextFile.c_str());
321 -  
322 } 343 }
323 string Mixer::getMainVideo(){ 344 string Mixer::getMainVideo(){
324 return this->mainVideo; 345 return this->mainVideo;
mixer/src/include/Mixer.h
@@ -17,9 +17,10 @@ @@ -17,9 +17,10 @@
17 #include <string> 17 #include <string>
18 #include <fstream> 18 #include <fstream>
19 #include "dprintf.h" 19 #include "dprintf.h"
  20 +#include "property.h"
20 21
21 using namespace std; 22 using namespace std;
22 - 23 +using namespace sndesc;
23 24
24 //SL Video Position 25 //SL Video Position
25 #define TOP_LEFT 1 26 #define TOP_LEFT 1
@@ -35,9 +36,12 @@ using namespace std; @@ -35,9 +36,12 @@ using namespace std;
35 #define MEDIUM_HEIGHT 432 //0,4*1080 36 #define MEDIUM_HEIGHT 432 //0,4*1080
36 #define LARGE_HEIGHT 540 //0.5*1080 37 #define LARGE_HEIGHT 540 //0.5*1080
37 38
  39 +#define MAX_SIZE_PATH 256
  40 +#define WEB_USER "web"
38 #define PATH_API "vlibras_user/vlibras-api/videos/" 41 #define PATH_API "vlibras_user/vlibras-api/videos/"
39 42
40 using namespace std; 43 using namespace std;
  44 +using namespace sndesc;
41 45
42 class Mixer { 46 class Mixer {
43 public: 47 public:
@@ -62,7 +66,7 @@ public: @@ -62,7 +66,7 @@ public:
62 int getTransparency(); 66 int getTransparency();
63 void setNumThreads(string); 67 void setNumThreads(string);
64 string getNumThreads(); 68 string getNumThreads();
65 - void initialize(string mainVideo, string slVideo, int, int, int, char*); 69 + void initialize(string mainVideo, string slVideo, int, int, int, char*, char*);
66 void setPathFinal(); 70 void setPathFinal();
67 71
68 private: 72 private:
@@ -78,11 +82,12 @@ private: @@ -78,11 +82,12 @@ private:
78 void convertSecondaryVideoFPS(double); 82 void convertSecondaryVideoFPS(double);
79 83
80 string mainVideo, secondaryVideo, temporaryTextFile, numThreads, pathFinal, user_id; 84 string mainVideo, secondaryVideo, temporaryTextFile, numThreads, pathFinal, user_id;
  85 + char* client;
81 int positionSecondaryVideo; 86 int positionSecondaryVideo;
82 double widthSecondaryVideo, heightSecondaryVideo; 87 double widthSecondaryVideo, heightSecondaryVideo;
83 int transparency; 88 int transparency;
84 89
85 - 90 + PropertyHandler* reader;
86 91
87 }; 92 };
88 93
servico/src/include/serviceWindowGeneration.h
@@ -11,7 +11,8 @@ @@ -11,7 +11,8 @@
11 #include <limits.h> 11 #include <limits.h>
12 #include "dprintf.h" 12 #include "dprintf.h"
13 #include "Mixer.h" 13 #include "Mixer.h"
14 -#include "inputFile.h" 14 +//#include "inputFile.h"
  15 +#include "property.h"
15 #include "listenerTradutor.h" 16 #include "listenerTradutor.h"
16 #include "tradutorPortGlosa.h" 17 #include "tradutorPortGlosa.h"
17 //#include "httpstreamer.h" 18 //#include "httpstreamer.h"
@@ -20,23 +21,25 @@ @@ -20,23 +21,25 @@
20 #include "serviceException.h" 21 #include "serviceException.h"
21 #include <lavidlib/base/RuntimeException.h> 22 #include <lavidlib/base/RuntimeException.h>
22 23
  24 +#define WEB_USER "web"
23 #define VIDEO_POSE_NEUTRA "poseneutra" 25 #define VIDEO_POSE_NEUTRA "poseneutra"
24 #define BASEDIR "vlibras_user/dicionario_libras/" 26 #define BASEDIR "vlibras_user/dicionario_libras/"
25 #define BASEDIRTRANSP "vlibras_user/dicionarioTransp_libras/" 27 #define BASEDIRTRANSP "vlibras_user/dicionarioTransp_libras/"
26 #define EXTENSAO_DICIONARIO ".ts" 28 #define EXTENSAO_DICIONARIO ".ts"
  29 +#define PATH_CONTENTS "vlibras_user/.vlibras-conf/contents/"
27 #define PATH_API "vlibras_user/vlibras-api/videos/" 30 #define PATH_API "vlibras_user/vlibras-api/videos/"
28 #define MAX_SIZE_PATH 256 31 #define MAX_SIZE_PATH 256
29 32
30 -/*#define SERVICE_TYPE_CC 1 /* Closed Caption */  
31 -#define SERVICE_TYPE_SRT 2 /* Subtitle SRT */  
32 -#define SERVICE_TYPE_REC 3 /* Reconhecimento de Voz */  
33 -#define SERVICE_TYPE_TEXT 4 /* Texto */  
34 -#define SERVICE_TYPE_SRT_ONLY 5 /* Subtitle SRT ONLY */  
35 -#define SERVICE_TYPE_REC_ONLY_AUDIO 6 /* Subtitle AUDIO ONLY */ 33 +#define SERVICE_TYPE_SRT 1 /* Subtitle SRT */
  34 +#define SERVICE_TYPE_REC 2 /* Reconhecimento de Voz */
  35 +#define SERVICE_TYPE_TEXT 3 /* Texto */
  36 +#define SERVICE_TYPE_SRT_ONLY 4 /* Subtitle SRT ONLY */
  37 +#define SERVICE_TYPE_REC_ONLY_AUDIO 5 /* Subtitle AUDIO ONLY */
36 38
37 using namespace Tradutor; 39 using namespace Tradutor;
38 -using namespace Util; 40 +//using namespace Util;
39 using namespace std; 41 using namespace std;
  42 +using namespace sndesc;
40 43
41 class ServiceWindowGeneration : public ListenerTradutor, public ListenerSynchronizer{ 44 class ServiceWindowGeneration : public ListenerTradutor, public ListenerSynchronizer{
42 45
@@ -45,8 +48,9 @@ protected: @@ -45,8 +48,9 @@ protected:
45 TradutorPortGlosa * tradutor; 48 TradutorPortGlosa * tradutor;
46 //HttpStreamer *sincronizador; 49 //HttpStreamer *sincronizador;
47 Synchronizer * sincronizador; 50 Synchronizer * sincronizador;
48 - InputFile * inputfile; 51 + //InputFile * inputfile;
49 Mixer * mixer; 52 Mixer * mixer;
  53 + PropertyHandler* reader;
50 54
51 vector<int64_t> * vetor_pts; 55 vector<int64_t> * vetor_pts;
52 56
servico/src/include/serviceWindowGenerationFromREC.h
@@ -20,7 +20,7 @@ private: @@ -20,7 +20,7 @@ private:
20 public: 20 public:
21 21
22 ServiceWindowGenerationFromREC(char* path_video, int sublanguage, int position, int size, int transparency, char* id, int _serviceType, char* rate); 22 ServiceWindowGenerationFromREC(char* path_video, int sublanguage, int position, int size, int transparency, char* id, int _serviceType, char* rate);
23 - ServiceWindowGenerationFromREC(char* path_video, int sublanguage, int position, int size, int transparency, char* id, int _serviceType); 23 + ServiceWindowGenerationFromREC(char* path_video, int sublanguage, int position, int size, int transparency, char* id, char* client_type, int _serviceType);
24 ~ServiceWindowGenerationFromREC(); 24 ~ServiceWindowGenerationFromREC();
25 25
26 virtual void notifyTextRecognized(unsigned char* text, int64_t pts); 26 virtual void notifyTextRecognized(unsigned char* text, int64_t pts);
servico/src/include/serviceWindowGenerationFromSRT.h
@@ -29,9 +29,9 @@ public: @@ -29,9 +29,9 @@ public:
29 29
30 /* Construtor 1 - legenda e vídeo */ 30 /* Construtor 1 - legenda e vídeo */
31 ServiceWindowGenerationFromSRT(char* path_video, char* path_srt, int sublanguage, 31 ServiceWindowGenerationFromSRT(char* path_video, char* path_srt, int sublanguage,
32 - int position, int size, int transparency, char* id, int _serviceType); 32 + int position, int size, int transparency, char* id, char* client_type, int _serviceType);
33 /* Construtor 2 - só legenda */ 33 /* Construtor 2 - só legenda */
34 - ServiceWindowGenerationFromSRT(char* path_srt, int transparency, char* id, int _serviceType); 34 + ServiceWindowGenerationFromSRT(char* path_srt, int transparency, char* id, char* client_type, int _serviceType);
35 ~ServiceWindowGenerationFromSRT(); 35 ~ServiceWindowGenerationFromSRT();
36 36
37 virtual void notifySubtitle(unsigned char* subtitle, int64_t pts); 37 virtual void notifySubtitle(unsigned char* subtitle, int64_t pts);
servico/src/include/serviceWindowGenerationFromText.h
@@ -17,8 +17,7 @@ private: @@ -17,8 +17,7 @@ private:
17 bool finish; 17 bool finish;
18 18
19 public: 19 public:
20 - ServiceWindowGenerationFromText (char* _path_file, char* _video_path_file,  
21 - int _transp, int _serviceType, char* _client_type); 20 + ServiceWindowGenerationFromText (char* _path_file, char* user_id, int _transp, int _serviceType, char* _client_type);
22 ~ServiceWindowGenerationFromText (); 21 ~ServiceWindowGenerationFromText ();
23 22
24 void notifyLine(unsigned char* line); 23 void notifyLine(unsigned char* line);
servico/src/serviceWindowGeneration.cpp
@@ -4,6 +4,9 @@ @@ -4,6 +4,9 @@
4 ServiceWindowGeneration::ServiceWindowGeneration() { 4 ServiceWindowGeneration::ServiceWindowGeneration() {
5 tradutor = new TradutorPortGlosa(); 5 tradutor = new TradutorPortGlosa();
6 vetor_pts = new vector<int64_t >(); 6 vetor_pts = new vector<int64_t >();
  7 + try{
  8 + reader = new PropertyHandler("vlibras_user/.vlibras-conf/configuration/params-vbox.conf");
  9 + }catch(RuntimeException &ex){printf("%s\n", ex.getMessage().c_str());}
7 numero_legendas = INT_MAX; 10 numero_legendas = INT_MAX;
8 legendas_enviadas = 0; 11 legendas_enviadas = 0;
9 this->running = true; 12 this->running = true;
@@ -14,7 +17,6 @@ ServiceWindowGeneration::ServiceWindowGeneration() { @@ -14,7 +17,6 @@ ServiceWindowGeneration::ServiceWindowGeneration() {
14 ServiceWindowGeneration::~ServiceWindowGeneration() { 17 ServiceWindowGeneration::~ServiceWindowGeneration() {
15 free(vetor_pts); 18 free(vetor_pts);
16 free(path_libras); 19 free(path_libras);
17 - if (inputfile) delete inputfile;  
18 if (mixer) delete mixer; 20 if (mixer) delete mixer;
19 if (tradutor) delete tradutor; 21 if (tradutor) delete tradutor;
20 if (sincronizador) delete sincronizador; 22 if (sincronizador) delete sincronizador;
@@ -74,11 +76,18 @@ void ServiceWindowGeneration::setTransparency(int transparency){ @@ -74,11 +76,18 @@ void ServiceWindowGeneration::setTransparency(int transparency){
74 } 76 }
75 77
76 void ServiceWindowGeneration::setPathLibras() { 78 void ServiceWindowGeneration::setPathLibras() {
  79 +
77 char* final_path = new char[MAX_SIZE_PATH]; 80 char* final_path = new char[MAX_SIZE_PATH];
78 - strcpy(final_path, "vlibras_user/vlibras-api/uploads/");  
79 - strcat(final_path, this->user_id);  
80 - strcat(final_path, "/libras.ts");  
81 81
  82 + if(strcmp(client_type, (char*)WEB_USER) == 0){
  83 + strcpy(final_path, "vlibras_user/vlibras-api/uploads/");
  84 + strcat(final_path, this->user_id);
  85 + strcat(final_path, "/libras.ts");
  86 + }else{
  87 + strcpy(final_path, PATH_CONTENTS);
  88 + strcat(final_path, "libras.ts");
  89 + }
  90 +
82 this->path_libras = final_path; 91 this->path_libras = final_path;
83 //DDPRINTF("Path TS File: %s\n", this->path_libras); 92 //DDPRINTF("Path TS File: %s\n", this->path_libras);
84 } 93 }
@@ -102,7 +111,7 @@ bool ServiceWindowGeneration::isRunning() { @@ -102,7 +111,7 @@ bool ServiceWindowGeneration::isRunning() {
102 void ServiceWindowGeneration::notifyEndOfSynchronization() { 111 void ServiceWindowGeneration::notifyEndOfSynchronization() {
103 if (serviceType == SERVICE_TYPE_REC || serviceType == SERVICE_TYPE_SRT) { 112 if (serviceType == SERVICE_TYPE_REC || serviceType == SERVICE_TYPE_SRT) {
104 mixer = new Mixer(); 113 mixer = new Mixer();
105 - mixer->initialize(this->path_input, this->path_libras,this->position,this->size,this->transparency, this->user_id); 114 + mixer->initialize(this->path_input, this->path_libras,this->position,this->size,this->transparency, this->user_id, this->client_type);
106 createThumbnail(); 115 createThumbnail();
107 }else{ 116 }else{
108 transcodeVideoToMp4(); 117 transcodeVideoToMp4();
@@ -112,8 +121,12 @@ void ServiceWindowGeneration::notifyEndOfSynchronization() { @@ -112,8 +121,12 @@ void ServiceWindowGeneration::notifyEndOfSynchronization() {
112 121
113 void ServiceWindowGeneration::initialize() { 122 void ServiceWindowGeneration::initialize() {
114 123
  124 + cout << "entrei" << endl;
  125 +
115 setPathLibras(); 126 setPathLibras();
116 127
  128 + cout << "passei" << endl;
  129 +
117 if (this->sublanguage == 1) { 130 if (this->sublanguage == 1) {
118 tradutor->addListener(this); 131 tradutor->addListener(this);
119 } 132 }
@@ -204,7 +217,7 @@ void ServiceWindowGeneration::transcodeVideoToWebm() { @@ -204,7 +217,7 @@ void ServiceWindowGeneration::transcodeVideoToWebm() {
204 string command = "ffmpeg -i "; 217 string command = "ffmpeg -i ";
205 command.append(path_libras) 218 command.append(path_libras)
206 .append(" -vcodec libvpx -acodec libvorbis ") 219 .append(" -vcodec libvpx -acodec libvorbis ")
207 - .append(" -v quiet ") 220 + //.append(" -v quiet ")
208 .append(PATH_API) 221 .append(PATH_API)
209 .append(getUserId()) 222 .append(getUserId())
210 .append(".webm"); 223 .append(".webm");
@@ -213,32 +226,60 @@ void ServiceWindowGeneration::transcodeVideoToWebm() { @@ -213,32 +226,60 @@ void ServiceWindowGeneration::transcodeVideoToWebm() {
213 } 226 }
214 227
215 void ServiceWindowGeneration::transcodeVideoToMp4() { 228 void ServiceWindowGeneration::transcodeVideoToMp4() {
216 - if (serviceType == SERVICE_TYPE_TEXT && strcmp(client_type, (char*)"WEB") == 0)  
217 - transcodeVideoToWebm();  
218 - else{ 229 + //if (serviceType == SERVICE_TYPE_TEXT && strcmp(client_type, (char*)"WEB") == 0)
  230 + // transcodeVideoToWebm();
  231 + //else{
219 //printf("[INFO]: A transcodificação para .mp4 está ativada!\n"); 232 //printf("[INFO]: A transcodificação para .mp4 está ativada!\n");
220 DDDPRINTF("[AGUARDE] Transcodificando o vídeo de Libras...\n"); 233 DDDPRINTF("[AGUARDE] Transcodificando o vídeo de Libras...\n");
221 string command = "ffmpeg -i "; 234 string command = "ffmpeg -i ";
222 command.append(path_libras) 235 command.append(path_libras)
223 - .append(" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 ")  
224 - .append(" -v quiet ")  
225 - .append(PATH_API)  
226 - .append(getUserId())  
227 - .append(".mp4"); 236 + .append(" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 ");
  237 + //.append(" -v quiet ");
  238 +
  239 + if(strcmp(client_type, (char*)WEB_USER) == 0){
  240 + command.append(PATH_API).append(getUserId());
  241 +
  242 + }else{
  243 + try{
  244 + char* vPath = new char[256];
  245 + vPath = reader->getAttributeValue("STORAGE");
  246 + command.append(vPath).append("/").append(getUserId());
  247 + }catch(RuntimeException &ex){
  248 + printf("%s\n", ex.getMessage().c_str());
  249 + }
  250 + }
  251 +
  252 + command.append(".mp4");
228 //printf("[INFO]: Transcodification command -> %s\n", command.c_str()); 253 //printf("[INFO]: Transcodification command -> %s\n", command.c_str());
229 system(command.c_str()); 254 system(command.c_str());
230 255
231 //.append(" -strict experimental -vcodec mjpeg -r 30 -pix_fmt yuvj422p ") 256 //.append(" -strict experimental -vcodec mjpeg -r 30 -pix_fmt yuvj422p ")
232 //.append(" -strict experimental -vcodec mpeg2video -r 30 ") 257 //.append(" -strict experimental -vcodec mpeg2video -r 30 ")
233 - } 258 + //}
234 } 259 }
235 260
236 void ServiceWindowGeneration::createThumbnail(){ 261 void ServiceWindowGeneration::createThumbnail(){
237 string command = "ffmpeg -ss 10 -i "; 262 string command = "ffmpeg -ss 10 -i ";
238 - command.append(PATH_API).append(user_id).append(".mp4")  
239 - .append(" -vcodec png -vframes 1 -an -f rawvideo -y -vf scale=200:200 ")  
240 - .append(" -v quiet ")  
241 - .append(PATH_API).append(user_id).append(".png"); 263 + //command.append(PATH_API).append(user_id).append(".mp4")
  264 + //.append(" -vcodec png -vframes 1 -an -f rawvideo -y -vf scale=200:200 ");
  265 + //.append(" -v quiet ");
  266 +
  267 + if(strcmp(client_type, (char*)WEB_USER) == 0){
  268 + command.append(PATH_API).append(user_id).append(".mp4")
  269 + .append(" -vcodec png -vframes 1 -an -f rawvideo -y -vf scale=200:200 ")
  270 + .append(PATH_API).append(getUserId());
  271 + }else{
  272 + try{
  273 + char* pPath = new char[256];
  274 + pPath = reader->getAttributeValue("STORAGE");
  275 + command.append(pPath).append("/").append(getUserId());
  276 + }catch(RuntimeException &ex){
  277 + printf("%s\n", ex.getMessage().c_str());
  278 + }
  279 +
  280 + command.append(PATH_CONTENTS).append(user_id).append(".mp4")
  281 + .append(" -vcodec png -vframes 1 -an -f rawvideo -y -vf scale=200:200 ");
  282 + }
  283 + command.append(".png");
242 system(command.c_str()); 284 system(command.c_str());
243 -}  
244 - 285 +}
245 \ No newline at end of file 286 \ No newline at end of file
servico/src/serviceWindowGenerationFromREC.cpp
@@ -16,7 +16,7 @@ ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( @@ -16,7 +16,7 @@ ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC(
16 } 16 }
17 17
18 ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( 18 ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC(
19 - char* path_video, int sublanguage, int position, int size, int transparency, char* id, int serviceType) { 19 + char* path_video, int sublanguage, int position, int size, int transparency, char* id, char* client_type, int _serviceType) {
20 20
21 setPathInput(path_video); 21 setPathInput(path_video);
22 setSubLanguage(sublanguage); 22 setSubLanguage(sublanguage);
@@ -24,6 +24,7 @@ ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( @@ -24,6 +24,7 @@ ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC(
24 setSize(size); 24 setSize(size);
25 setTransparency(transparency); 25 setTransparency(transparency);
26 setServiceType(serviceType); 26 setServiceType(serviceType);
  27 + setClientType(client_type);
27 setUserId(id); 28 setUserId(id);
28 rec = new Recognize(path_video, id); 29 rec = new Recognize(path_video, id);
29 finish = false; 30 finish = false;
servico/src/serviceWindowGenerationFromSRT.cpp
1 #include "serviceWindowGenerationFromSRT.h" 1 #include "serviceWindowGenerationFromSRT.h"
2 2
3 3
4 -//Construtor Service 2  
5 -ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(  
6 - char* path_video, char* path_srt, int sublanguage, int position, int size, int transparency, char* id, int serviceType) { 4 +//Construtor Service 1
  5 +ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* path_video, char* path_srt, int sublanguage,
  6 + int position, int size, int transparency, char* id, char* client_type, int serviceType) {
  7 +
  8 + // cout << "video: " << path_video << endl;
  9 + // cout << "srt: " << path_srt << endl;
  10 + // cout << "language: " << sublanguage << endl;
  11 + // cout << "position: " << position << endl;
  12 + // cout << "size: " << size << endl;
  13 + // cout << "transparency: " << transparency << endl;
  14 + // cout << "id: " << id << endl;
  15 + // cout << "serviceType: " << serviceType << endl;
  16 + //cout << "client_type: " << client_type << endl;
  17 +
7 extrator_factory = new ExtratorFactory(); 18 extrator_factory = new ExtratorFactory();
8 setPathInput(path_video); 19 setPathInput(path_video);
9 setPathSRT(path_srt); 20 setPathSRT(path_srt);
  21 + setClientType(client_type);
10 setPosition(position); 22 setPosition(position);
11 setSize(size); 23 setSize(size);
12 setTransparency(transparency); 24 setTransparency(transparency);
@@ -17,10 +29,11 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT( @@ -17,10 +29,11 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(
17 DPRINTF("Done!\n"); 29 DPRINTF("Done!\n");
18 } 30 }
19 31
20 -//Construtor Service 5  
21 -ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* path_srt, int transparency, char* id, int serviceType){ 32 +//Construtor Service 4
  33 +ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* path_srt, int transparency, char* id, char* client_type, int _serviceType) {
22 extrator_factory = new ExtratorFactory(); 34 extrator_factory = new ExtratorFactory();
23 setPathInput(path_srt); 35 setPathInput(path_srt);
  36 + setClientType(client_type);
24 setTransparency(transparency); 37 setTransparency(transparency);
25 setServiceType(serviceType); 38 setServiceType(serviceType);
26 setUserId(id); 39 setUserId(id);
@@ -67,11 +80,11 @@ void ServiceWindowGenerationFromSRT::initialize() { @@ -67,11 +80,11 @@ void ServiceWindowGenerationFromSRT::initialize() {
67 80
68 //codigo abaixo sera arrumado apos a aplicação do factory pattern 81 //codigo abaixo sera arrumado apos a aplicação do factory pattern
69 82
70 - if(serviceType == 2){ 83 + if(serviceType == 1){
71 84
72 extratorSRT = (ExtratorSRT*)extrator_factory->getExtrator(SRT); 85 extratorSRT = (ExtratorSRT*)extrator_factory->getExtrator(SRT);
73 extratorSRT->addListener(this); 86 extratorSRT->addListener(this);
74 - extratorSRT->setFilePath((char*) path_srt); 87 + extratorSRT->setFilePath(path_srt);
75 88
76 ServiceWindowGeneration::initialize(); 89 ServiceWindowGeneration::initialize();
77 90
@@ -88,7 +101,7 @@ void ServiceWindowGenerationFromSRT::initialize() { @@ -88,7 +101,7 @@ void ServiceWindowGenerationFromSRT::initialize() {
88 objeto InputFile().*/ 101 objeto InputFile().*/
89 extratorSRT = (ExtratorSRT*)extrator_factory->getExtrator(SRT); 102 extratorSRT = (ExtratorSRT*)extrator_factory->getExtrator(SRT);
90 extratorSRT->addListener(this); 103 extratorSRT->addListener(this);
91 - extratorSRT->setFilePath((char*) path_input); 104 + extratorSRT->setFilePath(path_input);
92 105
93 ServiceWindowGeneration::initialize(); 106 ServiceWindowGeneration::initialize();
94 107
servico/src/serviceWindowGenerationFromText.cpp
@@ -10,7 +10,6 @@ ServiceWindowGenerationFromText::ServiceWindowGenerationFromText ( @@ -10,7 +10,6 @@ ServiceWindowGenerationFromText::ServiceWindowGenerationFromText (
10 setTransparency(transp); 10 setTransparency(transp);
11 setServiceType(serviceType); 11 setServiceType(serviceType);
12 finish = false; 12 finish = false;
13 - DPRINTF("Done!\n");  
14 } 13 }
15 14
16 ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() { 15 ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() {
util/src/include/logger.h
@@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
17 #include <stddef.h> 17 #include <stddef.h>
18 #include <iostream> 18 #include <iostream>
19 #include <ctime> 19 #include <ctime>
  20 +#include "property.h"
20 //#include <lavidlib/utils/Logger.h> 21 //#include <lavidlib/utils/Logger.h>
21 22
22 23
@@ -31,7 +32,9 @@ namespace Util { @@ -31,7 +32,9 @@ namespace Util {
31 public: 32 public:
32 static Logger* Instance(); 33 static Logger* Instance();
33 void openLogFile(); 34 void openLogFile();
34 - void writeLog(char* exception); 35 + void openInfoLogFile(char* filepath);
  36 + void writeLog(char* log);
  37 + void writeInfoLog(char* filepath ,char* infoLog);
35 void closeLogFile(); 38 void closeLogFile();
36 char* getTime(); 39 char* getTime();
37 40
util/src/include/property.h 0 → 100644
@@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
  1 +/***************************************************************************
  2 + * Universidade Federal da Paraíba *
  3 + * Copyright (C) 2013 by Laboratório de Aplicações de Vídeo Digital *
  4 + * *
  5 + * Centro de Informática - UFPB - Campus I *
  6 + * João Pessoa - PB - Brasil *
  7 + * *
  8 + * Author: Leonardo de Araújo Domingues (leonardo.araujo@lavid.ufpb.br) *
  9 + * Date: Qui Nov 28 14:05:39 BRT 2013 *
  10 + * *
  11 + **************************************************************************/
  12 +
  13 + #ifndef PROPERTY_H
  14 + #define PROPERTY_H
  15 +
  16 + #include "logger.h"
  17 + #include <stdio.h>
  18 + #include <stdlib.h>
  19 + #include <string>
  20 + #include <string.h>
  21 + #include <lavidlib/io/BufferedReader.h>
  22 + #include <lavidlib/io/FileIO.h>
  23 + #include <lavidlib/io/IOException.h>
  24 + #include <lavidlib/io/EOFException.h>
  25 + #include <lavidlib/base/RuntimeException.h>
  26 +
  27 + #define EXTENSION ".conf"
  28 +
  29 + using namespace std;
  30 + using namespace lavidlib;
  31 +
  32 + namespace sndesc {
  33 +
  34 + class PropertyHandler {
  35 + public:
  36 + PropertyHandler(string filename);
  37 + virtual ~PropertyHandler();
  38 + char* getAttributeValue(string attr);
  39 +
  40 + private:
  41 + BufferedReader* rbuffer;
  42 + FileIO* file_property;
  43 + int checkFileExtension(string &filename);
  44 +
  45 + };
  46 + }
  47 +
  48 + #endif /* PROPERTY_H */
0 \ No newline at end of file 49 \ No newline at end of file
util/src/logger.cpp
@@ -30,6 +30,9 @@ namespace Util { @@ -30,6 +30,9 @@ namespace Util {
30 file.open("vlibras_user/vlibras-core/log/log", ios_base::app); 30 file.open("vlibras_user/vlibras-core/log/log", ios_base::app);
31 } 31 }
32 32
  33 + void Logger::openInfoLogFile(char* filepath){
  34 + file.open(filepath , ios_base::trunc);
  35 + }
33 36
34 void Logger::closeLogFile(){ 37 void Logger::closeLogFile(){
35 file.close(); 38 file.close();
@@ -46,6 +49,12 @@ namespace Util { @@ -46,6 +49,12 @@ namespace Util {
46 file << getTime(); 49 file << getTime();
47 file << exception << "\n\n\r"; 50 file << exception << "\n\n\r";
48 this->closeLogFile(); 51 this->closeLogFile();
49 - }  
50 - 52 + }
  53 +
  54 + void Logger::writeInfoLog(char* filepath ,char* infoLog){
  55 + this->openInfoLogFile(filepath);
  56 + file << getTime();
  57 + file << infoLog << "\n\r";
  58 + this->closeLogFile();
  59 + }
51 } 60 }
util/src/property.cpp 0 → 100644
@@ -0,0 +1,79 @@ @@ -0,0 +1,79 @@
  1 +/***************************************************************************
  2 + * Universidade Federal da Paraíba *
  3 + * Copyright (C) 2013 by Laboratório de Aplicações de Vídeo Digital *
  4 + * *
  5 + * Centro de Informática - UFPB - Campus I *
  6 + * João Pessoa - PB - Brasil *
  7 + * *
  8 + * Author: Leonardo de Araújo Domingues (leonardo.araujo@lavid.ufpb.br) *
  9 + * Date: Qui Nov 28 14:06:10 BRT 2013 *
  10 + * *
  11 + **************************************************************************/
  12 +
  13 + #include "property.h"
  14 +
  15 + using namespace std;
  16 +
  17 + namespace sndesc {
  18 +
  19 + PropertyHandler::PropertyHandler(string filename) {
  20 +
  21 + try {
  22 + if (checkFileExtension(filename) != 1)
  23 + throw new RuntimeException("Format file not is recognized!");
  24 + file_property = new FileIO(filename, FileIO::MODE_READ);
  25 + } catch (IOException &ex) {
  26 + printf("[FAILED] Can't open file %s\n%s\n", filename.c_str(),
  27 + ex.getMessage().c_str());
  28 + }
  29 + }
  30 +
  31 + PropertyHandler::~PropertyHandler() {
  32 + if (rbuffer)
  33 + delete rbuffer;
  34 + if (file_property)
  35 + delete file_property;
  36 + }
  37 +
  38 + char* PropertyHandler::getAttributeValue(string attr) {
  39 +
  40 + char* value1;
  41 + char* value2;
  42 +
  43 + rbuffer = new BufferedReader(file_property);
  44 + string fline;
  45 + try {
  46 + int target_pos = -1, begin = 0;
  47 + string attr_t, value_t;
  48 + while((fline = rbuffer->readLine()).size() > 0) {
  49 + target_pos = fline.find("=");
  50 + if (target_pos < 2)
  51 + throw new RuntimeException("The assignment symbol was not found.");
  52 +
  53 + attr_t = fline.substr(begin, target_pos);
  54 + begin = target_pos+1;
  55 + value_t = fline.substr(begin, fline.size());
  56 +
  57 + if (attr.compare(attr_t) == 0) {
  58 + file_property->seek(0);
  59 + value1 = new char[value_t.length() + 1];
  60 + strcpy(value1, value_t.c_str());
  61 + return value1;
  62 + }
  63 + target_pos = -1;
  64 + begin = 0;
  65 + }
  66 + } catch (lavidlib::EOFException &ex) {
  67 + printf("[INFO] File is completed.\n%s\n", ex.getMessage().c_str());
  68 + }
  69 + file_property->seek(0);
  70 + strcpy(value2, fline.c_str());
  71 + return value2;
  72 + }
  73 +
  74 + int PropertyHandler::checkFileExtension(string &filename) {
  75 +
  76 + return (filename.find(EXTENSION) > 0 &&
  77 + (filename.size() == (filename.find(EXTENSION) + strlen(EXTENSION)))) ? 1 : -1;
  78 + }
  79 + }
0 \ No newline at end of file 80 \ No newline at end of file