diff --git a/lib/cli/device/index.js b/lib/cli/device/index.js index c4e9f370..a9bd8a89 100644 --- a/lib/cli/device/index.js +++ b/lib/cli/device/index.js @@ -1,3 +1,7 @@ +/** +* Copyright © 2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 +**/ + module.exports.command = 'device' module.exports.builder = function(yargs) { @@ -92,6 +96,12 @@ module.exports.builder = function(yargs) { , type: 'string' , demand: true }) + .option('screen-frame-rate', { + describe: 'The frame rate (frames/s) to be used for screen transport on the network. ' + + 'Float value must be > 0.0 otherwise the default behavior is kept' + , type: 'number' + , default: process.env.SCREEN_FRAME_RATE || -1 + }) .option('screen-jpeg-quality', { describe: 'The JPG quality to use for the screen.' , type: 'number' @@ -164,6 +174,7 @@ module.exports.handler = function(argv) { , storageUrl: argv.storageUrl , adbHost: argv.adbHost , adbPort: argv.adbPort + , screenFrameRate: argv.screenFrameRate , screenJpegQuality: argv.screenJpegQuality , screenGrabber: argv.screenGrabber , screenPingInterval: argv.screenPingInterval diff --git a/lib/cli/provider/index.js b/lib/cli/provider/index.js index efe01f7e..8a4b4bab 100644 --- a/lib/cli/provider/index.js +++ b/lib/cli/provider/index.js @@ -115,6 +115,12 @@ module.exports.builder = function(yargs) { , type: 'string' , default: ip() }) + .option('screen-frame-rate', { + describe: 'The frame rate (frames/s) to be used for screen transport on the network. ' + + 'Float value must be > 0.0 otherwise the default behavior is kept' + , type: 'number' + , default: process.env.SCREEN_FRAME_RATE || -1 + }) .option('screen-jpeg-quality', { describe: 'The JPG quality to use for the screen.' , type: 'number' @@ -198,6 +204,7 @@ module.exports.handler = function(argv) { , '--storage-url', argv.storageUrl , '--adb-host', argv.adbHost , '--adb-port', argv.adbPort + , '--screen-frame-rate', argv.screenFrameRate , '--screen-jpeg-quality', argv.screenJpegQuality , '--screen-grabber', argv.screenGrabber , '--screen-ping-interval', argv.screenPingInterval diff --git a/lib/units/device/plugins/screen/stream.js b/lib/units/device/plugins/screen/stream.js index dd83f952..9a09973e 100644 --- a/lib/units/device/plugins/screen/stream.js +++ b/lib/units/device/plugins/screen/stream.js @@ -1,3 +1,7 @@ +/** +* Copyright © 2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 +**/ + var util = require('util') var Promise = require('bluebird') @@ -26,6 +30,7 @@ module.exports = syrup.serial() .define(function(options, adb, minicap, display, screenOptions) { var log = logger.createLogger('device:plugins:screen:stream') log.info('ScreenGrabber option set to %s', options.screenGrabber) + log.info('ScreenFrameRate option set to %d', options.screenFrameRate) function FrameProducer(config, grabber) { EventEmitter.call(this) @@ -230,12 +235,23 @@ module.exports = syrup.serial() FrameProducer.prototype._startService = function() { log.info('Launching screen service %s', this.grabber) - return minicap.run(this.grabber, util.format( - '-S -Q %d -P %s' - , options.screenJpegQuality - , this.frameConfig.toString() - )) - .timeout(10000) + if (options.screenFrameRate <= 0.0) { + return minicap.run(this.grabber, util.format( + '-S -Q %d -P %s' + , options.screenJpegQuality + , this.frameConfig.toString() + )) + .timeout(10000) + } + else { + return minicap.run(this.grabber, util.format( + '-S -r %d -Q %d -P %s' + , options.screenFrameRate + , options.screenJpegQuality + , this.frameConfig.toString() + )) + .timeout(10000) + } } FrameProducer.prototype._readOutput = function(out) {