|
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 DateTime; |
|
22
|
|
|
use phparia\Client\AriClient; |
|
23
|
|
|
use phparia\Events\Event; |
|
24
|
|
|
use phparia\Exception\ConflictException; |
|
25
|
|
|
use phparia\Exception\InvalidParameterException; |
|
26
|
|
|
use phparia\Exception\NotFoundException; |
|
27
|
|
|
use phparia\Exception\UnprocessableEntityException; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* A specific communication connection between Asterisk and an Endpoint. |
|
31
|
|
|
* |
|
32
|
|
|
* @author Brian Smith <[email protected]> |
|
33
|
|
|
*/ |
|
34
|
|
|
class Channel extends Resource |
|
35
|
|
|
{ |
|
36
|
|
|
/** |
|
37
|
|
|
* @var string |
|
38
|
|
|
*/ |
|
39
|
|
|
private $accountCode; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var CallerId |
|
43
|
|
|
*/ |
|
44
|
|
|
private $caller; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var CallerId |
|
48
|
|
|
*/ |
|
49
|
|
|
private $connected; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var DateTime |
|
53
|
|
|
*/ |
|
54
|
|
|
private $creationTime; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var DialplanCep |
|
58
|
|
|
*/ |
|
59
|
|
|
private $dialplan; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @var string Unique identifier of the channel. This is the same as the Uniqueid field in AMI. |
|
63
|
|
|
*/ |
|
64
|
|
|
private $id; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @var string Name of the channel (i.e. SIP/foo-0000a7e3) |
|
68
|
|
|
*/ |
|
69
|
|
|
private $name; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @var string |
|
73
|
|
|
*/ |
|
74
|
|
|
private $state; |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @return string |
|
78
|
|
|
*/ |
|
79
|
|
|
public function getAccountCode() |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->accountCode; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return CallerId Caller identification |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getCaller() |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->caller; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @return CallerId Connected caller identification |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getConnected() |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->connected; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @return DateTime |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getCreationTime() |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->creationTime; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @return DialplanCep Dialplan location (context/extension/priority) |
|
110
|
|
|
*/ |
|
111
|
1 |
|
public function getDialplan() |
|
112
|
|
|
{ |
|
113
|
1 |
|
return $this->dialplan; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @return string Unique identifier of the channel. This is the same as the Uniqueid field in AMI. |
|
118
|
|
|
*/ |
|
119
|
38 |
|
public function getId() |
|
120
|
|
|
{ |
|
121
|
38 |
|
return $this->id; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @return string Name of the channel (i.e. SIP/foo-0000a7e3) |
|
126
|
|
|
*/ |
|
127
|
|
|
public function getName() |
|
128
|
|
|
{ |
|
129
|
|
|
return $this->name; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @return string |
|
134
|
|
|
*/ |
|
135
|
|
|
public function getState() |
|
136
|
|
|
{ |
|
137
|
|
|
return $this->state; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* @param callable $callback |
|
142
|
|
|
*/ |
|
143
|
|
|
public function onStasisEnd(callable $callback) |
|
144
|
|
|
{ |
|
145
|
|
|
$this->on(Event::STASIS_END . '_' . $this->getId(), $callback); |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* @param callable $callback |
|
150
|
|
|
*/ |
|
151
|
|
|
public function onceStasisEnd(callable $callback) |
|
152
|
|
|
{ |
|
153
|
|
|
$this->once(Event::STASIS_END . '_' . $this->getId(), $callback); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @param callable $callback |
|
158
|
|
|
*/ |
|
159
|
|
|
public function onStasisStart(callable $callback) |
|
160
|
|
|
{ |
|
161
|
|
|
$this->on(Event::STASIS_START . '_' . $this->getId(), $callback); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* @param callable $callback |
|
166
|
|
|
*/ |
|
167
|
|
|
public function onceStasisStart(callable $callback) |
|
168
|
|
|
{ |
|
169
|
|
|
$this->once(Event::STASIS_START . '_' . $this->getId(), $callback); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* @param callable $callback |
|
174
|
|
|
*/ |
|
175
|
|
|
public function onChannelCallerId(callable $callback) |
|
176
|
|
|
{ |
|
177
|
|
|
$this->on(Event::CHANNEL_CALLER_ID . '_' . $this->getId(), $callback); |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* @param callable $callback |
|
182
|
|
|
*/ |
|
183
|
|
|
public function onceChannelCallerId(callable $callback) |
|
184
|
|
|
{ |
|
185
|
|
|
$this->once(Event::CHANNEL_CALLER_ID . '_' . $this->getId(), $callback); |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* @param callable $callback |
|
190
|
|
|
*/ |
|
191
|
|
|
public function onChannelCreated(callable $callback) |
|
192
|
|
|
{ |
|
193
|
|
|
$this->on(Event::CHANNEL_CREATED . '_' . $this->getId(), $callback); |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
/** |
|
197
|
|
|
* @param callable $callback |
|
198
|
|
|
*/ |
|
199
|
|
|
public function onceChannelCreated(callable $callback) |
|
200
|
|
|
{ |
|
201
|
|
|
$this->once(Event::CHANNEL_CREATED . '_' . $this->getId(), $callback); |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
/** |
|
205
|
|
|
* @param callable $callback |
|
206
|
|
|
*/ |
|
207
|
|
|
public function onChannelDestroyed(callable $callback) |
|
208
|
|
|
{ |
|
209
|
|
|
$this->on(Event::CHANNEL_DESTROYED . '_' . $this->getId(), $callback); |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* @param callable $callback |
|
214
|
|
|
*/ |
|
215
|
|
|
public function onceChannelDestroyed(callable $callback) |
|
216
|
|
|
{ |
|
217
|
|
|
$this->once(Event::CHANNEL_DESTROYED . '_' . $this->getId(), $callback); |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* @param callable $callback |
|
222
|
|
|
*/ |
|
223
|
|
|
public function removeChannelDestroyedListener(callable $callback) |
|
224
|
|
|
{ |
|
225
|
|
|
$this->removeListener(Event::CHANNEL_DESTROYED . '_' . $this->getId(), $callback); |
|
226
|
|
|
} |
|
227
|
|
|
|
|
228
|
|
|
/** |
|
229
|
|
|
* @param callable $callback |
|
230
|
|
|
*/ |
|
231
|
|
|
public function onChannelDialplan(callable $callback) |
|
232
|
|
|
{ |
|
233
|
|
|
$this->on(Event::CHANNEL_DIALPLAN . '_' . $this->getId(), $callback); |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
/** |
|
237
|
|
|
* @param callable $callback |
|
238
|
|
|
*/ |
|
239
|
|
|
public function onceChannelDialplan(callable $callback) |
|
240
|
|
|
{ |
|
241
|
|
|
$this->once(Event::CHANNEL_DIALPLAN . '_' . $this->getId(), $callback); |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
/** |
|
245
|
|
|
* @param callable $callback |
|
246
|
|
|
*/ |
|
247
|
|
|
public function onChannelDtmfReceived(callable $callback) |
|
248
|
|
|
{ |
|
249
|
|
|
$this->on(Event::CHANNEL_DTMF_RECEIVED . '_' . $this->getId(), $callback); |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
/** |
|
253
|
|
|
* @param callable $callback |
|
254
|
|
|
*/ |
|
255
|
|
|
public function onceChannelDtmfReceived(callable $callback) |
|
256
|
|
|
{ |
|
257
|
|
|
$this->once(Event::CHANNEL_DTMF_RECEIVED . '_' . $this->getId(), $callback); |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
/** |
|
261
|
|
|
* @param callable $callback |
|
262
|
|
|
*/ |
|
263
|
|
|
public function onChannelEnteredBridge(callable $callback) |
|
264
|
|
|
{ |
|
265
|
|
|
$this->on(Event::CHANNEL_ENTERED_BRIDGE . '_' . $this->getId(), $callback); |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
/** |
|
269
|
|
|
* @param callable $callback |
|
270
|
|
|
*/ |
|
271
|
|
|
public function onceChannelEnteredBridge(callable $callback) |
|
272
|
|
|
{ |
|
273
|
|
|
$this->once(Event::CHANNEL_ENTERED_BRIDGE . '_' . $this->getId(), $callback); |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
/** |
|
277
|
|
|
* @param callable $callback |
|
278
|
|
|
*/ |
|
279
|
|
|
public function onChannelHangupRequest(callable $callback) |
|
280
|
|
|
{ |
|
281
|
|
|
$this->on(Event::CHANNEL_HANGUP_REQUEST . '_' . $this->getId(), $callback); |
|
282
|
|
|
} |
|
283
|
|
|
|
|
284
|
|
|
/** |
|
285
|
|
|
* @param callable $callback |
|
286
|
|
|
*/ |
|
287
|
|
|
public function onceChannelHangupRequest(callable $callback) |
|
288
|
|
|
{ |
|
289
|
|
|
$this->once(Event::CHANNEL_HANGUP_REQUEST . '_' . $this->getId(), $callback); |
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
|
|
/** |
|
293
|
|
|
* @param callable $callback |
|
294
|
|
|
*/ |
|
295
|
|
|
public function onChannelLeftBridge(callable $callback) |
|
296
|
|
|
{ |
|
297
|
|
|
$this->on(Event::CHANNEL_LEFT_BRIDGE . '_' . $this->getId(), $callback); |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
/** |
|
301
|
|
|
* @param callable $callback |
|
302
|
|
|
*/ |
|
303
|
|
|
public function onceChannelLeftBridge(callable $callback) |
|
304
|
|
|
{ |
|
305
|
|
|
$this->once(Event::CHANNEL_LEFT_BRIDGE . '_' . $this->getId(), $callback); |
|
306
|
|
|
} |
|
307
|
|
|
|
|
308
|
|
|
/** |
|
309
|
|
|
* @param callable $callback |
|
310
|
|
|
*/ |
|
311
|
|
|
public function onChannelStateChange(callable $callback) |
|
312
|
|
|
{ |
|
313
|
|
|
$this->on(Event::CHANNEL_STATE_CHANGE . '_' . $this->getId(), $callback); |
|
314
|
|
|
} |
|
315
|
|
|
|
|
316
|
|
|
/** |
|
317
|
|
|
* @param callable $callback |
|
318
|
|
|
*/ |
|
319
|
|
|
public function onceChannelStateChange(callable $callback) |
|
320
|
|
|
{ |
|
321
|
|
|
$this->once(Event::CHANNEL_STATE_CHANGE . '_' . $this->getId(), $callback); |
|
322
|
|
|
} |
|
323
|
|
|
|
|
324
|
|
|
/** |
|
325
|
|
|
* @param callable $callback |
|
326
|
|
|
*/ |
|
327
|
|
|
public function onChannelHold(callable $callback) |
|
328
|
|
|
{ |
|
329
|
|
|
$this->on(Event::CHANNEL_HOLD . '_' . $this->getId(), $callback); |
|
330
|
|
|
} |
|
331
|
|
|
|
|
332
|
|
|
/** |
|
333
|
|
|
* @param callable $callback |
|
334
|
|
|
*/ |
|
335
|
|
|
public function onceChannelHold(callable $callback) |
|
336
|
|
|
{ |
|
337
|
|
|
$this->once(Event::CHANNEL_HOLD . '_' . $this->getId(), $callback); |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
|
|
/** |
|
341
|
|
|
* @param callable $callback |
|
342
|
|
|
*/ |
|
343
|
|
|
public function onChannelUnhold(callable $callback) |
|
344
|
|
|
{ |
|
345
|
|
|
$this->on(Event::CHANNEL_UNHOLD . '_' . $this->getId(), $callback); |
|
346
|
|
|
} |
|
347
|
|
|
|
|
348
|
|
|
/** |
|
349
|
|
|
* @param callable $callback |
|
350
|
|
|
*/ |
|
351
|
|
|
public function onceChanneUnhold(callable $callback) |
|
352
|
|
|
{ |
|
353
|
|
|
$this->once(Event::CHANNEL_UNHOLD . '_' . $this->getId(), $callback); |
|
354
|
|
|
} |
|
355
|
|
|
|
|
356
|
|
|
/** |
|
357
|
|
|
* @param callable $callback |
|
358
|
|
|
*/ |
|
359
|
|
|
public function onChannelTalkingFinished(callable $callback) |
|
360
|
|
|
{ |
|
361
|
|
|
$this->on(Event::CHANNEL_TALKING_FINISHED . '_' . $this->getId(), $callback); |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
/** |
|
365
|
|
|
* @param callable $callback |
|
366
|
|
|
*/ |
|
367
|
|
|
public function onceChannelTalkingFinished(callable $callback) |
|
368
|
|
|
{ |
|
369
|
|
|
$this->once(Event::CHANNEL_TALKING_FINISHED . '_' . $this->getId(), $callback); |
|
370
|
|
|
} |
|
371
|
|
|
|
|
372
|
|
|
/** |
|
373
|
|
|
* @param callable $callback |
|
374
|
|
|
*/ |
|
375
|
|
|
public function onChannelTalkingStarted(callable $callback) |
|
376
|
|
|
{ |
|
377
|
|
|
$this->on(Event::CHANNEL_TALKING_STARTED . '_' . $this->getId(), $callback); |
|
378
|
|
|
} |
|
379
|
|
|
|
|
380
|
|
|
/** |
|
381
|
|
|
* @param callable $callback |
|
382
|
|
|
*/ |
|
383
|
|
|
public function onceChannelTalkingStarted(callable $callback) |
|
384
|
|
|
{ |
|
385
|
37 |
|
$this->once(Event::CHANNEL_TALKING_STARTED . '_' . $this->getId(), $callback); |
|
386
|
|
|
} |
|
387
|
37 |
|
|
|
388
|
37 |
|
/** |
|
389
|
|
|
* @param callable $callback |
|
390
|
|
|
*/ |
|
391
|
|
|
public function onChannelUserevent(callable $callback) |
|
392
|
|
|
{ |
|
393
|
|
|
$this->on(Event::CHANNEL_USEREVENT . '_' . $this->getId(), $callback); |
|
394
|
|
|
} |
|
395
|
|
|
|
|
396
|
|
|
/** |
|
397
|
|
|
* @param callable $callback |
|
398
|
|
|
*/ |
|
399
|
|
|
public function onceChannelUserevent(callable $callback) |
|
400
|
|
|
{ |
|
401
|
|
|
$this->once(Event::CHANNEL_USEREVENT . '_' . $this->getId(), $callback); |
|
402
|
|
|
} |
|
403
|
|
|
|
|
404
|
|
|
/** |
|
405
|
|
|
* @param callable $callback |
|
406
|
|
|
*/ |
|
407
|
|
|
public function onChannelVarset(callable $callback) |
|
408
|
|
|
{ |
|
409
|
|
|
$this->on(Event::CHANNEL_VARSET . '_' . $this->getId(), $callback); |
|
410
|
37 |
|
} |
|
411
|
|
|
|
|
412
|
37 |
|
/** |
|
413
|
37 |
|
* @param callable $callback |
|
414
|
|
|
*/ |
|
415
|
|
|
public function onceChannelVarset(callable $callback) |
|
416
|
|
|
{ |
|
417
|
|
|
$this->once(Event::CHANNEL_VARSET . '_' . $this->getId(), $callback); |
|
418
|
|
|
} |
|
419
|
|
|
|
|
420
|
|
|
/** |
|
421
|
|
|
* Delete (i.e. hangup) a channel. |
|
422
|
|
|
* |
|
423
|
|
|
* @throws NotFoundException |
|
424
|
|
|
*/ |
|
425
|
|
|
public function deleteChannel() |
|
426
|
|
|
{ |
|
427
|
|
|
$this->client->channels()->deleteChannel($this->id); |
|
428
|
|
|
} |
|
429
|
|
|
|
|
430
|
|
|
/** |
|
431
|
|
|
* Hangup the channel if it still exists. |
|
432
|
|
|
*/ |
|
433
|
|
|
public function hangup() |
|
434
|
|
|
{ |
|
435
|
|
|
$this->client->channels()->hangup($this->id); |
|
436
|
|
|
} |
|
437
|
|
|
|
|
438
|
|
|
/** |
|
439
|
|
|
* Exit application; continue execution in the dialplan. |
|
440
|
|
|
* |
|
441
|
|
|
* @param string $context The context to continue to. |
|
442
|
|
|
* @param string $extension The extension to continue to. |
|
443
|
|
|
* @param int $priority The priority to continue to. |
|
444
|
|
|
* @throws NotFoundException |
|
445
|
|
|
* @throws ConflictException |
|
446
|
|
|
*/ |
|
447
|
|
|
public function continueDialplan($context, $extension, $priority) |
|
448
|
|
|
{ |
|
449
|
|
|
$this->client->channels()->continueDialplan($this->id, $context, $extension, $priority); |
|
450
|
|
|
} |
|
451
|
|
|
|
|
452
|
|
|
/** |
|
453
|
|
|
* Answer a channel. |
|
454
|
|
|
* |
|
455
|
|
|
* @throws NotFoundException |
|
456
|
|
|
* @throws ConflictException |
|
457
|
|
|
*/ |
|
458
|
|
|
public function answer() |
|
459
|
|
|
{ |
|
460
|
|
|
$this->client->channels()->answer($this->id); |
|
461
|
|
|
} |
|
462
|
|
|
|
|
463
|
|
|
/** |
|
464
|
|
|
* Indicate ringing to a channel. |
|
465
|
|
|
* |
|
466
|
|
|
* @throws NotFoundException |
|
467
|
|
|
* @throws ConflictException |
|
468
|
|
|
*/ |
|
469
|
|
|
public function startRinging() |
|
470
|
|
|
{ |
|
471
|
|
|
$this->client->channels()->startRinging($this->id); |
|
472
|
|
|
} |
|
473
|
|
|
|
|
474
|
|
|
/** |
|
475
|
|
|
* Stop ringing indication on a channel if locally generated. |
|
476
|
|
|
* |
|
477
|
|
|
* @throws NotFoundException |
|
478
|
|
|
* @throws ConflictException |
|
479
|
|
|
*/ |
|
480
|
|
|
public function stopRinging() |
|
481
|
|
|
{ |
|
482
|
|
|
$this->client->channels()->stopRinging($this->id); |
|
483
|
|
|
} |
|
484
|
|
|
|
|
485
|
|
|
/** |
|
486
|
|
|
* Send provided DTMF to a given channel. |
|
487
|
|
|
* |
|
488
|
|
|
* @param string $dtmf DTMF To send. |
|
489
|
|
|
* @param int $before Amount of time to wait before DTMF digits (specified in milliseconds) start. |
|
490
|
|
|
* @param int $between Amount of time in between DTMF digits (specified in milliseconds). Default: 100 |
|
491
|
|
|
* @param int $duration Length of each DTMF digit (specified in milliseconds). Default: 100 |
|
492
|
|
|
* @param int $after Amount of time to wait after DTMF digits (specified in milliseconds) end. |
|
493
|
|
|
* @throws InvalidParameterException |
|
494
|
|
|
* @throws NotFoundException |
|
495
|
|
|
* @throws ConflictException |
|
496
|
|
|
*/ |
|
497
|
|
|
public function sendDtmf($dtmf, $before = null, $between = null, $duration = null, $after = null) |
|
498
|
|
|
{ |
|
499
|
|
|
$this->client->channels()->sendDtmf($this->id, $dtmf, $before, $between, $duration, $after); |
|
500
|
|
|
} |
|
501
|
|
|
|
|
502
|
|
|
/** |
|
503
|
|
|
* Mute a channel. |
|
504
|
|
|
* |
|
505
|
|
|
* @param string $direction (default both) Direction in which to mute audio |
|
506
|
|
|
* @throws NotFoundException |
|
507
|
|
|
* @throws ConflictException |
|
508
|
|
|
*/ |
|
509
|
|
|
public function mute($direction) |
|
510
|
|
|
{ |
|
511
|
|
|
$this->client->channels()->mute($this->id, $direction); |
|
512
|
|
|
} |
|
513
|
|
|
|
|
514
|
|
|
/** |
|
515
|
|
|
* Unmute a channel. |
|
516
|
|
|
* |
|
517
|
|
|
* @param string $direction (default both) Direction in which to unmute audio |
|
518
|
|
|
* @throws NotFoundException |
|
519
|
|
|
* @throws ConflictException |
|
520
|
|
|
*/ |
|
521
|
|
|
public function unmute($direction) |
|
522
|
|
|
{ |
|
523
|
|
|
$this->client->channels()->unmute($this->id, $direction); |
|
524
|
|
|
} |
|
525
|
|
|
|
|
526
|
|
|
/** |
|
527
|
|
|
* Hold a channel. |
|
528
|
|
|
* |
|
529
|
|
|
* @throws NotFoundException |
|
530
|
|
|
* @throws ConflictException |
|
531
|
|
|
*/ |
|
532
|
|
|
public function hold() |
|
533
|
|
|
{ |
|
534
|
|
|
$this->client->channels()->hold($this->id); |
|
535
|
|
|
} |
|
536
|
|
|
|
|
537
|
|
|
/** |
|
538
|
|
|
* Remove a channel from hold. |
|
539
|
|
|
* |
|
540
|
|
|
* @throws NotFoundException |
|
541
|
|
|
* @throws ConflictException |
|
542
|
|
|
*/ |
|
543
|
|
|
public function unhold() |
|
544
|
|
|
{ |
|
545
|
|
|
$this->client->channels()->unhold($this->id); |
|
546
|
|
|
} |
|
547
|
|
|
|
|
548
|
|
|
/** |
|
549
|
|
|
* Play music on hold to a channel. Using media operations such as /play on a channel playing MOH in |
|
550
|
|
|
* this manner will suspend MOH without resuming automatically. If continuing music on hold is |
|
551
|
|
|
* desired, the stasis application must reinitiate music on hold. |
|
552
|
|
|
* |
|
553
|
|
|
* @param string $mohClass Music on hold class to use |
|
554
|
|
|
* @throws NotFoundException |
|
555
|
|
|
* @throws ConflictException |
|
556
|
|
|
*/ |
|
557
|
|
|
public function startMusicOnHold($mohClass) |
|
558
|
|
|
{ |
|
559
|
|
|
$this->client->channels()->startMusicOnHold($this->id, $mohClass); |
|
560
|
|
|
} |
|
561
|
|
|
|
|
562
|
|
|
/** |
|
563
|
|
|
* Stop playing music on hold to a channel. |
|
564
|
2 |
|
* |
|
565
|
|
|
* @throws NotFoundException |
|
566
|
2 |
|
* @throws ConflictException |
|
567
|
|
|
*/ |
|
568
|
|
|
public function stopMusicOnHold() |
|
569
|
|
|
{ |
|
570
|
|
|
$this->client->channels()->stopMusicOnHold($this->id); |
|
571
|
|
|
} |
|
572
|
|
|
|
|
573
|
|
|
/** |
|
574
|
|
|
* Play silence to a channel. Using media operations such as /play on a channel playing silence in this manner will suspend silence without resuming automatically. |
|
575
|
|
|
* |
|
576
|
|
|
* @throws NotFoundException |
|
577
|
|
|
* @throws ConflictException |
|
578
|
|
|
*/ |
|
579
|
|
|
public function startSilence() |
|
580
|
|
|
{ |
|
581
|
|
|
$this->client->channels()->startSilence($this->id); |
|
582
|
|
|
} |
|
583
|
|
|
|
|
584
|
|
|
/** |
|
585
|
4 |
|
* Stop playing silence to a channel. |
|
586
|
|
|
* |
|
587
|
4 |
|
* @throws NotFoundException |
|
588
|
4 |
|
* @throws ConflictException |
|
589
|
|
|
*/ |
|
590
|
|
|
public function stopSilence() |
|
591
|
|
|
{ |
|
592
|
|
|
$this->client->channels()->stopSilence($this->id); |
|
593
|
|
|
} |
|
594
|
|
|
|
|
595
|
|
|
/** |
|
596
|
|
|
* Start playback of media. The media URI may be any of a number of URI's. Currently sound:, |
|
597
|
|
|
* recording:, number:, digits:, characters:, and tone: URI's are supported. This operation creates a |
|
598
|
|
|
* playback resource that can be used to control the playback of media (pause, rewind, fast forward, |
|
599
|
|
|
* etc.) |
|
600
|
|
|
* |
|
601
|
|
|
* @link https://wiki.asterisk.org/wiki/display/AST/ARI+and+Channels%3A+Simple+Media+Manipulation Simple media playback |
|
602
|
|
|
* |
|
603
|
|
|
* @param string $media (required) Media's URI to play. |
|
604
|
|
|
* @param string $lang For sounds, selects language for sound. |
|
605
|
|
|
* @param int $offsetms Number of media to skip before playing. |
|
606
|
|
|
* @param int $skipms (3000 default) Number of milliseconds to skip for forward/reverse operations. |
|
607
|
|
|
* @param string $playbackId Playback Id. |
|
608
|
|
|
* @return Playback |
|
609
|
|
|
* @throws NotFoundException |
|
610
|
|
|
* @throws ConflictException |
|
611
|
|
|
*/ |
|
612
|
|
|
public function playMedia($media, $lang = null, $offsetms = null, $skipms = null, $playbackId = null) |
|
613
|
|
|
{ |
|
614
|
|
|
return $this->client->channels()->playMedia($this->id, $media, $lang, $offsetms, $skipms, $playbackId); |
|
615
|
|
|
} |
|
616
|
|
|
|
|
617
|
|
|
/** |
|
618
|
|
|
* Start playback of media and specify the playbackId. The media URI may be any of a number of URI's. |
|
619
|
|
|
* Currently sound: and recording: URI's are supported. This operation creates a playback resource |
|
620
|
|
|
* that can be used to control the playback of media (pause, rewind, fast forward, etc.) |
|
621
|
|
|
* |
|
622
|
|
|
* @link https://wiki.asterisk.org/wiki/display/AST/ARI+and+Channels%3A+Simple+Media+Manipulation Simple media playback |
|
623
|
|
|
* |
|
624
|
|
|
* @param string $media (required) Media's URI to play. |
|
625
|
|
|
* @param string $lang For sounds, selects language for sound. |
|
626
|
|
|
* @param int $offsetms Number of media to skip before playing. |
|
627
|
|
|
* @param int $skipms (3000 default) Number of milliseconds to skip for forward/reverse operations. |
|
628
|
|
|
* @param string $playbackId Playback Id. |
|
629
|
|
|
* @return Playback |
|
630
|
|
|
* @throws NotFoundException |
|
631
|
|
|
* @throws ConflictException |
|
632
|
|
|
*/ |
|
633
|
|
|
public function playMediaWithId($media, $lang = null, $offsetms = null, $skipms = null, $playbackId = null) |
|
634
|
|
|
{ |
|
635
|
|
|
return $this->client->channels()->playMediaWithId($this->getId(), $media, $lang, $offsetms, $skipms, |
|
636
|
|
|
$playbackId); |
|
637
|
|
|
} |
|
638
|
|
|
|
|
639
|
|
|
/** |
|
640
|
|
|
* Start a recording. Record audio from a channel. Note that this will not capture audio sent to the |
|
641
|
|
|
* channel. The bridge itself has a record feature if that's what you want. |
|
642
|
|
|
* |
|
643
|
|
|
* @param string $name (required) Recording's filename |
|
644
|
|
|
* @param string $format (required) Format to encode audio in |
|
645
|
|
|
* @param int $maxDurationSeconds Maximum duration of the recording, in seconds. 0 for no limit. Allowed range: Min: 0; Max: None |
|
646
|
|
|
* @param int $maxSilenceSeconds Maximum duration of silence, in seconds. 0 for no limit. Allowed range: Min: 0; Max: None |
|
647
|
|
|
* @param string $ifExists = Action to take if a recording with the same name already exists. default: fail, Allowed values: fail, overwrite, append |
|
648
|
|
|
* @param boolean $beep Play beep when recording begins |
|
649
|
|
|
* @param string $terminateOn DTMF input to terminate recording. Default: none, Allowed values: none, any, *, # |
|
650
|
|
|
* @return LiveRecording |
|
651
|
|
|
* @throws InvalidParameterException |
|
652
|
|
|
* @throws NotFoundException |
|
653
|
|
|
* @throws ConflictException |
|
654
|
|
|
* @throws UnprocessableEntityException |
|
655
|
|
|
*/ |
|
656
|
|
View Code Duplication |
public function record( |
|
657
|
|
|
$name, |
|
658
|
|
|
$format, |
|
659
|
|
|
$maxDurationSeconds = null, |
|
660
|
|
|
$maxSilenceSeconds = null, |
|
661
|
|
|
$ifExists = null, |
|
662
|
|
|
$beep = null, |
|
663
|
|
|
$terminateOn = null |
|
664
|
|
|
) |
|
665
|
|
|
{ |
|
666
|
|
|
return $this->client->channels()->record($this->id, $name, $format, $maxDurationSeconds, $maxSilenceSeconds, |
|
667
|
|
|
$ifExists, $beep, $terminateOn); |
|
668
|
|
|
} |
|
669
|
|
|
|
|
670
|
|
|
/** |
|
671
|
|
|
* Get the value of a channel variable or function. |
|
672
|
|
|
* |
|
673
|
|
|
* @param string $variable |
|
674
|
|
|
* @param null|string $default The value to return if the variable does not exist |
|
675
|
|
|
* @return string|Variable |
|
676
|
|
|
* @throws InvalidParameterException |
|
677
|
|
|
* @throws NotFoundException |
|
678
|
|
|
* @throws ConflictException |
|
679
|
|
|
*/ |
|
680
|
|
|
public function getVariable($variable, $default = null) |
|
681
|
|
|
{ |
|
682
|
|
|
return $this->client->channels()->getVariable($this->id, $variable, $default); |
|
|
|
|
|
|
683
|
|
|
} |
|
684
|
|
|
|
|
685
|
|
|
/** |
|
686
|
|
|
* Set the value of a channel variable or function. |
|
687
|
|
|
* |
|
688
|
|
|
* @param string $variable |
|
689
|
38 |
|
* @param string $value |
|
690
|
|
|
* @return Variable |
|
691
|
38 |
|
* @throws InvalidParameterException |
|
692
|
|
|
* @throws NotFoundException |
|
693
|
38 |
|
* @throws ConflictException |
|
694
|
38 |
|
*/ |
|
695
|
38 |
|
public function setVariable($variable, $value) |
|
696
|
38 |
|
{ |
|
697
|
38 |
|
return $this->client->channels()->setVariable($this->id, $variable, $value); |
|
|
|
|
|
|
698
|
38 |
|
} |
|
699
|
38 |
|
|
|
700
|
38 |
|
/** |
|
701
|
38 |
|
* Start snooping. Snoop (spy/whisper) on a specific channel. |
|
702
|
|
|
* |
|
703
|
|
|
* @param string $spy (default none) Direction of audio to spy on |
|
704
|
|
|
* @param string $whisper (default none) Direction of audio to whisper into |
|
705
|
|
|
* @param string $app (required) Application the snooping channel is placed into |
|
706
|
|
|
* @param string $appArgs The application arguments to pass to the Stasis application |
|
707
|
|
|
* @param string $snoopId Unique ID to assign to snooping channel |
|
708
|
|
|
* @return Channel |
|
709
|
|
|
* @throws InvalidParameterException |
|
710
|
|
|
* @throws NotFoundException |
|
711
|
|
|
*/ |
|
712
|
|
|
public function startSnoop($spy, $whisper, $app, $appArgs, $snoopId) |
|
713
|
|
|
{ |
|
714
|
|
|
return $this->client->channels()->startSnoop($this->id, $spy, $whisper, $app, $appArgs, $snoopId); |
|
715
|
|
|
} |
|
716
|
|
|
|
|
717
|
|
|
/** |
|
718
|
|
|
* Start snooping. Snoop (spy/whisper) on a specific channel. |
|
719
|
|
|
* |
|
720
|
|
|
* @param string $spy (default none) Direction of audio to spy on |
|
721
|
|
|
* @param string $whisper (default none) Direction of audio to whisper into |
|
722
|
|
|
* @param string $app (required) Application the snooping channel is placed into |
|
723
|
|
|
* @param string $appArgs The application arguments to pass to the Stasis application |
|
724
|
|
|
* @param string $snoopId Unique ID to assign to snooping channel |
|
725
|
|
|
* @return Channel |
|
726
|
|
|
* @throws InvalidParameterException |
|
727
|
|
|
* @throws NotFoundException |
|
728
|
|
|
*/ |
|
729
|
|
|
public function startSnoopWithId($spy, $whisper, $app, $appArgs, $snoopId) |
|
730
|
|
|
{ |
|
731
|
|
|
return $this->client->channels()->startSnoopWithId($this->id, $spy, $whisper, $app, $appArgs, $snoopId); |
|
732
|
|
|
} |
|
733
|
|
|
|
|
734
|
|
|
/** |
|
735
|
|
|
* @param AriClient $client |
|
736
|
|
|
* @param string $response |
|
737
|
|
|
*/ |
|
738
|
|
|
public function __construct(AriClient $client, $response) |
|
739
|
|
|
{ |
|
740
|
|
|
parent::__construct($client, $response); |
|
741
|
|
|
|
|
742
|
|
|
$this->accountCode = $this->getResponseValue('accountcode'); |
|
743
|
|
|
$this->caller = $this->getResponseValue('caller', '\phparia\Resources\CallerId'); |
|
744
|
|
|
$this->connected = $this->getResponseValue('connected', '\phparia\Resources\CallerId'); |
|
745
|
|
|
$this->creationTime = $this->getResponseValue('creationtime', '\DateTime'); |
|
746
|
|
|
$this->dialplan = $this->getResponseValue('dialplan', '\phparia\Resources\DialplanCep'); |
|
747
|
|
|
$this->id = $this->getResponseValue('id'); |
|
748
|
|
|
$this->name = $this->getResponseValue('name'); |
|
749
|
|
|
$this->state = $this->getResponseValue('state'); |
|
750
|
|
|
} |
|
751
|
|
|
|
|
752
|
|
|
} |
|
753
|
|
|
|
This method has been deprecated.