Commit bb4f663f10b8fdb1601d6227ae6e80c9a321936b

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

Documentação do componente servico

servico/src/include/serviceException.h
1 -/***************************************************************************  
2 - * Universidade Federal da Paraíba *  
3 - * Copyright (C) 2014 by Laboratório de Aplicações de Vídeo Digital *  
4 - * *  
5 - * Centro de Informática - UFPB - Campus I *  
6 - * João Pessoa - PB - Brasil *  
7 - * *  
8 - * Author: Erickson Silva (erickson.silva@lavid.ufpb.br) *  
9 - * *  
10 - **************************************************************************/ 1 +/**
  2 + * \file serviceException.h
  3 + *
  4 + * \author Erickson Silva <erickson.silva@lavid.ufpb.br>
  5 + * \date 2014
  6 + */
11 7
12 #ifndef SERVICEEXCEPTION_H 8 #ifndef SERVICEEXCEPTION_H
13 #define SERVICEEXCEPTION_H 9 #define SERVICEEXCEPTION_H
servico/src/include/serviceTester.h
  1 +/**
  2 + * \file serviceTester.h
  3 + *
  4 + * \author Wesnydy Lima Ribeiro <wesnydy@lavid.ufpb.br>
  5 + * \date 2015
  6 + */
  7 +
1 #ifndef SERVICETESTER_H 8 #ifndef SERVICETESTER_H
2 #define SERVICETESTER_H 9 #define SERVICETESTER_H
3 10
@@ -23,11 +30,28 @@ @@ -23,11 +30,28 @@
23 using namespace util; 30 using namespace util;
24 using namespace std; 31 using namespace std;
25 32
  33 +/** \brief Classe que implementa o serviço de testes.
  34 + *
  35 + * \headerfile servico/src/include/serviceTester.h
  36 + */
26 class ServiceTester: public Thread { 37 class ServiceTester: public Thread {
27 38
28 public: 39 public:
  40 + /** Construtor.
  41 + *
  42 + * \param position Posição do vídeo de LIBRAS em relação ao vídeo original.
  43 + * \param size Tamanho do vídeo de LIBRAS.
  44 + * \param Background Plano de fundo do vídeo de LIBRAS.
  45 + */
29 ServiceTester(int position, int size, int background); 46 ServiceTester(int position, int size, int background);
  47 +
  48 + /** Destrutor */
30 ~ServiceTester(); 49 ~ServiceTester();
  50 +
  51 + /** Indica o fim do processo de testes dos módulos.
  52 + *
  53 + * \return O status do do processo.
  54 + */
31 bool isFinished(); 55 bool isFinished();
32 56
33 private: 57 private:
@@ -48,14 +72,41 @@ private: @@ -48,14 +72,41 @@ private:
48 ServiceWindowGenerationFromSRT* service_srt; 72 ServiceWindowGenerationFromSRT* service_srt;
49 ServiceWindowGenerationFromText* service_text; 73 ServiceWindowGenerationFromText* service_text;
50 74
  75 + /** Checa o serviço de vídeo com legendas */
51 void checkServiceSRT(); 76 void checkServiceSRT();
  77 +
  78 + /** Checa o serviço de reconhecimento de vídeo */
52 void checkServiceRec(); 79 void checkServiceRec();
  80 +
  81 + /** Checa o serviço de tradução de texto */
53 void checkServiceText(); 82 void checkServiceText();
54 83
  84 + /** Este método é chamado quando a Thread for iniciada. */
55 void Run(); 85 void Run();
  86 +
  87 + /** Indica se houve falha em algum processo.
  88 + *
  89 + * \return retorna True se ocorreu algum erro, caso contrário, retorna false.
  90 + */
56 bool hasFailed(); 91 bool hasFailed();
  92 +
  93 + /** Remove os arquivos temporários, gerados pelos processos.*/
57 void deleteFiles(); 94 void deleteFiles();
  95 +
  96 + /** Define o path dos arquivos temporários. */
58 void setPathContents(); 97 void setPathContents();
  98 +
  99 + /** Verifica os arquivos de saída gerados.
  100 + *
  101 + * Caso os arquivos de sáida esperarados não existam,
  102 + * um status de falha será retornado.
  103 + * Nos casos em que houver mixagem, o vídeo de entrada
  104 + * e o vídeo de saída serão comparados pelo tamanho.
  105 + *
  106 + * \param fileIn arquivo de entrada.
  107 + * \param fileOut arquivo de saída.
  108 + * \return Status da verificação.
  109 + */
59 bool checkFiles(string fileIn, string fileOut); 110 bool checkFiles(string fileIn, string fileOut);
60 }; 111 };
61 112
servico/src/include/serviceWindowGeneration.h
  1 +/**
  2 + * \file serviceWindowGeneration.h
  3 + */
  4 +
