Fix issue on session timers

This commit is contained in:
bossiel 2012-02-07 05:31:32 +00:00
parent 00a8e48b10
commit 10722b880e
20 changed files with 216 additions and 3 deletions

View File

@ -289,4 +289,11 @@ bool MediaSessionMgr::defaultsSetVolume(int32_t volume)
int32_t MediaSessionMgr::defaultsGetVolume()
{
return tmedia_defaults_get_volume();
}
bool MediaSessionMgr::defaultsSetInviteSessionTimers(int32_t timeout, const char* refresher)
{
int ret = tmedia_defaults_set_inv_session_expires(timeout);
ret &= tmedia_defaults_set_inv_session_refresher(refresher);
return (ret == 0);
}

View File

@ -85,6 +85,7 @@ public:
static bool defaultsSetMediaType(twrap_media_type_t media_type);
static bool defaultsSetVolume(int32_t volume);
static int32_t defaultsGetVolume();
static bool defaultsSetInviteSessionTimers(int32_t timeout, const char* refresher);
private:
tmedia_session_mgr_t* m_pWrappedMgr;

View File

@ -216,6 +216,11 @@ public class MediaSessionMgr : IDisposable {
return ret;
}
public static bool defaultsSetInviteSessionTimers(int timeout, string refresher) {
bool ret = tinyWRAPPINVOKE.MediaSessionMgr_defaultsSetInviteSessionTimers(timeout, refresher);
return ret;
}
}
}

View File

