diff --git a/include/ctrlm_ipc_voice.h b/include/ctrlm_ipc_voice.h index 270b92d9..665ffaa5 100644 --- a/include/ctrlm_ipc_voice.h +++ b/include/ctrlm_ipc_voice.h @@ -228,7 +228,7 @@ typedef struct { ctrlm_network_type_t network_type; ///< Type of network on which the controller is bound ctrlm_controller_id_t controller_id; ///< A unique identifier of the remote unsigned long session_id; ///< A unique id for the voice session. - ctrlm_voice_session_end_reason_t reason; ///< The reason for ending + ctrlm_voice_session_end_reason_t reason; ///< The reason for ending session unsigned char is_voice_assistant; ///< Boolean indicating if the device is a far-field device (1) as opposed to a hand-held remote (0). } ctrlm_voice_iarm_event_session_end_t; diff --git a/src/telemetry/ctrlm_telemetry_markers.h b/src/telemetry/ctrlm_telemetry_markers.h index 9c0ba3a3..23c0f775 100644 --- a/src/telemetry/ctrlm_telemetry_markers.h +++ b/src/telemetry/ctrlm_telemetry_markers.h @@ -117,7 +117,7 @@ // - server message. // - flag to indicate if session was successful. #define MARKER_VOICE_SESSION_STATS "ctrlm.voice.session.stats" -#define MARKER_VOICE_SESSION_STATS_VERSION "1" +#define MARKER_VOICE_SESSION_STATS_VERSION "2" // End Voice Session Statistics diff --git a/src/voice/ctrlm_voice_obj.cpp b/src/voice/ctrlm_voice_obj.cpp index 1af6f059..6e4b354f 100644 --- a/src/voice/ctrlm_voice_obj.cpp +++ b/src/voice/ctrlm_voice_obj.cpp @@ -95,7 +95,7 @@ ctrlm_voice_t::ctrlm_voice_t() { session->session_active_controller = false; session->state_src = CTRLM_VOICE_STATE_SRC_INVALID; session->state_dst = CTRLM_VOICE_STATE_DST_INVALID; - session->end_reason = CTRLM_VOICE_SESSION_END_REASON_DONE; + session->end_reason_rcu = CTRLM_VOICE_SESSION_END_REASON_DONE; session->audio_pipe[PIPE_READ] = -1; session->audio_pipe[PIPE_WRITE] = -1; @@ -1872,7 +1872,7 @@ void ctrlm_voice_t::voice_session_end(ctrlm_voice_session_t *session, ctrlm_voic return; } - session->end_reason = reason; + session->end_reason_rcu = reason; if(timestamp != NULL) { session->session_timing.ctrl_stop = *timestamp; @@ -2522,7 +2522,7 @@ void ctrlm_voice_t::voice_session_begin_callback(ctrlm_voice_session_begin_cb_t session->ipc_common_data.voice_assistant = is_voice_assistant(session->voice_device); session->ipc_common_data.device_type = session->voice_device; session->endpoint_current = session_begin->endpoint; - session->end_reason = CTRLM_VOICE_SESSION_END_REASON_DONE; + session->end_reason_rcu = CTRLM_VOICE_SESSION_END_REASON_DONE; errno_t safec_rc = memset_s(&session->status, sizeof(session->status), 0 , sizeof(session->status)); ERR_CHK(safec_rc); @@ -2625,7 +2625,7 @@ void ctrlm_voice_t::voice_session_end_callback(ctrlm_voice_session_end_cb_t *ses if(command_status == VOICE_COMMAND_STATUS_PENDING) { switch(session->voice_device) { case CTRLM_VOICE_DEVICE_FF: { - session->status.status = (stats->reason == XRSR_SESSION_END_REASON_EOS) ? VOICE_COMMAND_STATUS_SUCCESS : VOICE_COMMAND_STATUS_FAILURE; + session->status.status = (stats->session_end_reason == XRSR_SESSION_END_REASON_EOS) ? VOICE_COMMAND_STATUS_SUCCESS : VOICE_COMMAND_STATUS_FAILURE; command_status = session->status.status; this->voice_status_set(session); break; @@ -2642,9 +2642,9 @@ void ctrlm_voice_t::voice_session_end_callback(ctrlm_voice_session_end_cb_t *ses } if(session->voice_device == CTRLM_VOICE_DEVICE_MICROPHONE || session->voice_device == CTRLM_VOICE_DEVICE_MICROPHONE_TAP) { - XLOGD_INFO("src <%s> reason <%s> voice command status <%s>", ctrlm_voice_device_str(session->voice_device), xrsr_session_end_reason_str(stats->reason), ctrlm_voice_command_status_str(command_status)); + XLOGD_INFO("src <%s> reason <%s> voice command status <%s>", ctrlm_voice_device_str(session->voice_device), xrsr_session_end_reason_str(stats->session_end_reason), ctrlm_voice_command_status_str(command_status)); } else { - XLOGD_INFO("src <%s> audio sent bytes <%u> samples <%u> reason <%s> voice command status <%s>", ctrlm_voice_device_str(session->voice_device), session->audio_sent_bytes, session->audio_sent_samples, xrsr_session_end_reason_str(stats->reason), ctrlm_voice_command_status_str(command_status)); + XLOGD_INFO("src <%s> audio sent bytes <%u> samples <%u> reason <%s> voice command status <%s>", ctrlm_voice_device_str(session->voice_device), session->audio_sent_bytes, session->audio_sent_samples, xrsr_session_end_reason_str(stats->session_end_reason), ctrlm_voice_command_status_str(command_status)); } // Update device status @@ -2657,18 +2657,18 @@ void ctrlm_voice_t::voice_session_end_callback(ctrlm_voice_session_end_cb_t *ses // Send Results IARM Event if(this->voice_ipc) { - if(stats->reason == XRSR_SESSION_END_REASON_ERROR_AUDIO_DURATION) { + if(stats->session_end_reason == XRSR_SESSION_END_REASON_ERROR_AUDIO_DURATION) { ctrlm_voice_ipc_event_session_end_t end; end.common = session->ipc_common_data; end.result = SESSION_END_SHORT_UTTERANCE; - end.reason = (int)session->end_reason; + end.reason = (int)session->end_reason_rcu; this->voice_ipc->session_end(end); } else { ctrlm_voice_ipc_event_session_end_server_stats_t server_stats; ctrlm_voice_ipc_event_session_end_t end; end.common = session->ipc_common_data; end.result = (session_end->success ? SESSION_END_SUCCESS : SESSION_END_FAILURE); - end.reason = stats->reason; + end.reason = stats->session_end_reason; end.return_code_protocol = stats->ret_code_protocol; end.return_code_protocol_library = stats->ret_code_library; end.return_code_server = session->server_ret_code; @@ -2690,7 +2690,7 @@ void ctrlm_voice_t::voice_session_end_callback(ctrlm_voice_session_end_cb_t *ses // Update controller metrics ctrlm_main_queue_msg_controller_voice_metrics_t metrics = {0}; metrics.controller_id = session->controller_id; - metrics.short_utterance = (stats->reason == XRSR_SESSION_END_REASON_ERROR_AUDIO_DURATION ? 1 : 0); + metrics.short_utterance = (stats->session_end_reason == XRSR_SESSION_END_REASON_ERROR_AUDIO_DURATION ? 1 : 0); metrics.packets_total = session->packets_processed + session->packets_lost; metrics.packets_lost = session->packets_lost; @@ -2719,8 +2719,8 @@ void ctrlm_voice_t::voice_session_end_callback(ctrlm_voice_session_end_cb_t *ses if(telemetry) { ctrlm_telemetry_event_t vs_marker(MARKER_VOICE_SESSION_TOTAL, 1); ctrlm_telemetry_event_t vs_status_marker(session_end->success ? MARKER_VOICE_SESSION_SUCCESS : MARKER_VOICE_SESSION_FAILURE, 1); - ctrlm_telemetry_event_t vs_end_reason_marker(MARKER_VOICE_END_REASON_PREFIX + std::string(ctrlm_voice_session_end_reason_str(session->end_reason)), 1); - ctrlm_telemetry_event_t vs_xrsr_end_reason_marker(MARKER_VOICE_XRSR_END_REASON_PREFIX + std::string(xrsr_session_end_reason_str(stats->reason)), 1); + ctrlm_telemetry_event_t vs_end_reason_marker(MARKER_VOICE_END_REASON_PREFIX + std::string(ctrlm_voice_session_end_reason_str(session->end_reason_rcu)), 1); + ctrlm_telemetry_event_t vs_xrsr_end_reason_marker(MARKER_VOICE_XRSR_END_REASON_PREFIX + std::string(xrsr_session_end_reason_str(stats->session_end_reason)), 1); // Handle all VSRsp error telemetry if(session->current_vsr_err_string != "") { @@ -2745,7 +2745,7 @@ void ctrlm_voice_t::voice_session_end_callback(ctrlm_voice_session_end_cb_t *ses telemetry->event(ctrlm_telemetry_report_t::VOICE, vs_xrsr_end_reason_marker); if(this->prefs.telemetry_session_stats) { - if(!session->telemetry_session_stats.update_on_session_end(session_end->success, session->end_reason, stats->reason, session->server_ret_code, session->server_message, session->stats_session.voice_key_held_ms)) { + if(!session->telemetry_session_stats.update_on_session_end(session_end->success, session->end_reason_rcu, stats->session_end_reason, session->server_ret_code, session->server_message, session->stats_session.voice_key_held_ms, stats->ret_code_protocol, stats->stream_end_reason)) { XLOGD_ERROR("failed to generate session stats event"); } } @@ -2980,7 +2980,7 @@ void ctrlm_voice_t::voice_stream_end_callback(ctrlm_voice_stream_end_cb_t *strea // This is a STREAM end.. ctrlm_voice_ipc_event_stream_end_t end; end.common = session->ipc_common_data; - end.reason = (int)session->end_reason; + end.reason = (int)session->end_reason_rcu; this->voice_ipc->stream_end(end); } diff --git a/src/voice/ctrlm_voice_obj.h b/src/voice/ctrlm_voice_obj.h index c4395b18..38699a6b 100644 --- a/src/voice/ctrlm_voice_obj.h +++ b/src/voice/ctrlm_voice_obj.h @@ -443,7 +443,7 @@ typedef struct { uint32_t packets_lost; uint32_t lqi_total; - ctrlm_voice_session_end_reason_t end_reason; + ctrlm_voice_session_end_reason_t end_reason_rcu; bool is_press_and_release; bool is_session_by_text; diff --git a/src/voice/endpoints/ctrlm_voice_endpoint_http.cpp b/src/voice/endpoints/ctrlm_voice_endpoint_http.cpp index 93396a4b..1ec3e647 100644 --- a/src/voice/endpoints/ctrlm_voice_endpoint_http.cpp +++ b/src/voice/endpoints/ctrlm_voice_endpoint_http.cpp @@ -286,7 +286,7 @@ void ctrlm_voice_endpoint_http_t::voice_session_end_callback_http(void *data, in } // Check if HTTP was successful - if((stats->reason != XRSR_SESSION_END_REASON_EOS && stats->reason != XRSR_SESSION_END_REASON_TERMINATE && stats->reason != XRSR_SESSION_END_REASON_EOT) + if((stats->session_end_reason != XRSR_SESSION_END_REASON_EOS && stats->session_end_reason != XRSR_SESSION_END_REASON_TERMINATE && stats->session_end_reason != XRSR_SESSION_END_REASON_EOT) || (stats->ret_code_library != 0) || (stats->ret_code_protocol != 200) || (this->server_ret_code != 0)) { success = false; } diff --git a/src/voice/endpoints/ctrlm_voice_endpoint_ws_nextgen.cpp b/src/voice/endpoints/ctrlm_voice_endpoint_ws_nextgen.cpp index fcf9b12a..e5165cd7 100644 --- a/src/voice/endpoints/ctrlm_voice_endpoint_ws_nextgen.cpp +++ b/src/voice/endpoints/ctrlm_voice_endpoint_ws_nextgen.cpp @@ -460,7 +460,7 @@ void ctrlm_voice_endpoint_ws_nextgen_t::voice_session_end_callback_ws_nextgen(vo } // Check if WS was successful - if((stats->reason != XRSR_SESSION_END_REASON_EOS && stats->reason != XRSR_SESSION_END_REASON_EOT) || (this->server_ret_code != 0 && this->server_ret_code != 200)) { + if((stats->session_end_reason != XRSR_SESSION_END_REASON_EOS && stats->session_end_reason != XRSR_SESSION_END_REASON_EOT) || (this->server_ret_code != 0 && this->server_ret_code != 200)) { success = false; } diff --git a/src/voice/endpoints/ctrlm_voice_endpoint_ws_nsp.cpp b/src/voice/endpoints/ctrlm_voice_endpoint_ws_nsp.cpp index da4d4035..a123c0d6 100644 --- a/src/voice/endpoints/ctrlm_voice_endpoint_ws_nsp.cpp +++ b/src/voice/endpoints/ctrlm_voice_endpoint_ws_nsp.cpp @@ -203,7 +203,7 @@ void ctrlm_voice_endpoint_ws_nsp_t::voice_session_end_callback_ws_nsp(void *data } // Check if WS was successful - if((stats->reason != XRSR_SESSION_END_REASON_DISCONNECT_REMOTE) || (this->server_ret_code != 0 && this->server_ret_code != 200)) { + if((stats->session_end_reason != XRSR_SESSION_END_REASON_DISCONNECT_REMOTE) || (this->server_ret_code != 0 && this->server_ret_code != 200)) { success = false; } diff --git a/src/voice/telemetry/ctrlm_voice_telemetry_events.cpp b/src/voice/telemetry/ctrlm_voice_telemetry_events.cpp index e7ac6e71..d5f6bba3 100644 --- a/src/voice/telemetry/ctrlm_voice_telemetry_events.cpp +++ b/src/voice/telemetry/ctrlm_voice_telemetry_events.cpp @@ -206,11 +206,13 @@ bool ctrlm_voice_telemetry_session_t::event() { ss << m_samples_lost << ","; ss << m_decoder_failures << ","; ss << m_samples_buffered_max << ","; - ss << m_end_reason_stream << ","; - ss << m_end_reason_protocol << ","; + ss << m_end_reason_rcu << ","; + ss << m_end_reason_session << ","; ss << m_end_reason_server << ","; ss << "\"" << m_server_message << "\","; - ss << m_result << "]]"; + ss << m_result << ","; + ss << m_end_reason_stream << ","; + ss << m_ret_code_protocol << "]]"; if(m_event_list.length() + ss.str().length() > m_event_list_max_size) { // Maximum data size exceeded XLOGD_WARN("telemetry event exceeds max size <%s,%s>", val_marker.c_str(), ss.str().c_str()); @@ -279,12 +281,14 @@ void ctrlm_voice_telemetry_session_t::update_on_stream_end(uint32_t time_stream_ } } -bool ctrlm_voice_telemetry_session_t::update_on_session_end(bool result, int32_t end_reason_stream, int32_t end_reason_protocol, int32_t end_reason_server, const std::string &server_message, int32_t time_stream_len_exp) { +bool ctrlm_voice_telemetry_session_t::update_on_session_end(bool result, int32_t end_reason_rcu, int32_t end_reason_session, int32_t end_reason_server, const std::string &server_message, int32_t time_stream_len_exp, int32_t ret_code_protocol, int32_t stream_end_reason) { m_result = result; - m_end_reason_stream = end_reason_stream; - m_end_reason_protocol = end_reason_protocol; + m_end_reason_rcu = end_reason_rcu; + m_end_reason_session = end_reason_session; m_end_reason_server = end_reason_server; m_server_message = server_message; + m_ret_code_protocol = ret_code_protocol; + m_end_reason_stream = stream_end_reason; if(!m_has_key_release) { // if there is no key release, the start time and end time are not known rdkx_timestamp_get(&m_time_prev_session_end); @@ -310,10 +314,11 @@ void ctrlm_voice_telemetry_session_t::reset_stats() { m_decoder_failures = 0; m_samples_buffered_max = 0; - m_end_reason_stream = 0; - m_end_reason_protocol = 0; + m_end_reason_rcu = 0; + m_end_reason_session = 0; m_end_reason_server = 0; m_result = false; + m_ret_code_protocol = 0; m_server_message.clear(); m_device_type.clear(); diff --git a/src/voice/telemetry/ctrlm_voice_telemetry_events.h b/src/voice/telemetry/ctrlm_voice_telemetry_events.h index d8bf90dd..adadfde6 100644 --- a/src/voice/telemetry/ctrlm_voice_telemetry_events.h +++ b/src/voice/telemetry/ctrlm_voice_telemetry_events.h @@ -76,7 +76,7 @@ class ctrlm_voice_telemetry_session_t : public ctrlm_telemetry_event_t