1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SquareetLabs\LaravelOpenVidu; |
4
|
|
|
|
5
|
|
|
use JsonSerializable; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class KurentoOptions |
9
|
|
|
* @package SquareetLabs\LaravelOpenVidu |
10
|
|
|
*/ |
11
|
|
|
class KurentoOptions implements JsonSerializable |
12
|
|
|
{ |
13
|
|
|
/** @var int */ |
14
|
|
|
private $videoMaxRecvBandwidth; |
15
|
|
|
/** @var int */ |
16
|
|
|
private $videoMinRecvBandwidth; |
17
|
|
|
/** @var int */ |
18
|
|
|
private $videoMaxSendBandwidth; |
19
|
|
|
/** @var int */ |
20
|
|
|
private $videoMinSendBandwidth; |
21
|
|
|
/** @var array */ |
22
|
|
|
private $allowedFilters = []; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* KurentoOptions constructor. |
26
|
|
|
* @param int|null $videoMaxRecvBandwidth |
27
|
|
|
* @param int|null $videoMinRecvBandwidth |
28
|
|
|
* @param int|null $videoMaxSendBandwidth |
29
|
|
|
* @param int|null $videoMinSendBandwidth |
30
|
|
|
* @param array|null $allowedFilters |
31
|
|
|
*/ |
32
|
|
|
public function __construct(?int $videoMaxRecvBandwidth = null, ?int $videoMinRecvBandwidth = null, ?int $videoMaxSendBandwidth = null, ?int $videoMinSendBandwidth = null, ?array $allowedFilters = null) |
33
|
|
|
{ |
34
|
|
|
$this->videoMaxRecvBandwidth = $videoMaxRecvBandwidth; |
35
|
|
|
$this->videoMinRecvBandwidth = $videoMinRecvBandwidth; |
36
|
|
|
$this->videoMaxSendBandwidth = $videoMaxSendBandwidth; |
37
|
|
|
$this->videoMinSendBandwidth = $videoMinSendBandwidth; |
38
|
|
|
$this->allowedFilters = $allowedFilters; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Convert the model instance to JSON. |
43
|
|
|
* |
44
|
|
|
* @param int $options |
45
|
|
|
* @return string |
46
|
|
|
* |
47
|
|
|
*/ |
48
|
|
|
public function toJson($options = 0): string |
49
|
|
|
{ |
50
|
|
|
return json_encode($this->jsonSerialize(), $options); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Specify data which should be serialized to JSON |
55
|
|
|
* @link https://php.net/manual/en/jsonserializable.jsonserialize.php |
56
|
|
|
* @return mixed data which can be serialized by <b>json_encode</b>, |
57
|
|
|
* which is a value of any type other than a resource. |
58
|
|
|
* @since 5.4.0 |
59
|
|
|
*/ |
60
|
|
|
public function jsonSerialize() |
61
|
|
|
{ |
62
|
|
|
return $this->toArray(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Convert the model instance to an array. |
67
|
|
|
* |
68
|
|
|
* @return array |
69
|
|
|
*/ |
70
|
|
|
public function toArray(): array |
71
|
|
|
{ |
72
|
|
|
$array = ['videoMaxRecvBandwidth' => $this->videoMaxRecvBandwidth, 'videoMinRecvBandwidth' => $this->videoMinRecvBandwidth, 'videoMaxSendBandwidth' => $this->videoMaxSendBandwidth, 'videoMinSendBandwidth' => $this->videoMinSendBandwidth]; |
73
|
|
|
foreach ($this->allowedFilters as $allowed_filter) { |
74
|
|
|
$array['allowedFilters'][] = $allowed_filter; |
75
|
|
|
} |
76
|
|
|
foreach ($array as $key => $value) { |
77
|
|
|
if (is_null($value) || $value == '') { |
78
|
|
|
unset($array[$key]); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
return $array; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
} |
85
|
|
|
|