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
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* A recording that is in progress |
26
|
|
|
* |
27
|
|
|
* @author Brian Smith <[email protected]> |
28
|
|
|
*/ |
29
|
|
|
class LiveRecording extends Resource |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @var string (optional) - Cause for recording failure if failed |
33
|
|
|
*/ |
34
|
|
|
private $cause; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var int (optional) - Duration in seconds of the recording |
38
|
|
|
*/ |
39
|
|
|
private $duration; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string Recording format (wav, gsm, etc.) |
43
|
|
|
*/ |
44
|
|
|
private $format; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string Base name for the recording |
48
|
|
|
*/ |
49
|
|
|
private $name; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var int (optional) - Duration of silence, in seconds, detected in the recording. This is only available if the recording was initiated with a non-zero maxSilenceSeconds. |
53
|
|
|
*/ |
54
|
|
|
private $silenceDuration; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var string |
58
|
|
|
*/ |
59
|
|
|
private $state; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var int (optional) - Duration of talking, in seconds, detected in the recording. This is only available if the recording was initiated with a non-zero maxSilenceSeconds. |
63
|
|
|
*/ |
64
|
|
|
private $talkingDuration; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @var string URI for the channel or bridge being recorded |
68
|
|
|
*/ |
69
|
|
|
private $targetUri; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return string (optional) - Cause for recording failure if failed |
73
|
|
|
*/ |
74
|
|
|
public function getCause() |
75
|
|
|
{ |
76
|
|
|
return $this->cause; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return int (optional) - Duration in seconds of the recording |
81
|
|
|
*/ |
82
|
|
|
public function getDuration() |
83
|
|
|
{ |
84
|
|
|
return $this->duration; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return string Recording format (wav, gsm, etc.) |
89
|
|
|
*/ |
90
|
|
|
public function getFormat() |
91
|
|
|
{ |
92
|
|
|
return $this->format; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return string Base name for the recording |
97
|
|
|
*/ |
98
|
1 |
|
public function getName() |
99
|
|
|
{ |
100
|
1 |
|
return $this->name; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return int (optional) - Duration of silence, in seconds, detected in the recording. This is only available if the recording was initiated with a non-zero maxSilenceSeconds. |
105
|
|
|
*/ |
106
|
|
|
public function getSilenceDuration() |
107
|
|
|
{ |
108
|
|
|
return $this->silenceDuration; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return string |
113
|
|
|
*/ |
114
|
|
|
public function getState() |
115
|
|
|
{ |
116
|
|
|
return $this->state; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return int (optional) - Duration of talking, in seconds, detected in the recording. This is only available if the recording was initiated with a non-zero maxSilenceSeconds. |
121
|
|
|
*/ |
122
|
|
|
public function getTalkingDuration() |
123
|
|
|
{ |
124
|
|
|
return $this->talkingDuration; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @return string URI for the channel or bridge being recorded |
129
|
|
|
*/ |
130
|
|
|
public function getTargetUri() |
131
|
|
|
{ |
132
|
|
|
return $this->targetUri; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @param callable $callback |
137
|
|
|
*/ |
138
|
|
|
public function onRecordingFailed(callable $callback) |
139
|
|
|
{ |
140
|
|
|
$this->on(Event::RECORDING_FAILED.'_'.$this->getName(), $callback); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @param callable $callback |
145
|
|
|
*/ |
146
|
|
|
public function onceRecordingFailed(callable $callback) |
147
|
|
|
{ |
148
|
|
|
$this->once(Event::RECORDING_FAILED.'_'.$this->getName(), $callback); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @param callable $callback |
153
|
|
|
*/ |
154
|
|
|
public function onRecordingFinished(callable $callback) |
155
|
|
|
{ |
156
|
|
|
$this->on(Event::RECORDING_FINISHED.'_'.$this->getName(), $callback); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @param callable $callback |
161
|
|
|
*/ |
162
|
|
|
public function onceRecordingFinished(callable $callback) |
163
|
|
|
{ |
164
|
|
|
$this->once(Event::RECORDING_FINISHED.'_'.$this->getName(), $callback); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @param callable $callback |
169
|
|
|
*/ |
170
|
|
|
public function onRecordingStarted(callable $callback) |
171
|
|
|
{ |
172
|
|
|
$this->on(Event::RECORDING_STARTED.'_'.$this->getName(), $callback); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @param callable $callback |
177
|
|
|
*/ |
178
|
|
|
public function onceRecordingStarted(callable $callback) |
179
|
|
|
{ |
180
|
|
|
$this->once(Event::RECORDING_STARTED.'_'.$this->getName(), $callback); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @param AriClient $client |
185
|
|
|
* @param string $response |
186
|
|
|
*/ |
187
|
1 |
|
public function __construct(AriClient $client, $response) |
188
|
|
|
{ |
189
|
1 |
|
parent::__construct($client, $response); |
190
|
|
|
|
191
|
1 |
|
$this->cause = $this->getResponseValue('cause'); |
192
|
1 |
|
$this->duration = $this->getResponseValue('duration'); |
193
|
1 |
|
$this->format = $this->getResponseValue('format'); |
194
|
1 |
|
$this->name = $this->getResponseValue('name'); |
195
|
1 |
|
$this->silenceDuration = $this->getResponseValue('silence_duration'); |
196
|
1 |
|
$this->state = $this->getResponseValue('state'); |
197
|
1 |
|
$this->talkingDuration = $this->getResponseValue('talking_duration'); |
198
|
1 |
|
$this->targetUri = $this->getResponseValue('target_uri'); |
199
|
1 |
|
} |
200
|
|
|
|
201
|
|
|
} |
202
|
|
|
|