in nlsCppSdk/transport/connectNode.cpp [3978:4105]
void ConnectNode::updateNodeProcess(std::string api, int status, bool enter,
size_t size) {
#ifdef ENABLE_NLS_DEBUG_2
uint64_t timewait_start, timewait_0, timewait_a, timewait_end;
timewait_start = utility::TextUtils::GetTimestampMs();
#endif
if (api == "start") {
if (enter) {
_nodeProcess.last_op_timestamp_ms = utility::TextUtils::GetTimestampMs();
_nodeProcess.start_timestamp_ms = _nodeProcess.last_op_timestamp_ms;
_nodeProcess.last_status = NodeInvoking;
_nodeProcess.api_start_run = true;
_nodeProcess.last_api_timestamp_ms = utility::TextUtils::GetTimestampMs();
} else {
_nodeProcess.api_start_run = false;
}
} else if (api == "stop") {
if (enter) {
_nodeProcess.last_op_timestamp_ms = utility::TextUtils::GetTimestampMs();
_nodeProcess.stop_timestamp_ms = _nodeProcess.last_op_timestamp_ms;
_nodeProcess.last_status = NodeStop;
_nodeProcess.api_stop_run = true;
_nodeProcess.last_api_timestamp_ms = utility::TextUtils::GetTimestampMs();
} else {
_nodeProcess.api_stop_run = false;
}
} else if (api == "cancel") {
if (enter) {
_nodeProcess.last_op_timestamp_ms = utility::TextUtils::GetTimestampMs();
_nodeProcess.cancel_timestamp_ms = _nodeProcess.last_op_timestamp_ms;
_nodeProcess.last_status = NodeCancel;
_nodeProcess.api_cancel_run = true;
_nodeProcess.last_api_timestamp_ms = utility::TextUtils::GetTimestampMs();
} else {
_nodeProcess.api_cancel_run = false;
}
} else if (api == "sendAudio") {
if (enter) {
_nodeProcess.last_op_timestamp_ms = utility::TextUtils::GetTimestampMs();
_nodeProcess.last_send_timestamp_ms = _nodeProcess.last_op_timestamp_ms;
_nodeProcess.last_status = NodeSendAudio;
_nodeProcess.recording_bytes += size;
_nodeProcess.send_count++;
_nodeProcess.api_send_run = true;
_nodeProcess.last_api_timestamp_ms = utility::TextUtils::GetTimestampMs();
} else {
_nodeProcess.api_send_run = false;
}
} else if (api == "ctrl") {
if (enter) {
_nodeProcess.last_op_timestamp_ms = utility::TextUtils::GetTimestampMs();
_nodeProcess.last_ctrl_timestamp_ms = _nodeProcess.last_op_timestamp_ms;
_nodeProcess.last_status = NodeSendControl;
_nodeProcess.api_ctrl_run = true;
_nodeProcess.last_api_timestamp_ms = utility::TextUtils::GetTimestampMs();
} else {
_nodeProcess.api_ctrl_run = false;
}
} else if (api == "send_text") {
if (enter) {
_nodeProcess.last_op_timestamp_ms = utility::TextUtils::GetTimestampMs();
_nodeProcess.last_status = NodeSendText;
_nodeProcess.api_ctrl_run = true;
_nodeProcess.last_api_timestamp_ms = utility::TextUtils::GetTimestampMs();
} else {
_nodeProcess.api_ctrl_run = false;
}
} else if (api == "callback") {
if (enter) {
#ifdef ENABLE_NLS_DEBUG_2
timewait_0 = utility::TextUtils::GetTimestampMs();
#endif
_nodeProcess.last_callback = (NlsEvent::EventType)status;
switch (_nodeProcess.last_callback) {
case NlsEvent::RecognitionStarted:
case NlsEvent::TranscriptionStarted:
_nodeProcess.last_op_timestamp_ms =
utility::TextUtils::GetTimestampMs();
_nodeProcess.started_timestamp_ms = _nodeProcess.last_op_timestamp_ms;
break;
case NlsEvent::TranscriptionCompleted:
case NlsEvent::RecognitionCompleted:
case NlsEvent::SynthesisCompleted:
_nodeProcess.last_op_timestamp_ms =
utility::TextUtils::GetTimestampMs();
_nodeProcess.completed_timestamp_ms =
_nodeProcess.last_op_timestamp_ms;
break;
case NlsEvent::Binary:
_nodeProcess.last_op_timestamp_ms =
utility::TextUtils::GetTimestampMs();
_nodeProcess.play_bytes += size;
_nodeProcess.play_count++;
_nodeProcess.last_status = NodePlayAudio;
if (_isFirstBinaryFrame) {
_nodeProcess.first_binary_timestamp_ms =
_nodeProcess.last_op_timestamp_ms;
}
break;
}
#ifdef ENABLE_NLS_DEBUG_2
timewait_a = utility::TextUtils::GetTimestampMs();
#endif
_nodeProcess.last_cb_start_timestamp_ms =
utility::TextUtils::GetTimestampMs();
_nodeProcess.last_cb_end_timestamp_ms = 0;
_nodeProcess.last_cb_run = true;
} else {
_nodeProcess.last_cb_end_timestamp_ms =
utility::TextUtils::GetTimestampMs();
_nodeProcess.last_cb_run = false;
}
}
#ifdef ENABLE_NLS_DEBUG_2
timewait_end = utility::TextUtils::GetTimestampMs();
if (timewait_end - timewait_start > 50) {
LOG_WARN(
"Request(%p) Node(%p) updateNodeProcess calback %d done with "
"excessive time "
"%llums, including 0:%llu a:%llu b:%llums.",
_request, this, _nodeProcess.last_callback,
timewait_end - timewait_start, timewait_0 - timewait_start,
timewait_a - timewait_start, timewait_end - timewait_a);
}
#endif
}