diff --git a/packages/video_player/CHANGELOG.md b/packages/video_player/CHANGELOG.md index bdfd2b6e5..0b8256b54 100644 --- a/packages/video_player/CHANGELOG.md +++ b/packages/video_player/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.4.3 + +* Migrate to in-package pigeon-generated code. + ## 2.4.2 * Add a queue for storing decoded media packet. diff --git a/packages/video_player/README.md b/packages/video_player/README.md index 4aa9516f1..43d45bafb 100644 --- a/packages/video_player/README.md +++ b/packages/video_player/README.md @@ -29,7 +29,7 @@ This package is not an _endorsed_ implementation of `video_player`. Therefore, y ```yaml dependencies: video_player: ^2.4.2 - video_player_tizen: ^2.4.2 + video_player_tizen: ^2.4.3 ``` Then you can import `video_player` in your Dart code: diff --git a/packages/video_player/lib/src/messages.g.dart b/packages/video_player/lib/src/messages.g.dart new file mode 100644 index 000000000..f05279230 --- /dev/null +++ b/packages/video_player/lib/src/messages.g.dart @@ -0,0 +1,533 @@ +// Autogenerated from Pigeon (v4.2.9), do not edit directly. +// See also: https://pub.dev/packages/pigeon +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import +import 'dart:async'; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; + +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; +import 'package:flutter/services.dart'; + +class TextureMessage { + TextureMessage({ + required this.textureId, + }); + + int textureId; + + Object encode() { + final Map pigeonMap = {}; + pigeonMap['textureId'] = textureId; + return pigeonMap; + } + + static TextureMessage decode(Object message) { + final Map pigeonMap = message as Map; + return TextureMessage( + textureId: pigeonMap['textureId']! as int, + ); + } +} + +class LoopingMessage { + LoopingMessage({ + required this.textureId, + required this.isLooping, + }); + + int textureId; + bool isLooping; + + Object encode() { + final Map pigeonMap = {}; + pigeonMap['textureId'] = textureId; + pigeonMap['isLooping'] = isLooping; + return pigeonMap; + } + + static LoopingMessage decode(Object message) { + final Map pigeonMap = message as Map; + return LoopingMessage( + textureId: pigeonMap['textureId']! as int, + isLooping: pigeonMap['isLooping']! as bool, + ); + } +} + +class VolumeMessage { + VolumeMessage({ + required this.textureId, + required this.volume, + }); + + int textureId; + double volume; + + Object encode() { + final Map pigeonMap = {}; + pigeonMap['textureId'] = textureId; + pigeonMap['volume'] = volume; + return pigeonMap; + } + + static VolumeMessage decode(Object message) { + final Map pigeonMap = message as Map; + return VolumeMessage( + textureId: pigeonMap['textureId']! as int, + volume: pigeonMap['volume']! as double, + ); + } +} + +class PlaybackSpeedMessage { + PlaybackSpeedMessage({ + required this.textureId, + required this.speed, + }); + + int textureId; + double speed; + + Object encode() { + final Map pigeonMap = {}; + pigeonMap['textureId'] = textureId; + pigeonMap['speed'] = speed; + return pigeonMap; + } + + static PlaybackSpeedMessage decode(Object message) { + final Map pigeonMap = message as Map; + return PlaybackSpeedMessage( + textureId: pigeonMap['textureId']! as int, + speed: pigeonMap['speed']! as double, + ); + } +} + +class PositionMessage { + PositionMessage({ + required this.textureId, + required this.position, + }); + + int textureId; + int position; + + Object encode() { + final Map pigeonMap = {}; + pigeonMap['textureId'] = textureId; + pigeonMap['position'] = position; + return pigeonMap; + } + + static PositionMessage decode(Object message) { + final Map pigeonMap = message as Map; + return PositionMessage( + textureId: pigeonMap['textureId']! as int, + position: pigeonMap['position']! as int, + ); + } +} + +class CreateMessage { + CreateMessage({ + this.asset, + this.uri, + this.packageName, + this.formatHint, + required this.httpHeaders, + }); + + String? asset; + String? uri; + String? packageName; + String? formatHint; + Map httpHeaders; + + Object encode() { + final Map pigeonMap = {}; + pigeonMap['asset'] = asset; + pigeonMap['uri'] = uri; + pigeonMap['packageName'] = packageName; + pigeonMap['formatHint'] = formatHint; + pigeonMap['httpHeaders'] = httpHeaders; + return pigeonMap; + } + + static CreateMessage decode(Object message) { + final Map pigeonMap = message as Map; + return CreateMessage( + asset: pigeonMap['asset'] as String?, + uri: pigeonMap['uri'] as String?, + packageName: pigeonMap['packageName'] as String?, + formatHint: pigeonMap['formatHint'] as String?, + httpHeaders: (pigeonMap['httpHeaders'] as Map?)! + .cast(), + ); + } +} + +class MixWithOthersMessage { + MixWithOthersMessage({ + required this.mixWithOthers, + }); + + bool mixWithOthers; + + Object encode() { + final Map pigeonMap = {}; + pigeonMap['mixWithOthers'] = mixWithOthers; + return pigeonMap; + } + + static MixWithOthersMessage decode(Object message) { + final Map pigeonMap = message as Map; + return MixWithOthersMessage( + mixWithOthers: pigeonMap['mixWithOthers']! as bool, + ); + } +} + +class _TizenVideoPlayerApiCodec extends StandardMessageCodec { + const _TizenVideoPlayerApiCodec(); + @override + void writeValue(WriteBuffer buffer, Object? value) { + if (value is CreateMessage) { + buffer.putUint8(128); + writeValue(buffer, value.encode()); + } else if (value is LoopingMessage) { + buffer.putUint8(129); + writeValue(buffer, value.encode()); + } else if (value is MixWithOthersMessage) { + buffer.putUint8(130); + writeValue(buffer, value.encode()); + } else if (value is PlaybackSpeedMessage) { + buffer.putUint8(131); + writeValue(buffer, value.encode()); + } else if (value is PositionMessage) { + buffer.putUint8(132); + writeValue(buffer, value.encode()); + } else if (value is TextureMessage) { + buffer.putUint8(133); + writeValue(buffer, value.encode()); + } else if (value is VolumeMessage) { + buffer.putUint8(134); + writeValue(buffer, value.encode()); + } else { + super.writeValue(buffer, value); + } + } + + @override + Object? readValueOfType(int type, ReadBuffer buffer) { + switch (type) { + case 128: + return CreateMessage.decode(readValue(buffer)!); + + case 129: + return LoopingMessage.decode(readValue(buffer)!); + + case 130: + return MixWithOthersMessage.decode(readValue(buffer)!); + + case 131: + return PlaybackSpeedMessage.decode(readValue(buffer)!); + + case 132: + return PositionMessage.decode(readValue(buffer)!); + + case 133: + return TextureMessage.decode(readValue(buffer)!); + + case 134: + return VolumeMessage.decode(readValue(buffer)!); + + default: + return super.readValueOfType(type, buffer); + } + } +} + +class TizenVideoPlayerApi { + /// Constructor for [TizenVideoPlayerApi]. The [binaryMessenger] named argument is + /// available for dependency injection. If it is left null, the default + /// BinaryMessenger will be used which routes to the host platform. + TizenVideoPlayerApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; + final BinaryMessenger? _binaryMessenger; + + static const MessageCodec codec = _TizenVideoPlayerApiCodec(); + + Future initialize() async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.TizenVideoPlayerApi.initialize', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send(null) as Map?; + if (replyMap == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyMap['error'] != null) { + final Map error = + (replyMap['error'] as Map?)!; + throw PlatformException( + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], + ); + } else { + return; + } + } + + Future create(CreateMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.TizenVideoPlayerApi.create', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_msg]) as Map?; + if (replyMap == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyMap['error'] != null) { + final Map error = + (replyMap['error'] as Map?)!; + throw PlatformException( + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], + ); + } else if (replyMap['result'] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (replyMap['result'] as TextureMessage?)!; + } + } + + Future dispose(TextureMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.TizenVideoPlayerApi.dispose', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_msg]) as Map?; + if (replyMap == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyMap['error'] != null) { + final Map error = + (replyMap['error'] as Map?)!; + throw PlatformException( + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], + ); + } else { + return; + } + } + + Future setLooping(LoopingMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.TizenVideoPlayerApi.setLooping', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_msg]) as Map?; + if (replyMap == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyMap['error'] != null) { + final Map error = + (replyMap['error'] as Map?)!; + throw PlatformException( + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], + ); + } else { + return; + } + } + + Future setVolume(VolumeMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.TizenVideoPlayerApi.setVolume', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_msg]) as Map?; + if (replyMap == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyMap['error'] != null) { + final Map error = + (replyMap['error'] as Map?)!; + throw PlatformException( + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], + ); + } else { + return; + } + } + + Future setPlaybackSpeed(PlaybackSpeedMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.TizenVideoPlayerApi.setPlaybackSpeed', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_msg]) as Map?; + if (replyMap == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyMap['error'] != null) { + final Map error = + (replyMap['error'] as Map?)!; + throw PlatformException( + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], + ); + } else { + return; + } + } + + Future play(TextureMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.TizenVideoPlayerApi.play', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_msg]) as Map?; + if (replyMap == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyMap['error'] != null) { + final Map error = + (replyMap['error'] as Map?)!; + throw PlatformException( + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], + ); + } else { + return; + } + } + + Future position(TextureMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.TizenVideoPlayerApi.position', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_msg]) as Map?; + if (replyMap == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyMap['error'] != null) { + final Map error = + (replyMap['error'] as Map?)!; + throw PlatformException( + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], + ); + } else if (replyMap['result'] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (replyMap['result'] as PositionMessage?)!; + } + } + + Future seekTo(PositionMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.TizenVideoPlayerApi.seekTo', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_msg]) as Map?; + if (replyMap == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyMap['error'] != null) { + final Map error = + (replyMap['error'] as Map?)!; + throw PlatformException( + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], + ); + } else { + return; + } + } + + Future pause(TextureMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.TizenVideoPlayerApi.pause', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_msg]) as Map?; + if (replyMap == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyMap['error'] != null) { + final Map error = + (replyMap['error'] as Map?)!; + throw PlatformException( + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], + ); + } else { + return; + } + } + + Future setMixWithOthers(MixWithOthersMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.TizenVideoPlayerApi.setMixWithOthers', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_msg]) as Map?; + if (replyMap == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyMap['error'] != null) { + final Map error = + (replyMap['error'] as Map?)!; + throw PlatformException( + code: (error['code'] as String?)!, + message: error['message'] as String?, + details: error['details'], + ); + } else { + return; + } + } +} diff --git a/packages/video_player/lib/video_player_tizen.dart b/packages/video_player/lib/video_player_tizen.dart new file mode 100644 index 000000000..4867fd6b8 --- /dev/null +++ b/packages/video_player/lib/video_player_tizen.dart @@ -0,0 +1,186 @@ +// 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. + +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; +import 'package:video_player_platform_interface/video_player_platform_interface.dart'; + +import 'src/messages.g.dart'; + +/// A Tizen implementation of [VideoPlayerPlatform] that uses the +/// Pigeon-generated [TizenVideoPlayerApi]. +class VideoPlayerTizen extends VideoPlayerPlatform { + final TizenVideoPlayerApi _api = TizenVideoPlayerApi(); + + /// Registers this class as the default platform instance. + static void register() { + VideoPlayerPlatform.instance = VideoPlayerTizen(); + } + + @override + Future init() { + return _api.initialize(); + } + + @override + Future dispose(int textureId) { + return _api.dispose(TextureMessage(textureId: textureId)); + } + + @override + Future create(DataSource dataSource) async { + String? asset; + String? packageName; + String? uri; + String? formatHint; + Map httpHeaders = {}; + switch (dataSource.sourceType) { + case DataSourceType.asset: + asset = dataSource.asset; + packageName = dataSource.package; + break; + case DataSourceType.network: + uri = dataSource.uri; + formatHint = _videoFormatStringMap[dataSource.formatHint]; + httpHeaders = dataSource.httpHeaders; + break; + case DataSourceType.file: + uri = dataSource.uri; + break; + case DataSourceType.contentUri: + uri = dataSource.uri; + break; + } + final CreateMessage message = CreateMessage( + asset: asset, + packageName: packageName, + uri: uri, + httpHeaders: httpHeaders, + formatHint: formatHint, + ); + + final TextureMessage response = await _api.create(message); + return response.textureId; + } + + @override + Future setLooping(int textureId, bool looping) { + return _api.setLooping(LoopingMessage( + textureId: textureId, + isLooping: looping, + )); + } + + @override + Future play(int textureId) { + return _api.play(TextureMessage(textureId: textureId)); + } + + @override + Future pause(int textureId) { + return _api.pause(TextureMessage(textureId: textureId)); + } + + @override + Future setVolume(int textureId, double volume) { + return _api.setVolume(VolumeMessage( + textureId: textureId, + volume: volume, + )); + } + + @override + Future setPlaybackSpeed(int textureId, double speed) { + assert(speed > 0); + + return _api.setPlaybackSpeed(PlaybackSpeedMessage( + textureId: textureId, + speed: speed, + )); + } + + @override + Future seekTo(int textureId, Duration position) { + return _api.seekTo(PositionMessage( + textureId: textureId, + position: position.inMilliseconds, + )); + } + + @override + Future getPosition(int textureId) async { + final PositionMessage response = + await _api.position(TextureMessage(textureId: textureId)); + return Duration(milliseconds: response.position); + } + + @override + Stream videoEventsFor(int textureId) { + return _eventChannelFor(textureId) + .receiveBroadcastStream() + .map((dynamic event) { + final Map map = event as Map; + switch (map['event']) { + case 'initialized': + return VideoEvent( + eventType: VideoEventType.initialized, + duration: Duration(milliseconds: map['duration'] as int), + size: Size((map['width'] as num?)?.toDouble() ?? 0.0, + (map['height'] as num?)?.toDouble() ?? 0.0), + rotationCorrection: map['rotationCorrection'] as int? ?? 0, + ); + case 'completed': + return VideoEvent( + eventType: VideoEventType.completed, + ); + case 'bufferingUpdate': + final List values = map['values'] as List; + + return VideoEvent( + buffered: values.map(_toDurationRange).toList(), + eventType: VideoEventType.bufferingUpdate, + ); + case 'bufferingStart': + return VideoEvent(eventType: VideoEventType.bufferingStart); + case 'bufferingEnd': + return VideoEvent(eventType: VideoEventType.bufferingEnd); + default: + return VideoEvent(eventType: VideoEventType.unknown); + } + }); + } + + @override + Widget buildView(int textureId) { + return Texture(textureId: textureId); + } + + @override + Future setMixWithOthers(bool mixWithOthers) { + return _api + .setMixWithOthers(MixWithOthersMessage(mixWithOthers: mixWithOthers)); + } + + EventChannel _eventChannelFor(int textureId) { + return EventChannel('flutter.io/videoPlayer/videoEvents$textureId'); + } + + static const Map _videoFormatStringMap = + { + VideoFormat.ss: 'ss', + VideoFormat.hls: 'hls', + VideoFormat.dash: 'dash', + VideoFormat.other: 'other', + }; + + DurationRange _toDurationRange(dynamic value) { + final List pair = value as List; + return DurationRange( + Duration(milliseconds: pair[0] as int), + Duration(milliseconds: pair[1] as int), + ); + } +} diff --git a/packages/video_player/pigeons/messages.dart b/packages/video_player/pigeons/messages.dart new file mode 100644 index 000000000..837ffbfa8 --- /dev/null +++ b/packages/video_player/pigeons/messages.dart @@ -0,0 +1,69 @@ +// 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. + +import 'package:pigeon/pigeon.dart'; + +@ConfigurePigeon(PigeonOptions( + dartOut: 'lib/src/messages.g.dart', + cppHeaderOut: 'tizen/src/messages.h', + cppSourceOut: 'tizen/src/messages.cc', +)) +class TextureMessage { + TextureMessage(this.textureId); + int textureId; +} + +class LoopingMessage { + LoopingMessage(this.textureId, this.isLooping); + int textureId; + bool isLooping; +} + +class VolumeMessage { + VolumeMessage(this.textureId, this.volume); + int textureId; + double volume; +} + +class PlaybackSpeedMessage { + PlaybackSpeedMessage(this.textureId, this.speed); + int textureId; + double speed; +} + +class PositionMessage { + PositionMessage(this.textureId, this.position); + int textureId; + int position; +} + +class CreateMessage { + CreateMessage({required this.httpHeaders}); + String? asset; + String? uri; + String? packageName; + String? formatHint; + Map httpHeaders; +} + +class MixWithOthersMessage { + MixWithOthersMessage(this.mixWithOthers); + bool mixWithOthers; +} + +@HostApi() +abstract class TizenVideoPlayerApi { + void initialize(); + TextureMessage create(CreateMessage msg); + void dispose(TextureMessage msg); + void setLooping(LoopingMessage msg); + void setVolume(VolumeMessage msg); + void setPlaybackSpeed(PlaybackSpeedMessage msg); + void play(TextureMessage msg); + PositionMessage position(TextureMessage msg); + @async + void seekTo(PositionMessage msg); + void pause(TextureMessage msg); + void setMixWithOthers(MixWithOthersMessage msg); +} diff --git a/packages/video_player/pubspec.yaml b/packages/video_player/pubspec.yaml index 9d8582609..5c45314ee 100644 --- a/packages/video_player/pubspec.yaml +++ b/packages/video_player/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for displaying inline video with other Flutter widgets on Tizen. homepage: https://github.com/flutter-tizen/plugins repository: https://github.com/flutter-tizen/plugins/tree/master/packages/video_player -version: 2.4.2 +version: 2.4.3 flutter: plugin: @@ -11,12 +11,16 @@ flutter: tizen: pluginClass: VideoPlayerTizenPlugin fileName: video_player_tizen_plugin.h + dartPluginClass: VideoPlayerTizen dependencies: flutter: sdk: flutter video_player_platform_interface: ^5.1.2 +dev_dependencies: + pigeon: ^4.2.9 + environment: flutter: ">=2.0.0" sdk: ">=2.12.0<3.0.0" diff --git a/packages/video_player/tizen/src/message.cc b/packages/video_player/tizen/src/message.cc deleted file mode 100644 index 4d102b7d7..000000000 --- a/packages/video_player/tizen/src/message.cc +++ /dev/null @@ -1,523 +0,0 @@ -// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "message.h" - -#include -#include - -int64_t TextureMessage::getTextureId() const { return textureId_; } - -void TextureMessage::setTextureId(int64_t textureId) { textureId_ = textureId; } - -flutter::EncodableValue TextureMessage::toMap() { - flutter::EncodableMap toMapResult = {{flutter::EncodableValue("textureId"), - flutter::EncodableValue(textureId_)}}; - return flutter::EncodableValue(toMapResult); -} - -TextureMessage TextureMessage::fromMap(const flutter::EncodableValue &value) { - TextureMessage fromMapResult; - if (std::holds_alternative(value)) { - flutter::EncodableMap map = std::get(value); - flutter::EncodableValue &textureId = - map[flutter::EncodableValue("textureId")]; - if (std::holds_alternative(textureId) || - std::holds_alternative(textureId)) { - fromMapResult.setTextureId(textureId.LongValue()); - } - } - return fromMapResult; -} - -std::string CreateMessage::getAsset() const { return asset_; } - -void CreateMessage::setAsset(const std::string &asset) { asset_ = asset; } - -std::string CreateMessage::getUri() const { return uri_; } - -void CreateMessage::setUri(const std::string &uri) { uri_ = uri; } - -std::string CreateMessage::getPackageName() const { return packageName_; } - -void CreateMessage::setPackageName(const std::string &packageName) { - packageName_ = packageName; -} - -std::string CreateMessage::getFormatHint() const { return formatHint_; } - -void CreateMessage::setFormatHint(const std::string &formatHint) { - formatHint_ = formatHint; -} - -flutter::EncodableValue CreateMessage::toMap() { - flutter::EncodableMap toMapResult = { - {flutter::EncodableValue("asset"), flutter::EncodableValue(asset_)}, - {flutter::EncodableValue("uri"), flutter::EncodableValue(uri_)}, - {flutter::EncodableValue("packageName"), - flutter::EncodableValue(packageName_)}, - {flutter::EncodableValue("formatHint"), - flutter::EncodableValue(formatHint_)}}; - return flutter::EncodableValue(toMapResult); -} - -CreateMessage CreateMessage::fromMap(const flutter::EncodableValue &value) { - CreateMessage fromMapResult; - if (std::holds_alternative(value)) { - flutter::EncodableMap map = std::get(value); - flutter::EncodableValue &asset = map[flutter::EncodableValue("asset")]; - if (std::holds_alternative(asset)) { - fromMapResult.setAsset(std::get(asset)); - } - - flutter::EncodableValue &uri = map[flutter::EncodableValue("uri")]; - if (std::holds_alternative(uri)) { - fromMapResult.setUri(std::get(uri)); - } - - flutter::EncodableValue &packageName = - map[flutter::EncodableValue("packageName")]; - if (std::holds_alternative(packageName)) { - fromMapResult.setPackageName(std::get(uri)); - } - - flutter::EncodableValue &formatHint = - map[flutter::EncodableValue("formatHint")]; - if (std::holds_alternative(formatHint)) { - fromMapResult.setFormatHint(std::get(formatHint)); - } - } - return fromMapResult; -} - -int64_t LoopingMessage::getTextureId() const { return textureId_; } - -void LoopingMessage::setTextureId(int64_t textureId) { textureId_ = textureId; } - -bool LoopingMessage::getIsLooping() const { return isLooping_; } - -void LoopingMessage::setIsLooping(bool isLooping) { isLooping_ = isLooping; } - -flutter::EncodableValue LoopingMessage::toMap() { - flutter::EncodableMap toMapResult = {{flutter::EncodableValue("textureId"), - flutter::EncodableValue(textureId_)}, - {flutter::EncodableValue("isLooping"), - flutter::EncodableValue(isLooping_)}}; - return flutter::EncodableValue(toMapResult); -} - -LoopingMessage LoopingMessage::fromMap(const flutter::EncodableValue &value) { - LoopingMessage fromMapResult; - if (std::holds_alternative(value)) { - flutter::EncodableMap map = std::get(value); - flutter::EncodableValue &textureId = - map[flutter::EncodableValue("textureId")]; - if (std::holds_alternative(textureId) || - std::holds_alternative(textureId)) { - fromMapResult.setTextureId(textureId.LongValue()); - } - - flutter::EncodableValue &isLooping = - map[flutter::EncodableValue("isLooping")]; - if (std::holds_alternative(isLooping)) { - fromMapResult.setIsLooping(std::get(isLooping)); - } - } - return fromMapResult; -} - -int64_t VolumeMessage::getTextureId() const { return textureId_; } - -void VolumeMessage::setTextureId(int64_t textureId) { textureId_ = textureId; } - -double VolumeMessage::getVolume() const { return volume_; } - -void VolumeMessage::setVolume(double volume) { volume_ = volume; } - -flutter::EncodableValue VolumeMessage::toMap() { - flutter::EncodableMap toMapResult = { - {flutter::EncodableValue("textureId"), - flutter::EncodableValue(textureId_)}, - {flutter::EncodableValue("volume"), flutter::EncodableValue(volume_)}}; - return flutter::EncodableValue(toMapResult); -} - -VolumeMessage VolumeMessage::fromMap(const flutter::EncodableValue &value) { - VolumeMessage fromMapResult; - if (std::holds_alternative(value)) { - flutter::EncodableMap map = std::get(value); - flutter::EncodableValue &textureId = - map[flutter::EncodableValue("textureId")]; - if (std::holds_alternative(textureId) || - std::holds_alternative(textureId)) { - fromMapResult.setTextureId(textureId.LongValue()); - } - - flutter::EncodableValue &volume = map[flutter::EncodableValue("volume")]; - if (std::holds_alternative(volume)) { - fromMapResult.setVolume(std::get(volume)); - } - } - return fromMapResult; -} - -int64_t PlaybackSpeedMessage::getTextureId() const { return textureId_; } - -void PlaybackSpeedMessage::setTextureId(int64_t textureId) { - textureId_ = textureId; -} - -double PlaybackSpeedMessage::getSpeed() const { return speed_; } - -void PlaybackSpeedMessage::setSpeed(double speed) { speed_ = speed; } - -flutter::EncodableValue PlaybackSpeedMessage::toMap() { - flutter::EncodableMap toMapResult = { - {flutter::EncodableValue("textureId"), - flutter::EncodableValue(textureId_)}, - {flutter::EncodableValue("speed"), flutter::EncodableValue(speed_)}}; - return flutter::EncodableValue(toMapResult); -} - -PlaybackSpeedMessage PlaybackSpeedMessage::fromMap( - const flutter::EncodableValue &value) { - PlaybackSpeedMessage fromMapResult; - if (std::holds_alternative(value)) { - flutter::EncodableMap map = std::get(value); - flutter::EncodableValue &textureId = - map[flutter::EncodableValue("textureId")]; - if (std::holds_alternative(textureId) || - std::holds_alternative(textureId)) { - fromMapResult.setTextureId(textureId.LongValue()); - } - - flutter::EncodableValue &speed = map[flutter::EncodableValue("speed")]; - if (std::holds_alternative(speed)) { - fromMapResult.setSpeed(std::get(speed)); - } - } - return fromMapResult; -} - -int64_t PositionMessage::getTextureId() const { return textureId_; } - -void PositionMessage::setTextureId(int64_t textureId) { - textureId_ = textureId; -} - -int64_t PositionMessage::getPosition() const { return position_; } - -void PositionMessage::setPosition(int64_t position) { position_ = position; } - -flutter::EncodableValue PositionMessage::toMap() { - flutter::EncodableMap toMapResult = {{flutter::EncodableValue("textureId"), - flutter::EncodableValue(textureId_)}, - {flutter::EncodableValue("position"), - flutter::EncodableValue(position_)}}; - return flutter::EncodableValue(toMapResult); -} - -PositionMessage PositionMessage::fromMap(const flutter::EncodableValue &value) { - PositionMessage fromMapResult; - if (std::holds_alternative(value)) { - flutter::EncodableMap map = std::get(value); - flutter::EncodableValue &textureId = - map[flutter::EncodableValue("textureId")]; - if (std::holds_alternative(textureId) || - std::holds_alternative(textureId)) { - fromMapResult.setTextureId(textureId.LongValue()); - } - - flutter::EncodableValue &position = - map[flutter::EncodableValue("position")]; - if (std::holds_alternative(position) || - std::holds_alternative(position)) { - fromMapResult.setPosition(position.LongValue()); - } - } - return fromMapResult; -} - -bool MixWithOthersMessage::getMixWithOthers() const { return mixWithOthers_; } - -void MixWithOthersMessage::setMixWithOthers(bool mixWithOthers) { - mixWithOthers_ = mixWithOthers; -} - -flutter::EncodableValue MixWithOthersMessage::toMap() { - flutter::EncodableMap toMapResult = { - {flutter::EncodableValue("mixWithOthers"), - flutter::EncodableValue(mixWithOthers_)}}; - return flutter::EncodableValue(toMapResult); -} - -MixWithOthersMessage MixWithOthersMessage::fromMap( - const flutter::EncodableValue &value) { - MixWithOthersMessage fromMapResult; - if (std::holds_alternative(value)) { - flutter::EncodableMap map = std::get(value); - flutter::EncodableValue &mixWithOthers = - map[flutter::EncodableValue("mixWithOthers")]; - if (std::holds_alternative(mixWithOthers)) { - fromMapResult.setMixWithOthers(std::get(mixWithOthers)); - } - } - return fromMapResult; -} - -void VideoPlayerApi::SetUp(flutter::BinaryMessenger *messenger, - VideoPlayerApi *api) { - auto init_channel = - std::make_unique>( - messenger, "dev.flutter.pigeon.VideoPlayerApi.initialize", - &flutter::StandardMessageCodec::GetInstance()); - if (api != nullptr) { - init_channel->SetMessageHandler( - [api](const flutter::EncodableValue &message, - flutter::MessageReply reply) { - flutter::EncodableMap wrapped; - try { - api->initialize(); - wrapped.emplace(flutter::EncodableValue("result"), - flutter::EncodableValue()); - } catch (const VideoPlayerError &error) { - wrapped.emplace(flutter::EncodableValue("error"), - VideoPlayerApi::WrapError(error)); - } - reply(flutter::EncodableValue(wrapped)); - }); - } - - auto create_channel = - std::make_unique>( - messenger, "dev.flutter.pigeon.VideoPlayerApi.create", - &flutter::StandardMessageCodec::GetInstance()); - if (api != nullptr) { - create_channel->SetMessageHandler( - [api](const flutter::EncodableValue &message, - flutter::MessageReply reply) { - CreateMessage input = CreateMessage::fromMap(message); - flutter::EncodableMap wrapped; - try { - TextureMessage output = api->create(input); - wrapped.emplace(flutter::EncodableValue("result"), output.toMap()); - } catch (const VideoPlayerError &error) { - wrapped.emplace(flutter::EncodableValue("error"), - VideoPlayerApi::WrapError(error)); - } - reply(flutter::EncodableValue(wrapped)); - }); - } - - auto dispose_channel = - std::make_unique>( - messenger, "dev.flutter.pigeon.VideoPlayerApi.dispose", - &flutter::StandardMessageCodec::GetInstance()); - if (api != nullptr) { - dispose_channel->SetMessageHandler( - [api](const flutter::EncodableValue &message, - flutter::MessageReply reply) { - TextureMessage input = TextureMessage::fromMap(message); - flutter::EncodableMap wrapped; - try { - api->dispose(input); - wrapped.emplace(flutter::EncodableValue("result"), - flutter::EncodableValue()); - } catch (const VideoPlayerError &error) { - wrapped.emplace(flutter::EncodableValue("error"), - VideoPlayerApi::WrapError(error)); - } - reply(flutter::EncodableValue(wrapped)); - }); - } - - auto looping_channel = - std::make_unique>( - messenger, "dev.flutter.pigeon.VideoPlayerApi.setLooping", - &flutter::StandardMessageCodec::GetInstance()); - if (api != nullptr) { - looping_channel->SetMessageHandler( - [api](const flutter::EncodableValue &message, - flutter::MessageReply reply) { - LoopingMessage input = LoopingMessage::fromMap(message); - flutter::EncodableMap wrapped; - try { - api->setLooping(input); - wrapped.emplace(flutter::EncodableValue("result"), - flutter::EncodableValue()); - } catch (const VideoPlayerError &error) { - wrapped.emplace(flutter::EncodableValue("error"), - VideoPlayerApi::WrapError(error)); - } - reply(flutter::EncodableValue(wrapped)); - }); - } - - auto volume_channel = - std::make_unique>( - messenger, "dev.flutter.pigeon.VideoPlayerApi.setVolume", - &flutter::StandardMessageCodec::GetInstance()); - if (api != nullptr) { - volume_channel->SetMessageHandler( - [api](const flutter::EncodableValue &message, - flutter::MessageReply reply) { - VolumeMessage input = VolumeMessage::fromMap(message); - flutter::EncodableMap wrapped; - try { - api->setVolume(input); - wrapped.emplace(flutter::EncodableValue("result"), - flutter::EncodableValue()); - } catch (const VideoPlayerError &error) { - wrapped.emplace(flutter::EncodableValue("error"), - VideoPlayerApi::WrapError(error)); - } - reply(flutter::EncodableValue(wrapped)); - }); - } - - auto speed_channel = - std::make_unique>( - messenger, "dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed", - &flutter::StandardMessageCodec::GetInstance()); - if (api != nullptr) { - speed_channel->SetMessageHandler( - [api](const flutter::EncodableValue &message, - flutter::MessageReply reply) { - PlaybackSpeedMessage input = PlaybackSpeedMessage::fromMap(message); - flutter::EncodableMap wrapped; - try { - api->setPlaybackSpeed(input); - wrapped.emplace(flutter::EncodableValue("result"), - flutter::EncodableValue()); - } catch (const VideoPlayerError &error) { - wrapped.emplace(flutter::EncodableValue("error"), - VideoPlayerApi::WrapError(error)); - } - reply(flutter::EncodableValue(wrapped)); - }); - } - - auto play_channel = - std::make_unique>( - messenger, "dev.flutter.pigeon.VideoPlayerApi.play", - &flutter::StandardMessageCodec::GetInstance()); - if (api != nullptr) { - play_channel->SetMessageHandler( - [api](const flutter::EncodableValue &message, - flutter::MessageReply reply) { - TextureMessage input = TextureMessage::fromMap(message); - flutter::EncodableMap wrapped; - try { - api->play(input); - wrapped.emplace(flutter::EncodableValue("result"), - flutter::EncodableValue()); - } catch (const VideoPlayerError &error) { - wrapped.emplace(flutter::EncodableValue("error"), - VideoPlayerApi::WrapError(error)); - } - reply(flutter::EncodableValue(wrapped)); - }); - } - - auto position_channel = - std::make_unique>( - messenger, "dev.flutter.pigeon.VideoPlayerApi.position", - &flutter::StandardMessageCodec::GetInstance()); - if (api != nullptr) { - position_channel->SetMessageHandler( - [api](const flutter::EncodableValue &message, - flutter::MessageReply reply) { - TextureMessage input = TextureMessage::fromMap(message); - flutter::EncodableMap wrapped; - try { - PositionMessage output = api->position(input); - wrapped.emplace(flutter::EncodableValue("result"), output.toMap()); - } catch (const VideoPlayerError &error) { - wrapped.emplace(flutter::EncodableValue("error"), - VideoPlayerApi::WrapError(error)); - } - reply(flutter::EncodableValue(wrapped)); - }); - } - - auto seek_to_channel = - std::make_unique>( - messenger, "dev.flutter.pigeon.VideoPlayerApi.seekTo", - &flutter::StandardMessageCodec::GetInstance()); - if (api != nullptr) { - seek_to_channel->SetMessageHandler( - [api](const flutter::EncodableValue &message, - flutter::MessageReply reply) { - PositionMessage input = PositionMessage::fromMap(message); - try { - api->seekTo(input, [reply]() { - flutter::EncodableMap wrapped = { - {flutter::EncodableValue("result"), - flutter::EncodableValue()}}; - reply(flutter::EncodableValue(wrapped)); - }); - } catch (const VideoPlayerError &error) { - flutter::EncodableMap wrapped = { - {flutter::EncodableValue("error"), - VideoPlayerApi::WrapError(error)}}; - reply(flutter::EncodableValue(wrapped)); - } - }); - } - - auto pause_channel = - std::make_unique>( - messenger, "dev.flutter.pigeon.VideoPlayerApi.pause", - &flutter::StandardMessageCodec::GetInstance()); - if (api != nullptr) { - pause_channel->SetMessageHandler( - [api](const flutter::EncodableValue &message, - flutter::MessageReply reply) { - TextureMessage input = TextureMessage::fromMap(message); - flutter::EncodableMap wrapped; - try { - api->pause(input); - wrapped.emplace(flutter::EncodableValue("result"), - flutter::EncodableValue()); - } catch (const VideoPlayerError &error) { - wrapped.emplace(flutter::EncodableValue("error"), - VideoPlayerApi::WrapError(error)); - } - reply(flutter::EncodableValue(wrapped)); - }); - } - - auto mix_channel = - std::make_unique>( - messenger, "dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers", - &flutter::StandardMessageCodec::GetInstance()); - if (api != nullptr) { - mix_channel->SetMessageHandler( - [api](const flutter::EncodableValue &message, - flutter::MessageReply reply) { - MixWithOthersMessage input = MixWithOthersMessage::fromMap(message); - flutter::EncodableMap wrapped; - try { - api->setMixWithOthers(input); - wrapped.emplace(flutter::EncodableValue("result"), - flutter::EncodableValue()); - } catch (const VideoPlayerError &error) { - wrapped.emplace(flutter::EncodableValue("error"), - VideoPlayerApi::WrapError(error)); - } - reply(flutter::EncodableValue(wrapped)); - }); - } -} - -flutter::EncodableValue VideoPlayerApi::WrapError( - const VideoPlayerError &error) { - flutter::EncodableMap wrapped = { - {flutter::EncodableValue("message"), - flutter::EncodableValue(error.getMessage())}, - {flutter::EncodableValue("code"), - flutter::EncodableValue(error.getCode())}, - {flutter::EncodableValue("details"), flutter::EncodableValue()}}; - return flutter::EncodableValue(wrapped); -} diff --git a/packages/video_player/tizen/src/message.h b/packages/video_player/tizen/src/message.h deleted file mode 100644 index f38b7352b..000000000 --- a/packages/video_player/tizen/src/message.h +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_PLUGIN_VIDEO_PLAYER_MESSAGE_H_ -#define FLUTTER_PLUGIN_VIDEO_PLAYER_MESSAGE_H_ - -#include -#include - -#include -#include - -#include "video_player_error.h" - -class TextureMessage { - public: - TextureMessage() : textureId_(0) {} - ~TextureMessage() = default; - TextureMessage(TextureMessage const &) = default; - TextureMessage &operator=(TextureMessage const &) = default; - - int64_t getTextureId() const; - void setTextureId(int64_t textureId); - flutter::EncodableValue toMap(); - static TextureMessage fromMap(const flutter::EncodableValue &value); - - private: - int64_t textureId_; -}; - -class CreateMessage { - public: - CreateMessage() = default; - ~CreateMessage() = default; - CreateMessage(CreateMessage const &) = default; - CreateMessage &operator=(CreateMessage const &) = default; - - std::string getAsset() const; - void setAsset(const std::string &asset); - std::string getUri() const; - void setUri(const std::string &uri); - std::string getPackageName() const; - void setPackageName(const std::string &packageName); - std::string getFormatHint() const; - void setFormatHint(const std::string &formatHint); - flutter::EncodableValue toMap(); - static CreateMessage fromMap(const flutter::EncodableValue &value); - - private: - std::string asset_; - std::string uri_; - std::string packageName_; - std::string formatHint_; -}; - -class LoopingMessage { - public: - LoopingMessage() : textureId_(0), isLooping_(false) {} - ~LoopingMessage() = default; - LoopingMessage(LoopingMessage const &) = default; - LoopingMessage &operator=(LoopingMessage const &) = default; - - int64_t getTextureId() const; - void setTextureId(int64_t textureId); - bool getIsLooping() const; - void setIsLooping(bool isLooping); - flutter::EncodableValue toMap(); - static LoopingMessage fromMap(const flutter::EncodableValue &value); - - private: - int64_t textureId_; - bool isLooping_; -}; - -class VolumeMessage { - public: - VolumeMessage() : textureId_(0), volume_(0.0) {} - ~VolumeMessage() = default; - VolumeMessage(VolumeMessage const &) = default; - VolumeMessage &operator=(VolumeMessage const &) = default; - - int64_t getTextureId() const; - void setTextureId(int64_t textureId); - double getVolume() const; - void setVolume(double volume); - flutter::EncodableValue toMap(); - static VolumeMessage fromMap(const flutter::EncodableValue &value); - - private: - int64_t textureId_; - double volume_; -}; - -class PlaybackSpeedMessage { - public: - PlaybackSpeedMessage() : textureId_(0), speed_(1.0) {} - ~PlaybackSpeedMessage() = default; - PlaybackSpeedMessage(PlaybackSpeedMessage const &) = default; - PlaybackSpeedMessage &operator=(PlaybackSpeedMessage const &) = default; - - int64_t getTextureId() const; - void setTextureId(int64_t textureId); - double getSpeed() const; - void setSpeed(double speed); - flutter::EncodableValue toMap(); - static PlaybackSpeedMessage fromMap(const flutter::EncodableValue &value); - - private: - int64_t textureId_; - double speed_; -}; - -class PositionMessage { - public: - PositionMessage() : textureId_(0), position_(0) {} - ~PositionMessage() = default; - PositionMessage(PositionMessage const &) = default; - PositionMessage &operator=(PositionMessage const &) = default; - - int64_t getTextureId() const; - void setTextureId(int64_t textureId); - int64_t getPosition() const; - void setPosition(int64_t position); - flutter::EncodableValue toMap(); - static PositionMessage fromMap(const flutter::EncodableValue &value); - - private: - int64_t textureId_; - int64_t position_; -}; - -class MixWithOthersMessage { - public: - MixWithOthersMessage() : mixWithOthers_(false) {} - ~MixWithOthersMessage() = default; - MixWithOthersMessage(MixWithOthersMessage const &) = default; - MixWithOthersMessage &operator=(MixWithOthersMessage const &) = default; - - bool getMixWithOthers() const; - void setMixWithOthers(bool mixWithOthers); - flutter::EncodableValue toMap(); - static MixWithOthersMessage fromMap(const flutter::EncodableValue &value); - - private: - bool mixWithOthers_; -}; - -class VideoPlayerApi { - public: - using SeekCompletedCallback = std::function; - - virtual void initialize() = 0; - virtual TextureMessage create(const CreateMessage &createMsg) = 0; - virtual void dispose(const TextureMessage &textureMsg) = 0; - virtual void setLooping(const LoopingMessage &loopingMsg) = 0; - virtual void setVolume(const VolumeMessage &volumeMsg) = 0; - virtual void setPlaybackSpeed(const PlaybackSpeedMessage &speedMsg) = 0; - virtual void play(const TextureMessage &textureMsg) = 0; - virtual void pause(const TextureMessage &textureMsg) = 0; - virtual PositionMessage position(const TextureMessage &textureMsg) = 0; - virtual void seekTo(const PositionMessage &positionMsg, - const SeekCompletedCallback &onSeekCompleted) = 0; - virtual void setMixWithOthers( - const MixWithOthersMessage &mixWithOthersMsg) = 0; - - static void SetUp(flutter::BinaryMessenger *messenger, VideoPlayerApi *api); - static flutter::EncodableValue WrapError(const VideoPlayerError &error); -}; - -#endif // FLUTTER_PLUGIN_VIDEO_PLAYER_MESSAGE_H_ diff --git a/packages/video_player/tizen/src/messages.cc b/packages/video_player/tizen/src/messages.cc new file mode 100644 index 000000000..d9a71e222 --- /dev/null +++ b/packages/video_player/tizen/src/messages.cc @@ -0,0 +1,863 @@ +// Autogenerated from Pigeon (v4.2.9), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +#undef _HAS_EXCEPTIONS + +#include "messages.h" + +#include +#include +#include +#include + +#include +#include +#include + +// TextureMessage + +int64_t TextureMessage::texture_id() const { return texture_id_; } +void TextureMessage::set_texture_id(int64_t value_arg) { + texture_id_ = value_arg; +} + +flutter::EncodableMap TextureMessage::ToEncodableMap() const { + return flutter::EncodableMap{ + {flutter::EncodableValue("textureId"), + flutter::EncodableValue(texture_id_)}, + }; +} + +TextureMessage::TextureMessage() {} + +TextureMessage::TextureMessage(flutter::EncodableMap map) { + auto& encodable_texture_id = map.at(flutter::EncodableValue("textureId")); + if (const int32_t* pointer_texture_id = + std::get_if(&encodable_texture_id)) + texture_id_ = *pointer_texture_id; + else if (const int64_t* pointer_texture_id_64 = + std::get_if(&encodable_texture_id)) + texture_id_ = *pointer_texture_id_64; +} + +// LoopingMessage + +int64_t LoopingMessage::texture_id() const { return texture_id_; } +void LoopingMessage::set_texture_id(int64_t value_arg) { + texture_id_ = value_arg; +} + +bool LoopingMessage::is_looping() const { return is_looping_; } +void LoopingMessage::set_is_looping(bool value_arg) { is_looping_ = value_arg; } + +flutter::EncodableMap LoopingMessage::ToEncodableMap() const { + return flutter::EncodableMap{ + {flutter::EncodableValue("textureId"), + flutter::EncodableValue(texture_id_)}, + {flutter::EncodableValue("isLooping"), + flutter::EncodableValue(is_looping_)}, + }; +} + +LoopingMessage::LoopingMessage() {} + +LoopingMessage::LoopingMessage(flutter::EncodableMap map) { + auto& encodable_texture_id = map.at(flutter::EncodableValue("textureId")); + if (const int32_t* pointer_texture_id = + std::get_if(&encodable_texture_id)) + texture_id_ = *pointer_texture_id; + else if (const int64_t* pointer_texture_id_64 = + std::get_if(&encodable_texture_id)) + texture_id_ = *pointer_texture_id_64; + auto& encodable_is_looping = map.at(flutter::EncodableValue("isLooping")); + if (const bool* pointer_is_looping = + std::get_if(&encodable_is_looping)) { + is_looping_ = *pointer_is_looping; + } +} + +// VolumeMessage + +int64_t VolumeMessage::texture_id() const { return texture_id_; } +void VolumeMessage::set_texture_id(int64_t value_arg) { + texture_id_ = value_arg; +} + +double VolumeMessage::volume() const { return volume_; } +void VolumeMessage::set_volume(double value_arg) { volume_ = value_arg; } + +flutter::EncodableMap VolumeMessage::ToEncodableMap() const { + return flutter::EncodableMap{ + {flutter::EncodableValue("textureId"), + flutter::EncodableValue(texture_id_)}, + {flutter::EncodableValue("volume"), flutter::EncodableValue(volume_)}, + }; +} + +VolumeMessage::VolumeMessage() {} + +VolumeMessage::VolumeMessage(flutter::EncodableMap map) { + auto& encodable_texture_id = map.at(flutter::EncodableValue("textureId")); + if (const int32_t* pointer_texture_id = + std::get_if(&encodable_texture_id)) + texture_id_ = *pointer_texture_id; + else if (const int64_t* pointer_texture_id_64 = + std::get_if(&encodable_texture_id)) + texture_id_ = *pointer_texture_id_64; + auto& encodable_volume = map.at(flutter::EncodableValue("volume")); + if (const double* pointer_volume = std::get_if(&encodable_volume)) { + volume_ = *pointer_volume; + } +} + +// PlaybackSpeedMessage + +int64_t PlaybackSpeedMessage::texture_id() const { return texture_id_; } +void PlaybackSpeedMessage::set_texture_id(int64_t value_arg) { + texture_id_ = value_arg; +} + +double PlaybackSpeedMessage::speed() const { return speed_; } +void PlaybackSpeedMessage::set_speed(double value_arg) { speed_ = value_arg; } + +flutter::EncodableMap PlaybackSpeedMessage::ToEncodableMap() const { + return flutter::EncodableMap{ + {flutter::EncodableValue("textureId"), + flutter::EncodableValue(texture_id_)}, + {flutter::EncodableValue("speed"), flutter::EncodableValue(speed_)}, + }; +} + +PlaybackSpeedMessage::PlaybackSpeedMessage() {} + +PlaybackSpeedMessage::PlaybackSpeedMessage(flutter::EncodableMap map) { + auto& encodable_texture_id = map.at(flutter::EncodableValue("textureId")); + if (const int32_t* pointer_texture_id = + std::get_if(&encodable_texture_id)) + texture_id_ = *pointer_texture_id; + else if (const int64_t* pointer_texture_id_64 = + std::get_if(&encodable_texture_id)) + texture_id_ = *pointer_texture_id_64; + auto& encodable_speed = map.at(flutter::EncodableValue("speed")); + if (const double* pointer_speed = std::get_if(&encodable_speed)) { + speed_ = *pointer_speed; + } +} + +// PositionMessage + +int64_t PositionMessage::texture_id() const { return texture_id_; } +void PositionMessage::set_texture_id(int64_t value_arg) { + texture_id_ = value_arg; +} + +int64_t PositionMessage::position() const { return position_; } +void PositionMessage::set_position(int64_t value_arg) { position_ = value_arg; } + +flutter::EncodableMap PositionMessage::ToEncodableMap() const { + return flutter::EncodableMap{ + {flutter::EncodableValue("textureId"), + flutter::EncodableValue(texture_id_)}, + {flutter::EncodableValue("position"), flutter::EncodableValue(position_)}, + }; +} + +PositionMessage::PositionMessage() {} + +PositionMessage::PositionMessage(flutter::EncodableMap map) { + auto& encodable_texture_id = map.at(flutter::EncodableValue("textureId")); + if (const int32_t* pointer_texture_id = + std::get_if(&encodable_texture_id)) + texture_id_ = *pointer_texture_id; + else if (const int64_t* pointer_texture_id_64 = + std::get_if(&encodable_texture_id)) + texture_id_ = *pointer_texture_id_64; + auto& encodable_position = map.at(flutter::EncodableValue("position")); + if (const int32_t* pointer_position = + std::get_if(&encodable_position)) + position_ = *pointer_position; + else if (const int64_t* pointer_position_64 = + std::get_if(&encodable_position)) + position_ = *pointer_position_64; +} + +// CreateMessage + +const std::string* CreateMessage::asset() const { + return asset_ ? &(*asset_) : nullptr; +} +void CreateMessage::set_asset(const std::string_view* value_arg) { + asset_ = value_arg ? std::optional(*value_arg) : std::nullopt; +} +void CreateMessage::set_asset(std::string_view value_arg) { + asset_ = value_arg; +} + +const std::string* CreateMessage::uri() const { + return uri_ ? &(*uri_) : nullptr; +} +void CreateMessage::set_uri(const std::string_view* value_arg) { + uri_ = value_arg ? std::optional(*value_arg) : std::nullopt; +} +void CreateMessage::set_uri(std::string_view value_arg) { uri_ = value_arg; } + +const std::string* CreateMessage::package_name() const { + return package_name_ ? &(*package_name_) : nullptr; +} +void CreateMessage::set_package_name(const std::string_view* value_arg) { + package_name_ = + value_arg ? std::optional(*value_arg) : std::nullopt; +} +void CreateMessage::set_package_name(std::string_view value_arg) { + package_name_ = value_arg; +} + +const std::string* CreateMessage::format_hint() const { + return format_hint_ ? &(*format_hint_) : nullptr; +} +void CreateMessage::set_format_hint(const std::string_view* value_arg) { + format_hint_ = + value_arg ? std::optional(*value_arg) : std::nullopt; +} +void CreateMessage::set_format_hint(std::string_view value_arg) { + format_hint_ = value_arg; +} + +const flutter::EncodableMap& CreateMessage::http_headers() const { + return http_headers_; +} +void CreateMessage::set_http_headers(const flutter::EncodableMap& value_arg) { + http_headers_ = value_arg; +} + +flutter::EncodableMap CreateMessage::ToEncodableMap() const { + return flutter::EncodableMap{ + {flutter::EncodableValue("asset"), + asset_ ? flutter::EncodableValue(*asset_) : flutter::EncodableValue()}, + {flutter::EncodableValue("uri"), + uri_ ? flutter::EncodableValue(*uri_) : flutter::EncodableValue()}, + {flutter::EncodableValue("packageName"), + package_name_ ? flutter::EncodableValue(*package_name_) + : flutter::EncodableValue()}, + {flutter::EncodableValue("formatHint"), + format_hint_ ? flutter::EncodableValue(*format_hint_) + : flutter::EncodableValue()}, + {flutter::EncodableValue("httpHeaders"), + flutter::EncodableValue(http_headers_)}, + }; +} + +CreateMessage::CreateMessage() {} + +CreateMessage::CreateMessage(flutter::EncodableMap map) { + auto& encodable_asset = map.at(flutter::EncodableValue("asset")); + if (const std::string* pointer_asset = + std::get_if(&encodable_asset)) { + asset_ = *pointer_asset; + } + auto& encodable_uri = map.at(flutter::EncodableValue("uri")); + if (const std::string* pointer_uri = + std::get_if(&encodable_uri)) { + uri_ = *pointer_uri; + } + auto& encodable_package_name = map.at(flutter::EncodableValue("packageName")); + if (const std::string* pointer_package_name = + std::get_if(&encodable_package_name)) { + package_name_ = *pointer_package_name; + } + auto& encodable_format_hint = map.at(flutter::EncodableValue("formatHint")); + if (const std::string* pointer_format_hint = + std::get_if(&encodable_format_hint)) { + format_hint_ = *pointer_format_hint; + } + auto& encodable_http_headers = map.at(flutter::EncodableValue("httpHeaders")); + if (const flutter::EncodableMap* pointer_http_headers = + std::get_if(&encodable_http_headers)) { + http_headers_ = *pointer_http_headers; + } +} + +// MixWithOthersMessage + +bool MixWithOthersMessage::mix_with_others() const { return mix_with_others_; } +void MixWithOthersMessage::set_mix_with_others(bool value_arg) { + mix_with_others_ = value_arg; +} + +flutter::EncodableMap MixWithOthersMessage::ToEncodableMap() const { + return flutter::EncodableMap{ + {flutter::EncodableValue("mixWithOthers"), + flutter::EncodableValue(mix_with_others_)}, + }; +} + +MixWithOthersMessage::MixWithOthersMessage() {} + +MixWithOthersMessage::MixWithOthersMessage(flutter::EncodableMap map) { + auto& encodable_mix_with_others = + map.at(flutter::EncodableValue("mixWithOthers")); + if (const bool* pointer_mix_with_others = + std::get_if(&encodable_mix_with_others)) { + mix_with_others_ = *pointer_mix_with_others; + } +} + +TizenVideoPlayerApiCodecSerializer::TizenVideoPlayerApiCodecSerializer() {} +flutter::EncodableValue TizenVideoPlayerApiCodecSerializer::ReadValueOfType( + uint8_t type, flutter::ByteStreamReader* stream) const { + switch (type) { + case 128: + return flutter::CustomEncodableValue( + CreateMessage(std::get(ReadValue(stream)))); + + case 129: + return flutter::CustomEncodableValue( + LoopingMessage(std::get(ReadValue(stream)))); + + case 130: + return flutter::CustomEncodableValue(MixWithOthersMessage( + std::get(ReadValue(stream)))); + + case 131: + return flutter::CustomEncodableValue(PlaybackSpeedMessage( + std::get(ReadValue(stream)))); + + case 132: + return flutter::CustomEncodableValue( + PositionMessage(std::get(ReadValue(stream)))); + + case 133: + return flutter::CustomEncodableValue( + TextureMessage(std::get(ReadValue(stream)))); + + case 134: + return flutter::CustomEncodableValue( + VolumeMessage(std::get(ReadValue(stream)))); + + default: + return flutter::StandardCodecSerializer::ReadValueOfType(type, stream); + } +} + +void TizenVideoPlayerApiCodecSerializer::WriteValue( + const flutter::EncodableValue& value, + flutter::ByteStreamWriter* stream) const { + if (const flutter::CustomEncodableValue* custom_value = + std::get_if(&value)) { + if (custom_value->type() == typeid(CreateMessage)) { + stream->WriteByte(128); + WriteValue( + flutter::EncodableValue( + std::any_cast(*custom_value).ToEncodableMap()), + stream); + return; + } + if (custom_value->type() == typeid(LoopingMessage)) { + stream->WriteByte(129); + WriteValue( + flutter::EncodableValue( + std::any_cast(*custom_value).ToEncodableMap()), + stream); + return; + } + if (custom_value->type() == typeid(MixWithOthersMessage)) { + stream->WriteByte(130); + WriteValue(flutter::EncodableValue( + std::any_cast(*custom_value) + .ToEncodableMap()), + stream); + return; + } + if (custom_value->type() == typeid(PlaybackSpeedMessage)) { + stream->WriteByte(131); + WriteValue(flutter::EncodableValue( + std::any_cast(*custom_value) + .ToEncodableMap()), + stream); + return; + } + if (custom_value->type() == typeid(PositionMessage)) { + stream->WriteByte(132); + WriteValue( + flutter::EncodableValue( + std::any_cast(*custom_value).ToEncodableMap()), + stream); + return; + } + if (custom_value->type() == typeid(TextureMessage)) { + stream->WriteByte(133); + WriteValue( + flutter::EncodableValue( + std::any_cast(*custom_value).ToEncodableMap()), + stream); + return; + } + if (custom_value->type() == typeid(VolumeMessage)) { + stream->WriteByte(134); + WriteValue( + flutter::EncodableValue( + std::any_cast(*custom_value).ToEncodableMap()), + stream); + return; + } + } + flutter::StandardCodecSerializer::WriteValue(value, stream); +} + +/// The codec used by TizenVideoPlayerApi. +const flutter::StandardMessageCodec& TizenVideoPlayerApi::GetCodec() { + return flutter::StandardMessageCodec::GetInstance( + &TizenVideoPlayerApiCodecSerializer::GetInstance()); +} + +// Sets up an instance of `TizenVideoPlayerApi` to handle messages through the +// `binary_messenger`. +void TizenVideoPlayerApi::SetUp(flutter::BinaryMessenger* binary_messenger, + TizenVideoPlayerApi* api) { + { + auto channel = + std::make_unique>( + binary_messenger, + "dev.flutter.pigeon.TizenVideoPlayerApi.initialize", &GetCodec()); + if (api != nullptr) { + channel->SetMessageHandler( + [api](const flutter::EncodableValue& message, + const flutter::MessageReply& reply) { + flutter::EncodableMap wrapped; + try { + std::optional output = api->Initialize(); + if (output.has_value()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(output.value())); + } else { + wrapped.emplace(flutter::EncodableValue("result"), + flutter::EncodableValue()); + } + } catch (const std::exception& exception) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(exception.what())); + } + reply(flutter::EncodableValue(wrapped)); + }); + } else { + channel->SetMessageHandler(nullptr); + } + } + { + auto channel = + std::make_unique>( + binary_messenger, "dev.flutter.pigeon.TizenVideoPlayerApi.create", + &GetCodec()); + if (api != nullptr) { + channel->SetMessageHandler( + [api](const flutter::EncodableValue& message, + const flutter::MessageReply& reply) { + flutter::EncodableMap wrapped; + try { + const auto& args = std::get(message); + const auto& encodable_msg_arg = args.at(0); + if (encodable_msg_arg.IsNull()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError("msg_arg unexpectedly null.")); + reply(flutter::EncodableValue(wrapped)); + return; + } + const auto& msg_arg = std::any_cast( + std::get(encodable_msg_arg)); + ErrorOr output = api->Create(msg_arg); + if (output.has_error()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(output.error())); + } else { + wrapped.emplace(flutter::EncodableValue("result"), + flutter::CustomEncodableValue( + std::move(output).TakeValue())); + } + } catch (const std::exception& exception) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(exception.what())); + } + reply(flutter::EncodableValue(wrapped)); + }); + } else { + channel->SetMessageHandler(nullptr); + } + } + { + auto channel = + std::make_unique>( + binary_messenger, "dev.flutter.pigeon.TizenVideoPlayerApi.dispose", + &GetCodec()); + if (api != nullptr) { + channel->SetMessageHandler( + [api](const flutter::EncodableValue& message, + const flutter::MessageReply& reply) { + flutter::EncodableMap wrapped; + try { + const auto& args = std::get(message); + const auto& encodable_msg_arg = args.at(0); + if (encodable_msg_arg.IsNull()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError("msg_arg unexpectedly null.")); + reply(flutter::EncodableValue(wrapped)); + return; + } + const auto& msg_arg = std::any_cast( + std::get(encodable_msg_arg)); + std::optional output = api->Dispose(msg_arg); + if (output.has_value()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(output.value())); + } else { + wrapped.emplace(flutter::EncodableValue("result"), + flutter::EncodableValue()); + } + } catch (const std::exception& exception) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(exception.what())); + } + reply(flutter::EncodableValue(wrapped)); + }); + } else { + channel->SetMessageHandler(nullptr); + } + } + { + auto channel = + std::make_unique>( + binary_messenger, + "dev.flutter.pigeon.TizenVideoPlayerApi.setLooping", &GetCodec()); + if (api != nullptr) { + channel->SetMessageHandler( + [api](const flutter::EncodableValue& message, + const flutter::MessageReply& reply) { + flutter::EncodableMap wrapped; + try { + const auto& args = std::get(message); + const auto& encodable_msg_arg = args.at(0); + if (encodable_msg_arg.IsNull()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError("msg_arg unexpectedly null.")); + reply(flutter::EncodableValue(wrapped)); + return; + } + const auto& msg_arg = std::any_cast( + std::get(encodable_msg_arg)); + std::optional output = api->SetLooping(msg_arg); + if (output.has_value()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(output.value())); + } else { + wrapped.emplace(flutter::EncodableValue("result"), + flutter::EncodableValue()); + } + } catch (const std::exception& exception) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(exception.what())); + } + reply(flutter::EncodableValue(wrapped)); + }); + } else { + channel->SetMessageHandler(nullptr); + } + } + { + auto channel = + std::make_unique>( + binary_messenger, + "dev.flutter.pigeon.TizenVideoPlayerApi.setVolume", &GetCodec()); + if (api != nullptr) { + channel->SetMessageHandler( + [api](const flutter::EncodableValue& message, + const flutter::MessageReply& reply) { + flutter::EncodableMap wrapped; + try { + const auto& args = std::get(message); + const auto& encodable_msg_arg = args.at(0); + if (encodable_msg_arg.IsNull()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError("msg_arg unexpectedly null.")); + reply(flutter::EncodableValue(wrapped)); + return; + } + const auto& msg_arg = std::any_cast( + std::get(encodable_msg_arg)); + std::optional output = api->SetVolume(msg_arg); + if (output.has_value()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(output.value())); + } else { + wrapped.emplace(flutter::EncodableValue("result"), + flutter::EncodableValue()); + } + } catch (const std::exception& exception) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(exception.what())); + } + reply(flutter::EncodableValue(wrapped)); + }); + } else { + channel->SetMessageHandler(nullptr); + } + } + { + auto channel = + std::make_unique>( + binary_messenger, + "dev.flutter.pigeon.TizenVideoPlayerApi.setPlaybackSpeed", + &GetCodec()); + if (api != nullptr) { + channel->SetMessageHandler( + [api](const flutter::EncodableValue& message, + const flutter::MessageReply& reply) { + flutter::EncodableMap wrapped; + try { + const auto& args = std::get(message); + const auto& encodable_msg_arg = args.at(0); + if (encodable_msg_arg.IsNull()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError("msg_arg unexpectedly null.")); + reply(flutter::EncodableValue(wrapped)); + return; + } + const auto& msg_arg = std::any_cast( + std::get(encodable_msg_arg)); + std::optional output = + api->SetPlaybackSpeed(msg_arg); + if (output.has_value()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(output.value())); + } else { + wrapped.emplace(flutter::EncodableValue("result"), + flutter::EncodableValue()); + } + } catch (const std::exception& exception) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(exception.what())); + } + reply(flutter::EncodableValue(wrapped)); + }); + } else { + channel->SetMessageHandler(nullptr); + } + } + { + auto channel = + std::make_unique>( + binary_messenger, "dev.flutter.pigeon.TizenVideoPlayerApi.play", + &GetCodec()); + if (api != nullptr) { + channel->SetMessageHandler( + [api](const flutter::EncodableValue& message, + const flutter::MessageReply& reply) { + flutter::EncodableMap wrapped; + try { + const auto& args = std::get(message); + const auto& encodable_msg_arg = args.at(0); + if (encodable_msg_arg.IsNull()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError("msg_arg unexpectedly null.")); + reply(flutter::EncodableValue(wrapped)); + return; + } + const auto& msg_arg = std::any_cast( + std::get(encodable_msg_arg)); + std::optional output = api->Play(msg_arg); + if (output.has_value()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(output.value())); + } else { + wrapped.emplace(flutter::EncodableValue("result"), + flutter::EncodableValue()); + } + } catch (const std::exception& exception) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(exception.what())); + } + reply(flutter::EncodableValue(wrapped)); + }); + } else { + channel->SetMessageHandler(nullptr); + } + } + { + auto channel = + std::make_unique>( + binary_messenger, "dev.flutter.pigeon.TizenVideoPlayerApi.position", + &GetCodec()); + if (api != nullptr) { + channel->SetMessageHandler( + [api](const flutter::EncodableValue& message, + const flutter::MessageReply& reply) { + flutter::EncodableMap wrapped; + try { + const auto& args = std::get(message); + const auto& encodable_msg_arg = args.at(0); + if (encodable_msg_arg.IsNull()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError("msg_arg unexpectedly null.")); + reply(flutter::EncodableValue(wrapped)); + return; + } + const auto& msg_arg = std::any_cast( + std::get(encodable_msg_arg)); + ErrorOr output = api->Position(msg_arg); + if (output.has_error()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(output.error())); + } else { + wrapped.emplace(flutter::EncodableValue("result"), + flutter::CustomEncodableValue( + std::move(output).TakeValue())); + } + } catch (const std::exception& exception) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(exception.what())); + } + reply(flutter::EncodableValue(wrapped)); + }); + } else { + channel->SetMessageHandler(nullptr); + } + } + { + auto channel = + std::make_unique>( + binary_messenger, "dev.flutter.pigeon.TizenVideoPlayerApi.seekTo", + &GetCodec()); + if (api != nullptr) { + channel->SetMessageHandler( + [api](const flutter::EncodableValue& message, + const flutter::MessageReply& reply) { + flutter::EncodableMap wrapped; + try { + const auto& args = std::get(message); + const auto& encodable_msg_arg = args.at(0); + if (encodable_msg_arg.IsNull()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError("msg_arg unexpectedly null.")); + reply(flutter::EncodableValue(wrapped)); + return; + } + const auto& msg_arg = std::any_cast( + std::get(encodable_msg_arg)); + api->SeekTo(msg_arg, [&wrapped, &reply]( + std::optional&& output) { + if (output.has_value()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(output.value())); + reply(flutter::EncodableValue(wrapped)); + } else { + wrapped.emplace(flutter::EncodableValue("result"), + flutter::EncodableValue()); + reply(flutter::EncodableValue(wrapped)); + } + }); + } catch (const std::exception& exception) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(exception.what())); + reply(flutter::EncodableValue(wrapped)); + } + }); + } else { + channel->SetMessageHandler(nullptr); + } + } + { + auto channel = + std::make_unique>( + binary_messenger, "dev.flutter.pigeon.TizenVideoPlayerApi.pause", + &GetCodec()); + if (api != nullptr) { + channel->SetMessageHandler( + [api](const flutter::EncodableValue& message, + const flutter::MessageReply& reply) { + flutter::EncodableMap wrapped; + try { + const auto& args = std::get(message); + const auto& encodable_msg_arg = args.at(0); + if (encodable_msg_arg.IsNull()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError("msg_arg unexpectedly null.")); + reply(flutter::EncodableValue(wrapped)); + return; + } + const auto& msg_arg = std::any_cast( + std::get(encodable_msg_arg)); + std::optional output = api->Pause(msg_arg); + if (output.has_value()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(output.value())); + } else { + wrapped.emplace(flutter::EncodableValue("result"), + flutter::EncodableValue()); + } + } catch (const std::exception& exception) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(exception.what())); + } + reply(flutter::EncodableValue(wrapped)); + }); + } else { + channel->SetMessageHandler(nullptr); + } + } + { + auto channel = + std::make_unique>( + binary_messenger, + "dev.flutter.pigeon.TizenVideoPlayerApi.setMixWithOthers", + &GetCodec()); + if (api != nullptr) { + channel->SetMessageHandler( + [api](const flutter::EncodableValue& message, + const flutter::MessageReply& reply) { + flutter::EncodableMap wrapped; + try { + const auto& args = std::get(message); + const auto& encodable_msg_arg = args.at(0); + if (encodable_msg_arg.IsNull()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError("msg_arg unexpectedly null.")); + reply(flutter::EncodableValue(wrapped)); + return; + } + const auto& msg_arg = std::any_cast( + std::get(encodable_msg_arg)); + std::optional output = + api->SetMixWithOthers(msg_arg); + if (output.has_value()) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(output.value())); + } else { + wrapped.emplace(flutter::EncodableValue("result"), + flutter::EncodableValue()); + } + } catch (const std::exception& exception) { + wrapped.emplace(flutter::EncodableValue("error"), + WrapError(exception.what())); + } + reply(flutter::EncodableValue(wrapped)); + }); + } else { + channel->SetMessageHandler(nullptr); + } + } +} + +flutter::EncodableMap TizenVideoPlayerApi::WrapError( + std::string_view error_message) { + return flutter::EncodableMap( + {{flutter::EncodableValue("message"), + flutter::EncodableValue(std::string(error_message))}, + {flutter::EncodableValue("code"), flutter::EncodableValue("Error")}, + {flutter::EncodableValue("details"), flutter::EncodableValue()}}); +} +flutter::EncodableMap TizenVideoPlayerApi::WrapError( + const FlutterError& error) { + return flutter::EncodableMap( + {{flutter::EncodableValue("message"), + flutter::EncodableValue(error.message())}, + {flutter::EncodableValue("code"), flutter::EncodableValue(error.code())}, + {flutter::EncodableValue("details"), error.details()}}); +} diff --git a/packages/video_player/tizen/src/messages.h b/packages/video_player/tizen/src/messages.h new file mode 100644 index 000000000..fee116a16 --- /dev/null +++ b/packages/video_player/tizen/src/messages.h @@ -0,0 +1,251 @@ +// Autogenerated from Pigeon (v4.2.9), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +#ifndef PIGEON_MESSAGES_H_ +#define PIGEON_MESSAGES_H_ +#include +#include +#include +#include + +#include +#include +#include + +// Generated class from Pigeon. + +class FlutterError { + public: + FlutterError(const std::string& code) : code_(code) {} + FlutterError(const std::string& code, const std::string& message) + : code_(code), message_(message) {} + FlutterError(const std::string& code, const std::string& message, + const flutter::EncodableValue& details) + : code_(code), message_(message), details_(details) {} + + const std::string& code() const { return code_; } + const std::string& message() const { return message_; } + const flutter::EncodableValue& details() const { return details_; } + + private: + std::string code_; + std::string message_; + flutter::EncodableValue details_; +}; + +template +class ErrorOr { + public: + ErrorOr(const T& rhs) { new (&v_) T(rhs); } + ErrorOr(const T&& rhs) { v_ = std::move(rhs); } + ErrorOr(const FlutterError& rhs) { new (&v_) FlutterError(rhs); } + ErrorOr(const FlutterError&& rhs) { v_ = std::move(rhs); } + + bool has_error() const { return std::holds_alternative(v_); } + const T& value() const { return std::get(v_); }; + const FlutterError& error() const { return std::get(v_); }; + + private: + friend class TizenVideoPlayerApi; + ErrorOr() = default; + T TakeValue() && { return std::get(std::move(v_)); } + + std::variant v_; +}; + +// Generated class from Pigeon that represents data sent in messages. +class TextureMessage { + public: + TextureMessage(); + int64_t texture_id() const; + void set_texture_id(int64_t value_arg); + + private: + TextureMessage(flutter::EncodableMap map); + flutter::EncodableMap ToEncodableMap() const; + friend class TizenVideoPlayerApi; + friend class TizenVideoPlayerApiCodecSerializer; + int64_t texture_id_; +}; + +// Generated class from Pigeon that represents data sent in messages. +class LoopingMessage { + public: + LoopingMessage(); + int64_t texture_id() const; + void set_texture_id(int64_t value_arg); + + bool is_looping() const; + void set_is_looping(bool value_arg); + + private: + LoopingMessage(flutter::EncodableMap map); + flutter::EncodableMap ToEncodableMap() const; + friend class TizenVideoPlayerApi; + friend class TizenVideoPlayerApiCodecSerializer; + int64_t texture_id_; + bool is_looping_; +}; + +// Generated class from Pigeon that represents data sent in messages. +class VolumeMessage { + public: + VolumeMessage(); + int64_t texture_id() const; + void set_texture_id(int64_t value_arg); + + double volume() const; + void set_volume(double value_arg); + + private: + VolumeMessage(flutter::EncodableMap map); + flutter::EncodableMap ToEncodableMap() const; + friend class TizenVideoPlayerApi; + friend class TizenVideoPlayerApiCodecSerializer; + int64_t texture_id_; + double volume_; +}; + +// Generated class from Pigeon that represents data sent in messages. +class PlaybackSpeedMessage { + public: + PlaybackSpeedMessage(); + int64_t texture_id() const; + void set_texture_id(int64_t value_arg); + + double speed() const; + void set_speed(double value_arg); + + private: + PlaybackSpeedMessage(flutter::EncodableMap map); + flutter::EncodableMap ToEncodableMap() const; + friend class TizenVideoPlayerApi; + friend class TizenVideoPlayerApiCodecSerializer; + int64_t texture_id_; + double speed_; +}; + +// Generated class from Pigeon that represents data sent in messages. +class PositionMessage { + public: + PositionMessage(); + int64_t texture_id() const; + void set_texture_id(int64_t value_arg); + + int64_t position() const; + void set_position(int64_t value_arg); + + private: + PositionMessage(flutter::EncodableMap map); + flutter::EncodableMap ToEncodableMap() const; + friend class TizenVideoPlayerApi; + friend class TizenVideoPlayerApiCodecSerializer; + int64_t texture_id_; + int64_t position_; +}; + +// Generated class from Pigeon that represents data sent in messages. +class CreateMessage { + public: + CreateMessage(); + const std::string* asset() const; + void set_asset(const std::string_view* value_arg); + void set_asset(std::string_view value_arg); + + const std::string* uri() const; + void set_uri(const std::string_view* value_arg); + void set_uri(std::string_view value_arg); + + const std::string* package_name() const; + void set_package_name(const std::string_view* value_arg); + void set_package_name(std::string_view value_arg); + + const std::string* format_hint() const; + void set_format_hint(const std::string_view* value_arg); + void set_format_hint(std::string_view value_arg); + + const flutter::EncodableMap& http_headers() const; + void set_http_headers(const flutter::EncodableMap& value_arg); + + private: + CreateMessage(flutter::EncodableMap map); + flutter::EncodableMap ToEncodableMap() const; + friend class TizenVideoPlayerApi; + friend class TizenVideoPlayerApiCodecSerializer; + std::optional asset_; + std::optional uri_; + std::optional package_name_; + std::optional format_hint_; + flutter::EncodableMap http_headers_; +}; + +// Generated class from Pigeon that represents data sent in messages. +class MixWithOthersMessage { + public: + MixWithOthersMessage(); + bool mix_with_others() const; + void set_mix_with_others(bool value_arg); + + private: + MixWithOthersMessage(flutter::EncodableMap map); + flutter::EncodableMap ToEncodableMap() const; + friend class TizenVideoPlayerApi; + friend class TizenVideoPlayerApiCodecSerializer; + bool mix_with_others_; +}; + +class TizenVideoPlayerApiCodecSerializer + : public flutter::StandardCodecSerializer { + public: + inline static TizenVideoPlayerApiCodecSerializer& GetInstance() { + static TizenVideoPlayerApiCodecSerializer sInstance; + return sInstance; + } + + TizenVideoPlayerApiCodecSerializer(); + + public: + void WriteValue(const flutter::EncodableValue& value, + flutter::ByteStreamWriter* stream) const override; + + protected: + flutter::EncodableValue ReadValueOfType( + uint8_t type, flutter::ByteStreamReader* stream) const override; +}; + +// Generated interface from Pigeon that represents a handler of messages from +// Flutter. +class TizenVideoPlayerApi { + public: + TizenVideoPlayerApi(const TizenVideoPlayerApi&) = delete; + TizenVideoPlayerApi& operator=(const TizenVideoPlayerApi&) = delete; + virtual ~TizenVideoPlayerApi(){}; + virtual std::optional Initialize() = 0; + virtual ErrorOr Create(const CreateMessage& msg) = 0; + virtual std::optional Dispose(const TextureMessage& msg) = 0; + virtual std::optional SetLooping(const LoopingMessage& msg) = 0; + virtual std::optional SetVolume(const VolumeMessage& msg) = 0; + virtual std::optional SetPlaybackSpeed( + const PlaybackSpeedMessage& msg) = 0; + virtual std::optional Play(const TextureMessage& msg) = 0; + virtual ErrorOr Position(const TextureMessage& msg) = 0; + virtual void SeekTo( + const PositionMessage& msg, + std::function reply)> result) = 0; + virtual std::optional Pause(const TextureMessage& msg) = 0; + virtual std::optional SetMixWithOthers( + const MixWithOthersMessage& msg) = 0; + + // The codec used by TizenVideoPlayerApi. + static const flutter::StandardMessageCodec& GetCodec(); + // Sets up an instance of `TizenVideoPlayerApi` to handle messages through the + // `binary_messenger`. + static void SetUp(flutter::BinaryMessenger* binary_messenger, + TizenVideoPlayerApi* api); + static flutter::EncodableMap WrapError(std::string_view error_message); + static flutter::EncodableMap WrapError(const FlutterError& error); + + protected: + TizenVideoPlayerApi() = default; +}; +#endif // PIGEON_MESSAGES_H_ diff --git a/packages/video_player/tizen/src/video_player.h b/packages/video_player/tizen/src/video_player.h index 0f176bba3..34402c9d6 100644 --- a/packages/video_player/tizen/src/video_player.h +++ b/packages/video_player/tizen/src/video_player.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/packages/video_player/tizen/src/video_player_error.h b/packages/video_player/tizen/src/video_player_error.h index 533dbb337..de7fd3bcd 100644 --- a/packages/video_player/tizen/src/video_player_error.h +++ b/packages/video_player/tizen/src/video_player_error.h @@ -23,8 +23,8 @@ class VideoPlayerError { return *this; } - std::string getCode() const { return code_; } - std::string getMessage() const { return message_; } + std::string code() const { return code_; } + std::string message() const { return message_; } private: std::string code_; diff --git a/packages/video_player/tizen/src/video_player_options.h b/packages/video_player/tizen/src/video_player_options.h index b74552720..aec315b47 100644 --- a/packages/video_player/tizen/src/video_player_options.h +++ b/packages/video_player/tizen/src/video_player_options.h @@ -13,10 +13,10 @@ class VideoPlayerOptions { VideoPlayerOptions(const VideoPlayerOptions &other) = default; VideoPlayerOptions &operator=(const VideoPlayerOptions &other) = default; - void setMixWithOthers(bool mix_with_others) { + void SetMixWithOthers(bool mix_with_others) { mix_with_others_ = mix_with_others; } - bool getMixWithOthers() const { return mix_with_others_; } + bool GetMixWithOthers() const { return mix_with_others_; } private: bool mix_with_others_ = true; diff --git a/packages/video_player/tizen/src/video_player_tizen_plugin.cc b/packages/video_player/tizen/src/video_player_tizen_plugin.cc index 28f918141..db98ec74d 100644 --- a/packages/video_player/tizen/src/video_player_tizen_plugin.cc +++ b/packages/video_player/tizen/src/video_player_tizen_plugin.cc @@ -5,45 +5,46 @@ #include "video_player_tizen_plugin.h" #include -#include -#include #include -#include #include #include #include -#include "flutter_texture_registrar.h" #include "log.h" -#include "message.h" +#include "messages.h" #include "video_player.h" #include "video_player_error.h" #include "video_player_options.h" namespace { -class VideoPlayerTizenPlugin : public flutter::Plugin, public VideoPlayerApi { +class VideoPlayerTizenPlugin : public flutter::Plugin, + public TizenVideoPlayerApi { public: static void RegisterWithRegistrar(flutter::PluginRegistrar *registrar); - // Creates a plugin that communicates on the given channel. VideoPlayerTizenPlugin(flutter::PluginRegistrar *registrar); virtual ~VideoPlayerTizenPlugin(); - virtual void initialize() override; - virtual TextureMessage create(const CreateMessage &createMsg) override; - virtual void dispose(const TextureMessage &textureMsg) override; - virtual void setLooping(const LoopingMessage &loopingMsg) override; - virtual void setVolume(const VolumeMessage &volumeMsg) override; - virtual void setPlaybackSpeed(const PlaybackSpeedMessage &speedMsg) override; - virtual void play(const TextureMessage &textureMsg) override; - virtual void pause(const TextureMessage &textureMsg) override; - virtual PositionMessage position(const TextureMessage &textureMsg) override; - virtual void seekTo(const PositionMessage &positionMsg, - const SeekCompletedCallback &onSeekCompleted) override; - virtual void setMixWithOthers( - const MixWithOthersMessage &mixWithOthersMsg) override; + virtual std::optional Initialize() override; + virtual ErrorOr Create(const CreateMessage &msg) override; + virtual std::optional Dispose( + const TextureMessage &msg) override; + virtual std::optional SetLooping( + const LoopingMessage &msg) override; + virtual std::optional SetVolume( + const VolumeMessage &msg) override; + virtual std::optional SetPlaybackSpeed( + const PlaybackSpeedMessage &msg) override; + virtual std::optional Play(const TextureMessage &msg) override; + virtual ErrorOr Position(const TextureMessage &msg) override; + virtual void SeekTo( + const PositionMessage &msg, + std::function reply)> result) override; + virtual std::optional Pause(const TextureMessage &msg) override; + virtual std::optional SetMixWithOthers( + const MixWithOthersMessage &msg) override; private: void DisposeAllPlayers(); @@ -65,157 +66,204 @@ VideoPlayerTizenPlugin::VideoPlayerTizenPlugin( : plugin_registrar_(registrar) { texture_registrar_ = registrar->texture_registrar(); - VideoPlayerApi::SetUp(registrar->messenger(), this); + TizenVideoPlayerApi::SetUp(registrar->messenger(), this); } VideoPlayerTizenPlugin::~VideoPlayerTizenPlugin() { DisposeAllPlayers(); } void VideoPlayerTizenPlugin::DisposeAllPlayers() { - LOG_DEBUG("[VideoPlayerTizenPlugin] player count: %d", players_.size()); - for (const auto &[id, player] : players_) { player->Dispose(); } players_.clear(); } -void VideoPlayerTizenPlugin::initialize() { - LOG_DEBUG("[VideoPlayerTizenPlugin] initialize"); - +std::optional VideoPlayerTizenPlugin::Initialize() { DisposeAllPlayers(); -} -TextureMessage VideoPlayerTizenPlugin::create(const CreateMessage &createMsg) { - LOG_DEBUG("[VideoPlayerTizenPlugin] asset: %s", createMsg.getAsset().c_str()); - LOG_DEBUG("[VideoPlayerTizenPlugin] uri: %s", createMsg.getUri().c_str()); - LOG_DEBUG("[VideoPlayerTizenPlugin] packageName: %s", - createMsg.getPackageName().c_str()); - LOG_DEBUG("[VideoPlayerTizenPlugin] formatHint: %s", - createMsg.getFormatHint().c_str()); + return std::nullopt; +} +ErrorOr VideoPlayerTizenPlugin::Create( + const CreateMessage &msg) { std::string uri; - if (createMsg.getAsset().empty()) { - uri = createMsg.getUri(); - } else { + if (msg.asset() && !msg.asset()->empty()) { char *res_path = app_get_resource_path(); if (res_path) { - uri = uri + res_path + "flutter_assets/" + createMsg.getAsset(); + uri = uri + res_path + "flutter_assets/" + *msg.asset(); free(res_path); } else { - throw VideoPlayerError("Internal error", "Failed to get resource path."); + return FlutterError("Internal error", "Failed to get resource path."); } + } else if (msg.uri() && !msg.uri()->empty()) { + uri = *msg.uri(); + } else { + return FlutterError("Invalid argument", "Either asset or uri must be set."); + } + LOG_DEBUG("[VideoPlayerTizenPlugin] uri: %s", uri.c_str()); + + int64_t texture_id = 0; + try { + auto player = std::make_unique( + plugin_registrar_, texture_registrar_, uri, options_); + texture_id = player->GetTextureId(); + players_[texture_id] = std::move(player); + } catch (const VideoPlayerError &error) { + return FlutterError(error.code(), error.message()); } - LOG_DEBUG("[VideoPlayerTizenPlugin] player uri: %s", uri.c_str()); - - auto player = std::make_unique( - plugin_registrar_, texture_registrar_, uri, options_); - int64_t texture_id = player->GetTextureId(); - players_[texture_id] = std::move(player); TextureMessage result; - result.setTextureId(texture_id); + result.set_texture_id(texture_id); return result; } -void VideoPlayerTizenPlugin::dispose(const TextureMessage &textureMsg) { - LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", - textureMsg.getTextureId()); +std::optional VideoPlayerTizenPlugin::Dispose( + const TextureMessage &msg) { + LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", msg.texture_id()); - auto iter = players_.find(textureMsg.getTextureId()); + auto iter = players_.find(msg.texture_id()); if (iter != players_.end()) { iter->second->Dispose(); players_.erase(iter); } + + return std::nullopt; } -void VideoPlayerTizenPlugin::setLooping(const LoopingMessage &loopingMsg) { - LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", - loopingMsg.getTextureId()); - LOG_DEBUG("[VideoPlayerTizenPlugin] isLooping: %d", - loopingMsg.getIsLooping()); +std::optional VideoPlayerTizenPlugin::SetLooping( + const LoopingMessage &msg) { + LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", msg.texture_id()); + LOG_DEBUG("[VideoPlayerTizenPlugin] isLooping: %d", msg.is_looping()); - auto iter = players_.find(loopingMsg.getTextureId()); - if (iter != players_.end()) { - iter->second->SetLooping(loopingMsg.getIsLooping()); + auto iter = players_.find(msg.texture_id()); + if (iter == players_.end()) { + return FlutterError("Invalid argument", "Player not found."); } + try { + iter->second->SetLooping(msg.is_looping()); + } catch (const VideoPlayerError &error) { + return FlutterError(error.code(), error.message()); + } + + return std::nullopt; } -void VideoPlayerTizenPlugin::setVolume(const VolumeMessage &volumeMsg) { - LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", - volumeMsg.getTextureId()); - LOG_DEBUG("[VideoPlayerTizenPlugin] volume: %f", volumeMsg.getVolume()); +std::optional VideoPlayerTizenPlugin::SetVolume( + const VolumeMessage &msg) { + LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", msg.texture_id()); + LOG_DEBUG("[VideoPlayerTizenPlugin] volume: %f", msg.volume()); - auto iter = players_.find(volumeMsg.getTextureId()); - if (iter != players_.end()) { - iter->second->SetVolume(volumeMsg.getVolume()); + auto iter = players_.find(msg.texture_id()); + if (iter == players_.end()) { + return FlutterError("Invalid argument", "Player not found."); + } + try { + iter->second->SetVolume(msg.volume()); + } catch (const VideoPlayerError &error) { + return FlutterError(error.code(), error.message()); } + + return std::nullopt; } -void VideoPlayerTizenPlugin::setPlaybackSpeed( - const PlaybackSpeedMessage &speedMsg) { - LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", speedMsg.getTextureId()); - LOG_DEBUG("[VideoPlayerTizenPlugin] speed: %f", speedMsg.getSpeed()); +std::optional VideoPlayerTizenPlugin::SetPlaybackSpeed( + const PlaybackSpeedMessage &msg) { + LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", msg.texture_id()); + LOG_DEBUG("[VideoPlayerTizenPlugin] speed: %f", msg.speed()); - auto iter = players_.find(speedMsg.getTextureId()); - if (iter != players_.end()) { - iter->second->SetPlaybackSpeed(speedMsg.getSpeed()); + auto iter = players_.find(msg.texture_id()); + if (iter == players_.end()) { + return FlutterError("Invalid argument", "Player not found."); + } + try { + iter->second->SetPlaybackSpeed(msg.speed()); + } catch (const VideoPlayerError &error) { + return FlutterError(error.code(), error.message()); } + + return std::nullopt; } -void VideoPlayerTizenPlugin::play(const TextureMessage &textureMsg) { - LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", - textureMsg.getTextureId()); +std::optional VideoPlayerTizenPlugin::Play( + const TextureMessage &msg) { + LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", msg.texture_id()); - auto iter = players_.find(textureMsg.getTextureId()); - if (iter != players_.end()) { + auto iter = players_.find(msg.texture_id()); + if (iter == players_.end()) { + return FlutterError("Invalid argument", "Player not found."); + } + try { iter->second->Play(); + } catch (const VideoPlayerError &error) { + return FlutterError(error.code(), error.message()); } + + return std::nullopt; } -void VideoPlayerTizenPlugin::pause(const TextureMessage &textureMsg) { - LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", - textureMsg.getTextureId()); +std::optional VideoPlayerTizenPlugin::Pause( + const TextureMessage &msg) { + LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", msg.texture_id()); - auto iter = players_.find(textureMsg.getTextureId()); - if (iter != players_.end()) { + auto iter = players_.find(msg.texture_id()); + if (iter == players_.end()) { + return FlutterError("Invalid argument", "Player not found."); + } + try { iter->second->Pause(); + } catch (const VideoPlayerError &error) { + return FlutterError(error.code(), error.message()); } + + return std::nullopt; } -PositionMessage VideoPlayerTizenPlugin::position( - const TextureMessage &textureMsg) { - LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", - textureMsg.getTextureId()); +ErrorOr VideoPlayerTizenPlugin::Position( + const TextureMessage &msg) { + LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", msg.texture_id()); + + auto iter = players_.find(msg.texture_id()); + if (iter == players_.end()) { + return FlutterError("Invalid argument", "Player not found."); + } PositionMessage result; - auto iter = players_.find(textureMsg.getTextureId()); - if (iter != players_.end()) { - result.setTextureId(textureMsg.getTextureId()); - result.setPosition(iter->second->GetPosition()); + result.set_texture_id(msg.texture_id()); + try { + result.set_position(iter->second->GetPosition()); + } catch (const VideoPlayerError &error) { + return FlutterError(error.code(), error.message()); } return result; } -void VideoPlayerTizenPlugin::seekTo( - const PositionMessage &positionMsg, - const SeekCompletedCallback &onSeekCompleted) { - LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", - positionMsg.getTextureId()); - LOG_DEBUG("[VideoPlayerTizenPlugin] position: %ld", - positionMsg.getPosition()); +void VideoPlayerTizenPlugin::SeekTo( + const PositionMessage &msg, + std::function reply)> result) { + LOG_DEBUG("[VideoPlayerTizenPlugin] textureId: %ld", msg.texture_id()); + LOG_DEBUG("[VideoPlayerTizenPlugin] position: %ld", msg.position()); - auto iter = players_.find(positionMsg.getTextureId()); - if (iter != players_.end()) { - iter->second->SeekTo(positionMsg.getPosition(), onSeekCompleted); + auto iter = players_.find(msg.texture_id()); + if (iter == players_.end()) { + result(FlutterError("Invalid argument", "Player not found.")); + return; + } + try { + iter->second->SeekTo(msg.position(), + [result]() -> void { result(std::nullopt); }); + } catch (const VideoPlayerError &error) { + result(FlutterError(error.code(), error.message())); } } -void VideoPlayerTizenPlugin::setMixWithOthers( - const MixWithOthersMessage &mixWithOthersMsg) { +std::optional VideoPlayerTizenPlugin::SetMixWithOthers( + const MixWithOthersMessage &msg) { LOG_DEBUG("[VideoPlayerTizenPlugin] mixWithOthers: %d", - mixWithOthersMsg.getMixWithOthers()); + msg.mix_with_others()); + + options_.SetMixWithOthers(msg.mix_with_others()); - options_.setMixWithOthers(mixWithOthersMsg.getMixWithOthers()); + return std::nullopt; } } // namespace