Asterisk - The Open Source Telephony Project GIT-master-f36a736
Data Structures | Functions
resource_recordings.h File Reference

Generated file - declares stubs to be implemented in res/ari/resource_recordings.c. More...

#include "asterisk/ari.h"
Include dependency graph for resource_recordings.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_ari_recordings_cancel_args
 
struct  ast_ari_recordings_copy_stored_args
 
struct  ast_ari_recordings_delete_stored_args
 
struct  ast_ari_recordings_get_live_args
 
struct  ast_ari_recordings_get_stored_args
 
struct  ast_ari_recordings_get_stored_file_args
 
struct  ast_ari_recordings_list_stored_args
 
struct  ast_ari_recordings_mute_args
 
struct  ast_ari_recordings_pause_args
 
struct  ast_ari_recordings_stop_args
 
struct  ast_ari_recordings_unmute_args
 
struct  ast_ari_recordings_unpause_args
 

Functions

void ast_ari_recordings_cancel (struct ast_variable *headers, struct ast_ari_recordings_cancel_args *args, struct ast_ari_response *response)
 Stop a live recording and discard it. More...
 
void ast_ari_recordings_copy_stored (struct ast_variable *headers, struct ast_ari_recordings_copy_stored_args *args, struct ast_ari_response *response)
 Copy a stored recording. More...
 
int ast_ari_recordings_copy_stored_parse_body (struct ast_json *body, struct ast_ari_recordings_copy_stored_args *args)
 Body parsing function for /recordings/stored/{recordingName}/copy. More...
 
void ast_ari_recordings_delete_stored (struct ast_variable *headers, struct ast_ari_recordings_delete_stored_args *args, struct ast_ari_response *response)
 Delete a stored recording. More...
 
void ast_ari_recordings_get_live (struct ast_variable *headers, struct ast_ari_recordings_get_live_args *args, struct ast_ari_response *response)
 List live recordings. More...
 
void ast_ari_recordings_get_stored (struct ast_variable *headers, struct ast_ari_recordings_get_stored_args *args, struct ast_ari_response *response)
 Get a stored recording's details. More...
 
void ast_ari_recordings_get_stored_file (struct ast_tcptls_session_instance *ser, struct ast_variable *headers, struct ast_ari_recordings_get_stored_file_args *args, struct ast_ari_response *response)
 Get the file associated with the stored recording. More...
 
void ast_ari_recordings_list_stored (struct ast_variable *headers, struct ast_ari_recordings_list_stored_args *args, struct ast_ari_response *response)
 List recordings that are complete. More...
 
void ast_ari_recordings_mute (struct ast_variable *headers, struct ast_ari_recordings_mute_args *args, struct ast_ari_response *response)
 Mute a live recording. More...
 
void ast_ari_recordings_pause (struct ast_variable *headers, struct ast_ari_recordings_pause_args *args, struct ast_ari_response *response)
 Pause a live recording. More...
 
void ast_ari_recordings_stop (struct ast_variable *headers, struct ast_ari_recordings_stop_args *args, struct ast_ari_response *response)
 Stop a live recording and store it. More...
 
void ast_ari_recordings_unmute (struct ast_variable *headers, struct ast_ari_recordings_unmute_args *args, struct ast_ari_response *response)
 Unmute a live recording. More...
 
void ast_ari_recordings_unpause (struct ast_variable *headers, struct ast_ari_recordings_unpause_args *args, struct ast_ari_response *response)
 Unpause a live recording. More...
 

Detailed Description

Generated file - declares stubs to be implemented in res/ari/resource_recordings.c.

Recording resources

Author
David M. Lee, II dlee@.nosp@m.digi.nosp@m.um.co.nosp@m.m

Definition in file resource_recordings.h.

Function Documentation

◆ ast_ari_recordings_cancel()

void ast_ari_recordings_cancel ( struct ast_variable headers,
struct ast_ari_recordings_cancel_args args,
struct ast_ari_response response 
)

Stop a live recording and discard it.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 313 of file resource_recordings.c.

