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_web] Add initializeCamera implementation
#4186
Merged
fluttergithubbot
merged 7 commits into
flutter:master
from
VeryGoodOpenSource:feat/camera-web-initialize-camera
Jul 24, 2021
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3b8f421
feat: add getVideoSize to Camera
bselwe bd6683f
test: add getVIdeoSize tests
bselwe c2efbe8
feat: add initializeCamera and onCameraInitialized implementation
bselwe a1f200d
test: add initializeCamera and onCameraInitialized tests
bselwe 2abbba1
test: use a blank canvas stream instead of an HTTPS stream
bselwe b8b8c8b
docs: update comments
bselwe 55fa4fd
Revert "docs: update comments"
ditman 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 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
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 |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:html'; | ||
| import 'dart:ui'; | ||
|
|
||
| import 'package:camera_platform_interface/camera_platform_interface.dart'; | ||
| import 'package:camera_web/src/camera.dart'; | ||
|
|
@@ -28,13 +29,7 @@ void main() { | |
| navigator = MockNavigator(); | ||
| mediaDevices = MockMediaDevices(); | ||
|
|
||
| final videoElement = VideoElement() | ||
| ..src = | ||
| 'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4' | ||
| ..preload = 'true' | ||
| ..width = 10 | ||
| ..height = 10; | ||
|
|
||
| final videoElement = getVideoElementWithBlankStream(Size(10, 10)); | ||
|
Member
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. Heck yes, this is great! |
||
| mediaStream = videoElement.captureStream(); | ||
|
|
||
| when(() => window.navigator).thenReturn(navigator); | ||
|
|
@@ -469,6 +464,49 @@ void main() { | |
| }); | ||
| }); | ||
|
|
||
| group('getVideoSize', () { | ||
| testWidgets( | ||
| 'returns a size ' | ||
| 'based on the first video track settings', (tester) async { | ||
| const videoSize = Size(1280, 720); | ||
|
|
||
| final videoElement = getVideoElementWithBlankStream(videoSize); | ||
| mediaStream = videoElement.captureStream(); | ||
|
|
||
| final camera = Camera( | ||
| textureId: 1, | ||
| window: window, | ||
| ); | ||
|
|
||
| await camera.initialize(); | ||
|
|
||
| expect( | ||
| await camera.getVideoSize(), | ||
| equals(videoSize), | ||
| ); | ||
| }); | ||
|
|
||
| testWidgets( | ||
| 'returns Size.zero ' | ||
| 'if the camera is missing video tracks', (tester) async { | ||
| // Create a video stream with no video tracks. | ||
| final videoElement = VideoElement(); | ||
| mediaStream = videoElement.captureStream(); | ||
|
|
||
| final camera = Camera( | ||
| textureId: 1, | ||
| window: window, | ||
| ); | ||
|
|
||
| await camera.initialize(); | ||
|
|
||
| expect( | ||
| await camera.getVideoSize(), | ||
| equals(Size.zero), | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| group('dispose', () { | ||
| testWidgets('resets the video element\'s source', (tester) async { | ||
| final camera = Camera( | ||
|
|
||
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
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
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
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.
@ditman Should this be reverted for now?
Uh oh!
There was an error while loading. Please reload this page.
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.
Correct, let's add a pass documenting all the web stuff in platform_interface later on, since we need to publish a new version of the platform_interface so the new docs show up in pub.