Commit 6cc9784d3f1ea06353cb136e5c77b855c8fa8ade
1 parent
5c626b53
Exists in
master
and in
1 other branch
Modificações para comunicação com o novo Player
Showing
5 changed files
with
197 additions
and
215 deletions
Show diff stats
renderer/src/include/renderer.h
... | ... | @@ -8,30 +8,34 @@ |
8 | 8 | #ifndef RENDERER_H |
9 | 9 | #define RENDERER_H |
10 | 10 | |
11 | -#include "jthread.h" | |
12 | -#include "logging.h" | |
13 | -#include "string.h" | |
14 | -#include <string> | |
15 | 11 | #include <list> |
12 | +#include <queue> | |
16 | 13 | #include <sstream> |
17 | -#include <iostream> | |
18 | -#include <unistd.h> | |
19 | 14 | #include <stdint.h> |
15 | +#include <unistd.h> | |
16 | +#include "string.h" | |
17 | +#include "jthread.h" | |
18 | +#include "logging.h" | |
20 | 19 | #include "listenerRenderer.h" |
21 | -#include <lavidlib/net/StreamSocket.h> | |
22 | 20 | #include <lavidlib/net/InetAddress.h> |
21 | +#include <lavidlib/net/StreamSocket.h> | |
22 | +#include <lavidlib/net/SocketException.h> | |
23 | 23 | #include <lavidlib/base/RuntimeException.h> |
24 | 24 | #include <lavidlib/net/UnknownHostException.h> |
25 | -#include <lavidlib/net/SocketException.h> | |
26 | 25 | |
27 | -#define PATH_RENDERER "vlibras_user/unityVideo/" | |
28 | -#define PATH_SCREENS "vlibras_user/.config/unity3d/LAViD/VLibrasPlayer/" | |
29 | -#define END_FLAG "FINALIZE" | |
30 | 26 | #define HOST "0.0.0.0" |
31 | -#define PORTNO 5555 | |
27 | +#define PORT 5555 | |
28 | + | |
29 | +#define OK_FLAG "OK" | |
30 | +#define END_FLAG "FINALIZE" | |
31 | +#define BADSENTENCE "SENTENCACOMBAIXAQUALIDADE" | |
32 | +#define BADTEXT "ESCOLHER TEXTO CERTO" | |
33 | + | |
34 | +#define PATH_RENDERER "vlibras_user/unityVideo/" | |
35 | +#define PATH_SCREENS "vlibras_user/.config/unity3d/LAViD/VLibrasVideoMaker/" | |
32 | 36 | |
33 | -using namespace lavidlib; | |
34 | 37 | using namespace jthread; |
38 | +using namespace lavidlib; | |
35 | 39 | using namespace std; |
36 | 40 | using namespace util; |
37 | 41 | |
... | ... | @@ -44,26 +48,22 @@ class Renderer : public Thread { |
44 | 48 | public: |
45 | 49 | /** Construtor. |
46 | 50 | * |
47 | - * \param videoPath Abstração do path do vídeo de saída. | |
48 | - * \param user_id Identificação do usuário. | |
51 | + * \param path_contents Abstração do path do vídeo de saída. | |
52 | + * \param id Identificação do usuário. | |
49 | 53 | */ |
50 | - Renderer(char* videoPath, char* user_id); | |
54 | + Renderer(char* path_Contents, char* id); | |
51 | 55 | |
52 | 56 | /** Destrutor. */ |
53 | 57 | ~Renderer(); |
54 | 58 | |
55 | - /** Indica o status do envio da glosa para o player. | |
59 | + /** Inicia os processos do renderizador. | |
56 | 60 | * |
57 | - * \return O status do envio. | |
61 | + * Inicia o servidor do Unity Player, | |
62 | + * faz a conexão do Core com o Player | |
63 | + * e da inicio ao envio das glosas para | |
64 | + * a geração do vídeo de LIBRAS. | |
58 | 65 | */ |
59 | - bool isSending(); | |
60 | - | |
61 | - /** Recebe a glosa q será enviada para o player. | |
62 | - * | |
63 | - * \param glosa A glosa que será enviada. | |
64 | - * \param pts A etiqueta de tempo da glosa. | |
65 | - */ | |
66 | - void receiveGlosa(std::string glosa, int64_t pts); | |
66 | + void initialize(); | |
67 | 67 | |
68 | 68 | /** Adiciona ouvintes do renderer. |
69 | 69 | * |
... | ... | @@ -71,64 +71,44 @@ public: |
71 | 71 | */ |
72 | 72 | void addListener(ListenerRenderer* listener); |
73 | 73 | |
74 | - /** Finaliza o envio das glosas. | |
74 | + /** Recebe a glosa q será enviada para o player. | |
75 | 75 | * |
76 | - * Uma flag de FINALIZE é enviada para o player | |
77 | - * sinalizando que não há mais glosas para serem | |
78 | - * enviadas. | |
76 | + * \param glosa A glosa que será enviada. | |
77 | + * \param pts A etiqueta de tempo da glosa. | |
79 | 78 | */ |
80 | - void finalize(); | |
79 | + void receiveGlosa(string glosa, int64_t pts); | |
81 | 80 | |
82 | - /** Este método é chamado quando a Thread for iniciada. */ | |
83 | - void Run(); | |
84 | - | |
85 | 81 | private: |
86 | - StreamSocket* core_socket; | |
87 | - list<ListenerRenderer*> * listeners; | |
88 | - | |
89 | - bool running; | |
90 | - int count_task; | |
91 | - int glosa_processed; | |
92 | - | |
93 | - char* folder_id; | |
94 | - char* path_video; | |
95 | - string glosa_copy; | |
96 | - | |
97 | - /** | |
98 | - * Renderiza o vídeo de libras a partir | |
99 | - * das screenshots geradas pelo player. | |
100 | - */ | |
101 | - void render(); | |
82 | + char* userID; | |
83 | + char* pathOutVideo; | |
102 | 84 | |
103 | - /** Envia a glosa para o player | |
104 | - * | |
105 | - * \exception RuntimeException Se houver falha no envio da glosa. | |
106 | - */ | |
107 | - void sendGlosa(); | |
85 | + StreamSocket* cSocket; | |
86 | + queue <string> glosaQueue; | |
87 | + list<ListenerRenderer*>* listeners; | |
108 | 88 | |
109 | - /** Notifica os ouvintes sobre o fim da renderização. */ | |
110 | - void notifyListeners(); | |
89 | + /** Executa o script que inicia o servidor do Player. */ | |
90 | + void executeServerScript(); | |
111 | 91 | |
112 | - /** Faz a conexão com o player do Unity | |
113 | - * | |
114 | - * \exception RuntimeException Se a conexão for mal sucedida. | |
115 | - */ | |
116 | - void connectToUnity(); | |
92 | + /** Faz a conexão do Core com o Player. */ | |
93 | + void connectToUnityPlayer(); | |
117 | 94 | |
118 | - /** Inicializa o servidor do player do Unity. | |
119 | - * | |
120 | - * A inicialização é feita a partir de um script externo. | |
121 | - */ | |
122 | - void serverInitialize(); | |
95 | + /** Envia as glosas para o Player. */ | |
96 | + void exportGlosa(); | |
123 | 97 | |
124 | - /** Aguarda o player gerar as screenshots do vídeo de LIBRAS. | |
125 | - * | |
126 | - * \exception RuntimeException Se falhar a comunicação com o player. | |
127 | - */ | |
98 | + /** Renderiza o vídeo de LIBRAS. */ | |
99 | + void renderVideo(); | |
100 | + | |
101 | + /** Aguarda o Player capturar as screenshots. */ | |
128 | 102 | void waitScreenShots(); |
129 | 103 | |
130 | - /** Remove os arquivos temporários, gerados pelos processos.*/ | |
104 | + /** Notifica o fim da renderização. */ | |
105 | + void notifyListeners(); | |
106 | + | |
107 | + /** Deleta os arquivos temporários */ | |
131 | 108 | void cleanFiles(); |
109 | + | |
110 | + /** Chamado quando a Thread é iniciada. */ | |
111 | + void Run(); | |
132 | 112 | }; |
133 | 113 | |
134 | 114 | -#endif /* RENDERER_H */ |
115 | +#endif /* RENDERER_H */ | |
135 | 116 | \ No newline at end of file | ... | ... |
renderer/src/renderer.cpp
1 | 1 | #include "renderer.h" |
2 | 2 | |
3 | -Renderer::Renderer(char* videoPath, char* user_id) { | |
4 | - this->folder_id = user_id; | |
5 | - this->path_video = videoPath; | |
6 | - running = true; | |
7 | - count_task = 0; | |
8 | - glosa_processed = 0; | |
9 | - core_socket = new StreamSocket(); | |
10 | - listeners = new list<ListenerRenderer*>(); | |
11 | - serverInitialize(); | |
12 | - PRINTL(util::_DEBUG, "Renderer Done!\n"); | |
3 | +Renderer::Renderer(char* path_Contents, char* id) { | |
4 | + this->pathOutVideo = path_Contents; | |
5 | + this->userID = id; | |
6 | + cSocket = new StreamSocket(); | |
7 | + listeners = new list<ListenerRenderer*>(); | |
8 | + PRINTL(util::_DEBUG, "Renderer Done!\n"); | |
13 | 9 | } |
14 | 10 | |
15 | 11 | Renderer::~Renderer() { |
16 | - listeners->clear(); | |
12 | + listeners->clear(); | |
17 | 13 | delete listeners; |
18 | - if(core_socket) delete core_socket; | |
14 | + if(cSocket) delete cSocket; | |
19 | 15 | PRINTL(util::_DEBUG, "Renderer finalized!\n"); |
20 | 16 | } |
21 | 17 | |
22 | -void Renderer::serverInitialize(){ | |
23 | - string render = "python render.py "; | |
24 | - render.append(folder_id).append(" >/dev/null 2>&1 &"); | |
25 | - | |
26 | - string command = "cd "; | |
27 | - char* shPath; | |
28 | - shPath = getenv("RENDERER"); | |
29 | - if(shPath != NULL) | |
30 | - command.append(shPath); | |
31 | - else | |
32 | - command.append(PATH_RENDERER); | |
33 | - | |
34 | - command.append(" && ").append(render); | |
35 | - system(command.c_str()); | |
36 | - sleep(5); | |
18 | +void Renderer::addListener(ListenerRenderer* listener) { | |
19 | + listeners->push_back(listener); | |
37 | 20 | } |
38 | 21 | |
39 | -void Renderer::receiveGlosa(std::string glosa, int64_t pts) { | |
40 | - if(glosa == "SENTENCACOMBAIXAQUALIDADE") | |
41 | - glosa_copy = "_DEFAULT"; | |
42 | - else | |
43 | - glosa_copy = glosa; | |
44 | - | |
45 | - ostringstream oss; | |
46 | - oss << pts; | |
47 | - glosa_copy += "#"; // formato da string enviada p/ o player: Glosa#pts | |
48 | - glosa_copy += oss.str(); | |
49 | - count_task++; | |
22 | +void Renderer::notifyListeners() { | |
23 | + PRINTL(util::_DEBUG, "Renderização finalizada!\n"); | |
24 | + for (list<ListenerRenderer*>::iterator i = listeners->begin(); i != listeners->end(); i++) { | |
25 | + (*i)->notifyEndOfRenderization(); | |
26 | + } | |
50 | 27 | } |
51 | 28 | |
52 | -void Renderer::sendGlosa() { | |
53 | - try{ | |
54 | - // while(!core_socket->isConnected()) | |
55 | - // sleep(1); | |
29 | +void Renderer::executeServerScript() { | |
30 | + PRINTL(util::_DEBUG, "Executando o Script de inicialização do servidor\n"); | |
56 | 31 | |
57 | - int glosa_size = strlen(glosa_copy.c_str())+1; | |
58 | - char* glosa_buffer = new char[glosa_size]; | |
59 | - strcpy(glosa_buffer, glosa_copy.c_str()); | |
60 | - core_socket->write(glosa_buffer, glosa_size); | |
32 | + string command = "cd "; | |
61 | 33 | |
62 | - char* ok_core = new char[3]; | |
63 | - do { | |
64 | - core_socket->read(ok_core, 3); //aguarda o unity confirmar o recebimento da glosa | |
65 | - }while(strcmp(ok_core, "OK") != 0); | |
66 | - glosa_processed++; | |
34 | + char* renderPath; | |
35 | + renderPath = getenv("RENDERER"); | |
36 | + if(renderPath != NULL) | |
37 | + command.append(renderPath); | |
38 | + else | |
39 | + command.append(PATH_RENDERER); | |
67 | 40 | |
68 | - delete [] ok_core; | |
69 | - delete [] glosa_buffer; | |
41 | + command.append(" && ").append("python render.py ") | |
42 | + .append(userID).append(" >/dev/null 2>&1 &"); | |
70 | 43 | |
71 | - }catch(lavidlib::RuntimeException &ex){ | |
72 | - throw lavidlib::RuntimeException(ex.getMessage().c_str()); | |
73 | - }catch(lavidlib::IOException &ex){ | |
74 | - throw lavidlib::RuntimeException(ex.getMessage().c_str()); | |
75 | - } | |
44 | + system(command.c_str()); | |
45 | + sleep(4); //tempo para inicializar o player | |
76 | 46 | } |
77 | 47 | |
78 | -void Renderer::connectToUnity() { | |
79 | - try{ | |
48 | +void Renderer::connectToUnityPlayer() { | |
49 | + try{ | |
80 | 50 | static InetAddress* addr = InetAddress::createByName(HOST); |
81 | - while(!core_socket->isConnected()){ | |
82 | - PRINTL(util::_DEBUG, "Conectando ao Unity...\n"); | |
83 | - core_socket->connect(addr, PORTNO); | |
51 | + while(!cSocket->isConnected()){ | |
52 | + PRINTL(util::_DEBUG, "Conectando ao UnityPlayer...\n"); | |
53 | + cSocket->connect(addr, PORT); | |
84 | 54 | sleep(1); |
85 | 55 | } |
86 | 56 | }catch(lavidlib::UnknownHostException &ex){ |
87 | - throw RuntimeException(ex.getMessage().c_str()); | |
57 | + throw lavidlib::RuntimeException(ex.getMessage().c_str()); | |
88 | 58 | }catch(lavidlib::SocketException &ex){ |
89 | - throw RuntimeException(ex.getMessage().c_str()); | |
59 | + throw lavidlib::RuntimeException(ex.getMessage().c_str()); | |
90 | 60 | } |
91 | 61 | } |
92 | 62 | |
93 | -void Renderer::waitScreenShots() { | |
94 | - PRINTL(util::_INFO, "Gerando vídeo...\n"); | |
95 | - char* endgeneration = new char[strlen(END_FLAG)+1]; | |
96 | - int connected; | |
97 | - try{ | |
98 | - do{ | |
99 | - connected = core_socket->read(endgeneration, sizeof(endgeneration)); | |
100 | - }while(strcmp(endgeneration, END_FLAG) != 0 && connected != 0); | |
101 | - core_socket->close(); | |
102 | - }catch(IOException &ex){ | |
103 | - throw RuntimeException(ex.getMessage().c_str()); | |
104 | - } | |
63 | +//Armazena as glosas em uma fila até q o método initialize() seja chamado p/ fazer os envios | |
64 | +void Renderer::receiveGlosa(string glosa, int64_t pts) { | |
65 | + ostringstream oss; | |
66 | + string formatedGlosa; //Formato da glosa que será enviada para o player: "glosa#pts" | |
67 | + | |
68 | + if(glosa == BADSENTENCE || glosa == BADTEXT) | |
69 | + formatedGlosa = "_DEFAULT"; //O player entende "#pts" como pose neutra | |
70 | + else | |
71 | + formatedGlosa = glosa; | |
72 | + | |
73 | + oss << pts; | |
74 | + formatedGlosa += "#"; | |
75 | + formatedGlosa += oss.str(); | |
76 | + glosaQueue.push(formatedGlosa); | |
105 | 77 | } |
106 | 78 | |
107 | -void Renderer::addListener(ListenerRenderer* listener) { | |
108 | - listeners->push_back(listener); | |
79 | +void Renderer::exportGlosa() { | |
80 | + if(glosaQueue.empty()) | |
81 | + throw lavidlib::RuntimeException("Fila de glosas vazia!"); | |
82 | + | |
83 | + int glosaSize; | |
84 | + char* glosaBff; | |
85 | + | |
86 | + string glosaCpy = glosaQueue.front(); //Pega quem estiver na frente da fila | |
87 | + glosaSize = strlen(glosaCpy.c_str())+1; | |
88 | + glosaBff = new char[glosaSize]; | |
89 | + strcpy(glosaBff, glosaCpy.c_str()); | |
90 | + | |
91 | + try { | |
92 | + cSocket->write(glosaBff, glosaSize); //Envia a glosa formatada p/ o player | |
93 | + }catch(lavidlib::IOException &ex){ | |
94 | + throw lavidlib::RuntimeException(ex.getMessage().c_str()); | |
95 | + } | |
96 | + | |
97 | + char* received = new char[3]; //Mensagem de confirmação de recebimento da glosa: "OK\0" | |
98 | + do { | |
99 | + try { | |
100 | + cSocket->read(received, 3); //Aguarda a confirmação | |
101 | + }catch(lavidlib::IOException &ex){ | |
102 | + throw lavidlib::RuntimeException(ex.getMessage().c_str()); | |
103 | + } | |
104 | + }while(strcmp(received, OK_FLAG) != 0); //Verifica se é a confirmação correta | |
105 | + | |
106 | + glosaQueue.pop(); //Se o envio foi bem sucedido, remove a glosa da fila | |
107 | + | |
108 | + delete [] glosaBff; | |
109 | + delete [] received; | |
109 | 110 | } |
110 | 111 | |
111 | -void Renderer::notifyListeners() { | |
112 | - PRINTL(util::_DEBUG, "Renderização finalizada!\n"); | |
113 | - for (list<ListenerRenderer*>::iterator i = listeners->begin(); i != listeners->end(); i++) { | |
114 | - (*i)->notifyEndOfRenderization(); | |
115 | - } | |
112 | +void Renderer::waitScreenShots() { | |
113 | + int endSize; | |
114 | + char* finalize; | |
115 | + | |
116 | + endSize = strlen(END_FLAG)+1; | |
117 | + finalize = new char[endSize]; | |
118 | + | |
119 | + PRINTL(util::_DEBUG, "Aguardando a captura das ScreenShots.\n"); | |
120 | + do { | |
121 | + try { | |
122 | + cSocket->read(finalize, endSize); //Aguarda o player notificar o fim da captura das ScreenShots | |
123 | + }catch(lavidlib::IOException &ex){ | |
124 | + throw lavidlib::RuntimeException(ex.getMessage().c_str()); | |
125 | + } | |
126 | + }while(strcmp(finalize, END_FLAG) != 0); //Verifica se é a mensagem correta ("FINALIZE\0") | |
127 | + | |
128 | + cSocket->close(); | |
116 | 129 | } |
117 | 130 | |
118 | -void Renderer::finalize() { | |
119 | - while(glosa_processed < count_task) | |
120 | - usleep(10000); | |
121 | - receiveGlosa(END_FLAG, (int64_t) -1); | |
122 | - this->running = false; | |
123 | -} | |
131 | +void Renderer::renderVideo() { | |
132 | + PRINTL(util::_INFO, "Gerando vídeo...\n"); | |
124 | 133 | |
125 | -bool Renderer::isSending() { | |
126 | - if(glosa_processed < count_task) | |
127 | - return true; | |
128 | - else | |
129 | - return false; | |
134 | + string command = "ffmpeg -y -loglevel quiet -framerate 30 -i "; | |
135 | + command.append(PATH_SCREENS).append(userID).append("/frame_%d.png ") | |
136 | + .append("-vcodec libx264 -pix_fmt yuv420p ").append(pathOutVideo); | |
137 | + system(command.c_str()); | |
130 | 138 | } |
131 | 139 | |
132 | -void Renderer::Run() { | |
133 | - try{ | |
134 | - while(running){ | |
135 | - while(count_task <= glosa_processed){ | |
136 | - usleep(10000); | |
137 | - } | |
138 | - if(!core_socket->isConnected()) | |
139 | - connectToUnity(); | |
140 | - sendGlosa(); | |
141 | - } | |
142 | - waitScreenShots(); | |
143 | - render(); | |
144 | - cleanFiles(); | |
145 | - }catch(lavidlib::RuntimeException &ex){ | |
146 | - PRINTL(util::_ERROR, "%s\n", ex.getMessage().c_str()); | |
147 | - Logging::instance()->writeLog("renderer.cpp <Error>: Falha na comunicação com o Unity player"); | |
148 | - throw RuntimeException(ex.getMessage().c_str()); | |
149 | - } | |
140 | +void Renderer::initialize() { | |
141 | + executeServerScript(); | |
142 | + try{ | |
143 | + connectToUnityPlayer(); | |
144 | + }catch(lavidlib::RuntimeException &ex){ | |
145 | + throw lavidlib::RuntimeException(ex.getMessage().c_str()); | |
146 | + } | |
147 | + this->Start(); | |
150 | 148 | } |
151 | 149 | |
152 | -void Renderer::render() { | |
153 | - string command = "ffmpeg -y -loglevel quiet -framerate 30 -i "; | |
154 | - command.append(PATH_SCREENS).append(folder_id).append("/frame_%d.png ") | |
155 | - .append("-vcodec libx264 -pix_fmt yuv420p ").append(path_video); | |
156 | - system(command.c_str()); | |
157 | - notifyListeners(); | |
150 | +void Renderer::Run() { | |
151 | + PRINTL(util::_DEBUG, "Enviando glosas para o player...\n"); | |
152 | + while(!glosaQueue.empty()){ //Inicia o envio das glosas que estão na fila | |
153 | + try{ | |
154 | + exportGlosa(); | |
155 | + }catch(lavidlib::RuntimeException &ex){ | |
156 | + throw lavidlib::RuntimeException(ex.getMessage().c_str()); | |
157 | + } | |
158 | + } | |
159 | + | |
160 | + receiveGlosa(END_FLAG, -1); //Quando a fila estiver vazia, a flag "FINALIZE" será enviada | |
161 | + try{ | |
162 | + exportGlosa(); | |
163 | + waitScreenShots(); | |
164 | + }catch(lavidlib::RuntimeException &ex){ | |
165 | + throw lavidlib::RuntimeException(ex.getMessage().c_str()); | |
166 | + } | |
167 | + renderVideo(); | |
168 | + notifyListeners(); | |
169 | + cleanFiles(); | |
158 | 170 | } |
159 | 171 | |
160 | 172 | void Renderer::cleanFiles() { |
161 | 173 | string clean = "rm -rf "; |
162 | - clean.append(PATH_SCREENS).append(folder_id).append("/"); | |
174 | + clean.append(PATH_SCREENS).append(userID).append("/"); | |
163 | 175 | system(clean.c_str()); |
164 | 176 | } |
165 | 177 | \ No newline at end of file | ... | ... |
servico/src/serviceWindowGenerationFromRec.cpp
... | ... | @@ -50,7 +50,6 @@ ServiceWindowGenerationFromRec::~ServiceWindowGenerationFromRec(){ |
50 | 50 | if (tradutor) delete tradutor; |
51 | 51 | if (renderer) delete renderer; |
52 | 52 | if (rec) delete rec; |
53 | - if (mixer) delete mixer; | |
54 | 53 | PRINTL(util::_DEBUG, "Service Rec finished!\n"); |
55 | 54 | } |
56 | 55 | |
... | ... | @@ -123,7 +122,7 @@ void ServiceWindowGenerationFromRec::setSizeOfSubtitles(int sub_size){ |
123 | 122 | numero_legendas = sub_size; |
124 | 123 | if (legendas_enviadas >= numero_legendas){ |
125 | 124 | try{ |
126 | - renderer->finalize(); | |
125 | + renderer->initialize(); | |
127 | 126 | }catch(lavidlib::RuntimeException &ex){ |
128 | 127 | throw ServiceException(ex.getMessage().c_str()); |
129 | 128 | } |
... | ... | @@ -146,8 +145,6 @@ void ServiceWindowGenerationFromRec::notifyTextRecognized(unsigned char* text, i |
146 | 145 | |
147 | 146 | void ServiceWindowGenerationFromRec::notifyTranslation(char* glosa) { |
148 | 147 | string sGlosa(reinterpret_cast<char*>(glosa)); |
149 | - while(renderer->isSending()) | |
150 | - usleep(10000); | |
151 | 148 | try{ |
152 | 149 | renderer->receiveGlosa(sGlosa, vetor_pts->front()); |
153 | 150 | legendas_enviadas++; |
... | ... | @@ -157,12 +154,12 @@ void ServiceWindowGenerationFromRec::notifyTranslation(char* glosa) { |
157 | 154 | vetor_pts->erase(vetor_pts->begin()); |
158 | 155 | } |
159 | 156 | |
160 | -void ServiceWindowGenerationFromRec::notifyEndOfRenderization() { | |
161 | - mixer = new Mixer(this->path_input, this->path_libras, this->size, this->position, | |
162 | - this->transparency, this->user_id, this->path_uploads, this->path_contents); | |
163 | - | |
157 | +void ServiceWindowGenerationFromRec::notifyEndOfRenderization() { | |
164 | 158 | if(this->service_type == SERVICE_TYPE_REC){ |
159 | + mixer = new Mixer(this->path_input, this->path_libras, this->size, this->position, | |
160 | + this->transparency, this->user_id, this->path_uploads, this->path_contents); | |
165 | 161 | mixer->initialize(); |
162 | + delete mixer; | |
166 | 163 | } |
167 | 164 | running = false; |
168 | 165 | } |
... | ... | @@ -190,7 +187,6 @@ void ServiceWindowGenerationFromRec::initialize(){ |
190 | 187 | renderer->addListener(this); |
191 | 188 | |
192 | 189 | try{ |
193 | - renderer->Start(); | |
194 | 190 | rec->initialize(); |
195 | 191 | } catch(RecognizeException ex){ |
196 | 192 | throw ServiceException(ex.getMessage()); | ... | ... |
servico/src/serviceWindowGenerationFromSRT.cpp
... | ... | @@ -49,8 +49,8 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, in |
49 | 49 | |
50 | 50 | ServiceWindowGenerationFromSRT::~ServiceWindowGenerationFromSRT() { |
51 | 51 | free(vetor_pts); |
52 | - if (this->mixer) delete mixer; | |
53 | 52 | if (tradutor) delete tradutor; |
53 | + // if (mixer) delete mixer; | |
54 | 54 | if (renderer) delete renderer; |
55 | 55 | if (extratorSRT)delete extratorSRT; |
56 | 56 | if (extrator_factory) delete extrator_factory; |
... | ... | @@ -123,7 +123,7 @@ void ServiceWindowGenerationFromSRT::setSizeOfSubtitles(int sub_size) { |
123 | 123 | numero_legendas = sub_size; |
124 | 124 | if (legendas_enviadas >= numero_legendas){ |
125 | 125 | try{ |
126 | - renderer->finalize(); | |
126 | + renderer->initialize(); | |
127 | 127 | }catch(lavidlib::RuntimeException &ex){ |
128 | 128 | throw ServiceException(ex.getMessage().c_str()); |
129 | 129 | } |
... | ... | @@ -158,8 +158,6 @@ void ServiceWindowGenerationFromSRT::notifyTranslation(char* glosa) { |
158 | 158 | } |
159 | 159 | |
160 | 160 | void ServiceWindowGenerationFromSRT::notifyRenderer(string glosa) { |
161 | - while(renderer->isSending()) | |
162 | - usleep(10000); | |
163 | 161 | try{ |
164 | 162 | renderer->receiveGlosa(glosa, vetor_pts->front()); |
165 | 163 | legendas_enviadas++; |
... | ... | @@ -170,11 +168,11 @@ void ServiceWindowGenerationFromSRT::notifyRenderer(string glosa) { |
170 | 168 | } |
171 | 169 | |
172 | 170 | void ServiceWindowGenerationFromSRT::notifyEndOfRenderization() { |
173 | - mixer = new Mixer(this->path_input, this->path_libras, this->size, this->position, | |
174 | - this->transparency, this->user_id, this->path_uploads, this->path_contents); | |
175 | - | |
176 | 171 | if(this->service_type == SERVICE_TYPE_SRT){ |
172 | + mixer = new Mixer(this->path_input, this->path_libras, this->size, this->position, | |
173 | + this->transparency, this->user_id, this->path_uploads, this->path_contents); | |
177 | 174 | mixer->initialize(); |
175 | + delete mixer; | |
178 | 176 | } |
179 | 177 | this->running = false; |
180 | 178 | } |
... | ... | @@ -207,8 +205,7 @@ void ServiceWindowGenerationFromSRT::initialize() { |
207 | 205 | renderer = new Renderer(this->path_libras ,this->user_id); |
208 | 206 | renderer->addListener(this); |
209 | 207 | |
210 | - try{ | |
211 | - renderer->Start(); | |
208 | + try{ | |
212 | 209 | extratorSRT->initialize(); |
213 | 210 | }catch(ExtratorException ex){ |
214 | 211 | throw ServiceException(ex.getMessage()); | ... | ... |
servico/src/serviceWindowGenerationFromText.cpp
... | ... | @@ -83,7 +83,7 @@ void ServiceWindowGenerationFromText::setSizeOfSubtitles(int sub_size) { |
83 | 83 | numero_legendas = sub_size; |
84 | 84 | if (legendas_enviadas >= numero_legendas){ |
85 | 85 | try{ |
86 | - renderer->finalize(); | |
86 | + renderer->initialize(); | |
87 | 87 | }catch(lavidlib::RuntimeException &ex){ |
88 | 88 | throw ServiceException(ex.getMessage().c_str()); |
89 | 89 | } |
... | ... | @@ -109,8 +109,6 @@ void ServiceWindowGenerationFromText::notifyTranslation(char* glosa) { |
109 | 109 | } |
110 | 110 | |
111 | 111 | void ServiceWindowGenerationFromText::notifyRenderer(string glosa) { |
112 | - while(renderer->isSending()) | |
113 | - usleep(10000); | |
114 | 112 | try{ |
115 | 113 | renderer->receiveGlosa(glosa, (int64_t) -1); |
116 | 114 | legendas_enviadas++; |
... | ... | @@ -152,7 +150,6 @@ void ServiceWindowGenerationFromText::initialize() { |
152 | 150 | renderer->addListener(this); |
153 | 151 | |
154 | 152 | try{ |
155 | - renderer->Start(); | |
156 | 153 | extratorTXT->initialize(); |
157 | 154 | }catch(ExtratorException ex){ |
158 | 155 | throw ServiceException(ex.getMessage().c_str()); | ... | ... |