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.7k
[camera] Move camera streaming to platform interface #5783
Merged
fluttergithubbot
merged 10 commits into
flutter:main
from
stuartmorgan-g:camera-stream-platform-interface
May 25, 2022
Merged
Changes from 1 commit
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-g d86e912
Platform interface package parts
stuartmorgan-g ea8c032
Rewire app-facing package
stuartmorgan-g 7a84131
Test update
stuartmorgan-g 3b6865c
Temporary pubspec overrides
stuartmorgan-g 7414e48
Version bumps
stuartmorgan-g b191e34
Future-proof the new API with an options dictionary
stuartmorgan-g 014f1c0
Review comments
stuartmorgan-g 701eefe
Revert app-facing portion
stuartmorgan-g 881786c
Merge branch 'main' into camera-stream-platform-interface
stuartmorgan-g 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
Next
Next commit
Add platform interface versions of the image data classes
- Loading branch information
commit 6fb3c2404aafc4fa45f6b4e51b9fcb45931a8d33
There are no files selected for viewing
119 changes: 119 additions & 0 deletions
119
packages/camera/camera_platform_interface/lib/src/types/camera_image_data.dart
This file contains hidden or 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 | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,119 @@ | ||||||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||||||
| // Use of this source code is governed by a BSD-style license that can be | ||||||
| // found in the LICENSE file. | ||||||
|
|
||||||
| import 'dart:typed_data'; | ||||||
|
|
||||||
| import 'package:flutter/foundation.dart'; | ||||||
|
|
||||||
| import '../../camera_platform_interface.dart'; | ||||||
|
|
||||||
| /// A single color plane of image data. | ||||||
| /// | ||||||
| /// The number and meaning of the planes in an image are determined by its | ||||||
| /// format. | ||||||
| @immutable | ||||||
| class CameraImagePlane { | ||||||
| /// Creates a new instance with the given bytes and optional metadata. | ||||||
| const CameraImagePlane({ | ||||||
| required this.bytes, | ||||||
| required this.bytesPerRow, | ||||||
| this.bytesPerPixel, | ||||||
| this.height, | ||||||
| this.width, | ||||||
| }); | ||||||
|
|
||||||
| /// Bytes representing this plane. | ||||||
| final Uint8List bytes; | ||||||
|
|
||||||
| /// The row stride for this color plane, in bytes. | ||||||
| final int bytesPerRow; | ||||||
|
|
||||||
| /// The distance between adjacent pixel samples in bytes, when available. | ||||||
| final int? bytesPerPixel; | ||||||
|
|
||||||
| /// Height of the pixel buffer, when available | ||||||
| final int? height; | ||||||
|
|
||||||
| /// Width of the pixel buffer, when available | ||||||
|
||||||
| /// Width of the pixel buffer, when available | |
| /// Width of the pixel buffer, when available. |
Contributor
Author
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.
Fixed.
This file contains hidden or 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
38 changes: 38 additions & 0 deletions
38
packages/camera/camera_platform_interface/test/types/camera_image_data_test.dart
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:typed_data'; | ||
|
|
||
| import 'package:camera_platform_interface/camera_platform_interface.dart'; | ||
| import 'package:flutter/foundation.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| void main() { | ||
| test('CameraImageData can be created', () { | ||
| debugDefaultTargetPlatformOverride = TargetPlatform.android; | ||
| final CameraImageData cameraImage = CameraImageData( | ||
| format: const CameraImageFormat(ImageFormatGroup.jpeg, raw: 42), | ||
| height: 100, | ||
| width: 200, | ||
| lensAperture: 1.8, | ||
| sensorExposureTime: 11, | ||
| sensorSensitivity: 92.0, | ||
| planes: <CameraImagePlane>[ | ||
| CameraImagePlane( | ||
| bytes: Uint8List.fromList(<int>[1, 2, 3, 4]), | ||
| bytesPerRow: 4, | ||
| bytesPerPixel: 2, | ||
| height: 100, | ||
| width: 200) | ||
| ], | ||
| ); | ||
| expect(cameraImage.format.group, ImageFormatGroup.jpeg); | ||
| expect(cameraImage.lensAperture, 1.8); | ||
| expect(cameraImage.sensorExposureTime, 11); | ||
| expect(cameraImage.sensorSensitivity, 92.0); | ||
| expect(cameraImage.height, 100); | ||
| expect(cameraImage.width, 200); | ||
| expect(cameraImage.planes.length, 1); | ||
| }); | ||
| } |
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
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.
Fixed.