Commit 01eb3dc9cb70bc61df203a10440466d881f69ace
1 parent
77505731
Exists in
master
and in
1 other branch
Adiciona serviço 6 (OnlyAudio)
Showing
5 changed files
with
86 additions
and
42 deletions
Show diff stats
main.cpp
... | ... | @@ -28,9 +28,10 @@ void serviceSRT(char* path_in, char* path_srt, char* sublanguage, char* position |
28 | 28 | void serviceOnlySRT(char* path_file, char* transparency, char* username); |
29 | 29 | void serviceREC(char* path_video, char* sublanguage, char* position, char* size, char* transparency, char* username, char* rate); |
30 | 30 | void serviceREC(char* path_video, char* sublanguage, char* position, char* size, char* transparency, char* username); |
31 | - | |
31 | +void serviceOnlyAudio(char* path_audio, char* transparency, char* username, char* rate); | |
32 | +void serviceOnlyAudio(char* path_audio, char* transparency, char* username); | |
32 | 33 | void serviceText(char* path_text, char* transparency, char* username, char* client_type); |
33 | -void serviceREC2(); | |
34 | + | |
34 | 35 | void help(); |
35 | 36 | void fail(string msg); |
36 | 37 | void hasFailed(); |
... | ... | @@ -99,8 +100,16 @@ int main(int argc, char* argv[]) { |
99 | 100 | serviceOnlySRT(argv[2], argv[3], argv[4]); |
100 | 101 | break; |
101 | 102 | case 6: |
102 | - serviceREC2(); | |
103 | - hasInvalid(); | |
103 | + if(argc <= 4){ | |
104 | + cout << "\nParametros inválidos. Tente novamente.\nService Type REC: ./vlibras 6 INPUT_AUDIO TRANSPARENCY{0=Opaque, 1=Transparent} ID" << endl; | |
105 | + help(); | |
106 | + hasInvalid(); | |
107 | + break; | |
108 | + } | |
109 | + if (argc == 6) | |
110 | + serviceOnlyAudio(argv[2], argv[3], argv[4], argv[5]); | |
111 | + else | |
112 | + serviceOnlyAudio(argv[2], argv[3], argv[4]); | |
104 | 113 | break; |
105 | 114 | default: |
106 | 115 | cout << "\nServiço inválido. Tente novamente." << endl; |
... | ... | @@ -283,32 +292,52 @@ void serviceOnlySRT(char* path_file, char* transparency, char* id){ |
283 | 292 | |
284 | 293 | } |
285 | 294 | |
286 | -void serviceREC2(){ | |
287 | - | |
288 | - cout << "\n--> Serviço não disponível.\n" << endl; | |
295 | +void serviceOnlyAudio(char* path_audio, char* transparency, char* id, char* rate){ | |
289 | 296 | |
290 | -/** | |
291 | - cout << "\nSERVICE RECOGNIZER FROM AUDIO - Delivers only LIBRAS Translation\n" << endl; | |
292 | - | |
293 | - char* path_in = (char*) argv[2]; | |
294 | - int transparency = (int) atoi(argv[3]); | |
295 | - char* id = (char*) argv[4]; | |
296 | - filename = createFileToRespWeb(id); | |
297 | + ServiceWindowGenerationFromREC * service_rec; | |
298 | + service_rec = new ServiceWindowGenerationFromREC( | |
299 | + path_audio, | |
300 | + 0, | |
301 | + 0, | |
302 | + 0, | |
303 | + (int) atoi(transparency), | |
304 | + id, 6, rate); | |
297 | 305 | |
298 | - printf("Main 1\n"); | |
306 | + try{ | |
307 | + service_rec->initialize(); | |
308 | + }catch(ServiceException ex){ | |
309 | + fail(ex.getMessage()); | |
310 | + hasFailed(); | |
311 | + return; | |
312 | + } | |
313 | + while(service_rec->isRunning()){ | |
314 | + sleep(2); | |
315 | + } | |
316 | + delete service_rec; | |
317 | +} | |
318 | + | |
319 | +void serviceOnlyAudio(char* path_audio, char* transparency, char* id){ | |
299 | 320 | |
300 | 321 | ServiceWindowGenerationFromREC * service_rec; |
301 | - service_rec = new ServiceWindowGenerationFromREC(path_in, id, transparency, 6); | |
322 | + service_rec = new ServiceWindowGenerationFromREC( | |
323 | + path_audio, | |
324 | + 0, | |
325 | + 0, | |
326 | + 0, | |
327 | + (int) atoi(transparency), | |
328 | + id, 6); | |
302 | 329 | |
303 | - service_rec->initialize(); | |
304 | - | |
330 | + try{ | |
331 | + service_rec->initialize(); | |
332 | + }catch(ServiceException ex){ | |
333 | + fail(ex.getMessage()); | |
334 | + hasFailed(); | |
335 | + return; | |
336 | + } | |
305 | 337 | while(service_rec->isRunning()){ |
306 | - sleep(5); | |
307 | - printf("\nservice_rec->isRunning()...\n"); | |
338 | + sleep(2); | |
308 | 339 | } |
309 | - printf("\nService REC_FROM_AUDIO finished!\n"); | |
310 | - updateRequestStatus(filename.c_str(), id, "true"); | |
311 | -**/ | |
340 | + delete service_rec; | |
312 | 341 | } |
313 | 342 | |
314 | 343 | void fail(string msg){ | ... | ... |
recognize/src/include/recognize.h
... | ... | @@ -45,12 +45,15 @@ public: |
45 | 45 | void notifyPCRBase(uint64_t pcrbase); |
46 | 46 | |
47 | 47 | bool isFinished(); |
48 | + void hasAudio(); | |
49 | + | |
48 | 50 | |
49 | 51 | void Run(); |
50 | 52 | int count_lines; |
51 | 53 | |
52 | 54 | private: |
53 | 55 | |
56 | + bool isAudio; | |
54 | 57 | int64_t pcr_base; |
55 | 58 | bool hasPCRBase; |
56 | 59 | char* pathVideo; | ... | ... |
recognize/src/recognize.cpp
... | ... | @@ -103,8 +103,8 @@ void Recognize::initialize() { |
103 | 103 | ifstream file(pathVideo, ifstream::binary); |
104 | 104 | if(!file.is_open()){ |
105 | 105 | finished = true; |
106 | - Util::Logger::Instance()->writeLog((char*) "[ERRO: recognize.cpp] Arquivo de vídeo não encontrado."); | |
107 | - throw RecognizeException("Falha ao abrir o arquivo de vídeo! Verifique se o mesmo existe."); | |
106 | + Util::Logger::Instance()->writeLog((char*) "[ERRO: recognize.cpp] Arquivo não encontrado."); | |
107 | + throw RecognizeException("Falha ao abrir o arquivo! Verifique se o mesmo existe."); | |
108 | 108 | } |
109 | 109 | this->Start(); |
110 | 110 | } |
... | ... | @@ -112,7 +112,6 @@ void Recognize::initialize() { |
112 | 112 | void Recognize::Run(){ |
113 | 113 | |
114 | 114 | finished = false; |
115 | - | |
116 | 115 | createDir(); |
117 | 116 | extractAudioFromVideo(); |
118 | 117 | breakVideoParts(getTimeMediaSec()); |
... | ... | @@ -125,6 +124,10 @@ void Recognize::Run(){ |
125 | 124 | notifyEndExtraction(count_lines); |
126 | 125 | } |
127 | 126 | |
127 | +void Recognize::hasAudio(){ | |
128 | + isAudio = true; | |
129 | +} | |
130 | + | |
128 | 131 | void Recognize::setFrequency(int freq) { |
129 | 132 | frequency = freq; |
130 | 133 | } | ... | ... |
servico/src/serviceWindowGeneration.cpp
... | ... | @@ -46,7 +46,7 @@ bool ServiceWindowGeneration::isRunning() { |
46 | 46 | |
47 | 47 | /* Quando o sincronizador termina, ele invoca esse método para avisar! */ |
48 | 48 | void ServiceWindowGeneration::finalizouSincronizacao() { |
49 | - if (getRunningOption() != '2' && serviceType != SERVICE_TYPE_TEXT && serviceType != SERVICE_TYPE_SRT_ONLY) { | |
49 | + if (getRunningOption() != '2' && serviceType == SERVICE_TYPE_REC && serviceType == SERVICE_TYPE_SRT) { | |
50 | 50 | mixer = new Mixer(); |
51 | 51 | mixer->initialize(this->path_input, this->path_libras,this->position,this->size,this->transparency, this->user_id); |
52 | 52 | createThumbnail(); |
... | ... | @@ -255,6 +255,7 @@ void ServiceWindowGeneration::transcodeVideoToMp4() { |
255 | 255 | if (serviceType == SERVICE_TYPE_TEXT && strcmp(client_type, (char*)"WEB") == 0) |
256 | 256 | transcodeVideoToWebm(); |
257 | 257 | else{ |
258 | + | |
258 | 259 | //printf("[INFO]: A transcodificação para .mp4 está ativada!\n"); |
259 | 260 | string command = "ffmpeg -i "; |
260 | 261 | command.append(path_libras) | ... | ... |
servico/src/serviceWindowGenerationFromREC.cpp
... | ... | @@ -18,7 +18,7 @@ ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( |
18 | 18 | |
19 | 19 | ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( |
20 | 20 | char* path_video, int sublanguage, int position, int size, int transparency, char* id, int serviceType) { |
21 | - | |
21 | + | |
22 | 22 | setPathInput(path_video); |
23 | 23 | setSubLanguage(sublanguage); |
24 | 24 | setPosition(position); |
... | ... | @@ -39,28 +39,36 @@ void ServiceWindowGenerationFromREC::initialize() { |
39 | 39 | |
40 | 40 | rec->addListener(this); |
41 | 41 | |
42 | - inputfile = new InputFile(this->path_input); | |
43 | - monitor_pcr_base = new MonitorPCR(); | |
42 | + if (serviceType == 6){ | |
43 | + rec->hasAudio(); | |
44 | + | |
45 | + } else { | |
44 | 46 | |
45 | - if (strstr(this->path_input, "ts") != NULL) { | |
46 | - char* format_video = new char[3]; | |
47 | - strcpy(format_video, "ts"); | |
48 | - monitor_pcr_base->setFormatVideo(format_video); | |
47 | + inputfile = new InputFile(this->path_input); | |
48 | + monitor_pcr_base = new MonitorPCR(); | |
49 | + | |
50 | + if (strstr(this->path_input, "ts") != NULL) { | |
51 | + char* format_video = new char[3]; | |
52 | + strcpy(format_video, "ts"); | |
53 | + monitor_pcr_base->setFormatVideo(format_video); | |
54 | + } | |
55 | + | |
56 | + monitor_pcr_base->addListenerPCRBase(rec); | |
57 | + inputfile->registraOuvinte(monitor_pcr_base); | |
58 | + try{ | |
59 | + inputfile->initialize(); | |
60 | + } catch(InputException ex){ | |
61 | + throw ServiceException(ex.getMessage()); | |
62 | + } | |
49 | 63 | } |
50 | 64 | |
51 | - monitor_pcr_base->addListenerPCRBase(rec); | |
52 | - inputfile->registraOuvinte(monitor_pcr_base); | |
53 | - | |
54 | 65 | ServiceWindowGeneration::initialize(); |
55 | - | |
66 | + | |
56 | 67 | try{ |
57 | - inputfile->initialize(); | |
58 | 68 | rec->initialize(); |
59 | 69 | } catch(RecognizeException ex){ |
60 | 70 | throw ServiceException(ex.getMessage()); |
61 | - } catch(InputException ex){ | |
62 | - throw ServiceException(ex.getMessage()); | |
63 | - } | |
71 | + } | |
64 | 72 | this->Start(); |
65 | 73 | } |
66 | 74 | ... | ... |