@@ -4,7 +4,6 @@ import {SubProcess} from 'teen_process';
44import { encodeBase64OrUpload } from '../utils' ;
55import { WDA_BASE_URL } from 'appium-webdriveragent' ;
66import { waitForCondition } from 'asyncbox' ;
7- import url from 'node:url' ;
87import type { XCUITestDriver } from '../driver' ;
98import type { StartRecordingScreenOptions , StopRecordingScreenOptions } from './types' ;
109import type { WDASettings } from 'appium-webdriveragent' ;
@@ -86,7 +85,7 @@ export class ScreenRecorder {
8685 private mainProcess : SubProcess | null ;
8786 private timeoutHandler : NodeJS . Timeout | null ;
8887
89- constructor ( udid : string , log : any , videoPath : string , opts : ScreenRecorderOptions = { } ) {
88+ constructor ( udid : string , log : any , videoPath : string , opts : ScreenRecorderOptions ) {
9089 this . videoPath = videoPath ;
9190 this . log = log ;
9291 this . opts = opts ;
@@ -144,8 +143,8 @@ export class ScreenRecorder {
144143 if ( ( videoFps && videoType === 'libx264' ) || videoTypeHWAccel ) {
145144 args . push ( '-r' , String ( videoFps ) ) ;
146145 }
147- const { protocol , hostname } = url . parse ( remoteUrl || '' ) ;
148- args . push ( '-i' , `${ protocol } //${ hostname } :${ remotePort } ` ) ;
146+ const parsed = new URL ( remoteUrl ) ;
147+ args . push ( '-i' , `${ parsed . protocol } //${ parsed . hostname } :${ remotePort } ` ) ;
149148
150149 if ( videoFilters || videoScale ) {
151150 args . push ( '-vf' , videoFilters || `${ scaleFilterHWAccel || 'scale' } =${ videoScale } ` ) ;
@@ -283,10 +282,9 @@ export async function startRecordingScreen(
283282 suffix : MP4_EXT ,
284283 } ) ;
285284
286- const wdaBaseUrl = this . opts . wdaBaseUrl || WDA_BASE_URL ;
287285 const screenRecorder = new ScreenRecorder ( this . device . udid , this . log , videoPath , {
288286 remotePort : this . opts . mjpegServerPort || DEFAULT_MJPEG_SERVER_PORT ,
289- remoteUrl : wdaBaseUrl ,
287+ remoteUrl : this . opts . wdaBaseUrl || WDA_BASE_URL ,
290288 videoType,
291289 videoFilters,
292290 videoScale,
@@ -405,8 +403,8 @@ export async function stopRecordingScreen(
405403
406404interface ScreenRecorderOptions {
407405 hardwareAcceleration ?: string ;
408- remotePort ? : number ;
409- remoteUrl ? : string ;
406+ remotePort : number ;
407+ remoteUrl : string ;
410408 videoFps ?: number ;
411409 videoType ?: string ;
412410 videoScale ?: string ;
0 commit comments