Skip to content

Commit f8c6691

Browse files
authored
Merge pull request #357 from shiniwat/feature/issue-115
SDL 0274: Add preferred FPS to VideoStreamingCapability
2 parents 423c810 + 819e366 commit f8c6691

4 files changed

Lines changed: 29 additions & 3 deletions

File tree

lib/js/src/rpc/structs/VideoStreamingCapability.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,25 @@ class VideoStreamingCapability extends RpcStruct {
183183
getScale () {
184184
return this.getParameter(VideoStreamingCapability.KEY_SCALE);
185185
}
186+
187+
/**
188+
* Set the PreferredFPS
189+
* @param {Number} fps - The preferred frame rate per second of the head unit. The mobile application / app library may take other factors into account that constrain the frame rate lower than this value, but it should not perform streaming at a higher frame rate than this value. - The desired PreferredFPS.
190+
* {'num_min_value': 0, 'num_max_value': 2147483647}
191+
* @returns {VideoStreamingCapability} - The class instance for method chaining.
192+
*/
193+
setPreferredFPS (fps) {
194+
this.setParameter(VideoStreamingCapability.KEY_PREFERRED_FPS, fps);
195+
return this;
196+
}
197+
198+
/**
199+
* Get the PreferredFPS
200+
* @returns {Number} - the KEY_PREFERRED_FPS value
201+
*/
202+
getPreferredFPS () {
203+
return this.getParameter(VideoStreamingCapability.KEY_PREFERRED_FPS);
204+
}
186205
}
187206

188207
VideoStreamingCapability.KEY_PREFERRED_RESOLUTION = 'preferredResolution';
@@ -192,5 +211,6 @@ VideoStreamingCapability.KEY_HAPTIC_SPATIAL_DATA_SUPPORTED = 'hapticSpatialDataS
192211
VideoStreamingCapability.KEY_DIAGONAL_SCREEN_SIZE = 'diagonalScreenSize';
193212
VideoStreamingCapability.KEY_PIXEL_PER_INCH = 'pixelPerInch';
194213
VideoStreamingCapability.KEY_SCALE = 'scale';
214+
VideoStreamingCapability.KEY_PREFERRED_FPS = 'preferredFPS';
195215

196216
export { VideoStreamingCapability };

lib/js/src/streaming/video/_VideoStreamingParameters.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ class _VideoStreamingParameters {
104104
if (formats !== null && formats.length > 0) {
105105
this._format = formats[0];
106106
}
107+
const fps = capability.getPreferredFPS();
108+
if (fps !== null) {
109+
this._frameRate = fps;
110+
}
107111
}
108112

109113
/**
@@ -214,4 +218,4 @@ class _VideoStreamingParameters {
214218
}
215219
}
216220

217-
export { _VideoStreamingParameters };
221+
export { _VideoStreamingParameters };

tests/node/streaming/video/VideoStreamingParametersTest.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ describe('VideoStreamingParametersTest', function () {
9191

9292
format = new VideoStreamingFormat(VideoStreamingProtocol.RTP, VideoStreamingCodec.H264);
9393
capability.setSupportedFormats([format]);
94+
capability.setPreferredFPS(15);
9495
params.update(capability);
9596
Validator.assertEquals(params.getFormat(), format);
97+
Validator.assertEquals(params.getFrameRate(), 15);
9698

9799
done();
98100
});
99-
});
101+
});

0 commit comments

Comments
 (0)