1 #ifndef SERVICEWINDOWGENERATION_H 5 #ifndef SERVICEWINDOWGENERATION_H
2 #define SERVICEWINDOWGENERATION_H 6 #define SERVICEWINDOWGENERATION_H
3 7
@@ -36,6 +40,10 @@ using namespace std; @@ -36,6 +40,10 @@ using namespace std;
36 using namespace lavidlib; 40 using namespace lavidlib;
37 using namespace util; 41 using namespace util;
38 42
  43 +/** \brief A classe base para todos os serviços.
  44 + *
  45 + * \headerfile servico/src/include/serviceWindowGeneration.h
  46 + */
39 class ServiceWindowGeneration { 47 class ServiceWindowGeneration {
40 48
41 protected: 49 protected:
@@ -67,13 +75,32 @@ protected: @@ -67,13 +75,32 @@ protected:
67 int numero_legendas; 75 int numero_legendas;
68 int legendas_enviadas; 76 int legendas_enviadas;
69 77
  78 + /** Seta o número de legendas.
  79 + *
  80 + * \param sub_size A quantidade de legendas.
  81 + */
70 virtual void setSizeOfSubtitles(int sub_size) = 0; 82 virtual void setSizeOfSubtitles(int sub_size) = 0;
  83 +
  84 + /** Define o path dos arquivos de saída. */
71 virtual void setPathContents() = 0; 85 virtual void setPathContents() = 0;
72 86
73 public: 87 public:
  88 + /** Define o path do vídeo de LIBRAS. */
74 virtual void setPathLibras() = 0; 89 virtual void setPathLibras() = 0;
  90 +
  91 + /** Inicializa o serviço. */
75 virtual void initialize() = 0; 92 virtual void initialize() = 0;
  93 +
  94 + /** Indica o fim do processo do serviço.
  95 + *
  96 + * \return O status do processo.
  97 + */
76 virtual bool isFinished() = 0; 98 virtual bool isFinished() = 0;
  99 +
  100 + /** Envia para a tradução a sentença obtida.
  101 + *
  102 + * \param text A sentença obtida.
  103 + */
77 virtual void notifyTranslator(unsigned char* text) = 0; 104 virtual void notifyTranslator(unsigned char* text) = 0;
78 }; 105 };
79 106
servico/src/include/serviceWindowGenerationFromRec.h
  1 +/**
  2 + * \file serviceWindowGenerationFromRec.h
  3 + */
  4 +
1 #ifndef SERVICEWINDOWGENERATIONFROMREC_H 5 #ifndef SERVICEWINDOWGENERATIONFROMREC_H
2 #define SERVICEWINDOWGENERATIONFROMREC_H 6 #define SERVICEWINDOWGENERATIONFROMREC_H
3 7
@@ -9,31 +13,117 @@ @@ -9,31 +13,117 @@
9 #define SERVICE_TYPE_REC_ONLY_AUDIO 5 13 #define SERVICE_TYPE_REC_ONLY_AUDIO 5
10 #define SERVICE_TYPE_REC_UNMIXED 6 14 #define SERVICE_TYPE_REC_UNMIXED 6
11 15
  16 +/** \brief Classe que implementa o serviço de Reconhecimento.
  17 + *
  18 + * \headerfile servico/src/include/serviceWindowGenerationFromRec.h
  19 + */
