本文整理汇总了C++中pjsip_endpt_cancel_timer函数的典型用法代码示例。如果您正苦于以下问题:C++ pjsip_endpt_cancel_timer函数的具体用法?C++ pjsip_endpt_cancel_timer怎么用?C++ pjsip_endpt_cancel_timer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pjsip_endpt_cancel_timer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stop_timer
/* Stop Session Timers */
static void stop_timer(pjsip_inv_session *inv)
{
if (inv->timer->timer.id != 0) {
pjsip_endpt_cancel_timer(inv->dlg->endpt, &inv->timer->timer);
inv->timer->timer.id = 0;
}
if (inv->timer->expire_timer.id != 0) {
pjsip_endpt_cancel_timer(inv->dlg->endpt, &inv->timer->expire_timer);
inv->timer->expire_timer.id = 0;
}
}
示例2: PJ_DEF
PJ_DEF(pj_status_t) pjsip_publishc_unpublish(pjsip_publishc *pubc,
pjsip_tx_data **p_tdata)
{
pjsip_tx_data *tdata;
pjsip_msg *msg;
pjsip_expires_hdr *expires;
pj_status_t status;
PJ_ASSERT_RETURN(pubc && p_tdata, PJ_EINVAL);
if (pubc->timer.id != 0) {
pjsip_endpt_cancel_timer(pubc->endpt, &pubc->timer);
pubc->timer.id = 0;
}
status = create_request(pubc, &tdata);
if (status != PJ_SUCCESS)
return status;
msg = tdata->msg;
/* Add Expires:0 header */
expires = pjsip_expires_hdr_create(tdata->pool, 0);
pjsip_msg_add_hdr( msg, (pjsip_hdr*)expires);
*p_tdata = tdata;
return PJ_SUCCESS;
}
示例3: rt_on_rx_response
static pj_bool_t rt_on_rx_response(pjsip_rx_data *rdata)
{
if (!pj_strncmp(&rdata->msg_info.cid->id, &rt_call_id, rt_call_id.slen)) {
char *pos = pj_strchr(&rdata->msg_info.cid->id, '/')+1;
int thread_id = (*pos - '0');
pj_timestamp recv_time;
pj_mutex_lock(rt_test_data[thread_id].mutex);
/* Stop timer. */
pjsip_endpt_cancel_timer(endpt, &rt_test_data[thread_id].timeout_timer);
/* Update counter and end-time. */
rt_test_data[thread_id].recv_response_count++;
pj_get_timestamp(&recv_time);
pj_sub_timestamp(&recv_time, &rt_test_data[thread_id].send_time);
pj_add_timestamp(&rt_test_data[thread_id].total_rt_time, &recv_time);
if (!rt_stop) {
pj_time_val tx_delay = { 0, 0 };
pj_assert(rt_test_data[thread_id].tx_timer.user_data == NULL);
rt_test_data[thread_id].tx_timer.user_data = (void*)1;
pjsip_endpt_schedule_timer(endpt, &rt_test_data[thread_id].tx_timer,
&tx_delay);
}
pj_mutex_unlock(rt_test_data[thread_id].mutex);
return PJ_TRUE;
}
return PJ_FALSE;
}
示例4: PJ_DEF
PJ_DEF(pj_status_t) pjsip_regc_destroy(pjsip_regc *regc)
{
PJ_ASSERT_RETURN(regc, PJ_EINVAL);
pj_lock_acquire(regc->lock);
if (regc->has_tsx || pj_atomic_get(regc->busy_ctr) != 0) {
regc->_delete_flag = 1;
regc->cb = NULL;
pj_lock_release(regc->lock);
} else {
pjsip_tpselector_dec_ref(®c->tp_sel);
if (regc->last_transport) {
pjsip_transport_dec_ref(regc->last_transport);
regc->last_transport = NULL;
}
if (regc->timer.id != 0) {
pjsip_endpt_cancel_timer(regc->endpt, ®c->timer);
regc->timer.id = 0;
}
pj_atomic_destroy(regc->busy_ctr);
pj_lock_release(regc->lock);
pj_lock_destroy(regc->lock);
regc->lock = NULL;
pjsip_endpt_release_pool(regc->endpt, regc->pool);
}
return PJ_SUCCESS;
}
示例5: pjsip_regc_set_delay_before_refresh
pjsip_regc_set_delay_before_refresh( pjsip_regc *regc,
pj_uint32_t delay )
{
PJ_ASSERT_RETURN(regc, PJ_EINVAL);
if (delay > regc->expires)
return PJ_ETOOBIG;
pj_lock_acquire(regc->lock);
if (regc->delay_before_refresh != delay)
{
regc->delay_before_refresh = delay;
if (regc->timer.id != 0) {
/* Cancel registration timer */
pjsip_endpt_cancel_timer(regc->endpt, ®c->timer);
regc->timer.id = 0;
/* Schedule next registration */
schedule_registration(regc, regc->expires);
}
}
pj_lock_release(regc->lock);
return PJ_SUCCESS;
}
示例6: update_next_refresh
/* This will update the UAC's refresh schedule. */
static void update_next_refresh(pjsip_event_sub *sub, int interval)
{
pj_time_val delay = {0, 0};
pj_parsed_time pt;
if (interval < SECONDS_BEFORE_EXPIRY) {
PJ_LOG(4,(THIS_FILE,
"event_sub%p (%s): expiration delay too short (%d sec)! updated.",
sub, state[sub->state].ptr, interval));
interval = SECONDS_BEFORE_EXPIRY;
}
if (sub->timer.id != 0)
pjsip_endpt_cancel_timer(sub->endpt, &sub->timer);
sub->timer.id = TIMER_ID_REFRESH;
sub->timer.user_data = sub;
sub->timer.cb = &refresh_timer_cb;
pj_gettimeofday(&sub->expiry_time);
delay.sec = interval - SECONDS_BEFORE_EXPIRY;
sub->expiry_time.sec += delay.sec;
pj_time_decode(&sub->expiry_time, &pt);
PJ_LOG(4,(THIS_FILE,
"event_sub%p (%s): will send SUBSCRIBE at %02d:%02d:%02d (in %d secs)",
sub, state[sub->state].ptr,
pt.hour, pt.min, pt.sec,
delay.sec));
pjsip_endpt_schedule_timer( sub->endpt, &sub->timer, &delay );
}
示例7: tcp_destroy
/* Destroy TCP transport */
static pj_status_t tcp_destroy(pjsip_transport *transport,
pj_status_t reason)
{
struct tcp_transport *tcp = (struct tcp_transport*)transport;
if (tcp->close_reason == 0)
tcp->close_reason = reason;
if (tcp->is_registered) {
tcp->is_registered = PJ_FALSE;
pjsip_transport_destroy(transport);
/* pjsip_transport_destroy will recursively call this function
* again.
*/
return PJ_SUCCESS;
}
/* Mark transport as closing */
tcp->is_closing = PJ_TRUE;
/* Stop keep-alive timer. */
if (tcp->ka_timer.id) {
pjsip_endpt_cancel_timer(tcp->base.endpt, &tcp->ka_timer);
tcp->ka_timer.id = PJ_FALSE;
}
/* Cancel all delayed transmits */
while (!pj_list_empty(&tcp->delayed_list)) {
struct delayed_tdata *pending_tx;
pj_ioqueue_op_key_t *op_key;
pending_tx = tcp->delayed_list.next;
pj_list_erase(pending_tx);
op_key = (pj_ioqueue_op_key_t*)pending_tx->tdata_op_key;
on_data_sent(tcp->asock, op_key, -reason);
}
if (tcp->asock) {
pj_activesock_close(tcp->asock);
tcp->asock = NULL;
tcp->sock = PJ_INVALID_SOCKET;
} else if (tcp->sock != PJ_INVALID_SOCKET) {
pj_sock_close(tcp->sock);
tcp->sock = PJ_INVALID_SOCKET;
}
if (tcp->grp_lock) {
pj_grp_lock_t *grp_lock = tcp->grp_lock;
tcp->grp_lock = NULL;
pj_grp_lock_dec_ref(grp_lock);
/* Transport may have been deleted at this point */
} else {
tcp_on_destroy(tcp);
}
return PJ_SUCCESS;
}
示例8: PJ_DEF
PJ_DEF(pj_status_t) pjsip_regc_register(pjsip_regc *regc, pj_bool_t autoreg,
pjsip_tx_data **p_tdata)
{
pjsip_msg *msg;
pjsip_contact_hdr *hdr;
pj_status_t status;
pjsip_tx_data *tdata;
PJ_ASSERT_RETURN(regc && p_tdata, PJ_EINVAL);
pj_lock_acquire(regc->lock);
status = create_request(regc, &tdata);
if (status != PJ_SUCCESS) {
pj_lock_release(regc->lock);
return status;
}
msg = tdata->msg;
/* Add Contact headers. */
hdr = regc->contact_hdr_list.next;
while (hdr != ®c->contact_hdr_list) {
pjsip_msg_add_hdr(msg, (pjsip_hdr*)
pjsip_hdr_shallow_clone(tdata->pool, hdr));
hdr = hdr->next;
}
/* Also add bindings which are to be removed */
while (!pj_list_empty(®c->removed_contact_hdr_list)) {
hdr = regc->removed_contact_hdr_list.next;
pjsip_msg_add_hdr(msg, (pjsip_hdr*)
pjsip_hdr_clone(tdata->pool, hdr));
pj_list_erase(hdr);
}
if (regc->expires_hdr)
pjsip_msg_add_hdr(msg, (pjsip_hdr*)
pjsip_hdr_shallow_clone(tdata->pool,
regc->expires_hdr));
if (regc->timer.id != 0) {
pjsip_endpt_cancel_timer(regc->endpt, ®c->timer);
regc->timer.id = 0;
}
regc->auto_reg = autoreg;
pj_lock_release(regc->lock);
/* Done */
*p_tdata = tdata;
return PJ_SUCCESS;
}
示例9: rt_send_request
static pj_status_t rt_send_request(int thread_id)
{
pj_status_t status;
pj_str_t target, from, to, contact, call_id;
pjsip_tx_data *tdata;
pj_time_val timeout_delay;
pj_mutex_lock(rt_test_data[thread_id].mutex);
/* Create a request message. */
target = pj_str(rt_target_uri);
from = pj_str(FROM_HDR);
to = pj_str(rt_target_uri);
contact = pj_str(CONTACT_HDR);
call_id = rt_test_data[thread_id].call_id;
status = pjsip_endpt_create_request( endpt, &pjsip_options_method,
&target, &from, &to,
&contact, &call_id, -1,
NULL, &tdata );
if (status != PJ_SUCCESS) {
app_perror(" error: unable to create request", status);
pj_mutex_unlock(rt_test_data[thread_id].mutex);
return -610;
}
/* Start time. */
pj_get_timestamp(&rt_test_data[thread_id].send_time);
/* Send the message (statelessly). */
status = pjsip_endpt_send_request_stateless( endpt, tdata, NULL, NULL);
if (status != PJ_SUCCESS) {
/* Immediate error! */
app_perror(" error: send request", status);
pjsip_tx_data_dec_ref(tdata);
pj_mutex_unlock(rt_test_data[thread_id].mutex);
return -620;
}
/* Update counter. */
rt_test_data[thread_id].sent_request_count++;
/* Set timeout timer. */
if (rt_test_data[thread_id].timeout_timer.user_data != NULL) {
pjsip_endpt_cancel_timer(endpt, &rt_test_data[thread_id].timeout_timer);
}
timeout_delay.sec = 100; timeout_delay.msec = 0;
rt_test_data[thread_id].timeout_timer.user_data = (void*)1;
pjsip_endpt_schedule_timer(endpt, &rt_test_data[thread_id].timeout_timer,
&timeout_delay);
pj_mutex_unlock(rt_test_data[thread_id].mutex);
return PJ_SUCCESS;
}
示例10: pjsip_endpt_cancel_timer
/// Restart the timer using the specified id and timeout.
void Flow::restart_timer(int id, int timeout)
{
if (_timer.id)
{
// Stop the existing timer.
pjsip_endpt_cancel_timer(stack_data.endpt, &_timer);
_timer.id = 0;
}
pj_time_val delay = {timeout, 0};
pjsip_endpt_schedule_timer(stack_data.endpt, &_timer, &delay);
_timer.id = id;
}
示例11: PJ_DEF
/*
* Destroy subscription.
* If there are pending transactions, then this will just set the flag.
*/
PJ_DEF(pj_status_t) pjsip_event_sub_destroy(pjsip_event_sub *sub)
{
pj_assert(sub != NULL);
if (sub == NULL)
return -1;
/* Application must terminate the subscription first. */
pj_assert(sub->state == PJSIP_EVENT_SUB_STATE_NULL ||
sub->state == PJSIP_EVENT_SUB_STATE_TERMINATED);
PJ_LOG(4,(THIS_FILE, "event_sub%p (%s): about to be destroyed",
sub, state[sub->state].ptr));
pj_mutex_lock(mgr.mutex);
pj_mutex_lock(sub->mutex);
/* Set delete flag. */
sub->delete_flag = 1;
/* Unregister timer, if any. */
if (sub->timer.id != 0) {
pjsip_endpt_cancel_timer(sub->endpt, &sub->timer);
sub->timer.id = 0;
}
if (sub->pending_tsx > 0) {
pj_mutex_unlock(sub->mutex);
pj_mutex_unlock(mgr.mutex);
PJ_LOG(4,(THIS_FILE, "event_sub%p (%s): has %d pending, will destroy later",
sub, state[sub->state].ptr,
sub->pending_tsx));
return 1;
}
/* Unregister from hash table. */
pj_hash_set(sub->pool, mgr.ht, sub->key.ptr, sub->key.slen, NULL);
/* Destroy. */
pj_mutex_destroy(sub->mutex);
pjsip_endpt_destroy_pool(sub->endpt, sub->pool);
pj_mutex_unlock(mgr.mutex);
PJ_LOG(4,(THIS_FILE, "event_sub%p: destroyed", sub));
return 0;
}
示例12: PJ_DEF
PJ_DEF(pj_status_t) pjsip_publishc_destroy(pjsip_publishc *pubc)
{
PJ_ASSERT_RETURN(pubc, PJ_EINVAL);
if (pubc->pending_tsx || pubc->in_callback) {
pubc->_delete_flag = 1;
pubc->cb = NULL;
} else {
/* Cancel existing timer, if any */
if (pubc->timer.id != 0) {
pjsip_endpt_cancel_timer(pubc->endpt, &pubc->timer);
pubc->timer.id = 0;
}
if (pubc->mutex)
pj_mutex_destroy(pubc->mutex);
pjsip_endpt_release_pool(pubc->endpt, pubc->pool);
}
return PJ_SUCCESS;
}
示例13: pjsua_pres_shutdown
/*
* Shutdown presence.
*/
void pjsua_pres_shutdown(void)
{
unsigned i;
if (pjsua_var.pres_timer.id != 0) {
pjsip_endpt_cancel_timer(pjsua_var.endpt, &pjsua_var.pres_timer);
pjsua_var.pres_timer.id = PJ_FALSE;
}
for (i=0; i<PJ_ARRAY_SIZE(pjsua_var.acc); ++i) {
if (!pjsua_var.acc[i].valid)
continue;
pjsua_pres_delete_acc(i);
}
for (i=0; i<PJ_ARRAY_SIZE(pjsua_var.buddy); ++i) {
pjsua_var.buddy[i].monitor = 0;
}
pjsua_pres_refresh();
}
示例14: sub_schedule_uas_expire
/* Schedule notifier expiration. */
static void sub_schedule_uas_expire( pjsip_event_sub *sub, int sec_delay)
{
pj_time_val delay = { 0, 0 };
pj_parsed_time pt;
if (sub->timer.id != 0)
pjsip_endpt_cancel_timer(sub->endpt, &sub->timer);
pj_gettimeofday(&sub->expiry_time);
sub->expiry_time.sec += sec_delay;
sub->timer.id = TIMER_ID_UAS_EXPIRY;
sub->timer.user_data = sub;
sub->timer.cb = &uas_expire_timer_cb;
delay.sec = sec_delay;
pjsip_endpt_schedule_timer( sub->endpt, &sub->timer, &delay);
pj_time_decode(&sub->expiry_time, &pt);
PJ_LOG(4,(THIS_FILE,
"event_sub%p (%s)(UAS): will expire at %02d:%02d:%02d (in %d secs)",
sub, state[sub->state].ptr, pt.hour, pt.min, pt.sec, sec_delay));
}
示例15: pjsip_transport_remove_state_listener
Flow::~Flow()
{
if (PJSIP_TRANSPORT_IS_RELIABLE(_transport))
{
// Remove the state listener to ensure it doesn't get called after the
// flow is destroyed.
pjsip_transport_remove_state_listener(_transport,
_tp_state_listener_key,
this);
// We incremented the ref count when we put it in the map.
pjsip_transport_dec_ref(_transport);
}
if (_timer.id)
{
// Stop the keepalive timer.
pjsip_endpt_cancel_timer(stack_data.endpt, &_timer);
_timer.id = 0;
}
pthread_mutex_destroy(&_flow_lock);
}