[asterisk-commits] mjordan: branch 12 r419565 - in /branches/12: res/ res/ari/ rest-api/api-docs/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jul 25 09:41:28 CDT 2014
Author: mjordan
Date: Fri Jul 25 09:41:23 2014
New Revision: 419565
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=419565
Log:
ARI: report duration values in LiveRecording objects
This patch adds three new fields to the LiveRecording model:
- total_duration: the total length of the live recording
- talking_duration: optional. The duration of talking energy that was
detected while the recording was made.
- silence_duration: optional. The duration of silence that was detected while
the recording was made.
These values are reported in the RecordingFinished ARI event.
When a DSP is enabled on the channel during the recording - which occurs when
the recording is created with max_silence_seconds (indicating that the user
actually cares about how much silence is in the file), we will report the
talking_duration and silence_duration in addition to the total_duration.
Review: https://reviewboard.asterisk.org/r/3770/
ASTERISK-24037 #close
Reported by: Samuel Galarneau
Modified:
branches/12/res/ari/ari_model_validators.c
branches/12/res/ari/ari_model_validators.h
branches/12/res/res_stasis_recording.c
branches/12/rest-api/api-docs/recordings.json
Modified: branches/12/res/ari/ari_model_validators.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/ari/ari_model_validators.c?view=diff&rev=419565&r1=419564&r2=419565
==============================================================================
--- branches/12/res/ari/ari_model_validators.c (original)
+++ branches/12/res/ari/ari_model_validators.c Fri Jul 25 09:41:23 2014
@@ -1038,6 +1038,15 @@
res = 0;
}
} else
+ if (strcmp("duration", ast_json_object_iter_key(iter)) == 0) {
+ int prop_is_valid;
+ prop_is_valid = ast_ari_validate_int(
+ ast_json_object_iter_value(iter));
+ if (!prop_is_valid) {
+ ast_log(LOG_ERROR, "ARI LiveRecording field duration failed validation\n");
+ res = 0;
+ }
+ } else
if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
int prop_is_valid;
has_format = 1;
@@ -1058,6 +1067,15 @@
res = 0;
}
} else
+ if (strcmp("silence_duration", ast_json_object_iter_key(iter)) == 0) {
+ int prop_is_valid;
+ prop_is_valid = ast_ari_validate_int(
+ ast_json_object_iter_value(iter));
+ if (!prop_is_valid) {
+ ast_log(LOG_ERROR, "ARI LiveRecording field silence_duration failed validation\n");
+ res = 0;
+ }
+ } else
if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
int prop_is_valid;
has_state = 1;
@@ -1065,6 +1083,15 @@
ast_json_object_iter_value(iter));
if (!prop_is_valid) {
ast_log(LOG_ERROR, "ARI LiveRecording field state failed validation\n");
+ res = 0;
+ }
+ } else
+ if (strcmp("talking_duration", ast_json_object_iter_key(iter)) == 0) {
+ int prop_is_valid;
+ prop_is_valid = ast_ari_validate_int(
+ ast_json_object_iter_value(iter));
+ if (!prop_is_valid) {
+ ast_log(LOG_ERROR, "ARI LiveRecording field talking_duration failed validation\n");
res = 0;
}
} else
Modified: branches/12/res/ari/ari_model_validators.h
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/ari/ari_model_validators.h?view=diff&rev=419565&r1=419564&r2=419565
==============================================================================
--- branches/12/res/ari/ari_model_validators.h (original)
+++ branches/12/res/ari/ari_model_validators.h Fri Jul 25 09:41:23 2014
@@ -1179,9 +1179,12 @@
* - technology: string (required)
* LiveRecording
* - cause: string
+ * - duration: int
* - format: string (required)
* - name: string (required)
+ * - silence_duration: int
* - state: string (required)
+ * - talking_duration: int
* - target_uri: string (required)
* StoredRecording
* - format: string (required)
Modified: branches/12/res/res_stasis_recording.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_stasis_recording.c?view=diff&rev=419565&r1=419564&r2=419565
==============================================================================
--- branches/12/res/res_stasis_recording.c (original)
+++ branches/12/res/res_stasis_recording.c Fri Jul 25 09:41:23 2014
@@ -61,6 +61,13 @@
struct stasis_app_control *control;
/*! Current state of the recording. */
enum stasis_app_recording_state state;
+ /*! Duration calculations */
+ struct {
+ /*! Total duration */
+ int total;
+ /*! Duration minus any silence */
+ int energy_only;
+ } duration;
/*! Indicates whether the recording is currently muted */
int muted:1;
};
@@ -285,7 +292,6 @@
NULL, recording_cleanup);
char *acceptdtmf;
int res;
- int duration = 0;
recording = data;
ast_assert(recording != NULL);
@@ -325,8 +331,8 @@
recording->absolute_name,
recording->options->max_duration_seconds,
recording->options->format,
- &duration,
- NULL, /* sound_duration */
+ &recording->duration.total,
+ recording->options->max_silence_seconds ? &recording->duration.energy_only : NULL,
recording->options->beep,
-1, /* silencethreshold */
recording->options->max_silence_seconds * 1000,
@@ -381,6 +387,8 @@
errno = ENOMEM;
return NULL;
}
+ recording->duration.total = -1;
+ recording->duration.energy_only = -1;
ast_asprintf(&recording->absolute_name, "%s/%s",
ast_config_AST_RECORDING_DIR, options->name);
@@ -480,6 +488,16 @@
"format", recording->options->format,
"state", state_to_string(recording->state),
"target_uri", recording->options->target);
+ if (json && recording->duration.total > -1) {
+ ast_json_object_set(json, "duration",
+ ast_json_integer_create(recording->duration.total));
+ }
+ if (json && recording->duration.energy_only > -1) {
+ ast_json_object_set(json, "talking_duration",
+ ast_json_integer_create(recording->duration.energy_only));
+ ast_json_object_set(json, "silence_duration",
+ ast_json_integer_create(recording->duration.total - recording->duration.energy_only));
+ }
return ast_json_ref(json);
}
Modified: branches/12/rest-api/api-docs/recordings.json
URL: http://svnview.digium.com/svn/asterisk/branches/12/rest-api/api-docs/recordings.json?view=diff&rev=419565&r1=419564&r2=419565
==============================================================================
--- branches/12/rest-api/api-docs/recordings.json (original)
+++ branches/12/rest-api/api-docs/recordings.json Fri Jul 25 09:41:23 2014
@@ -338,7 +338,7 @@
"description": "URI for the channel or bridge being recorded"
},
"state": {
- "required": false,
+ "required": true,
"type": "string",
"allowableValues": {
"valueType": "LIST",
@@ -352,18 +352,25 @@
]
}
},
+ "duration": {
+ "required": false,
+ "type": "int",
+ "description": "Duration in seconds of the recording"
+ },
+ "talking_duration": {
+ "required": false,
+ "type": "int",
+ "description": "Duration of talking, in seconds, detected in the recording. This is only available if the recording was initiated with a non-zero maxSilenceSeconds."
+ },
+ "silence_duration": {
+ "required": false,
+ "type": "int",
+ "description": "Duration of silence, in seconds, detected in the recording. This is only available if the recording was initiated with a non-zero maxSilenceSeconds."
+ },
"cause": {
"required": false,
"type": "string",
"description": "Cause for recording failure if failed"
- },
- "state": {
- "required": true,
- "type": "string"
- },
- "format": {
- "required": true,
- "type": "string"
}
}
}
More information about the asterisk-commits
mailing list