Skip to content

Commit

Permalink
Merge pull request #1996 from irontec/PROVIDER-667-asterisk-rtp-timeout
Browse files Browse the repository at this point in the history
Add RTP timeout fields to asterisk endpoints table
  • Loading branch information
Kaian committed Jan 26, 2023
2 parents 32f1aeb + 0520d70 commit 76a08f5
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 2 deletions.
60 changes: 58 additions & 2 deletions library/Ivoz/Ast/Domain/Model/PsEndpoint/PsEndpointAbstract.php
Expand Up @@ -161,6 +161,18 @@ abstract class PsEndpointAbstract
*/
protected $t38UdptlNat = 'no';

/**
* @var int
* column: rtp_timeout
*/
protected $rtpTimeout = 60;

/**
* @var int
* column: rtp_timeout_hold
*/
protected $rtpTimeoutHold = 600;

/**
* @var ?TerminalInterface
* inversedBy psEndpoint
Expand Down Expand Up @@ -197,7 +209,9 @@ protected function __construct(
string $t38Udptl,
string $t38UdptlEc,
int $t38UdptlMaxdatagram,
string $t38UdptlNat
string $t38UdptlNat,
int $rtpTimeout,
int $rtpTimeoutHold
) {
$this->setSorceryId($sorceryId);
$this->setContext($context);
Expand All @@ -208,6 +222,8 @@ protected function __construct(
$this->setT38UdptlEc($t38UdptlEc);
$this->setT38UdptlMaxdatagram($t38UdptlMaxdatagram);
$this->setT38UdptlNat($t38UdptlNat);
$this->setRtpTimeout($rtpTimeout);
$this->setRtpTimeoutHold($rtpTimeoutHold);
}

abstract public function getId(): null|string|int;
Expand Down Expand Up @@ -286,6 +302,10 @@ public static function fromDto(
Assertion::notNull($t38UdptlMaxdatagram, 'getT38UdptlMaxdatagram value is null, but non null value was expected.');
$t38UdptlNat = $dto->getT38UdptlNat();
Assertion::notNull($t38UdptlNat, 'getT38UdptlNat value is null, but non null value was expected.');
$rtpTimeout = $dto->getRtpTimeout();
Assertion::notNull($rtpTimeout, 'getRtpTimeout value is null, but non null value was expected.');
$rtpTimeoutHold = $dto->getRtpTimeoutHold();
Assertion::notNull($rtpTimeoutHold, 'getRtpTimeoutHold value is null, but non null value was expected.');

$self = new static(
$sorceryId,
Expand All @@ -296,7 +316,9 @@ public static function fromDto(
$t38Udptl,
$t38UdptlEc,
$t38UdptlMaxdatagram,
$t38UdptlNat
$t38UdptlNat,
$rtpTimeout,
$rtpTimeoutHold
);

$self
Expand Down Expand Up @@ -351,6 +373,10 @@ public function updateFromDto(
Assertion::notNull($t38UdptlMaxdatagram, 'getT38UdptlMaxdatagram value is null, but non null value was expected.');
$t38UdptlNat = $dto->getT38UdptlNat();
Assertion::notNull($t38UdptlNat, 'getT38UdptlNat value is null, but non null value was expected.');
$rtpTimeout = $dto->getRtpTimeout();
Assertion::notNull($rtpTimeout, 'getRtpTimeout value is null, but non null value was expected.');
$rtpTimeoutHold = $dto->getRtpTimeoutHold();
Assertion::notNull($rtpTimeoutHold, 'getRtpTimeoutHold value is null, but non null value was expected.');

$this
->setSorceryId($sorceryId)
Expand All @@ -375,6 +401,8 @@ public function updateFromDto(
->setT38UdptlEc($t38UdptlEc)
->setT38UdptlMaxdatagram($t38UdptlMaxdatagram)
->setT38UdptlNat($t38UdptlNat)
->setRtpTimeout($rtpTimeout)
->setRtpTimeoutHold($rtpTimeoutHold)
->setTerminal($fkTransformer->transform($dto->getTerminal()))
->setFriend($fkTransformer->transform($dto->getFriend()))
->setResidentialDevice($fkTransformer->transform($dto->getResidentialDevice()))
Expand Down Expand Up @@ -411,6 +439,8 @@ public function toDto(int $depth = 0): PsEndpointDto
->setT38UdptlEc(self::getT38UdptlEc())
->setT38UdptlMaxdatagram(self::getT38UdptlMaxdatagram())
->setT38UdptlNat(self::getT38UdptlNat())
->setRtpTimeout(self::getRtpTimeout())
->setRtpTimeoutHold(self::getRtpTimeoutHold())
->setTerminal(Terminal::entityToDto(self::getTerminal(), $depth))
->setFriend(Friend::entityToDto(self::getFriend(), $depth))
->setResidentialDevice(ResidentialDevice::entityToDto(self::getResidentialDevice(), $depth))
Expand Down Expand Up @@ -445,6 +475,8 @@ protected function __toArray(): array
't38_udptl_ec' => self::getT38UdptlEc(),
't38_udptl_maxdatagram' => self::getT38UdptlMaxdatagram(),
't38_udptl_nat' => self::getT38UdptlNat(),
'rtp_timeout' => self::getRtpTimeout(),
'rtp_timeout_hold' => self::getRtpTimeoutHold(),
'terminalId' => self::getTerminal()?->getId(),
'friendId' => self::getFriend()?->getId(),
'residentialDeviceId' => self::getResidentialDevice()?->getId(),
Expand Down Expand Up @@ -861,6 +893,30 @@ public function getT38UdptlNat(): string
return $this->t38UdptlNat;
}

protected function setRtpTimeout(int $rtpTimeout): static
{
$this->rtpTimeout = $rtpTimeout;

return $this;
}

public function getRtpTimeout(): int
{
return $this->rtpTimeout;
}

protected function setRtpTimeoutHold(int $rtpTimeoutHold): static
{
$this->rtpTimeoutHold = $rtpTimeoutHold;

return $this;
}

public function getRtpTimeoutHold(): int
{
return $this->rtpTimeoutHold;
}

public function setTerminal(?TerminalInterface $terminal = null): static
{
$this->terminal = $terminal;
Expand Down
38 changes: 38 additions & 0 deletions library/Ivoz/Ast/Domain/Model/PsEndpoint/PsEndpointDtoAbstract.php
Expand Up @@ -127,6 +127,16 @@ abstract class PsEndpointDtoAbstract implements DataTransferObjectInterface
*/
private $t38UdptlNat = 'no';

