Skip to content

[camera] Convert Windows to Pigeon - #6925

Merged
auto-submit[bot] merged 14 commits into
flutter:mainfrom
stuartmorgan-g:camera-windows-pigeon
Jul 9, 2024
Merged

[camera] Convert Windows to Pigeon#6925
auto-submit[bot] merged 14 commits into
flutter:mainfrom
stuartmorgan-g:camera-windows-pigeon

Conversation

@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

Replaces all of the manual method channel code in camera_windows with Pigeon.

I attempted to change the structure as little as possible, since this was already a large change. I don't particularly like the way the native result callback objects are managed (passed to Camera and tracked in a map), but I decided that redesigning that would be out of scope and introduced a std::variant to allow minimal changes to that structure. That does slightly undermine the type safety of the callbacks, but it's still strictly enforced at the level of the helpers that interact with the map.

Fixesflutter/flutter#117905

Pre-launch Checklist

@stuartmorgan-gstuartmorgan-g left a comment

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some overview of the changes to help with review:

Comment threadpackages/camera/camera_windows/lib/camera_windows.dart
Comment threadpackages/camera/camera_windows/lib/camera_windows.dart
}

// Pigeon version of the relevant subset of VideoCaptureOptions.
class PlatformVideoCaptureOptions {

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fully expect this to contain other things later, thus the use of the wrapper now.

// Returns an error result if the result has already been added.
virtual bool AddPendingResult(PendingResultType type,
std::unique_ptr<MethodResult<>> result) = 0;
virtual bool AddPendingVoidResult(

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new methods are because callbacks are no longer one generic type. I could have just changed the existing API to take the new variant, but I opted to hide that to minimize the number of places where we are essentially dropping type safety.

That will also make it simpler to change to something fully type-safe later since it will be internal to this one class.

Comment threadpackages/camera/camera_windows/windows/camera.h
using Microsoft::WRL::ComPtr;

// Camera resolution presets. Used to request a capture resolution.
enum class ResolutionPreset {

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is replaced by a Pigeon-generated enum.

// Allows to tune recorded video parameters, such as resolution, frame rate,
// bitrate. If [fps], [video_bitrate] or [audio_bitrate] are passed, they must
// be greater than zero.
struct RecordSettings {

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This struct is replaced by a Pigeon-generated data class.

Comment threadpackages/camera/camera_windows/windows/test/camera_test.cpp
Comment threadpackages/camera/camera_windows/windows/test/mocks.h
@stuartmorgan-g

Copy link
Copy Markdown
CollaboratorAuthor

@cbracken Ping on this review in case you missed the notification while you were out.

@cbracken

Copy link
Copy Markdown
Member

Back as of yesterday and mostly caught up on mail. Looking!

Comment threadpackages/camera/camera_windows/pigeons/messages.dart Outdated
Comment threadpackages/camera/camera_windows/pigeons/messages.dart Outdated
Comment threadpackages/camera/camera_windows/test/camera_windows_test.dart

@cbrackencbracken left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM stamp from a Japanese personal seal

@stuartmorgan-gstuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 9, 2024
@auto-submit
auto-submitBot merged commit 5cc6418 into flutter:mainJul 9, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 10, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 10, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 10, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 10, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 10, 2024
auto-submitBot pushed a commit to flutter/flutter that referenced this pull request Jul 10, 2024
flutter/packages@14341d1...ea35fc6
2024-07-10 737941+loic-sharma@users.noreply.github.com [camera_avfoundation] Adds Swift Package Manager compatibility (flutter/packages#7080)
2024-07-10 737941+loic-sharma@users.noreply.github.com [webview_flutter_wkwebview] Adds Swift Package Manager compatibility (flutter/packages#7091)
2024-07-10 contact@thaun.dev [webview_flutter_web] Migrate to package:web. (flutter/packages#6792)
2024-07-10 stuartmorgan@google.com [camera] Clean up `maxDuration` code (flutter/packages#7039)
2024-07-10 reidbaker@google.com Update espresso dependencies (flutter/packages#7048)
2024-07-09 stuartmorgan@google.com [camera] Fix iOS torch mode regression (flutter/packages#7085)
2024-07-09 stuartmorgan@google.com [google_maps_flutter] Convert Obj-C->Dart calls to Pigeon (flutter/packages#7086)
2024-07-09 engine-flutter-autoroll@skia.org Roll Flutter from fafd67d to 5103d75 (27 revisions) (flutter/packages#7084)
2024-07-09 30872003+misos1@users.noreply.github.com [camera_avfoundation] fix sample times not being numeric after pause/resume. (flutter/packages#6897)
2024-07-09 stuartmorgan@google.com [camera] Convert Windows to Pigeon (flutter/packages#6925)
2024-07-09 stuartmorgan@google.com [camera] Deprecate `maxDuration` in platform interface (flutter/packages#7078)
2024-07-09 stuartmorgan@google.com [google_maps_flutter] Semi-convert remaining iOS host API calls to Pigeon (flutter/packages#7079)
2024-07-09 stuartmorgan@google.com [path_provider] Remove `win32` (flutter/packages#7073)
2024-07-08 stuartmorgan@google.com [google_maps_flutter] Move iOS inspector to Pigeon (flutter/packages#6937)
2024-07-08 49699333+dependabot[bot]@users.noreply.github.com [camera]: Bump com.android.tools.build:gradle from 7.3.0 to 8.5.0 in /packages/camera/camera_android_camerax/android (flutter/packages#7072)
2024-07-08 49699333+dependabot[bot]@users.noreply.github.com [local_auth]: Bump com.android.tools.build:gradle from 7.3.1 to 8.5.0 in /packages/local_auth/local_auth_android/android (flutter/packages#7069)
If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human
is aware of the problem.
To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose
To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622
Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
Replaces all of the manual method channel code in `camera_windows` with Pigeon.
I attempted to change the structure as little as possible, since this was already a large change. I don't particularly like the way the native result callback objects are managed (passed to `Camera` and tracked in a map), but I decided that redesigning that would be out of scope and introduced a `std::variant` to allow minimal changes to that structure. That does slightly undermine the type safety of the callbacks, but it's still strictly enforced at the level of the helpers that interact with the map.
Fixesflutter/flutter#117905
bisor0627 pushed a commit to bisor0627/packages that referenced this pull request Jun 19, 2026
Replaces all of the manual method channel code in `camera_windows` with Pigeon.
I attempted to change the structure as little as possible, since this was already a large change. I don't particularly like the way the native result callback objects are managed (passed to `Camera` and tracked in a map), but I decided that redesigning that would be out of scope and introduced a `std::variant` to allow minimal changes to that structure. That does slightly undermine the type safety of the callbacks, but it's still strictly enforced at the level of the helpers that interact with the map.
Fixesflutter/flutter#117905
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmitMerge PR when tree becomes green via auto submit Appp: cameraplatform-windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[camera] Convert to Pigeon

2 participants

@stuartmorgan-g@cbracken