diff --git a/packages/video_player_avplay/CHANGELOG.md b/packages/video_player_avplay/CHANGELOG.md index 1505320d5..12f44baa7 100644 --- a/packages/video_player_avplay/CHANGELOG.md +++ b/packages/video_player_avplay/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.5.10 + +* Add setDisplayRotate API +* Add setDisplayMode API + ## 0.5.9 * Fix dash player fail to seek issue. diff --git a/packages/video_player_avplay/README.md b/packages/video_player_avplay/README.md index b43238712..d6372a21e 100644 --- a/packages/video_player_avplay/README.md +++ b/packages/video_player_avplay/README.md @@ -12,7 +12,7 @@ To use this package, add `video_player_avplay` as a dependency in your `pubspec. ```yaml dependencies: - video_player_avplay: ^0.5.8 + video_player_avplay: ^0.5.10 ``` Then you can import `video_player_avplay` in your Dart code: diff --git a/packages/video_player_avplay/lib/src/messages.g.dart b/packages/video_player_avplay/lib/src/messages.g.dart index f7e9ede48..ceea36618 100644 --- a/packages/video_player_avplay/lib/src/messages.g.dart +++ b/packages/video_player_avplay/lib/src/messages.g.dart @@ -452,6 +452,58 @@ class BufferConfigMessage { } } +class RotationMessage { + RotationMessage({ + required this.playerId, + required this.rotation, + }); + + int playerId; + + int rotation; + + Object encode() { + return [ + playerId, + rotation, + ]; + } + + static RotationMessage decode(Object result) { + result as List; + return RotationMessage( + playerId: result[0]! as int, + rotation: result[1]! as int, + ); + } +} + +class DisplayModeMessage { + DisplayModeMessage({ + required this.playerId, + required this.displayMode, + }); + + int playerId; + + int displayMode; + + Object encode() { + return [ + playerId, + displayMode, + ]; + } + + static DisplayModeMessage decode(Object result) { + result as List; + return DisplayModeMessage( + playerId: result[0]! as int, + displayMode: result[1]! as int, + ); + } +} + class _VideoPlayerAvplayApiCodec extends StandardMessageCodec { const _VideoPlayerAvplayApiCodec(); @override @@ -462,45 +514,51 @@ class _VideoPlayerAvplayApiCodec extends StandardMessageCodec { } else if (value is CreateMessage) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else if (value is DurationMessage) { + } else if (value is DisplayModeMessage) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else if (value is GeometryMessage) { + } else if (value is DurationMessage) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else if (value is LoopingMessage) { + } else if (value is GeometryMessage) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else if (value is MixWithOthersMessage) { + } else if (value is LoopingMessage) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is PlaybackSpeedMessage) { + } else if (value is MixWithOthersMessage) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is PlayerMessage) { + } else if (value is PlaybackSpeedMessage) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is PositionMessage) { + } else if (value is PlayerMessage) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is SelectedTracksMessage) { + } else if (value is PositionMessage) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is StreamingPropertyMessage) { + } else if (value is RotationMessage) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is StreamingPropertyTypeMessage) { + } else if (value is SelectedTracksMessage) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is TrackMessage) { + } else if (value is StreamingPropertyMessage) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is TrackTypeMessage) { + } else if (value is StreamingPropertyTypeMessage) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is VolumeMessage) { + } else if (value is TrackMessage) { buffer.putUint8(142); writeValue(buffer, value.encode()); + } else if (value is TrackTypeMessage) { + buffer.putUint8(143); + writeValue(buffer, value.encode()); + } else if (value is VolumeMessage) { + buffer.putUint8(144); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -514,30 +572,34 @@ class _VideoPlayerAvplayApiCodec extends StandardMessageCodec { case 129: return CreateMessage.decode(readValue(buffer)!); case 130: - return DurationMessage.decode(readValue(buffer)!); + return DisplayModeMessage.decode(readValue(buffer)!); case 131: - return GeometryMessage.decode(readValue(buffer)!); + return DurationMessage.decode(readValue(buffer)!); case 132: - return LoopingMessage.decode(readValue(buffer)!); + return GeometryMessage.decode(readValue(buffer)!); case 133: - return MixWithOthersMessage.decode(readValue(buffer)!); + return LoopingMessage.decode(readValue(buffer)!); case 134: - return PlaybackSpeedMessage.decode(readValue(buffer)!); + return MixWithOthersMessage.decode(readValue(buffer)!); case 135: - return PlayerMessage.decode(readValue(buffer)!); + return PlaybackSpeedMessage.decode(readValue(buffer)!); case 136: - return PositionMessage.decode(readValue(buffer)!); + return PlayerMessage.decode(readValue(buffer)!); case 137: - return SelectedTracksMessage.decode(readValue(buffer)!); + return PositionMessage.decode(readValue(buffer)!); case 138: - return StreamingPropertyMessage.decode(readValue(buffer)!); + return RotationMessage.decode(readValue(buffer)!); case 139: - return StreamingPropertyTypeMessage.decode(readValue(buffer)!); + return SelectedTracksMessage.decode(readValue(buffer)!); case 140: - return TrackMessage.decode(readValue(buffer)!); + return StreamingPropertyMessage.decode(readValue(buffer)!); case 141: - return TrackTypeMessage.decode(readValue(buffer)!); + return StreamingPropertyTypeMessage.decode(readValue(buffer)!); case 142: + return TrackMessage.decode(readValue(buffer)!); + case 143: + return TrackTypeMessage.decode(readValue(buffer)!); + case 144: return VolumeMessage.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -1059,4 +1121,60 @@ class VideoPlayerAvplayApi { return; } } + + Future setDisplayRotate(RotationMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setDisplayRotate', + codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_msg]) as List?; + if (replyList == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyList.length > 1) { + throw PlatformException( + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], + ); + } else if (replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (replyList[0] as bool?)!; + } + } + + Future setDisplayMode(DisplayModeMessage arg_msg) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.setDisplayMode', + codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_msg]) as List?; + if (replyList == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyList.length > 1) { + throw PlatformException( + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], + ); + } else if (replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (replyList[0] as bool?)!; + } + } } diff --git a/packages/video_player_avplay/lib/src/video_player_tizen.dart b/packages/video_player_avplay/lib/src/video_player_tizen.dart index 483f038c7..a4ec563ff 100644 --- a/packages/video_player_avplay/lib/src/video_player_tizen.dart +++ b/packages/video_player_avplay/lib/src/video_player_tizen.dart @@ -213,6 +213,18 @@ class VideoPlayerTizen extends VideoPlayerPlatform { bufferConfigValue: value)); } + @override + Future setDisplayRotate(int playerId, DisplayRotation rotation) { + return _api.setDisplayRotate( + RotationMessage(playerId: playerId, rotation: rotation.index)); + } + + @override + Future setDisplayMode(int playerId, DisplayMode displayMode) { + return _api.setDisplayMode( + DisplayModeMessage(playerId: playerId, displayMode: displayMode.index)); + } + @override Future setStreamingProperty( int playerId, StreamingPropertyType type, String value) async { diff --git a/packages/video_player_avplay/lib/video_player.dart b/packages/video_player_avplay/lib/video_player.dart index 4428e2985..85ac1c65d 100644 --- a/packages/video_player_avplay/lib/video_player.dart +++ b/packages/video_player_avplay/lib/video_player.dart @@ -756,6 +756,24 @@ class VideoPlayerController extends ValueNotifier { return _videoPlayerPlatform.setBufferConfig(_playerId, type, value); } + /// Set the rotate angle of display + Future setDisplayRotate(DisplayRotation rotation) async { + if (_isDisposedOrNotInitialized) { + return false; + } + + return _videoPlayerPlatform.setDisplayRotate(_playerId, rotation); + } + + /// Set the video display mode. + Future setDisplayMode(DisplayMode displayMode) async { + if (_isDisposedOrNotInitialized) { + return false; + } + + return _videoPlayerPlatform.setDisplayMode(_playerId, displayMode); + } + /// Sets the playback speed of [this]. /// /// [speed] indicates a speed value with different platforms accepting diff --git a/packages/video_player_avplay/lib/video_player_platform_interface.dart b/packages/video_player_avplay/lib/video_player_platform_interface.dart index 705fd2736..2f64ac1c6 100644 --- a/packages/video_player_avplay/lib/video_player_platform_interface.dart +++ b/packages/video_player_avplay/lib/video_player_platform_interface.dart @@ -144,6 +144,16 @@ abstract class VideoPlayerPlatform extends PlatformInterface { throw UnimplementedError('setBufferConfig() has not been implemented.'); } + /// Set the rotate angle of display. + Future setDisplayRotate(int playerId, DisplayRotation rotation) { + throw UnimplementedError('setDisplayRotate() has not been implemented.'); + } + + /// Set the video display mode. + Future setDisplayMode(int playerId, DisplayMode displayMode) { + throw UnimplementedError('setDisplayMode() has not been implemented.'); + } + /// Set streamingengine property. Future setStreamingProperty( int playerId, StreamingPropertyType type, String value) { @@ -353,6 +363,48 @@ enum BufferConfigType { bufferingTimeoutInSecForPlay, } +/// The different types of display rotations that can be set on the player. +enum DisplayRotation { + /// No rotation. + rotation0, + + /// 90 degrees rotation. + rotation90, + + /// 180 degrees rotation. + rotation180, + + /// 270 degrees rotation. + rotation270, +} + +/// Sets the video screen mode in the specified display area. +enum DisplayMode { + /// player display mode letter box + letterBox, + + /// player display mode origin size + originSize, + + /// player display mode full screen + fullScreen, + + /// player display mode cropped full + croppedFull, + + /// player display mode origin or letter + originOrLetter, + + /// player display mode dst roi + dstRoi, + + /// player display mode auto aspect ratio + autoAspectRatio, + + /// player display mode dst roi auto aspect ratio + dstRoiAutoAspectRatio, +} + /// Event emitted from the platform implementation. @immutable class VideoEvent { diff --git a/packages/video_player_avplay/pigeons/messages.dart b/packages/video_player_avplay/pigeons/messages.dart index c98dd14e7..d80b1d029 100644 --- a/packages/video_player_avplay/pigeons/messages.dart +++ b/packages/video_player_avplay/pigeons/messages.dart @@ -111,6 +111,24 @@ class BufferConfigMessage { int bufferConfigValue; } +class RotationMessage { + RotationMessage( + this.playerId, + this.rotation, + ); + int playerId; + int rotation; +} + +class DisplayModeMessage { + DisplayModeMessage( + this.playerId, + this.displayMode, + ); + int playerId; + int displayMode; +} + @HostApi() abstract class VideoPlayerAvplayApi { void initialize(); @@ -134,4 +152,6 @@ abstract class VideoPlayerAvplayApi { String getStreamingProperty(StreamingPropertyTypeMessage msg); bool setBufferConfig(BufferConfigMessage msg); void setStreamingProperty(StreamingPropertyMessage msg); + bool setDisplayRotate(RotationMessage msg); + bool setDisplayMode(DisplayModeMessage msg); } diff --git a/packages/video_player_avplay/pubspec.yaml b/packages/video_player_avplay/pubspec.yaml index f65adc55a..3fbf89574 100644 --- a/packages/video_player_avplay/pubspec.yaml +++ b/packages/video_player_avplay/pubspec.yaml @@ -2,7 +2,7 @@ name: video_player_avplay description: Flutter plugin for displaying inline video on Tizen TV devices. homepage: https://github.com/flutter-tizen/plugins repository: https://github.com/flutter-tizen/plugins/tree/master/packages/video_player_avplay -version: 0.5.8 +version: 0.5.10 environment: sdk: ">=3.1.0 <4.0.0" diff --git a/packages/video_player_avplay/tizen/src/media_player.cc b/packages/video_player_avplay/tizen/src/media_player.cc index e25512c43..6f90ad91f 100644 --- a/packages/video_player_avplay/tizen/src/media_player.cc +++ b/packages/video_player_avplay/tizen/src/media_player.cc @@ -729,3 +729,30 @@ int MediaPlayer::OnDrmUpdatePsshData(drm_init_data_type init_type, void *data, } return 0; } + +bool MediaPlayer::SetDisplayRotate(int64_t rotation) { + LOG_INFO("[MediaPlayer] rotation: %d", rotation); + int ret = player_set_display_rotation( + player_, static_cast(rotation)); + if (ret != PLAYER_ERROR_NONE) { + LOG_ERROR("[MediaPlayer] player_set_display_rotation failed: %s", + get_error_message(ret)); + return false; + } + return true; +} +bool MediaPlayer::SetDisplayMode(int64_t display_mode) { + LOG_INFO("[MediaPlayer] display_mode: %d", display_mode); + if (display_mode > PLAYER_DISPLAY_MODE_NUM) { + LOG_ERROR("[MediaPlayer] display mode out of range"); + return false; + } + int ret = player_set_display_mode( + player_, static_cast(display_mode)); + if (ret != PLAYER_ERROR_NONE) { + LOG_ERROR("[MediaPlayer] player_set_display_mode failed: %s", + get_error_message(ret)); + return false; + } + return true; +} diff --git a/packages/video_player_avplay/tizen/src/media_player.h b/packages/video_player_avplay/tizen/src/media_player.h index 4f3eb47ed..c8d091315 100644 --- a/packages/video_player_avplay/tizen/src/media_player.h +++ b/packages/video_player_avplay/tizen/src/media_player.h @@ -39,6 +39,8 @@ class MediaPlayer : public VideoPlayer { bool IsReady() override; flutter::EncodableList GetTrackInfo(std::string track_type) override; bool SetTrackSelection(int32_t track_id, std::string track_type) override; + bool SetDisplayRotate(int64_t rotation) override; + bool SetDisplayMode(int64_t display_mode) override; private: bool IsLive(); diff --git a/packages/video_player_avplay/tizen/src/messages.cc b/packages/video_player_avplay/tizen/src/messages.cc index b71a28ab8..8a30df162 100644 --- a/packages/video_player_avplay/tizen/src/messages.cc +++ b/packages/video_player_avplay/tizen/src/messages.cc @@ -695,6 +695,65 @@ BufferConfigMessage BufferConfigMessage::FromEncodableList( return decoded; } +// RotationMessage + +RotationMessage::RotationMessage(int64_t player_id, int64_t rotation) + : player_id_(player_id), rotation_(rotation) {} + +int64_t RotationMessage::player_id() const { return player_id_; } + +void RotationMessage::set_player_id(int64_t value_arg) { + player_id_ = value_arg; +} + +int64_t RotationMessage::rotation() const { return rotation_; } + +void RotationMessage::set_rotation(int64_t value_arg) { rotation_ = value_arg; } + +EncodableList RotationMessage::ToEncodableList() const { + EncodableList list; + list.reserve(2); + list.push_back(EncodableValue(player_id_)); + list.push_back(EncodableValue(rotation_)); + return list; +} + +RotationMessage RotationMessage::FromEncodableList(const EncodableList& list) { + RotationMessage decoded(list[0].LongValue(), list[1].LongValue()); + return decoded; +} + +// DisplayModeMessage + +DisplayModeMessage::DisplayModeMessage(int64_t player_id, int64_t display_mode) + : player_id_(player_id), display_mode_(display_mode) {} + +int64_t DisplayModeMessage::player_id() const { return player_id_; } + +void DisplayModeMessage::set_player_id(int64_t value_arg) { + player_id_ = value_arg; +} + +int64_t DisplayModeMessage::display_mode() const { return display_mode_; } + +void DisplayModeMessage::set_display_mode(int64_t value_arg) { + display_mode_ = value_arg; +} + +EncodableList DisplayModeMessage::ToEncodableList() const { + EncodableList list; + list.reserve(2); + list.push_back(EncodableValue(player_id_)); + list.push_back(EncodableValue(display_mode_)); + return list; +} + +DisplayModeMessage DisplayModeMessage::FromEncodableList( + const EncodableList& list) { + DisplayModeMessage decoded(list[0].LongValue(), list[1].LongValue()); + return decoded; +} + VideoPlayerAvplayApiCodecSerializer::VideoPlayerAvplayApiCodecSerializer() {} EncodableValue VideoPlayerAvplayApiCodecSerializer::ReadValueOfType( @@ -707,43 +766,49 @@ EncodableValue VideoPlayerAvplayApiCodecSerializer::ReadValueOfType( return CustomEncodableValue(CreateMessage::FromEncodableList( std::get(ReadValue(stream)))); case 130: - return CustomEncodableValue(DurationMessage::FromEncodableList( + return CustomEncodableValue(DisplayModeMessage::FromEncodableList( std::get(ReadValue(stream)))); case 131: - return CustomEncodableValue(GeometryMessage::FromEncodableList( + return CustomEncodableValue(DurationMessage::FromEncodableList( std::get(ReadValue(stream)))); case 132: - return CustomEncodableValue(LoopingMessage::FromEncodableList( + return CustomEncodableValue(GeometryMessage::FromEncodableList( std::get(ReadValue(stream)))); case 133: - return CustomEncodableValue(MixWithOthersMessage::FromEncodableList( + return CustomEncodableValue(LoopingMessage::FromEncodableList( std::get(ReadValue(stream)))); case 134: - return CustomEncodableValue(PlaybackSpeedMessage::FromEncodableList( + return CustomEncodableValue(MixWithOthersMessage::FromEncodableList( std::get(ReadValue(stream)))); case 135: - return CustomEncodableValue(PlayerMessage::FromEncodableList( + return CustomEncodableValue(PlaybackSpeedMessage::FromEncodableList( std::get(ReadValue(stream)))); case 136: - return CustomEncodableValue(PositionMessage::FromEncodableList( + return CustomEncodableValue(PlayerMessage::FromEncodableList( std::get(ReadValue(stream)))); case 137: - return CustomEncodableValue(SelectedTracksMessage::FromEncodableList( + return CustomEncodableValue(PositionMessage::FromEncodableList( std::get(ReadValue(stream)))); case 138: - return CustomEncodableValue(StreamingPropertyMessage::FromEncodableList( + return CustomEncodableValue(RotationMessage::FromEncodableList( std::get(ReadValue(stream)))); case 139: + return CustomEncodableValue(SelectedTracksMessage::FromEncodableList( + std::get(ReadValue(stream)))); + case 140: + return CustomEncodableValue(StreamingPropertyMessage::FromEncodableList( + std::get(ReadValue(stream)))); + case 141: return CustomEncodableValue( StreamingPropertyTypeMessage::FromEncodableList( std::get(ReadValue(stream)))); - case 140: + case 142: return CustomEncodableValue(TrackMessage::FromEncodableList( std::get(ReadValue(stream)))); - case 141: + case 143: return CustomEncodableValue(TrackTypeMessage::FromEncodableList( std::get(ReadValue(stream)))); - case 142: + case 144: return CustomEncodableValue(VolumeMessage::FromEncodableList( std::get(ReadValue(stream)))); default: @@ -771,8 +836,15 @@ void VideoPlayerAvplayApiCodecSerializer::WriteValue( stream); return; } - if (custom_value->type() == typeid(DurationMessage)) { + if (custom_value->type() == typeid(DisplayModeMessage)) { stream->WriteByte(130); + WriteValue(EncodableValue(std::any_cast(*custom_value) + .ToEncodableList()), + stream); + return; + } + if (custom_value->type() == typeid(DurationMessage)) { + stream->WriteByte(131); WriteValue( EncodableValue( std::any_cast(*custom_value).ToEncodableList()), @@ -780,7 +852,7 @@ void VideoPlayerAvplayApiCodecSerializer::WriteValue( return; } if (custom_value->type() == typeid(GeometryMessage)) { - stream->WriteByte(131); + stream->WriteByte(132); WriteValue( EncodableValue( std::any_cast(*custom_value).ToEncodableList()), @@ -788,7 +860,7 @@ void VideoPlayerAvplayApiCodecSerializer::WriteValue( return; } if (custom_value->type() == typeid(LoopingMessage)) { - stream->WriteByte(132); + stream->WriteByte(133); WriteValue( EncodableValue( std::any_cast(*custom_value).ToEncodableList()), @@ -796,7 +868,7 @@ void VideoPlayerAvplayApiCodecSerializer::WriteValue( return; } if (custom_value->type() == typeid(MixWithOthersMessage)) { - stream->WriteByte(133); + stream->WriteByte(134); WriteValue( EncodableValue(std::any_cast(*custom_value) .ToEncodableList()), @@ -804,7 +876,7 @@ void VideoPlayerAvplayApiCodecSerializer::WriteValue( return; } if (custom_value->type() == typeid(PlaybackSpeedMessage)) { - stream->WriteByte(134); + stream->WriteByte(135); WriteValue( EncodableValue(std::any_cast(*custom_value) .ToEncodableList()), @@ -812,7 +884,7 @@ void VideoPlayerAvplayApiCodecSerializer::WriteValue( return; } if (custom_value->type() == typeid(PlayerMessage)) { - stream->WriteByte(135); + stream->WriteByte(136); WriteValue( EncodableValue( std::any_cast(*custom_value).ToEncodableList()), @@ -820,15 +892,23 @@ void VideoPlayerAvplayApiCodecSerializer::WriteValue( return; } if (custom_value->type() == typeid(PositionMessage)) { - stream->WriteByte(136); + stream->WriteByte(137); WriteValue( EncodableValue( std::any_cast(*custom_value).ToEncodableList()), stream); return; } + if (custom_value->type() == typeid(RotationMessage)) { + stream->WriteByte(138); + WriteValue( + EncodableValue( + std::any_cast(*custom_value).ToEncodableList()), + stream); + return; + } if (custom_value->type() == typeid(SelectedTracksMessage)) { - stream->WriteByte(137); + stream->WriteByte(139); WriteValue( EncodableValue(std::any_cast(*custom_value) .ToEncodableList()), @@ -836,7 +916,7 @@ void VideoPlayerAvplayApiCodecSerializer::WriteValue( return; } if (custom_value->type() == typeid(StreamingPropertyMessage)) { - stream->WriteByte(138); + stream->WriteByte(140); WriteValue( EncodableValue(std::any_cast(*custom_value) .ToEncodableList()), @@ -844,7 +924,7 @@ void VideoPlayerAvplayApiCodecSerializer::WriteValue( return; } if (custom_value->type() == typeid(StreamingPropertyTypeMessage)) { - stream->WriteByte(139); + stream->WriteByte(141); WriteValue(EncodableValue( std::any_cast(*custom_value) .ToEncodableList()), @@ -852,7 +932,7 @@ void VideoPlayerAvplayApiCodecSerializer::WriteValue( return; } if (custom_value->type() == typeid(TrackMessage)) { - stream->WriteByte(140); + stream->WriteByte(142); WriteValue( EncodableValue( std::any_cast(*custom_value).ToEncodableList()), @@ -860,7 +940,7 @@ void VideoPlayerAvplayApiCodecSerializer::WriteValue( return; } if (custom_value->type() == typeid(TrackTypeMessage)) { - stream->WriteByte(141); + stream->WriteByte(143); WriteValue( EncodableValue( std::any_cast(*custom_value).ToEncodableList()), @@ -868,7 +948,7 @@ void VideoPlayerAvplayApiCodecSerializer::WriteValue( return; } if (custom_value->type() == typeid(VolumeMessage)) { - stream->WriteByte(142); + stream->WriteByte(144); WriteValue( EncodableValue( std::any_cast(*custom_value).ToEncodableList()), @@ -1584,6 +1664,76 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger, channel->SetMessageHandler(nullptr); } } + { + auto channel = std::make_unique>( + binary_messenger, + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi." + "setDisplayRotate", + &GetCodec()); + if (api != nullptr) { + channel->SetMessageHandler( + [api](const EncodableValue& message, + const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_msg_arg = args.at(0); + if (encodable_msg_arg.IsNull()) { + reply(WrapError("msg_arg unexpectedly null.")); + return; + } + const auto& msg_arg = std::any_cast( + std::get(encodable_msg_arg)); + ErrorOr output = api->SetDisplayRotate(msg_arg); + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); + } else { + channel->SetMessageHandler(nullptr); + } + } + { + auto channel = std::make_unique>( + binary_messenger, + "dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi." + "setDisplayMode", + &GetCodec()); + if (api != nullptr) { + channel->SetMessageHandler( + [api](const EncodableValue& message, + const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_msg_arg = args.at(0); + if (encodable_msg_arg.IsNull()) { + reply(WrapError("msg_arg unexpectedly null.")); + return; + } + const auto& msg_arg = std::any_cast( + std::get(encodable_msg_arg)); + ErrorOr output = api->SetDisplayMode(msg_arg); + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); + } else { + channel->SetMessageHandler(nullptr); + } + } } EncodableValue VideoPlayerAvplayApi::WrapError(std::string_view error_message) { diff --git a/packages/video_player_avplay/tizen/src/messages.h b/packages/video_player_avplay/tizen/src/messages.h index 3946daeb6..8cf10c064 100644 --- a/packages/video_player_avplay/tizen/src/messages.h +++ b/packages/video_player_avplay/tizen/src/messages.h @@ -444,6 +444,49 @@ class BufferConfigMessage { int64_t buffer_config_value_; }; +// Generated class from Pigeon that represents data sent in messages. +class RotationMessage { + public: + // Constructs an object setting all fields. + explicit RotationMessage(int64_t player_id, int64_t rotation); + + int64_t player_id() const; + void set_player_id(int64_t value_arg); + + int64_t rotation() const; + void set_rotation(int64_t value_arg); + + private: + static RotationMessage FromEncodableList(const flutter::EncodableList& list); + flutter::EncodableList ToEncodableList() const; + friend class VideoPlayerAvplayApi; + friend class VideoPlayerAvplayApiCodecSerializer; + int64_t player_id_; + int64_t rotation_; +}; + +// Generated class from Pigeon that represents data sent in messages. +class DisplayModeMessage { + public: + // Constructs an object setting all fields. + explicit DisplayModeMessage(int64_t player_id, int64_t display_mode); + + int64_t player_id() const; + void set_player_id(int64_t value_arg); + + int64_t display_mode() const; + void set_display_mode(int64_t value_arg); + + private: + static DisplayModeMessage FromEncodableList( + const flutter::EncodableList& list); + flutter::EncodableList ToEncodableList() const; + friend class VideoPlayerAvplayApi; + friend class VideoPlayerAvplayApiCodecSerializer; + int64_t player_id_; + int64_t display_mode_; +}; + class VideoPlayerAvplayApiCodecSerializer : public flutter::StandardCodecSerializer { public: @@ -495,6 +538,8 @@ class VideoPlayerAvplayApi { virtual ErrorOr SetBufferConfig(const BufferConfigMessage& msg) = 0; virtual std::optional SetStreamingProperty( const StreamingPropertyMessage& msg) = 0; + virtual ErrorOr SetDisplayRotate(const RotationMessage& msg) = 0; + virtual ErrorOr SetDisplayMode(const DisplayModeMessage& msg) = 0; // The codec used by VideoPlayerAvplayApi. static const flutter::StandardMessageCodec& GetCodec(); diff --git a/packages/video_player_avplay/tizen/src/plus_player.cc b/packages/video_player_avplay/tizen/src/plus_player.cc index 90ed622bf..9ad13407d 100644 --- a/packages/video_player_avplay/tizen/src/plus_player.cc +++ b/packages/video_player_avplay/tizen/src/plus_player.cc @@ -411,7 +411,7 @@ bool PlusPlayer::SetDisplay() { return false; } - ret = SetDisplayMode(player_, plusplayer::DisplayMode::kDstRoi); + ret = ::SetDisplayMode(player_, plusplayer::DisplayMode::kDstRoi); if (!ret) { LOG_ERROR("[PlusPlayer] Player fail to set display mode."); return false; @@ -631,6 +631,38 @@ void PlusPlayer::SetStreamingProperty(const std::string &type, ::SetStreamingProperty(player_, type, value); } +bool PlusPlayer::SetDisplayRotate(int64_t rotation) { + if (!player_) { + LOG_ERROR("[PlusPlayer] Player not created."); + return false; + } + + plusplayer::State state = GetState(player_); + if (state == plusplayer::State::kNone) { + LOG_ERROR("[PlusPlayer] Player is in invalid state[%d]", state); + return false; + } + + LOG_INFO("[PlusPlayer] rotation: %d", rotation); + return ::SetDisplayRotate(player_, + static_cast(rotation)); +} + +bool PlusPlayer::SetDisplayMode(int64_t display_mode) { + if (!player_) { + LOG_ERROR("[PlusPlayer] Player not created."); + return false; + } + + plusplayer::State state = GetState(player_); + if (state == plusplayer::State::kNone) { + LOG_ERROR("[PlusPlayer] Player is in invalid state[%d]", state); + return false; + } + LOG_INFO("[PlusPlayer] display_mode: %d", display_mode); + ::SetDisplayMode(player_, static_cast(display_mode)); +} + bool PlusPlayer::OnLicenseAcquired(int *drm_handle, unsigned int length, unsigned char *pssh_data, void *user_data) { LOG_INFO("[PlusPlayer] License acquired."); diff --git a/packages/video_player_avplay/tizen/src/plus_player.h b/packages/video_player_avplay/tizen/src/plus_player.h index 348b6eb5c..874eeedd6 100644 --- a/packages/video_player_avplay/tizen/src/plus_player.h +++ b/packages/video_player_avplay/tizen/src/plus_player.h @@ -46,6 +46,8 @@ class PlusPlayer : public VideoPlayer { bool SetBufferConfig(const std::string &key, int64_t value) override; void SetStreamingProperty(const std::string &type, const std::string &value) override; + bool SetDisplayRotate(int64_t rotation) override; + bool SetDisplayMode(int64_t display_mode) override; private: bool IsLive(); diff --git a/packages/video_player_avplay/tizen/src/video_player.h b/packages/video_player_avplay/tizen/src/video_player.h index 74a88631a..99cd3c705 100644 --- a/packages/video_player_avplay/tizen/src/video_player.h +++ b/packages/video_player_avplay/tizen/src/video_player.h @@ -55,9 +55,10 @@ class VideoPlayer { virtual bool SetBufferConfig(const std::string &key, int64_t value) { return false; }; - virtual void SetStreamingProperty(const std::string &type, const std::string &value){}; + virtual bool SetDisplayRotate(int64_t rotation) = 0; + virtual bool SetDisplayMode(int64_t display_mode) = 0; protected: virtual void GetVideoSize(int32_t *width, int32_t *height) = 0; diff --git a/packages/video_player_avplay/tizen/src/video_player_tizen_plugin.cc b/packages/video_player_avplay/tizen/src/video_player_tizen_plugin.cc index 03836dcfd..29de99c6d 100644 --- a/packages/video_player_avplay/tizen/src/video_player_tizen_plugin.cc +++ b/packages/video_player_avplay/tizen/src/video_player_tizen_plugin.cc @@ -61,6 +61,9 @@ class VideoPlayerTizenPlugin : public flutter::Plugin, std::optional SetStreamingProperty( const StreamingPropertyMessage &msg) override; + ErrorOr SetDisplayRotate(const RotationMessage &msg) override; + ErrorOr SetDisplayMode(const DisplayModeMessage &msg) override; + static VideoPlayer *FindPlayerById(int64_t player_id) { auto iter = players_.find(player_id); if (iter != players_.end()) { @@ -323,6 +326,24 @@ ErrorOr VideoPlayerTizenPlugin::SetBufferConfig( msg.buffer_config_value()); } +ErrorOr VideoPlayerTizenPlugin::SetDisplayRotate( + const RotationMessage &msg) { + VideoPlayer *player = FindPlayerById(msg.player_id()); + if (!player) { + return FlutterError("Invalid argument", "Player not found"); + } + return player->SetDisplayRotate(msg.rotation()); +} + +ErrorOr VideoPlayerTizenPlugin::SetDisplayMode( + const DisplayModeMessage &msg) { + VideoPlayer *player = FindPlayerById(msg.player_id()); + if (!player) { + return FlutterError("Invalid argument", "Player not found"); + } + return player->SetDisplayMode(msg.display_mode()); +} + std::optional VideoPlayerTizenPlugin::SetStreamingProperty( const StreamingPropertyMessage &msg) { VideoPlayer *player = FindPlayerById(msg.player_id());