mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 12:42:02 +00:00
enhance timers and make rtp use it that way
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2669 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -102,6 +102,7 @@ struct mdl_profile {
|
||||
char *server;
|
||||
char *exten;
|
||||
char *context;
|
||||
char *timer_name;
|
||||
ldl_handle_t *handle;
|
||||
uint32_t flags;
|
||||
uint32_t user_flags;
|
||||
@@ -343,6 +344,7 @@ static int activate_rtp(struct private_object *tech_pvt)
|
||||
tech_pvt->read_codec.implementation->microseconds_per_frame,
|
||||
flags,
|
||||
NULL,
|
||||
tech_pvt->profile->timer_name,
|
||||
&err, switch_core_session_get_pool(tech_pvt->session)))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
@@ -1326,6 +1328,8 @@ static void set_profile_val(struct mdl_profile *profile, char *var, char *val)
|
||||
profile->extip = switch_core_strdup(module_pool, val);
|
||||
} else if (!strcasecmp(var, "server")) {
|
||||
profile->server = switch_core_strdup(module_pool, val);
|
||||
} else if (!strcasecmp(var, "rtp-timer-name")) {
|
||||
profile->timer_name = switch_core_strdup(module_pool, val);
|
||||
} else if (!strcasecmp(var, "lanaddr")) {
|
||||
profile->lanaddr = switch_core_strdup(module_pool, val);
|
||||
} else if (!strcasecmp(var, "tls")) {
|
||||
|
||||
@@ -585,6 +585,7 @@ static switch_status_t activate_rtp(struct private_object *tech_pvt)
|
||||
ms,
|
||||
flags,
|
||||
key,
|
||||
"soft",
|
||||
&err, switch_core_session_get_pool(tech_pvt->session));
|
||||
|
||||
if (switch_rtp_ready(tech_pvt->rtp_session)) {
|
||||
|
||||
@@ -111,6 +111,7 @@ struct sofia_profile {
|
||||
char *username;
|
||||
char *url;
|
||||
char *sipdomain;
|
||||
char *timer_name;
|
||||
int sip_port;
|
||||
char *codec_string;
|
||||
char *codec_order[SWITCH_MAX_CODECS];
|
||||
@@ -697,6 +698,7 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt)
|
||||
tech_pvt->codec_ms * 1000,
|
||||
(switch_rtp_flag_t) flags,
|
||||
NULL,
|
||||
tech_pvt->profile->timer_name,
|
||||
&err,
|
||||
switch_core_session_get_pool(tech_pvt->session));
|
||||
|
||||
@@ -1698,6 +1700,8 @@ static switch_status_t config_sofia(int reload)
|
||||
profile->sipip = switch_core_strdup(profile->pool, val);
|
||||
} else if (!strcmp(var, "sip-domain")) {
|
||||
profile->sipdomain = switch_core_strdup(profile->pool, val);
|
||||
} else if (!strcmp(var, "rtp-timer-name")) {
|
||||
profile->timer_name = switch_core_strdup(profile->pool, val);
|
||||
} else if (!strcmp(var, "ext-sip-ip")) {
|
||||
profile->extsipip = switch_core_strdup(profile->pool, val);
|
||||
} else if (!strcmp(var, "bitpacking")) {
|
||||
|
||||
@@ -48,7 +48,7 @@ struct timer_private {
|
||||
#endif
|
||||
};
|
||||
|
||||
static switch_status_t soft_timer_init(switch_timer_t *timer)
|
||||
static inline switch_status_t soft_timer_init(switch_timer_t *timer)
|
||||
{
|
||||
struct timer_private *private;
|
||||
|
||||
@@ -65,7 +65,7 @@ static switch_status_t soft_timer_init(switch_timer_t *timer)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t soft_timer_next(switch_timer_t *timer)
|
||||
static inline switch_status_t soft_timer_next(switch_timer_t *timer)
|
||||
{
|
||||
struct timer_private *private = timer->private_info;
|
||||
|
||||
@@ -91,7 +91,44 @@ static switch_status_t soft_timer_next(switch_timer_t *timer)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t soft_timer_destroy(switch_timer_t *timer)
|
||||
static inline switch_status_t soft_timer_step(switch_timer_t *timer)
|
||||
{
|
||||
struct timer_private *private = timer->private_info;
|
||||
#ifdef WINTIMER
|
||||
private->base.QuadPart += timer->interval * (private->freq.QuadPart / 1000);
|
||||
#else
|
||||
private->reference += timer->interval * 1000;
|
||||
#endif
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static inline switch_status_t soft_timer_check(switch_timer_t *timer)
|
||||
|
||||
{
|
||||
struct timer_private *private = timer->private_info;
|
||||
#ifdef WINTIMER
|
||||
QueryPerformanceCounter(&private->now);
|
||||
if (private->now.QuadPart >= private->base.QuadPart) {
|
||||
private->base.QuadPart += timer->interval * (private->freq.QuadPart / 1000);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
#else
|
||||
if (switch_time_now() < private->reference) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
private->reference += timer->interval * 1000;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
static inline switch_status_t soft_timer_destroy(switch_timer_t *timer)
|
||||
{
|
||||
timer->private_info = NULL;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -101,6 +138,8 @@ static const switch_timer_interface_t soft_timer_interface = {
|
||||
/*.interface_name */ "soft",
|
||||
/*.timer_init */ soft_timer_init,
|
||||
/*.timer_next */ soft_timer_next,
|
||||
/*.timer_step */ soft_timer_step,
|
||||
/*.timer_check */ soft_timer_check,
|
||||
/*.timer_destroy */ soft_timer_destroy
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user