From 9cca1e24c9d348050b07a7ea5706dbad869022f3 Mon Sep 17 00:00:00 2001 From: Liong Sauw Ming Date: Mon, 11 Oct 2010 10:59:37 +0000 Subject: Fix #1145: API to enable/disable support for iOS BG feature during runtime git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3336 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/include/pj/activesock.h | 12 ++++++++++++ pjlib/src/pj/activesock.c | 9 ++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'pjlib') diff --git a/pjlib/include/pj/activesock.h b/pjlib/include/pj/activesock.h index 1ebb5a2e..4d30ac97 100644 --- a/pjlib/include/pj/activesock.h +++ b/pjlib/include/pj/activesock.h @@ -316,6 +316,18 @@ PJ_DECL(pj_status_t) pj_activesock_close(pj_activesock_t *asock); */ PJ_DECL(void) pj_activesock_set_iphone_os_bg(pj_activesock_t *asock, int val); + +/** + * Enable/disable support for iPhone OS background mode. This setting + * will apply globally and will affect any active sockets created + * afterwards, if you want to change the setting for a particular + * active socket, use #pj_activesock_set_iphone_os_bg() instead. + * By default, this setting is enabled. + * + * @param val The value of global background mode setting. + * + */ +PJ_DECL(void) pj_activesock_enable_iphone_os_bg(pj_bool_t val); #endif /** diff --git a/pjlib/src/pj/activesock.c b/pjlib/src/pj/activesock.c index 9de23156..b0332ce6 100644 --- a/pjlib/src/pj/activesock.c +++ b/pjlib/src/pj/activesock.c @@ -29,6 +29,8 @@ #if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0 # include + + static pj_bool_t ios_bg_support = PJ_TRUE; #endif #define PJ_ACTIVESOCK_MAX_LOOP 50 @@ -133,7 +135,7 @@ static void activesock_destroy_iphone_os_stream(pj_activesock_t *asock) static void activesock_create_iphone_os_stream(pj_activesock_t *asock) { - if (asock->bg_setting && asock->stream_oriented) { + if (ios_bg_support && asock->bg_setting && asock->stream_oriented) { activesock_destroy_iphone_os_stream(asock); CFStreamCreatePairWithSocket(kCFAllocatorDefault, asock->sock, @@ -164,6 +166,11 @@ PJ_DEF(void) pj_activesock_set_iphone_os_bg(pj_activesock_t *asock, else activesock_destroy_iphone_os_stream(asock); } + +PJ_DEF(void) pj_activesock_enable_iphone_os_bg(pj_bool_t val) +{ + ios_bg_support = val; +} #endif PJ_DEF(pj_status_t) pj_activesock_create( pj_pool_t *pool, -- cgit v1.2.3