diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart index 43c96f272692..ba72f207218d 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart @@ -160,7 +160,7 @@ class AndroidCameraCameraX extends CameraPlatform { final StreamController cameraEventStreamController = StreamController.broadcast(); - /// The stream of camera events. + /// The stream of camera events for the camera with ID cameraId. Stream _cameraEvents(int cameraId) => cameraEventStreamController .stream .where((CameraEvent event) => event.cameraId == cameraId); @@ -449,7 +449,7 @@ class AndroidCameraCameraX extends CameraPlatform { return _flutterSurfaceTextureId; } - /// Initializes the camera on the device. + /// Initializes the camera with ID [cameraId] on the device. /// /// Specifically, this method: /// * Configures the [ImageAnalysis] instance according to the specified @@ -523,9 +523,7 @@ class AndroidCameraCameraX extends CameraPlatform { ); } - /// Releases the resources of the accessed camera. - /// - /// [cameraId] not used. + /// Releases the resources of the accessed camera with ID [cameraId]. @override Future dispose(int cameraId) async { await preview?.releaseSurfaceProvider(); @@ -535,13 +533,13 @@ class AndroidCameraCameraX extends CameraPlatform { await deviceOrientationManager.stopListeningForDeviceOrientationChange(); } - /// The camera has been initialized. + /// The camera with ID [cameraId] has been initialized. @override Stream onCameraInitialized(int cameraId) { return _cameraEvents(cameraId).whereType(); } - /// The camera's resolution has changed. + /// The resolution of camera with ID [cameraId] has changed. /// /// This stream currently has no events being added to it from this plugin. @override @@ -549,13 +547,13 @@ class AndroidCameraCameraX extends CameraPlatform { return _cameraEvents(cameraId).whereType(); } - /// The camera started to close. + /// The camera with ID [cameraId] has started to close. @override Stream onCameraClosing(int cameraId) { return _cameraEvents(cameraId).whereType(); } - /// The camera experienced an error. + /// The camera with ID [cameraId] experienced an error. @override Stream onCameraError(int cameraId) { return StreamGroup.mergeBroadcast( @@ -570,13 +568,13 @@ class AndroidCameraCameraX extends CameraPlatform { ); } - /// The camera finished recording a video. + /// The camera with ID [cameraId] finished recording a video. @override Stream onVideoRecordedEvent(int cameraId) { return _cameraEvents(cameraId).whereType(); } - /// Locks the capture orientation. + /// Locks the capture orientation of camera with ID [cameraId]. @override Future lockCaptureOrientation( int cameraId, @@ -599,22 +597,21 @@ class AndroidCameraCameraX extends CameraPlatform { await videoCapture!.setTargetRotation(targetLockedRotation); } - /// Unlocks the capture orientation. + /// Unlocks the capture orientation of camera with ID [cameraId]. @override Future unlockCaptureOrientation(int cameraId) async { // Flag that default rotation should be set for UseCases as needed. captureOrientationLocked = false; } - /// Sets the exposure point for automatically determining the exposure values. + /// Sets the exposure point for automatically determining the exposure values for + /// camera with ID [cameraId]. /// /// Supplying `null` for the [point] argument will result in resetting to the /// original exposure point value. /// /// Supplied non-null point must be mapped to the entire un-altered preview /// surface for the exposure point to be applied accurately. - /// - /// [cameraId] is not used. @override Future setExposurePoint(int cameraId, Point? point) async { // We lock the new focus and metering action if focus mode has been locked @@ -629,9 +626,7 @@ class AndroidCameraCameraX extends CameraPlatform { ); } - /// Gets the minimum supported exposure offset for the selected camera in EV units. - /// - /// [cameraId] not used. + /// Gets the minimum supported exposure offset for the camera with ID [cameraId] in EV units. @override Future getMinExposureOffset(int cameraId) async { final ExposureState exposureState = cameraInfo!.exposureState; @@ -639,9 +634,7 @@ class AndroidCameraCameraX extends CameraPlatform { exposureState.exposureCompensationStep; } - /// Gets the maximum supported exposure offset for the selected camera in EV units. - /// - /// [cameraId] not used. + /// Gets the maximum supported exposure offset for the camera with ID [cameraId] in EV units. @override Future getMaxExposureOffset(int cameraId) async { final ExposureState exposureState = cameraInfo!.exposureState; @@ -649,7 +642,7 @@ class AndroidCameraCameraX extends CameraPlatform { exposureState.exposureCompensationStep; } - /// Sets the focus mode for taking pictures. + /// Sets the focus mode for taking pictures with camera with ID [cameraId] /// /// Setting [FocusMode.locked] will lock the current focus point if one exists /// or the center of entire sensor area if not, and will stay locked until @@ -730,11 +723,9 @@ class AndroidCameraCameraX extends CameraPlatform { } } - /// Gets the supported step size for exposure offset for the selected camera in EV units. + /// Gets the supported step size for exposure offset for the camera with ID [cameraId] in EV units. /// /// Returns -1 if exposure compensation is not supported for the device. - /// - /// [cameraId] not used. @override Future getExposureOffsetStepSize(int cameraId) async { final ExposureState exposureState = cameraInfo!.exposureState; @@ -748,7 +739,7 @@ class AndroidCameraCameraX extends CameraPlatform { return exposureOffsetStepSize; } - /// Sets the exposure offset for the selected camera. + /// Sets the exposure offset for the camera with ID [cameraId]. /// /// The supplied [offset] value should be in EV units. 1 EV unit represents a /// doubling in brightness. It should be between the minimum and maximum offsets @@ -807,15 +798,14 @@ class AndroidCameraCameraX extends CameraPlatform { } } - /// Sets the focus point for automatically determining the focus values. + /// Sets the focus point for automatically determining the focus values for the + /// camera with ID [cameraId]. /// /// Supplying `null` for the [point] argument will result in resetting to the /// original focus point value. /// /// Supplied non-null point must be mapped to the entire un-altered preview /// surface for the focus point to be applied accurately. - /// - /// [cameraId] is not used. @override Future setFocusPoint(int cameraId, Point? point) async { // We lock the new focus and metering action if focus mode has been locked @@ -830,12 +820,10 @@ class AndroidCameraCameraX extends CameraPlatform { ); } - /// Sets the exposure mode for taking pictures. + /// Sets the exposure mode for taking pictures with the camera with ID [cameraId]. /// /// Setting [ExposureMode.locked] will lock current exposure point until it /// is unset by setting [ExposureMode.auto]. - /// - /// [cameraId] is not used. @override Future setExposureMode(int cameraId, ExposureMode mode) async { final camera2Control = Camera2CameraControl.from( @@ -861,9 +849,7 @@ class AndroidCameraCameraX extends CameraPlatform { _currentExposureMode = mode; } - /// Gets the maximum supported zoom level for the selected camera. - /// - /// [cameraId] not used. + /// Gets the maximum supported zoom level for the camera with ID [cameraId]. @override Future getMaxZoomLevel(int cameraId) async { final LiveData liveZoomState = await cameraInfo!.getZoomState(); @@ -878,9 +864,7 @@ class AndroidCameraCameraX extends CameraPlatform { return zoomState.maxZoomRatio; } - /// Gets the minimum supported zoom level for the selected camera. - /// - /// [cameraId] not used. + /// Gets the minimum supported zoom level for the camera with ID [cameraId]. @override Future getMinZoomLevel(int cameraId) async { final LiveData liveZoomState = await cameraInfo!.getZoomState(); @@ -895,7 +879,7 @@ class AndroidCameraCameraX extends CameraPlatform { return zoomState.minZoomRatio; } - /// Set the zoom level for the selected camera. + /// Set the zoom level for the camera with ID [cameraId]. /// /// The supplied [zoom] value should be between the minimum and the maximum /// supported zoom level returned by [getMinZoomLevel] and [getMaxZoomLevel]. @@ -918,9 +902,7 @@ class AndroidCameraCameraX extends CameraPlatform { return deviceOrientationChangedStreamController.stream; } - /// Pause the active preview on the current frame for the selected camera. - /// - /// [cameraId] not used. + /// Pause the active preview on the current frame for the camera with ID [cameraId]. @override Future pausePreview(int cameraId) async { _previewIsPaused = true; @@ -975,18 +957,17 @@ class AndroidCameraCameraX extends CameraPlatform { await _updateCameraInfoAndLiveCameraState(_flutterSurfaceTextureId); } - /// Resume the paused preview for the selected camera. - /// - /// [cameraId] not used. + /// Resume the paused preview for the camera with ID [cameraId]. @override Future resumePreview(int cameraId) async { _previewIsPaused = false; await _bindUseCaseToLifecycle(preview!, cameraId); } - /// Returns a widget showing a live camera preview. + /// Returns a widget showing a live camera preview for the camera with ID [cameraId]. /// - /// [createCamera] must be called before attempting to build this preview. + /// [createCamera] must be called before attempting to build this preview, and + /// [cameraId] can be retrieved from that call. @override Widget buildPreview(int cameraId) { if (!previewInitiallyBound) { @@ -1017,9 +998,7 @@ class AndroidCameraCameraX extends CameraPlatform { ); } - /// Captures an image and returns the file where it was saved. - /// - /// [cameraId] is not used. + /// Captures an image using the camera with ID [cameraId] and returns the file where it was saved. @override Future takePicture(int cameraId) async { await _bindUseCaseToLifecycle(imageCapture!, cameraId); @@ -1044,7 +1023,7 @@ class AndroidCameraCameraX extends CameraPlatform { return XFile(picturePath); } - /// Sets the flash mode for the selected camera. + /// Sets the flash mode for the camera with ID [cameraId]. /// /// When the [FlashMode.torch] is enabled, any previously set [FlashMode] with /// this method will be disabled, just as with any other [FlashMode]; while @@ -1092,8 +1071,9 @@ class AndroidCameraCameraX extends CameraPlatform { return Future.value(); } - /// Configures and starts a video recording. Returns silently without doing - /// anything if there is currently an active recording. + /// Configures and starts a video recording with the camera with ID [cameraId]. + /// Returns silently without doing anything if there is currently an active + /// recording. /// /// Note that the preset resolution is used to configure the recording, but /// 240p ([ResolutionPreset.low]) is unsupported and will fallback to @@ -1246,7 +1226,7 @@ class AndroidCameraCameraX extends CameraPlatform { return videoFile; } - /// Pause the current video recording if it is not null. + /// Pause the current video recording of the camera with ID [cameraId] if it is not null. @override Future pauseVideoRecording(int cameraId) async { if (recording != null) { @@ -1254,7 +1234,7 @@ class AndroidCameraCameraX extends CameraPlatform { } } - /// Resume the current video recording if it is not null. + /// Resume the current video recording of the camera with ID [cameraId] if it is not null. @override Future resumeVideoRecording(int cameraId) async { if (recording != null) { @@ -1265,7 +1245,7 @@ class AndroidCameraCameraX extends CameraPlatform { @override bool supportsImageStreaming() => true; - /// A new streamed frame is available. + /// A new streamed frame is available from the camera with ID [cameraId]. /// /// Listening to this stream will start streaming, and canceling will stop. /// To temporarily stop receiving frames, cancel, then listen again later. @@ -1278,7 +1258,7 @@ class AndroidCameraCameraX extends CameraPlatform { /// streamed images will still have format [ImageFormatGroup.yuv420], but /// their image data will be formatted in NV21. /// - /// [cameraId] and [options] are not used. + /// [options] are not used. @override Stream onStreamedFrameAvailable( int cameraId, { @@ -1299,7 +1279,7 @@ class AndroidCameraCameraX extends CameraPlatform { /// /// [cameraId] used to build [CameraEvent]s should you wish to filter /// these based on a reference to a cameraId received from calling - /// `createCamera(...)`. + /// [createCamera]. Future _bindUseCaseToLifecycle(UseCase useCase, int cameraId) async { final bool useCaseIsBound = await processCameraProvider!.isBound(useCase); final bool useCaseIsPausedPreview = useCase is Preview && _previewIsPaused;