Commit 793a42310abc9e1581e0f0d9fb60103c85221f22

Authored by Erickson Silva
1 parent 505a1abd
Exists in master and in 1 other branch devel

Corrige chamadas ao core

endpoints/audio.js
... ... @@ -97,8 +97,7 @@ function callCore(id, audio, req, res) {
97 97  
98 98 /* Cria a linha de comando */
99 99 /* slice(2) é para transformar ./path em path */
100   - var command_line = 'vlibras_user/vlibras-core/./vlibras ' + parameters.getServiceType(req.body.servico) + ' ' +
101   - audio.path.slice(2) + ' ' + parameters.getTransparency(req.body.transparencia) + ' ' + id + ' > /tmp/core_log 2>&1';
  100 + var command_line = 'vlibras_user/vlibras-core/./vlibras -A ' + audio.path.slice(2) + ' -b ' + parameters.getTransparency(req.body.transparencia) + ' --id ' + id + ' --mode devel > /tmp/core_log 2>&1';
102 101  
103 102 console.log("=== Core: " + command_line);
104 103  
... ...
endpoints/legenda.js
... ... @@ -13,19 +13,19 @@ function init(req, res) {
13 13 var id = uuid.v4();
14 14  
15 15 /* Verifica se o paramêtro [transparencia] possue algum valor */
16   - if (req.body.transparencia !== '') {
  16 + if (req.body.transparencia === '') {
17 17 res.send(500, parameters.errorMessage('O valor de algum parâmetro está vazio'));
18 18 return;
19 19 }
20 20  
21 21 /* Verifica se os paramêtros [transparencia] possuem os seus únicos valores possíveis */
22   - if ((parameters.checkTransparency(req.body.transparencia) === true)) {
  22 + if ((parameters.checkTransparency(req.body.transparencia) === false)) {
23 23 res.send(500, parameters.errorMessage('Parâmetros insuficientes ou inválidos'));
24 24 return;
25 25 }
26 26  
27 27 /* Checa se o arquivo de legenda submetivo possui uma extensão válida */
28   - if (parameters.checkSubtitle(req.files.legenda.name)) {
  28 + if (parameters.checkSubtitle(req.files.legenda.name) == false) {
29 29 res.send(500, parameters.errorMessage('Legenda com Extensão Inválida'));
30 30 return;
31 31 }
... ... @@ -36,13 +36,13 @@ function init(req, res) {
36 36 /* Listener que dispara quando a pasta é criada */
37 37 child.on('close', function(code, signal){
38 38 /* Move a legenda submetido para a pasta com o seu ID correspondente */
39   - fs.rename(req.files.legenda.path, __dirname + '/uploads/' + id + '/' + req.files.legenda.name, function(error) {
  39 + fs.rename(req.files.legenda.path, __dirname + 'uploads/' + id + '/' + req.files.legenda.name, function(error) {
40 40 if (error) { console.log(error); }
41 41 });
42 42  
43 43 /* Cria a linha de comando */
44   - var command_line = 'vlibras_user/vlibras-core/./vlibras ' + parameters.getServiceType(req.body.servico) + ' uploads/' + id + '/' +
45   - req.files.legenda.name + ' ' + parameters.getTransparency(req.body.transparencia) + ' ' + id;
  44 + var command_line = 'vlibras_user/vlibras-core/./vlibras -S' + ' uploads/' + id + '/' +
  45 + req.files.legenda.name + ' -l ' + parameters.getLanguage(req.body.linguagem) + ' -b ' + parameters.getTransparency(req.body.transparencia) + ' --id ' + id + ' --mode devel > /tmp/core_log 2>&1';
46 46  
47 47 /* Executa a linha de comando */
48 48 // child = exec(command_line, function(err, stdout, stderr) {
... ...
endpoints/texto.js
... ... @@ -14,10 +14,11 @@ function init(req, res, Request) {
14 14 var id = uuid.v4();
15 15  
16 16 /* Verifica se os paramêtros [transparencia, texto] possuem algum valor */
17   - if ((req.body.transparencia === '') || (req.body.texto === '')) {
  17 +
  18 + if ((req.body.transparencia === '') || (req.body.texto === '') || (req.body.linguagem === '')) {
18 19 res.send(500, parameters.errorMessage('O valor de algum parâmetro está vazio'));
19 20 return;
20   - }
  21 + }
21 22  
22 23 /* Verifica se o paramêtro [transparencia] possui os únicos valores possíveis [opaco, transparente] */
23 24 if (parameters.checkTransparency(req.body.transparencia) === false) {
... ... @@ -25,6 +26,12 @@ function init(req, res, Request) {
25 26 return;
26 27 }
27 28  
  29 + /* Verifica se o paramêtro [linguagem] possui os únicos valores possíveis [portugues, glosa] */
  30 + if (parameters.checkLanguage(req.body.linguagem) === false) {
  31 + res.send(500, parameters.errorMessage('Parâmetros insuficientes ou inválidos'));
  32 + return;
  33 + }
  34 +
28 35 var request_object = new Request({
29 36 id: id,
30 37 type: req.body.servico,
... ... @@ -43,8 +50,7 @@ function init(req, res, Request) {
43 50 });
44 51  
45 52 /* Cria a linha de comando */
46   - var command_line = 'echo ' + req.body.texto + ' >> text_files/' + id + ' && mkdir uploads/' + id + ' && vlibras_user/vlibras-core/./vlibras ' + parameters.getServiceType(req.body.servico) + ' text_files/' +
47   - id + ' ' + parameters.getTransparency(req.body.transparencia) + ' ' + id + ' Web > /tmp/core_log 2>&1';
  53 + var command_line = 'echo ' + req.body.texto + ' >> text_files/' + id + ' && mkdir uploads/' + id + ' && vlibras_user/vlibras-core/./vlibras -T ' + 'text_files/' + id + ' -l ' + parameters.getLanguage(req.body.linguagem) + ' -b ' + parameters.getTransparency(req.body.transparencia) + ' --id ' + id + ' --mode devel >> /tmp/core_log 2>&1';
48 54  
49 55 console.log(command_line);
50 56 var child;
... ...
endpoints/video.js
... ... @@ -97,9 +97,7 @@ function callCore(id, video, subtitle, req, res) {
97 97  
98 98 /* Cria a linha de comando */
99 99 /* slice(2) é para transformar ./path em path */
100   - var command_line = 'vlibras_user/vlibras-core/./vlibras ' + parameters.getServiceType(req.body.servico) + ' ' +
101   - video.path.slice(2) + ' 1 ' + parameters.getPosition(req.body.posicao) + ' ' + parameters.getSize(req.body.tamanho) + ' ' +
102   - parameters.getTransparency(req.body.transparencia) + ' ' + id + ' > /tmp/core_log 2>&1';
  100 + var command_line = 'vlibras_user/vlibras-core/./vlibras -V ' + video.path.slice(2) + ' -p ' + parameters.getPosition(req.body.posicao) + ' -r ' + parameters.getSize(req.body.tamanho) + ' -b ' + parameters.getTransparency(req.body.transparencia) + ' --id ' + id + ' --mode devel > /tmp/core_log 2>&1';
103 101  
104 102 console.log("=== Core: " + command_line);
105 103  
... ...
endpoints/video_legenda.js
... ... @@ -102,10 +102,8 @@ function callCore(id, video, subtitle, req, res) {
102 102  
103 103 /* Cria a linha de comando */
104 104 /* slice(2) é para transformar ./path em path */
105   - var command_line = 'vlibras_user/vlibras-core/./vlibras ' + parameters.getServiceType(req.body.servico) + ' ' +
106   - video.path.slice(2) + ' ' + subtitle.path.slice(2) + ' ' + parameters.getLanguage(req.body.linguagem) +
107   - ' ' + parameters.getPosition(req.body.posicao) + ' ' + parameters.getSize(req.body.tamanho) + ' ' +
108   - parameters.getTransparency(req.body.transparencia) + ' ' + id + ' > /tmp/core_log 2>&1';
  105 + var command_line = 'vlibras_user/vlibras-core/./vlibras -V ' + video.path.slice(2) + ' -S ' + subtitle.path.slice(2) + ' -l ' + parameters.getLanguage(req.body.linguagem) + ' -p ' + parameters.getPosition(req.body.posicao) + ' -r ' + parameters.getSize(req.body.tamanho) + ' -b ' +
  106 + parameters.getTransparency(req.body.transparencia) + ' --id ' + id + ' --mode devel > /tmp/core_log 2>&1';
109 107  
110 108 console.log("=== Core: " + command_line);
111 109  
... ...
endpoints/videornp.js
... ... @@ -134,7 +134,7 @@ function callCore(id, video, subtitle, req, res, Request, request_object) {
134 134  
135 135 /* Cria a linha de comando */
136 136 /* slice(2) é para transformar ./path em path */
137   - var command_line = 'vlibras_user/vlibras-core/./vlibras 7 ' + video.path.slice(2) + ' ' + id + ' > /tmp/core_log 2>&1';
  137 + var command_line = 'vlibras_user/vlibras-core/./vlibras -V ' + video.path.slice(2) + ' -p bottom_right -r large - -b opaque --no-mixer --id ' + id + ' --mode devel > /tmp/core_log 2>&1';
138 138  
139 139 console.log("=== Core: " + command_line);
140 140  
... ... @@ -149,8 +149,8 @@ function callCoreSubtitle(id, subtitle, req, res, Request, request_object) {
149 149 });
150 150  
151 151 /* Cria a linha de comando */
152   - var command_line = 'vlibras_user/vlibras-core/./vlibras 7 ' + ' uploads/' + id + '/' +
153   - req.files.legenda.name + ' opaco ' + id;
  152 + var command_line = 'vlibras_user/vlibras-core/./vlibras -S ' + ' uploads/' + id + '/' +
  153 + req.files.legenda.name + ' -l portugues -b opaco --id' + id + ' --mode devel > /tmp/core_log 2>&1';
154 154  
155 155 /* Executa a linha de comando */
156 156 child = exec(command_line, function(err, stdout, stderr) {
... ...
helpers/parameters.js
... ... @@ -28,11 +28,11 @@ function getServiceType(service_type) {
28 28 function getLanguage(language) {
29 29 switch(language) {
30 30 case 'portugues':
31   - return 1;
  31 + return 'portugues';
32 32 break;
33 33  
34 34 case 'glosa':
35   - return 2;
  35 + return 'glosa';
36 36 break;
37 37 }
38 38 };
... ... @@ -40,19 +40,19 @@ function getLanguage(language) {
40 40 function getPosition(position) {
41 41 switch(position) {
42 42 case 'superior-esquerdo':
43   - return 1;
  43 + return 'top_left';
44 44 break;
45 45  
46 46 case 'superior-direito':
47   - return 2;
  47 + return 'top_right';
48 48 break;
49 49  
50 50 case 'inferior-direito':
51   - return 3;
  51 + return 'bottom_right';
52 52 break;
53 53  
54 54 case 'inferior-esquerdo':
55   - return 4;
  55 + return 'bottom_left';
56 56 break;
57 57 }
58 58 };
... ... @@ -76,11 +76,27 @@ function getSize(size) {
76 76 function getTransparency(transparency) {
77 77 switch(transparency) {
78 78 case 'opaco':
79   - return 0;
  79 + return 'opaque';
80 80 break;
81 81  
82 82 case 'transparente':
83   - return 1;
  83 + return 'transp';
  84 + break;
  85 + }
  86 +};
  87 +
  88 +function getSize(size) {
  89 + switch(size) {
  90 + case 'pequeno':
  91 + return 'small';
  92 + break;
  93 +
  94 + case 'medio':
  95 + return 'medium';
  96 + break;
  97 +
  98 + case 'grande':
  99 + return 'large';
84 100 break;
85 101 }
86 102 };
... ...
server.js
... ... @@ -6,6 +6,7 @@ var ep_ios = require('./endpoints/ios');
6 6 var ep_video = require('./endpoints/video');
7 7 var ep_legenda = require('./endpoints/legenda');
8 8 var ep_video_legenda = require('./endpoints/video_legenda');
  9 +var ep_video_rnp = require('./endpoints/videornp');
9 10  
10 11 var mongoose = require('mongoose');
11 12 require('./db/config').connect(mongoose);
... ...