upstream: integrar Oasis 1.3.3
Diferencia 1.3.1 -> 1.3.3 del codigo de la APK oficial aplicada a tres bandas encima de la rama: karma en el perfil, salas con directo, fotos selladas, visibilidad de menciones, telefono por stream en Android y las traducciones nuevas. Sin dependencias nuevas. OasisMobile.css sigue siendo el del fork; del oficial solo se traen al final las reglas de las piezas nuevas (karma, directo a pantalla completa, salas en vivo, graphos).
This commit is contained in:
parent
bc64565e9c
commit
948b6460d9
95 changed files with 3613 additions and 1356 deletions
53
src/server/phone_stream_android.js
Normal file
53
src/server/phone_stream_android.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
const fs = require('fs');
|
||||
const net = require('net');
|
||||
const path = require('path');
|
||||
|
||||
const MARKER = path.join(__dirname, '..', '..', '.audio_bridge');
|
||||
const FRAME_MAX = 4 * 1024 * 1024;
|
||||
|
||||
const bridgePort = () => {
|
||||
try {
|
||||
const port = Number(String(fs.readFileSync(MARKER, 'utf8')).trim());
|
||||
return Number.isFinite(port) && port > 0 ? port : 0;
|
||||
} catch (_) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = () => ({
|
||||
open(file, { onJpeg, onPcm, onEnd }) {
|
||||
let ended = false;
|
||||
const finish = () => {
|
||||
if (ended) return;
|
||||
ended = true;
|
||||
try { onEnd(); } catch (_) {}
|
||||
};
|
||||
const port = bridgePort();
|
||||
if (!port) {
|
||||
setImmediate(finish);
|
||||
return { stop() { ended = true; } };
|
||||
}
|
||||
const sock = net.connect(port, '127.0.0.1');
|
||||
let buf = Buffer.alloc(0);
|
||||
sock.setNoDelay(true);
|
||||
sock.on('error', finish);
|
||||
sock.on('close', finish);
|
||||
sock.on('connect', () => sock.write(Buffer.concat([Buffer.from('S'), Buffer.from(`${file}\n`, 'utf8')])));
|
||||
sock.on('data', (chunk) => {
|
||||
buf = buf.length ? Buffer.concat([buf, chunk]) : chunk;
|
||||
while (buf.length >= 5) {
|
||||
const len = buf.readUInt32BE(1);
|
||||
if (len > FRAME_MAX) { sock.destroy(); return; }
|
||||
if (buf.length < 5 + len) return;
|
||||
const type = buf[0];
|
||||
const payload = Buffer.from(buf.subarray(5, 5 + len));
|
||||
buf = buf.subarray(5 + len);
|
||||
if (ended) continue;
|
||||
if (type === 0x4a) onJpeg(payload);
|
||||
else if (type === 0x41) onPcm(payload);
|
||||
else if (type === 0x45) { finish(); sock.destroy(); return; }
|
||||
}
|
||||
});
|
||||
return { stop() { ended = true; try { sock.destroy(); } catch (_) {} } };
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue