Changeset 3299 for pjproject/trunk/pjlib/src/pj/activesock.c
- Timestamp:
- Aug 27, 2010 6:46:29 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/activesock.c
r2980 r3299 22 22 #include <pj/assert.h> 23 23 #include <pj/errno.h> 24 #include <pj/log.h> 24 25 #include <pj/pool.h> 25 26 #include <pj/sock.h> 26 27 #include <pj/string.h> 28 29 #if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ 30 PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0 31 # include <CFNetwork/CFNetwork.h> 32 #endif 27 33 28 34 #define PJ_ACTIVESOCK_MAX_LOOP 50 … … 72 78 unsigned max_loop; 73 79 pj_activesock_cb cb; 74 80 #if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ 81 PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0 82 int bg_setting; 83 pj_sock_t sock; 84 CFReadStreamRef readStream; 85 #endif 86 75 87 struct send_data send_data; 76 88 … … 106 118 } 107 119 120 #if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ 121 PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0 122 static void activesock_destroy_iphone_os_stream(pj_activesock_t *asock) 123 { 124 if (asock->readStream) { 125 CFReadStreamClose(asock->readStream); 126 CFRelease(asock->readStream); 127 asock->readStream = NULL; 128 } 129 } 130 131 static void activesock_create_iphone_os_stream(pj_activesock_t *asock) 132 { 133 if (asock->bg_setting && asock->stream_oriented) { 134 activesock_destroy_iphone_os_stream(asock); 135 136 CFStreamCreatePairWithSocket(kCFAllocatorDefault, asock->sock, 137 &asock->readStream, NULL); 138 139 if (!asock->readStream || 140 CFReadStreamSetProperty(asock->readStream, 141 kCFStreamNetworkServiceType, 142 kCFStreamNetworkServiceTypeVoIP) 143 != TRUE || 144 CFReadStreamOpen(asock->readStream) != TRUE) 145 { 146 PJ_LOG(2,("", "Failed to configure TCP transport for VoIP " 147 "usage. Background mode will not be supported.")); 148 149 activesock_destroy_iphone_os_stream(asock); 150 } 151 } 152 } 153 154 155 PJ_DEF(void) pj_activesock_set_iphone_os_bg(pj_activesock_t *asock, 156 int val) 157 { 158 asock->bg_setting = val; 159 if (asock->bg_setting) 160 activesock_create_iphone_os_stream(asock); 161 else 162 activesock_destroy_iphone_os_stream(asock); 163 } 164 #endif 108 165 109 166 PJ_DEF(pj_status_t) pj_activesock_create( pj_pool_t *pool, … … 157 214 } 158 215 216 #if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ 217 PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0 218 asock->sock = sock; 219 pj_activesock_set_iphone_os_bg(asock, 220 PJ_ACTIVESOCK_TCP_IPHONE_OS_BG); 221 #endif 222 159 223 *p_asock = asock; 160 224 return PJ_SUCCESS; … … 216 280 PJ_ASSERT_RETURN(asock, PJ_EINVAL); 217 281 if (asock->key) { 282 #if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ 283 PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0 284 activesock_destroy_iphone_os_stream(asock); 285 #endif 286 218 287 pj_ioqueue_unregister(asock->key); 219 288 asock->key = NULL; … … 734 803 return; 735 804 805 #if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ 806 PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0 807 activesock_create_iphone_os_stream(asock); 808 #endif 736 809 } else if (status==PJ_SUCCESS) { 737 810 /* Application doesn't handle the new socket, we need to … … 776 849 return; 777 850 } 851 852 #if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ 853 PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0 854 activesock_create_iphone_os_stream(asock); 855 #endif 856 778 857 } 779 858 }
Note: See TracChangeset
for help on using the changeset viewer.