Skip to content

Commit

Permalink
ignore setting mjpegServer when liveVideo is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
sudharsan-selvaraj committed Jun 22, 2024
1 parent 870d046 commit 8518fa1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "appium-device-farm",
"version": "8.4.7-rc.43",
"version": "8.4.7-rc.44",
"description": "An appium 2.0 plugin that manages and create driver session on available devices",
"main": "./lib/src/main.js",
"scripts": {
Expand Down
22 changes: 17 additions & 5 deletions src/CapabilityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ export async function androidCapabilities(
caps.firstMatch[0]['appium:adbPort'] = freeDevice.adbPort;
if (freeDevice.chromeDriverPath)
caps.firstMatch[0]['appium:chromedriverExecutable'] = freeDevice.chromeDriverPath;
if (!isCapabilityAlreadyPresent(caps, 'appium:mjpegServerPort') && !!options.liveVideo) {
caps.firstMatch[0]['appium:mjpegServerPort'] = await getPort();
if (!isCapabilityAlreadyPresent(caps, 'appium:mjpegServerPort')) {
caps.firstMatch[0]['appium:mjpegServerPort'] = !!options.liveVideo
? await getPort()
: undefined;
}
if (!options.liveVideo) {
deleteAlwaysMatch(caps, 'appium:mjpegServerPort');
}
deleteAlwaysMatch(caps, 'appium:udid');
deleteAlwaysMatch(caps, 'appium:systemPort');
Expand Down Expand Up @@ -90,9 +95,11 @@ export async function iOSCapabilities(
caps.firstMatch[0]['appium:deviceName'] = freeDevice.name;
caps.firstMatch[0]['appium:platformVersion'] = freeDevice.sdk;
caps.firstMatch[0]['appium:wdaLocalPort'] = freeDevice.wdaLocalPort;
caps.firstMatch[0]['appium:mjpegServerPort'] = !!options.liveVideo
? freeDevice.mjpegServerPort
: undefined;
if (!isCapabilityAlreadyPresent(caps, 'appium:mjpegServerPort')) {
caps.firstMatch[0]['appium:mjpegServerPort'] = !!options.liveVideo
? await getPort()
: undefined;
}
if (freeDevice.realDevice && !caps.firstMatch[0]['df:skipReport']) {
const wdaInfo = await prisma.appInformation.findFirst({
where: { fileName: 'wda-resign.ipa' },
Expand All @@ -103,6 +110,7 @@ export async function iOSCapabilities(
caps.firstMatch[0]['appium:updatedWDABundleIdSuffix'] = '';
}
}

const deleteMatch = [
'appium:derivedDataPath',
'appium:platformVersion',
Expand All @@ -112,6 +120,10 @@ export async function iOSCapabilities(
'appium:deviceName',
'appium:app',
];

if (!options.liveVideo) {
deleteMatch.push('appium:mjpegServerPort');
}
deleteMatch.forEach((value) => deleteAlwaysMatch(caps, value));
}

Expand Down
4 changes: 3 additions & 1 deletion src/device-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ export async function allocateDeviceForSession(
deviceFarmCapabilities[DEVICE_FARM_CAPABILITIES.DEVICE_TIMEOUT] || deviceTimeOutMs;
const intervalBetweenAttempts =
deviceFarmCapabilities[DEVICE_FARM_CAPABILITIES.DEVICE_QUERY_INTERVAL] || deviceQueryIntervalMs;
const liveVideo = deviceFarmCapabilities[DEVICE_FARM_CAPABILITIES.LIVE_VIDEO] || true;
const liveVideo = _.isNil(deviceFarmCapabilities[DEVICE_FARM_CAPABILITIES.LIVE_VIDEO])
? true
: JSON.parse(deviceFarmCapabilities[DEVICE_FARM_CAPABILITIES.LIVE_VIDEO]);

try {
await waitUntil(
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DevicePlugin } from './plugin';
import { path as ffmpeg } from '@ffmpeg-installer/ffmpeg';
import ffmpeg from '@ffmpeg-installer/ffmpeg';
import { loadExternalModules, registerErrorHandlers } from './helpers';

//Add FFMPEG to path for appium to record video of the session
process.env.PATH = process.env.PATH + ':' + ffmpeg.replace(/ffmpeg$/g, '');
process.env.PATH = process.env.PATH + ':' + ffmpeg.path.replace(/ffmpeg$/g, '');
loadExternalModules();

registerErrorHandlers();
Expand Down

0 comments on commit 8518fa1

Please sign in to comment.