-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[camera_web] Add camera errors handling #4207
[camera_web] Add camera errors handling #4207
Conversation
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.
Let's keep the momentum going. Since CameraSettings
is an internal implementation detail, it can be renamed/split in a further PR.
/// A utility to fetch, map camera settings and | ||
/// obtain the camera stream. | ||
class CameraSettings { |
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.
Is it time to find a better name for CameraSettings
? Is it maybe doing too much? Slightly confusing naming with CameraOptions
?
Maybe the parts regarding the management of the Camera Stream should be moved to a new class? Is this class more of a CameraStreamsHelper
/Handler
?
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! It is currently responsible for getting the camera stream based on CameraOptions
, getting the facing mode setting based on the camera video track and mapping camera video track settings. How about renaming it to a CameraService
(this way we will no longer mix settings with options)?
I'm also okay with extracting the camera stream logic to a separate class (CameraStreams.getStreamForOptions
maybe?) if you prefer it that way.
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.
CameraService
sounds good to me. For the conversion functions, what I've been doing is to have a fat "convert.dart" with a bunch of functions there that translate from one type to my own (and vice-versa). See convert.dart in google maps. I normally prefer those functions to be stateless, so they can be just utility functions (they don't need to belong to any class or namespace).
Adds camera errors handling to the web implementation of the camera platform interface.
CameraErrorCode
(media error).CameraWebException
thrown when the camera reports an initialization, configuration or video streaming error, or enters into an unexpected state.getMediaStreamForOptions
toCameraSettings
- returns a media stream for the camera constrained by the given options.PlatformException
rather than aDomException
/CameraException
for consistency with the MethodChannelCamera implementation. The only exemptions areavailableCameras
andcreateCamera
that may throw aCameraException
.CameraWebException
is caught and emitted on theonCameraError
stream.onCameraError
stream.Part of flutter/flutter#45297.
Pre-launch Checklist
dart format
.)[shared_preferences]
///
).