Commit 05be5b7a2f7e8f876adfb54de70b99c365382351

Authored by Erickson Silva
2 parents d7f0c9d9 e9b85bfd
Exists in master

Merge devel

Showing 68 changed files with 5786 additions and 2815 deletions   Show diff stats
1 #general 1 #general
2 -*.ts  
3 -*.flv  
4 -*.swp*  
5 -*.class  
6 -*.a  
7 -*.so  
8 *.o 2 *.o
9 -*.log  
10 -*.jar  
11 -*.pyc  
12 -*.srt  
13 vlibras_user 3 vlibras_user
14 -tamanho.txt  
15 -vlibras  
16 \ No newline at end of file 4 \ No newline at end of file
  5 +vlibras
  6 +doc
17 \ No newline at end of file 7 \ No newline at end of file
1 -  
2 -REVISION=`svn info |grep Rev | sed 2d | cut -d" " -f2`  
3 -  
4 -CC=g++  
5 -FLAGS=-g  
6 -  
7 -#LIBS= -L libs/jthread/lib -L libs/jcommon/lib -L libs/jsocket/lib -ljthread -lpthread -ljcommon -ljsocket  
8 -  
9 -LIBS= \ 1 +BIN = vlibras
  2 +
  3 +CC = g++
  4 +FLAGS = -g
  5 +
  6 +EXTRATORDIR = extrator/src/
  7 +MIXERDIR = mixer/src/
  8 +RECOGNIZEDIR = recognize/src/
  9 +RENDERDIR = renderer/src/
  10 +SERVICODIR = servico/src/
  11 +TRADUTORDIR = tradutor/src/
  12 +UTILDIR = util/src/
  13 +
  14 +INCLUDES = \
  15 + -I $(EXTRATORDIR)include \
  16 + -I $(MIXERDIR)include \
  17 + -I $(RECOGNIZEDIR)include \
  18 + -I $(RENDERDIR)include \
  19 + -I $(SERVICODIR)include \
  20 + -I $(TRADUTORDIR)include \
  21 + -I $(UTILDIR)include \
  22 + -I /usr/include/python2.7 \
  23 + -I /usr/include/julius \
  24 + -I /usr/include/sent
  25 +
  26 +CFLAGS = \
10 `pkg-config --cflags jlibcpp` \ 27 `pkg-config --cflags jlibcpp` \
11 - `pkg-config --libs jlibcpp` \  
12 `pkg-config --cflags jsoncpp` \ 28 `pkg-config --cflags jsoncpp` \
  29 + $(INCLUDES)
  30 +
  31 +LDFLAGS = \
  32 + `pkg-config --libs jlibcpp` \
13 `pkg-config --libs jsoncpp` \ 33 `pkg-config --libs jsoncpp` \
14 - -lpython2.7 -llavid_base -llavid_io  
15 -  
16 -INCLUDES= \  
17 - -I /usr/include/python2.7 \  
18 - -I util/src/include \  
19 - -I tradutor/src/include \  
20 - -I extrator/src/include \  
21 - -I input/src/include \  
22 - -I servico/src/include \  
23 - -I synchronizer/src/include \  
24 - -I mixer/src/include \  
25 - -I recognize/src/include  
26 -#-I libs/jthread/include -I libs/jcommon/include -I libs/jsocket/include -Wall  
27 -  
28 -utilObjs= \  
29 - logger.o  
30 -  
31 -tradutorObjs = \  
32 - pyTradutor.o \  
33 - tradutorPortGlosa.o  
34 -  
35 -extratorObjs= \  
36 - extratorFactory.o \  
37 - extratorSRT.o \  
38 - extratorTXT.o \  
39 - subtitle.o \  
40 - extratorException.o  
41 -  
42 -inputObjs= \  
43 - inputFile.o \  
44 - inputException.o  
45 -  
46 -servicoObjs= \  
47 - serviceWindowGenerationFromSRT.o \  
48 - serviceWindowGenerationFromRec.o \  
49 - serviceWindowGenerationFromText.o \  
50 - serviceException.o  
51 -  
52 -synchronizerObjs= \  
53 - synchronizer.o  
54 -  
55 -mixerObjs= \  
56 - Mixer.o  
57 -  
58 -recognizeObjs = \  
59 - recognize.o \  
60 - recognizeException.o  
61 -  
62 -utilObjsPre = $(addprefix util/src/,$(utilObjs) )  
63 -tradutorObjsPre = $(addprefix tradutor/src/,$(tradutorObjs) )  
64 -inputObjsPre = $(addprefix input/src/,$(inputObjs) )  
65 -servicoObjsPre = $(addprefix servico/src/,$(servicoObjs) )  
66 -synchronizerObjsPre = $(addprefix synchronizer/src/,$(synchronizerObjs) )  
67 -mixerObjsPre = $(addprefix mixer/src/,$(mixerObjs) )  
68 -extratorObjsPre = $(addprefix extrator/src/,$(extratorObjs) )  
69 -recognizeObjsPre = $(addprefix recognize/src/,$(recognizeObjs) )  
70 -extratorTXTObjsPre = $(addprefix extratorTXT/src/,$(extratorTXTObjs) ) 34 + -lpython2.7 -llavid_base -llavid_io -llavid_net -ljulius -ldl -lsent
  35 +
  36 +extratorOBJS = \
  37 + extratorException.o \
  38 + extratorFactory.o \
  39 + extratorSRT.o \
  40 + extratorTXT.o \
  41 + extratorVTT.o \
  42 + subtitle.o
  43 +
  44 +mixerOBJS = \
  45 + mixer.o
  46 +
  47 +recognizeOBJS = \
  48 + audiofile.o \
  49 + recognize.o \
  50 + recognizeException.o \
  51 + recognizer.o \
  52 + wavcut.o
  53 +
  54 +rendererOBJS = \
  55 + renderer.o
  56 +
  57 +servicoOBJS = \
  58 + serviceException.o \
  59 + serviceTester.o \
  60 + serviceWindowGenerationFromRec.o \
  61 + serviceWindowGenerationFromSubtitle.o \
  62 + serviceWindowGenerationFromText.o
  63 +
  64 +tradutorOBJS = \
  65 + pyTradutor.o \
  66 + tradutorPortGlosa.o
  67 +
  68 +utilOBJS = \
  69 + argParser.o \
  70 + logging.o
  71 +
  72 +extratorOBJSPre = $(addprefix $(EXTRATORDIR),$(extratorOBJS) )
  73 +mixerOBJSPre = $(addprefix $(MIXERDIR),$(mixerOBJS) )
  74 +recognizeOBJSPre = $(addprefix $(RECOGNIZEDIR),$(recognizeOBJS) )
  75 +rendererOBJSPre = $(addprefix $(RENDERDIR),$(rendererOBJS) )
  76 +servicoOBJSPre = $(addprefix $(SERVICODIR),$(servicoOBJS) )
  77 +tradutorOBJSPre = $(addprefix $(TRADUTORDIR),$(tradutorOBJS) )
  78 +utilOBJSPre = $(addprefix $(UTILDIR),$(utilOBJS) )
71 79
72 OBJECTS = \ 80 OBJECTS = \
73 - $(utilObjsPre) \  
74 - $(tradutorObjsPre) \  
75 - $(extratorObjsPre) \  
76 - $(inputObjsPre) \  
77 - $(servicoObjsPre) \  
78 - $(synchronizerObjsPre) \  
79 - $(mixerObjsPre) \  
80 - $(recognizeObjsPre) \  
81 - main.o  
82 -  
83 -all: user_config libras  
84 - 81 + $(extratorOBJSPre) \
  82 + $(mixerOBJSPre) \
  83 + $(recognizeOBJSPre) \
  84 + $(rendererOBJSPre) \
  85 + $(servicoOBJSPre) \
  86 + $(tradutorOBJSPre) \
  87 + $(utilOBJSPre) \
  88 + main.o
  89 +
  90 +all: user_config compile
  91 +
85 user_config: 92 user_config:
86 @if [ ! -e "vlibras_user" ];then \ 93 @if [ ! -e "vlibras_user" ];then \
87 echo -n "Criando um link simbólico para este diretório...\n"; \ 94 echo -n "Criando um link simbólico para este diretório...\n"; \
88 sudo chmod +x link_config.sh; \ 95 sudo chmod +x link_config.sh; \
89 sh link_config.sh; \ 96 sh link_config.sh; \
90 fi 97 fi
91 -  
92 -libras: $(OBJECTS)  
93 - $(CC) -o vlibras $(OBJECTS) $(LIBS) $(INCLUDES) $(FLAGS)  
94 98
95 -  
96 -.c.o: $<  
97 - $(CC) -DDEBUG_LEVEL=15 -c $< -o $@ $(LIBS) $(INCLUDES) $(FLAGS) 99 +compile: $(OBJECTS)
  100 + $(CC) $(CFLAGS) -o $(BIN) $(OBJECTS) $(LDFLAGS) $(FLAGS) -lz
98 101
99 .cpp.o: $< 102 .cpp.o: $<
100 - $(CC) -DDEBUG_LEVEL=15 -c $< -o $@ $(LIBS) $(INCLUDES) $(FLAGS) 103 + $(CC) -DDEBUG_LEVEL=15 -c $< -o $@ $(LDFLAGS) $(CFLAGS) $(FLAGS)
101 104
102 clean: 105 clean:
103 @find -iname "*.o" -exec rm {} \; 106 @find -iname "*.o" -exec rm {} \;
104 - @find -iname ".*.o" -exec rm {} \;  
105 - @find -iname "*.so" -exec rm {} \;  
106 - @find -iname "*~" -exec rm {} \;  
107 - @find -iname "*.swp" -exec rm {} \;  
108 @find -iname "vlibras" -exec rm {} \; 107 @find -iname "vlibras" -exec rm {} \;
109 - @find -iname "*.class" -exec rm {} \;  
110 - @find -iname "*.pyc" -exec rm {} \;  
111 @if [ -e "vlibras_user" ];then \ 108 @if [ -e "vlibras_user" ];then \
112 echo -n "Removendo o link simbólico deste usuário...\n"; \ 109 echo -n "Removendo o link simbólico deste usuário...\n"; \
113 rm vlibras_user; \ 110 rm vlibras_user; \
114 fi 111 fi
  112 + @if [ -e "doc" ];then \
  113 + echo -n "Removendo documentação...\n"; \
  114 + rm -r doc; \
  115 + fi
115 116
116 -del:  
117 - @find -iname "*.java" -exec rm {} \;  
118 - @find -iname "*.c" -exec rm {} \;  
119 - @find -iname "*.cpp" -exec rm {} \;  
120 - @find -iname "*.h" -exec rm {} \;  
121 - @find -iname "*.class" -exec rm {} \;  
122 - @find -iname "*.form" -exec rm {} \;  
123 - @find -iname "*.o" -exec rm {} \;  
124 - @find -iname ".*.o" -exec rm {} \;  
125 - @find -iname "*~" -exec rm {} \;  
126 - @find -iname "*.log" -exec rm {} \;  
127 - @find -iname "*.swp" -exec rm {} \;  
128 - @find -iname "*.tmp" -exec rm {} \;  
129 - @find -iname "*.svn-base" -exec rm -r {} \;  
130 - @find -iname "*.svn" -exec rm -r {} \;  
131 - @find -iname "Makefile" -exec rm {} \;  
132 -  
133 -svn:  
134 - @find -iname "*.log" -exec rm {} \;  
135 - @find -iname "*.swp" -exec rm {} \;  
136 - @find -iname "*.tmp" -exec rm {} \;  
137 - @find -iname "*.svn-base" -exec rm -r {} \;  
138 - @find -iname "*.svn" -exec rm -r {} ;\ 117 +doc:
  118 + @echo -n "Gerando Documentação...\n"; \
  119 + doxygen doc_config
core_install.sh
1 #!/bin/bash 1 #!/bin/bash
2 2
3 -echo -e "\n## Iniciando a instalação do vlibras-core ##\n" 3 +echo -e "\n\033[32m##### Iniciando a instalação VLibras-Core #####\033[0m\n"
4 4
5 DIR=$HOME/vlibras-libs 5 DIR=$HOME/vlibras-libs
6 6
@@ -11,38 +11,45 @@ fi @@ -11,38 +11,45 @@ fi
11 #garanto que não tem nenhuma versão prévia instalada 11 #garanto que não tem nenhuma versão prévia instalada
12 sudo apt-get remove -y ffmpeg x264 libx264-dev yasm 12 sudo apt-get remove -y ffmpeg x264 libx264-dev yasm
13 13
14 -echo -e "\n## Fazendo download das dependências...\n" 14 +echo -e "\n\033[32m##### Fazendo download das dependências #####\033[0m\n"
15 15
16 sudo apt-get update 16 sudo apt-get update
17 sudo apt-get install -y aptitude 17 sudo apt-get install -y aptitude
18 -sudo aptitude install -y build-essential cmake libvpx-dev sox libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev automake autoconf libmad0-dev libgpm-dev libavcodec-dev libavformat-dev libdirectfb-extra libtool libavcodec-extra-52 libavformat-extra-52 libdirectfb-bin libdirectfb-dev libgtk+2.0-directfb0 libgtk+2.0-directfb-dev 18 +sudo aptitude install -y build-essential git cmake recode python-pip libssl-dev python-dev xvfb xserver-xephyr libjsoncpp-dev libvpx-dev sox curl libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev automake autoconf libmad0-dev libgpm-dev libavcodec-dev libavformat-dev libdirectfb-extra libtool libavcodec-extra-52 libavformat-extra-52 libdirectfb-bin libdirectfb-dev libgtk+2.0-directfb0 libgtk+2.0-directfb-dev
  19 +sudo pip install pyvirtualdisplay
19 20
20 cd ~/vlibras-libs 21 cd ~/vlibras-libs
21 22
  23 +wget http://150.165.204.30:8080/core/linux/unityVideo.tar.gz
22 wget http://150.165.204.30:8080/core/linux/yasm-1.2.0.tar.gz 24 wget http://150.165.204.30:8080/core/linux/yasm-1.2.0.tar.gz
23 wget http://150.165.204.30:8080/core/linux/jlibcpp-1.5.0.tar.gz 25 wget http://150.165.204.30:8080/core/linux/jlibcpp-1.5.0.tar.gz
24 wget http://150.165.204.30:8080/core/linux/julius-4.3.1.tar.gz 26 wget http://150.165.204.30:8080/core/linux/julius-4.3.1.tar.gz
25 wget http://150.165.204.30:8080/core/linux/lavid-lib.tar.gz 27 wget http://150.165.204.30:8080/core/linux/lavid-lib.tar.gz
26 wget http://150.165.204.30:8080/core/linux/ffmpeg-vlibras.tar.gz 28 wget http://150.165.204.30:8080/core/linux/ffmpeg-vlibras.tar.gz
27 29
28 -echo -e "\n## Extraindo...\n" 30 +echo -e "\n\033[32m##### Extraindo #####\033[0m\n"
29 31
  32 +tar -xf unityVideo.tar.gz -C $HOME
30 tar -xf ffmpeg-vlibras.tar.gz 33 tar -xf ffmpeg-vlibras.tar.gz
31 tar -xf yasm-1.2.0.tar.gz 34 tar -xf yasm-1.2.0.tar.gz
32 tar -xf jlibcpp-1.5.0.tar.gz 35 tar -xf jlibcpp-1.5.0.tar.gz
33 tar -xf julius-4.3.1.tar.gz 36 tar -xf julius-4.3.1.tar.gz
34 tar -xf lavid-lib.tar.gz 37 tar -xf lavid-lib.tar.gz
35 38
36 -echo -e "\n## Instalando dependências...\n" 39 +echo -e "\n\033[32m##### Baixando sinais #####\033[0m\n"
37 40
38 -echo -e "\n## Instalando Yasm...\n" 41 +cd ~/vlibras-core
  42 +./dict_update.sh
  43 +
  44 +echo -e "\n\033[32m##### Instalando Yasm #####\033[0m\n"
  45 +cd ~/vlibras-libs
39 cd yasm-1.2.0 46 cd yasm-1.2.0
40 chmod +x configure 47 chmod +x configure
41 ./configure 48 ./configure
42 make 49 make
43 sudo make install 50 sudo make install
44 51
45 -echo -e "\n## Instalando x264...\n" 52 +echo -e "\n\033[32m##### Instalando x264 #####\033[0m\n"
46 cd .. 53 cd ..
47 git clone --depth 1 git://git.videolan.org/x264 54 git clone --depth 1 git://git.videolan.org/x264
48 cd x264 55 cd x264
@@ -52,7 +59,7 @@ make @@ -52,7 +59,7 @@ make
52 sudo make install 59 sudo make install
53 sudo ldconfig 60 sudo ldconfig
54 61
55 -echo -e "\n## Instalando FFmpeg...\n" 62 +echo -e "\n\033[32m##### Instalando FFMPEG #####\033[0m\n"
56 cd .. 63 cd ..
57 cd ffmpeg 64 cd ffmpeg
58 chmod +x configure 65 chmod +x configure
@@ -61,30 +68,21 @@ make @@ -61,30 +68,21 @@ make
61 sudo make install 68 sudo make install
62 hash x264 ffmpeg ffprobe 69 hash x264 ffmpeg ffprobe
63 70
64 -echo -e "\n## Instalando jlibcpp...\n" 71 +echo -e "\n\033[32m##### Instalando jlibcpp #####\033[0m\n"
65 cd .. 72 cd ..
66 cd jlibcpp 73 cd jlibcpp
67 make ENABLE_DIRECTFB=no 74 make ENABLE_DIRECTFB=no
68 sudo make install 75 sudo make install
69 sudo ldconfig 76 sudo ldconfig
70 77
71 -echo -e "\n## Instalando JsonCpp...\n"  
72 -cd ..  
73 -git clone https://github.com/open-source-parsers/jsoncpp.git  
74 -cd jsoncpp  
75 -python amalgamate.py  
76 -./travis.sh  
77 -make  
78 -sudo make install  
79 -  
80 -echo -e "\n## Instalando Julius...\n" 78 +echo -e "\n\033[32m##### Instalando Julius #####\033[0m\n"
81 cd .. 79 cd ..
82 cd julius-4.3.1 80 cd julius-4.3.1
83 ./configure 81 ./configure
84 make 82 make
85 sudo make install 83 sudo make install
86 84
87 -echo -e "\n## Instalando Lavidlib...\n" 85 +echo -e "\n\033[32m##### Instalando Lavidlib #####\033[0m\n"
88 cd .. 86 cd ..
89 cd lavid-lib 87 cd lavid-lib
90 make 88 make
@@ -92,4 +90,4 @@ sudo make install @@ -92,4 +90,4 @@ sudo make install
92 90
93 cd .. 91 cd ..
94 rm ffmpeg-vlibras.tar.gz yasm-1.2.0.tar.gz jlibcpp-1.5.0.tar.gz julius-4.3.1.tar.gz lavid-lib.tar.gz 92 rm ffmpeg-vlibras.tar.gz yasm-1.2.0.tar.gz jlibcpp-1.5.0.tar.gz julius-4.3.1.tar.gz lavid-lib.tar.gz
95 -echo -e "\n## Instalação finalizada! ##\n"  
96 \ No newline at end of file 93 \ No newline at end of file
  94 +echo -e "\n\033[32m##### Instalação Finalizada! #####\033[0m\n"
dict_update.sh 0 → 100755
@@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
  1 +#!/bin/bash
  2 +
  3 +echo -e "\n\033[32m##### Atualizando dicionário #####\033[0m\n"
  4 +
  5 +NOT_INSTALLED=false
  6 +DIR=/opt/vlibras_desktop/vlibras_player_Data/Bundles
  7 +PLAYER_DATA="$HOME/unityVideo/videoCreator_Data"
  8 +BUNDLES="$PLAYER_DATA/Bundles"
  9 +
  10 +function check_update_patches()
  11 +{
  12 + count=0
  13 + for d in "$DIR/*" ; do
  14 + count=$((count+1))
  15 + apt-get install --only-upgrade --force-yes --yes patch${count}.0.0 > /dev/null 2>&1
  16 + done
  17 +}
  18 +
  19 +if [ ! -f /etc/apt/sources.list.d/dicionario-vlibras.list ]; then
  20 + # Add repository to update the dictionary
  21 + echo 'deb http://150.165.204.46:8080 precise main' | sudo tee /etc/apt/sources.list.d/dicionario-vlibras.list > /dev/null 2>&1
  22 +fi
  23 +
  24 +PKG_DICT=$(dpkg-query -W --showformat='${Status}\n' dicionario-vlibras:i386|grep "install ok installed")
  25 +if [ "" == "$PKG_DICT" ]; then
  26 + NOT_INSTALLED=true
  27 + sudo apt-get install --force-yes --yes dicionario-vlibras:i386
  28 +else
  29 + sudo apt-get update
  30 + check_update_patches
  31 + sudo apt-get install --only-upgrade --force-yes --yes dicionario-vlibras:i386
  32 +fi
  33 +
  34 +#remove pasta bundles
  35 +if [ -d "$BUNDLES" ] ; then
  36 + rm -r $BUNDLES
  37 +fi
  38 +
  39 +#copia dicionário para pasta de bundles
  40 +cp -r $DIR $PLAYER_DATA
  41 +cd $BUNDLES
  42 +rm *.description
  43 +
  44 +#remove pacote
  45 +if [ "$NOT_INSTALLED" = true ] ; then
  46 + sudo apt-get autoremove -y dicionario-vlibras:i386
  47 +fi
0 \ No newline at end of file 48 \ No newline at end of file
doc_config 0 → 100644
@@ -0,0 +1,1781 @@ @@ -0,0 +1,1781 @@
  1 +# Doxyfile 1.7.6.1
  2 +
  3 +# This file describes the settings to be used by the documentation system
  4 +# doxygen (www.doxygen.org) for a project.
  5 +#
  6 +# All text after a hash (#) is considered a comment and will be ignored.
  7 +# The format is:
  8 +# TAG = value [value, ...]
  9 +# For lists items can also be appended using:
  10 +# TAG += value [value, ...]
  11 +# Values that contain spaces should be placed between quotes (" ").
  12 +
  13 +#---------------------------------------------------------------------------
  14 +# Project related configuration options
  15 +#---------------------------------------------------------------------------
  16 +
  17 +# This tag specifies the encoding used for all characters in the config file
  18 +# that follow. The default is UTF-8 which is also the encoding used for all
  19 +# text before the first occurrence of this tag. Doxygen uses libiconv (or the
  20 +# iconv built into libc) for the transcoding. See
  21 +# http://www.gnu.org/software/libiconv for the list of possible encodings.
  22 +
  23 +DOXYFILE_ENCODING = UTF-8
  24 +
  25 +# The PROJECT_NAME tag is a single word (or sequence of words) that should
  26 +# identify the project. Note that if you do not use Doxywizard you need
  27 +# to put quotes around the project name if it contains spaces.
  28 +
  29 +PROJECT_NAME = "VLibras Core"
  30 +
  31 +# The PROJECT_NUMBER tag can be used to enter a project or revision number.
  32 +# This could be handy for archiving the generated documentation or
  33 +# if some version control system is used.
  34 +
  35 +PROJECT_NUMBER =
  36 +
  37 +# Using the PROJECT_BRIEF tag one can provide an optional one line description
  38 +# for a project that appears at the top of each page and should give viewer
  39 +# a quick idea about the purpose of the project. Keep the description short.
  40 +
  41 +PROJECT_BRIEF = "Ferramenta para tradução de conteúdo digital para LIBRAS"
  42 +
  43 +# With the PROJECT_LOGO tag one can specify an logo or icon that is
  44 +# included in the documentation. The maximum height of the logo should not
  45 +# exceed 55 pixels and the maximum width should not exceed 200 pixels.
  46 +# Doxygen will copy the logo to the output directory.
  47 +
  48 +PROJECT_LOGO =
  49 +
  50 +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
  51 +# base path where the generated documentation will be put.
  52 +# If a relative path is entered, it will be relative to the location
  53 +# where doxygen was started. If left blank the current directory will be used.
  54 +
  55 +OUTPUT_DIRECTORY = doc/
  56 +
  57 +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
  58 +# 4096 sub-directories (in 2 levels) under the output directory of each output
  59 +# format and will distribute the generated files over these directories.
  60 +# Enabling this option can be useful when feeding doxygen a huge amount of
  61 +# source files, where putting all generated files in the same directory would
  62 +# otherwise cause performance problems for the file system.
  63 +
  64 +CREATE_SUBDIRS = NO
  65 +
  66 +# The OUTPUT_LANGUAGE tag is used to specify the language in which all
  67 +# documentation generated by doxygen is written. Doxygen will use this
  68 +# information to generate all constant output in the proper language.
  69 +# The default language is English, other supported languages are:
  70 +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
  71 +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
  72 +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
  73 +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
  74 +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,
  75 +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
  76 +
  77 +OUTPUT_LANGUAGE = Brazilian
  78 +
  79 +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
  80 +# include brief member descriptions after the members that are listed in
  81 +# the file and class documentation (similar to JavaDoc).
  82 +# Set to NO to disable this.
  83 +
  84 +BRIEF_MEMBER_DESC = YES
  85 +
  86 +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
  87 +# the brief description of a member or function before the detailed description.
  88 +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
  89 +# brief descriptions will be completely suppressed.
  90 +
  91 +REPEAT_BRIEF = YES
  92 +
  93 +# This tag implements a quasi-intelligent brief description abbreviator
  94 +# that is used to form the text in various listings. Each string
  95 +# in this list, if found as the leading text of the brief description, will be
  96 +# stripped from the text and the result after processing the whole list, is
  97 +# used as the annotated text. Otherwise, the brief description is used as-is.
  98 +# If left blank, the following values are used ("$name" is automatically
  99 +# replaced with the name of the entity): "The $name class" "The $name widget"
  100 +# "The $name file" "is" "provides" "specifies" "contains"
  101 +# "represents" "a" "an" "the"
  102 +
  103 +ABBREVIATE_BRIEF =
  104 +
  105 +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
  106 +# Doxygen will generate a detailed section even if there is only a brief
  107 +# description.
  108 +
  109 +ALWAYS_DETAILED_SEC = NO
  110 +
  111 +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
  112 +# inherited members of a class in the documentation of that class as if those
  113 +# members were ordinary class members. Constructors, destructors and assignment
  114 +# operators of the base classes will not be shown.
  115 +
  116 +INLINE_INHERITED_MEMB = NO
  117 +
  118 +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
  119 +# path before files name in the file list and in the header files. If set
  120 +# to NO the shortest path that makes the file name unique will be used.
  121 +
  122 +FULL_PATH_NAMES = YES
  123 +
  124 +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
  125 +# can be used to strip a user-defined part of the path. Stripping is
  126 +# only done if one of the specified strings matches the left-hand part of
  127 +# the path. The tag can be used to show relative paths in the file list.
  128 +# If left blank the directory from which doxygen is run is used as the
  129 +# path to strip.
  130 +
  131 +STRIP_FROM_PATH =
  132 +
  133 +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
  134 +# the path mentioned in the documentation of a class, which tells
  135 +# the reader which header file to include in order to use a class.
  136 +# If left blank only the name of the header file containing the class
  137 +# definition is used. Otherwise one should specify the include paths that
  138 +# are normally passed to the compiler using the -I flag.
  139 +
  140 +STRIP_FROM_INC_PATH =
  141 +
  142 +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
  143 +# (but less readable) file names. This can be useful if your file system
  144 +# doesn't support long names like on DOS, Mac, or CD-ROM.
  145 +
  146 +SHORT_NAMES = NO
  147 +
  148 +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
  149 +# will interpret the first line (until the first dot) of a JavaDoc-style
  150 +# comment as the brief description. If set to NO, the JavaDoc
  151 +# comments will behave just like regular Qt-style comments
  152 +# (thus requiring an explicit @brief command for a brief description.)
  153 +
  154 +JAVADOC_AUTOBRIEF = NO
  155 +
  156 +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
  157 +# interpret the first line (until the first dot) of a Qt-style
  158 +# comment as the brief description. If set to NO, the comments
  159 +# will behave just like regular Qt-style comments (thus requiring
  160 +# an explicit \brief command for a brief description.)
  161 +
  162 +QT_AUTOBRIEF = NO
  163 +
  164 +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
  165 +# treat a multi-line C++ special comment block (i.e. a block of //! or ///
  166 +# comments) as a brief description. This used to be the default behaviour.
  167 +# The new default is to treat a multi-line C++ comment block as a detailed
  168 +# description. Set this tag to YES if you prefer the old behaviour instead.
  169 +
  170 +MULTILINE_CPP_IS_BRIEF = NO
  171 +
  172 +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
  173 +# member inherits the documentation from any documented member that it
  174 +# re-implements.
  175 +
  176 +INHERIT_DOCS = YES
  177 +
  178 +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
  179 +# a new page for each member. If set to NO, the documentation of a member will
  180 +# be part of the file/class/namespace that contains it.
  181 +
  182 +SEPARATE_MEMBER_PAGES = NO
  183 +
  184 +# The TAB_SIZE tag can be used to set the number of spaces in a tab.
  185 +# Doxygen uses this value to replace tabs by spaces in code fragments.
  186 +
  187 +TAB_SIZE = 8
  188 +
  189 +# This tag can be used to specify a number of aliases that acts
  190 +# as commands in the documentation. An alias has the form "name=value".
  191 +# For example adding "sideeffect=\par Side Effects:\n" will allow you to
  192 +# put the command \sideeffect (or @sideeffect) in the documentation, which
  193 +# will result in a user-defined paragraph with heading "Side Effects:".
  194 +# You can put \n's in the value part of an alias to insert newlines.
  195 +
  196 +ALIASES =
  197 +
  198 +# This tag can be used to specify a number of word-keyword mappings (TCL only).
  199 +# A mapping has the form "name=value". For example adding
  200 +# "class=itcl::class" will allow you to use the command class in the
  201 +# itcl::class meaning.
  202 +
  203 +TCL_SUBST =
  204 +
  205 +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
  206 +# sources only. Doxygen will then generate output that is more tailored for C.
  207 +# For instance, some of the names that are used will be different. The list
  208 +# of all members will be omitted, etc.
  209 +
  210 +OPTIMIZE_OUTPUT_FOR_C = NO
  211 +
  212 +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
  213 +# sources only. Doxygen will then generate output that is more tailored for
  214 +# Java. For instance, namespaces will be presented as packages, qualified
  215 +# scopes will look different, etc.
  216 +
  217 +OPTIMIZE_OUTPUT_JAVA = NO
  218 +
  219 +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
  220 +# sources only. Doxygen will then generate output that is more tailored for
  221 +# Fortran.
  222 +
  223 +OPTIMIZE_FOR_FORTRAN = NO
  224 +
  225 +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
  226 +# sources. Doxygen will then generate output that is tailored for
  227 +# VHDL.
  228 +
  229 +OPTIMIZE_OUTPUT_VHDL = NO
  230 +
  231 +# Doxygen selects the parser to use depending on the extension of the files it
  232 +# parses. With this tag you can assign which parser to use for a given extension.
  233 +# Doxygen has a built-in mapping, but you can override or extend it using this
  234 +# tag. The format is ext=language, where ext is a file extension, and language
  235 +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C,
  236 +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make
  237 +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
  238 +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions
  239 +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
  240 +
  241 +EXTENSION_MAPPING =
  242 +
  243 +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
  244 +# to include (a tag file for) the STL sources as input, then you should
  245 +# set this tag to YES in order to let doxygen match functions declarations and
  246 +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
  247 +# func(std::string) {}). This also makes the inheritance and collaboration
  248 +# diagrams that involve STL classes more complete and accurate.
  249 +
  250 +BUILTIN_STL_SUPPORT = NO
  251 +
  252 +# If you use Microsoft's C++/CLI language, you should set this option to YES to
  253 +# enable parsing support.
  254 +
  255 +CPP_CLI_SUPPORT = NO
  256 +
  257 +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
  258 +# Doxygen will parse them like normal C++ but will assume all classes use public
  259 +# instead of private inheritance when no explicit protection keyword is present.
  260 +
  261 +SIP_SUPPORT = NO
  262 +
  263 +# For Microsoft's IDL there are propget and propput attributes to indicate getter
  264 +# and setter methods for a property. Setting this option to YES (the default)
  265 +# will make doxygen replace the get and set methods by a property in the
  266 +# documentation. This will only work if the methods are indeed getting or
  267 +# setting a simple type. If this is not the case, or you want to show the
  268 +# methods anyway, you should set this option to NO.
  269 +
  270 +IDL_PROPERTY_SUPPORT = YES
  271 +
  272 +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
  273 +# tag is set to YES, then doxygen will reuse the documentation of the first
  274 +# member in the group (if any) for the other members of the group. By default
  275 +# all members of a group must be documented explicitly.
  276 +
  277 +DISTRIBUTE_GROUP_DOC = NO
  278 +
  279 +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
  280 +# the same type (for instance a group of public functions) to be put as a
  281 +# subgroup of that type (e.g. under the Public Functions section). Set it to
  282 +# NO to prevent subgrouping. Alternatively, this can be done per class using
  283 +# the \nosubgrouping command.
  284 +
  285 +SUBGROUPING = YES
  286 +
  287 +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
  288 +# unions are shown inside the group in which they are included (e.g. using
  289 +# @ingroup) instead of on a separate page (for HTML and Man pages) or
  290 +# section (for LaTeX and RTF).
  291 +
  292 +INLINE_GROUPED_CLASSES = NO
  293 +
  294 +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and
  295 +# unions with only public data fields will be shown inline in the documentation
  296 +# of the scope in which they are defined (i.e. file, namespace, or group
  297 +# documentation), provided this scope is documented. If set to NO (the default),
  298 +# structs, classes, and unions are shown on a separate page (for HTML and Man
  299 +# pages) or section (for LaTeX and RTF).
  300 +
  301 +INLINE_SIMPLE_STRUCTS = NO
  302 +
  303 +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
  304 +# is documented as struct, union, or enum with the name of the typedef. So
  305 +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
  306 +# with name TypeT. When disabled the typedef will appear as a member of a file,
  307 +# namespace, or class. And the struct will be named TypeS. This can typically
  308 +# be useful for C code in case the coding convention dictates that all compound
  309 +# types are typedef'ed and only the typedef is referenced, never the tag name.
  310 +
  311 +TYPEDEF_HIDES_STRUCT = NO
  312 +
  313 +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
  314 +# determine which symbols to keep in memory and which to flush to disk.
  315 +# When the cache is full, less often used symbols will be written to disk.
  316 +# For small to medium size projects (<1000 input files) the default value is
  317 +# probably good enough. For larger projects a too small cache size can cause
  318 +# doxygen to be busy swapping symbols to and from disk most of the time
  319 +# causing a significant performance penalty.
  320 +# If the system has enough physical memory increasing the cache will improve the
  321 +# performance by keeping more symbols in memory. Note that the value works on
  322 +# a logarithmic scale so increasing the size by one will roughly double the
  323 +# memory usage. The cache size is given by this formula:
  324 +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
  325 +# corresponding to a cache size of 2^16 = 65536 symbols.
  326 +
  327 +SYMBOL_CACHE_SIZE = 0
  328 +
  329 +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be
  330 +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given
  331 +# their name and scope. Since this can be an expensive process and often the
  332 +# same symbol appear multiple times in the code, doxygen keeps a cache of
  333 +# pre-resolved symbols. If the cache is too small doxygen will become slower.
  334 +# If the cache is too large, memory is wasted. The cache size is given by this
  335 +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0,
  336 +# corresponding to a cache size of 2^16 = 65536 symbols.
  337 +
  338 +LOOKUP_CACHE_SIZE = 0
  339 +
  340 +#---------------------------------------------------------------------------
  341 +# Build related configuration options
  342 +#---------------------------------------------------------------------------
  343 +
  344 +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
  345 +# documentation are documented, even if no documentation was available.
  346 +# Private class members and static file members will be hidden unless
  347 +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
  348 +
  349 +EXTRACT_ALL = NO
  350 +
  351 +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
  352 +# will be included in the documentation.
  353 +
  354 +EXTRACT_PRIVATE = NO
  355 +
  356 +# If the EXTRACT_STATIC tag is set to YES all static members of a file
  357 +# will be included in the documentation.
  358 +
  359 +EXTRACT_STATIC = NO
  360 +
  361 +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
  362 +# defined locally in source files will be included in the documentation.
  363 +# If set to NO only classes defined in header files are included.
  364 +
  365 +EXTRACT_LOCAL_CLASSES = YES
  366 +
  367 +# This flag is only useful for Objective-C code. When set to YES local
  368 +# methods, which are defined in the implementation section but not in
  369 +# the interface are included in the documentation.
  370 +# If set to NO (the default) only methods in the interface are included.
  371 +
  372 +EXTRACT_LOCAL_METHODS = NO
  373 +
  374 +# If this flag is set to YES, the members of anonymous namespaces will be
  375 +# extracted and appear in the documentation as a namespace called
  376 +# 'anonymous_namespace{file}', where file will be replaced with the base
  377 +# name of the file that contains the anonymous namespace. By default
  378 +# anonymous namespaces are hidden.
  379 +
  380 +EXTRACT_ANON_NSPACES = NO
  381 +
  382 +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
  383 +# undocumented members of documented classes, files or namespaces.
  384 +# If set to NO (the default) these members will be included in the
  385 +# various overviews, but no documentation section is generated.
  386 +# This option has no effect if EXTRACT_ALL is enabled.
  387 +
  388 +HIDE_UNDOC_MEMBERS = NO
  389 +
  390 +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
  391 +# undocumented classes that are normally visible in the class hierarchy.
  392 +# If set to NO (the default) these classes will be included in the various
  393 +# overviews. This option has no effect if EXTRACT_ALL is enabled.
  394 +
  395 +HIDE_UNDOC_CLASSES = NO
  396 +
  397 +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
  398 +# friend (class|struct|union) declarations.
  399 +# If set to NO (the default) these declarations will be included in the
  400 +# documentation.
  401 +
  402 +HIDE_FRIEND_COMPOUNDS = NO
  403 +
  404 +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
  405 +# documentation blocks found inside the body of a function.
  406 +# If set to NO (the default) these blocks will be appended to the
  407 +# function's detailed documentation block.
  408 +
  409 +HIDE_IN_BODY_DOCS = NO
  410 +
  411 +# The INTERNAL_DOCS tag determines if documentation
  412 +# that is typed after a \internal command is included. If the tag is set
  413 +# to NO (the default) then the documentation will be excluded.
  414 +# Set it to YES to include the internal documentation.
  415 +
  416 +INTERNAL_DOCS = NO
  417 +
  418 +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
  419 +# file names in lower-case letters. If set to YES upper-case letters are also
  420 +# allowed. This is useful if you have classes or files whose names only differ
  421 +# in case and if your file system supports case sensitive file names. Windows
  422 +# and Mac users are advised to set this option to NO.
  423 +
  424 +CASE_SENSE_NAMES = YES
  425 +
  426 +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
  427 +# will show members with their full class and namespace scopes in the
  428 +# documentation. If set to YES the scope will be hidden.
  429 +
  430 +HIDE_SCOPE_NAMES = NO
  431 +
  432 +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
  433 +# will put a list of the files that are included by a file in the documentation
  434 +# of that file.
  435 +
  436 +SHOW_INCLUDE_FILES = YES
  437 +
  438 +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
  439 +# will list include files with double quotes in the documentation
  440 +# rather than with sharp brackets.
  441 +
  442 +FORCE_LOCAL_INCLUDES = NO
  443 +
  444 +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
  445 +# is inserted in the documentation for inline members.
  446 +
  447 +INLINE_INFO = YES
  448 +
  449 +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
  450 +# will sort the (detailed) documentation of file and class members
  451 +# alphabetically by member name. If set to NO the members will appear in
  452 +# declaration order.
  453 +
  454 +SORT_MEMBER_DOCS = YES
  455 +
  456 +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
  457 +# brief documentation of file, namespace and class members alphabetically
  458 +# by member name. If set to NO (the default) the members will appear in
  459 +# declaration order.
  460 +
  461 +SORT_BRIEF_DOCS = NO
  462 +
  463 +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
  464 +# will sort the (brief and detailed) documentation of class members so that
  465 +# constructors and destructors are listed first. If set to NO (the default)
  466 +# the constructors will appear in the respective orders defined by
  467 +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
  468 +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
  469 +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
  470 +
  471 +SORT_MEMBERS_CTORS_1ST = NO
  472 +
  473 +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
  474 +# hierarchy of group names into alphabetical order. If set to NO (the default)
  475 +# the group names will appear in their defined order.
  476 +
  477 +SORT_GROUP_NAMES = NO
  478 +
  479 +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
  480 +# sorted by fully-qualified names, including namespaces. If set to
  481 +# NO (the default), the class list will be sorted only by class name,
  482 +# not including the namespace part.
  483 +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
  484 +# Note: This option applies only to the class list, not to the
  485 +# alphabetical list.
  486 +
  487 +SORT_BY_SCOPE_NAME = NO
  488 +
  489 +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to
  490 +# do proper type resolution of all parameters of a function it will reject a
  491 +# match between the prototype and the implementation of a member function even
  492 +# if there is only one candidate or it is obvious which candidate to choose
  493 +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen
  494 +# will still accept a match between prototype and implementation in such cases.
  495 +
  496 +STRICT_PROTO_MATCHING = NO
  497 +
  498 +# The GENERATE_TODOLIST tag can be used to enable (YES) or
  499 +# disable (NO) the todo list. This list is created by putting \todo
  500 +# commands in the documentation.
  501 +
  502 +GENERATE_TODOLIST = YES
  503 +
  504 +# The GENERATE_TESTLIST tag can be used to enable (YES) or
  505 +# disable (NO) the test list. This list is created by putting \test
  506 +# commands in the documentation.
  507 +
  508 +GENERATE_TESTLIST = YES
  509 +
  510 +# The GENERATE_BUGLIST tag can be used to enable (YES) or
  511 +# disable (NO) the bug list. This list is created by putting \bug
  512 +# commands in the documentation.
  513 +
  514 +GENERATE_BUGLIST = YES
  515 +
  516 +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
  517 +# disable (NO) the deprecated list. This list is created by putting
  518 +# \deprecated commands in the documentation.
  519 +
  520 +GENERATE_DEPRECATEDLIST= YES
  521 +
  522 +# The ENABLED_SECTIONS tag can be used to enable conditional
  523 +# documentation sections, marked by \if sectionname ... \endif.
  524 +
  525 +ENABLED_SECTIONS =
  526 +
  527 +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
  528 +# the initial value of a variable or macro consists of for it to appear in
  529 +# the documentation. If the initializer consists of more lines than specified
  530 +# here it will be hidden. Use a value of 0 to hide initializers completely.
  531 +# The appearance of the initializer of individual variables and macros in the
  532 +# documentation can be controlled using \showinitializer or \hideinitializer
  533 +# command in the documentation regardless of this setting.
  534 +
  535 +MAX_INITIALIZER_LINES = 30
  536 +
  537 +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
  538 +# at the bottom of the documentation of classes and structs. If set to YES the
  539 +# list will mention the files that were used to generate the documentation.
  540 +
  541 +SHOW_USED_FILES = YES
  542 +
  543 +# If the sources in your project are distributed over multiple directories
  544 +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
  545 +# in the documentation. The default is NO.
  546 +
  547 +SHOW_DIRECTORIES = NO
  548 +
  549 +# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
  550 +# This will remove the Files entry from the Quick Index and from the
  551 +# Folder Tree View (if specified). The default is YES.
  552 +
  553 +SHOW_FILES = YES
  554 +
  555 +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
  556 +# Namespaces page.
  557 +# This will remove the Namespaces entry from the Quick Index
  558 +# and from the Folder Tree View (if specified). The default is YES.
  559 +
  560 +SHOW_NAMESPACES = YES
  561 +
  562 +# The FILE_VERSION_FILTER tag can be used to specify a program or script that
  563 +# doxygen should invoke to get the current version for each file (typically from
  564 +# the version control system). Doxygen will invoke the program by executing (via
  565 +# popen()) the command <command> <input-file>, where <command> is the value of
  566 +# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
  567 +# provided by doxygen. Whatever the program writes to standard output
  568 +# is used as the file version. See the manual for examples.
  569 +
  570 +FILE_VERSION_FILTER =
  571 +
  572 +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
  573 +# by doxygen. The layout file controls the global structure of the generated
  574 +# output files in an output format independent way. The create the layout file
  575 +# that represents doxygen's defaults, run doxygen with the -l option.
  576 +# You can optionally specify a file name after the option, if omitted
  577 +# DoxygenLayout.xml will be used as the name of the layout file.
  578 +
  579 +LAYOUT_FILE =
  580 +
  581 +# The CITE_BIB_FILES tag can be used to specify one or more bib files
  582 +# containing the references data. This must be a list of .bib files. The
  583 +# .bib extension is automatically appended if omitted. Using this command
  584 +# requires the bibtex tool to be installed. See also
  585 +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style
  586 +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this
  587 +# feature you need bibtex and perl available in the search path.
  588 +
  589 +CITE_BIB_FILES =
  590 +
  591 +#---------------------------------------------------------------------------
  592 +# configuration options related to warning and progress messages
  593 +#---------------------------------------------------------------------------
  594 +
  595 +# The QUIET tag can be used to turn on/off the messages that are generated
  596 +# by doxygen. Possible values are YES and NO. If left blank NO is used.
  597 +
  598 +QUIET = NO
  599 +
  600 +# The WARNINGS tag can be used to turn on/off the warning messages that are
  601 +# generated by doxygen. Possible values are YES and NO. If left blank
  602 +# NO is used.
  603 +
  604 +WARNINGS = YES
  605 +
  606 +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
  607 +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
  608 +# automatically be disabled.
  609 +
  610 +WARN_IF_UNDOCUMENTED = YES
  611 +
  612 +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
  613 +# potential errors in the documentation, such as not documenting some
  614 +# parameters in a documented function, or documenting parameters that
  615 +# don't exist or using markup commands wrongly.
  616 +
  617 +WARN_IF_DOC_ERROR = YES
  618 +
  619 +# The WARN_NO_PARAMDOC option can be enabled to get warnings for
  620 +# functions that are documented, but have no documentation for their parameters
  621 +# or return value. If set to NO (the default) doxygen will only warn about
  622 +# wrong or incomplete parameter documentation, but not about the absence of
  623 +# documentation.
  624 +
  625 +WARN_NO_PARAMDOC = NO
  626 +
  627 +# The WARN_FORMAT tag determines the format of the warning messages that
  628 +# doxygen can produce. The string should contain the $file, $line, and $text
  629 +# tags, which will be replaced by the file and line number from which the
  630 +# warning originated and the warning text. Optionally the format may contain
  631 +# $version, which will be replaced by the version of the file (if it could
  632 +# be obtained via FILE_VERSION_FILTER)
  633 +
  634 +WARN_FORMAT = "$file:$line: $text"
  635 +
  636 +# The WARN_LOGFILE tag can be used to specify a file to which warning
  637 +# and error messages should be written. If left blank the output is written
  638 +# to stderr.
  639 +
  640 +WARN_LOGFILE =
  641 +
  642 +#---------------------------------------------------------------------------
  643 +# configuration options related to the input files
  644 +#---------------------------------------------------------------------------
  645 +
  646 +# The INPUT tag can be used to specify the files and/or directories that contain
  647 +# documented source files. You may enter file names like "myfile.cpp" or
  648 +# directories like "/usr/src/myproject". Separate the files or directories
  649 +# with spaces.
  650 +
  651 +INPUT = extrator/src/include servico/src/include renderer/src/include mixer/src/include util/src/include tradutor/src/include
  652 +
  653 +# This tag can be used to specify the character encoding of the source files
  654 +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
  655 +# also the default input encoding. Doxygen uses libiconv (or the iconv built
  656 +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
  657 +# the list of possible encodings.
  658 +
  659 +INPUT_ENCODING = UTF-8
  660 +
  661 +# If the value of the INPUT tag contains directories, you can use the
  662 +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
  663 +# and *.h) to filter out the source-files in the directories. If left
  664 +# blank the following patterns are tested:
  665 +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh
  666 +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
  667 +# *.f90 *.f *.for *.vhd *.vhdl
  668 +
  669 +FILE_PATTERNS =
  670 +
  671 +# The RECURSIVE tag can be used to turn specify whether or not subdirectories
  672 +# should be searched for input files as well. Possible values are YES and NO.
  673 +# If left blank NO is used.
  674 +
  675 +RECURSIVE = NO
  676 +
  677 +# The EXCLUDE tag can be used to specify files and/or directories that should be
  678 +# excluded from the INPUT source files. This way you can easily exclude a
  679 +# subdirectory from a directory tree whose root is specified with the INPUT tag.
  680 +# Note that relative paths are relative to the directory from which doxygen is
  681 +# run.
  682 +
  683 +EXCLUDE =
  684 +
  685 +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
  686 +# directories that are symbolic links (a Unix file system feature) are excluded
  687 +# from the input.
  688 +
  689 +EXCLUDE_SYMLINKS = NO
  690 +
  691 +# If the value of the INPUT tag contains directories, you can use the
  692 +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
  693 +# certain files from those directories. Note that the wildcards are matched
  694 +# against the file with absolute path, so to exclude all test directories
  695 +# for example use the pattern */test/*
  696 +
  697 +EXCLUDE_PATTERNS =
  698 +
  699 +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
  700 +# (namespaces, classes, functions, etc.) that should be excluded from the
  701 +# output. The symbol name can be a fully qualified name, a word, or if the
  702 +# wildcard * is used, a substring. Examples: ANamespace, AClass,
  703 +# AClass::ANamespace, ANamespace::*Test
  704 +
  705 +EXCLUDE_SYMBOLS =
  706 +
  707 +# The EXAMPLE_PATH tag can be used to specify one or more files or
  708 +# directories that contain example code fragments that are included (see
  709 +# the \include command).
  710 +
  711 +EXAMPLE_PATH =
  712 +
  713 +# If the value of the EXAMPLE_PATH tag contains directories, you can use the
  714 +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
  715 +# and *.h) to filter out the source-files in the directories. If left
  716 +# blank all files are included.
  717 +
  718 +EXAMPLE_PATTERNS =
  719 +
  720 +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
  721 +# searched for input files to be used with the \include or \dontinclude
  722 +# commands irrespective of the value of the RECURSIVE tag.
  723 +# Possible values are YES and NO. If left blank NO is used.
  724 +
  725 +EXAMPLE_RECURSIVE = NO
  726 +
  727 +# The IMAGE_PATH tag can be used to specify one or more files or
  728 +# directories that contain image that are included in the documentation (see
  729 +# the \image command).
  730 +
  731 +IMAGE_PATH =
  732 +
  733 +# The INPUT_FILTER tag can be used to specify a program that doxygen should
  734 +# invoke to filter for each input file. Doxygen will invoke the filter program
  735 +# by executing (via popen()) the command <filter> <input-file>, where <filter>
  736 +# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
  737 +# input file. Doxygen will then use the output that the filter program writes
  738 +# to standard output.
  739 +# If FILTER_PATTERNS is specified, this tag will be
  740 +# ignored.
  741 +
  742 +INPUT_FILTER =
  743 +
  744 +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
  745 +# basis.
  746 +# Doxygen will compare the file name with each pattern and apply the
  747 +# filter if there is a match.
  748 +# The filters are a list of the form:
  749 +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
  750 +# info on how filters are used. If FILTER_PATTERNS is empty or if
  751 +# non of the patterns match the file name, INPUT_FILTER is applied.
  752 +
  753 +FILTER_PATTERNS =
  754 +
  755 +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
  756 +# INPUT_FILTER) will be used to filter the input files when producing source
  757 +# files to browse (i.e. when SOURCE_BROWSER is set to YES).
  758 +
  759 +FILTER_SOURCE_FILES = NO
  760 +
  761 +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
  762 +# pattern. A pattern will override the setting for FILTER_PATTERN (if any)
  763 +# and it is also possible to disable source filtering for a specific pattern
  764 +# using *.ext= (so without naming a filter). This option only has effect when
  765 +# FILTER_SOURCE_FILES is enabled.
  766 +
  767 +FILTER_SOURCE_PATTERNS =
  768 +
  769 +#---------------------------------------------------------------------------
  770 +# configuration options related to source browsing
  771 +#---------------------------------------------------------------------------
  772 +
  773 +# If the SOURCE_BROWSER tag is set to YES then a list of source files will
  774 +# be generated. Documented entities will be cross-referenced with these sources.
  775 +# Note: To get rid of all source code in the generated output, make sure also
  776 +# VERBATIM_HEADERS is set to NO.
  777 +
  778 +SOURCE_BROWSER = NO
  779 +
  780 +# Setting the INLINE_SOURCES tag to YES will include the body
  781 +# of functions and classes directly in the documentation.
  782 +
  783 +INLINE_SOURCES = NO
  784 +
  785 +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
  786 +# doxygen to hide any special comment blocks from generated source code
  787 +# fragments. Normal C and C++ comments will always remain visible.
  788 +
  789 +STRIP_CODE_COMMENTS = YES
  790 +
  791 +# If the REFERENCED_BY_RELATION tag is set to YES
  792 +# then for each documented function all documented
  793 +# functions referencing it will be listed.
  794 +
  795 +REFERENCED_BY_RELATION = NO
  796 +
  797 +# If the REFERENCES_RELATION tag is set to YES
  798 +# then for each documented function all documented entities
  799 +# called/used by that function will be listed.
  800 +
  801 +REFERENCES_RELATION = NO
  802 +
  803 +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
  804 +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
  805 +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
  806 +# link to the source code.
  807 +# Otherwise they will link to the documentation.
  808 +
  809 +REFERENCES_LINK_SOURCE = YES
  810 +
  811 +# If the USE_HTAGS tag is set to YES then the references to source code
  812 +# will point to the HTML generated by the htags(1) tool instead of doxygen
  813 +# built-in source browser. The htags tool is part of GNU's global source
  814 +# tagging system (see http://www.gnu.org/software/global/global.html). You
  815 +# will need version 4.8.6 or higher.
  816 +
  817 +USE_HTAGS = NO
  818 +
  819 +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
  820 +# will generate a verbatim copy of the header file for each class for
  821 +# which an include is specified. Set to NO to disable this.
  822 +
  823 +VERBATIM_HEADERS = YES
  824 +
  825 +#---------------------------------------------------------------------------
  826 +# configuration options related to the alphabetical class index
  827 +#---------------------------------------------------------------------------
  828 +
  829 +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
  830 +# of all compounds will be generated. Enable this if the project
  831 +# contains a lot of classes, structs, unions or interfaces.
  832 +
  833 +ALPHABETICAL_INDEX = YES
  834 +
  835 +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
  836 +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
  837 +# in which this list will be split (can be a number in the range [1..20])
  838 +
  839 +COLS_IN_ALPHA_INDEX = 5
  840 +
  841 +# In case all classes in a project start with a common prefix, all
  842 +# classes will be put under the same header in the alphabetical index.
  843 +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
  844 +# should be ignored while generating the index headers.
  845 +
  846 +IGNORE_PREFIX =
  847 +
  848 +#---------------------------------------------------------------------------
  849 +# configuration options related to the HTML output
  850 +#---------------------------------------------------------------------------
  851 +
  852 +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
  853 +# generate HTML output.
  854 +
  855 +GENERATE_HTML = YES
  856 +
  857 +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
  858 +# If a relative path is entered the value of OUTPUT_DIRECTORY will be
  859 +# put in front of it. If left blank `html' will be used as the default path.
  860 +
  861 +HTML_OUTPUT = html
  862 +
  863 +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
  864 +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
  865 +# doxygen will generate files with .html extension.
  866 +
  867 +HTML_FILE_EXTENSION = .html
  868 +
  869 +# The HTML_HEADER tag can be used to specify a personal HTML header for
  870 +# each generated HTML page. If it is left blank doxygen will generate a
  871 +# standard header. Note that when using a custom header you are responsible
  872 +# for the proper inclusion of any scripts and style sheets that doxygen
  873 +# needs, which is dependent on the configuration options used.
  874 +# It is advised to generate a default header using "doxygen -w html
  875 +# header.html footer.html stylesheet.css YourConfigFile" and then modify
  876 +# that header. Note that the header is subject to change so you typically
  877 +# have to redo this when upgrading to a newer version of doxygen or when
  878 +# changing the value of configuration settings such as GENERATE_TREEVIEW!
  879 +
  880 +HTML_HEADER =
  881 +
  882 +# The HTML_FOOTER tag can be used to specify a personal HTML footer for
  883 +# each generated HTML page. If it is left blank doxygen will generate a
  884 +# standard footer.
  885 +
  886 +HTML_FOOTER =
  887 +
  888 +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
  889 +# style sheet that is used by each HTML page. It can be used to
  890 +# fine-tune the look of the HTML output. If the tag is left blank doxygen
  891 +# will generate a default style sheet. Note that doxygen will try to copy
  892 +# the style sheet file to the HTML output directory, so don't put your own
  893 +# style sheet in the HTML output directory as well, or it will be erased!
  894 +
  895 +HTML_STYLESHEET =
  896 +
  897 +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
  898 +# other source files which should be copied to the HTML output directory. Note
  899 +# that these files will be copied to the base HTML output directory. Use the
  900 +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
  901 +# files. In the HTML_STYLESHEET file, use the file name only. Also note that
  902 +# the files will be copied as-is; there are no commands or markers available.
  903 +
  904 +HTML_EXTRA_FILES =
  905 +
  906 +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
  907 +# Doxygen will adjust the colors in the style sheet and background images
  908 +# according to this color. Hue is specified as an angle on a colorwheel,
  909 +# see http://en.wikipedia.org/wiki/Hue for more information.
  910 +# For instance the value 0 represents red, 60 is yellow, 120 is green,
  911 +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
  912 +# The allowed range is 0 to 359.
  913 +
  914 +HTML_COLORSTYLE_HUE = 220
  915 +
  916 +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
  917 +# the colors in the HTML output. For a value of 0 the output will use
  918 +# grayscales only. A value of 255 will produce the most vivid colors.
  919 +
  920 +HTML_COLORSTYLE_SAT = 100
  921 +
  922 +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
  923 +# the luminance component of the colors in the HTML output. Values below
  924 +# 100 gradually make the output lighter, whereas values above 100 make
  925 +# the output darker. The value divided by 100 is the actual gamma applied,
  926 +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
  927 +# and 100 does not change the gamma.
  928 +
  929 +HTML_COLORSTYLE_GAMMA = 80
  930 +
  931 +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
  932 +# page will contain the date and time when the page was generated. Setting
  933 +# this to NO can help when comparing the output of multiple runs.
  934 +
  935 +HTML_TIMESTAMP = YES
  936 +
  937 +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
  938 +# files or namespaces will be aligned in HTML using tables. If set to
  939 +# NO a bullet list will be used.
  940 +
  941 +HTML_ALIGN_MEMBERS = YES
  942 +
  943 +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
  944 +# documentation will contain sections that can be hidden and shown after the
  945 +# page has loaded. For this to work a browser that supports
  946 +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
  947 +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
  948 +
  949 +HTML_DYNAMIC_SECTIONS = NO
  950 +
  951 +# If the GENERATE_DOCSET tag is set to YES, additional index files
  952 +# will be generated that can be used as input for Apple's Xcode 3
  953 +# integrated development environment, introduced with OSX 10.5 (Leopard).
  954 +# To create a documentation set, doxygen will generate a Makefile in the
  955 +# HTML output directory. Running make will produce the docset in that
  956 +# directory and running "make install" will install the docset in
  957 +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
  958 +# it at startup.
  959 +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
  960 +# for more information.
  961 +
  962 +GENERATE_DOCSET = NO
  963 +
  964 +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
  965 +# feed. A documentation feed provides an umbrella under which multiple
  966 +# documentation sets from a single provider (such as a company or product suite)
  967 +# can be grouped.
  968 +
  969 +DOCSET_FEEDNAME = "Doxygen generated docs"
  970 +
  971 +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
  972 +# should uniquely identify the documentation set bundle. This should be a
  973 +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
  974 +# will append .docset to the name.
  975 +
  976 +DOCSET_BUNDLE_ID = org.doxygen.Project
  977 +
  978 +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify
  979 +# the documentation publisher. This should be a reverse domain-name style
  980 +# string, e.g. com.mycompany.MyDocSet.documentation.
  981 +
  982 +DOCSET_PUBLISHER_ID = org.doxygen.Publisher
  983 +
  984 +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
  985 +
  986 +DOCSET_PUBLISHER_NAME = Publisher
  987 +
  988 +# If the GENERATE_HTMLHELP tag is set to YES, additional index files
  989 +# will be generated that can be used as input for tools like the
  990 +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
  991 +# of the generated HTML documentation.
  992 +
  993 +GENERATE_HTMLHELP = NO
  994 +
  995 +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
  996 +# be used to specify the file name of the resulting .chm file. You
  997 +# can add a path in front of the file if the result should not be
  998 +# written to the html output directory.
  999 +
  1000 +CHM_FILE =
  1001 +
  1002 +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
  1003 +# be used to specify the location (absolute path including file name) of
  1004 +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
  1005 +# the HTML help compiler on the generated index.hhp.
  1006 +
  1007 +HHC_LOCATION =
  1008 +
  1009 +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
  1010 +# controls if a separate .chi index file is generated (YES) or that
  1011 +# it should be included in the master .chm file (NO).
  1012 +
  1013 +GENERATE_CHI = NO
  1014 +
  1015 +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
  1016 +# is used to encode HtmlHelp index (hhk), content (hhc) and project file
  1017 +# content.
  1018 +
  1019 +CHM_INDEX_ENCODING =
  1020 +
  1021 +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
  1022 +# controls whether a binary table of contents is generated (YES) or a
  1023 +# normal table of contents (NO) in the .chm file.
  1024 +
  1025 +BINARY_TOC = NO
  1026 +
  1027 +# The TOC_EXPAND flag can be set to YES to add extra items for group members
  1028 +# to the contents of the HTML help documentation and to the tree view.
  1029 +
  1030 +TOC_EXPAND = NO
  1031 +
  1032 +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
  1033 +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
  1034 +# that can be used as input for Qt's qhelpgenerator to generate a
  1035 +# Qt Compressed Help (.qch) of the generated HTML documentation.
  1036 +
  1037 +GENERATE_QHP = NO
  1038 +
  1039 +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
  1040 +# be used to specify the file name of the resulting .qch file.
  1041 +# The path specified is relative to the HTML output folder.
  1042 +
  1043 +QCH_FILE =
  1044 +
  1045 +# The QHP_NAMESPACE tag specifies the namespace to use when generating
  1046 +# Qt Help Project output. For more information please see
  1047 +# http://doc.trolltech.com/qthelpproject.html#namespace
  1048 +
  1049 +QHP_NAMESPACE = org.doxygen.Project
  1050 +
  1051 +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
  1052 +# Qt Help Project output. For more information please see
  1053 +# http://doc.trolltech.com/qthelpproject.html#virtual-folders
  1054 +
  1055 +QHP_VIRTUAL_FOLDER = doc
  1056 +
  1057 +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
  1058 +# add. For more information please see
  1059 +# http://doc.trolltech.com/qthelpproject.html#custom-filters
  1060 +
  1061 +QHP_CUST_FILTER_NAME =
  1062 +
  1063 +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
  1064 +# custom filter to add. For more information please see
  1065 +# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">
  1066 +# Qt Help Project / Custom Filters</a>.
  1067 +
  1068 +QHP_CUST_FILTER_ATTRS =
  1069 +
  1070 +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
  1071 +# project's
  1072 +# filter section matches.
  1073 +# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">
  1074 +# Qt Help Project / Filter Attributes</a>.
  1075 +
  1076 +QHP_SECT_FILTER_ATTRS =
  1077 +
  1078 +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
  1079 +# be used to specify the location of Qt's qhelpgenerator.
  1080 +# If non-empty doxygen will try to run qhelpgenerator on the generated
  1081 +# .qhp file.
  1082 +
  1083 +QHG_LOCATION =
  1084 +
  1085 +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
  1086 +# will be generated, which together with the HTML files, form an Eclipse help
  1087 +# plugin. To install this plugin and make it available under the help contents
  1088 +# menu in Eclipse, the contents of the directory containing the HTML and XML
  1089 +# files needs to be copied into the plugins directory of eclipse. The name of
  1090 +# the directory within the plugins directory should be the same as
  1091 +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
  1092 +# the help appears.
  1093 +
  1094 +GENERATE_ECLIPSEHELP = NO
  1095 +
  1096 +# A unique identifier for the eclipse help plugin. When installing the plugin
  1097 +# the directory name containing the HTML and XML files should also have
  1098 +# this name.
  1099 +
  1100 +ECLIPSE_DOC_ID = org.doxygen.Project
  1101 +
  1102 +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs)
  1103 +# at top of each HTML page. The value NO (the default) enables the index and
  1104 +# the value YES disables it. Since the tabs have the same information as the
  1105 +# navigation tree you can set this option to NO if you already set
  1106 +# GENERATE_TREEVIEW to YES.
  1107 +
  1108 +DISABLE_INDEX = NO
  1109 +
  1110 +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
  1111 +# structure should be generated to display hierarchical information.
  1112 +# If the tag value is set to YES, a side panel will be generated
  1113 +# containing a tree-like index structure (just like the one that
  1114 +# is generated for HTML Help). For this to work a browser that supports
  1115 +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
  1116 +# Windows users are probably better off using the HTML help feature.
  1117 +# Since the tree basically has the same information as the tab index you
  1118 +# could consider to set DISABLE_INDEX to NO when enabling this option.
  1119 +
  1120 +GENERATE_TREEVIEW = NO
  1121 +
  1122 +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
  1123 +# (range [0,1..20]) that doxygen will group on one line in the generated HTML
  1124 +# documentation. Note that a value of 0 will completely suppress the enum
  1125 +# values from appearing in the overview section.
  1126 +
  1127 +ENUM_VALUES_PER_LINE = 4
  1128 +
  1129 +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
  1130 +# and Class Hierarchy pages using a tree view instead of an ordered list.
  1131 +
  1132 +USE_INLINE_TREES = NO
  1133 +
  1134 +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
  1135 +# used to set the initial width (in pixels) of the frame in which the tree
  1136 +# is shown.
  1137 +
  1138 +TREEVIEW_WIDTH = 250
  1139 +
  1140 +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
  1141 +# links to external symbols imported via tag files in a separate window.
  1142 +
  1143 +EXT_LINKS_IN_WINDOW = NO
  1144 +
  1145 +# Use this tag to change the font size of Latex formulas included
  1146 +# as images in the HTML documentation. The default is 10. Note that
  1147 +# when you change the font size after a successful doxygen run you need
  1148 +# to manually remove any form_*.png images from the HTML output directory
  1149 +# to force them to be regenerated.
  1150 +
  1151 +FORMULA_FONTSIZE = 10
  1152 +
  1153 +# Use the FORMULA_TRANPARENT tag to determine whether or not the images
  1154 +# generated for formulas are transparent PNGs. Transparent PNGs are
  1155 +# not supported properly for IE 6.0, but are supported on all modern browsers.
  1156 +# Note that when changing this option you need to delete any form_*.png files
  1157 +# in the HTML output before the changes have effect.
  1158 +
  1159 +FORMULA_TRANSPARENT = YES
  1160 +
  1161 +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax
  1162 +# (see http://www.mathjax.org) which uses client side Javascript for the
  1163 +# rendering instead of using prerendered bitmaps. Use this if you do not
  1164 +# have LaTeX installed or if you want to formulas look prettier in the HTML
  1165 +# output. When enabled you also need to install MathJax separately and
  1166 +# configure the path to it using the MATHJAX_RELPATH option.
  1167 +
  1168 +USE_MATHJAX = NO
  1169 +
  1170 +# When MathJax is enabled you need to specify the location relative to the
  1171 +# HTML output directory using the MATHJAX_RELPATH option. The destination
  1172 +# directory should contain the MathJax.js script. For instance, if the mathjax
  1173 +# directory is located at the same level as the HTML output directory, then
  1174 +# MATHJAX_RELPATH should be ../mathjax. The default value points to the
  1175 +# mathjax.org site, so you can quickly see the result without installing
  1176 +# MathJax, but it is strongly recommended to install a local copy of MathJax
  1177 +# before deployment.
  1178 +
  1179 +MATHJAX_RELPATH = http://www.mathjax.org/mathjax
  1180 +
  1181 +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension
  1182 +# names that should be enabled during MathJax rendering.
  1183 +
  1184 +MATHJAX_EXTENSIONS =
  1185 +
  1186 +# When the SEARCHENGINE tag is enabled doxygen will generate a search box
  1187 +# for the HTML output. The underlying search engine uses javascript
  1188 +# and DHTML and should work on any modern browser. Note that when using
  1189 +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
  1190 +# (GENERATE_DOCSET) there is already a search function so this one should
  1191 +# typically be disabled. For large projects the javascript based search engine
  1192 +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
  1193 +
  1194 +SEARCHENGINE = YES
  1195 +
  1196 +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
  1197 +# implemented using a PHP enabled web server instead of at the web client
  1198 +# using Javascript. Doxygen will generate the search PHP script and index
  1199 +# file to put on the web server. The advantage of the server
  1200 +# based approach is that it scales better to large projects and allows
  1201 +# full text search. The disadvantages are that it is more difficult to setup
  1202 +# and does not have live searching capabilities.
  1203 +
  1204 +SERVER_BASED_SEARCH = NO
  1205 +
  1206 +#---------------------------------------------------------------------------
  1207 +# configuration options related to the LaTeX output
  1208 +#---------------------------------------------------------------------------
  1209 +
  1210 +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
  1211 +# generate Latex output.
  1212 +
  1213 +GENERATE_LATEX = NO
  1214 +
  1215 +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
  1216 +# If a relative path is entered the value of OUTPUT_DIRECTORY will be
  1217 +# put in front of it. If left blank `latex' will be used as the default path.
  1218 +
  1219 +LATEX_OUTPUT = latex
  1220 +
  1221 +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
  1222 +# invoked. If left blank `latex' will be used as the default command name.
  1223 +# Note that when enabling USE_PDFLATEX this option is only used for
  1224 +# generating bitmaps for formulas in the HTML output, but not in the
  1225 +# Makefile that is written to the output directory.
  1226 +
  1227 +LATEX_CMD_NAME = latex
  1228 +
  1229 +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
  1230 +# generate index for LaTeX. If left blank `makeindex' will be used as the
  1231 +# default command name.
  1232 +
  1233 +MAKEINDEX_CMD_NAME = makeindex
  1234 +
  1235 +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
  1236 +# LaTeX documents. This may be useful for small projects and may help to
  1237 +# save some trees in general.
  1238 +
  1239 +COMPACT_LATEX = NO
  1240 +
  1241 +# The PAPER_TYPE tag can be used to set the paper type that is used
  1242 +# by the printer. Possible values are: a4, letter, legal and
  1243 +# executive. If left blank a4wide will be used.
  1244 +
  1245 +PAPER_TYPE = a4
  1246 +
  1247 +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
  1248 +# packages that should be included in the LaTeX output.
  1249 +
  1250 +EXTRA_PACKAGES =
  1251 +
  1252 +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
  1253 +# the generated latex document. The header should contain everything until
  1254 +# the first chapter. If it is left blank doxygen will generate a
  1255 +# standard header. Notice: only use this tag if you know what you are doing!
  1256 +
  1257 +LATEX_HEADER =
  1258 +
  1259 +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for
  1260 +# the generated latex document. The footer should contain everything after
  1261 +# the last chapter. If it is left blank doxygen will generate a
  1262 +# standard footer. Notice: only use this tag if you know what you are doing!
  1263 +
  1264 +LATEX_FOOTER =
  1265 +
  1266 +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
  1267 +# is prepared for conversion to pdf (using ps2pdf). The pdf file will
  1268 +# contain links (just like the HTML output) instead of page references
  1269 +# This makes the output suitable for online browsing using a pdf viewer.
  1270 +
  1271 +PDF_HYPERLINKS = YES
  1272 +
  1273 +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
  1274 +# plain latex in the generated Makefile. Set this option to YES to get a
  1275 +# higher quality PDF documentation.
  1276 +
  1277 +USE_PDFLATEX = YES
  1278 +
  1279 +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
  1280 +# command to the generated LaTeX files. This will instruct LaTeX to keep
  1281 +# running if errors occur, instead of asking the user for help.
  1282 +# This option is also used when generating formulas in HTML.
  1283 +
  1284 +LATEX_BATCHMODE = NO
  1285 +
  1286 +# If LATEX_HIDE_INDICES is set to YES then doxygen will not
  1287 +# include the index chapters (such as File Index, Compound Index, etc.)
  1288 +# in the output.
  1289 +
  1290 +LATEX_HIDE_INDICES = NO
  1291 +
  1292 +# If LATEX_SOURCE_CODE is set to YES then doxygen will include
  1293 +# source code with syntax highlighting in the LaTeX output.
  1294 +# Note that which sources are shown also depends on other settings
  1295 +# such as SOURCE_BROWSER.
  1296 +
  1297 +LATEX_SOURCE_CODE = NO
  1298 +
  1299 +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
  1300 +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See
  1301 +# http://en.wikipedia.org/wiki/BibTeX for more info.
  1302 +
  1303 +LATEX_BIB_STYLE = plain
  1304 +
  1305 +#---------------------------------------------------------------------------
  1306 +# configuration options related to the RTF output
  1307 +#---------------------------------------------------------------------------
  1308 +
  1309 +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
  1310 +# The RTF output is optimized for Word 97 and may not look very pretty with
  1311 +# other RTF readers or editors.
  1312 +
  1313 +GENERATE_RTF = NO
  1314 +
  1315 +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
  1316 +# If a relative path is entered the value of OUTPUT_DIRECTORY will be
  1317 +# put in front of it. If left blank `rtf' will be used as the default path.
  1318 +
  1319 +RTF_OUTPUT = rtf
  1320 +
  1321 +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
  1322 +# RTF documents. This may be useful for small projects and may help to
  1323 +# save some trees in general.
  1324 +
  1325 +COMPACT_RTF = NO
  1326 +
  1327 +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
  1328 +# will contain hyperlink fields. The RTF file will
  1329 +# contain links (just like the HTML output) instead of page references.
  1330 +# This makes the output suitable for online browsing using WORD or other
  1331 +# programs which support those fields.
  1332 +# Note: wordpad (write) and others do not support links.
  1333 +
  1334 +RTF_HYPERLINKS = NO
  1335 +
  1336 +# Load style sheet definitions from file. Syntax is similar to doxygen's
  1337 +# config file, i.e. a series of assignments. You only have to provide
  1338 +# replacements, missing definitions are set to their default value.
  1339 +
  1340 +RTF_STYLESHEET_FILE =
  1341 +
  1342 +# Set optional variables used in the generation of an rtf document.
  1343 +# Syntax is similar to doxygen's config file.
  1344 +
  1345 +RTF_EXTENSIONS_FILE =
  1346 +
  1347 +#---------------------------------------------------------------------------
  1348 +# configuration options related to the man page output
  1349 +#---------------------------------------------------------------------------
  1350 +
  1351 +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
  1352 +# generate man pages
  1353 +
  1354 +GENERATE_MAN = NO
  1355 +
  1356 +# The MAN_OUTPUT tag is used to specify where the man pages will be put.
  1357 +# If a relative path is entered the value of OUTPUT_DIRECTORY will be
  1358 +# put in front of it. If left blank `man' will be used as the default path.
  1359 +
  1360 +MAN_OUTPUT = man
  1361 +
  1362 +# The MAN_EXTENSION tag determines the extension that is added to
  1363 +# the generated man pages (default is the subroutine's section .3)
  1364 +
  1365 +MAN_EXTENSION = .3
  1366 +
  1367 +# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
  1368 +# then it will generate one additional man file for each entity
  1369 +# documented in the real man page(s). These additional files
  1370 +# only source the real man page, but without them the man command
  1371 +# would be unable to find the correct page. The default is NO.
  1372 +
  1373 +MAN_LINKS = NO
  1374 +
  1375 +#---------------------------------------------------------------------------
  1376 +# configuration options related to the XML output
  1377 +#---------------------------------------------------------------------------
  1378 +
  1379 +# If the GENERATE_XML tag is set to YES Doxygen will
  1380 +# generate an XML file that captures the structure of
  1381 +# the code including all documentation.
  1382 +
  1383 +GENERATE_XML = NO
  1384 +
  1385 +# The XML_OUTPUT tag is used to specify where the XML pages will be put.
  1386 +# If a relative path is entered the value of OUTPUT_DIRECTORY will be
  1387 +# put in front of it. If left blank `xml' will be used as the default path.
  1388 +
  1389 +XML_OUTPUT = xml
  1390 +
  1391 +# The XML_SCHEMA tag can be used to specify an XML schema,
  1392 +# which can be used by a validating XML parser to check the
  1393 +# syntax of the XML files.
  1394 +
  1395 +XML_SCHEMA =
  1396 +
  1397 +# The XML_DTD tag can be used to specify an XML DTD,
  1398 +# which can be used by a validating XML parser to check the
  1399 +# syntax of the XML files.
  1400 +
  1401 +XML_DTD =
  1402 +
  1403 +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
  1404 +# dump the program listings (including syntax highlighting
  1405 +# and cross-referencing information) to the XML output. Note that
  1406 +# enabling this will significantly increase the size of the XML output.
  1407 +
  1408 +XML_PROGRAMLISTING = YES
  1409 +
  1410 +#---------------------------------------------------------------------------
  1411 +# configuration options for the AutoGen Definitions output
  1412 +#---------------------------------------------------------------------------
  1413 +
  1414 +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
  1415 +# generate an AutoGen Definitions (see autogen.sf.net) file
  1416 +# that captures the structure of the code including all
  1417 +# documentation. Note that this feature is still experimental
  1418 +# and incomplete at the moment.
  1419 +
  1420 +GENERATE_AUTOGEN_DEF = NO
  1421 +
  1422 +#---------------------------------------------------------------------------
  1423 +# configuration options related to the Perl module output
  1424 +#---------------------------------------------------------------------------
  1425 +
  1426 +# If the GENERATE_PERLMOD tag is set to YES Doxygen will
  1427 +# generate a Perl module file that captures the structure of
  1428 +# the code including all documentation. Note that this
  1429 +# feature is still experimental and incomplete at the
  1430 +# moment.
  1431 +
  1432 +GENERATE_PERLMOD = NO
  1433 +
  1434 +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
  1435 +# the necessary Makefile rules, Perl scripts and LaTeX code to be able
  1436 +# to generate PDF and DVI output from the Perl module output.
  1437 +
  1438 +PERLMOD_LATEX = NO
  1439 +
  1440 +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
  1441 +# nicely formatted so it can be parsed by a human reader.
  1442 +# This is useful
  1443 +# if you want to understand what is going on.
  1444 +# On the other hand, if this
  1445 +# tag is set to NO the size of the Perl module output will be much smaller
  1446 +# and Perl will parse it just the same.
  1447 +
  1448 +PERLMOD_PRETTY = YES
  1449 +
  1450 +# The names of the make variables in the generated doxyrules.make file
  1451 +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
  1452 +# This is useful so different doxyrules.make files included by the same
  1453 +# Makefile don't overwrite each other's variables.
  1454 +
  1455 +PERLMOD_MAKEVAR_PREFIX =
  1456 +
  1457 +#---------------------------------------------------------------------------
  1458 +# Configuration options related to the preprocessor
  1459 +#---------------------------------------------------------------------------
  1460 +
  1461 +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
  1462 +# evaluate all C-preprocessor directives found in the sources and include
  1463 +# files.
  1464 +
  1465 +ENABLE_PREPROCESSING = YES
  1466 +
  1467 +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
  1468 +# names in the source code. If set to NO (the default) only conditional
  1469 +# compilation will be performed. Macro expansion can be done in a controlled
  1470 +# way by setting EXPAND_ONLY_PREDEF to YES.
  1471 +
  1472 +MACRO_EXPANSION = NO
  1473 +
  1474 +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
  1475 +# then the macro expansion is limited to the macros specified with the
  1476 +# PREDEFINED and EXPAND_AS_DEFINED tags.
  1477 +
  1478 +EXPAND_ONLY_PREDEF = NO
  1479 +
  1480 +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
  1481 +# pointed to by INCLUDE_PATH will be searched when a #include is found.
  1482 +
  1483 +SEARCH_INCLUDES = YES
  1484 +
  1485 +# The INCLUDE_PATH tag can be used to specify one or more directories that
  1486 +# contain include files that are not input files but should be processed by
  1487 +# the preprocessor.
  1488 +
  1489 +INCLUDE_PATH =
  1490 +
  1491 +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
  1492 +# patterns (like *.h and *.hpp) to filter out the header-files in the
  1493 +# directories. If left blank, the patterns specified with FILE_PATTERNS will
  1494 +# be used.
  1495 +
  1496 +INCLUDE_FILE_PATTERNS =
  1497 +
  1498 +# The PREDEFINED tag can be used to specify one or more macro names that
  1499 +# are defined before the preprocessor is started (similar to the -D option of
  1500 +# gcc). The argument of the tag is a list of macros of the form: name
  1501 +# or name=definition (no spaces). If the definition and the = are
  1502 +# omitted =1 is assumed. To prevent a macro definition from being
  1503 +# undefined via #undef or recursively expanded use the := operator
  1504 +# instead of the = operator.
  1505 +
  1506 +PREDEFINED =
  1507 +
  1508 +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
  1509 +# this tag can be used to specify a list of macro names that should be expanded.
  1510 +# The macro definition that is found in the sources will be used.
  1511 +# Use the PREDEFINED tag if you want to use a different macro definition that
  1512 +# overrules the definition found in the source code.
  1513 +
  1514 +EXPAND_AS_DEFINED =
  1515 +
  1516 +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
  1517 +# doxygen's preprocessor will remove all references to function-like macros
  1518 +# that are alone on a line, have an all uppercase name, and do not end with a
  1519 +# semicolon, because these will confuse the parser if not removed.
  1520 +
  1521 +SKIP_FUNCTION_MACROS = YES
  1522 +
  1523 +#---------------------------------------------------------------------------
  1524 +# Configuration::additions related to external references
  1525 +#---------------------------------------------------------------------------
  1526 +
  1527 +# The TAGFILES option can be used to specify one or more tagfiles.
  1528 +# Optionally an initial location of the external documentation
  1529 +# can be added for each tagfile. The format of a tag file without
  1530 +# this location is as follows:
  1531 +#
  1532 +# TAGFILES = file1 file2 ...
  1533 +# Adding location for the tag files is done as follows:
  1534 +#
  1535 +# TAGFILES = file1=loc1 "file2 = loc2" ...
  1536 +# where "loc1" and "loc2" can be relative or absolute paths or
  1537 +# URLs. If a location is present for each tag, the installdox tool
  1538 +# does not have to be run to correct the links.
  1539 +# Note that each tag file must have a unique name
  1540 +# (where the name does NOT include the path)
  1541 +# If a tag file is not located in the directory in which doxygen
  1542 +# is run, you must also specify the path to the tagfile here.
  1543 +
  1544 +TAGFILES =
  1545 +
  1546 +# When a file name is specified after GENERATE_TAGFILE, doxygen will create
  1547 +# a tag file that is based on the input files it reads.
  1548 +
  1549 +GENERATE_TAGFILE =
  1550 +
  1551 +# If the ALLEXTERNALS tag is set to YES all external classes will be listed
  1552 +# in the class index. If set to NO only the inherited external classes
  1553 +# will be listed.
  1554 +
  1555 +ALLEXTERNALS = NO
  1556 +
  1557 +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
  1558 +# in the modules index. If set to NO, only the current project's groups will
  1559 +# be listed.
  1560 +
  1561 +EXTERNAL_GROUPS = YES
  1562 +
  1563 +# The PERL_PATH should be the absolute path and name of the perl script
  1564 +# interpreter (i.e. the result of `which perl').
  1565 +
  1566 +PERL_PATH = /usr/bin/perl
  1567 +
  1568 +#---------------------------------------------------------------------------
  1569 +# Configuration options related to the dot tool
  1570 +#---------------------------------------------------------------------------
  1571 +
  1572 +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
  1573 +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
  1574 +# or super classes. Setting the tag to NO turns the diagrams off. Note that
  1575 +# this option also works with HAVE_DOT disabled, but it is recommended to
  1576 +# install and use dot, since it yields more powerful graphs.
  1577 +
  1578 +CLASS_DIAGRAMS = YES
  1579 +
  1580 +# You can define message sequence charts within doxygen comments using the \msc
  1581 +# command. Doxygen will then run the mscgen tool (see
  1582 +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
  1583 +# documentation. The MSCGEN_PATH tag allows you to specify the directory where
  1584 +# the mscgen tool resides. If left empty the tool is assumed to be found in the
  1585 +# default search path.
  1586 +
  1587 +MSCGEN_PATH =
  1588 +
  1589 +# If set to YES, the inheritance and collaboration graphs will hide
  1590 +# inheritance and usage relations if the target is undocumented
  1591 +# or is not a class.
  1592 +
  1593 +HIDE_UNDOC_RELATIONS = YES
  1594 +
  1595 +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
  1596 +# available from the path. This tool is part of Graphviz, a graph visualization
  1597 +# toolkit from AT&T and Lucent Bell Labs. The other options in this section
  1598 +# have no effect if this option is set to NO (the default)
  1599 +
  1600 +HAVE_DOT = NO
  1601 +
  1602 +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
  1603 +# allowed to run in parallel. When set to 0 (the default) doxygen will
  1604 +# base this on the number of processors available in the system. You can set it
  1605 +# explicitly to a value larger than 0 to get control over the balance
  1606 +# between CPU load and processing speed.
  1607 +
  1608 +DOT_NUM_THREADS = 0
  1609 +
  1610 +# By default doxygen will use the Helvetica font for all dot files that
  1611 +# doxygen generates. When you want a differently looking font you can specify
  1612 +# the font name using DOT_FONTNAME. You need to make sure dot is able to find
  1613 +# the font, which can be done by putting it in a standard location or by setting
  1614 +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
  1615 +# directory containing the font.
  1616 +
  1617 +DOT_FONTNAME = Helvetica
  1618 +
  1619 +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
  1620 +# The default size is 10pt.
  1621 +
  1622 +DOT_FONTSIZE = 10
  1623 +
  1624 +# By default doxygen will tell dot to use the Helvetica font.
  1625 +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to
  1626 +# set the path where dot can find it.
  1627 +
  1628 +DOT_FONTPATH =
  1629 +
  1630 +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
  1631 +# will generate a graph for each documented class showing the direct and
  1632 +# indirect inheritance relations. Setting this tag to YES will force the
  1633 +# CLASS_DIAGRAMS tag to NO.
  1634 +
  1635 +CLASS_GRAPH = YES
  1636 +
  1637 +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
  1638 +# will generate a graph for each documented class showing the direct and
  1639 +# indirect implementation dependencies (inheritance, containment, and
  1640 +# class references variables) of the class with other documented classes.
  1641 +
  1642 +COLLABORATION_GRAPH = YES
  1643 +
  1644 +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
  1645 +# will generate a graph for groups, showing the direct groups dependencies
  1646 +
  1647 +GROUP_GRAPHS = YES
  1648 +
  1649 +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
  1650 +# collaboration diagrams in a style similar to the OMG's Unified Modeling
  1651 +# Language.
  1652 +
  1653 +UML_LOOK = NO
  1654 +
  1655 +# If set to YES, the inheritance and collaboration graphs will show the
  1656 +# relations between templates and their instances.
  1657 +
  1658 +TEMPLATE_RELATIONS = NO
  1659 +
  1660 +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
  1661 +# tags are set to YES then doxygen will generate a graph for each documented
  1662 +# file showing the direct and indirect include dependencies of the file with
  1663 +# other documented files.
  1664 +
  1665 +INCLUDE_GRAPH = YES
  1666 +
  1667 +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
  1668 +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
  1669 +# documented header file showing the documented files that directly or
  1670 +# indirectly include this file.
  1671 +
  1672 +INCLUDED_BY_GRAPH = YES
  1673 +
  1674 +# If the CALL_GRAPH and HAVE_DOT options are set to YES then
  1675 +# doxygen will generate a call dependency graph for every global function
  1676 +# or class method. Note that enabling this option will significantly increase
  1677 +# the time of a run. So in most cases it will be better to enable call graphs
  1678 +# for selected functions only using the \callgraph command.
  1679 +
  1680 +CALL_GRAPH = NO
  1681 +
  1682 +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
  1683 +# doxygen will generate a caller dependency graph for every global function
  1684 +# or class method. Note that enabling this option will significantly increase
  1685 +# the time of a run. So in most cases it will be better to enable caller
  1686 +# graphs for selected functions only using the \callergraph command.
  1687 +
  1688 +CALLER_GRAPH = NO
  1689 +
  1690 +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
  1691 +# will generate a graphical hierarchy of all classes instead of a textual one.
  1692 +
  1693 +GRAPHICAL_HIERARCHY = YES
  1694 +
  1695 +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
  1696 +# then doxygen will show the dependencies a directory has on other directories
  1697 +# in a graphical way. The dependency relations are determined by the #include
  1698 +# relations between the files in the directories.
  1699 +
  1700 +DIRECTORY_GRAPH = YES
  1701 +
  1702 +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
  1703 +# generated by dot. Possible values are svg, png, jpg, or gif.
  1704 +# If left blank png will be used. If you choose svg you need to set
  1705 +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files
  1706 +# visible in IE 9+ (other browsers do not have this requirement).
  1707 +
  1708 +DOT_IMAGE_FORMAT = png
  1709 +
  1710 +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
  1711 +# enable generation of interactive SVG images that allow zooming and panning.
  1712 +# Note that this requires a modern browser other than Internet Explorer.
  1713 +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you
  1714 +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files
  1715 +# visible. Older versions of IE do not have SVG support.
  1716 +
  1717 +INTERACTIVE_SVG = NO
  1718 +
  1719 +# The tag DOT_PATH can be used to specify the path where the dot tool can be
  1720 +# found. If left blank, it is assumed the dot tool can be found in the path.
  1721 +
  1722 +DOT_PATH =
  1723 +
  1724 +# The DOTFILE_DIRS tag can be used to specify one or more directories that
  1725 +# contain dot files that are included in the documentation (see the
  1726 +# \dotfile command).
  1727 +
  1728 +DOTFILE_DIRS =
  1729 +
  1730 +# The MSCFILE_DIRS tag can be used to specify one or more directories that
  1731 +# contain msc files that are included in the documentation (see the
  1732 +# \mscfile command).
  1733 +
  1734 +MSCFILE_DIRS =
  1735 +
  1736 +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
  1737 +# nodes that will be shown in the graph. If the number of nodes in a graph
  1738 +# becomes larger than this value, doxygen will truncate the graph, which is
  1739 +# visualized by representing a node as a red box. Note that doxygen if the
  1740 +# number of direct children of the root node in a graph is already larger than
  1741 +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
  1742 +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
  1743 +
  1744 +DOT_GRAPH_MAX_NODES = 50
  1745 +
  1746 +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
  1747 +# graphs generated by dot. A depth value of 3 means that only nodes reachable
  1748 +# from the root by following a path via at most 3 edges will be shown. Nodes
  1749 +# that lay further from the root node will be omitted. Note that setting this
  1750 +# option to 1 or 2 may greatly reduce the computation time needed for large
  1751 +# code bases. Also note that the size of a graph can be further restricted by
  1752 +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
  1753 +
  1754 +MAX_DOT_GRAPH_DEPTH = 0
  1755 +
  1756 +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
  1757 +# background. This is disabled by default, because dot on Windows does not
  1758 +# seem to support this out of the box. Warning: Depending on the platform used,
  1759 +# enabling this option may lead to badly anti-aliased labels on the edges of
  1760 +# a graph (i.e. they become hard to read).
  1761 +
  1762 +DOT_TRANSPARENT = NO
  1763 +
  1764 +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
  1765 +# files in one run (i.e. multiple -o and -T options on the command line). This
  1766 +# makes dot run faster, but since only newer versions of dot (>1.8.10)
  1767 +# support this, this feature is disabled by default.
  1768 +
  1769 +DOT_MULTI_TARGETS = YES
  1770 +
  1771 +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
  1772 +# generate a legend page explaining the meaning of the various boxes and
  1773 +# arrows in the dot generated graphs.
  1774 +
  1775 +GENERATE_LEGEND = YES
  1776 +
  1777 +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
  1778 +# remove the intermediate dot files that are used to generate
  1779 +# the various graphs.
  1780 +
  1781 +DOT_CLEANUP = YES
extrator/src/extratorFactory.cpp
1 #include "extratorFactory.h" 1 #include "extratorFactory.h"
2 2
3 -ExtratorFactory::ExtratorFactory(){  
4 - //TODO  
5 -}  
6 -  
7 -ExtratorFactory::~ExtratorFactory(){  
8 - //TODO  
9 -}  
10 -  
11 Extrator* ExtratorFactory::getExtrator(Extrator::ExtratorType extrator_type) { 3 Extrator* ExtratorFactory::getExtrator(Extrator::ExtratorType extrator_type) {
12 extrator = extrator_type; 4 extrator = extrator_type;
13 switch(extrator){ 5 switch(extrator){
14 case Extrator::SRT: 6 case Extrator::SRT:
  7 + PRINTL(util::_DEBUG, "ExtratorSRT selected!\n");
15 return new ExtratorSRT(); 8 return new ExtratorSRT();
16 case Extrator::TXT: 9 case Extrator::TXT:
  10 + PRINTL(util::_DEBUG, "ExtratorTXT selected!\n");
17 return new ExtratorTXT(); 11 return new ExtratorTXT();
  12 + case Extrator::VTT:
  13 + PRINTL(util::_DEBUG, "ExtratorVTT selected!\n");
  14 + return new ExtratorVTT();
18 } 15 }
19 } 16 }
20 \ No newline at end of file 17 \ No newline at end of file
extrator/src/extratorSRT.cpp
1 #include "extratorSRT.h" 1 #include "extratorSRT.h"
2 2
3 ExtratorSRT::ExtratorSRT(){ 3 ExtratorSRT::ExtratorSRT(){
4 - listeners = new list<ListenerSRT*>(); 4 + listeners = new list<ListenerSub*>();
5 finish = false; 5 finish = false;
6 seek_pos = 0; 6 seek_pos = 0;
7 hasNextSub = true; 7 hasNextSub = true;
8 - DPRINTF("Done!\n"); 8 + PRINTL(util::_DEBUG, "ExtratorSTR Done!\n");
9 } 9 }
10 10
11 -ExtratorSRT::~ExtratorSRT(){  
12 - listeners->clear(); 11 +ExtratorSRT::~ExtratorSRT(){
  12 + listeners->clear();
13 delete listeners; 13 delete listeners;
14 - //if (bff_reader) delete bff_reader;  
15 if (file_io) delete file_io; 14 if (file_io) delete file_io;
16 - DDDPRINTF("ExtratorSTR finalized!\n"); 15 + PRINTL(util::_DEBUG, "ExtratorSTR finalized!\n");
17 } 16 }
18 17
19 -void ExtratorSRT::initialize(){  
20 -  
21 - file = new lavidlib::File(filePath);  
22 -  
23 - try{  
24 - file_io = new lavidlib::FileIO(file->getPath(), FileIO::MODE_READ);  
25 - }catch(Exception ex){  
26 - finish = true;  
27 - Util::Logger::Instance()->writeLog((char*) "[ERRO: extratorSRT.cpp] Arquivo de legenda não encontrado.");  
28 - throw ExtratorException("Falha ao abrir o arquivo de legenda! Verifique se o mesmo existe.\n");  
29 - }  
30 -  
31 - this->Start();  
32 -}  
33 -  
34 -  
35 -void ExtratorSRT::addListener(ListenerSRT* listener){ 18 +void ExtratorSRT::addListener(ListenerSub* listener){
36 listeners->push_back(listener); 19 listeners->push_back(listener);
37 } 20 }
38 21
39 void ExtratorSRT::notifyListeners(unsigned char* subtitle, int64_t pts) { 22 void ExtratorSRT::notifyListeners(unsigned char* subtitle, int64_t pts) {
40 - for(list<ListenerSRT*>::iterator it = listeners->begin(); it != listeners->end(); it++){ 23 + for(list<ListenerSub*>::iterator it = listeners->begin(); it != listeners->end(); it++){
41 (*it)->notifySubtitle(subtitle, pts); 24 (*it)->notifySubtitle(subtitle, pts);
42 - } 25 + }
43 } 26 }
44 27
45 void ExtratorSRT::notifyEndExtraction(int size) { 28 void ExtratorSRT::notifyEndExtraction(int size) {
46 - DPRINTF("Extrator SRT concluiu a extração: %d legendas.\n", size);  
47 - for(list<ListenerSRT*>::iterator it = listeners->begin(); it != listeners->end(); it++){ 29 + PRINTL(util::_DEBUG, "Extrator SRT concluiu a extração: %d legendas.\n", size);
  30 + for(list<ListenerSub*>::iterator it = listeners->begin(); it != listeners->end(); it++){
48 (*it)->notifyEnd(size); 31 (*it)->notifyEnd(size);
49 } 32 }
50 } 33 }
51 34
52 -void ExtratorSRT::setFilePath(char* path){  
53 - filePath = (char*) path;  
54 - string command1 = "perl -p -e 's/\r$//' < ";  
55 - command1.append(filePath).append(" > ").append(INPUT_SRT);  
56 - system(command1.c_str());  
57 -  
58 - string command2 = "iconv -f";  
59 - command2.append(" $(file --mime-encoding -b ")  
60 - .append(INPUT_SRT).append(")")  
61 - .append(" -t utf-8 ").append(INPUT_SRT).append(" > ").append(filePath)  
62 - .append(" && rm -f ").append(INPUT_SRT);  
63 - system(command2.c_str()); 35 +void ExtratorSRT::encodingfiletoUTF8() {
  36 + string recmd = "recode ";
  37 + recmd.append("$(file --mime-encoding -b ")
  38 + .append(this->filePath).append(")..utf-8 ")
  39 + .append(this->filePath);
  40 + system(recmd.c_str());
  41 +
  42 + string sedcmd = "sed -i 's/\r$//;$d' ";
  43 + sedcmd.append(this->filePath);
  44 + system(sedcmd.c_str());
  45 +
  46 +}
  47 +
  48 +void ExtratorSRT::setFilePath(char* path) {
  49 + this->filePath = path;
  50 + encodingfiletoUTF8();
  51 +}
  52 +
  53 +void ExtratorSRT::initialize(){
  54 +
  55 + file = new lavidlib::File(this->filePath);
  56 +
  57 + try{
  58 + file_io = new lavidlib::FileIO(file->getPath(), FileIO::MODE_READ);
  59 + }catch(Exception &ex){
  60 + finish = true;
  61 + Logging::instance()->writeLog("extratorSRT.cpp <Error>: Arquivo de legenda não encontrado.");
  62 + throw ExtratorException("Falha ao abrir o arquivo de legenda! Verifique se o mesmo existe.\n");
  63 + }
  64 + this->Start();
  65 +
64 } 66 }
65 67
66 bool ExtratorSRT::isFinished(){ 68 bool ExtratorSRT::isFinished(){
@@ -72,15 +74,15 @@ bool ExtratorSRT::hasNextSubtitle() { @@ -72,15 +74,15 @@ bool ExtratorSRT::hasNextSubtitle() {
72 } 74 }
73 75
74 void ExtratorSRT::Run(){ 76 void ExtratorSRT::Run(){
75 - DPRINTF("[AGUARDE] Extraindo Legendas...\n");  
76 - 77 + PRINTL(util::_INFO, "Extraindo Legendas...\n");
77 int sub_index = 0; 78 int sub_index = 0;
78 string sub_text = ""; 79 string sub_text = "";
79 -  
80 while(hasNextSubtitle()){ 80 while(hasNextSubtitle()){
81 try{ 81 try{
82 subtitle = next(); 82 subtitle = next();
83 - }catch(ExtratorException ex){ break; } 83 + }catch(ExtratorException ex){
  84 + break;
  85 + }
84 sub_text = subtitle->getSubtitleText(); 86 sub_text = subtitle->getSubtitleText();
85 notifyListeners((unsigned char*)sub_text.c_str(), calcula_pts((double) subtitle->getTimeIn())); 87 notifyListeners((unsigned char*)sub_text.c_str(), calcula_pts((double) subtitle->getTimeIn()));
86 sub_index++; 88 sub_index++;
@@ -88,63 +90,83 @@ void ExtratorSRT::Run(){ @@ -88,63 +90,83 @@ void ExtratorSRT::Run(){
88 } 90 }
89 if(sub_index == 0) 91 if(sub_index == 0)
90 notifyListeners((unsigned char*)"ARQUIVO_INVALIDO", 0); 92 notifyListeners((unsigned char*)"ARQUIVO_INVALIDO", 0);
  93 +
91 finish = true; 94 finish = true;
92 notifyEndExtraction(sub_index); 95 notifyEndExtraction(sub_index);
93 } 96 }
94 97
95 Subtitle* ExtratorSRT::next() { 98 Subtitle* ExtratorSRT::next() {
96 -  
97 - if (seek_pos >= file_io->getSize())  
98 - throw ExtratorException("[ERRO: extratorSRT.cpp] Esse arquivo já foi lido.");  
99 - 99 +
100 file_io->seek(seek_pos); 100 file_io->seek(seek_pos);
101 try{ 101 try{
102 bff_reader = new BufferedReader(file_io); 102 bff_reader = new BufferedReader(file_io);
103 }catch(Exception &ex){ 103 }catch(Exception &ex){
104 - throw ExtratorException("[ERRO: extratorSRT.cpp] O BufferedReader não foi inicializado."); 104 + Logging::instance()->writeLog("extratorSRT.cpp <Error>: BufferedReader não inicializado.");
  105 + throw ExtratorException("O BufferedReader não foi inicializado.");
105 } 106 }
106 107
107 Subtitle* sub = new Subtitle(); 108 Subtitle* sub = new Subtitle();
108 - string line = ""; 109 + string line = "";
109 string text_sub = ""; 110 string text_sub = "";
110 - 111 +
111 try { 112 try {
112 /* ID */ 113 /* ID */
113 int id = 0; 114 int id = 0;
114 line = bff_reader->readLine(); 115 line = bff_reader->readLine();
115 seek_pos += (int64_t) line.size() + SIZE_CSCAPE; 116 seek_pos += (int64_t) line.size() + SIZE_CSCAPE;
116 - id = atoi(line.c_str()); 117 + id = atoi(line.c_str());
117 sub->setID(id); 118 sub->setID(id);
118 119
119 /* TimeIn and TimeOut */ 120 /* TimeIn and TimeOut */
120 int64_t t_in = 0, t_out = 0; 121 int64_t t_in = 0, t_out = 0;
121 line = bff_reader->readLine(); 122 line = bff_reader->readLine();
122 seek_pos += (int64_t) line.size() + SIZE_CSCAPE; 123 seek_pos += (int64_t) line.size() + SIZE_CSCAPE;
123 - 124 +
124 int target_pos = line.find(TARGET_TIME); 125 int target_pos = line.find(TARGET_TIME);
125 t_in = str_to_time(line.substr(0, target_pos)); 126 t_in = str_to_time(line.substr(0, target_pos));
126 sub->setTimeIn(t_in); 127 sub->setTimeIn(t_in);
127 t_out = str_to_time(line.substr(target_pos + strlen(TARGET_TIME)+1, line.size())); 128 t_out = str_to_time(line.substr(target_pos + strlen(TARGET_TIME)+1, line.size()));
128 - sub->setTimeOut(t_out);  
129 -  
130 - /* Text: read until line be empty */ 129 + sub->setTimeOut(t_out);
  130 +
  131 + /* Text: read until line be empty */
131 while ((line = bff_reader->readLine()).size() > 0) { 132 while ((line = bff_reader->readLine()).size() > 0) {
132 text_sub += line; 133 text_sub += line;
133 - text_sub.append(" "); 134 + text_sub.append(" ");
134 } 135 }
135 seek_pos += (int64_t) text_sub.size() + SIZE_CSCAPE; 136 seek_pos += (int64_t) text_sub.size() + SIZE_CSCAPE;
136 - 137 +
137 } catch (lavidlib::EOFException &ex) { 138 } catch (lavidlib::EOFException &ex) {
138 - sub->setSubtitleText(text_sub); 139 + if(text_sub == "")
  140 + sub->setTimeIn(0); //seta o valor 0 para nao gerar um valor aleatório
  141 +
  142 + sub->setSubtitleText(formatText(text_sub));
139 seek_pos += (int64_t) text_sub.size() + SIZE_CSCAPE; 143 seek_pos += (int64_t) text_sub.size() + SIZE_CSCAPE;
140 hasNextSub = false; 144 hasNextSub = false;
  145 + delete(bff_reader);
141 return sub; 146 return sub;
142 } 147 }
143 - sub->setSubtitleText(text_sub); 148 + sub->setSubtitleText(formatText(text_sub));
144 delete(bff_reader); 149 delete(bff_reader);
145 return sub; 150 return sub;
146 } 151 }
147 - 152 +
  153 +string ExtratorSRT::formatText(string line){
  154 + int lessThanPos;
  155 + int moreThanPos;
  156 + string f_line = line;
  157 +
  158 + lessThanPos = f_line.find_first_of(LESS_THAN); //pega a posição do simbolo '<'
  159 + moreThanPos = f_line.find_first_of(MORE_THAN); //pega a posição do simbolo '>'
  160 +
  161 + while(lessThanPos != string::npos && moreThanPos != string::npos){
  162 + f_line = f_line.erase(lessThanPos, moreThanPos - (lessThanPos-1)); //remove o trecho '<string>'
  163 + lessThanPos = f_line.find_first_of(LESS_THAN);
  164 + moreThanPos = f_line.find_first_of(MORE_THAN);
  165 + }
  166 +
  167 + return f_line;
  168 +}
  169 +
148 int64_t ExtratorSRT::str_to_time(string str_time) { 170 int64_t ExtratorSRT::str_to_time(string str_time) {
149 171
150 int64_t ttime = 0; 172 int64_t ttime = 0;
@@ -153,7 +175,7 @@ int64_t ExtratorSRT::str_to_time(string str_time) { @@ -153,7 +175,7 @@ int64_t ExtratorSRT::str_to_time(string str_time) {
153 175
154 int index = 0; 176 int index = 0;
155 int values [4]; // hh, mm, ss, ms 177 int values [4]; // hh, mm, ss, ms
156 - char * str = strtok(tokens, ":,"); 178 + char * str = strtok(tokens, ":,");
157 while (str != NULL) { 179 while (str != NULL) {
158 values[index] = atoi(str); 180 values[index] = atoi(str);
159 str = strtok(NULL, ":,"); 181 str = strtok(NULL, ":,");
@@ -162,7 +184,7 @@ int64_t ExtratorSRT::str_to_time(string str_time) { @@ -162,7 +184,7 @@ int64_t ExtratorSRT::str_to_time(string str_time) {
162 delete(tokens); 184 delete(tokens);
163 185
164 /* calculate time */ 186 /* calculate time */
165 - ttime = /*hour to sec*/((((values[0] * 60) * 60) + 187 + ttime = /*hour to sec*/((((values[0] * 60) * 60) +
166 /*min to sec*/(values[1] * 60) +/*sec*/values[2])*1000) + values[3]; 188 /*min to sec*/(values[1] * 60) +/*sec*/values[2])*1000) + values[3];
167 189
168 return ttime; 190 return ttime;
@@ -170,5 +192,5 @@ int64_t ExtratorSRT::str_to_time(string str_time) { @@ -170,5 +192,5 @@ int64_t ExtratorSRT::str_to_time(string str_time) {
170 } 192 }
171 193
172 uint64_t ExtratorSRT::calcula_pts(double msec) { 194 uint64_t ExtratorSRT::calcula_pts(double msec) {
173 - return (uint64_t)(1000 /*pcr_base*/ + ((msec/1000) * 90000.0)); 195 + return (uint64_t)msec;
174 } 196 }
extrator/src/extratorTXT.cpp
@@ -8,35 +8,22 @@ @@ -8,35 +8,22 @@
8 * Author: Erickson Silva (erickson.silva@lavid.ufpb.br) * 8 * Author: Erickson Silva (erickson.silva@lavid.ufpb.br) *
9 * * 9 * *
10 **************************************************************************/ 10 **************************************************************************/
11 - 11 +
12 #include "extratorTXT.h" 12 #include "extratorTXT.h"
13 13
14 ExtratorTXT::ExtratorTXT(){ 14 ExtratorTXT::ExtratorTXT(){
15 listeners = new list<ListenerTXT*>(); 15 listeners = new list<ListenerTXT*>();
16 finish = false; 16 finish = false;
17 - DPRINTF("Done!\n"); 17 + PRINTL(util::_DEBUG, "ExtratorTXT Done!\n");
18 } 18 }
19 19
20 -ExtratorTXT::~ExtratorTXT(){ 20 +ExtratorTXT::~ExtratorTXT(){
21 listeners->clear(); 21 listeners->clear();
22 delete listeners; 22 delete listeners;
23 delete file; 23 delete file;
24 delete file_io; 24 delete file_io;
25 delete bff_reader; 25 delete bff_reader;
26 - DDDPRINTF("ExtratorTXT finalized!\n");  
27 -}  
28 -  
29 -void ExtratorTXT::initialize(){  
30 - file = new lavidlib::File(filePath);  
31 - try{  
32 - file_io = new lavidlib::FileIO(file->getPath(), FileIO::MODE_READ);  
33 - bff_reader = new BufferedReader(file_io);  
34 - }catch(Exception &ex){  
35 - finish = true;  
36 - Util::Logger::Instance()->writeLog((char*) "[ERRO: extratorTXT.cpp] Arquivo de texto não encontrado.");  
37 - throw ExtratorException("Falha ao abrir o arquivo de texto! Verifique se o mesmo existe.");  
38 - }  
39 - this->Start(); 26 + PRINTL(util::_DEBUG, "ExtratorTXT finalized!\n");
40 } 27 }
41 28
42 void ExtratorTXT::addListener(ListenerTXT* listener){ 29 void ExtratorTXT::addListener(ListenerTXT* listener){
@@ -46,28 +33,44 @@ void ExtratorTXT::addListener(ListenerTXT* listener){ @@ -46,28 +33,44 @@ void ExtratorTXT::addListener(ListenerTXT* listener){
46 void ExtratorTXT::notifyListeners(unsigned char* line) { 33 void ExtratorTXT::notifyListeners(unsigned char* line) {
47 for(list<ListenerTXT*>::iterator it = listeners->begin(); it != listeners->end(); it++){ 34 for(list<ListenerTXT*>::iterator it = listeners->begin(); it != listeners->end(); it++){
48 (*it)->notifyLine(line); 35 (*it)->notifyLine(line);
49 - } 36 + }
50 } 37 }
51 38
52 void ExtratorTXT::notifyEndExtraction(int size) { 39 void ExtratorTXT::notifyEndExtraction(int size) {
53 - DPRINTF("ExtratorTXT concluiu a extração: %d linhas.\n", size); 40 + PRINTL(util::_DEBUG, "ExtratorTXT concluiu a extração: %d linhas.\n", size);
54 for(list<ListenerTXT*>::iterator it = listeners->begin(); it != listeners->end(); it++){ 41 for(list<ListenerTXT*>::iterator it = listeners->begin(); it != listeners->end(); it++){
55 (*it)->notifyEnd(size); 42 (*it)->notifyEnd(size);
56 } 43 }
57 } 44 }
58 45
  46 +void ExtratorTXT::encodingfiletoUTF8() {
  47 + string recmd = "recode ";
  48 + recmd.append("$(file --mime-encoding -b ")
  49 + .append(this->filePath).append(")..utf-8 ")
  50 + .append(this->filePath);
  51 + system(recmd.c_str());
  52 +
  53 + string sedcmd = "sed -i 's/\\r//' ";
  54 + sedcmd.append(this->filePath);
  55 + system(sedcmd.c_str());
  56 +}
  57 +
59 void ExtratorTXT::setFilePath(char* path){ 58 void ExtratorTXT::setFilePath(char* path){
60 - filePath = (char*) path;  
61 - string command1 = "perl -p -e 's/\r$//' < ";  
62 - command1.append(filePath).append(" > ").append(INPUT_TXT);  
63 - system(command1.c_str()); 59 + this->filePath = path;
  60 + encodingfiletoUTF8();
  61 +}
64 62
65 - string command2 = "iconv -f";  
66 - command2.append(" $(file --mime-encoding -b ")  
67 - .append(INPUT_TXT).append(")")  
68 - .append(" -t utf-8 ").append(INPUT_TXT).append(" > ").append(filePath)  
69 - .append(" && rm -f ").append(INPUT_TXT);  
70 - system(command2.c_str()); 63 +void ExtratorTXT::initialize(){
  64 + file = new lavidlib::File(filePath);
  65 + try{
  66 + file_io = new lavidlib::FileIO(file->getPath(), FileIO::MODE_READ);
  67 + bff_reader = new BufferedReader(file_io);
  68 + }catch(Exception &ex){
  69 + finish = true;
  70 + Logging::instance()->writeLog("extratorTXT.cpp <Error>: Arquivo de texto não encontrado.");
  71 + throw ExtratorException("Falha ao abrir o arquivo de texto! Verifique se o mesmo existe.");
  72 + }
  73 + this->Start();
71 } 74 }
72 75
73 bool ExtratorTXT::isFinished(){ 76 bool ExtratorTXT::isFinished(){
@@ -75,19 +78,16 @@ bool ExtratorTXT::isFinished(){ @@ -75,19 +78,16 @@ bool ExtratorTXT::isFinished(){
75 } 78 }
76 79
77 void ExtratorTXT::Run(){ 80 void ExtratorTXT::Run(){
78 -  
79 - DPRINTF("[AGUARDE] Extraindo Texto...\n")  
80 - 81 + PRINTL(util::_INFO, "Extraindo Texto...\n");
81 int line_index = 0; 82 int line_index = 0;
82 - bool hasNext = true; 83 + bool hasNext = true;
83 string line; 84 string line;
84 85
85 while (hasNext) { 86 while (hasNext) {
86 try{ 87 try{
87 line = bff_reader->readLine(); 88 line = bff_reader->readLine();
88 - if (line.length() > 0){ 89 + if (line.length() > 0){
89 notifyListeners((unsigned char*) line.c_str()); 90 notifyListeners((unsigned char*) line.c_str());
90 - //cout << " . ";  
91 line_index++; 91 line_index++;
92 } 92 }
93 }catch (EOFException &ex){ 93 }catch (EOFException &ex){
@@ -95,8 +95,8 @@ void ExtratorTXT::Run(){ @@ -95,8 +95,8 @@ void ExtratorTXT::Run(){
95 notifyListeners((unsigned char*)"ARQUIVO_INVALIDO"); 95 notifyListeners((unsigned char*)"ARQUIVO_INVALIDO");
96 hasNext = false; 96 hasNext = false;
97 }catch (...){ 97 }catch (...){
98 - Util::Logger::Instance()->writeLog((char*) "[ERRO: extratorTXT.cpp] Erro durante a leitura do arquivo de texto.");  
99 - throw ExtratorException("Falha desconhecida na leitura do arquivo. Tente novamente."); 98 + Logging::instance()->writeLog("extratorTXT.cpp <Error>: Erro durante a leitura do arquivo de texto.");
  99 + throw ExtratorException("Falha desconhecida na leitura do arquivo. Tente novamente.");
100 } 100 }
101 } 101 }
102 finish = true; 102 finish = true;
extrator/src/extratorVTT.cpp 0 → 100644
@@ -0,0 +1,171 @@ @@ -0,0 +1,171 @@
  1 +#include "extratorVTT.h"
  2 +
  3 +ExtratorVTT::ExtratorVTT() {
  4 + listeners = new list<ListenerSub*>();
  5 + seekPos = 0;
  6 + this->finish = false;
  7 + hasNextCue = true;
  8 + PRINTL(util::_DEBUG, "ExtratorVTT Done!\n");
  9 +}
  10 +
  11 +ExtratorVTT::~ExtratorVTT() {
  12 + listeners->clear();
  13 + delete listeners;
  14 + if (file_io) delete file_io;
  15 + PRINTL(util::_DEBUG, "ExtratorVTT finalized!\n");
  16 +}
  17 +
  18 +void ExtratorVTT::addListener(ListenerSub* listener){
  19 + listeners->push_back(listener);
  20 +}
  21 +
  22 +void ExtratorVTT::notifyListeners(unsigned char* subtitle, uint64_t pts) {
  23 + for(list<ListenerSub*>::iterator it = listeners->begin(); it != listeners->end(); it++){
  24 + (*it)->notifySubtitle(subtitle, pts);
  25 + }
  26 +}
  27 +
  28 +void ExtratorVTT::notifyEndExtraction(int size) {
  29 + PRINTL(util::_DEBUG, "Extrator webVTT concluiu a extração: %d legendas.\n", size);
  30 + for(list<ListenerSub*>::iterator it = listeners->begin(); it != listeners->end(); it++){
  31 + (*it)->notifyEnd(size);
  32 + }
  33 +}
  34 +
  35 +void ExtratorVTT::encodingfiletoUTF8() {
  36 + string recmd = "recode ";
  37 + recmd.append("$(file --mime-encoding -b ")
  38 + .append(this->filePath).append(")..utf-8 ")
  39 + .append(this->filePath);
  40 + system(recmd.c_str());
  41 +
  42 + string sedcmd = "sed -i 's/\r$//;$d' ";
  43 + sedcmd.append(this->filePath);
  44 + system(sedcmd.c_str());
  45 +}
  46 +
  47 +void ExtratorVTT::setFilePath(char* path) {
  48 + this->filePath = path;
  49 + encodingfiletoUTF8();
  50 +}
  51 +
  52 +void ExtratorVTT::initialize() {
  53 + file = new lavidlib::File(this->filePath);
  54 +
  55 + try{
  56 + file_io = new lavidlib::FileIO(file->getPath(), FileIO::MODE_READ);
  57 + }catch(Exception &ex){
  58 + finish = true;
  59 + Logging::instance()->writeLog("extratorVTT.cpp <Error>: Arquivo de legenda não encontrado.");
  60 + throw lavidlib::RuntimeException("Falha ao abrir o arquivo de legenda! Verifique se o mesmo existe.\n");
  61 + }
  62 + this->Start();
  63 +}
  64 +
  65 +bool ExtratorVTT::isFinished() {
  66 + return this->finish;
  67 +}
  68 +
  69 +Subtitle* ExtratorVTT::nextCue() {
  70 + string line;
  71 + string cueText = "";
  72 + int target_pos;
  73 + int64_t time_in;
  74 +
  75 + file_io->seek(seekPos);
  76 + try{
  77 + bff_reader = new BufferedReader(file_io);
  78 + }catch(Exception &ex){
  79 + Logging::instance()->writeLog("extratorSRT.cpp <Error>: BufferedReader não inicializado.");
  80 + throw lavidlib::RuntimeException("O BufferedReader não foi inicializado.");
  81 + }
  82 +
  83 + Subtitle* cue = new Subtitle();
  84 +
  85 + try{
  86 + do{
  87 + line = bff_reader->readLine();
  88 + seekPos += line.size() + SIZE_SCAPE;
  89 + }while(line.find(TARGET_TIME) == string::npos);
  90 +
  91 + target_pos = line.find(TARGET_TIME);
  92 + time_in = str_to_time(line.substr(0, target_pos));
  93 + cue->setTimeIn(time_in);
  94 +
  95 + while((line = bff_reader->readLine()) != ""){
  96 + cueText += line;
  97 + cueText += " ";
  98 + }
  99 +
  100 + }catch(lavidlib::EOFException &ex){
  101 + if(cueText == "")
  102 + cue->setTimeIn(0); //seta o valor 0 para nao gerar um valor aleatório
  103 +
  104 + cue->setSubtitleText(formatText(cueText));
  105 + seekPos += (int64_t) cueText.size() + SIZE_SCAPE;
  106 + hasNextCue =false;
  107 + delete(bff_reader);
  108 + return cue;
  109 + }
  110 +
  111 + cue->setSubtitleText(formatText(cueText));
  112 + seekPos += (int64_t) cueText.size() + SIZE_SCAPE;
  113 + delete(bff_reader);
  114 + return cue;
  115 +}
  116 +
  117 +string ExtratorVTT::formatText(string line){
  118 + int lessThanPos;
  119 + int moreThanPos;
  120 + string f_line = line;
  121 +
  122 + lessThanPos = f_line.find_first_of(LESS_THAN); //pega a posição do simbolo '<'
  123 + moreThanPos = f_line.find_first_of(MORE_THAN); //pega a posição do simbolo '>'
  124 +
  125 + while(lessThanPos != string::npos && moreThanPos != string::npos){
  126 + f_line = f_line.erase(lessThanPos, moreThanPos - (lessThanPos-1)); //remove o trecho '<string>'
  127 + lessThanPos = f_line.find_first_of(LESS_THAN);
  128 + moreThanPos = f_line.find_first_of(MORE_THAN);
  129 + }
  130 + return f_line;
  131 +}
  132 +
  133 +int64_t ExtratorVTT::str_to_time(string str_time) {
  134 + int64_t ttime = 0;
  135 + char* tokens = new char[4]; // hh, mm, ss, ms
  136 + strcpy(tokens, (char*)str_time.c_str());
  137 +
  138 + int index = 0;
  139 + int values [4]; // hh, mm, ss, ms
  140 + char * str = strtok(tokens, ":,.");
  141 + while (str != NULL) {
  142 + values[index] = atoi(str);
  143 + str = strtok(NULL, ":,.");
  144 + index++;
  145 + }
  146 + delete(tokens);
  147 +
  148 + /* calculate time */
  149 + ttime = /*hour to sec*/((((values[0] * 60) * 60) +
  150 + /*min to sec*/(values[1] * 60) +/*sec*/values[2])*1000) + values[3];
  151 +
  152 + return ttime;
  153 +}
  154 +
  155 +void ExtratorVTT::Run() {
  156 + PRINTL(util::_INFO, "Extraindo Legendas...\n");
  157 +
  158 + int sub_index = 0;
  159 + string cue_text = "";
  160 + while(hasNextCue){
  161 + subtitle = nextCue();
  162 + cue_text = subtitle->getSubtitleText();
  163 + notifyListeners((unsigned char*)cue_text.c_str(), (uint64_t) subtitle->getTimeIn());
  164 + sub_index++;
  165 + free(subtitle);
  166 + }
  167 + if(sub_index == 0)
  168 + notifyListeners((unsigned char*)"ARQUIVO_INVALIDO", 0);
  169 + this->finish = true;
  170 + notifyEndExtraction(sub_index);
  171 +}
extrator/src/include/extrator.h
  1 +/**
  2 + * \file extrator.h
  3 + *
  4 + * \author Wesnydy Lima Ribeiro <wesnydy@lavid.ufpb.br>
  5 + * \date 2015
  6 + */
  7 +
1 #ifndef EXTRATOR_H 8 #ifndef EXTRATOR_H
2 #define EXTRATOR_H 9 #define EXTRATOR_H
3 10
  11 +#include "logging.h"
4 #include <lavidlib/io/File.h> 12 #include <lavidlib/io/File.h>
5 #include <lavidlib/io/FileIO.h> 13 #include <lavidlib/io/FileIO.h>
6 #include <lavidlib/io/BufferedReader.h> 14 #include <lavidlib/io/BufferedReader.h>
7 #include <lavidlib/io/IOException.h> 15 #include <lavidlib/io/IOException.h>
8 #include <lavidlib/io/EOFException.h> 16 #include <lavidlib/io/EOFException.h>
9 17
  18 +using namespace util;
10 using namespace lavidlib; 19 using namespace lavidlib;
11 20
  21 +/** \brief A classe base para todos os extratores.
  22 + *
  23 + * \headerfile extrator/src/include/extrator.h
  24 + */
12 class Extrator { 25 class Extrator {
13 26
14 protected: 27 protected:
@@ -18,16 +31,33 @@ protected: @@ -18,16 +31,33 @@ protected:
18 File* file; 31 File* file;
19 FileIO* file_io; 32 FileIO* file_io;
20 BufferedReader* bff_reader; 33 BufferedReader* bff_reader;
21 - 34 +
22 public: 35 public:
23 - enum ExtratorType {  
24 - SRT,  
25 - TXT  
26 - }; 36 + enum ExtratorType {SRT, TXT, VTT};
  37 +
  38 + /** Notifica o fim da extração do conteúdo do arquivo.
  39 + *
  40 + * \param size Quantidade de conteúdo extraído.
  41 + */
27 virtual void notifyEndExtraction(int size) = 0; 42 virtual void notifyEndExtraction(int size) = 0;
  43 +
  44 + /** Define o path do arquivo de entrada.
  45 + *
  46 + * \param path O path do arquivo.
  47 + */
28 virtual void setFilePath(char* path) = 0; 48 virtual void setFilePath(char* path) = 0;
  49 +
  50 + /** Recodifica o arquivo para utf-8 */
  51 + virtual void encodingfiletoUTF8() = 0;
  52 +
  53 + /** Inicializa a extração do conteúdo. */
29 virtual void initialize() = 0; 54 virtual void initialize() = 0;
  55 +
  56 + /** Indica o fim do processo de extração.
  57 + *
  58 + * \return O status do do processo.
  59 + */
30 virtual bool isFinished() = 0; 60 virtual bool isFinished() = 0;
31 }; 61 };
32 62
33 -#endif /* EXTRATOR_H */  
34 \ No newline at end of file 63 \ No newline at end of file
  64 +#endif /* EXTRATOR_H */
extrator/src/include/extratorException.h
  1 +/**
  2 + * \file extratorException.h
  3 + */
  4 +
1 #ifndef EXTRATOREXCEPTION_H 5 #ifndef EXTRATOREXCEPTION_H
2 #define EXTRATOREXCEPTION_H 6 #define EXTRATOREXCEPTION_H
3 7
@@ -8,18 +12,7 @@ using namespace std; @@ -8,18 +12,7 @@ using namespace std;
8 12
9 class ExtratorException : public RuntimeException { 13 class ExtratorException : public RuntimeException {
10 public: 14 public:
11 - /**  
12 - * Construtor da classe.  
13 - * Cria uma nova exceção com uma mensagem detalhada.  
14 - * @param message A mensagem em forma de um objeto string.  
15 - */  
16 ExtratorException(const string message); 15 ExtratorException(const string message);
17 -  
18 - /**  
19 - * Construtor da classe.  
20 - * Cria uma nova exceção com uma mensagem detalhada.  
21 - * @param message A mensagem em forma de um array de caracteres.  
22 - */  
23 ExtratorException(const char* message); 16 ExtratorException(const char* message);
24 }; 17 };
25 18
extrator/src/include/extratorFactory.h
  1 +/**
  2 + * \file extratorFactory.h
  3 + *
  4 + * \author Wesnydy Lima Ribeiro <wesnydy@lavid.ufpb.br>
  5 + * \date 2015
  6 + */
1 #ifndef EXTRATORFACTORY_H 7 #ifndef EXTRATORFACTORY_H
2 #define EXTRATORFACTORY_H 8 #define EXTRATORFACTORY_H
3 9
4 #include "extrator.h" 10 #include "extrator.h"
5 #include "extratorSRT.h" 11 #include "extratorSRT.h"
6 #include "extratorTXT.h" 12 #include "extratorTXT.h"
  13 +#include "extratorVTT.h"
7 14
  15 +/** \brief Classe que implementa o factory pattern. */
8 class ExtratorFactory{ 16 class ExtratorFactory{
9 17
10 public: 18 public:
11 - ExtratorFactory();  
12 - ~ExtratorFactory(); 19 + /** Construtor */
  20 + ExtratorFactory(){};
13 21
  22 + /** Destrutor */
  23 + ~ExtratorFactory(){};
  24 +
  25 + /** Retorna uma referência para o tipo de extrator selecionado. */
14 Extrator* getExtrator(Extrator::ExtratorType extrator_type); 26 Extrator* getExtrator(Extrator::ExtratorType extrator_type);
15 27
16 private: 28 private:
extrator/src/include/extratorSRT.h
1 -/*  
2 - * File: extratorSRT.h  
3 - * Author: leonardo 1 +/**
  2 + * \file extratorSRT.h
4 * 3 *
5 - * Created on 17 de Fevereiro de 2012, 17:51 4 + * \author Leonardo de Araújo Domingues <leonardo.araujo@lavid.ufpb.br>
  5 + * \date 17/02/2012
6 */ 6 */
  7 +
7 #ifndef EXTRATORSRT_H 8 #ifndef EXTRATORSRT_H
8 #define EXTRATORSRT_H 9 #define EXTRATORSRT_H
9 10
10 #include <list> 11 #include <list>
11 #include <string.h> 12 #include <string.h>
12 #include <stdlib.h> 13 #include <stdlib.h>
13 -#include <fstream> 14 +#include <fstream>
14 #include <stdio.h> 15 #include <stdio.h>
15 #include "jthread.h" 16 #include "jthread.h"
16 -#include "dprintf.h"  
17 -#include "logger.h"  
18 #include "extrator.h" 17 #include "extrator.h"
19 #include "subtitle.h" 18 #include "subtitle.h"
20 -#include "listenerSRT.h" 19 +#include "listenerSub.h"
21 #include "extratorException.h" 20 #include "extratorException.h"
22 21
23 #define SIZE_CSCAPE 1 22 #define SIZE_CSCAPE 1
24 #define TARGET_TIME "-->" 23 #define TARGET_TIME "-->"
25 -#define INPUT_SRT "vlibras_user/inputSRT.srt" 24 +#define LESS_THAN "<"
  25 +#define MORE_THAN ">"
26 //#define MAX_LINE 1024 26 //#define MAX_LINE 1024
27 27
28 using namespace jthread; 28 using namespace jthread;
29 using namespace std; 29 using namespace std;
30 using namespace sndesc; 30 using namespace sndesc;
31 31
32 -/** Classe que modela ExtratorSRT.  
33 -* Instâncias do tipo ExtratorSRT são modelados  
34 -* a partir desta classe, esses objetos são  
35 -* responsáveis por extrair o conteudo de arquivos  
36 -* com a extensão SubRipText(SRT). 32 +/** \brief Classe que implementa o extrator de legenda.
  33 +*
  34 +* Instâncias desta classe extraem o conteúdo de
  35 +* arquivos SubRipText(SRT).
  36 +*
  37 +* \headerfile extrator/src/include/extratorSRT.h
37 */ 38 */
38 class ExtratorSRT: public Extrator, public Thread { 39 class ExtratorSRT: public Extrator, public Thread {
39 - 40 +
40 public: 41 public:
  42 + /** Construtor */
41 ExtratorSRT(); 43 ExtratorSRT();
  44 +
  45 + /** Destrutor */
42 ~ExtratorSRT(); 46 ~ExtratorSRT();
43 -  
44 - void addListener(ListenerSRT* listener); 47 +
  48 + /** Adiciona ouvintes do extratorSRT.
  49 + *
  50 + * \param listener O ouvinte a ser registrado.
  51 + */
  52 + void addListener(ListenerSub* listener);
  53 +
  54 + /** Notifica os ouvintes sobre novas extrações realizadas.
  55 + *
  56 + * \param subtitle A legenda extraída.
  57 + * \param pts Etiqueta de tempo (Presentation timestamp) da legenda.
  58 + */
45 void notifyListeners(unsigned char* subtitle, int64_t pts); 59 void notifyListeners(unsigned char* subtitle, int64_t pts);
  60 +
  61 + /** Notifica o fim da extração das legendas.
  62 + *
  63 + * \param size Quantidade de legendas extraídas.
  64 + */
46 void notifyEndExtraction(int size); 65 void notifyEndExtraction(int size);
47 66
  67 + /** Define o path do arquivo de entrada.
  68 + *
  69 + * \param path O path do arquivo.
  70 + */
48 void setFilePath(char* path); 71 void setFilePath(char* path);
  72 +
  73 + /** Inicializa o processo de extração da legendas.
  74 + *
  75 + * \exception ExtratorException caso o arquivo de legenda não seja encontrado.
  76 + */
49 void initialize(); 77 void initialize();
  78 +
  79 + /** Indica o fim do processo de extração das legendas.
  80 + *
  81 + * \return O status do do processo.
  82 + */
50 bool isFinished(); 83 bool isFinished();
51 - 84 +
  85 + /** Retorna o conteúdo da legenda extraída.
  86 + *
  87 + * \return Referência para um objeto Subtitle.
  88 + * \exception ExtratorException se ocorrer algum erro no processo de extração.
  89 + */
52 Subtitle* next(); 90 Subtitle* next();
  91 +
  92 + /** Indica se há legendas para serem extraídas do arquivo.
  93 + *
  94 + * \return True se houver legendas, caso contrário, retorna False.
  95 + */
53 bool hasNextSubtitle(); 96 bool hasNextSubtitle();
  97 +
  98 + /** Este método é chamado quando a Thread for iniciada. */
54 void Run(); 99 void Run();
55 - 100 +
56 private: 101 private:
57 - list<ListenerSRT*> *listeners; 102 + list<ListenerSub*> *listeners;
58 103
59 - Subtitle *subtitle; 104 + Subtitle *subtitle;
60 int64_t seek_pos; 105 int64_t seek_pos;
61 bool hasNextSub; 106 bool hasNextSub;
62 107
  108 + void encodingfiletoUTF8();
  109 + string formatText(string line);
63 uint64_t calcula_pts(double msec); 110 uint64_t calcula_pts(double msec);
64 - int64_t str_to_time(std::string str_time); 111 + int64_t str_to_time(std::string str_time);
65 }; 112 };
66 113
67 -#endif /* EXTRATORSRT_H */  
68 \ No newline at end of file 114 \ No newline at end of file
  115 +#endif /* EXTRATORSRT_H */
extrator/src/include/extratorTXT.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 extratorTXT.h
  3 + *
  4 + * \author Erickson Silva <erickson.silva@lavid.ufpb.br>
  5 + * \date 2014
  6 + */
11 7
12 #ifndef EXTRATORTXT_H 8 #ifndef EXTRATORTXT_H
13 #define EXTRATORTXT_H 9 #define EXTRATORTXT_H
14 10
15 #include <list> 11 #include <list>
16 #include "jthread.h" 12 #include "jthread.h"
17 -#include "dprintf.h"  
18 -#include "logger.h"  
19 #include "extrator.h" 13 #include "extrator.h"
20 #include "listenerTXT.h" 14 #include "listenerTXT.h"
21 #include "extratorException.h" 15 #include "extratorException.h"
22 16
23 -#define INPUT_TXT "vlibras_user/inputTXT.txt"  
24 -  
25 using namespace jthread; 17 using namespace jthread;
26 using namespace std; 18 using namespace std;
27 19
28 -/**  
29 -* Classe que modela o ExtratorTXT.  
30 -* O ExtratorTXT extrai o conteúdo  
31 -* de um arquivo txt. 20 +/** \brief Classe que implementa o extrator de texto.
  21 +*
  22 +* Instâncias desta classe extraem o conteúdo de
  23 +* arquivos txt.
  24 +*
  25 +* \headerfile extrator/src/include/extratorTXT.h
32 */ 26 */
33 class ExtratorTXT: public Extrator, public Thread { 27 class ExtratorTXT: public Extrator, public Thread {
34 - 28 +
35 public: 29 public:
  30 + /** Construtor */
36 ExtratorTXT(); 31 ExtratorTXT();
  32 +
  33 + /** Destrutor */
37 ~ExtratorTXT(); 34 ~ExtratorTXT();
38 35
  36 + /** Adiciona ouvintes do extratorTXT.
  37 + *
  38 + * \param listener O ouvinte a ser registrado.
  39 + */
39 void addListener(ListenerTXT* listener); 40 void addListener(ListenerTXT* listener);
  41 +
  42 + /** Notifica os ouvintes sobre novas extrações realizadas.
  43 + *
  44 + * \param line A linha extraída.
  45 + */
40 void notifyListeners(unsigned char* line); 46 void notifyListeners(unsigned char* line);
  47 +
  48 + /** Notifica o fim da extração do texto.
  49 + *
  50 + * \param size Quantidade de linhas extraídas.
  51 + */
41 void notifyEndExtraction(int size); 52 void notifyEndExtraction(int size);
42 53
  54 + /** Define o path do arquivo de entrada.
  55 + *
  56 + * \param path O path do arquivo.
  57 + */
43 void setFilePath(char* path); 58 void setFilePath(char* path);
  59 +
  60 + /** Inicializa o processo de extração do texto.
  61 + *
  62 + * \exception ExtratorException caso o arquivo de texto não seja encontrado.
  63 + */
44 void initialize(); 64 void initialize();
  65 +
  66 + /** Indica o fim do processo de extração do texto.
  67 + *
  68 + * \return O status do do processo.
  69 + */
45 bool isFinished(); 70 bool isFinished();
46 - 71 +
  72 + /** Este método é chamado quando a Thread for iniciada. */
47 void Run(); 73 void Run();
48 74
49 private: 75 private:
50 - list<ListenerTXT*> *listeners; 76 + list<ListenerTXT*> *listeners;
  77 + void encodingfiletoUTF8();
51 }; 78 };
52 79
53 #endif /* EXTRATORTXT_H */ 80 #endif /* EXTRATORTXT_H */
54 -  
extrator/src/include/extratorVTT.h 0 → 100644
@@ -0,0 +1,90 @@ @@ -0,0 +1,90 @@
  1 +/**
  2 + * \file extratorVTT.h
  3 + *
  4 + * \author Wesnydy Ribeiro <wesnydy@lavid.ufpb.br>
  5 + * \date 2015
  6 + */
  7 +
  8 +#ifndef EXTRATORVTT_H
  9 +#define EXTRATORVTT_H
  10 +
  11 +#include <list>
  12 +#include <string.h>
  13 +#include <stdlib.h>
  14 +#include <stdio.h>
  15 +#include "jthread.h"
  16 +#include "extrator.h"
  17 +#include "subtitle.h"
  18 +#include "listenerSub.h"
  19 +#include <iostream>
  20 +
  21 +#define SIGNATURE "WEBVTT"
  22 +#define TARGET_TIME "-->"
  23 +#define LESS_THAN "<"
  24 +#define MORE_THAN ">"
  25 +#define SIZE_SCAPE 1
  26 +
  27 +using namespace std;
  28 +using namespace sndesc;
  29 +using namespace jthread;
  30 +
  31 +/** \brief Classe que implementa o extrator de legenda.
  32 +*
  33 +* Instâncias desta classe extraem o conteúdo de
  34 +* arquivos webVTT.
  35 +*
  36 +* \headerfile extrator/src/include/extratorVTT.h
  37 +*/
  38 +class ExtratorVTT: public Extrator, public Thread {
  39 +
  40 +public:
  41 + /** Construtor */
  42 + ExtratorVTT();
  43 +
  44 + /** Destrutor */
  45 + ~ExtratorVTT();
  46 +
  47 + /** Define o path do arquivo de entrada.
  48 + *
  49 + * \param path O path do arquivo.
  50 + */
  51 + void setFilePath(char* path);
  52 +
  53 + /** Adiciona ouvintes do extratorVTT.
  54 + *
  55 + * \param listener O ouvinte a ser registrado.
  56 + */
  57 + void addListener(ListenerSub* listener);
  58 +
  59 + /** Inicializa o processo de extração da legendas.
  60 + *
  61 + * \exception ExtratorException caso o arquivo de legenda não seja encontrado.
  62 + */
  63 + void initialize();
  64 +
  65 + /** Indica o fim do processo de extração das legendas.
  66 + *
  67 + * \return O status do do processo.
  68 + */
  69 + bool isFinished();
  70 +
  71 + /** Este método é chamado quando a Thread for iniciada. */
  72 + void Run();
  73 +
  74 +private:
  75 + Subtitle* subtitle;
  76 + list<ListenerSub*> *listeners;
  77 +
  78 + int64_t seekPos;
  79 + bool hasNextCue;
  80 +
  81 + void notifyEndExtraction(int size);
  82 + void notifyListeners(unsigned char* subtitle, uint64_t pts);
  83 +
  84 + Subtitle* nextCue();
  85 + void encodingfiletoUTF8();
  86 + string formatText(string line);
  87 + int64_t str_to_time(string str_time);
  88 +};
  89 +
  90 +#endif /* EXTRATORVTT_H */
extrator/src/include/listenerSRT.h
@@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
1 -#ifndef LISTENERSRT_H  
2 -#define LISTENERSRT_H  
3 -  
4 -#include <stdint.h>  
5 -  
6 -class ListenerSRT{  
7 -  
8 -public:  
9 - virtual void notifySubtitle(unsigned char* subtitle, int64_t pts) = 0;  
10 - virtual void notifyEnd(int sub_size) = 0;  
11 -};  
12 -  
13 -#endif /* LISTENEREXTRATOR_H */  
14 \ No newline at end of file 0 \ No newline at end of file
extrator/src/include/listenerSub.h 0 → 100644
@@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
  1 +/**
  2 + * \file listenerSRT.h
  3 + */
  4 +
  5 +#ifndef LISTENERSUB_H
  6 +#define LISTENERSUB_H
  7 +
  8 +#include <stdint.h>
  9 +
  10 +class ListenerSub{
  11 +
  12 +public:
  13 + virtual void notifySubtitle(unsigned char* subtitle, uint64_t pts) = 0;
  14 + virtual void notifyEnd(int sub_size) = 0;
  15 +};
  16 +
  17 +#endif /* LISTENERSUB_H */
0 \ No newline at end of file 18 \ No newline at end of file
extrator/src/include/listenerTXT.h
  1 +/**
  2 + * \file listenerTXT.h
  3 + */
  4 +
1 #ifndef LISTENERTXT_H 5 #ifndef LISTENERTXT_H
2 #define LISTENERTXT_H 6 #define LISTENERTXT_H
3 7
extrator/src/include/subtitle.h
1 -/***************************************************************************  
2 - * Universidade Federal da Paraíba *  
3 - * Copyright (C) 2013 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: Leonardo de Araújo Domingues (leonardo.araujo@lavid.ufpb.br) *  
9 - * Date: Qui Out 24 22:26:35 BRT 2013 *  
10 - * *  
11 - **************************************************************************/ 1 +/**
  2 + * \file subtitle.h
  3 + *
  4 + * \author Leonardo de Araújo Domingues <leonardo.araujo@lavid.ufpb.br>
  5 + * \date 24/10/2015
  6 + */
12 7
13 #ifndef SUBTITLE_H 8 #ifndef SUBTITLE_H
14 #define SUBTITLE_H 9 #define SUBTITLE_H
@@ -23,115 +18,90 @@ @@ -23,115 +18,90 @@
23 18
24 namespace sndesc { 19 namespace sndesc {
25 20
26 - /**  
27 - * Classe que modela legendas.  
28 - * Objetos com informações de legendas  
29 - * são implementados através desta classe.  
30 - */ 21 + /** \brief Representação abstrata de legendas.
  22 + *
  23 + * Objetos com informações de legendas
  24 + * são implementados através desta classe.
  25 + * \headerfile extrator/src/include/subtitle.h
  26 + */
31 class Subtitle { 27 class Subtitle {
32 28
33 public: 29 public:
34 - /**  
35 - * Construtor da classe.  
36 - * Cria uma nova instância da classe para  
37 - * representar uma legenda, as variáveis  
38 - * iniciam com valores default.  
39 - */ 30 + /** Construtor */
40 Subtitle(); 31 Subtitle();
41 32
42 - /**  
43 - * Construtor da clasee.  
44 - * Cria uma nova instância da classe para a representar uma legenda,  
45 - * as variáveis iniciam com valores passados por parametros.  
46 - * @param _id O numero da legenda.  
47 - * @param _sub_text O texto da legenda.  
48 - * @param _timein O tempo de inicio da legenda.  
49 - * @param _timeout O tempo de termino da legenda. 33 + /** Construtor.
  34 + *
  35 + * \param _id Número da legenda.
  36 + * \param _sub_text Texto da legenda.
  37 + * \param _timein Tempo de inicio da legenda.
  38 + * \param _timeout Tempo de termino da legenda.
50 */ 39 */
51 Subtitle(int _id, string _sub_text, int64_t _timein, int64_t _timeout); 40 Subtitle(int _id, string _sub_text, int64_t _timein, int64_t _timeout);
52 41
53 - /**  
54 - * Destrutor da classe.  
55 - * Desaloca todo espaço de armazenamento atribuído  
56 - * para a instância do Subtitle.  
57 - */ 42 + /** Destrutor */
58 ~Subtitle(); 43 ~Subtitle();
59 44
60 - /**  
61 - * Seta o id da legenda.  
62 - * @param _id O numero da legenda. 45 + /** Seta o id da legenda.
  46 + *
  47 + * \param _id O numero da legenda.
63 */ 48 */
64 void setID(int _id); 49 void setID(int _id);
65 50
66 - /**  
67 - * Seta o texto da legenda.  
68 - * @param _subtext O texto da legenda. 51 + /** Seta o texto da legenda.
  52 + *
  53 + * \param _subtext O texto da legenda.
69 */ 54 */
70 void setSubtitleText(std::string _subtext); 55 void setSubtitleText(std::string _subtext);
71 56
72 - /**  
73 - * Seta o tempo de inicio da legenda.  
74 - * @param _timein O tempo de entrada da legenda. 57 + /** Seta o tempo de inicio da legenda.
  58 + *
  59 + * \param _timein O tempo de entrada da legenda.
75 */ 60 */
76 void setTimeIn(int64_t _timein); 61 void setTimeIn(int64_t _timein);
77 62
78 - /**  
79 - * Seta o tempo de termino da legenda.  
80 - * @param _timeout O tempo de saida da legenda. 63 + /** Seta o tempo de termino da legenda.
  64 + *
  65 + * \param _timeout O tempo de saida da legenda.
81 */ 66 */
82 void setTimeOut(int64_t _timeout); 67 void setTimeOut(int64_t _timeout);
83 68
84 - /**  
85 - * Obtém o texto da legenda.  
86 - * @return O texto da legenda. 69 + /** Obtém o texto da legenda.
  70 + *
  71 + * \return O texto da legenda.
87 */ 72 */
88 std::string getSubtitleText(); 73 std::string getSubtitleText();
89 74
90 - /**  
91 - * Obtém o tempo de inicio da legenda.  
92 - * @return O tempo de inicio. 75 + /** Obtém o tempo de inicio da legenda.
  76 + *
  77 + * \return O tempo de inicio.
93 */ 78 */
94 int64_t getTimeIn(); 79 int64_t getTimeIn();
95 80
96 - /**  
97 - * Obtém o tempo de termino da legenda.  
98 - * @return O tempo de saida. 81 + /** Obtém o tempo de termino da legenda.
  82 + *
  83 + * \return O tempo de termino.
99 */ 84 */
100 int64_t getTimeOut(); 85 int64_t getTimeOut();
101 86
102 - /**  
103 - * Obtém o id da legenda.  
104 - * @return O numero da legenda. 87 + /** Obtém o id da legenda.
  88 + *
  89 + * \return O numero da legenda.
105 */ 90 */
106 int getID(); 91 int getID();
107 92
108 - /**  
109 - * Converte os dados de uma legenda em uma string.  
110 - * @return Uma string com a representação da legenda. 93 + /** Converte os dados de uma legenda em uma string.
  94 + *
  95 + * \return Uma string com a representação da legenda.
111 */ 96 */
112 string toString(); 97 string toString();
113 98
114 private: 99 private:
115 - /**  
116 - * O numero da legenda.  
117 - */  
118 - int id;  
119 -  
120 - /**  
121 - * O texto da legenda.  
122 - */  
123 - string subtitle_text;  
124 100
125 - /**  
126 - * O tempo de entrada da legenda.  
127 - */ 101 + int id;
128 int64_t time_in; 102 int64_t time_in;
129 -  
130 - /**  
131 - * O tempo de saida da legenda.  
132 - */  
133 int64_t time_out; 103 int64_t time_out;
134 - 104 + string subtitle_text;
135 }; 105 };
136 } 106 }
137 107
input/src/include/inputException.h
@@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
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 - **************************************************************************/  
11 -  
12 - #ifndef INPUTEXCEPTION_H  
13 - #define INPUTEXCEPTION_H  
14 -  
15 - #include <lavidlib/base/RuntimeException.h>  
16 -  
17 - using namespace lavidlib;  
18 -  
19 - class InputException : public RuntimeException {  
20 - public:  
21 - InputException(const std::string message);  
22 - InputException(const char* message);  
23 - };  
24 -  
25 -  
26 - #endif /* INPUTEXCEPTION_H */  
27 \ No newline at end of file 0 \ No newline at end of file
input/src/include/inputFile.h
@@ -1,46 +0,0 @@ @@ -1,46 +0,0 @@
1 -/*  
2 - * File: fileInput.h  
3 - * Author: leonardo  
4 - *  
5 - * Created on 6 de Janeiro de 2012, 11:11  
6 - */  
7 -  
8 -#ifndef INPUTFILE_H  
9 -#define INPUTFILE_H  
10 -  
11 -#include <stdio.h>  
12 -#include <list>  
13 -#include <stdlib.h>  
14 -#include <fstream>  
15 -#include <string.h>  
16 -#include "logger.h"  
17 -#include "listenerInput.h"  
18 -#include "inputException.h"  
19 -#include "dprintf.h"  
20 -  
21 -#define MAX_SIZE_PACKET 188  
22 -  
23 -using namespace std;  
24 -  
25 -class InputFile {  
26 -  
27 -public:  
28 - InputFile(char* path);  
29 - ~InputFile();  
30 - void initialize();  
31 - void addListener(ListenerInput* listener);  
32 - void removeListener(ListenerInput* listener);  
33 - void notifyListeners(unsigned char* pack);  
34 - bool isFinished();  
35 -  
36 - //void notificaQuantidadeGlosas(int quantidade);  
37 -  
38 -private:  
39 - list<ListenerInput*> *listeners;  
40 - char *path;  
41 - bool finish;  
42 -  
43 -};  
44 -  
45 -#endif /* INPUTFILE_H */  
46 -  
input/src/include/listenerInput.h
@@ -1,19 +0,0 @@ @@ -1,19 +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 _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/inputException.cpp
@@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
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 - **************************************************************************/  
11 -  
12 - #include "inputException.h"  
13 -  
14 - InputException::InputException(const std::string message)  
15 - : RuntimeException(message)  
16 - { /* TODO */ }  
17 - InputException::InputException(const char* message)  
18 - : RuntimeException(message)  
19 - { /* TODO */ }  
20 -  
21 \ No newline at end of file 0 \ No newline at end of file
input/src/inputFile.cpp
@@ -1,59 +0,0 @@ @@ -1,59 +0,0 @@
1 -  
2 -#include "inputFile.h"  
3 -  
4 -InputFile::InputFile(char* path) {  
5 - this->path = path;  
6 - this->listeners = new list<ListenerInput*>();  
7 - finish = false;  
8 - DPRINTF("Done!\n");  
9 -}  
10 -  
11 -InputFile::~InputFile(){  
12 - listeners->clear();  
13 - delete listeners;  
14 - DDDPRINTF("Input finalized!\n");  
15 -}  
16 -  
17 -void InputFile::initialize(){  
18 - ifstream filein(path, ifstream::binary);  
19 -  
20 - if (strstr(path, ".ts") != NULL) {  
21 - if (filein.is_open()) {  
22 - char buffer [MAX_SIZE_PACKET];  
23 - DPRINTF("[AGUARDE] Lendo arquivo...\n")  
24 - while (!filein.eof()) {  
25 - filein.read(buffer, MAX_SIZE_PACKET);  
26 - unsigned char* packet = (unsigned char*) buffer;  
27 - notifyListeners(packet);  
28 - }  
29 - printf("\n");  
30 - filein.close();  
31 - //finished = true;  
32 - } else {  
33 - finish = true;  
34 - Util::Logger::Instance()->writeLog((char*) "[ERRO: inputFile.cpp] Arquivo de vídeo não encontrado.");  
35 - throw InputException("Falha ao abrir o arquivo de vídeo! Verifique se o mesmo existe.");  
36 - }  
37 - }  
38 - finish = true;  
39 -  
40 -}  
41 -  
42 -bool InputFile::isFinished(){  
43 - return this->finish;  
44 -}  
45 -  
46 -void InputFile::addListener(ListenerInput* listener){  
47 - this->listeners->push_back(listener);  
48 -}  
49 -  
50 -void InputFile::removeListener(ListenerInput* listener) {  
51 - this->listeners->remove(listener);  
52 -}  
53 -  
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);  
57 - }  
58 -}  
59 -  
@@ -11,95 +11,154 @@ @@ -11,95 +11,154 @@
11 * 11 *
12 * Edit on 03 de Fevereiro de 2014 12 * Edit on 03 de Fevereiro de 2014
13 */ 13 */
14 -#include "serviceWindowGenerationFromSRT.h" 14 +#include <stdlib.h>
  15 +#include <string.h>
  16 +#include <sys/time.h>
  17 +#include "logging.h"
  18 +#include "argParser.h"
  19 +#include "serviceTester.h"
  20 +#include "serviceException.h"
  21 +#include "serviceWindowGenerationFromSubtitle.h"
15 #include "serviceWindowGenerationFromRec.h" 22 #include "serviceWindowGenerationFromRec.h"
16 #include "serviceWindowGenerationFromText.h" 23 #include "serviceWindowGenerationFromText.h"
17 -#include "serviceException.h"  
18 -#include <sys/time.h>  
19 -#include <stdlib.h> 24 +#include <lavidlib/base/RuntimeException.h>
  25 +
  26 +#define MAX_SIZE_PATH 256
  27 +#define PATH_VBOX_UPLOADS "vlibras_user/.vlibras-config/uploads"
  28 +#define PATH_DEVEL_CONTENTS "vlibras_user/vlibras-contents/videos"
  29 +#define PATH_DEVEL_UPLOADS "vlibras_user/vlibras-contents/uploads"
20 30
21 using namespace std; 31 using namespace std;
  32 +using namespace util;
22 33
23 -void serviceSRT(char* service, char* path_video, char* path_srt, char* sublanguage, char* position, char* size, char* transparency, char* id, char* client_type);  
24 -void serviceOnlySRT(char* service, char* path_file, char* transparency, char* username, char* client_type);  
25 -//void serviceREC(char* path_video, char* sublanguage, char* position, char* size, char* transparency, char* username, char* rate);  
26 -void serviceREC(char* service, char* path_video, char* sublanguage, char* position, char* size, char* transparency, char* id, char* client_type);  
27 -//void serviceOnlyAudio(char* path_audio, char* transparency, char* username, char* rate);  
28 -void serviceOnlyAudio(char* service, char* path_audio, char* transparency, char* id, char* client_type);  
29 -void serviceText(char* service, char* path_text, char* transparency, char* id, char* client_type); 34 +void serviceSRT(int service, string path_video, string path_srt, int language, int position, int size, int background, string id, int mode);
  35 +void serviceREC(int service, string path_video, int position, int size, int background, string id, int mode);
  36 +void serviceOnlySRT(int service, string path_srt, int language, int background, string id, int mode);
  37 +void serviceOnlyAudio(int service, string path_audio, int background, string id, int mode);
  38 +void serviceText(string path_text, int language, int background, string id, int mode);
  39 +void serviceRECWithoutMixing(int service, string path_video, int background, string id, int mode);
  40 +void serviceTest(int position, int size, int background);
30 41
31 void help(); 42 void help();
32 -void serviceHelp(int service);  
33 -void fail(string msg);  
34 void hasFailed(); 43 void hasFailed();
35 void hasInvalid(); 44 void hasInvalid();
  45 +void fail(string msg);
  46 +void setPathContents(int mode, string id);
36 47
37 bool isFailed; 48 bool isFailed;
38 bool isInvalid; 49 bool isInvalid;
39 50
40 int main(int argc, char* argv[]) { 51 int main(int argc, char* argv[]) {
41 52
  53 + int service;
  54 + int language;
  55 + int position;
  56 + int size;
  57 + int background;
  58 + int mode;
  59 + int nomixer;
  60 +
  61 + string input;
  62 + string input_srt;
  63 + string id;
  64 +
  65 + ArgParser *parser;
  66 +
42 struct timeval tv1, tv2; 67 struct timeval tv1, tv2;
43 double t1, t2; 68 double t1, t2;
44 69
45 gettimeofday(&tv1, NULL); 70 gettimeofday(&tv1, NULL);
46 t1 = (double)(tv1.tv_sec) + (double)(tv1.tv_usec)/ 1000000.00; 71 t1 = (double)(tv1.tv_sec) + (double)(tv1.tv_usec)/ 1000000.00;
47 -  
48 - if(argc > 2) {  
49 - printf("\n################## VLIBRAS : LAVID ##################\n\n");  
50 - DDPRINTF("Service Type: %s\n", argv[1]);  
51 - switch((int) atoi(argv[1])){  
52 - case 1:  
53 - if(argc <= 9){  
54 - serviceHelp(1);  
55 - hasInvalid();  
56 - }else{  
57 - serviceSRT(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9]);  
58 - }  
59 - break;  
60 - case 2:  
61 - if(argc <= 8){  
62 - serviceHelp(2);  
63 - hasInvalid();  
64 - }else{  
65 - serviceREC(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8]);  
66 - }  
67 - break;  
68 - case 3:  
69 - if(argc <= 5){  
70 - serviceHelp(3);  
71 - hasInvalid();  
72 - }else{  
73 - serviceText(argv[1], argv[2], argv[3], argv[4], argv[5]);  
74 - }  
75 - break;  
76 - case 4:  
77 - if(argc <= 5){  
78 - serviceHelp(4);  
79 - hasInvalid();  
80 - }else{  
81 - serviceOnlySRT(argv[1], argv[2], argv[3], argv[4], argv[5]);  
82 - }  
83 - break;  
84 - case 5:  
85 - if(argc <= 5){  
86 - serviceHelp(5);  
87 - hasInvalid();  
88 - }else{  
89 - serviceOnlyAudio(argv[1], argv[2], argv[3], argv[4], argv[5]);  
90 - }  
91 - break;  
92 - default:  
93 - cout << "\nFAIL VLibras: Serviço inválido! Tente --help" << endl;  
94 - hasInvalid();  
95 - break;  
96 - }  
97 - }else if(argc == 2 && (strcmp(argv[1], "--help")) == 0){  
98 - help();  
99 - exit(0);  
100 - }else{  
101 - cout << "\nFAIL VLibras: Tente --help para obter informações.\n" << endl;  
102 - hasInvalid(); 72 +
  73 + parser = new ArgParser();
  74 + try{
  75 + parser->readArgs(argv, argc);
  76 + }catch(lavidlib::RuntimeException &ex){
  77 + exit(1);
  78 + }
  79 +
  80 + //printf("\n################## LAViD : VLibras ##################\n\n");
  81 +
  82 + service = parser->getService();
  83 + util::Logging::instance()->setLevel(parser->getLog());
  84 +
  85 + switch(service){
  86 + case 1:
  87 + PRINTL(util::_INFO, "Service Type: Video with Subtitles\n");
  88 + input = parser->getInput();
  89 + input_srt = parser->getInputSRT();
  90 + language = parser->getLanguage();
  91 + position = parser->getPosition();
  92 + size = parser->getSize();
  93 + background = parser->getBackground();
  94 + id = parser->getId();
  95 + mode = parser->getMode();
  96 + serviceSRT(service, input, input_srt, language, position, size, background, id, mode);
  97 + break;
  98 +
  99 + case 2:
  100 + PRINTL(util::_INFO, "Service Type: Video Recognize\n");
  101 + input = parser->getInput();
  102 + position = parser->getPosition();
  103 + size = parser->getSize();
  104 + background = parser->getBackground();
  105 + id = parser->getId();
  106 + mode = parser->getMode();
  107 + serviceREC(service, input, position, size, background, id, mode);
  108 + break;
  109 +
  110 + case 3:
  111 + PRINTL(util::_INFO, "Service Type: Text\n");
  112 + input = parser->getInput();
  113 + language = parser->getLanguage();
  114 + background = parser->getBackground();
  115 + id = parser->getId();
  116 + mode = parser->getMode();
  117 + serviceText(input, language, background, id, mode);
  118 + break;
  119 +
  120 + case 4:
  121 + PRINTL(util::_INFO, "Service Type: Subtitles only\n");
  122 + input = parser->getInput();
  123 + language = parser->getLanguage();
  124 + background = parser->getBackground();
  125 + id = parser->getId();
  126 + mode = parser->getMode();
  127 + serviceOnlySRT(service, input, language, background, id, mode);
  128 + break;
  129 +
  130 + case 5: //reconhecimento de audio
  131 + PRINTL(util::_INFO, "Service Type: Audio Recognize\n");
  132 + input = parser->getInput();
  133 + background = parser->getBackground();
  134 + id = parser->getId();
  135 + mode = parser->getMode();
  136 + serviceREC(service, input, 0, 0, background, id, mode);
  137 + break;
  138 +
  139 + case 6: //Reconhecimento de video sem mixagem
  140 + PRINTL(util::_INFO, "Service Type: Video Recognize (Mixer Disabled)\n");
  141 + input = parser->getInput();
  142 + background = parser->getBackground();
  143 + id = parser->getId();
  144 + mode = parser->getMode();
  145 + serviceREC(service, input, 0, 0, background, id, mode);//como service != 2 então não há mixagem
  146 + break;
  147 +
  148 + case 7: // serviço de teste
  149 + position = parser->getPosition();
  150 + size = parser->getSize();
  151 + background = parser->getBackground();
  152 + serviceTest(position, size, background);
  153 + break;
  154 +
  155 + case 8: //ajuda
  156 + help();
  157 + break;
  158 +
  159 + default:
  160 + PRINTL(util::_ERROR, "Opção de serviço não reconhecida!\n");
  161 + hasInvalid();
103 } 162 }
104 163
105 if(isFailed) 164 if(isFailed)
@@ -109,17 +168,24 @@ int main(int argc, char* argv[]) { @@ -109,17 +168,24 @@ int main(int argc, char* argv[]) {
109 168
110 gettimeofday(&tv2, NULL); 169 gettimeofday(&tv2, NULL);
111 t2 = (double)(tv2.tv_sec) + (double)(tv2.tv_usec)/ 1000000.00; 170 t2 = (double)(tv2.tv_sec) + (double)(tv2.tv_usec)/ 1000000.00;
112 - DDPRINTF("Time: %lf\n", (t2-t1));  
113 - DDPRINTF("VLibras finalized!\n\n"); 171 + PRINTL(util::_DEBUG, "Time: %lf\n", (t2-t1));
  172 + PRINTL(util::_INFO, "VLibras finalized!\n\n");
114 exit(0); 173 exit(0);
115 } 174 }
116 175
117 -void serviceSRT(char* service, char* path_video, char* path_srt, char* sublanguage, char* position,  
118 - char* size, char* transparency, char* id, char* client_type){ 176 +void serviceSRT(int service, string path_video, string path_srt, int language, int position, int size, int background, string id, int mode){
  177 + char* video = new char[MAX_SIZE_PATH];
  178 + char* srt = new char[MAX_SIZE_PATH];
  179 + char* name = new char[id.size()];
  180 +
  181 + strcpy(video, path_video.c_str());
  182 + strcpy(srt, path_srt.c_str());
  183 + strcpy(name, id.c_str());
119 184
120 - ServiceWindowGenerationFromSRT * service_srt;  
121 - service_srt = new ServiceWindowGenerationFromSRT(path_video, path_srt, (int) atoi(sublanguage),  
122 - (int) atoi(position), (int) atoi(size), (int) atoi(transparency), id, client_type, (int) atoi(service)); 185 + setPathContents(mode, id);
  186 +
  187 + ServiceWindowGenerationFromSubtitle* service_srt;
  188 + service_srt = new ServiceWindowGenerationFromSubtitle(video, srt, language, position, size, background, name, mode, service);
123 189
124 try{ 190 try{
125 service_srt->initialize(); 191 service_srt->initialize();
@@ -131,16 +197,24 @@ void serviceSRT(char* service, char* path_video, char* path_srt, char* sublangua @@ -131,16 +197,24 @@ void serviceSRT(char* service, char* path_video, char* path_srt, char* sublangua
131 while(!service_srt->isFinished()){ 197 while(!service_srt->isFinished()){
132 sleep(5); 198 sleep(5);
133 } 199 }
134 - 200 +
  201 + delete [] video;
  202 + delete [] srt;
  203 + delete [] name;
135 delete service_srt; 204 delete service_srt;
136 } 205 }
137 206
138 -void serviceREC(char* service, char* path_video, char* sublanguage, char* position, char* size,  
139 - char* transparency, char* id, char* client_type){ 207 +void serviceREC(int service, string path_video, int position, int size, int background, string id, int mode){
  208 + char* video = new char[MAX_SIZE_PATH];
  209 + char* name = new char[id.size()];
  210 +
  211 + strcpy(video, path_video.c_str());
  212 + strcpy(name, id.c_str());
140 213
141 - ServiceWindowGenerationFromRec * service_rec;  
142 - service_rec = new ServiceWindowGenerationFromRec(path_video, (int) atoi(sublanguage),  
143 - (int) atoi(position), (int) atoi(size), (int) atoi(transparency), id, client_type, (int) atoi(service)); 214 + setPathContents(mode, id);
  215 +
  216 + ServiceWindowGenerationFromRec* service_rec;
  217 + service_rec = new ServiceWindowGenerationFromRec(video, position, size, background, name, mode, service);
144 218
145 try{ 219 try{
146 service_rec->initialize(); 220 service_rec->initialize();
@@ -150,15 +224,25 @@ void serviceREC(char* service, char* path_video, char* sublanguage, char* positi @@ -150,15 +224,25 @@ void serviceREC(char* service, char* path_video, char* sublanguage, char* positi
150 return; 224 return;
151 } 225 }
152 while(!service_rec->isFinished()){ 226 while(!service_rec->isFinished()){
153 - sleep(2); 227 + sleep(5);
154 } 228 }
  229 +
  230 + delete [] video;
  231 + delete [] name;
155 delete service_rec; 232 delete service_rec;
156 } 233 }
157 234
158 -void serviceText(char* service, char* path_text, char* transparency, char* id, char* client_type){ 235 +void serviceText(string path_text, int language, int background, string id, int mode){
  236 + char* text = new char[MAX_SIZE_PATH];
  237 + char* name = new char[id.size()];
  238 +
  239 + strcpy(text, path_text.c_str());
  240 + strcpy(name, id.c_str());
159 241
160 - ServiceWindowGenerationFromText *service_text;  
161 - service_text = new ServiceWindowGenerationFromText(path_text, (int) atoi(transparency), id, client_type); 242 + setPathContents(mode, id);
  243 +
  244 + ServiceWindowGenerationFromText* service_text;
  245 + service_text = new ServiceWindowGenerationFromText(text, language, background, name, mode);
162 246
163 try{ 247 try{
164 service_text->initialize(); 248 service_text->initialize();
@@ -171,12 +255,23 @@ void serviceText(char* service, char* path_text, char* transparency, char* id, c @@ -171,12 +255,23 @@ void serviceText(char* service, char* path_text, char* transparency, char* id, c
171 while (!service_text->isFinished()) { 255 while (!service_text->isFinished()) {
172 usleep(100000); //100ms 256 usleep(100000); //100ms
173 } 257 }
  258 +
  259 + delete [] text;
  260 + delete [] name;
174 delete service_text; 261 delete service_text;
175 } 262 }
176 263
177 -void serviceOnlySRT(char* service, char* path_file, char* transparency, char* id, char* client_type){  
178 - ServiceWindowGenerationFromSRT * service_srt;  
179 - service_srt = new ServiceWindowGenerationFromSRT(path_file, (int) atoi(transparency), id, client_type, (int) atoi(service)); 264 +void serviceOnlySRT(int service, string path_srt, int language, int background, string id, int mode){
  265 + char* srt = new char[MAX_SIZE_PATH];
  266 + char* name = new char[id.size()];
  267 +
  268 + strcpy(srt, path_srt.c_str());
  269 + strcpy(name, id.c_str());
  270 +
  271 + setPathContents(mode, id);
  272 +
  273 + ServiceWindowGenerationFromSubtitle* service_srt;
  274 + service_srt = new ServiceWindowGenerationFromSubtitle(srt, language, background, name, mode, service);
180 try{ 275 try{
181 service_srt->initialize(); 276 service_srt->initialize();
182 }catch(ServiceException ex){ 277 }catch(ServiceException ex){
@@ -188,81 +283,32 @@ void serviceOnlySRT(char* service, char* path_file, char* transparency, char* id @@ -188,81 +283,32 @@ void serviceOnlySRT(char* service, char* path_file, char* transparency, char* id
188 while (!service_srt->isFinished()) { 283 while (!service_srt->isFinished()) {
189 usleep(100000); //100ms 284 usleep(100000); //100ms
190 } 285 }
191 - delete service_srt;  
192 286
  287 + delete [] srt;
  288 + delete [] name;
  289 + delete service_srt;
193 } 290 }
194 291
195 -void serviceOnlyAudio(char* service, char* path_audio, char* transparency, char* id, char* client_type){  
196 -  
197 - ServiceWindowGenerationFromRec * service_rec;  
198 - service_rec = new ServiceWindowGenerationFromRec(path_audio, 0, 0, 0, (int) atoi(transparency), id, client_type, (int) atoi(service));  
199 - 292 +void serviceTest(int position, int size, int background) {
  293 + ServiceTester* service_t;
  294 + service_t = new ServiceTester(position, size, background);
200 try{ 295 try{
201 - service_rec->initialize();  
202 - }catch(ServiceException ex){ 296 + service_t->Start();
  297 + }catch(ServiceException &ex){
203 fail(ex.getMessage()); 298 fail(ex.getMessage());
204 hasFailed(); 299 hasFailed();
205 return; 300 return;
206 - }  
207 - while(!service_rec->isFinished()){  
208 - sleep(2);  
209 } 301 }
210 - delete service_rec;  
211 -}  
212 302
213 -/*void serviceREC(char* path_video, char* sublanguage,  
214 - char* position, char* size, char* transparency, char* id, char* rate){  
215 -  
216 - ServiceWindowGenerationFromREC * service_rec;  
217 - service_rec = new ServiceWindowGenerationFromREC(  
218 - path_video,  
219 - (int) atoi(sublanguage),  
220 - (int) atoi(position),  
221 - (int) atoi(size),  
222 - (int) atoi(transparency),  
223 - id, 2, rate);  
224 -  
225 - try{  
226 - service_rec->initialize();  
227 - }catch(ServiceException ex){  
228 - fail(ex.getMessage());  
229 - hasFailed();  
230 - return;  
231 - }  
232 - while(!service_rec->isFinished()){  
233 - sleep(2); 303 + while (!service_t->isFinished()) {
  304 + sleep(5);
234 } 305 }
235 - delete service_rec;  
236 -}*/  
237 -  
238 -/*void serviceOnlyAudio(char* path_audio, char* transparency, char* id, char* rate){  
239 -  
240 - ServiceWindowGenerationFromREC * service_rec;  
241 - service_rec = new ServiceWindowGenerationFromREC(  
242 - path_audio,  
243 - 0,  
244 - 0,  
245 - 0,  
246 - (int) atoi(transparency),  
247 - id, 5, rate);  
248 -  
249 - try{  
250 - service_rec->initialize();  
251 - }catch(ServiceException ex){  
252 - fail(ex.getMessage());  
253 - hasFailed();  
254 - return;  
255 - }  
256 - while(!service_rec->isFinished()){  
257 - sleep(2);  
258 - }  
259 - delete service_rec;  
260 -}*/ 306 + delete service_t;
  307 +}
261 308
262 void fail(string msg){ 309 void fail(string msg){
263 - printf("\n");  
264 - DDDDPRINTF("Ops... Tivemos um problema! :(\n");  
265 - DDDDPRINTF("Possível causa do erro: %s\n\n", msg.c_str()); 310 + PRINTL(util::_ERROR, "\nOps... Tivemos um problema! :(\n");
  311 + PRINTL(util::_ERROR, "Possível causa do erro: %s\n\n", msg.c_str());
266 } 312 }
267 313
268 void hasFailed(){ 314 void hasFailed(){
@@ -273,66 +319,53 @@ void hasInvalid(){ @@ -273,66 +319,53 @@ void hasInvalid(){
273 isInvalid = true; 319 isInvalid = true;
274 } 320 }
275 321
276 -void serviceHelp(int service){  
277 - cout << "\nParâmetros inválidos! Tente novamente.\n";  
278 - switch(service){  
279 - case 1:  
280 - cout << "\nService Type: Video with Subtitles\n"  
281 - << "./vlibras INPUT_VIDEO INPUT_SRT LANGUAGE(1: Portuguese, 2:Glosa) POSITION(1: Top_Left, 2: Top_Right, 3: Bottom_Right, 4: Bottom_Left) "  
282 - << "SIZE(1: Small, 2: Medium, 3: Large) TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";  
283 - break;  
284 - case 2:  
285 - cout << "\nService Type: Video Recognize\n"  
286 - << "./vlibras INPUT_VIDEO LANGUAGE(1: Portuguese, 2:Glosa) POSITION(1: Top_Left, 2: Top_Right, 3: Bottom_Right, 4: Bottom_Left) "  
287 - << "SIZE(1: Small, 2: Medium, 3: Large) TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";  
288 - break;  
289 - case 3:  
290 - cout << "\nService Type: Text\n"  
291 - << "./vlibras INPUT_TEXT_FILE TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";  
292 - break;  
293 - case 4:  
294 - cout << "\nService Type: Subtitles only\n"  
295 - << "./vlibras INPUT_SRT TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";  
296 - break;  
297 - case 5:  
298 - cout << "\nService Type: Audio Recognize\n"  
299 - << "./vlibras INPUT_AUDIO TRANSPARENCY(0: Opaque, 1: Transparent) ID CLIENT_TYPE\n";  
300 - break; 322 +void setPathContents(int mode, string id){
  323 + string command = "mkdir -p ";
  324 + switch(mode){
  325 + case 1://devel
  326 + char* vlStorage;
  327 + char* vlUploads;
  328 + vlStorage = getenv("VLSTORAGE");
  329 + vlUploads = getenv("VLUPLOADS");
  330 +
  331 + if(vlStorage == NULL || vlUploads == NULL){
  332 + command.append(PATH_DEVEL_CONTENTS).append(" && mkdir -p ")
  333 + .append(PATH_DEVEL_UPLOADS).append("/").append(id);
  334 + system(command.c_str());
  335 + }
  336 + break;
  337 +
  338 + case 2://produção
  339 + command.append(PATH_VBOX_UPLOADS).append("/").append(id);
  340 + system(command.c_str());
  341 + break;
  342 +
  343 + default:
  344 + fail("Modo de execução não reconhecido!");
  345 + exit(127);
301 } 346 }
302 } 347 }
303 348
304 -//Help do programa, explicando todos os parâmetros existentes...  
305 -void help() {  
306 -  
307 - cout << endl  
308 - << "Usage Summary: vlibras [SERVICE] [INPUT] ... [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"  
309 - << "\nSERVICE:\n"  
310 - << "1 Video with Subtitles (SRT) - requires INPUT_VIDEO and INPUT_SRT\n"  
311 - << "2 Video Recognize - requires INPUT_VIDEO\n"  
312 - << "3 Text - requires INPUT_TEXT_FILE\n"  
313 - << "4 Subtitles only (SRT) - requires INPUT_SRT\n"  
314 - << "5 Audio Recognize - requires INPUT_AUDIO\n"  
315 - << "\nSERVICES PARAMETERS:\n"  
316 - << "Video with subtitles:\n"  
317 - << " [INPUT_VIDEO] [INPUT_SRT] [LANGUAGE] [POSITION] [SIZE] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"  
318 - << "\nVideo Recognize:\n"  
319 - << " [INPUT_VIDEO] [LANGUAGE] [POSITION] [SIZE] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"  
320 - << "\nText:\n"  
321 - << " [INPUT_TEXT_FILE] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"  
322 - << "\nSubtitles only:\n"  
323 - << " [INPUT_SRT] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"  
324 - << "\nAudio Recognize\n"  
325 - << " [INPUT_AUDIO] [TRANSPARENCY] [ID] [CLIENT_TYPE]\n"  
326 - << "\nPARAMETERS:\n"  
327 - << "INPUT_VIDEO Path of the video file\n"  
328 - << "INPUT_SRT Path of the subtitle file\n"  
329 - << "INPUT_TEXT_FILE Path of the text file\n"  
330 - << "INPUT_AUDIO Path of the audio file\n"  
331 - << "LANGUAGE 1 - means Portuguese, 2 - means Glosa\n"  
332 - << "POSITION 1 - means Top_Left, 2 - means Top_Right, 3 - means Bottom_Right, 4 - means Bottom_Left\n"  
333 - << "SIZE 1 - means Small, 2 - means Medium, 3 - means Large\n"  
334 - << "TRANSPARENCY 0 - means that the background is opaque , 1 - means that the background is transparent\n"  
335 - << "ID Relative to the unique ID on the Database\n"  
336 - << "CLIENT_TYPE prod - means that the client is web/cloud, devel - means that the client is developer\n"  
337 - << endl;  
338 -}  
339 \ No newline at end of file 349 \ No newline at end of file
  350 +void help()
  351 +{
  352 + std::cout << std::endl
  353 + << "Usage Summary: vlibras [Service_option] filepath [Options] --id [name] --mode [devel,prod]"
  354 + << "\n\nService_option:"
  355 + << "\n\tVideo with Subtitles -V, --video [filePath] -S, --subtitle [filePath]"
  356 + << "\n\tVideo Recognize -V, --video [filePath]"
  357 + << "\n\tAudio Recognize -A, --audio [filepath]"
  358 + << "\n\tText -T, --text [filePath]"
  359 + << "\n\tSubtitles only -S, --subtitle [filePath]"
  360 + << "\n\nOptions:"
  361 + << "\n\t-l, --language [portugues,glosa]"
  362 + << "\n\t-b, --background [opaque,transp]"
  363 + << "\n\t-r, --resolution [small,medium,large]"
  364 + << "\n\t-p, --position [top_left,top_right,bottom_left,bottom_right]"
  365 + << "\n\t-m, --mode [devel,prod]"
  366 + << "\n\t-v, --loglevel [quiet,error,warning,info,debug]"
  367 + << "\n\t--id [name] Relative to the unique ID on the Database."
  368 + << "\n\t--no-mixer Disables mixing with the original video."
  369 + << "\n\nSee man vlibras for detailed descriptions."
  370 + << std::endl;
  371 + exit(0);
  372 +}
mixer/src/Mixer.cpp
@@ -1,353 +0,0 @@ @@ -1,353 +0,0 @@
1 -/*  
2 - * File: Mixer.cpp  
3 - * Author: eduardo  
4 - *  
5 - * Created on 17 de Janeiro de 2012, 15:28  
6 - */  
7 -#include "Mixer.h"  
8 -  
9 -/* Construtores e destrutores...*/  
10 -Mixer::Mixer() {  
11 - this->setNumThreads("1");  
12 - DPRINTF("Done!\n");  
13 -}  
14 -Mixer::Mixer(string mainVideo, string secondaryVideo) {  
15 - this->setMainVideo(mainVideo);  
16 - this->setSecondaryVideo(secondaryVideo);  
17 - this->setNumThreads("1");  
18 - DPRINTF("Done!\n");  
19 -}  
20 -Mixer::~Mixer() {  
21 - DDDPRINTF("Mixer finalized!\n");  
22 -}  
23 -/* FIM de Construtores e destrutores...*/  
24 -  
25 -/*Faz a chamada ffmpeg no terminal.*/  
26 -  
27 -void Mixer::initialize(string mainVideo, string slVideo, int positionSecondaryVideo, int sizeSecondaryVideo,  
28 - int transparency, char* _id, char* path_uploads, char* path_contents){  
29 -  
30 - DPRINTF("[AGUARDE] Mixando...\n")  
31 - uploads = path_uploads;  
32 - contents = path_contents;  
33 - stringstream ss;  
34 - ss << _id;  
35 - ss >> user_id;  
36 -  
37 - this->setMainVideo(mainVideo);  
38 - this->setSecondaryVideo(slVideo);  
39 - this->setNumThreads("8"); //tem que aparecer antes do metodo adjustVideosFps()  
40 - //this->adjustVideosFps();  
41 -  
42 - this->setSize(sizeSecondaryVideo);  
43 - this->setPositionSecondaryVideo(positionSecondaryVideo);  
44 - this->setTransparency(transparency);  
45 - this->setPathFinal();  
46 - this->mixVideos();  
47 -}  
48 -  
49 -void Mixer::mixVideos () {  
50 - //convertendo os numeros em string para concatenar à frase  
51 - std::stringstream num1;  
52 - num1 << this->widthSecondaryVideo;  
53 - string num1String;  
54 - num1 >> num1String;  
55 -  
56 - std::stringstream num2;  
57 - num2 << this->heightSecondaryVideo;  
58 - string num2String;  
59 - num2 >> num2String;  
60 -  
61 - /*std::stringstream num2;  
62 - num2 << this->heightSecondaryVideo;  
63 - string num2String, aux;  
64 - num2 >> aux;  
65 - num2String = "in_h*"+aux;*/  
66 -  
67 - string strPosition;  
68 - if(this->getPositionSecondaryVideo() == TOP_LEFT)  
69 - strPosition = "10:10";  
70 - else if((this->getPositionSecondaryVideo() == TOP_RIGHT))  
71 - strPosition = "main_w-overlay_w-10:10";  
72 - else if((this->getPositionSecondaryVideo() == BOTTOM_RIGHT))  
73 - strPosition = "main_w-overlay_w-10:main_h-overlay_h-10";  
74 - else if((this->getPositionSecondaryVideo() == BOTTOM_LEFT))  
75 - strPosition = "10:main_h-overlay_h-10";  
76 - else{ //se não escolheu nenhum inteiro válido, consideramos BOTTOM_RIGHT o local padrão, mostra msg de erro  
77 - strPosition = "main_w-overlay_w-10:main_h-overlay_h-10";  
78 - cout << "####################################################################\n";  
79 - cout << "# Posicao do vídeo de libras é inválido! #\n";  
80 - cout << "# Assumiremos a posicao padrao (Bottom_Right)! #\n";  
81 - cout << "# OPCOES: 1-Top_Left; 2-Top_Right; 3-Bottom_Right; 4-Bottom_Left; #\n";  
82 - cout << "####################################################################";  
83 - }  
84 -  
85 - //retira a string .ts da primeira string  
86 - //string nameOfMainVideo = mainVideo.substr(0,mainVideo.length()-3);  
87 - int dotPosition = 0;  
88 - for(int k = mainVideo.length(); k >= 0; k--) {  
89 - if (mainVideo[k] == '.') {  
90 - dotPosition = k;  
91 - break;  
92 - }  
93 - }  
94 - string nameOfMainVideo = mainVideo.substr(0, dotPosition);  
95 -  
96 - string transparency;  
97 - if(this->getTransparency()==0){  
98 - transparency = "";  
99 - }  
100 - else  
101 - transparency = "transp";  
102 -  
103 - /*string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+  
104 - "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS [movie]; "+  
105 - "[in] setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+  
106 - " [out]\" -sameq -threads "+this->numThreads+" "+nameOfMainVideo+"_Libras.ts";*/  
107 -  
108 - /*string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+  
109 - "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS [movie]; "+  
110 - "[in] setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+  
111 - " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+nameOfMainVideo+"_Libras.flv";*/  
112 -  
113 - //LEONARDO  
114 - /*string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+  
115 - "scale="+ num1String +":"+num2String+", [movie] overlay"+transparency+"="+strPosition+  
116 - " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+nameOfMainVideo+"_Libras.flv";*/  
117 -  
118 - //TRANSCODIFICAR PARA FLV  
119 - /*  
120 - string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+  
121 - "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+  
122 - " [out]\" -sameq -strict experimental -vcodec mpeg2video -r 30 -threads "+this->numThreads+" "+pathFinal;  
123 - */  
124 -  
125 - string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -v quiet -y -vf \"movie="+this->secondaryVideo+", "+  
126 - "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+  
127 - " [out]\" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 -threads "+this->numThreads+" "+pathFinal;  
128 -  
129 -  
130 -  
131 - /*  
132 - string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+  
133 - "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+  
134 - " [out]\" -sameq -threads "+this->numThreads+" "+pathFinal;  
135 - */  
136 -  
137 - /*  
138 - convertendo e obtendo ótimos resultados de tamanho do vídeo  
139 - ffmpeg -i videoDemoLibras.ts -vcodec libx264 -f flv -ar 22050 -ab 32 -sameq -threads 8 -y teste.flv  
140 - */  
141 -  
142 - //printf("\n\n%s\n\n", ffmpegSentence.c_str());  
143 - system(ffmpegSentence.c_str());  
144 -  
145 - //string removeVideoCMD = "rm -rf "+nameOfMainVideo+".ts"; //removo o vídeo exemplo-45fps.ts  
146 - //system(removeVideoCMD.c_str());  
147 -}  
148 -  
149 -void Mixer::setPathFinal(){  
150 - stringstream ss;  
151 - ss << contents;  
152 - ss >> pathFinal;  
153 - pathFinal.append(user_id).append(".mp4");  
154 -}  
155 -  
156 -/*Ajusta o FPS do vídeo principal para 45 se preciso...*/  
157 -void Mixer::adjustVideosFps(){  
158 - //primeiro executo a linha de comando que me dá todas as informações do vídeo  
159 - string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" 2> "+temporaryTextFile;  
160 - system(ffmpegSentence.c_str()); //executo o comando ffmpeg que escreve no arquivo temporário  
161 -  
162 - fpsAndLine arrayDeFps[10]; //array onde será guardado os fps encontrados  
163 - int qtdadeDeFPSEncontrados = 0;  
164 - this->readFileFPS(arrayDeFps, &qtdadeDeFPSEncontrados); //leio o arquivo procurando os FPS disponíveis  
165 -  
166 - this->convertMainVideoFPS(arrayDeFps, &qtdadeDeFPSEncontrados); //converte o fps do vídeo principal  
167 -}  
168 -  
169 -/*Lê do arquivo procurando o fps...*/  
170 -void Mixer::readFileFPS(fpsAndLine arrayDeFps [], int * qtdadeDeFPSEncontrados){  
171 - ifstream arq(temporaryTextFile.c_str());//abrindo arquivo com info. dos vídeos  
172 - if (arq.is_open()){  
173 - int indiceDoFPSEncontrados = 0; //indice a ser utilizado no array  
174 - string line;  
175 - while (!arq.eof()){  
176 - getline(arq,line); //linha lida no arquivo  
177 -  
178 - int auxProgram = line.find("Program "); //procura pela string "fps,"  
179 - if(auxProgram >= 0){  
180 - string id = line.substr(auxProgram+10);  
181 - if(atoi(id.c_str()) != 0){ //diferente de 0, a conversão deu blz...  
182 - arrayDeFps[indiceDoFPSEncontrados].possibleProgramID = id;  
183 - printf("\n\n\n\n\nID: %s\n\n\n\n\n",id.c_str());  
184 - }  
185 - }  
186 -  
187 - int aux = line.find("fps,"); //procura pela string "fps,"  
188 - if(aux >= 0){  
189 - int i;  
190 - int espacos = 0; //quantidade de espacos encontrados  
191 - for(i = aux;espacos != 2;i--){  
192 - if(line.at(i) == ' '){ //se for espaço incremente  
193 - espacos++;  
194 - }  
195 - }  
196 - string fps = line.substr(i+espacos,aux-i-espacos-1);//extrai o fps da linha  
197 - double fpsDouble = atof(fps.c_str()); //transformo de string pra double  
198 -  
199 - arrayDeFps[indiceDoFPSEncontrados].fps = fpsDouble; //armazeno o fps em um array de struct  
200 - arrayDeFps[indiceDoFPSEncontrados].line = line; //armazeno a linha em um array de struct  
201 -  
202 - indiceDoFPSEncontrados++; //achei um fps, preenchi um struct, vou pro prox.  
203 - }  
204 - }  
205 - arq.close();  
206 - //*qtdadeDeFPSEncontrados = indiceDoFPSEncontrados + 1;  
207 - *qtdadeDeFPSEncontrados = indiceDoFPSEncontrados;  
208 - }  
209 -  
210 -}  
211 -  
212 -void Mixer::convertMainVideoFPS(fpsAndLine arrayDeFps [], int * qtdadeDeFPSEncontrados){  
213 - //retira a string .ts da primeira string  
214 - string nameOfMainVideo = mainVideo.substr(0,mainVideo.length()-3);  
215 -  
216 - int i;  
217 - if(*qtdadeDeFPSEncontrados > 1){  
218 - //cout << "\n############################\nConverter fps do vídeo principal com vários canais!\n############################\n");  
219 - for(i = 0; i < *qtdadeDeFPSEncontrados;i++){  
220 - //procura pela string "Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9],"  
221 - int indexMainVideo1 = arrayDeFps[i].line.find("Video: h264 (High)");  
222 - int indexMainVideo2 = arrayDeFps[i].line.find("yuv420p");  
223 - int indexMainVideo3 = arrayDeFps[i].line.find("1920x1080");  
224 - //int indexMainVideo = arrayDeFps[i].line.find("DAR 16:9");  
225 -  
226 - //printf("\n\n\n\n\n\n\nPID do canal: %s \n\n\n\n\n\n\n",arrayDeFps[i].possibleProgramID.c_str());  
227 - if(indexMainVideo1 > 0 && indexMainVideo2 > 0 && indexMainVideo3 > 0){ //eis aqui o vídeo principal  
228 - //printf("\n\n\n\n\n\n\nPID do canal a ser alterado: %s \n\n\n\n\n\n\n",arrayDeFps[i].possibleProgramID.c_str());  
229 - string ffmpegSentence45 = "ffmpeg -i "+this->mainVideo+" -v quiet -y -r 45 -vcodec libx264 -streamid 0:"+arrayDeFps[i].possibleProgramID+  
230 - "-sameq -threads "+this->numThreads+" "+nameOfMainVideo+"-45fps.ts";  
231 - system(ffmpegSentence45.c_str());  
232 - //string removeVideoCMD = "rm -rf "+nameOfMainVideo+".ts"; //removo o vídeo exemplo.ts  
233 - //system(removeVideoCMD.c_str());  
234 - this->setMainVideo(nameOfMainVideo+"-45fps.ts");  
235 - break;  
236 - }  
237 - }  
238 - }  
239 - else{  
240 - //cout << "\n############################\nConverter fps do vídeo principal com apenas um canal!\n############################\n");  
241 - string ffmpegSentence45 = "ffmpeg -i "+this->mainVideo+" -v quiet -y -r 45 -vcodec libx264 "  
242 - "-sameq -threads "+this->numThreads+" "+nameOfMainVideo+"-45fps.ts";  
243 - system(ffmpegSentence45.c_str());  
244 - //string removeVideoCMD = "rm -rf "+nameOfMainVideo+".ts"; //removo o vídeo exemplo.ts  
245 - //system(removeVideoCMD.c_str());  
246 - this->setMainVideo(nameOfMainVideo+"-45fps.ts");  
247 - }  
248 -}  
249 -  
250 -  
251 -  
252 -  
253 -/* O valor da largura e altura está na unidade de Pixels.  
254 - * Se o valor da variável for -1, deverá manter a proporção da mesma em relação  
255 - * à outra.  
256 - * Ex.: 600:-1 ==> largura é 600 e a altura será calculada em relação à mesma para  
257 - * manter proporção.  
258 - * Ex.: -1:600 ==> altura é 600 e a largura será calculada em relação à mesma para  
259 - * manter proporção.  
260 - */  
261 -void Mixer::setSize(int size){  
262 -  
263 - string ffprobeSentence = "ffprobe -show_streams "+this->mainVideo+" 2> /dev/null | grep \"height=\" | cut -d'=' -f2 > "+temporaryTextFile;  
264 - system(ffprobeSentence.c_str());  
265 -  
266 - //printf("\n\n%s\n\n",ffprobeSentence.c_str());  
267 -  
268 -  
269 - string heightStr = "324"; //se não conseguir ler do arquivo a altura será essa.. :(  
270 -  
271 - ifstream arq(temporaryTextFile.c_str());//abrindo arquivo com info. dos vídeos  
272 - if (arq.is_open()){  
273 - getline(arq,heightStr); //lendo o tamanho(altura) do vídeo  
274 - arq.close();  
275 - }  
276 -  
277 - string removeFileSentence = "rm -rf "+temporaryTextFile;  
278 - //system(removeFileSentence.c_str());  
279 -  
280 - int height = atoi(heightStr.c_str());  
281 -  
282 -  
283 - if(size == SMALL){  
284 - this->widthSecondaryVideo = -1;  
285 - this->heightSecondaryVideo = (0.3*height);  
286 - }  
287 - else if(size == MEDIUM){  
288 - this->widthSecondaryVideo = -1;  
289 - this->heightSecondaryVideo = (0.4*height);  
290 - }  
291 - else if(size == LARGE){  
292 - this->widthSecondaryVideo = -1;  
293 - this->heightSecondaryVideo = (0.5*height);  
294 - }  
295 - else{ //se não escolheu nenhum inteiro válido, consideramos MEDIUM_WIDTH a largura padrão, mostra msg de erro  
296 - this->widthSecondaryVideo = -1;  
297 - this->heightSecondaryVideo = (0.4*height);  
298 - cout << "################################################\n";  
299 - cout << "# Tamanho do vídeo de libras é inválido! #\n";  
300 - cout << "# Assumiremos a largura padrao (Medium_Width)! #\n";  
301 - cout << "# OPCOES: 1-Small; 2-Medium; 3-Large; #\n";  
302 - cout << "################################################";  
303 - }  
304 -}  
305 -  
306 -/*Setters e getters...*/  
307 -void Mixer::setMainVideo(string mainVideo){  
308 - this->mainVideo = mainVideo;  
309 - //retira a string .ts da primeira string, adiciona o "temp" antes e o ".txt" depois  
310 - //string nameOfMainVideo = mainVideo.substr(0,mainVideo.length()-3);  
311 - int dotPosition = 0;  
312 - for(int k = mainVideo.length(); k >= 0; k--) {  
313 - if (mainVideo[k] == '.') {  
314 - dotPosition = k;  
315 - break;  
316 - }  
317 - }  
318 -//ajeitar isso depois  
319 - string nameOfMainVideo = mainVideo.substr(0, dotPosition);  
320 -  
321 - stringstream ss;  
322 - ss << uploads;  
323 - ss >> temporaryTextFile;  
324 - temporaryTextFile.append(this->user_id).append("/tamanho.txt");  
325 - //printf("##########temporaryTextFile: %s\n", temporaryTextFile.c_str());  
326 -}  
327 -string Mixer::getMainVideo(){  
328 - return this->mainVideo;  
329 -}  
330 -void Mixer::setSecondaryVideo(string secondaryVideo){  
331 - this->secondaryVideo = secondaryVideo;  
332 -}  
333 -string Mixer::getSecondaryVideo(){  
334 - return this->secondaryVideo;  
335 -}  
336 -void Mixer::setPositionSecondaryVideo(int positionSecondaryVideo){  
337 - this->positionSecondaryVideo = positionSecondaryVideo;  
338 -}  
339 -int Mixer::getPositionSecondaryVideo(){  
340 - return this->positionSecondaryVideo;  
341 -}  
342 -void Mixer::setTransparency(int transparency){  
343 - this->transparency = transparency;  
344 -}  
345 -int Mixer::getTransparency(){  
346 - return this->transparency;  
347 -}  
348 -void Mixer::setNumThreads(string numThreads){  
349 - this->numThreads = numThreads;  
350 -}  
351 -string Mixer::getNumThreads(){  
352 - return this->numThreads;  
353 -}  
mixer/src/include/Mixer.h
@@ -1,86 +0,0 @@ @@ -1,86 +0,0 @@
1 -/*  
2 - * File: Mixer.h  
3 - * Author: eduardo  
4 - *  
5 - * Created on 17 de Janeiro de 2012, 15:28  
6 - */  
7 -  
8 -#ifndef MIXER_H  
9 -#define MIXER_H  
10 -  
11 -#include "string.h"  
12 -#include <cstdlib>  
13 -#include <iostream>  
14 -#include <stdio.h>  
15 -#include <stdlib.h>  
16 -#include <sstream>  
17 -#include <string>  
18 -#include <fstream>  
19 -#include "dprintf.h"  
20 -  
21 -//SL Video Position  
22 -#define TOP_LEFT 1  
23 -#define TOP_RIGHT 2  
24 -#define BOTTOM_RIGHT 3  
25 -#define BOTTOM_LEFT 4  
26 -//SL Video Size  
27 -#define SMALL 1  
28 -#define MEDIUM 2  
29 -#define LARGE 3  
30 -//SL Video Width  
31 -#define SMALL_HEIGHT 324 //0,3*1080 se fosse full hd  
32 -#define MEDIUM_HEIGHT 432 //0,4*1080  
33 -#define LARGE_HEIGHT 540 //0.5*1080  
34 -  
35 -#define MAX_SIZE_PATH 256  
36 -  
37 -using namespace std;  
38 -  
39 -class Mixer {  
40 -public:  
41 -  
42 - Mixer(string,string);  
43 - Mixer();  
44 - virtual ~Mixer();  
45 -  
46 - void adjustVideosFps();  
47 -  
48 - void mixVideos();  
49 - void setSize(int);  
50 -  
51 - /* Setters e getters...*/  
52 - void setMainVideo(string);  
53 - string getMainVideo();  
54 - void setSecondaryVideo(string);  
55 - string getSecondaryVideo();  
56 - void setPositionSecondaryVideo(int);  
57 - int getPositionSecondaryVideo();  
58 - void setTransparency(int);  
59 - int getTransparency();  
60 - void setNumThreads(string);  
61 - string getNumThreads();  
62 - void initialize(string mainVideo, string slVideo, int, int, int, char*, char*, char*);  
63 - void setPathFinal();  
64 -  
65 -private:  
66 -  
67 - struct fpsAndLine {  
68 - string line;  
69 - double fps;  
70 - string possibleProgramID;  
71 - };  
72 -  
73 - void readFileFPS(fpsAndLine [], int *);  
74 - void convertMainVideoFPS(fpsAndLine [], int *);  
75 - void convertSecondaryVideoFPS(double);  
76 -  
77 - string mainVideo, secondaryVideo, temporaryTextFile, numThreads, pathFinal, user_id;  
78 - char* contents;  
79 - char* uploads;  
80 - int positionSecondaryVideo;  
81 - double widthSecondaryVideo, heightSecondaryVideo;  
82 - int transparency;  
83 -};  
84 -  
85 -#endif /* MIXER_H */  
86 -  
mixer/src/include/mixer.h 0 → 100644
@@ -0,0 +1,118 @@ @@ -0,0 +1,118 @@
  1 +/**
  2 + * \file Mixer.h
  3 + *
  4 + * \author Eduardo
  5 + * \date 17/01/2012
  6 + */
  7 +
  8 +/**
  9 +* edit: Wesnydy Ribeiro
  10 +* date: 16/10/2015
  11 +*/
  12 +
  13 +#ifndef MIXER_H
  14 +#define MIXER_H
  15 +
  16 +#include <string>
  17 +#include <iostream>
  18 +#include <sstream>
  19 +#include <fstream>
  20 +#include "logging.h"
  21 +
  22 +//Secondary Video Position
  23 +#define TOP_LEFT 1
  24 +#define TOP_RIGHT 2
  25 +#define BOTTOM_RIGHT 3
  26 +#define BOTTOM_LEFT 4
  27 +
  28 +//Secondary Video Size
  29 +#define SMALL 1
  30 +#define MEDIUM 2
  31 +#define LARGE 3
  32 +
  33 +#define NUMTHREADS "8"
  34 +
  35 +using namespace std;
  36 +using namespace util;
  37 +
  38 +/** \brief Classe que implementa o mixador de vídeos.
  39 + *
  40 + * \headerfile mixer/src/include/mixer.h
  41 + */
  42 +class Mixer {
  43 +
  44 +public:
  45 + /** Construtor.
  46 + *
  47 + * \param mVideo Path do vídeo principal.
  48 + * \param sVideo Path do vídeo secundário.
  49 + * \param ssVideo Tamanho do vídeo secundario.
  50 + * \param psVideo Posição do vídeo secundário em relação ao vídeo principal.
  51 + * \param tsVideo Transparência do vídeo sencundário.
  52 + * \param id Identificação do cliente na base de dados.
  53 + * \param pathTemp Path onde serão armazenados os arquivos temporários.
  54 + * \param pathContents Path onde será armazenado o vídeo mixado.
  55 + */
  56 + Mixer(string mVideo, string sVideo, int ssVideo, int psVideo, int tsVideo,
  57 + string id, string pathTemp, string pathContents);
  58 +
  59 + /** Destrutor. */
  60 + ~Mixer();
  61 +
  62 + /** Inicializa o processo de mixagem.
  63 + *
  64 + * A mixagem é feita através de uma chamada do FFMPEG.
  65 + */
  66 + void initialize();
  67 +
  68 +private:
  69 + string pathMixedVideo;
  70 + string pathTempFiles;
  71 +
  72 + string mainVideo;
  73 + string secondaryVideo;
  74 + string temporaryTextFile;
  75 + string transparency;
  76 + string userID;
  77 +
  78 + string heigthStr;
  79 + string widthStr;
  80 + string positionStr;
  81 +
  82 + double widthSVideo;
  83 + double heigthSVideo;
  84 +
  85 + int positionSVideo;
  86 + int sizeSVideo;
  87 + int transpSVideo;
  88 +
  89 + /** Realiza a mixagem dos vídeos.
  90 + *
  91 + * Chama o FFMPEG passando os parâmetros necessários
  92 + * para a mixagem dos vídeos.
  93 + */
  94 + void mixVideos();
  95 +
  96 + /** Define o tamanho do vídeo secundário.
  97 + *
  98 + * O tamanho do vídeo secundário depende do tamanho
  99 + * do vídeo principal e da opção de resolução selecionada.
  100 + */
  101 + void setSVSize();
  102 +
  103 + /** Define a posição do vídeo secundário.
  104 + *
  105 + * A posição do vídeo secundário depende da posição
  106 + * selecionada pelo usuário.
  107 + */
  108 + void setSVPosition();
  109 +
  110 + /** Seta o path dos arquivos.
  111 + *
  112 + * O path dos arquivos temporários e do vídeo mixado
  113 + * são setados através desse método.
  114 + */
  115 + void setPathOfFiles();
  116 +};
  117 +
  118 +#endif /* MIXER_H */
0 \ No newline at end of file 119 \ No newline at end of file
mixer/src/mixer.cpp 0 → 100644
@@ -0,0 +1,139 @@ @@ -0,0 +1,139 @@
  1 +#include "mixer.h"
  2 +
  3 +Mixer::Mixer(string mVideo, string sVideo, int ssVideo, int psVideo, int tsVideo,
  4 + string id, string pathTemp, string pathContents) {
  5 + this->mainVideo = mVideo;
  6 + this->secondaryVideo = sVideo;
  7 + this->sizeSVideo = ssVideo;
  8 + this->positionSVideo = psVideo;
  9 + this->transpSVideo = tsVideo;
  10 + this->transparency = ""; //Por enquanto, a transparência esta desativada.
  11 + this->pathTempFiles = pathTemp;
  12 + this->pathMixedVideo = pathContents;
  13 + this->userID = id;
  14 + PRINTL(util::_DEBUG, "Mixer Done!\n");
  15 +}
  16 +
  17 +Mixer::~Mixer() {
  18 + PRINTL(util::_DEBUG, "Mixer finalized!\n");
  19 +}
  20 +
  21 +void Mixer::setPathOfFiles() {
  22 + this->pathTempFiles.append("/").append(this->userID);
  23 + this->pathMixedVideo.append("/").append(this->userID).append(".mp4");
  24 +}
  25 +
  26 +/* O valor da largura e altura está na unidade de Pixels.
  27 + * Se o valor da variável for -1, deverá manter a proporção da mesma em relação
  28 + * à outra.
  29 + * Ex.: 600:-1 ==> largura é 600 e a altura será calculada em relação à mesma para
  30 + * manter proporção.
  31 + * Ex.: -1:600 ==> altura é 600 e a largura será calculada em relação à mesma para
  32 + * manter proporção.
  33 + */
  34 +void Mixer::setSVSize() {
  35 + string tempTextFile = this->pathTempFiles;
  36 + tempTextFile.append("/").append("tamanho.txt");
  37 +
  38 + string ffprobeSentence = "ffprobe -show_streams "+this->mainVideo+" 2> /dev/null | grep \"height=\" | cut -d'=' -f2 > "+tempTextFile;
  39 + system(ffprobeSentence.c_str());
  40 +
  41 + string strHeight = "324"; //Se não conseguir ler do arquivo a altura será essa...
  42 + ifstream arq(tempTextFile.c_str()); //Abrindo arquivo com info. dos vídeos
  43 + if (arq.is_open()) {
  44 + getline(arq,strHeight); //Lendo o tamanho(altura) do vídeo
  45 + arq.close();
  46 + }
  47 + int height = atoi(strHeight.c_str());
  48 +
  49 + stringstream alt;
  50 + stringstream larg;
  51 +
  52 + switch(this->sizeSVideo){
  53 + case SMALL:
  54 + this->widthSVideo = -1;
  55 + this->heigthSVideo = (0.3*height);
  56 +
  57 + larg << this->widthSVideo;
  58 + larg >> this->widthStr;
  59 +
  60 + alt << this->heigthSVideo;
  61 + alt >> this->heigthStr;
  62 + break;
  63 +
  64 + case MEDIUM:
  65 + this->widthSVideo = -1;
  66 + this->heigthSVideo = (0.4*height);
  67 +
  68 + larg << this->widthSVideo;
  69 + larg >> this->widthStr;
  70 +
  71 + alt << this->heigthSVideo;
  72 + alt >> this->heigthStr;
  73 + break;
  74 +
  75 + case LARGE:
  76 + this->widthSVideo = -1;
  77 + this->heigthSVideo = (0.5*height);
  78 +
  79 + larg << this->widthSVideo;
  80 + larg >> this->widthStr;
  81 +
  82 + alt << this->heigthSVideo;
  83 + alt >> this->heigthStr;
  84 + break;
  85 +
  86 + default: //Se não escolheu nenhum inteiro válido, consideramos MEDIUM como o tamanho padrão.
  87 + this->widthSVideo = -1;
  88 + this->heigthSVideo = (0.4*height);
  89 +
  90 + larg << this->widthSVideo;
  91 + larg >> this->widthStr;
  92 +
  93 + alt << this->heigthSVideo;
  94 + alt >> this->heigthStr;
  95 +
  96 + PRINTL(util::_WARNING, "Tamanho do vídeo de libras é inválido! Tamanho padrão selecionado.\n");
  97 + }
  98 +}
  99 +
  100 +void Mixer::setSVPosition() {
  101 + switch(this->positionSVideo){
  102 + case TOP_LEFT:
  103 + this->positionStr = "10:10";
  104 + break;
  105 +
  106 + case TOP_RIGHT:
  107 + this->positionStr = "main_w-overlay_w-10:10";
  108 + break;
  109 +
  110 + case BOTTOM_RIGHT:
  111 + this->positionStr = "main_w-overlay_w-10:main_h-overlay_h-10";
  112 + break;
  113 +
  114 + case BOTTOM_LEFT:
  115 + this->positionStr = "10:main_h-overlay_h-10";
  116 + break;
  117 +
  118 + default: //Se não escolheu nenhum inteiro válido, consideramos BOTTOM_RIGHT como a posição padrão.
  119 + this->positionStr = "main_w-overlay_w-10:main_h-overlay_h-10";
  120 + PRINTL(util::_WARNING, "Posição do vídeo de libras é inválido! Posição padrão selecionada.\n");
  121 + }
  122 +}
  123 +
  124 +void Mixer::initialize() {
  125 + setPathOfFiles(); //Tem que aparecer antes de setSVSize();
  126 + setSVSize();
  127 + setSVPosition();
  128 + mixVideos();
  129 +}
  130 +
  131 +void Mixer::mixVideos() {
  132 + PRINTL(util::_INFO, "Mixando...\n");
  133 +
  134 + string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -v quiet -y -vf \"movie="+this->secondaryVideo+", "+
  135 + "scale="+ this->widthStr +":"+this->heigthStr+", setpts=PTS-STARTPTS, [movie] overlay"+this->transparency+"="+this->positionStr+
  136 + " [out]\" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 -threads "+NUMTHREADS+" "+this->pathMixedVideo;
  137 +
  138 + system(ffmpegSentence.c_str());
  139 +}
0 \ No newline at end of file 140 \ No newline at end of file
recognize/src/audiofile.cpp 0 → 100644
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +#include "audiofile.h"
  2 +
  3 +Audiofile::Audiofile(char *_file_path,float _start_seg,float _end_seg){
  4 +
  5 + file_path = _file_path;
  6 + start_seg = _start_seg;
  7 + end_seg = _end_seg;
  8 +}
  9 +
  10 +Audiofile::~Audiofile(){
  11 +
  12 +
  13 +}
0 \ No newline at end of file 14 \ No newline at end of file
recognize/src/include/audiofile.h 0 → 100644
@@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
  1 +#ifndef AUDIOFILE_H
  2 +#define AUDIOFILE_H
  3 +
  4 +class Audiofile
  5 +{
  6 +
  7 +public:
  8 +
  9 + Audiofile(char *_file_path,float _start_seg,float _end_seg);
  10 + ~Audiofile();
  11 +
  12 + char* file_path;
  13 + float start_seg;
  14 + float end_seg;
  15 +
  16 +
  17 +
  18 +
  19 +};
  20 +
  21 +#endif // AUDIOFILE_H
0 \ No newline at end of file 22 \ No newline at end of file
recognize/src/include/recognize.h
  1 +#ifndef RECOGNIZE_H
  2 +#define RECOGNIZE_H
  3 +
  4 +
1 #include "jthread.h" 5 #include "jthread.h"
2 #include <iostream> 6 #include <iostream>
3 #include <stdlib.h> 7 #include <stdlib.h>
@@ -12,18 +16,22 @@ @@ -12,18 +16,22 @@
12 #include <iterator> 16 #include <iterator>
13 #include <sys/stat.h> 17 #include <sys/stat.h>
14 #include <lavidlib/io/FileIO.h> 18 #include <lavidlib/io/FileIO.h>
15 -#include "dprintf.h"  
16 -#include "logger.h" 19 +#include "logging.h"
17 #include "recognizeListener.h" 20 #include "recognizeListener.h"
18 #include "recognizeException.h" 21 #include "recognizeException.h"
19 22
  23 +#include "wavcut.h"
  24 +#include "recognizer.h"
  25 +
20 #define FREQUENCY_PATTERN 22050 26 #define FREQUENCY_PATTERN 22050
21 #define INPUT_PATTERN 1 /* 1 = Raw file, 2 = Mic */ 27 #define INPUT_PATTERN 1 /* 1 = Raw file, 2 = Mic */
22 #define BLOCS_PATTERN 10 28 #define BLOCS_PATTERN 10
23 #define SIZE_BUFFER 256 29 #define SIZE_BUFFER 256
24 #define CONFIDENCE_RATE 0.10 30 #define CONFIDENCE_RATE 0.10
25 31
  32 +#define RECOGNIZER_MODE 1 // 0 = Julius, 1 = Google
26 #define PATH_JCONFIG "vlibras_user/vlibras-core/recognize/src/julius.jconf" 33 #define PATH_JCONFIG "vlibras_user/vlibras-core/recognize/src/julius.jconf"
  34 +#define PATH_WCONFIG "vlibras_user/vlibras-core/recognize/src/wavcut.jconf"
27 #define PATH_AUDIO_ORIGIN "/audio/origin/audio_origin.wav" 35 #define PATH_AUDIO_ORIGIN "/audio/origin/audio_origin.wav"
28 #define PATH_AUDIO_PARTS "/audio/parts/" 36 #define PATH_AUDIO_PARTS "/audio/parts/"
29 #define FILENAME_RECOGNIZED_OUT "/audio/recognized.out" 37 #define FILENAME_RECOGNIZED_OUT "/audio/recognized.out"
@@ -42,6 +50,7 @@ @@ -42,6 +50,7 @@
42 50
43 using namespace jthread; 51 using namespace jthread;
44 using namespace std; 52 using namespace std;
  53 +using namespace util;
45 54
46 class Recognize: public Thread { 55 class Recognize: public Thread {
47 56
@@ -110,4 +119,9 @@ private: @@ -110,4 +119,9 @@ private:
110 int64_t calcula_pts(double msec); 119 int64_t calcula_pts(double msec);
111 int64_t convert_pts(string pts); 120 int64_t convert_pts(string pts);
112 121
  122 + void executeGoogleEngine();
  123 + Jconf* load_config();
  124 +
113 }; 125 };
  126 +
  127 +#endif // RECOGNIZE_H
114 \ No newline at end of file 128 \ No newline at end of file
recognize/src/include/recognizer.h 0 → 100644
@@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
  1 +#ifndef RECOGNIZER_H
  2 +#define RECOGNIZER_H
  3 +
  4 +#include <julius/juliuslib.h>
  5 +#include <iostream>
  6 +#include <sstream>
  7 +#include <sys/stat.h>
  8 +#include <fstream>
  9 +#include <iostream>
  10 +#include <string.h>
  11 +#include <stdio.h>
  12 +#include <stdlib.h>
  13 +#include <string>
  14 +#include <list>
  15 +#include <stdint.h>
  16 +
  17 +using namespace std;
  18 +
  19 +class Recognizer
  20 +{
  21 +
  22 +public:
  23 + Recognizer();
  24 + ~Recognizer();
  25 + int recognize(string file_in);
  26 + string getsentence();
  27 + float getconfidence();
  28 +
  29 +
  30 +private:
  31 +
  32 + Jconf *jconf;
  33 + Recog *recog;
  34 +
  35 +};
  36 +
  37 +#endif // RECOGNIZER_H
recognize/src/include/wavcut.h 0 → 100644
@@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
  1 +#ifndef WAVCUT_H
  2 +#define WAVCUT_H
  3 +
  4 +#include <julius/juliuslib.h>
  5 +#include <string>
  6 +#include <algorithm>
  7 +#undef min
  8 +#undef max
  9 +#include <vector>
  10 +#include "audiofile.h"
  11 +
  12 +
  13 +
  14 +using namespace std;
  15 +class Wavcut{
  16 +
  17 +public:
  18 +
  19 + Wavcut(char* _pathAudio, char* _outputPath, char* _id);
  20 + ~Wavcut();
  21 +
  22 + int initialize(Jconf *jconf);
  23 + vector<Audiofile> list_audio_files();
  24 + int count_lines;
  25 +
  26 +private:
  27 + static int adin_callback_file(SP16 *now, int len, Recog *recog);
  28 +};
  29 +
  30 +#endif // WAVCUT_H
0 \ No newline at end of file 31 \ No newline at end of file
recognize/src/recognize.cpp
@@ -11,7 +11,7 @@ Recognize::Recognize(char* _pathVideo, char* _id) { @@ -11,7 +11,7 @@ Recognize::Recognize(char* _pathVideo, char* _id) {
11 ss << _id; 11 ss << _id;
12 ss >> id; 12 ss >> id;
13 confidenceRate=CONFIDENCE_RATE; 13 confidenceRate=CONFIDENCE_RATE;
14 - DPRINTF("Done!\n"); 14 + PRINTL(util::_DEBUG, "Recognize Done!\n");
15 } 15 }
16 16
17 Recognize::Recognize(char* _pathVideo, char* _id, char* rate) { 17 Recognize::Recognize(char* _pathVideo, char* _id, char* rate) {
@@ -27,7 +27,7 @@ Recognize::Recognize(char* _pathVideo, char* _id, char* rate) { @@ -27,7 +27,7 @@ Recognize::Recognize(char* _pathVideo, char* _id, char* rate) {
27 istringstream(rate) >> confidenceRate; 27 istringstream(rate) >> confidenceRate;
28 if (confidenceRate == 0) 28 if (confidenceRate == 0)
29 confidenceRate=CONFIDENCE_RATE; 29 confidenceRate=CONFIDENCE_RATE;
30 - DPRINTF("Done!\n"); 30 + PRINTL(util::_DEBUG, "Recognize Done!\n");
31 } 31 }
32 32
33 Recognize::Recognize(char* _pathVideo, int _inputType, char* _id) { 33 Recognize::Recognize(char* _pathVideo, int _inputType, char* _id) {
@@ -38,26 +38,26 @@ Recognize::Recognize(char* _pathVideo, int _inputType, char* _id) { @@ -38,26 +38,26 @@ Recognize::Recognize(char* _pathVideo, int _inputType, char* _id) {
38 frequency = FREQUENCY_PATTERN; 38 frequency = FREQUENCY_PATTERN;
39 sizeBlocs = BLOCS_PATTERN; 39 sizeBlocs = BLOCS_PATTERN;
40 id = _id; 40 id = _id;
41 - DPRINTF("Done!\n"); 41 + PRINTL(util::_DEBUG, "Recognize Done!\n");
42 } 42 }
43 43
44 Recognize::~Recognize() { 44 Recognize::~Recognize() {
45 listeners->clear(); 45 listeners->clear();
46 delete listeners; 46 delete listeners;
47 - DDDPRINTF("Recognize finalized!\n"); 47 + PRINTL(util::_DEBUG, "Recognize finalized!\n");
48 } 48 }
49 49
50 50
51 void Recognize::initialize() { 51 void Recognize::initialize() {
52 52
53 - DPRINTF("Recognizing...\n"); 53 + PRINTL(util::_INFO, "Reconhecendo áudio...\n");
54 /**printf("*** Initialized Recognition ***\n\nVideo: %s\nType [1-File; 2-Mic]: %d\nFrequency: %d\n\n", 54 /**printf("*** Initialized Recognition ***\n\nVideo: %s\nType [1-File; 2-Mic]: %d\nFrequency: %d\n\n",
55 this->pathVideo, this->inputType, this->frequency);**/ 55 this->pathVideo, this->inputType, this->frequency);**/
56 56
57 ifstream file(pathVideo, ifstream::binary); 57 ifstream file(pathVideo, ifstream::binary);
58 if(!file.is_open()){ 58 if(!file.is_open()){
59 finish = true; 59 finish = true;
60 - Util::Logger::Instance()->writeLog((char*) "[ERRO: recognize.cpp] Arquivo não encontrado."); 60 + Logging::instance()->writeLog("recognize.cpp <Error> Arquivo não encontrado.");
61 throw RecognizeException("Falha ao abrir o arquivo! Verifique se o mesmo existe."); 61 throw RecognizeException("Falha ao abrir o arquivo! Verifique se o mesmo existe.");
62 } 62 }
63 this->Start(); 63 this->Start();
@@ -68,14 +68,17 @@ void Recognize::Run(){ @@ -68,14 +68,17 @@ void Recognize::Run(){
68 finish = false; 68 finish = false;
69 createDir(); 69 createDir();
70 extractAudioFromVideo(); 70 extractAudioFromVideo();
71 - breakVideoParts(getTimeMediaSec());  
72 - executeJuliusEngine();  
73 - generateConfidence();  
74 - //filterOutputJulius();  
75 - //cleanFiles();  
76 - 71 + if (RECOGNIZER_MODE == 0){
  72 + breakVideoParts(getTimeMediaSec());
  73 + executeJuliusEngine();
  74 + generateConfidence();
  75 + } else {
  76 + executeGoogleEngine();
  77 + }
  78 +
77 finish = true; 79 finish = true;
78 - //notifyEndExtraction(count_lines); 80 + notifyEndExtraction(count_lines);
  81 + cleanFiles();
79 } 82 }
80 83
81 void Recognize::setFrequency(int freq) { 84 void Recognize::setFrequency(int freq) {
@@ -107,7 +110,7 @@ char* Recognize::extractAudioFromVideo() { @@ -107,7 +110,7 @@ char* Recognize::extractAudioFromVideo() {
107 //command.append(strFreq).append(" -ac 1 -f wav ").append(PATH_AUDIO_ORIGIN).append(" &"); 110 //command.append(strFreq).append(" -ac 1 -f wav ").append(PATH_AUDIO_ORIGIN).append(" &");
108 command.append(strFreq). 111 command.append(strFreq).
109 append(" -ac 1 -f wav "). 112 append(" -ac 1 -f wav ").
110 - append(path_contents).append(id). 113 + append(path_contents).append("/").append(id).
111 append(PATH_AUDIO_ORIGIN).append(" -v quiet"); 114 append(PATH_AUDIO_ORIGIN).append(" -v quiet");
112 115
113 /*string tmp = "echo "; 116 /*string tmp = "echo ";
@@ -121,7 +124,7 @@ int Recognize::getTimeMediaSec() { @@ -121,7 +124,7 @@ int Recognize::getTimeMediaSec() {
121 124
122 string command = PROGRAM; 125 string command = PROGRAM;
123 126
124 - command.append(" -i ").append(path_contents).append(id).append(PATH_AUDIO_ORIGIN) 127 + command.append(" -i ").append(path_contents).append("/").append(id).append(PATH_AUDIO_ORIGIN)
125 .append(" 2>&1 | grep Duration >> outfile"); 128 .append(" 2>&1 | grep Duration >> outfile");
126 system(command.c_str()); 129 system(command.c_str());
127 130
@@ -183,8 +186,8 @@ void Recognize::breakVideoParts(int timeTotal) { @@ -183,8 +186,8 @@ void Recognize::breakVideoParts(int timeTotal) {
183 pts.push_back(convert_pts(ss_str)); 186 pts.push_back(convert_pts(ss_str));
184 187
185 command = "sox "; 188 command = "sox ";
186 - command.append(path_contents).append(id).append(PATH_AUDIO_ORIGIN).append(" ")  
187 - .append(path_contents).append(id).append(PATH_AUDIO_PARTS); 189 + command.append(path_contents).append("/").append(id).append(PATH_AUDIO_ORIGIN).append(" ")
  190 + .append(path_contents).append("/").append(id).append(PATH_AUDIO_PARTS);
188 191
189 sprintf(tmp, "%i", count++); 192 sprintf(tmp, "%i", count++);
190 filename.append(tmp).append(".wav"); 193 filename.append(tmp).append(".wav");
@@ -194,8 +197,8 @@ void Recognize::breakVideoParts(int timeTotal) { @@ -194,8 +197,8 @@ void Recognize::breakVideoParts(int timeTotal) {
194 197
195 string apcomm = "echo "; 198 string apcomm = "echo ";
196 199
197 - apcomm.append(path_contents).append(id).append(PATH_AUDIO_PARTS).append(filename).append(" >> ")  
198 - .append(path_contents).append(id).append(FILENAME_AUDIOLIST); 200 + apcomm.append(path_contents).append("/").append(id).append(PATH_AUDIO_PARTS).append(filename).append(" >> ")
  201 + .append(path_contents).append("/").append(id).append(FILENAME_AUDIOLIST);
199 202
200 system(apcomm.c_str()); 203 system(apcomm.c_str());
201 204
@@ -209,7 +212,7 @@ void Recognize::breakVideoParts(int timeTotal) { @@ -209,7 +212,7 @@ void Recognize::breakVideoParts(int timeTotal) {
209 void Recognize::executeJuliusEngine() { 212 void Recognize::executeJuliusEngine() {
210 213
211 string type, freqStr; 214 string type, freqStr;
212 - string command = "julius -C "; 215 + string command = "julius -quiet -C ";
213 char cfreq[10]; 216 char cfreq[10];
214 217
215 char* jPath; 218 char* jPath;
@@ -227,12 +230,12 @@ void Recognize::executeJuliusEngine() { @@ -227,12 +230,12 @@ void Recognize::executeJuliusEngine() {
227 else 230 else
228 type = "mic"; 231 type = "mic";
229 232
230 - command.append(type).append(" -filelist ").append(path_contents).append(id).append(FILENAME_AUDIOLIST); 233 + command.append(type).append(" -filelist ").append(path_contents).append("/").append(id).append(FILENAME_AUDIOLIST);
231 sprintf(cfreq, "%i", frequency); 234 sprintf(cfreq, "%i", frequency);
232 command.append(" -smpFreq "). 235 command.append(" -smpFreq ").
233 append(cfreq). 236 append(cfreq).
234 append(" >> "); 237 append(" >> ");
235 - command.append(path_contents).append(id).append(FILENAME_RECOGNIZED_OUT); 238 + command.append(path_contents).append("/").append(id).append(FILENAME_RECOGNIZED_OUT);
236 //Command of execute Julius 239 //Command of execute Julius
237 //printf("\n\nCommand for executeJuliusEngine: %s\n", command.c_str()); 240 //printf("\n\nCommand for executeJuliusEngine: %s\n", command.c_str());
238 system(command.c_str()); 241 system(command.c_str());
@@ -242,13 +245,13 @@ void Recognize::executeJuliusEngine() { @@ -242,13 +245,13 @@ void Recognize::executeJuliusEngine() {
242 void Recognize::generateConfidence() { 245 void Recognize::generateConfidence() {
243 246
244 string command = "cat "; 247 string command = "cat ";
245 - command.append(path_contents).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep ").  
246 - append(FIND_CONFIDENCE).append(" >> ").append(path_contents).append(id).append(FILENAME_CONFIDENCEOUT); 248 + command.append(path_contents).append("/").append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep ").
  249 + append(FIND_CONFIDENCE).append(" >> ").append(path_contents).append("/").append(id).append(FILENAME_CONFIDENCEOUT);
247 system(command.c_str()); 250 system(command.c_str());
248 //printf("\n\n---> command: %s\n\n", command.c_str()); 251 //printf("\n\n---> command: %s\n\n", command.c_str());
249 252
250 string path; 253 string path;
251 - path.append(path_contents).append(id).append(FILENAME_CONFIDENCEOUT); 254 + path.append(path_contents).append("/").append(id).append(FILENAME_CONFIDENCEOUT);
252 ifstream in(path.c_str()); 255 ifstream in(path.c_str());
253 256
254 if (!in) { 257 if (!in) {
@@ -293,13 +296,11 @@ void Recognize::generateConfidence() { @@ -293,13 +296,11 @@ void Recognize::generateConfidence() {
293 296
294 }else if(pass==0){ 297 }else if(pass==0){
295 notifyListeners((char*) "SENTENCA_COM_BAIXA_QUALIDADE", 0); 298 notifyListeners((char*) "SENTENCA_COM_BAIXA_QUALIDADE", 0);
296 - notifyEndExtraction(count_lines);  
297 return; 299 return;
298 } 300 }
299 } while (!in.eof()); 301 } while (!in.eof());
300 in.close(); 302 in.close();
301 filterOutputJulius(); 303 filterOutputJulius();
302 - notifyEndExtraction(count_lines);  
303 } 304 }
304 } 305 }
305 306
@@ -317,15 +318,15 @@ void Recognize::filterOutputJulius() { @@ -317,15 +318,15 @@ void Recognize::filterOutputJulius() {
317 sentences = new std::list<char*>(); 318 sentences = new std::list<char*>();
318 319
319 string command = "cat "; 320 string command = "cat ";
320 - command.append(path_contents).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep -e ").  
321 - append(FIND_SENTENCE).append(" -e \"").append(AUDIO_SILENT).append("\"").append(" >> ").append(path_contents).append(id).append(FILENAME_FILTEROUT); 321 + command.append(path_contents).append("/").append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep -e ").
  322 + append(FIND_SENTENCE).append(" -e \"").append(AUDIO_SILENT).append("\"").append(" >> ").append(path_contents).append("/").append(id).append(FILENAME_FILTEROUT);
322 system(command.c_str()); 323 system(command.c_str());
323 //printf("\n\n---> command: %s\n\n", command.c_str()); 324 //printf("\n\n---> command: %s\n\n", command.c_str());
324 325
325 count_lines = 0; 326 count_lines = 0;
326 327
327 string path; 328 string path;
328 - path.append(path_contents).append(id).append(FILENAME_FILTEROUT); 329 + path.append(path_contents).append("/").append(id).append(FILENAME_FILTEROUT);
329 ifstream in(path.c_str()); 330 ifstream in(path.c_str());
330 string strFilter; 331 string strFilter;
331 332
@@ -369,13 +370,15 @@ void Recognize::notifyListeners(char* text, int64_t pts) { @@ -369,13 +370,15 @@ void Recognize::notifyListeners(char* text, int64_t pts) {
369 //cout << "NOTIFY: " << text << endl; 370 //cout << "NOTIFY: " << text << endl;
370 371
371 for(list<RecognizeListener*>::iterator it = listeners->begin(); it != listeners->end(); it++){ 372 for(list<RecognizeListener*>::iterator it = listeners->begin(); it != listeners->end(); it++){
372 - (*it)->notifyTextRecognized((unsigned char*) text, calcula_pts(pts)); 373 + //(*it)->notifyTextRecognized((unsigned char*) text, calcula_pts(pts));
  374 + (*it)->notifyTextRecognized((unsigned char*) text, pts);
  375 +
373 } 376 }
374 377
375 } 378 }
376 379
377 void Recognize::notifyEndExtraction(int sentences_size) { 380 void Recognize::notifyEndExtraction(int sentences_size) {
378 - DPRINTF("Recognizer concluiu o reconhecimento: %d sentenças.\n", sentences_size); 381 + PRINTL(util::_DEBUG, "Recognizer concluiu o reconhecimento: %d sentenças.\n", sentences_size);
379 for(list<RecognizeListener*>::iterator it = listeners->begin(); it != listeners->end(); it++){ 382 for(list<RecognizeListener*>::iterator it = listeners->begin(); it != listeners->end(); it++){
380 (*it)->notifyEnd(sentences_size); 383 (*it)->notifyEnd(sentences_size);
381 } 384 }
@@ -406,15 +409,119 @@ bool Recognize::isFinished() { @@ -406,15 +409,119 @@ bool Recognize::isFinished() {
406 void Recognize::cleanFiles() { 409 void Recognize::cleanFiles() {
407 410
408 string command = "rm -r "; 411 string command = "rm -r ";
409 - command.append(path_contents).append(id).append("/audio"); 412 + command.append(path_contents).append("/").append(id).append("/audio");
410 system(command.c_str()); 413 system(command.c_str());
411 } 414 }
412 415
413 void Recognize::createDir(){ 416 void Recognize::createDir(){
414 417
415 - string command = "mkdir ";  
416 - command.append(path_contents).append(id).append("/audio")  
417 - .append(" && mkdir ").append(path_contents).append(id).append("/audio/parts")  
418 - .append(" && mkdir ").append(path_contents).append(id).append("/audio/origin"); 418 + string command = "mkdir -p ";
  419 + command.append(path_contents).append("/").append(id).append("/audio")
  420 + .append(" && mkdir -p ").append(path_contents).append("/").append(id).append("/audio/parts")
  421 + .append(" && mkdir -p ").append(path_contents).append("/").append(id).append("/audio/origin");
419 system(command.c_str()); 422 system(command.c_str());
420 } 423 }
  424 +
  425 +void Recognize::executeGoogleEngine() {
  426 + jlog_set_output(NULL);
  427 +
  428 + Wavcut* wavcut;
  429 + Recognizer* recog;
  430 +
  431 + vector<Audiofile> audioList;
  432 + string file_in = "";
  433 + file_in.append(path_contents).append("/").append(id).append(PATH_AUDIO_ORIGIN);
  434 + string path_out= "";
  435 + path_out.append(path_contents).append("/").append(id).append("/");
  436 + char* pathAudio = new char[file_in.size()+1];
  437 + char* outputPath = new char[path_out.size()+1];
  438 + char* _id = new char[id.size()+1];
  439 + strcpy(pathAudio, file_in.c_str());
  440 + strcpy(outputPath, path_out.c_str());
  441 + strcpy(_id, id.c_str());
  442 +
  443 +
  444 + wavcut = new Wavcut(pathAudio,outputPath,_id);
  445 + Jconf *jconf;
  446 +
  447 + char* wPath;
  448 + wPath = getenv("WCONFIG");
  449 +
  450 + if(wPath != NULL)
  451 + jconf = j_config_load_file_new(wPath);
  452 + else
  453 + jconf = j_config_load_file_new(PATH_WCONFIG);
  454 +
  455 + if(wavcut->initialize(jconf)<2){
  456 +
  457 + wavcut->initialize(load_config());
  458 + }
  459 +
  460 + audioList = wavcut->list_audio_files();
  461 +
  462 +
  463 + delete wavcut;
  464 + recog = new Recognizer();
  465 +
  466 + int ii;
  467 + count_lines = 0;
  468 + for(ii=0; ii < audioList.size(); ii++)
  469 + {
  470 +
  471 + /*chama o reconhecedor passando cada arquivo de audio*/
  472 + recog->recognize(audioList[ii].file_path);
  473 +
  474 + /*remove o audio ja reconhecido*/
  475 + remove(audioList[ii].file_path);
  476 +
  477 + /*segundos do inicio do audio reconhecido*/
  478 + //cout<< calcula_pts(audioList[ii].start_seg) << endl;
  479 +
  480 + /* texto do audio reconhecido*/
  481 + //cout<< recog->getsentence() << endl;
  482 +
  483 + /* porcentagem de confiança do reconhecimento (de 0 a 1) */
  484 + //cout<< recog->getconfidence() << endl;
  485 +
  486 + if(recog->getconfidence() >= confidenceRate)
  487 + notifyListeners((char*)recog->getsentence().c_str(), (int64_t)(audioList[ii].start_seg*1000));
  488 + else
  489 + notifyListeners((char*) "SENTENCA_COM_BAIXA_QUALIDADE", (int64_t)(audioList[ii].start_seg*1000));
  490 + if(recog->getconfidence()> 0)
  491 + count_lines++;
  492 + }
  493 + delete recog;
  494 +
  495 +}
  496 +
  497 +Jconf* Recognize::load_config(){
  498 +
  499 + Jconf* jconf;
  500 + jconf = j_jconf_new();
  501 +
  502 + char *parametros[12];
  503 +
  504 + parametros[1]="-lv";
  505 + parametros[2]="3000";
  506 + parametros[3]="-zc";
  507 + parametros[4]="150";
  508 + parametros[5]="-headmargin";
  509 + parametros[6]="200";
  510 + parametros[7]="-tailmargin";
  511 + parametros[8]="150";
  512 + parametros[9]="-rejectshort";
  513 + parametros[10]="1500";
  514 + //cout << "load_config" << endl;
  515 + /* read arguments and set parameters */
  516 + if (j_config_load_args(jconf, 11, parametros) == -1) {
  517 + fprintf(stderr, "Error reading arguments\n");
  518 +
  519 + }
  520 +
  521 + jconf->input.type = INPUT_WAVEFORM;
  522 + jconf->input.speech_input = SP_RAWFILE;
  523 + jconf->detect.silence_cut = 1;
  524 +
  525 +
  526 +return jconf;
  527 +}
recognize/src/recognizer.cpp 0 → 100644
@@ -0,0 +1,101 @@ @@ -0,0 +1,101 @@
  1 +
  2 +
  3 +
  4 +#include "recognizer.h"
  5 +#include <json/json.h>
  6 +
  7 +
  8 +static boolean reconhecendo ;
  9 +static string sentence;
  10 +static float confidence;
  11 +string lenguage = "pt-BR";
  12 +
  13 +using namespace std;
  14 +
  15 +
  16 +void resultado(Recog *recog, void *dummy);
  17 +
  18 +
  19 +
  20 +Recognizer::Recognizer(){
  21 +
  22 +}
  23 +
  24 +
  25 +Recognizer::~Recognizer(){
  26 +
  27 +}
  28 +
  29 +
  30 +
  31 +int Recognizer::recognize(string file_in)
  32 +{
  33 + FILE *file;
  34 + string cmFinal;
  35 + char message[100];
  36 + message[0] = '\0';
  37 + string jsonResult ="";
  38 + string vozReconhecida = "";
  39 + int indexLineSrt =0;
  40 + stringstream comand;
  41 + stringstream index;
  42 +
  43 +
  44 + string fileName = file_in;
  45 +
  46 + // inicio preparação requisição
  47 +
  48 + comand << " curl -ss -X POST --data-binary @";
  49 + comand << fileName;
  50 +
  51 + //requisição para o google speech
  52 + comand<< " --user-agent 'Mozilla/5.0' --header 'Content-Type: audio/l16; rate=22050;' 'https://www.google.com/speech-api/v2/recognize?client=chromium&lang="<<lenguage<<"&maxresults=1&key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw'";
  53 + //AIzaSyBeeYW4l2OuCwiUfzBaUXXeWAO6Uy-u0F8'";
  54 + //public key Ezequiel project 1
  55 + //AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw'";
  56 + //fim
  57 + cmFinal = comand.str();
  58 + file = popen(cmFinal.c_str(),"r");
  59 + if(file == NULL)
  60 + printf("ERROR\n");
  61 + int vez =0;
  62 + while (fgets(message, sizeof (message), file))
  63 + {
  64 + vez++;
  65 +
  66 + if(vez>1){
  67 + jsonResult+= message;
  68 +
  69 + }
  70 + }
  71 + //cout<< jsonResult <<endl<<endl;
  72 + Json::Value root;
  73 + Json::Reader reader;
  74 + bool parsingSuccessful = reader.parse(jsonResult, root);
  75 + // cout << root["result"]<<endl;
  76 + confidence = 0.0;
  77 + sentence = "";
  78 + if (parsingSuccessful)
  79 + {
  80 + sentence = root["result"][0]["alternative"][0]["transcript"].asString();
  81 + confidence = root["result"][0]["alternative"][0]["confidence"].asFloat();
  82 + }
  83 +
  84 +
  85 + fclose(file);
  86 +
  87 + jsonResult = "";
  88 + comand.str("");
  89 +
  90 + return 1;
  91 +}
  92 +
  93 +
  94 +float Recognizer::getconfidence(){
  95 + return confidence;
  96 +}
  97 +string Recognizer::getsentence(){
  98 + // printf("palavra %s\n",sentence.c_str() );
  99 + return sentence;
  100 +}
  101 +
recognize/src/wavcut.cpp 0 → 100644
@@ -0,0 +1,187 @@ @@ -0,0 +1,187 @@
  1 +#include "wavcut.h"
  2 +
  3 +#include <vector>
  4 +// #include <iostream>
  5 +
  6 +
  7 +int sfreq = 22050; ///< Temporal storage of sample rate
  8 +int speechlen; ///< samples of one recorded segments
  9 +FILE *fp = NULL; ///< File pointer for WAV output
  10 +int sid = 0; ///< current file ID (for SPOUT_FILE)
  11 +char *outpath = NULL; ///< work space for output file name formatting
  12 +boolean writing_file = FALSE; ///< TRUE if writing to a file
  13 +int trigger_sample;
  14 +char *pathAudio;
  15 +char* outputPath;
  16 +char* id_file;
  17 +static vector<Audiofile> audioList;
  18 +
  19 +
  20 +Wavcut::Wavcut(char* _pathAudio, char* _outputPath, char* _id){
  21 +
  22 + pathAudio = _pathAudio;
  23 + outputPath = _outputPath;
  24 + id_file = _id;
  25 + //printf("%s\n","Entrou aquiiiii" )
  26 +}
  27 +
  28 +Wavcut::~Wavcut(){
  29 + //printf("%s\n","Wavcut finalizado" );
  30 +}
  31 +
  32 +
  33 +int Wavcut::adin_callback_file(SP16 *now, int len, Recog *recog)
  34 + {
  35 + /* cria novo arquivo wav para salvar o audio sem silencio*/
  36 + if (speechlen == 0) {
  37 +
  38 + sprintf(outpath, "%s%d.wav",outputPath, sid);
  39 +
  40 + if (access(outpath, F_OK) == 0) {
  41 + if (access(outpath, W_OK) != 0) {
  42 + return(-1);
  43 + }
  44 +
  45 + }
  46 +
  47 + if ((fp = wrwav_open(outpath, sfreq)) != NULL) {
  48 + //fprintf(stderr, "novo arquivo\n");
  49 + }else{
  50 + return -1;
  51 + }
  52 + writing_file = TRUE;
  53 + }
  54 +
  55 + /* write recorded sample to file */
  56 + if (wrwav_data(fp, &(now[0]), len) == FALSE) {
  57 + return -1;
  58 + }
  59 +
  60 + /* accumulate sample num of this segment */
  61 +speechlen += len;
  62 +
  63 +return(0);
  64 +}
  65 +
  66 +//acumula o tempo de cada segmento
  67 +void registra_tempo(Recog *recog, void *data)
  68 +{
  69 + trigger_sample = recog->adin->last_trigger_sample;
  70 +}
  71 +
  72 +boolean close_files()
  73 +{
  74 + if (writing_file) {
  75 +
  76 + if (wrwav_close(fp) == FALSE) {
  77 + fprintf(stderr, "adinrec: failed to close file\n");
  78 + return FALSE;
  79 + }
  80 + char* fileout=(char *)mymalloc(100);;
  81 + // sprintf(fileout,*outpath);
  82 + sprintf(fileout, outpath);
  83 + audioList.push_back(Audiofile(fileout,(float)trigger_sample / (float)sfreq,
  84 + (float)(trigger_sample + speechlen) / (float)sfreq));
  85 +
  86 + writing_file = FALSE;
  87 +}
  88 +
  89 +return TRUE;
  90 +}
  91 +
  92 +
  93 + int Wavcut::initialize(Jconf *jconf) {
  94 +
  95 + sid = 0;
  96 + audioList.clear();
  97 + //Jconf *jconf;
  98 + Recog *recog;
  99 +
  100 + int ret;
  101 + boolean is_continues;
  102 +
  103 + /* cria instancia do reconhecedor */
  104 + recog = j_recog_new();
  105 + /* carrega as configurações contidas no jconfig */
  106 + // jconf = j_config_load_file_new("/home/ezequiel/speech-recognizer/wavcut.jconf");
  107 +
  108 + jconf->input.sfreq = sfreq;
  109 + /*adciona a configuração ao reconhecedor*/
  110 + recog->jconf = jconf;
  111 +
  112 + outpath = (char *)mymalloc(256);
  113 +
  114 +/*registra calback do contador de tempo*/
  115 + callback_add(recog, CALLBACK_EVENT_SPEECH_START, registra_tempo, NULL);
  116 +
  117 + /*Inicializa o reconhecedor*/
  118 + if (j_adin_init(recog) == FALSE) {
  119 + fprintf(stderr, "Error in initializing adin device\n");
  120 + return 0;
  121 + }
  122 +
  123 + /*Abre o quivo de áudio para ser cortado*/
  124 + if(j_open_stream(recog,pathAudio) == -2)
  125 + return sid;
  126 +
  127 + /* loop de detecção de voz*/
  128 +
  129 + do {
  130 +
  131 + speechlen = 0;
  132 +
  133 + ret = adin_go(adin_callback_file, NULL, recog);
  134 +
  135 +
  136 + switch(ret) {
  137 + case -1: /* device read error or callback error */
  138 + //fprintf(stderr, "[error]\n");
  139 + break;
  140 + case 0: /* reached to end of input */
  141 + //fprintf(stderr, "[eof]\n");
  142 + return sid;
  143 + break;
  144 + default:
  145 + break;
  146 + }
  147 +
  148 + if (ret == -1) {
  149 + /* error in input device or callback function, so terminate program here */
  150 + return sid;
  151 + }
  152 + /* um intervalo de silencio detectado */
  153 +
  154 + if (close_files() == FALSE)
  155 + return sid;
  156 +
  157 + /* incremento do contador de partes cortadas */
  158 +
  159 +
  160 + sid++;
  161 +
  162 + is_continues = FALSE;
  163 + if (ret > 0 || ret == -2) {
  164 + is_continues = TRUE;
  165 + }
  166 +
  167 + } while (is_continues);
  168 +
  169 + /*Quando termina de ler todo áudio finaliza*/
  170 + adin_end(recog->adin);
  171 +
  172 + return sid;
  173 +
  174 +}
  175 +
  176 +vector<Audiofile> Wavcut::list_audio_files(){
  177 +
  178 +
  179 + return audioList;
  180 +}
  181 +
  182 +
  183 +
  184 +
  185 +
  186 +
  187 +
recognize/src/wavcut.jconf 0 → 100644
@@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
  1 +-smpFreq 22050
  2 +-lv 1000
  3 +-zc 60
  4 +-headmargin 200
  5 +-tailmargin 150
  6 +-rejectshort 1500
  7 +-input rawfile
  8 +-cutsilence
  9 +
  10 +
  11 +
  12 +#-smpFreq 22050
  13 +#-lv 3000
  14 +#-zc 150
  15 +#-headmargin 200
  16 +#-tailmargin 150
  17 +#-rejectshort 1500
  18 +#-input rawfile
  19 +#-cutsilence
  20 +
  21 +
  22 +
  23 +
  24 +
renderer/src/include/listenerRenderer.h 0 → 100644
@@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
  1 +/**
  2 + * \file listenerRenderer.h
  3 + */
  4 +
  5 +#ifndef LISTENER_RENDERER_H
  6 +#define LISTENER_RENDERER_H
  7 +
  8 +#include <string>
  9 +#include <stdint.h>
  10 +
  11 +using namespace std;
  12 +
  13 +class ListenerRenderer {
  14 +public:
  15 + virtual void notifyEndOfRenderization() = 0;
  16 +};
  17 +
  18 +#endif /* LISTENER_RENDERER_H */
0 \ No newline at end of file 19 \ No newline at end of file
renderer/src/include/renderer.h 0 → 100644
@@ -0,0 +1,114 @@ @@ -0,0 +1,114 @@
  1 +/**
  2 + * \file renderer.h
  3 + *
  4 + * \author Wesnydy Lima Ribeiro <wesnydy@lavid.ufpb.br>
  5 + * \date 2015
  6 + */
  7 +
  8 +#ifndef RENDERER_H
  9 +#define RENDERER_H
  10 +
  11 +#include <list>
  12 +#include <queue>
  13 +#include <sstream>
  14 +#include <stdint.h>
  15 +#include <unistd.h>
  16 +#include "string.h"
  17 +#include "jthread.h"
  18 +#include "logging.h"
  19 +#include "listenerRenderer.h"
  20 +#include <lavidlib/net/InetAddress.h>
  21 +#include <lavidlib/net/StreamSocket.h>
  22 +#include <lavidlib/net/SocketException.h>
  23 +#include <lavidlib/base/RuntimeException.h>
  24 +#include <lavidlib/net/UnknownHostException.h>
  25 +
  26 +#define HOST "0.0.0.0"
  27 +#define PORT 5555
  28 +
  29 +#define OK_FLAG "OK"
  30 +#define END_FLAG "FINALIZE"
  31 +#define BADSENTENCE "SENTENCACOMBAIXAQUALIDADE"
  32 +#define BADTEXT "ESCOLHER TEXTO CERTO"
  33 +
  34 +#define PATH_RENDERER "vlibras_user/unityVideo/"
  35 +#define PATH_SCREENS "vlibras_user/.config/unity3d/LAViD/VLibrasVideoMaker/"
  36 +
  37 +using namespace jthread;
  38 +using namespace lavidlib;
  39 +using namespace std;
  40 +using namespace util;
  41 +
  42 +/** \brief Classe que implementa o Renderizador.
  43 + *
  44 + * \headerfile renderer/src/include/renderer.h
  45 + */
  46 +class Renderer : public Thread {
  47 +
  48 +public:
  49 + /** Construtor.
  50 + *
  51 + * \param path_contents Abstração do path do vídeo de saída.
  52 + * \param id Identificação do usuário.
  53 + */
  54 + Renderer(char* path_Contents, char* id);
  55 +
  56 + /** Destrutor. */
  57 + ~Renderer();
  58 +
  59 + /** Inicia os processos do renderizador.
  60 + *
  61 + * Inicia o servidor do Unity Player,
  62 + * faz a conexão do Core com o Player
  63 + * e da inicio ao envio das glosas para
  64 + * a geração do vídeo de LIBRAS.
  65 + */
  66 + void initialize();
  67 +
  68 + /** Adiciona ouvintes do renderer.
  69 + *
  70 + * \param listener O ouvinte a ser registrado.
  71 + */
  72 + void addListener(ListenerRenderer* listener);
  73 +
  74 + /** Recebe a glosa q será enviada para o player.
  75 + *
  76 + * \param glosa A glosa que será enviada.
  77 + * \param pts A etiqueta de tempo da glosa.
  78 + */
  79 + void receiveGlosa(string glosa, int64_t pts);
  80 +
  81 +private:
  82 + char* userID;
  83 + char* pathOutVideo;
  84 +
  85 + StreamSocket* cSocket;
  86 + queue <string> glosaQueue;
  87 + list<ListenerRenderer*>* listeners;
  88 +
  89 + /** Executa o script que inicia o servidor do Player. */
  90 + void executeServerScript();
  91 +
  92 + /** Faz a conexão do Core com o Player. */
  93 + void connectToUnityPlayer();
  94 +
  95 + /** Envia as glosas para o Player. */
  96 + void exportGlosa();
  97 +
  98 + /** Renderiza o vídeo de LIBRAS. */
  99 + void renderVideo();
  100 +
  101 + /** Aguarda o Player capturar as screenshots. */
  102 + void waitScreenShots();
  103 +
  104 + /** Notifica o fim da renderização. */
  105 + void notifyListeners();
  106 +
  107 + /** Deleta os arquivos temporários */
  108 + void cleanFiles();
  109 +
  110 + /** Chamado quando a Thread é iniciada. */
  111 + void Run();
  112 +};
  113 +
  114 +#endif /* RENDERER_H */
0 \ No newline at end of file 115 \ No newline at end of file
renderer/src/renderer.cpp 0 → 100644
@@ -0,0 +1,190 @@ @@ -0,0 +1,190 @@
  1 +#include "renderer.h"
  2 +
  3 +Renderer::Renderer(char* path_Contents, char* id) {
  4 + this->pathOutVideo = path_Contents;
  5 + this->userID = id;
  6 + cSocket = new StreamSocket();
  7 + listeners = new list<ListenerRenderer*>();
  8 + PRINTL(util::_DEBUG, "Renderer Done!\n");
  9 +}
  10 +
  11 +Renderer::~Renderer() {
  12 + listeners->clear();
  13 + delete listeners;
  14 + if(cSocket) delete cSocket;
  15 + PRINTL(util::_DEBUG, "Renderer finalized!\n");
  16 +}
  17 +
  18 +void Renderer::addListener(ListenerRenderer* listener) {
  19 + listeners->push_back(listener);
  20 +}
  21 +
  22 +void Renderer::notifyListeners() {
  23 + PRINTL(util::_DEBUG, "Renderização finalizada!\n");
  24 + for (list<ListenerRenderer*>::iterator i = listeners->begin(); i != listeners->end(); i++) {
  25 + (*i)->notifyEndOfRenderization();
  26 + }
  27 +}
  28 +
  29 +void Renderer::executeServerScript() {
  30 + PRINTL(util::_DEBUG, "Executando o Script de inicialização do servidor\n");
  31 +
  32 + //Temporário. 'Matar' todos os processos do player.
  33 + string killcmd = "killall -9 videoCreator.x86_64 > /dev/null 2>&1";
  34 + system(killcmd.c_str());
  35 + sleep(2); //tempo para matar o processo
  36 +
  37 + string command = "cd ";
  38 +
  39 + char* renderPath;
  40 + renderPath = getenv("RENDERER");
  41 + if(renderPath != NULL)
  42 + command.append(renderPath);
  43 + else
  44 + command.append(PATH_RENDERER);
  45 +
  46 + command.append(" && ").append("python render.py ")
  47 + .append(userID).append(" >/dev/null 2>&1 &");
  48 + system(command.c_str());
  49 +}
  50 +
  51 +void Renderer::connectToUnityPlayer() {
  52 + try{
  53 + int i = 0; // Contador de tentativas
  54 + static InetAddress* addr = InetAddress::createByName(HOST);
  55 +
  56 + PRINTL(util::_DEBUG, "Conectando ao UnityPlayer...\n");
  57 + while(!cSocket->isConnected()){
  58 + try{
  59 +
  60 + cSocket->connect(addr, PORT);
  61 +
  62 + }catch(lavidlib::SocketException &ex){
  63 + if(i < 10) { // Numeros de tentativas de conexão (pode ser alterado)
  64 + i++;
  65 + sleep(1);
  66 + }else{
  67 + PRINTL(util::_ERROR, "Número de tentativas de conexão excedido!\n");
  68 + throw lavidlib::RuntimeException(ex.getMessage().c_str());
  69 + }
  70 + }
  71 + }
  72 + }catch(lavidlib::UnknownHostException &ex){
  73 + throw lavidlib::RuntimeException(ex.getMessage().c_str());
  74 + }
  75 +}
  76 +
  77 +//Armazena as glosas em uma fila até q o método initialize() seja chamado p/ fazer os envios
  78 +void Renderer::receiveGlosa(string glosa, int64_t pts) {
  79 + ostringstream oss;
  80 + string formatedGlosa; //Formato da glosa que será enviada para o player: "glosa#pts"
  81 +
  82 + if(glosa == BADSENTENCE || glosa == BADTEXT)
  83 + formatedGlosa = ""; //O player entende "#pts" como pose neutra
  84 + else
  85 + formatedGlosa = glosa;
  86 +
  87 + oss << pts;
  88 + formatedGlosa += "#";
  89 + formatedGlosa += oss.str();
  90 + glosaQueue.push(formatedGlosa);
  91 +}
  92 +
  93 +void Renderer::exportGlosa() {
  94 + if(glosaQueue.empty())
  95 + throw lavidlib::RuntimeException("Fila de glosas vazia!");
  96 +
  97 + int glosaSize;
  98 + char* glosaBff;
  99 +
  100 + string glosaCpy = glosaQueue.front(); //Pega quem estiver na frente da fila
  101 + glosaSize = strlen(glosaCpy.c_str())+1;
  102 + glosaBff = new char[glosaSize];
  103 + strcpy(glosaBff, glosaCpy.c_str());
  104 +
  105 + try {
  106 + cSocket->write(glosaBff, glosaSize); //Envia a glosa formatada p/ o player
  107 + }catch(lavidlib::IOException &ex){
  108 + throw lavidlib::RuntimeException(ex.getMessage().c_str());
  109 + }
  110 +
  111 + char* received = new char[3]; //Mensagem de confirmação de recebimento da glosa: "OK\0"
  112 + do {
  113 + try {
  114 + cSocket->read(received, 3); //Aguarda a confirmação
  115 + }catch(lavidlib::IOException &ex){
  116 + throw lavidlib::RuntimeException(ex.getMessage().c_str());
  117 + }
  118 + }while(strcmp(received, OK_FLAG) != 0); //Verifica se é a confirmação correta
  119 +
  120 + glosaQueue.pop(); //Se o envio foi bem sucedido, remove a glosa da fila
  121 +
  122 + delete [] glosaBff;
  123 + delete [] received;
  124 +}
  125 +
  126 +void Renderer::waitScreenShots() {
  127 + int endSize;
  128 + char* finalize;
  129 +
  130 + endSize = strlen(END_FLAG)+1;
  131 + finalize = new char[endSize];
  132 +
  133 + PRINTL(util::_DEBUG, "Aguardando a captura das ScreenShots.\n");
  134 + do {
  135 + try {
  136 + cSocket->read(finalize, endSize); //Aguarda o player notificar o fim da captura das ScreenShots
  137 + }catch(lavidlib::IOException &ex){
  138 + throw lavidlib::RuntimeException(ex.getMessage().c_str());
  139 + }
  140 + }while(strcmp(finalize, END_FLAG) != 0); //Verifica se é a mensagem correta ("FINALIZE\0")
  141 +
  142 + cSocket->close();
  143 +}
  144 +
  145 +void Renderer::renderVideo() {
  146 + PRINTL(util::_DEBUG, "Renderizando...\n");
  147 + string command = "ffmpeg -y -loglevel quiet -framerate 30 -i ";
  148 + command.append(PATH_SCREENS).append(userID).append("/frame_%d.png ")
  149 + .append("-vcodec libx264 -pix_fmt yuv420p ").append(pathOutVideo);
  150 + system(command.c_str());
  151 +}
  152 +
  153 +void Renderer::initialize() {
  154 + executeServerScript();
  155 + try{
  156 + connectToUnityPlayer();
  157 + }catch(lavidlib::RuntimeException &ex){
  158 + throw lavidlib::RuntimeException(ex.getMessage().c_str());
  159 + }
  160 + this->Start();
  161 +}
  162 +
  163 +void Renderer::Run() {
  164 + PRINTL(util::_DEBUG, "Enviando glosas para o player...\n");
  165 + while(!glosaQueue.empty()){ //Inicia o envio das glosas que estão na fila
  166 + try{
  167 + exportGlosa();
  168 + }catch(lavidlib::RuntimeException &ex){
  169 + throw lavidlib::RuntimeException(ex.getMessage().c_str());
  170 + }
  171 + }
  172 +
  173 + PRINTL(util::_INFO, "Gerando vídeo...\n");
  174 + receiveGlosa(END_FLAG, -1); //Quando a fila estiver vazia, a flag "FINALIZE" será enviada
  175 + try{
  176 + exportGlosa();
  177 + waitScreenShots();
  178 + }catch(lavidlib::RuntimeException &ex){
  179 + throw lavidlib::RuntimeException(ex.getMessage().c_str());
  180 + }
  181 + renderVideo();
  182 + notifyListeners();
  183 + cleanFiles();
  184 +}
  185 +
  186 +void Renderer::cleanFiles() {
  187 + string clean = "rm -rf ";
  188 + clean.append(PATH_SCREENS).append(userID).append("/");
  189 + system(clean.c_str());
  190 +}
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 0 → 100644
@@ -0,0 +1,113 @@ @@ -0,0 +1,113 @@
  1 +/**
  2 + * \file serviceTester.h
  3 + *
  4 + * \author Wesnydy Lima Ribeiro <wesnydy@lavid.ufpb.br>
  5 + * \date 2015
  6 + */
  7 +
  8 +#ifndef SERVICETESTER_H
  9 +#define SERVICETESTER_H
  10 +
  11 +#include <iostream>
  12 +#include <lavidlib/io/File.h>
  13 +#include <lavidlib/io/FileIO.h>
  14 +#include "serviceException.h"
  15 +#include "serviceWindowGenerationFromRec.h"
  16 +#include "serviceWindowGenerationFromSubtitle.h"
  17 +#include "serviceWindowGenerationFromText.h"
  18 +
  19 +#define MODE_TEST 3
  20 +#define TESTER_ID "Test"
  21 +#define PATH_TEST_CONTENTS "vlibras_user/.vlibras-config/test/videos"
  22 +#define PATH_TEST_UPLOADS "vlibras_user/.vlibras-config/test/uploads"
  23 +
  24 +#define VID_FILE "vlibras_user/.vlibras-config/test/uploads/test_video.mp4"
  25 +#define SRT_FILE "vlibras_user/.vlibras-config/test/uploads/test_srt.srt"
  26 +#define REC_FILE "vlibras_user/.vlibras-config/test/uploads/test_rec.mov"
  27 +#define TXT_FILE "vlibras_user/.vlibras-config/test/uploads/test_text.txt"
  28 +#define OUT_FILE "vlibras_user/.vlibras-config/test/videos/Test.mp4"
  29 +
  30 +using namespace util;
  31 +using namespace std;
  32 +
  33 +/** \brief Classe que implementa o serviço de testes.
  34 + *
  35 + * \headerfile servico/src/include/serviceTester.h
  36 + */
  37 +class ServiceTester: public Thread {
  38 +
  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 + */
  46 + ServiceTester(int position, int size, int background);
  47 +
  48 + /** Destrutor */
  49 + ~ServiceTester();
  50 +
  51 + /** Indica o fim do processo de testes dos módulos.
  52 + *
  53 + * \return O status do do processo.
  54 + */
  55 + bool isFinished();
  56 +
  57 +private:
  58 + int position;
  59 + int resolution;
  60 + int background;
  61 +
  62 + bool fail;
  63 + bool finish;
  64 + string msgErr;
  65 +
  66 + File* fIn;
  67 + File* fOut;
  68 + FileIO* fIO_in;
  69 + FileIO* fIO_out;
  70 +
  71 + ServiceWindowGenerationFromRec* service_rec;
  72 + ServiceWindowGenerationFromSubtitle* service_srt;
  73 + ServiceWindowGenerationFromText* service_text;
  74 +
  75 + /** Checa o serviço de vídeo com legendas */
  76 + void checkServiceSRT();
  77 +
  78 + /** Checa o serviço de reconhecimento de vídeo */
  79 + void checkServiceRec();
  80 +
  81 + /** Checa o serviço de tradução de texto */
  82 + void checkServiceText();
  83 +
  84 + /** Este método é chamado quando a Thread for iniciada. */
  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 + */
  91 + bool hasFailed();
  92 +
  93 + /** Remove os arquivos temporários, gerados pelos processos.*/
  94 + void deleteFiles();
  95 +
  96 + /** Define o path dos arquivos temporários. */
  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 + */
  110 + bool checkFiles(string fileIn, string fileOut);
  111 +};
  112 +
  113 +#endif /* SERVICETESTER_H */
0 \ No newline at end of file 114 \ No newline at end of file
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
4 #include <vector> 8 #include <vector>
  9 +#include <iostream>
5 #include <stdint.h> 10 #include <stdint.h>
6 #include <string> 11 #include <string>
  12 +#include <sstream>
7 #include <locale> 13 #include <locale>
8 #include "jthread.h" 14 #include "jthread.h"
9 -#include "dprintf.h"  
10 -#include "Mixer.h"  
11 -#include "synchronizer.h"  
12 -#include "listenerSynchronizer.h" 15 +#include "logging.h"
  16 +#include "mixer.h"
  17 +#include "renderer.h"
  18 +#include "listenerRenderer.h"
13 #include "listenerTradutor.h" 19 #include "listenerTradutor.h"
14 #include "tradutorPortGlosa.h" 20 #include "tradutorPortGlosa.h"
15 #include "serviceException.h" 21 #include "serviceException.h"
16 -#include <json/json.h> 22 +#include <json/json.h>
17 #include <lavidlib/base/RuntimeException.h> 23 #include <lavidlib/base/RuntimeException.h>
18 24
19 -#define DEVELOPER "devel"  
20 -#define PRODUCTION "prod"  
21 -#define BASEDIR "vlibras_user/dicionario_libras/"  
22 -#define BASEDIRTRANSP "vlibras_user/dicionarioTransp_libras/"  
23 -#define VIDEO_POSE_NEUTRA "poseneutra"  
24 -#define EXTENSAO_DICIONARIO ".ts"  
25 -#define PATH_DEVEL "vlibras_user/vlibras-contents/videos/"  
26 -#define PATH_DEVEL_UPLOADS "vlibras_user/vlibras-contents/uploads/"  
27 -#define PATH_VBOX_UPLOADS "vlibras_user/.vlibras-conf/uploads/"  
28 -#define PATH_CONF_FILE "vlibras_user/.vlibras-conf/param.json" 25 +#define DEVELOPER 1
  26 +#define PRODUCTION 2
  27 +#define TESTER 3
  28 +#define PATH_DEVEL_CONTENTS "vlibras_user/vlibras-contents/videos"
  29 +#define PATH_DEVEL_UPLOADS "vlibras_user/vlibras-contents/uploads"
  30 +#define PATH_TESTER_CONTENTS "vlibras_user/.vlibras-config/test/videos"
  31 +#define PATH_TESTER_UPLOADS "vlibras_user/.vlibras-config/test/uploads"
  32 +#define PATH_VBOX_UPLOADS "vlibras_user/.vlibras-config/uploads"
  33 +#define PATH_CONF_FILE "vlibras_user/.vlibras-config/params.json"
  34 +#define PATH_TESTER_FILE "/home/user/.vlibras-config/test/tester.json"
29 #define MAX_SIZE_PATH 256 35 #define MAX_SIZE_PATH 256
30 36
31 -using namespace Json;  
32 using namespace Tradutor; 37 using namespace Tradutor;
33 using namespace jthread; 38 using namespace jthread;
34 using namespace std; 39 using namespace std;
  40 +using namespace lavidlib;
  41 +using namespace util;
35 42
  43 +/** \brief A classe base para todos os serviços.
  44 + *
  45 + * \headerfile servico/src/include/serviceWindowGeneration.h
  46 + */
36 class ServiceWindowGeneration { 47 class ServiceWindowGeneration {
37 48
38 protected: 49 protected:
39 TradutorPortGlosa* tradutor; 50 TradutorPortGlosa* tradutor;
40 - Synchronizer* sincronizador; 51 + Renderer* renderer;
41 Mixer* mixer; 52 Mixer* mixer;
42 53
43 - Value root;  
44 - Reader reader; 54 + Json::Value root;
  55 + Json::Reader reader;
45 vector<int64_t>* vetor_pts; 56 vector<int64_t>* vetor_pts;
46 57
47 bool finish; 58 bool finish;
@@ -49,10 +60,10 @@ protected: @@ -49,10 +60,10 @@ protected:
49 bool parsingSuccessful; 60 bool parsingSuccessful;
50 61
51 char* path_input; 62 char* path_input;
  63 + char* path_client;
52 char* path_libras; 64 char* path_libras;
53 char* path_contents; 65 char* path_contents;
54 char* path_uploads; 66 char* path_uploads;
55 - char* client_type;  
56 char* user_id; 67 char* user_id;
57 68
58 int size; 69 int size;
@@ -60,20 +71,36 @@ protected: @@ -60,20 +71,36 @@ protected:
60 int transparency; 71 int transparency;
61 int sub_language; 72 int sub_language;
62 int service_type; 73 int service_type;
  74 + int exec_mode;
63 int numero_legendas; 75 int numero_legendas;
64 int legendas_enviadas; 76 int legendas_enviadas;
65 77
  78 + /** Seta o número de legendas.
  79 + *
  80 + * \param sub_size A quantidade de legendas.
  81 + */
66 virtual void setSizeOfSubtitles(int sub_size) = 0; 82 virtual void setSizeOfSubtitles(int sub_size) = 0;
67 - virtual void setPathContents() = 0;  
68 - virtual void setPathLibras() = 0;  
69 - virtual void setBackground() = 0;  
70 83
71 - //virtual void transcodeVideoToWebm();  
72 - virtual void transcodeVideoToMp4() = 0; 84 + /** Define o path dos arquivos de saída. */
  85 + virtual void setPathContents() = 0;
73 86
74 public: 87 public:
  88 + /** Define o path do vídeo de LIBRAS. */
  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
@@ -7,36 +11,119 @@ @@ -7,36 +11,119 @@
7 11
8 #define SERVICE_TYPE_REC 2 12 #define SERVICE_TYPE_REC 2
9 #define SERVICE_TYPE_REC_ONLY_AUDIO 5 13 #define SERVICE_TYPE_REC_ONLY_AUDIO 5
  14 +#define SERVICE_TYPE_REC_UNMIXED 6
10 15
11 -class ServiceWindowGenerationFromRec : public ServiceWindowGeneration, public RecognizeListener, public ListenerTradutor, public ListenerSynchronizer, public Thread { 16 +/** \brief Classe que implementa o serviço de Reconhecimento.
  17 + *
  18 + * \headerfile servico/src/include/serviceWindowGenerationFromRec.h
  19 + */
  20 +class ServiceWindowGenerationFromRec : public ServiceWindowGeneration, public RecognizeListener, public ListenerTradutor, public ListenerRenderer, public Thread {
12 21
13 private: 22 private:
14 Recognize* rec; 23 Recognize* rec;
15 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 + */
16 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 + */
17 void setSizeOfSubtitles(int sub_size); 37 void setSizeOfSubtitles(int sub_size);
18 - void setPathContents(); 38 +
  39 + /** Define o path do vídeo de LIBRAS. */
19 void setPathLibras(); 40 void setPathLibras();
20 - void setBackground();  
21 41
22 - void transcodeVideoToMp4();  
23 - void createThumbnail(); 42 + /** Define o path dos arquivos de saída.
  43 + *
  44 + * \exception RuntimeException Se houver algum erro durante a execução.
  45 + */
  46 + void setPathContents();
  47 +
  48 + /** Indica se o serviço está sendo executado.
  49 + *
  50 + * \return O status do serviço.
  51 + */
24 bool isRunning(); 52 bool isRunning();
25 public: 53 public:
26 - ServiceWindowGenerationFromRec(char* pathVideo, int sublanguage, int position, int size,  
27 - int transparency, char* id, int serviceType, char* rate);  
28 - ServiceWindowGenerationFromRec(char* pathVideo, int sublanguage, int pos, int size,  
29 - int transp, char* id, char* client, int serviceType); 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 + */
  66 + ServiceWindowGenerationFromRec(char* pathVideo, int position, int size,
  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 + */
  79 + ServiceWindowGenerationFromRec(char* pathVideo, int pos, int size,
  80 + int transp, char* id, int mode, int serviceType);
  81 +
  82 + /** Destrutor */
30 ~ServiceWindowGenerationFromRec(); 83 ~ServiceWindowGenerationFromRec();
31 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 + */
32 void notifyTextRecognized(unsigned char* text, int64_t pts); 90 void notifyTextRecognized(unsigned char* text, int64_t pts);
33 - void notifyTranslation(vector<string>* glosas); 91 +
  92 + /** Recebe a notificação do fim da renderização do vídeo */
  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 + */
  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 + */
34 void notifyTranslator(unsigned char* text); 106 void notifyTranslator(unsigned char* text);
35 - void notifyEndOfSynchronization(); 107 +
  108 + /** Notifica o fim do reconhecimento.
  109 + *
  110 + * \param sentences_size O número de sentenças reconhecidas.
  111 + */
36 void notifyEnd(int sentences_size); 112 void notifyEnd(int sentences_size);
37 113
  114 + /** Inicia o serviço de reconhecimento.
  115 + *
  116 + * \exception ServiceException Se houver algum erro durante a execução.
  117 + */
38 void initialize(); 118 void initialize();
  119 +
  120 + /** Indica o fim do processo do serviço.
  121 + *
  122 + * \return O status do processo.
  123 + */
39 bool isFinished(); 124 bool isFinished();
  125 +
  126 + /** Este método é chamado quando a Thread for iniciada. */
40 void Run(); 127 void Run();
41 }; 128 };
42 129
servico/src/include/serviceWindowGenerationFromSRT.h
@@ -1,47 +0,0 @@ @@ -1,47 +0,0 @@
1 -#ifndef SERVICEWINDOWGENERATIONFROMSRT_H  
2 -#define SERVICEWINDOWGENERATIONFROMSRT_H  
3 -  
4 -#include "listenerSRT.h"  
5 -#include "extratorFactory.h"  
6 -#include "serviceWindowGeneration.h"  
7 -  
8 -#define SERVICE_TYPE_SRT 1  
9 -#define SERVICE_TYPE_SRT_ONLY 4  
10 -  
11 -class ServiceWindowGenerationFromSRT : public ServiceWindowGeneration, public ListenerSRT, public ListenerTradutor, public ListenerSynchronizer, public Thread {  
12 -  
13 -private:  
14 - ExtratorFactory* extrator_factory;  
15 - ExtratorSRT* extratorSRT;  
16 -  
17 - char* path_srt;  
18 -  
19 - void addPTS(int64_t pts);  
20 - void setSizeOfSubtitles(int sub_size);  
21 - void setPathContents();  
22 - void setPathLibras();  
23 - void setBackground();  
24 -  
25 - void transcodeVideoToMp4();  
26 - void createThumbnail();  
27 - bool isRunning();  
28 -public:  
29 - //construtor de serviço de video e legenda  
30 - ServiceWindowGenerationFromSRT(char* pathVideo, char* pathSRT, int sublanguage, int pos,  
31 - int size, int transp, char* id, char* client, int serviceType);  
32 - //construtor de serviço de somente legenda  
33 - ServiceWindowGenerationFromSRT(char* pathSRT, int transparency, char* id, char* client, int serviceType);  
34 - ~ServiceWindowGenerationFromSRT();  
35 -  
36 - void notifySubtitle(unsigned char* subtitle, int64_t pts);  
37 - void notifyTranslation(vector<string>* glosas);  
38 - void notifyTranslator(unsigned char* text);  
39 - void notifyEndOfSynchronization();  
40 - void notifyEnd(int sub_size);  
41 -  
42 - void initialize();  
43 - bool isFinished();  
44 - void Run();  
45 -};  
46 -  
47 -#endif /* SERVICEWINDOWGENERATIONFROMSRT_H_ */  
48 \ No newline at end of file 0 \ No newline at end of file
servico/src/include/serviceWindowGenerationFromSubtitle.h 0 → 100644
@@ -0,0 +1,150 @@ @@ -0,0 +1,150 @@
  1 +/**
  2 + * \file ServiceWindowGenerationFromSubtitle.h
  3 + */
  4 +
  5 +#ifndef SERVICEWINDOWGENERATIONFROMSUB_H
  6 +#define SERVICEWINDOWGENERATIONFROMSUB_H
  7 +
  8 +#include "listenerSub.h"
  9 +#include "extratorFactory.h"
  10 +#include "serviceWindowGeneration.h"
  11 +#include <lavidlib/io/File.h>
  12 +#include <lavidlib/io/FileIO.h>
  13 +#include <lavidlib/io/BufferedReader.h>
  14 +#include <lavidlib/io/IOException.h>
  15 +#include <lavidlib/io/EOFException.h>
  16 +
  17 +#define SIGNATURE "WEBVTT"
  18 +#define SERVICE_TYPE_SRT 1
  19 +#define SERVICE_TYPE_SRT_ONLY 4
  20 +
  21 +/** \brief Classe que implementa o serviço de extração de legendas.
  22 + *
  23 + * \headerfile servico/src/include/ServiceWindowGenerationFromSubtitle.h
  24 + */
  25 +class ServiceWindowGenerationFromSubtitle : public ServiceWindowGeneration, public ListenerSub, public ListenerTradutor, public ListenerRenderer, public Thread {
  26 +
  27 +private:
  28 + char* path_srt;
  29 +
  30 + ExtratorFactory* extrator_factory;
  31 + ExtratorSRT* extratorSRT;
  32 + ExtratorVTT* extratorVTT;
  33 +
  34 + File* file;
  35 + FileIO* fileIO;
  36 + BufferedReader* bffReader;
  37 +
  38 + /** Adiciona a etiqueta de tempo.
  39 + *
  40 + * Cada sentença conterá sua respectiva de tempo.
  41 + * \param pts A etiqueta de tempo.
  42 + */
  43 + void addPTS(int64_t pts);
  44 +
  45 + /** Seta o número de legendas.
  46 + *
  47 + * \param A quantidade de legendas.
  48 + * \exception ServiceException Se houver algum erro durante a execução.
  49 + */
  50 + void setSizeOfSubtitles(int sub_size);
  51 +
  52 + /** Define o path do vídeo de LIBRAS. */
  53 + void setPathLibras();
  54 +
  55 + /** Define o path dos arquivos de saída.
  56 + *
  57 + * \exception RuntimeException Se houver algum erro durante a execução.
  58 + */
  59 + void setPathContents();
  60 +
  61 + /** Retorna o extrator espefifico do arquivo de legenda. */
  62 + Extrator::ExtratorType getExtratorType();
  63 +
  64 + /** Indica se o serviço está sendo executado.
  65 + *
  66 + * \return O status do serviço.
  67 + */
  68 + bool isRunning();
  69 +public:
  70 + /** Construtor do serviço de vídeo com legendas.
  71 + *
  72 + * \param pathVideo Path do vídeo de entrada.
  73 + * \param pathSRT Path do arquivo de legendas.
  74 + * \param sublanguage Linguagem das legendas do arquivo.
  75 + * \param pos Posição do vídeo de LIBRAS em relação ao vídeo original.
  76 + * \param size Tamanho do vídeo de LIBRAS.
  77 + * \param transp Transparência do plano de fundo do vídeo.
  78 + * \param id Identificação do cliente.
  79 + * \param mode Modo de execução.
  80 + * \param serviceType Tipo do serviço.
  81 + */
  82 + ServiceWindowGenerationFromSubtitle(char* pathVideo, char* pathSRT, int sublanguage, int pos,
  83 + int size, int transp, char* id, int mode, int serviceType);
  84 +
  85 + /** Construtor do serviço de legendas.
  86 + *
  87 + * \param pathSRT Path do arquivo de legendas.
  88 + * \param sublanguage Linguagem das legendas do arquivo.
  89 + * \param transparency Transparência do plano de fundo do vídeo.
  90 + * \param id Identificação do cliente.
  91 + * \param mode Modo de execução.
  92 + * \param serviceType Tipo do serviço.
  93 + */
  94 + ServiceWindowGenerationFromSubtitle(char* pathSRT, int sublanguage, int transparency, char* id, int mode, int serviceType);
  95 +
  96 + /** Destrutor */
  97 + ~ServiceWindowGenerationFromSubtitle();
  98 +
  99 + /** Notifica novas legendas extraídas.
  100 + *
  101 + * \param subtitle A legenda extraída.
  102 + * \param pts A etiqueta de tempo da legenda.
  103 + */
  104 + void notifySubtitle(unsigned char* subtitle, uint64_t pts);
  105 +
  106 + /** Recebe a notificação do fim da renderização do vídeo */
  107 + void notifyEndOfRenderization();
  108 +
  109 + /** Recebe a notificação do fim da tradução da legenda.
  110 + *
  111 + * \param glosa A legenda traduzida.
  112 + */
  113 + void notifyTranslation(char* glosas);
  114 +
  115 + /** Envia para a tradução a legenda obtida.
  116 + *
  117 + * \param text A legenda obtida.
  118 + */
  119 + void notifyTranslator(unsigned char* text);
  120 +
  121 + /** Envia a glosa para o renderizador.
  122 + *
  123 + * \param glosa A glosa obtida.
  124 + * \exception ServiceException Se houver algum erro durante a execução.
  125 + */
  126 + void notifyRenderer(string glosa);
  127 +
  128 + /** Notifica o fim da extração de legendas.
  129 + *
  130 + * \param sub_size O número de legendas extraídas.
  131 + */
  132 + void notifyEnd(int sub_size);
  133 +
  134 + /** Inicia o serviço de extração de legendas.
  135 + *
  136 + * \exception ServiceException Se houver algum erro durante a execução.
  137 + */
  138 + void initialize();
  139 +
  140 + /** Indica o fim do processo do serviço.
  141 + *
  142 + * \return O status do processo.
  143 + */
  144 + bool isFinished();
  145 +
  146 + /** Este método é chamado quando a Thread for iniciada. */
  147 + void Run();
  148 +};
  149 +
  150 +#endif /* SERVICEWINDOWGENERATIONFROMSUB_H_ */
0 \ No newline at end of file 151 \ No newline at end of file
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,31 +11,98 @@ @@ -7,31 +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
10 -class ServiceWindowGenerationFromText : public ServiceWindowGeneration, public ListenerTXT, public ListenerTradutor, public ListenerSynchronizer, public Thread { 14 +/** \brief Classe que implementa o serviço de extração de texto.
  15 + *
  16 + * \headerfile servico/src/include/serviceWindowGenerationFromTXT.h
  17 + */
  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. */
  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 + */
17 void setPathContents(); 38 void setPathContents();
18 - void setPathLibras();  
19 - void setBackground();  
20 39
21 - void transcodeVideoToMp4(); 40 + /** Indica se o serviço está sendo executado.
  41 + *
  42 + * \return O status do serviço.
  43 + */
22 bool isRunning(); 44 bool isRunning();
23 public: 45 public:
24 - ServiceWindowGenerationFromText(char* pathFile, int transparency, char* id, char* client); 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 + */
  54 + ServiceWindowGenerationFromText(char* pathFile, int sublanguage, int transparency, char* id, int mode);
  55 +
  56 + /** Destrutor */
25 ~ServiceWindowGenerationFromText(); 57 ~ServiceWindowGenerationFromText();
26 58
  59 + /** Notifica novas linhas extraídas.
  60 + *
  61 + * \param line A linha extraída.
  62 + */
27 void notifyLine(unsigned char* line); 63 void notifyLine(unsigned char* line);
28 - void notifyTranslation(vector<string>* glosas); 64 +
  65 + /** Recebe a notificação do fim da renderização do vídeo */
  66 + void notifyEndOfRenderization();
  67 +
  68 + /** Recebe a notificação do fim da tradução do texto.
  69 + *
  70 + * \param glosa O texto traduzido.
  71 + */
  72 + void notifyTranslation(char* glosa);
  73 +
  74 + /** Envia para a tradução a linha obtida.
  75 + *
  76 + * \param text A linha obtida.
  77 + */
29 void notifyTranslator(unsigned char* text); 78 void notifyTranslator(unsigned char* text);
30 - void notifyEndOfSynchronization(); 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 + */
  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 + */
31 void notifyEnd(int line_size); 91 void notifyEnd(int line_size);
32 92
  93 + /** Inicia o serviço de extração de texto.
  94 + *
  95 + * \exception ServiceException Se houver algum erro durante a execução.
  96 + */
33 void initialize(); 97 void initialize();
  98 +
  99 + /** Indica o fim do processo do serviço.
  100 + *
  101 + * \return O status do processo.
  102 + */
34 bool isFinished(); 103 bool isFinished();
  104 +
  105 + /** Este método é chamado quando a Thread for iniciada. */
35 void Run(); 106 void Run();
36 }; 107 };
37 108
servico/src/serviceTester.cpp 0 → 100644
@@ -0,0 +1,168 @@ @@ -0,0 +1,168 @@
  1 +#include "serviceTester.h"
  2 +
  3 +ServiceTester::ServiceTester(int _position, int _size, int _background) {
  4 + if(_position != 0)
  5 + this->position = _position;
  6 + else
  7 + this->position = 3; //bottom_rigth
  8 +
  9 + if(_size != 0)
  10 + this->resolution = _size;
  11 + else
  12 + this->resolution = 2; //medium
  13 +
  14 + this->background = _background;
  15 + msgErr = "";
  16 + finish = false;
  17 + fail = false;
  18 + PRINTL(util::_DEBUG, "ServiceTester Done!\n");
  19 +}
  20 +
  21 +ServiceTester::~ServiceTester() {
  22 + PRINTL(util::_DEBUG, "ServiceTester Finalized!\n");
  23 +}
  24 +
  25 +void ServiceTester::checkServiceSRT() {
  26 + PRINTL(util::_DEBUG, "Checando extração de legenda...\n");
  27 + setPathContents();
  28 +
  29 + service_srt = new ServiceWindowGenerationFromSubtitle((char*)VID_FILE, (char*)SRT_FILE, 1, position,
  30 + resolution, background, (char*)TESTER_ID, MODE_TEST, 1);
  31 +
  32 + try{
  33 + service_srt->initialize();
  34 + }catch(ServiceException &ex){
  35 + msgErr += "Extração de legenda\n";
  36 + fail = true;
  37 + return;
  38 + }
  39 +
  40 + while(!service_srt->isFinished())
  41 + sleep(5);
  42 + delete service_srt;
  43 +
  44 + bool sucess;
  45 + sucess = checkFiles(VID_FILE, OUT_FILE);
  46 + if(!sucess){
  47 + msgErr += "Extração de legenda\n";
  48 + }
  49 + deleteFiles();
  50 +}
  51 +
  52 +void ServiceTester::checkServiceRec() {
  53 + PRINTL(util::_DEBUG, "Checando reconhecimento...\n");
  54 + setPathContents();
  55 +
  56 + service_rec = new ServiceWindowGenerationFromRec((char*)REC_FILE, 0, 0,
  57 + background, (char*)TESTER_ID, MODE_TEST, 6);// 6 serviço sem mixagem
  58 +
  59 + try{
  60 + service_rec->initialize();
  61 + }catch(ServiceException &ex){
  62 + msgErr += "Reconhecimento\n";
  63 + fail = true;
  64 + return;
  65 + }
  66 + while(!service_rec->isFinished())
  67 + sleep(5);
  68 + delete service_rec;
  69 +
  70 + bool sucess;
  71 + sucess = checkFiles(REC_FILE, OUT_FILE);
  72 + if(!sucess){
  73 + msgErr += "Reconhecimento\n";
  74 + }
  75 + deleteFiles();
  76 +}
  77 +void ServiceTester::checkServiceText() {
  78 + PRINTL(util::_DEBUG, "Checando extração de texto...\n");
  79 + setPathContents();
  80 +
  81 + service_text = new ServiceWindowGenerationFromText((char*)TXT_FILE, 1, background,
  82 + (char*)TESTER_ID, MODE_TEST);
  83 +
  84 + try{
  85 + service_text->initialize();
  86 + }catch(ServiceException &ex){
  87 + msgErr += "Extração de texto\n";
  88 + fail = true;
  89 + return;
  90 + }
  91 +
  92 + while (!service_text->isFinished())
  93 + usleep(100000); //100ms
  94 + delete service_text;
  95 +
  96 + bool sucess;
  97 + sucess = checkFiles(TXT_FILE, OUT_FILE);
  98 + if(!sucess){
  99 + msgErr += "Extração de texto\n";
  100 + }
  101 + deleteFiles();
  102 +}
  103 +
  104 +bool ServiceTester::checkFiles(string fileIn, string fileOut) {
  105 + int64_t inSize;
  106 + int64_t outSize;
  107 + fIn = new lavidlib::File(fileIn);
  108 + fOut = new lavidlib::File(fileOut);
  109 +
  110 + try{
  111 + fIO_in = new lavidlib::FileIO(fIn->getPath(), FileIO::MODE_READ);
  112 + fIO_out = new lavidlib::FileIO(fOut->getPath(), FileIO::MODE_READ);
  113 + }catch(Exception &ex){
  114 + delete fIn;
  115 + delete fOut;
  116 + fail = true;
  117 + return false;
  118 + }
  119 +
  120 + inSize = fIO_in->getSize();
  121 + outSize = fIO_out->getSize();
  122 +
  123 + delete fIn;
  124 + delete fOut;
  125 + delete fIO_in;
  126 + delete fIO_out;
  127 +
  128 + if(outSize != 0 && outSize != inSize)
  129 + return true;
  130 +
  131 + fail = true;
  132 + return false;
  133 +}
  134 +
  135 +bool ServiceTester::isFinished(){
  136 + return this->finish;
  137 +}
  138 +
  139 +bool ServiceTester::hasFailed() {
  140 + return this->fail;
  141 +}
  142 +
  143 +void ServiceTester::setPathContents() {
  144 + string command = "mkdir -p ";
  145 + command.append(PATH_TEST_CONTENTS).append(" && mkdir -p ")
  146 + .append(PATH_TEST_UPLOADS).append("/").append(TESTER_ID);
  147 + system(command.c_str());
  148 +}
  149 +
  150 +void ServiceTester::deleteFiles() {
  151 + string command = "rm -f ";
  152 + command.append(OUT_FILE).append(" && rm -rf ")
  153 + .append(PATH_TEST_UPLOADS).append("/").append(TESTER_ID);
  154 + system(command.c_str());
  155 +}
  156 +
  157 +void ServiceTester::Run() {
  158 + PRINTL(util::_INFO, "Verificando módulos, aguarde...\n");
  159 + checkServiceText();
  160 + checkServiceSRT();
  161 + checkServiceRec();
  162 +
  163 + if(hasFailed())
  164 + throw ServiceException(msgErr);
  165 +
  166 + PRINTL(util::_INFO, "Não foram encontrados problemas!\n");
  167 + finish = true;
  168 +}
0 \ No newline at end of file 169 \ No newline at end of file
servico/src/serviceWindowGenerationFromRec.cpp
1 #include "serviceWindowGenerationFromRec.h" 1 #include "serviceWindowGenerationFromRec.h"
2 2
3 ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec( 3 ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec(
4 - char* pathVideo, int sublanguage, int pos, int size, int transp, char* id, int serviceType, char* rate){ 4 + char* pathVideo, int pos, int size, int transp, char* id, char* client, int serviceType, char* rate){
5 5
6 this->path_input = pathVideo; 6 this->path_input = pathVideo;
7 - this->sub_language = sublanguage;  
8 this->position = pos; 7 this->position = pos;
9 this->size = size; 8 this->size = size;
10 this->transparency = transp; 9 this->transparency = transp;
11 this->user_id = id; 10 this->user_id = id;
  11 + // this->client_type = client;
12 this->service_type = serviceType; 12 this->service_type = serviceType;
13 numero_legendas = INT_MAX; 13 numero_legendas = INT_MAX;
14 legendas_enviadas = 0; 14 legendas_enviadas = 0;
@@ -17,19 +17,18 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec( @@ -17,19 +17,18 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec(
17 tradutor = new TradutorPortGlosa(); 17 tradutor = new TradutorPortGlosa();
18 running = true; 18 running = true;
19 finish = false; 19 finish = false;
20 - DPRINTF("Done!\n"); 20 + PRINTL(util::_DEBUG, "Service Rec Done!\n");
21 } 21 }
22 22
23 ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec( 23 ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec(
24 - char* pathVideo, int sublanguage, int pos, int size, int transp, char* id, char* client, int serviceType){ 24 + char* pathVideo, int pos, int size, int transp, char* id, int mode, int serviceType){
25 25
26 this->path_input = pathVideo; 26 this->path_input = pathVideo;
27 - this->sub_language = sublanguage;  
28 this->position = pos; 27 this->position = pos;
29 this->size = size; 28 this->size = size;
30 this->transparency = transp; 29 this->transparency = transp;
31 this->user_id = id; 30 this->user_id = id;
32 - this->client_type = client; 31 + this->exec_mode = mode;
33 this->service_type = serviceType; 32 this->service_type = serviceType;
34 numero_legendas = INT_MAX; 33 numero_legendas = INT_MAX;
35 legendas_enviadas = 0; 34 legendas_enviadas = 0;
@@ -43,73 +42,91 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec( @@ -43,73 +42,91 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec(
43 } 42 }
44 running = true; 43 running = true;
45 finish = false; 44 finish = false;
46 - DPRINTF("Done!\n"); 45 + PRINTL(util::_DEBUG, "Service Rec Done!\n");
47 } 46 }
48 47
49 ServiceWindowGenerationFromRec::~ServiceWindowGenerationFromRec(){ 48 ServiceWindowGenerationFromRec::~ServiceWindowGenerationFromRec(){
50 free(vetor_pts); 49 free(vetor_pts);
51 if (tradutor) delete tradutor; 50 if (tradutor) delete tradutor;
  51 + if (renderer) delete renderer;
52 if (rec) delete rec; 52 if (rec) delete rec;
53 - if (sincronizador) delete sincronizador;  
54 - if (mixer) delete mixer;  
55 - DDDPRINTF("Service Rec finished!\n"); 53 + PRINTL(util::_DEBUG, "Service Rec finished!\n");
56 } 54 }
57 55
58 void ServiceWindowGenerationFromRec::setPathContents(){ 56 void ServiceWindowGenerationFromRec::setPathContents(){
59 - if(strcmp(client_type,DEVELOPER) == 0){  
60 - this->path_contents = PATH_DEVEL;  
61 - this->path_uploads = PATH_DEVEL_UPLOADS;  
62 - rec->setPathAudioContents(path_uploads);  
63 - }else if(strcmp(client_type, PRODUCTION) == 0){  
64 - ifstream conf_file(PATH_CONF_FILE, ifstream::binary);  
65 - parsingSuccessful = reader.parse(conf_file, root);  
66 - if(!parsingSuccessful){  
67 - conf_file.close();  
68 - throw ServiceException("Fail to parsing param.json");  
69 - }  
70 - string attr = root.get("storage", PATH_VBOX_UPLOADS).asString();  
71 - this->path_contents = new char[MAX_SIZE_PATH];  
72 - strcpy(this->path_contents, attr.c_str());  
73 - this->path_uploads = PATH_VBOX_UPLOADS;  
74 - rec->setPathAudioContents(path_uploads);  
75 - conf_file.close();  
76 - }else{  
77 - throw ServiceException("Invalid client!");  
78 - } 57 + switch(exec_mode) {
  58 + case DEVELOPER:
  59 + {
  60 + char* vStorage;
  61 + char* vUploads;
  62 + vStorage = getenv("VLSTORAGE");
  63 + vUploads = getenv("VLUPLOADS");
  64 +
  65 + if(vStorage != NULL && vUploads != NULL){
  66 + this->path_contents = vStorage;
  67 + this->path_uploads = vUploads;
  68 + PRINTL(util::_DEBUG, "Paths definidos pelo desenvolvedor:\n %s\n%s\n", path_contents, path_uploads);
  69 + }else{
  70 + this->path_contents = (char*) PATH_DEVEL_CONTENTS;
  71 + this->path_uploads = (char*) PATH_DEVEL_UPLOADS;
  72 + }
  73 + rec->setPathAudioContents(path_uploads);
  74 + }break;
  75 +
  76 + case PRODUCTION:
  77 + {
  78 + ifstream conf_file(PATH_CONF_FILE, ifstream::binary);
  79 + parsingSuccessful = reader.parse(conf_file, root);
  80 +
  81 + if(parsingSuccessful) {
  82 + string attr = "vlibras_user/";
  83 + attr += root.get("storage", PATH_VBOX_UPLOADS).asString();
  84 + this->path_contents = new char[MAX_SIZE_PATH];
  85 + strcpy(this->path_contents, attr.c_str());
  86 + this->path_uploads = (char*) PATH_VBOX_UPLOADS;
  87 + rec->setPathAudioContents(path_uploads);
  88 + }else{
  89 + conf_file.close();
  90 + Logging::instance()->writeLog("Erro com a leitura do arquivo params.json");
  91 + throw RuntimeException("Fail to parsing params.json");
  92 + }
  93 + conf_file.close();
  94 + }break;
  95 +
  96 + case TESTER:
  97 + {
  98 + this->path_contents = (char*) PATH_TESTER_CONTENTS;
  99 + this->path_uploads = (char*) PATH_TESTER_UPLOADS;
  100 + rec->setPathAudioContents(path_uploads);
  101 + }break;
  102 +
  103 + default:
  104 + throw ServiceException("Invalid execution mode!");
  105 + }
79 } 106 }
80 107
81 -void ServiceWindowGenerationFromRec::setPathLibras(){  
82 - char* final_path = new char[MAX_SIZE_PATH];  
83 - strcpy(final_path, this->path_uploads);  
84 - strcat(final_path, this->user_id);  
85 - strcat(final_path, "/video_libras.ts"); 108 +void ServiceWindowGenerationFromRec::setPathLibras() {
  109 + string final_path = "";
  110 + path_libras = new char[MAX_SIZE_PATH];
86 111
87 - this->path_libras = final_path;  
88 -} 112 + if(this->service_type == SERVICE_TYPE_REC)
  113 + final_path.append(this->path_uploads).append("/").append(this->user_id);
  114 + else
  115 + final_path.append(this->path_contents);
89 116
90 -void ServiceWindowGenerationFromRec::setBackground(){  
91 - if(this->transparency == 0) { //pega dicionario com BackGround opaco  
92 - char* dicPath;  
93 - dicPath = getenv("DIC_LIBRAS");  
94 - if(dicPath != NULL)  
95 - sincronizador = new Synchronizer(dicPath, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);  
96 - else  
97 - sincronizador = new Synchronizer(BASEDIR, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);  
98 -  
99 - } else if(this->transparency == 1) { //pega dicionario com BackGround transparente  
100 - char* dicTPath;  
101 - dicTPath = getenv("DICTRANSP_LIBRAS");  
102 - if(dicTPath != NULL)  
103 - sincronizador = new Synchronizer(dicTPath, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);  
104 - else  
105 - sincronizador = new Synchronizer(BASEDIRTRANSP, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);  
106 - } 117 + final_path.append("/").append(this->user_id).append(".mp4");
  118 + strcpy(this->path_libras, final_path.c_str());
107 } 119 }
108 120
109 void ServiceWindowGenerationFromRec::setSizeOfSubtitles(int sub_size){ 121 void ServiceWindowGenerationFromRec::setSizeOfSubtitles(int sub_size){
110 numero_legendas = sub_size; 122 numero_legendas = sub_size;
111 - if (legendas_enviadas >= numero_legendas)  
112 - sincronizador->stop(); 123 + if (legendas_enviadas >= numero_legendas){
  124 + try{
  125 + renderer->initialize();
  126 + }catch(lavidlib::RuntimeException &ex){
  127 + throw ServiceException(ex.getMessage().c_str());
  128 + }
  129 + }
113 } 130 }
114 131
115 void ServiceWindowGenerationFromRec::addPTS(int64_t pts){ 132 void ServiceWindowGenerationFromRec::addPTS(int64_t pts){
@@ -126,36 +143,34 @@ void ServiceWindowGenerationFromRec::notifyTextRecognized(unsigned char* text, i @@ -126,36 +143,34 @@ void ServiceWindowGenerationFromRec::notifyTextRecognized(unsigned char* text, i
126 notifyTranslator(text); 143 notifyTranslator(text);
127 } 144 }
128 145
129 -//Quando o sincronizador termina, ele invoca esse método para avisar  
130 -void ServiceWindowGenerationFromRec::notifyEndOfSynchronization() {  
131 - if (this->service_type == SERVICE_TYPE_REC) {  
132 - mixer = new Mixer();  
133 - mixer->initialize(this->path_input, this->path_libras,this->position,this->size,  
134 - this->transparency, this->user_id, this->path_uploads, this->path_contents);  
135 - createThumbnail();  
136 - }else{  
137 - transcodeVideoToMp4(); 146 +void ServiceWindowGenerationFromRec::notifyTranslation(char* glosa) {
  147 + string sGlosa(reinterpret_cast<char*>(glosa));
  148 + try{
  149 + renderer->receiveGlosa(sGlosa, vetor_pts->front());
  150 + legendas_enviadas++;
  151 + }catch(lavidlib::RuntimeException &ex){
  152 + throw ServiceException(ex.getMessage().c_str());
138 } 153 }
139 - this->running = false; 154 + vetor_pts->erase(vetor_pts->begin());
140 } 155 }
141 156
142 -void ServiceWindowGenerationFromRec::notifyTranslation(vector<string> * glosas) {  
143 - for (int i = 0; i < glosas->size(); i++) {  
144 - locale loc;  
145 - string glosa_lower = "";  
146 - for (int k = 0; k < glosas->at(i).length(); k++){  
147 - glosa_lower += std::tolower(glosas->at(i).at(k), loc);  
148 - }  
149 - int64_t pts_notificado = vetor_pts->front();  
150 - sincronizador->recebeglosa(glosa_lower, pts_notificado); 157 +void ServiceWindowGenerationFromRec::notifyEndOfRenderization() {
  158 + if(this->service_type == SERVICE_TYPE_REC){
  159 + mixer = new Mixer(this->path_input, this->path_libras, this->size, this->position,
  160 + this->transparency, this->user_id, this->path_uploads, this->path_contents);
  161 + mixer->initialize();
  162 + delete mixer;
151 } 163 }
152 - vetor_pts->erase(vetor_pts->begin());  
153 - legendas_enviadas++; 164 + running = false;
154 } 165 }
155 166
156 void ServiceWindowGenerationFromRec::notifyEnd(int sentences_size){ 167 void ServiceWindowGenerationFromRec::notifyEnd(int sentences_size){
157 - DPRINTF("Service REC recebeu: %d sentenças.\n", sentences_size);  
158 - setSizeOfSubtitles(sentences_size); 168 + PRINTL(util::_DEBUG, "Service REC recebeu: %d sentenças.\n", sentences_size);
  169 + try{
  170 + setSizeOfSubtitles(sentences_size);
  171 + }catch(ServiceException &ex) {
  172 + finish = true;
  173 + }
159 } 174 }
160 175
161 bool ServiceWindowGenerationFromRec::isRunning(){ 176 bool ServiceWindowGenerationFromRec::isRunning(){
@@ -167,69 +182,24 @@ bool ServiceWindowGenerationFromRec::isFinished(){ @@ -167,69 +182,24 @@ bool ServiceWindowGenerationFromRec::isFinished(){
167 } 182 }
168 183
169 void ServiceWindowGenerationFromRec::initialize(){ 184 void ServiceWindowGenerationFromRec::initialize(){
170 - DPRINTF("Service REC Initialize.\n");  
171 - rec->addListener(this); 185 + PRINTL(util::_DEBUG, "Service REC Initialize.\n");
172 setPathLibras(); 186 setPathLibras();
  187 + rec->addListener(this);
  188 + tradutor->addListener(this);
173 189
174 - if(this->sub_language == 1)  
175 - tradutor->addListener(this);  
176 -  
177 - if(this->service_type != SERVICE_TYPE_REC_ONLY_AUDIO){  
178 - vector<string> tokens;  
179 - char* pathtmp = this->path_input;  
180 - int size = strlen(pathtmp);  
181 - char vtemp [size];  
182 -  
183 - strcpy(vtemp, pathtmp);  
184 - pathtmp = strtok(vtemp, ".");  
185 - while (pathtmp != NULL) {  
186 - tokens.push_back(string(pathtmp));  
187 - pathtmp = strtok(NULL, ".");  
188 - }  
189 -  
190 - string buildstrpath = tokens[0] + "_libras" + EXTENSAO_DICIONARIO;  
191 - this->path_libras = new char[buildstrpath.size()];  
192 - strcpy(this->path_libras, buildstrpath.c_str());  
193 - //printf("O Serviço montou o seguinte path para o vídeo de Libras: %s\n", path_libras);  
194 -  
195 - }else{  
196 - tradutor->addListener(this);  
197 - }  
198 -  
199 - setBackground();  
200 -  
201 - uint64_t pcr_base = (uint64_t) 1000; //FIXME: macro  
202 - sincronizador->setPCRBase(pcr_base);  
203 - sincronizador->addListener(this);  
204 - sincronizador->Start();  
205 - 190 + renderer = new Renderer(this->path_libras ,this->user_id);
  191 + renderer->addListener(this);
  192 +
206 try{ 193 try{
207 rec->initialize(); 194 rec->initialize();
208 } catch(RecognizeException ex){ 195 } catch(RecognizeException ex){
209 throw ServiceException(ex.getMessage()); 196 throw ServiceException(ex.getMessage());
210 - } 197 + } catch(RuntimeException &ex){
  198 + throw ServiceException(ex.getMessage().c_str());
  199 + }
211 this->Start(); 200 this->Start();
212 } 201 }
213 202
214 -void ServiceWindowGenerationFromRec::transcodeVideoToMp4(){  
215 - DPRINTF("[AGUARDE] Transcodificando o vídeo de Libras...\n");  
216 - string command = "ffmpeg -i ";  
217 - command.append(path_libras)  
218 - .append(" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 ").append(" -v quiet ")  
219 - .append(path_contents).append(user_id).append(".mp4");  
220 - //printf("[INFO]: Transcodification command -> %s\n", command.c_str());  
221 - system(command.c_str());  
222 -}  
223 -  
224 -void ServiceWindowGenerationFromRec::createThumbnail(){  
225 - string command = "ffmpeg -ss 10 -i ";  
226 - command.append(path_contents).append(user_id).append(".mp4")  
227 - .append(" -vcodec png -vframes 1 -an -f rawvideo -y -vf scale=200:200 ").append(" -v quiet ")  
228 - .append(path_contents).append(user_id).append(".png");  
229 - //printf("[INFO]: Thumbnail command -> %s\n", command.c_str());  
230 - system(command.c_str());  
231 -}  
232 -  
233 void ServiceWindowGenerationFromRec::Run(){ 203 void ServiceWindowGenerationFromRec::Run(){
234 while(isRunning()){ 204 while(isRunning()){
235 usleep(200000); 205 usleep(200000);
servico/src/serviceWindowGenerationFromSRT.cpp
@@ -1,248 +0,0 @@ @@ -1,248 +0,0 @@
1 -#include "serviceWindowGenerationFromSRT.h"  
2 -  
3 -ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo, char* pathSRT, int sublanguage,  
4 - int pos, int size, int transp, char* id, char* client, int serviceType) {  
5 -  
6 - this->path_input = pathVideo;  
7 - this->path_srt = pathSRT;  
8 - this-> sub_language = sublanguage;  
9 - this->position = pos;  
10 - this->size = size;  
11 - this->transparency = transp;  
12 - this->user_id = id;  
13 - this->client_type = client;  
14 - this->service_type = serviceType;  
15 - numero_legendas = INT_MAX;  
16 - legendas_enviadas = 0;  
17 - vetor_pts = new vector<int64_t >();  
18 - tradutor = new TradutorPortGlosa();  
19 - extrator_factory = new ExtratorFactory();  
20 - try{  
21 - setPathContents();  
22 - }catch(RuntimeException ex){  
23 - throw ServiceException(ex.getMessage());  
24 - }  
25 - running = true;  
26 - finish = false;  
27 - DPRINTF("Done!\n");  
28 -}  
29 -  
30 -ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, int transp, char* id, char* client, int serviceType) {  
31 -  
32 - this->path_srt = pathSRT;  
33 - this->transparency = transp;  
34 - this->user_id = id;  
35 - this->client_type = client;  
36 - this->service_type = serviceType;  
37 - numero_legendas = INT_MAX;  
38 - legendas_enviadas = 0;  
39 - vetor_pts = new vector<int64_t >();  
40 - tradutor = new TradutorPortGlosa();  
41 - extrator_factory = new ExtratorFactory();  
42 - try{  
43 - setPathContents();  
44 - }catch(RuntimeException ex){  
45 - throw ServiceException(ex.getMessage());  
46 - }  
47 - running = true;  
48 - finish = false;  
49 - DPRINTF("Done!\n");  
50 -}  
51 -  
52 -ServiceWindowGenerationFromSRT::~ServiceWindowGenerationFromSRT() {  
53 - free(vetor_pts);  
54 - if (mixer) delete mixer;  
55 - if (tradutor) delete tradutor;  
56 - if (sincronizador) delete sincronizador;  
57 - if (extratorSRT)delete extratorSRT;  
58 - if (extrator_factory) delete extrator_factory;  
59 - DDDPRINTF("Service SRT finalized!\n");  
60 -}  
61 -  
62 -void ServiceWindowGenerationFromSRT::setPathContents() {  
63 - if(strcmp(client_type,DEVELOPER) == 0){  
64 - this->path_contents = PATH_DEVEL;  
65 - this->path_uploads = PATH_DEVEL_UPLOADS;  
66 - }else if(strcmp(client_type, PRODUCTION) == 0){  
67 - ifstream conf_file(PATH_CONF_FILE, ifstream::binary);  
68 - parsingSuccessful = reader.parse(conf_file, root);  
69 - if(!parsingSuccessful){  
70 - conf_file.close();  
71 - throw ServiceException("Fail to parsing param.json");  
72 - }  
73 - string attr = root.get("storage", PATH_VBOX_UPLOADS).asString();  
74 - this->path_contents = new char[MAX_SIZE_PATH];  
75 - strcpy(this->path_contents, attr.c_str());  
76 - this->path_uploads = PATH_VBOX_UPLOADS;  
77 - conf_file.close();  
78 - }else{  
79 - throw ServiceException("Invalid client!");  
80 - }  
81 -}  
82 -  
83 -void ServiceWindowGenerationFromSRT::setPathLibras() {  
84 - char* final_path = new char[MAX_SIZE_PATH];  
85 - strcpy(final_path, this->path_uploads);  
86 - strcat(final_path, this->user_id);  
87 - strcat(final_path, "/video_libras.ts");  
88 -  
89 - this->path_libras = final_path;  
90 -}  
91 -  
92 -void ServiceWindowGenerationFromSRT::setBackground() {  
93 - if(this->transparency == 0) { //pega dicionario com BackGround opaco  
94 - char* dicPath;  
95 - dicPath = getenv("DIC_LIBRAS");  
96 - if(dicPath != NULL)  
97 - sincronizador = new Synchronizer(dicPath, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);  
98 - else  
99 - sincronizador = new Synchronizer(BASEDIR, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);  
100 -  
101 - } else if(this->transparency == 1) { //pega dicionario com BackGround transparente  
102 - char* dicTPath;  
103 - dicTPath = getenv("DICTRANSP_LIBRAS");  
104 - if(dicTPath != NULL)  
105 - sincronizador = new Synchronizer(dicTPath, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);  
106 - else  
107 - sincronizador = new Synchronizer(BASEDIRTRANSP, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);  
108 - }  
109 -}  
110 -  
111 -void ServiceWindowGenerationFromSRT::setSizeOfSubtitles(int sub_size) {  
112 - numero_legendas = sub_size;  
113 - if (legendas_enviadas >= numero_legendas)  
114 - sincronizador->stop();  
115 -}  
116 -  
117 -void ServiceWindowGenerationFromSRT::addPTS(int64_t pts){  
118 - vetor_pts->push_back(pts);  
119 -}  
120 -  
121 -void ServiceWindowGenerationFromSRT::notifyTranslator(unsigned char* subtitle) {  
122 - const char* constchar = (const char*) subtitle;  
123 - char* legenda_copy = new char[strlen(constchar)+1];  
124 - strcpy(legenda_copy, constchar);  
125 - tradutor->traduz((unsigned char*) legenda_copy);  
126 - free(legenda_copy);  
127 -}  
128 -  
129 -void ServiceWindowGenerationFromSRT::notifySubtitle(unsigned char *subtitle, int64_t pts){  
130 - addPTS(pts);  
131 - notifyTranslator(subtitle);  
132 -}  
133 -  
134 -void ServiceWindowGenerationFromSRT::notifyEndOfSynchronization() {  
135 - if (this->service_type == SERVICE_TYPE_SRT) {  
136 - mixer = new Mixer();  
137 - mixer->initialize(this->path_input, this->path_libras,this->position,this->size,  
138 - this->transparency, this->user_id, this->path_uploads, this->path_contents);  
139 - createThumbnail();  
140 - }else{  
141 - transcodeVideoToMp4();  
142 - }  
143 - this->running = false;  
144 -}  
145 -  
146 -void ServiceWindowGenerationFromSRT::notifyTranslation(vector<string> * glosas) {  
147 - for (int i = 0; i < glosas->size(); i++) {  
148 - locale loc;  
149 - string glosa_lower = "";  
150 - for (int k = 0; k < glosas->at(i).length(); k++){  
151 - glosa_lower += std::tolower(glosas->at(i).at(k), loc);  
152 - }  
153 - int64_t pts_notificado = vetor_pts->front();  
154 - sincronizador->recebeglosa(glosa_lower, pts_notificado);  
155 - }  
156 - vetor_pts->erase(vetor_pts->begin());  
157 - legendas_enviadas++;  
158 -}  
159 -  
160 -void ServiceWindowGenerationFromSRT::notifyEnd(int sub_size) {  
161 - DPRINTF("Service SRT recebeu: %d legendas.\n", sub_size);  
162 - setSizeOfSubtitles(sub_size);  
163 -}  
164 -  
165 -bool ServiceWindowGenerationFromSRT::isRunning() {  
166 - return this->running;  
167 -}  
168 -  
169 -bool ServiceWindowGenerationFromSRT::isFinished() {  
170 - return this->finish;  
171 -}  
172 -  
173 -void ServiceWindowGenerationFromSRT::initialize() {  
174 - DPRINTF("Service SRT Initialize.\n");  
175 - extratorSRT = (ExtratorSRT*) extrator_factory->getExtrator(Extrator::SRT);  
176 - extratorSRT->addListener(this);  
177 - extratorSRT->setFilePath(path_srt);  
178 -  
179 - setPathLibras();  
180 -  
181 - if (this->sub_language == 1)  
182 - tradutor->addListener(this);  
183 -  
184 - if(this->service_type != SERVICE_TYPE_SRT_ONLY){  
185 - vector<string> tokens;  
186 - char* pathtmp = this->path_input;  
187 - int size = strlen(pathtmp);  
188 - char vtemp [size];  
189 -  
190 - strcpy(vtemp, pathtmp);  
191 - pathtmp = strtok(vtemp, ".");  
192 - while (pathtmp != NULL) {  
193 - tokens.push_back(string(pathtmp));  
194 - pathtmp = strtok(NULL, ".");  
195 - }  
196 -  
197 - string buildstrpath = tokens[0] + "_libras" + EXTENSAO_DICIONARIO;  
198 - this->path_libras = new char[buildstrpath.size()];  
199 - strcpy(this->path_libras, buildstrpath.c_str());  
200 - //printf("O Serviço montou o seguinte path para o vídeo de Libras: %s\n", path_libras);  
201 -  
202 - }else{  
203 - tradutor->addListener(this);  
204 - }  
205 -  
206 - setBackground();  
207 -  
208 - if (service_type != SERVICE_TYPE_SRT) {  
209 - uint64_t pcr_base = (uint64_t) 1000; //FIXME: macro  
210 - sincronizador->setPCRBase(pcr_base);  
211 - }  
212 -  
213 - sincronizador->addListener(this);  
214 - sincronizador->Start();  
215 -  
216 - try{  
217 - extratorSRT->initialize();  
218 - }catch(ExtratorException ex){  
219 - throw ServiceException(ex.getMessage());  
220 - }  
221 - this->Start();  
222 -}  
223 -  
224 -void ServiceWindowGenerationFromSRT::transcodeVideoToMp4(){  
225 - DPRINTF("[AGUARDE] Transcodificando o vídeo de Libras...\n");  
226 - string command = "ffmpeg -i ";  
227 - command.append(path_libras)  
228 - .append(" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 ").append(" -v quiet ")  
229 - .append(path_contents).append(user_id).append(".mp4");  
230 - //printf("[INFO]: Transcodification command -> %s\n", command.c_str());  
231 - system(command.c_str());  
232 -}  
233 -  
234 -void ServiceWindowGenerationFromSRT::createThumbnail(){  
235 - string command = "ffmpeg -ss 10 -i ";  
236 - command.append(path_contents).append(user_id).append(".mp4")  
237 - .append(" -vcodec png -vframes 1 -an -f rawvideo -y -vf scale=200:200 ").append(" -v quiet ")  
238 - .append(path_contents).append(user_id).append(".png");  
239 - //printf("[INFO]: Thumbnail command -> %s\n", command.c_str());  
240 - system(command.c_str());  
241 -}  
242 -  
243 -void ServiceWindowGenerationFromSRT::Run() {  
244 - while(isRunning()){  
245 - usleep(200000);  
246 - }  
247 - finish = true;  
248 -}  
249 \ No newline at end of file 0 \ No newline at end of file
servico/src/serviceWindowGenerationFromSubtitle.cpp 0 → 100644
@@ -0,0 +1,288 @@ @@ -0,0 +1,288 @@
  1 +#include "serviceWindowGenerationFromSubtitle.h"
  2 +
  3 +ServiceWindowGenerationFromSubtitle::ServiceWindowGenerationFromSubtitle(char* pathVideo, char* pathSRT, int sublanguage,
  4 + int pos, int size, int transp, char* id, int mode, int serviceType) {
  5 +
  6 + this->path_input = pathVideo;
  7 + this->path_srt = pathSRT;
  8 + this->sub_language = sublanguage;
  9 + this->position = pos;
  10 + this->size = size;
  11 + this->transparency = transp;
  12 + this->user_id = id;
  13 + this->exec_mode = mode;
  14 + this->service_type = serviceType;
  15 + numero_legendas = INT_MAX;
  16 + legendas_enviadas = 0;
  17 + vetor_pts = new vector<int64_t >();
  18 + extrator_factory = new ExtratorFactory();
  19 + try{
  20 + setPathContents();
  21 + }catch(RuntimeException ex){
  22 + throw ServiceException(ex.getMessage());
  23 + }
  24 + running = true;
  25 + finish = false;
  26 + PRINTL(util::_DEBUG, "Service Subtitle Done!\n");
  27 +}
  28 +
  29 +ServiceWindowGenerationFromSubtitle::ServiceWindowGenerationFromSubtitle(char* pathSRT, int sublanguage, int transp, char* id, int mode, int serviceType) {
  30 + this->path_srt = pathSRT;
  31 + this->sub_language = sublanguage;
  32 + this->transparency = transp;
  33 + this->user_id = id;
  34 + this->exec_mode = mode;
  35 + this->service_type = serviceType;
  36 + numero_legendas = INT_MAX;
  37 + legendas_enviadas = 0;
  38 + vetor_pts = new vector<int64_t >();
  39 + extrator_factory = new ExtratorFactory();
  40 + try{
  41 + setPathContents();
  42 + }catch(RuntimeException ex){
  43 + throw ServiceException(ex.getMessage());
  44 + }
  45 + running = true;
  46 + finish = false;
  47 + PRINTL(util::_DEBUG, "Service Subtitle Done!\n");
  48 +}
  49 +
  50 +ServiceWindowGenerationFromSubtitle::~ServiceWindowGenerationFromSubtitle() {
  51 + free(vetor_pts);
  52 + if (tradutor) delete tradutor;
  53 + // if (mixer) delete mixer;
  54 + if (renderer) delete renderer;
  55 + if (extratorVTT)delete extratorVTT;
  56 + if (extrator_factory) delete extrator_factory;
  57 + PRINTL(util::_DEBUG, "Service Subtitle finalized!\n");
  58 +}
  59 +
  60 +void ServiceWindowGenerationFromSubtitle::setPathContents() {
  61 + switch(exec_mode) {
  62 + case DEVELOPER:
  63 + {
  64 + char* vStorage;
  65 + char* vUploads;
  66 + vStorage = getenv("VLSTORAGE");
  67 + vUploads = getenv("VLUPLOADS");
  68 +
  69 + if(vStorage != NULL && vUploads != NULL){
  70 + this->path_contents = vStorage;
  71 + this->path_uploads = vUploads;
  72 + PRINTL(util::_DEBUG, "Paths definidos pelo desenvolvedor:\n %s\n%s\n", path_contents, path_uploads);
  73 + }else{
  74 + this->path_contents = (char*) PATH_DEVEL_CONTENTS;
  75 + this->path_uploads = (char*) PATH_DEVEL_UPLOADS;
  76 + }
  77 + }break;
  78 +
  79 + case PRODUCTION:
  80 + {
  81 + ifstream conf_file(PATH_CONF_FILE, ifstream::binary);
  82 + parsingSuccessful = reader.parse(conf_file, root);
  83 +
  84 + if(parsingSuccessful) {
  85 + string attr = "vlibras_user/";
  86 + attr += root.get("storage", PATH_VBOX_UPLOADS).asString();
  87 + this->path_contents = new char[MAX_SIZE_PATH];
  88 + strcpy(this->path_contents, attr.c_str());
  89 + this->path_uploads = (char*) PATH_VBOX_UPLOADS;
  90 + }else{
  91 + conf_file.close();
  92 + Logging::instance()->writeLog("Erro com a leitura do arquivo params.json");
  93 + throw new RuntimeException("Fail to parsing params.json");
  94 + }
  95 + conf_file.close();
  96 + }break;
  97 +
  98 + case TESTER:
  99 + {
  100 + this->path_contents = (char*) PATH_TESTER_CONTENTS;
  101 + this->path_uploads = (char*) PATH_TESTER_UPLOADS;
  102 + }break;
  103 +
  104 + default:
  105 + throw ServiceException("Invalid execution mode!");
  106 + }
  107 +}
  108 +
  109 +Extrator::ExtratorType ServiceWindowGenerationFromSubtitle::getExtratorType(){
  110 + this->file = new lavidlib::File(this->path_srt);
  111 + try{
  112 + this->fileIO = new lavidlib::FileIO(file->getPath(), FileIO::MODE_READ);
  113 + this->bffReader = new BufferedReader(fileIO);
  114 + }catch(Exception &ex){
  115 + Logging::instance()->writeLog("ServiceWindowGenerationFromSubtitle.cpp <Error>: Arquivo de legenda não encontrado.");
  116 + throw ServiceException("Falha ao abrir o arquivo de legenda! Verifique se o mesmo existe.\n");
  117 + }
  118 +
  119 + string signature;
  120 + try{
  121 + signature = bffReader->readLine();
  122 + }catch(lavidlib::EOFException &ex){
  123 + throw ServiceException("Arquivo sem conteúdo.");
  124 + }
  125 +
  126 + /* As verificações a seguir estão de acordo com o padrão
  127 + * definido pelo W3C Community Group.
  128 + */
  129 + if(signature.size() < 6){
  130 + return Extrator::SRT;
  131 + }
  132 +
  133 + if(signature.size() == 6 && strcmp(SIGNATURE, signature.c_str()) == 0){
  134 + return Extrator::VTT;
  135 + }else{
  136 + return Extrator::SRT;
  137 + }
  138 +
  139 + if(signature.size() > 6 && signature.find(SIGNATURE) == string::npos){
  140 + return Extrator::SRT;
  141 + }else if(!isspace(signature.at(6))){
  142 + return Extrator::SRT;
  143 + }
  144 +
  145 + delete bffReader;
  146 + delete fileIO;
  147 +
  148 + return Extrator::VTT;
  149 +}
  150 +
  151 +void ServiceWindowGenerationFromSubtitle::setPathLibras() {
  152 + string final_path = "";
  153 + path_libras = new char[MAX_SIZE_PATH];
  154 +
  155 + if(this->service_type == SERVICE_TYPE_SRT)
  156 + final_path.append(this->path_uploads).append("/").append(this->user_id);
  157 + else
  158 + final_path.append(this->path_contents);
  159 +
  160 + final_path.append("/").append(this->user_id).append(".mp4");
  161 + strcpy(this->path_libras, final_path.c_str());
  162 +}
  163 +
  164 +void ServiceWindowGenerationFromSubtitle::setSizeOfSubtitles(int sub_size) {
  165 + numero_legendas = sub_size;
  166 + if (legendas_enviadas >= numero_legendas){
  167 + try{
  168 + renderer->initialize();
  169 + }catch(lavidlib::RuntimeException &ex){
  170 + throw ServiceException(ex.getMessage().c_str());
  171 + }
  172 + }
  173 +}
  174 +
  175 +void ServiceWindowGenerationFromSubtitle::addPTS(int64_t pts){
  176 + vetor_pts->push_back(pts);
  177 +}
  178 +
  179 +void ServiceWindowGenerationFromSubtitle::notifyTranslator(unsigned char* subtitle) {
  180 + const char* constchar = (const char*) subtitle;
  181 + char* legenda_copy = new char[strlen(constchar)+1];
  182 + strcpy(legenda_copy, constchar);
  183 + tradutor->traduz((unsigned char*) legenda_copy);
  184 + free(legenda_copy);
  185 +}
  186 +
  187 +void ServiceWindowGenerationFromSubtitle::notifySubtitle(unsigned char *subtitle, uint64_t pts){
  188 + addPTS(pts);
  189 + if (sub_language == 1) {
  190 + notifyTranslator(subtitle);
  191 + }else{
  192 + string subt(reinterpret_cast<char*>(subtitle));
  193 +
  194 + locale loc;
  195 + string glosa = "";
  196 + for (string::size_type i=0; i< subt.length(); ++i) {
  197 + glosa += std::toupper(subt[i], loc);
  198 + }
  199 + notifyRenderer(glosa);
  200 + }
  201 +}
  202 +
  203 +void ServiceWindowGenerationFromSubtitle::notifyTranslation(char* glosa) {
  204 + string sGlosa(glosa);
  205 + notifyRenderer(sGlosa);
  206 +}
  207 +
  208 +void ServiceWindowGenerationFromSubtitle::notifyRenderer(string glosa) {
  209 + try{
  210 + renderer->receiveGlosa(glosa, vetor_pts->front());
  211 + legendas_enviadas++;
  212 + }catch(lavidlib::RuntimeException &ex){
  213 + throw ServiceException(ex.getMessage().c_str());
  214 + }
  215 + vetor_pts->erase(vetor_pts->begin());
  216 +}
  217 +
  218 +void ServiceWindowGenerationFromSubtitle::notifyEndOfRenderization() {
  219 + if(this->service_type == SERVICE_TYPE_SRT){
  220 + mixer = new Mixer(this->path_input, this->path_libras, this->size, this->position,
  221 + this->transparency, this->user_id, this->path_uploads, this->path_contents);
  222 + mixer->initialize();
  223 + delete mixer;
  224 + }
  225 + this->running = false;
  226 +}
  227 +
  228 +void ServiceWindowGenerationFromSubtitle::notifyEnd(int sub_size) {
  229 + PRINTL(util::_DEBUG, "Service Subtitle recebeu: %d legendas.\n", sub_size);
  230 + try{
  231 + setSizeOfSubtitles(sub_size);
  232 + }catch(ServiceException &ex) {
  233 + finish = true;
  234 + }
  235 +
  236 +}
  237 +
  238 +bool ServiceWindowGenerationFromSubtitle::isRunning() {
  239 + return this->running;
  240 +}
  241 +
  242 +bool ServiceWindowGenerationFromSubtitle::isFinished() {
  243 + return this->finish;
  244 +}
  245 +
  246 +void ServiceWindowGenerationFromSubtitle::initialize() {
  247 + PRINTL(util::_DEBUG, "Service Subtitle Initialize.\n");
  248 + setPathLibras();
  249 +
  250 + Extrator::ExtratorType extrator_t = getExtratorType();
  251 +
  252 + if(extrator_t == Extrator::SRT){
  253 + extratorSRT = (ExtratorSRT*) extrator_factory->getExtrator(Extrator::SRT);
  254 + extratorSRT->addListener(this);
  255 + extratorSRT->setFilePath(path_srt);
  256 + }else{
  257 + extratorVTT = (ExtratorVTT*) extrator_factory->getExtrator(Extrator::VTT);
  258 + extratorVTT->addListener(this);
  259 + extratorVTT->setFilePath(path_srt);
  260 + }
  261 +
  262 + tradutor = new TradutorPortGlosa();
  263 + if (this->sub_language == 1) {
  264 + tradutor->addListener(this);
  265 + }
  266 +
  267 + renderer = new Renderer(this->path_libras ,this->user_id);
  268 + renderer->addListener(this);
  269 +
  270 + try{
  271 + if(extrator_t == Extrator::SRT)
  272 + extratorSRT->initialize();
  273 + else
  274 + extratorVTT->initialize();
  275 + }catch(ExtratorException ex){
  276 + throw ServiceException(ex.getMessage());
  277 + }catch(RuntimeException &ex){
  278 + throw ServiceException(ex.getMessage().c_str());
  279 + }
  280 + this->Start();
  281 +}
  282 +
  283 +void ServiceWindowGenerationFromSubtitle::Run() {
  284 + while(isRunning()){
  285 + usleep(200000);
  286 + }
  287 + finish = true;
  288 +}
servico/src/serviceWindowGenerationFromText.cpp
1 #include "serviceWindowGenerationFromText.h" 1 #include "serviceWindowGenerationFromText.h"
2 2
3 -ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile, int transp, char* id, char* client) { 3 +ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile, int sublanguage, int transp, char* id, int mode) {
4 this->path_input = pathFile; 4 this->path_input = pathFile;
5 this->transparency = transp; 5 this->transparency = transp;
  6 + this->sub_language = sublanguage;
6 this->user_id = id; 7 this->user_id = id;
7 - client_type = client; 8 + this->exec_mode = mode;
8 running = true; 9 running = true;
9 finish = false; 10 finish = false;
10 numero_legendas = INT_MAX; 11 numero_legendas = INT_MAX;
11 legendas_enviadas = 0; 12 legendas_enviadas = 0;
12 - vetor_pts = new vector<int64_t >();  
13 - tradutor = new TradutorPortGlosa();  
14 extrator_factory = new ExtratorFactory(); 13 extrator_factory = new ExtratorFactory();
15 try{ 14 try{
16 setPathContents(); 15 setPathContents();
@@ -19,102 +18,122 @@ ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile, @@ -19,102 +18,122 @@ ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile,
19 } 18 }
20 running = true; 19 running = true;
21 finish = false; 20 finish = false;
22 - DPRINTF("Done!\n"); 21 + PRINTL(util::_DEBUG, "Service Text Done!\n");
23 } 22 }
24 23
25 ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() { 24 ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() {
26 - free(vetor_pts);  
27 if (tradutor) delete tradutor; 25 if (tradutor) delete tradutor;
28 - if (sincronizador) delete sincronizador; 26 + if (renderer) delete renderer;
29 if (extratorTXT)delete extratorTXT; 27 if (extratorTXT)delete extratorTXT;
30 if (extrator_factory) delete extrator_factory; 28 if (extrator_factory) delete extrator_factory;
31 - DDDPRINTF("Service Text finalized!\n"); 29 + PRINTL(util::_DEBUG, "Service Text finalized!\n");
32 } 30 }
33 31
34 void ServiceWindowGenerationFromText::setPathContents() { 32 void ServiceWindowGenerationFromText::setPathContents() {
35 - if(strcmp(client_type,DEVELOPER) == 0){  
36 - this->path_contents = PATH_DEVEL;  
37 - this->path_uploads = PATH_DEVEL_UPLOADS;  
38 - }else if(strcmp(client_type, PRODUCTION) == 0){  
39 - ifstream conf_file(PATH_CONF_FILE, ifstream::binary);  
40 - parsingSuccessful = reader.parse(conf_file, root);  
41 - if(!parsingSuccessful){  
42 - throw new RuntimeException("Fail to parsing param.json");  
43 - }  
44 - string attr = root.get("storage", PATH_VBOX_UPLOADS).asString();  
45 - this->path_contents = new char[MAX_SIZE_PATH];  
46 - strcpy(this->path_contents, attr.c_str());  
47 - this->path_uploads = PATH_VBOX_UPLOADS;  
48 - }else{  
49 - throw ServiceException("Invalid client!"); 33 + switch(exec_mode) {
  34 + case DEVELOPER:
  35 + {
  36 + char* vStorage;
  37 + vStorage = getenv("VLSTORAGE");
  38 + if(vStorage != NULL){
  39 + this->path_contents = vStorage;
  40 + PRINTL(util::_DEBUG, "Path definido pelo desenvolvedor:\n%s\n", path_contents);
  41 + }else{
  42 + this->path_contents = (char*) PATH_DEVEL_CONTENTS;
  43 + }
  44 + }break;
  45 +
  46 + case PRODUCTION:
  47 + {
  48 + ifstream conf_file(PATH_CONF_FILE, ifstream::binary);
  49 + parsingSuccessful = reader.parse(conf_file, root);
  50 +
  51 + if(parsingSuccessful) {
  52 + string attr = "vlibras_user/";
  53 + attr += root.get("storage", PATH_VBOX_UPLOADS).asString();
  54 + this->path_contents = new char[MAX_SIZE_PATH];
  55 + strcpy(this->path_contents, attr.c_str());
  56 + }else{
  57 + conf_file.close();
  58 + Logging::instance()->writeLog("Erro com a leitura do arquivo params.json");
  59 + throw new RuntimeException("Fail to parsing params.json");
  60 + }
  61 + conf_file.close();
  62 + }break;
  63 +
  64 + case TESTER:
  65 + {
  66 + this->path_contents = (char*) PATH_TESTER_CONTENTS;
  67 + }break;
  68 +
  69 + default:
  70 + throw ServiceException("Invalid execution mode!");
50 } 71 }
51 } 72 }
52 73
53 void ServiceWindowGenerationFromText::setPathLibras() { 74 void ServiceWindowGenerationFromText::setPathLibras() {
54 - char* final_path = new char[MAX_SIZE_PATH];  
55 - strcpy(final_path, this->path_uploads);  
56 - strcat(final_path, this->user_id);  
57 - strcat(final_path, "/video_libras.ts");  
58 -  
59 - this->path_libras = final_path; 75 + string final_path = "";
  76 + path_libras = new char[MAX_SIZE_PATH];
  77 + final_path.append(this->path_contents).append("/").
  78 + append(this->user_id).append(".mp4");
  79 + strcpy(this->path_libras, final_path.c_str());
60 } 80 }
61 81
62 -void ServiceWindowGenerationFromText::setBackground() {  
63 - if(this->transparency == 0) { //pega dicionario com BackGround opaco  
64 - char* dicPath;  
65 - dicPath = getenv("DIC_LIBRAS");  
66 - if(dicPath != NULL)  
67 - sincronizador = new Synchronizer(dicPath, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);  
68 - else  
69 - sincronizador = new Synchronizer(BASEDIR, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);  
70 -  
71 - } else if(this->transparency == 1) { //pega dicionario com BackGround transparente  
72 - char* dicTPath;  
73 - dicTPath = getenv("DICTRANSP_LIBRAS");  
74 - if(dicTPath != NULL)  
75 - sincronizador = new Synchronizer(dicTPath, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);  
76 - else{  
77 - sincronizador = new Synchronizer(BASEDIRTRANSP, EXTENSAO_DICIONARIO, this->path_libras, this->transparency); 82 +void ServiceWindowGenerationFromText::setSizeOfSubtitles(int sub_size) {
  83 + numero_legendas = sub_size;
  84 + if (legendas_enviadas >= numero_legendas){
  85 + try{
  86 + renderer->initialize();
  87 + }catch(lavidlib::RuntimeException &ex){
  88 + throw ServiceException(ex.getMessage().c_str());
78 } 89 }
79 } 90 }
80 } 91 }
81 92
82 -void ServiceWindowGenerationFromText::setSizeOfSubtitles(int sub_size) {  
83 - numero_legendas = sub_size;  
84 - if (legendas_enviadas >= numero_legendas)  
85 - sincronizador->stop();  
86 -}  
87 -  
88 void ServiceWindowGenerationFromText::notifyTranslator(unsigned char* text) { 93 void ServiceWindowGenerationFromText::notifyTranslator(unsigned char* text) {
89 - tradutor->traduz(text); 94 + tradutor->traduz(text);
90 } 95 }
91 96
92 -void ServiceWindowGenerationFromText::notifyLine(unsigned char* line) {  
93 - notifyTranslator(line); 97 +void ServiceWindowGenerationFromText::notifyLine(unsigned char* line){
  98 + if (sub_language == 1)
  99 + notifyTranslator(line);
  100 + else{
  101 + string text(reinterpret_cast<char*>(line));
  102 +
  103 + locale loc;
  104 + string glosa = "";
  105 + for (string::size_type i=0; i< text.length(); ++i) {
  106 + glosa += std::toupper(text[i], loc);
  107 + }
  108 + notifyRenderer(glosa);
  109 + }
94 } 110 }
95 111
96 -void ServiceWindowGenerationFromText::notifyEndOfSynchronization() {  
97 - transcodeVideoToMp4();  
98 - this->running = false; 112 +void ServiceWindowGenerationFromText::notifyTranslation(char* glosa) {
  113 + string sGlosa(glosa);
  114 + notifyRenderer(sGlosa);
99 } 115 }
100 116
101 -void ServiceWindowGenerationFromText::notifyTranslation(vector<string> * glosas) {  
102 - for (int i = 0; i < glosas->size(); i++) {  
103 - locale loc;  
104 - string glosa_lower = "";  
105 - for (int k = 0; k < glosas->at(i).length(); k++){  
106 - glosa_lower += std::tolower(glosas->at(i).at(k), loc);  
107 - }  
108 - sincronizador->recebeglosa(glosa_lower, 1000); 117 +void ServiceWindowGenerationFromText::notifyRenderer(string glosa) {
  118 + try{
  119 + renderer->receiveGlosa(glosa, (int64_t) -1);
  120 + legendas_enviadas++;
  121 + }catch(lavidlib::RuntimeException &ex){
  122 + throw ServiceException(ex.getMessage().c_str());
109 } 123 }
110 - sincronizador->stop();  
111 - legendas_enviadas++;  
112 } 124 }
113 125
  126 +void ServiceWindowGenerationFromText::notifyEndOfRenderization() {
  127 + this->running = false;
  128 +}
114 129
115 void ServiceWindowGenerationFromText::notifyEnd(int line_size) { 130 void ServiceWindowGenerationFromText::notifyEnd(int line_size) {
116 - DPRINTF("Service Text recebeu: %d linhas.\n", line_size);  
117 - setSizeOfSubtitles(line_size); 131 + PRINTL(util::_DEBUG, "Service Text recebeu: %d linhas.\n", line_size);
  132 + try{
  133 + setSizeOfSubtitles(line_size);
  134 + }catch(ServiceException &ex) {
  135 + finish = true;
  136 + }
118 } 137 }
119 138
120 bool ServiceWindowGenerationFromText::isRunning() { 139 bool ServiceWindowGenerationFromText::isRunning() {
@@ -126,43 +145,33 @@ bool ServiceWindowGenerationFromText::isFinished() { @@ -126,43 +145,33 @@ bool ServiceWindowGenerationFromText::isFinished() {
126 } 145 }
127 146
128 void ServiceWindowGenerationFromText::initialize() { 147 void ServiceWindowGenerationFromText::initialize() {
129 - DPRINTF("Service Text Initialize.\n");  
130 - extratorTXT = (ExtratorTXT*) extrator_factory->getExtrator(Extrator::TXT); 148 + PRINTL(util::_DEBUG, "Service Text Initialize.\n");
  149 + setPathLibras();
  150 + extratorTXT = (ExtratorTXT*) extrator_factory->getExtrator(Extrator::TXT);
131 extratorTXT->addListener(this); 151 extratorTXT->addListener(this);
132 extratorTXT->setFilePath(path_input); 152 extratorTXT->setFilePath(path_input);
133 153
134 - setPathLibras();  
135 -  
136 - tradutor->addListener(this);  
137 -  
138 - setBackground(); 154 + tradutor = new TradutorPortGlosa();
  155 + if (this->sub_language == 1) {
  156 + tradutor->addListener(this);
  157 + }
139 158
140 - uint64_t pcr_base = (uint64_t) 1000; //FIXME: macro  
141 - sincronizador->setPCRBase(pcr_base);  
142 - sincronizador->addListener(this);  
143 - sincronizador->Start(); 159 + renderer = new Renderer(this->path_libras, this->user_id);
  160 + renderer->addListener(this);
144 161
145 try{ 162 try{
146 - extratorTXT->initialize(); 163 + extratorTXT->initialize();
147 }catch(ExtratorException ex){ 164 }catch(ExtratorException ex){
148 - throw ServiceException(ex.getMessage()); 165 + throw ServiceException(ex.getMessage().c_str());
  166 + }catch(RuntimeException &ex){
  167 + throw ServiceException(ex.getMessage().c_str());
149 } 168 }
150 this->Start(); 169 this->Start();
151 } 170 }
152 171
153 -void ServiceWindowGenerationFromText::transcodeVideoToMp4(){  
154 - DPRINTF("[AGUARDE] Transcodificando o vídeo de Libras...\n");  
155 - string command = "ffmpeg -i ";  
156 - command.append(path_libras)  
157 - .append(" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 ").append(" -v quiet ")  
158 - .append(path_contents).append(user_id).append(".mp4");  
159 - //printf("[INFO]: Transcodification command -> %s\n", command.c_str());  
160 - system(command.c_str());  
161 -}  
162 -  
163 void ServiceWindowGenerationFromText::Run(){ 172 void ServiceWindowGenerationFromText::Run(){
164 while(isRunning()){ 173 while(isRunning()){
165 usleep(200000); 174 usleep(200000);
166 } 175 }
167 finish = true; 176 finish = true;
168 -}  
169 \ No newline at end of file 177 \ No newline at end of file
  178 +}
synchronizer/src/include/listenerSynchronizer.h
@@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
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  
15 \ No newline at end of file 0 \ No newline at end of file
synchronizer/src/include/synchronizer.h
@@ -1,126 +0,0 @@ @@ -1,126 +0,0 @@
1 -#ifndef SYNCHRONIZER_H  
2 -#define SYNCHRONIZER_H  
3 -  
4 -#include <stdio.h>  
5 -#include <stdlib.h>  
6 -#include <string.h>  
7 -#include <errno.h>  
8 -#include <time.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>  
18 -#include <fstream>  
19 -#include "dprintf.h"  
20 -#include "jmutex.h"  
21 -#include "jthread.h"  
22 -#include "listenerSynchronizer.h"  
23 -//#include "httpstreamer.h"  
24 -  
25 -#define VIDEO_PADRAO "vlibras_user/dicionario_libras/poseneutra.ts"  
26 -#define VIDEOTRANSP_PADRAO "vlibras_user/dicionarioTransp_libras/poseneutra.ts"  
27 -  
28 -//DICIONARIO 30 fps  
29 -#define PCRPID 256  
30 -#define PESPID 256  
31 -  
32 -//DICIONARIO 45 fps  
33 -//#define PCRPID 4097  
34 -//#define PESPID 4113  
35 -  
36 -using namespace jthread;  
37 -using namespace std;  
38 -  
39 -class Synchronizer : public jthread::Thread {  
40 -  
41 -private:  
42 - bool hastext;  
43 - int taxa;  
44 - int filefd;  
45 - vector <char*> *videos;  
46 - int devicetv;  
47 -  
48 - uint64_t pcrBaseGeral;  
49 - uint64_t ultimoPCRBase;  
50 - uint64_t ultimoPCRBaseMod;  
51 - int64_t pcr_inicial;  
52 - int mediaDiferencaPCR;  
53 - int contagemPCR;  
54 -  
55 - ofstream escreveAux;  
56 - char* extensao;  
57 - char* baseDir;  
58 -  
59 - int64_t tempo_poseneutra;  
60 - vector <int64_t> *vector_pts;  
61 - int flagPrimeiroArquivo;  
62 -  
63 - list<ListenerSynchronizer*> * listeners;  
64 - Mutex* mutex_sync;  
65 - Mutex* mutexi;  
66 -  
67 - char* path_libras;  
68 - int transparency;  
69 -  
70 - int count_tasks;  
71 - bool service_running;  
72 -  
73 -  
74 -public:  
75 - Synchronizer();  
76 - Synchronizer(/*int64_t pcr_inicial, */char*baseDir, char* extensao, char* path_libras, int transparency);  
77 - virtual ~Synchronizer();  
78 -  
79 - void setPCRBase(uint64_t pcr_base);  
80 -  
81 - void Run();  
82 - void stop();  
83 -  
84 - void soletraGlosa(string glosa, int64_t pts);//em fase de teste  
85 - void recebeglosa(char * video, int tam, int64_t pts);  
86 - void recebeglosa(string glosa, int64_t pts);  
87 - char * getproximoarquivo();  
88 -  
89 - void msleep(long tsleep, long *desconto);  
90 -  
91 - int gettaxa();  
92 - int64_t getMilisegundos();  
93 -  
94 - void settaxa(int taxa);  
95 -  
96 - vector <char*> * getVideos();  
97 -  
98 - void analisaPCR(unsigned char * pacote);  
99 - void analisaPTSDTS(unsigned char *pacote);  
100 - int getPid(unsigned char *pacote);  
101 - bool contemAF(unsigned char *pacote);  
102 - int getTamanhoAF(unsigned char *pacote);  
103 - bool contemPCR(unsigned char *pacote);  
104 - uint64_t retornaPCRBase(unsigned char *pacote);  
105 - void setPCRBase(unsigned char *pacote, uint64_t pcrbase);  
106 - bool contemPayloadStartIndicator(unsigned char *pacote);  
107 - bool contemPayloadData(unsigned char *pacote);  
108 - bool verificaPESStartCode(unsigned char *PESPacket);  
109 - bool verificaPESStreamID(unsigned char *PESPacket);  
110 - bool contemPTS(unsigned char *PESPacket);  
111 - bool contemDTS(unsigned char *PESPacket);  
112 - uint64_t retornaPTS(unsigned char *PESPacket);  
113 - uint64_t retornaDTS(unsigned char *PESPacket);  
114 - void setNovoPTS(unsigned char *pacote, uint64_t PTS);  
115 - void setNovoDTS(unsigned char *pacote, uint64_t DTS);  
116 - void escrevePacote(char *pacote);  
117 - int escrevePacote(int * descritor, char *pacote, int size);  
118 -  
119 - virtual void addListener(ListenerSynchronizer* listener);  
120 - virtual void removeListener(ListenerSynchronizer* listener);  
121 - virtual void notifyListeners();  
122 -  
123 -};  
124 -  
125 -  
126 -#endif /* SYNCHRONIZER_H */  
synchronizer/src/synchronizer.cpp
@@ -1,568 +0,0 @@ @@ -1,568 +0,0 @@
1 -#include "synchronizer.h"  
2 -  
3 -Synchronizer::Synchronizer() {  
4 - baseDir = (char*) "vlibras_user/dicionario_libras/";  
5 - extensao = (char*) ".ts";  
6 - filefd = 0;  
7 - videos = new vector <char*> ();  
8 - vector_pts = new vector <int64_t > ();  
9 - this->mutexi = new Mutex();  
10 -  
11 - this->baseDir = new char[strlen(baseDir) + 1];  
12 - strcpy(this->baseDir, baseDir);  
13 -  
14 - this->extensao = new char[strlen(extensao) + 1];  
15 - strcpy(this->extensao, extensao);  
16 - flagPrimeiroArquivo = 1;  
17 - listeners = new list<ListenerSynchronizer*>();  
18 - this->path_libras = path_libras;  
19 - DPRINTF("Done!\n")  
20 -}  
21 -  
22 -Synchronizer::Synchronizer(/*int64_t pcr_inicial, */char* baseDir, char* extensao, char* path_libras, int transparency) {  
23 -  
24 - hastext = true;  
25 - count_tasks = 0; // Usado no teste de Eduardo!  
26 - service_running = true;  
27 -  
28 - this->pcr_inicial = -1;  
29 - this->tempo_poseneutra = 120000;  
30 -  
31 - this->transparency = transparency;  
32 -  
33 - //cout << "\n\nTransparencia: " << this->transparency << "\n";  
34 -  
35 - this->baseDir = new char[strlen(baseDir) + 1];  
36 - strcpy(this->baseDir, baseDir);  
37 -  
38 - //cout << "\n\n#######BASEDIR: " << this->baseDir << "\n";  
39 -  
40 - this->extensao = new char[strlen(extensao) + 1];  
41 - strcpy(this->extensao, extensao);  
42 -  
43 - filefd = 0;  
44 - videos = new vector <char*> ();  
45 - pcrBaseGeral = 0;  
46 - ultimoPCRBase = 0;  
47 - mediaDiferencaPCR = 0;  
48 - contagemPCR = 0;  
49 - vector_pts = new vector <int64_t > ();  
50 - flagPrimeiroArquivo = 1;  
51 - listeners = new list<ListenerSynchronizer*>();  
52 - this->path_libras = new char[strlen(path_libras) + 1];  
53 - strcpy(this->path_libras, path_libras);  
54 - //cout << "-> path libras sync: " << path_libras << endl;  
55 - this->mutex_sync = new Mutex();  
56 - this->mutexi = new Mutex();  
57 -  
58 - DPRINTF("Done!\n")  
59 -}  
60 -  
61 -Synchronizer::~Synchronizer() {  
62 - free(videos);  
63 - listeners->clear();  
64 - delete listeners;  
65 - if (escreveAux.is_open()) escreveAux.close();  
66 - DDDPRINTF("Synchronizer finalized!\n");  
67 -  
68 -}  
69 -  
70 -string toLower(string strr) {  
71 - char str[100];  
72 - string ret;  
73 - strcpy(str, strr.c_str());  
74 - int differ = 'A' - 'a';  
75 - char ch;  
76 - int ii = strlen(str);  
77 - for (int i = 0; i < ii; i++) {  
78 - strncpy(&ch, str + i, 1);  
79 - if (ch >= 'A' && ch <= 'Z') {  
80 - ch = ch - differ;  
81 - memcpy(str + i, &ch, 1);  
82 - }  
83 - }  
84 - ret = str;  
85 - return ret;  
86 -}  
87 -  
88 -void Synchronizer::setPCRBase(uint64_t pcr_base){  
89 - this->pcr_inicial = pcr_base;  
90 -}  
91 -  
92 -char* converteString(string palavra) {  
93 -  
94 - const char* aux = new char[palavra.size()];  
95 - aux = palavra.c_str();  
96 - char * aux2 = (char*) aux;  
97 -  
98 - return aux2;  
99 -}  
100 -  
101 -/* Método utilizado pelos serviços (Services Generation) para informar que  
102 - este processo pode ser finalizado após a demanda atual, isto é, depois  
103 - que terminar de gerar os vídeos que estão na fila.  
104 - */  
105 -void Synchronizer::stop() {  
106 - //printf("> O Synchronizer recebeu a mensagem de que pode terminar a execução\n");  
107 - service_running = false;  
108 -}  
109 -  
110 -int Synchronizer::gettaxa() {  
111 - return taxa;  
112 -}  
113 -  
114 -void Synchronizer::settaxa(int taxa) {  
115 - this->taxa = taxa;  
116 -}  
117 -  
118 -vector <char*> * Synchronizer::getVideos() {  
119 - return videos;  
120 -}  
121 -  
122 -/* Trata a glosa de modo single, ou seja, havendo sinal ou soletrando,  
123 - este método é chamado individualmente em cada sinal correspondente.  
124 - */  
125 -void Synchronizer::recebeglosa(char * video, int tam, int64_t pts) {  
126 - mutexi->Lock();  
127 - char *video_copy = new char [tam + 1];  
128 - strcpy(video_copy, video);  
129 - videos->push_back(video_copy);  
130 - count_tasks++;  
131 - vector_pts->push_back(pts);  
132 - mutexi->Unlock();  
133 -}  
134 -  
135 -int64_t Synchronizer::getMilisegundos() {  
136 - struct timeval tempo;  
137 - gettimeofday(&tempo, NULL);  
138 - return (int64_t) tempo.tv_sec * 1000 + tempo.tv_usec / 1000;  
139 -}  
140 -  
141 -void Synchronizer::msleep(long tsleep, long *desconto) {  
142 - struct timeval tempo;  
143 - long deltaTAux = 0;  
144 - long tusleep = 0;  
145 - int64_t tAux = 0, tAux2 = 0;  
146 -  
147 - tsleep -= *desconto;  
148 -  
149 - tusleep = tsleep / 1000;  
150 -  
151 - gettimeofday(&tempo, NULL);  
152 - tAux = tempo.tv_sec * 1000 + tempo.tv_usec / 1000;  
153 -  
154 - while ((tsleep > 0) && (deltaTAux <= tsleep)) {  
155 - usleep(tusleep);  
156 -  
157 - gettimeofday(&tempo, NULL);  
158 - tAux2 = tempo.tv_sec * 1000 + tempo.tv_usec / 1000;  
159 -  
160 - deltaTAux = (tAux2 - tAux)*1000;  
161 - }  
162 -  
163 - //desconto = (deltaTAux - (tsleep/1000))*1000;  
164 - *desconto = (deltaTAux - tsleep);  
165 -}  
166 -  
167 -char* proximo = new char[1000];  
168 -char* proximo2 = new char[1000];  
169 -  
170 -char * Synchronizer::getproximoarquivo() {  
171 - char * video = new char[1000];  
172 - string s1, s2, s3;  
173 - video = NULL;  
174 - list<char *>::iterator it;  
175 - //proximo = NULL;  
176 -  
177 - if (videos->size() == 0) {  
178 - if(this->transparency == 0){  
179 - return VIDEO_PADRAO;  
180 - }else{  
181 - return VIDEOTRANSP_PADRAO;  
182 - }  
183 - }  
184 -  
185 - mutexi->Lock();  
186 - video = videos->front();  
187 -  
188 - videos->erase(videos->begin());  
189 - mutexi->Unlock();  
190 -  
191 - if (video == NULL) {  
192 - if(this->transparency == 0){  
193 - return VIDEO_PADRAO;  
194 - }else{  
195 - return VIDEOTRANSP_PADRAO;  
196 - }  
197 - }else{  
198 - return video;  
199 - }  
200 -}  
201 -  
202 -void Synchronizer::analisaPCR(unsigned char *pacote) {  
203 - // preciso ter o PID de PCR  
204 - if ((getPid(pacote) != PCRPID) || (!contemAF(pacote))  
205 - //if ((!contemAF(pacote))  
206 - || (getTamanhoAF(pacote) == 0) || (!contemPCR(pacote))) {  
207 -  
208 -  
209 - if (contemPCR(pacote)){  
210 - //printf("Encontrei PCR - PID:%d\n", getPid(pacote));  
211 -  
212 - }  
213 - return;  
214 - }  
215 -  
216 - uint64_t pcrBase = retornaPCRBase(pacote);  
217 -  
218 - if (mediaDiferencaPCR != 0 && contagemPCR == 0) { // nesse caso esse eh o primeiro PCR de um novo video  
219 - //printf("Encontrei o primeiro PCR de um video!\n");  
220 - setPCRBase(pacote, pcrBaseGeral + mediaDiferencaPCR); // tem que multiplicar por 2 o mediaDiferencaPCR?  
221 - ultimoPCRBaseMod = pcrBaseGeral + mediaDiferencaPCR;  
222 - mediaDiferencaPCR = 0;  
223 - } else if (mediaDiferencaPCR == 0 && contagemPCR == 0 && flagPrimeiroArquivo == 1) {  
224 - flagPrimeiroArquivo = 0;  
225 - setPCRBase(pacote, pcr_inicial + mediaDiferencaPCR); // tem que multiplicar por 2 o mediaDiferencaPCR?  
226 - contagemPCR++;  
227 - sleep(1);  
228 - ultimoPCRBaseMod = pcr_inicial + mediaDiferencaPCR;  
229 -  
230 - }  
231 - else {  
232 -  
233 - mediaDiferencaPCR = (ultimoPCRBase > 0) ? pcrBase - ultimoPCRBase : 0;  
234 - contagemPCR++;  
235 -  
236 - //if (pcrBaseGeral != 0) { // se nao for o primeiro video //2 - Mudei para o serviço  
237 - setPCRBase(pacote, ultimoPCRBaseMod + mediaDiferencaPCR);  
238 - ultimoPCRBaseMod += mediaDiferencaPCR;  
239 - //}  
240 - }  
241 -  
242 - ultimoPCRBase = pcrBase;  
243 -  
244 -}  
245 -  
246 -void Synchronizer::analisaPTSDTS(unsigned char *pacote) {  
247 - int inicioPESData = 4;  
248 - if (contemAF(pacote)) inicioPESData += getTamanhoAF(pacote) + 1;  
249 -  
250 - if ((!verificaPESStartCode(pacote + inicioPESData)) ||  
251 - (!verificaPESStreamID(pacote + inicioPESData)) ||  
252 - (!contemPTS(pacote + inicioPESData))) {  
253 -  
254 - return;  
255 - }  
256 -  
257 - uint64_t PTS = retornaPTS(pacote + inicioPESData);  
258 - int diferenca = PTS - ultimoPCRBase;  
259 - // confirmar se isso aqui SEMPRE eh chamado depois de pelo menos um PCR ser encontrado, principalmente  
260 - // no inicio do video  
261 - if (ultimoPCRBaseMod != 0)  
262 - setNovoPTS(pacote + inicioPESData, ultimoPCRBaseMod + diferenca);  
263 - else  
264 - setNovoPTS(pacote + inicioPESData, pcrBaseGeral + diferenca);  
265 -  
266 - if (!contemDTS(pacote + inicioPESData)) return;  
267 -  
268 - uint64_t DTS = retornaDTS(pacote + inicioPESData);  
269 - diferenca = DTS - ultimoPCRBase;  
270 -  
271 - if (ultimoPCRBaseMod != 0)  
272 - setNovoDTS(pacote + inicioPESData, ultimoPCRBaseMod + diferenca);  
273 - else  
274 - setNovoDTS(pacote + inicioPESData, pcrBaseGeral + diferenca);  
275 -}  
276 -  
277 -int Synchronizer::getPid(unsigned char *pacote) {  
278 - return ((pacote[1] & 0x1F) << 8) | pacote[2];  
279 -}  
280 -  
281 -bool Synchronizer::contemAF(unsigned char *pacote) {  
282 - return pacote[3] & 0x20;  
283 -}  
284 -  
285 -int Synchronizer::getTamanhoAF(unsigned char *pacote) {  
286 - return pacote[4];  
287 -}  
288 -  
289 -bool Synchronizer::contemPCR(unsigned char *pacote) {  
290 - return pacote[5] & 0x10;  
291 -}  
292 -  
293 -uint64_t Synchronizer::retornaPCRBase(unsigned char *pacote) {  
294 - uint64_t pcrbase = 0;  
295 -  
296 - pcrbase = (uint64_t) pacote[6] << 25 | pacote[7] << 17 | pacote[8] << 9  
297 - | pacote[9] << 1 | (pacote[10] & 0x80) >> 7;  
298 -  
299 - return pcrbase;  
300 -}  
301 -  
302 -void Synchronizer::setPCRBase(unsigned char *pacote, uint64_t pcrbase) {  
303 - pacote[6] = pcrbase >> 25;  
304 - pacote[7] = pcrbase >> 17;  
305 - pacote[8] = pcrbase >> 9;  
306 - pacote[9] = pcrbase >> 1;  
307 - if ((pcrbase << 63) != 0)  
308 - pacote[10] = pacote[10] | 0x80;  
309 - else  
310 - pacote[10] = pacote[10] & 0x7F;  
311 -}  
312 -  
313 -bool Synchronizer::contemPayloadStartIndicator(unsigned char *pacote) {  
314 - return pacote[1] & 0x40;  
315 -}  
316 -  
317 -bool Synchronizer::contemPayloadData(unsigned char *pacote) {  
318 - return pacote[3] & 0x10;  
319 -}  
320 -  
321 -bool Synchronizer::verificaPESStartCode(unsigned char *PESPacket) {  
322 - return (((PESPacket[0] << 16) | (PESPacket[1] << 8) | (PESPacket[2]))  
323 - == 0x000001) ? 1 : 0;  
324 -}  
325 -  
326 -bool Synchronizer::verificaPESStreamID(unsigned char *PESPacket) {  
327 - int stream_id = PESPacket[3];  
328 -  
329 - return ((stream_id != 0xBC) && (stream_id != 0xBE) && (stream_id != 0xBF)  
330 - && (stream_id != 0xF0) && (stream_id != 0xF1) && (stream_id != 0xFF)  
331 - && (stream_id != 0xF2) && (stream_id != 0xF8));  
332 -}  
333 -  
334 -bool Synchronizer::contemPTS(unsigned char *PESPacket) {  
335 - //printf("\nTem PTS: %d\n", PESPacket[7] & 0x80);  
336 - return PESPacket[7] & 0x80;  
337 -}  
338 -  
339 -bool Synchronizer::contemDTS(unsigned char *PESPacket) {  
340 - return PESPacket[7] & 0x40;  
341 -}  
342 -  
343 -uint64_t Synchronizer::retornaPTS(unsigned char *PESPacket) {  
344 - uint64_t PTS = (uint64_t) ((PESPacket[9] & 0x0E) >> 1) << 30 |  
345 - (PESPacket[10] << 22) |  
346 - (((PESPacket[11] & 0xFE) >> 1) << 15) |  
347 - (PESPacket[12] << 7) |  
348 - ((PESPacket[13] & 0xFE) >> 1);  
349 - return PTS;  
350 -}  
351 -  
352 -uint64_t Synchronizer::retornaDTS(unsigned char *PESPacket) {  
353 - uint64_t DTS = (uint64_t) ((PESPacket[14] & 0x0E) >> 1) << 30 |  
354 - (PESPacket[15] << 22) |  
355 - (((PESPacket[16] & 0xFE) >> 1) << 15) |  
356 - (PESPacket[17] << 7) |  
357 - ((PESPacket[18] & 0xFE) >> 1);  
358 - return DTS;  
359 -}  
360 -  
361 -void Synchronizer::setNovoPTS(unsigned char *pacote, uint64_t PTS) {  
362 - pacote[9] = pacote[9] & 0xF1;  
363 - pacote[9] = pacote[9] | ((PTS >> 30) << 1);  
364 - pacote[10] = PTS >> 22;  
365 - pacote[11] = pacote[11] & 0x1;  
366 - pacote[11] = pacote[11] | ((PTS >> 15) << 1);  
367 - pacote[12] = PTS >> 7;  
368 - pacote[13] = pacote[13] & 0x1;  
369 - pacote[13] = pacote[13] | PTS << 1;  
370 -}  
371 -  
372 -void Synchronizer::setNovoDTS(unsigned char *pacote, uint64_t DTS) {  
373 - pacote[14] = pacote[14] & 0xF1;  
374 - pacote[14] = pacote[14] | ((DTS >> 30) << 1);  
375 - pacote[15] = DTS >> 22;  
376 - pacote[16] = pacote[16] & 0x1;  
377 - pacote[16] = pacote[16] | ((DTS >> 15) << 1);  
378 - pacote[17] = DTS >> 7;  
379 - pacote[18] = pacote[18] & 0x1;  
380 - pacote[18] = pacote[18] | DTS << 1;  
381 -}  
382 -  
383 -void Synchronizer::escrevePacote(char *pacote) {  
384 - if (!escreveAux.is_open()) {  
385 - escreveAux.open(this->path_libras, ios::out | ios::binary);  
386 -  
387 - }  
388 - //printf("tamanho do pacote = %d\n\n", strlen(pacote));  
389 - escreveAux.write(pacote, 188*70);  
390 - //printf(" OK!\n\n");  
391 -  
392 -}  
393 -  
394 -int Synchronizer::escrevePacote(int * descritor, char *pacote, int size) {  
395 - if (*descritor < 0) {// ainda não abri  
396 - *descritor = open(this->path_libras, O_WRONLY | O_CREAT, 0660);  
397 - if (descritor < 0) {  
398 - printf("Can't open output file\n");  
399 - return -1;  
400 - }  
401 - }  
402 - return write(*descritor, pacote, size);  
403 -}  
404 -  
405 -void ouch(int sig) {  
406 - printf("\nSinal Capturado %d", sig);  
407 - (void) signal(SIGPIPE, SIG_DFL);  
408 -  
409 -}  
410 -  
411 -void Synchronizer::soletraGlosa(string glosa, int64_t pts) {  
412 -  
413 - //string path = (string) baseDir + glosa + (string) extensao;  
414 - //cout << "\n***Glosa NAO ENCONTRADA: " << glosa << endl;  
415 - /*mutexi->Lock();  
416 - int file = open(converteString(path), O_RDONLY);  
417 - mutexi->Unlock();*/  
418 - //if (file != NULL) {  
419 - for (int i = 0; i < glosa.length(); i++) {  
420 - if (glosa[i] == '[')  
421 - return;  
422 - char c = glosa[i];  
423 - if (c >= 97 && c <= 122) {  
424 - string path2 = (string) baseDir + glosa[i] + (string) extensao;  
425 - char* path2_char = converteString(path2);  
426 - recebeglosa(converteString(path2), strlen(path2_char), pts);  
427 - }  
428 - }  
429 - //close(file);  
430 - //} else {  
431 - // printf("*** ERRO ao abrir o arquivo.");  
432 - //}  
433 -  
434 -}  
435 -  
436 -/* Utilizado no teste de Eduardo */  
437 -void Synchronizer::recebeglosa(string glosa, int64_t pts) {  
438 - glosa = toLower(glosa);  
439 -  
440 - size_t found;  
441 - found=glosa.rfind("dl");  
442 - if (found == 0)  
443 - glosa = glosa.substr(2, glosa.length());  
444 -  
445 - string path = (string) baseDir + glosa.c_str() + (string) extensao;  
446 - char* urlchar = converteString(path);  
447 - mutexi->Lock();  
448 - FILE *f = fopen(urlchar, "r");  
449 - mutexi->Unlock();  
450 - if (f == NULL) {  
451 - soletraGlosa(glosa, pts);  
452 - } else {  
453 - fclose(f);  
454 - recebeglosa(urlchar, strlen(urlchar), pts);  
455 - }  
456 -  
457 -}  
458 -  
459 -  
460 -void Synchronizer::addListener(ListenerSynchronizer* listener) {  
461 - listeners->push_back(listener);  
462 -}  
463 -  
464 -void Synchronizer::removeListener(ListenerSynchronizer* listener) {  
465 - listeners->remove(listener);  
466 -}  
467 -  
468 -void Synchronizer::notifyListeners() {  
469 - for (list<ListenerSynchronizer*>::iterator i = listeners->begin(); i != listeners->end(); i++) {  
470 - (*i)->notifyEndOfSynchronization();  
471 - }  
472 -}  
473 -  
474 -void Synchronizer::Run() {  
475 -  
476 - pcrBaseGeral = ultimoPCRBase = mediaDiferencaPCR = contagemPCR = ultimoPCRBaseMod = 0;  
477 - int64_t t0 = 0, tf = 0;  
478 - int64_t pts_run;  
479 - int cnt, finalcnt, bitrate = 1121600, deltaT = 0;  
480 - int bufferSize = 7 * 188;  
481 - char * buff = new char[bufferSize];  
482 -  
483 - char * arquivo;  
484 -  
485 - while (videos->size() == 0){  
486 - usleep(50000); //50ms  
487 - }  
488 -  
489 - if(this->transparency == 0)  
490 - arquivo = VIDEO_PADRAO;  
491 - else  
492 - arquivo = VIDEOTRANSP_PADRAO;  
493 -  
494 - mutexi->Lock();  
495 - filefd = open(arquivo, O_RDONLY);  
496 - mutexi->Unlock();  
497 -  
498 - if (filefd < 0)  
499 - cout << "NAO CONSEGUI ABRIR O ARQUIVO2 - " << arquivo << endl;  
500 -  
501 - (void) signal(SIGPIPE, ouch);  
502 -  
503 - int videos_processed = 0;  
504 -  
505 - int desc_out = -1;  
506 -  
507 - while (videos_processed <= count_tasks || service_running) {  
508 -  
509 - cnt = read(filefd, buff, bufferSize);  
510 -  
511 - // atualiza os valores de PCR e PTS/DTS para cada video  
512 - for (int i = 0; i < cnt / 188; i++) {  
513 - analisaPCR((unsigned char*) buff + (188 * i));  
514 - analisaPTSDTS((unsigned char*) buff + (188 * i));  
515 - }  
516 -  
517 - escrevePacote(&desc_out,buff,cnt);  
518 - free(buff);  
519 - buff = new char[bufferSize];  
520 -  
521 - finalcnt = cnt;  
522 - if (finalcnt == 0) {  
523 -  
524 - while (videos->size() == 0 && service_running) { // esperando arquivos do serviço  
525 - usleep(10000);  
526 - }  
527 -  
528 - pts_run = vector_pts->front();  
529 - if (ultimoPCRBaseMod + tempo_poseneutra < pts_run) {  
530 - if(this->transparency == 0){  
531 - arquivo = VIDEO_PADRAO;  
532 - }else{  
533 - arquivo = VIDEOTRANSP_PADRAO;  
534 - }  
535 -  
536 - }else {  
537 - if (vector_pts->size() > 0) {  
538 - vector_pts->erase(vector_pts->begin());  
539 - arquivo = getproximoarquivo();  
540 - }  
541 - videos_processed++;  
542 - }  
543 -  
544 - close(filefd);  
545 - filefd = open(arquivo, O_RDONLY);  
546 - if (ultimoPCRBase != 0) {  
547 - if (ultimoPCRBaseMod != 0) {  
548 - pcrBaseGeral = ultimoPCRBaseMod;  
549 - } else {  
550 - pcrBaseGeral = ultimoPCRBase;  
551 - }  
552 - contagemPCR = 0;  
553 - ultimoPCRBaseMod = 0;  
554 - }  
555 - } else if (finalcnt == -1) {  
556 - printf("Erro: Finalizando Sincronizador!\n");  
557 - this->stop();  
558 - }  
559 - } // Fim do while!  
560 -  
561 - //fsync(desc_out);  
562 - close(filefd);  
563 - close(desc_out);  
564 - notifyListeners();  
565 -  
566 -}  
567 -  
568 -  
tradutor/src/include/listenerTradutor.h
1 -/*  
2 - * File: ouvinteTradutor.h  
3 - * Author: derzu  
4 - *  
5 - * Created on 2 de Fevereiro de 2010, 15:48 1 +/**
  2 + * \file listenerTradutor.h
  3 + *
  4 + * \author Derzu Omaia
  5 + * \date 02/02/2010
6 */ 6 */
  7 +
7 #ifndef _LISTENERTRADUTOR_H 8 #ifndef _LISTENERTRADUTOR_H
8 #define _LISTENERTRADUTOR_H 9 #define _LISTENERTRADUTOR_H
9 10
@@ -14,11 +15,7 @@ namespace Tradutor { @@ -14,11 +15,7 @@ namespace Tradutor {
14 15
15 class ListenerTradutor { 16 class ListenerTradutor {
16 public: 17 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; 18 + virtual void notifyTranslation(char* glosa) = 0;
22 }; 19 };
23 20
24 } 21 }
tradutor/src/include/pyTradutor.h
@@ -8,7 +8,8 @@ @@ -8,7 +8,8 @@
8 //***************************************************************** 8 //*****************************************************************
9 9
10 /** 10 /**
11 - * \file pyTradutor.hpp 11 + * \file pyTradutor.h
  12 + *
12 * \authors Erickson Silva, Gustavo Sobral 13 * \authors Erickson Silva, Gustavo Sobral
13 * \date Janeiro 2015 14 * \date Janeiro 2015
14 */ 15 */
@@ -20,6 +21,8 @@ @@ -20,6 +21,8 @@
20 * Essa classe permite a execução e comunição do Tradutor 21 * Essa classe permite a execução e comunição do Tradutor
21 * (Português -> Glosa) do sistema escrito em Python 22 * (Português -> Glosa) do sistema escrito em Python
22 * permitindo sua utilização numa aplicação C++. 23 * permitindo sua utilização numa aplicação C++.
  24 + *
  25 + * \headerfile tradutor/src/include/pyTradutor.h
23 */ 26 */
24 class PyTradutor 27 class PyTradutor
25 { 28 {
@@ -32,19 +35,19 @@ private: @@ -32,19 +35,19 @@ private:
32 PyObject * pResult; 35 PyObject * pResult;
33 public: 36 public:
34 37
35 - /** \brief O construtor da classe 38 + /** O construtor da classe
36 * 39 *
37 * O construtor inicia o ambiente Python para execução da tradução do tradutor. 40 * O construtor inicia o ambiente Python para execução da tradução do tradutor.
38 */ 41 */
39 PyTradutor(); 42 PyTradutor();
40 43
41 - /** \brief O destrutor da classe 44 + /** O destrutor da classe
42 * 45 *
43 * O Destrutor finaliza o ambiente Python montado para execução da tradução. 46 * O Destrutor finaliza o ambiente Python montado para execução da tradução.
44 */ 47 */
45 ~PyTradutor(); 48 ~PyTradutor();
46 49
47 - /** \brief Converte Português para Glosa 50 + /** Converte Português para Glosa
48 * 51 *
49 * Converte a string de entrada em Português para Glosa 52 * Converte a string de entrada em Português para Glosa
50 * através da execução do Tradutor e retorna esse resultado 53 * através da execução do Tradutor e retorna esse resultado
tradutor/src/include/tradutorPortGlosa.h
1 /** 1 /**
2 - * edit:  
3 - * @author Erickson Silva  
4 - * @date 14/10/2013 2 + * \file tradutorPortGlosa.h
5 * 3 *
  4 + * \authors Derzu Omaia, Erickson Silva
  5 + * \date 14/10/2013
6 */ 6 */
7 7
8 -/**  
9 - * Essa classe converte portugues para Glosa  
10 - *  
11 - * @author Derzu Omaia  
12 - * @date 21/10/2009  
13 - *  
14 - */  
15 #include <iostream> 8 #include <iostream>
16 #include <list> 9 #include <list>
17 #include <pthread.h> 10 #include <pthread.h>
18 #include "listenerTradutor.h" 11 #include "listenerTradutor.h"
19 -#include "pyTradutor.h"  
20 -#include "listenerInput.h"  
21 -#include "dprintf.h" 12 +#include "pyTradutor.h"
  13 +#include "logging.h"
22 14
23 #ifndef _GERADOR_GLOSA_H_ 15 #ifndef _GERADOR_GLOSA_H_
24 #define _GERADOR_GLOSA_H_ 16 #define _GERADOR_GLOSA_H_
25 17
26 using namespace std; 18 using namespace std;
  19 +using namespace util;
27 20
28 namespace Tradutor { 21 namespace Tradutor {
29 22
30 - class TradutorPortGlosa : public ListenerInput{ 23 + /** \brief classe para conversão de português para glosa
  24 + *
  25 + * \headerfile tradutor/src/include/tradutorPortGlosa.h
  26 + */
  27 + class TradutorPortGlosa {
31 public: 28 public:
  29 +
  30 + /** Construtor. */
32 TradutorPortGlosa(); 31 TradutorPortGlosa();
  32 +
  33 + /** Destrutor. */
33 virtual ~TradutorPortGlosa(); 34 virtual ~TradutorPortGlosa();
34 - std::vector<std::string> * portuguesToGlosaVector(const char * input);  
35 - std::vector<std::string> * portuguesToGlosaVectorSplit(char * pGlosa); 35 +
  36 + /**
  37 + * Traduz um texto (char* input) para um vetor de tokens<string> contendo a
  38 + * traducao para glosa.
  39 + *
  40 + * \param input texto de entrada.
  41 + * \return Vetor de string contendo os tokens em glosa traduzidos.
  42 + */
  43 + char* portuguesToGlosaVector(const char * input);
36 44
37 - // Adiciona 45 + /** Adiciona ouvintes do tradutorPortGlosa.
  46 + *
  47 + * \param listener O ouvinte a ser registrado.
  48 + */
38 void addListener(ListenerTradutor * listener); 49 void addListener(ListenerTradutor * listener);
39 - // Remove 50 +
  51 + /** Remove ouvintes do tradutorPortGlosa.
  52 + *
  53 + * \param listener O ouvinte a ser removido.
  54 + */
40 void removeListener(ListenerTradutor * listener); 55 void removeListener(ListenerTradutor * listener);
41 56
  57 + /** Traduz o portugues para glosa.
  58 + *
  59 + * Traduz o texto de portugues para glosa e notifica os ouvintes
  60 + * após a tradução.
  61 + *
  62 + * \param texto O texto a ser traduzido.
  63 + */
42 void traduz(unsigned char * texto); 64 void traduz(unsigned char * texto);
  65 +
  66 + /** Invoca os notificadores.
  67 + *
  68 + * Após a tradução, os ouvintes são notificados
  69 + * sobre a nova glosa.
  70 + *
  71 + * \param texto O texto para a tradução.
  72 + */
43 virtual void notifyInput(unsigned char * texto); 73 virtual void notifyInput(unsigned char * texto);
44 //virtual void notificaCC(unsigned char * cc, int64_t pts); 74 //virtual void notificaCC(unsigned char * cc, int64_t pts);
45 75
46 76
47 private: 77 private:
48 - void notifyListeners(std::vector<std::string> * traducao); 78 + /** Notifica os ouvintes sobre o fim da tradução. */
  79 + void notifyListeners(char* traducao);
49 80
50 std::list<ListenerTradutor*> * listeners; 81 std::list<ListenerTradutor*> * listeners;
51 PyTradutor * pyTradutor; 82 PyTradutor * pyTradutor;
tradutor/src/pyTradutor.cpp
@@ -39,7 +39,7 @@ PyTradutor::PyTradutor() @@ -39,7 +39,7 @@ PyTradutor::PyTradutor()
39 PyTradutor::~PyTradutor() 39 PyTradutor::~PyTradutor()
40 { 40 {
41 // Free the allocated memory and finalize the Python interpreter 41 // Free the allocated memory and finalize the Python interpreter
42 - Py_Finalize(); 42 + //Py_Finalize();
43 } 43 }
44 44
45 char * PyTradutor::convertStringToGlosa(const char * input) 45 char * PyTradutor::convertStringToGlosa(const char * input)
tradutor/src/tradutorPortGlosa.cpp
@@ -21,7 +21,7 @@ namespace Tradutor { @@ -21,7 +21,7 @@ namespace Tradutor {
21 // Inicia o mutex 21 // Inicia o mutex
22 mutex = (pthread_mutex_t *) malloc( sizeof(pthread_mutex_t) ); 22 mutex = (pthread_mutex_t *) malloc( sizeof(pthread_mutex_t) );
23 pthread_mutex_init(mutex, NULL); 23 pthread_mutex_init(mutex, NULL);
24 - DPRINTF("Done!\n") 24 + PRINTL(util::_DEBUG, "Translator Done!\n");
25 } 25 }
26 26
27 27
@@ -31,11 +31,10 @@ namespace Tradutor { @@ -31,11 +31,10 @@ namespace Tradutor {
31 if (mutex) { 31 if (mutex) {
32 int ret = pthread_mutex_destroy(mutex); 32 int ret = pthread_mutex_destroy(mutex);
33 if (ret) 33 if (ret)
34 - DDDPRINTF("Erro, destruindo mutex.\n"); 34 + PRINTL(util::_ERROR, "Erro, destruindo mutex.\n");
35 free(mutex); 35 free(mutex);
36 } 36 }
37 - DDDPRINTF("Translator finalized!\n")  
38 - 37 + PRINTL(util::_DEBUG, "Translator finalized!\n");
39 } 38 }
40 39
41 void TradutorPortGlosa::addListener(ListenerTradutor* listener) { 40 void TradutorPortGlosa::addListener(ListenerTradutor* listener) {
@@ -48,7 +47,7 @@ namespace Tradutor { @@ -48,7 +47,7 @@ namespace Tradutor {
48 } 47 }
49 48
50 49
51 - void TradutorPortGlosa::notifyListeners(vector<string> * traducao) { 50 + void TradutorPortGlosa::notifyListeners(char* traducao) {
52 for (list<ListenerTradutor*>::iterator i = listeners->begin() ; i != listeners->end() ; i++){ 51 for (list<ListenerTradutor*>::iterator i = listeners->begin() ; i != listeners->end() ; i++){
53 (*i)->notifyTranslation(traducao); 52 (*i)->notifyTranslation(traducao);
54 } 53 }
@@ -73,10 +72,8 @@ namespace Tradutor { @@ -73,10 +72,8 @@ namespace Tradutor {
73 72
74 void TradutorPortGlosa::traduz(unsigned char * texto) { 73 void TradutorPortGlosa::traduz(unsigned char * texto) {
75 74
76 - vector<string> * vGlosa = portuguesToGlosaVector((const char *)texto);  
77 - if (vGlosa->size() > 0)  
78 - notifyListeners(vGlosa);  
79 - free(vGlosa); 75 + char* glosa = portuguesToGlosaVector((const char *)texto);
  76 + notifyListeners(glosa);
80 } 77 }
81 78
82 79
@@ -87,42 +84,10 @@ namespace Tradutor { @@ -87,42 +84,10 @@ namespace Tradutor {
87 * @param input texto de entrada 84 * @param input texto de entrada
88 * @return vetor de string contendo os tokens em glosa traduzidos. 85 * @return vetor de string contendo os tokens em glosa traduzidos.
89 **/ 86 **/
90 - vector<string> * TradutorPortGlosa::portuguesToGlosaVector(const char * input) {  
91 - char * sGlosa;  
92 - vector<string> * vGlosa; 87 + char* TradutorPortGlosa::portuguesToGlosaVector(const char * input) {
  88 + char * glosa;
93 // Faz a tradução de portugues para glosa 89 // Faz a tradução de portugues para glosa
94 - sGlosa = pyTradutor->convertStringToGlosa(input);  
95 - // Cria vetor de string contendo os tokens da glosa já traduzidos  
96 - vGlosa = portuguesToGlosaVectorSplit(sGlosa);  
97 - return vGlosa;  
98 - }  
99 -  
100 - /**  
101 - * Faz split de uma string (char * sGlosa) para um vector<string> contendo os  
102 - * tokens da glosa  
103 - *  
104 - * @param sGlosa string de glosa  
105 - * @return vetor de string contendo os tokens em glosa.  
106 - **/  
107 - vector<string> * TradutorPortGlosa::portuguesToGlosaVectorSplit(char * sGlosa) {  
108 -  
109 - //printf("[INFO] Glosa: %s\n", sGlosa);  
110 -  
111 - vector<string> * vGlosa = new vector<string>();  
112 - string str(reinterpret_cast<char*>(sGlosa));  
113 -  
114 - int cutAt;  
115 - while((cutAt = str.find_first_of(" ")) != str.npos){  
116 - if(cutAt > 0){  
117 - vGlosa->push_back(str.substr(0,cutAt));  
118 - }  
119 - str = str.substr(cutAt+1);  
120 - }  
121 -  
122 - if(str.length() > 0) {  
123 - vGlosa->push_back(str);  
124 - }  
125 -  
126 - return vGlosa; 90 + glosa = pyTradutor->convertStringToGlosa(input);
  91 + return glosa;
127 } 92 }
128 } 93 }
util/src/argParser.cpp 0 → 100644
@@ -0,0 +1,282 @@ @@ -0,0 +1,282 @@
  1 +#include "argParser.h"
  2 +
  3 +ArgParser::ArgParser(){}
  4 +
  5 +ArgParser::~ArgParser(){}
  6 +
  7 +void ArgParser::readArgs(char** argv, int argc)
  8 +{
  9 + int opt;
  10 + int long_index = 0;
  11 +
  12 + static struct option long_options[] = {
  13 + {"audio", required_argument, NULL, 'A'},
  14 + {"subtitle", required_argument, NULL, 'S'},
  15 + {"text", required_argument, NULL, 'T'},
  16 + {"video", required_argument, NULL, 'V'},
  17 + {"language", required_argument, NULL, 'l'},
  18 + {"background", required_argument, NULL, 'b'},
  19 + {"resolution", required_argument, NULL, 'r'},
  20 + {"position", required_argument, NULL, 'p'},
  21 + {"mode", required_argument, NULL, 'm'},
  22 + {"id", required_argument, NULL, 'i'},
  23 + {"no-mixer", no_argument, NULL, 'x'},
  24 + {"check-modules", no_argument, NULL, 'C'},
  25 + {"loglevel", required_argument, NULL, 'v'},
  26 + {"help", no_argument, NULL, 'h'},
  27 + {0, 0, 0, 0 }
  28 + };
  29 +
  30 + while ((opt = getopt_long_only(argc, argv, "A:S:T:V:b:l:m:p:r:v:", long_options, &long_index))!= -1)
  31 + {
  32 + switch (opt)
  33 + {
  34 + case 'A':
  35 + if(argc < 9){
  36 + PRINTL(util::_ERROR, "Insuficient arguments. Try again\n");
  37 + throw lavidlib::RuntimeException();
  38 + }
  39 +
  40 + globalArgs.service = _REC_AUDIO;
  41 + globalArgs.input = optarg;
  42 + break;
  43 +
  44 + case 'S':
  45 + if(argc < 11 || (globalArgs.service == _REC_VIDEO && argc < 17)){
  46 + PRINTL(util::_ERROR, "Insuficient arguments. Try again\n");
  47 + throw lavidlib::RuntimeException();
  48 + }
  49 +
  50 + if(globalArgs.service == _REC_VIDEO){ // ativa o serviço de vídeo e legendas
  51 + globalArgs.service = _VIDEO_WITH_SRT;
  52 + globalArgs.input_srt = optarg;
  53 + }else{
  54 + globalArgs.service = _ONLY_SRT;
  55 + globalArgs.input = optarg;
  56 + }
  57 + break;
  58 +
  59 + case 'T':
  60 + if(argc < 11){
  61 + PRINTL(util::_ERROR, "Insuficient arguments. Try again\n");
  62 + throw lavidlib::RuntimeException();
  63 + }
  64 +
  65 + globalArgs.service = _TEXT;
  66 + globalArgs.input = optarg;
  67 + break;
  68 +
  69 + case 'V':
  70 + if(argc < 13 || ((globalArgs.service == _ONLY_SRT && argc < 17))){
  71 + PRINTL(util::_ERROR, "Insuficient arguments. Try again\n");
  72 + throw lavidlib::RuntimeException();
  73 + }
  74 +
  75 + if(globalArgs.service == _ONLY_SRT){ // ativa o serviço de vídeo e legendas
  76 + globalArgs.service = _VIDEO_WITH_SRT;
  77 + globalArgs.input_srt = globalArgs.input;
  78 + }else if(globalArgs.mixer == _NO_MIXER) // desativa a mixagem
  79 + globalArgs.service = _WITHOUT_MIXER;
  80 + else
  81 + globalArgs.service = _REC_VIDEO;
  82 + globalArgs.input = optarg;
  83 + break;
  84 +
  85 + case 'l':
  86 + globalArgs.language = languageFromString(optarg);
  87 + break;
  88 +
  89 + case 'b':
  90 + globalArgs.back = backgroundFromString(optarg);
  91 + break;
  92 +
  93 + case 'r':
  94 + globalArgs.size = resolutionFromString(optarg);
  95 + break;
  96 +
  97 + case 'p':
  98 + globalArgs.position = positionFromString(optarg);
  99 + break;
  100 +
  101 + case 'm':
  102 + globalArgs.mode = executionModeFromString(optarg);
  103 + break;
  104 +
  105 + case 'i':
  106 + globalArgs.id = optarg;
  107 + break;
  108 +
  109 + case 'x':
  110 + if(globalArgs.service == _REC_VIDEO) // desativa a mixagem
  111 + globalArgs.service = _WITHOUT_MIXER;
  112 + else
  113 + globalArgs.mixer = _NO_MIXER;
  114 + break;
  115 +
  116 + case 'C':
  117 + globalArgs.service = _TESTER;
  118 + break;
  119 +
  120 + case 'v':
  121 + globalArgs.l_level = logFromString(optarg);
  122 + break;
  123 +
  124 + case 'h':
  125 + globalArgs.service = _HELP;
  126 + break;
  127 + case '?':
  128 + /* o getopt já mostra o erro no terminal!*/
  129 + break;
  130 + default:
  131 + printf("\nUsage: %s [Service_option] filepath [Options] --id [name] --mode [devel,prod]\n", argv[0]);
  132 + printf("\nTry --help for more informations.");
  133 + throw lavidlib::RuntimeException();
  134 + }
  135 + }
  136 +
  137 + if (argc < 2){
  138 + printf("Not enough arguments. Try --help.\n");
  139 + throw lavidlib::RuntimeException();
  140 + }
  141 +
  142 + /* Mostra os argumentos restantes depois das opções de linha de comando */
  143 + if (optind < argc)
  144 + {
  145 + printf("non-option ARGV-elements:\n");
  146 + while (optind < argc)
  147 + printf("%s\n", argv[optind++]);
  148 + }
  149 +}
  150 +
  151 +util::logLevel ArgParser::logFromString(const string& level)
  152 +{
  153 + if(level == "quiet")
  154 + return util::_QUIET;
  155 + if(level == "debug")
  156 + return util::_DEBUG;
  157 + if(level == "info")
  158 + return util::_INFO;
  159 + if(level == "warning")
  160 + return util::_WARNING;
  161 + if(level == "error")
  162 + return util::_ERROR;
  163 +
  164 + return util::_INFO;//default
  165 +}
  166 +
  167 +ArgParser::Languages ArgParser::languageFromString(const string& language)
  168 +{
  169 + if(language == "portugues")
  170 + return _PORTUGUESE;
  171 + if(language == "glosa")
  172 + return _GLOSA;
  173 +
  174 + returnErr("--language");
  175 +}
  176 +
  177 +ArgParser::Positions ArgParser::positionFromString(const string& position)
  178 +{
  179 + if(position == "top_left")
  180 + return _TOP_LEFT;
  181 + if(position == "top_right")
  182 + return _TOP_RIGHT;
  183 + if(position == "bottom_right")
  184 + return _BOTTOM_RIGHT;
  185 + if(position == "bottom_left")
  186 + return _BOTTOM_LEFT;
  187 +
  188 + returnErr("--position");
  189 +}
  190 +
  191 +ArgParser::Resolution ArgParser::resolutionFromString(const string& resolution)
  192 +{
  193 + if(resolution == "small")
  194 + return _SMALL;
  195 + if(resolution == "medium")
  196 + return _MEDIUM;
  197 + if(resolution == "large")
  198 + return _LARGE;
  199 +
  200 + returnErr("--resolution");
  201 +}
  202 +
  203 +ArgParser::Background ArgParser::backgroundFromString(const string& back)
  204 +{
  205 + if(back == "opaque")
  206 + return _OPAQUE;
  207 + if(back == "transp")
  208 + return _TRANSPARENT;
  209 +
  210 + returnErr("--background");
  211 +}
  212 +
  213 +ArgParser::Mode ArgParser::executionModeFromString(const string& mode)
  214 +{
  215 + if(mode == "prod")
  216 + return _PROD;
  217 + if(mode == "devel")
  218 + return _DEVEL;
  219 +
  220 + returnErr("--mode");
  221 +}
  222 +
  223 +void ArgParser::returnErr(const string& option)
  224 +{
  225 + cout << "Option '" << option << "' contains an invalid argument." << endl;
  226 + throw lavidlib::RuntimeException();
  227 +}
  228 +
  229 +int ArgParser::getService()
  230 +{
  231 + return globalArgs.service;
  232 +}
  233 +
  234 +int ArgParser::getLanguage()
  235 +{
  236 + return globalArgs.language;
  237 +}
  238 +
  239 +int ArgParser::getPosition()
  240 +{
  241 + return globalArgs.position;
  242 +}
  243 +
  244 +int ArgParser::getSize()
  245 +{
  246 + return globalArgs.size;
  247 +}
  248 +
  249 +int ArgParser::getBackground()
  250 +{
  251 + return globalArgs.back;
  252 +}
  253 +
  254 +int ArgParser::getMode()
  255 +{
  256 + return globalArgs.mode;
  257 +}
  258 +
  259 +int ArgParser::getOption()
  260 +{
  261 + return globalArgs.mixer;
  262 +}
  263 +
  264 +string ArgParser::getInput()
  265 +{
  266 + return globalArgs.input;
  267 +}
  268 +
  269 +string ArgParser::getInputSRT()
  270 +{
  271 + return globalArgs.input_srt;
  272 +}
  273 +
  274 +string ArgParser::getId()
  275 +{
  276 + return globalArgs.id;
  277 +}
  278 +
  279 +util::logLevel ArgParser::getLog()
  280 +{
  281 + return globalArgs.l_level;
  282 +}
util/src/include/argParser.h 0 → 100644
@@ -0,0 +1,177 @@ @@ -0,0 +1,177 @@
  1 +/**
  2 + * \file argParser.h
  3 + *
  4 + * \author Wesnydy Lima Ribeiro <wesnydy@lavid.ufpb.br>
  5 + * \date 2015
  6 + */
  7 +
  8 +#ifndef ARG_PARSER_H
  9 +#define ARG_PARSER_H
  10 +
  11 +#include <stdio.h>
  12 +#include <string.h>
  13 +#include <iostream>
  14 +#include <stdlib.h>
  15 +#include <unistd.h>
  16 +#include <getopt.h>
  17 +#include "logging.h"
  18 +#include <lavidlib/base/RuntimeException.h>
  19 +
  20 +#define MAX_SIZE_PATH 256
  21 +
  22 +using namespace std;
  23 +using namespace util;
  24 +
  25 +/** \brief Analizador de argumentos de linha de comando.
  26 + *
  27 + * \headerfile util/src/include/argParser.h
  28 + */
  29 +class ArgParser {
  30 +public:
  31 + /** Construtor */
  32 + ArgParser();
  33 +
  34 + /** Destrutor */
  35 + ~ArgParser();
  36 +
  37 + /** Analiza os argumentos da linha de comando.
  38 + *
  39 + * \param argv Os argumentos.
  40 + * \param arc O número de argumentos.
  41 + * \exception RuntimeException Se forem encontrados argumentos inválidos ou na falta de argumentos.
  42 + */
  43 + void readArgs(char** argv, int argc);
  44 +
  45 + /** Retorna o serviço requisitado.
  46 + *
  47 + * \return O serviço.
  48 + */
  49 + int getService();
  50 +
  51 + /** Retorna a linguagem do arquivo de entrada.
  52 + *
  53 + * \return A linguagem do arquivo.
  54 + */
  55 + int getLanguage();
  56 +
  57 + /** Retorna a posição do vídeo de LIBRAS.
  58 + *
  59 + * \return A posição do vídeo.
  60 + */
  61 + int getPosition();
  62 +
  63 + /** Retorna o tamanho do vídeo de LIBRAS.
  64 + *
  65 + * \return O tamanho do vídeo.
  66 + */
  67 + int getSize();
  68 +
  69 + /** Retorna a transparência do plano de fundo.
  70 + *
  71 + * \return O background do vídeo.
  72 + */
  73 + int getBackground();
  74 +
  75 + /** Retorna o modo de execução.
  76 + *
  77 + * \return O modo de execução.
  78 + */
  79 + int getMode();
  80 +
  81 + /** Retorna opções extras ativadas.
  82 + *
  83 + * \return A opção extra.
  84 + */
  85 + int getOption();
  86 +
  87 + /** Retorna o path arquivo de entrada.
  88 + *
  89 + * \return O path do arquivo.
  90 + */
  91 + string getInput();
  92 +
  93 + /** Retorna o path arquivo de legendas.
  94 + *
  95 + * \return O path do arquivo de legendas.
  96 + */
  97 + string getInputSRT();
  98 +
  99 + /** Retorna a identificação do cliente.
  100 + *
  101 + * \return O ID do cliente.
  102 + */
  103 + string getId();
  104 +
  105 + /** Retorna o nível de log selecionado.
  106 + *
  107 + * \return O nível do log.
  108 + */
  109 + util::logLevel getLog();
  110 +
  111 +private:
  112 + enum Services { _VIDEO_WITH_SRT = 1, _REC_VIDEO, _TEXT, _ONLY_SRT, _REC_AUDIO, _WITHOUT_MIXER, _TESTER , _HELP};
  113 + enum Languages { _PORTUGUESE = 1, _GLOSA };
  114 + enum Positions { _TOP_LEFT = 1, _TOP_RIGHT, _BOTTOM_RIGHT, _BOTTOM_LEFT };
  115 + enum Resolution { _SMALL = 1, _MEDIUM, _LARGE };
  116 + enum Background { _OPAQUE, _TRANSPARENT };
  117 + enum Options { _NO_MIXER = 1 };
  118 + enum Mode { _DEVEL = 1 , _PROD };
  119 +
  120 + struct globalArgs_t {
  121 + Services service;
  122 + Languages language;
  123 + Positions position;
  124 + Resolution size;
  125 + Background back;
  126 + Options mixer;
  127 + Mode mode;
  128 + string input;
  129 + string input_srt;
  130 + string id;
  131 + util::logLevel l_level;
  132 + }globalArgs;
  133 +
  134 + /** Exibe erros ocorridos durante a analise dos argumentos.
  135 + *
  136 + * \param option A mensagem de erro.
  137 + */
  138 + void returnErr(const string& option);
  139 +
  140 + /** Retorna a opção de linguagem a partir de uma string.
  141 + *
  142 + * \return A linguagem do arquivo.
  143 + */
  144 + Languages languageFromString(const string& language);
  145 +
  146 + /** Retorna a opção de posição a partir de uma string.
  147 + *
  148 + * \return A posição do vídeo.
  149 + */
  150 + Positions positionFromString(const string& position);
  151 +
  152 + /** Retorna a opção de resolução a partir de uma string.
  153 + *
  154 + * \return A resolução do vídeo.
  155 + */
  156 + Resolution resolutionFromString(const string& resolution);
  157 +
  158 + /** Retorna a opção de background a partir de uma string.
  159 + *
  160 + * \return O background do vídeo.
  161 + */
  162 + Background backgroundFromString(const string& backg);
  163 +
  164 + /** Retorna a opção do modo de execução a partir de uma string.
  165 + *
  166 + * \return O modo de execução.
  167 + */
  168 + Mode executionModeFromString(const string& mode);
  169 +
  170 + /** Retorna o nível de log selecionado.
  171 + *
  172 + * \return O nível de log.
  173 + */
  174 + util::logLevel logFromString(const string& level);
  175 +};
  176 +
  177 +#endif /* ARG_PARSER_H */
0 \ No newline at end of file 178 \ No newline at end of file
util/src/include/dprintf.h
@@ -1,79 +0,0 @@ @@ -1,79 +0,0 @@
1 -#ifndef __DPRINTF_H__  
2 -#define __DPRINTF_H__  
3 -  
4 -/* A macro DEBUG_LEVEL determina o nivel de debugging  
5 - * A seguinte regra eh utilizada:  
6 - *  
7 - * DEBUG_LEVEL >= 3: Apenas DDDPRINTF serah compilada.  
8 - * DEBUG_LEVEL >= 2: DDDPRINTF E DDPRINTF serao compiladas.  
9 - * DEBUG_LEVEL >= 1: DDDPRINTF, DDPRINTF e DPRINTF serao compiladas.  
10 - * DEBUG_LEVEL == 0: Nada sera compilado. */  
11 -  
12 -#include <stdio.h>  
13 -  
14 -/* tamanho maximo (em bytes) do arquivo de log (1M) */  
15 -//#define TAMANHO_MAXIMO_LOG 1048576  
16 -#define TAMANHO_MAXIMO_LOG 5242880  
17 -  
18 - #define _DPRINTF_ERROR "\033[30m"  
19 - #define _DPRINTF_WARN "\033[33m"  
20 - #define _DPRINTF_INFO "\033[32m"  
21 - #define _DPRINTF_FAIL "\033[31m"  
22 - #define _DPRINTF_END "\033[0m"  
23 -  
24 -#define _DPRINTF_NOP(format, ...) do { } while (0)  
25 -  
26 -#ifdef DEBUG_LEVEL  
27 -  
28 - #if DEBUG_LEVEL & 4  
29 - #define DDDPRINTF(format, ...) { \  
30 - fprintf(stderr, \  
31 - _DPRINTF_ERROR"%s::%s [%d] -> "_DPRINTF_END format, \  
32 - __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \  
33 - }  
34 -  
35 - #else /* !DEBUG_LEVEL > 2 */  
36 - #define DDDPRINTF _DPRINTF_NOP  
37 - #endif /* DEBUG_LEVEL > 2 */  
38 -  
39 - #if DEBUG_LEVEL & 2  
40 - #define DDPRINTF(format, ...) { \  
41 - fprintf(stderr, \  
42 - _DPRINTF_WARN"%s::%s [%d] -> "_DPRINTF_END format, \  
43 - __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \  
44 - }  
45 -  
46 -#else /* !DEBUG_LEVEL > 1 */  
47 - #define DDPRINTF _DPRINTF_NOP  
48 - #endif /* DEBUG_LEVEL > 1 */  
49 -  
50 - #if DEBUG_LEVEL & 1  
51 - #define DPRINTF(format, ...) { \  
52 - fprintf(stderr, \  
53 - _DPRINTF_INFO"%s::%s [%d] -> "_DPRINTF_END format, \  
54 - __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \  
55 - }  
56 -  
57 - #else /* !DEBUG_LEVEL > 0 */  
58 - #define DPRINTF _DPRINTF_NOP  
59 - #endif /* DEBUG_LEVEL > 0 */  
60 -  
61 - #if DEBUG_LEVEL & 1  
62 - #define DDDDPRINTF(format, ...) { \  
63 - fprintf(stderr, \  
64 - _DPRINTF_FAIL"%s::%s [%d] -> "_DPRINTF_END format, \  
65 - __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \  
66 - }  
67 -  
68 - #else /* !DEBUG_LEVEL > 0 */  
69 - #define DDDDPRINTF _DPRINTF_NOP  
70 - #endif /* DEBUG_LEVEL > 0 */  
71 -  
72 -#else /* DEBUG_LEVEL */  
73 - #define DPRINTF _DPRINTF_NOP  
74 - #define DDPRINTF _DPRINTF_NOP  
75 - #define DDDPRINTF _DPRINTF_NOP  
76 -#endif /* ! DEBUG_LEVEL */  
77 -  
78 -#endif /* __DPRINTF_H__ */  
79 -  
util/src/include/logger.h
@@ -1,52 +0,0 @@ @@ -1,52 +0,0 @@
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 - **************************************************************************/  
11 -  
12 -#include <iostream>  
13 -#include <fstream>  
14 -#include <time.h>  
15 -#include <stdio.h>  
16 -#include <stdlib.h>  
17 -#include <stddef.h>  
18 -#include <iostream>  
19 -#include <ctime>  
20 -//#include <lavidlib/utils/Logger.h>  
21 -  
22 -  
23 -#ifndef _LOGGER_H_  
24 -#define _LOGGER_H_  
25 -  
26 -using namespace std;  
27 -  
28 -namespace Util {  
29 -  
30 - class Logger {  
31 - public:  
32 - static Logger* Instance();  
33 - void openLogFile();  
34 - void writeLog(char* log);  
35 - void closeLogFile();  
36 - char* getTime();  
37 -  
38 - private:  
39 - Logger() ; // Private so that it can not be called  
40 - Logger(Logger const&){}; // copy constructor is private  
41 - Logger& operator=(Logger const&){}; // assignment operator is private  
42 - static Logger* m_pInstance;  
43 - ofstream file;  
44 -  
45 -  
46 - };  
47 -  
48 -  
49 -}  
50 -  
51 -  
52 -#endif  
util/src/include/logging.h 0 → 100644
@@ -0,0 +1,84 @@ @@ -0,0 +1,84 @@
  1 +/**
  2 + * \file logging.h
  3 + *
  4 + * \author Wesnydy Lima Ribeiro <wesnydy@lavid.ufpb.br>
  5 + * \date 2015
  6 + */
  7 +
  8 +#ifndef LOGGING_H
  9 +#define LOGGING_H
  10 +
  11 +#include <stdio.h>
  12 +#include <stdlib.h>
  13 +#include <time.h>
  14 +
  15 +#define _ERROR_ "\033[31m"
  16 +#define _DEBUG_ "\033[30m"
  17 +#define _WARN_ "\033[33m"
  18 +#define _INFO_ "\033[32m"
  19 +#define _END_ "\033[0m"
  20 +
  21 +#define LOG_FILE "vlibras_user/vlibras-core/log/log"
  22 +
  23 +namespace util {
  24 +
  25 + enum logLevel { _QUIET = 1 , _ERROR, _WARNING, _INFO, _DEBUG};
  26 +
  27 + /** \brief Classe responsável pelo log exibido no terminal.
  28 + *
  29 + * \headerfile util/src/include/logging.h
  30 + */
  31 + class Logging {
  32 + public:
  33 + static Logging* instance();
  34 +
  35 + /** Retorna o nível de log selecionado.
  36 + *
  37 + * \return O nível de log.
  38 + */
  39 + logLevel getLevel();
  40 +
  41 + /** Seta o nível de log, no terminal. */
  42 + void setLevel(logLevel level);
  43 +
  44 + /** Escreve o log em um arquivo.
  45 + *
  46 + * \param logMsg A mensagem do log.
  47 + */
  48 + void writeLog(const char* logMsg);
  49 +
  50 + private:
  51 + Logging(){};
  52 + Logging(Logging const&){};
  53 + Logging& operator=(Logging const&){};
  54 +
  55 + static Logging* l_instance;
  56 + static logLevel l_level;
  57 + FILE* l_file;
  58 +
  59 + char* getTime();
  60 + };
  61 +
  62 + #define PRINTL(level, format, ... ) { \
  63 + logLevel llevel; \
  64 + llevel = Logging::instance()->getLevel(); \
  65 + if(level <= llevel){ \
  66 + switch(level){ \
  67 + case _DEBUG: \
  68 + fprintf(stdout, _DEBUG_"%s::%s<%d>: "_END_ format, __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \
  69 + break; \
  70 + case _INFO: \
  71 + fprintf(stdout, _INFO_"%s::%s<%d>: "_END_ format, __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \
  72 + break; \
  73 + case _WARNING: \
  74 + fprintf(stdout, _WARN_"%s::%s<%d>: "_END_ format, __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \
  75 + break; \
  76 + case _ERROR: \
  77 + fprintf(stderr, _ERROR_"%s::%s<%d>: "_END_ format, __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \
  78 + break; \
  79 + } \
  80 + } \
  81 + }//fim da função PRINTL
  82 +}
  83 +
  84 +#endif /* LOGGING_H */
0 \ No newline at end of file 85 \ No newline at end of file
util/src/logger.cpp
@@ -1,51 +0,0 @@ @@ -1,51 +0,0 @@
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 - **************************************************************************/  
11 -  
12 -#include "logger.h"  
13 -  
14 -namespace Util {  
15 -  
16 - Logger* Logger::m_pInstance = NULL;  
17 -  
18 - Logger::Logger(){  
19 - }  
20 -  
21 - Logger* Logger::Instance(){  
22 - if (!m_pInstance) // Only allow one instance of class to be generated.  
23 - m_pInstance = new Logger;  
24 -  
25 - return m_pInstance;  
26 - }  
27 -  
28 -  
29 - void Logger::openLogFile(){  
30 - file.open("vlibras_user/vlibras-core/log/log", ios_base::app);  
31 - }  
32 -  
33 -  
34 - void Logger::closeLogFile(){  
35 - file.close();  
36 - }  
37 -  
38 - char* Logger::getTime(){  
39 - time_t curtime;  
40 - time(&curtime);  
41 - return ctime(&curtime);  
42 - }  
43 -  
44 - void Logger::writeLog(char* exception){  
45 - this->openLogFile();  
46 - file << getTime();  
47 - file << exception << "\n\n\r";  
48 - this->closeLogFile();  
49 - }  
50 -  
51 -}  
util/src/logging.cpp 0 → 100644
@@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
  1 +#include "logging.h"
  2 +
  3 +namespace util {
  4 +
  5 + Logging* Logging::l_instance = NULL;
  6 + logLevel Logging::l_level = _INFO;
  7 +
  8 + Logging* Logging::instance() {
  9 + if(!l_instance)
  10 + l_instance = new Logging();
  11 + return l_instance;
  12 + }
  13 +
  14 + logLevel Logging::getLevel() {
  15 + return this->l_level;
  16 + }
  17 +
  18 + void Logging::setLevel(logLevel level) {
  19 + if(level != 0)
  20 + this->l_level = level;
  21 + }
  22 +
  23 + char* Logging::getTime() {
  24 + time_t curtime;
  25 + time(&curtime);
  26 + return ctime(&curtime);
  27 + }
  28 +
  29 + void Logging::writeLog(const char* logMsg) {
  30 + l_file = fopen(LOG_FILE, "a");
  31 +
  32 + if(l_file == NULL)
  33 + return;
  34 +
  35 + fprintf(l_file, "%s'%s'\n\n\r", getTime() ,logMsg);
  36 + fclose(l_file);
  37 + }
  38 +}
0 \ No newline at end of file 39 \ No newline at end of file