316{
318 response);
319}
static void control_recording(const char *name, enum stasis_app_recording_media_operation operation, struct ast_ari_response *response)
@ STASIS_APP_RECORDING_CANCEL
const char * args

References args, control_recording(), and STASIS_APP_RECORDING_CANCEL.

Referenced by ast_ari_recordings_cancel_cb().

◆ ast_ari_recordings_copy_stored()

void ast_ari_recordings_copy_stored ( struct ast_variable headers,
struct ast_ari_recordings_copy_stored_args args,
struct ast_ari_response response 
)

Copy a stored recording.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 145 of file resource_recordings.c.

148{
149 RAII_VAR(struct stasis_app_stored_recording *, src_recording, NULL,
151 RAII_VAR(struct stasis_app_stored_recording *, dst_recording, NULL,
153 struct ast_json *json;
154 int res;
155
157 args->recording_name);
158 if (src_recording == NULL) {
159 ast_ari_response_error(response, 404, "Not Found",
160 "Recording not found");
161 return;
162 }
163
165 args->destination_recording_name);
166 if (dst_recording) {
167 ast_ari_response_error(response, 409, "Conflict",
168 "A recording with the same name already exists on the system");
169 return;
170 }
171
172 /* See if we got our name rejected */
173 switch (errno) {
174 case EINVAL:
175 ast_ari_response_error(response, 400, "Bad request",
176 "Invalid destination recording name");
177 return;
178 case EACCES:
179 ast_ari_response_error(response, 403, "Forbidden",
180 "Destination file path is forbidden");
181 return;
182 default:
183 break;
184 }
185
186 res = stasis_app_stored_recording_copy(src_recording,
187 args->destination_recording_name, &dst_recording);
188 if (res) {
189 switch (errno) {
190 case EACCES:
191 case EPERM:
192 ast_ari_response_error(response, 500,
193 "Internal Server Error",
194 "Copy failed");
195 break;
196 default:
198 "Unexpected error copying recording %s to %s: %s\n",
199 args->recording_name, args->destination_recording_name, strerror(errno));
200 ast_ari_response_error(response, 500,
201 "Internal Server Error",
202 "Copy failed");
203 break;
204 }
205 return;
206 }
207
208 json = stasis_app_stored_recording_to_json(dst_recording);
209 if (json == NULL) {
210 ast_ari_response_error(response, 500,
211 "Internal Server Error", "Error building response");
212 return;
213 }
214
215 ast_ari_response_ok(response, json);
216}
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
Definition: res_ari.c:259
void ast_ari_response_ok(struct ast_ari_response *response, struct ast_json *message)
Fill in an OK (200) ast_ari_response.
Definition: res_ari.c:276
#define ast_log
Definition: astobj2.c:42
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
#define LOG_WARNING
int errno
#define NULL
Definition: resample.c:96
struct ast_json * stasis_app_stored_recording_to_json(struct stasis_app_stored_recording *recording)
Convert stored recording info to JSON.
Definition: stored.c:455
struct stasis_app_stored_recording * stasis_app_stored_recording_find_by_name(const char *name)
Creates a stored recording object, with the given name.
Definition: stored.c:318
int stasis_app_stored_recording_copy(struct stasis_app_stored_recording *src_recording, const char *dst, struct stasis_app_stored_recording **dst_recording)
Copy a recording.
Definition: stored.c:398
Abstract JSON element (object, array, string, int, ...).
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941

References ao2_cleanup, args, ast_ari_response_error(), ast_ari_response_ok(), ast_log, errno, LOG_WARNING, NULL, RAII_VAR, stasis_app_stored_recording_copy(), stasis_app_stored_recording_find_by_name(), and stasis_app_stored_recording_to_json().

Referenced by ast_ari_recordings_copy_stored_cb().

◆ ast_ari_recordings_copy_stored_parse_body()

int ast_ari_recordings_copy_stored_parse_body ( struct ast_json body,
struct ast_ari_recordings_copy_stored_args args 
)

Body parsing function for /recordings/stored/{recordingName}/copy.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 287 of file res_ari_recordings.c.

