Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/camera/camera_platform_interface/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ Anton Borries <mail@antonborri.es>
Alex Li <google@alexv525.com>
Rahul Raj <64.rahulraj@gmail.com>
Mairramer <mairramer.dasilva28@hotmail.com>
Rui Craveiro <ruicraveiro@squarealfa.com>
5 changes: 5 additions & 0 deletions packages/camera/camera_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.12.0

* Adds support for video stabilization.

## 2.11.0

* Adds a flag to configure a recording to be persistent across camera changes. See
Expand All @@ -20,6 +24,7 @@
most platforms, and there is no plan to implement it in the future.
* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.


## 2.7.4

* Updates minimum supported SDK version to Flutter 3.13/Dart 3.1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,34 @@ abstract class CameraPlatform extends PlatformInterface {
throw UnimplementedError('setZoomLevel() is not implemented.');
}

/// Gets a list of video stabilization modes that are supported for the selected camera.
Future<Iterable<VideoStabilizationMode>> getSupportedVideoStabilizationModes(
int cameraId,
) => Future<List<VideoStabilizationMode>>.value(<VideoStabilizationMode>[]);

/// Sets the video stabilization mode for the selected camera.
Future<void> setVideoStabilizationMode(
int cameraId,
VideoStabilizationMode mode,
) {
throw UnimplementedError('setVideoStabilizationMode() is not implemented.');
}

/// Gets the fallback mode of video stabilization [mode].
///
/// This method returns the video stabilization mode that [setVideoStabilizationMode]
/// should set when the device does not support the given [mode].
static VideoStabilizationMode? getFallbackVideoStabilizationMode(
VideoStabilizationMode mode,
) {
return switch (mode) {
VideoStabilizationMode.off => null,
VideoStabilizationMode.level1 => VideoStabilizationMode.off,
VideoStabilizationMode.level2 => VideoStabilizationMode.level1,
VideoStabilizationMode.level3 => VideoStabilizationMode.level2,
};
}

/// Pause the active preview on the current frame for the selected camera.
Future<void> pausePreview(int cameraId) {
throw UnimplementedError('pausePreview() is not implemented.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export 'image_format_group.dart';
export 'media_settings.dart';
export 'resolution_preset.dart';
export 'video_capture_options.dart';
export 'video_stabilization_mode.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// The possible video stabilization modes that can be capturing video.
enum VideoStabilizationMode {
/// Video stabilization is disabled.
off,

/// Least stabilized video stabilization mode with the least latency.
level1,

/// More stabilized video with more latency.
level2,

/// Most stabilized video with the most latency.
level3,
}
2 changes: 1 addition & 1 deletion packages/camera/camera_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/camera/camera
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 2.11.0
version: 2.12.0

environment:
sdk: ^3.7.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,48 @@ void main() {
expect(cameraPlatform.supportsImageStreaming(), false);
},
);

test(
'getFallbackVideoStabilizationMode returns level2 for mode level3',
() {
final VideoStabilizationMode? fallbackMode =
CameraPlatform.getFallbackVideoStabilizationMode(
VideoStabilizationMode.level3,
);

expect(fallbackMode, VideoStabilizationMode.level2);
},
);

test(
'getFallbackVideoStabilizationMode returns level1 for mode level2',
() {
final VideoStabilizationMode? fallbackMode =
CameraPlatform.getFallbackVideoStabilizationMode(
VideoStabilizationMode.level2,
);

expect(fallbackMode, VideoStabilizationMode.level1);
},
);

test('getFallbackVideoStabilizationMode returns off for mode level1', () {
final VideoStabilizationMode? fallbackMode =
CameraPlatform.getFallbackVideoStabilizationMode(
VideoStabilizationMode.level1,
);

expect(fallbackMode, VideoStabilizationMode.off);
});

test('getFallbackVideoStabilizationMode returns null for mode off', () {
final VideoStabilizationMode? fallbackMode =
CameraPlatform.getFallbackVideoStabilizationMode(
VideoStabilizationMode.off,
);

expect(fallbackMode, null);
});
});

group('exports', () {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:camera_platform_interface/src/types/video_stabilization_mode.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
test('VideoStabilizationMode should contain 4 options', () {
const List<VideoStabilizationMode> values = VideoStabilizationMode.values;

expect(values.length, 4);
});

test('VideoStabilizationMode enum should have items in correct index', () {
const List<VideoStabilizationMode> values = VideoStabilizationMode.values;

expect(values[0], VideoStabilizationMode.off);
expect(values[1], VideoStabilizationMode.level1);
expect(values[2], VideoStabilizationMode.level2);
expect(values[3], VideoStabilizationMode.level3);
});
}