res_stasis_recording: Add a "target_uri" field to recording events.

This change adds a target_uri field to the live recording object. It
contains the URI of what is being recorded.

(closes issue ASTERISK-23258)
Reported by: Ben Merrills

Review: https://reviewboard.asterisk.org/r/3299/
........

Merged revisions 410025 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410027 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2014-03-06 18:20:37 +00:00
parent 59ff66ef02
commit 3f730662f7
8 changed files with 37 additions and 2 deletions

View File

@@ -89,6 +89,15 @@ Debugging
without configuration changes. These dynamic logger channels will only without configuration changes. These dynamic logger channels will only
exist until the next restart of asterisk. exist until the next restart of asterisk.
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 12.1.0 to Asterisk 12.2.0 ------------
------------------------------------------------------------------------------
ARI
------------------
* The live recording object on recording events now contains a target_uri
field which contains the URI of what is being recorded.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
--- Functionality changes from Asterisk 12.0.0 to Asterisk 12.1.0 ------------ --- Functionality changes from Asterisk 12.0.0 to Asterisk 12.1.0 ------------
------------------------------------------------------------------------------ ------------------------------------------------------------------------------

View File

@@ -140,6 +140,7 @@ struct stasis_app_recording_options {
AST_DECLARE_STRING_FIELDS( AST_DECLARE_STRING_FIELDS(
AST_STRING_FIELD(name); /*!< name Name of the recording. */ AST_STRING_FIELD(name); /*!< name Name of the recording. */
AST_STRING_FIELD(format); /*!< Format to be recorded (wav, gsm, etc.) */ AST_STRING_FIELD(format); /*!< Format to be recorded (wav, gsm, etc.) */
AST_STRING_FIELD(target); /*!< URI of what is being recorded */
); );
/*! Number of seconds of silence before ending the recording. */ /*! Number of seconds of silence before ending the recording. */
int max_silence_seconds; int max_silence_seconds;

View File

@@ -1026,6 +1026,7 @@ int ast_ari_validate_live_recording(struct ast_json *json)
int has_format = 0; int has_format = 0;
int has_name = 0; int has_name = 0;
int has_state = 0; int has_state = 0;
int has_target_uri = 0;
for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) { 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) { if (strcmp("cause", ast_json_object_iter_key(iter)) == 0) {
@@ -1067,6 +1068,16 @@ int ast_ari_validate_live_recording(struct ast_json *json)
res = 0; res = 0;
} }
} else } else
if (strcmp("target_uri", ast_json_object_iter_key(iter)) == 0) {
int prop_is_valid;
has_target_uri = 1;
prop_is_valid = ast_ari_validate_string(
ast_json_object_iter_value(iter));
if (!prop_is_valid) {
ast_log(LOG_ERROR, "ARI LiveRecording field target_uri failed validation\n");
res = 0;
}
} else
{ {
ast_log(LOG_ERROR, ast_log(LOG_ERROR,
"ARI LiveRecording has undocumented field %s\n", "ARI LiveRecording has undocumented field %s\n",
@@ -1090,6 +1101,11 @@ int ast_ari_validate_live_recording(struct ast_json *json)
res = 0; res = 0;
} }
if (!has_target_uri) {
ast_log(LOG_ERROR, "ARI LiveRecording missing required field target_uri\n");
res = 0;
}
return res; return res;
} }

View File

@@ -1146,6 +1146,7 @@ ari_validator ast_ari_validate_application_fn(void);
* - format: string (required) * - format: string (required)
* - name: string (required) * - name: string (required)
* - state: string (required) * - state: string (required)
* - target_uri: string (required)
* StoredRecording * StoredRecording
* - format: string (required) * - format: string (required)
* - name: string (required) * - name: string (required)

View File

@@ -462,6 +462,7 @@ void ast_ari_bridges_record(struct ast_variable *headers,
return; return;
} }
ast_string_field_build(options, target, "bridge:%s", args->bridge_id);
options->max_silence_seconds = args->max_silence_seconds; options->max_silence_seconds = args->max_silence_seconds;
options->max_duration_seconds = args->max_duration_seconds; options->max_duration_seconds = args->max_duration_seconds;
options->terminate_on = options->terminate_on =

View File

@@ -468,6 +468,7 @@ void ast_ari_channels_record(struct ast_variable *headers,
response, 500, "Internal Server Error", response, 500, "Internal Server Error",
"Out of memory"); "Out of memory");
} }
ast_string_field_build(options, target, "channel:%s", args->channel_id);
options->max_silence_seconds = args->max_silence_seconds; options->max_silence_seconds = args->max_silence_seconds;
options->max_duration_seconds = args->max_duration_seconds; options->max_duration_seconds = args->max_duration_seconds;
options->terminate_on = options->terminate_on =

View File

@@ -476,10 +476,11 @@ struct ast_json *stasis_app_recording_to_json(
return NULL; return NULL;
} }
json = ast_json_pack("{s: s, s: s, s: s}", json = ast_json_pack("{s: s, s: s, s: s, s: s}",
"name", recording->options->name, "name", recording->options->name,
"format", recording->options->format, "format", recording->options->format,
"state", state_to_string(recording->state)); "state", state_to_string(recording->state),
"target_uri", recording->options->target);
return ast_json_ref(json); return ast_json_ref(json);
} }

View File

@@ -292,6 +292,11 @@
"type": "string", "type": "string",
"description": "Recording format (wav, gsm, etc.)" "description": "Recording format (wav, gsm, etc.)"
}, },
"target_uri": {
"required": true,
"type": "string",
"description": "URI for the channel or bridge being recorded"
},
"state": { "state": {
"required": false, "required": false,
"type": "string", "type": "string",