Commit a219d957019a4d7e4d061e038ebe3d4e52d4199e

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

Remove a verificação de arquivo já lido do ExtratorSRT

extrator/src/extratorSRT.cpp
... ... @@ -8,8 +8,8 @@ ExtratorSRT::ExtratorSRT(){
8 8 PRINTL(util::_DEBUG, "ExtratorSTR Done!\n");
9 9 }
10 10  
11   -ExtratorSRT::~ExtratorSRT(){
12   - listeners->clear();
  11 +ExtratorSRT::~ExtratorSRT(){
  12 + listeners->clear();
13 13 delete listeners;
14 14 //if (bff_reader) delete bff_reader;
15 15 if (file_io) delete file_io;
... ... @@ -22,12 +22,12 @@ void ExtratorSRT::initialize(){
22 22  
23 23 try{
24 24 file_io = new lavidlib::FileIO(file->getPath(), FileIO::MODE_READ);
25   - }catch(Exception ex){
  25 + }catch(Exception ex){
26 26 finish = true;
27 27 Logging::instance()->writeLog("extratorSRT.cpp <Error>: Arquivo de legenda não encontrado.");
28 28 throw ExtratorException("Falha ao abrir o arquivo de legenda! Verifique se o mesmo existe.\n");
29 29 }
30   -
  30 +
31 31 this->Start();
32 32 }
33 33  
... ... @@ -39,7 +39,7 @@ void ExtratorSRT::addListener(ListenerSub* listener){
39 39 void ExtratorSRT::notifyListeners(unsigned char* subtitle, int64_t pts) {
40 40 for(list<ListenerSub*>::iterator it = listeners->begin(); it != listeners->end(); it++){
41 41 (*it)->notifySubtitle(subtitle, pts);
42   - }
  42 + }
43 43 }
44 44  
45 45 void ExtratorSRT::notifyEndExtraction(int size) {
... ... @@ -50,7 +50,7 @@ void ExtratorSRT::notifyEndExtraction(int size) {
50 50 }
51 51  
52 52 void ExtratorSRT::setFilePath(char* path){
53   - filePath = (char*) path;
  53 + filePath = (char*) path;
54 54 string command1 = "perl -p -e 's/\r$//' < ";
55 55 command1.append(filePath).append(" > ").append(INPUT_SRT);
56 56 system(command1.c_str());
... ... @@ -78,7 +78,9 @@ void ExtratorSRT::Run(){
78 78 while(hasNextSubtitle()){
79 79 try{
80 80 subtitle = next();
81   - }catch(ExtratorException ex){ break; }
  81 + }catch(ExtratorException ex){
  82 + break;
  83 + }
82 84 sub_text = subtitle->getSubtitleText();
83 85 notifyListeners((unsigned char*)sub_text.c_str(), calcula_pts((double) subtitle->getTimeIn()));
84 86 sub_index++;
... ... @@ -91,12 +93,7 @@ void ExtratorSRT::Run(){
91 93 }
92 94  
93 95 Subtitle* ExtratorSRT::next() {
94   -
95   - if (seek_pos >= file_io->getSize()){
96   - Logging::instance()->writeLog("extratorSRT.cpp <Error>: Arquivo de legenda já foi lido.");
97   - throw ExtratorException("Esse arquivo já foi lido.");
98   - }
99   -
  96 +
100 97 file_io->seek(seek_pos);
101 98 try{
102 99 bff_reader = new BufferedReader(file_io);
... ... @@ -106,35 +103,35 @@ Subtitle* ExtratorSRT::next() {
106 103 }
107 104  
108 105 Subtitle* sub = new Subtitle();
109   - string line = "";
  106 + string line = "";
110 107 string text_sub = "";
111   -
  108 +
112 109 try {
113 110 /* ID */
114 111 int id = 0;
115 112 line = bff_reader->readLine();
116 113 seek_pos += (int64_t) line.size() + SIZE_CSCAPE;
117   - id = atoi(line.c_str());
  114 + id = atoi(line.c_str());
118 115 sub->setID(id);
119 116  
120 117 /* TimeIn and TimeOut */
121 118 int64_t t_in = 0, t_out = 0;
122 119 line = bff_reader->readLine();
123 120 seek_pos += (int64_t) line.size() + SIZE_CSCAPE;
124   -
  121 +
125 122 int target_pos = line.find(TARGET_TIME);
126 123 t_in = str_to_time(line.substr(0, target_pos));
127 124 sub->setTimeIn(t_in);
128 125 t_out = str_to_time(line.substr(target_pos + strlen(TARGET_TIME)+1, line.size()));
129   - sub->setTimeOut(t_out);
130   -
131   - /* Text: read until line be empty */
  126 + sub->setTimeOut(t_out);
  127 +
  128 + /* Text: read until line be empty */
132 129 while ((line = bff_reader->readLine()).size() > 0) {
133 130 text_sub += line;
134   - text_sub.append(" ");
  131 + text_sub.append(" ");
135 132 }
136 133 seek_pos += (int64_t) text_sub.size() + SIZE_CSCAPE;
137   -
  134 +
138 135 } catch (lavidlib::EOFException &ex) {
139 136 sub->setSubtitleText(formatText(text_sub));
140 137 seek_pos += (int64_t) text_sub.size() + SIZE_CSCAPE;
... ... @@ -162,7 +159,7 @@ string ExtratorSRT::formatText(string line){
162 159  
163 160 return f_line;
164 161 }
165   -
  162 +
166 163 int64_t ExtratorSRT::str_to_time(string str_time) {
167 164  
168 165 int64_t ttime = 0;
... ... @@ -171,7 +168,7 @@ int64_t ExtratorSRT::str_to_time(string str_time) {
171 168  
172 169 int index = 0;
173 170 int values [4]; // hh, mm, ss, ms
174   - char * str = strtok(tokens, ":,");
  171 + char * str = strtok(tokens, ":,");
175 172 while (str != NULL) {
176 173 values[index] = atoi(str);
177 174 str = strtok(NULL, ":,");
... ... @@ -180,7 +177,7 @@ int64_t ExtratorSRT::str_to_time(string str_time) {
180 177 delete(tokens);
181 178  
182 179 /* calculate time */
183   - ttime = /*hour to sec*/((((values[0] * 60) * 60) +
  180 + ttime = /*hour to sec*/((((values[0] * 60) * 60) +
184 181 /*min to sec*/(values[1] * 60) +/*sec*/values[2])*1000) + values[3];
185 182  
186 183 return ttime;
... ... @@ -188,5 +185,5 @@ int64_t ExtratorSRT::str_to_time(string str_time) {
188 185 }
189 186  
190 187 uint64_t ExtratorSRT::calcula_pts(double msec) {
191   - return (uint64_t)msec;
  188 + return (uint64_t)msec;
192 189 }
... ...
renderer/src/renderer.cpp
... ... @@ -9,7 +9,7 @@ Renderer::Renderer(char* path_Contents, char* id) {
9 9 }
10 10  
11 11 Renderer::~Renderer() {
12   - listeners->clear();
  12 + listeners->clear();
13 13 delete listeners;
14 14 if(cSocket) delete cSocket;
15 15 PRINTL(util::_DEBUG, "Renderer finalized!\n");
... ... @@ -60,7 +60,7 @@ void Renderer::connectToUnityPlayer() {
60 60 PRINTL(util::_ERROR, "Número de tentativas de conexão excedido!\n");
61 61 throw lavidlib::RuntimeException(ex.getMessage().c_str());
62 62 }
63   - }
  63 + }
64 64 }
65 65 }catch(lavidlib::UnknownHostException &ex){
66 66 throw lavidlib::RuntimeException(ex.getMessage().c_str());
... ... @@ -71,7 +71,7 @@ void Renderer::connectToUnityPlayer() {
71 71 void Renderer::receiveGlosa(string glosa, int64_t pts) {
72 72 ostringstream oss;
73 73 string formatedGlosa; //Formato da glosa que será enviada para o player: "glosa#pts"
74   -
  74 +
75 75 if(glosa == BADSENTENCE || glosa == BADTEXT)
76 76 formatedGlosa = ""; //O player entende "#pts" como pose neutra
77 77 else
... ... @@ -162,7 +162,7 @@ void Renderer::Run() {
162 162 throw lavidlib::RuntimeException(ex.getMessage().c_str());
163 163 }
164 164 }
165   -
  165 +
166 166 PRINTL(util::_INFO, "Gerando vídeo...\n");
167 167 receiveGlosa(END_FLAG, -1); //Quando a fila estiver vazia, a flag "FINALIZE" será enviada
168 168 try{
... ... @@ -180,4 +180,4 @@ void Renderer::cleanFiles() {
180 180 string clean = "rm -rf ";
181 181 clean.append(PATH_SCREENS).append(userID).append("/");
182 182 system(clean.c_str());
183   -}
184 183 \ No newline at end of file
  184 +}
... ...
servico/src/serviceWindowGenerationFromSubtitle.cpp
... ... @@ -127,7 +127,7 @@ Extrator::ExtratorType ServiceWindowGenerationFromSubtitle::getExtratorType(){
127 127 * definido pelo W3C Community Group.
128 128 */
129 129 if(signature.size() < 6){
130   - return Extrator::SRT;
  130 + return Extrator::SRT;
131 131 }
132 132  
133 133 if(signature.size() == 6 && strcmp(SIGNATURE, signature.c_str()) == 0){
... ... @@ -257,7 +257,7 @@ void ServiceWindowGenerationFromSubtitle::initialize() {
257 257 renderer->addListener(this);
258 258  
259 259 try{
260   - if(extrator_t == Extrator::SRT)
  260 + if(extrator_t == Extrator::SRT)
261 261 extratorSRT->initialize();
262 262 else
263 263 extratorVTT->initialize();
... ... @@ -273,5 +273,5 @@ void ServiceWindowGenerationFromSubtitle::Run() {
273 273 while(isRunning()){
274 274 usleep(200000);
275 275 }
276   - finish = true;
277   -}
278 276 \ No newline at end of file
  277 + finish = true;
  278 +}
... ...