summaryrefslogtreecommitdiff
path: root/res/ari
diff options
context:
space:
mode:
authorDavid M. Lee <dlee@digium.com>2013-08-06 14:44:45 +0000
committerDavid M. Lee <dlee@digium.com>2013-08-06 14:44:45 +0000
commitc79084879427750dc848834a8390bb0c8468f24b (patch)
tree2e6c4371cda2c73172642b267aa54dea469d600d /res/ari
parentb97d318b7bc31b47fbd4b74421e351095f05139d (diff)
ARI: Add recording controls
This patch implements the controls from ARI recordings. The controls are: * DELETE /recordings/live/{recordingName} - stop recording and discard it * POST /recordings/live/{recordingName}/stop - stop recording * POST /recordings/live/{recordingName}/pause - pause recording * POST /recordings/live/{recordingName}/unpause - resume recording * POST /recordings/live/{recordingName}/mute - mute recording (record silence to the file) * POST /recordings/live/{recordingName}/unmute - unmute recording. Since this underlying functionality did not already exist, is was added to app.c by a set of control frames, similar to how playback control works. The pause/mute control frames are toggles, even though the ARI controls are idempotent, to be consistent with the playback control frames. (closes issue ASTERISK-22181) Review: https://reviewboard.asterisk.org/r/2697/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396331 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/ari')
-rw-r--r--res/ari/resource_recordings.c78
-rw-r--r--res/ari/resource_recordings.h2
2 files changed, 67 insertions, 13 deletions
diff --git a/res/ari/resource_recordings.c b/res/ari/resource_recordings.c
index 46439ff0b..f87ff0a0a 100644
--- a/res/ari/resource_recordings.c
+++ b/res/ari/resource_recordings.c
@@ -71,27 +71,81 @@ void ast_ari_get_live_recording(struct ast_variable *headers,
ast_ari_response_ok(response, ast_json_ref(json));
}
-void ast_ari_cancel_recording(struct ast_variable *headers, struct ast_cancel_recording_args *args, struct ast_ari_response *response)
+static void control_recording(const char *name,
+ enum stasis_app_recording_media_operation operation,
+ struct ast_ari_response *response)
{
- ast_log(LOG_ERROR, "TODO: ast_ari_cancel_recording\n");
+ RAII_VAR(struct stasis_app_recording *, recording, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+ enum stasis_app_recording_oper_results res;
+
+ recording = stasis_app_recording_find_by_name(name);
+ if (recording == NULL) {
+ ast_ari_response_error(response, 404, "Not Found",
+ "Recording not found");
+ return;
+ }
+
+ res = stasis_app_recording_operation(recording, operation);
+
+ switch (res) {
+ case STASIS_APP_RECORDING_OPER_OK:
+ ast_ari_response_no_content(response);
+ return;
+ case STASIS_APP_RECORDING_OPER_FAILED:
+ ast_ari_response_error(response, 500,
+ "Internal Server Error", "Recording operation failed");
+ return;
+ case STASIS_APP_RECORDING_OPER_NOT_RECORDING:
+ ast_ari_response_error(response, 409,
+ "Conflict", "Recording not in session");
+ }
}
-void ast_ari_stop_recording(struct ast_variable *headers, struct ast_stop_recording_args *args, struct ast_ari_response *response)
+
+void ast_ari_cancel_recording(struct ast_variable *headers,
+ struct ast_cancel_recording_args *args,
+ struct ast_ari_response *response)
{
- ast_log(LOG_ERROR, "TODO: ast_ari_stop_recording\n");
+ control_recording(args->recording_name, STASIS_APP_RECORDING_CANCEL,
+ response);
}
-void ast_ari_pause_recording(struct ast_variable *headers, struct ast_pause_recording_args *args, struct ast_ari_response *response)
+
+void ast_ari_stop_recording(struct ast_variable *headers,
+ struct ast_stop_recording_args *args,
+ struct ast_ari_response *response)
+{
+ control_recording(args->recording_name, STASIS_APP_RECORDING_STOP,
+ response);
+}
+
+void ast_ari_pause_recording(struct ast_variable *headers,
+ struct ast_pause_recording_args *args,
+ struct ast_ari_response *response)
{
- ast_log(LOG_ERROR, "TODO: ast_ari_pause_recording\n");
+ control_recording(args->recording_name, STASIS_APP_RECORDING_PAUSE,
+ response);
}
-void ast_ari_unpause_recording(struct ast_variable *headers, struct ast_unpause_recording_args *args, struct ast_ari_response *response)
+
+void ast_ari_unpause_recording(struct ast_variable *headers,
+ struct ast_unpause_recording_args *args,
+ struct ast_ari_response *response)
{
- ast_log(LOG_ERROR, "TODO: ast_ari_unpause_recording\n");
+ control_recording(args->recording_name, STASIS_APP_RECORDING_UNPAUSE,
+ response);
}
-void ast_ari_mute_recording(struct ast_variable *headers, struct ast_mute_recording_args *args, struct ast_ari_response *response)
+
+void ast_ari_mute_recording(struct ast_variable *headers,
+ struct ast_mute_recording_args *args,
+ struct ast_ari_response *response)
{
- ast_log(LOG_ERROR, "TODO: ast_ari_mute_recording\n");
+ control_recording(args->recording_name, STASIS_APP_RECORDING_MUTE,
+ response);
}
-void ast_ari_unmute_recording(struct ast_variable *headers, struct ast_unmute_recording_args *args, struct ast_ari_response *response)
+
+void ast_ari_unmute_recording(struct ast_variable *headers,
+ struct ast_unmute_recording_args *args,
+ struct ast_ari_response *response)
{
- ast_log(LOG_ERROR, "TODO: ast_ari_unmute_recording\n");
+ control_recording(args->recording_name, STASIS_APP_RECORDING_UNMUTE,
+ response);
}
diff --git a/res/ari/resource_recordings.h b/res/ari/resource_recordings.h
index e3ee88be8..2529766e7 100644
--- a/res/ari/resource_recordings.h
+++ b/res/ari/resource_recordings.h
@@ -134,7 +134,7 @@ struct ast_pause_recording_args {
/*!
* \brief Pause a live recording.
*
- * Pausing a recording suspends silence detection, which will be restarted when the recording is unpaused.
+ * 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.
*
* \param headers HTTP headers
* \param args Swagger parameters