12 class ServiceWindowGenerationFromRec : public ServiceWindowGeneration, public RecognizeListener, public ListenerTradutor, public ListenerRenderer, public Thread { 20 class ServiceWindowGenerationFromRec : public ServiceWindowGeneration, public RecognizeListener, public ListenerTradutor, public ListenerRenderer, public Thread {
13 21
14 private: 22 private:
15 Recognize* rec; 23 Recognize* rec;
16 24
  25 + /** Adiciona a etiqueta de tempo.
  26 + *
  27 + * Cada sentença conterá sua respectiva de tempo.
  28 + * \param pts A etiqueta de tempo.
  29 + */
17 void addPTS(int64_t pts); 30 void addPTS(int64_t pts);
  31 +
  32 + /** Seta o número de legendas.
  33 + *
  34 + * \param A quantidade de legendas.
  35 + * \exception ServiceException Se houver algum erro durante a execução.
  36 + */
18 void setSizeOfSubtitles(int sub_size); 37 void setSizeOfSubtitles(int sub_size);
  38 +
  39 + /** Define o path do vídeo de LIBRAS. */
19 void setPathLibras(); 40 void setPathLibras();
  41 +
  42 + /** Define o path dos arquivos de saída.
  43 + *
  44 + * \exception RuntimeException Se houver algum erro durante a execução.
  45 + */
20 void setPathContents(); 46 void setPathContents();
  47 +
  48 + /** Indica se o serviço está sendo executado.
  49 + *
  50 + * \return O status do serviço.
  51 + */
21 bool isRunning(); 52 bool isRunning();
22 public: 53 public:
  54 +
  55 + /** Construtor.
  56 + *
  57 + * \param pathVideo Path do vídeo de entrada.
  58 + * \param position Posição do vídeo de LIBRAS em relação ao vídeo original.
  59 + * \param size Tamanho do vídeo de LIBRAS.
  60 + * \param transparency Transparência do plano de fundo do vídeo.
  61 + * \param id Identificação do cliente.
  62 + * \param client Modo de execução.
  63 + * \param serviceType Tipo do serviço.
  64 + * \param rate
  65 + */
23 ServiceWindowGenerationFromRec(char* pathVideo, int position, int size, 66 ServiceWindowGenerationFromRec(char* pathVideo, int position, int size,
24 int transparency, char* id, char* client, int serviceType, char* rate); 67 int transparency, char* id, char* client, int serviceType, char* rate);
  68 +
  69 + /** Construtor.
  70 + *
  71 + * \param pathVideo Path do vídeo de entrada.
  72 + * \param pos Posição do vídeo de LIBRAS em relação ao vídeo original.
  73 + * \param size Tamanho do vídeo de LIBRAS.
  74 + * \param transp Transparência do plano de fundo do vídeo.
  75 + * \param id Identificação do cliente.
  76 + * \param mode Modo de execução.
  77 + * \param serviceType Tipo do serviço.
  78 + */
25 ServiceWindowGenerationFromRec(char* pathVideo, int pos, int size, 79 ServiceWindowGenerationFromRec(char* pathVideo, int pos, int size,
26 int transp, char* id, int mode, int serviceType); 80 int transp, char* id, int mode, int serviceType);
  81 +
  82 + /** Destrutor */
27 ~ServiceWindowGenerationFromRec(); 83 ~ServiceWindowGenerationFromRec();
28 84
  85 + /** Notifica novas sentenças reconhecidas.
  86 + *
  87 + * \param text A sentença reconhecida.
  88 + * \param pts A etiqueta de tempo da sentença.
  89 + */
29 void notifyTextRecognized(unsigned char* text, int64_t pts); 90 void notifyTextRecognized(unsigned char* text, int64_t pts);
  91 +
  92 + /** Recebe a notificação do fim da renderização do vídeo */
30 void notifyEndOfRenderization(); 93 void notifyEndOfRenderization();
  94 +
  95 + /** Recebe a notificação do fim da tradução da sentença.
  96 + *
  97 + * \param glosa A sentença traduzida.
  98 + * \exception ServiceException Se houver algum erro durante a execução.
  99 + */
31 void notifyTranslation(char* glosa); 100 void notifyTranslation(char* glosa);
  101 +
  102 + /** Envia para a tradução a sentença obtida.
  103 + *
  104 + * \param text A sentença obtida.
  105 + */
32 void notifyTranslator(unsigned char* text); 106 void notifyTranslator(unsigned char* text);
  107 +
  108 + /** Notifica o fim do reconhecimento.
  109 + *
  110 + * \param sentences_size O número de sentenças reconhecidas.
  111 + */
33 void notifyEnd(int sentences_size); 112 void notifyEnd(int sentences_size);
34 113
  114 + /** Inicia o serviço de reconhecimento.
  115 + *
  116 + * \exception ServiceException Se houver algum erro durante a execução.
  117 + */
35 void initialize(); 118 void initialize();
  119 +
  120 + /** Indica o fim do processo do serviço.
  121 + *
  122 + * \return O status do processo.
  123 + */
36 bool isFinished(); 124 bool isFinished();
  125 +
  126 + /** Este método é chamado quando a Thread for iniciada. */
37 void Run(); 127 void Run();
38 }; 128 };
39 129
servico/src/include/serviceWindowGenerationFromSRT.h
  1 +/**
  2 + * \file serviceWindowGenerationFromSRT.h
  3 + */
  4 +
