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\Filters\HLSFilter; |
15
|
|
|
use Streaming\Traits\Representation as Representations; |
16
|
|
|
use Streaming\Filters\Filter; |
17
|
|
|
|
18
|
|
|
class HLS extends Export |
19
|
|
|
{ |
20
|
|
|
use Representations; |
21
|
|
|
|
22
|
|
|
/** @var string */ |
23
|
|
|
private $hls_time = 5; |
24
|
|
|
|
25
|
|
|
/** @var bool */ |
26
|
|
|
private $hls_allow_cache = true; |
27
|
|
|
|
28
|
|
|
/** @var string */ |
29
|
|
|
private $hls_key_info_file = ""; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param string $hls_time |
33
|
|
|
* @return HLS |
34
|
|
|
*/ |
35
|
|
|
public function setHlsTime(string $hls_time): HLS |
36
|
|
|
{ |
37
|
|
|
$this->hls_time = $hls_time; |
38
|
|
|
return $this; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return string |
43
|
|
|
*/ |
44
|
|
|
public function getHlsTime(): string |
45
|
|
|
{ |
46
|
|
|
return $this->hls_time; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param bool $hls_allow_cache |
51
|
|
|
* @return HLS |
52
|
|
|
*/ |
53
|
|
|
public function setHlsAllowCache(bool $hls_allow_cache): HLS |
54
|
|
|
{ |
55
|
|
|
$this->hls_allow_cache = $hls_allow_cache; |
56
|
|
|
return $this; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return bool |
61
|
|
|
*/ |
62
|
|
|
public function isHlsAllowCache(): bool |
63
|
|
|
{ |
64
|
|
|
return $this->hls_allow_cache; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param string $hls_key_info_file |
69
|
|
|
* @return HLS |
70
|
|
|
*/ |
71
|
|
|
public function setHlsKeyInfoFile(string $hls_key_info_file): HLS |
72
|
|
|
{ |
73
|
|
|
$this->hls_key_info_file = $hls_key_info_file; |
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param string $url |
79
|
|
|
* @param string $path |
80
|
|
|
* @param string $binary |
81
|
|
|
* @return HLS |
82
|
|
|
* @throws Exception\Exception |
83
|
|
|
*/ |
84
|
|
|
public function generateRandomKeyInfo(string $url = null, string $path = null, string $binary = "openssl"): HLS |
85
|
|
|
{ |
86
|
|
|
if (null === $url && null === $path){ |
87
|
|
|
$key_name = $url = Helper::randomString() . ".key"; |
88
|
|
|
$path = $this->path_info["dirname"] . DIRECTORY_SEPARATOR . $key_name; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
$this->hls_key_info_file = (string) new KeyInfo($url, $path, $binary); |
|
|
|
|
92
|
|
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return string |
97
|
|
|
*/ |
98
|
|
|
public function getHlsKeyInfoFile(): string |
99
|
|
|
{ |
100
|
|
|
return $this->hls_key_info_file; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return Filter |
105
|
|
|
*/ |
106
|
|
|
protected function getFilter(): Filter |
107
|
|
|
{ |
108
|
|
|
return $this->filter; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return mixed|void |
113
|
|
|
*/ |
114
|
|
|
protected function setFilter() |
115
|
|
|
{ |
116
|
|
|
$this->filter = new HLSFilter($this); |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|