1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the PHP-FFmpeg-video-streaming package. |
5
|
|
|
* |
6
|
|
|
* (c) Amin Yazdanpanah <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Streaming; |
13
|
|
|
|
14
|
|
|
use Streaming\Exception\InvalidArgumentException; |
15
|
|
|
|
16
|
|
|
class Representation |
17
|
|
|
{ |
18
|
|
|
private $kiloBitrate = 1000; |
19
|
|
|
private $audioKiloBitrate = null; |
20
|
|
|
private $resize = ''; |
21
|
|
|
private $width = 0; |
22
|
|
|
private $height = 0; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @return mixed |
26
|
|
|
*/ |
27
|
|
|
public function getResize() |
28
|
|
|
{ |
29
|
|
|
return $this->resize; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param $width |
34
|
|
|
* @param $height |
35
|
|
|
* @return Representation |
36
|
|
|
* @throws InvalidArgumentException |
37
|
|
|
*/ |
38
|
|
|
public function setResize(int $width, int $height): Representation |
39
|
|
|
{ |
40
|
|
|
if ($width < 1 || $height < 1) { |
41
|
|
|
throw new InvalidArgumentException('Invalid resize value'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$this->width = $width; |
45
|
|
|
$this->height = $height; |
46
|
|
|
$this->resize = $width . "x" . $height; |
47
|
|
|
|
48
|
|
|
return $this; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return int |
53
|
|
|
*/ |
54
|
|
|
public function getKiloBitrate(): int |
55
|
|
|
{ |
56
|
|
|
return $this->kiloBitrate; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return int|null |
61
|
|
|
*/ |
62
|
|
|
public function getAudioKiloBitrate() |
63
|
|
|
{ |
64
|
|
|
return $this->audioKiloBitrate; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Sets the video kiloBitrate value. |
69
|
|
|
* |
70
|
|
|
* @param integer $kiloBitrate |
71
|
|
|
* @return Representation |
72
|
|
|
* @throws InvalidArgumentException |
73
|
|
|
*/ |
74
|
|
|
public function setKiloBitrate(int $kiloBitrate): Representation |
75
|
|
|
{ |
76
|
|
|
if ($kiloBitrate < 1) { |
77
|
|
|
throw new InvalidArgumentException('Invalid kilo bit rate value'); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
$this->kiloBitrate = (int)$kiloBitrate; |
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Sets the video kiloBitrate value. |
86
|
|
|
* |
87
|
|
|
* @param integer $audioKiloBitrate |
88
|
|
|
* @return Representation |
89
|
|
|
* @throws InvalidArgumentException |
90
|
|
|
*/ |
91
|
|
|
public function setAudioKiloBitrate(int $audioKiloBitrate): Representation |
92
|
|
|
{ |
93
|
|
|
$this->audioKiloBitrate = $audioKiloBitrate; |
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return int |
99
|
|
|
*/ |
100
|
|
|
public function getWidth(): int |
101
|
|
|
{ |
102
|
|
|
return $this->width; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return int |
107
|
|
|
*/ |
108
|
|
|
public function getHeight(): int |
109
|
|
|
{ |
110
|
|
|
return $this->height; |
111
|
|
|
} |
112
|
|
|
} |