From ccbb015a453a7c41f4d6f61af7a8264da115e708 Mon Sep 17 00:00:00 2001 From: KnosTx <135945845+KnosTx@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:39:52 +0700 Subject: [PATCH 01/13] Create VideoStreamConnectPacket.php --- src/VideoStreamConnectPacket.php | 81 ++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/VideoStreamConnectPacket.php diff --git a/src/VideoStreamConnectPacket.php b/src/VideoStreamConnectPacket.php new file mode 100644 index 00000000..755ad119 --- /dev/null +++ b/src/VideoStreamConnectPacket.php @@ -0,0 +1,81 @@ + + * + * BedrockProtocol is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + */ + +declare(strict_types=1); + +namespace pocketmine\network\mcpe\protocol; + +use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; +use pocketmine\network\mcpe\protocol\types\VideoStreamAction; + +class VideoStreamConnectPacket extends DataPacket implements ClientboundPacket { + public const NETWORK_ID = ProtocolInfo::VIDEO_STREAM_CONNECT_PACKET; + + /** @var string */ + public string $address; + + /** @var float */ + public float $screenshotFrequency; + + /** @var int */ + public int $action; + + /** @var int */ + public int $width; + + /** @var int */ + public int $height; + + /** + * @generate-create-func + * @param string $address + * @param float $screenshotFrequency + * @param int $action + * @param int $width + * @param int $height + */ + public static function create( + string $address, + float $screenshotFrequency, + int $action, + int $width, + int $height + ) : self { + $result = new self; + $result->address = $address; + $result->screenshotFrequency = $screenshotFrequency; + $result->action = $action; + $result->width = $width; + $result->height = $height; + return $result; + } + + protected function decodePayload(PacketSerializer $in) : void{ + $this->address = $in->getString(); + $this->screenshotFrequency = $in->getLFloat(); + $this->action = $in->getUnsignedVarInt(); + $this->width = $in->getVarInt(); + $this->height = $in->getVarInt(); + } + + protected function encodePayload(PacketSerializer $out) : void{ + $out->putString($this->address); + $out->putLFloat($this->screenshotFrequency); + $out->putUnsignedVarInt($this->action); + $out->putVarInt($this->width); + $out->putVarInt($this->height); + } + + public function handle(PacketHandlerInterface $handler) : bool{ + return $handler->handleVideoStreamConnect($this); + } +} From a5792d3053c1dd6fbff846533059f5a11d7692c6 Mon Sep 17 00:00:00 2001 From: KnosTx <135945845+KnosTx@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:40:52 +0700 Subject: [PATCH 02/13] Create VideoStreamAction.php --- src/types/VideoStreamAction.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/types/VideoStreamAction.php diff --git a/src/types/VideoStreamAction.php b/src/types/VideoStreamAction.php new file mode 100644 index 00000000..dda26e16 --- /dev/null +++ b/src/types/VideoStreamAction.php @@ -0,0 +1,20 @@ + + * + * BedrockProtocol is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + */ + +declare(strict_types=1); + +namespace pocketmine\network\mcpe\protocol\types; + +final class VideoStreamAction{ + public const OPEN = 0; + public const CLOSE = 1; +} From 98efa4089e6e9e9a39d08e75e24360bbe1d8f050 Mon Sep 17 00:00:00 2001 From: KnosTx <135945845+KnosTx@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:42:58 +0700 Subject: [PATCH 03/13] Update PacketPool.php --- src/PacketPool.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PacketPool.php b/src/PacketPool.php index 8813e6e1..2ac12a85 100644 --- a/src/PacketPool.php +++ b/src/PacketPool.php @@ -238,6 +238,7 @@ public function __construct(){ $this->registerPacket(new MovementEffectPacket()); $this->registerPacket(new SetMovementAuthorityPacket()); $this->registerPacket(new CameraAimAssistPresetsPacket()); + $this->registerPacket(new VideoStreamConnectPacket()); } public function registerPacket(Packet $packet) : void{ From e30e589285b71706a9b6fd47a642a20d8952f9da Mon Sep 17 00:00:00 2001 From: KnosTx <135945845+KnosTx@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:45:39 +0700 Subject: [PATCH 04/13] Update PacketHandlerInterface.php --- src/PacketHandlerInterface.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PacketHandlerInterface.php b/src/PacketHandlerInterface.php index 70d7fa93..0c4dcf5c 100644 --- a/src/PacketHandlerInterface.php +++ b/src/PacketHandlerInterface.php @@ -427,4 +427,6 @@ public function handleMovementEffect(MovementEffectPacket $packet) : bool; public function handleSetMovementAuthority(SetMovementAuthorityPacket $packet) : bool; public function handleCameraAimAssistPresets(CameraAimAssistPresetsPacket $packet) : bool; + + public function handleVideoStreamConnect(VideoStreamConnectPacket $packet) : bool; } From d47cdd8e09e9d0e2744bef30838d7b9ba06f75b1 Mon Sep 17 00:00:00 2001 From: KnosTx <135945845+KnosTx@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:47:33 +0700 Subject: [PATCH 05/13] Add file via upload --- src/ProtocolInfo.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ProtocolInfo.php b/src/ProtocolInfo.php index b373de66..eae0a804 100644 --- a/src/ProtocolInfo.php +++ b/src/ProtocolInfo.php @@ -256,4 +256,5 @@ private function __construct(){ public const MOVEMENT_EFFECT_PACKET = 0x13e; public const SET_MOVEMENT_AUTHORITY_PACKET = 0x13f; public const CAMERA_AIM_ASSIST_PRESETS_PACKET = 0x140; + public const VIDEO_STREAM_CONNECT_PACKET = 0x141; } From 435767ecef8950eaca5bede367e54bfc96c5df44 Mon Sep 17 00:00:00 2001 From: KnosTx <135945845+KnosTx@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:01:29 +0700 Subject: [PATCH 06/13] Update VideoStreamConnectPacket.php --- src/VideoStreamConnectPacket.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/VideoStreamConnectPacket.php b/src/VideoStreamConnectPacket.php index 755ad119..0c3ada47 100644 --- a/src/VideoStreamConnectPacket.php +++ b/src/VideoStreamConnectPacket.php @@ -17,31 +17,21 @@ use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; use pocketmine\network\mcpe\protocol\types\VideoStreamAction; -class VideoStreamConnectPacket extends DataPacket implements ClientboundPacket { +class VideoStreamConnectPacket extends DataPacket implements ClientboundPacket{ public const NETWORK_ID = ProtocolInfo::VIDEO_STREAM_CONNECT_PACKET; - /** @var string */ public string $address; - /** @var float */ public float $screenshotFrequency; - /** @var int */ public int $action; - /** @var int */ public int $width; - /** @var int */ public int $height; /** * @generate-create-func - * @param string $address - * @param float $screenshotFrequency - * @param int $action - * @param int $width - * @param int $height */ public static function create( string $address, From 26e0e0bbad530b8fca59b0aa0956949e8ebf41ac Mon Sep 17 00:00:00 2001 From: KnosTx <135945845+KnosTx@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:10:35 +0700 Subject: [PATCH 07/13] Update VideoStreamConnectPacket.php --- src/VideoStreamConnectPacket.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/VideoStreamConnectPacket.php b/src/VideoStreamConnectPacket.php index 0c3ada47..fef6dd9c 100644 --- a/src/VideoStreamConnectPacket.php +++ b/src/VideoStreamConnectPacket.php @@ -32,6 +32,7 @@ class VideoStreamConnectPacket extends DataPacket implements ClientboundPacket{ /** * @generate-create-func + * @phpstan-param VideoStreamAction::* $action */ public static function create( string $address, From a42304f2f180a14edca02072b5694dc57d4bb18e Mon Sep 17 00:00:00 2001 From: KnosTx <135945845+KnosTx@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:13:06 +0700 Subject: [PATCH 08/13] Fix --- src/VideoStreamConnectPacket.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/VideoStreamConnectPacket.php b/src/VideoStreamConnectPacket.php index fef6dd9c..0fd79e70 100644 --- a/src/VideoStreamConnectPacket.php +++ b/src/VideoStreamConnectPacket.php @@ -34,13 +34,7 @@ class VideoStreamConnectPacket extends DataPacket implements ClientboundPacket{ * @generate-create-func * @phpstan-param VideoStreamAction::* $action */ - public static function create( - string $address, - float $screenshotFrequency, - int $action, - int $width, - int $height - ) : self { + public static function create(string $address, float $screenshotFrequency, int $action, int $width, int $height) : self{ $result = new self; $result->address = $address; $result->screenshotFrequency = $screenshotFrequency; From 1b2e03e8d63eb6943cf4003dd7a3898062f05b2c Mon Sep 17 00:00:00 2001 From: KnosTx <135945845+KnosTx@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:16:10 +0700 Subject: [PATCH 09/13] fix CS --- src/VideoStreamConnectPacket.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/VideoStreamConnectPacket.php b/src/VideoStreamConnectPacket.php index 0fd79e70..30ce53fe 100644 --- a/src/VideoStreamConnectPacket.php +++ b/src/VideoStreamConnectPacket.php @@ -15,7 +15,6 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use pocketmine\network\mcpe\protocol\types\VideoStreamAction; class VideoStreamConnectPacket extends DataPacket implements ClientboundPacket{ public const NETWORK_ID = ProtocolInfo::VIDEO_STREAM_CONNECT_PACKET; @@ -32,7 +31,6 @@ class VideoStreamConnectPacket extends DataPacket implements ClientboundPacket{ /** * @generate-create-func - * @phpstan-param VideoStreamAction::* $action */ public static function create(string $address, float $screenshotFrequency, int $action, int $width, int $height) : self{ $result = new self; From 9ed1773082ed681a1b5631592573ee8ae52067a9 Mon Sep 17 00:00:00 2001 From: KnosTx <135945845+KnosTx@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:28:32 +0700 Subject: [PATCH 10/13] Update VideoStreamConnectPacket.php --- src/VideoStreamConnectPacket.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/VideoStreamConnectPacket.php b/src/VideoStreamConnectPacket.php index 30ce53fe..2d591b2d 100644 --- a/src/VideoStreamConnectPacket.php +++ b/src/VideoStreamConnectPacket.php @@ -23,6 +23,10 @@ class VideoStreamConnectPacket extends DataPacket implements ClientboundPacket{ public float $screenshotFrequency; + /** + * @var int + * @phpstan-var VideoStreamAction::* + */ public int $action; public int $width; @@ -31,6 +35,7 @@ class VideoStreamConnectPacket extends DataPacket implements ClientboundPacket{ /** * @generate-create-func + * @phpstan-var VideoStreamAction::* */ public static function create(string $address, float $screenshotFrequency, int $action, int $width, int $height) : self{ $result = new self; From f20c6782e0501cbb5e56d36afd6e7f8ce537302d Mon Sep 17 00:00:00 2001 From: KnosTx <135945845+KnosTx@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:37:30 +0700 Subject: [PATCH 11/13] Update VideoStreamConnectPacket.php --- src/VideoStreamConnectPacket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VideoStreamConnectPacket.php b/src/VideoStreamConnectPacket.php index 2d591b2d..a572f74e 100644 --- a/src/VideoStreamConnectPacket.php +++ b/src/VideoStreamConnectPacket.php @@ -24,7 +24,7 @@ class VideoStreamConnectPacket extends DataPacket implements ClientboundPacket{ public float $screenshotFrequency; /** - * @var int + * @var int Action type * @phpstan-var VideoStreamAction::* */ public int $action; From 8310b26a70971c88867023d9236ece14e0a3d71c Mon Sep 17 00:00:00 2001 From: KnosTx <135945845+KnosTx@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:38:33 +0700 Subject: [PATCH 12/13] Update VideoStreamConnectPacket.php --- src/VideoStreamConnectPacket.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/VideoStreamConnectPacket.php b/src/VideoStreamConnectPacket.php index a572f74e..a6b17228 100644 --- a/src/VideoStreamConnectPacket.php +++ b/src/VideoStreamConnectPacket.php @@ -15,6 +15,7 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; +use pocketmine\network\mcpe\protocol\types\VideoStreamAction; class VideoStreamConnectPacket extends DataPacket implements ClientboundPacket{ public const NETWORK_ID = ProtocolInfo::VIDEO_STREAM_CONNECT_PACKET; From e565b2cd135f77d8322cb51944b95a13952ca02f Mon Sep 17 00:00:00 2001 From: KnosTx <135945845+KnosTx@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:45:26 +0700 Subject: [PATCH 13/13] Update VideoStreamConnectPacket.php --- src/VideoStreamConnectPacket.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/VideoStreamConnectPacket.php b/src/VideoStreamConnectPacket.php index a6b17228..2ae8f447 100644 --- a/src/VideoStreamConnectPacket.php +++ b/src/VideoStreamConnectPacket.php @@ -25,7 +25,7 @@ class VideoStreamConnectPacket extends DataPacket implements ClientboundPacket{ public float $screenshotFrequency; /** - * @var int Action type + * @var int $action * @phpstan-var VideoStreamAction::* */ public int $action; @@ -36,7 +36,6 @@ class VideoStreamConnectPacket extends DataPacket implements ClientboundPacket{ /** * @generate-create-func - * @phpstan-var VideoStreamAction::* */ public static function create(string $address, float $screenshotFrequency, int $action, int $width, int $height) : self{ $result = new self;