Commit 4eeb9359f380ba016a464b50ce6d4df10c698b25

Authored by Wesnydy Ribeiro
1 parent cb055103
Exists in master and in 1 other branch devel

Adaptado o padrão de desenvolvimento dos componentes input, synchronizer e tradutor

@@ -20,7 +20,7 @@ logger.o @@ -20,7 +20,7 @@ logger.o
20 tradutorObjs = \ 20 tradutorObjs = \
21 pyTradutor.o \ 21 pyTradutor.o \
22 tradutorPortGlosa.o \ 22 tradutorPortGlosa.o \
23 -ouvinteTradutor.o 23 +#ouvinteTradutor.o
24 24
25 extratorSRTObjs = \ 25 extratorSRTObjs = \
26 extratorSRT.o \ 26 extratorSRT.o \
@@ -37,7 +37,6 @@ monitor_pcr.o @@ -37,7 +37,6 @@ monitor_pcr.o
37 inputObjs = \ 37 inputObjs = \
38 inputFile.o \ 38 inputFile.o \
39 inputException.o \ 39 inputException.o \
40 -ouvinteInput.o  
41 40
42 servicoObjs = \ 41 servicoObjs = \
43 serviceWindowGeneration.o \ 42 serviceWindowGeneration.o \
@@ -48,7 +47,6 @@ serviceException.o @@ -48,7 +47,6 @@ serviceException.o
48 47
49 synchronizerObjs = \ 48 synchronizerObjs = \
50 synchronizer.o \ 49 synchronizer.o \
51 -ouvinteSynchronizer.o  
52 50
53 mixerObjs = \ 51 mixerObjs = \
54 Mixer.o 52 Mixer.o
extratorSRT/src/extratorSRT.cpp
1 1
2 -  
3 #include "extratorSRT.h" 2 #include "extratorSRT.h"
4 3
5 -using namespace std;  
6 4
7 ExtratorSRT::ExtratorSRT(){ 5 ExtratorSRT::ExtratorSRT(){
8 listeners = new list<ListenerSRT*>(); 6 listeners = new list<ListenerSRT*>();
@@ -30,8 +28,8 @@ void ExtratorSRT::initialize(){ @@ -30,8 +28,8 @@ void ExtratorSRT::initialize(){
30 file_io = new lavidlib::FileIO(file->getPath(), FileIO::MODE_READ); 28 file_io = new lavidlib::FileIO(file->getPath(), FileIO::MODE_READ);
31 }catch(Exception ex){ 29 }catch(Exception ex){
32 finish = true; 30 finish = true;
33 - Util::Logger::Instance()->writeLog((char*) "[ERRO: extratorSRT.cpp] Arquivo de texto não encontrado.");  
34 - throw ExtratorSrtException("Falha ao abrir o arquivo de texto! Verifique se o mesmo existe.\n"); 31 + Util::Logger::Instance()->writeLog((char*) "[ERRO: extratorSRT.cpp] Arquivo de legenda não encontrado.");
  32 + throw ExtratorSrtException("Falha ao abrir o arquivo de legenda! Verifique se o mesmo existe.\n");
35 } 33 }
36 34
37 this->Start(); 35 this->Start();
@@ -93,13 +91,13 @@ void ExtratorSRT::Run(){ @@ -93,13 +91,13 @@ void ExtratorSRT::Run(){
93 Subtitle* ExtratorSRT::next() { 91 Subtitle* ExtratorSRT::next() {
94 92
95 if (seek_pos >= file_io->getSize()) 93 if (seek_pos >= file_io->getSize())
96 - throw ExtratorSrtException("[ERRO: reader_srt.cpp] Esse arquivo já foi lido."); 94 + throw ExtratorSrtException("[ERRO: extratorSRT.cpp] Esse arquivo já foi lido.");
97 95
98 file_io->seek(seek_pos); 96 file_io->seek(seek_pos);
99 try{ 97 try{
100 bff_reader = new BufferedReader(file_io); 98 bff_reader = new BufferedReader(file_io);
101 }catch(Exception &ex){ 99 }catch(Exception &ex){
102 - throw ExtratorSrtException("[ERRO: reader_srt.cpp] O BufferedReader não foi inicializado."); 100 + throw ExtratorSrtException("[ERRO: extratorSRT.cpp] O BufferedReader não foi inicializado.");
103 } 101 }
104 102
105 Subtitle* sub = new Subtitle(); 103 Subtitle* sub = new Subtitle();
extratorSRT/src/include/extratorSRT.h
@@ -8,10 +8,6 @@ @@ -8,10 +8,6 @@
8 #ifndef EXTRATORSRT_H 8 #ifndef EXTRATORSRT_H
9 #define EXTRATORSRT_H 9 #define EXTRATORSRT_H
10 10
11 -//#define MAX_LINE 1024  
12 -#define SIZE_CSCAPE 1  
13 -#define TARGET_TIME "-->"  
14 -  
15 #include <string.h> 11 #include <string.h>
16 #include <stdlib.h> 12 #include <stdlib.h>
17 #include <fstream> 13 #include <fstream>
@@ -30,6 +26,10 @@ @@ -30,6 +26,10 @@
30 #include "listenerMonitorPCRBase.h" 26 #include "listenerMonitorPCRBase.h"
31 #include "extratorSRT_exception.h" 27 #include "extratorSRT_exception.h"
32 28
  29 +#define SIZE_CSCAPE 1
  30 +#define TARGET_TIME "-->"
  31 +//#define MAX_LINE 1024
  32 +
33 using namespace jthread; 33 using namespace jthread;
34 using namespace std; 34 using namespace std;
35 using namespace sndesc; 35 using namespace sndesc;
@@ -51,7 +51,6 @@ public: @@ -51,7 +51,6 @@ public:
51 void initialize(); 51 void initialize();
52 void Run(); 52 void Run();
53 53
54 - /* @Override: reader.h */  
55 Subtitle* next(); 54 Subtitle* next();
56 55
57 void notifyPCRBase(uint64_t pcrbase); 56 void notifyPCRBase(uint64_t pcrbase);
@@ -59,12 +58,12 @@ public: @@ -59,12 +58,12 @@ public:
59 private: 58 private:
60 59
61 list<ListenerSRT*> *listeners; 60 list<ListenerSRT*> *listeners;
62 - char* filepath; 61 + char *filepath;
63 bool finish; 62 bool finish;
64 - File* file; 63 + File *file;
65 FileIO *file_io; 64 FileIO *file_io;
66 BufferedReader *bff_reader; 65 BufferedReader *bff_reader;
67 - Subtitle * subtitle; 66 + Subtitle *subtitle;
68 67
69 uint64_t pcr_base; 68 uint64_t pcr_base;
70 int64_t seek_pos; 69 int64_t seek_pos;
extratorSRT/src/include/subtitle.h
@@ -13,12 +13,12 @@ @@ -13,12 +13,12 @@
13 #ifndef SUBTITLE_H 13 #ifndef SUBTITLE_H
14 #define SUBTITLE_H 14 #define SUBTITLE_H
15 15
16 - #define MAX_FIELD 64  
17 -  
18 #include <string> 16 #include <string>
19 #include <stdint.h> 17 #include <stdint.h>
20 #include <stdio.h> 18 #include <stdio.h>
21 19
  20 + #define MAX_FIELD 64
  21 +
22 namespace sndesc { 22 namespace sndesc {
23 23
24 class Subtitle { 24 class Subtitle {
extratorTXT/src/extratorTXT.cpp
@@ -11,8 +11,6 @@ @@ -11,8 +11,6 @@
11 11
12 #include "extratorTXT.h" 12 #include "extratorTXT.h"
13 13
14 -using namespace std;  
15 -  
16 ExtratorTXT::ExtratorTXT(){ 14 ExtratorTXT::ExtratorTXT(){
17 listeners = new list<ListenerTXT*>(); 15 listeners = new list<ListenerTXT*>();
18 finish = false; 16 finish = false;
@@ -25,7 +23,7 @@ ExtratorTXT::~ExtratorTXT(){ @@ -25,7 +23,7 @@ ExtratorTXT::~ExtratorTXT(){
25 delete file; 23 delete file;
26 delete file_io; 24 delete file_io;
27 delete bff_reader; 25 delete bff_reader;
28 - DDDPRINTF("Extractor Text finalized!\n"); 26 + DDDPRINTF("Extractor TXT finalized!\n");
29 } 27 }
30 28
31 void ExtratorTXT::initialize(){ 29 void ExtratorTXT::initialize(){
@@ -45,16 +43,16 @@ void ExtratorTXT::addListener(ListenerTXT* listener){ @@ -45,16 +43,16 @@ void ExtratorTXT::addListener(ListenerTXT* listener){
45 listeners->push_back(listener); 43 listeners->push_back(listener);
46 } 44 }
47 45
48 -void ExtratorTXT::notifyListeners(unsigned char* subtitle) { 46 +void ExtratorTXT::notifyListeners(unsigned char* line) {
49 for(list<ListenerTXT*>::iterator it = listeners->begin(); it != listeners->end(); it++){ 47 for(list<ListenerTXT*>::iterator it = listeners->begin(); it != listeners->end(); it++){
50 - (*it)->notificaTradutor(subtitle); 48 + (*it)->notifyLine(line);
51 } 49 }
52 } 50 }
53 51
54 -void ExtratorTXT::notifyEndExtraction(int sub_size) {  
55 - DDPRINTF("Extrator Text concluiu a extração: %d linhas.\n", sub_size); 52 +void ExtratorTXT::notifyEndExtraction(int line_size) {
  53 + DDPRINTF("ExtratorTXT concluiu a extração: %d linhas.\n", line_size);
56 for(list<ListenerTXT*>::iterator it = listeners->begin(); it != listeners->end(); it++){ 54 for(list<ListenerTXT*>::iterator it = listeners->begin(); it != listeners->end(); it++){
57 - (*it)->notifyEnd(sub_size); 55 + (*it)->notifyEnd(line_size);
58 } 56 }
59 } 57 }
60 58
extratorTXT/src/include/extratorTXT.h
@@ -34,8 +34,8 @@ public: @@ -34,8 +34,8 @@ public:
34 ~ExtratorTXT(); 34 ~ExtratorTXT();
35 35
36 void addListener(ListenerTXT* listener); 36 void addListener(ListenerTXT* listener);
37 - void notifyListeners(unsigned char* subtitle);  
38 - void notifyEndExtraction(int sub_size); 37 + void notifyListeners(unsigned char* line);
  38 + void notifyEndExtraction(int line_size);
39 39
40 void setFilePath(char* path); 40 void setFilePath(char* path);
41 bool isFinished(); 41 bool isFinished();
extratorTXT/src/include/listenerTXT.h
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 class ListenerTXT { 17 class ListenerTXT {
18 18
19 public: 19 public:
20 - virtual void notificaTradutor(unsigned char* line) = 0; 20 + virtual void notifyLine(unsigned char* line) = 0;
21 virtual void notifyEnd(int line_size) = 0; 21 virtual void notifyEnd(int line_size) = 0;
22 }; 22 };
23 23
input/src/include/inputFile.h
@@ -8,36 +8,37 @@ @@ -8,36 +8,37 @@
8 #ifndef INPUTFILE_H 8 #ifndef INPUTFILE_H
9 #define INPUTFILE_H 9 #define INPUTFILE_H
10 10
  11 +#include <stdio.h>
  12 +#include <list>
  13 +#include <stdlib.h>
11 #include <fstream> 14 #include <fstream>
12 #include <string.h> 15 #include <string.h>
13 #include "logger.h" 16 #include "logger.h"
14 -#include "ouvinteInput.h" 17 +#include "listenerInput.h"
15 #include "inputException.h" 18 #include "inputException.h"
16 #include "dprintf.h" 19 #include "dprintf.h"
17 20
  21 +#define MAX_SIZE_PACKET 188
18 22
19 using namespace std; 23 using namespace std;
20 24
21 class InputFile { 25 class InputFile {
22 26
23 -public:  
24 - static const int MAX_SIZE_PACKET = 188;  
25 - bool finished;  
26 - 27 +public:
27 InputFile(char* path); 28 InputFile(char* path);
28 ~InputFile(); 29 ~InputFile();
29 void initialize(); 30 void initialize();
30 - void registraOuvinte(OuvinteInput *ouvinte);  
31 - void removeOuvinte(OuvinteInput *ouvinte);  
32 - void notificaOuvintes(unsigned char * pacote); 31 + void addListener(ListenerInput* listener);
  32 + void removeListener(ListenerInput* listener);
  33 + void notifyListeners(unsigned char* pack);
33 bool isFinished(); 34 bool isFinished();
34 35
35 //void notificaQuantidadeGlosas(int quantidade); 36 //void notificaQuantidadeGlosas(int quantidade);
36 37
37 private: 38 private:
38 -  
39 - char * path;  
40 - list<OuvinteInput*> *ouvintes; 39 + list<ListenerInput*> *listeners;
  40 + char *path;
  41 + bool finish;
41 42
42 }; 43 };
43 44
input/src/include/listenerInput.h 0 → 100644
@@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
  1 +/*
  2 + * File: ouvinteInput.h
  3 + * Author: derzu
  4 + *
  5 + * Created on 8 de Fevereiro de 2010, 18:19
  6 + */
  7 +
  8 +#ifndef _LISTENERINPUT_H
  9 +#define _LISTENERINPUT_H
  10 +
  11 +class ListenerInput {
  12 +public:
  13 + virtual void notifyInput(unsigned char *pack)=0;
  14 + //virtual void finalizouInput()=0;
  15 +
  16 +};
  17 +
  18 +#endif /* _LISTENERINPUT_H */
  19 +
input/src/include/ouvinteInput.h
@@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
1 -/*  
2 - * File: ouvinteInput.h  
3 - * Author: derzu  
4 - *  
5 - * Created on 8 de Fevereiro de 2010, 18:19  
6 - */  
7 -  
8 -#ifndef _OUVINTEINPUT_H  
9 -#define _OUVINTEINPUT_H  
10 -  
11 -class OuvinteInput {  
12 -public:  
13 - OuvinteInput();  
14 - virtual ~OuvinteInput();  
15 - virtual void chegouInput(unsigned char *pacote)=0;  
16 - //virtual void finalizouInput()=0;  
17 -  
18 -private:  
19 -  
20 -};  
21 -  
22 -#endif /* _OUVINTEINPUT_H */  
23 -  
input/src/inputFile.cpp
1 -#include <stdio.h>  
2 -#include <list>  
3 -#include <stdlib.h>  
4 1
5 #include "inputFile.h" 2 #include "inputFile.h"
6 -#include "ouvinteInput.h"  
7 3
8 InputFile::InputFile(char* path) { 4 InputFile::InputFile(char* path) {
9 this->path = path; 5 this->path = path;
10 - this->ouvintes = new list<OuvinteInput*>();  
11 - finished = false; 6 + this->listeners = new list<ListenerInput*>();
  7 + finish = false;
12 DPRINTF("Done!\n"); 8 DPRINTF("Done!\n");
13 } 9 }
14 10
15 InputFile::~InputFile(){ 11 InputFile::~InputFile(){
16 - ouvintes->clear();  
17 - delete ouvintes; 12 + listeners->clear();
  13 + delete listeners;
18 DDDPRINTF("Input finalized!\n"); 14 DDDPRINTF("Input finalized!\n");
19 } 15 }
20 16
@@ -28,36 +24,36 @@ void InputFile::initialize(){ @@ -28,36 +24,36 @@ void InputFile::initialize(){
28 while (!filein.eof()) { 24 while (!filein.eof()) {
29 filein.read(buffer, MAX_SIZE_PACKET); 25 filein.read(buffer, MAX_SIZE_PACKET);
30 unsigned char* packet = (unsigned char*) buffer; 26 unsigned char* packet = (unsigned char*) buffer;
31 - notificaOuvintes(packet); 27 + notifyListeners(packet);
32 } 28 }
33 printf("\n"); 29 printf("\n");
34 filein.close(); 30 filein.close();
35 //finished = true; 31 //finished = true;
36 } else { 32 } else {
37 - finished = true; 33 + finish = true;
38 Util::Logger::Instance()->writeLog((char*) "[ERRO: inputFile.cpp] Arquivo de vídeo não encontrado."); 34 Util::Logger::Instance()->writeLog((char*) "[ERRO: inputFile.cpp] Arquivo de vídeo não encontrado.");
39 throw InputException("Falha ao abrir o arquivo de vídeo! Verifique se o mesmo existe."); 35 throw InputException("Falha ao abrir o arquivo de vídeo! Verifique se o mesmo existe.");
40 } 36 }
41 } 37 }
42 - finished = true; 38 + finish = true;
43 39
44 } 40 }
45 41
46 bool InputFile::isFinished(){ 42 bool InputFile::isFinished(){
47 - return this->finished; 43 + return this->finish;
48 } 44 }
49 45
50 -void InputFile::registraOuvinte(OuvinteInput* ouvinte){  
51 - this->ouvintes->push_back(ouvinte); 46 +void InputFile::addListener(ListenerInput* listener){
  47 + this->listeners->push_back(listener);
52 } 48 }
53 49
54 -void InputFile::removeOuvinte(OuvinteInput* ouvinte) {  
55 - this->ouvintes->remove(ouvinte); 50 +void InputFile::removeListener(ListenerInput* listener) {
  51 + this->listeners->remove(listener);
56 } 52 }
57 53
58 -void InputFile::notificaOuvintes(unsigned char* pacote){  
59 - for(list<OuvinteInput*>::iterator it = this->ouvintes->begin(); it != this->ouvintes->end(); it++){  
60 - (*it)->chegouInput(pacote); 54 +void InputFile::notifyListeners(unsigned char* pack){
  55 + for(list<ListenerInput*>::iterator it = this->listeners->begin(); it != this->listeners->end(); it++){
  56 + (*it)->notifyInput(pack);
61 } 57 }
62 } 58 }
63 59
input/src/ouvinteInput.cpp
@@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
1 -/*  
2 - * File: ouvinteInput.cpp  
3 - * Author: derzu  
4 - *  
5 - * Created on 8 de Fevereiro de 2010, 18:19  
6 - */  
7 -  
8 -#include "ouvinteInput.h"  
9 -  
10 -OuvinteInput::OuvinteInput() {  
11 -}  
12 -  
13 -OuvinteInput::~OuvinteInput() {  
14 -}  
mixer/src/Mixer.cpp
@@ -4,11 +4,7 @@ @@ -4,11 +4,7 @@
4 * 4 *
5 * Created on 17 de Janeiro de 2012, 15:28 5 * Created on 17 de Janeiro de 2012, 15:28
6 */ 6 */
7 -  
8 #include "Mixer.h" 7 #include "Mixer.h"
9 -#define PATH_API "vlibras_user/vlibras-api/videos/"  
10 -  
11 -using namespace std;  
12 8
13 /* Construtores e destrutores...*/ 9 /* Construtores e destrutores...*/
14 Mixer::Mixer() { 10 Mixer::Mixer() {
mixer/src/include/Mixer.h
@@ -5,13 +5,9 @@ @@ -5,13 +5,9 @@
5 * Created on 17 de Janeiro de 2012, 15:28 5 * Created on 17 de Janeiro de 2012, 15:28
6 */ 6 */
7 7
8 -  
9 -  
10 -  
11 #ifndef MIXER_H 8 #ifndef MIXER_H
12 #define MIXER_H 9 #define MIXER_H
13 10
14 -  
15 #include "string.h" 11 #include "string.h"
16 #include <cstdlib> 12 #include <cstdlib>
17 #include <iostream> 13 #include <iostream>
@@ -30,7 +26,6 @@ using namespace std; @@ -30,7 +26,6 @@ using namespace std;
30 #define TOP_RIGHT 2 26 #define TOP_RIGHT 2
31 #define BOTTOM_RIGHT 3 27 #define BOTTOM_RIGHT 3
32 #define BOTTOM_LEFT 4 28 #define BOTTOM_LEFT 4
33 -  
34 //SL Video Size 29 //SL Video Size
35 #define SMALL 1 30 #define SMALL 1
36 #define MEDIUM 2 31 #define MEDIUM 2
@@ -40,7 +35,9 @@ using namespace std; @@ -40,7 +35,9 @@ using namespace std;
40 #define MEDIUM_HEIGHT 432 //0,4*1080 35 #define MEDIUM_HEIGHT 432 //0,4*1080
41 #define LARGE_HEIGHT 540 //0.5*1080 36 #define LARGE_HEIGHT 540 //0.5*1080
42 37
  38 +#define PATH_API "vlibras_user/vlibras-api/videos/"
43 39
  40 +using namespace std;
44 41
45 class Mixer { 42 class Mixer {
46 public: 43 public:
monitorPCR/src/include/monitor_pcr.h
@@ -8,20 +8,24 @@ @@ -8,20 +8,24 @@
8 #ifndef MONITOR_PCR_H 8 #ifndef MONITOR_PCR_H
9 #define MONITOR_PCR_H 9 #define MONITOR_PCR_H
10 10
  11 +#include <stdio.h>
  12 +#include <string.h>
  13 +#include <locale>
11 #include <stdint.h> 14 #include <stdint.h>
12 -#include "ouvinteInput.h"  
13 -#include "listenerMonitorPCRBase.h"  
14 #include <list> 15 #include <list>
  16 +#include "listenerInput.h"
  17 +#include "listenerMonitorPCRBase.h"
15 #include "dprintf.h" 18 #include "dprintf.h"
16 19
  20 +#define PCRBASE_PADRAO 1000000
17 21
18 using namespace std; 22 using namespace std;
19 23
20 -class MonitorPCR: public OuvinteInput { 24 +class MonitorPCR: public ListenerInput {
21 25
22 public: 26 public:
23 27
24 - char* extvideo; 28 + char* extvideo;
25 29
26 MonitorPCR(); 30 MonitorPCR();
27 ~MonitorPCR(); 31 ~MonitorPCR();
@@ -29,7 +33,7 @@ class MonitorPCR: public OuvinteInput { @@ -29,7 +33,7 @@ class MonitorPCR: public OuvinteInput {
29 void addListenerPCRBase(ListenerMonitorPCRBase * listener); 33 void addListenerPCRBase(ListenerMonitorPCRBase * listener);
30 void notifyListenersWithPCRBase(uint64_t pcrbase); 34 void notifyListenersWithPCRBase(uint64_t pcrbase);
31 uint64_t getPCRBase(); 35 uint64_t getPCRBase();
32 - void chegouInput(unsigned char* packet); 36 + void notifyInput(unsigned char* packet);
33 37
34 /** 38 /**
35 * Informa para o monitor o formato do vídeo que está sendo manipulado. 39 * Informa para o monitor o formato do vídeo que está sendo manipulado.
monitorPCR/src/monitor_pcr.cpp
1 -#include <stdio.h>  
2 -#include <string.h>  
3 -#include <locale>  
4 #include "monitor_pcr.h" 1 #include "monitor_pcr.h"
5 -#define PCRBASE_PADRAO 1000000  
6 -using namespace std;  
7 2
8 MonitorPCR::MonitorPCR(){ 3 MonitorPCR::MonitorPCR(){
9 pcr_base = 0; 4 pcr_base = 0;
@@ -29,7 +24,7 @@ void MonitorPCR::setFormatVideo(char* format) { @@ -29,7 +24,7 @@ void MonitorPCR::setFormatVideo(char* format) {
29 } 24 }
30 25
31 26
32 -void MonitorPCR::chegouInput(unsigned char* packet) { 27 +void MonitorPCR::notifyInput(unsigned char* packet) {
33 28
34 if (!find) { // verifica se o PCRBase já foi encontrado 29 if (!find) { // verifica se o PCRBase já foi encontrado
35 *extvideo = tolower(*extvideo); 30 *extvideo = tolower(*extvideo);
recognize/src/include/recognize.h
@@ -4,18 +4,46 @@ @@ -4,18 +4,46 @@
4 #include <stdint.h> 4 #include <stdint.h>
5 #include <string.h> 5 #include <string.h>
6 #include <list> 6 #include <list>
  7 +#include <fstream>
  8 +#include <stdio.h>
  9 +#include <sstream>
  10 +#include <algorithm>
  11 +#include <vector>
  12 +#include <iterator>
  13 +#include <sys/stat.h>
  14 +#include <lavidlib/io/FileIO.h>
7 #include "dprintf.h" 15 #include "dprintf.h"
8 #include "logger.h" 16 #include "logger.h"
9 -  
10 #include "listenerMonitorPCRBase.h" 17 #include "listenerMonitorPCRBase.h"
11 #include "recognizeListener.h" 18 #include "recognizeListener.h"
12 #include "recognizeException.h" 19 #include "recognizeException.h"
13 20
  21 +#define FREQUENCY_PATTERN 22050
  22 +#define INPUT_PATTERN 1 /* 1 = Raw file, 2 = Mic */
  23 +#define BLOCS_PATTERN 10
  24 +#define SIZE_BUFFER 256
  25 +#define CONFIDENCE_RATE 0.45
  26 +
  27 +#define PATH_API_UPLOADS "vlibras_user/vlibras-api/uploads/"
  28 +#define PATH_AUDIO_ORIGIN "/audio/origin/audio_origin.wav"
  29 +#define PATH_AUDIO_PARTS "/audio/parts/"
  30 +#define FILENAME_RECOGNIZED_OUT "/audio/recognized.out"
  31 +#define FILENAME_AUDIOLIST "/audio/audiolist"
  32 +#define FILENAME_FILTEROUT "/audio/filter"
  33 +#define FILENAME_CONFIDENCEOUT "/audio/confidence"
  34 +
  35 +#define FIND_CONFIDENCE "\"cmscore1:\""
  36 +#define FIND_SENTENCE "\"sentence1:\""
  37 +
  38 +#define FILENAME_AUDIOPART "audio00"
  39 +#define AUDIO_SILENT "<input rejected by short input>"
  40 +
  41 +#define PROGRAM "ffmpeg" // ffmpeg
  42 +#define PTS_PATTERN 1000
14 43
15 using namespace jthread; 44 using namespace jthread;
16 using namespace std; 45 using namespace std;
17 46
18 -  
19 class Recognize: public Thread, public ListenerMonitorPCRBase { 47 class Recognize: public Thread, public ListenerMonitorPCRBase {
20 48
21 public: 49 public:
@@ -56,7 +84,7 @@ private: @@ -56,7 +84,7 @@ private:
56 char* pathVideo; 84 char* pathVideo;
57 string id; 85 string id;
58 float confidenceRate; 86 float confidenceRate;
59 - bool finished; 87 + bool finish;
60 vector<float> scores; 88 vector<float> scores;
61 vector<int64_t> pts; 89 vector<int64_t> pts;
62 90
recognize/src/recognize.cpp
1 -#include <fstream>  
2 -#include <stdio.h>  
3 -#include <sstream>  
4 -#include <stdlib.h>  
5 -#include <algorithm>  
6 -#include <vector>  
7 -#include <iterator>  
8 -#include <stdlib.h>  
9 -#include <iostream>  
10 -#include <string>  
11 -#include <sys/stat.h>  
12 -  
13 -#include <lavidlib/io/FileIO.h>  
14 -  
15 #include <recognize.h> 1 #include <recognize.h>
16 2
17 -#define FREQUENCY_PATTERN 22050  
18 -#define INPUT_PATTERN 1 /* 1 = Raw file, 2 = Mic */  
19 -#define BLOCS_PATTERN 10  
20 -#define SIZE_BUFFER 256  
21 -#define CONFIDENCE_RATE 0.45  
22 -  
23 -#define PATH_API_UPLOADS "vlibras_user/vlibras-api/uploads/"  
24 -#define PATH_AUDIO_ORIGIN "/audio/origin/audio_origin.wav"  
25 -#define PATH_AUDIO_PARTS "/audio/parts/"  
26 -#define FILENAME_RECOGNIZED_OUT "/audio/recognized.out"  
27 -#define FILENAME_AUDIOLIST "/audio/audiolist"  
28 -#define FILENAME_FILTEROUT "/audio/filter"  
29 -#define FILENAME_CONFIDENCEOUT "/audio/confidence"  
30 -  
31 -#define FIND_CONFIDENCE "\"cmscore1:\""  
32 -#define FIND_SENTENCE "\"sentence1:\""  
33 -  
34 -#define FILENAME_AUDIOPART "audio00"  
35 -#define AUDIO_SILENT "<input rejected by short input>"  
36 -  
37 -#define PROGRAM "ffmpeg" // ffmpeg  
38 -#define PTS_PATTERN 1000  
39 -  
40 -using namespace std;  
41 -  
42 -  
43 Recognize::Recognize(char* _pathVideo, char* _id) { 3 Recognize::Recognize(char* _pathVideo, char* _id) {
44 4
45 listeners = new list<RecognizeListener*>(); 5 listeners = new list<RecognizeListener*>();
@@ -102,7 +62,7 @@ void Recognize::initialize() { @@ -102,7 +62,7 @@ void Recognize::initialize() {
102 62
103 ifstream file(pathVideo, ifstream::binary); 63 ifstream file(pathVideo, ifstream::binary);
104 if(!file.is_open()){ 64 if(!file.is_open()){
105 - finished = true; 65 + finish = true;
106 Util::Logger::Instance()->writeLog((char*) "[ERRO: recognize.cpp] Arquivo não encontrado."); 66 Util::Logger::Instance()->writeLog((char*) "[ERRO: recognize.cpp] Arquivo não encontrado.");
107 throw RecognizeException("Falha ao abrir o arquivo! Verifique se o mesmo existe."); 67 throw RecognizeException("Falha ao abrir o arquivo! Verifique se o mesmo existe.");
108 } 68 }
@@ -111,7 +71,7 @@ void Recognize::initialize() { @@ -111,7 +71,7 @@ void Recognize::initialize() {
111 71
112 void Recognize::Run(){ 72 void Recognize::Run(){
113 73
114 - finished = false; 74 + finish = false;
115 createDir(); 75 createDir();
116 extractAudioFromVideo(); 76 extractAudioFromVideo();
117 breakVideoParts(getTimeMediaSec()); 77 breakVideoParts(getTimeMediaSec());
@@ -120,7 +80,7 @@ void Recognize::Run(){ @@ -120,7 +80,7 @@ void Recognize::Run(){
120 filterOutputJulius(); 80 filterOutputJulius();
121 //cleanFiles(); 81 //cleanFiles();
122 82
123 - finished = true; 83 + finish = true;
124 notifyEndExtraction(count_lines); 84 notifyEndExtraction(count_lines);
125 } 85 }
126 86
@@ -429,7 +389,7 @@ void Recognize::addListener(RecognizeListener* listener) { @@ -429,7 +389,7 @@ void Recognize::addListener(RecognizeListener* listener) {
429 389
430 390
431 bool Recognize::isFinished() { 391 bool Recognize::isFinished() {
432 - return finished; 392 + return finish;
433 } 393 }
434 394
435 395
servico/src/include/serviceWindowGeneration.h
@@ -5,13 +5,13 @@ @@ -5,13 +5,13 @@
5 #include <locale> 5 #include <locale>
6 #include <string> 6 #include <string>
7 #include "dprintf.h" 7 #include "dprintf.h"
8 -#include "ouvinteTradutor.h" 8 +#include "listenerTradutor.h"
9 #include "tradutorPortGlosa.h" 9 #include "tradutorPortGlosa.h"
10 #include <iostream> 10 #include <iostream>
11 #include <vector> 11 #include <vector>
12 //#include "httpstreamer.h" 12 //#include "httpstreamer.h"
13 #include "synchronizer.h" 13 #include "synchronizer.h"
14 -#include "ouvinteSynchronizer.h" 14 +#include "listenerSynchronizer.h"
15 #include "Mixer.h" 15 #include "Mixer.h"
16 #include <fcntl.h> 16 #include <fcntl.h>
17 #include "listenerMonitorPCRBase.h" 17 #include "listenerMonitorPCRBase.h"
@@ -23,6 +23,13 @@ @@ -23,6 +23,13 @@
23 #include "serviceException.h" 23 #include "serviceException.h"
24 #include <lavidlib/base/RuntimeException.h> 24 #include <lavidlib/base/RuntimeException.h>
25 25
  26 +#define VIDEO_POSE_NEUTRA "poseneutra"
  27 +#define BASEDIR "vlibras_user/dicionario_libras/"
  28 +#define BASEDIRTRANSP "vlibras_user/dicionarioTransp_libras/"
  29 +#define EXTENSAO_DICIONARIO ".ts"
  30 +#define PATH_API "vlibras_user/vlibras-api/videos/"
  31 +#define MAX_SIZE_PATH 256
  32 +
26 /*#define SERVICE_TYPE_CC 1 /* Closed Caption */ 33 /*#define SERVICE_TYPE_CC 1 /* Closed Caption */
27 #define SERVICE_TYPE_SRT 2 /* Subtitle SRT */ 34 #define SERVICE_TYPE_SRT 2 /* Subtitle SRT */
28 #define SERVICE_TYPE_REC 3 /* Reconhecimento de Voz */ 35 #define SERVICE_TYPE_REC 3 /* Reconhecimento de Voz */
@@ -34,7 +41,7 @@ using namespace Tradutor; @@ -34,7 +41,7 @@ using namespace Tradutor;
34 using namespace Util; 41 using namespace Util;
35 using namespace std; 42 using namespace std;
36 43
37 -class ServiceWindowGeneration : public OuvinteTradutor, public OuvinteSynchronizer{ 44 +class ServiceWindowGeneration : public ListenerTradutor, public ListenerSynchronizer{
38 45
39 protected: 46 protected:
40 47
@@ -76,9 +83,8 @@ public: @@ -76,9 +83,8 @@ public:
76 83
77 ServiceWindowGeneration(); 84 ServiceWindowGeneration();
78 ~ServiceWindowGeneration(); 85 ~ServiceWindowGeneration();
79 - //virtual void notificaGlosaTraduzida( vector<string> * glosas);  
80 - virtual void codifica(vector<string> * glosas);  
81 - virtual void finalizouSincronizacao(); 86 + virtual void notifyTranslation(vector<string>* glosas);
  87 + virtual void notifyEndOfSynchronization();
82 //virtual void notifyPCRBase(uint64_t pcr_base); 88 //virtual void notifyPCRBase(uint64_t pcr_base);
83 void initialize(); 89 void initialize();
84 TradutorPortGlosa * getTradutor(); 90 TradutorPortGlosa * getTradutor();
servico/src/include/serviceWindowGenerationFromText.h
@@ -19,7 +19,7 @@ public: @@ -19,7 +19,7 @@ public:
19 ServiceWindowGenerationFromText (char* _path_file, char* _video_path_file, 19 ServiceWindowGenerationFromText (char* _path_file, char* _video_path_file,
20 int _transp, int _serviceType, char* _client_type); 20 int _transp, int _serviceType, char* _client_type);
21 ~ServiceWindowGenerationFromText (); 21 ~ServiceWindowGenerationFromText ();
22 - void notificaTradutor(unsigned char* legenda); 22 + void notifyLine(unsigned char* line);
23 void notifyEnd(int line_size); 23 void notifyEnd(int line_size);
24 void initialize(); 24 void initialize();
25 bool isAlive(); 25 bool isAlive();
servico/src/serviceWindowGeneration.cpp
1 1
2 #include "serviceWindowGeneration.h" 2 #include "serviceWindowGeneration.h"
3 3
4 -#define VIDEO_POSE_NEUTRA "poseneutra"  
5 -#define BASEDIR "vlibras_user/dicionario_libras/"  
6 -#define BASEDIRTRANSP "vlibras_user/dicionarioTransp_libras/"  
7 -#define EXTENSAO_DICIONARIO ".ts"  
8 -#define PATH_API "vlibras_user/vlibras-api/videos/"  
9 -#define MAX_SIZE_PATH 256  
10 -  
11 -  
12 ServiceWindowGeneration::ServiceWindowGeneration() { 4 ServiceWindowGeneration::ServiceWindowGeneration() {
13 if (getRunningOption() != '3') { 5 if (getRunningOption() != '3') {
14 tradutor = new TradutorPortGlosa(); 6 tradutor = new TradutorPortGlosa();
@@ -45,7 +37,7 @@ bool ServiceWindowGeneration::isRunning() { @@ -45,7 +37,7 @@ bool ServiceWindowGeneration::isRunning() {
45 } 37 }
46 38
47 /* Quando o sincronizador termina, ele invoca esse método para avisar! */ 39 /* Quando o sincronizador termina, ele invoca esse método para avisar! */
48 -void ServiceWindowGeneration::finalizouSincronizacao() { 40 +void ServiceWindowGeneration::notifyEndOfSynchronization() {
49 if (getRunningOption() != '2' && serviceType == SERVICE_TYPE_REC || serviceType == SERVICE_TYPE_SRT) { 41 if (getRunningOption() != '2' && serviceType == SERVICE_TYPE_REC || serviceType == SERVICE_TYPE_SRT) {
50 mixer = new Mixer(); 42 mixer = new Mixer();
51 mixer->initialize(this->path_input, this->path_libras,this->position,this->size,this->transparency, this->user_id); 43 mixer->initialize(this->path_input, this->path_libras,this->position,this->size,this->transparency, this->user_id);
@@ -141,7 +133,7 @@ void ServiceWindowGeneration::initialize() { @@ -141,7 +133,7 @@ void ServiceWindowGeneration::initialize() {
141 133
142 this->finish = false; 134 this->finish = false;
143 if (getRunningOption() != '3' && this->sublanguage == 1) { 135 if (getRunningOption() != '3' && this->sublanguage == 1) {
144 - tradutor->registraOuvinte(this); 136 + tradutor->addListener(this);
145 } 137 }
146 138
147 // o path do arquivo só poderá conter um "."(ponto), esse identifica a extensão. 139 // o path do arquivo só poderá conter um "."(ponto), esse identifica a extensão.
@@ -165,7 +157,7 @@ void ServiceWindowGeneration::initialize() { @@ -165,7 +157,7 @@ void ServiceWindowGeneration::initialize() {
165 //printf("O ServiceWGeneration montou o seguinte path para o vídeo de Libras: %s\n", path_libras); 157 //printf("O ServiceWGeneration montou o seguinte path para o vídeo de Libras: %s\n", path_libras);
166 158
167 } else { 159 } else {
168 - tradutor->registraOuvinte(this); 160 + tradutor->addListener(this);
169 } 161 }
170 162
171 if(this->transparency == 0) { //pega dicionario com BackGround opaco 163 if(this->transparency == 0) { //pega dicionario com BackGround opaco
@@ -194,13 +186,12 @@ void ServiceWindowGeneration::initialize() { @@ -194,13 +186,12 @@ void ServiceWindowGeneration::initialize() {
194 } 186 }
195 } 187 }
196 188
197 - sincronizador->registraOuvinte(this); 189 + sincronizador->addListener(this);
198 sincronizador->Start(); 190 sincronizador->Start();
199 } 191 }
200 192
201 /* Método utilizado pelo Tradutor para notificar o texto traduzido. */ 193 /* Método utilizado pelo Tradutor para notificar o texto traduzido. */
202 -void ServiceWindowGeneration::codifica(vector<string> * glosas) {  
203 - 194 +void ServiceWindowGeneration::notifyTranslation(vector<string> * glosas) {
204 if (serviceType != SERVICE_TYPE_TEXT) { 195 if (serviceType != SERVICE_TYPE_TEXT) {
205 for (int i = 0; i < glosas->size(); i++) { 196 for (int i = 0; i < glosas->size(); i++) {
206 std::locale loc; 197 std::locale loc;
@@ -237,9 +228,7 @@ void ServiceWindowGeneration::codifica(vector&lt;string&gt; * glosas) { @@ -237,9 +228,7 @@ void ServiceWindowGeneration::codifica(vector&lt;string&gt; * glosas) {
237 } 228 }
238 229
239 void ServiceWindowGeneration::transcodeVideoToWebm() { 230 void ServiceWindowGeneration::transcodeVideoToWebm() {
240 -  
241 //printf("[INFO]: A transcodificação para .webm está ativada!\n"); 231 //printf("[INFO]: A transcodificação para .webm está ativada!\n");
242 -  
243 string command = "ffmpeg -i "; 232 string command = "ffmpeg -i ";
244 command.append(path_libras) 233 command.append(path_libras)
245 .append(" -vcodec libvpx -acodec libvorbis ") 234 .append(" -vcodec libvpx -acodec libvorbis ")
@@ -251,11 +240,9 @@ void ServiceWindowGeneration::transcodeVideoToWebm() { @@ -251,11 +240,9 @@ void ServiceWindowGeneration::transcodeVideoToWebm() {
251 } 240 }
252 241
253 void ServiceWindowGeneration::transcodeVideoToMp4() { 242 void ServiceWindowGeneration::transcodeVideoToMp4() {
254 -  
255 if (serviceType == SERVICE_TYPE_TEXT && strcmp(client_type, (char*)"WEB") == 0) 243 if (serviceType == SERVICE_TYPE_TEXT && strcmp(client_type, (char*)"WEB") == 0)
256 transcodeVideoToWebm(); 244 transcodeVideoToWebm();
257 else{ 245 else{
258 -  
259 //printf("[INFO]: A transcodificação para .mp4 está ativada!\n"); 246 //printf("[INFO]: A transcodificação para .mp4 está ativada!\n");
260 string command = "ffmpeg -i "; 247 string command = "ffmpeg -i ";
261 command.append(path_libras) 248 command.append(path_libras)
@@ -268,12 +255,10 @@ void ServiceWindowGeneration::transcodeVideoToMp4() { @@ -268,12 +255,10 @@ void ServiceWindowGeneration::transcodeVideoToMp4() {
268 255
269 //.append(" -strict experimental -vcodec mjpeg -r 30 -pix_fmt yuvj422p ") 256 //.append(" -strict experimental -vcodec mjpeg -r 30 -pix_fmt yuvj422p ")
270 //.append(" -strict experimental -vcodec mpeg2video -r 30 ") 257 //.append(" -strict experimental -vcodec mpeg2video -r 30 ")
271 -  
272 } 258 }
273 } 259 }
274 260
275 void ServiceWindowGeneration::createThumbnail(){ 261 void ServiceWindowGeneration::createThumbnail(){
276 -  
277 string command = "ffmpeg -ss 10 -i "; 262 string command = "ffmpeg -ss 10 -i ";
278 command.append(PATH_API).append(user_id).append(".mp4") 263 command.append(PATH_API).append(user_id).append(".mp4")
279 .append(" -vcodec png -vframes 1 -an -f rawvideo -y -vf scale=200:200 ") 264 .append(" -vcodec png -vframes 1 -an -f rawvideo -y -vf scale=200:200 ")
servico/src/serviceWindowGenerationFromREC.cpp
1 #include "serviceWindowGenerationFromREC.h" 1 #include "serviceWindowGenerationFromREC.h"
2 2
3 -using namespace std;  
4 -  
5 ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( 3 ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC(
6 char* path_video, int sublanguage, int position, int size, int transparency, char* id, int serviceType, char* rate) { 4 char* path_video, int sublanguage, int position, int size, int transparency, char* id, int serviceType, char* rate) {
7 5
@@ -51,7 +49,7 @@ void ServiceWindowGenerationFromREC::initialize() { @@ -51,7 +49,7 @@ void ServiceWindowGenerationFromREC::initialize() {
51 } 49 }
52 50
53 monitor_pcr_base->addListenerPCRBase(rec); 51 monitor_pcr_base->addListenerPCRBase(rec);
54 - inputfile->registraOuvinte(monitor_pcr_base); 52 + inputfile->addListener(monitor_pcr_base);
55 try{ 53 try{
56 inputfile->initialize(); 54 inputfile->initialize();
57 } catch(InputException ex){ 55 } catch(InputException ex){
servico/src/serviceWindowGenerationFromSRT.cpp
1 #include "serviceWindowGenerationFromSRT.h" 1 #include "serviceWindowGenerationFromSRT.h"
2 2
3 -using namespace std;  
4 3
5 //Construtor Service 2 4 //Construtor Service 2
6 ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT( 5 ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(
@@ -103,7 +102,7 @@ void ServiceWindowGenerationFromSRT::initialize() { @@ -103,7 +102,7 @@ void ServiceWindowGenerationFromSRT::initialize() {
103 102
104 monitor_pcr_base->addListenerPCRBase(extratorSRT); 103 monitor_pcr_base->addListenerPCRBase(extratorSRT);
105 104
106 - inputfile->registraOuvinte(monitor_pcr_base); 105 + inputfile->addListener(monitor_pcr_base);
107 extratorSRT->addListener(this); 106 extratorSRT->addListener(this);
108 extratorSRT->setFilePath((char*) path_srt); 107 extratorSRT->setFilePath((char*) path_srt);
109 108
servico/src/serviceWindowGenerationFromText.cpp
@@ -35,11 +35,11 @@ void ServiceWindowGenerationFromText::initialize() { @@ -35,11 +35,11 @@ void ServiceWindowGenerationFromText::initialize() {
35 } 35 }
36 36
37 void ServiceWindowGenerationFromText::notifyEnd(int line_size) { 37 void ServiceWindowGenerationFromText::notifyEnd(int line_size) {
38 - DDPRINTF("Service SRT recebeu: %d linhas.\n", line_size); 38 + DDPRINTF("Service TXT recebeu: %d linhas.\n", line_size);
39 setSizeOfSubtitles(line_size); 39 setSizeOfSubtitles(line_size);
40 } 40 }
41 41
42 -void ServiceWindowGenerationFromText::notificaTradutor(unsigned char* line) { 42 +void ServiceWindowGenerationFromText::notifyLine(unsigned char* line) {
43 tradutor->traduz(line); 43 tradutor->traduz(line);
44 } 44 }
45 45
synchronizer/src/include/listenerSynchronizer.h 0 → 100644
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
  1 +#ifndef _LISTENER_SYNCHRONIZER_H
  2 +#define _LISTENER_SYNCHRONIZER_H
  3 +
  4 +#include <string>
  5 +#include <stdint.h>
  6 +
  7 +using namespace std;
  8 +
  9 +class ListenerSynchronizer {
  10 +public:
  11 + virtual void notifyEndOfSynchronization() = 0;
  12 +};
  13 +
  14 +#endif
0 \ No newline at end of file 15 \ No newline at end of file
synchronizer/src/include/ouvinteSynchronizer.h
@@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
1 -#ifndef _OUVINTE_SYNCHRONIZER_H  
2 -#define _OUVINTE_SYNCHRONIZER_H  
3 -  
4 -#include <string>  
5 -#include <stdint.h>  
6 -  
7 -using namespace std;  
8 -  
9 -class OuvinteSynchronizer {  
10 -public:  
11 - OuvinteSynchronizer();  
12 - virtual ~OuvinteSynchronizer();  
13 -  
14 - // inclusão do parâmetro "long int pts"  
15 - virtual void finalizouSincronizacao() = 0;  
16 -private:  
17 -  
18 -};  
19 -  
20 -#endif  
21 \ No newline at end of file 0 \ No newline at end of file
synchronizer/src/include/synchronizer.h
1 #ifndef SYNCHRONIZER_H 1 #ifndef SYNCHRONIZER_H
2 #define SYNCHRONIZER_H 2 #define SYNCHRONIZER_H
3 3
4 -#include "jthread.h"  
5 #include <stdio.h> 4 #include <stdio.h>
6 #include <stdlib.h> 5 #include <stdlib.h>
7 #include <string.h> 6 #include <string.h>
8 #include <errno.h> 7 #include <errno.h>
9 -#include <arpa/inet.h>  
10 -#include <sys/socket.h>  
11 -#include <fcntl.h>  
12 -#include <sys/time.h>  
13 #include <time.h> 8 #include <time.h>
14 #include <unistd.h> 9 #include <unistd.h>
  10 +#include <signal.h>
  11 +#include <fcntl.h>
  12 +#include <sys/time.h>
  13 +#include <arpa/inet.h>
  14 +#include <sys/socket.h>
  15 +#include <vector>
  16 +#include <list>
  17 +#include <iostream>
15 #include <fstream> 18 #include <fstream>
  19 +#include "dprintf.h"
16 #include "jmutex.h" 20 #include "jmutex.h"
17 -#include <signal.h>  
18 -#include "ouvinteSynchronizer.h" 21 +#include "jthread.h"
  22 +#include "listenerSynchronizer.h"
19 #include "listenerMonitorPCRBase.h" 23 #include "listenerMonitorPCRBase.h"
  24 +//#include "httpstreamer.h"
20 25
21 -#include <vector>  
22 -#include <list> 26 +#define VIDEO_PADRAO "vlibras_user/dicionario_libras/poseneutra.ts"
  27 +#define VIDEOTRANSP_PADRAO "vlibras_user/dicionarioTransp_libras/poseneutra.ts"
  28 +
  29 +//DICIONARIO 30 fps
  30 +#define PCRPID 256
  31 +#define PESPID 256
  32 +
  33 +//DICIONARIO 45 fps
  34 +//#define PCRPID 4097
  35 +//#define PESPID 4113
23 36
24 using namespace jthread; 37 using namespace jthread;
25 using namespace std; 38 using namespace std;
26 39
27 class Synchronizer : public jthread::Thread, public ListenerMonitorPCRBase { 40 class Synchronizer : public jthread::Thread, public ListenerMonitorPCRBase {
  41 +
28 private: 42 private:
29 bool hastext; 43 bool hastext;
30 int taxa; 44 int taxa;
31 int filefd; 45 int filefd;
32 vector <char*> *videos; 46 vector <char*> *videos;
33 int devicetv; 47 int devicetv;
  48 +
34 uint64_t pcrBaseGeral; 49 uint64_t pcrBaseGeral;
35 uint64_t ultimoPCRBase; 50 uint64_t ultimoPCRBase;
36 uint64_t ultimoPCRBaseMod; 51 uint64_t ultimoPCRBaseMod;
  52 + int64_t pcr_inicial;
37 int mediaDiferencaPCR; 53 int mediaDiferencaPCR;
38 int contagemPCR; 54 int contagemPCR;
  55 +
39 ofstream escreveAux; 56 ofstream escreveAux;
40 char* extensao; 57 char* extensao;
41 char* baseDir; 58 char* baseDir;
42 - int64_t pcr_inicial; 59 +
43 int64_t tempo_poseneutra; 60 int64_t tempo_poseneutra;
44 vector <int64_t> *vector_pts; 61 vector <int64_t> *vector_pts;
45 int flagPrimeiroArquivo; 62 int flagPrimeiroArquivo;
46 - list<OuvinteSynchronizer*> * ouvintes;  
47 - char* path_libras; 63 +
  64 + list<ListenerSynchronizer*> * listeners;
48 Mutex* mutex_sync; 65 Mutex* mutex_sync;
  66 + Mutex* mutexi;
49 67
  68 + char* path_libras;
50 int transparency; 69 int transparency;
51 70
52 int count_tasks; 71 int count_tasks;
@@ -57,13 +76,14 @@ public: @@ -57,13 +76,14 @@ public:
57 Synchronizer(); 76 Synchronizer();
58 Synchronizer(/*int64_t pcr_inicial, */char*baseDir, char* extensao, char* path_libras, int transparency); 77 Synchronizer(/*int64_t pcr_inicial, */char*baseDir, char* extensao, char* path_libras, int transparency);
59 virtual ~Synchronizer(); 78 virtual ~Synchronizer();
  79 +
60 virtual void notifyPCRBase(uint64_t pcr_base); 80 virtual void notifyPCRBase(uint64_t pcr_base);
61 void setPCRBase(uint64_t pcr_base); 81 void setPCRBase(uint64_t pcr_base);
62 - //em fase de teste  
63 - void soletraGlosa(string glosa, int64_t pts);  
64 82
65 void Run(); 83 void Run();
66 void stop(); 84 void stop();
  85 +
  86 + void soletraGlosa(string glosa, int64_t pts);//em fase de teste
67 void recebeglosa(char * video, int tam, int64_t pts); 87 void recebeglosa(char * video, int tam, int64_t pts);
68 void recebeglosa(string glosa, int64_t pts); 88 void recebeglosa(string glosa, int64_t pts);
69 char * getproximoarquivo(); 89 char * getproximoarquivo();
@@ -98,9 +118,9 @@ public: @@ -98,9 +118,9 @@ public:
98 void escrevePacote(char *pacote); 118 void escrevePacote(char *pacote);
99 int escrevePacote(int * descritor, char *pacote, int size); 119 int escrevePacote(int * descritor, char *pacote, int size);
100 120
101 - virtual void registraOuvinte(OuvinteSynchronizer * ouvinte);  
102 - virtual void removeOuvinte(OuvinteSynchronizer * ouvinte);  
103 - virtual void notificaOuvintes(); 121 + virtual void addListener(ListenerSynchronizer* listener);
  122 + virtual void removeListener(ListenerSynchronizer* listener);
  123 + virtual void notifyListeners();
104 124
105 }; 125 };
106 126
synchronizer/src/ouvinteSynchronizer.cpp
@@ -1,7 +0,0 @@ @@ -1,7 +0,0 @@
1 -#include "ouvinteSynchronizer.h"  
2 -  
3 -OuvinteSynchronizer::OuvinteSynchronizer() {  
4 -}  
5 -  
6 -OuvinteSynchronizer::~OuvinteSynchronizer() {  
7 -}  
synchronizer/src/synchronizer.cpp
1 -#include <stdio.h>  
2 -#include <iostream>  
3 -#include "dprintf.h"  
4 #include "synchronizer.h" 1 #include "synchronizer.h"
5 -//#include "httpstreamer.h"  
6 -#include "jmutex.h"  
7 -#define VIDEO_PADRAO "vlibras_user/dicionario_libras/poseneutra.ts"  
8 -#define VIDEOTRANSP_PADRAO "vlibras_user/dicionarioTransp_libras/poseneutra.ts"  
9 -  
10 -//DICIONARIO 45 fps  
11 -//#define PCRPID 4097  
12 -//#define PESPID 4113  
13 -  
14 -  
15 -//DICIONARIO 30 fps  
16 -#define PCRPID 256  
17 -#define PESPID 256  
18 -  
19 -Mutex* mutexi = new Mutex();  
20 2
21 Synchronizer::Synchronizer() { 3 Synchronizer::Synchronizer() {
22 baseDir = (char*) "vlibras_user/dicionario_libras/"; 4 baseDir = (char*) "vlibras_user/dicionario_libras/";
@@ -24,6 +6,7 @@ Synchronizer::Synchronizer() { @@ -24,6 +6,7 @@ Synchronizer::Synchronizer() {
24 filefd = 0; 6 filefd = 0;
25 videos = new vector <char*> (); 7 videos = new vector <char*> ();
26 vector_pts = new vector <int64_t > (); 8 vector_pts = new vector <int64_t > ();
  9 + this->mutexi = new Mutex();
27 10
28 this->baseDir = new char[strlen(baseDir) + 1]; 11 this->baseDir = new char[strlen(baseDir) + 1];
29 strcpy(this->baseDir, baseDir); 12 strcpy(this->baseDir, baseDir);
@@ -31,7 +14,7 @@ Synchronizer::Synchronizer() { @@ -31,7 +14,7 @@ Synchronizer::Synchronizer() {
31 this->extensao = new char[strlen(extensao) + 1]; 14 this->extensao = new char[strlen(extensao) + 1];
32 strcpy(this->extensao, extensao); 15 strcpy(this->extensao, extensao);
33 flagPrimeiroArquivo = 1; 16 flagPrimeiroArquivo = 1;
34 - ouvintes = new list<OuvinteSynchronizer*>(); 17 + listeners = new list<ListenerSynchronizer*>();
35 this->path_libras = path_libras; 18 this->path_libras = path_libras;
36 DPRINTF("Done!\n") 19 DPRINTF("Done!\n")
37 } 20 }
@@ -50,7 +33,6 @@ Synchronizer::Synchronizer(/*int64_t pcr_inicial, */char* baseDir, char* extensa @@ -50,7 +33,6 @@ Synchronizer::Synchronizer(/*int64_t pcr_inicial, */char* baseDir, char* extensa
50 33
51 //cout << "\n\nTransparencia: " << this->transparency << "\n"; 34 //cout << "\n\nTransparencia: " << this->transparency << "\n";
52 35
53 -  
54 this->baseDir = new char[strlen(baseDir) + 1]; 36 this->baseDir = new char[strlen(baseDir) + 1];
55 strcpy(this->baseDir, baseDir); 37 strcpy(this->baseDir, baseDir);
56 38
@@ -67,22 +49,22 @@ Synchronizer::Synchronizer(/*int64_t pcr_inicial, */char* baseDir, char* extensa @@ -67,22 +49,22 @@ Synchronizer::Synchronizer(/*int64_t pcr_inicial, */char* baseDir, char* extensa
67 contagemPCR = 0; 49 contagemPCR = 0;
68 vector_pts = new vector <int64_t > (); 50 vector_pts = new vector <int64_t > ();
69 flagPrimeiroArquivo = 1; 51 flagPrimeiroArquivo = 1;
70 - ouvintes = new list<OuvinteSynchronizer*>(); 52 + listeners = new list<ListenerSynchronizer*>();
71 this->path_libras = new char[strlen(path_libras) + 1]; 53 this->path_libras = new char[strlen(path_libras) + 1];
72 strcpy(this->path_libras, path_libras); 54 strcpy(this->path_libras, path_libras);
73 //cout << "-> path libras sync: " << path_libras << endl; 55 //cout << "-> path libras sync: " << path_libras << endl;
74 this->mutex_sync = new Mutex(); 56 this->mutex_sync = new Mutex();
  57 + this->mutexi = new Mutex();
75 58
76 DPRINTF("Done!\n") 59 DPRINTF("Done!\n")
77 -  
78 } 60 }
79 61
80 Synchronizer::~Synchronizer() { 62 Synchronizer::~Synchronizer() {
81 free(videos); 63 free(videos);
82 - ouvintes->clear();  
83 - delete ouvintes; 64 + listeners->clear();
  65 + delete listeners;
84 if (escreveAux.is_open()) escreveAux.close(); 66 if (escreveAux.is_open()) escreveAux.close();
85 - DDDPRINTF("Synchronized finalized!\n"); 67 + DDDPRINTF("Synchronizer finalized!\n");
86 68
87 } 69 }
88 70
@@ -108,12 +90,10 @@ string toLower(string strr) { @@ -108,12 +90,10 @@ string toLower(string strr) {
108 return ret; 90 return ret;
109 } 91 }
110 92
111 -  
112 void Synchronizer::setPCRBase(uint64_t pcr_base){ 93 void Synchronizer::setPCRBase(uint64_t pcr_base){
113 this->pcr_inicial = pcr_base; 94 this->pcr_inicial = pcr_base;
114 } 95 }
115 96
116 -  
117 char* converteString(string palavra) { 97 char* converteString(string palavra) {
118 98
119 const char* aux = new char[palavra.size()]; 99 const char* aux = new char[palavra.size()];
@@ -123,9 +103,6 @@ char* converteString(string palavra) { @@ -123,9 +103,6 @@ char* converteString(string palavra) {
123 return aux2; 103 return aux2;
124 } 104 }
125 105
126 -  
127 -  
128 -  
129 /* Método utilizado pelos serviços (Services Generation) para informar que 106 /* Método utilizado pelos serviços (Services Generation) para informar que
130 este processo pode ser finalizado após a demanda atual, isto é, depois 107 este processo pode ser finalizado após a demanda atual, isto é, depois
131 que terminar de gerar os vídeos que estão na fila. 108 que terminar de gerar os vídeos que estão na fila.
@@ -226,7 +203,6 @@ char * Synchronizer::getproximoarquivo() { @@ -226,7 +203,6 @@ char * Synchronizer::getproximoarquivo() {
226 203
227 } 204 }
228 205
229 -  
230 void Synchronizer::analisaPCR(unsigned char *pacote) { 206 void Synchronizer::analisaPCR(unsigned char *pacote) {
231 // preciso ter o PID de PCR 207 // preciso ter o PID de PCR
232 if ((getPid(pacote) != PCRPID) || (!contemAF(pacote)) 208 if ((getPid(pacote) != PCRPID) || (!contemAF(pacote))
@@ -272,8 +248,6 @@ void Synchronizer::analisaPCR(unsigned char *pacote) { @@ -272,8 +248,6 @@ void Synchronizer::analisaPCR(unsigned char *pacote) {
272 } 248 }
273 249
274 void Synchronizer::analisaPTSDTS(unsigned char *pacote) { 250 void Synchronizer::analisaPTSDTS(unsigned char *pacote) {
275 -  
276 -  
277 int inicioPESData = 4; 251 int inicioPESData = 4;
278 if (contemAF(pacote)) inicioPESData += getTamanhoAF(pacote) + 1; 252 if (contemAF(pacote)) inicioPESData += getTamanhoAF(pacote) + 1;
279 253
@@ -488,17 +462,17 @@ void Synchronizer::recebeglosa(string glosa, int64_t pts) { @@ -488,17 +462,17 @@ void Synchronizer::recebeglosa(string glosa, int64_t pts) {
488 } 462 }
489 463
490 464
491 -void Synchronizer::registraOuvinte(OuvinteSynchronizer * ouvinte) {  
492 - ouvintes->push_back(ouvinte); 465 +void Synchronizer::addListener(ListenerSynchronizer* listener) {
  466 + listeners->push_back(listener);
493 } 467 }
494 468
495 -void Synchronizer::removeOuvinte(OuvinteSynchronizer * ouvinte) {  
496 - ouvintes->remove(ouvinte); 469 +void Synchronizer::removeListener(ListenerSynchronizer* listener) {
  470 + listeners->remove(listener);
497 } 471 }
498 472
499 -void Synchronizer::notificaOuvintes() {  
500 - for (list<OuvinteSynchronizer*>::iterator i = ouvintes->begin(); i != ouvintes->end(); i++) {  
501 - (*i)->finalizouSincronizacao(); 473 +void Synchronizer::notifyListeners() {
  474 + for (list<ListenerSynchronizer*>::iterator i = listeners->begin(); i != listeners->end(); i++) {
  475 + (*i)->notifyEndOfSynchronization();
502 } 476 }
503 } 477 }
504 478
@@ -592,7 +566,7 @@ void Synchronizer::Run() { @@ -592,7 +566,7 @@ void Synchronizer::Run() {
592 //fsync(desc_out); 566 //fsync(desc_out);
593 close(filefd); 567 close(filefd);
594 close(desc_out); 568 close(desc_out);
595 - notificaOuvintes(); 569 + notifyListeners();
596 570
597 } 571 }
598 572
tradutor/src/include/listenerTradutor.h 0 → 100644
@@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
  1 +/*
  2 + * File: ouvinteTradutor.h
  3 + * Author: derzu
  4 + *
  5 + * Created on 2 de Fevereiro de 2010, 15:48
  6 + */
  7 +#ifndef _LISTENERTRADUTOR_H
  8 +#define _LISTENERTRADUTOR_H
  9 +
  10 +#include <string>
  11 +#include <vector>
  12 +
  13 +namespace Tradutor {
  14 +
  15 + class ListenerTradutor {
  16 + public:
  17 + //OuvinteTradutor();
  18 + //virtual ~OuvinteTradutor();
  19 +
  20 + // Metodo que vai ser chamado quando chegar a traducao
  21 + virtual void notifyTranslation(std::vector<std::string> * glosas) = 0;
  22 + };
  23 +
  24 +}
  25 +
  26 +#endif /* _LISTENERTRADUTOR_H */
tradutor/src/include/ouvinteTradutor.h
@@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
1 -/*  
2 - * File: ouvinteTradutor.h  
3 - * Author: derzu  
4 - *  
5 - * Created on 2 de Fevereiro de 2010, 15:48  
6 - */  
7 -  
8 -#ifndef _OUVINTETRADUTOR_H  
9 -#define _OUVINTETRADUTOR_H  
10 -  
11 -#include <string>  
12 -#include <vector>  
13 -  
14 -namespace Tradutor {  
15 -  
16 - class OuvinteTradutor {  
17 - public:  
18 - OuvinteTradutor();  
19 - virtual ~OuvinteTradutor();  
20 -  
21 - // Metodo que vai ser chamado quando chegar a traducao  
22 - virtual void codifica(std::vector<std::string> * glosas)=0;  
23 - };  
24 -  
25 -}  
26 -  
27 -#endif /* _OUVINTETRADUTOR_H */  
tradutor/src/include/pyTradutor.h
@@ -11,18 +11,19 @@ @@ -11,18 +11,19 @@
11 #define _PYTRADUTOR_H 11 #define _PYTRADUTOR_H
12 12
13 namespace Tradutor { 13 namespace Tradutor {
  14 +
14 class PyTradutor{ 15 class PyTradutor{
15 - public:  
16 - PyTradutor();  
17 - ~PyTradutor();  
18 - char * convertStringToGlosa(const char * input);  
19 - PyObject * pName;  
20 - PyObject * pModule;  
21 - PyObject * pDict;  
22 - PyObject * pFunc;  
23 - PyObject * pArgs;  
24 - PyObject * pResult;  
25 - bool isRunning; 16 + public:
  17 + PyTradutor();
  18 + ~PyTradutor();
  19 + char * convertStringToGlosa(const char * input);
  20 + PyObject * pName;
  21 + PyObject * pModule;
  22 + PyObject * pDict;
  23 + PyObject * pFunc;
  24 + PyObject * pArgs;
  25 + PyObject * pResult;
  26 + bool isRunning;
26 }; 27 };
27 } 28 }
28 29
tradutor/src/include/tradutorPortGlosa.h
@@ -12,44 +12,45 @@ @@ -12,44 +12,45 @@
12 * @date 21/10/2009 12 * @date 21/10/2009
13 * 13 *
14 */ 14 */
15 -  
16 #include <iostream> 15 #include <iostream>
17 #include <list> 16 #include <list>
18 #include <pthread.h> 17 #include <pthread.h>
19 -#include "ouvinteTradutor.h" 18 +#include "listenerTradutor.h"
20 #include "pyTradutor.h" 19 #include "pyTradutor.h"
21 -#include "ouvinteInput.h" 20 +#include "listenerInput.h"
22 #include "dprintf.h" 21 #include "dprintf.h"
23 22
24 #ifndef _GERADOR_GLOSA_H_ 23 #ifndef _GERADOR_GLOSA_H_
25 #define _GERADOR_GLOSA_H_ 24 #define _GERADOR_GLOSA_H_
26 25
  26 +using namespace std;
  27 +
27 namespace Tradutor { 28 namespace Tradutor {
28 29
29 - class TradutorPortGlosa : public OuvinteInput{ 30 + class TradutorPortGlosa : public ListenerInput{
30 public: 31 public:
31 - TradutorPortGlosa();  
32 - virtual ~TradutorPortGlosa();  
33 - std::vector<std::string> * portuguesToGlosaVector(const char * input);  
34 - std::vector<std::string> * portuguesToGlosaVectorSplit(char * pGlosa); 32 + TradutorPortGlosa();
  33 + virtual ~TradutorPortGlosa();
  34 + std::vector<std::string> * portuguesToGlosaVector(const char * input);
  35 + std::vector<std::string> * portuguesToGlosaVectorSplit(char * pGlosa);
35 36
36 - // Adiciona  
37 - void registraOuvinte(OuvinteTradutor * ouvinte);  
38 - // Remove  
39 - void removeOuvinte(OuvinteTradutor * ouvinte); 37 + // Adiciona
  38 + void addListener(ListenerTradutor * listener);
  39 + // Remove
  40 + void removeListener(ListenerTradutor * listener);
40 41
41 - void traduz(unsigned char * texto);  
42 - virtual void chegouInput(unsigned char * texto);  
43 - //virtual void notificaCC(unsigned char * cc, int64_t pts); 42 + void traduz(unsigned char * texto);
  43 + virtual void notifyInput(unsigned char * texto);
  44 + //virtual void notificaCC(unsigned char * cc, int64_t pts);
44 45
45 46
46 private: 47 private:
47 - void notificaOuvintes(std::vector<std::string> * traducao); 48 + void notifyListeners(std::vector<std::string> * traducao);
48 49
49 - std::list<OuvinteTradutor*> * ouvintes;  
50 - PyTradutor * pyTradutor;  
51 - // Mutex para evitar mutiplas chamadas de notificadores  
52 - pthread_mutex_t *mutex; 50 + std::list<ListenerTradutor*> * listeners;
  51 + PyTradutor * pyTradutor;
  52 + // Mutex para evitar mutiplas chamadas de notificadores
  53 + pthread_mutex_t *mutex;
53 54
54 }; 55 };
55 } 56 }
tradutor/src/ouvinteTradutor.cpp
@@ -1,18 +0,0 @@ @@ -1,18 +0,0 @@
1 -/*  
2 - * File: ouvinteTradutor.cpp  
3 - * Author: derzu  
4 - *  
5 - * Created on 2 de Fevereiro de 2010, 15:48  
6 - */  
7 -  
8 -#include "ouvinteTradutor.h"  
9 -  
10 -namespace Tradutor {  
11 -  
12 - OuvinteTradutor::OuvinteTradutor() {  
13 - }  
14 -  
15 - OuvinteTradutor::~OuvinteTradutor() {  
16 - }  
17 -  
18 -}  
tradutor/src/tradutorPortGlosa.cpp
@@ -12,27 +12,21 @@ @@ -12,27 +12,21 @@
12 * @date 21/10/2009 12 * @date 21/10/2009
13 * 13 *
14 */ 14 */
15 -  
16 #include "tradutorPortGlosa.h" 15 #include "tradutorPortGlosa.h"
17 16
18 -using namespace std;  
19 -  
20 -  
21 namespace Tradutor { 17 namespace Tradutor {
22 TradutorPortGlosa::TradutorPortGlosa() { 18 TradutorPortGlosa::TradutorPortGlosa() {
23 - ouvintes = new list<OuvinteTradutor*>();  
24 - pyTradutor = new PyTradutor();  
25 - 19 + listeners = new list<ListenerTradutor*>();
  20 + pyTradutor = new PyTradutor();
26 // Inicia o mutex 21 // Inicia o mutex
27 mutex = (pthread_mutex_t *) malloc( sizeof(pthread_mutex_t) ); 22 mutex = (pthread_mutex_t *) malloc( sizeof(pthread_mutex_t) );
28 pthread_mutex_init(mutex, NULL); 23 pthread_mutex_init(mutex, NULL);
29 DPRINTF("Done!\n") 24 DPRINTF("Done!\n")
30 -  
31 } 25 }
32 26
33 27
34 TradutorPortGlosa::~TradutorPortGlosa() { 28 TradutorPortGlosa::~TradutorPortGlosa() {
35 - delete ouvintes; 29 + delete listeners;
36 delete pyTradutor; 30 delete pyTradutor;
37 if (mutex) { 31 if (mutex) {
38 int ret = pthread_mutex_destroy(mutex); 32 int ret = pthread_mutex_destroy(mutex);
@@ -44,93 +38,93 @@ namespace Tradutor { @@ -44,93 +38,93 @@ namespace Tradutor {
44 38
45 } 39 }
46 40
47 - void TradutorPortGlosa::registraOuvinte(OuvinteTradutor * ouvinte) {  
48 - ouvintes->push_back(ouvinte);  
49 - } 41 + void TradutorPortGlosa::addListener(ListenerTradutor* listener) {
  42 + listeners->push_back(listener);
  43 + }
50 44
51 45
52 - void TradutorPortGlosa::removeOuvinte(OuvinteTradutor * ouvinte) {  
53 - ouvintes->remove(ouvinte);  
54 - } 46 + void TradutorPortGlosa::removeListener(ListenerTradutor* listener) {
  47 + listeners->remove(listener);
  48 + }
55 49
56 50
57 - void TradutorPortGlosa::notificaOuvintes(vector<string> * traducao) {  
58 - for (list<OuvinteTradutor*>::iterator i=ouvintes->begin() ; i!= ouvintes->end() ; i++){  
59 - (*i)->codifica(traducao);  
60 - }  
61 - } 51 + void TradutorPortGlosa::notifyListeners(vector<string> * traducao) {
  52 + for (list<ListenerTradutor*>::iterator i = listeners->begin() ; i != listeners->end() ; i++){
  53 + (*i)->notifyTranslation(traducao);
  54 + }
  55 + }
62 56
63 - /*  
64 - // Implemento o metodo da classe que estou ouvindo, classe ExtratorCC  
65 - void TradutorPortGlosa::notificaCC(unsigned char * cc, int64_t pts) {  
66 - // Mutex para evitar bug multiplas chamadas dos notificadores  
67 - pthread_mutex_lock(mutex);  
68 - traduz(cc);  
69 - pthread_mutex_unlock(mutex);  
70 - }*/  
71 -  
72 - // Implemento o metodo da classe que estou ouvindo, classe ExtratorCC  
73 - void TradutorPortGlosa::chegouInput(unsigned char * texto) {  
74 - // Mutex para evitar bug multiplas chamadas dos notificadores  
75 - pthread_mutex_lock(mutex);  
76 - traduz(texto);  
77 - pthread_mutex_unlock(mutex);  
78 - }  
79 -  
80 - void TradutorPortGlosa::traduz(unsigned char * texto) {  
81 - vector<string> * vGlosa = portuguesToGlosaVector((const char *)texto);  
82 - if (vGlosa->size() > 0)  
83 - notificaOuvintes(vGlosa);  
84 - free(vGlosa);  
85 - } 57 + /*
  58 + // Implemento o metodo da classe que estou ouvindo, classe ExtratorCC
  59 + void TradutorPortGlosa::notificaCC(unsigned char * cc, int64_t pts) {
  60 + // Mutex para evitar bug multiplas chamadas dos notificadores
  61 + pthread_mutex_lock(mutex);
  62 + traduz(cc);
  63 + pthread_mutex_unlock(mutex);
  64 + }*/
  65 +
  66 + // Implemento o metodo da classe que estou ouvindo.
  67 + void TradutorPortGlosa::notifyInput(unsigned char * texto) {
  68 + // Mutex para evitar bug multiplas chamadas dos notificadores
  69 + pthread_mutex_lock(mutex);
  70 + traduz(texto);
  71 + pthread_mutex_unlock(mutex);
  72 + }
  73 +
  74 + void TradutorPortGlosa::traduz(unsigned char * texto) {
  75 + vector<string> * vGlosa = portuguesToGlosaVector((const char *)texto);
  76 + if (vGlosa->size() > 0)
  77 + notifyListeners(vGlosa);
  78 + free(vGlosa);
  79 + }
86 80
87 81
88 - /**  
89 - * Traduz um texto (char * input) para um vetor de tokens<string> contendo a  
90 - * traducao para glosa  
91 - *  
92 - * @param input texto de entrada  
93 - * @return vetor de string contendo os tokens em glosa traduzidos.  
94 - **/  
95 - vector<string> * TradutorPortGlosa::portuguesToGlosaVector(const char * input) {  
96 - char * sGlosa;  
97 - vector<string> * vGlosa; 82 + /**
  83 + * Traduz um texto (char * input) para um vetor de tokens<string> contendo a
  84 + * traducao para glosa
  85 + *
  86 + * @param input texto de entrada
  87 + * @return vetor de string contendo os tokens em glosa traduzidos.
  88 + **/
  89 + vector<string> * TradutorPortGlosa::portuguesToGlosaVector(const char * input) {
  90 + char * sGlosa;
  91 + vector<string> * vGlosa;
98 92
99 - // Faz a tradução de portugues para glosa  
100 - sGlosa = pyTradutor->convertStringToGlosa(input); 93 + // Faz a tradução de portugues para glosa
  94 + sGlosa = pyTradutor->convertStringToGlosa(input);
101 95
102 - // Cria vetor de string contendo os tokens da glosa já traduzidos  
103 - vGlosa = portuguesToGlosaVectorSplit(sGlosa);  
104 -  
105 - return vGlosa;  
106 - } 96 + // Cria vetor de string contendo os tokens da glosa já traduzidos
  97 + vGlosa = portuguesToGlosaVectorSplit(sGlosa);
107 98
  99 + return vGlosa;
  100 + }
108 101
109 - /**  
110 - * Faz split de uma string (char * sGlosa) para um vector<string> contendo os  
111 - * tokens da glosa  
112 - *  
113 - * @param sGlosa string de glosa  
114 - * @return vetor de string contendo os tokens em glosa.  
115 - **/  
116 - vector<string> * TradutorPortGlosa::portuguesToGlosaVectorSplit(char * sGlosa) { 102 + /**
  103 + * Faz split de uma string (char * sGlosa) para um vector<string> contendo os
  104 + * tokens da glosa
  105 + *
  106 + * @param sGlosa string de glosa
  107 + * @return vetor de string contendo os tokens em glosa.
  108 + **/
  109 + vector<string> * TradutorPortGlosa::portuguesToGlosaVectorSplit(char * sGlosa) {
117 110
118 - //printf("[INFO] Glosa: %s\n", sGlosa); 111 + //printf("[INFO] Glosa: %s\n", sGlosa);
119 112
120 - vector<string> * vGlosa = new vector<string>();  
121 - string str(reinterpret_cast<char*>(sGlosa)); 113 + vector<string> * vGlosa = new vector<string>();
  114 + string str(reinterpret_cast<char*>(sGlosa));
122 115
123 - int cutAt;  
124 - while((cutAt = str.find_first_of(" ")) != str.npos){  
125 - if(cutAt > 0) {  
126 - vGlosa->push_back(str.substr(0,cutAt));  
127 - }  
128 - str = str.substr(cutAt+1);  
129 - }  
130 - if(str.length() > 0) {  
131 - vGlosa->push_back(str); 116 + int cutAt;
  117 + while((cutAt = str.find_first_of(" ")) != str.npos){
  118 + if(cutAt > 0){
  119 + vGlosa->push_back(str.substr(0,cutAt));
132 } 120 }
  121 + str = str.substr(cutAt+1);
  122 + }
133 123
134 - return vGlosa; 124 + if(str.length() > 0) {
  125 + vGlosa->push_back(str);
135 } 126 }
  127 +
  128 + return vGlosa;
  129 + }
136 } 130 }
util/src/include/logger.h
@@ -25,7 +25,6 @@ @@ -25,7 +25,6 @@
25 25
26 using namespace std; 26 using namespace std;
27 27
28 -  
29 namespace Util { 28 namespace Util {
30 29
31 class Logger { 30 class Logger {
util/src/logger.cpp
@@ -11,8 +11,6 @@ @@ -11,8 +11,6 @@
11 11
12 #include "logger.h" 12 #include "logger.h"
13 13
14 -using namespace std;  
15 -  
16 namespace Util { 14 namespace Util {
17 15
18 Logger* Logger::m_pInstance = NULL; 16 Logger* Logger::m_pInstance = NULL;