Commit ccc268c5e3a235eca011e5bf07f9eda10fdb3a1d
1 parent
d2ad080a
Exists in
master
and in
2 other branches
Service IOS Text adicionado. REC inicializando como nova Thread. Sincronizacao REC implementada.
Showing
10 changed files
with
141 additions
and
28 deletions
Show diff stats
extratorSRT/src/include/extratorSRT.h
main.cpp
| @@ -227,7 +227,7 @@ void serviceSRT(char* path_in, char* path_srt, char* sublanguage, | @@ -227,7 +227,7 @@ void serviceSRT(char* path_in, char* path_srt, char* sublanguage, | ||
| 227 | void serviceText(char* path_text, char* transparency, char* id, char* client_type){ | 227 | void serviceText(char* path_text, char* transparency, char* id, char* client_type){ |
| 228 | 228 | ||
| 229 | //filename = createFileToRespWeb(id); | 229 | //filename = createFileToRespWeb(id); |
| 230 | - | 230 | + if (strcmp(client_type, (char*)"WEB") == 0) { |
| 231 | ServiceWindowGenerationFromText *service_text; | 231 | ServiceWindowGenerationFromText *service_text; |
| 232 | service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, client_type); | 232 | service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, client_type); |
| 233 | try{ | 233 | try{ |
| @@ -243,6 +243,26 @@ void serviceText(char* path_text, char* transparency, char* id, char* client_typ | @@ -243,6 +243,26 @@ void serviceText(char* path_text, char* transparency, char* id, char* client_typ | ||
| 243 | } | 243 | } |
| 244 | //updateRequestStatusWeb(filename.c_str(), id, "true"); | 244 | //updateRequestStatusWeb(filename.c_str(), id, "true"); |
| 245 | delete service_text; | 245 | delete service_text; |
| 246 | + } else { | ||
| 247 | + printf("ServicoIOS\n"); | ||
| 248 | + ServiceWindowGenerationFromText *service_text; | ||
| 249 | + service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, (char*)"IOS"); | ||
| 250 | + try{ | ||
| 251 | + service_text->initialize(); | ||
| 252 | + }catch(ServiceException ex){ | ||
| 253 | + fail(ex.getMessage()); | ||
| 254 | + hasFailed(); | ||
| 255 | + return; | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + while (service_text->isAlive()) { | ||
| 259 | + usleep(100000); //100ms | ||
| 260 | + } | ||
| 261 | + //updateRequestStatusWeb(filename.c_str(), id, "true"); | ||
| 262 | + delete service_text; | ||
| 263 | + | ||
| 264 | + | ||
| 265 | + } | ||
| 246 | 266 | ||
| 247 | } | 267 | } |
| 248 | 268 |
mixer/src/Mixer.cpp
| @@ -130,7 +130,7 @@ void Mixer::mixVideos () { | @@ -130,7 +130,7 @@ void Mixer::mixVideos () { | ||
| 130 | ffmpeg -i videoDemoLibras.ts -vcodec libx264 -f flv -ar 22050 -ab 32 -sameq -threads 8 -y teste.flv | 130 | ffmpeg -i videoDemoLibras.ts -vcodec libx264 -f flv -ar 22050 -ab 32 -sameq -threads 8 -y teste.flv |
| 131 | */ | 131 | */ |
| 132 | 132 | ||
| 133 | - printf("\n\n%s\n\n", ffmpegSentence.c_str()); | 133 | + //printf("\n\n%s\n\n", ffmpegSentence.c_str()); |
| 134 | system(ffmpegSentence.c_str()); | 134 | system(ffmpegSentence.c_str()); |
| 135 | 135 | ||
| 136 | //string removeVideoCMD = "rm -rf "+nameOfMainVideo+".ts"; //removo o vídeo exemplo-45fps.ts | 136 | //string removeVideoCMD = "rm -rf "+nameOfMainVideo+".ts"; //removo o vídeo exemplo-45fps.ts |
| @@ -258,7 +258,7 @@ void Mixer::setSize(int size){ | @@ -258,7 +258,7 @@ void Mixer::setSize(int size){ | ||
| 258 | string ffprobeSentence = "ffprobe -show_streams "+this->mainVideo+" 2> /dev/null | grep \"height=\" | cut -d'=' -f2 > "+temporaryTextFile; | 258 | string ffprobeSentence = "ffprobe -show_streams "+this->mainVideo+" 2> /dev/null | grep \"height=\" | cut -d'=' -f2 > "+temporaryTextFile; |
| 259 | system(ffprobeSentence.c_str()); | 259 | system(ffprobeSentence.c_str()); |
| 260 | 260 | ||
| 261 | - printf("\n\n%s\n\n",ffprobeSentence.c_str()); | 261 | + //printf("\n\n%s\n\n",ffprobeSentence.c_str()); |
| 262 | 262 | ||
| 263 | 263 | ||
| 264 | string heightStr = "324"; //se não conseguir ler do arquivo a altura será essa.. :( | 264 | string heightStr = "324"; //se não conseguir ler do arquivo a altura será essa.. :( |
| @@ -315,7 +315,7 @@ void Mixer::setMainVideo(string mainVideo){ | @@ -315,7 +315,7 @@ void Mixer::setMainVideo(string mainVideo){ | ||
| 315 | this->temporaryTextFile = "vlibras_user/vlibras-web/public/uploads/videos/"; | 315 | this->temporaryTextFile = "vlibras_user/vlibras-web/public/uploads/videos/"; |
| 316 | temporaryTextFile.append(this->user_id).append("/tamanho.txt"); | 316 | temporaryTextFile.append(this->user_id).append("/tamanho.txt"); |
| 317 | 317 | ||
| 318 | - printf("##########temporaryTextFile: %s\n", temporaryTextFile.c_str()); | 318 | + //printf("##########temporaryTextFile: %s\n", temporaryTextFile.c_str()); |
| 319 | 319 | ||
| 320 | } | 320 | } |
| 321 | string Mixer::getMainVideo(){ | 321 | string Mixer::getMainVideo(){ |
recognize/src/include/recognize.h
| 1 | +#include "jthread.h" | ||
| 1 | #include <iostream> | 2 | #include <iostream> |
| 2 | #include <stdlib.h> | 3 | #include <stdlib.h> |
| 3 | #include <stdint.h> | 4 | #include <stdint.h> |
| @@ -6,13 +7,16 @@ | @@ -6,13 +7,16 @@ | ||
| 6 | #include "dprintf.h" | 7 | #include "dprintf.h" |
| 7 | #include "logger.h" | 8 | #include "logger.h" |
| 8 | 9 | ||
| 10 | +#include "listenerMonitorPCRBase.h" | ||
| 9 | #include "recognizeListener.h" | 11 | #include "recognizeListener.h" |
| 10 | #include "recognizeException.h" | 12 | #include "recognizeException.h" |
| 11 | 13 | ||
| 12 | 14 | ||
| 15 | +using namespace jthread; | ||
| 13 | using namespace std; | 16 | using namespace std; |
| 14 | 17 | ||
| 15 | -class Recognize { | 18 | + |
| 19 | +class Recognize: public Thread, public ListenerMonitorPCRBase { | ||
| 16 | 20 | ||
| 17 | public: | 21 | public: |
| 18 | 22 | ||
| @@ -38,15 +42,24 @@ public: | @@ -38,15 +42,24 @@ public: | ||
| 38 | 42 | ||
| 39 | void addListener(RecognizeListener* listener); | 43 | void addListener(RecognizeListener* listener); |
| 40 | 44 | ||
| 45 | + void notifyPCRBase(uint64_t pcrbase); | ||
| 46 | + | ||
| 41 | bool isFinished(); | 47 | bool isFinished(); |
| 42 | 48 | ||
| 49 | + void Run(); | ||
| 50 | + int count_lines; | ||
| 51 | + | ||
| 43 | private: | 52 | private: |
| 44 | 53 | ||
| 54 | + int64_t pcr_base; | ||
| 55 | + bool hasPCRBase; | ||
| 45 | char* pathVideo; | 56 | char* pathVideo; |
| 46 | string id; | 57 | string id; |
| 47 | float confidenceRate; | 58 | float confidenceRate; |
| 48 | bool finished; | 59 | bool finished; |
| 49 | vector<float> scores; | 60 | vector<float> scores; |
| 61 | + vector<int64_t> pts; | ||
| 62 | + | ||
| 50 | 63 | ||
| 51 | /** inputType: 1 = RawFile, 2 = Mic */ | 64 | /** inputType: 1 = RawFile, 2 = Mic */ |
| 52 | int inputType, frequency, sizeBlocs; | 65 | int inputType, frequency, sizeBlocs; |
| @@ -63,8 +76,13 @@ private: | @@ -63,8 +76,13 @@ private: | ||
| 63 | void filterOutputJulius(); | 76 | void filterOutputJulius(); |
| 64 | void generateConfidence(); | 77 | void generateConfidence(); |
| 65 | void notifyListeners(char* text); | 78 | void notifyListeners(char* text); |
| 79 | + void notifyEndExtraction(int sentences_size); | ||
| 80 | + | ||
| 66 | void cleanFiles(); | 81 | void cleanFiles(); |
| 67 | void createDir(); | 82 | void createDir(); |
| 68 | - bool getConfidence(int i); | 83 | + bool getConfidence(); |
| 69 | 84 | ||
| 85 | + int64_t calcula_pts(double msec); | ||
| 86 | + int64_t convert_pts(string pts); | ||
| 87 | + | ||
| 70 | }; | 88 | }; |
recognize/src/include/recognizeListener.h
| @@ -14,7 +14,8 @@ class RecognizeListener { | @@ -14,7 +14,8 @@ class RecognizeListener { | ||
| 14 | 14 | ||
| 15 | public: | 15 | public: |
| 16 | virtual void notifyTextRecognized(unsigned char* text, int64_t pts) = 0; | 16 | virtual void notifyTextRecognized(unsigned char* text, int64_t pts) = 0; |
| 17 | - | 17 | + virtual void notifyEnd(int sentences_size) = 0; |
| 18 | + | ||
| 18 | }; | 19 | }; |
| 19 | 20 | ||
| 20 | #endif /* RECOGNIZELISTENER_H */ | 21 | #endif /* RECOGNIZELISTENER_H */ |
recognize/src/recognize.cpp
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <vector> | 6 | #include <vector> |
| 7 | #include <iterator> | 7 | #include <iterator> |
| 8 | - | 8 | +#include <stdlib.h> |
| 9 | #include <iostream> | 9 | #include <iostream> |
| 10 | #include <string> | 10 | #include <string> |
| 11 | #include <sys/stat.h> | 11 | #include <sys/stat.h> |
| @@ -50,6 +50,8 @@ Recognize::Recognize(char* _pathVideo, char* _id) { | @@ -50,6 +50,8 @@ Recognize::Recognize(char* _pathVideo, char* _id) { | ||
| 50 | ss << _id; | 50 | ss << _id; |
| 51 | ss >> id; | 51 | ss >> id; |
| 52 | confidenceRate=CONFIDENCE_RATE; | 52 | confidenceRate=CONFIDENCE_RATE; |
| 53 | + pcr_base = 0; | ||
| 54 | + hasPCRBase = false; | ||
| 53 | DPRINTF("Done!\n"); | 55 | DPRINTF("Done!\n"); |
| 54 | } | 56 | } |
| 55 | 57 | ||
| @@ -60,6 +62,8 @@ Recognize::Recognize(char* _pathVideo, char* _id, char* rate) { | @@ -60,6 +62,8 @@ Recognize::Recognize(char* _pathVideo, char* _id, char* rate) { | ||
| 60 | inputType = INPUT_PATTERN; | 62 | inputType = INPUT_PATTERN; |
| 61 | frequency = FREQUENCY_PATTERN; | 63 | frequency = FREQUENCY_PATTERN; |
| 62 | sizeBlocs = BLOCS_PATTERN; | 64 | sizeBlocs = BLOCS_PATTERN; |
| 65 | + pcr_base = 0; | ||
| 66 | + hasPCRBase = false; | ||
| 63 | stringstream ss; | 67 | stringstream ss; |
| 64 | ss << _id; | 68 | ss << _id; |
| 65 | ss >> id; | 69 | ss >> id; |
| @@ -77,6 +81,8 @@ Recognize::Recognize(char* _pathVideo, int _inputType, char* _id) { | @@ -77,6 +81,8 @@ Recognize::Recognize(char* _pathVideo, int _inputType, char* _id) { | ||
| 77 | frequency = FREQUENCY_PATTERN; | 81 | frequency = FREQUENCY_PATTERN; |
| 78 | sizeBlocs = BLOCS_PATTERN; | 82 | sizeBlocs = BLOCS_PATTERN; |
| 79 | id = _id; | 83 | id = _id; |
| 84 | + pcr_base = 0; | ||
| 85 | + hasPCRBase = false; | ||
| 80 | DPRINTF("Done!\n"); | 86 | DPRINTF("Done!\n"); |
| 81 | } | 87 | } |
| 82 | 88 | ||
| @@ -99,6 +105,10 @@ void Recognize::initialize() { | @@ -99,6 +105,10 @@ void Recognize::initialize() { | ||
| 99 | Util::Logger::Instance()->writeLog((char*) "[ERRO: recognize.cpp] Arquivo de vídeo não encontrado."); | 105 | Util::Logger::Instance()->writeLog((char*) "[ERRO: recognize.cpp] Arquivo de vídeo não encontrado."); |
| 100 | throw RecognizeException("Falha ao abrir o arquivo de vídeo! Verifique se o mesmo existe."); | 106 | throw RecognizeException("Falha ao abrir o arquivo de vídeo! Verifique se o mesmo existe."); |
| 101 | } | 107 | } |
| 108 | + this->Start(); | ||
| 109 | +} | ||
| 110 | + | ||
| 111 | +void Recognize::Run(){ | ||
| 102 | 112 | ||
| 103 | finished = false; | 113 | finished = false; |
| 104 | 114 | ||
| @@ -111,10 +121,9 @@ void Recognize::initialize() { | @@ -111,10 +121,9 @@ void Recognize::initialize() { | ||
| 111 | cleanFiles(); | 121 | cleanFiles(); |
| 112 | 122 | ||
| 113 | finished = true; | 123 | finished = true; |
| 114 | - | 124 | + notifyEndExtraction(count_lines-1); |
| 115 | } | 125 | } |
| 116 | 126 | ||
| 117 | - | ||
| 118 | void Recognize::setFrequency(int freq) { | 127 | void Recognize::setFrequency(int freq) { |
| 119 | frequency = freq; | 128 | frequency = freq; |
| 120 | } | 129 | } |
| @@ -213,9 +222,12 @@ void Recognize::breakVideoParts(int timeTotal) { | @@ -213,9 +222,12 @@ void Recognize::breakVideoParts(int timeTotal) { | ||
| 213 | sprintf(tmp, "%i", t); | 222 | sprintf(tmp, "%i", t); |
| 214 | t_str = tmp; | 223 | t_str = tmp; |
| 215 | } | 224 | } |
| 225 | + | ||
| 216 | sprintf(tmp, "%i", ss); | 226 | sprintf(tmp, "%i", ss); |
| 217 | ss_str = tmp; | 227 | ss_str = tmp; |
| 218 | 228 | ||
| 229 | + pts.push_back(convert_pts(ss_str)); | ||
| 230 | + | ||
| 219 | command = "sox "; | 231 | command = "sox "; |
| 220 | command.append(PATH_GTAAAS_WEB).append(id).append(PATH_AUDIO_ORIGIN).append(" ").append(PATH_GTAAAS_WEB).append(id).append(PATH_AUDIO_PARTS); | 232 | command.append(PATH_GTAAAS_WEB).append(id).append(PATH_AUDIO_ORIGIN).append(" ").append(PATH_GTAAAS_WEB).append(id).append(PATH_AUDIO_PARTS); |
| 221 | sprintf(tmp, "%i", count++); | 233 | sprintf(tmp, "%i", count++); |
| @@ -255,7 +267,8 @@ void Recognize::executeJuliusEngine() { | @@ -255,7 +267,8 @@ void Recognize::executeJuliusEngine() { | ||
| 255 | append(PATH_GTAAAS_WEB).append(id). | 267 | append(PATH_GTAAAS_WEB).append(id). |
| 256 | append(FILENAME_RECOGNIZED_OUT); | 268 | append(FILENAME_RECOGNIZED_OUT); |
| 257 | 269 | ||
| 258 | - printf("\n\nCommand for executeJuliusEngine: %s\n", command.c_str()); | 270 | + //Command of execute Julius |
| 271 | + //printf("\n\nCommand for executeJuliusEngine: %s\n", command.c_str()); | ||
| 259 | system(command.c_str()); | 272 | system(command.c_str()); |
| 260 | 273 | ||
| 261 | } | 274 | } |
| @@ -267,7 +280,7 @@ void Recognize::generateConfidence() { | @@ -267,7 +280,7 @@ void Recognize::generateConfidence() { | ||
| 267 | append(FIND_CONFIDENCE).append(" >> ").append(PATH_GTAAAS_WEB).append(id).append(FILENAME_CONFIDENCEOUT); | 280 | append(FIND_CONFIDENCE).append(" >> ").append(PATH_GTAAAS_WEB).append(id).append(FILENAME_CONFIDENCEOUT); |
| 268 | 281 | ||
| 269 | system(command.c_str()); | 282 | system(command.c_str()); |
| 270 | - printf("\n\n---> command: %s\n\n", command.c_str()); | 283 | + //printf("\n\n---> command: %s\n\n", command.c_str()); |
| 271 | 284 | ||
| 272 | string path; | 285 | string path; |
| 273 | path.append(PATH_GTAAAS_WEB).append(id).append(FILENAME_CONFIDENCEOUT); | 286 | path.append(PATH_GTAAAS_WEB).append(id).append(FILENAME_CONFIDENCEOUT); |
| @@ -316,9 +329,9 @@ void Recognize::generateConfidence() { | @@ -316,9 +329,9 @@ void Recognize::generateConfidence() { | ||
| 316 | } | 329 | } |
| 317 | } | 330 | } |
| 318 | 331 | ||
| 319 | -bool Recognize::getConfidence(int i){ | 332 | +bool Recognize::getConfidence(){ |
| 320 | //cout << "CONFIDENCE: " << scores[i] << endl; | 333 | //cout << "CONFIDENCE: " << scores[i] << endl; |
| 321 | - if (scores[i] < confidenceRate) | 334 | + if (scores.front() < confidenceRate) |
| 322 | return false; | 335 | return false; |
| 323 | return true; | 336 | return true; |
| 324 | } | 337 | } |
| @@ -334,9 +347,9 @@ void Recognize::filterOutputJulius() { | @@ -334,9 +347,9 @@ void Recognize::filterOutputJulius() { | ||
| 334 | append(FIND_SENTENCE).append(" >> ").append(PATH_GTAAAS_WEB).append(id).append(FILENAME_FILTEROUT); | 347 | append(FIND_SENTENCE).append(" >> ").append(PATH_GTAAAS_WEB).append(id).append(FILENAME_FILTEROUT); |
| 335 | 348 | ||
| 336 | system(command.c_str()); | 349 | system(command.c_str()); |
| 337 | - printf("\n\n---> command: %s\n\n", command.c_str()); | 350 | + //printf("\n\n---> command: %s\n\n", command.c_str()); |
| 338 | 351 | ||
| 339 | - int count_lines = 0; | 352 | + count_lines = 0; |
| 340 | 353 | ||
| 341 | string path; | 354 | string path; |
| 342 | path.append(PATH_GTAAAS_WEB).append(id).append(FILENAME_FILTEROUT); | 355 | path.append(PATH_GTAAAS_WEB).append(id).append(FILENAME_FILTEROUT); |
| @@ -356,10 +369,11 @@ void Recognize::filterOutputJulius() { | @@ -356,10 +369,11 @@ void Recognize::filterOutputJulius() { | ||
| 356 | strFilter = line.substr(strlen(FIND_SENTENCE), sizeLine); | 369 | strFilter = line.substr(strlen(FIND_SENTENCE), sizeLine); |
| 357 | sentence_ptr = new char[strFilter.length()+1]; | 370 | sentence_ptr = new char[strFilter.length()+1]; |
| 358 | strcpy(sentence_ptr, (char*) strFilter.c_str()); | 371 | strcpy(sentence_ptr, (char*) strFilter.c_str()); |
| 359 | - if(getConfidence(count_lines)) | 372 | + if(getConfidence()) |
| 360 | notifyListeners(sentence_ptr); | 373 | notifyListeners(sentence_ptr); |
| 361 | else | 374 | else |
| 362 | notifyListeners((char*) "SENTENCA_COM_BAIXA_QUALIDADE"); | 375 | notifyListeners((char*) "SENTENCA_COM_BAIXA_QUALIDADE"); |
| 376 | + scores.erase(scores.begin()); | ||
| 363 | } | 377 | } |
| 364 | count_lines++; | 378 | count_lines++; |
| 365 | } while (!in.eof()); | 379 | } while (!in.eof()); |
| @@ -375,13 +389,39 @@ void Recognize::filterOutputJulius() { | @@ -375,13 +389,39 @@ void Recognize::filterOutputJulius() { | ||
| 375 | void Recognize::notifyListeners(char* text) { | 389 | void Recognize::notifyListeners(char* text) { |
| 376 | //cout << "NOTIFY: " << text << endl; | 390 | //cout << "NOTIFY: " << text << endl; |
| 377 | 391 | ||
| 378 | - int64_t pts = PTS_PATTERN; | 392 | + int64_t pts_run = pts.front(); |
| 379 | for(list<RecognizeListener*>::iterator it = listeners->begin(); it != listeners->end(); it++){ | 393 | for(list<RecognizeListener*>::iterator it = listeners->begin(); it != listeners->end(); it++){ |
| 380 | - (*it)->notifyTextRecognized((unsigned char*) text, pts); | 394 | + (*it)->notifyTextRecognized((unsigned char*) text, calcula_pts(pts_run)); |
| 395 | + | ||
| 381 | } | 396 | } |
| 397 | + pts.erase(pts.begin()); | ||
| 382 | 398 | ||
| 383 | } | 399 | } |
| 384 | 400 | ||
| 401 | +void Recognize::notifyEndExtraction(int sentences_size) { | ||
| 402 | + DDPRINTF("Recognizer concluiu o reconhecimento: %d sentenças.\n", sentences_size); | ||
| 403 | + for(list<RecognizeListener*>::iterator it = listeners->begin(); it != listeners->end(); it++){ | ||
| 404 | + (*it)->notifyEnd(sentences_size); | ||
| 405 | + } | ||
| 406 | +} | ||
| 407 | + | ||
| 408 | +void Recognize::notifyPCRBase(uint64_t pcrbase){ | ||
| 409 | + //DDPRINTF("PCRBase = %ld\n", pcrbase); | ||
| 410 | + this->pcr_base = pcrbase; | ||
| 411 | + this->hasPCRBase = true; | ||
| 412 | +} | ||
| 413 | + | ||
| 414 | +int64_t Recognize::calcula_pts(double msec) { | ||
| 415 | + return (int64_t)(pcr_base + ((msec/1000) * 100000.0)); | ||
| 416 | +} | ||
| 417 | + | ||
| 418 | +int64_t Recognize::convert_pts(string pts){ | ||
| 419 | + int64_t ui64; | ||
| 420 | + stringstream ss; | ||
| 421 | + ss << pts; | ||
| 422 | + ss >> ui64; | ||
| 423 | + return ui64*1000; | ||
| 424 | +} | ||
| 385 | 425 | ||
| 386 | void Recognize::addListener(RecognizeListener* listener) { | 426 | void Recognize::addListener(RecognizeListener* listener) { |
| 387 | listeners->push_back(listener); | 427 | listeners->push_back(listener); |
| @@ -401,10 +441,10 @@ void Recognize::cleanFiles() { | @@ -401,10 +441,10 @@ void Recognize::cleanFiles() { | ||
| 401 | } | 441 | } |
| 402 | 442 | ||
| 403 | void Recognize::createDir(){ | 443 | void Recognize::createDir(){ |
| 444 | + | ||
| 404 | string command = "mkdir "; | 445 | string command = "mkdir "; |
| 405 | command.append(PATH_GTAAAS_WEB).append(id).append("/audio").append(" && mkdir "). | 446 | command.append(PATH_GTAAAS_WEB).append(id).append("/audio").append(" && mkdir "). |
| 406 | append(PATH_GTAAAS_WEB).append(id).append("/audio/parts").append(" && mkdir "). | 447 | append(PATH_GTAAAS_WEB).append(id).append("/audio/parts").append(" && mkdir "). |
| 407 | append(PATH_GTAAAS_WEB).append(id).append("/audio/origin"); | 448 | append(PATH_GTAAAS_WEB).append(id).append("/audio/origin"); |
| 408 | - printf("%s\n", command.c_str()); | ||
| 409 | system(command.c_str()); | 449 | system(command.c_str()); |
| 410 | } | 450 | } |
servico/src/include/serviceWindowGenerationFromREC.h
| @@ -6,6 +6,8 @@ | @@ -6,6 +6,8 @@ | ||
| 6 | #include "jthread.h" | 6 | #include "jthread.h" |
| 7 | #include "serviceWindowGeneration.h" | 7 | #include "serviceWindowGeneration.h" |
| 8 | #include "recognize.h" | 8 | #include "recognize.h" |
| 9 | +#include "inputFile.h" | ||
| 10 | +#include "monitor_pcr.h" | ||
| 9 | 11 | ||
| 10 | using namespace std; | 12 | using namespace std; |
| 11 | using namespace jthread; | 13 | using namespace jthread; |
| @@ -16,7 +18,7 @@ private: | @@ -16,7 +18,7 @@ private: | ||
| 16 | Recognize *rec; | 18 | Recognize *rec; |
| 17 | 19 | ||
| 18 | public: | 20 | public: |
| 19 | - | 21 | + |
| 20 | ServiceWindowGenerationFromREC(char* path_video, int sublanguage, int position, int size, int transparency, char* id, int _serviceType, char* rate); | 22 | ServiceWindowGenerationFromREC(char* path_video, int sublanguage, int position, int size, int transparency, char* id, int _serviceType, char* rate); |
| 21 | 23 | ||
| 22 | ServiceWindowGenerationFromREC(char* path_video, int sublanguage, int position, int size, int transparency, char* id, int _serviceType); | 24 | ServiceWindowGenerationFromREC(char* path_video, int sublanguage, int position, int size, int transparency, char* id, int _serviceType); |
| @@ -25,6 +27,8 @@ public: | @@ -25,6 +27,8 @@ public: | ||
| 25 | void initialize(); | 27 | void initialize(); |
| 26 | 28 | ||
| 27 | virtual void notifyTextRecognized(unsigned char* text, int64_t pts); | 29 | virtual void notifyTextRecognized(unsigned char* text, int64_t pts); |
| 30 | + virtual void notifyEnd(int sentences_size); | ||
| 31 | + | ||
| 28 | 32 | ||
| 29 | void notifyTranslator(unsigned char *text); | 33 | void notifyTranslator(unsigned char *text); |
| 30 | void notifySynchWithoutTranslator(unsigned char *text, int64_t pts); | 34 | void notifySynchWithoutTranslator(unsigned char *text, int64_t pts); |
servico/src/include/serviceWindowGenerationFromText.h
| @@ -28,7 +28,7 @@ public: | @@ -28,7 +28,7 @@ public: | ||
| 28 | bool isAlive(); | 28 | bool isAlive(); |
| 29 | void Run(); | 29 | void Run(); |
| 30 | void transcodeVideoToWebm(); | 30 | void transcodeVideoToWebm(); |
| 31 | - | 31 | + void transcodeVideoToAvi(); |
| 32 | }; | 32 | }; |
| 33 | 33 | ||
| 34 | #endif /* _SERVICEWINDOWGENERATIONFROMTEXT_H */ | 34 | #endif /* _SERVICEWINDOWGENERATIONFROMTEXT_H */ |
servico/src/serviceWindowGenerationFromREC.cpp
| @@ -36,11 +36,20 @@ ServiceWindowGenerationFromREC::~ServiceWindowGenerationFromREC() { | @@ -36,11 +36,20 @@ ServiceWindowGenerationFromREC::~ServiceWindowGenerationFromREC() { | ||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | void ServiceWindowGenerationFromREC::initialize() { | 38 | void ServiceWindowGenerationFromREC::initialize() { |
| 39 | - rec->addListener(this); | ||
| 40 | - | 39 | + |
| 40 | + rec->addListener(this); | ||
| 41 | + | ||
| 42 | + inputfile = new InputFile(this->path_input); | ||
| 43 | + monitor_pcr_base = new MonitorPCR(); | ||
| 44 | + | ||
| 45 | + monitor_pcr_base->addListenerPCRBase(rec); | ||
| 46 | + inputfile->registraOuvinte(monitor_pcr_base); | ||
| 47 | + | ||
| 41 | ServiceWindowGeneration::initialize(); | 48 | ServiceWindowGeneration::initialize(); |
| 49 | + | ||
| 42 | try{ | 50 | try{ |
| 43 | - rec->initialize(); | 51 | + rec->initialize(); |
| 52 | + inputfile->initialize(); | ||
| 44 | }catch(RecognizeException ex){ | 53 | }catch(RecognizeException ex){ |
| 45 | throw ServiceException(ex.getMessage()); | 54 | throw ServiceException(ex.getMessage()); |
| 46 | } | 55 | } |
| @@ -60,6 +69,11 @@ void ServiceWindowGenerationFromREC::notifyTranslator(unsigned char *text) { | @@ -60,6 +69,11 @@ void ServiceWindowGenerationFromREC::notifyTranslator(unsigned char *text) { | ||
| 60 | tradutor->traduz(text); | 69 | tradutor->traduz(text); |
| 61 | } | 70 | } |
| 62 | 71 | ||
| 72 | +void ServiceWindowGenerationFromREC::notifyEnd(int sentences_size) { | ||
| 73 | + DDPRINTF("Service REC recebeu: %d sentenças.\n", sentences_size); | ||
| 74 | + setSizeOfSubtitles(sentences_size); | ||
| 75 | +} | ||
| 76 | + | ||
| 63 | void ServiceWindowGenerationFromREC::notifySynchWithoutTranslator(unsigned char *text, int64_t pts) { | 77 | void ServiceWindowGenerationFromREC::notifySynchWithoutTranslator(unsigned char *text, int64_t pts) { |
| 64 | char* pch = strtok((char*) text, " "); | 78 | char* pch = strtok((char*) text, " "); |
| 65 | while (pch != NULL) { | 79 | while (pch != NULL) { |
| @@ -75,5 +89,4 @@ void ServiceWindowGenerationFromREC::Run() { | @@ -75,5 +89,4 @@ void ServiceWindowGenerationFromREC::Run() { | ||
| 75 | while (!rec->isFinished()) { | 89 | while (!rec->isFinished()) { |
| 76 | sleep(2); | 90 | sleep(2); |
| 77 | } | 91 | } |
| 78 | - sincronizador->stop(); | ||
| 79 | } | 92 | } |
servico/src/serviceWindowGenerationFromText.cpp
| @@ -67,6 +67,10 @@ void ServiceWindowGenerationFromText::Run() { | @@ -67,6 +67,10 @@ void ServiceWindowGenerationFromText::Run() { | ||
| 67 | if (strcmp(client_type, (char*)"WEB") == 0) { | 67 | if (strcmp(client_type, (char*)"WEB") == 0) { |
| 68 | printf("[INFO]: A transcodificação para .webm está ativada!\n"); | 68 | printf("[INFO]: A transcodificação para .webm está ativada!\n"); |
| 69 | transcodeVideoToWebm(); | 69 | transcodeVideoToWebm(); |
| 70 | + } else if (strcmp(client_type, (char*)"IOS") == 0) { | ||
| 71 | + printf("[INFO]: A transcodificação para .avi está ativada!\n"); | ||
| 72 | + | ||
| 73 | + transcodeVideoToAvi(); | ||
| 70 | } | 74 | } |
| 71 | else | 75 | else |
| 72 | transcodeVideoToFlv(); | 76 | transcodeVideoToFlv(); |
| @@ -86,4 +90,18 @@ void ServiceWindowGenerationFromText::transcodeVideoToWebm() { | @@ -86,4 +90,18 @@ void ServiceWindowGenerationFromText::transcodeVideoToWebm() { | ||
| 86 | .append(getPathLibras()); | 90 | .append(getPathLibras()); |
| 87 | //printf("[INFO]: Transcodification command -> %s\n", command.c_str()); | 91 | //printf("[INFO]: Transcodification command -> %s\n", command.c_str()); |
| 88 | system(command.c_str()); | 92 | system(command.c_str()); |
| 89 | -} | ||
| 90 | \ No newline at end of file | 93 | \ No newline at end of file |
| 94 | +} | ||
| 95 | + | ||
| 96 | +void ServiceWindowGenerationFromText::transcodeVideoToAvi() { | ||
| 97 | + | ||
| 98 | + string command = "ffmpeg -i "; | ||
| 99 | + command.append(getPathLibras()) | ||
| 100 | + .append(" -vcodec mjpeg -r 30 -pix_fmt yuvj422p ") | ||
| 101 | + .append(PATH_LIBRAS) | ||
| 102 | + .append(getUserId()) | ||
| 103 | + .append(".mp4") | ||
| 104 | + .append(" && rm ") | ||
| 105 | + .append(getPathLibras()); | ||
| 106 | + //printf("[INFO]: Transcodification command -> %s\n", command.c_str()); | ||
| 107 | + system(command.c_str()); | ||
| 108 | +} |