Revision 0270beb3 plugins/janus_sip.c

View differences:

plugins/janus_sip.c
138 138
static int keepalive_interval = 120;
139 139
static gboolean behind_nat = FALSE;
140 140
static char *user_agent;
141
#define JANUS_DEFAULT_REGISTER_TTL	3600
142
static int register_ttl = JANUS_DEFAULT_REGISTER_TTL;
141 143

  
142 144
static GThread *handler_thread;
143 145
static GThread *watchdog;
......
420 422
	if(item && item->value)
421 423
		keepalive_interval = atoi(item->value);
422 424
	JANUS_LOG(LOG_VERB, "SIP keep-alive interval set to %d seconds\n", keepalive_interval);
425
	item = janus_config_get_item_drilldown(config, "general", "register_ttl");
426
	if(item && item->value)
427
		register_ttl = atoi(item->value);
428
	JANUS_LOG(LOG_VERB, "SIP registration TTL set to %d seconds\n", register_ttl);
423 429
	item = janus_config_get_item_drilldown(config, "general", "behind_nat");
424 430
	if(item && item->value)
425 431
		behind_nat = janus_is_true(item->value);
......
955 961
				}
956 962
			}
957 963

  
964
			/* Parse register TTL */
965
			int ttl = register_ttl;
966
			json_t *reg_ttl = json_object_get(root, "register_ttl");
967
			if (reg_ttl && json_is_integer(reg_ttl))
968
				ttl = json_integer_value(reg_ttl);
969
			if (ttl <= 0)
970
				ttl = JANUS_DEFAULT_REGISTER_TTL;
971

  
958 972
			/* Now the user part, if needed */
959 973
			json_t *username = json_object_get(root, "username");
960 974
			if(!guest && !username) {
......
1071 1085
					g_snprintf(error_cause, 512, "Invalid NUA Handle");
1072 1086
					goto error;
1073 1087
				}
1088
				char ttl_text[20];
1089
				g_snprintf(ttl_text, sizeof(ttl_text), "%d", ttl);
1074 1090
				nua_register(session->stack->s_nh_r,
1075 1091
					NUTAG_M_USERNAME(session->account.username),
1076 1092
					SIPTAG_FROM_STR(username_text),
1077 1093
					SIPTAG_TO_STR(username_text),
1094
					SIPTAG_EXPIRES_STR(ttl_text),
1078 1095
					NUTAG_PROXY(proxy_text),
1079 1096
					TAG_END());
1080 1097
				result = json_object();

Also available in: Unified diff