@@ -234,7 +234,7 @@ export class ScreenRecorder {
234234 * (`false`) or to start a new recording immediately and terminate the existing one if running (`true`).
235235 * @throws {Error } If screen recording has failed to start or is not supported on the device under test.
236236 */
237- export async function startRecordingScreen (
237+ export async function windowsStartRecordingScreen (
238238 timeLimit ,
239239 videoFilter ,
240240 fps ,
@@ -301,7 +301,7 @@ export async function startRecordingScreen (
301301 * or the file content cannot be uploaded to the remote location
302302 * or screen recording is not supported on the device under test.
303303 */
304- export async function stopRecordingScreen (
304+ export async function windowsStopRecordingScreen (
305305 remotePath ,
306306 user ,
307307 pass ,
@@ -335,6 +335,120 @@ export async function stopRecordingScreen (
335335 } ) ;
336336}
337337
338+ /**
339+ * @typedef {Object } StartRecordingOptions
340+ *
341+ * @property {string } videoFilter - The video filter spec to apply for ffmpeg.
342+ * See https://trac.ffmpeg.org/wiki/FilteringGuide for more details on the possible values.
343+ * Example: Set it to `scale=ifnot(gte(iw\,1024)\,iw\,1024):-2` in order to limit the video width
344+ * to 1024px. The height will be adjusted automatically to match the actual ratio.
345+ * @property {number|string } fps [15] - The count of frames per second in the resulting video.
346+ * The greater fps it has the bigger file size is.
347+ * @property {string } preset [veryfast] - One of the supported encoding presets. Possible values are:
348+ * - ultrafast
349+ * - superfast
350+ * - veryfast
351+ * - faster
352+ * - fast
353+ * - medium
354+ * - slow
355+ * - slower
356+ * - veryslow
357+ * A preset is a collection of options that will provide a certain encoding speed to compression ratio.
358+ * A slower preset will provide better compression (compression is quality per filesize).
359+ * This means that, for example, if you target a certain file size or constant bit rate, you will achieve better
360+ * quality with a slower preset. Read https://trac.ffmpeg.org/wiki/Encode/H.264 for more details.
361+ * @property {boolean } captureCursor [false] - Whether to capture the mouse cursor while recording
362+ * the screen
363+ * @property {boolean } captureClicks [false] - Whether to capture mouse clicks while recording the
364+ * screen
365+ * @property {string } audioInput - If set then the given audio input will be used to record the computer audio
366+ * along with the desktop video. The list of available devices could be retrieved using
367+ * `ffmpeg -list_devices true -f dshow -i dummy` command.
368+ * @property {string|number } timeLimit [600] - The maximum recording time, in seconds. The default
369+ * value is 600 seconds (10 minutes).
370+ * @property {boolean } forceRestart [true] - Whether to ignore the call if a screen recording is currently running
371+ * (`false`) or to start a new recording immediately and terminate the existing one if running (`true`).
372+ */
373+
374+ /**
375+ * Record the display in background while the automated test is running.
376+ * This method requires FFMPEG (https://www.ffmpeg.org/download.html) to be installed
377+ * and present in PATH.
378+ * The resulting video uses H264 codec and is ready to be played by media players built-in into web browsers.
379+ *
380+ * @param {StartRecordingOptions } options - The available options.
381+ * @this {import('../driver').WindowsDriver}
382+ * @throws {Error } If screen recording has failed to start or is not supported on the device under test.
383+ */
384+ export async function startRecordingScreen ( options ) {
385+ const {
386+ timeLimit,
387+ videoFilter,
388+ fps,
389+ preset,
390+ captureCursor,
391+ captureClicks,
392+ audioInput,
393+ forceRestart = true ,
394+ } = options ?? { } ;
395+
396+ await this . windowsStartRecordingScreen (
397+ timeLimit ,
398+ videoFilter ,
399+ fps ,
400+ preset ,
401+ captureCursor ,
402+ captureClicks ,
403+ audioInput ,
404+ forceRestart
405+ ) ;
406+ }
407+
408+ /**
409+ * @typedef {Object } StopRecordingOptions
410+ *
411+ * @property {string } remotePath - The path to the remote location, where the resulting video should be uploaded.
412+ * The following protocols are supported: http/https, ftp.
413+ * Null or empty string value (the default setting) means the content of resulting
414+ * file should be encoded as Base64 and passed as the endpoint response value.
415+ * An exception will be thrown if the generated media file is too big to
416+ * fit into the available process memory.
417+ * @property {string } user - The name of the user for the remote authentication.
418+ * @property {string } pass - The password for the remote authentication.
419+ * @property {string } method - The http multipart upload method name. The 'PUT' one is used by default.
420+ * @property {Object } headers - Additional headers mapping for multipart http(s) uploads
421+ * @property {string } fileFieldName [file] - The name of the form field, where the file content BLOB should be stored for
422+ * http(s) uploads
423+ * @property {Object[]|[string, string][] } formFields - Additional form fields for multipart http(s) uploads
424+ */
425+
426+ /**
427+ * Stop recording the screen.
428+ * If no screen recording has been started before then the method returns an empty string.
429+ *
430+ * @param {StopRecordingOptions } options - The available options.
431+ * @returns {Promise<string> } Base64-encoded content of the recorded media file if 'remotePath'
432+ * parameter is falsy or an empty string.
433+ * @this {import('../driver').WindowsDriver}
434+ * @throws {Error } If there was an error while getting the name of a media file
435+ * or the file content cannot be uploaded to the remote location
436+ * or screen recording is not supported on the device under test.
437+ */
438+ export async function stopRecordingScreen ( options ) {
439+ const { remotePath, user, pass, method, headers, fileFieldName, formFields} = options ?? { } ;
440+
441+ return await this . windowsStopRecordingScreen (
442+ remotePath ,
443+ user ,
444+ pass ,
445+ method ,
446+ headers ,
447+ fileFieldName ,
448+ formFields
449+ ) ;
450+ }
451+
338452/**
339453 * @typedef {import('../driver').WindowsDriver } WindowsDriver
340454 */
0 commit comments