290{
291 struct ast_json *field;
292 /* Parse query parameters out of it */
293 field = ast_json_object_get(body, "destinationRecordingName");
294 if (field) {
295 args->destination_recording_name = ast_json_string_get(field);
296 }
297 return 0;
298}
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:283
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:407

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_recordings_copy_stored_cb().

◆ ast_ari_recordings_delete_stored()

void ast_ari_recordings_delete_stored ( struct ast_variable headers,
struct ast_ari_recordings_delete_stored_args args,
struct ast_ari_response response 
)

Delete a stored recording.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 218 of file resource_recordings.c.

221{
222 RAII_VAR(struct stasis_app_stored_recording *, recording, NULL,
224 int res;
225
227 args->recording_name);
228 if (recording == NULL) {
229 ast_ari_response_error(response, 404, "Not Found",
230 "Recording not found");
231 return;
232 }
233
234 res = stasis_app_stored_recording_delete(recording);
235
236 if (res != 0) {
237 switch (errno) {
238 case EACCES:
239 case EPERM:
240 ast_ari_response_error(response, 500,
241 "Internal Server Error",
242 "Delete failed");
243 break;
244 default:
246 "Unexpected error deleting recording %s: %s\n",
247 args->recording_name, strerror(errno));
248 ast_ari_response_error(response, 500,
249 "Internal Server Error",
250 "Delete failed");
251 break;
252 }
253 return;
254 }
255
257}
void ast_ari_response_no_content(struct ast_ari_response *response)
Fill in a No Content (204) ast_ari_response.
Definition: res_ari.c:284
int stasis_app_stored_recording_delete(struct stasis_app_stored_recording *recording)
Delete a recording from disk.
Definition: stored.c:448

References ao2_cleanup, args, ast_ari_response_error(), ast_ari_response_no_content(), ast_log, errno, LOG_WARNING, NULL, RAII_VAR, stasis_app_stored_recording_delete(), and stasis_app_stored_recording_find_by_name().

Referenced by ast_ari_recordings_delete_stored_cb().

◆ ast_ari_recordings_get_live()

void ast_ari_recordings_get_live ( struct ast_variable headers,
struct ast_ari_recordings_get_live_args args,
struct ast_ari_response response 
)

List live recordings.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 259 of file resource_recordings.c.

262{
263 RAII_VAR(struct stasis_app_recording *, recording, NULL, ao2_cleanup);
264 struct ast_json *json;
265
266 recording = stasis_app_recording_find_by_name(args->recording_name);
267 if (recording == NULL) {
268 ast_ari_response_error(response, 404, "Not Found",
269 "Recording not found");
270 return;
271 }
272
273 json = stasis_app_recording_to_json(recording);
274 if (json == NULL) {
275 ast_ari_response_error(response, 500,
276 "Internal Server Error", "Error building response");
277 return;
278 }
279
280 ast_ari_response_ok(response, json);
281}
struct ast_json * stasis_app_recording_to_json(const struct stasis_app_recording *recording)
Construct a JSON model of a recording.
struct stasis_app_recording * stasis_app_recording_find_by_name(const char *name)
Finds the recording object with the given name.

References ao2_cleanup, args, ast_ari_response_error(), ast_ari_response_ok(), NULL, RAII_VAR, stasis_app_recording_find_by_name(), and stasis_app_recording_to_json().

Referenced by ast_ari_recordings_get_live_cb().

◆ ast_ari_recordings_get_stored()

void ast_ari_recordings_get_stored ( struct ast_variable headers,
struct ast_ari_recordings_get_stored_args args,
struct ast_ari_response response 
)

Get a stored recording's details.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 75 of file resource_recordings.c.

78{
79 RAII_VAR(struct stasis_app_stored_recording *, recording, NULL,
81 struct ast_json *json;
82
84 args->recording_name);
85 if (recording == NULL) {
86 ast_ari_response_error(response, 404, "Not Found",
87 "Recording not found");
88 return;
89 }
90
92 if (json == NULL) {
93 ast_ari_response_error(response, 500,
94 "Internal Server Error", "Error building response");
95 return;
96 }
97
98 ast_ari_response_ok(response, json);
99}

