This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[camera] Move camera streaming to platform interface #5783
Merged
fluttergithubbot
merged 10 commits into
flutter:main
from
stuartmorgan:camera-stream-platform-interface
May 25, 2022
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6fb3c24
Add platform interface versions of the image data classes
stuartmorgan d86e912
Platform interface package parts
stuartmorgan ea8c032
Rewire app-facing package
stuartmorgan 7a84131
Test update
stuartmorgan 3b6865c
Temporary pubspec overrides
stuartmorgan 7414e48
Version bumps
stuartmorgan b191e34
Future-proof the new API with an options dictionary
stuartmorgan 014f1c0
Review comments
stuartmorgan 701eefe
Revert app-facing portion
stuartmorgan 881786c
Merge branch 'main' into camera-stream-platform-interface
stuartmorgan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,64 @@ | |
import 'dart:typed_data'; | ||
|
||
import 'package:camera/camera.dart'; | ||
import 'package:camera_platform_interface/camera_platform_interface.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('$CameraImage tests', () { | ||
test('translates correctly from platform interface classes', () { | ||
final CameraImageData originalImage = CameraImageData( | ||
format: const CameraImageFormat(ImageFormatGroup.jpeg, raw: 1234), | ||
planes: <CameraImagePlane>[ | ||
CameraImagePlane( | ||
bytes: Uint8List.fromList(<int>[1, 2, 3, 4]), | ||
bytesPerRow: 20, | ||
bytesPerPixel: 3, | ||
width: 200, | ||
height: 100, | ||
), | ||
CameraImagePlane( | ||
bytes: Uint8List.fromList(<int>[5, 6, 7, 8]), | ||
bytesPerRow: 18, | ||
bytesPerPixel: 4, | ||
width: 220, | ||
height: 110, | ||
), | ||
], | ||
width: 640, | ||
height: 480, | ||
lensAperture: 2.5, | ||
sensorExposureTime: 5, | ||
sensorSensitivity: 1.3, | ||
); | ||
|
||
final CameraImage image = CameraImage.fromPlatformInterface(originalImage); | ||
// Simple values. | ||
expect(image.width, originalImage.width); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: For There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
expect(image.height, originalImage.height); | ||
expect(image.lensAperture, originalImage.lensAperture); | ||
expect(image.sensorExposureTime, originalImage.sensorExposureTime); | ||
expect(image.sensorSensitivity, originalImage.sensorSensitivity); | ||
// Format. | ||
expect(image.format.group, originalImage.format.group); | ||
expect(image.format.raw, originalImage.format.raw); | ||
// Planes. | ||
expect(image.planes.length, originalImage.planes.length); | ||
for (int i = 0; i < image.planes.length; i++) { | ||
expect( | ||
image.planes[i].bytes.length, originalImage.planes[i].bytes.length); | ||
for (int j = 0; j < image.planes[i].bytes.length; j++) { | ||
expect(image.planes[i].bytes[j], originalImage.planes[i].bytes[j]); | ||
} | ||
expect( | ||
image.planes[i].bytesPerPixel, originalImage.planes[i].bytesPerPixel); | ||
expect(image.planes[i].bytesPerRow, originalImage.planes[i].bytesPerRow); | ||
expect(image.planes[i].width, originalImage.planes[i].width); | ||
expect(image.planes[i].height, originalImage.planes[i].height); | ||
} | ||
}); | ||
|
||
group('legacy constructors', () { | ||
test('$CameraImage can be created', () { | ||
debugDefaultTargetPlatformOverride = TargetPlatform.android; | ||
final CameraImage cameraImage = | ||
|
39 changes: 0 additions & 39 deletions
39
packages/camera/camera/test/utils/method_channel_mock.dart
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Is there an issue tracking this or is it coming in a follow up PR soon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I filed flutter/flutter#104188
I'm not sure if we want to do a breaking change just for this or not. It's pretty minor... but on the other hand most clients wouldn't be affected, and it's a quick change for those who are, so it wouldn't be too disruptive to do.