These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * Copyright 2014 Brian Smith <[email protected]>. |
||
5 | * |
||
6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
7 | * you may not use this file except in compliance with the License. |
||
8 | * You may obtain a copy of the License at |
||
9 | * |
||
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
11 | * |
||
12 | * Unless required by applicable law or agreed to in writing, software |
||
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
15 | * See the License for the specific language governing permissions and |
||
16 | * limitations under the License. |
||
17 | */ |
||
18 | |||
19 | namespace phparia\Resources; |
||
20 | |||
21 | use phparia\Client\AriClient; |
||
22 | use phparia\Events\Event; |
||
23 | use phparia\Exception\ConflictException; |
||
24 | use phparia\Exception\InvalidParameterException; |
||
25 | use phparia\Exception\NotFoundException; |
||
26 | use phparia\Exception\UnprocessableEntityException; |
||
27 | |||
28 | /** |
||
29 | * The merging of media from one or more channels. |
||
30 | * Everyone on the bridge receives the same audio. |
||
31 | * |
||
32 | * @author Brian Smith <[email protected]> |
||
33 | */ |
||
34 | class Bridge extends Resource |
||
35 | { |
||
36 | const TYPE_MIXING = 'mixing'; |
||
37 | const TYPE_HOLDING = 'holding'; |
||
38 | const TYPE_DTMF_EVENTS = 'dtmf_events'; |
||
39 | const TYPE_PROXY_MEDIA = 'proxy_media'; |
||
40 | |||
41 | /** |
||
42 | * @var string Bridging class |
||
43 | */ |
||
44 | private $bridgeClass; |
||
45 | |||
46 | /** |
||
47 | * @var string Type of bridge technology (mixing, holding, dtmf_events, proxy_media) |
||
48 | */ |
||
49 | private $bridgeType; |
||
50 | |||
51 | /** |
||
52 | * @var array Ids of channels participating in this bridge |
||
53 | */ |
||
54 | private $channels; |
||
55 | |||
56 | /** |
||
57 | * @var string Entity that created the bridge |
||
58 | */ |
||
59 | private $creator; |
||
60 | |||
61 | /** |
||
62 | * @var string Unique identifier for this bridge |
||
63 | */ |
||
64 | private $id; |
||
65 | |||
66 | /** |
||
67 | * @var string Unique identifier for this bridge |
||
68 | */ |
||
69 | private $name; |
||
70 | |||
71 | /** |
||
72 | * @var string Name of the current bridging technology |
||
73 | */ |
||
74 | private $technology; |
||
75 | |||
76 | /** |
||
77 | * @return string Bridging class |
||
78 | */ |
||
79 | public function getBridgeClass() |
||
80 | { |
||
81 | return $this->bridgeClass; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @return string Type of bridge technology (mixing, holding, dtmf_events, proxy_media) |
||
86 | */ |
||
87 | public function getBridgeType() |
||
88 | { |
||
89 | return $this->bridgeType; |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * @todo Should this be renamed to getChannelIds()? |
||
94 | * @return array Ids of channels participating in this bridge |
||
95 | */ |
||
96 | 3 | public function getChannels() |
|
97 | { |
||
98 | 3 | return $this->channels; |
|
99 | } |
||
100 | |||
101 | /** |
||
102 | * @return string Entity that created the bridge |
||
103 | */ |
||
104 | public function getCreator() |
||
105 | { |
||
106 | return $this->creator; |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * @return string Unique identifier for this bridge |
||
111 | */ |
||
112 | 2 | public function getId() |
|
113 | { |
||
114 | 2 | return $this->id; |
|
115 | } |
||
116 | |||
117 | /** |
||
118 | * @return string Unique identifier for this bridge |
||
119 | */ |
||
120 | public function getName() |
||
121 | { |
||
122 | return $this->name; |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * @return string Name of the current bridging technology |
||
127 | */ |
||
128 | public function getTechnology() |
||
129 | { |
||
130 | return $this->technology; |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * @param callable $callback |
||
135 | */ |
||
136 | public function onBridgeCreated(callable $callback) |
||
137 | { |
||
138 | $this->on(Event::BRIDGE_CREATED.'_'.$this->getId(), $callback); |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * @param callable $callback |
||
143 | */ |
||
144 | public function onceBridgeCreated(callable $callback) |
||
145 | { |
||
146 | $this->once(Event::BRIDGE_CREATED.'_'.$this->getId(), $callback); |
||
147 | } |
||
148 | |||
149 | /** |
||
150 | * @param callable $callback |
||
151 | */ |
||
152 | public function onBridgeDestroyed(callable $callback) |
||
153 | { |
||
154 | $this->on(Event::BRIDGE_DESTROYED.'_'.$this->getId(), $callback); |
||
155 | } |
||
156 | |||
157 | /** |
||
158 | * @param callable $callback |
||
159 | */ |
||
160 | public function onceBridgeDestroyed(callable $callback) |
||
161 | { |
||
162 | $this->once(Event::BRIDGE_DESTROYED.'_'.$this->getId(), $callback); |
||
163 | } |
||
164 | |||
165 | /** |
||
166 | * @param callable $callback |
||
167 | */ |
||
168 | public function onBridgeMerged(callable $callback) |
||
169 | { |
||
170 | $this->on(Event::BRIDGE_MERGED.'_'.$this->getId(), $callback); |
||
171 | } |
||
172 | |||
173 | /** |
||
174 | * @param callable $callback |
||
175 | */ |
||
176 | public function onceBridgeMerged(callable $callback) |
||
177 | { |
||
178 | $this->once(Event::BRIDGE_MERGED.'_'.$this->getId(), $callback); |
||
179 | } |
||
180 | |||
181 | /** |
||
182 | * Shut down a bridge. If any channels are in this bridge, they will be removed and resume whatever they were doing beforehand. |
||
183 | * |
||
184 | * @throws NotFoundException |
||
185 | */ |
||
186 | public function deleteBridge() |
||
187 | { |
||
188 | $this->client->bridges()->deleteBridge($this->id); |
||
189 | } |
||
190 | |||
191 | /** |
||
192 | * Add a channel to a bridge. |
||
193 | * |
||
194 | * @param string $channel (required) Ids of channels to add to bridge. Allows comma separated values. |
||
195 | * @param string $role Channel's role in the bridge |
||
196 | * @throws NotFoundException |
||
197 | * @throws ConflictException |
||
198 | * @throws UnprocessableEntityException |
||
199 | */ |
||
200 | public function addChannel($channel, $role = null) |
||
201 | { |
||
202 | $this->client->bridges()->addChannel($this->id, $channel, $role); |
||
203 | } |
||
204 | |||
205 | /** |
||
206 | * Remove a channel from a bridge. |
||
207 | * |
||
208 | * @param string $channel (required) Ids of channels to remove from bridge. Allows comma separated values. |
||
209 | * @throws NotFoundException |
||
210 | * @throws ConflictException |
||
211 | * @throws UnprocessableEntityException |
||
212 | */ |
||
213 | public function removeChannel($channel) |
||
214 | { |
||
215 | $this->client->bridges()->removeChannel($this->id, $channel); |
||
216 | } |
||
217 | |||
218 | /** |
||
219 | * Play music on hold to a bridge or change the MOH class that is playing. |
||
220 | * |
||
221 | * @param string $mohClass Music on hold class to use |
||
222 | * @throws NotFoundException |
||
223 | * @throws ConflictException |
||
224 | */ |
||
225 | public function startMusicOnHold($mohClass) |
||
226 | { |
||
227 | $this->client->bridges()->startMusicOnHold($this->id, $mohClass); |
||
228 | } |
||
229 | |||
230 | /** |
||
231 | * Stop playing music on hold to a bridge. This will only stop music on hold being played via POST bridges/{bridgeId}/moh. |
||
232 | * |
||
233 | * @throws NotFoundException |
||
234 | * @throws ConflictException |
||
235 | */ |
||
236 | public function stopMusicOnHold() |
||
237 | { |
||
238 | $this->client->bridges()->stopMusicOnHold($this->id); |
||
239 | } |
||
240 | |||
241 | /** |
||
242 | * Start playback of media on a bridge. The media URI may be any of a number of URI's. Currently |
||
243 | * sound:, recording:, number:, digits:, characters:, and tone: URI's are supported. This operation |
||
244 | * creates a playback resource that can be used to control the playback of media (pause, rewind, |
||
245 | * fast forward, etc.) |
||
246 | * |
||
247 | * @link https://wiki.asterisk.org/wiki/display/AST/ARI+and+Channels%3A+Simple+Media+Manipulation Simple media playback |
||
248 | * |
||
249 | * @param string $media (required) Media's URI to play. |
||
250 | * @param string $lang For sounds, selects language for sound. |
||
251 | * @param int $offsetms Number of media to skip before playing. |
||
252 | * @param int $skipms (3000 default) Number of milliseconds to skip for forward/reverse operations. |
||
253 | * @param string $playbackId Playback Id. |
||
254 | * @return Playback |
||
255 | * @throws NotFoundException |
||
256 | * @throws ConflictException |
||
257 | */ |
||
258 | public function playMedia($media, $lang = null, $offsetms = null, $skipms = null, $playbackId = null) |
||
259 | { |
||
260 | return $this->client->bridges()->playMedia($this->id, $media, $lang, $offsetms, $skipms, $playbackId); |
||
261 | } |
||
262 | |||
263 | /** |
||
264 | * Start playback of media on a bridge. The media URI may be any of a number of URI's. Currently |
||
265 | * sound:, recording:, number:, digits:, characters:, and tone: URI's are supported. This operation |
||
266 | * creates a playback resource that can be used to control the playback of media (pause, rewind, |
||
267 | * fast forward, etc.) |
||
268 | * |
||
269 | * @link https://wiki.asterisk.org/wiki/display/AST/ARI+and+Channels%3A+Simple+Media+Manipulation Simple media playback |
||
270 | * |
||
271 | * @param string $media (required) Media's URI to play. |
||
272 | * @param string $lang For sounds, selects language for sound. |
||
273 | * @param int $offsetms Number of media to skip before playing. |
||
274 | * @param int $skipms (3000 default) Number of milliseconds to skip for forward/reverse operations. |
||
275 | * @param string $playbackId Playback Id. |
||
276 | * @return Playback |
||
277 | * @throws NotFoundException |
||
278 | * @throws ConflictException |
||
279 | */ |
||
280 | public function playMediaWithId($media, $lang = null, $offsetms = null, $skipms = null, $playbackId = null) |
||
281 | { |
||
282 | return $this->client->bridges()->playMediaWithId($this->id, $media, $lang, $offsetms, $skipms, $playbackId); |
||
283 | } |
||
284 | |||
285 | /** |
||
286 | * Start a recording. Record audio from a channel. Note that this will not capture audio sent to the |
||
287 | * channel. The bridge itself has a record feature if that's what you want. |
||
288 | * |
||
289 | * @param string $name (required) Recording's filename |
||
290 | * @param string $format (required) Format to encode audio in |
||
291 | * @param int $maxDurationSeconds Maximum duration of the recording, in seconds. 0 for no limit. Allowed range: Min: 0; Max: None |
||
292 | * @param int $maxSilenceSeconds Maximum duration of silence, in seconds. 0 for no limit. Allowed range: Min: 0; Max: None |
||
293 | * @param string $ifExists = Action to take if a recording with the same name already exists. default: fail, Allowed values: fail, overwrite, append |
||
294 | * @param boolean $beep Play beep when recording begins |
||
295 | * @param string $terminateOn DTMF input to terminate recording. Default: none, Allowed values: none, any, *, # |
||
296 | * @return LiveRecording |
||
297 | * @throws InvalidParameterException |
||
298 | * @throws NotFoundException |
||
299 | * @throws ConflictException |
||
300 | * @throws UnprocessableEntityException |
||
301 | */ |
||
302 | View Code Duplication | public function record( |
|
303 | $name, |
||
304 | $format, |
||
305 | $maxDurationSeconds = null, |
||
306 | $maxSilenceSeconds = null, |
||
307 | $ifExists = null, |
||
308 | $beep = null, |
||
309 | $terminateOn = null |
||
310 | ) { |
||
311 | return $this->client->bridges()->record($this->id, $name, $format, $maxDurationSeconds, $maxSilenceSeconds, |
||
312 | $ifExists, $beep, $terminateOn); |
||
313 | } |
||
314 | |||
315 | /** |
||
316 | * @param AriClient $client |
||
317 | * @param string $response |
||
318 | */ |
||
319 | 23 | public function __construct(AriClient $client, $response) |
|
320 | { |
||
321 | 23 | parent::__construct($client, $response); |
|
322 | |||
323 | 23 | $this->bridgeClass = $this->getResponseValue('bridge_class'); |
|
324 | 23 | $this->bridgeType = $this->getResponseValue('bridge_type'); |
|
325 | 23 | $this->channels = $this->getResponseValue('channels'); |
|
0 ignored issues
–
show
|
|||
326 | 23 | $this->creator = $this->getResponseValue('creator'); |
|
327 | 23 | $this->id = $this->getResponseValue('id'); |
|
328 | 23 | $this->name = $this->getResponseValue('name'); |
|
329 | 23 | $this->technology = $this->getResponseValue('technology'); |
|
330 | 23 | } |
|
331 | |||
332 | } |
||
333 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..