diff --git a/main.cpp b/main.cpp index 8af99a8..b219b54 100644 --- a/main.cpp +++ b/main.cpp @@ -28,9 +28,10 @@ void serviceSRT(char* path_in, char* path_srt, char* sublanguage, char* position void serviceOnlySRT(char* path_file, char* transparency, char* username); void serviceREC(char* path_video, char* sublanguage, char* position, char* size, char* transparency, char* username, char* rate); void serviceREC(char* path_video, char* sublanguage, char* position, char* size, char* transparency, char* username); - +void serviceOnlyAudio(char* path_audio, char* transparency, char* username, char* rate); +void serviceOnlyAudio(char* path_audio, char* transparency, char* username); void serviceText(char* path_text, char* transparency, char* username, char* client_type); -void serviceREC2(); + void help(); void fail(string msg); void hasFailed(); @@ -99,8 +100,16 @@ int main(int argc, char* argv[]) { serviceOnlySRT(argv[2], argv[3], argv[4]); break; case 6: - serviceREC2(); - hasInvalid(); + if(argc <= 4){ + cout << "\nParametros inválidos. Tente novamente.\nService Type REC: ./vlibras 6 INPUT_AUDIO TRANSPARENCY{0=Opaque, 1=Transparent} ID" << endl; + help(); + hasInvalid(); + break; + } + if (argc == 6) + serviceOnlyAudio(argv[2], argv[3], argv[4], argv[5]); + else + serviceOnlyAudio(argv[2], argv[3], argv[4]); break; default: cout << "\nServiço inválido. Tente novamente." << endl; @@ -283,32 +292,52 @@ void serviceOnlySRT(char* path_file, char* transparency, char* id){ } -void serviceREC2(){ - - cout << "\n--> Serviço não disponível.\n" << endl; +void serviceOnlyAudio(char* path_audio, char* transparency, char* id, char* rate){ -/** - cout << "\nSERVICE RECOGNIZER FROM AUDIO - Delivers only LIBRAS Translation\n" << endl; - - char* path_in = (char*) argv[2]; - int transparency = (int) atoi(argv[3]); - char* id = (char*) argv[4]; - filename = createFileToRespWeb(id); + ServiceWindowGenerationFromREC * service_rec; + service_rec = new ServiceWindowGenerationFromREC( + path_audio, + 0, + 0, + 0, + (int) atoi(transparency), + id, 6, rate); - printf("Main 1\n"); + try{ + service_rec->initialize(); + }catch(ServiceException ex){ + fail(ex.getMessage()); + hasFailed(); + return; + } + while(service_rec->isRunning()){ + sleep(2); + } + delete service_rec; +} + +void serviceOnlyAudio(char* path_audio, char* transparency, char* id){ ServiceWindowGenerationFromREC * service_rec; - service_rec = new ServiceWindowGenerationFromREC(path_in, id, transparency, 6); + service_rec = new ServiceWindowGenerationFromREC( + path_audio, + 0, + 0, + 0, + (int) atoi(transparency), + id, 6); - service_rec->initialize(); - + try{ + service_rec->initialize(); + }catch(ServiceException ex){ + fail(ex.getMessage()); + hasFailed(); + return; + } while(service_rec->isRunning()){ - sleep(5); - printf("\nservice_rec->isRunning()...\n"); + sleep(2); } - printf("\nService REC_FROM_AUDIO finished!\n"); - updateRequestStatus(filename.c_str(), id, "true"); -**/ + delete service_rec; } void fail(string msg){ diff --git a/recognize/src/include/recognize.h b/recognize/src/include/recognize.h index b614438..5700745 100644 --- a/recognize/src/include/recognize.h +++ b/recognize/src/include/recognize.h @@ -45,12 +45,15 @@ public: void notifyPCRBase(uint64_t pcrbase); bool isFinished(); + void hasAudio(); + void Run(); int count_lines; private: + bool isAudio; int64_t pcr_base; bool hasPCRBase; char* pathVideo; diff --git a/recognize/src/recognize.cpp b/recognize/src/recognize.cpp index 11d0188..6a018be 100644 --- a/recognize/src/recognize.cpp +++ b/recognize/src/recognize.cpp @@ -103,8 +103,8 @@ void Recognize::initialize() { ifstream file(pathVideo, ifstream::binary); if(!file.is_open()){ finished = true; - Util::Logger::Instance()->writeLog((char*) "[ERRO: recognize.cpp] Arquivo de vídeo não encontrado."); - throw RecognizeException("Falha ao abrir o arquivo de vídeo! Verifique se o mesmo existe."); + Util::Logger::Instance()->writeLog((char*) "[ERRO: recognize.cpp] Arquivo não encontrado."); + throw RecognizeException("Falha ao abrir o arquivo! Verifique se o mesmo existe."); } this->Start(); } @@ -112,7 +112,6 @@ void Recognize::initialize() { void Recognize::Run(){ finished = false; - createDir(); extractAudioFromVideo(); breakVideoParts(getTimeMediaSec()); @@ -125,6 +124,10 @@ void Recognize::Run(){ notifyEndExtraction(count_lines); } +void Recognize::hasAudio(){ + isAudio = true; +} + void Recognize::setFrequency(int freq) { frequency = freq; } diff --git a/servico/src/serviceWindowGeneration.cpp b/servico/src/serviceWindowGeneration.cpp index d2e7ea2..3e20014 100644 --- a/servico/src/serviceWindowGeneration.cpp +++ b/servico/src/serviceWindowGeneration.cpp @@ -46,7 +46,7 @@ bool ServiceWindowGeneration::isRunning() { /* Quando o sincronizador termina, ele invoca esse método para avisar! */ void ServiceWindowGeneration::finalizouSincronizacao() { - if (getRunningOption() != '2' && serviceType != SERVICE_TYPE_TEXT && serviceType != SERVICE_TYPE_SRT_ONLY) { + if (getRunningOption() != '2' && serviceType == SERVICE_TYPE_REC && serviceType == SERVICE_TYPE_SRT) { mixer = new Mixer(); mixer->initialize(this->path_input, this->path_libras,this->position,this->size,this->transparency, this->user_id); createThumbnail(); @@ -255,6 +255,7 @@ void ServiceWindowGeneration::transcodeVideoToMp4() { if (serviceType == SERVICE_TYPE_TEXT && strcmp(client_type, (char*)"WEB") == 0) transcodeVideoToWebm(); else{ + //printf("[INFO]: A transcodificação para .mp4 está ativada!\n"); string command = "ffmpeg -i "; command.append(path_libras) diff --git a/servico/src/serviceWindowGenerationFromREC.cpp b/servico/src/serviceWindowGenerationFromREC.cpp index bbd2889..86153c4 100644 --- a/servico/src/serviceWindowGenerationFromREC.cpp +++ b/servico/src/serviceWindowGenerationFromREC.cpp @@ -18,7 +18,7 @@ ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( char* path_video, int sublanguage, int position, int size, int transparency, char* id, int serviceType) { - + setPathInput(path_video); setSubLanguage(sublanguage); setPosition(position); @@ -39,28 +39,36 @@ void ServiceWindowGenerationFromREC::initialize() { rec->addListener(this); - inputfile = new InputFile(this->path_input); - monitor_pcr_base = new MonitorPCR(); + if (serviceType == 6){ + rec->hasAudio(); + + } else { - if (strstr(this->path_input, "ts") != NULL) { - char* format_video = new char[3]; - strcpy(format_video, "ts"); - monitor_pcr_base->setFormatVideo(format_video); + inputfile = new InputFile(this->path_input); + monitor_pcr_base = new MonitorPCR(); + + if (strstr(this->path_input, "ts") != NULL) { + char* format_video = new char[3]; + strcpy(format_video, "ts"); + monitor_pcr_base->setFormatVideo(format_video); + } + + monitor_pcr_base->addListenerPCRBase(rec); + inputfile->registraOuvinte(monitor_pcr_base); + try{ + inputfile->initialize(); + } catch(InputException ex){ + throw ServiceException(ex.getMessage()); + } } - monitor_pcr_base->addListenerPCRBase(rec); - inputfile->registraOuvinte(monitor_pcr_base); - ServiceWindowGeneration::initialize(); - + try{ - inputfile->initialize(); rec->initialize(); } catch(RecognizeException ex){ throw ServiceException(ex.getMessage()); - } catch(InputException ex){ - throw ServiceException(ex.getMessage()); - } + } this->Start(); } -- libgit2 0.21.2