References ao2_cleanup, args, ast_ari_response_error(), ast_ari_response_ok(), NULL, RAII_VAR, stasis_app_stored_recording_find_by_name(), and stasis_app_stored_recording_to_json().

Referenced by ast_ari_recordings_get_stored_cb().

◆ ast_ari_recordings_get_stored_file()

void ast_ari_recordings_get_stored_file ( struct ast_tcptls_session_instance ser,
struct ast_variable headers,
struct ast_ari_recordings_get_stored_file_args args,
struct ast_ari_response response 
)

Get the file associated with the stored recording.

Parameters
serTCP/TLS session instance
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 101 of file resource_recordings.c.

104{
105 RAII_VAR(struct stasis_app_stored_recording *, recording,
108 static const char *format_type_names[AST_MEDIA_TYPE_TEXT + 1] = {
109 [AST_MEDIA_TYPE_UNKNOWN] = "binary",
110 [AST_MEDIA_TYPE_AUDIO] = "audio",
111 [AST_MEDIA_TYPE_VIDEO] = "video",
112 [AST_MEDIA_TYPE_IMAGE] = "image",
113 [AST_MEDIA_TYPE_TEXT] = "text",
114 };
115 struct ast_format *format;
116
117 response->message = ast_json_null();
118
119 if (!recording) {
120 ast_ari_response_error(response, 404, "Not Found",
121 "Recording not found");
122 return;
123 }
124
126 if (!format) {
127 ast_ari_response_error(response, 500, "Internal Server Error",
128 "Format specified by recording not available or loaded");
129 return;
130 }
131
132 response->fd = open(stasis_app_stored_recording_get_filename(recording), O_RDONLY);
133 if (response->fd < 0) {
134 ast_ari_response_error(response, 403, "Forbidden",
135 "Recording could not be opened");
136 return;
137 }
138
139 ast_str_append(&response->headers, 0, "Content-Type: %s/%s\r\n",
140 format_type_names[ast_format_get_type(format)],
143}
@ AST_MEDIA_TYPE_AUDIO
Definition: codec.h:32
@ AST_MEDIA_TYPE_UNKNOWN
Definition: codec.h:31
@ AST_MEDIA_TYPE_VIDEO
Definition: codec.h:33
@ AST_MEDIA_TYPE_IMAGE
Definition: codec.h:34
@ AST_MEDIA_TYPE_TEXT
Definition: codec.h:35
struct ast_format * ast_get_format_for_file_ext(const char *file_ext)
Get the ast_format associated with the given file extension.
Definition: file.c:2006
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition: format.c:354
struct ast_json * ast_json_null(void)
Get the JSON null value.
Definition: json.c:248
const char * stasis_app_stored_recording_get_filename(struct stasis_app_stored_recording *recording)
Returns the full filename, with extension, for this recording.
Definition: stored.c:62
const char * stasis_app_stored_recording_get_extension(struct stasis_app_stored_recording *recording)
Returns the extension for this recording.
Definition: stored.c:71
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1139
struct ast_str * headers
Definition: ari.h:96
struct ast_json * message
Definition: ari.h:94
Definition of a media format.
Definition: format.c:43

References ao2_cleanup, args, ast_ari_response_error(), ast_ari_response_ok(), ast_format_get_type(), ast_get_format_for_file_ext(), ast_json_null(), AST_MEDIA_TYPE_AUDIO, AST_MEDIA_TYPE_IMAGE, AST_MEDIA_TYPE_TEXT, AST_MEDIA_TYPE_UNKNOWN, AST_MEDIA_TYPE_VIDEO, ast_str_append(), ast_ari_response::fd, ast_ari_response::headers, ast_ari_response::message, RAII_VAR, stasis_app_stored_recording_find_by_name(), stasis_app_stored_recording_get_extension(), and stasis_app_stored_recording_get_filename().

Referenced by ast_ari_recordings_get_stored_file_cb().

◆ ast_ari_recordings_list_stored()

void ast_ari_recordings_list_stored ( struct ast_variable headers,
struct ast_ari_recordings_list_stored_args args,
struct ast_ari_response response 
)

List recordings that are complete.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 35 of file resource_recordings.c.

38{
40 RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
41 struct ao2_iterator i;
42 void *obj;
43
45
46 if (!recordings) {
48 return;
49 }
50
51 json = ast_json_array_create();
52 if (!json) {
54 return;
55 }
56
58 while ((obj = ao2_iterator_next(&i))) {
59 RAII_VAR(struct stasis_app_stored_recording *, recording, obj,
61
64 if (r != 0) {
67 return;
68 }
69 }
71
72 ast_ari_response_ok(response, ast_json_ref(json));
73}
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
Definition: res_ari.c:298
#define ao2_iterator_next(iter)
Definition: astobj2.h:1911
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
int ast_json_array_append(struct ast_json *array, struct ast_json *value)
Append to an array.
Definition: json.c:378
struct ast_json * ast_json_array_create(void)
Create a empty JSON array.
Definition: json.c:362
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Definition: json.c:67
static struct stasis_rest_handlers recordings
REST handler for /api-docs/recordings.json.
struct ao2_container * stasis_app_stored_recording_find_all(void)
Find all stored recordings on disk.
Definition: stored.c:297
Generic container type.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1821

References ao2_cleanup, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ast_ari_response_alloc_failed(), ast_ari_response_ok(), ast_json_array_append(), ast_json_array_create(), ast_json_ref(), ast_json_unref(), NULL, RAII_VAR, recordings, stasis_app_stored_recording_find_all(), and stasis_app_stored_recording_to_json().

Referenced by ast_ari_recordings_list_stored_cb().

◆ ast_ari_recordings_mute()

void ast_ari_recordings_mute ( struct ast_variable headers,
struct ast_ari_recordings_mute_args args,
struct ast_ari_response response 
)

Mute a live recording.

Muting a recording suspends silence detection, which will be restarted when the recording is unmuted.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 345 of file resource_recordings.c.

348{
350 response);
351}
@ STASIS_APP_RECORDING_MUTE

References args, control_recording(), and STASIS_APP_RECORDING_MUTE.

Referenced by ast_ari_recordings_mute_cb().

◆ ast_ari_recordings_pause()

void ast_ari_recordings_pause ( struct ast_variable headers,
struct ast_ari_recordings_pause_args args,
struct ast_ari_response response 
)

Pause a live recording.

Pausing a recording suspends silence detection, which will be restarted when the recording is unpaused. Paused time is not included in the accounting for maxDurationSeconds.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 329 of file resource_recordings.c.

332{
334 response);
335}
@ STASIS_APP_RECORDING_PAUSE

References args, control_recording(), and STASIS_APP_RECORDING_PAUSE.

Referenced by ast_ari_recordings_pause_cb().

◆ ast_ari_recordings_stop()

void ast_ari_recordings_stop ( struct ast_variable headers,
struct ast_ari_recordings_stop_args args,
struct ast_ari_response response 
)

Stop a live recording and store it.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 321 of file resource_recordings.c.

324{
326 response);
327}
@ STASIS_APP_RECORDING_STOP

References args, control_recording(), and STASIS_APP_RECORDING_STOP.

Referenced by ast_ari_recordings_stop_cb().

◆ ast_ari_recordings_unmute()

void ast_ari_recordings_unmute ( struct ast_variable headers,
struct ast_ari_recordings_unmute_args args,
struct ast_ari_response response 
)

Unmute a live recording.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 353 of file resource_recordings.c.

356{
358 response);
359}
@ STASIS_APP_RECORDING_UNMUTE

References args, control_recording(), and STASIS_APP_RECORDING_UNMUTE.

Referenced by ast_ari_recordings_unmute_cb().

◆ ast_ari_recordings_unpause()

void ast_ari_recordings_unpause ( struct ast_variable headers,
struct ast_ari_recordings_unpause_args args,
struct ast_ari_response response 
)

Unpause a live recording.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 337 of file resource_recordings.c.

340{
342 response);
343}
@ STASIS_APP_RECORDING_UNPAUSE

References args, control_recording(), and STASIS_APP_RECORDING_UNPAUSE.

Referenced by ast_ari_recordings_unpause_cb().