1
|
|
|
<?php |
2
|
|
|
// |
3
|
|
|
// This code and all components (c) Copyright 2006 - 2018, Wowza Media Systems, LLC. All rights reserved. |
4
|
|
|
// This code is licensed pursuant to the Wowza Public License version 1.0, available at www.wowza.com/legal. |
5
|
|
|
// |
6
|
|
|
|
7
|
|
|
namespace Com\Wowza; |
8
|
|
|
|
9
|
|
|
use Com\Wowza\Entities\Application\Helpers\Settings; |
10
|
|
|
|
11
|
|
|
class StreamTarget extends Wowza |
12
|
|
|
{ |
13
|
|
|
protected $sourceStreamName = 'myStream'; |
14
|
|
|
protected $entryName = 'ppsource'; |
15
|
|
|
protected $profile = 'rtmp'; |
16
|
|
|
protected $host = 'localhost'; |
17
|
|
|
protected $application = 'live'; |
18
|
|
|
protected $userName = null; |
19
|
|
|
protected $password = null; |
20
|
|
|
protected $streamName = 'myStream'; |
21
|
|
|
protected $appName; |
22
|
|
|
protected $port = 1935 |
23
|
|
|
|
24
|
|
|
public function __construct(Settings $settings, $appName) |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
parent::__construct($settings); |
27
|
|
|
$this->appName = $appName; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function create( |
31
|
|
|
$sourceStreamName = null, |
32
|
|
|
$entryName = null, |
33
|
|
|
$profile = null, |
34
|
|
|
$host = null, |
35
|
|
|
$userName = null, |
36
|
|
|
$password = null, |
37
|
|
|
$streamName = null, |
38
|
|
|
$application = null, |
39
|
|
|
$port = null |
40
|
|
|
) { |
41
|
|
|
$this->restURI = $this->getRestURI() . '/' . $entryName; |
42
|
|
|
$this->sourceStreamName = (!is_null($sourceStreamName)) ? $sourceStreamName : $this->sourceStreamName; |
43
|
|
|
$this->entryName = (!is_null($entryName)) ? $entryName : $this->entryName; |
44
|
|
|
$this->profile = (!is_null($profile)) ? $profile : $this->profile; |
45
|
|
|
$this->host = (!is_null($host)) ? $host : $this->host; |
46
|
|
|
$this->userName = (!is_null($userName)) ? $userName : $this->userName; |
47
|
|
|
$this->password = (!is_null($password)) ? $password : $this->password; |
48
|
|
|
$this->streamName = (!is_null($streamName)) ? $streamName : $this->streamName; |
49
|
|
|
$this->application = (!is_null($application)) ? $application : $this->application; |
50
|
|
|
$this->port = (!is_null($port)) ? ($int)$port : $this->port; |
51
|
|
|
|
52
|
|
|
$response = $this->sendRequest($this->preparePropertiesForRequest(self::class), []); |
53
|
|
|
|
54
|
|
|
return $response; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function update( |
58
|
|
|
$sourceStreamName = null, |
59
|
|
|
$entryName = null, |
60
|
|
|
$profile = null, |
61
|
|
|
$host = null, |
62
|
|
|
$userName = null, |
63
|
|
|
$password = null, |
64
|
|
|
$streamName = null, |
65
|
|
|
$application = null, |
66
|
|
|
$port = null |
67
|
|
|
) { |
68
|
|
|
$this->restURI = $this->getRestURI() . "/" . $entryName; |
69
|
|
|
$this->sourceStreamName = (!is_null($sourceStreamName)) ? $sourceStreamName : $this->sourceStreamName; |
70
|
|
|
$this->entryName = (!is_null($entryName)) ? $entryName : $this->entryName; |
71
|
|
|
$this->profile = (!is_null($profile)) ? $profile : $this->profile; |
72
|
|
|
$this->host = (!is_null($host)) ? $host : $this->host; |
73
|
|
|
$this->userName = (!is_null($userName)) ? $userName : $this->userName; |
74
|
|
|
$this->password = (!is_null($password)) ? $password : $this->password; |
75
|
|
|
$this->streamName = (!is_null($streamName)) ? $streamName : $this->streamName; |
76
|
|
|
$this->application = (!is_null($application)) ? $application : $this->application; |
77
|
|
|
$this->port = (!is_null($port)) ? ($int)$port : $this->port; |
78
|
|
|
|
79
|
|
|
return $this->sendRequest($this->preparePropertiesForRequest(self::class), [], self::VERB_PUT); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getAll() |
83
|
|
|
{ |
84
|
|
|
$this->setNoParams(); |
85
|
|
|
$this->restURI = $this->getRestURI(); |
86
|
|
|
|
87
|
|
|
return $this->sendRequest($this->preparePropertiesForRequest(self::class), [], self::VERB_GET); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
private function setNoParams() |
91
|
|
|
{ |
92
|
|
|
$this->addSkipParameter('userName', true)//todo: correct key name? |
93
|
|
|
->addSkipParameter('password', true) |
94
|
|
|
->addSkipParameter('group', true) |
95
|
|
|
->addSkipParameter('sourceStreamName', true) |
96
|
|
|
->addSkipParameter('entryName', true) |
97
|
|
|
->addSkipParameter('profile', true) |
98
|
|
|
->addSkipParameter('host', true) |
99
|
|
|
->addSkipParameter('application', true) |
100
|
|
|
->addSkipParameter('streamName', true); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function remove($entryName) |
104
|
|
|
{ |
105
|
|
|
$this->setNoParams(); |
106
|
|
|
$this->restURI = $this->getRestURI() . '/' . $entryName; |
107
|
|
|
|
108
|
|
|
return $this->sendRequest($this->preparePropertiesForRequest(self::class), [], self::VERB_DELETE); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
protected function getRestURI() |
112
|
|
|
{ |
113
|
|
|
return $this->getHost() . '/servers/' . $this->getServerInstance() . '/vhosts/' . $this->getVHostInstance() . '/applications/' . $this->appName . '/pushpublish/mapentries'; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|