/**
* @var int|null
*/
private $rtpTimeout = 60;

/**
* @var int|null
*/
private $rtpTimeoutHold = 600;

/**
* @var int|null
*/
Expand Down Expand Up @@ -192,6 +202,8 @@ public static function getPropertyMap(string $context = '', string $role = null)
't38UdptlEc' => 't38UdptlEc',
't38UdptlMaxdatagram' => 't38UdptlMaxdatagram',
't38UdptlNat' => 't38UdptlNat',
'rtpTimeout' => 'rtpTimeout',
'rtpTimeoutHold' => 'rtpTimeoutHold',
'id' => 'id',
'terminalId' => 'terminal',
'friendId' => 'friend',
Expand Down Expand Up @@ -228,6 +240,8 @@ public function toArray(bool $hideSensitiveData = false): array
't38UdptlEc' => $this->getT38UdptlEc(),
't38UdptlMaxdatagram' => $this->getT38UdptlMaxdatagram(),
't38UdptlNat' => $this->getT38UdptlNat(),
'rtpTimeout' => $this->getRtpTimeout(),
'rtpTimeoutHold' => $this->getRtpTimeoutHold(),
'id' => $this->getId(),
'terminal' => $this->getTerminal(),
'friend' => $this->getFriend(),
Expand Down Expand Up @@ -513,6 +527,30 @@ public function getT38UdptlNat(): ?string
return $this->t38UdptlNat;
}

public function setRtpTimeout(int $rtpTimeout): static
{
$this->rtpTimeout = $rtpTimeout;

return $this;
}

public function getRtpTimeout(): ?int
{
return $this->rtpTimeout;
}

public function setRtpTimeoutHold(int $rtpTimeoutHold): static
{
$this->rtpTimeoutHold = $rtpTimeoutHold;

return $this;
}

public function getRtpTimeoutHold(): ?int
{
return $this->rtpTimeoutHold;
}

public function setId($id): static
{
$this->id = $id;
Expand Down
Expand Up @@ -135,6 +135,10 @@ public function getT38UdptlMaxdatagram(): int;

public function getT38UdptlNat(): string;

public function getRtpTimeout(): int;

public function getRtpTimeoutHold(): int;

public function setTerminal(?TerminalInterface $terminal = null): static;

public function getTerminal(): ?TerminalInterface;
Expand Down
Expand Up @@ -144,6 +144,18 @@
<option name="default">no</option>
</options>
</field>
<field name="rtpTimeout" type="integer" column="rtp_timeout" nullable="false">
<options>
<option name="fixed"/>
<option name="default">60</option>
</options>
</field>
<field name="rtpTimeoutHold" type="integer" column="rtp_timeout_hold" nullable="false">
<options>
<option name="fixed"/>
<option name="default">600</option>
</options>
</field>
<one-to-one field="terminal" target-entity="Ivoz\Provider\Domain\Model\Terminal\TerminalInterface" inversed-by="psEndpoint" fetch="LAZY">
<join-columns>
<join-column name="terminalId" referenced-column-name="id" on-delete="CASCADE"/>
Expand Down
29 changes: 29 additions & 0 deletions schema/DoctrineMigrations/Version20230125165233.php
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Application\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230125165233 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add rtp_timeout and rtp_timeout_hold fields to ast_ps_endpoints table';
}

public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE ast_ps_endpoints ADD rtp_timeout INT DEFAULT 60 NOT NULL, ADD rtp_timeout_hold INT DEFAULT 600 NOT NULL');
}

public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE ast_ps_endpoints DROP rtp_timeout, DROP rtp_timeout_hold');
}
}
Expand Up @@ -147,6 +147,8 @@ protected function it_updates_ps_endpoint()
't38_udptl_ec' => 'redundancy',
't38_udptl_maxdatagram' => 1440,
't38_udptl_nat' => 'no',
'rtp_timeout' => 60,
'rtp_timeout_hold' => 600,
'residentialDeviceId' => 2,
'id' => 6
]
Expand Down

0 comments on commit 76a08f5

Please sign in to comment.