Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow setting compression quality and scaling factor for the mjpeg-stream #196

Merged
merged 1 commit into from
Aug 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions WebDriverAgentLib/Utilities/FBMjpegServer.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,16 @@ - (void)streamScreenshot
BOOL usesScaling = fabs(FBMaxScalingFactor - scalingFactor) > DBL_EPSILON;

CGFloat compressionQuality = FBConfiguration.mjpegServerScreenshotQuality / 100.0f;

// If scaling is applied we perform another JPEG compression after scaling
// To get the desired compressionQuality we need to do a lossless compression here
if (usesScaling) {
compressionQuality = FBMaxScalingFactor;
}
CGFloat screenshotCompressionQuality = usesScaling ? FBMaxCompressionQuality : compressionQuality;

id<XCTestManager_ManagerInterface> proxy = [FBXCTestDaemonsProxy testRunnerProxy];
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
[proxy _XCT_requestScreenshotOfScreenWithID:[[XCUIScreen mainScreen] displayID]
withRect:CGRectNull
uti:(__bridge id)kUTTypeJPEG
compressionQuality:compressionQuality
compressionQuality:screenshotCompressionQuality
withReply:^(NSData *data, NSError *error) {
if (error != nil) {
[FBLogger logFmt:@"Error taking screenshot: %@", [error description]];
Expand Down