Add support for incoming call pre-cheking
This commit is contained in:
parent
6f6c31222d
commit
e2f0f6156c
|
@ -473,6 +473,16 @@ int32_t MediaSessionMgr::defaultsGetNoiseSuppLevel()
|
|||
return tmedia_defaults_get_noise_supp_level();
|
||||
}
|
||||
|
||||
bool MediaSessionMgr::defaultsSetConditionalRingingEnabled(bool _cond_ringing_enabled)
|
||||
{
|
||||
return tmedia_defaults_set_conditional_ringing_enabled(_cond_ringing_enabled ? tsk_true : tsk_false) == 0;
|
||||
}
|
||||
|
||||
bool MediaSessionMgr::defaultsGetConditionalRingingEnabled()
|
||||
{
|
||||
return !!tmedia_defaults_get_conditional_ringing_enabled();
|
||||
}
|
||||
|
||||
bool MediaSessionMgr::defaultsSet100relEnabled(bool _100rel_enabled)
|
||||
{
|
||||
return tmedia_defaults_set_100rel_enabled(_100rel_enabled ? tsk_true : tsk_false) == 0;
|
||||
|
@ -480,7 +490,7 @@ bool MediaSessionMgr::defaultsSet100relEnabled(bool _100rel_enabled)
|
|||
|
||||
bool MediaSessionMgr::defaultsGet100relEnabled()
|
||||
{
|
||||
return tmedia_defaults_get_100rel_enabled() == 0;
|
||||
return !!tmedia_defaults_get_100rel_enabled();
|
||||
}
|
||||
|
||||
bool MediaSessionMgr::defaultsSetScreenSize(int32_t sx, int32_t sy)
|
||||
|
|
|
@ -197,6 +197,8 @@ public:
|
|||
static bool defaultsGetNoiseSuppEnabled();
|
||||
static bool defaultsSetNoiseSuppLevel(int32_t noise_supp_level);
|
||||
static int32_t defaultsGetNoiseSuppLevel();
|
||||
static bool defaultsSetConditionalRingingEnabled(bool _cond_ringing_enabled);
|
||||
static bool defaultsGetConditionalRingingEnabled();
|
||||
static bool defaultsSet100relEnabled(bool _100rel_enabled);
|
||||
static bool defaultsGet100relEnabled();
|
||||
static bool defaultsSetScreenSize(int32_t sx, int32_t sy);
|
||||
|
|
|
@ -103,6 +103,7 @@ tsip_event_type_t;
|
|||
#define tsip_event_code_dialog_request_outgoing 802
|
||||
#define tsip_event_code_dialog_request_cancelled 803
|
||||
#define tsip_event_code_dialog_request_sent 804
|
||||
#define tsip_event_code_dialog_request_prechecking 805
|
||||
|
||||
// 9xx ==> Informational
|
||||
#define tsip_event_code_dialog_connecting 900
|
||||
|
|
|
@ -69,6 +69,8 @@ TINYMEDIA_API int tmedia_defaults_set_noise_supp_enabled(tsk_bool_t noise_supp_e
|
|||
TINYMEDIA_API tsk_bool_t tmedia_defaults_get_noise_supp_enabled();
|
||||
TINYMEDIA_API int tmedia_defaults_set_noise_supp_level(int32_t noise_supp_level);
|
||||
TINYMEDIA_API int32_t tmedia_defaults_get_noise_supp_level();
|
||||
TINYMEDIA_API int tmedia_defaults_set_conditional_ringing_enabled(tsk_bool_t _cond_ringing_enabled);
|
||||
TINYMEDIA_API tsk_bool_t tmedia_defaults_get_conditional_ringing_enabled();
|
||||
TINYMEDIA_API int tmedia_defaults_set_100rel_enabled(tsk_bool_t _100rel_enabled);
|
||||
TINYMEDIA_API tsk_bool_t tmedia_defaults_get_100rel_enabled();
|
||||
TINYMEDIA_API int tmedia_defaults_set_screen_size(int32_t sx, int32_t sy);
|
||||
|
|
|
@ -49,6 +49,7 @@ static float __agc_level = 8000.0f;
|
|||
static tsk_bool_t __vad_enabled = tsk_false;
|
||||
static tsk_bool_t __noise_supp_enabled = tsk_true;
|
||||
static int32_t __noise_supp_level = -30;
|
||||
static tsk_bool_t __cond_ringing_enabled = tsk_false; // Whether to let the user decide if sending ringing is needed or not -> If enabled then, the state machine will hang on "PreChecking" state until "accept" request is received from the end-user
|
||||
static tsk_bool_t __100rel_enabled = tsk_true;
|
||||
static int32_t __sx = -1;
|
||||
static int32_t __sy = -1;
|
||||
|
@ -333,6 +334,16 @@ int32_t tmedia_defaults_get_noise_supp_level()
|
|||
return __noise_supp_level;
|
||||
}
|
||||
|
||||
int tmedia_defaults_set_conditional_ringing_enabled(tsk_bool_t _cond_ringing_enabled)
|
||||
{
|
||||
__cond_ringing_enabled = _cond_ringing_enabled;
|
||||
return 0;
|
||||
}
|
||||
tsk_bool_t tmedia_defaults_get_conditional_ringing_enabled()
|
||||
{
|
||||
return __cond_ringing_enabled;
|
||||
}
|
||||
|
||||
int tmedia_defaults_set_100rel_enabled(tsk_bool_t _100rel_enabled)
|
||||
{
|
||||
__100rel_enabled = _100rel_enabled;
|
||||
|
|
|
@ -46,6 +46,7 @@ typedef enum tsip_invite_event_type_e {
|
|||
// Sip Events
|
||||
//
|
||||
tsip_i_newcall,
|
||||
tsip_i_prechecking,
|
||||
|
||||
//! in-dialog requests/reponses
|
||||
tsip_i_request,
|
||||
|
|
|
@ -93,6 +93,7 @@ typedef enum _fsm_state_e {
|
|||
_fsm_state_Started,
|
||||
_fsm_state_Outgoing,
|
||||
_fsm_state_Incoming,
|
||||
_fsm_state_PreChecking,
|
||||
_fsm_state_Trying,
|
||||
_fsm_state_Ringing,
|
||||
_fsm_state_Cancelling,
|
||||
|
|
|
@ -51,6 +51,7 @@ typedef struct tsip_dialog_invite {
|
|||
tsk_bool_t use_rtcpmux;
|
||||
tsk_bool_t is_initial_iack_pending; // we're waiting for the initial incoming ACK (for the 200 OK) to ensure the session
|
||||
tsk_bool_t is_cancelling; // whether we're cancelling the outgoing INVITE
|
||||
tsk_bool_t is_conditional_ringing_enabled; // whether to ask end-user before sending 18x ringing message
|
||||
uint32_t rseq;
|
||||
uint32_t cseq_out_media_update; // CSeq for the last media update request (INVITE or UPDATE).
|
||||
uint64_t last_out_fastupdate_time;
|
||||
|
|
|
@ -65,6 +65,7 @@ tsip_event_type_t;
|
|||
#define tsip_event_code_dialog_request_outgoing 802
|
||||
#define tsip_event_code_dialog_request_cancelled 803
|
||||
#define tsip_event_code_dialog_request_sent 804
|
||||
#define tsip_event_code_dialog_request_prechecking 805
|
||||
|
||||
// 9xx ==> Informational @tinyWRAP
|
||||
#define tsip_event_code_dialog_connecting 900
|
||||
|
|
|
@ -259,6 +259,7 @@ typedef struct tsip_ssession_s {
|
|||
} stun;
|
||||
|
||||
/* Features */
|
||||
unsigned enable_conditional_ringing:1;
|
||||
unsigned enable_100rel:1;
|
||||
unsigned enable_ice:1;
|
||||
unsigned enable_icestun:1;
|
||||
|
|
|
@ -1882,6 +1882,7 @@ static tsk_object_t* tsip_dialog_invite_ctor(tsk_object_t * self, va_list * app)
|
|||
|
||||
dialog->ice.last_action_id = tsk_fsm_state_none;
|
||||
dialog->refersub = tsk_true;
|
||||
dialog->is_conditional_ringing_enabled = ((tsip_ssession_t*)ss)->media.enable_conditional_ringing;
|
||||
// ... do the same for preconditions, replaces, ....
|
||||
|
||||
/* Initialize the class itself */
|
||||
|
|
|
@ -62,8 +62,13 @@ static int send_UNSUPPORTED(tsip_dialog_invite_t* self, const tsip_request_t* re
|
|||
/* ======================== transitions ======================== */
|
||||
static int s0000_Started_2_Terminated_X_iINVITE(va_list *app); // Failure
|
||||
static int s0000_Started_2_Started_X_iINVITE(va_list *app); // Session Interval Too Small
|
||||
static int s0000_Started_2_PreChecking_X_iINVITE(va_list *app); // Conditional ringing (or any pre-chechecking) enabled
|
||||
static int s0000_Started_2_InProgress_X_iINVITE(va_list *app); // 100rel supported
|
||||
static int s0000_Started_2_Ringing_X_iINVITE(va_list *app); // Neither 100rel nor QoS
|
||||
static int s0000_PreChecking_2_Terminated_X_Reject(va_list *app); // User rejected the incoming call after pre-checking
|
||||
static int s0000_PreChecking_2_Terminated_X_iCANCEL(va_list *app);
|
||||
static int s0000_PreChecking_2_InProgress_X_Accept(va_list *app); // User accepted the incoming call after pre-checking - 100rel supported
|
||||
static int s0000_PreChecking_2_Ringing_X_Accept(va_list *app); // User accepted the incoming call after pre-checking - neither 100rel nor QoS
|
||||
static int s0000_InProgress_2_InProgress_X_iPRACK(va_list *app); // PRACK for our 18x response (with QoS)
|
||||
static int s0000_InProgress_2_Ringing_X_iPRACK(va_list *app); // PRACK for our 18x response (without QoS)
|
||||
static int s0000_InProgress_2_InProgress_X_iUPDATE(va_list *app); // QoS cannot resume
|
||||
|
@ -219,11 +224,15 @@ static tsk_bool_t _fsm_cond_cannotresume(tsip_dialog_invite_t* self, tsip_messag
|
|||
}
|
||||
}
|
||||
|
||||
static tsk_bool_t _fsm_cond_initial_iack_pending(tsip_dialog_invite_t* self, tsip_message_t* rACK)
|
||||
static tsk_bool_t _fsm_cond_initial_iack_pending(tsip_dialog_invite_t* self, tsip_message_t* message)
|
||||
{
|
||||
return self->is_initial_iack_pending;
|
||||
}
|
||||
|
||||
static tsk_bool_t _fsm_cond_prechecking_enabled(tsip_dialog_invite_t* self, tsip_message_t* rACK)
|
||||
{
|
||||
return self->is_conditional_ringing_enabled && !self->is_client; // add here other options requiring pre-checking using OR (|)
|
||||
}
|
||||
|
||||
|
||||
/* Init FSM */
|
||||
|
@ -240,11 +249,26 @@ int tsip_dialog_invite_server_init(tsip_dialog_invite_t *self)
|
|||
TSK_FSM_ADD(_fsm_state_Started, _fsm_action_iINVITE, _fsm_cond_bad_content, _fsm_state_Terminated, s0000_Started_2_Terminated_X_iINVITE, "s0000_Started_2_Terminated_X_iINVITE"),
|
||||
// Started -> (Session Interval Too Small) -> Started
|
||||
TSK_FSM_ADD(_fsm_state_Started, _fsm_action_iINVITE, _fsm_cond_toosmall, _fsm_state_Started, s0000_Started_2_Started_X_iINVITE, "s0000_Started_2_Started_X_iINVITE"),
|
||||
// Started ->(Pre-Checking enabled) -> PreChecking
|
||||
TSK_FSM_ADD(_fsm_state_Started, _fsm_action_iINVITE, _fsm_cond_prechecking_enabled, _fsm_state_PreChecking, s0000_Started_2_PreChecking_X_iINVITE, "s0000_Started_2_PreChecking_X_iINVITE"),
|
||||
// Started -> (100rel && (QoS or ICE)) -> InProgress
|
||||
TSK_FSM_ADD(_fsm_state_Started, _fsm_action_iINVITE, _fsm_cond_use_early_media, _fsm_state_InProgress, s0000_Started_2_InProgress_X_iINVITE, "s0000_Started_2_InProgress_X_iINVITE"),
|
||||
// Started -> (non-100rel and non-QoS, referred to as "basic") -> Ringing
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_iINVITE, _fsm_state_Ringing, s0000_Started_2_Ringing_X_iINVITE, "s0000_Started_2_Ringing_X_iINVITE"),
|
||||
|
||||
/*=======================
|
||||
* === PreChecking ===
|
||||
*/
|
||||
// PreChecking ->(iCANCEL) -> Terminated
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_PreChecking, _fsm_action_iCANCEL, _fsm_state_Terminated, s0000_PreChecking_2_Terminated_X_iCANCEL, "s0000_PreChecking_2_Terminated_X_iCancel"),
|
||||
// PreChecking ->(oReject) -> Terminated
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_PreChecking, _fsm_action_reject, _fsm_state_Terminated, s0000_PreChecking_2_Terminated_X_Reject, "s0000_PreChecking_2_Terminated_X_Reject"),
|
||||
// PreChecking ->(oCANCEL) -> Terminated
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_PreChecking, _fsm_action_oCANCEL, _fsm_state_Terminated, s0000_PreChecking_2_Terminated_X_Reject, "s0000_PreChecking_2_Terminated_X_oCANCEL"),
|
||||
// PreChecking -> (oAccept + 100rel && (QoS or ICE)) -> InProgress
|
||||
TSK_FSM_ADD(_fsm_state_PreChecking, _fsm_action_accept, _fsm_cond_use_early_media, _fsm_state_InProgress, s0000_PreChecking_2_InProgress_X_Accept, "s0000_PreChecking_2_InProgress_X_Accept"),
|
||||
// PreChecking -> (oAccept + non-100rel and non-QoS, referred to as "basic") -> Ringing
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_PreChecking, _fsm_action_accept, _fsm_state_Ringing, s0000_PreChecking_2_Ringing_X_Accept, "s0000_PreChecking_2_Ringing_X_Accept"),
|
||||
|
||||
/*=======================
|
||||
* === InProgress ===
|
||||
|
@ -317,11 +341,30 @@ int s0000_Started_2_Started_X_iINVITE(va_list *app)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Started ->(Pre-Checking enabled) -> PreChecking */
|
||||
int s0000_Started_2_PreChecking_X_iINVITE(va_list *app)
|
||||
{
|
||||
tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *);
|
||||
tsip_request_t *request = va_arg(*app, tsip_request_t *);
|
||||
|
||||
/* update last INVITE */
|
||||
TSK_OBJECT_SAFE_FREE(self->last_iInvite);
|
||||
self->last_iInvite = tsk_object_ref(request);
|
||||
|
||||
/* alert the user (session) */
|
||||
TSIP_DIALOG_INVITE_SIGNAL(self, tsip_i_prechecking,
|
||||
tsip_event_code_dialog_request_prechecking, "Pre-checking incoming Call", request);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Started -> (non-100rel and non-QoS, referred to as "basic") -> Ringing */
|
||||
int s0000_Started_2_Ringing_X_iINVITE(va_list *app)
|
||||
{
|
||||
tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *);
|
||||
tsip_request_t *request = va_arg(*app, tsip_request_t *);
|
||||
tsip_request_t *request = self->is_conditional_ringing_enabled // When called from pre-checking state (s0000_PreChecking_2_Ringing_X_Accept) then, there is no 'request embedded'
|
||||
? tsk_object_ref(self->last_iInvite)
|
||||
: va_arg(*app, tsip_request_t *);
|
||||
const tsip_header_Session_Expires_t* hdr_SessionExpires;
|
||||
|
||||
/* we are not the client */
|
||||
|
@ -366,7 +409,9 @@ int s0000_Started_2_Ringing_X_iINVITE(va_list *app)
|
|||
int s0000_Started_2_InProgress_X_iINVITE(va_list *app)
|
||||
{
|
||||
tsip_dialog_invite_t *self = va_arg(*app, tsip_dialog_invite_t *);
|
||||
tsip_request_t *request = va_arg(*app, tsip_request_t *);
|
||||
tsip_request_t *request = self->is_conditional_ringing_enabled // When called from pre-checking state (s0000_PreChecking_2_InProgress_X_Accept) then, there is no 'request embedded'
|
||||
? tsk_object_ref(self->last_iInvite)
|
||||
: va_arg(*app, tsip_request_t *);
|
||||
|
||||
/* We are not the client */
|
||||
self->is_client = tsk_false;
|
||||
|
@ -396,6 +441,30 @@ int s0000_Started_2_InProgress_X_iINVITE(va_list *app)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* PreChecking ->(oReject) -> Terminated */
|
||||
int s0000_PreChecking_2_Terminated_X_iCANCEL(va_list *app)
|
||||
{
|
||||
return s0000_Ringing_2_Terminated_X_iCANCEL(app);
|
||||
}
|
||||
|
||||
/* PreChecking ->(oReject) -> Terminated */
|
||||
int s0000_PreChecking_2_Terminated_X_Reject(va_list *app)
|
||||
{
|
||||
return s0000_Ringing_2_Terminated_X_Reject(app);
|
||||
}
|
||||
|
||||
// PreChecking -> (oAccept + 100rel && (QoS or ICE)) -> InProgress
|
||||
int s0000_PreChecking_2_InProgress_X_Accept(va_list *app)
|
||||
{
|
||||
return s0000_Started_2_InProgress_X_iINVITE(app);
|
||||
}
|
||||
|
||||
/* PreChecking -> (oAccept + non-100rel and non-QoS, referred to as "basic") -> Ringing */
|
||||
int s0000_PreChecking_2_Ringing_X_Accept(va_list *app)
|
||||
{
|
||||
return s0000_Started_2_Ringing_X_iINVITE(app);
|
||||
}
|
||||
|
||||
/* InProgress ->(iPRACK with QoS) -> InProgress */
|
||||
int s0000_InProgress_2_InProgress_X_iPRACK(va_list *app)
|
||||
{
|
||||
|
|
|
@ -708,6 +708,7 @@ static tsk_object_t* tsip_ssession_ctor(tsk_object_t * self, va_list * app)
|
|||
ss->media.profile = tmedia_defaults_get_profile();
|
||||
ss->media.srtp_mode = tmedia_defaults_get_srtp_mode();
|
||||
ss->media.avpf_mode = tmedia_defaults_get_avpf_mode();
|
||||
ss->media.enable_conditional_ringing = tmedia_defaults_get_conditional_ringing_enabled();
|
||||
ss->media.enable_100rel = tmedia_defaults_get_100rel_enabled();
|
||||
ss->media.enable_ice = tmedia_defaults_get_ice_enabled();
|
||||
ss->media.enable_icestun = tmedia_defaults_get_icestun_enabled();
|
||||
|
|
Loading…
Reference in New Issue