@ -365,6 +365,9 @@ class tinyWRAPPINVOKE {
[DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsGetVolume")]
public static extern int MediaSessionMgr_defaultsGetVolume();
[DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsSetInviteSessionTimers")]
public static extern bool MediaSessionMgr_defaultsSetInviteSessionTimers(int jarg1, string jarg2);
[DllImport("tinyWRAP", EntryPoint="CSharp_delete_MediaContent")]
public static extern void delete_MediaContent(HandleRef jarg1);

View File

@ -1879,6 +1879,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsGetVolume() {
}
SWIGEXPORT unsigned int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsSetInviteSessionTimers(int jarg1, char * jarg2) {
unsigned int jresult ;
int32_t arg1 ;
char *arg2 = (char *) 0 ;
bool result;
arg1 = (int32_t)jarg1;
arg2 = (char *)jarg2;
result = (bool)MediaSessionMgr::defaultsSetInviteSessionTimers(arg1,(char const *)arg2);
jresult = result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_delete_MediaContent(void * jarg1) {
MediaContent *arg1 = (MediaContent *) 0 ;

View File

@ -175,4 +175,8 @@ public class MediaSessionMgr {
return tinyWRAPJNI.MediaSessionMgr_defaultsGetVolume();
}
public static boolean defaultsSetInviteSessionTimers(int timeout, String refresher) {
return tinyWRAPJNI.MediaSessionMgr_defaultsSetInviteSessionTimers(timeout, refresher);
}
}

View File

@ -175,4 +175,8 @@ public class MediaSessionMgr {
return tinyWRAPJNI.MediaSessionMgr_defaultsGetVolume();
}
public static boolean defaultsSetInviteSessionTimers(int timeout, String refresher) {
return tinyWRAPJNI.MediaSessionMgr_defaultsSetInviteSessionTimers(timeout, refresher);
}
}

View File

@ -70,6 +70,7 @@ class tinyWRAPJNI {
public final static native boolean MediaSessionMgr_defaultsSetMediaType(int jarg1);
public final static native boolean MediaSessionMgr_defaultsSetVolume(int jarg1);
public final static native int MediaSessionMgr_defaultsGetVolume();
public final static native boolean MediaSessionMgr_defaultsSetInviteSessionTimers(int jarg1, String jarg2);
public final static native void delete_MediaContent(long jarg1);
public final static native String MediaContent_getType(long jarg1, MediaContent jarg1_);
public final static native long MediaContent_getDataLength(long jarg1, MediaContent jarg1_);

View File

@ -2857,6 +2857,27 @@ SWIGEXPORT jint JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetInviteSessionTimers(JNIEnv *jenv, jclass jcls, jint jarg1, jstring jarg2) {
jboolean jresult = 0 ;
int32_t arg1 ;
char *arg2 = (char *) 0 ;
bool result;
(void)jenv;
(void)jcls;
arg1 = (int32_t)jarg1;
arg2 = 0;
if (jarg2) {
arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
if (!arg2) return 0;
}
result = (bool)MediaSessionMgr::defaultsSetInviteSessionTimers(arg1,(char const *)arg2);
jresult = (jboolean)result;
if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
return jresult;
}
SWIGEXPORT void JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_delete_1MediaContent(JNIEnv *jenv, jclass jcls, jlong jarg1) {
MediaContent *arg1 = (MediaContent *) 0 ;

View File

@ -70,6 +70,7 @@ class tinyWRAPJNI {
public final static native boolean MediaSessionMgr_defaultsSetMediaType(int jarg1);
public final static native boolean MediaSessionMgr_defaultsSetVolume(int jarg1);
public final static native int MediaSessionMgr_defaultsGetVolume();
public final static native boolean MediaSessionMgr_defaultsSetInviteSessionTimers(int jarg1, String jarg2);
public final static native void delete_MediaContent(long jarg1);
public final static native String MediaContent_getType(long jarg1, MediaContent jarg1_);
public final static native long MediaContent_getDataLength(long jarg1, MediaContent jarg1_);

View File

@ -2857,6 +2857,27 @@ SWIGEXPORT jint JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetInviteSessionTimers(JNIEnv *jenv, jclass jcls, jint jarg1, jstring jarg2) {
jboolean jresult = 0 ;
int32_t arg1 ;
char *arg2 = (char *) 0 ;
bool result;
(void)jenv;
(void)jcls;
arg1 = (int32_t)jarg1;
arg2 = 0;
if (jarg2) {
arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
if (!arg2) return 0;
}
result = (bool)MediaSessionMgr::defaultsSetInviteSessionTimers(arg1,(char const *)arg2);
jresult = (jboolean)result;
if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
return jresult;
}
SWIGEXPORT void JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_delete_1MediaContent(JNIEnv *jenv, jclass jcls, jlong jarg1) {
MediaContent *arg1 = (MediaContent *) 0 ;

View File

@ -227,6 +227,7 @@ sub DESTROY {
*defaultsSetMediaType = *tinyWRAPc::MediaSessionMgr_defaultsSetMediaType;
*defaultsSetVolume = *tinyWRAPc::MediaSessionMgr_defaultsSetVolume;
*defaultsGetVolume = *tinyWRAPc::MediaSessionMgr_defaultsGetVolume;
*defaultsSetInviteSessionTimers = *tinyWRAPc::MediaSessionMgr_defaultsSetInviteSessionTimers;
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);

View File

@ -4137,6 +4137,45 @@ XS(_wrap_MediaSessionMgr_defaultsGetVolume) {
}
XS(_wrap_MediaSessionMgr_defaultsSetInviteSessionTimers) {
{
int32_t arg1 ;
char *arg2 = (char *) 0 ;
int val1 ;
int ecode1 = 0 ;
int res2 ;
char *buf2 = 0 ;
int alloc2 = 0 ;
int argvi = 0;
bool result;
dXSARGS;
if ((items < 2) || (items > 2)) {
SWIG_croak("Usage: MediaSessionMgr_defaultsSetInviteSessionTimers(timeout,refresher);");
}
ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1);
if (!SWIG_IsOK(ecode1)) {
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MediaSessionMgr_defaultsSetInviteSessionTimers" "', argument " "1"" of type '" "int32_t""'");
}
arg1 = static_cast< int32_t >(val1);
res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MediaSessionMgr_defaultsSetInviteSessionTimers" "', argument " "2"" of type '" "char const *""'");
}
arg2 = reinterpret_cast< char * >(buf2);
result = (bool)MediaSessionMgr::defaultsSetInviteSessionTimers(arg1,(char const *)arg2);
ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ;
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
XSRETURN(argvi);
fail:
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
SWIG_croak_null();
}
}
XS(_wrap_delete_MediaContent) {
{
MediaContent *arg1 = (MediaContent *) 0 ;
@ -23257,6 +23296,7 @@ static swig_command_info swig_commands[] = {
{"tinyWRAPc::MediaSessionMgr_defaultsSetMediaType", _wrap_MediaSessionMgr_defaultsSetMediaType},
{"tinyWRAPc::MediaSessionMgr_defaultsSetVolume", _wrap_MediaSessionMgr_defaultsSetVolume},
{"tinyWRAPc::MediaSessionMgr_defaultsGetVolume", _wrap_MediaSessionMgr_defaultsGetVolume},
{"tinyWRAPc::MediaSessionMgr_defaultsSetInviteSessionTimers", _wrap_MediaSessionMgr_defaultsSetInviteSessionTimers},
{"tinyWRAPc::delete_MediaContent", _wrap_delete_MediaContent},
{"tinyWRAPc::MediaContent_getType", _wrap_MediaContent_getType},
{"tinyWRAPc::MediaContent_getDataLength", _wrap_MediaContent_getDataLength},

View File

@ -209,6 +209,8 @@ class MediaSessionMgr(_object):
if _newclass:defaultsSetVolume = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetVolume)
__swig_getmethods__["defaultsGetVolume"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsGetVolume
if _newclass:defaultsGetVolume = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsGetVolume)
__swig_getmethods__["defaultsSetInviteSessionTimers"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsSetInviteSessionTimers
if _newclass:defaultsSetInviteSessionTimers = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetInviteSessionTimers)
MediaSessionMgr_swigregister = _tinyWRAP.MediaSessionMgr_swigregister
MediaSessionMgr_swigregister(MediaSessionMgr)
@ -320,6 +322,10 @@ def MediaSessionMgr_defaultsGetVolume():
return _tinyWRAP.MediaSessionMgr_defaultsGetVolume()
MediaSessionMgr_defaultsGetVolume = _tinyWRAP.MediaSessionMgr_defaultsGetVolume
def MediaSessionMgr_defaultsSetInviteSessionTimers(*args):
return _tinyWRAP.MediaSessionMgr_defaultsSetInviteSessionTimers(*args)
MediaSessionMgr_defaultsSetInviteSessionTimers = _tinyWRAP.MediaSessionMgr_defaultsSetInviteSessionTimers
class MediaContent(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, MediaContent, name, value)

View File

@ -6724,6 +6724,40 @@ fail:
}
SWIGINTERN PyObject *_wrap_MediaSessionMgr_defaultsSetInviteSessionTimers(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
int32_t arg1 ;
char *arg2 = (char *) 0 ;
int val1 ;
int ecode1 = 0 ;
int res2 ;
char *buf2 = 0 ;
int alloc2 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
bool result;
if (!PyArg_ParseTuple(args,(char *)"OO:MediaSessionMgr_defaultsSetInviteSessionTimers",&obj0,&obj1)) SWIG_fail;
ecode1 = SWIG_AsVal_int(obj0, &val1);
if (!SWIG_IsOK(ecode1)) {
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MediaSessionMgr_defaultsSetInviteSessionTimers" "', argument " "1"" of type '" "int32_t""'");
}
arg1 = static_cast< int32_t >(val1);
res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MediaSessionMgr_defaultsSetInviteSessionTimers" "', argument " "2"" of type '" "char const *""'");
}
arg2 = reinterpret_cast< char * >(buf2);
result = (bool)MediaSessionMgr::defaultsSetInviteSessionTimers(arg1,(char const *)arg2);
resultobj = SWIG_From_bool(static_cast< bool >(result));
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
return resultobj;
fail:
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
return NULL;
}
SWIGINTERN PyObject *MediaSessionMgr_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
@ -22290,6 +22324,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"MediaSessionMgr_defaultsSetMediaType", _wrap_MediaSessionMgr_defaultsSetMediaType, METH_VARARGS, NULL},
{ (char *)"MediaSessionMgr_defaultsSetVolume", _wrap_MediaSessionMgr_defaultsSetVolume, METH_VARARGS, NULL},
{ (char *)"MediaSessionMgr_defaultsGetVolume", _wrap_MediaSessionMgr_defaultsGetVolume, METH_VARARGS, NULL},
{ (char *)"MediaSessionMgr_defaultsSetInviteSessionTimers", _wrap_MediaSessionMgr_defaultsSetInviteSessionTimers, METH_VARARGS, NULL},
{ (char *)"MediaSessionMgr_swigregister", MediaSessionMgr_swigregister, METH_VARARGS, NULL},
{ (char *)"delete_MediaContent", _wrap_delete_MediaContent, METH_VARARGS, NULL},
{ (char *)"MediaContent_getType", _wrap_MediaContent_getType, METH_VARARGS, NULL},

View File

@ -72,6 +72,10 @@ TINYMEDIA_API tmedia_type_t tmedia_defaults_get_media_type();
TINYMEDIA_API int tmedia_defaults_set_media_type(tmedia_type_t media_type);
TINYMEDIA_API int tmedia_defaults_set_volume(int32_t volume);
TINYMEDIA_API int32_t tmedia_defaults_get_volume();
TINYMEDIA_API int32_t tmedia_defaults_get_inv_session_expires();
TINYMEDIA_API int tmedia_defaults_set_inv_session_expires(int32_t timeout);
TINYMEDIA_API const char* tmedia_defaults_get_inv_session_refresher();
TINYMEDIA_API int tmedia_defaults_set_inv_session_refresher(const char* refresher);

View File

@ -64,6 +64,8 @@ static uint16_t __rtp_port_range_start = 1024;
static uint16_t __rtp_port_range_stop = 65535;
static tmedia_type_t __media_type = tmedia_audio;
static int32_t __volume = 100;
static int32_t __inv_session_expires = 0; // Session Timers: 0: disabled
static char* __inv_session_refresher = tsk_null;
int tmedia_defaults_set_jb_margin(int32_t jb_margin_ms)
{
@ -242,7 +244,30 @@ int tmedia_defaults_set_volume(int32_t volume){
__volume = TSK_CLAMP(0, volume, 100);
return 0;
}
int32_t tmedia_defaults_get_volume(){
return __volume;
}
int32_t tmedia_defaults_get_inv_session_expires(){
return __inv_session_expires;
}
int tmedia_defaults_set_inv_session_expires(int32_t timeout){
if(timeout >= 0){
__inv_session_expires = timeout;
return 0;
}
TSK_DEBUG_ERROR("Invalid parameter");
return -1;
}
const char* tmedia_defaults_get_inv_session_refresher(){
return __inv_session_refresher;
}
int tmedia_defaults_set_inv_session_refresher(const char* refresher){
if(refresher){
tsk_strupdate(&__inv_session_refresher, refresher);
return 0;
}
TSK_DEBUG_ERROR("Invalid parameter");
return -1;
}

View File

@ -1351,7 +1351,14 @@ int send_RESPONSE(tsip_dialog_invite_t *self, const tsip_request_t* request, sho
if((response = tsip_dialog_response_new(TSIP_DIALOG(self), code, phrase, request))){
if(TSIP_REQUEST_IS_INVITE(request) || TSIP_REQUEST_IS_UPDATE(request)){
/* Session timers (for 2xx to INVITE or UPDATE) */
if(self->stimers.timer.timeout){
if(self->require.timer){
tsip_message_add_headers(response,
TSIP_HEADER_REQUIRE_VA_ARGS("timer"),
TSIP_HEADER_SESSION_EXPIRES_VA_ARGS(self->stimers.timer.timeout, tsk_striequals(self->stimers.refresher, "uas")),
tsk_null
);
}
else if(self->supported.timer){
tsip_message_add_headers(response,
TSIP_HEADER_SUPPORTED_VA_ARGS("timer"),
TSIP_HEADER_SESSION_EXPIRES_VA_ARGS(self->stimers.timer.timeout, tsk_striequals(self->stimers.refresher, "uas")),

View File

@ -300,6 +300,7 @@ 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 *);
const tsip_header_Session_Expires_t* hdr_SessionExpires;
/* we are not the client */
self->is_client = tsk_false;
@ -308,11 +309,21 @@ int s0000_Started_2_Ringing_X_iINVITE(va_list *app)
TSK_OBJECT_SAFE_FREE(self->last_iInvite);
self->last_iInvite = tsk_object_ref(request);
// add "require" tag if the incoming INVITE contains "100rel" tag in "supported" header
// add "require:100rel" tag if the incoming INVITE contains "100rel" tag in "supported" header
if(self->last_iInvite && (tsip_message_supported(self->last_iInvite, "100rel") || tsip_message_required(self->last_iInvite, "100rel")) && self->supported._100rel){
self->require._100rel = tsk_true;
}
// add "require:timer" tag if incoming INVITE contains "timer" tag in "supported" header and session timers is enabled
if(TSIP_DIALOG_GET_SS(self)->media.timers.timeout){
if((hdr_SessionExpires = (const tsip_header_Session_Expires_t*)tsip_message_get_header(request, tsip_htype_Session_Expires))){
// "hdr_SessionExpires->delta_seconds" smallnest already checked
self->stimers.timer.timeout = hdr_SessionExpires->delta_seconds;
tsk_strupdate(&self->stimers.refresher, hdr_SessionExpires->refresher_uas ? "uas" : "uac");
self->require.timer = tsk_true;
}
}
/* update state */
tsip_dialog_update_2(TSIP_DIALOG(self), request);

View File

@ -563,6 +563,8 @@ static tsk_object_t* tsip_ssession_ctor(tsk_object_t * self, va_list * app)
ss->media.type = tmedia_none;
ss->media.qos.type = tmedia_qos_stype_none;
ss->media.qos.strength = tmedia_qos_strength_none;
ss->media.timers.refresher = tsk_strdup(tmedia_defaults_get_inv_session_refresher());
ss->media.timers.timeout = tmedia_defaults_get_inv_session_expires();
/* add the session to the stack */
if(ss->stack){