Skip to content

Commit

Permalink
add support CasparCG v2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Besedin committed Aug 31, 2021
1 parent 8789f34 commit 9f72f66
Show file tree
Hide file tree
Showing 63 changed files with 129 additions and 141 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Is an implementation of CasparCG 2.0 AMCP Protocol and OSC Protocol

Requirements
-----
- CasparCG v2.0.7
- CasparCG v2.0.7|v2.3.0
- PHP 7.0

Installation
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.0"
"php": ">=7.0"
},
"autoload": {
"psr-4": {
Expand Down
24 changes: 12 additions & 12 deletions src/Command/Basic/Builder/AddBuilder.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace CosmonovaRnD\CasparCG\Command\Basic\Builder;
Expand Down Expand Up @@ -114,7 +115,7 @@ protected function buildChannel(): string
protected function buildDeckLink(): string
{
if ($this->deckLink) {
return 'DECKLINK ' . $this->deckLink;
return 'DECKLINK '.$this->deckLink;
}

return '';
Expand All @@ -123,7 +124,7 @@ protected function buildDeckLink(): string
protected function buildBluefish(): string
{
if ($this->bluefish) {
return 'BLUEFISH ' . $this->bluefish;
return 'BLUEFISH '.$this->bluefish;
}

return '';
Expand All @@ -150,7 +151,7 @@ public function buildAudio(): string
public function buildImage()
{
if ($this->image) {
return 'IMAGE ' . $this->image;
return 'IMAGE '.$this->image;
}

return '';
Expand All @@ -159,10 +160,10 @@ public function buildImage()
public function buildFile(): string
{
if ($this->file) {
$result = 'FILE ' . $this->file;
$result = 'FILE '.$this->file;

if ($this->separateKey) {
$result = $result . ' SEPARATE_KEY';
$result = $result.' SEPARATE_KEY';
}

return $result;
Expand All @@ -174,10 +175,10 @@ public function buildFile(): string
public function buildStream(): string
{
if ($this->stream) {
$result = 'STREAM ' . $this->stream;
$result = 'STREAM '.$this->stream;

if ($this->streamArgs) {
$result = $result . ' ' . $this->streamArgs;
$result .= ' '.$this->streamArgs;
}

return $result;
Expand All @@ -189,7 +190,7 @@ public function buildStream(): string
/**
* @inheritDoc
*/
public function build(): string
public function build(bool $legacy = false): string
{
$commandParts[] = 'ADD';
$commandParts[] = $this->buildChannel();
Expand All @@ -202,15 +203,15 @@ public function build(): string
$this->buildAudio(),
$this->buildImage(),
$this->buildFile(),
$this->buildStream()
$this->buildStream(),
];

$consumerCommandPart = null;

foreach ($consumerBuilders as $consumerBuilder) {
$consumer = $consumerBuilder;

if (strlen($consumer)) {
if ('' !== $consumer) {
$consumerCommandPart = $consumer;
}
}
Expand All @@ -222,9 +223,8 @@ public function build(): string
$commandParts[] = $consumerCommandPart;

$commandParts = array_filter($commandParts);
$command = join(' ', $commandParts);

return $command;
return implode(' ', $commandParts);
}

#endregion
Expand Down
24 changes: 11 additions & 13 deletions src/Command/Basic/Builder/CallBuilder.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php

declare(strict_types=1);

namespace CosmonovaRnD\CasparCG\Command\Basic\Builder;

use function array_filter;
use function implode;

/**
* Class CallBuilder
*
Expand All @@ -22,13 +26,6 @@ class CallBuilder extends LoadBgBuilder

#region setters

/**
* Set INVOKE
*
* @param string $command
*
* @return \CosmonovaRnD\CasparCG\Command\Basic\Builder\CallBuilder
*/
public function invoke(string $command): CallBuilder
{
$this->invoke = $command;
Expand All @@ -40,19 +37,21 @@ public function invoke(string $command): CallBuilder

#region builders

protected function buildInvoke(): string
protected function buildInvoke(bool $legacy): string
{
return null !== $this->invoke ? sprintf('INVOKE "%s"', addslashes($this->invoke)) : '';
$invoke = $legacy ? 'INVOKE' : '';

return null !== $this->invoke ? sprintf('%s "%s"', $invoke, addslashes($this->invoke)) : '';
}

/**
* @inheritDoc
*/
public function build(): string
public function build(bool $legacy = false): string
{
$commandParts[] = 'CALL';
$commandParts[] = $this->buildChannel();
$commandParts[] = $this->buildInvoke();
$commandParts[] = $this->buildInvoke($legacy);
$commandParts[] = $this->buildLoop();
$commandParts[] = $this->buildTransitionGroup();
$commandParts[] = $this->buildSeek();
Expand All @@ -61,9 +60,8 @@ public function build(): string
$commandParts[] = $this->buildAuto();

$commandParts = array_filter($commandParts);
$command = join(' ', $commandParts);

return $command;
return implode(' ', $commandParts);
}

#endregion
Expand Down
8 changes: 5 additions & 3 deletions src/Command/Basic/Builder/ClearBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace CosmonovaRnD\CasparCG\Command\Basic\Builder;

use function array_filter;
use function implode;

/**
* Class ClearBuilder
*
Expand All @@ -17,14 +20,13 @@ class ClearBuilder extends BaseBuilder
/**
* @inheritDoc
*/
public function build(): string
public function build(bool $legacy = false): string
{
$commandParts[] = 'CLEAR';
$commandParts[] = $this->buildChannel();

$commandParts = array_filter($commandParts);
$command = join(' ', $commandParts);

return $command;
return implode(' ', $commandParts);
}
}
14 changes: 6 additions & 8 deletions src/Command/Basic/Builder/LoadBgBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function loop($loop = true): ExtendBuilderInterface
public function transition(string $transition): ExtendBuilderInterface
{
if (!in_array(strtoupper($transition), static::transitionTypes())) {
$message = 'Transition must be one of the following values: ' . join(',', static::transitionTypes());
$message = 'Transition must be one of the following values: ' . implode(',', static::transitionTypes());
throw new ParamException($message);
}

Expand Down Expand Up @@ -138,7 +138,7 @@ public function duration(int $duration): ExtendBuilderInterface
public function tween(string $tween): ExtendBuilderInterface
{
if (!in_array($tween, Tween::animationTypes())) {
$message = 'Tween param must be one of the following values: ' . join(',', Tween::animationTypes());
$message = 'Tween param must be one of the following values: ' . implode(',', Tween::animationTypes());
throw new ParamException($message);
}

Expand All @@ -155,7 +155,7 @@ public function direction(string $direction): ExtendBuilderInterface
$directions = [self::DIRECTION_LEFT, self::DIRECTION_RIGHT];

if (!in_array(strtoupper($direction), $directions)) {
$message = 'Direction must be one of the following values: ' . join(',', $directions);
$message = 'Direction must be one of the following values: ' . implode(',', $directions);
throw new ParamException($message);
}

Expand Down Expand Up @@ -261,9 +261,8 @@ protected function buildTransitionGroup(): string
$transitionParts[] = $this->direction;

$transitionParts = array_filter($transitionParts);
$transition = join(' ', $transitionParts);

return $transition;
return implode(' ', $transitionParts);
}

return '';
Expand Down Expand Up @@ -338,7 +337,7 @@ protected function buildAuto(): string
/**
* @inheritDoc
*/
public function build(): string
public function build(bool $legacy = false): string
{
$commandParts[] = 'LOADBG';
$commandParts[] = $this->buildChannel();
Expand All @@ -353,9 +352,8 @@ public function build(): string


$commandParts = array_filter($commandParts);
$command = join(' ', $commandParts);

return $command;
return implode(' ', $commandParts);
}

#endregion
Expand Down
5 changes: 2 additions & 3 deletions src/Command/Basic/Builder/LoadBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LoadBuilder extends LoadBgBuilder
/**
* @inheritDoc
*/
public function build(): string
public function build(bool $legacy = false): string
{
$commandParts[] = 'LOAD';
$commandParts[] = $this->buildChannel();
Expand All @@ -31,8 +31,7 @@ public function build(): string


$commandParts = array_filter($commandParts);
$command = join(' ', $commandParts);

return $command;
return implode(' ', $commandParts);
}
}
5 changes: 2 additions & 3 deletions src/Command/Basic/Builder/PauseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ class PauseBuilder extends BaseBuilder
/**
* @inheritDoc
*/
public function build(): string
public function build(bool $legacy = false): string
{
$commandParts[] = 'PAUSE';
$commandParts[] = $this->buildChannel();

$commandParts = array_filter($commandParts);
$command = join(' ', $commandParts);

return $command;
return implode(' ', $commandParts);
}
}
5 changes: 2 additions & 3 deletions src/Command/Basic/Builder/PlayBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function buildClip(): string
/**
* @inheritDoc
*/
public function build(): string
public function build(bool $legacy = false): string
{
$commandParts[] = 'PLAY';
$commandParts[] = $this->buildChannel();
Expand All @@ -40,9 +40,8 @@ public function build(): string


$commandParts = array_filter($commandParts);
$command = join(' ', $commandParts);

return $command;
return implode(' ', $commandParts);
}

}
15 changes: 5 additions & 10 deletions src/Command/Basic/Builder/RemoveBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ public function buildImage()
public function buildFile(): string
{
if ($this->file) {
$result = 'FILE ' . $this->file;

return $result;
return 'FILE ' . $this->file;
}

return '';
Expand All @@ -159,9 +157,7 @@ public function buildFile(): string
public function buildStream(): string
{
if ($this->stream) {
$result = 'STREAM ' . $this->stream;

return $result;
return 'STREAM ' . $this->stream;
}

return '';
Expand All @@ -170,7 +166,7 @@ public function buildStream(): string
/**
* @inheritDoc
*/
public function build(): string
public function build(bool $legacy = false): string
{
$commandParts[] = 'REMOVE';
$commandParts[] = $this->buildChannel();
Expand All @@ -191,7 +187,7 @@ public function build(): string
foreach ($consumerBuilders as $consumerBuilder) {
$consumer = $consumerBuilder;

if (strlen($consumer)) {
if ('' !== $consumer) {
$consumerCommandPart = $consumer;
}
}
Expand All @@ -203,9 +199,8 @@ public function build(): string
$commandParts[] = $consumerCommandPart;

$commandParts = array_filter($commandParts);
$command = join(' ', $commandParts);

return $command;
return implode(' ', $commandParts);
}

#endregion
Expand Down
5 changes: 2 additions & 3 deletions src/Command/Basic/Builder/ResumeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ class ResumeBuilder extends BaseBuilder
/**
* @inheritDoc
*/
public function build(): string
public function build(bool $legacy = false): string
{
$commandParts[] = 'RESUME';
$commandParts[] = $this->buildChannel();

$commandParts = array_filter($commandParts);
$command = join(' ', $commandParts);

return $command;
return implode(' ', $commandParts);
}
}
Loading

0 comments on commit 9f72f66

Please sign in to comment.