Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding VideoStreamConnect Packet #282

Closed
wants to merge 13 commits into from
2 changes: 2 additions & 0 deletions src/PacketHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions src/PacketPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
1 change: 1 addition & 0 deletions src/ProtocolInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
69 changes: 69 additions & 0 deletions src/VideoStreamConnectPacket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

/*
* This file is part of BedrockProtocol.
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
*
* 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;

Check failure on line 44 in src/VideoStreamConnectPacket.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.1)

Property pocketmine\network\mcpe\protocol\VideoStreamConnectPacket::$action (0|1) does not accept int.

Check failure on line 44 in src/VideoStreamConnectPacket.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2)

Property pocketmine\network\mcpe\protocol\VideoStreamConnectPacket::$action (0|1) does not accept int.

Check failure on line 44 in src/VideoStreamConnectPacket.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3)

Property pocketmine\network\mcpe\protocol\VideoStreamConnectPacket::$action (0|1) does not accept int.
$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();

Check failure on line 53 in src/VideoStreamConnectPacket.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.1)

Property pocketmine\network\mcpe\protocol\VideoStreamConnectPacket::$action (0|1) does not accept int.

Check failure on line 53 in src/VideoStreamConnectPacket.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.2)

Property pocketmine\network\mcpe\protocol\VideoStreamConnectPacket::$action (0|1) does not accept int.

Check failure on line 53 in src/VideoStreamConnectPacket.php

View workflow job for this annotation

GitHub Actions / Tests (PHP 8.3)

Property pocketmine\network\mcpe\protocol\VideoStreamConnectPacket::$action (0|1) does not accept int.
$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);
}
}
20 changes: 20 additions & 0 deletions src/types/VideoStreamAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/*
* This file is part of BedrockProtocol.
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
*
* 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;
}
Loading