diff --git a/packages/camera/camera_windows/windows/messages.g.cpp b/packages/camera/camera_windows/windows/messages.g.cpp index c2824f5fab7e..01bd140708ce 100644 --- a/packages/camera/camera_windows/windows/messages.g.cpp +++ b/packages/camera/camera_windows/windows/messages.g.cpp @@ -25,106 +25,104 @@ using flutter::EncodableMap; using flutter::EncodableValue; FlutterError CreateConnectionError(const std::string channel_name) { - return FlutterError( - "channel-error", - "Unable to establish connection on channel: '" + channel_name + "'.", - EncodableValue("")); + return FlutterError( + "channel-error", + "Unable to establish connection on channel: '" + channel_name + "'.", + EncodableValue("")); } // PlatformMediaSettings PlatformMediaSettings::PlatformMediaSettings( - const PlatformResolutionPreset& resolution_preset, bool enable_audio) - : resolution_preset_(resolution_preset), enable_audio_(enable_audio) {} + const PlatformResolutionPreset& resolution_preset, + bool enable_audio) + : resolution_preset_(resolution_preset), + enable_audio_(enable_audio) {} PlatformMediaSettings::PlatformMediaSettings( - const PlatformResolutionPreset& resolution_preset, - const int64_t* frames_per_second, const int64_t* video_bitrate, - const int64_t* audio_bitrate, bool enable_audio) - : resolution_preset_(resolution_preset), - frames_per_second_(frames_per_second - ? std::optional(*frames_per_second) - : std::nullopt), - video_bitrate_(video_bitrate ? std::optional(*video_bitrate) - : std::nullopt), - audio_bitrate_(audio_bitrate ? std::optional(*audio_bitrate) - : std::nullopt), - enable_audio_(enable_audio) {} - -const PlatformResolutionPreset& PlatformMediaSettings::resolution_preset() - const { + const PlatformResolutionPreset& resolution_preset, + const int64_t* frames_per_second, + const int64_t* video_bitrate, + const int64_t* audio_bitrate, + bool enable_audio) + : resolution_preset_(resolution_preset), + frames_per_second_(frames_per_second ? std::optional(*frames_per_second) : std::nullopt), + video_bitrate_(video_bitrate ? std::optional(*video_bitrate) : std::nullopt), + audio_bitrate_(audio_bitrate ? std::optional(*audio_bitrate) : std::nullopt), + enable_audio_(enable_audio) {} + +const PlatformResolutionPreset& PlatformMediaSettings::resolution_preset() const { return resolution_preset_; } -void PlatformMediaSettings::set_resolution_preset( - const PlatformResolutionPreset& value_arg) { +void PlatformMediaSettings::set_resolution_preset(const PlatformResolutionPreset& value_arg) { resolution_preset_ = value_arg; } + const int64_t* PlatformMediaSettings::frames_per_second() const { return frames_per_second_ ? &(*frames_per_second_) : nullptr; } void PlatformMediaSettings::set_frames_per_second(const int64_t* value_arg) { - frames_per_second_ = - value_arg ? std::optional(*value_arg) : std::nullopt; + frames_per_second_ = value_arg ? std::optional(*value_arg) : std::nullopt; } void PlatformMediaSettings::set_frames_per_second(int64_t value_arg) { frames_per_second_ = value_arg; } + const int64_t* PlatformMediaSettings::video_bitrate() const { return video_bitrate_ ? &(*video_bitrate_) : nullptr; } void PlatformMediaSettings::set_video_bitrate(const int64_t* value_arg) { - video_bitrate_ = - value_arg ? std::optional(*value_arg) : std::nullopt; + video_bitrate_ = value_arg ? std::optional(*value_arg) : std::nullopt; } void PlatformMediaSettings::set_video_bitrate(int64_t value_arg) { video_bitrate_ = value_arg; } + const int64_t* PlatformMediaSettings::audio_bitrate() const { return audio_bitrate_ ? &(*audio_bitrate_) : nullptr; } void PlatformMediaSettings::set_audio_bitrate(const int64_t* value_arg) { - audio_bitrate_ = - value_arg ? std::optional(*value_arg) : std::nullopt; + audio_bitrate_ = value_arg ? std::optional(*value_arg) : std::nullopt; } void PlatformMediaSettings::set_audio_bitrate(int64_t value_arg) { audio_bitrate_ = value_arg; } -bool PlatformMediaSettings::enable_audio() const { return enable_audio_; } + +bool PlatformMediaSettings::enable_audio() const { + return enable_audio_; +} void PlatformMediaSettings::set_enable_audio(bool value_arg) { enable_audio_ = value_arg; } + EncodableList PlatformMediaSettings::ToEncodableList() const { EncodableList list; list.reserve(5); list.push_back(CustomEncodableValue(resolution_preset_)); - list.push_back(frames_per_second_ ? EncodableValue(*frames_per_second_) - : EncodableValue()); - list.push_back(video_bitrate_ ? EncodableValue(*video_bitrate_) - : EncodableValue()); - list.push_back(audio_bitrate_ ? EncodableValue(*audio_bitrate_) - : EncodableValue()); + list.push_back(frames_per_second_ ? EncodableValue(*frames_per_second_) : EncodableValue()); + list.push_back(video_bitrate_ ? EncodableValue(*video_bitrate_) : EncodableValue()); + list.push_back(audio_bitrate_ ? EncodableValue(*audio_bitrate_) : EncodableValue()); list.push_back(EncodableValue(enable_audio_)); return list; } -PlatformMediaSettings PlatformMediaSettings::FromEncodableList( - const EncodableList& list) { - PlatformMediaSettings decoded(std::any_cast( - std::get(list[0])), - std::get(list[4])); +PlatformMediaSettings PlatformMediaSettings::FromEncodableList(const EncodableList& list) { + PlatformMediaSettings decoded( + std::any_cast(std::get(list[0])), + std::get(list[4])); auto& encodable_frames_per_second = list[1]; if (!encodable_frames_per_second.IsNull()) { decoded.set_frames_per_second(encodable_frames_per_second.LongValue()); @@ -142,16 +140,29 @@ PlatformMediaSettings PlatformMediaSettings::FromEncodableList( // PlatformSize -PlatformSize::PlatformSize(double width, double height) - : width_(width), height_(height) {} +PlatformSize::PlatformSize( + double width, + double height) + : width_(width), + height_(height) {} + +double PlatformSize::width() const { + return width_; +} + +void PlatformSize::set_width(double value_arg) { + width_ = value_arg; +} -double PlatformSize::width() const { return width_; } -void PlatformSize::set_width(double value_arg) { width_ = value_arg; } +double PlatformSize::height() const { + return height_; +} -double PlatformSize::height() const { return height_; } +void PlatformSize::set_height(double value_arg) { + height_ = value_arg; +} -void PlatformSize::set_height(double value_arg) { height_ = value_arg; } EncodableList PlatformSize::ToEncodableList() const { EncodableList list; @@ -162,60 +173,51 @@ EncodableList PlatformSize::ToEncodableList() const { } PlatformSize PlatformSize::FromEncodableList(const EncodableList& list) { - PlatformSize decoded(std::get(list[0]), std::get(list[1])); + PlatformSize decoded( + std::get(list[0]), + std::get(list[1])); return decoded; } + PigeonCodecSerializer::PigeonCodecSerializer() {} EncodableValue PigeonCodecSerializer::ReadValueOfType( - uint8_t type, flutter::ByteStreamReader* stream) const { + uint8_t type, + flutter::ByteStreamReader* stream) const { switch (type) { case 129: - return CustomEncodableValue(PlatformMediaSettings::FromEncodableList( - std::get(ReadValue(stream)))); + return CustomEncodableValue(PlatformMediaSettings::FromEncodableList(std::get(ReadValue(stream)))); case 130: - return CustomEncodableValue(PlatformSize::FromEncodableList( - std::get(ReadValue(stream)))); - case 131: { - const auto& encodable_enum_arg = ReadValue(stream); - const int64_t enum_arg_value = - encodable_enum_arg.IsNull() ? 0 : encodable_enum_arg.LongValue(); - return encodable_enum_arg.IsNull() - ? EncodableValue() - : CustomEncodableValue( - static_cast(enum_arg_value)); - } + return CustomEncodableValue(PlatformSize::FromEncodableList(std::get(ReadValue(stream)))); + case 131: + { + const auto& encodable_enum_arg = ReadValue(stream); + const int64_t enum_arg_value = encodable_enum_arg.IsNull() ? 0 : encodable_enum_arg.LongValue(); + return encodable_enum_arg.IsNull() ? EncodableValue() : CustomEncodableValue(static_cast(enum_arg_value)); + } default: return flutter::StandardCodecSerializer::ReadValueOfType(type, stream); - } + } } void PigeonCodecSerializer::WriteValue( - const EncodableValue& value, flutter::ByteStreamWriter* stream) const { - if (const CustomEncodableValue* custom_value = - std::get_if(&value)) { + const EncodableValue& value, + flutter::ByteStreamWriter* stream) const { + if (const CustomEncodableValue* custom_value = std::get_if(&value)) { if (custom_value->type() == typeid(PlatformMediaSettings)) { stream->WriteByte(129); - WriteValue( - EncodableValue(std::any_cast(*custom_value) - .ToEncodableList()), - stream); + WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); return; } if (custom_value->type() == typeid(PlatformSize)) { stream->WriteByte(130); - WriteValue( - EncodableValue( - std::any_cast(*custom_value).ToEncodableList()), - stream); + WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); return; } if (custom_value->type() == typeid(PlatformResolutionPreset)) { stream->WriteByte(131); - WriteValue(EncodableValue(static_cast( - std::any_cast(*custom_value))), - stream); + WriteValue(EncodableValue(static_cast(std::any_cast(*custom_value))), stream); return; } } @@ -224,417 +226,333 @@ void PigeonCodecSerializer::WriteValue( /// The codec used by CameraApi. const flutter::StandardMessageCodec& CameraApi::GetCodec() { - return flutter::StandardMessageCodec::GetInstance( - &PigeonCodecSerializer::GetInstance()); + return flutter::StandardMessageCodec::GetInstance(&PigeonCodecSerializer::GetInstance()); } -// Sets up an instance of `CameraApi` to handle messages through the -// `binary_messenger`. -void CameraApi::SetUp(flutter::BinaryMessenger* binary_messenger, - CameraApi* api) { +// Sets up an instance of `CameraApi` to handle messages through the `binary_messenger`. +void CameraApi::SetUp( + flutter::BinaryMessenger* binary_messenger, + CameraApi* api) { CameraApi::SetUp(binary_messenger, api, ""); } -void CameraApi::SetUp(flutter::BinaryMessenger* binary_messenger, - CameraApi* api, - const std::string& message_channel_suffix) { - const std::string prepended_suffix = - message_channel_suffix.length() > 0 - ? std::string(".") + message_channel_suffix - : ""; +void CameraApi::SetUp( + flutter::BinaryMessenger* binary_messenger, + CameraApi* api, + const std::string& message_channel_suffix) { + const std::string prepended_suffix = message_channel_suffix.length() > 0 ? std::string(".") + message_channel_suffix : ""; { - BasicMessageChannel<> channel( - binary_messenger, - "dev.flutter.pigeon.camera_windows.CameraApi.getAvailableCameras" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.camera_windows.CameraApi.getAvailableCameras" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - ErrorOr output = api->GetAvailableCameras(); - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + ErrorOr output = api->GetAvailableCameras(); + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel( - binary_messenger, - "dev.flutter.pigeon.camera_windows.CameraApi.create" + prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.camera_windows.CameraApi.create" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_camera_name_arg = args.at(0); - if (encodable_camera_name_arg.IsNull()) { - reply(WrapError("camera_name_arg unexpectedly null.")); - return; - } - const auto& camera_name_arg = - std::get(encodable_camera_name_arg); - const auto& encodable_settings_arg = args.at(1); - if (encodable_settings_arg.IsNull()) { - reply(WrapError("settings_arg unexpectedly null.")); - return; - } - const auto& settings_arg = - std::any_cast( - std::get(encodable_settings_arg)); - api->Create(camera_name_arg, settings_arg, - [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; - wrapped.push_back( - EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_camera_name_arg = args.at(0); + if (encodable_camera_name_arg.IsNull()) { + reply(WrapError("camera_name_arg unexpectedly null.")); + return; + } + const auto& camera_name_arg = std::get(encodable_camera_name_arg); + const auto& encodable_settings_arg = args.at(1); + if (encodable_settings_arg.IsNull()) { + reply(WrapError("settings_arg unexpectedly null.")); + return; + } + const auto& settings_arg = std::any_cast(std::get(encodable_settings_arg)); + api->Create(camera_name_arg, settings_arg, [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; } + EncodableList wrapped; + wrapped.push_back(EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel( - binary_messenger, - "dev.flutter.pigeon.camera_windows.CameraApi.initialize" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.camera_windows.CameraApi.initialize" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_camera_id_arg = args.at(0); - if (encodable_camera_id_arg.IsNull()) { - reply(WrapError("camera_id_arg unexpectedly null.")); - return; - } - const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); - api->Initialize( - camera_id_arg, [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; - wrapped.push_back( - CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_camera_id_arg = args.at(0); + if (encodable_camera_id_arg.IsNull()) { + reply(WrapError("camera_id_arg unexpectedly null.")); + return; + } + const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); + api->Initialize(camera_id_arg, [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; } + EncodableList wrapped; + wrapped.push_back(CustomEncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel( - binary_messenger, - "dev.flutter.pigeon.camera_windows.CameraApi.dispose" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.camera_windows.CameraApi.dispose" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_camera_id_arg = args.at(0); - if (encodable_camera_id_arg.IsNull()) { - reply(WrapError("camera_id_arg unexpectedly null.")); - return; - } - const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); - std::optional output = api->Dispose(camera_id_arg); - if (output.has_value()) { - reply(WrapError(output.value())); - return; - } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_camera_id_arg = args.at(0); + if (encodable_camera_id_arg.IsNull()) { + reply(WrapError("camera_id_arg unexpectedly null.")); + return; + } + const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); + std::optional output = api->Dispose(camera_id_arg); + if (output.has_value()) { + reply(WrapError(output.value())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel( - binary_messenger, - "dev.flutter.pigeon.camera_windows.CameraApi.takePicture" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.camera_windows.CameraApi.takePicture" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_camera_id_arg = args.at(0); - if (encodable_camera_id_arg.IsNull()) { - reply(WrapError("camera_id_arg unexpectedly null.")); - return; - } - const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); - api->TakePicture( - camera_id_arg, [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; - wrapped.push_back( - EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_camera_id_arg = args.at(0); + if (encodable_camera_id_arg.IsNull()) { + reply(WrapError("camera_id_arg unexpectedly null.")); + return; + } + const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); + api->TakePicture(camera_id_arg, [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; } + EncodableList wrapped; + wrapped.push_back(EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel( - binary_messenger, - "dev.flutter.pigeon.camera_windows.CameraApi.startVideoRecording" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.camera_windows.CameraApi.startVideoRecording" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_camera_id_arg = args.at(0); - if (encodable_camera_id_arg.IsNull()) { - reply(WrapError("camera_id_arg unexpectedly null.")); - return; - } - const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); - api->StartVideoRecording( - camera_id_arg, [reply](std::optional&& output) { - if (output.has_value()) { - reply(WrapError(output.value())); - return; - } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_camera_id_arg = args.at(0); + if (encodable_camera_id_arg.IsNull()) { + reply(WrapError("camera_id_arg unexpectedly null.")); + return; + } + const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); + api->StartVideoRecording(camera_id_arg, [reply](std::optional&& output) { + if (output.has_value()) { + reply(WrapError(output.value())); + return; } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel( - binary_messenger, - "dev.flutter.pigeon.camera_windows.CameraApi.stopVideoRecording" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.camera_windows.CameraApi.stopVideoRecording" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_camera_id_arg = args.at(0); - if (encodable_camera_id_arg.IsNull()) { - reply(WrapError("camera_id_arg unexpectedly null.")); - return; - } - const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); - api->StopVideoRecording( - camera_id_arg, [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; - wrapped.push_back( - EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_camera_id_arg = args.at(0); + if (encodable_camera_id_arg.IsNull()) { + reply(WrapError("camera_id_arg unexpectedly null.")); + return; + } + const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); + api->StopVideoRecording(camera_id_arg, [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; } + EncodableList wrapped; + wrapped.push_back(EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel( - binary_messenger, - "dev.flutter.pigeon.camera_windows.CameraApi.startImageStream" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.camera_windows.CameraApi.startImageStream" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_camera_id_arg = args.at(0); - if (encodable_camera_id_arg.IsNull()) { - reply(WrapError("camera_id_arg unexpectedly null.")); - return; - } - const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); - api->StartImageStream( - camera_id_arg, [reply](std::optional&& output) { - if (output.has_value()) { - reply(WrapError(output.value())); - return; - } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_camera_id_arg = args.at(0); + if (encodable_camera_id_arg.IsNull()) { + reply(WrapError("camera_id_arg unexpectedly null.")); + return; + } + const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); + api->StartImageStream(camera_id_arg, [reply](std::optional&& output) { + if (output.has_value()) { + reply(WrapError(output.value())); + return; } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel( - binary_messenger, - "dev.flutter.pigeon.camera_windows.CameraApi.stopImageStream" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.camera_windows.CameraApi.stopImageStream" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_camera_id_arg = args.at(0); - if (encodable_camera_id_arg.IsNull()) { - reply(WrapError("camera_id_arg unexpectedly null.")); - return; - } - const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); - api->StopImageStream( - camera_id_arg, [reply](std::optional&& output) { - if (output.has_value()) { - reply(WrapError(output.value())); - return; - } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_camera_id_arg = args.at(0); + if (encodable_camera_id_arg.IsNull()) { + reply(WrapError("camera_id_arg unexpectedly null.")); + return; + } + const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); + api->StopImageStream(camera_id_arg, [reply](std::optional&& output) { + if (output.has_value()) { + reply(WrapError(output.value())); + return; } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel( - binary_messenger, - "dev.flutter.pigeon.camera_windows.CameraApi.pausePreview" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.camera_windows.CameraApi.pausePreview" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_camera_id_arg = args.at(0); - if (encodable_camera_id_arg.IsNull()) { - reply(WrapError("camera_id_arg unexpectedly null.")); - return; - } - const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); - api->PausePreview(camera_id_arg, - [reply](std::optional&& output) { - if (output.has_value()) { - reply(WrapError(output.value())); - return; - } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_camera_id_arg = args.at(0); + if (encodable_camera_id_arg.IsNull()) { + reply(WrapError("camera_id_arg unexpectedly null.")); + return; + } + const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); + api->PausePreview(camera_id_arg, [reply](std::optional&& output) { + if (output.has_value()) { + reply(WrapError(output.value())); + return; } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel( - binary_messenger, - "dev.flutter.pigeon.camera_windows.CameraApi.resumePreview" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.camera_windows.CameraApi.resumePreview" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_camera_id_arg = args.at(0); - if (encodable_camera_id_arg.IsNull()) { - reply(WrapError("camera_id_arg unexpectedly null.")); - return; - } - const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); - api->ResumePreview(camera_id_arg, - [reply](std::optional&& output) { - if (output.has_value()) { - reply(WrapError(output.value())); - return; - } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_camera_id_arg = args.at(0); + if (encodable_camera_id_arg.IsNull()) { + reply(WrapError("camera_id_arg unexpectedly null.")); + return; + } + const int64_t camera_id_arg = encodable_camera_id_arg.LongValue(); + api->ResumePreview(camera_id_arg, [reply](std::optional&& output) { + if (output.has_value()) { + reply(WrapError(output.value())); + return; } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } @@ -642,15 +560,19 @@ void CameraApi::SetUp(flutter::BinaryMessenger* binary_messenger, } EncodableValue CameraApi::WrapError(std::string_view error_message) { - return EncodableValue( - EncodableList{EncodableValue(std::string(error_message)), - EncodableValue("Error"), EncodableValue()}); + return EncodableValue(EncodableList{ + EncodableValue(std::string(error_message)), + EncodableValue("Error"), + EncodableValue() + }); } EncodableValue CameraApi::WrapError(const FlutterError& error) { - return EncodableValue(EncodableList{EncodableValue(error.code()), - EncodableValue(error.message()), - error.details()}); + return EncodableValue(EncodableList{ + EncodableValue(error.code()), + EncodableValue(error.message()), + error.details() + }); } } // namespace camera_windows diff --git a/packages/camera/camera_windows/windows/messages.g.h b/packages/camera/camera_windows/windows/messages.g.h index 772aa3c6200d..81ddae51edde 100644 --- a/packages/camera/camera_windows/windows/messages.g.h +++ b/packages/camera/camera_windows/windows/messages.g.h @@ -147,32 +147,6 @@ class PlatformSize { }; - -// Pigeon version of the relevant subset of VideoCaptureOptions. -// -// Generated class from Pigeon that represents data sent in messages. -class PlatformVideoCaptureOptions { - public: - // Constructs an object setting all non-nullable fields. - PlatformVideoCaptureOptions(); - - // Constructs an object setting all fields. - explicit PlatformVideoCaptureOptions(const int64_t* max_duration_milliseconds); - - const int64_t* max_duration_milliseconds() const; - void set_max_duration_milliseconds(const int64_t* value_arg); - void set_max_duration_milliseconds(int64_t value_arg); - - - private: - static PlatformVideoCaptureOptions FromEncodableList(const flutter::EncodableList& list); - flutter::EncodableList ToEncodableList() const; - friend class CameraApi; - friend class PigeonCodecSerializer; - std::optional max_duration_milliseconds_; - -}; - class PigeonCodecSerializer : public flutter::StandardCodecSerializer { public: PigeonCodecSerializer(); @@ -219,7 +193,6 @@ class CameraApi { // Starts recording video with the given camera. virtual void StartVideoRecording( int64_t camera_id, - const PlatformVideoCaptureOptions& options, std::function reply)> result) = 0; // Finishes recording video with the given camera, and returns the path to // the resulting file.