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; } 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{ 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; } diff --git a/src/VideoStreamConnectPacket.php b/src/VideoStreamConnectPacket.php new file mode 100644 index 00000000..2ae8f447 --- /dev/null +++ b/src/VideoStreamConnectPacket.php @@ -0,0 +1,69 @@ + + * + * 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; + + public string $address; + + public float $screenshotFrequency; + + /** + * @var int $action + * @phpstan-var VideoStreamAction::* + */ + public int $action; + + public int $width; + + public int $height; + + /** + * @generate-create-func + */ + 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); + } +} 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; +}