1 #ifndef SERVICEWINDOWGENERATIONFROMSRT_H 5 #ifndef SERVICEWINDOWGENERATIONFROMSRT_H
2 #define SERVICEWINDOWGENERATIONFROMSRT_H 6 #define SERVICEWINDOWGENERATIONFROMSRT_H
3 7
@@ -8,6 +12,10 @@ @@ -8,6 +12,10 @@
8 #define SERVICE_TYPE_SRT 1 12 #define SERVICE_TYPE_SRT 1
9 #define SERVICE_TYPE_SRT_ONLY 4 13 #define SERVICE_TYPE_SRT_ONLY 4
10 14
  15 +/** \brief Classe que implementa o serviço de extração de legendas.
  16 + *
  17 + * \headerfile servico/src/include/serviceWindowGenerationFromSRT.h
  18 + */
11 class ServiceWindowGenerationFromSRT : public ServiceWindowGeneration, public ListenerSRT, public ListenerTradutor, public ListenerRenderer, public Thread { 19 class ServiceWindowGenerationFromSRT : public ServiceWindowGeneration, public ListenerSRT, public ListenerTradutor, public ListenerRenderer, public Thread {
12 20
13 private: 21 private:
@@ -16,28 +24,112 @@ private: @@ -16,28 +24,112 @@ private:
16 24
17 char* path_srt; 25 char* path_srt;
18 26
  27 + /** Adiciona a etiqueta de tempo.
  28 + *
  29 + * Cada sentença conterá sua respectiva de tempo.
  30 + * \param pts A etiqueta de tempo.
  31 + */
19 void addPTS(int64_t pts); 32 void addPTS(int64_t pts);
  33 +
  34 + /** Seta o número de legendas.
  35 + *
  36 + * \param A quantidade de legendas.
  37 + * \exception ServiceException Se houver algum erro durante a execução.
  38 + */
20 void setSizeOfSubtitles(int sub_size); 39 void setSizeOfSubtitles(int sub_size);
  40 +
  41 + /** Define o path do vídeo de LIBRAS. */
21 void setPathLibras(); 42 void setPathLibras();
  43 +
  44 + /** Define o path dos arquivos de saída.
  45 + *
  46 + * \exception RuntimeException Se houver algum erro durante a execução.
  47 + */
22 void setPathContents(); 48 void setPathContents();
  49 +
  50 + /** Indica se o serviço está sendo executado.
  51 + *
  52 + * \return O status do serviço.
  53 + */
23 bool isRunning(); 54 bool isRunning();
24 public: 55 public:
25 - //construtor de serviço de video e legenda 56 + /** Construtor do serviço de vídeo com legendas.
  57 + *
  58 + * \param pathVideo Path do vídeo de entrada.
  59 + * \param pathSRT Path do arquivo de legendas.
  60 + * \param sublanguage Linguagem das legendas do arquivo.
  61 + * \param pos Posição do vídeo de LIBRAS em relação ao vídeo original.
  62 + * \param size Tamanho do vídeo de LIBRAS.
  63 + * \param transp Transparência do plano de fundo do vídeo.
  64 + * \param id Identificação do cliente.
  65 + * \param mode Modo de execução.
  66 + * \param serviceType Tipo do serviço.
  67 + */
26 ServiceWindowGenerationFromSRT(char* pathVideo, char* pathSRT, int sublanguage, int pos, 68 ServiceWindowGenerationFromSRT(char* pathVideo, char* pathSRT, int sublanguage, int pos,
27 int size, int transp, char* id, int mode, int serviceType); 69 int size, int transp, char* id, int mode, int serviceType);
28 - //construtor de serviço de somente legenda 70 +
  71 + /** Construtor do serviço de legendas.
  72 + *
  73 + * \param pathSRT Path do arquivo de legendas.
  74 + * \param sublanguage Linguagem das legendas do arquivo.
  75 + * \param transparency Transparência do plano de fundo do vídeo.
  76 + * \param id Identificação do cliente.
  77 + * \param mode Modo de execução.
  78 + * \param serviceType Tipo do serviço.
  79 + */
29 ServiceWindowGenerationFromSRT(char* pathSRT, int sublanguage, int transparency, char* id, int mode, int serviceType); 80 ServiceWindowGenerationFromSRT(char* pathSRT, int sublanguage, int transparency, char* id, int mode, int serviceType);
  81 +
  82 + /** Destrutor */
30 ~ServiceWindowGenerationFromSRT(); 83 ~ServiceWindowGenerationFromSRT();
31 84
  85 + /** Notifica novas legendas extraídas.
  86 + *
  87 + * \param subtitle A legenda extraída.
  88 + * \param pts A etiqueta de tempo da legenda.
  89 + */
32 void notifySubtitle(unsigned char* subtitle, int64_t pts); 90 void notifySubtitle(unsigned char* subtitle, int64_t pts);
  91 +
  92 + /** Recebe a notificação do fim da renderização do vídeo */
33 void notifyEndOfRenderization(); 93 void notifyEndOfRenderization();
  94 +
  95 + /** Recebe a notificação do fim da tradução da legenda.
  96 + *
  97 + * \param glosa A legenda traduzida.
  98 + */
34 void notifyTranslation(char* glosas); 99 void notifyTranslation(char* glosas);
  100 +
  101 + /** Envia para a tradução a legenda obtida.
  102 + *
  103 + * \param text A legenda obtida.
  104 + */
35 void notifyTranslator(unsigned char* text); 105 void notifyTranslator(unsigned char* text);
  106 +
  107 + /** Envia a glosa para o renderizador.
  108 + *
  109 + * \param glosa A glosa obtida.
  110 + * \exception ServiceException Se houver algum erro durante a execução.
  111 + */
36 void notifyRenderer(string glosa); 112 void notifyRenderer(string glosa);
  113 +
  114 + /** Notifica o fim da extração de legendas.
  115 + *
  116 + * \param sub_size O número de legendas extraídas.
  117 + */
37 void notifyEnd(int sub_size); 118 void notifyEnd(int sub_size);
38 119
  120 + /** Inicia o serviço de extração de legendas.
  121 + *
  122 + * \exception ServiceException Se houver algum erro durante a execução.
  123 + */
39 void initialize(); 124 void initialize();
  125 +
  126 + /** Indica o fim do processo do serviço.
  127 + *
  128 + * \return O status do processo.
  129 + */
40 bool isFinished(); 130 bool isFinished();
  131 +
  132 + /** Este método é chamado quando a Thread for iniciada. */
41 void Run(); 133 void Run();
42 }; 134 };
43 135
servico/src/include/serviceWindowGenerationFromText.h
  1 +/**
  2 + * \file serviceWindowGenerationFromTXT.h
  3 + */
  4 +
