2006-12-21 06:30:28 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Sofia-SIP package
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Nokia Corporation.
|
|
|
|
*
|
|
|
|
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2.1 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**@CFILE test_nua_basic_call.c
|
|
|
|
* @brief Test basic call.
|
|
|
|
*
|
|
|
|
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
|
|
|
* @author Martti Mela <Martti Mela@nokia.com>
|
|
|
|
*
|
|
|
|
* @date Created: Wed Aug 17 12:12:12 EEST 2005 ppessi
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "test_nua.h"
|
|
|
|
#include <sofia-sip/su_tag_class.h>
|
|
|
|
|
|
|
|
#if HAVE_FUNC
|
|
|
|
#elif HAVE_FUNCTION
|
|
|
|
#define __func__ __FUNCTION__
|
|
|
|
#else
|
|
|
|
#define __func__ "test_basic_call"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* ======================================================================== */
|
|
|
|
|
|
|
|
int until_terminated(CONDITION_PARAMS)
|
|
|
|
{
|
|
|
|
if (!check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
save_event_in_list(ctx, event, ep, call);
|
|
|
|
|
|
|
|
return event == nua_i_state && callstate(tags) == nua_callstate_terminated;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
X accept_call ep
|
|
|
|
| |
|
|
|
|
|-------INVITE------>|
|
|
|
|
|<----100 Trying-----|
|
|
|
|
| |
|
|
|
|
|<----180 Ringing----|
|
|
|
|
| |
|
|
|
|
|<--------200--------|
|
|
|
|
|---------ACK------->|
|
|
|
|
*/
|
|
|
|
int accept_call(CONDITION_PARAMS)
|
|
|
|
{
|
|
|
|
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
save_event_in_list(ctx, event, ep, call);
|
|
|
|
|
|
|
|
switch (callstate(tags)) {
|
|
|
|
case nua_callstate_received:
|
|
|
|
RESPOND(ep, call, nh, SIP_180_RINGING,
|
|
|
|
TAG_END());
|
|
|
|
return 0;
|
|
|
|
case nua_callstate_early:
|
|
|
|
RESPOND(ep, call, nh, SIP_200_OK,
|
|
|
|
TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
|
|
|
|
TAG_END());
|
|
|
|
return 0;
|
|
|
|
case nua_callstate_ready:
|
|
|
|
return 1;
|
|
|
|
case nua_callstate_terminated:
|
|
|
|
if (call)
|
|
|
|
nua_handle_destroy(call->nh), call->nh = NULL;
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
X accept_call ep
|
|
|
|
| |
|
|
|
|
|-------INVITE------>|
|
|
|
|
|<----100 Trying-----|
|
|
|
|
| |
|
|
|
|
|<----180 Ringing----|
|
|
|
|
| |
|
|
|
|
|<--------200--------|
|
|
|
|
|---------ACK------->|
|
|
|
|
*/
|
|
|
|
int accept_call_with_early_sdp(CONDITION_PARAMS)
|
|
|
|
{
|
|
|
|
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
save_event_in_list(ctx, event, ep, call);
|
|
|
|
|
|
|
|
switch (callstate(tags)) {
|
|
|
|
case nua_callstate_received:
|
|
|
|
RESPOND(ep, call, nh, SIP_180_RINGING,
|
|
|
|
TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
|
2007-04-15 02:03:41 +00:00
|
|
|
NUTAG_M_DISPLAY("Bob"),
|
|
|
|
NUTAG_M_USERNAME("b+b"),
|
2006-12-21 06:30:28 +00:00
|
|
|
TAG_END());
|
|
|
|
return 0;
|
|
|
|
case nua_callstate_early:
|
|
|
|
RESPOND(ep, call, nh, SIP_200_OK,
|
|
|
|
TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
|
|
|
|
TAG_END());
|
|
|
|
return 0;
|
|
|
|
case nua_callstate_ready:
|
|
|
|
return 1;
|
|
|
|
case nua_callstate_terminated:
|
|
|
|
if (call)
|
|
|
|
nua_handle_destroy(call->nh), call->nh = NULL;
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
X INVITE
|
|
|
|
| |
|
|
|
|
|-------INVITE------>|
|
|
|
|
|<--------200--------|
|
|
|
|
|---------ACK------->|
|
|
|
|
*/
|
|
|
|
int until_ready(CONDITION_PARAMS)
|
|
|
|
{
|
|
|
|
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
save_event_in_list(ctx, event, ep, call);
|
|
|
|
|
|
|
|
switch (callstate(tags)) {
|
|
|
|
case nua_callstate_ready:
|
|
|
|
return 1;
|
|
|
|
case nua_callstate_terminated:
|
|
|
|
if (call)
|
|
|
|
nua_handle_destroy(call->nh), call->nh = NULL;
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ======================================================================== */
|
|
|
|
|
|
|
|
/* Basic call:
|
|
|
|
|
|
|
|
A B
|
|
|
|
|-------INVITE------>|
|
|
|
|
|<----100 Trying-----|
|
|
|
|
| |
|
|
|
|
|<----180 Ringing----|
|
|
|
|
| |
|
|
|
|
|<------200 OK-------|
|
|
|
|
|--------ACK-------->|
|
|
|
|
| |
|
|
|
|
|<-------BYE---------|
|
|
|
|
|-------200 OK------>|
|
|
|
|
| |
|
|
|
|
|
|
|
|
Client transitions:
|
|
|
|
INIT -(C1)-> CALLING -(C2a)-> PROCEEDING -(C3+C4)-> READY
|
|
|
|
Server transitions:
|
|
|
|
INIT -(S1)-> RECEIVED -(S2a)-> EARLY -(S3b)-> COMPLETED -(S4)-> READY
|
|
|
|
|
|
|
|
B sends BYE:
|
|
|
|
READY -(T2)-> TERMINATING -(T3)-> TERMINATED
|
|
|
|
A receives BYE:
|
|
|
|
READY -(T1)-> TERMINATED
|
|
|
|
|
|
|
|
See @page nua_call_model in nua.docs for more information
|
|
|
|
*/
|
|
|
|
|
|
|
|
int test_basic_call_1(struct context *ctx)
|
|
|
|
{
|
|
|
|
BEGIN();
|
|
|
|
|
|
|
|
struct endpoint *a = &ctx->a, *b = &ctx->b;
|
|
|
|
struct call *a_call = a->call, *b_call = b->call;
|
|
|
|
struct event *e;
|
|
|
|
sip_t *sip;
|
|
|
|
sip_replaces_t *repa, *repb;
|
|
|
|
nua_handle_t *nh;
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
static int once = 0;
|
|
|
|
sip_time_t se, min_se;
|
|
|
|
|
2006-12-21 06:30:28 +00:00
|
|
|
if (print_headings)
|
|
|
|
printf("TEST NUA-3.1: Basic call\n");
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
/* Disable session timer from proxy */
|
|
|
|
test_proxy_get_session_timer(ctx->p, &se, &min_se);
|
|
|
|
test_proxy_set_session_timer(ctx->p, 0, 0);
|
|
|
|
|
2006-12-21 06:30:28 +00:00
|
|
|
a_call->sdp = "m=audio 5008 RTP/AVP 8";
|
|
|
|
b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
|
|
|
|
|
|
|
|
TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_has_active_call(a_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
|
|
|
|
|
|
|
|
INVITE(a, a_call, a_call->nh,
|
|
|
|
TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
|
|
|
|
SOATAG_USER_SDP_STR(a_call->sdp),
|
2007-04-15 02:03:41 +00:00
|
|
|
NUTAG_M_USERNAME("a+a"),
|
|
|
|
NUTAG_M_DISPLAY("Alice"),
|
2006-12-21 06:30:28 +00:00
|
|
|
TAG_END());
|
|
|
|
|
|
|
|
run_ab_until(ctx, -1, until_ready, -1, accept_call_with_early_sdp);
|
|
|
|
|
|
|
|
TEST_1(nua_handle_has_active_call(a_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
|
|
|
|
|
|
|
|
TEST_1(nua_handle_has_active_call(b_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
|
|
|
|
|
|
|
|
TEST_1(repa = nua_handle_make_replaces(a_call->nh, nua_handle_home(a_call->nh), 0));
|
|
|
|
TEST_1(repb = nua_handle_make_replaces(b_call->nh, nua_handle_home(b_call->nh), 0));
|
|
|
|
|
|
|
|
TEST_S(repa->rp_call_id, repb->rp_call_id);
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_by_replaces(a->nua, repa));
|
|
|
|
TEST_1(!nua_handle_by_replaces(b->nua, repb));
|
|
|
|
|
|
|
|
TEST_1(nh = nua_handle_by_replaces(a->nua, repb));
|
|
|
|
TEST_P(nh, a_call->nh);
|
|
|
|
nua_handle_unref(nh);
|
|
|
|
|
|
|
|
TEST_1(nh = nua_handle_by_replaces(b->nua, repa));
|
|
|
|
TEST_P(nh, b_call->nh);
|
|
|
|
nua_handle_unref(nh);
|
|
|
|
|
|
|
|
/* Client transitions:
|
|
|
|
INIT -(C1)-> CALLING: nua_invite(), nua_i_state
|
|
|
|
CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state
|
|
|
|
PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
|
|
|
|
TEST_1(is_offer_sent(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
|
|
|
|
TEST(e->data->e_status, 180);
|
|
|
|
TEST_1(sip = sip_object(e->data->e_msg));
|
|
|
|
TEST_S(sip->sip_call_id->i_id, repb->rp_call_id);
|
|
|
|
TEST_S(sip->sip_from->a_tag, repb->rp_to_tag);
|
|
|
|
TEST_S(sip->sip_to->a_tag, repb->rp_from_tag);
|
|
|
|
TEST_1(sip->sip_payload);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
|
|
|
|
TEST_1(is_answer_recv(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
|
|
|
|
TEST(e->data->e_status, 200);
|
2007-02-17 06:25:21 +00:00
|
|
|
TEST_1(sip = sip_object(e->data->e_msg));
|
2007-04-15 02:03:41 +00:00
|
|
|
TEST_1(sip->sip_payload);
|
|
|
|
TEST_1(sip->sip_contact);
|
|
|
|
TEST_S(sip->sip_contact->m_display, "Bob");
|
|
|
|
TEST_S(sip->sip_contact->m_url->url_user, "b+b");
|
|
|
|
if (!once) {
|
|
|
|
/* The session expiration is not used by default. */
|
|
|
|
TEST_1(sip->sip_session_expires == NULL);
|
|
|
|
}
|
2006-12-21 06:30:28 +00:00
|
|
|
/* Test that B uses application-specific contact */
|
|
|
|
if (ctx->proxy_tests)
|
|
|
|
TEST_1(sip->sip_contact->m_url->url_user);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, a->events);
|
|
|
|
|
|
|
|
/*
|
|
|
|
Server transitions:
|
|
|
|
INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
|
|
|
|
RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
|
|
|
|
EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
|
|
|
|
COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
|
|
|
|
TEST(e->data->e_status, 100);
|
2007-04-15 02:03:41 +00:00
|
|
|
TEST_1(sip = sip_object(e->data->e_msg));
|
|
|
|
TEST_1(sip->sip_contact);
|
|
|
|
TEST_S(sip->sip_contact->m_display, "Alice");
|
|
|
|
TEST_S(sip->sip_contact->m_url->url_user, "a+a");
|
|
|
|
if (!once++) {
|
|
|
|
/* The Session-Expires header is not used by default. */
|
|
|
|
TEST_1(sip->sip_session_expires == NULL);
|
|
|
|
}
|
2006-12-21 06:30:28 +00:00
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
|
|
|
|
TEST_1(is_offer_recv(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
|
|
|
|
TEST_1(is_answer_sent(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
|
|
|
|
TEST_1(is_answer_sent(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
|
|
|
|
TEST_1(sip = sip_object(e->data->e_msg));
|
|
|
|
TEST_S(sip->sip_call_id->i_id, repa->rp_call_id);
|
|
|
|
TEST_S(sip->sip_from->a_tag, repa->rp_from_tag);
|
|
|
|
TEST_S(sip->sip_to->a_tag, repa->rp_to_tag);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, b->events);
|
|
|
|
|
|
|
|
BYE(b, b_call, b_call->nh, TAG_END());
|
|
|
|
run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
|
|
|
|
|
|
|
|
/* B transitions:
|
|
|
|
READY --(T2)--> TERMINATING: nua_bye()
|
|
|
|
TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_bye);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, b->events);
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_has_active_call(b_call->nh));
|
|
|
|
|
|
|
|
/* A transitions:
|
|
|
|
READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_bye);
|
|
|
|
TEST(e->data->e_status, 200);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, a->events);
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_has_active_call(a_call->nh));
|
|
|
|
|
|
|
|
nua_handle_destroy(a_call->nh), a_call->nh = NULL;
|
|
|
|
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
test_proxy_set_session_timer(ctx->p, se, min_se);
|
|
|
|
|
2006-12-21 06:30:28 +00:00
|
|
|
if (print_headings)
|
|
|
|
printf("TEST NUA-3.1: PASSED\n");
|
|
|
|
|
|
|
|
END();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
accept_early_answer
|
|
|
|
X ep
|
|
|
|
| |
|
|
|
|
|-------INVITE------>|
|
|
|
|
|<----100 Trying-----|
|
|
|
|
| |
|
|
|
|
|<----180 Ringing----|
|
|
|
|
| |
|
|
|
|
|<--------200--------|
|
|
|
|
|---------ACK------->|
|
|
|
|
*/
|
|
|
|
int accept_early_answer(CONDITION_PARAMS)
|
|
|
|
{
|
|
|
|
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
save_event_in_list(ctx, event, ep, call);
|
|
|
|
|
|
|
|
switch (callstate(tags)) {
|
|
|
|
case nua_callstate_received:
|
|
|
|
RESPOND(ep, call, nh, SIP_180_RINGING,
|
|
|
|
NUTAG_EARLY_ANSWER(1),
|
|
|
|
TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
|
|
|
|
TAG_END());
|
|
|
|
return 0;
|
|
|
|
case nua_callstate_early:
|
|
|
|
RESPOND(ep, call, nh, SIP_200_OK,
|
|
|
|
TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
|
|
|
|
TAG_END());
|
|
|
|
return 0;
|
|
|
|
case nua_callstate_ready:
|
|
|
|
return 1;
|
|
|
|
case nua_callstate_terminated:
|
|
|
|
if (call)
|
|
|
|
nua_handle_destroy(call->nh), call->nh = NULL;
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int test_basic_call_2(struct context *ctx)
|
|
|
|
{
|
|
|
|
BEGIN();
|
|
|
|
|
|
|
|
struct endpoint *a = &ctx->a, *b = &ctx->b;
|
|
|
|
struct call *a_call = a->call, *b_call = b->call;
|
|
|
|
struct event *e;
|
|
|
|
sip_t const *sip;
|
|
|
|
|
|
|
|
if (print_headings)
|
|
|
|
printf("TEST NUA-3.2: Basic call with SDP in 180\n");
|
|
|
|
|
|
|
|
a_call->sdp = "m=audio 5008 RTP/AVP 8";
|
|
|
|
b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
|
|
|
|
|
|
|
|
TEST_1(a_call->nh = nua_handle(a->nua, a_call,
|
|
|
|
SIPTAG_TO_STR("<sip:b@x.org>"),
|
|
|
|
TAG_END()));
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_has_active_call(a_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
|
|
|
|
|
|
|
|
INVITE(a, a_call, a_call->nh,
|
|
|
|
NUTAG_URL(b->contact->m_url),
|
|
|
|
SOATAG_USER_SDP_STR(a_call->sdp),
|
2007-04-15 02:03:41 +00:00
|
|
|
NUTAG_ALLOW("INFO"),
|
2006-12-21 06:30:28 +00:00
|
|
|
TAG_END());
|
|
|
|
|
|
|
|
run_ab_until(ctx, -1, until_ready, -1, accept_early_answer);
|
|
|
|
|
|
|
|
/* Client transitions:
|
|
|
|
INIT -(C1)-> CALLING: nua_invite(), nua_i_state
|
|
|
|
CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state
|
|
|
|
PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
|
|
|
|
TEST_1(is_offer_sent(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
|
|
|
|
TEST(e->data->e_status, 180);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
|
|
|
|
TEST_1(is_answer_recv(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
|
|
|
|
TEST(e->data->e_status, 200);
|
|
|
|
TEST_1(sip = sip_object(e->data->e_msg));
|
|
|
|
TEST_1(sip->sip_content_type);
|
|
|
|
TEST_S(sip->sip_content_type->c_type, "application/sdp");
|
|
|
|
TEST_1(sip->sip_payload); /* there is sdp in 200 OK */
|
|
|
|
TEST_1(sip->sip_contact);
|
|
|
|
/* Test that B does not use application-specific contact */
|
|
|
|
TEST_1(!sip->sip_contact->m_url->url_user);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
|
|
|
|
TEST_1(!is_answer_recv(e->data->e_tags)); /* but it is ignored */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, a->events);
|
|
|
|
|
|
|
|
TEST_1(nua_handle_has_active_call(a_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
|
|
|
|
|
|
|
|
/*
|
|
|
|
Server transitions:
|
|
|
|
INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
|
|
|
|
RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
|
|
|
|
EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
|
|
|
|
COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
|
|
|
|
TEST(e->data->e_status, 100);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
|
|
|
|
TEST_1(is_offer_recv(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
|
|
|
|
TEST_1(is_answer_sent(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
|
|
|
|
TEST_1(is_answer_sent(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, b->events);
|
|
|
|
|
|
|
|
TEST_1(nua_handle_has_active_call(b_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
/* Send a NOTIFY from B to A */
|
|
|
|
if (print_headings)
|
|
|
|
printf("TEST NUA-3.2.2: send a NOTIFY within a dialog\n");
|
|
|
|
|
|
|
|
/* Make A to accept NOTIFY */
|
|
|
|
nua_set_params(a->nua, NUTAG_APPL_METHOD("NOTIFY"), TAG_END());
|
|
|
|
run_a_until(ctx, nua_r_set_params, until_final_response);
|
|
|
|
|
|
|
|
NOTIFY(b, b_call, b_call->nh,
|
|
|
|
NUTAG_NEWSUB(1),
|
|
|
|
SIPTAG_SUBJECT_STR("NUA-3.2.2"),
|
|
|
|
SIPTAG_EVENT_STR("message-summary"),
|
|
|
|
SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
|
|
|
|
SIPTAG_PAYLOAD_STR("Messages-Waiting: no"),
|
|
|
|
TAG_END());
|
|
|
|
|
|
|
|
run_ab_until(ctx, -1, accept_notify, -1, save_until_final_response);
|
|
|
|
|
|
|
|
/* Notifier events: nua_r_notify */
|
|
|
|
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_notify);
|
|
|
|
TEST(e->data->e_status, 200);
|
|
|
|
TEST_1(tl_find(e->data->e_tags, nutag_substate));
|
|
|
|
TEST(tl_find(e->data->e_tags, nutag_substate)->t_value,
|
|
|
|
nua_substate_terminated);
|
|
|
|
|
|
|
|
/* watcher events: nua_i_notify */
|
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_notify);
|
|
|
|
TEST_1(sip = sip_object(e->data->e_msg));
|
|
|
|
TEST_1(sip->sip_subscription_state);
|
|
|
|
TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
|
|
|
|
TEST_1(tl_find(e->data->e_tags, nutag_substate));
|
|
|
|
TEST(tl_find(e->data->e_tags, nutag_substate)->t_value,
|
|
|
|
nua_substate_terminated);
|
|
|
|
TEST_1(!e->next);
|
|
|
|
|
|
|
|
free_events_in_list(ctx, a->events);
|
|
|
|
free_events_in_list(ctx, b->events);
|
|
|
|
|
|
|
|
if (print_headings)
|
|
|
|
printf("TEST NUA-3.2.2: PASSED\n");
|
|
|
|
|
|
|
|
INFO(b, b_call, b_call->nh, TAG_END());
|
2006-12-21 06:30:28 +00:00
|
|
|
BYE(b, b_call, b_call->nh, TAG_END());
|
2007-04-15 02:03:41 +00:00
|
|
|
INFO(b, b_call, b_call->nh, TAG_END());
|
|
|
|
|
2006-12-21 06:30:28 +00:00
|
|
|
run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
while (!b->events->head || /* r_info */
|
|
|
|
!b->events->head->next || /* r_bye */
|
|
|
|
!b->events->head->next->next || /* i_state */
|
|
|
|
!b->events->head->next->next->next) /* r_info */
|
|
|
|
run_ab_until(ctx, -1, save_events, -1, save_until_final_response);
|
|
|
|
|
2006-12-21 06:30:28 +00:00
|
|
|
/* B transitions:
|
2007-04-15 02:03:41 +00:00
|
|
|
nua_info()
|
2006-12-21 06:30:28 +00:00
|
|
|
READY --(T2)--> TERMINATING: nua_bye()
|
2007-04-15 02:03:41 +00:00
|
|
|
nua_r_info with 200
|
2006-12-21 06:30:28 +00:00
|
|
|
TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
|
2007-04-15 02:03:41 +00:00
|
|
|
nua_r_info with 481/900
|
2006-12-21 06:30:28 +00:00
|
|
|
*/
|
2007-04-15 02:03:41 +00:00
|
|
|
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_info);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
|
2006-12-21 06:30:28 +00:00
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
|
2007-04-15 02:03:41 +00:00
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_info);
|
|
|
|
TEST_1(e->data->e_status >= 900 || e->data->e_status == 481);
|
2006-12-21 06:30:28 +00:00
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, b->events);
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_has_active_call(b_call->nh));
|
|
|
|
|
|
|
|
/* A transitions:
|
2007-04-15 02:03:41 +00:00
|
|
|
nua_i_info
|
2006-12-21 06:30:28 +00:00
|
|
|
READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
|
|
|
|
*/
|
2007-04-15 02:03:41 +00:00
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_info);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_bye);
|
2006-12-21 06:30:28 +00:00
|
|
|
TEST(e->data->e_status, 200);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, a->events);
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
BYE(a, a_call, a_call->nh, TAG_END());
|
|
|
|
run_a_until(ctx, -1, save_until_final_response);
|
|
|
|
|
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_bye);
|
|
|
|
TEST_1(e->data->e_status >= 900);
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, a->events);
|
2006-12-21 06:30:28 +00:00
|
|
|
|
|
|
|
nua_handle_destroy(a_call->nh), a_call->nh = NULL;
|
|
|
|
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
|
|
|
|
|
|
|
|
if (print_headings)
|
|
|
|
printf("TEST NUA-3.2: PASSED\n");
|
|
|
|
|
|
|
|
END();
|
|
|
|
}
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
/* ====================================================================== */
|
|
|
|
|
|
|
|
/* Basic calls with soa disabled */
|
|
|
|
|
|
|
|
int accept_call_no_media(CONDITION_PARAMS)
|
|
|
|
{
|
|
|
|
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
save_event_in_list(ctx, event, ep, call);
|
|
|
|
|
|
|
|
switch (callstate(tags)) {
|
|
|
|
case nua_callstate_received:
|
|
|
|
RESPOND(ep, call, nh, SIP_180_RINGING,
|
|
|
|
NUTAG_MEDIA_ENABLE(0),
|
|
|
|
TAG_END());
|
|
|
|
return 0;
|
|
|
|
case nua_callstate_early:
|
|
|
|
RESPOND(ep, call, nh, SIP_200_OK,
|
|
|
|
TAG_IF(call->sdp, SIPTAG_CONTENT_TYPE_STR("application/sdp")),
|
|
|
|
TAG_IF(call->sdp, SIPTAG_PAYLOAD_STR(call->sdp)),
|
|
|
|
TAG_END());
|
|
|
|
return 0;
|
|
|
|
case nua_callstate_ready:
|
|
|
|
return 1;
|
|
|
|
case nua_callstate_terminated:
|
|
|
|
if (call)
|
|
|
|
nua_handle_destroy(call->nh), call->nh = NULL;
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int test_basic_call_3(struct context *ctx)
|
|
|
|
{
|
|
|
|
BEGIN();
|
|
|
|
|
|
|
|
struct endpoint *a = &ctx->a, *b = &ctx->b;
|
|
|
|
struct call *a_call = a->call, *b_call = b->call;
|
|
|
|
struct event *e;
|
|
|
|
sip_t const *sip;
|
|
|
|
|
|
|
|
if (print_headings)
|
|
|
|
printf("TEST NUA-3.3: Basic call with media disabled\n");
|
|
|
|
|
|
|
|
a_call->sdp = "v=0\r\n"
|
|
|
|
"o=- 1 1 IN IP4 127.0.0.1\r\n"
|
|
|
|
"s=-\r\n"
|
|
|
|
"c=IN IP4 127.0.0.1\r\n"
|
|
|
|
"t=0 0\r\n"
|
|
|
|
"m=audio 5008 RTP/AVP 8\r\n";
|
|
|
|
|
|
|
|
b_call->sdp =
|
|
|
|
"v=0\r\n"
|
|
|
|
"o=- 2 1 IN IP4 127.0.0.1\r\n"
|
|
|
|
"s=-\r\n"
|
|
|
|
"c=IN IP4 127.0.0.1\r\n"
|
|
|
|
"t=0 0\r\n"
|
|
|
|
"m=audio 5010 RTP/AVP 0 8\r\n";
|
|
|
|
|
|
|
|
TEST_1(a_call->nh = nua_handle(a->nua, a_call,
|
|
|
|
SIPTAG_TO_STR("<sip:b@x.org>"),
|
|
|
|
TAG_END()));
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_has_active_call(a_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
|
|
|
|
|
|
|
|
INVITE(a, a_call, a_call->nh,
|
|
|
|
NUTAG_MEDIA_ENABLE(0),
|
|
|
|
NUTAG_URL(b->contact->m_url),
|
|
|
|
SIPTAG_CONTENT_TYPE_STR("application/sdp"),
|
|
|
|
SIPTAG_PAYLOAD_STR(a_call->sdp),
|
|
|
|
TAG_END());
|
|
|
|
|
|
|
|
run_ab_until(ctx, -1, until_ready, -1, accept_call_no_media);
|
|
|
|
|
|
|
|
/* Client transitions:
|
|
|
|
INIT -(C1)-> CALLING: nua_invite(), nua_i_state
|
|
|
|
CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state
|
|
|
|
PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
|
|
|
|
TEST_1(is_offer_sent(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
|
|
|
|
TEST(e->data->e_status, 180);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
|
|
|
|
TEST_1(!is_answer_recv(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
|
|
|
|
TEST(e->data->e_status, 200);
|
|
|
|
TEST_1(sip = sip_object(e->data->e_msg));
|
|
|
|
TEST_1(sip->sip_content_type);
|
|
|
|
TEST_S(sip->sip_content_type->c_type, "application/sdp");
|
|
|
|
TEST_1(sip->sip_payload); /* there is sdp in 200 OK */
|
|
|
|
TEST_1(sip->sip_contact);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
|
|
|
|
TEST_1(is_answer_recv(e->data->e_tags));
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, a->events);
|
|
|
|
|
|
|
|
TEST_1(nua_handle_has_active_call(a_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
|
|
|
|
|
|
|
|
/*
|
|
|
|
Server transitions:
|
|
|
|
INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
|
|
|
|
RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
|
|
|
|
EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
|
|
|
|
COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
|
|
|
|
TEST(e->data->e_status, 100);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
|
|
|
|
TEST_1(is_offer_recv(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
|
|
|
|
TEST_1(!is_answer_sent(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
|
|
|
|
TEST_1(is_answer_sent(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, b->events);
|
|
|
|
|
|
|
|
TEST_1(nua_handle_has_active_call(b_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
|
|
|
|
|
|
|
|
BYE(b, b_call, b_call->nh, TAG_END());
|
|
|
|
|
|
|
|
run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
|
|
|
|
|
|
|
|
/* B transitions:
|
|
|
|
READY --(T2)--> TERMINATING: nua_bye()
|
|
|
|
TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_bye);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, b->events);
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_has_active_call(b_call->nh));
|
|
|
|
|
|
|
|
/* A transitions:
|
|
|
|
nua_i_info
|
|
|
|
READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_bye);
|
|
|
|
TEST(e->data->e_status, 200);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, a->events);
|
|
|
|
|
|
|
|
nua_handle_destroy(a_call->nh), a_call->nh = NULL;
|
|
|
|
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
|
|
|
|
|
|
|
|
if (print_headings)
|
|
|
|
printf("TEST NUA-3.3: PASSED\n");
|
|
|
|
|
|
|
|
END();
|
|
|
|
}
|
|
|
|
|
|
|
|
int ack_when_completing_no_media(CONDITION_PARAMS)
|
|
|
|
{
|
|
|
|
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
save_event_in_list(ctx, event, ep, call);
|
|
|
|
|
|
|
|
switch (callstate(tags)) {
|
|
|
|
case nua_callstate_completing:
|
|
|
|
ACK(ep, call, nh,
|
|
|
|
TAG_IF(call->sdp, SIPTAG_CONTENT_TYPE_STR("application/sdp")),
|
|
|
|
TAG_IF(call->sdp, SIPTAG_PAYLOAD_STR(call->sdp)),
|
|
|
|
TAG_END());
|
|
|
|
return 0;
|
|
|
|
case nua_callstate_ready:
|
|
|
|
return 1;
|
|
|
|
case nua_callstate_terminated:
|
|
|
|
if (call)
|
|
|
|
nua_handle_destroy(call->nh), call->nh = NULL;
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int accept_call_no_media2(CONDITION_PARAMS)
|
|
|
|
{
|
|
|
|
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
save_event_in_list(ctx, event, ep, call);
|
|
|
|
|
|
|
|
switch (callstate(tags)) {
|
|
|
|
case nua_callstate_received:
|
|
|
|
RESPOND(ep, call, nh, SIP_180_RINGING,
|
|
|
|
NUTAG_MEDIA_ENABLE(0),
|
|
|
|
TAG_IF(call->sdp, SIPTAG_CONTENT_TYPE_STR("application/sdp")),
|
|
|
|
TAG_IF(call->sdp, SIPTAG_PAYLOAD_STR(call->sdp)),
|
|
|
|
TAG_END());
|
|
|
|
return 0;
|
|
|
|
case nua_callstate_early:
|
|
|
|
RESPOND(ep, call, nh, SIP_200_OK,
|
|
|
|
TAG_IF(call->sdp, SIPTAG_CONTENT_TYPE_STR("application/sdp")),
|
|
|
|
TAG_IF(call->sdp, SIPTAG_PAYLOAD_STR(call->sdp)),
|
|
|
|
TAG_END());
|
|
|
|
return 0;
|
|
|
|
case nua_callstate_ready:
|
|
|
|
return 1;
|
|
|
|
case nua_callstate_terminated:
|
|
|
|
if (call)
|
|
|
|
nua_handle_destroy(call->nh), call->nh = NULL;
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Media disabled, offer/answer in 200 OK/ACK */
|
|
|
|
int test_basic_call_4(struct context *ctx)
|
|
|
|
{
|
|
|
|
BEGIN();
|
|
|
|
|
|
|
|
struct endpoint *a = &ctx->a, *b = &ctx->b;
|
|
|
|
struct call *a_call = a->call, *b_call = b->call;
|
|
|
|
struct event *e;
|
|
|
|
sip_t const *sip;
|
|
|
|
|
|
|
|
if (print_headings)
|
|
|
|
printf("TEST NUA-3.4: 3pcc call with media disabled\n");
|
|
|
|
|
|
|
|
a_call->sdp = "v=0\r\n"
|
|
|
|
"o=- 1 1 IN IP4 127.0.0.1\r\n"
|
|
|
|
"s=-\r\n"
|
|
|
|
"c=IN IP4 127.0.0.1\r\n"
|
|
|
|
"t=0 0\r\n"
|
|
|
|
"m=audio 5008 RTP/AVP 8\r\n";
|
|
|
|
|
|
|
|
b_call->sdp =
|
|
|
|
"v=0\r\n"
|
|
|
|
"o=- 2 1 IN IP4 127.0.0.1\r\n"
|
|
|
|
"s=-\r\n"
|
|
|
|
"c=IN IP4 127.0.0.1\r\n"
|
|
|
|
"t=0 0\r\n"
|
|
|
|
"m=audio 5010 RTP/AVP 0 8\r\n";
|
|
|
|
|
|
|
|
TEST_1(a_call->nh = nua_handle(a->nua, a_call,
|
|
|
|
SIPTAG_TO_STR("<sip:b@x.org>"),
|
|
|
|
TAG_END()));
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_has_active_call(a_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
|
|
|
|
|
|
|
|
INVITE(a, a_call, a_call->nh,
|
|
|
|
NUTAG_MEDIA_ENABLE(0),
|
|
|
|
NUTAG_URL(b->contact->m_url),
|
|
|
|
NUTAG_AUTOACK(0),
|
|
|
|
TAG_END());
|
|
|
|
|
|
|
|
run_ab_until(ctx, -1, ack_when_completing_no_media,
|
|
|
|
-1, accept_call_no_media2);
|
|
|
|
|
|
|
|
/* Client transitions:
|
|
|
|
INIT -(C1)-> CALLING: nua_invite(), nua_i_state
|
|
|
|
CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state
|
|
|
|
PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
|
|
|
|
TEST_1(!is_offer_sent(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
|
|
|
|
TEST(e->data->e_status, 180);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
|
|
|
|
TEST_1(!is_answer_recv(e->data->e_tags));
|
|
|
|
TEST_1(is_offer_recv(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
|
|
|
|
TEST(e->data->e_status, 200);
|
|
|
|
TEST_1(sip = sip_object(e->data->e_msg));
|
|
|
|
TEST_1(sip->sip_content_type);
|
|
|
|
TEST_S(sip->sip_content_type->c_type, "application/sdp");
|
|
|
|
TEST_1(sip->sip_payload); /* there is sdp in 200 OK */
|
|
|
|
TEST_1(sip->sip_contact);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_completing); /* COMPLETING */
|
|
|
|
TEST_1(is_offer_recv(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
|
|
|
|
TEST_1(is_answer_sent(e->data->e_tags));
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, a->events);
|
|
|
|
|
|
|
|
TEST_1(nua_handle_has_active_call(a_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
|
|
|
|
|
|
|
|
/*
|
|
|
|
Server transitions:
|
|
|
|
INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
|
|
|
|
RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
|
|
|
|
EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
|
|
|
|
COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
|
|
|
|
TEST(e->data->e_status, 100);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
|
|
|
|
TEST_1(!is_offer_recv(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
|
|
|
|
TEST_1(!is_answer_sent(e->data->e_tags));
|
|
|
|
TEST_1(is_offer_sent(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
|
|
|
|
TEST_1(is_offer_sent(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
|
|
|
|
TEST_1(is_answer_recv(e->data->e_tags));
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, b->events);
|
|
|
|
|
|
|
|
TEST_1(nua_handle_has_active_call(b_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
|
|
|
|
|
|
|
|
BYE(b, b_call, b_call->nh, TAG_END());
|
|
|
|
|
|
|
|
run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
|
|
|
|
|
|
|
|
/* B transitions:
|
|
|
|
READY --(T2)--> TERMINATING: nua_bye()
|
|
|
|
TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_bye);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, b->events);
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_has_active_call(b_call->nh));
|
|
|
|
|
|
|
|
/* A transitions:
|
|
|
|
nua_i_info
|
|
|
|
READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_bye);
|
|
|
|
TEST(e->data->e_status, 200);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, a->events);
|
|
|
|
|
|
|
|
nua_handle_destroy(a_call->nh), a_call->nh = NULL;
|
|
|
|
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
|
|
|
|
|
|
|
|
if (print_headings)
|
|
|
|
printf("TEST NUA-3.4: PASSED\n");
|
|
|
|
|
|
|
|
END();
|
|
|
|
}
|
2006-12-21 06:30:28 +00:00
|
|
|
|
2007-05-08 19:14:10 +00:00
|
|
|
int change_uri_in_ack(CONDITION_PARAMS)
|
|
|
|
{
|
|
|
|
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
save_event_in_list(ctx, event, ep, call);
|
|
|
|
|
|
|
|
switch (callstate(tags)) {
|
|
|
|
case nua_callstate_completing:
|
|
|
|
ACK(ep, call, nh,
|
|
|
|
SIPTAG_FROM_STR("sip:anonymous@org.invalid"),
|
|
|
|
SIPTAG_TO_STR("sip:anonymous@net.invalid"),
|
|
|
|
TAG_END());
|
|
|
|
return 0;
|
|
|
|
case nua_callstate_ready:
|
|
|
|
return 1;
|
|
|
|
case nua_callstate_terminated:
|
|
|
|
if (call)
|
|
|
|
nua_handle_destroy(call->nh), call->nh = NULL;
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test changing from/to within dialog */
|
|
|
|
int test_basic_call_5(struct context *ctx)
|
|
|
|
{
|
|
|
|
BEGIN();
|
|
|
|
|
|
|
|
struct endpoint *a = &ctx->a, *b = &ctx->b;
|
|
|
|
struct call *a_call = a->call, *b_call = b->call;
|
|
|
|
struct event *e;
|
|
|
|
sip_t const *sip;
|
|
|
|
|
|
|
|
if (print_headings)
|
|
|
|
printf("TEST NUA-3.5: test changing From/To URL in ACK\n");
|
|
|
|
|
|
|
|
a_call->sdp = "m=audio 5008 RTP/AVP 8";
|
|
|
|
b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
|
|
|
|
|
|
|
|
TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_has_active_call(a_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
|
|
|
|
|
|
|
|
INVITE(a, a_call, a_call->nh,
|
|
|
|
TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
|
|
|
|
SOATAG_USER_SDP_STR(a_call->sdp),
|
|
|
|
NUTAG_AUTOACK(0),
|
|
|
|
TAG_END());
|
|
|
|
|
|
|
|
run_ab_until(ctx, -1, change_uri_in_ack, -1, accept_call);
|
|
|
|
|
|
|
|
/* Client transitions:
|
|
|
|
INIT -(C1)-> CALLING: nua_invite(), nua_i_state
|
|
|
|
CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state
|
|
|
|
PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
|
|
|
|
TEST(e->data->e_status, 180);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
|
|
|
|
TEST(e->data->e_status, 200);
|
|
|
|
TEST_1(sip = sip_object(e->data->e_msg));
|
|
|
|
TEST_1(sip->sip_contact);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_completing); /* COMPLETING */
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, a->events);
|
|
|
|
|
|
|
|
TEST_1(nua_handle_has_active_call(a_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
|
|
|
|
|
|
|
|
/*
|
|
|
|
Server transitions:
|
|
|
|
INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
|
|
|
|
RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
|
|
|
|
EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
|
|
|
|
COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
|
|
|
|
TEST(e->data->e_status, 100);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
|
|
|
|
TEST_1(sip = sip_object(e->data->e_msg));
|
|
|
|
TEST_S(sip->sip_to->a_url->url_user, "anonymous");
|
|
|
|
TEST_S(sip->sip_from->a_url->url_user, "anonymous");
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, b->events);
|
|
|
|
|
|
|
|
TEST_1(nua_handle_has_active_call(b_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
|
|
|
|
|
|
|
|
BYE(b, b_call, b_call->nh, TAG_END());
|
|
|
|
|
|
|
|
run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
|
|
|
|
|
|
|
|
/* B transitions:
|
|
|
|
READY --(T2)--> TERMINATING: nua_bye()
|
|
|
|
TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_bye);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, b->events);
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_has_active_call(b_call->nh));
|
|
|
|
|
|
|
|
/* A transitions:
|
|
|
|
nua_i_info
|
|
|
|
READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_bye);
|
|
|
|
TEST(e->data->e_status, 200);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, a->events);
|
|
|
|
|
|
|
|
nua_handle_destroy(a_call->nh), a_call->nh = NULL;
|
|
|
|
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
|
|
|
|
|
|
|
|
if (print_headings)
|
Update sofia-sip from darcs:
Mon May 14 12:43:07 EDT 2007 martti.mela@nokia.com
* su_base_port.c: fixed a double free in su_base_port_start_shared().
Fri May 25 13:56:23 EDT 2007 Pekka.Pessi@nokia.com
* soa: added SOATAG_ORDERED_USER(), SOATAG_REUSE_REJECTED().
Allow replacing existing m=lines.
Sun May 27 14:52:13 EDT 2007 Pekka.Pessi@nokia.com
* msg_parser.c: fixed bug #1726034
Mon May 28 04:57:08 EDT 2007 Pekka.Pessi@nokia.com
* test_nth.c: using non-blocking connect in test program, too.
Mon May 28 04:58:05 EDT 2007 Pekka.Pessi@nokia.com
* su.c: making all sockets non-blocking by default.
Mon May 28 04:59:28 EDT 2007 Pekka.Pessi@nokia.com
* m4/sac-su.m4: moved contents into sac-s2.m4
Mon May 28 05:32:26 EDT 2007 Pekka.Pessi@nokia.com
* RELEASE: updated.
Wed May 30 10:37:53 EDT 2007 Pekka.Pessi@nokia.com
* m4/sac-su2.m4: added configure option --disable-tag-cast.
Added SU_INLINE_TAG_CAST into sofia-sip/su_configure.h{,.in}.
Using SU_INLINE_TAG_CAST in
sofia-sip/sip_tag.h{,.in}
sofia-sip/http_tag.h{,.in}
sofia-sip/su_tag.h
sofia-sip/su_tag_io.h
sofia-sip/auth_module.h
sofia-sip/nth_tag.h
sofia-sip/nua_tag.h
Fri Jun 1 15:11:52 EDT 2007 Pekka.Pessi@nokia.com
* tport.c: fixed tport_set_params() with secondary transports
Fri Jun 1 15:13:23 EDT 2007 Pekka.Pessi@nokia.com
* tport_type_tcp.c: checking for end-of-stream even if su_getmsgsize() promised more data
Fri Jun 1 15:15:34 EDT 2007 Pekka.Pessi@nokia.com
* tport: added tport_is_clear_to_send(), allow use of tport_pending() without msg
The error callback from tport can now be registered even if there is no
request pending on transport (e.g., when keeping a transport connection open
for inbound messages).
Fri Jun 1 15:16:43 EDT 2007 Pekka.Pessi@nokia.com
* nta: not retrying after an transport error if application provided the transport
Fri Jun 1 15:17:23 EDT 2007 Pekka.Pessi@nokia.com
* sip: do not accept empty URIs (<>) in From, To, and other headers expecting name-addr format
Fri Jun 1 15:17:43 EDT 2007 Pekka.Pessi@nokia.com
* torture_url.c: added test for parsing empty URLs.
Fri Jun 1 15:19:27 EDT 2007 Pekka.Pessi@nokia.com
* nua/test_proxy.[hc]: use registered connections for outbound with TCP.
Added test_proxy_close_tports() used testing recovering from TCP failures.
Fri Jun 1 15:20:33 EDT 2007 Pekka.Pessi@nokia.com
* test_nua.c: added --print-tags and --tags-a, --tags=b and --tags=c options
Added more functions for handling events
Fri Jun 1 15:22:08 EDT 2007 Pekka.Pessi@nokia.com
* test_nua: fixed some tests depending on delivery of responses in correct order
Reordering might happen if some messages are sent over TCP, other over UDP.
Fri Jun 1 15:27:55 EDT 2007 Pekka.Pessi@nokia.com
* nua_register.c: re-registering in case the TCP connection towards proxy is closed
In test_nua, Mr. B is now using TCP with the test proxy.
Fri Jun 1 15:35:39 EDT 2007 Pekka.Pessi@nokia.com
* nua/test_refer.c: fixed SIP payload checks
Fri Jun 1 15:36:08 EDT 2007 Pekka.Pessi@nokia.com
* nta_internal.h: added orq_user_tport field
Tue Jun 5 06:16:43 EDT 2007 Pekka.Pessi@nokia.com
* hide_email.sh: now fixing links, too.
Fri Jun 15 05:34:29 EDT 2007 Pekka.Pessi@nokia.com
* nua: fixed documentation entries for API functions left out from doxygen
Thanks for Jerry Ricahrds for pointing this out.
Wed May 23 10:26:26 EDT 2007 Mikhail Zabaluev <mikhail.zabaluev@nokia.com>
* Correct documentation for parameter type of NUTAG_WITH_SAVED
Mon Jun 18 12:34:58 EDT 2007 Mikhail Zabaluev <mikhail.zabaluev@nokia.com>
* Make nua_saved_event_request() and hence NUTAG_WITH_SAVED resilient to a NULL event content
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5413 d0543943-73ff-0310-b7d9-9358b9ac24b2
2007-06-20 10:41:15 +00:00
|
|
|
printf("TEST NUA-3.5: PASSED\n");
|
2007-05-08 19:14:10 +00:00
|
|
|
|
|
|
|
END();
|
|
|
|
}
|
|
|
|
|
2007-08-06 19:24:10 +00:00
|
|
|
/* ======================================================================== */
|
|
|
|
|
|
|
|
/* Call with media upgrade:
|
|
|
|
|
|
|
|
A B
|
|
|
|
|-------INVITE------>|
|
|
|
|
| with audio only |
|
|
|
|
|<----100 Trying-----|
|
|
|
|
| |
|
|
|
|
|<----180 Ringing----|
|
|
|
|
| |
|
|
|
|
|<------200 OK-------|
|
|
|
|
|--------ACK-------->|
|
|
|
|
| |
|
|
|
|
|<------INVITE-------|
|
|
|
|
| with video |
|
|
|
|
|-----100 Trying---->|
|
|
|
|
| |
|
|
|
|
|-------200 OK------>|
|
|
|
|
| with video |
|
|
|
|
|<-------ACK---------|
|
|
|
|
| |
|
|
|
|
|<-------BYE---------|
|
|
|
|
|-------200 OK------>|
|
|
|
|
| |
|
|
|
|
|
|
|
|
Client transitions:
|
|
|
|
INIT -(C1)-> CALLING -(C2a)-> PROCEEDING -(C3+C4)-> READY
|
|
|
|
Server transitions:
|
|
|
|
INIT -(S1)-> RECEIVED -(S2a)-> EARLY -(S3b)-> COMPLETED -(S4)-> READY
|
|
|
|
|
|
|
|
B sends BYE:
|
|
|
|
READY -(T2)-> TERMINATING -(T3)-> TERMINATED
|
|
|
|
A receives BYE:
|
|
|
|
READY -(T1)-> TERMINATED
|
|
|
|
|
|
|
|
See @page nua_call_model in nua.docs for more information
|
|
|
|
*/
|
|
|
|
int accept_upgrade(CONDITION_PARAMS);
|
|
|
|
|
|
|
|
int test_video_call_1(struct context *ctx)
|
|
|
|
{
|
|
|
|
BEGIN();
|
|
|
|
|
|
|
|
struct endpoint *a = &ctx->a, *b = &ctx->b;
|
|
|
|
struct call *a_call = a->call, *b_call = b->call;
|
|
|
|
struct event *e;
|
|
|
|
sip_t *sip;
|
|
|
|
sdp_session_t *b_sdp;
|
|
|
|
sdp_media_t *m, b_video[1];
|
|
|
|
sdp_rtpmap_t *rm, b_h261[1];
|
|
|
|
|
|
|
|
sip_time_t se, min_se;
|
|
|
|
|
|
|
|
if (print_headings)
|
|
|
|
printf("TEST NUA-3.6: Basic call\n");
|
|
|
|
|
|
|
|
/* Disable session timer from proxy */
|
|
|
|
test_proxy_get_session_timer(ctx->p, &se, &min_se);
|
|
|
|
test_proxy_set_session_timer(ctx->p, 0, 0);
|
|
|
|
|
|
|
|
a_call->sdp = "m=audio 5008 RTP/AVP 8";
|
|
|
|
b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
|
|
|
|
|
|
|
|
TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_has_active_call(a_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
|
|
|
|
|
|
|
|
INVITE(a, a_call, a_call->nh,
|
|
|
|
TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
|
|
|
|
SOATAG_USER_SDP_STR(a_call->sdp),
|
|
|
|
NUTAG_AUTOANSWER(0),
|
|
|
|
TAG_END());
|
|
|
|
|
|
|
|
run_ab_until(ctx, -1, until_ready, -1, accept_call_with_early_sdp);
|
|
|
|
|
|
|
|
TEST_1(nua_handle_has_active_call(a_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
|
|
|
|
|
|
|
|
TEST_1(nua_handle_has_active_call(b_call->nh));
|
|
|
|
TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
|
|
|
|
|
|
|
|
/* Client transitions:
|
|
|
|
INIT -(C1)-> CALLING: nua_invite(), nua_i_state
|
|
|
|
CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state
|
|
|
|
PROCEEDING -(C3+C4)-> READY: nua_r_invite, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
|
|
|
|
TEST_1(is_offer_sent(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
|
|
|
|
TEST(e->data->e_status, 180);
|
|
|
|
TEST_1(sip = sip_object(e->data->e_msg));
|
|
|
|
TEST_1(sip->sip_payload);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
|
|
|
|
TEST_1(is_answer_recv(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
|
|
|
|
TEST(e->data->e_status, 200);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, a->events);
|
|
|
|
|
|
|
|
/*
|
|
|
|
Server transitions:
|
|
|
|
INIT -(S1)-> RECEIVED: nua_i_invite, nua_i_state
|
|
|
|
RECEIVED -(S2a)-> EARLY: nua_respond(), nua_i_state
|
|
|
|
EARLY -(S3b)-> COMPLETED: nua_respond(), nua_i_state
|
|
|
|
COMPLETED -(S4)-> READY: nua_i_ack, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
|
|
|
|
TEST(e->data->e_status, 100);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
|
|
|
|
TEST_1(is_offer_recv(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
|
|
|
|
TEST_1(is_answer_sent(e->data->e_tags));
|
|
|
|
TEST_1(tl_find(e->data->e_tags, soatag_local_sdp));
|
|
|
|
TEST_1(b_sdp = sdp_session_dup(nua_handle_home(a_call->nh),
|
|
|
|
(sdp_session_t *)
|
|
|
|
tl_find(e->data->e_tags, soatag_local_sdp)
|
|
|
|
->t_value));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
|
|
|
|
TEST_1(is_answer_sent(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, b->events);
|
|
|
|
|
|
|
|
a_call->sdp =
|
|
|
|
"m=audio 5008 RTP/AVP 8\n"
|
|
|
|
"m=video 5014 RTP/AVP 34 31\n";
|
|
|
|
|
|
|
|
m = memset(b_video, 0, sizeof b_video);
|
|
|
|
m->m_size = sizeof *m;
|
|
|
|
m->m_session = b_sdp;
|
|
|
|
m->m_type = sdp_media_video, m->m_type_name = "video";
|
|
|
|
m->m_port = 5016;
|
|
|
|
m->m_proto = sdp_proto_rtp; m->m_proto_name = "RTP/AVP";
|
|
|
|
m->m_rtpmaps = memset(rm = b_h261, 0, sizeof b_h261);
|
|
|
|
rm->rm_size = sizeof *rm;
|
|
|
|
rm->rm_pt = 31; rm->rm_encoding = "h261"; rm->rm_rate = 90000;
|
|
|
|
|
|
|
|
b_sdp->sdp_media->m_next = m;
|
|
|
|
|
|
|
|
INVITE(b, b_call, b_call->nh,
|
|
|
|
SOATAG_USER_SDP(b_sdp),
|
|
|
|
TAG_END());
|
|
|
|
run_ab_until(ctx, -1, accept_upgrade, -1, until_ready);
|
|
|
|
|
|
|
|
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
|
|
|
|
TEST_1(tl_find(e->data->e_tags, soatag_local_sdp_str));
|
|
|
|
TEST_1(strstr((char *)
|
|
|
|
tl_find(e->data->e_tags, soatag_local_sdp_str)->t_value,
|
|
|
|
"m=video"));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
|
|
|
|
TEST(e->data->e_status, 200);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST_1(is_answer_recv(e->data->e_tags));
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, b->events);
|
|
|
|
|
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_invite);
|
|
|
|
TEST(e->data->e_status, 100);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
|
|
|
|
TEST_1(is_offer_recv(e->data->e_tags));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_completed); /* COMPLETED */
|
|
|
|
TEST_1(is_answer_sent(e->data->e_tags));
|
|
|
|
TEST_1(tl_find(e->data->e_tags, soatag_local_sdp_str));
|
|
|
|
TEST_1(strstr((char *)
|
|
|
|
tl_find(e->data->e_tags, soatag_local_sdp_str)->t_value,
|
|
|
|
"m=video"));
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_ack);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, a->events);
|
|
|
|
|
|
|
|
BYE(b, b_call, b_call->nh, TAG_END());
|
|
|
|
run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
|
|
|
|
|
|
|
|
/* B transitions:
|
|
|
|
READY --(T2)--> TERMINATING: nua_bye()
|
|
|
|
TERMINATING --(T3)--> TERMINATED: nua_r_bye, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_bye);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, b->events);
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_has_active_call(b_call->nh));
|
|
|
|
|
|
|
|
/* A transitions:
|
|
|
|
READY -(T1)-> TERMINATED: nua_i_bye, nua_i_state
|
|
|
|
*/
|
|
|
|
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_bye);
|
|
|
|
TEST(e->data->e_status, 200);
|
|
|
|
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
|
|
|
|
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
|
|
|
|
TEST_1(!e->next);
|
|
|
|
free_events_in_list(ctx, a->events);
|
|
|
|
|
|
|
|
TEST_1(!nua_handle_has_active_call(a_call->nh));
|
|
|
|
|
|
|
|
nua_handle_destroy(a_call->nh), a_call->nh = NULL;
|
|
|
|
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
|
|
|
|
|
|
|
|
test_proxy_set_session_timer(ctx->p, se, min_se);
|
|
|
|
|
|
|
|
if (print_headings)
|
|
|
|
printf("TEST NUA-3.6: PASSED\n");
|
|
|
|
|
|
|
|
END();
|
|
|
|
}
|
|
|
|
|
|
|
|
int accept_upgrade(CONDITION_PARAMS)
|
|
|
|
{
|
|
|
|
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
save_event_in_list(ctx, event, ep, call);
|
|
|
|
|
|
|
|
if (event == nua_i_invite && status < 200) {
|
|
|
|
RESPOND(ep, call, nh, SIP_200_OK,
|
|
|
|
TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
|
|
|
|
TAG_END());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (callstate(tags)) {
|
|
|
|
case nua_callstate_ready:
|
|
|
|
return 1;
|
|
|
|
case nua_callstate_terminated:
|
|
|
|
if (call)
|
|
|
|
nua_handle_destroy(call->nh), call->nh = NULL;
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2007-05-08 19:14:10 +00:00
|
|
|
|
2006-12-21 06:30:28 +00:00
|
|
|
int test_basic_call(struct context *ctx)
|
|
|
|
{
|
2007-05-08 19:14:10 +00:00
|
|
|
return
|
|
|
|
test_basic_call_1(ctx)
|
|
|
|
|| test_basic_call_2(ctx)
|
|
|
|
|| test_basic_call_3(ctx)
|
|
|
|
|| test_basic_call_4(ctx)
|
|
|
|
|| test_basic_call_5(ctx)
|
2007-08-06 19:24:10 +00:00
|
|
|
|| test_video_call_1(ctx)
|
2007-05-08 19:14:10 +00:00
|
|
|
;
|
2006-12-21 06:30:28 +00:00
|
|
|
}
|