return ast_ari_validate_playback_started;
}
+int ast_ari_validate_recording_failed(struct ast_json *json)
+{
+ int res = 1;
+ struct ast_json_iter *iter;
+ int has_cause = 0;
+ int has_recording = 0;
+
+ for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+ if (strcmp("cause", ast_json_object_iter_key(iter)) == 0) {
+ int prop_is_valid;
+ has_cause = 1;
+ prop_is_valid = ast_ari_validate_string(
+ ast_json_object_iter_value(iter));
+ if (!prop_is_valid) {
+ ast_log(LOG_ERROR, "ARI RecordingFailed field cause failed validation\n");
+ res = 0;
+ }
+ } else
+ if (strcmp("recording", ast_json_object_iter_key(iter)) == 0) {
+ int prop_is_valid;
+ has_recording = 1;
+ prop_is_valid = ast_ari_validate_live_recording(
+ ast_json_object_iter_value(iter));
+ if (!prop_is_valid) {
+ ast_log(LOG_ERROR, "ARI RecordingFailed field recording failed validation\n");
+ res = 0;
+ }
+ } else
+ {
+ ast_log(LOG_ERROR,
+ "ARI RecordingFailed has undocumented field %s\n",
+ ast_json_object_iter_key(iter));
+ res = 0;
+ }
+ }
+
+ if (!has_cause) {
+ ast_log(LOG_ERROR, "ARI RecordingFailed missing required field cause\n");
+ res = 0;
+ }
+
+ if (!has_recording) {
+ ast_log(LOG_ERROR, "ARI RecordingFailed missing required field recording\n");
+ res = 0;
+ }
+
+ return res;
+}
+
+ari_validator ast_ari_validate_recording_failed_fn(void)
+{
+ return ast_ari_validate_recording_failed;
+}
+
+int ast_ari_validate_recording_finished(struct ast_json *json)
+{
+ int res = 1;
+ struct ast_json_iter *iter;
+ int has_recording = 0;
+
+ for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+ if (strcmp("recording", ast_json_object_iter_key(iter)) == 0) {
+ int prop_is_valid;
+ has_recording = 1;
+ prop_is_valid = ast_ari_validate_live_recording(
+ ast_json_object_iter_value(iter));
+ if (!prop_is_valid) {
+ ast_log(LOG_ERROR, "ARI RecordingFinished field recording failed validation\n");
+ res = 0;
+ }
+ } else
+ {
+ ast_log(LOG_ERROR,
+ "ARI RecordingFinished has undocumented field %s\n",
+ ast_json_object_iter_key(iter));
+ res = 0;
+ }
+ }
+
+ if (!has_recording) {
+ ast_log(LOG_ERROR, "ARI RecordingFinished missing required field recording\n");
+ res = 0;
+ }
+
+ return res;
+}
+
+ari_validator ast_ari_validate_recording_finished_fn(void)
+{
+ return ast_ari_validate_recording_finished;
+}
+
+int ast_ari_validate_recording_started(struct ast_json *json)
+{
+ int res = 1;
+ struct ast_json_iter *iter;
+ int has_recording = 0;
+
+ for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+ if (strcmp("recording", ast_json_object_iter_key(iter)) == 0) {
+ int prop_is_valid;
+ has_recording = 1;
+ prop_is_valid = ast_ari_validate_live_recording(
+ ast_json_object_iter_value(iter));
+ if (!prop_is_valid) {
+ ast_log(LOG_ERROR, "ARI RecordingStarted field recording failed validation\n");
+ res = 0;
+ }
+ } else
+ {
+ ast_log(LOG_ERROR,
+ "ARI RecordingStarted has undocumented field %s\n",
+ ast_json_object_iter_key(iter));
+ res = 0;
+ }
+ }
+
+ if (!has_recording) {
+ ast_log(LOG_ERROR, "ARI RecordingStarted missing required field recording\n");
+ res = 0;
+ }
+
+ return res;
+}
+
+ari_validator ast_ari_validate_recording_started_fn(void)
+{
+ return ast_ari_validate_recording_started;
+}
+
int ast_ari_validate_stasis_end(struct ast_json *json)
{
int res = 1;
*/
ari_validator ast_ari_validate_playback_started_fn(void);
+/*!
+ * \brief Validator for RecordingFailed.
+ *
+ * Event showing failure of a recording operation.
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ast_ari_validate_recording_failed(struct ast_json *json);
+
+/*!
+ * \brief Function pointer to ast_ari_validate_recording_failed().
+ *
+ * See \ref ast_ari_model_validators.h for more details.
+ */
+ari_validator ast_ari_validate_recording_failed_fn(void);
+
+/*!
+ * \brief Validator for RecordingFinished.
+ *
+ * Event showing the completion of a recording operation.
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ast_ari_validate_recording_finished(struct ast_json *json);
+
+/*!
+ * \brief Function pointer to ast_ari_validate_recording_finished().
+ *
+ * See \ref ast_ari_model_validators.h for more details.
+ */
+ari_validator ast_ari_validate_recording_finished_fn(void);
+
+/*!
+ * \brief Validator for RecordingStarted.
+ *
+ * Event showing the start of a recording operation.
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ast_ari_validate_recording_started(struct ast_json *json);
+
+/*!
+ * \brief Function pointer to ast_ari_validate_recording_started().
+ *
+ * See \ref ast_ari_model_validators.h for more details.
+ */
+ari_validator ast_ari_validate_recording_started_fn(void);
+
/*!
* \brief Validator for StasisEnd.
*
* - application: string (required)
* - timestamp: Date
* - playback: Playback (required)
+ * RecordingFailed
+ * - cause: string (required)
+ * - recording: LiveRecording (required)
+ * RecordingFinished
+ * - recording: LiveRecording (required)
+ * RecordingStarted
+ * - recording: LiveRecording (required)
* StasisEnd
* - type: string (required)
* - application: string (required)
break;
case EEXIST:
ast_ari_response_error(response, 409, "Conflict",
- "Recording '%s' already in progress",
+ "Recording '%s' already exists and can not be overwritten",
args->name);
break;
case ENOMEM:
break;
case EEXIST:
ast_ari_response_error(response, 409, "Conflict",
- "Recording '%s' already in progress",
+ "Recording '%s' already exists and can not be overwritten",
args->name);
break;
case ENOMEM:
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
- case 400: /* Recording name invalid */
+ case 400: /* Invalid parameters */
case 404: /* Bridge not found */
- case 409: /* Bridge not in Stasis application; Recording already in progress */
+ case 409: /* Bridge is not in a Stasis application; A recording with the same name already exists on the system and can not be overwritten because it is in progress or ifExists=fail */
is_valid = 1;
break;
default:
case 501: /* Not Implemented */
case 400: /* Invalid parameters */
case 404: /* Channel not found */
- case 409: /* Channel is not in a Stasis application; the channel is currently bridged with other channels; A recording with the same name is currently in progress. */
+ case 409: /* Channel is not in a Stasis application; the channel is currently bridged with other hcannels; A recording with the same name already exists on the system and can not be overwritten because it is in progress or ifExists=fail */
is_valid = 1;
break;
default:
recording->control = control;
recording->state = STASIS_APP_RECORDING_STATE_QUEUED;
+ if ((recording->options->if_exists == AST_RECORD_IF_EXISTS_FAIL) &&
+ (ast_fileexists(recording->absolute_name, NULL, NULL))) {
+ ast_log(LOG_WARNING, "Recording file '%s' already exists and ifExists option is failure.\n",
+ recording->absolute_name);
+ errno = EEXIST;
+ return NULL;
+ }
+
{
RAII_VAR(struct stasis_app_recording *, old_recording, NULL,
ao2_cleanup);
}
}
],
- "errorResponses": [
- {
- "code": 400,
- "reason": "Recording name invalid"
- },
- {
- "code": 404,
- "reason": "Bridge not found"
- },
- {
- "code": 409,
- "reason": "Bridge not in Stasis application; Recording already in progress"
- }
- ]
+ "errorResponses": [
+ {
+ "code": 400,
+ "reason": "Invalid parameters"
+ },
+ {
+ "code": 404,
+ "reason": "Bridge not found"
+ },
+ {
+ "code": 409,
+ "reason": "Bridge is not in a Stasis application; A recording with the same name already exists on the system and can not be overwritten because it is in progress or ifExists=fail"
+ }
+ ]
}
]
}
},
{
"code": 409,
- "reason": "Channel is not in a Stasis application; the channel is currently bridged with other channels; A recording with the same name is currently in progress."
+ "reason": "Channel is not in a Stasis application; the channel is currently bridged with other hcannels; A recording with the same name already exists on the system and can not be overwritten because it is in progress or ifExists=fail"
}
]
}
}
}
},
+ "RecordingStarted": {
+ "id": "RecordingStarted",
+ "extends": "Event",
+ "description": "Event showing the start of a recording operation.",
+ "properties": {
+ "recording": {
+ "type": "LiveRecording",
+ "description": "Recording control object",
+ "required": true
+ }
+ }
+ },
+ "RecordingFinished": {
+ "id": "RecordingFinished",
+ "extends": "Event",
+ "description": "Event showing the completion of a recording operation.",
+ "properties": {
+ "recording": {
+ "type": "LiveRecording",
+ "description": "Recording control object",
+ "required": true
+ }
+ }
+ },
+ "RecordingFailed": {
+ "id": "RecordingFailed",
+ "extends": "Event",
+ "description": "Event showing failure of a recording operation.",
+ "properties": {
+ "recording": {
+ "type": "LiveRecording",
+ "description": "Recording control object",
+ "required": true
+ },
+ "cause": {
+ "type": "string",
+ "description": "Cause for the recording failure",
+ "required": true
+ }
+ }
+ },
"ApplicationReplaced": {
"id": "ApplicationReplaced",
"description": "Notification that another WebSocket has taken over for an application.\n\nAn application may only be subscribed to by a single WebSocket at a time. If multiple WebSockets attempt to subscribe to the same application, the newer WebSocket wins, and the older one receives this event.",
"valueType": "LIST",
"values": [
"queued",
- "playing",
+ "recording",
"paused",
- "done"
+ "done",
+ "failed",
+ "canceled"
]
}
},