1 #ifndef SERVICEWINDOWGENERATIONFROMTEXT_H 5 #ifndef SERVICEWINDOWGENERATIONFROMTEXT_H
2 #define SERVICEWINDOWGENERATIONFROMTEXT_H 6 #define SERVICEWINDOWGENERATIONFROMTEXT_H
3 7
@@ -7,29 +11,98 @@ @@ -7,29 +11,98 @@
7 11
8 #define MAX_TEXT_SIZE 2048 //FIXME: está restrito a 2K bytes de texto 12 #define MAX_TEXT_SIZE 2048 //FIXME: está restrito a 2K bytes de texto
9 13
  14 +/** \brief Classe que implementa o serviço de extração de texto.
  15 + *
  16 + * \headerfile servico/src/include/serviceWindowGenerationFromTXT.h
  17 + */
10 class ServiceWindowGenerationFromText : public ServiceWindowGeneration, public ListenerTXT, public ListenerTradutor, public ListenerRenderer, public Thread { 18 class ServiceWindowGenerationFromText : public ServiceWindowGeneration, public ListenerTXT, public ListenerTradutor, public ListenerRenderer, public Thread {
11 19
12 private: 20 private:
13 ExtratorFactory* extrator_factory; 21 ExtratorFactory* extrator_factory;
14 ExtratorTXT* extratorTXT; 22 ExtratorTXT* extratorTXT;
15 23
  24 + /** Seta o número de linhas.
  25 + *
  26 + * \param A quantidade de linhas.
  27 + * \exception ServiceException Se houver algum erro durante a execução.
  28 + */
16 void setSizeOfSubtitles(int sub_size); 29 void setSizeOfSubtitles(int sub_size);
  30 +
  31 + /** Define o path do vídeo de LIBRAS. */
17 void setPathLibras(); 32 void setPathLibras();
  33 +
  34 + /** Define o path dos arquivos de saída.
  35 + *
  36 + * \exception RuntimeException Se houver algum erro durante a execução.
  37 + */
18 void setPathContents(); 38 void setPathContents();
  39 +
  40 + /** Indica se o serviço está sendo executado.
  41 + *
  42 + * \return O status do serviço.
  43 + */
19 bool isRunning(); 44 bool isRunning();
20 public: 45 public:
  46 + /** Construtor.
  47 + *
  48 + * \param pathFile Path do arquivo de texto de entrada.
  49 + * \param sublanguage Linguagem das legendas do arquivo.
  50 + * \param transparency Transparência do plano de fundo do vídeo.
  51 + * \param id Identificação do cliente.
  52 + * \param mode Modo de execução.
  53 + */
21 ServiceWindowGenerationFromText(char* pathFile, int sublanguage, int transparency, char* id, int mode); 54 ServiceWindowGenerationFromText(char* pathFile, int sublanguage, int transparency, char* id, int mode);
  55 +
  56 + /** Destrutor */
22 ~ServiceWindowGenerationFromText(); 57 ~ServiceWindowGenerationFromText();
23 58
  59 + /** Notifica novas linhas extraídas.
  60 + *
  61 + * \param line A linha extraída.
  62 + */
24 void notifyLine(unsigned char* line); 63 void notifyLine(unsigned char* line);
  64 +
  65 + /** Recebe a notificação do fim da renderização do vídeo */
25 void notifyEndOfRenderization(); 66 void notifyEndOfRenderization();
  67 +
  68 + /** Recebe a notificação do fim da tradução do texto.
  69 + *
  70 + * \param glosa O texto traduzido.
  71 + */
26 void notifyTranslation(char* glosa); 72 void notifyTranslation(char* glosa);
  73 +
  74 + /** Envia para a tradução a linha obtida.
  75 + *
  76 + * \param text A linha obtida.
  77 + */
27 void notifyTranslator(unsigned char* text); 78 void notifyTranslator(unsigned char* text);
  79 +
  80 + /** Envia a glosa para o renderizador.
  81 + *
  82 + * \param glosa A glosa obtida.
  83 + * \exception ServiceException Se houver algum erro durante a execução.
  84 + */
28 void notifyRenderer(string glosa); 85 void notifyRenderer(string glosa);
  86 +
  87 + /** Notifica o fim da extração do texto.
  88 + *
  89 + * \param line_size O número de linhas extraídas.
  90 + */
29 void notifyEnd(int line_size); 91 void notifyEnd(int line_size);
30 92
  93 + /** Inicia o serviço de extração de texto.
  94 + *
  95 + * \exception ServiceException Se houver algum erro durante a execução.
  96 + */
31 void initialize(); 97 void initialize();
  98 +
  99 + /** Indica o fim do processo do serviço.
  100 + *
  101 + * \return O status do processo.
  102 + */
32 bool isFinished(); 103 bool isFinished();
  104 +
  105 + /** Este método é chamado quando a Thread for iniciada. */
33 void Run(); 106 void Run();
34 }; 107 };
35 108