mirror of
https://github.com/jambonz/freeswitch-modules.git
synced 2025-12-19 09:07:44 +00:00
env variable for tts stream connection timeout (#114)
* env variable for tts stream connection timeout Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> * env variable for tts stream connection timeout Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> * env variable for tts stream connection timeout Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> --------- Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com>
This commit is contained in:
@@ -66,6 +66,27 @@ std::string secondsToMillisecondsString(double seconds) {
|
||||
return std::to_string(milliseconds_long);
|
||||
}
|
||||
|
||||
static std::string getEnvVar(const std::string& varName) {
|
||||
const char* val = std::getenv(varName.c_str());
|
||||
return val ? std::string(val) : "";
|
||||
}
|
||||
|
||||
static long getConnectionTimeout() {
|
||||
std::string connectTimeoutStr = getEnvVar("RIMELABS_TTS_CURL_CONNECT_TIMEOUT");
|
||||
|
||||
if (connectTimeoutStr.empty()) {
|
||||
connectTimeoutStr = getEnvVar("TTS_CURL_CONNECT_TIMEOUT");
|
||||
}
|
||||
|
||||
long connectTimeout = 10L;
|
||||
|
||||
if (!connectTimeoutStr.empty()) {
|
||||
connectTimeout = std::stol(connectTimeoutStr);
|
||||
}
|
||||
|
||||
return connectTimeout;
|
||||
}
|
||||
|
||||
static CURL* createEasyHandle(void) {
|
||||
CURL* easy = curl_easy_init();
|
||||
if(!easy) {
|
||||
@@ -78,7 +99,7 @@ static CURL* createEasyHandle(void) {
|
||||
|
||||
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
||||
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
||||
curl_easy_setopt(easy, CURLOPT_TIMEOUT, 10L);
|
||||
curl_easy_setopt(easy, CURLOPT_TIMEOUT, getConnectionTimeout());
|
||||
|
||||
return easy ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user