diff options
author | Matthew Jordan <mjordan@digium.com> | 2014-07-25 14:47:09 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2014-07-25 14:47:09 +0000 |
commit | 355dc3d2ad98db624184a797206ccb88f4b8a526 (patch) | |
tree | b7247b841d9bb4587560208202b2182706a1fb5c /res/res_stasis_recording.c | |
parent | ba9867fab07b4e6f74916c898122bb6705598413 (diff) |
Multiple revisions 419565-419566
........
r419565 | mjordan | 2014-07-25 09:41:23 -0500 (Fri, 25 Jul 2014) | 21 lines
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
........
r419566 | mjordan | 2014-07-25 09:46:15 -0500 (Fri, 25 Jul 2014) | 1 line
Update CHANGES for r419565
........
Merged revisions 419565-419566 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419567 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_stasis_recording.c')
-rw-r--r-- | res/res_stasis_recording.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/res/res_stasis_recording.c b/res/res_stasis_recording.c index 55954cd1e..f74974349 100644 --- a/res/res_stasis_recording.c +++ b/res/res_stasis_recording.c @@ -61,6 +61,13 @@ struct stasis_app_recording { 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 @@ static int record_file(struct stasis_app_control *control, NULL, recording_cleanup); char *acceptdtmf; int res; - int duration = 0; recording = data; ast_assert(recording != NULL); @@ -325,8 +331,8 @@ static int record_file(struct stasis_app_control *control, 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 @@ struct stasis_app_recording *stasis_app_control_record( 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 @@ struct ast_json *stasis_app_recording_to_json( "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); } |