Commit fac85c34fd238bbd726434db630fbe8a7f0e46eb
1 parent
9c8dd613
Exists in
master
and in
1 other branch
Integração com o player do Unity
Showing
13 changed files
with
141 additions
and
69 deletions
Show diff stats
extrator/src/extratorSRT.cpp
| @@ -170,5 +170,5 @@ int64_t ExtratorSRT::str_to_time(string str_time) { | @@ -170,5 +170,5 @@ int64_t ExtratorSRT::str_to_time(string str_time) { | ||
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | uint64_t ExtratorSRT::calcula_pts(double msec) { | 172 | uint64_t ExtratorSRT::calcula_pts(double msec) { |
| 173 | - return (uint64_t)(1000 /*pcr_base*/ + ((msec/1000) * 90000.0)); | 173 | + return (uint64_t)msec; |
| 174 | } | 174 | } |
mixer/src/Mixer.cpp
| @@ -150,7 +150,8 @@ void Mixer::setPathFinal(){ | @@ -150,7 +150,8 @@ void Mixer::setPathFinal(){ | ||
| 150 | stringstream ss; | 150 | stringstream ss; |
| 151 | ss << contents; | 151 | ss << contents; |
| 152 | ss >> pathFinal; | 152 | ss >> pathFinal; |
| 153 | - pathFinal.append(user_id).append(".mp4"); | 153 | + pathFinal.append("/").append(user_id).append(".mp4"); |
| 154 | + cout << "Path: " << pathFinal << endl; | ||
| 154 | } | 155 | } |
| 155 | 156 | ||
| 156 | /*Ajusta o FPS do vídeo principal para 45 se preciso...*/ | 157 | /*Ajusta o FPS do vídeo principal para 45 se preciso...*/ |
| @@ -316,12 +317,12 @@ void Mixer::setMainVideo(string mainVideo){ | @@ -316,12 +317,12 @@ void Mixer::setMainVideo(string mainVideo){ | ||
| 316 | } | 317 | } |
| 317 | } | 318 | } |
| 318 | //ajeitar isso depois | 319 | //ajeitar isso depois |
| 319 | - string nameOfMainVideo = mainVideo.substr(0, dotPosition); | 320 | + nameOfMainVideo = mainVideo.substr(0, dotPosition); |
| 320 | 321 | ||
| 321 | stringstream ss; | 322 | stringstream ss; |
| 322 | ss << uploads; | 323 | ss << uploads; |
| 323 | ss >> temporaryTextFile; | 324 | ss >> temporaryTextFile; |
| 324 | - temporaryTextFile.append(this->user_id).append("/tamanho.txt"); | 325 | + temporaryTextFile.append("/").append(this->user_id).append("/tamanho.txt"); |
| 325 | //printf("##########temporaryTextFile: %s\n", temporaryTextFile.c_str()); | 326 | //printf("##########temporaryTextFile: %s\n", temporaryTextFile.c_str()); |
| 326 | } | 327 | } |
| 327 | string Mixer::getMainVideo(){ | 328 | string Mixer::getMainVideo(){ |
mixer/src/include/Mixer.h
| @@ -74,7 +74,7 @@ private: | @@ -74,7 +74,7 @@ private: | ||
| 74 | void convertMainVideoFPS(fpsAndLine [], int *); | 74 | void convertMainVideoFPS(fpsAndLine [], int *); |
| 75 | void convertSecondaryVideoFPS(double); | 75 | void convertSecondaryVideoFPS(double); |
| 76 | 76 | ||
| 77 | - string mainVideo, secondaryVideo, temporaryTextFile, numThreads, pathFinal, user_id; | 77 | + string mainVideo, secondaryVideo, temporaryTextFile, numThreads, pathFinal, user_id, nameOfMainVideo; |
| 78 | char* contents; | 78 | char* contents; |
| 79 | char* uploads; | 79 | char* uploads; |
| 80 | int positionSecondaryVideo; | 80 | int positionSecondaryVideo; |
recognize/src/recognize.cpp
| @@ -107,7 +107,7 @@ char* Recognize::extractAudioFromVideo() { | @@ -107,7 +107,7 @@ char* Recognize::extractAudioFromVideo() { | ||
| 107 | //command.append(strFreq).append(" -ac 1 -f wav ").append(PATH_AUDIO_ORIGIN).append(" &"); | 107 | //command.append(strFreq).append(" -ac 1 -f wav ").append(PATH_AUDIO_ORIGIN).append(" &"); |
| 108 | command.append(strFreq). | 108 | command.append(strFreq). |
| 109 | append(" -ac 1 -f wav "). | 109 | append(" -ac 1 -f wav "). |
| 110 | - append(path_contents).append(id). | 110 | + append(path_contents).append("/").append(id). |
| 111 | append(PATH_AUDIO_ORIGIN).append(" -v quiet"); | 111 | append(PATH_AUDIO_ORIGIN).append(" -v quiet"); |
| 112 | 112 | ||
| 113 | /*string tmp = "echo "; | 113 | /*string tmp = "echo "; |
| @@ -121,7 +121,7 @@ int Recognize::getTimeMediaSec() { | @@ -121,7 +121,7 @@ int Recognize::getTimeMediaSec() { | ||
| 121 | 121 | ||
| 122 | string command = PROGRAM; | 122 | string command = PROGRAM; |
| 123 | 123 | ||
| 124 | - command.append(" -i ").append(path_contents).append(id).append(PATH_AUDIO_ORIGIN) | 124 | + command.append(" -i ").append(path_contents).append("/").append(id).append(PATH_AUDIO_ORIGIN) |
| 125 | .append(" 2>&1 | grep Duration >> outfile"); | 125 | .append(" 2>&1 | grep Duration >> outfile"); |
| 126 | system(command.c_str()); | 126 | system(command.c_str()); |
| 127 | 127 | ||
| @@ -183,8 +183,8 @@ void Recognize::breakVideoParts(int timeTotal) { | @@ -183,8 +183,8 @@ void Recognize::breakVideoParts(int timeTotal) { | ||
| 183 | pts.push_back(convert_pts(ss_str)); | 183 | pts.push_back(convert_pts(ss_str)); |
| 184 | 184 | ||
| 185 | command = "sox "; | 185 | command = "sox "; |
| 186 | - command.append(path_contents).append(id).append(PATH_AUDIO_ORIGIN).append(" ") | ||
| 187 | - .append(path_contents).append(id).append(PATH_AUDIO_PARTS); | 186 | + command.append(path_contents).append("/").append(id).append(PATH_AUDIO_ORIGIN).append(" ") |
| 187 | + .append(path_contents).append("/").append(id).append(PATH_AUDIO_PARTS); | ||
| 188 | 188 | ||
| 189 | sprintf(tmp, "%i", count++); | 189 | sprintf(tmp, "%i", count++); |
| 190 | filename.append(tmp).append(".wav"); | 190 | filename.append(tmp).append(".wav"); |
| @@ -194,8 +194,8 @@ void Recognize::breakVideoParts(int timeTotal) { | @@ -194,8 +194,8 @@ void Recognize::breakVideoParts(int timeTotal) { | ||
| 194 | 194 | ||
| 195 | string apcomm = "echo "; | 195 | string apcomm = "echo "; |
| 196 | 196 | ||
| 197 | - apcomm.append(path_contents).append(id).append(PATH_AUDIO_PARTS).append(filename).append(" >> ") | ||
| 198 | - .append(path_contents).append(id).append(FILENAME_AUDIOLIST); | 197 | + apcomm.append(path_contents).append("/").append(id).append(PATH_AUDIO_PARTS).append(filename).append(" >> ") |
| 198 | + .append(path_contents).append("/").append(id).append(FILENAME_AUDIOLIST); | ||
| 199 | 199 | ||
| 200 | system(apcomm.c_str()); | 200 | system(apcomm.c_str()); |
| 201 | 201 | ||
| @@ -227,12 +227,12 @@ void Recognize::executeJuliusEngine() { | @@ -227,12 +227,12 @@ void Recognize::executeJuliusEngine() { | ||
| 227 | else | 227 | else |
| 228 | type = "mic"; | 228 | type = "mic"; |
| 229 | 229 | ||
| 230 | - command.append(type).append(" -filelist ").append(path_contents).append(id).append(FILENAME_AUDIOLIST); | 230 | + command.append(type).append(" -filelist ").append(path_contents).append("/").append(id).append(FILENAME_AUDIOLIST); |
| 231 | sprintf(cfreq, "%i", frequency); | 231 | sprintf(cfreq, "%i", frequency); |
| 232 | command.append(" -smpFreq "). | 232 | command.append(" -smpFreq "). |
| 233 | append(cfreq). | 233 | append(cfreq). |
| 234 | append(" >> "); | 234 | append(" >> "); |
| 235 | - command.append(path_contents).append(id).append(FILENAME_RECOGNIZED_OUT); | 235 | + command.append(path_contents).append("/").append(id).append(FILENAME_RECOGNIZED_OUT); |
| 236 | //Command of execute Julius | 236 | //Command of execute Julius |
| 237 | //printf("\n\nCommand for executeJuliusEngine: %s\n", command.c_str()); | 237 | //printf("\n\nCommand for executeJuliusEngine: %s\n", command.c_str()); |
| 238 | system(command.c_str()); | 238 | system(command.c_str()); |
| @@ -242,13 +242,13 @@ void Recognize::executeJuliusEngine() { | @@ -242,13 +242,13 @@ void Recognize::executeJuliusEngine() { | ||
| 242 | void Recognize::generateConfidence() { | 242 | void Recognize::generateConfidence() { |
| 243 | 243 | ||
| 244 | string command = "cat "; | 244 | string command = "cat "; |
| 245 | - command.append(path_contents).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep "). | ||
| 246 | - append(FIND_CONFIDENCE).append(" >> ").append(path_contents).append(id).append(FILENAME_CONFIDENCEOUT); | 245 | + command.append(path_contents).append("/").append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep "). |
| 246 | + append(FIND_CONFIDENCE).append(" >> ").append(path_contents).append("/").append(id).append(FILENAME_CONFIDENCEOUT); | ||
| 247 | system(command.c_str()); | 247 | system(command.c_str()); |
| 248 | //printf("\n\n---> command: %s\n\n", command.c_str()); | 248 | //printf("\n\n---> command: %s\n\n", command.c_str()); |
| 249 | 249 | ||
| 250 | string path; | 250 | string path; |
| 251 | - path.append(path_contents).append(id).append(FILENAME_CONFIDENCEOUT); | 251 | + path.append(path_contents).append("/").append(id).append(FILENAME_CONFIDENCEOUT); |
| 252 | ifstream in(path.c_str()); | 252 | ifstream in(path.c_str()); |
| 253 | 253 | ||
| 254 | if (!in) { | 254 | if (!in) { |
| @@ -317,15 +317,15 @@ void Recognize::filterOutputJulius() { | @@ -317,15 +317,15 @@ void Recognize::filterOutputJulius() { | ||
| 317 | sentences = new std::list<char*>(); | 317 | sentences = new std::list<char*>(); |
| 318 | 318 | ||
| 319 | string command = "cat "; | 319 | string command = "cat "; |
| 320 | - command.append(path_contents).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep -e "). | ||
| 321 | - append(FIND_SENTENCE).append(" -e \"").append(AUDIO_SILENT).append("\"").append(" >> ").append(path_contents).append(id).append(FILENAME_FILTEROUT); | 320 | + command.append(path_contents).append("/").append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep -e "). |
| 321 | + append(FIND_SENTENCE).append(" -e \"").append(AUDIO_SILENT).append("\"").append(" >> ").append(path_contents).append("/").append(id).append(FILENAME_FILTEROUT); | ||
| 322 | system(command.c_str()); | 322 | system(command.c_str()); |
| 323 | //printf("\n\n---> command: %s\n\n", command.c_str()); | 323 | //printf("\n\n---> command: %s\n\n", command.c_str()); |
| 324 | 324 | ||
| 325 | count_lines = 0; | 325 | count_lines = 0; |
| 326 | 326 | ||
| 327 | string path; | 327 | string path; |
| 328 | - path.append(path_contents).append(id).append(FILENAME_FILTEROUT); | 328 | + path.append(path_contents).append("/").append(id).append(FILENAME_FILTEROUT); |
| 329 | ifstream in(path.c_str()); | 329 | ifstream in(path.c_str()); |
| 330 | string strFilter; | 330 | string strFilter; |
| 331 | 331 | ||
| @@ -406,15 +406,15 @@ bool Recognize::isFinished() { | @@ -406,15 +406,15 @@ bool Recognize::isFinished() { | ||
| 406 | void Recognize::cleanFiles() { | 406 | void Recognize::cleanFiles() { |
| 407 | 407 | ||
| 408 | string command = "rm -r "; | 408 | string command = "rm -r "; |
| 409 | - command.append(path_contents).append(id).append("/audio"); | 409 | + command.append(path_contents).append("/").append(id).append("/audio"); |
| 410 | system(command.c_str()); | 410 | system(command.c_str()); |
| 411 | } | 411 | } |
| 412 | 412 | ||
| 413 | void Recognize::createDir(){ | 413 | void Recognize::createDir(){ |
| 414 | 414 | ||
| 415 | string command = "mkdir "; | 415 | string command = "mkdir "; |
| 416 | - command.append(path_contents).append(id).append("/audio") | ||
| 417 | - .append(" && mkdir ").append(path_contents).append(id).append("/audio/parts") | ||
| 418 | - .append(" && mkdir ").append(path_contents).append(id).append("/audio/origin"); | 416 | + command.append(path_contents).append("/").append(id).append("/audio") |
| 417 | + .append(" && mkdir ").append(path_contents).append("/").append(id).append("/audio/parts") | ||
| 418 | + .append(" && mkdir ").append(path_contents).append("/").append(id).append("/audio/origin"); | ||
| 419 | system(command.c_str()); | 419 | system(command.c_str()); |
| 420 | } | 420 | } |
renderer/src/include/renderer.h
| @@ -3,12 +3,12 @@ | @@ -3,12 +3,12 @@ | ||
| 3 | 3 | ||
| 4 | #include "jthread.h" | 4 | #include "jthread.h" |
| 5 | #include "dprintf.h" | 5 | #include "dprintf.h" |
| 6 | -#include "stdint.h" | ||
| 7 | #include "string.h" | 6 | #include "string.h" |
| 8 | #include <string> | 7 | #include <string> |
| 9 | #include <list> | 8 | #include <list> |
| 10 | #include <sstream> | 9 | #include <sstream> |
| 11 | #include <iostream> | 10 | #include <iostream> |
| 11 | +#include <stdint.h> | ||
| 12 | #include "listenerRenderer.h" | 12 | #include "listenerRenderer.h" |
| 13 | #include <lavidlib/net/StreamSocket.h> | 13 | #include <lavidlib/net/StreamSocket.h> |
| 14 | #include <lavidlib/net/InetAddress.h> | 14 | #include <lavidlib/net/InetAddress.h> |
| @@ -17,6 +17,7 @@ | @@ -17,6 +17,7 @@ | ||
| 17 | #include <lavidlib/net/SocketException.h> | 17 | #include <lavidlib/net/SocketException.h> |
| 18 | 18 | ||
| 19 | #define PATH_RENDERER "vlibras_user/unityVideo/" | 19 | #define PATH_RENDERER "vlibras_user/unityVideo/" |
| 20 | +#define PATH_SCREENS "vlibras_user/.config/unity3d/LAViD/VLibrasPlayer/" | ||
| 20 | #define END_FLAG "FINALIZE" | 21 | #define END_FLAG "FINALIZE" |
| 21 | #define HOST "127.0.0.1" | 22 | #define HOST "127.0.0.1" |
| 22 | #define PORTNO 5555 | 23 | #define PORTNO 5555 |
| @@ -27,7 +28,7 @@ using namespace std; | @@ -27,7 +28,7 @@ using namespace std; | ||
| 27 | 28 | ||
| 28 | class Renderer : public Thread { | 29 | class Renderer : public Thread { |
| 29 | public: | 30 | public: |
| 30 | - Renderer(char* filename); | 31 | + Renderer(char* videoPath, char* user_id); |
| 31 | ~Renderer(); | 32 | ~Renderer(); |
| 32 | 33 | ||
| 33 | bool isSending(); | 34 | bool isSending(); |
| @@ -44,14 +45,17 @@ private: | @@ -44,14 +45,17 @@ private: | ||
| 44 | int count_task; | 45 | int count_task; |
| 45 | int glosa_processed; | 46 | int glosa_processed; |
| 46 | 47 | ||
| 47 | - char* output; | 48 | + char* folder_id; |
| 49 | + char* path_video; | ||
| 48 | string glosa_copy; | 50 | string glosa_copy; |
| 49 | 51 | ||
| 50 | - void notifyListeners(); | 52 | + void render(); |
| 51 | void sendGlosa(); | 53 | void sendGlosa(); |
| 54 | + void notifyListeners(); | ||
| 52 | void connectToUnity(); | 55 | void connectToUnity(); |
| 53 | - void waitScreenShots(); | ||
| 54 | void serverInitialize(); | 56 | void serverInitialize(); |
| 57 | + void waitScreenShots(); | ||
| 58 | + void cleanFiles(); | ||
| 55 | }; | 59 | }; |
| 56 | 60 | ||
| 57 | #endif /* RENDERER_H */ | 61 | #endif /* RENDERER_H */ |
renderer/src/renderer.cpp
| 1 | #include "renderer.h" | 1 | #include "renderer.h" |
| 2 | 2 | ||
| 3 | -Renderer::Renderer(char* filename) { | ||
| 4 | - this->output = filename; | ||
| 5 | - // serverInitialize(); | 3 | +Renderer::Renderer(char* videoPath, char* user_id) { |
| 4 | + this->folder_id = user_id; | ||
| 5 | + this->path_video = videoPath; | ||
| 6 | + //serverInitialize(); | ||
| 6 | running = true; | 7 | running = true; |
| 7 | count_task = 0; | 8 | count_task = 0; |
| 8 | glosa_processed = 0; | 9 | glosa_processed = 0; |
| @@ -20,7 +21,7 @@ Renderer::~Renderer() { | @@ -20,7 +21,7 @@ Renderer::~Renderer() { | ||
| 20 | 21 | ||
| 21 | void Renderer::serverInitialize(){ | 22 | void Renderer::serverInitialize(){ |
| 22 | string render = "./render.sh "; | 23 | string render = "./render.sh "; |
| 23 | - render.append(output).append(" \"VLIBRAS\"").append(" 1920 1080").append(" 1").append(" 30"); | 24 | + render.append(folder_id).append(" \"VLIBRAS\"").append(" 1920 1080").append(" 1").append(" 30"); |
| 24 | 25 | ||
| 25 | string command = "cd "; | 26 | string command = "cd "; |
| 26 | char* shPath; | 27 | char* shPath; |
| @@ -31,27 +32,16 @@ void Renderer::serverInitialize(){ | @@ -31,27 +32,16 @@ void Renderer::serverInitialize(){ | ||
| 31 | command.append(PATH_RENDERER); | 32 | command.append(PATH_RENDERER); |
| 32 | 33 | ||
| 33 | command.append(" && ").append(render); | 34 | command.append(" && ").append(render); |
| 34 | - cout << command << endl; | ||
| 35 | system(command.c_str()); | 35 | system(command.c_str()); |
| 36 | - // sleep(1); | ||
| 37 | -} | ||
| 38 | - | ||
| 39 | -void Renderer::addListener(ListenerRenderer* listener) { | ||
| 40 | - listeners->push_back(listener); | ||
| 41 | -} | ||
| 42 | - | ||
| 43 | -void Renderer::notifyListeners() { | ||
| 44 | - for (list<ListenerRenderer*>::iterator i = listeners->begin(); i != listeners->end(); i++) { | ||
| 45 | - (*i)->notifyEndOfRenderization(); | ||
| 46 | - } | 36 | + sleep(2); |
| 47 | } | 37 | } |
| 48 | 38 | ||
| 49 | void Renderer::receiveGlosa(std::string glosa, int64_t pts) { | 39 | void Renderer::receiveGlosa(std::string glosa, int64_t pts) { |
| 50 | glosa_copy = glosa; | 40 | glosa_copy = glosa; |
| 51 | - stringstream ss; | ||
| 52 | - ss << pts; | ||
| 53 | - glosa_copy += "#"; // '#' para identificar que vem um pts | ||
| 54 | - glosa_copy += ss.str(); | 41 | + ostringstream oss; |
| 42 | + oss << pts; | ||
| 43 | + glosa_copy += "#"; // formato da string enviada p/ o player: Glosa#pts | ||
| 44 | + glosa_copy += oss.str(); | ||
| 55 | count_task++; | 45 | count_task++; |
| 56 | } | 46 | } |
| 57 | 47 | ||
| @@ -90,20 +80,29 @@ void Renderer::connectToUnity() { | @@ -90,20 +80,29 @@ void Renderer::connectToUnity() { | ||
| 90 | } | 80 | } |
| 91 | 81 | ||
| 92 | void Renderer::waitScreenShots() { | 82 | void Renderer::waitScreenShots() { |
| 83 | + DPRINTF("[AGUARDE] Gerando vídeo...\n"); | ||
| 93 | char* endgeneration = new char[strlen(END_FLAG)+1]; | 84 | char* endgeneration = new char[strlen(END_FLAG)+1]; |
| 94 | int connected; | 85 | int connected; |
| 95 | try{ | 86 | try{ |
| 96 | do{ | 87 | do{ |
| 97 | - | ||
| 98 | connected = core_socket->read(endgeneration, sizeof(endgeneration)); | 88 | connected = core_socket->read(endgeneration, sizeof(endgeneration)); |
| 99 | }while(strcmp(endgeneration, END_FLAG) != 0 && connected != 0); | 89 | }while(strcmp(endgeneration, END_FLAG) != 0 && connected != 0); |
| 100 | core_socket->close(); | 90 | core_socket->close(); |
| 101 | - notifyListeners(); | ||
| 102 | }catch(IOException &ex){ | 91 | }catch(IOException &ex){ |
| 103 | throw RuntimeException(ex.getMessage().c_str()); | 92 | throw RuntimeException(ex.getMessage().c_str()); |
| 104 | } | 93 | } |
| 105 | } | 94 | } |
| 106 | 95 | ||
| 96 | +void Renderer::addListener(ListenerRenderer* listener) { | ||
| 97 | + listeners->push_back(listener); | ||
| 98 | +} | ||
| 99 | + | ||
| 100 | +void Renderer::notifyListeners() { | ||
| 101 | + for (list<ListenerRenderer*>::iterator i = listeners->begin(); i != listeners->end(); i++) { | ||
| 102 | + (*i)->notifyEndOfRenderization(); | ||
| 103 | + } | ||
| 104 | +} | ||
| 105 | + | ||
| 107 | void Renderer::finalize() { | 106 | void Renderer::finalize() { |
| 108 | while(glosa_processed < count_task) | 107 | while(glosa_processed < count_task) |
| 109 | usleep(10000); | 108 | usleep(10000); |
| @@ -129,8 +128,24 @@ void Renderer::Run() { | @@ -129,8 +128,24 @@ void Renderer::Run() { | ||
| 129 | sendGlosa(); | 128 | sendGlosa(); |
| 130 | } | 129 | } |
| 131 | waitScreenShots(); | 130 | waitScreenShots(); |
| 131 | + render(); | ||
| 132 | + cleanFiles(); | ||
| 132 | }catch(lavidlib::RuntimeException &ex){ | 133 | }catch(lavidlib::RuntimeException &ex){ |
| 133 | DDDDPRINTF("Erro: %s\n", ex.getMessage().c_str()); | 134 | DDDDPRINTF("Erro: %s\n", ex.getMessage().c_str()); |
| 134 | throw RuntimeException(ex.getMessage().c_str()); | 135 | throw RuntimeException(ex.getMessage().c_str()); |
| 135 | } | 136 | } |
| 137 | +} | ||
| 138 | + | ||
| 139 | +void Renderer::render() { | ||
| 140 | + string command = "avconv -loglevel quiet -framerate 30 -i "; | ||
| 141 | + command.append(PATH_SCREENS).append(folder_id).append("/frame_%d.png ") | ||
| 142 | + .append("-vcodec libx264 -pix_fmt yuv420p ").append(path_video); | ||
| 143 | + system(command.c_str()); | ||
| 144 | + notifyListeners(); | ||
| 145 | +} | ||
| 146 | + | ||
| 147 | +void Renderer::cleanFiles() { | ||
| 148 | + string clean = "rm -rf "; | ||
| 149 | + clean.append(PATH_SCREENS).append(user_id).append("/"); | ||
| 150 | + system(clean.c_str()); | ||
| 136 | } | 151 | } |
| 137 | \ No newline at end of file | 152 | \ No newline at end of file |
servico/src/include/serviceWindowGeneration.h
| @@ -20,9 +20,9 @@ | @@ -20,9 +20,9 @@ | ||
| 20 | 20 | ||
| 21 | #define DEVELOPER "devel" | 21 | #define DEVELOPER "devel" |
| 22 | #define PRODUCTION "prod" | 22 | #define PRODUCTION "prod" |
| 23 | -#define PATH_DEVEL_CONTENTS "vlibras_user/vlibras-contents/videos/" | ||
| 24 | -#define PATH_DEVEL_UPLOADS "vlibras_user/vlibras-contents/uploads/" | ||
| 25 | -#define PATH_VBOX_UPLOADS "vlibras_user/.vlibras-conf/uploads/" | 23 | +#define PATH_DEVEL_CONTENTS "vlibras_user/vlibras-contents/videos" |
| 24 | +#define PATH_DEVEL_UPLOADS "vlibras_user/vlibras-contents/uploads" | ||
| 25 | +#define PATH_VBOX_UPLOADS "vlibras_user/.vlibras-conf/uploads" | ||
| 26 | #define PATH_CONF_FILE "vlibras_user/.vlibras-conf/params.json" | 26 | #define PATH_CONF_FILE "vlibras_user/.vlibras-conf/params.json" |
| 27 | #define MAX_SIZE_PATH 256 | 27 | #define MAX_SIZE_PATH 256 |
| 28 | 28 | ||
| @@ -49,6 +49,7 @@ protected: | @@ -49,6 +49,7 @@ protected: | ||
| 49 | 49 | ||
| 50 | char* path_input; | 50 | char* path_input; |
| 51 | char* path_client; | 51 | char* path_client; |
| 52 | + char* path_libras; | ||
| 52 | char* path_contents; | 53 | char* path_contents; |
| 53 | char* path_uploads; | 54 | char* path_uploads; |
| 54 | char* client_type; | 55 | char* client_type; |
| @@ -66,6 +67,7 @@ protected: | @@ -66,6 +67,7 @@ protected: | ||
| 66 | virtual void setPathContents() = 0; | 67 | virtual void setPathContents() = 0; |
| 67 | 68 | ||
| 68 | public: | 69 | public: |
| 70 | + virtual void setPathLibras() = 0; | ||
| 69 | virtual void initialize() = 0; | 71 | virtual void initialize() = 0; |
| 70 | virtual bool isFinished() = 0; | 72 | virtual bool isFinished() = 0; |
| 71 | virtual void notifyTranslator(unsigned char* text) = 0; | 73 | virtual void notifyTranslator(unsigned char* text) = 0; |
servico/src/include/serviceWindowGenerationFromRec.h
| @@ -15,6 +15,7 @@ private: | @@ -15,6 +15,7 @@ private: | ||
| 15 | 15 | ||
| 16 | void addPTS(int64_t pts); | 16 | void addPTS(int64_t pts); |
| 17 | void setSizeOfSubtitles(int sub_size); | 17 | void setSizeOfSubtitles(int sub_size); |
| 18 | + void setPathLibras(); | ||
| 18 | void setPathContents(); | 19 | void setPathContents(); |
| 19 | bool isRunning(); | 20 | bool isRunning(); |
| 20 | public: | 21 | public: |
servico/src/include/serviceWindowGenerationFromSRT.h
| @@ -18,6 +18,7 @@ private: | @@ -18,6 +18,7 @@ private: | ||
| 18 | 18 | ||
| 19 | void addPTS(int64_t pts); | 19 | void addPTS(int64_t pts); |
| 20 | void setSizeOfSubtitles(int sub_size); | 20 | void setSizeOfSubtitles(int sub_size); |
| 21 | + void setPathLibras(); | ||
| 21 | void setPathContents(); | 22 | void setPathContents(); |
| 22 | bool isRunning(); | 23 | bool isRunning(); |
| 23 | public: | 24 | public: |
servico/src/include/serviceWindowGenerationFromText.h
| @@ -14,6 +14,7 @@ private: | @@ -14,6 +14,7 @@ private: | ||
| 14 | ExtratorTXT* extratorTXT; | 14 | ExtratorTXT* extratorTXT; |
| 15 | 15 | ||
| 16 | void setSizeOfSubtitles(int sub_size); | 16 | void setSizeOfSubtitles(int sub_size); |
| 17 | + void setPathLibras(); | ||
| 17 | void setPathContents(); | 18 | void setPathContents(); |
| 18 | bool isRunning(); | 19 | bool isRunning(); |
| 19 | public: | 20 | public: |
servico/src/serviceWindowGenerationFromRec.cpp
| @@ -15,7 +15,6 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec( | @@ -15,7 +15,6 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec( | ||
| 15 | vetor_pts = new vector<int64_t >(); | 15 | vetor_pts = new vector<int64_t >(); |
| 16 | rec = new Recognize(pathVideo, id, rate); | 16 | rec = new Recognize(pathVideo, id, rate); |
| 17 | tradutor = new TradutorPortGlosa(); | 17 | tradutor = new TradutorPortGlosa(); |
| 18 | - renderer = new Renderer(this->user_id); | ||
| 19 | running = true; | 18 | running = true; |
| 20 | finish = false; | 19 | finish = false; |
| 21 | DPRINTF("Done!\n"); | 20 | DPRINTF("Done!\n"); |
| @@ -37,7 +36,6 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec( | @@ -37,7 +36,6 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec( | ||
| 37 | vetor_pts = new vector<int64_t >(); | 36 | vetor_pts = new vector<int64_t >(); |
| 38 | rec = new Recognize(path_input, id); | 37 | rec = new Recognize(path_input, id); |
| 39 | tradutor = new TradutorPortGlosa(); | 38 | tradutor = new TradutorPortGlosa(); |
| 40 | - renderer = new Renderer(this->user_id); | ||
| 41 | try{ | 39 | try{ |
| 42 | setPathContents(); | 40 | setPathContents(); |
| 43 | }catch(RuntimeException ex){ | 41 | }catch(RuntimeException ex){ |
| @@ -80,6 +78,19 @@ void ServiceWindowGenerationFromRec::setPathContents(){ | @@ -80,6 +78,19 @@ void ServiceWindowGenerationFromRec::setPathContents(){ | ||
| 80 | } | 78 | } |
| 81 | } | 79 | } |
| 82 | 80 | ||
| 81 | +void ServiceWindowGenerationFromRec::setPathLibras() { | ||
| 82 | + string final_path = ""; | ||
| 83 | + path_libras = new char[MAX_SIZE_PATH]; | ||
| 84 | + | ||
| 85 | + if(this->service_type == SERVICE_TYPE_REC) | ||
| 86 | + final_path.append(this->path_uploads).append("/").append(this->user_id); | ||
| 87 | + else | ||
| 88 | + final_path.append(this->path_contents); | ||
| 89 | + | ||
| 90 | + final_path.append("/").append(this->user_id).append(".mp4"); | ||
| 91 | + strcpy(this->path_libras, final_path.c_str()); | ||
| 92 | +} | ||
| 93 | + | ||
| 83 | void ServiceWindowGenerationFromRec::setSizeOfSubtitles(int sub_size){ | 94 | void ServiceWindowGenerationFromRec::setSizeOfSubtitles(int sub_size){ |
| 84 | numero_legendas = sub_size; | 95 | numero_legendas = sub_size; |
| 85 | if (legendas_enviadas >= numero_legendas){ | 96 | if (legendas_enviadas >= numero_legendas){ |
| @@ -107,6 +118,7 @@ void ServiceWindowGenerationFromRec::notifyTextRecognized(unsigned char* text, i | @@ -107,6 +118,7 @@ void ServiceWindowGenerationFromRec::notifyTextRecognized(unsigned char* text, i | ||
| 107 | 118 | ||
| 108 | void ServiceWindowGenerationFromRec::notifyTranslation(vector<string> * glosas) { | 119 | void ServiceWindowGenerationFromRec::notifyTranslation(vector<string> * glosas) { |
| 109 | string glosa = ""; | 120 | string glosa = ""; |
| 121 | + int64_t pts_notificado; | ||
| 110 | for (int i = 0; i < glosas->size(); i++) { | 122 | for (int i = 0; i < glosas->size(); i++) { |
| 111 | locale loc; | 123 | locale loc; |
| 112 | string glosa_lower = ""; | 124 | string glosa_lower = ""; |
| @@ -115,9 +127,8 @@ void ServiceWindowGenerationFromRec::notifyTranslation(vector<string> * glosas) | @@ -115,9 +127,8 @@ void ServiceWindowGenerationFromRec::notifyTranslation(vector<string> * glosas) | ||
| 115 | } | 127 | } |
| 116 | glosa += glosa_lower; | 128 | glosa += glosa_lower; |
| 117 | glosa += " "; | 129 | glosa += " "; |
| 118 | - | 130 | + pts_notificado = vetor_pts->front(); |
| 119 | } | 131 | } |
| 120 | - int64_t pts_notificado = vetor_pts->front(); | ||
| 121 | while(renderer->isSending()) | 132 | while(renderer->isSending()) |
| 122 | usleep(10000); | 133 | usleep(10000); |
| 123 | try{ | 134 | try{ |
| @@ -131,6 +142,11 @@ void ServiceWindowGenerationFromRec::notifyTranslation(vector<string> * glosas) | @@ -131,6 +142,11 @@ void ServiceWindowGenerationFromRec::notifyTranslation(vector<string> * glosas) | ||
| 131 | } | 142 | } |
| 132 | 143 | ||
| 133 | void ServiceWindowGenerationFromRec::notifyEndOfRenderization() { | 144 | void ServiceWindowGenerationFromRec::notifyEndOfRenderization() { |
| 145 | + if(this->service_type == SERVICE_TYPE_REC){ | ||
| 146 | + mixer = new Mixer(); | ||
| 147 | + mixer->initialize(this->path_input, this->path_libras, this->position, this->size, | ||
| 148 | + this->transparency, this->user_id, this->path_uploads, this->path_contents); | ||
| 149 | + } | ||
| 134 | running = false; | 150 | running = false; |
| 135 | } | 151 | } |
| 136 | 152 | ||
| @@ -149,9 +165,11 @@ bool ServiceWindowGenerationFromRec::isFinished(){ | @@ -149,9 +165,11 @@ bool ServiceWindowGenerationFromRec::isFinished(){ | ||
| 149 | 165 | ||
| 150 | void ServiceWindowGenerationFromRec::initialize(){ | 166 | void ServiceWindowGenerationFromRec::initialize(){ |
| 151 | DPRINTF("Service REC Initialize.\n"); | 167 | DPRINTF("Service REC Initialize.\n"); |
| 152 | - | 168 | + setPathLibras(); |
| 153 | rec->addListener(this); | 169 | rec->addListener(this); |
| 154 | tradutor->addListener(this); | 170 | tradutor->addListener(this); |
| 171 | + | ||
| 172 | + renderer = new Renderer(this->path_libras ,this->user_id); | ||
| 155 | renderer->addListener(this); | 173 | renderer->addListener(this); |
| 156 | 174 | ||
| 157 | try{ | 175 | try{ |
servico/src/serviceWindowGenerationFromSRT.cpp
| @@ -16,7 +16,6 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo, | @@ -16,7 +16,6 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo, | ||
| 16 | legendas_enviadas = 0; | 16 | legendas_enviadas = 0; |
| 17 | vetor_pts = new vector<int64_t >(); | 17 | vetor_pts = new vector<int64_t >(); |
| 18 | tradutor = new TradutorPortGlosa(); | 18 | tradutor = new TradutorPortGlosa(); |
| 19 | - renderer = new Renderer(this->user_id); | ||
| 20 | extrator_factory = new ExtratorFactory(); | 19 | extrator_factory = new ExtratorFactory(); |
| 21 | try{ | 20 | try{ |
| 22 | setPathContents(); | 21 | setPathContents(); |
| @@ -29,7 +28,6 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo, | @@ -29,7 +28,6 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo, | ||
| 29 | } | 28 | } |
| 30 | 29 | ||
| 31 | ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, int transp, char* id, char* client, int serviceType) { | 30 | ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, int transp, char* id, char* client, int serviceType) { |
| 32 | - | ||
| 33 | this->path_srt = pathSRT; | 31 | this->path_srt = pathSRT; |
| 34 | this->transparency = transp; | 32 | this->transparency = transp; |
| 35 | this->user_id = id; | 33 | this->user_id = id; |
| @@ -39,7 +37,6 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, in | @@ -39,7 +37,6 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, in | ||
| 39 | legendas_enviadas = 0; | 37 | legendas_enviadas = 0; |
| 40 | vetor_pts = new vector<int64_t >(); | 38 | vetor_pts = new vector<int64_t >(); |
| 41 | tradutor = new TradutorPortGlosa(); | 39 | tradutor = new TradutorPortGlosa(); |
| 42 | - renderer = new Renderer(this->user_id); | ||
| 43 | extrator_factory = new ExtratorFactory(); | 40 | extrator_factory = new ExtratorFactory(); |
| 44 | try{ | 41 | try{ |
| 45 | setPathContents(); | 42 | setPathContents(); |
| @@ -64,6 +61,7 @@ ServiceWindowGenerationFromSRT::~ServiceWindowGenerationFromSRT() { | @@ -64,6 +61,7 @@ ServiceWindowGenerationFromSRT::~ServiceWindowGenerationFromSRT() { | ||
| 64 | void ServiceWindowGenerationFromSRT::setPathContents() { | 61 | void ServiceWindowGenerationFromSRT::setPathContents() { |
| 65 | if(strcmp(client_type,DEVELOPER) == 0){ | 62 | if(strcmp(client_type,DEVELOPER) == 0){ |
| 66 | this->path_contents = PATH_DEVEL_CONTENTS; | 63 | this->path_contents = PATH_DEVEL_CONTENTS; |
| 64 | + this->path_uploads = PATH_DEVEL_UPLOADS; | ||
| 67 | }else if(strcmp(client_type, PRODUCTION) == 0){ | 65 | }else if(strcmp(client_type, PRODUCTION) == 0){ |
| 68 | ifstream conf_file(PATH_CONF_FILE, ifstream::binary); | 66 | ifstream conf_file(PATH_CONF_FILE, ifstream::binary); |
| 69 | parsingSuccessful = reader.parse(conf_file, root); | 67 | parsingSuccessful = reader.parse(conf_file, root); |
| @@ -74,12 +72,26 @@ void ServiceWindowGenerationFromSRT::setPathContents() { | @@ -74,12 +72,26 @@ void ServiceWindowGenerationFromSRT::setPathContents() { | ||
| 74 | string attr = root.get("storage", PATH_VBOX_UPLOADS).asString(); | 72 | string attr = root.get("storage", PATH_VBOX_UPLOADS).asString(); |
| 75 | this->path_contents = new char[MAX_SIZE_PATH]; | 73 | this->path_contents = new char[MAX_SIZE_PATH]; |
| 76 | strcpy(this->path_contents, attr.c_str()); | 74 | strcpy(this->path_contents, attr.c_str()); |
| 75 | + this->path_uploads = PATH_VBOX_UPLOADS; | ||
| 77 | conf_file.close(); | 76 | conf_file.close(); |
| 78 | }else{ | 77 | }else{ |
| 79 | throw ServiceException("Invalid client!"); | 78 | throw ServiceException("Invalid client!"); |
| 80 | } | 79 | } |
| 81 | } | 80 | } |
| 82 | 81 | ||
| 82 | +void ServiceWindowGenerationFromSRT::setPathLibras() { | ||
| 83 | + string final_path = ""; | ||
| 84 | + path_libras = new char[MAX_SIZE_PATH]; | ||
| 85 | + | ||
| 86 | + if(this->service_type == SERVICE_TYPE_SRT) | ||
| 87 | + final_path.append(this->path_uploads).append("/").append(this->user_id); | ||
| 88 | + else | ||
| 89 | + final_path.append(this->path_contents); | ||
| 90 | + | ||
| 91 | + final_path.append("/").append(this->user_id).append(".mp4"); | ||
| 92 | + strcpy(this->path_libras, final_path.c_str()); | ||
| 93 | +} | ||
| 94 | + | ||
| 83 | void ServiceWindowGenerationFromSRT::setSizeOfSubtitles(int sub_size) { | 95 | void ServiceWindowGenerationFromSRT::setSizeOfSubtitles(int sub_size) { |
| 84 | numero_legendas = sub_size; | 96 | numero_legendas = sub_size; |
| 85 | if (legendas_enviadas >= numero_legendas){ | 97 | if (legendas_enviadas >= numero_legendas){ |
| @@ -110,6 +122,7 @@ void ServiceWindowGenerationFromSRT::notifySubtitle(unsigned char *subtitle, int | @@ -110,6 +122,7 @@ void ServiceWindowGenerationFromSRT::notifySubtitle(unsigned char *subtitle, int | ||
| 110 | 122 | ||
| 111 | void ServiceWindowGenerationFromSRT::notifyTranslation(vector<string> * glosas) { | 123 | void ServiceWindowGenerationFromSRT::notifyTranslation(vector<string> * glosas) { |
| 112 | string glosa = ""; | 124 | string glosa = ""; |
| 125 | + int64_t pts_notificado; | ||
| 113 | for (int i = 0; i < glosas->size(); i++) { | 126 | for (int i = 0; i < glosas->size(); i++) { |
| 114 | locale loc; | 127 | locale loc; |
| 115 | string glosa_lower = ""; | 128 | string glosa_lower = ""; |
| @@ -118,9 +131,8 @@ void ServiceWindowGenerationFromSRT::notifyTranslation(vector<string> * glosas) | @@ -118,9 +131,8 @@ void ServiceWindowGenerationFromSRT::notifyTranslation(vector<string> * glosas) | ||
| 118 | } | 131 | } |
| 119 | glosa += glosa_lower; | 132 | glosa += glosa_lower; |
| 120 | glosa += " "; | 133 | glosa += " "; |
| 121 | - | 134 | + pts_notificado = vetor_pts->front(); |
| 122 | } | 135 | } |
| 123 | - int64_t pts_notificado = vetor_pts->front(); | ||
| 124 | while(renderer->isSending()) | 136 | while(renderer->isSending()) |
| 125 | usleep(10000); | 137 | usleep(10000); |
| 126 | try{ | 138 | try{ |
| @@ -134,6 +146,11 @@ void ServiceWindowGenerationFromSRT::notifyTranslation(vector<string> * glosas) | @@ -134,6 +146,11 @@ void ServiceWindowGenerationFromSRT::notifyTranslation(vector<string> * glosas) | ||
| 134 | } | 146 | } |
| 135 | 147 | ||
| 136 | void ServiceWindowGenerationFromSRT::notifyEndOfRenderization() { | 148 | void ServiceWindowGenerationFromSRT::notifyEndOfRenderization() { |
| 149 | + if(this->service_type == SERVICE_TYPE_SRT){ | ||
| 150 | + mixer = new Mixer(); | ||
| 151 | + mixer->initialize(this->path_input, this->path_libras, this->position, this->size, | ||
| 152 | + this->transparency, this->user_id, this->path_uploads, this->path_contents); | ||
| 153 | + } | ||
| 137 | this->running = false; | 154 | this->running = false; |
| 138 | } | 155 | } |
| 139 | 156 | ||
| @@ -152,11 +169,14 @@ bool ServiceWindowGenerationFromSRT::isFinished() { | @@ -152,11 +169,14 @@ bool ServiceWindowGenerationFromSRT::isFinished() { | ||
| 152 | 169 | ||
| 153 | void ServiceWindowGenerationFromSRT::initialize() { | 170 | void ServiceWindowGenerationFromSRT::initialize() { |
| 154 | DPRINTF("Service SRT Initialize.\n"); | 171 | DPRINTF("Service SRT Initialize.\n"); |
| 172 | + setPathLibras(); | ||
| 155 | extratorSRT = (ExtratorSRT*) extrator_factory->getExtrator(Extrator::SRT); | 173 | extratorSRT = (ExtratorSRT*) extrator_factory->getExtrator(Extrator::SRT); |
| 156 | extratorSRT->addListener(this); | 174 | extratorSRT->addListener(this); |
| 157 | extratorSRT->setFilePath(path_srt); | 175 | extratorSRT->setFilePath(path_srt); |
| 158 | 176 | ||
| 159 | tradutor->addListener(this); | 177 | tradutor->addListener(this); |
| 178 | + | ||
| 179 | + renderer = new Renderer(this->path_libras ,this->user_id); | ||
| 160 | renderer->addListener(this); | 180 | renderer->addListener(this); |
| 161 | 181 | ||
| 162 | try{ | 182 | try{ |
servico/src/serviceWindowGenerationFromText.cpp
| @@ -9,9 +9,7 @@ ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile, | @@ -9,9 +9,7 @@ ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile, | ||
| 9 | finish = false; | 9 | finish = false; |
| 10 | numero_legendas = INT_MAX; | 10 | numero_legendas = INT_MAX; |
| 11 | legendas_enviadas = 0; | 11 | legendas_enviadas = 0; |
| 12 | - vetor_pts = new vector<int64_t >(); | ||
| 13 | tradutor = new TradutorPortGlosa(); | 12 | tradutor = new TradutorPortGlosa(); |
| 14 | - renderer = new Renderer(this->user_id); | ||
| 15 | extrator_factory = new ExtratorFactory(); | 13 | extrator_factory = new ExtratorFactory(); |
| 16 | try{ | 14 | try{ |
| 17 | setPathContents(); | 15 | setPathContents(); |
| @@ -24,7 +22,6 @@ ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile, | @@ -24,7 +22,6 @@ ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile, | ||
| 24 | } | 22 | } |
| 25 | 23 | ||
| 26 | ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() { | 24 | ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() { |
| 27 | - free(vetor_pts); | ||
| 28 | if (tradutor) delete tradutor; | 25 | if (tradutor) delete tradutor; |
| 29 | if (renderer) delete renderer; | 26 | if (renderer) delete renderer; |
| 30 | if (extratorTXT)delete extratorTXT; | 27 | if (extratorTXT)delete extratorTXT; |
| @@ -35,6 +32,7 @@ ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() { | @@ -35,6 +32,7 @@ ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() { | ||
| 35 | void ServiceWindowGenerationFromText::setPathContents() { | 32 | void ServiceWindowGenerationFromText::setPathContents() { |
| 36 | if(strcmp(client_type,DEVELOPER) == 0){ | 33 | if(strcmp(client_type,DEVELOPER) == 0){ |
| 37 | this->path_contents = PATH_DEVEL_CONTENTS; | 34 | this->path_contents = PATH_DEVEL_CONTENTS; |
| 35 | + //this->path_uploads = PATH_DEVEL_UPLOADS; | ||
| 38 | }else if(strcmp(client_type, PRODUCTION) == 0){ | 36 | }else if(strcmp(client_type, PRODUCTION) == 0){ |
| 39 | ifstream conf_file(PATH_CONF_FILE, ifstream::binary); | 37 | ifstream conf_file(PATH_CONF_FILE, ifstream::binary); |
| 40 | parsingSuccessful = reader.parse(conf_file, root); | 38 | parsingSuccessful = reader.parse(conf_file, root); |
| @@ -44,11 +42,20 @@ void ServiceWindowGenerationFromText::setPathContents() { | @@ -44,11 +42,20 @@ void ServiceWindowGenerationFromText::setPathContents() { | ||
| 44 | string attr = root.get("storage", PATH_VBOX_UPLOADS).asString(); | 42 | string attr = root.get("storage", PATH_VBOX_UPLOADS).asString(); |
| 45 | this->path_contents = new char[MAX_SIZE_PATH]; | 43 | this->path_contents = new char[MAX_SIZE_PATH]; |
| 46 | strcpy(this->path_contents, attr.c_str()); | 44 | strcpy(this->path_contents, attr.c_str()); |
| 45 | + //this->path_uploads = PATH_VBOX_UPLOADS; | ||
| 47 | }else{ | 46 | }else{ |
| 48 | throw ServiceException("Invalid client!"); | 47 | throw ServiceException("Invalid client!"); |
| 49 | } | 48 | } |
| 50 | } | 49 | } |
| 51 | 50 | ||
| 51 | +void ServiceWindowGenerationFromText::setPathLibras() { | ||
| 52 | + string final_path = ""; | ||
| 53 | + path_libras = new char[MAX_SIZE_PATH]; | ||
| 54 | + final_path.append(this->path_contents).append("/"). | ||
| 55 | + append(this->user_id).append(".mp4"); | ||
| 56 | + strcpy(this->path_libras, final_path.c_str()); | ||
| 57 | +} | ||
| 58 | + | ||
| 52 | void ServiceWindowGenerationFromText::setSizeOfSubtitles(int sub_size) { | 59 | void ServiceWindowGenerationFromText::setSizeOfSubtitles(int sub_size) { |
| 53 | numero_legendas = sub_size; | 60 | numero_legendas = sub_size; |
| 54 | if (legendas_enviadas >= numero_legendas){ | 61 | if (legendas_enviadas >= numero_legendas){ |
| @@ -79,10 +86,9 @@ void ServiceWindowGenerationFromText::notifyTranslation(vector<string> * glosas) | @@ -79,10 +86,9 @@ void ServiceWindowGenerationFromText::notifyTranslation(vector<string> * glosas) | ||
| 79 | glosa += glosa_lower; | 86 | glosa += glosa_lower; |
| 80 | glosa += " "; | 87 | glosa += " "; |
| 81 | } | 88 | } |
| 82 | - while(renderer->isSending()){ | 89 | + while(renderer->isSending()){ // aguarda o renderizador processar a glosa anterior |
| 83 | usleep(10000); | 90 | usleep(10000); |
| 84 | - } // aguarda o renderizador processar a glosa anterior | ||
| 85 | - | 91 | + } |
| 86 | try{ | 92 | try{ |
| 87 | renderer->receiveGlosa(glosa, (int64_t) -1); | 93 | renderer->receiveGlosa(glosa, (int64_t) -1); |
| 88 | legendas_enviadas++; | 94 | legendas_enviadas++; |
| @@ -110,11 +116,14 @@ bool ServiceWindowGenerationFromText::isFinished() { | @@ -110,11 +116,14 @@ bool ServiceWindowGenerationFromText::isFinished() { | ||
| 110 | 116 | ||
| 111 | void ServiceWindowGenerationFromText::initialize() { | 117 | void ServiceWindowGenerationFromText::initialize() { |
| 112 | DPRINTF("Service Text Initialize.\n"); | 118 | DPRINTF("Service Text Initialize.\n"); |
| 119 | + setPathLibras(); | ||
| 113 | extratorTXT = (ExtratorTXT*) extrator_factory->getExtrator(Extrator::TXT); | 120 | extratorTXT = (ExtratorTXT*) extrator_factory->getExtrator(Extrator::TXT); |
| 114 | extratorTXT->addListener(this); | 121 | extratorTXT->addListener(this); |
| 115 | extratorTXT->setFilePath(path_input); | 122 | extratorTXT->setFilePath(path_input); |
| 116 | 123 | ||
| 117 | tradutor->addListener(this); | 124 | tradutor->addListener(this); |
| 125 | + | ||
| 126 | + renderer = new Renderer(this->path_libras, this->user_id); | ||
| 118 | renderer->addListener(this); | 127 | renderer->addListener(this); |
| 119 | 128 | ||
| 120 | try{ | 129 | try{ |