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