Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/ctrlm_ipc_voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/telemetry/ctrlm_telemetry_markers.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
// <server_message> - server message.
// <result> - 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

Expand Down
28 changes: 14 additions & 14 deletions src/voice/ctrlm_voice_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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<int> vs_marker(MARKER_VOICE_SESSION_TOTAL, 1);
ctrlm_telemetry_event_t<int> vs_status_marker(session_end->success ? MARKER_VOICE_SESSION_SUCCESS : MARKER_VOICE_SESSION_FAILURE, 1);
ctrlm_telemetry_event_t<int> 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<int> 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<int> 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<int> 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 != "") {
Expand All @@ -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");
}
}
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/voice/ctrlm_voice_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/voice/endpoints/ctrlm_voice_endpoint_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/voice/endpoints/ctrlm_voice_endpoint_ws_nextgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/voice/endpoints/ctrlm_voice_endpoint_ws_nsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
20 changes: 12 additions & 8 deletions src/voice/telemetry/ctrlm_voice_telemetry_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_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());
Expand Down Expand Up @@ -279,12 +281,13 @@ 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;

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);
Expand All @@ -310,10 +313,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();
Expand Down
7 changes: 4 additions & 3 deletions src/voice/telemetry/ctrlm_voice_telemetry_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ctrlm_voice_telemetry_session_t : public ctrlm_telemetry_event_t<std::stri
void update_on_session_begin(const std::string &device_type, const std::string &device_version, const std::string &encoding, bool press_and_release, bool end_of_speech_detection);
void update_on_key_release(int32_t time_start_lag, int32_t time_stream_len_exp, rdkx_timestamp_t *time_key_down, rdkx_timestamp_t *time_key_up);
void update_on_stream_end(uint32_t time_stream_len_act, uint32_t packets_total, uint32_t packets_lost, uint32_t samples_total, uint32_t samples_lost, uint32_t decoder_failures, uint32_t samples_buffered_max);
bool update_on_session_end(bool result, int32_t end_reason_stream, int32_t end_reason_protocol, int32_t server_return_code, const std::string &server_message, int32_t time_stream_len_exp);
bool update_on_session_end(bool result, int32_t end_reason_rcu, int32_t end_reason_session, int32_t server_return_code, const std::string &server_message, int32_t time_stream_len_exp, int32_t ret_code_protocol, int32_t stream_end_reason);

private:
static const uint32_t m_event_list_max_size = 4536; // Maximum size of event list in bytes (there are limitations in the T2 implementation that restrict the maximum size of an event string. This value should be within the limits of the T2 implementation)
Expand All @@ -103,11 +103,12 @@ class ctrlm_voice_telemetry_session_t : public ctrlm_telemetry_event_t<std::stri
uint32_t m_decoder_failures; // decoder failure count
uint32_t m_samples_buffered_max; // sample buffer high watermark

int32_t m_end_reason_stream; // reason for ending the stream
int32_t m_end_reason_protocol; // reason for ending the connection
int32_t m_end_reason_rcu; // reason for ending the stream as reported by RCU
int32_t m_end_reason_session; // reason for ending the session
int32_t m_end_reason_server; // server response success/error code
std::string m_server_message; // server message
bool m_result; // flag to indicate if session was successful
int32_t m_ret_code_protocol; // protocol return code

bool m_has_key_release; // flag to indicate if key release event has been received

Expand Down