Commit 67e44a375d2d51cecda669775d361322b5ac3af0

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

Modificação nos parâmetros da linha de comando

@@ -27,6 +27,7 @@ INCLUDES= \ @@ -27,6 +27,7 @@ INCLUDES= \
27 -I recognize/src/include 27 -I recognize/src/include
28 28
29 utilObjs= \ 29 utilObjs= \
  30 + argParser.o \
30 logger.o 31 logger.o
31 32
32 tradutorObjs = \ 33 tradutorObjs = \
@@ -15,107 +15,132 @@ @@ -15,107 +15,132 @@
15 #include "serviceWindowGenerationFromRec.h" 15 #include "serviceWindowGenerationFromRec.h"
16 #include "serviceWindowGenerationFromText.h" 16 #include "serviceWindowGenerationFromText.h"
17 #include "serviceException.h" 17 #include "serviceException.h"
  18 +#include <lavidlib/base/RuntimeException.h>
  19 +#include "argParser.h"
18 #include <sys/time.h> 20 #include <sys/time.h>
19 #include <stdlib.h> 21 #include <stdlib.h>
20 22
  23 +#define MAX_SIZE_PATH 256
21 #define PATH_DEVEL_CONTENTS "vlibras_user/vlibras-contents/videos" 24 #define PATH_DEVEL_CONTENTS "vlibras_user/vlibras-contents/videos"
22 #define PATH_DEVEL_UPLOADS "vlibras_user/vlibras-contents/uploads" 25 #define PATH_DEVEL_UPLOADS "vlibras_user/vlibras-contents/uploads"
23 #define PATH_VBOX_UPLOADS "vlibras_user/.vlibras-config/uploads" 26 #define PATH_VBOX_UPLOADS "vlibras_user/.vlibras-config/uploads"
24 27
25 using namespace std; 28 using namespace std;
26 29
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 serviceREC(char* service, char* path_video, char* position, char* size, char* transparency, char* id, char* client_type); 30 +void serviceSRT(int service, string path_video, string path_srt, int language, int position, int size, int background, string id, int mode);
  31 +void serviceREC(int service, string path_video, int position, int size, int background, string id, int mode);
  32 +void serviceOnlySRT(int service, string path_srt, int language, int background, string id, int mode);
  33 +void serviceOnlyAudio(int service, string path_audio, int background, string id, int mode);
  34 +void serviceText(string path_text, int language, int background, string id, int mode);
  35 +void serviceRECWithoutMixing(int service, string path_video, int background, string id, int mode);
29 36
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 -  
35 -//void serviceREC(char* path_video, char* sublanguage, char* position, char* size, char* transparency, char* username, char* rate);  
36 -//void serviceOnlyAudio(char* path_audio, char* transparency, char* username, char* rate);  
37 -  
38 -void help();  
39 -void serviceHelp(int service);  
40 -void setPathContents(char* client);  
41 -void fail(string msg);  
42 void hasFailed(); 37 void hasFailed();
43 void hasInvalid(); 38 void hasInvalid();
  39 +void fail(string msg);
  40 +void setPathContents(int mode, string id);
