Release Vulpes OS 2.7-preview.24
This commit is contained in:
parent
49572b6b45
commit
97ef99f827
135 changed files with 7717 additions and 2524 deletions
|
|
@ -3,7 +3,14 @@ import {Subprocess} from 'resource://gre/modules/Subprocess.sys.mjs';
|
|||
import {setTimeout, clearTimeout} from 'resource://gre/modules/Timer.sys.mjs';
|
||||
|
||||
export class NativeCamera {
|
||||
constructor() { this.session = null; this.queue = Promise.resolve(); this.closing = Promise.resolve(); this.nextSession = 0; }
|
||||
constructor(device = '') {
|
||||
this.device = device;
|
||||
this.previewSize = device === 'beatles' ? {width:320,height:240} : {width:640,height:480};
|
||||
this.session = null;
|
||||
this.queue = Promise.resolve();
|
||||
this.closing = Promise.resolve();
|
||||
this.nextSession = 0;
|
||||
}
|
||||
|
||||
request(actor, params) {
|
||||
const work = this.queue.then(() => this.perform(actor, params));
|
||||
|
|
@ -24,7 +31,8 @@ export class NativeCamera {
|
|||
if(length>65536) throw Error('CAMERA_INVALID_FORMAT');
|
||||
return pipe.readJSON(length);
|
||||
}
|
||||
if(length!==0 && length!==640*480*3/2) throw Error('CAMERA_INVALID_FRAME');
|
||||
const expected = this.session.width * this.session.height * 3 / 2;
|
||||
if(length!==0 && length!==expected) throw Error('CAMERA_INVALID_FRAME');
|
||||
return {sequence,data:length ? await pipe.read(length) : null};
|
||||
})(),
|
||||
new Promise((_, reject) => { timer=setTimeout(()=>reject(Error('CAMERA_TIMEOUT')),15000); }),
|
||||
|
|
@ -40,15 +48,28 @@ export class NativeCamera {
|
|||
if (params.action === 'start') {
|
||||
if (this.session && this.session.actor !== actor) throw Error('CAMERA_BUSY');
|
||||
await this.close();
|
||||
const process = await Subprocess.call({command:'/usr/bin/python3',
|
||||
arguments:['-u', '/etc/tundra/camera-preview.py', '--camera', params.camera === 'front' ? '1' : '0'],
|
||||
if (this.device === 'beatles' && params.camera === 'front') throw Error('CAMERA_UNAVAILABLE');
|
||||
const beatles = this.device === 'beatles';
|
||||
const process = await Subprocess.call({command:beatles?'/usr/bin/python3.11':'/usr/bin/python3',
|
||||
arguments:beatles
|
||||
? ['-u','/opt/vulpes/tundra/runtime/beatles-camera-client.py']
|
||||
: ['-u', '/etc/tundra/camera-preview.py', '--camera', params.camera === 'front' ? '1' : '0',
|
||||
'--width',String(this.previewSize.width),'--height',String(this.previewSize.height)],
|
||||
stderr:'ignore'});
|
||||
this.session = {actor, process, id: ++this.nextSession};
|
||||
try {
|
||||
const metadata = await this.packet(this.session, true);
|
||||
if (!metadata.ready || metadata.format !== 'nv21' || metadata.width !== 640 || metadata.height !== 480)
|
||||
if (!metadata.ready || metadata.format !== 'nv21' ||
|
||||
metadata.width !== this.previewSize.width || metadata.height !== this.previewSize.height)
|
||||
throw Error('CAMERA_INVALID_FORMAT');
|
||||
return {...metadata, session: this.session.id};
|
||||
this.session.width = metadata.width;
|
||||
this.session.height = metadata.height;
|
||||
return {...metadata, session: this.session.id,
|
||||
// The 2720 Flip has 400 MB of RAM and copies each frame through
|
||||
// CameraService, Gecko IPC and a software canvas. Polling at the
|
||||
// sensor's nominal rate exhausts its zram; keep its preview bounded.
|
||||
frameRate: beatles ? 5 : 30,
|
||||
cameras: beatles ? ['back'] : ['back','front']};
|
||||
} catch (error) { this.close(); throw error; }
|
||||
}
|
||||
if (!this.session || this.session.actor !== actor || this.session.id !== params.session)
|
||||
|
|
|
|||
Loading…
Reference in a new issue