// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_CREATE_MESSAGE_H_ #define PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_CREATE_MESSAGE_H_ #include #include class CreateMessage { public: CreateMessage() = default; ~CreateMessage() = default; // Prevent copying. CreateMessage(CreateMessage const&) = default; CreateMessage& operator=(CreateMessage const&) = default; void SetAsset(const std::string& asset) { asset_ = asset; } std::string GetAsset() const { return asset_; } void SetUri(const std::string& uri) { uri_ = uri; } std::string GetUri() const { return uri_; } void SetPackageName(const std::string& packageName) { package_name_ = packageName; } std::string GetPackageName() const { return package_name_; } void SetFormatHint(const std::string& formatHint) { format_hint_ = formatHint; } std::string GetFormatHint() const { return format_hint_; } flutter::EncodableValue ToMap() { // todo: Add httpHeaders. flutter::EncodableMap map = { {flutter::EncodableValue("asset"), flutter::EncodableValue(asset_)}, {flutter::EncodableValue("uri"), flutter::EncodableValue(uri_)}, {flutter::EncodableValue("packageName"), flutter::EncodableValue(package_name_)}, {flutter::EncodableValue("formatHint"), flutter::EncodableValue(format_hint_)}}; return flutter::EncodableValue(map); } static CreateMessage FromMap(const flutter::EncodableValue& value) { CreateMessage message; if (std::holds_alternative(value)) { auto map = std::get(value); flutter::EncodableValue& asset = map[flutter::EncodableValue("asset")]; if (std::holds_alternative(asset)) { message.SetAsset(std::get(asset)); } flutter::EncodableValue& uri = map[flutter::EncodableValue("uri")]; if (std::holds_alternative(uri)) { message.SetUri(std::get(uri)); } flutter::EncodableValue& packageName = map[flutter::EncodableValue("packageName")]; if (std::holds_alternative(packageName)) { message.SetPackageName(std::get(packageName)); } flutter::EncodableValue& formatHint = map[flutter::EncodableValue("formatHint")]; if (std::holds_alternative(formatHint)) { message.SetFormatHint(std::get(formatHint)); } } return message; } private: std::string asset_; std::string uri_; std::string package_name_; std::string format_hint_; }; #endif // PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_CREATE_MESSAGE_H_