Passed
Push — master ( c16b3d...220de3 )
by Amin
04:06
created

Media::stream2file()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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 FFMpeg\Media\MediaTypeInterface;
15
16
/**
17
 * @method mixed save(\FFMpeg\Format\FormatInterface $format, $outputPathfile)
18
 * @method mixed addFilter(\FFMpeg\Filters\FilterInterface $filter)
19
 * @method mixed getFormat()
20
 * @method mixed getStreams()
21
 */
22
class Media
23
{
24
25
    protected $media;
26
    /**
27
     * @var string
28
     */
29
    private $path;
30
    /**
31
     * @var bool
32
     */
33
    private $is_tmp;
34
35
    /**
36
     * Media constructor.
37
     * @param MediaTypeInterface $media
38
     * @param string $path
39
     * @param bool $is_tmp
40
     */
41
    public function __construct(MediaTypeInterface $media, string $path, bool $is_tmp)
42
    {
43
        $this->media = $media;
44
        $this->path = $path;
45
        $this->is_tmp = $is_tmp;
46
    }
47
48
    /**
49
     * @return DASH
50
     */
51
    public function DASH(): DASH
52
    {
53
        return new DASH($this);
54
    }
55
56
    /**
57
     * @return HLS
58
     */
59
    public function HLS(): HLS
60
    {
61
        return new HLS($this);
62
    }
63
64
    /**
65
     * @return StreamToFile
66
     */
67
    public function stream2file(): StreamToFile
68
    {
69
        return new StreamToFile($this);
70
    }
71
72
    /**
73
     * @return array
74
     */
75
    public function probe(): array
76
    {
77
        return [
78
            'format' => $this->getFormat(),
79
            'streams' => $this->getStreams()
80
        ];
81
    }
82
83
    /**
84
     * @param $argument
85
     * @return Media
86
     */
87
    private function isInstanceofArgument($argument)
88
    {
89
        return ($argument instanceof $this->media) ? $this : $argument;
90
    }
91
92
    /**
93
     * @param $method
94
     * @param $parameters
95
     * @return Media
96
     */
97
    public function __call($method, $parameters)
98
    {
99
        return $this->isInstanceofArgument(
100
            call_user_func_array([$this->media, $method], $parameters)
101
        );
102
    }
103
104
    /**
105
     * @return string
106
     */
107
    public function getPath(): string
108
    {
109
        return $this->path;
110
    }
111
112
    /**
113
     * @return bool
114
     */
115
    public function isTmp(): bool
116
    {
117
        return $this->is_tmp;
118
    }
119
}