From de676ddc8140c1833007183c8cfdc8dd30955073 Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Fri, 28 Jun 2024 18:08:40 +0700 Subject: [PATCH] append null to ostringstream will make c_str return part of a string. (#83) * append null to ostringstream will make c_str return part of a string. * fixed review comment Signed-off-by: Quan HL * fixed review comment Signed-off-by: Quan HL * fixed review comment Signed-off-by: Quan HL --------- Signed-off-by: Quan HL --- mod_azure_transcribe/azure_transcribe_glue.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/mod_azure_transcribe/azure_transcribe_glue.cpp b/mod_azure_transcribe/azure_transcribe_glue.cpp index d8439ed..23be778 100644 --- a/mod_azure_transcribe/azure_transcribe_glue.cpp +++ b/mod_azure_transcribe/azure_transcribe_glue.cpp @@ -382,22 +382,18 @@ private: const char* endpoint = switch_channel_get_variable(channel, "AZURE_SERVICE_ENDPOINT"); const char* endpointId = switch_channel_get_variable(channel, "AZURE_SERVICE_ENDPOINT_ID"); - configuration_stream << - endpoint << ";" << - endpointId << ";"; + configuration_stream << (endpoint ? endpoint : "") << ";" + << (endpointId ? endpointId : "") << ";"; if (switch_true(switch_channel_get_variable(channel, "AZURE_USE_OUTPUT_FORMAT_DETAILED"))) { configuration_stream << "output_format_detailed;"; } if (switch_true(switch_channel_get_variable(channel, "AZURE_AUDIO_LOGGING"))) { configuration_stream << "audio_logging;"; } - if (nullptr != proxyIP && nullptr != proxyPort) { - configuration_stream << - proxyIP << ";" << - proxyPort << ";" << - proxyUsername << ";" << - proxyPassword << ";"; - } + configuration_stream << (proxyIP ? proxyIP : "") << ";" + << (proxyPort ? proxyPort : "") << ";" + << (proxyUsername ? proxyUsername : "") << ";" + << (proxyPassword ? proxyPassword : "") << ";"; const char* var; if (var = switch_channel_get_variable(channel, "AZURE_SPEECH_ALTERNATIVE_LANGUAGE_CODES")) { configuration_stream << var << ";";