44 41
45 bool isFailed; 42 bool isFailed;
46 bool isInvalid; 43 bool isInvalid;
47 44
48 int main(int argc, char* argv[]) { 45 int main(int argc, char* argv[]) {
49 46
  47 + int service;
  48 + int language;
  49 + int position;
  50 + int size;
  51 + int background;
  52 + int mode;
  53 + int nomixer;
  54 +
  55 + string input;
  56 + string input_srt;
  57 + string id;
  58 +
  59 + ArgParser *parser;
  60 +
50 struct timeval tv1, tv2; 61 struct timeval tv1, tv2;
51 double t1, t2; 62 double t1, t2;
52 63
53 gettimeofday(&tv1, NULL); 64 gettimeofday(&tv1, NULL);
54 t1 = (double)(tv1.tv_sec) + (double)(tv1.tv_usec)/ 1000000.00; 65 t1 = (double)(tv1.tv_sec) + (double)(tv1.tv_usec)/ 1000000.00;
55 -  
56 - if(argc > 2) {  
57 - printf("\n################## VLIBRAS : LAVID ##################\n\n");  
58 - DDPRINTF("Service Type: %s\n", argv[1]);  
59 - switch((int) atoi(argv[1])){  
60 - case 1:  
61 - if(argc <= 9){  
62 - serviceHelp(1);  
63 - hasInvalid();  
64 - }else{  
65 - serviceSRT(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9]);  
66 - }  
67 - break;  
68 - case 2:  
69 - if(argc <= 7){  
70 - serviceHelp(2);  
71 - hasInvalid();  
72 - }else{  
73 - serviceREC(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7]);  
74 - }  
75 - break;  
76 - case 3:  
77 - if(argc <= 6){  
78 - serviceHelp(3);  
79 - hasInvalid();  
80 - }else{  
81 - serviceText(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);  
82 - }  
83 - break;  
84 - case 4:  
85 - if(argc <= 5){  
86 - serviceHelp(4);  
87 - hasInvalid();  
88 - }else{  
89 - serviceOnlySRT(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);  
90 - }  
91 - break;  
92 - case 5:  
93 - if(argc <= 5){  
94 - serviceHelp(5);  
95 - hasInvalid();  
96 - }else{  
97 - serviceOnlyAudio(argv[1], argv[2], argv[3], argv[4], argv[5]);  
98 - }  
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;  
108 - default:  
109 - cout << "\nFAIL VLibras: Serviço inválido! Tente --help" << endl;  
110 - hasInvalid();  
111 - break;  
112 - }  
113 - }else if(argc == 2 && (strcmp(argv[1], "--help")) == 0){  
114 - help();  
115 - exit(0);  
116 - }else{  
117 - cout << "\nFAIL VLibras: Tente --help para obter informações.\n" << endl;  
118 - hasInvalid(); 66 +
  67 + parser = new ArgParser();
  68 + try{
  69 + parser->readArgs(argv, argc);
  70 + }catch(lavidlib::RuntimeException &ex){
  71 + exit(1);
  72 + }
  73 +
  74 + printf("\n################## LAViD : VLibras ##################\n\n");
  75 +
  76 + service = parser->getService();
  77 +
  78 + switch(service){
  79 + case 1:
  80 + DDPRINTF("Service Type: Video with Subtitles\n");
  81 + input = parser->getInput();
  82 + input_srt = parser->getInputSRT();
  83 + language = parser->getLanguage();
  84 + position = parser->getPosition();
  85 + size = parser->getSize();
  86 + background = parser->getBackground();
  87 + id = parser->getId();
  88 + mode = parser->getMode();
  89 + serviceSRT(service, input, input_srt, language, position, size, background, id, mode);
  90 + break;
  91 +
  92 + case 2:
  93 + DDPRINTF("Service Type: Video Recognize\n");
  94 + input = parser->getInput();
  95 + position = parser->getPosition();
  96 + size = parser->getSize();
  97 + background = parser->getBackground();
  98 + id = parser->getId();
  99 + mode = parser->getMode();
  100 + serviceREC(service, input, position, size, background, id, mode);
  101 + break;
  102 +
  103 + case 3:
  104 + DDPRINTF("Service Type: Text\n");
  105 + input = parser->getInput();
  106 + language = parser->getLanguage();
  107 + background = parser->getBackground();
  108 + id = parser->getId();
  109 + mode = parser->getMode();
  110 + serviceText(input, language, background, id, mode);
  111 + break;
  112 +
  113 + case 4:
  114 + DDPRINTF("Service Type: Subtitles only\n");
  115 + input = parser->getInput();
  116 + language = parser->getLanguage();
  117 + background = parser->getBackground();
  118 + id = parser->getId();
  119 + mode = parser->getMode();
  120 + serviceOnlySRT(service, input, language, background, id, mode);
  121 + break;
  122 +
  123 + case 5: //reconhecimento de audio
  124 + DDPRINTF("Service Type: Audio Recognize\n");
  125 + input = parser->getInput();
  126 + background = parser->getBackground();
  127 + id = parser->getId();
  128 + mode = parser->getMode();
  129 + serviceREC(service, input, 0, 0, background, id, mode);
  130 + break;
  131 +
  132 + case 6: //Reconhecimento de video sem mixagem
  133 + DDPRINTF("Service Type: Video Recognize (Mixer Disabled)\n");
  134 + input = parser->getInput();
  135 + background = parser->getBackground();
  136 + id = parser->getId();
  137 + mode = parser->getMode();
  138 + serviceREC(service, input, 0, 0, background, id, mode);//como service != 2 então não há mixagem
  139 + break;
  140 +
  141 + default:
  142 + printf("\nOpção de serviço não reconhecida!\n");
  143 + hasInvalid();
119 } 144 }
120 145
121 if(isFailed) 146 if(isFailed)
@@ -130,14 +155,19 @@ int main(int argc, char* argv[]) { @@ -130,14 +155,19 @@ int main(int argc, char* argv[]) {
130 exit(0); 155 exit(0);
131 } 156 }
132 157
133 -void serviceSRT(char* service, char* path_video, char* path_srt, char* sublanguage, char* position,  
134 - char* size, char* transparency, char* id, char* client_type){ 158 +void serviceSRT(int service, string path_video, string path_srt, int language, int position, int size, int background, string id, int mode){
  159 + char* video = new char[MAX_SIZE_PATH];
  160 + char* srt = new char[MAX_SIZE_PATH];
  161 + char* name = new char[64];
135 162
136 - setPathContents(client_type); 163 + strcpy(video, path_video.c_str());
  164 + strcpy(srt, path_srt.c_str());
  165 + strcpy(name, id.c_str());
137 166
138 - ServiceWindowGenerationFromSRT * service_srt;  
139 - service_srt = new ServiceWindowGenerationFromSRT(path_video, path_srt, (int) atoi(sublanguage),  
140 - (int) atoi(position), (int) atoi(size), (int) atoi(transparency), id, client_type, (int) atoi(service)); 167 + setPathContents(mode, id);
  168 +
  169 + ServiceWindowGenerationFromSRT* service_srt;
  170 + service_srt = new ServiceWindowGenerationFromSRT(video, srt, language, position, size, background, name, mode, service);
141 171
142 try{ 172 try{
143 service_srt->initialize(); 173 service_srt->initialize();
@@ -149,18 +179,24 @@ void serviceSRT(char* service, char* path_video, char* path_srt, char* sublangua @@ -149,18 +179,24 @@ void serviceSRT(char* service, char* path_video, char* path_srt, char* sublangua
149 while(!service_srt->isFinished()){ 179 while(!service_srt->isFinished()){
150 sleep(5); 180 sleep(5);
151 } 181 }
152 - 182 +
  183 + delete [] video;
  184 + delete [] srt;
  185 + delete [] name;
153 delete service_srt; 186 delete service_srt;
154 } 187 }
155 188
156 -void serviceREC(char* service, char* path_video, char* position, char* size,  
157 - char* transparency, char* id, char* client_type){ 189 +void serviceREC(int service, string path_video, int position, int size, int background, string id, int mode){
  190 + char* video = new char[MAX_SIZE_PATH];
  191 + char* name = new char[64];
  192 +
  193 + strcpy(video, path_video.c_str());
  194 + strcpy(name, id.c_str());
158 195
159 - setPathContents(client_type); 196 + setPathContents(mode, id);
160 197
161 - ServiceWindowGenerationFromRec * service_rec;  
162 - service_rec = new ServiceWindowGenerationFromRec(path_video, (int) atoi(position),  
163 - (int) atoi(size), (int) atoi(transparency), id, client_type, (int) atoi(service)); 198 + ServiceWindowGenerationFromRec* service_rec;
  199 + service_rec = new ServiceWindowGenerationFromRec(video, position, size, background, name, mode, service);
164 200
165 try{ 201 try{
166 service_rec->initialize(); 202 service_rec->initialize();
@@ -170,26 +206,25 @@ void serviceREC(char* service, char* path_video, char* position, char* size, @@ -170,26 +206,25 @@ void serviceREC(char* service, char* path_video, char* position, char* size,
170 return; 206 return;
171 } 207 }
172 while(!service_rec->isFinished()){ 208 while(!service_rec->isFinished()){
173 - sleep(2); 209 + sleep(5);
174 } 210 }
  211 +
  212 + delete [] video;
  213 + delete [] name;
175 delete service_rec; 214 delete service_rec;
176 } 215 }
177 216
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 -} 217 +void serviceText(string path_text, int language, int background, string id, int mode){
  218 + char* text = new char[MAX_SIZE_PATH];
  219 + char* name = new char[64];
186 220
187 -void serviceText(char* service, char* path_text, char* sublanguage, char* transparency, char* id, char* client_type){ 221 + strcpy(text, path_text.c_str());
  222 + strcpy(name, id.c_str());
188 223
189 - setPathContents(client_type); 224 + setPathContents(mode, id);
190 225
191 - ServiceWindowGenerationFromText *service_text;  
192 - service_text = new ServiceWindowGenerationFromText(path_text, (int) atoi(sublanguage), (int) atoi(transparency), id, client_type); 226 + ServiceWindowGenerationFromText* service_text;
  227 + service_text = new ServiceWindowGenerationFromText(text, language, background, name, mode);
193 228
194 try{ 229 try{
195 service_text->initialize(); 230 service_text->initialize();
@@ -202,15 +237,23 @@ void serviceText(char* service, char* path_text, char* sublanguage, char* transp @@ -202,15 +237,23 @@ void serviceText(char* service, char* path_text, char* sublanguage, char* transp
202 while (!service_text->isFinished()) { 237 while (!service_text->isFinished()) {
203 usleep(100000); //100ms 238 usleep(100000); //100ms
204 } 239 }
  240 +
  241 + delete [] text;
  242 + delete [] name;
205 delete service_text; 243 delete service_text;
206 } 244 }
207 245
208 -void serviceOnlySRT(char* service, char* path_file, char* sublanguage, char* transparency, char* id, char* client_type){ 246 +void serviceOnlySRT(int service, string path_srt, int language, int background, string id, int mode){
  247 + char* srt = new char[MAX_SIZE_PATH];
  248 + char* name = new char[64];
209 249
210 - setPathContents(client_type); 250 + strcpy(srt, path_srt.c_str());
  251 + strcpy(name, id.c_str());
211 252
212 - ServiceWindowGenerationFromSRT * service_srt;  
213 - service_srt = new ServiceWindowGenerationFromSRT(path_file, (int) atoi(sublanguage), (int) atoi(transparency), id, client_type, (int) atoi(service)); 253 + setPathContents(mode, id);
  254 +
  255 + ServiceWindowGenerationFromSRT* service_srt;
  256 + service_srt = new ServiceWindowGenerationFromSRT(srt, language, background, name, mode, service);
214 try{ 257 try{
215 service_srt->initialize(); 258 service_srt->initialize();
216 }catch(ServiceException ex){ 259 }catch(ServiceException ex){
@@ -222,67 +265,12 @@ void serviceOnlySRT(char* service, char* path_file, char* sublanguage, char* tra @@ -222,67 +265,12 @@ void serviceOnlySRT(char* service, char* path_file, char* sublanguage, char* tra
222 while (!service_srt->isFinished()) { 265 while (!service_srt->isFinished()) {
223 usleep(100000); //100ms 266 usleep(100000); //100ms
224 } 267 }
225 - delete service_srt;  
226 -}  
227 -  
228 -void serviceOnlyAudio(char* service, char* path_audio, char* transparency, char* id, char* client_type){  
229 268
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); 269 + delete [] srt;
  270 + delete [] name;
  271 + delete service_srt;
235 } 272 }
236 273
237 -/*void serviceREC(char* path_video, char* sublanguage,  
238 - char* position, char* size, char* transparency, char* id, char* rate){  
239 -  
240 - ServiceWindowGenerationFromREC * service_rec;  
241 - service_rec = new ServiceWindowGenerationFromREC(  
242 - path_video,  
243 - (int) atoi(sublanguage),  
244 - (int) atoi(position),  
245 - (int) atoi(size),  
246 - (int) atoi(transparency),  
247 - id, 2, rate);  
248 -  
249 - try{  
250 - service_rec->initialize();  
251 - }catch(ServiceException ex){  
252 - fail(ex.getMessage());  
253 - hasFailed();  
254 - return;  
255 - }  
256 - while(!service_rec->isFinished()){  
257 - sleep(2);  
258 - }  
259 - delete service_rec;  
260 -}*/  
261 -  
262 -/*void serviceOnlyAudio(char* path_audio, char* transparency, char* id, char* rate){  
263 -  
264 - ServiceWindowGenerationFromREC * service_rec;  
265 - service_rec = new ServiceWindowGenerationFromREC(  
266 - path_audio,  
267 - 0,  
268 - 0,  
269 - 0,  
270 - (int) atoi(transparency),  
271 - id, 5, rate);  
272 -  
273 - try{  
274 - service_rec->initialize();  
275 - }catch(ServiceException ex){  
276 - fail(ex.getMessage());  
277 - hasFailed();  
278 - return;  
279 - }  
280 - while(!service_rec->isFinished()){  
281 - sleep(2);  
282 - }  
283 - delete service_rec;  
284 -}*/  
285 -  
286 void fail(string msg){ 274 void fail(string msg){
287 printf("\n"); 275 printf("\n");
288 DDDDPRINTF("Ops... Tivemos um problema! :(\n"); 276 DDDDPRINTF("Ops... Tivemos um problema! :(\n");
@@ -297,84 +285,15 @@ void hasInvalid(){ @@ -297,84 +285,15 @@ void hasInvalid(){
297 isInvalid = true; 285 isInvalid = true;
298 } 286 }
299 287
300 -void setPathContents(char* client){ 288 +void setPathContents(int mode, string id){
301 string command = "mkdir -p "; 289 string command = "mkdir -p ";
302 - if(strcmp(client, "devel") == 0)  
303 - command.append(PATH_DEVEL_CONTENTS).append(" && mkdir -p ").append(PATH_DEVEL_UPLOADS);  
304 - else if (strcmp(client, "prod") == 0) 290 + if(mode == 1)// 1 aqui é devel
  291 + command.append(PATH_DEVEL_CONTENTS).append(" && mkdir -p ").append(PATH_DEVEL_UPLOADS).append("/").append(id);
  292 + else if (mode == 2)// 2 aqui é prod
305 command.append(PATH_VBOX_UPLOADS); 293 command.append(PATH_VBOX_UPLOADS);
306 else { 294 else {
307 - fail("Cliente Inválido!"); 295 + fail("Modo de execução não reconhecido!");
308 exit(127); 296 exit(127);
309 } 297 }
310 system(command.c_str()); 298 system(command.c_str());
311 } 299 }
312 -  
313 -void serviceHelp(int service){  
314 - cout << "\nParâmetros inválidos! Tente novamente.\n";  
315 - switch(service){  
316 - case 1:  
317 - cout << "\nService Type: Video with Subtitles\n"  
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) "  
319 - << "SIZE(1: Small, 2: Medium, 3: Large) TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";  
320 - break;  
321 - case 2:  
322 - cout << "\nService Type: Video Recognize\n"  
323 - << "./vlibras 2 INPUT_VIDEO POSITION(1: Top_Left, 2: Top_Right, 3: Bottom_Right, 4: Bottom_Left) "  
324 - << "SIZE(1: Small, 2: Medium, 3: Large) TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";  
325 - break;  
326 - case 3:  
327 - cout << "\nService Type: Text\n"  
328 - << "./vlibras 3 INPUT_TEXT_FILE LANGUAGE(1: Portuguese, 2:Glosa) TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";  
329 - break;  
330 - case 4:  
331 - cout << "\nService Type: Subtitles only\n"  
332 - << "./vlibras 4 INPUT_SRT LANGUAGE(1: Portuguese, 2:Glosa) TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";  
333 - break;  
334 - case 5:  
335 - cout << "\nService Type: Audio Recognize\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";  
341 - break;  
342 - }  
343 -}  
344 -  
345 -//Help do programa, explicando todos os parâmetros existentes...  
346 -void help() {  
347 -  
348 - cout << endl  
349 - << "Usage Summary: vlibras [SERVICE] [INPUT] ... [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"  
350 - << "\nSERVICE:\n"  
351 - << "1 Video with Subtitles (SRT) - requires INPUT_VIDEO and INPUT_SRT\n"  
352 - << "2 Video Recognize - requires INPUT_VIDEO\n"  
353 - << "3 Text - requires INPUT_TEXT_FILE\n"  
354 - << "4 Subtitles only (SRT) - requires INPUT_SRT\n"  
355 - << "5 Audio Recognize - requires INPUT_AUDIO\n"  
356 - << "6 Video Recognize without mixing - requires INPUT_VIDEO\n"  
357 - << "\nSERVICES PARAMETERS:\n"  
358 - << "Video with subtitles:\n"  
359 - << " [INPUT_VIDEO] [INPUT_SRT] [LANGUAGE] [POSITION] [SIZE] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"  
360 - << "\nVideo Recognize:\n"  
361 - << " [INPUT_VIDEO] [LANGUAGE] [POSITION] [SIZE] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"  
362 - << "\nText:\n"  
363 - << " [INPUT_TEXT_FILE] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"  
364 - << "\nSubtitles only:\n"  
365 - << " [INPUT_SRT] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"  
366 - << "\nAudio Recognize\n"  
367 - << " [INPUT_AUDIO] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"  
368 - << "\nPARAMETERS:\n"  
369 - << "INPUT_VIDEO Path of the video file\n"  
370 - << "INPUT_SRT Path of the subtitle file\n"  
371 - << "INPUT_TEXT_FILE Path of the text file\n"  
372 - << "INPUT_AUDIO Path of the audio file\n"  
373 - << "LANGUAGE 1 - means Portuguese, 2 - means Glosa\n"  
374 - << "POSITION 1 - means Top_Left, 2 - means Top_Right, 3 - means Bottom_Right, 4 - means Bottom_Left\n"  
375 - << "SIZE 1 - means Small, 2 - means Medium, 3 - means Large\n"  
376 - << "TRANSPARENCY 0 - means that the background is opaque , 1 - means that the background is transparent\n"  
377 - << "ID Relative to the unique ID on the Database\n"  
378 - << "CLIENT_TYPE prod - means that the client is web/cloud, devel - means that the client is developer\n"  
379 - << endl;  
380 -}  
381 \ No newline at end of file 300 \ No newline at end of file
servico/src/include/serviceWindowGeneration.h
@@ -18,8 +18,8 @@ @@ -18,8 +18,8 @@
18 #include <json/json.h> 18 #include <json/json.h>
19 #include <lavidlib/base/RuntimeException.h> 19 #include <lavidlib/base/RuntimeException.h>
20 20
21 -#define DEVELOPER "devel"  
22 -#define PRODUCTION "prod" 21 +#define DEVELOPER 1
  22 +#define PRODUCTION 2
23 #define PATH_DEVEL_CONTENTS "vlibras_user/vlibras-contents/videos" 23 #define PATH_DEVEL_CONTENTS "vlibras_user/vlibras-contents/videos"
24 #define PATH_DEVEL_UPLOADS "vlibras_user/vlibras-contents/uploads" 24 #define PATH_DEVEL_UPLOADS "vlibras_user/vlibras-contents/uploads"
25 #define PATH_VBOX_UPLOADS "vlibras_user/.vlibras-config/uploads" 25 #define PATH_VBOX_UPLOADS "vlibras_user/.vlibras-config/uploads"
@@ -51,7 +51,6 @@ protected: @@ -51,7 +51,6 @@ protected:
51 char* path_libras; 51 char* path_libras;
52 char* path_contents; 52 char* path_contents;
53 char* path_uploads; 53 char* path_uploads;
54 - char* client_type;  
55 char* user_id; 54 char* user_id;
56 55
57 int size; 56 int size;
@@ -59,6 +58,7 @@ protected: @@ -59,6 +58,7 @@ protected:
59 int transparency; 58 int transparency;
60 int sub_language; 59 int sub_language;
61 int service_type; 60 int service_type;
  61 + int exec_mode;
62 int numero_legendas; 62 int numero_legendas;
63 int legendas_enviadas; 63 int legendas_enviadas;
64 64
servico/src/include/serviceWindowGenerationFromRec.h
@@ -23,7 +23,7 @@ public: @@ -23,7 +23,7 @@ public:
23 ServiceWindowGenerationFromRec(char* pathVideo, int position, int size, 23 ServiceWindowGenerationFromRec(char* pathVideo, int position, int size,
24 int transparency, char* id, char* client, int serviceType, char* rate); 24 int transparency, char* id, char* client, int serviceType, char* rate);
25 ServiceWindowGenerationFromRec(char* pathVideo, int pos, int size, 25 ServiceWindowGenerationFromRec(char* pathVideo, int pos, int size,
26 - int transp, char* id, char* client, int serviceType); 26 + int transp, char* id, int mode, int serviceType);
27 ~ServiceWindowGenerationFromRec(); 27 ~ServiceWindowGenerationFromRec();
28 28
29 void notifyTextRecognized(unsigned char* text, int64_t pts); 29 void notifyTextRecognized(unsigned char* text, int64_t pts);
servico/src/include/serviceWindowGenerationFromSRT.h
@@ -24,9 +24,9 @@ private: @@ -24,9 +24,9 @@ private:
24 public: 24 public:
25 //construtor de serviço de video e legenda 25 //construtor de serviço de video e legenda
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, int mode, int serviceType);
28 //construtor de serviço de somente legenda 28 //construtor de serviço de somente legenda
29 - ServiceWindowGenerationFromSRT(char* pathSRT, int sublanguage, int transparency, char* id, char* client, int serviceType); 29 + ServiceWindowGenerationFromSRT(char* pathSRT, int sublanguage, int transparency, char* id, int mode, 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);
servico/src/include/serviceWindowGenerationFromText.h
@@ -18,7 +18,7 @@ private: @@ -18,7 +18,7 @@ private:
18 void setPathContents(); 18 void setPathContents();
19 bool isRunning(); 19 bool isRunning();
20 public: 20 public:
21 - ServiceWindowGenerationFromText(char* pathFile, int sublanguage, int transparency, char* id, char* client); 21 + ServiceWindowGenerationFromText(char* pathFile, int sublanguage, int transparency, char* id, int mode);
22 ~ServiceWindowGenerationFromText(); 22 ~ServiceWindowGenerationFromText();
23 23
24 void notifyLine(unsigned char* line); 24 void notifyLine(unsigned char* line);
servico/src/serviceWindowGenerationFromRec.cpp
@@ -8,7 +8,7 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec( @@ -8,7 +8,7 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec(
8 this->size = size; 8 this->size = size;
9 this->transparency = transp; 9 this->transparency = transp;
10 this->user_id = id; 10 this->user_id = id;
11 - this->client_type = client; 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,14 +21,14 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec( @@ -21,14 +21,14 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec(
21 } 21 }
22 22
23 ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec( 23 ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec(
24 - char* pathVideo, int pos, int size, int transp, char* id, char* client, int serviceType){ 24 + char* pathVideo, int pos, int size, int transp, char* id, int mode, int serviceType){
25 25
26 this->path_input = pathVideo; 26 this->path_input = pathVideo;
27 this->position = pos; 27 this->position = pos;
28 this->size = size; 28 this->size = size;
29 this->transparency = transp; 29 this->transparency = transp;
30 this->user_id = id; 30 this->user_id = id;
31 - this->client_type = client; 31 + this->exec_mode = mode;
32 this->service_type = serviceType; 32 this->service_type = serviceType;
33 numero_legendas = INT_MAX; 33 numero_legendas = INT_MAX;
34 legendas_enviadas = 0; 34 legendas_enviadas = 0;
@@ -55,11 +55,12 @@ ServiceWindowGenerationFromRec::~ServiceWindowGenerationFromRec(){ @@ -55,11 +55,12 @@ ServiceWindowGenerationFromRec::~ServiceWindowGenerationFromRec(){
55 } 55 }
56 56
57 void ServiceWindowGenerationFromRec::setPathContents(){ 57 void ServiceWindowGenerationFromRec::setPathContents(){
58 - if(strcmp(client_type,DEVELOPER) == 0){ 58 + if(this->exec_mode == DEVELOPER){
59 this->path_contents = PATH_DEVEL_CONTENTS; 59 this->path_contents = PATH_DEVEL_CONTENTS;
60 this->path_uploads = PATH_DEVEL_UPLOADS; 60 this->path_uploads = PATH_DEVEL_UPLOADS;
61 rec->setPathAudioContents(path_uploads); 61 rec->setPathAudioContents(path_uploads);
62 - }else if(strcmp(client_type, PRODUCTION) == 0){ 62 +
  63 + }else if(this->exec_mode == PRODUCTION){
63 ifstream conf_file(PATH_CONF_FILE, ifstream::binary); 64 ifstream conf_file(PATH_CONF_FILE, ifstream::binary);
64 parsingSuccessful = reader.parse(conf_file, root); 65 parsingSuccessful = reader.parse(conf_file, root);
65 if(!parsingSuccessful){ 66 if(!parsingSuccessful){
@@ -74,7 +75,7 @@ void ServiceWindowGenerationFromRec::setPathContents(){ @@ -74,7 +75,7 @@ void ServiceWindowGenerationFromRec::setPathContents(){
74 rec->setPathAudioContents(path_uploads); 75 rec->setPathAudioContents(path_uploads);
75 conf_file.close(); 76 conf_file.close();
76 }else{ 77 }else{
77 - throw ServiceException("Invalid client!"); 78 + throw ServiceException("Invalid execution mode!");
78 } 79 }
79 } 80 }
80 81
servico/src/serviceWindowGenerationFromSRT.cpp
1 #include "serviceWindowGenerationFromSRT.h" 1 #include "serviceWindowGenerationFromSRT.h"
2 2
3 ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo, char* pathSRT, int sublanguage, 3 ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo, char* pathSRT, int sublanguage,
4 - int pos, int size, int transp, char* id, char* client, int serviceType) { 4 + int pos, int size, int transp, char* id, int mode, int serviceType) {
5 5
6 this->path_input = pathVideo; 6 this->path_input = pathVideo;
7 this->path_srt = pathSRT; 7 this->path_srt = pathSRT;
@@ -10,7 +10,7 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo, @@ -10,7 +10,7 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo,
10 this->size = size; 10 this->size = size;
11 this->transparency = transp; 11 this->transparency = transp;
12 this->user_id = id; 12 this->user_id = id;
13 - this->client_type = client; 13 + this->exec_mode = mode;
14 this->service_type = serviceType; 14 this->service_type = serviceType;
15 numero_legendas = INT_MAX; 15 numero_legendas = INT_MAX;
16 legendas_enviadas = 0; 16 legendas_enviadas = 0;
@@ -26,12 +26,12 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo, @@ -26,12 +26,12 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo,
26 DPRINTF("Done!\n"); 26 DPRINTF("Done!\n");
27 } 27 }
28 28
29 -ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, int sublanguage, int transp, char* id, char* client, int serviceType) { 29 +ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, int sublanguage, int transp, char* id, int mode, int serviceType) {
30 this->path_srt = pathSRT; 30 this->path_srt = pathSRT;
31 this->sub_language = sublanguage; 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->exec_mode = mode;
35 this->service_type = serviceType; 35 this->service_type = serviceType;
36 numero_legendas = INT_MAX; 36 numero_legendas = INT_MAX;
37 legendas_enviadas = 0; 37 legendas_enviadas = 0;
@@ -58,10 +58,11 @@ ServiceWindowGenerationFromSRT::~ServiceWindowGenerationFromSRT() { @@ -58,10 +58,11 @@ ServiceWindowGenerationFromSRT::~ServiceWindowGenerationFromSRT() {
58 } 58 }
59 59
60 void ServiceWindowGenerationFromSRT::setPathContents() { 60 void ServiceWindowGenerationFromSRT::setPathContents() {
61 - if(strcmp(client_type,DEVELOPER) == 0){ 61 + if(this->exec_mode == DEVELOPER){
62 this->path_contents = PATH_DEVEL_CONTENTS; 62 this->path_contents = PATH_DEVEL_CONTENTS;
63 this->path_uploads = PATH_DEVEL_UPLOADS; 63 this->path_uploads = PATH_DEVEL_UPLOADS;
64 - }else if(strcmp(client_type, PRODUCTION) == 0){ 64 +
  65 + }else if(this->exec_mode = PRODUCTION){
65 ifstream conf_file(PATH_CONF_FILE, ifstream::binary); 66 ifstream conf_file(PATH_CONF_FILE, ifstream::binary);
66 parsingSuccessful = reader.parse(conf_file, root); 67 parsingSuccessful = reader.parse(conf_file, root);
67 if(!parsingSuccessful){ 68 if(!parsingSuccessful){
@@ -76,7 +77,7 @@ void ServiceWindowGenerationFromSRT::setPathContents() { @@ -76,7 +77,7 @@ void ServiceWindowGenerationFromSRT::setPathContents() {
76 this->path_uploads = PATH_VBOX_UPLOADS; 77 this->path_uploads = PATH_VBOX_UPLOADS;
77 conf_file.close(); 78 conf_file.close();
78 }else{ 79 }else{
79 - throw ServiceException("Invalid client!"); 80 + throw ServiceException("Invalid execution mode!");
80 } 81 }
81 } 82 }
82 83
servico/src/serviceWindowGenerationFromText.cpp
1 #include "serviceWindowGenerationFromText.h" 1 #include "serviceWindowGenerationFromText.h"
2 2
3 -ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile, int sublanguage, int transp, char* id, char* client) { 3 +ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile, int sublanguage, int transp, char* id, int mode) {
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->sub_language = sublanguage;
7 this->user_id = id; 7 this->user_id = id;
8 - client_type = client; 8 + this->exec_mode = mode;
9 running = true; 9 running = true;
10 finish = false; 10 finish = false;
11 numero_legendas = INT_MAX; 11 numero_legendas = INT_MAX;
@@ -30,10 +30,10 @@ ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() { @@ -30,10 +30,10 @@ ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() {
30 } 30 }
31 31
32 void ServiceWindowGenerationFromText::setPathContents() { 32 void ServiceWindowGenerationFromText::setPathContents() {
33 - if(strcmp(client_type,DEVELOPER) == 0){ 33 + if(this->exec_mode == DEVELOPER){
34 this->path_contents = PATH_DEVEL_CONTENTS; 34 this->path_contents = PATH_DEVEL_CONTENTS;
35 //this->path_uploads = PATH_DEVEL_UPLOADS; 35 //this->path_uploads = PATH_DEVEL_UPLOADS;
36 - }else if(strcmp(client_type, PRODUCTION) == 0){ 36 + }else if(this->exec_mode == PRODUCTION){
37 ifstream conf_file(PATH_CONF_FILE, ifstream::binary); 37 ifstream conf_file(PATH_CONF_FILE, ifstream::binary);
38 parsingSuccessful = reader.parse(conf_file, root); 38 parsingSuccessful = reader.parse(conf_file, root);
39 if(!parsingSuccessful){ 39 if(!parsingSuccessful){
@@ -45,7 +45,7 @@ void ServiceWindowGenerationFromText::setPathContents() { @@ -45,7 +45,7 @@ void ServiceWindowGenerationFromText::setPathContents() {
45 strcpy(this->path_contents, attr.c_str()); 45 strcpy(this->path_contents, attr.c_str());
46 //this->path_uploads = PATH_VBOX_UPLOADS; 46 //this->path_uploads = PATH_VBOX_UPLOADS;
47 }else{ 47 }else{
48 - throw ServiceException("Invalid client!"); 48 + throw ServiceException("Invalid execution mode!");
49 } 49 }
50 } 50 }
51 51
util/src/argParser.cpp 0 → 100644
@@ -0,0 +1,241 @@ @@ -0,0 +1,241 @@
  1 +#include "argParser.h"
  2 +
  3 +ArgParser::ArgParser(){}
  4 +
  5 +ArgParser::~ArgParser(){}
  6 +
  7 +void ArgParser::readArgs(char** argv, int argc)
  8 +{
  9 + int opt;
  10 + int long_index = 0;
  11 +
  12 + static struct option long_options[] = {
  13 + {"audio", required_argument, NULL, 'A'},
  14 + {"subtitle", required_argument, NULL, 'S'},
  15 + {"text", required_argument, NULL, 'T'},
  16 + {"video", required_argument, NULL, 'V'},
  17 + {"language", required_argument, NULL, 'l'},
  18 + {"background", required_argument, NULL, 'b'},
  19 + {"resolution", required_argument, NULL, 'r'},
  20 + {"position", required_argument, NULL, 'p'},
  21 + {"mode", required_argument, NULL, 'm'},
  22 + {"id", required_argument, NULL, 'i'},
  23 + {"no-mixer", no_argument, NULL, 'x'},
  24 + {"help", no_argument, NULL, 'h'},
  25 + {0, 0, 0, 0 }
  26 + };
  27 +
  28 + while ((opt = getopt_long_only(argc, argv, "A:S:T:V:l:b:r:p:m:", long_options, &long_index))!= -1)
  29 + {
  30 + switch (opt)
  31 + {
  32 + case 'A':
  33 + if(argc <= 5)
  34 + returnErr("Insuficient arguments. Try again");
  35 +
  36 + globalArgs.service = _REC_AUDIO;
  37 + globalArgs.input = optarg;
  38 + break;
  39 +
  40 + case 'S':
  41 + if(argc <= 6 || (globalArgs.service == _REC_VIDEO && argc <= 9))
  42 + returnErr("Insuficient arguments. Try again");
  43 +
  44 + if(globalArgs.service == _REC_VIDEO){ // ativa o serviço de vídeo e legendas
  45 + globalArgs.service = _VIDEO_WITH_SRT;
  46 + globalArgs.input_srt = optarg;
  47 + }else{
  48 + globalArgs.service = _ONLY_SRT;
  49 + globalArgs.input = optarg;
  50 + }
  51 + break;
  52 +
  53 + case 'T':
  54 + if(argc <= 5)
  55 + returnErr("Insuficient arguments. Try again");
  56 +
  57 + globalArgs.service = _TEXT;
  58 + globalArgs.input = optarg;
  59 + break;
  60 +
  61 + case 'V':
  62 + if(argc <= 7 || ((globalArgs.service == _ONLY_SRT && argc <= 9)))
  63 + returnErr("Insuficient arguments. Try again");
  64 +
  65 + if(globalArgs.service == _ONLY_SRT){ // ativa o serviço de vídeo e legendas
  66 + globalArgs.service = _VIDEO_WITH_SRT;
  67 + globalArgs.input_srt = globalArgs.input;
  68 + }else if(globalArgs.mixer == _NO_MIXER) // desativa a mixagem
  69 + globalArgs.service = _WITHOUT_MIXER;
  70 + else
  71 + globalArgs.service = _REC_VIDEO;
  72 + globalArgs.input = optarg;
  73 + break;
  74 +
  75 + case 'l':
  76 + if (strcmp(optarg,"portugues") == 0)
  77 + globalArgs.language = _PORTUGUESE;
  78 + else if (strcmp(optarg,"libras") == 0)
  79 + globalArgs.language = _GLOSA;
  80 + else
  81 + returnErr("--language");
  82 + break;
  83 +
  84 + case 'b':
  85 + if (strcmp(optarg,"opaque") == 0)
  86 + globalArgs.back = _OPAQUE;
  87 + else if (strcmp(optarg,"transp") == 0)
  88 + globalArgs.back = _TRANSPARENT;
  89 + else
  90 + returnErr("--background");
  91 + break;
  92 +
  93 + case 'r':
  94 + if (strcmp(optarg,"small") == 0)
  95 + globalArgs.size = _SMALL;
  96 + else if (strcmp(optarg,"medium") == 0)
  97 + globalArgs.size = _MEDIUM;
  98 + else if (strcmp(optarg,"large") == 0)
  99 + globalArgs.size = _LARGE;
  100 + else
  101 + returnErr("--resolution");
  102 + break;
  103 +
  104 + case 'p':
  105 + if (strcmp(optarg,"top_left") == 0)
  106 + globalArgs.position = _TOP_LEFT;
  107 + else if (strcmp(optarg,"top_right") == 0)
  108 + globalArgs.position = _TOP_RIGHT;
  109 + else if (strcmp(optarg,"bottom_right") == 0)
  110 + globalArgs.position = _BOTTOM_RIGHT;
  111 + else if (strcmp(optarg,"bottom_left") == 0)
  112 + globalArgs.position = _BOTTOM_LEFT;
  113 + else
  114 + returnErr("--position");
  115 + break;
  116 +
  117 + case 'm':
  118 + if(strcmp(optarg,"prod") == 0)
  119 + globalArgs.mode = _PROD;
  120 + else if (strcmp(optarg,"devel") == 0)
  121 + globalArgs.mode = _DEVEL;
  122 + else
  123 + returnErr("--mode");
  124 + break;
  125 +
  126 + case 'i':
  127 + globalArgs.id = optarg;
  128 + break;
  129 +
  130 + case 'x':
  131 + if(globalArgs.service == _REC_VIDEO) // desativa a mixagem
  132 + globalArgs.service = _WITHOUT_MIXER;
  133 + else
  134 + globalArgs.mixer = _NO_MIXER;
  135 + break;
  136 +
  137 + case 'h':
  138 + help();
  139 + break;
  140 + case '?':
  141 + /* o getopt já mostra o erro no terminal!*/
  142 + break;
  143 + default:
  144 + printf("\nUsage: %s [Service_option] filepath [Options] --id [name] --mode [devel,prod]\n", argv[0]);
  145 + printf("\nTry --help for more informations.");
  146 + throw lavidlib::RuntimeException();
  147 + }
  148 + }
  149 +
  150 + if (argc < 2){
  151 + printf("Not enough arguments.\nTry --help.\n");
  152 + throw lavidlib::RuntimeException();
  153 + }
  154 +
  155 + /* Mostra os argumentos restantes depois das opções de linha de comando */
  156 + if (optind < argc)
  157 + {
  158 + printf("non-option ARGV-elements: ");
  159 + while (optind < argc)
  160 + printf("%s ", argv[optind++]);
  161 + }
  162 +}
  163 +
  164 +void ArgParser::help()
  165 +{
  166 + std::cout << std::endl
  167 + << "Usage Summary: vlibras [Service_option] filepath [Options] --id [name] --mode [devel,prod]"
  168 + << "\n\nService_option:"
  169 + << "\n\tVideo with Subtitles -V, --video [filePath] -S, --subtitle [filePath]"
  170 + << "\n\tVideo Recognize -V, --video [filePath]"
  171 + << "\n\tAudio Recognize -A, --audio [filepath]"
  172 + << "\n\tText -T, --text [filePath]"
  173 + << "\n\tSubtitles only -S, --subtitle [filePath]"
  174 + << "\n\nOptions:"
  175 + << "\n\t-l, --language [portugues,libras]"
  176 + << "\n\t-b, --background [opaque,transp]"
  177 + << "\n\t-r, --resolution [small,medium,large]"
  178 + << "\n\t-p, --position [top_left,top_right,bottom_left,bottom_right]"
  179 + << "\n\t-m, --mode [devel,prod]"
  180 + << "\n\t--id [name] Relative to the unique ID on the Database."
  181 + << "\n\t--no-mixer Disables mixing with the original video."
  182 + << "\n\nSee man vlibras for detailed descriptions."
  183 + << std::endl;
  184 + throw lavidlib::RuntimeException(); //para nao iniciar o vlibras
  185 +}
  186 +
  187 +void ArgParser::returnErr(string option)
  188 +{
  189 + cout << "Option '" << option << "' contains an invalid argument." << endl;
  190 + throw lavidlib::RuntimeException();
  191 +}
  192 +
  193 +int ArgParser::getService()
  194 +{
  195 + return globalArgs.service;
  196 +}
  197 +
  198 +int ArgParser::getLanguage()
  199 +{
  200 + return globalArgs.language;
  201 +}
  202 +
  203 +int ArgParser::getPosition()
  204 +{
  205 + return globalArgs.position;
  206 +}
  207 +
  208 +int ArgParser::getSize()
  209 +{
  210 + return globalArgs.size;
  211 +}
  212 +
  213 +int ArgParser::getBackground()
  214 +{
  215 + return globalArgs.back;
  216 +}
  217 +
  218 +int ArgParser::getMode()
  219 +{
  220 + return globalArgs.mode;
  221 +}
  222 +
  223 +int ArgParser::getOption()
  224 +{
  225 + return globalArgs.mixer;
  226 +}
  227 +
  228 +string ArgParser::getInput()
  229 +{
  230 + return globalArgs.input;
  231 +}
  232 +
  233 +string ArgParser::getInputSRT()
  234 +{
  235 + return globalArgs.input_srt;
  236 +}
  237 +
  238 +string ArgParser::getId()
  239 +{
  240 + return globalArgs.id;
  241 +}
0 \ No newline at end of file 242 \ No newline at end of file
util/src/include/argParser.h 0 → 100644
@@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
  1 +#ifndef ARG_PARSER_H
  2 +#define ARG_PARSER_H
  3 +
  4 +#include <stdio.h>
  5 +#include <string.h>
  6 +#include <iostream>
  7 +#include <stdlib.h>
  8 +#include <unistd.h>
  9 +#include <getopt.h>
  10 +#include <lavidlib/base/RuntimeException.h>
  11 +
  12 +#define MAX_SIZE_PATH 256
  13 +
  14 +using namespace std;
  15 +
  16 +class ArgParser {
  17 +public:
  18 + ArgParser();
  19 + ~ArgParser();
  20 + void readArgs(char** argv, int argc);
  21 +
  22 + int getService();
  23 + int getLanguage();
  24 + int getPosition();
  25 + int getSize();
  26 + int getBackground();
  27 + int getMode();
  28 + int getOption();
  29 +
  30 + string getInput();
  31 + string getInputSRT();
  32 + string getId();
  33 +
  34 +private:
  35 + enum Services { _VIDEO_WITH_SRT = 1, _REC_VIDEO, _TEXT, _ONLY_SRT, _REC_AUDIO, _WITHOUT_MIXER };
  36 + enum Languages { _PORTUGUESE = 1, _GLOSA };
  37 + enum Positions { _TOP_LEFT = 1, _TOP_RIGHT, _BOTTOM_RIGHT, _BOTTOM_LEFT };
  38 + enum Sizes { _SMALL = 1, _MEDIUM, _LARGE };
  39 + enum Background { _OPAQUE, _TRANSPARENT };
  40 + enum Options { _NO_MIXER = 1 };
  41 + enum Mode { _DEVEL = 1 , _PROD };
  42 +
  43 + struct globalArgs_t {
  44 + Services service;
  45 + Languages language;
  46 + Positions position;
  47 + Sizes size;
  48 + Background back;
  49 + Options mixer;
  50 + Mode mode;
  51 + string input;
  52 + string input_srt;
  53 + string id;
  54 + }globalArgs;
  55 +
  56 + void help();
  57 + void returnErr(string option);
  58 +};
  59 +
  60 +#endif /* ARG_PARSER_H */
0 \ No newline at end of file 61 \ No newline at end of file