- Timestamp:
- Sep 5, 2013 4:16:19 AM (11 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-audiodev/coreaudio_dev.c
r4527 r4590 51 51 #define USE_AUDIO_ROUTE_CHANGE_PROP_LISTENER 0 52 52 53 /* Starting iOS SDK 7, Audio Session API is deprecated. */ 54 #ifdef __IPHONE_7_0 55 #define USE_AUDIO_SESSION_API 0 56 #else 57 #define USE_AUDIO_SESSION_API 1 58 #endif 53 59 #endif 54 60 … … 177 183 struct coreaudio_stream *strm, 178 184 AudioUnit *io_unit); 179 #if !COREAUDIO_MAC 185 #if !COREAUDIO_MAC && USE_AUDIO_SESSION_API != 0 180 186 static void interruptionListener(void *inClientData, UInt32 inInterruption); 181 187 static void propListener(void * inClientData, … … 237 243 #if !COREAUDIO_MAC 238 244 unsigned i; 239 OSStatus ostatus;240 245 #endif 241 246 … … 284 289 285 290 /* Set the device capabilities here */ 291 #if USE_AUDIO_SESSION_API != 0 286 292 cdi->info.caps = PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY | 287 293 PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY | … … 293 299 PJMEDIA_AUD_DEV_ROUTE_EARPIECE | 294 300 PJMEDIA_AUD_DEV_ROUTE_BLUETOOTH; 301 #else 302 cdi->info.caps = PJMEDIA_AUD_DEV_CAP_EC; 303 #endif 295 304 296 305 PJ_LOG(4, (THIS_FILE, " dev_id %d: %s (in=%d, out=%d) %dHz", … … 302 311 } 303 312 304 /* Initialize the Audio Session */ 305 ostatus = AudioSessionInitialize(NULL, NULL, interruptionListener, NULL); 306 if (ostatus != kAudioSessionNoError) { 307 PJ_LOG(4, (THIS_FILE, 308 "Warning: cannot initialize audio session services (%i)", 309 ostatus)); 310 } 311 312 /* Listen for audio routing change notifications. */ 313 #if USE_AUDIO_SESSION_API != 0 314 { 315 OSStatus ostatus; 316 317 /* Initialize the Audio Session */ 318 ostatus = AudioSessionInitialize(NULL, NULL, interruptionListener, 319 NULL); 320 if (ostatus != kAudioSessionNoError) { 321 PJ_LOG(4, (THIS_FILE, 322 "Warning: cannot initialize audio session services (%i)", 323 ostatus)); 324 } 325 326 /* Listen for audio routing change notifications. */ 313 327 #if USE_AUDIO_ROUTE_CHANGE_PROP_LISTENER != 0 314 ostatus = AudioSessionAddPropertyListener( 315 kAudioSessionProperty_AudioRouteChange, 316 propListener, cf); 317 if (ostatus != kAudioSessionNoError) { 318 PJ_LOG(4, (THIS_FILE, 319 "Warning: cannot listen for audio route change " 320 "notifications (%i)", ostatus)); 328 ostatus = AudioSessionAddPropertyListener( 329 kAudioSessionProperty_AudioRouteChange, 330 propListener, cf); 331 if (ostatus != kAudioSessionNoError) { 332 PJ_LOG(4, (THIS_FILE, 333 "Warning: cannot listen for audio route change " 334 "notifications (%i)", ostatus)); 335 } 336 #endif 321 337 } 322 338 #endif … … 341 357 342 358 #if !COREAUDIO_MAC 343 #if USE_AUDIO_ ROUTE_CHANGE_PROP_LISTENER != 0359 #if USE_AUDIO_SESSION_API != 0 && USE_AUDIO_ROUTE_CHANGE_PROP_LISTENER != 0 344 360 AudioSessionRemovePropertyListenerWithUserData( 345 361 kAudioSessionProperty_AudioRouteChange, propListener, cf); … … 1059 1075 } 1060 1076 1061 #if !COREAUDIO_MAC 1077 #if !COREAUDIO_MAC && USE_AUDIO_SESSION_API != 0 1062 1078 static void propListener(void *inClientData, 1063 1079 AudioSessionPropertyID inID, … … 1224 1240 { 1225 1241 OSStatus ostatus; 1226 #if !COREAUDIO_MAC 1242 #if !COREAUDIO_MAC && USE_AUDIO_SESSION_API != 0 1227 1243 UInt32 audioCategory = kAudioSessionCategory_PlayAndRecord; 1228 1244 /* We want to be able to open playback and recording streams */ … … 1700 1716 } 1701 1717 } 1702 #el se1718 #elif USE_AUDIO_SESSION_API != 0 1703 1719 Float32 latency, latency2; 1704 1720 UInt32 size = sizeof(Float32); … … 1748 1764 } 1749 1765 } 1750 #el se1766 #elif USE_AUDIO_SESSION_API != 0 1751 1767 Float32 latency, latency2; 1752 1768 UInt32 size = sizeof(Float32); … … 1766 1782 *(unsigned*)pval = (++strm->param.output_latency_ms * 2); 1767 1783 return PJ_SUCCESS; 1784 #if COREAUDIO_MAC || USE_AUDIO_SESSION_API != 0 1768 1785 } else if (cap==PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING && 1769 1786 (strm->param.dir & PJMEDIA_DIR_PLAYBACK)) … … 1784 1801 if (ostatus != noErr) 1785 1802 return PJMEDIA_AUDIODEV_ERRNO_FROM_COREAUDIO(ostatus); 1786 #el se1803 #elif USE_AUDIO_SESSION_API != 0 1787 1804 ostatus = AudioSessionGetProperty( 1788 1805 kAudioSessionProperty_CurrentHardwareOutputVolume, … … 1795 1812 *(unsigned*)pval = (unsigned)(volume * 100); 1796 1813 return PJ_SUCCESS; 1814 #endif 1815 1797 1816 #if !COREAUDIO_MAC 1817 #if USE_AUDIO_SESSION_API != 0 1798 1818 } else if (cap==PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE && 1799 1819 (strm->param.dir & PJMEDIA_DIR_CAPTURE)) … … 1837 1857 1838 1858 return PJ_SUCCESS; 1859 #endif 1839 1860 } else if (cap==PJMEDIA_AUD_DEV_CAP_EC) { 1840 1861 AudioComponentDescription desc; … … 1888 1909 1889 1910 #else 1890 1891 if ((cap==PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY && 1911 if (cap==PJMEDIA_AUD_DEV_CAP_EC) { 1912 AudioComponentDescription desc; 1913 AudioComponent io_comp; 1914 1915 desc.componentType = kAudioUnitType_Output; 1916 desc.componentSubType = (*(pj_bool_t*)pval)? 1917 kAudioUnitSubType_VoiceProcessingIO : 1918 kAudioUnitSubType_RemoteIO; 1919 desc.componentManufacturer = kAudioUnitManufacturer_Apple; 1920 desc.componentFlags = 0; 1921 desc.componentFlagsMask = 0; 1922 1923 io_comp = AudioComponentFindNext(NULL, &desc); 1924 if (io_comp == NULL) 1925 return PJMEDIA_AUDIODEV_ERRNO_FROM_COREAUDIO(-1); 1926 strm->cf->io_comp = io_comp; 1927 strm->param.ec_enabled = *(pj_bool_t*)pval; 1928 1929 PJ_LOG(4, (THIS_FILE, "Using %s audio unit", 1930 (desc.componentSubType == 1931 kAudioUnitSubType_RemoteIO? "RemoteIO": 1932 "VoiceProcessingIO"))); 1933 1934 return PJ_SUCCESS; 1935 } 1936 1937 #if USE_AUDIO_SESSION_API != 0 1938 1939 else if ((cap==PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY && 1892 1940 (strm->param.dir & PJMEDIA_DIR_CAPTURE)) || 1893 1941 (cap==PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY && … … 1949 1997 strm->param.output_route = *(pjmedia_aud_dev_route*)pval; 1950 1998 return PJ_SUCCESS; 1951 } else if (cap==PJMEDIA_AUD_DEV_CAP_EC) { 1952 AudioComponentDescription desc; 1953 AudioComponent io_comp; 1954 1955 desc.componentType = kAudioUnitType_Output; 1956 desc.componentSubType = (*(pj_bool_t*)pval)? 1957 kAudioUnitSubType_VoiceProcessingIO : 1958 kAudioUnitSubType_RemoteIO; 1959 desc.componentManufacturer = kAudioUnitManufacturer_Apple; 1960 desc.componentFlags = 0; 1961 desc.componentFlagsMask = 0; 1962 1963 io_comp = AudioComponentFindNext(NULL, &desc); 1964 if (io_comp == NULL) 1965 return PJMEDIA_AUDIODEV_ERRNO_FROM_COREAUDIO(-1); 1966 strm->cf->io_comp = io_comp; 1967 strm->param.ec_enabled = *(pj_bool_t*)pval; 1968 1969 PJ_LOG(4, (THIS_FILE, "Using %s audio unit", 1970 (desc.componentSubType == 1971 kAudioUnitSubType_RemoteIO? "RemoteIO": 1972 "VoiceProcessingIO"))); 1973 1974 return PJ_SUCCESS; 1975 } 1999 } 2000 #endif 1976 2001 #endif 1977 2002 … … 2001 2026 } 2002 2027 2003 #if !COREAUDIO_MAC 2028 #if !COREAUDIO_MAC && USE_AUDIO_SESSION_API != 0 2004 2029 AudioSessionSetActive(true); 2005 2030 #endif … … 2059 2084 pj_mutex_unlock(stream->cf->mutex); 2060 2085 2061 #if !COREAUDIO_MAC 2086 #if !COREAUDIO_MAC && USE_AUDIO_SESSION_API != 0 2062 2087 if (should_deactivate) 2063 2088 AudioSessionSetActive(false); -
pjproject/trunk/pjsip-apps/src/pjsua/ios/ipjsua.xcodeproj/project.pbxproj
r4510 r4590 421 421 ONLY_ACTIVE_ARCH = YES; 422 422 PRODUCT_NAME = "$(TARGET_NAME)"; 423 VALID_ARCHS = armv7; 423 424 WRAPPER_EXTENSION = app; 424 425 }; … … 455 456 ONLY_ACTIVE_ARCH = YES; 456 457 PRODUCT_NAME = "$(TARGET_NAME)"; 458 VALID_ARCHS = armv7; 457 459 WRAPPER_EXTENSION = app; 458 460 }; -
pjproject/trunk/pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaAppDelegate.m
r4497 r4590 152 152 153 153 - (void)keepAlive { 154 int i , timeout = KEEP_ALIVE_INTERVAL;154 int i; 155 155 156 156 if (!pj_thread_is_registered()) … … 159 159 } 160 160 161 /* Since iOS requires that the minimum keep alive interval is 600s, 162 * application needs to make sure that the account's registration 163 * timeout is long enough. 164 */ 161 165 for (i = 0; i < (int)pjsua_acc_get_count(); ++i) { 162 166 if (pjsua_acc_is_valid(i)) { 163 pjsua_acc_config acc_cfg; 164 165 pjsua_acc_get_config(i, &acc_cfg); 166 if (!acc_cfg.reg_uri.slen) 167 continue; 168 if (acc_cfg.reg_timeout < timeout) { 169 acc_cfg.reg_timeout = timeout; 170 pjsua_acc_modify(i, &acc_cfg); 171 } else { 172 pjsua_acc_set_registration(i, PJ_TRUE); 173 } 167 pjsua_acc_set_registration(i, PJ_TRUE); 174 168 } 175 169 }
Note: See TracChangeset
for help on using the changeset viewer.