From bb4f3926a098b5ee53c067edbc9a3c1e350f689e Mon Sep 17 00:00:00 2001 From: Rohan Sakhale Date: Wed, 24 Apr 2024 10:24:38 +0530 Subject: [PATCH 1/6] Deleted vendor and code refactor --- .gitignore | 3 + .phpunit.result.cache | 1 + composer.json | 3 +- src/PHPClient.php | 6 +- src/RenderMediaOnLambdaResponse.php | 10 ++ src/RenderParams.php | 93 +++++++++---------- src/Semantic.php | 8 ++ ...Exceptions.php => ValidationException.php} | 4 +- src/Version.php | 4 - {src => tests}/PHPClientTest.php | 4 +- {src => tests}/PHPRenderProgressTest.php | 5 +- 11 files changed, 74 insertions(+), 67 deletions(-) create mode 100644 .gitignore create mode 100644 .phpunit.result.cache create mode 100644 src/RenderMediaOnLambdaResponse.php create mode 100644 src/Semantic.php rename src/{Exceptions.php => ValidationException.php} (81%) delete mode 100644 src/Version.php rename {src => tests}/PHPClientTest.php (84%) rename {src => tests}/PHPRenderProgressTest.php (73%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..04ee5f3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +vendor/ +.phpunit.result.cache +.idea/ diff --git a/.phpunit.result.cache b/.phpunit.result.cache new file mode 100644 index 0000000..2778692 --- /dev/null +++ b/.phpunit.result.cache @@ -0,0 +1 @@ +{"version":1,"defects":[],"times":{"Remotion\\LambdaPhp\\Tests\\PHPRenderProgressTest::testClient":0.018,"Remotion\\LambdaPhp\\Tests\\PHPClientTest::testClient":0.028}} \ No newline at end of file diff --git a/composer.json b/composer.json index 700ea1d..1a798f7 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "license": "proprietary", "autoload": { "psr-4": { - "Remotion\\LambdaPhp\\": "src/" + "Remotion\\LambdaPhp\\": "src/", + "Remotion\\LambdaPhp\\Tests\\": "tests/" } }, "require": { diff --git a/src/PHPClient.php b/src/PHPClient.php index 15c4fb3..b7c3047 100644 --- a/src/PHPClient.php +++ b/src/PHPClient.php @@ -1,14 +1,10 @@ $renderId, 'bucketName' => $bucketName, 'type' => 'status', - "version" => VERSION, + "version" => Semantic::VERSION, "s3OutputProvider" => null, "logLevel" => $logLevel , ); diff --git a/src/RenderMediaOnLambdaResponse.php b/src/RenderMediaOnLambdaResponse.php new file mode 100644 index 0000000..dbfb6d9 --- /dev/null +++ b/src/RenderMediaOnLambdaResponse.php @@ -0,0 +1,10 @@ +chromiumOptions = new stdClass(); @@ -150,6 +141,7 @@ public function __construct( } private array $inputProps = array(); + public function serializeParams() { $parameters = [ @@ -176,7 +168,7 @@ public function serializeParams() 'downloadBehavior' => $this->getDownloadBehavior(), 'muted' => $this->getMuted(), 'preferLossless' => $this->getPreferLossless(), - 'version' => VERSION, + 'version' => Semantic::VERSION, 'overwrite' => $this->getOverwrite(), 'audioBitrate' => $this->getAudioBitrate(), 'videoBitrate' => $this->getVideoBitrate(), @@ -451,7 +443,7 @@ public function setMaxRetries($maxRetries) return $this; } - /** + /** * Get the value of jpegQuality */ public function getJpegQuality() @@ -491,7 +483,7 @@ public function setPrivacy($privacy) return $this; } - /** + /** * Get the value of colorspace */ public function getColorSpace() @@ -530,6 +522,7 @@ public function setLogLevel($logLevel) return $this; } + // Setter methods public function setFrameRange($frameRange) { @@ -627,6 +620,7 @@ public function setMuted($muted) { $this->muted = $muted; } + // Setter methods public function setPreferLossless($preferLossless) { @@ -718,6 +712,7 @@ public function getForceWidth() { return $this->forceWidth; } + public function getOffthreadVideoCacheSizeInBytes() { return $this->offthreadVideoCacheSizeInBytes; @@ -850,8 +845,8 @@ public function getX264Preset() public function setX264Preset($x264Preset) { - $this->x264Preset = $x264Preset; - return $this; + $this->x264Preset = $x264Preset; + return $this; } public function getDeleteAfter() @@ -861,7 +856,7 @@ public function getDeleteAfter() public function setDeleteAfter($deleteAfter) { - $this->$deleteAfter = $deleteAfter; - return $this; + $this->$deleteAfter = $deleteAfter; + return $this; } } diff --git a/src/Semantic.php b/src/Semantic.php new file mode 100644 index 0000000..701e8bc --- /dev/null +++ b/src/Semantic.php @@ -0,0 +1,8 @@ + Date: Wed, 24 Apr 2024 10:26:31 +0530 Subject: [PATCH 2/6] Deleted phpunit result cache --- .phpunit.result.cache | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .phpunit.result.cache diff --git a/.phpunit.result.cache b/.phpunit.result.cache deleted file mode 100644 index 2778692..0000000 --- a/.phpunit.result.cache +++ /dev/null @@ -1 +0,0 @@ -{"version":1,"defects":[],"times":{"Remotion\\LambdaPhp\\Tests\\PHPRenderProgressTest::testClient":0.018,"Remotion\\LambdaPhp\\Tests\\PHPClientTest::testClient":0.028}} \ No newline at end of file From d580731025a64eeee7b52381c43f7fd4484f78a8 Mon Sep 17 00:00:00 2001 From: Rohan Sakhale Date: Wed, 24 Apr 2024 10:28:00 +0530 Subject: [PATCH 3/6] Added composer run test command to run phpunit tests --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 1a798f7..23ca166 100644 --- a/composer.json +++ b/composer.json @@ -15,5 +15,8 @@ }, "require-dev": { "phpunit/phpunit": "^10.1" + }, + "scripts": { + "test": "phpunit tests" } } From 09514e53b69fc11d6eff18ce1cdacee90d44c3c5 Mon Sep 17 00:00:00 2001 From: Rohan Sakhale Date: Wed, 24 Apr 2024 11:25:15 +0530 Subject: [PATCH 4/6] Fix for method --- src/RenderParams.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RenderParams.php b/src/RenderParams.php index bdd6950..f0816cb 100644 --- a/src/RenderParams.php +++ b/src/RenderParams.php @@ -856,7 +856,7 @@ public function getDeleteAfter() public function setDeleteAfter($deleteAfter) { - $this->$deleteAfter = $deleteAfter; + $this->deleteAfter = $deleteAfter; return $this; } } From 6bc2d89d8ae46bc4bfdc6db7637c6717a6e4fa3f Mon Sep 17 00:00:00 2001 From: Rohan Sakhale Date: Wed, 24 Apr 2024 11:51:30 +0530 Subject: [PATCH 5/6] Handling towards null chunks --- src/GetRenderProgressResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GetRenderProgressResponse.php b/src/GetRenderProgressResponse.php index 94e74bc..4dab3d0 100644 --- a/src/GetRenderProgressResponse.php +++ b/src/GetRenderProgressResponse.php @@ -4,7 +4,7 @@ class GetRenderProgressResponse { - public int $chunks; + public ?int $chunks; public bool $done; public float $overallProgress; public string $type; From 060b7c6abad90c78dd3cd37466732fa9b8d4b636 Mon Sep 17 00:00:00 2001 From: Rohan Sakhale Date: Wed, 24 Apr 2024 11:53:41 +0530 Subject: [PATCH 6/6] Update properties to protected so as to allow inheritance and overriding of code --- src/PHPClient.php | 8 ++-- src/RenderParams.php | 87 ++++++++++++++++++++++---------------------- 2 files changed, 47 insertions(+), 48 deletions(-) diff --git a/src/PHPClient.php b/src/PHPClient.php index b7c3047..09ff2a8 100644 --- a/src/PHPClient.php +++ b/src/PHPClient.php @@ -7,10 +7,10 @@ class PHPClient { - private $client; - private $region; - private $serveUrl; - private $functionName; + protected $client; + protected $region; + protected $serveUrl; + protected $functionName; public function __construct(string $region, string $serveUrl, string $functionName, ?callable $credential) { diff --git a/src/RenderParams.php b/src/RenderParams.php index f0816cb..6dbd3e5 100644 --- a/src/RenderParams.php +++ b/src/RenderParams.php @@ -6,52 +6,51 @@ class RenderParams { - - private $data = null; - private $bucketName = null; - private $region = null; - private $outName = null; - private $composition = null; - private $serverUrl = null; - private $framesPerLambda = null; - - private $codec = 'h264'; - private $version = ""; - private $imageFormat = 'jpeg'; - private $crf = null; - private $envVariables = []; - private $maxRetries = 1; - private $jpegQuality = 80; - private $privacy = 'private'; - private $colorSpace = 'default'; - private $logLevel = 'info'; - private $frameRange = null; - private $timeoutInMilliseconds = 30000; - private $chromiumOptions = null; - private $scale = 1; - private $everyNthFrame = 1; - private $numberOfGifLoops = 0; - private $concurrencyPerLambda = 1; - private $downloadBehavior = [ + protected $data = null; + protected $bucketName = null; + protected $region = null; + protected $outName = null; + protected $composition = null; + protected $serverUrl = null; + protected $framesPerLambda = null; + + protected $codec = 'h264'; + protected $version = ""; + protected $imageFormat = 'jpeg'; + protected $crf = null; + protected $envVariables = []; + protected $maxRetries = 1; + protected $jpegQuality = 80; + protected $privacy = 'privacy'; + protected $colorSpace = 'default'; + protected $logLevel = 'info'; + protected $frameRange = null; + protected $timeoutInMilliseconds = 30000; + protected $chromiumOptions = null; + protected $scale = 1; + protected $everyNthFrame = 1; + protected $numberOfGifLoops = 0; + protected $concurrencyPerLambda = 1; + protected $downloadBehavior = [ 'type' => 'play-in-browser', ]; - private $muted = false; - private $preferLossless = false; - private $overwrite = false; - private $audioBitrate = null; - private $videoBitrate = null; - private $encodingBufferSize = null; - private $maxRate = null; - private $webhook = null; - private $forceHeight = null; - private $forceWidth = null; - private $offthreadVideoCacheSizeInBytes = null; - private $audioCodec = null; - private $rendererFunctionName = null; - private $proResProfile = null; - private $pixelFormat = null; - private $x264Preset = null; - private $deleteAfter = null; + protected $muted = false; + protected $preferLossless = false; + protected $overwrite = false; + protected $audioBitrate = null; + protected $videoBitrate = null; + protected $encodingBufferSize = null; + protected $maxRate = null; + protected $webhook = null; + protected $forceHeight = null; + protected $forceWidth = null; + protected $offthreadVideoCacheSizeInBytes = null; + protected $audioCodec = null; + protected $rendererFunctionName = null; + protected $proResProfile = null; + protected $pixelFormat = null; + protected $x264Preset = null; + protected $deleteAfter = null; public function __construct( ?array $data = null,