Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
MP4Box | |
0.00% |
0 / 9 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
end | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
remaining | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
read | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | /** |
3 | * .m3u8 playlist generation for HLS (HTTP Live Streaming) |
4 | * |
5 | * @file |
6 | * @ingroup HLS |
7 | */ |
8 | |
9 | namespace MediaWiki\TimedMediaHandler\HLS; |
10 | |
11 | /** |
12 | * Wrapper for reading from an MP4 box that contains a series of additional boxes. |
13 | * Forces end of stream at the end of the input. |
14 | * Warning: could get confused if you close the underlying reader. |
15 | */ |
16 | class MP4Box extends MP4Reader { |
17 | public int $start; |
18 | public int $size; |
19 | public string $type; |
20 | |
21 | /** |
22 | * @param resource $file |
23 | * @param int $start |
24 | * @param int $size |
25 | * @param string $type |
26 | */ |
27 | public function __construct( $file, int $start, int $size, string $type ) { |
28 | parent::__construct( $file ); |
29 | $this->start = $start; |
30 | $this->size = $size; |
31 | $this->type = $type; |
32 | } |
33 | |
34 | public function end(): int { |
35 | return $this->start + $this->size; |
36 | } |
37 | |
38 | public function remaining(): int { |
39 | return $this->end() - $this->pos(); |
40 | } |
41 | |
42 | /** |
43 | * Won't read beyond the end of this box. |
44 | */ |
45 | public function read( int $length ): string { |
46 | if ( $length > $this->remaining() ) { |
47 | throw new ShortReadException( parent::read( $this->remaining() ) ); |
48 | } |
49 | return parent::read( $length ); |
50 | } |
51 | } |