diff --git a/extrator/src/extratorSRT.cpp b/extrator/src/extratorSRT.cpp index 670e6c9..0a9a2e2 100644 --- a/extrator/src/extratorSRT.cpp +++ b/extrator/src/extratorSRT.cpp @@ -170,5 +170,5 @@ int64_t ExtratorSRT::str_to_time(string str_time) { } uint64_t ExtratorSRT::calcula_pts(double msec) { - return (uint64_t)(1000 /*pcr_base*/ + ((msec/1000) * 90000.0)); + return (uint64_t)msec; } diff --git a/mixer/src/Mixer.cpp b/mixer/src/Mixer.cpp index 79a7109..1ba1dbe 100644 --- a/mixer/src/Mixer.cpp +++ b/mixer/src/Mixer.cpp @@ -150,7 +150,8 @@ void Mixer::setPathFinal(){ stringstream ss; ss << contents; ss >> pathFinal; - pathFinal.append(user_id).append(".mp4"); + pathFinal.append("/").append(user_id).append(".mp4"); + cout << "Path: " << pathFinal << endl; } /*Ajusta o FPS do vídeo principal para 45 se preciso...*/ @@ -316,12 +317,12 @@ void Mixer::setMainVideo(string mainVideo){ } } //ajeitar isso depois - string nameOfMainVideo = mainVideo.substr(0, dotPosition); + nameOfMainVideo = mainVideo.substr(0, dotPosition); stringstream ss; ss << uploads; ss >> temporaryTextFile; - temporaryTextFile.append(this->user_id).append("/tamanho.txt"); + temporaryTextFile.append("/").append(this->user_id).append("/tamanho.txt"); //printf("##########temporaryTextFile: %s\n", temporaryTextFile.c_str()); } string Mixer::getMainVideo(){ diff --git a/mixer/src/include/Mixer.h b/mixer/src/include/Mixer.h index 626912f..8a458fa 100644 --- a/mixer/src/include/Mixer.h +++ b/mixer/src/include/Mixer.h @@ -74,7 +74,7 @@ private: void convertMainVideoFPS(fpsAndLine [], int *); void convertSecondaryVideoFPS(double); - string mainVideo, secondaryVideo, temporaryTextFile, numThreads, pathFinal, user_id; + string mainVideo, secondaryVideo, temporaryTextFile, numThreads, pathFinal, user_id, nameOfMainVideo; char* contents; char* uploads; int positionSecondaryVideo; diff --git a/recognize/src/recognize.cpp b/recognize/src/recognize.cpp index 353fb57..44111bb 100644 --- a/recognize/src/recognize.cpp +++ b/recognize/src/recognize.cpp @@ -107,7 +107,7 @@ char* Recognize::extractAudioFromVideo() { //command.append(strFreq).append(" -ac 1 -f wav ").append(PATH_AUDIO_ORIGIN).append(" &"); command.append(strFreq). append(" -ac 1 -f wav "). - append(path_contents).append(id). + append(path_contents).append("/").append(id). append(PATH_AUDIO_ORIGIN).append(" -v quiet"); /*string tmp = "echo "; @@ -121,7 +121,7 @@ int Recognize::getTimeMediaSec() { string command = PROGRAM; - command.append(" -i ").append(path_contents).append(id).append(PATH_AUDIO_ORIGIN) + command.append(" -i ").append(path_contents).append("/").append(id).append(PATH_AUDIO_ORIGIN) .append(" 2>&1 | grep Duration >> outfile"); system(command.c_str()); @@ -183,8 +183,8 @@ void Recognize::breakVideoParts(int timeTotal) { pts.push_back(convert_pts(ss_str)); command = "sox "; - command.append(path_contents).append(id).append(PATH_AUDIO_ORIGIN).append(" ") - .append(path_contents).append(id).append(PATH_AUDIO_PARTS); + command.append(path_contents).append("/").append(id).append(PATH_AUDIO_ORIGIN).append(" ") + .append(path_contents).append("/").append(id).append(PATH_AUDIO_PARTS); sprintf(tmp, "%i", count++); filename.append(tmp).append(".wav"); @@ -194,8 +194,8 @@ void Recognize::breakVideoParts(int timeTotal) { string apcomm = "echo "; - apcomm.append(path_contents).append(id).append(PATH_AUDIO_PARTS).append(filename).append(" >> ") - .append(path_contents).append(id).append(FILENAME_AUDIOLIST); + apcomm.append(path_contents).append("/").append(id).append(PATH_AUDIO_PARTS).append(filename).append(" >> ") + .append(path_contents).append("/").append(id).append(FILENAME_AUDIOLIST); system(apcomm.c_str()); @@ -227,12 +227,12 @@ void Recognize::executeJuliusEngine() { else type = "mic"; - command.append(type).append(" -filelist ").append(path_contents).append(id).append(FILENAME_AUDIOLIST); + command.append(type).append(" -filelist ").append(path_contents).append("/").append(id).append(FILENAME_AUDIOLIST); sprintf(cfreq, "%i", frequency); command.append(" -smpFreq "). append(cfreq). append(" >> "); - command.append(path_contents).append(id).append(FILENAME_RECOGNIZED_OUT); + command.append(path_contents).append("/").append(id).append(FILENAME_RECOGNIZED_OUT); //Command of execute Julius //printf("\n\nCommand for executeJuliusEngine: %s\n", command.c_str()); system(command.c_str()); @@ -242,13 +242,13 @@ void Recognize::executeJuliusEngine() { void Recognize::generateConfidence() { string command = "cat "; - command.append(path_contents).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep "). - append(FIND_CONFIDENCE).append(" >> ").append(path_contents).append(id).append(FILENAME_CONFIDENCEOUT); + command.append(path_contents).append("/").append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep "). + append(FIND_CONFIDENCE).append(" >> ").append(path_contents).append("/").append(id).append(FILENAME_CONFIDENCEOUT); system(command.c_str()); //printf("\n\n---> command: %s\n\n", command.c_str()); string path; - path.append(path_contents).append(id).append(FILENAME_CONFIDENCEOUT); + path.append(path_contents).append("/").append(id).append(FILENAME_CONFIDENCEOUT); ifstream in(path.c_str()); if (!in) { @@ -317,15 +317,15 @@ void Recognize::filterOutputJulius() { sentences = new std::list(); string command = "cat "; - command.append(path_contents).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep -e "). - append(FIND_SENTENCE).append(" -e \"").append(AUDIO_SILENT).append("\"").append(" >> ").append(path_contents).append(id).append(FILENAME_FILTEROUT); + command.append(path_contents).append("/").append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep -e "). + append(FIND_SENTENCE).append(" -e \"").append(AUDIO_SILENT).append("\"").append(" >> ").append(path_contents).append("/").append(id).append(FILENAME_FILTEROUT); system(command.c_str()); //printf("\n\n---> command: %s\n\n", command.c_str()); count_lines = 0; string path; - path.append(path_contents).append(id).append(FILENAME_FILTEROUT); + path.append(path_contents).append("/").append(id).append(FILENAME_FILTEROUT); ifstream in(path.c_str()); string strFilter; @@ -406,15 +406,15 @@ bool Recognize::isFinished() { void Recognize::cleanFiles() { string command = "rm -r "; - command.append(path_contents).append(id).append("/audio"); + command.append(path_contents).append("/").append(id).append("/audio"); system(command.c_str()); } void Recognize::createDir(){ string command = "mkdir "; - command.append(path_contents).append(id).append("/audio") - .append(" && mkdir ").append(path_contents).append(id).append("/audio/parts") - .append(" && mkdir ").append(path_contents).append(id).append("/audio/origin"); + command.append(path_contents).append("/").append(id).append("/audio") + .append(" && mkdir ").append(path_contents).append("/").append(id).append("/audio/parts") + .append(" && mkdir ").append(path_contents).append("/").append(id).append("/audio/origin"); system(command.c_str()); } diff --git a/renderer/src/include/renderer.h b/renderer/src/include/renderer.h index 4601da1..ff8505c 100644 --- a/renderer/src/include/renderer.h +++ b/renderer/src/include/renderer.h @@ -3,12 +3,12 @@ #include "jthread.h" #include "dprintf.h" -#include "stdint.h" #include "string.h" #include #include #include #include +#include #include "listenerRenderer.h" #include #include @@ -17,6 +17,7 @@ #include #define PATH_RENDERER "vlibras_user/unityVideo/" +#define PATH_SCREENS "vlibras_user/.config/unity3d/LAViD/VLibrasPlayer/" #define END_FLAG "FINALIZE" #define HOST "127.0.0.1" #define PORTNO 5555 @@ -27,7 +28,7 @@ using namespace std; class Renderer : public Thread { public: - Renderer(char* filename); + Renderer(char* videoPath, char* user_id); ~Renderer(); bool isSending(); @@ -44,14 +45,17 @@ private: int count_task; int glosa_processed; - char* output; + char* folder_id; + char* path_video; string glosa_copy; - void notifyListeners(); + void render(); void sendGlosa(); + void notifyListeners(); void connectToUnity(); - void waitScreenShots(); void serverInitialize(); + void waitScreenShots(); + void cleanFiles(); }; #endif /* RENDERER_H */ diff --git a/renderer/src/renderer.cpp b/renderer/src/renderer.cpp index 882f1bb..9d964b1 100644 --- a/renderer/src/renderer.cpp +++ b/renderer/src/renderer.cpp @@ -1,8 +1,9 @@ #include "renderer.h" -Renderer::Renderer(char* filename) { - this->output = filename; - // serverInitialize(); +Renderer::Renderer(char* videoPath, char* user_id) { + this->folder_id = user_id; + this->path_video = videoPath; + //serverInitialize(); running = true; count_task = 0; glosa_processed = 0; @@ -20,7 +21,7 @@ Renderer::~Renderer() { void Renderer::serverInitialize(){ string render = "./render.sh "; - render.append(output).append(" \"VLIBRAS\"").append(" 1920 1080").append(" 1").append(" 30"); + render.append(folder_id).append(" \"VLIBRAS\"").append(" 1920 1080").append(" 1").append(" 30"); string command = "cd "; char* shPath; @@ -31,27 +32,16 @@ void Renderer::serverInitialize(){ command.append(PATH_RENDERER); command.append(" && ").append(render); - cout << command << endl; system(command.c_str()); - // sleep(1); -} - -void Renderer::addListener(ListenerRenderer* listener) { - listeners->push_back(listener); -} - -void Renderer::notifyListeners() { - for (list::iterator i = listeners->begin(); i != listeners->end(); i++) { - (*i)->notifyEndOfRenderization(); - } + sleep(2); } void Renderer::receiveGlosa(std::string glosa, int64_t pts) { glosa_copy = glosa; - stringstream ss; - ss << pts; - glosa_copy += "#"; // '#' para identificar que vem um pts - glosa_copy += ss.str(); + ostringstream oss; + oss << pts; + glosa_copy += "#"; // formato da string enviada p/ o player: Glosa#pts + glosa_copy += oss.str(); count_task++; } @@ -90,20 +80,29 @@ void Renderer::connectToUnity() { } void Renderer::waitScreenShots() { + DPRINTF("[AGUARDE] Gerando vídeo...\n"); char* endgeneration = new char[strlen(END_FLAG)+1]; int connected; try{ do{ - connected = core_socket->read(endgeneration, sizeof(endgeneration)); }while(strcmp(endgeneration, END_FLAG) != 0 && connected != 0); core_socket->close(); - notifyListeners(); }catch(IOException &ex){ throw RuntimeException(ex.getMessage().c_str()); } } +void Renderer::addListener(ListenerRenderer* listener) { + listeners->push_back(listener); +} + +void Renderer::notifyListeners() { + for (list::iterator i = listeners->begin(); i != listeners->end(); i++) { + (*i)->notifyEndOfRenderization(); + } +} + void Renderer::finalize() { while(glosa_processed < count_task) usleep(10000); @@ -129,8 +128,24 @@ void Renderer::Run() { sendGlosa(); } waitScreenShots(); + render(); + cleanFiles(); }catch(lavidlib::RuntimeException &ex){ DDDDPRINTF("Erro: %s\n", ex.getMessage().c_str()); throw RuntimeException(ex.getMessage().c_str()); } +} + +void Renderer::render() { + string command = "avconv -loglevel quiet -framerate 30 -i "; + command.append(PATH_SCREENS).append(folder_id).append("/frame_%d.png ") + .append("-vcodec libx264 -pix_fmt yuv420p ").append(path_video); + system(command.c_str()); + notifyListeners(); +} + +void Renderer::cleanFiles() { + string clean = "rm -rf "; + clean.append(PATH_SCREENS).append(user_id).append("/"); + system(clean.c_str()); } \ No newline at end of file diff --git a/servico/src/include/serviceWindowGeneration.h b/servico/src/include/serviceWindowGeneration.h index 647d52e..3a3feac 100644 --- a/servico/src/include/serviceWindowGeneration.h +++ b/servico/src/include/serviceWindowGeneration.h @@ -20,9 +20,9 @@ #define DEVELOPER "devel" #define PRODUCTION "prod" -#define PATH_DEVEL_CONTENTS "vlibras_user/vlibras-contents/videos/" -#define PATH_DEVEL_UPLOADS "vlibras_user/vlibras-contents/uploads/" -#define PATH_VBOX_UPLOADS "vlibras_user/.vlibras-conf/uploads/" +#define PATH_DEVEL_CONTENTS "vlibras_user/vlibras-contents/videos" +#define PATH_DEVEL_UPLOADS "vlibras_user/vlibras-contents/uploads" +#define PATH_VBOX_UPLOADS "vlibras_user/.vlibras-conf/uploads" #define PATH_CONF_FILE "vlibras_user/.vlibras-conf/params.json" #define MAX_SIZE_PATH 256 @@ -49,6 +49,7 @@ protected: char* path_input; char* path_client; + char* path_libras; char* path_contents; char* path_uploads; char* client_type; @@ -66,6 +67,7 @@ protected: virtual void setPathContents() = 0; public: + virtual void setPathLibras() = 0; virtual void initialize() = 0; virtual bool isFinished() = 0; virtual void notifyTranslator(unsigned char* text) = 0; diff --git a/servico/src/include/serviceWindowGenerationFromRec.h b/servico/src/include/serviceWindowGenerationFromRec.h index 5843ee8..a59c38a 100644 --- a/servico/src/include/serviceWindowGenerationFromRec.h +++ b/servico/src/include/serviceWindowGenerationFromRec.h @@ -15,6 +15,7 @@ private: void addPTS(int64_t pts); void setSizeOfSubtitles(int sub_size); + void setPathLibras(); void setPathContents(); bool isRunning(); public: diff --git a/servico/src/include/serviceWindowGenerationFromSRT.h b/servico/src/include/serviceWindowGenerationFromSRT.h index 10e68c6..30df73a 100644 --- a/servico/src/include/serviceWindowGenerationFromSRT.h +++ b/servico/src/include/serviceWindowGenerationFromSRT.h @@ -18,6 +18,7 @@ private: void addPTS(int64_t pts); void setSizeOfSubtitles(int sub_size); + void setPathLibras(); void setPathContents(); bool isRunning(); public: diff --git a/servico/src/include/serviceWindowGenerationFromText.h b/servico/src/include/serviceWindowGenerationFromText.h index 1c13d35..00ed357 100644 --- a/servico/src/include/serviceWindowGenerationFromText.h +++ b/servico/src/include/serviceWindowGenerationFromText.h @@ -14,6 +14,7 @@ private: ExtratorTXT* extratorTXT; void setSizeOfSubtitles(int sub_size); + void setPathLibras(); void setPathContents(); bool isRunning(); public: diff --git a/servico/src/serviceWindowGenerationFromRec.cpp b/servico/src/serviceWindowGenerationFromRec.cpp index 3e1db50..79a12e7 100644 --- a/servico/src/serviceWindowGenerationFromRec.cpp +++ b/servico/src/serviceWindowGenerationFromRec.cpp @@ -15,7 +15,6 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec( vetor_pts = new vector(); rec = new Recognize(pathVideo, id, rate); tradutor = new TradutorPortGlosa(); - renderer = new Renderer(this->user_id); running = true; finish = false; DPRINTF("Done!\n"); @@ -37,7 +36,6 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec( vetor_pts = new vector(); rec = new Recognize(path_input, id); tradutor = new TradutorPortGlosa(); - renderer = new Renderer(this->user_id); try{ setPathContents(); }catch(RuntimeException ex){ @@ -80,6 +78,19 @@ void ServiceWindowGenerationFromRec::setPathContents(){ } } +void ServiceWindowGenerationFromRec::setPathLibras() { + string final_path = ""; + path_libras = new char[MAX_SIZE_PATH]; + + if(this->service_type == SERVICE_TYPE_REC) + final_path.append(this->path_uploads).append("/").append(this->user_id); + else + final_path.append(this->path_contents); + + final_path.append("/").append(this->user_id).append(".mp4"); + strcpy(this->path_libras, final_path.c_str()); +} + void ServiceWindowGenerationFromRec::setSizeOfSubtitles(int sub_size){ numero_legendas = sub_size; if (legendas_enviadas >= numero_legendas){ @@ -107,6 +118,7 @@ void ServiceWindowGenerationFromRec::notifyTextRecognized(unsigned char* text, i void ServiceWindowGenerationFromRec::notifyTranslation(vector * glosas) { string glosa = ""; + int64_t pts_notificado; for (int i = 0; i < glosas->size(); i++) { locale loc; string glosa_lower = ""; @@ -115,9 +127,8 @@ void ServiceWindowGenerationFromRec::notifyTranslation(vector * glosas) } glosa += glosa_lower; glosa += " "; - + pts_notificado = vetor_pts->front(); } - int64_t pts_notificado = vetor_pts->front(); while(renderer->isSending()) usleep(10000); try{ @@ -131,6 +142,11 @@ void ServiceWindowGenerationFromRec::notifyTranslation(vector * glosas) } void ServiceWindowGenerationFromRec::notifyEndOfRenderization() { + if(this->service_type == SERVICE_TYPE_REC){ + mixer = new Mixer(); + mixer->initialize(this->path_input, this->path_libras, this->position, this->size, + this->transparency, this->user_id, this->path_uploads, this->path_contents); + } running = false; } @@ -149,9 +165,11 @@ bool ServiceWindowGenerationFromRec::isFinished(){ void ServiceWindowGenerationFromRec::initialize(){ DPRINTF("Service REC Initialize.\n"); - + setPathLibras(); rec->addListener(this); tradutor->addListener(this); + + renderer = new Renderer(this->path_libras ,this->user_id); renderer->addListener(this); try{ diff --git a/servico/src/serviceWindowGenerationFromSRT.cpp b/servico/src/serviceWindowGenerationFromSRT.cpp index 8133202..597863e 100644 --- a/servico/src/serviceWindowGenerationFromSRT.cpp +++ b/servico/src/serviceWindowGenerationFromSRT.cpp @@ -16,7 +16,6 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo, legendas_enviadas = 0; vetor_pts = new vector(); tradutor = new TradutorPortGlosa(); - renderer = new Renderer(this->user_id); extrator_factory = new ExtratorFactory(); try{ setPathContents(); @@ -29,7 +28,6 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo, } ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, int transp, char* id, char* client, int serviceType) { - this->path_srt = pathSRT; this->transparency = transp; this->user_id = id; @@ -39,7 +37,6 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, in legendas_enviadas = 0; vetor_pts = new vector(); tradutor = new TradutorPortGlosa(); - renderer = new Renderer(this->user_id); extrator_factory = new ExtratorFactory(); try{ setPathContents(); @@ -64,6 +61,7 @@ ServiceWindowGenerationFromSRT::~ServiceWindowGenerationFromSRT() { void ServiceWindowGenerationFromSRT::setPathContents() { if(strcmp(client_type,DEVELOPER) == 0){ this->path_contents = PATH_DEVEL_CONTENTS; + this->path_uploads = PATH_DEVEL_UPLOADS; }else if(strcmp(client_type, PRODUCTION) == 0){ ifstream conf_file(PATH_CONF_FILE, ifstream::binary); parsingSuccessful = reader.parse(conf_file, root); @@ -74,12 +72,26 @@ void ServiceWindowGenerationFromSRT::setPathContents() { string attr = root.get("storage", PATH_VBOX_UPLOADS).asString(); this->path_contents = new char[MAX_SIZE_PATH]; strcpy(this->path_contents, attr.c_str()); + this->path_uploads = PATH_VBOX_UPLOADS; conf_file.close(); }else{ throw ServiceException("Invalid client!"); } } +void ServiceWindowGenerationFromSRT::setPathLibras() { + string final_path = ""; + path_libras = new char[MAX_SIZE_PATH]; + + if(this->service_type == SERVICE_TYPE_SRT) + final_path.append(this->path_uploads).append("/").append(this->user_id); + else + final_path.append(this->path_contents); + + final_path.append("/").append(this->user_id).append(".mp4"); + strcpy(this->path_libras, final_path.c_str()); +} + void ServiceWindowGenerationFromSRT::setSizeOfSubtitles(int sub_size) { numero_legendas = sub_size; if (legendas_enviadas >= numero_legendas){ @@ -110,6 +122,7 @@ void ServiceWindowGenerationFromSRT::notifySubtitle(unsigned char *subtitle, int void ServiceWindowGenerationFromSRT::notifyTranslation(vector * glosas) { string glosa = ""; + int64_t pts_notificado; for (int i = 0; i < glosas->size(); i++) { locale loc; string glosa_lower = ""; @@ -118,9 +131,8 @@ void ServiceWindowGenerationFromSRT::notifyTranslation(vector * glosas) } glosa += glosa_lower; glosa += " "; - + pts_notificado = vetor_pts->front(); } - int64_t pts_notificado = vetor_pts->front(); while(renderer->isSending()) usleep(10000); try{ @@ -134,6 +146,11 @@ void ServiceWindowGenerationFromSRT::notifyTranslation(vector * glosas) } void ServiceWindowGenerationFromSRT::notifyEndOfRenderization() { + if(this->service_type == SERVICE_TYPE_SRT){ + mixer = new Mixer(); + mixer->initialize(this->path_input, this->path_libras, this->position, this->size, + this->transparency, this->user_id, this->path_uploads, this->path_contents); + } this->running = false; } @@ -152,11 +169,14 @@ bool ServiceWindowGenerationFromSRT::isFinished() { void ServiceWindowGenerationFromSRT::initialize() { DPRINTF("Service SRT Initialize.\n"); + setPathLibras(); extratorSRT = (ExtratorSRT*) extrator_factory->getExtrator(Extrator::SRT); extratorSRT->addListener(this); extratorSRT->setFilePath(path_srt); tradutor->addListener(this); + + renderer = new Renderer(this->path_libras ,this->user_id); renderer->addListener(this); try{ diff --git a/servico/src/serviceWindowGenerationFromText.cpp b/servico/src/serviceWindowGenerationFromText.cpp index c999e99..b28c3f8 100644 --- a/servico/src/serviceWindowGenerationFromText.cpp +++ b/servico/src/serviceWindowGenerationFromText.cpp @@ -9,9 +9,7 @@ ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile, finish = false; numero_legendas = INT_MAX; legendas_enviadas = 0; - vetor_pts = new vector(); tradutor = new TradutorPortGlosa(); - renderer = new Renderer(this->user_id); extrator_factory = new ExtratorFactory(); try{ setPathContents(); @@ -24,7 +22,6 @@ ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile, } ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() { - free(vetor_pts); if (tradutor) delete tradutor; if (renderer) delete renderer; if (extratorTXT)delete extratorTXT; @@ -35,6 +32,7 @@ ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() { void ServiceWindowGenerationFromText::setPathContents() { if(strcmp(client_type,DEVELOPER) == 0){ this->path_contents = PATH_DEVEL_CONTENTS; + //this->path_uploads = PATH_DEVEL_UPLOADS; }else if(strcmp(client_type, PRODUCTION) == 0){ ifstream conf_file(PATH_CONF_FILE, ifstream::binary); parsingSuccessful = reader.parse(conf_file, root); @@ -44,11 +42,20 @@ void ServiceWindowGenerationFromText::setPathContents() { string attr = root.get("storage", PATH_VBOX_UPLOADS).asString(); this->path_contents = new char[MAX_SIZE_PATH]; strcpy(this->path_contents, attr.c_str()); + //this->path_uploads = PATH_VBOX_UPLOADS; }else{ throw ServiceException("Invalid client!"); } } +void ServiceWindowGenerationFromText::setPathLibras() { + string final_path = ""; + path_libras = new char[MAX_SIZE_PATH]; + final_path.append(this->path_contents).append("/"). + append(this->user_id).append(".mp4"); + strcpy(this->path_libras, final_path.c_str()); +} + void ServiceWindowGenerationFromText::setSizeOfSubtitles(int sub_size) { numero_legendas = sub_size; if (legendas_enviadas >= numero_legendas){ @@ -79,10 +86,9 @@ void ServiceWindowGenerationFromText::notifyTranslation(vector * glosas) glosa += glosa_lower; glosa += " "; } - while(renderer->isSending()){ + while(renderer->isSending()){ // aguarda o renderizador processar a glosa anterior usleep(10000); - } // aguarda o renderizador processar a glosa anterior - + } try{ renderer->receiveGlosa(glosa, (int64_t) -1); legendas_enviadas++; @@ -110,11 +116,14 @@ bool ServiceWindowGenerationFromText::isFinished() { void ServiceWindowGenerationFromText::initialize() { DPRINTF("Service Text Initialize.\n"); + setPathLibras(); extratorTXT = (ExtratorTXT*) extrator_factory->getExtrator(Extrator::TXT); extratorTXT->addListener(this); extratorTXT->setFilePath(path_input); tradutor->addListener(this); + + renderer = new Renderer(this->path_libras, this->user_id); renderer->addListener(this); try{ -- libgit2 0.21.2